DevUI for Angular

repository·master·Indexed 23 days ago

https://github.com/devcloudfe/ng-devui

An enterprise-grade design system providing a collection of UI components, design languages, and best practices for Angular ^19.0.0. It includes complex components such as a data-table with template and column configuration modes, and a modular toggle-menu system for building dropdowns like Select and Auto-complete.

Tokens
161.8K
Snippets
322
Records
810
Agent score
82%

What's inside ng-devui

  1. Data Table directory structure and available features

    master

    The data-table package is organized into core components, models, and various demo implementations.

    Core Components

    • data-table.component.ts: The main entry point for the data table.
    • data-table.module.ts: The Angular module for importing the data table.
    • data-table.model.ts: Type definitions for the data table.
    • display-cell-value.pipe.ts: A pipe used for cell value display in column configuration mode.
    • editor-host.directive.ts: A directive used to host editor components during cell editing.

    Available Demo Features

    Developers can implement the following patterns using the provided demo code:

    • Data Loading: Async loading, Lazy loading, Virtual scroll.
    • Layout & Structure: Cell merging, Header grouping (header-grouping, multi-header), Fixed columns (fix-column), Expandable rows (expand-row), Tree tables (tree-table).
    • Interactions: Row dragging (drag-row, muti-drag-row), Column dragging (drag-column), Sorting and Filtering, Table interactions.
    • Editing: Cell editing (editable).
    • Styling: Custom styles (mutil-styles), Max height (fixed header).
  2. Collaborative Dragging with dDragSync and dDropSortSync

    master

    For complex scenarios like two-dimensional dragging or cross-dimension dragging where multiple objects must be synchronized, use the collaborative dragging directives.

    dDragSync

    Applied to dDraggable objects to synchronize them within a specific group.

    • dDragSync (string): The mandatory name of the synchronization group.

    dDropSortSync

    Applied to the same element as dDroppable to manage sorting within a synchronized area.

    • dDropSortSync (string): The mandatory name of the synchronization group.
    • dDropSyncDirection ('v' | 'h' | default: 'v'): The direction of sorting (vertical or horizontal) relative to the dSortable direction.

    dDragDropSyncBox

    A utility directive used to collect statistics on the common parent ancestors of dDragSync and dDropSortSync elements.

  3. Customize uploadedFilesRef template

    master

    Use the uploadedFilesRef template to customize how the list of successfully uploaded files is displayed.

    Available Template Variables:

    • let-uploadedFiles: The list of successfully uploaded files.
    • let-filePath: The path of the specific file.
    • let-deleteFile: A function to trigger the deletion of the file.
    <ng-template
      let-uploadedFiles="uploadedFiles"
      let-filePath="filePath"
      let-deleteFile="deleteFile">
    </ng-template
  4. Understand avatar display priority and rules

    master

    The d-avatar component determines what to display based on a specific priority and character processing logic.

    Display Priority

    The component selects the content to show in the following order of precedence:

    1. imgSrc (Custom image)
    2. customText (Custom text)
    3. name (Generated from name string)

    Name Generation Rules

    When using the name property, the component generates initials based on these rules:

    • Starts with Chinese characters: Takes the last two characters of the string.
    • Starts with English characters: Takes the first two characters of the string.
    • Multiple English names: Takes the first letter of the first two English names.
    • Other (non-Chinese/English): Takes the first two characters of the string.

    Special Display Cases

    • User does not exist: If name, customText, and imgSrc are all missing, the avatar is treated as if the user does not exist.
    • No nickname: If name, customText, or imgSrc are provided but are empty strings, the component uses the default avatar.
  5. Understand AccordionMenuType and data structures

    master

    The accordion uses a hierarchical data structure defined by AccordionMenuType. Data items can be simple base items, foldable menus, or linkable items.

    Data Interfaces

    • AccordionBase: Minimum requirement (title: string, optional disabled: boolean).
    • AccordionBaseMenu<T>: Extends base with open?: boolean, loading?: boolean, and children?: Array<T>.
    • AccordionLinkableItem: Extends base with link?: string, target?: boolean, and linkType?: 'routerLink' | 'hrefLink' | string.
    • AccordionMenuItem: A complete item that can be a base item, a foldable menu, and linkable.

    Example Structure

    // A single item in an AccordionMenuType array
    const menuData: AccordionMenuType = [
      {
        title: 'Parent Menu',
        open: true,
        children: [
          {
            title: 'Child Link',
            link: '/home',
            linkType: 'routerLink'
          }
        ]
      }
    ];
    /* 基础数据类型 */
    type AccordionMenuItemLinkType = 'routerLink' | 'hrefLink' | string;
    export interface AccordionBase {
      title: string;
      disabled?: boolean;
      [prop: string]: any;
    }
    interface IAccordionActiveable {
      active?: boolean;
    }
    interface IAccordionFoldable<T> {
      open?: boolean;
      loading?: boolean;
      children?: Array<T>;
    }
    
    interface IAccordionLinkable {
      link?: string;
      target?: boolean;
      linkType?: AccordionMenuItemLinkType;
    }
    export interface AccordionBaseItem extends AccordionBase, IAccordionActiveable {}
    export interface AccordionBaseMenu<T> extends AccordionBase, IAccordionFoldable<T> {}
    
    export interface AccordionLinkableItem extends AccordionBase, IAccordionActiveable, IAccordionLinkable {}
    export interface AccordionMenuItem extends AccordionBase, IAccordionActiveable, IAccordionFoldable<AccordionMenuItem>, IAccordionLinkable {}
    
    export type AccordionMenuType = Array<AccordionMenuItem>;
  6. Understand ModalOpenResult and modalInstance methods

    master

    When calling modalService.open(), it returns a ModalOpenResult object which provides access to the modal instance.

    ModalOpenResult Properties

    • modalInstance: Returns the ModalComponent instance. This can be used as the context for contentTemplate.
    • modalContentInstance: Returns the object instance of the modal content.

    modalInstance Public Methods

    • hide(): Closes the modal.
    • updateButtonOptions(buttons: Array<...>): Dynamically updates the button configurations (e.g., to disable a button) within the dialog.
  7. Configure error update strategies with DValidationErrorStrategy

    master

    The errorStrategy determines when error messages are displayed:

    • pristine: Errors are shown immediately if validation rules are not met.
    • dirty: Errors are only shown when the form control's state is dirty (i.e., the user has interacted with it).
  8. Implement multi-row headers and cell merging

    master

    To create complex headers with merged cells (rowspan/colspan), use the advancedHeader property on the d-column component.

    advancedHeader expects an array of objects defining the header structure:

    advancedHeader: Array<{ 
      header: string; 
      rowspan: number; 
      colspan: number; 
    }>

    Important Notes:

    • Empty cells must be explicitly represented with rowspan or colspan set to 0.
    • If using column resizing alongside advancedHeader, ensure you provide a width for column content. If the first row's width is incorrect, manually add a $width property to the corresponding advancedHeader[rowNumber] object.
    advancedHeader: Array < { 
        header: string; 
        rowspan: number; 
        colspan: number; 
    } >
  9. Structure a d-card using block divisions

    master

    The d-card component is composed of several specialized block division tags to organize content:

    • d-card-header: The title area used for overviews. Typically contains d-card-title, d-card-subtitle, and dAvatar.
    • dCardMeta: A media information area for pictures, graphics, or videos.
    • d-card-content: The auxiliary information area for abstracts or descriptions.
    • d-card-actions: The decision-making area for operation text or icons.