robobyte-front-builder 1.0.25 → 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INTEGRATION.md +94 -10
- package/LICENSE +65 -0
- package/README.md +149 -21
- package/docs/ReportViewer.md +581 -0
- package/docs/fetchReportData.md +379 -0
- package/docs/printLayout.md +405 -0
- package/package.json +29 -1
- package/src/lib/agGridTheme.js +58 -0
- package/src/lib/agGridThemeContext.jsx +42 -0
- package/src/lib/index.js +7 -0
- package/src/lib/providers/RoboByteFrontBuilderProvider.jsx +14 -0
- package/src/views/builder/viewer/renderers/DataGridRenderer.jsx +4 -4
- package/src/views/genericTable/SGrid.js +5 -5
- package/src/views/genericTable/TAGGrid.js +3 -5
- package/src/views/rolePermissions/UpdateReportPermissionDialog.js +4 -0
- package/training/00-index.md +168 -0
- package/training/01-input.md +144 -0
- package/training/02-checkbox.md +107 -0
- package/training/03-dropdown.md +135 -0
- package/training/04-datepicker.md +139 -0
- package/training/05-radio.md +123 -0
- package/training/06-number.md +133 -0
- package/training/07-textarea.md +114 -0
- package/training/08-richtext.md +112 -0
- package/training/09-tag.md +110 -0
- package/training/10-time.md +107 -0
- package/training/11-toggle.md +108 -0
- package/training/12-signature.md +107 -0
- package/training/13-autocomplete.md +134 -0
- package/training/14-button.md +168 -0
- package/training/15-label.md +138 -0
- package/training/16-header.md +128 -0
- package/training/17-divider.md +96 -0
- package/training/18-image.md +105 -0
- package/training/19-link.md +108 -0
- package/training/20-banner.md +122 -0
- package/training/21-progress-circle.md +101 -0
- package/training/22-progress-line.md +93 -0
- package/training/23-menu.md +139 -0
- package/training/24-popover.md +114 -0
- package/training/25-layout.md +116 -0
- package/training/26-layout-cell.md +143 -0
- package/training/27-card.md +87 -0
- package/training/28-wizard.md +126 -0
- package/training/29-wizard-step.md +92 -0
- package/training/30-repeater.md +123 -0
- package/training/31-dialog.md +131 -0
- package/training/32-breadcrumb.md +121 -0
- package/training/33-dataGrid.md +129 -0
- package/training/34-dataTableViewer.md +115 -0
- package/training/35-reportViewer.md +673 -0
- package/training/36-viewRenderer.md +110 -0
- package/training/37-treeView.md +170 -0
- package/training/38-kpi-metric.md +148 -0
- package/training/39-kpi-trend.md +105 -0
- package/training/40-kpi-badge.md +112 -0
- package/training/41-kpi-statusDot.md +118 -0
- package/training/42-kpi-iconBox.md +114 -0
- package/training/43-kpi-gauge.md +143 -0
- package/training/44-kpi-bulletChart.md +126 -0
- package/training/45-kpi-colorScale.md +143 -0
- package/training/46-kpi-rating.md +125 -0
- package/training/47-kpi-countdown.md +151 -0
- package/training/48-fetchReportData.md +276 -0
- package/training/49-printLayout.md +215 -0
- package/training/examples/01-login-form.json +176 -0
- package/training/examples/02-contact-form.json +141 -0
- package/training/examples/03-kpi-cards-row.json +123 -0
- package/training/examples/04-settings-toggles.json +153 -0
- package/training/examples/05-user-profile-card.json +136 -0
- package/training/examples/06-date-range-filter.json +108 -0
- package/training/examples/07-search-bar-results.json +130 -0
- package/training/examples/08-notification-settings.json +131 -0
- package/training/examples/09-employee-profile-form.json +259 -0
- package/training/examples/10-invoice-form.json +241 -0
- package/training/examples/11-dashboard-overview.json +251 -0
- package/training/examples/12-registration-wizard.json +154 -0
- package/training/examples/13-product-catalog.json +168 -0
- package/training/examples/14-data-table-with-filters.json +180 -0
- package/training/examples/15-tabbed-profile.json +92 -0
- package/training/examples/16-kpi-full-row.json +203 -0
- package/training/examples/17-tree-detail-view.json +139 -0
- package/training/examples/18-employee-management.json +233 -0
- package/training/examples/19-sales-dashboard.json +272 -0
- package/training/examples/20-checkout-wizard.json +225 -0
- package/training/examples/21-analytics-page.json +222 -0
- package/training/examples/22-hr-onboarding.json +222 -0
- package/training/examples/23-document-browser.json +241 -0
- package/training/examples/24-order-management.json +290 -0
- package/training/examples/25-crm-contact-page.json +272 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Component: viewRenderer
|
|
2
|
+
|
|
3
|
+
Embeds another saved view (by ID) inside the current page. Supports isolated data state, data seeding, refresh triggers, and height control.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Props — Main Tab
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Options / Notes |
|
|
10
|
+
|------|------|-----------------|
|
|
11
|
+
| `key` | expression | Optional identifier. |
|
|
12
|
+
| `viewId` | expression | **Required.** Numeric ID of the view to embed, e.g. `data.selectedViewId` or `"42"`. |
|
|
13
|
+
| `refreshKey` | expression | When this expression's value changes, the child view is re-fetched and remounted. Use a counter or a reactive data value. |
|
|
14
|
+
| `initialData` | expression | Object merged into the child view's data state on first load (and on each `refreshKey` change). One-time seed. E.g. `{ userId: data.user.id, mode: 'edit' }`. |
|
|
15
|
+
| `externalData` | expression | Object pushed into the child view on every parent re-render. Reactive — child always sees the latest value. E.g. `{ selectedRow: data.selectedRow }`. |
|
|
16
|
+
| `isolated` | boolean | `true` (default) — child has its own independent data/form stores. `false` — child shares the parent page's `data`/`setData`/`form`. |
|
|
17
|
+
| `heightMode` | select | `auto` — wraps content height. `full` — fills parent flex container. `fixed` — exact pixel height, content scrolls. |
|
|
18
|
+
| `height` | number | Exact height in pixels when `heightMode: fixed`. |
|
|
19
|
+
| `minHeight` | number | Minimum height floor in pixels when `heightMode: auto`. |
|
|
20
|
+
| `title` | expression | Optional title label shown above the embedded view. |
|
|
21
|
+
| `showBorder` | boolean | Shows a border around the embedded view container. |
|
|
22
|
+
| `showRefresh` | boolean | Shows a refresh button in the container header. |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Props — Style Tab
|
|
27
|
+
|
|
28
|
+
No dedicated style tab.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Props — Actions Tab
|
|
33
|
+
|
|
34
|
+
No actions.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Use Cases
|
|
39
|
+
|
|
40
|
+
**When to use:**
|
|
41
|
+
- Embedding a complex sub-form that is maintained as a separate view.
|
|
42
|
+
- Master-detail layouts: a table on top, an embedded detail view below.
|
|
43
|
+
- Dynamically swapping which view is shown based on selection (`viewId: data.selectedViewId`).
|
|
44
|
+
- Modular dashboards where each panel is a standalone view.
|
|
45
|
+
- Sharing a sub-form across multiple parent pages.
|
|
46
|
+
|
|
47
|
+
**When NOT to use:**
|
|
48
|
+
- Simple inline content → just drop components directly.
|
|
49
|
+
- Dialog body → use `dialog`'s `viewId` prop instead.
|
|
50
|
+
- Static content → no need for a separate view.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Schema Examples
|
|
55
|
+
|
|
56
|
+
### Embedding a static view
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"type": "viewRenderer",
|
|
60
|
+
"props": {
|
|
61
|
+
"key": "userDetails",
|
|
62
|
+
"viewId": "45",
|
|
63
|
+
"heightMode": "auto",
|
|
64
|
+
"showBorder": true
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Master-detail: embed detail view for selected row
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"type": "viewRenderer",
|
|
73
|
+
"props": {
|
|
74
|
+
"key": "detailPanel",
|
|
75
|
+
"viewId": "data.detailViewId",
|
|
76
|
+
"externalData": "{ selectedId: data.selectedEmployeeId }",
|
|
77
|
+
"refreshKey": "data.selectedEmployeeId",
|
|
78
|
+
"heightMode": "fixed",
|
|
79
|
+
"height": 400,
|
|
80
|
+
"isolated": true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Sub-form sharing parent state
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"type": "viewRenderer",
|
|
89
|
+
"props": {
|
|
90
|
+
"key": "addressForm",
|
|
91
|
+
"viewId": "12",
|
|
92
|
+
"isolated": false,
|
|
93
|
+
"heightMode": "auto"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Dynamic view switching
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"type": "viewRenderer",
|
|
102
|
+
"props": {
|
|
103
|
+
"key": "dynamicContent",
|
|
104
|
+
"viewId": "data.activeViewId",
|
|
105
|
+
"refreshKey": "data.activeViewId",
|
|
106
|
+
"heightMode": "full",
|
|
107
|
+
"showRefresh": true
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Component: treeView
|
|
2
|
+
|
|
3
|
+
A hierarchical tree component. Accepts flat (parentId-linked) or nested (children arrays) data — auto-detected. Supports lazy loading, selection, checkboxes, search, icons, and row actions.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Props — Main Tab
|
|
8
|
+
|
|
9
|
+
### Data
|
|
10
|
+
| Prop | Type | Options / Notes |
|
|
11
|
+
|------|------|-----------------|
|
|
12
|
+
| `dataKey` | expression | Key in page data pointing to the tree array. E.g. `"orgTree"` or `"data.departments"`. |
|
|
13
|
+
| `idField` | expression | Property on each node used as its unique ID, e.g. `"id"`. |
|
|
14
|
+
| `labelField` | expression | Property used as the display text for each node, e.g. `"name"`. |
|
|
15
|
+
| `childrenField` | expression | Property that holds nested children (for nested arrays), e.g. `"children"`. |
|
|
16
|
+
| `parentIdField` | expression | Property linking nodes to their parent (for flat arrays), e.g. `"parentId"`. |
|
|
17
|
+
|
|
18
|
+
### Lazy Loading
|
|
19
|
+
| Prop | Type | Options / Notes |
|
|
20
|
+
|------|------|-----------------|
|
|
21
|
+
| `hasChildrenField` | expression | Boolean flag property on each node indicating it has children to be loaded, e.g. `"hasChildren"`. When a node with this flag is expanded, `onExpandCode` runs. |
|
|
22
|
+
| `onExpandCode` | code (action) | Runs when an expandable node is opened. Fetch children here and call `setData({ [dataKey]: updatedTree })`. |
|
|
23
|
+
|
|
24
|
+
### Selection
|
|
25
|
+
| Prop | Type | Options / Notes |
|
|
26
|
+
|------|------|-----------------|
|
|
27
|
+
| `selectedKey` | expression | Data key where selected node(s) are written, e.g. `"selectedNode"`. |
|
|
28
|
+
| `selectable` | boolean | Enables node selection on click. |
|
|
29
|
+
| `multiSelect` | boolean | Allows selecting multiple nodes. |
|
|
30
|
+
| `checkboxSelection` | boolean | Shows checkboxes on each node for selection. |
|
|
31
|
+
| `onSelectCode` | code (action) | Runs when a node is selected/deselected. Available: the selected node(s). |
|
|
32
|
+
|
|
33
|
+
### Icons
|
|
34
|
+
| Prop | Type | Options / Notes |
|
|
35
|
+
|------|------|-----------------|
|
|
36
|
+
| `iconField` | expression | Property on each node containing a MUI icon name, e.g. `"iconName"`. |
|
|
37
|
+
| `defaultIcon` | expression | Fallback MUI icon name for all nodes, e.g. `"FolderOutlined"`. |
|
|
38
|
+
| `leafIcon` | expression | Icon for leaf nodes (no children), e.g. `"InsertDriveFileOutlined"`. |
|
|
39
|
+
|
|
40
|
+
### Expand Behavior
|
|
41
|
+
| Prop | Type | Options / Notes |
|
|
42
|
+
|------|------|-----------------|
|
|
43
|
+
| `expandAll` | boolean | Expands all nodes on initial render. |
|
|
44
|
+
| `defaultExpanded` | expression | Array of node IDs to expand by default. |
|
|
45
|
+
|
|
46
|
+
### Search
|
|
47
|
+
| Prop | Type | Options / Notes |
|
|
48
|
+
|------|------|-----------------|
|
|
49
|
+
| `showSearch` | boolean | Shows a search box above the tree. |
|
|
50
|
+
| `searchPlaceholder` | expression | Placeholder text in the search box. |
|
|
51
|
+
|
|
52
|
+
### Appearance
|
|
53
|
+
| Prop | Type | Options / Notes |
|
|
54
|
+
|------|------|-----------------|
|
|
55
|
+
| `dense` | boolean | Reduces node spacing for compact trees. |
|
|
56
|
+
| `showLines` | boolean | Draws vertical connector lines between nodes. |
|
|
57
|
+
| `showCount` | boolean | Shows a count badge next to each node with children. |
|
|
58
|
+
| `indent` | expression | Indentation per level in px, e.g. `"20"`. |
|
|
59
|
+
| `height` | expression | Tree container height, e.g. `"400px"`. |
|
|
60
|
+
| `fontSize` | expression | Node label font size. |
|
|
61
|
+
| `nodeColor` | expression | Default node text color. |
|
|
62
|
+
| `selectedBg` | expression | Background color of selected nodes. |
|
|
63
|
+
| `selectedColor` | expression | Text color of selected nodes. |
|
|
64
|
+
| `hoverBg` | expression | Background color on hover. |
|
|
65
|
+
| `borderRadius` | expression | Border radius of node rows. |
|
|
66
|
+
| `actionsConfig` | actions-config-editor | Action buttons shown in a popover on each node. Inside action code, `data.row` is the node object. |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Props — Style Tab
|
|
71
|
+
|
|
72
|
+
No dedicated style tab.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Props — Actions Tab
|
|
77
|
+
|
|
78
|
+
No dedicated action tab. Use `onSelectCode`, `onExpandCode`, and `actionsConfig` in Main.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Use Cases
|
|
83
|
+
|
|
84
|
+
**When to use:**
|
|
85
|
+
- Organizational hierarchy browsers.
|
|
86
|
+
- File/folder tree navigation.
|
|
87
|
+
- Category trees for content management.
|
|
88
|
+
- Permission/role hierarchies with checkbox selection.
|
|
89
|
+
- Lazy-loading large trees (load children on expand).
|
|
90
|
+
|
|
91
|
+
**When NOT to use:**
|
|
92
|
+
- Flat lists → use `reportViewer` or `dataGrid`.
|
|
93
|
+
- Only 2 levels deep → consider `dropdown` with grouping.
|
|
94
|
+
- Non-hierarchical data → use a list component.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Schema Examples
|
|
99
|
+
|
|
100
|
+
### Basic tree from nested data
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"type": "treeView",
|
|
104
|
+
"props": {
|
|
105
|
+
"dataKey": "orgChart",
|
|
106
|
+
"idField": "id",
|
|
107
|
+
"labelField": "name",
|
|
108
|
+
"childrenField": "children",
|
|
109
|
+
"selectable": true,
|
|
110
|
+
"selectedKey": "selectedNode",
|
|
111
|
+
"defaultIcon": "PersonOutlined",
|
|
112
|
+
"leafIcon": "PersonOutlined",
|
|
113
|
+
"showSearch": true,
|
|
114
|
+
"height": "400px"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Flat tree with parentId
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"type": "treeView",
|
|
123
|
+
"props": {
|
|
124
|
+
"dataKey": "categories",
|
|
125
|
+
"idField": "id",
|
|
126
|
+
"labelField": "title",
|
|
127
|
+
"parentIdField": "parentId",
|
|
128
|
+
"selectable": true,
|
|
129
|
+
"selectedKey": "selectedCategoryId",
|
|
130
|
+
"showLines": true,
|
|
131
|
+
"dense": true,
|
|
132
|
+
"height": "350px"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Lazy loading tree
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"type": "treeView",
|
|
141
|
+
"props": {
|
|
142
|
+
"dataKey": "fileTree",
|
|
143
|
+
"idField": "id",
|
|
144
|
+
"labelField": "name",
|
|
145
|
+
"childrenField": "children",
|
|
146
|
+
"hasChildrenField": "hasChildren",
|
|
147
|
+
"onExpandCode": "loadChildren({ nodeId: data.node.id })",
|
|
148
|
+
"defaultIcon": "FolderOutlined",
|
|
149
|
+
"leafIcon": "InsertDriveFileOutlined",
|
|
150
|
+
"height": "500px"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Multi-select with checkboxes
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"type": "treeView",
|
|
159
|
+
"props": {
|
|
160
|
+
"dataKey": "permissionsTree",
|
|
161
|
+
"idField": "permId",
|
|
162
|
+
"labelField": "permName",
|
|
163
|
+
"childrenField": "children",
|
|
164
|
+
"checkboxSelection": true,
|
|
165
|
+
"multiSelect": true,
|
|
166
|
+
"selectedKey": "selectedPermissions",
|
|
167
|
+
"expandAll": true
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Component: kpi-metric
|
|
2
|
+
|
|
3
|
+
Displays a single numeric KPI value with label, sub-label, formatting, and conditional threshold colors. The most commonly used KPI component.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Props — Main Tab
|
|
8
|
+
|
|
9
|
+
### Data
|
|
10
|
+
| Prop | Type | Options / Notes |
|
|
11
|
+
|------|------|-----------------|
|
|
12
|
+
| `valueKey` | expression | Data key or expression returning the numeric value. Modes: string key (`"revenue"` → uses `data["revenue"]`) or direct expression (`data.price * data.qty`). |
|
|
13
|
+
| `label` | expression | Primary label shown above or below the value. |
|
|
14
|
+
| `sublabel` | expression | Secondary label shown below the label. |
|
|
15
|
+
|
|
16
|
+
### Format
|
|
17
|
+
| Prop | Type | Options / Notes |
|
|
18
|
+
|------|------|-----------------|
|
|
19
|
+
| `format` | select | `number` · `currency` · `percent` · `compact` · `bytes` · `duration` |
|
|
20
|
+
| `decimals` | expression | Decimal places, e.g. `2`. |
|
|
21
|
+
| `prefix` | expression | Text/symbol before the value, e.g. `"$"`. |
|
|
22
|
+
| `suffix` | expression | Text/symbol after the value, e.g. `" units"`. |
|
|
23
|
+
| `currency` | expression | ISO currency code for `currency` format, e.g. `"USD"`, `"EUR"`. |
|
|
24
|
+
| `asRatio` | boolean | When `true`, treats percent values as 0–1 ratios (multiplies by 100 for display). |
|
|
25
|
+
|
|
26
|
+
### Value Appearance
|
|
27
|
+
| Prop | Type | Options / Notes |
|
|
28
|
+
|------|------|-----------------|
|
|
29
|
+
| `fontSize` | expression | Value font size, e.g. `"36px"`, `"2rem"`. |
|
|
30
|
+
| `fontWeight` | select | `400` · `500` · `600` · `700` · `800` · `900` |
|
|
31
|
+
| `align` | select | `left` · `center` · `right` |
|
|
32
|
+
| `labelPosition` | select | `above` · `below` — Whether the label appears above or below the value. |
|
|
33
|
+
|
|
34
|
+
### Label Style
|
|
35
|
+
| Prop | Type | Options / Notes |
|
|
36
|
+
|------|------|-----------------|
|
|
37
|
+
| `labelFontSize` | expression | Label text size. |
|
|
38
|
+
| `labelFontWeight` | select | `300` · `400` · `500` · `600` · `700` · `800` |
|
|
39
|
+
| `labelColor` | expression | Label color, e.g. `"text.secondary"` or `"#555"`. |
|
|
40
|
+
|
|
41
|
+
### Sub-label Style
|
|
42
|
+
| Prop | Type | Options / Notes |
|
|
43
|
+
|------|------|-----------------|
|
|
44
|
+
| `sublabelFontSize` | expression | Sub-label font size. |
|
|
45
|
+
| `sublabelFontWeight` | select | `300` · `400` · `500` · `600` · `700` · `800` |
|
|
46
|
+
| `sublabelColor` | expression | Sub-label color, e.g. `"text.disabled"` or `"#999"`. |
|
|
47
|
+
|
|
48
|
+
### Thresholds
|
|
49
|
+
| Prop | Type | Notes |
|
|
50
|
+
|------|------|-------|
|
|
51
|
+
| `thresholds` | thresholds-editor | Rules mapping value ranges to colors. E.g. `< 50 → error.main`, `>= 50 → success.main`. |
|
|
52
|
+
|
|
53
|
+
### Actions
|
|
54
|
+
| Prop | Type | Notes |
|
|
55
|
+
|------|------|-------|
|
|
56
|
+
| `onClick` | kpi-action | Fires when the metric is clicked. Available in action code: `clickedValue`. |
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Use Cases
|
|
61
|
+
|
|
62
|
+
**When to use:**
|
|
63
|
+
- Dashboard KPI cards: revenue, orders, users, growth.
|
|
64
|
+
- Summary statistics in reports.
|
|
65
|
+
- Any single important numeric value that needs emphasis.
|
|
66
|
+
- Metrics with conditional color based on value (green when positive, red when negative).
|
|
67
|
+
|
|
68
|
+
**When NOT to use:**
|
|
69
|
+
- Trend/change values → use `kpi-trend`.
|
|
70
|
+
- Progress toward a goal → use `kpi-gauge` or `kpi-bullet`.
|
|
71
|
+
- Status labels → use `kpi-badge`.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Schema Examples
|
|
76
|
+
|
|
77
|
+
### Revenue KPI
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"type": "kpi-metric",
|
|
81
|
+
"props": {
|
|
82
|
+
"valueKey": "data.totalRevenue",
|
|
83
|
+
"label": "Total Revenue",
|
|
84
|
+
"format": "currency",
|
|
85
|
+
"currency": "USD",
|
|
86
|
+
"decimals": 0,
|
|
87
|
+
"fontSize": "32px",
|
|
88
|
+
"fontWeight": "700",
|
|
89
|
+
"align": "center",
|
|
90
|
+
"labelPosition": "below",
|
|
91
|
+
"labelColor": "text.secondary"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Percentage with thresholds
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"type": "kpi-metric",
|
|
100
|
+
"props": {
|
|
101
|
+
"valueKey": "data.errorRate",
|
|
102
|
+
"label": "Error Rate",
|
|
103
|
+
"format": "percent",
|
|
104
|
+
"decimals": 1,
|
|
105
|
+
"asRatio": true,
|
|
106
|
+
"align": "center",
|
|
107
|
+
"thresholds": [
|
|
108
|
+
{ "operator": "<", "value": 0.05, "color": "success.main" },
|
|
109
|
+
{ "operator": "<", "value": 0.1, "color": "warning.main" },
|
|
110
|
+
{ "operator": ">=", "value": 0.1, "color": "error.main" }
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Compact large number
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"type": "kpi-metric",
|
|
120
|
+
"props": {
|
|
121
|
+
"valueKey": "data.totalUsers",
|
|
122
|
+
"label": "Users",
|
|
123
|
+
"sublabel": "Active this month",
|
|
124
|
+
"format": "compact",
|
|
125
|
+
"align": "center",
|
|
126
|
+
"fontSize": "28px",
|
|
127
|
+
"fontWeight": "600",
|
|
128
|
+
"sublabelColor": "text.disabled"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Clickable metric
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"type": "kpi-metric",
|
|
137
|
+
"props": {
|
|
138
|
+
"valueKey": "data.pendingOrders",
|
|
139
|
+
"label": "Pending Orders",
|
|
140
|
+
"format": "number",
|
|
141
|
+
"align": "center",
|
|
142
|
+
"onClick": {
|
|
143
|
+
"type": "custom",
|
|
144
|
+
"code": "setData({ filterStatus: 'pending' }); navigateTo('/orders')"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Component: kpi-trend
|
|
2
|
+
|
|
3
|
+
Displays a delta/change value with directional icon and color. Shows positive/negative trends with up/down arrows.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Props — Main Tab
|
|
8
|
+
|
|
9
|
+
### Data
|
|
10
|
+
| Prop | Type | Options / Notes |
|
|
11
|
+
|------|------|-----------------|
|
|
12
|
+
| `valueKey` | expression | Data key or expression returning the delta value (positive = up, negative = down). E.g. `"revenueDelta"` → `data.revenueDelta`. |
|
|
13
|
+
| `label` | expression | Context label shown alongside the trend, e.g. `"vs last month"`. |
|
|
14
|
+
|
|
15
|
+
### Format
|
|
16
|
+
| Prop | Type | Options / Notes |
|
|
17
|
+
|------|------|-----------------|
|
|
18
|
+
| `isPercent` | boolean | `true` if the value is a percentage change (appends `%`). |
|
|
19
|
+
| `decimals` | expression | Decimal places for the displayed value. |
|
|
20
|
+
| `invertColors` | boolean | `true` inverts the color logic — down becomes good (green), up becomes bad (red). Useful for cost/expense metrics. |
|
|
21
|
+
|
|
22
|
+
### Appearance
|
|
23
|
+
| Prop | Type | Options / Notes |
|
|
24
|
+
|------|------|-----------------|
|
|
25
|
+
| `variant` | select | `chip` — pill-shaped chip with icon. `text` — plain text with icon. `inline` — compact inline display. |
|
|
26
|
+
| `size` | select | `small` · `medium` · `large` |
|
|
27
|
+
| `showIcon` | boolean | Shows the up/down arrow icon. Default: `true`. |
|
|
28
|
+
| `align` | select | `left` · `center` · `right` |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Props — Style Tab
|
|
33
|
+
|
|
34
|
+
No dedicated style tab.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Props — Actions Tab
|
|
39
|
+
|
|
40
|
+
No actions.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Use Cases
|
|
45
|
+
|
|
46
|
+
**When to use:**
|
|
47
|
+
- Paired with `kpi-metric` to show the change alongside the current value.
|
|
48
|
+
- Revenue vs last month, users vs last week, etc.
|
|
49
|
+
- Any delta that needs directional context (up/down) and color (green/red).
|
|
50
|
+
|
|
51
|
+
**When NOT to use:**
|
|
52
|
+
- Absolute values (not deltas) → use `kpi-metric`.
|
|
53
|
+
- Percentage of a total → use `kpi-metric` with percent format.
|
|
54
|
+
- Progress toward goal → use `kpi-gauge` or `kpi-bullet`.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Schema Examples
|
|
59
|
+
|
|
60
|
+
### Revenue change chip
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"type": "kpi-trend",
|
|
64
|
+
"props": {
|
|
65
|
+
"valueKey": "data.revenueGrowth",
|
|
66
|
+
"label": "vs last month",
|
|
67
|
+
"isPercent": true,
|
|
68
|
+
"decimals": 1,
|
|
69
|
+
"variant": "chip",
|
|
70
|
+
"size": "medium",
|
|
71
|
+
"showIcon": true,
|
|
72
|
+
"align": "center"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Inverted (cost reduction is good)
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"type": "kpi-trend",
|
|
81
|
+
"props": {
|
|
82
|
+
"valueKey": "data.costDelta",
|
|
83
|
+
"label": "cost change",
|
|
84
|
+
"isPercent": true,
|
|
85
|
+
"decimals": 1,
|
|
86
|
+
"invertColors": true,
|
|
87
|
+
"variant": "text",
|
|
88
|
+
"align": "left"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Inline compact trend
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"type": "kpi-trend",
|
|
97
|
+
"props": {
|
|
98
|
+
"valueKey": "data.userGrowth",
|
|
99
|
+
"isPercent": true,
|
|
100
|
+
"variant": "inline",
|
|
101
|
+
"size": "small",
|
|
102
|
+
"decimals": 0
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Component: kpi-badge
|
|
2
|
+
|
|
3
|
+
A colored status badge/chip. Displays a value (text or number) as a colored pill. Threshold rules map values to colors.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Props — Main Tab
|
|
8
|
+
|
|
9
|
+
### Data
|
|
10
|
+
| Prop | Type | Options / Notes |
|
|
11
|
+
|------|------|-----------------|
|
|
12
|
+
| `valueKey` | expression | Data key or expression for the displayed value. String or number. E.g. `"status"` → `data.status`. |
|
|
13
|
+
| `label` | expression | Static text override. Leave blank to display the raw value from `valueKey`. If set, shows this text instead of the value (color still driven by value through thresholds). |
|
|
14
|
+
|
|
15
|
+
### Appearance
|
|
16
|
+
| Prop | Type | Options / Notes |
|
|
17
|
+
|------|------|-----------------|
|
|
18
|
+
| `variant` | select | `soft` — light tinted background. `outlined` — border with no fill. `filled` — solid colored background. |
|
|
19
|
+
| `size` | select | `small` · `medium` · `large` |
|
|
20
|
+
| `dot` | boolean | Shows a small colored dot before the label text. |
|
|
21
|
+
| `align` | select | `left` · `center` · `right` |
|
|
22
|
+
|
|
23
|
+
### Thresholds
|
|
24
|
+
| Prop | Type | Notes |
|
|
25
|
+
|------|------|-------|
|
|
26
|
+
| `thresholds` | thresholds-editor | Rules mapping values to colors. String matching: `"== active"` → `success.main`. Numeric: `"> 80"` → `warning.main`. Threshold `label` field overrides the displayed text per rule. |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Props — Style Tab
|
|
31
|
+
|
|
32
|
+
No dedicated style tab.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Props — Actions Tab
|
|
37
|
+
|
|
38
|
+
No actions.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Use Cases
|
|
43
|
+
|
|
44
|
+
**When to use:**
|
|
45
|
+
- Status displays: Active/Inactive/Pending, Open/Closed/Resolved.
|
|
46
|
+
- Priority badges: Low/Medium/High/Critical.
|
|
47
|
+
- Category or type labels in tables and cards.
|
|
48
|
+
- Any value that maps cleanly to a color: green = good, red = bad, yellow = warning.
|
|
49
|
+
|
|
50
|
+
**When NOT to use:**
|
|
51
|
+
- Numeric metrics → use `kpi-metric`.
|
|
52
|
+
- Progress → use `kpi-gauge` or `kpi-bullet`.
|
|
53
|
+
- On/off dot only → use `kpi-status-dot`.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Schema Examples
|
|
58
|
+
|
|
59
|
+
### Status badge with thresholds
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"type": "kpi-badge",
|
|
63
|
+
"props": {
|
|
64
|
+
"valueKey": "data.record.status",
|
|
65
|
+
"variant": "soft",
|
|
66
|
+
"size": "medium",
|
|
67
|
+
"dot": true,
|
|
68
|
+
"align": "center",
|
|
69
|
+
"thresholds": [
|
|
70
|
+
{ "operator": "==", "value": "active", "color": "success.main", "label": "Active" },
|
|
71
|
+
{ "operator": "==", "value": "inactive", "color": "error.main", "label": "Inactive" },
|
|
72
|
+
{ "operator": "==", "value": "pending", "color": "warning.main", "label": "Pending" }
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Priority badge (filled)
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"type": "kpi-badge",
|
|
82
|
+
"props": {
|
|
83
|
+
"valueKey": "data.task.priority",
|
|
84
|
+
"variant": "filled",
|
|
85
|
+
"size": "small",
|
|
86
|
+
"thresholds": [
|
|
87
|
+
{ "operator": "==", "value": "critical", "color": "#d32f2f", "label": "CRITICAL" },
|
|
88
|
+
{ "operator": "==", "value": "high", "color": "#f57c00", "label": "HIGH" },
|
|
89
|
+
{ "operator": "==", "value": "medium", "color": "#1976d2", "label": "MEDIUM" },
|
|
90
|
+
{ "operator": "==", "value": "low", "color": "#388e3c", "label": "LOW" }
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Outlined numeric badge
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"type": "kpi-badge",
|
|
100
|
+
"props": {
|
|
101
|
+
"valueKey": "data.score",
|
|
102
|
+
"label": "",
|
|
103
|
+
"variant": "outlined",
|
|
104
|
+
"size": "medium",
|
|
105
|
+
"thresholds": [
|
|
106
|
+
{ "operator": ">=", "value": 80, "color": "success.main" },
|
|
107
|
+
{ "operator": ">=", "value": 50, "color": "warning.main" },
|
|
108
|
+
{ "operator": "<", "value": 50, "color": "error.main" }
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|