element-pro-components

repository·main·Indexed 43 days ago

https://github.com/tolking/element-pro-components

A component library for Vue 3 built on top of element-plus, providing enhanced UI components and layouts. Version 1.4.1 includes components such as AutocompleteTag for tag-input interfaces, Breadcrumb for automatic navigation trails, a grid-capable Card container, Checkbox and CheckboxButton for selection, and ColumnSetting for managing table column visibility and sorting.

Tokens
89.5K
Snippets
199
Records
276
Agent score
56%

What's inside element-pro-components

  1. Overview of the Form component

    main

    The Form component is a container used to collect, verify, and submit data. It is designed to work with any component that supports value binding via v-model.

    Supported components include:

    • el-input
    • el-switch
    • Standard input elements
    • radio, select, checkbox, and more.

    Unsupported components:

    • Components that do not support v-model binding (e.g., el-upload) require custom implementation or rewriting to be compatible with the Form component.
  2. Overview of element-pro-components

    main

    element-pro-components is a component library designed for Vue 3. It is built upon element-plus, vue, and vue-router.

    The library focuses on encapsulating non-business logic into reusable components, specifically targeting forms and tables. A key feature is the conversion of verbose el-table-column and el-form-item structures into dynamic column attributes. By passing in a reactive array of column configurations, tables and forms can update automatically, enabling easier implementation of features like dynamic permissions.

  3. Enable strict checking with check-strictly

    main

    By default, checking a parent node automatically selects all its children, and unchecking a child affects the parent. Set the check-strictly attribute to true to decouple this behavior. When enabled, the checked state of a node will not affect its father or child nodes.

    <TreeSelect
      v-model="checkedValues"
      :data="treeData"
      check-strictly
    />
  4. Implement Auth Routing

    main

    The library does not provide built-in authentication-based route filtering. To implement protected routes (Auth Routing), you must manually manage which routes are visible to the menu and accessible to the user.

    Recommended approaches:

    1. Dynamic Filtering: When generating or adding routes, filter out any route objects that the user does not have permission to access.
    2. Navigation Guards: Use router.beforeEach to intercept navigation and check permissions.
    3. Hybrid: Combine both methods for maximum security and UI consistency.
  5. Configure Crud component props and slots

    main

    The Crud component acts as a high-level wrapper that integrates several sub-components. It inherits and supports the following behaviors:

    • Table Props: Supports all props from the Table component.
    • Form Props: Supports all props from the Form component.
    • Descriptions Props: Supports all event props from the Descriptions component. Note: To configure the title in Descriptions, use the descriptions-title slot instead of a prop.
    • Dialog Props: Supports event props from ElDialog (excluding modelValue and destroy-on-close). It is not recommended to modify title and width via props; use slots or standard methods if necessary.
    • Search Props: To pass specific configuration values to the internal Search component, use the search-props attribute.

    When multiple sub-components share prop names, the Crud component intelligently passes the configuration to the appropriate underlying component.

  6. Create complex layouts with nested Cards

    main

    The Card component supports a grid-based layout system similar to el-row and el-col.

    • The outer pro-card acts as a row (el-row).
    • Nested pro-card components act as columns (el-col).

    When nesting Cards, you can use layout-specific props like split, gutter, direction, justify, and align to control the internal grid behavior. Setting split to true enables an enhanced split-card layout for nested items.

    <!-- Conceptual nesting pattern -->
    <pro-card>
      <pro-card :span="12" />
      <pro-card :span="12" />
    </pro-card>