PO UI for Angular

repository·master·Indexed 21 days ago

https://github.com/po-ui/po-angular

A UI component library for Angular designed for enterprise-grade applications. It includes a wide range of components, templates, and schematics, as well as specialized libraries such as @po-ui/ng-code-editor for source code editing, @po-ui/ng-storage for local device data storage (supporting Websql, Indexeddb, LocalStorage, and LokiJS), and @po-ui/ng-sync for maintaining synchronization between local data and the server.

Tokens
81.7K
Snippets
346
Records
535
Agent score
76%

What's inside po-angular

  1. What are PO UI Schematics?

    master
    PO UI Schematics is a library designed for building Angular schematics. Its primary purpose is to share common source files and logic across different Angular CLI-like operations, specifically for ng-add (installation/setup), ng-generate (scaffolding), and ng-update (migration/upgrading) within the PO UI ecosystem.
  2. Understand PO UI deprecation and removal policy

    master

    PO UI follows a deprecation policy to minimize breaking changes and provide migration paths.

    • Deprecation Announcement: When a feature is deprecated, it is marked as Deprecated in the documentation and is no longer used in portal samples. Deprecations are announced in the CHANGELOG.
    • Removal Timeline: Deprecated features typically remain available for approximately two major versions before being removed. Removal only occurs during a major version release.
    • Support: Until a feature is removed, PO UI maintains support for critical issues and security vulnerabilities and provides migration tools to automate most updates.
  3. How PO Sync works

    master

    PO Sync is a library that enables local data storage in an application while maintaining synchronization between local and server data. This allows users to use the application both online and offline with a consistent experience.

    Core Mechanism: Event Sourcing

    All modifications (create, update, delete) occur first in local storage. For every modification, an event is created consisting of the operation type and the modified record. These events are added to an event queue consumed by the synchronization process.

    The Synchronization Process

    Synchronization happens in the background while the application is online and occurs in two stages:

    1. Local to Server: The process retrieves items from the event queue and sends modified data to the server sequentially.
    2. Server to Local: The process fetches data modified on the server and updates the local application.

    Synchronization Triggers

    • Reactive: Triggered by device hardware changes (e.g., switching from 4G to Wi-Fi).
    • Periodic: Triggered based on configuration parameters in PoSyncConfig.
    • Manual: Triggered by calling PoSyncService.sync().
  4. Implement Logical Deletion for PO Sync

    master

    To support synchronization, the API must implement logical deletion instead of physical deletion. This ensures that other applications or clients can be notified that a record was removed.

    Each record must contain a field (e.g., isDeleted) indicating its status. This field name must be provided in the deletedField property of the PoSyncSchema definition.

    Example Record Structure

    {
      "id": 1,
      "title": "PO conference 2018",
      "isDeleted": false
    }
    {
      "id": 1,
      "title": "PO conference 2018",
      "date": "2018-08-11T00:00:00Z",
      "location": "Av. Santos Dumont, 831 - Santo Antônio, Joinville - SC",
      "description": "Conference organized by PO",
      "isDeleted": false
    }
  5. When to use a Column Chart

    master

    A Column Chart organizes data temporally or by topic along the horizontal (x) axis, with values varying along the vertical (y) axis.

    Use cases:

    • Demonstrating data variations over a period of time.
    • Illustrating comparisons between directly related topics.

    Best Practices:

    • Prefer a Bar Chart if there are many items, as Column Charts have less space for horizontal axis labels.
  6. Handle function binding deprecation in PO UI v2

    master

    In PO UI v2, passing functions to component properties without explicit binding is deprecated. You must now use .bind(this) to ensure the function executes within the correct component context. This applies to functions passed within arrays or via property binding.

    Affected Components: PageChangePassword, ButtonGroup, Menu, MenuPanel, Navbar, PageList, PageDefault, Popup, Stepper, Table, and Toolbar.

    Examples:

    1. Functions inside arrays (e.g., PoPageAction):

    // Before
    actions: Array<PoPageAction> = [
      { label: 'Adicionar', action: this.add }
    ]
    
    // After
    actions: Array<PoPageAction> = [
      { label: 'Adicionar', action: this.add.bind(this) }
    ]

    2. Functions via property binding:

    <!-- Before -->
    <po-step p-label="Personal" [p-can-active-next-step="canActiveNextStep"></po-step>
    
    <!-- After -->
    <po-step p-label="Personal" [p-can-active-next-step="canActiveNextStep.bind(this)"></po-step>
    // Correct way to pass functions in v2
    actions: Array<PoPageAction> = [
      { label: 'Adicionar', action: this.add.bind(this) }
    ]
  7. How to use @docExtends for class inheritance

    master

    When a class inherits from another, you can include the parent's description and properties in the child's documentation using the @docExtends tag.

    To prevent the parent class's description from appearing in the child's documentation, add the @ignoreExtendedDescription tag to the parent class or interface.

    /**
     * @docExtends PoButtonBaseComponent
     */
    export class PoButtonComponent extends PoButtonBaseComponent { }
  8. When to use a Pie Chart

    master

    A Pie Chart is suitable for showing parts of a whole, where slices sum up to 100%.

    Use cases:

    • Demonstrating proportions (e.g., budget percentage by department, survey responses, or time allocation).

    Best Practices:

    • Avoid using Pie Charts for comparing data.
    • Avoid using more than five slices, as it hinders understanding and visualization.
  9. Define a custom PoTheme object

    master

    A PoTheme object allows you to define multiple theme types (light/dark) and accessibility levels.

    Key configuration sections within a theme:

    • color: Defines brand, neutral, and feedback color palettes using a scale (e.g., brand.01.base).
    • onRoot: Sets global CSS variables for typography, border radius, and density (padding/gaps).
    • perComponent: Allows granular CSS variable overrides for specific components (e.g., po-button).
    • type: An array of configurations for different modes (light/dark) and accessibility levels (a11y).
    import { PoTheme, PoThemeTypeEnum, PoThemeA11yEnum } from '@po-ui/ng-components';
    
    export const corporateTheme: PoTheme = {
      name: 'corporate',
      type: [
        {
          light: {
            color: {
              brand: {
                '01': { 
                  base: '#2A5C8D',
                  light: '#4D7BA5',
                  dark: '#1D4364'
                }
              }
            },
            onRoot: {
              '--font-family': "'Inter', sans-serif",
              '--border-radius': '6px',
              '--po-density-header-padding': '2rem',
              '--po-density-content-padding': '1rem'
            },
            perComponent: {
              'po-button': {
                '--padding': '0.75rem 1.5rem',
                '--font-weight': '600'
              }
            }
          },
          dark: { /* Dark mode settings */ },
          a11y: PoThemeA11yEnum.AAA
        }
      ],
      active: { type: PoThemeTypeEnum.light, a11y: PoThemeA11yEnum.AAA }
    };
  10. When to use an Area Chart

    master

    The PO UI Area Chart is an overlapping area chart. It combines line and bar chart characteristics by adding shading between the lines and a baseline.

    Use cases:

    • Representing accumulated totals using numbers or percentages (e.g., stacked area charts) over time.
    • Showing trends over time between related attributes.