@smartsoft001/claude-plugins 2.201.0 → 2.203.0
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/package.json +1 -1
- package/plugins/smart-angular/.claude-plugin/plugin.json +1 -1
- package/plugins/smart-angular/skills/angular-components-accordion/SKILL.md +84 -80
- package/plugins/smart-angular/skills/angular-components-action-panel/SKILL.md +35 -60
- package/plugins/smart-angular/skills/angular-components-alert/SKILL.md +24 -29
- package/plugins/smart-angular/skills/angular-components-avatar/SKILL.md +30 -30
- package/plugins/smart-angular/skills/angular-components-badge/SKILL.md +18 -12
- package/plugins/smart-angular/skills/angular-components-breadcrumbs/SKILL.md +27 -10
- package/plugins/smart-angular/skills/angular-components-button/SKILL.md +43 -17
- package/plugins/smart-angular/skills/angular-components-button-group/SKILL.md +26 -14
- package/plugins/smart-angular/skills/angular-components-calendar/SKILL.md +47 -28
- package/plugins/smart-angular/skills/angular-components-card/SKILL.md +29 -22
- package/plugins/smart-angular/skills/angular-components-card-heading/SKILL.md +24 -18
- package/plugins/smart-angular/skills/angular-components-command-palette/SKILL.md +41 -32
- package/plugins/smart-angular/skills/angular-components-container/SKILL.md +21 -20
- package/plugins/smart-angular/skills/angular-components-date-edit/SKILL.md +48 -45
- package/plugins/smart-angular/skills/angular-components-date-range/SKILL.md +72 -82
- package/plugins/smart-angular/skills/angular-components-description-list/SKILL.md +23 -10
- package/plugins/smart-angular/skills/angular-components-detail/SKILL.md +20 -8
- package/plugins/smart-angular/skills/angular-components-details/SKILL.md +64 -13
- package/plugins/smart-angular/skills/angular-components-divider/SKILL.md +36 -18
- package/plugins/smart-angular/skills/angular-components-drawer/SKILL.md +28 -23
- package/plugins/smart-angular/skills/angular-components-dropdown/SKILL.md +35 -16
- package/plugins/smart-angular/skills/angular-components-empty-state/SKILL.md +49 -11
- package/plugins/smart-angular/skills/angular-components-feed/SKILL.md +45 -12
- package/plugins/smart-angular/skills/angular-components-form/SKILL.md +53 -25
- package/plugins/smart-angular/skills/angular-components-grid-list/SKILL.md +37 -13
- package/plugins/smart-angular/skills/angular-components-icon/SKILL.md +8 -8
- package/plugins/smart-angular/skills/angular-components-info/SKILL.md +19 -15
- package/plugins/smart-angular/skills/angular-components-input/SKILL.md +86 -49
- package/plugins/smart-angular/skills/angular-components-list/SKILL.md +131 -81
- package/plugins/smart-angular/skills/angular-components-list-container/SKILL.md +24 -32
- package/plugins/smart-angular/skills/angular-components-media-object/SKILL.md +19 -17
- package/plugins/smart-angular/skills/angular-components-modal/SKILL.md +78 -17
- package/plugins/smart-angular/skills/angular-components-multi-column-layout/SKILL.md +19 -16
- package/plugins/smart-angular/skills/angular-components-navbar/SKILL.md +38 -21
- package/plugins/smart-angular/skills/angular-components-notification/SKILL.md +32 -33
- package/plugins/smart-angular/skills/angular-components-page/SKILL.md +48 -52
- package/plugins/smart-angular/skills/angular-components-page-heading/SKILL.md +42 -25
- package/plugins/smart-angular/skills/angular-components-paging/SKILL.md +17 -15
- package/plugins/smart-angular/skills/angular-components-password-strength/SKILL.md +21 -19
- package/plugins/smart-angular/skills/angular-components-progress-bars/SKILL.md +61 -24
- package/plugins/smart-angular/skills/angular-components-searchbar/SKILL.md +30 -37
- package/plugins/smart-angular/skills/angular-components-section-heading/SKILL.md +38 -27
- package/plugins/smart-angular/skills/angular-components-select-menu/SKILL.md +33 -17
- package/plugins/smart-angular/skills/angular-components-sidebar-layout/SKILL.md +30 -26
- package/plugins/smart-angular/skills/angular-components-sidebar-navigation/SKILL.md +79 -16
- package/plugins/smart-angular/skills/angular-components-sign-in-form/SKILL.md +64 -24
- package/plugins/smart-angular/skills/angular-components-stacked-layout/SKILL.md +24 -23
- package/plugins/smart-angular/skills/angular-components-stacked-list/SKILL.md +40 -21
- package/plugins/smart-angular/skills/angular-components-stats/SKILL.md +28 -15
- package/plugins/smart-angular/skills/angular-components-table/SKILL.md +42 -22
- package/plugins/smart-angular/skills/angular-components-tabs/SKILL.md +37 -13
- package/plugins/smart-angular/skills/angular-components-textarea/SKILL.md +48 -46
- package/plugins/smart-angular/skills/angular-components-toggle/SKILL.md +21 -28
- package/plugins/smart-angular/skills/angular-components-vertical-navigation/SKILL.md +66 -24
- package/plugins/smart-angular/skills/smart-crud/SKILL.md +5 -2
- package/plugins/smart-core/.claude-plugin/plugin.json +1 -1
- package/plugins/smart-react/.claude-plugin/plugin.json +1 -1
- package/plugins/smart-react/skills/react-components-action-panel/SKILL.md +13 -13
- package/plugins/smart-react/skills/react-components-alert/SKILL.md +2 -2
- package/plugins/smart-react/skills/react-components-avatar/SKILL.md +11 -11
- package/plugins/smart-react/skills/react-components-badge/SKILL.md +2 -2
- package/plugins/smart-react/skills/react-components-breadcrumbs/SKILL.md +7 -7
- package/plugins/smart-react/skills/react-components-button/SKILL.md +20 -20
- package/plugins/smart-react/skills/react-components-button-group/SKILL.md +2 -2
- package/plugins/smart-react/skills/react-components-calendar/SKILL.md +13 -13
- package/plugins/smart-react/skills/react-components-card/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-card-heading/SKILL.md +2 -2
- package/plugins/smart-react/skills/react-components-command-palette/SKILL.md +3 -3
- package/plugins/smart-react/skills/react-components-container/SKILL.md +6 -6
- package/plugins/smart-react/skills/react-components-date-edit/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-date-range/SKILL.md +4 -4
- package/plugins/smart-react/skills/react-components-description-list/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-detail/SKILL.md +25 -16
- package/plugins/smart-react/skills/react-components-details/SKILL.md +16 -16
- package/plugins/smart-react/skills/react-components-divider/SKILL.md +6 -6
- package/plugins/smart-react/skills/react-components-drawer/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-dropdown/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-empty-state/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-feed/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-grid-list/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-info/SKILL.md +3 -1
- package/plugins/smart-react/skills/react-components-input/SKILL.md +51 -17
- package/plugins/smart-react/skills/react-components-list/SKILL.md +81 -45
- package/plugins/smart-react/skills/react-components-list-container/SKILL.md +6 -6
- package/plugins/smart-react/skills/react-components-loader/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-media-object/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-modal/SKILL.md +10 -10
- package/plugins/smart-react/skills/react-components-multi-column-layout/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-navbar/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-notification/SKILL.md +9 -9
- package/plugins/smart-react/skills/react-components-overlays/SKILL.md +3 -3
- package/plugins/smart-react/skills/react-components-page/SKILL.md +5 -5
- package/plugins/smart-react/skills/react-components-page-heading/SKILL.md +6 -6
- package/plugins/smart-react/skills/react-components-paging/SKILL.md +28 -28
- package/plugins/smart-react/skills/react-components-password-strength/SKILL.md +4 -4
- package/plugins/smart-react/skills/react-components-progress-bars/SKILL.md +19 -19
- package/plugins/smart-react/skills/react-components-searchbar/SKILL.md +10 -10
- package/plugins/smart-react/skills/react-components-section-heading/SKILL.md +13 -13
- package/plugins/smart-react/skills/react-components-select-menu/SKILL.md +19 -19
- package/plugins/smart-react/skills/react-components-sidebar-layout/SKILL.md +9 -9
- package/plugins/smart-react/skills/react-components-sidebar-navigation/SKILL.md +29 -29
- package/plugins/smart-react/skills/react-components-sign-in-form/SKILL.md +3 -3
- package/plugins/smart-react/skills/react-components-stacked-layout/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-stacked-list/SKILL.md +2 -2
- package/plugins/smart-react/skills/react-components-stats/SKILL.md +2 -2
- package/plugins/smart-react/skills/react-components-table/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-tabs/SKILL.md +2 -2
- package/plugins/smart-react/skills/react-components-textarea/SKILL.md +8 -8
- package/plugins/smart-react/skills/react-components-toggle/SKILL.md +3 -2
- package/plugins/smart-react/skills/react-components-vertical-navigation/SKILL.md +9 -9
- package/plugins/smart-react/skills/react-provider/SKILL.md +1 -1
- package/plugins/smart-react/skills/smart-crud-react/SKILL.md +2 -2
|
@@ -42,10 +42,10 @@ The preset's class helpers (`getDividerContainerClasses`, `getDividerIconClasses
|
|
|
42
42
|
|
|
43
43
|
### `IDividerOptions`
|
|
44
44
|
|
|
45
|
-
| Field | Type | Default | Description
|
|
46
|
-
| ----------- | ------------------------------- | ---------- |
|
|
47
|
-
| `variant?` | `SmartDividerVariant` |
|
|
48
|
-
| `position?` | `'left' \| 'center' \| 'right'` | `'center'` | Where the content sits on the line.
|
|
45
|
+
| Field | Type | Default | Description |
|
|
46
|
+
| ----------- | ------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
47
|
+
| `variant?` | `SmartDividerVariant` | inferred | `with-label`, `with-icon`, `with-title`, `with-button` (only the action button on the line: `label` and `title` are not shown) or `with-toolbar` (label or title, a line, then the action). Preset only; inferred from the props when omitted (action, title, icon, label, in that order). |
|
|
48
|
+
| `position?` | `'left' \| 'center' \| 'right'` | `'center'` | Where the content sits on the line (preset, except `with-toolbar`). The standard only writes it to the `data-position` attribute of its root, for your own CSS. |
|
|
49
49
|
|
|
50
50
|
### Related types
|
|
51
51
|
|
|
@@ -85,7 +85,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
|
|
|
85
85
|
}
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
`SmartDividerPreset` is the styled (preset) implementation: register it
|
|
88
|
+
`SmartDividerPreset` is the styled (preset) implementation: register it under the `'divider'` key of `SmartProvider`'s `components`, render it directly in place of `SmartDivider`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
89
89
|
|
|
90
90
|
```tsx
|
|
91
91
|
import { SmartDividerProps } from '@smartsoft001/react';
|
|
@@ -115,7 +115,7 @@ export function TextDivider({
|
|
|
115
115
|
## Styling
|
|
116
116
|
|
|
117
117
|
- `SmartDividerStandard` renders the title, label and action button, or an `<hr />` when none is given; it does not render `iconName`.
|
|
118
|
-
- `SmartDividerPreset` draws the connecting lines around the content per `position`, with `smart:dark:` variants.
|
|
118
|
+
- `SmartDividerPreset` draws the connecting lines around the content per `position`, with `smart:dark:` variants; `with-toolbar` draws the content, a line and the action in one row.
|
|
119
119
|
|
|
120
120
|
## File Locations
|
|
121
121
|
|
|
@@ -103,7 +103,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
|
|
|
103
103
|
}
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
`SmartDrawerPreset` is the styled (preset) implementation: register it
|
|
106
|
+
`SmartDrawerPreset` is the styled (preset) implementation: register it under the `'drawer'` key of `SmartProvider`'s `components`, render it directly in place of `SmartDrawer`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
107
107
|
|
|
108
108
|
### The `useDrawer` hook
|
|
109
109
|
|
|
@@ -116,7 +116,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
|
|
|
116
116
|
}
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
`SmartDropdownPreset` is the styled (preset) implementation: register it
|
|
119
|
+
`SmartDropdownPreset` is the styled (preset) implementation: register it under the `'dropdown'` key of `SmartProvider`'s `components`, render it directly in place of `SmartDropdown`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
120
120
|
|
|
121
121
|
### The `useDropdown` hook
|
|
122
122
|
|
|
@@ -157,7 +157,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
|
|
|
157
157
|
}
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
-
`SmartEmptyStatePreset` is the styled (preset) implementation: register it
|
|
160
|
+
`SmartEmptyStatePreset` is the styled (preset) implementation: register it under the `'empty-state'` key of `SmartProvider`'s `components`, render it directly in place of `SmartEmptyState`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
161
161
|
|
|
162
162
|
```tsx
|
|
163
163
|
import { SmartEmptyStateProps } from '@smartsoft001/react';
|
|
@@ -133,7 +133,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
|
|
|
133
133
|
}
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
`SmartFeedPreset` is the styled (preset) implementation: register it
|
|
136
|
+
`SmartFeedPreset` is the styled (preset) implementation: register it under the `'feed'` key of `SmartProvider`'s `components`, render it directly in place of `SmartFeed`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
137
137
|
|
|
138
138
|
```tsx
|
|
139
139
|
import { SmartFeedProps } from '@smartsoft001/react';
|
|
@@ -121,7 +121,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
|
|
|
121
121
|
}
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
`SmartGridListPreset` is the styled (preset) implementation: register it
|
|
124
|
+
`SmartGridListPreset` is the styled (preset) implementation: register it under the `'grid-list'` key of `SmartProvider`'s `components`, render it directly in place of `SmartGridList`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
125
125
|
|
|
126
126
|
```tsx
|
|
127
127
|
import { SmartGridListProps } from '@smartsoft001/react';
|
|
@@ -43,6 +43,8 @@ Props of `SmartInfoPreset`. Extends `SmartInfoProps`.
|
|
|
43
43
|
| ------------ | --------------------- | ------- | ---------------------------------------- |
|
|
44
44
|
| `placement?` | `InfoPresetPlacement` | `'top'` | Side of the toggle the tooltip opens on. |
|
|
45
45
|
|
|
46
|
+
`placement` is only available when `SmartInfoPreset` is rendered directly: `SmartInfoProps` has no `placement`, so a preset registered under the `info` key always opens its tooltip on `'top'`.
|
|
47
|
+
|
|
46
48
|
### `IInfoOptions`
|
|
47
49
|
|
|
48
50
|
| Field | Type | Default | Description |
|
|
@@ -91,7 +93,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
|
|
|
91
93
|
}
|
|
92
94
|
```
|
|
93
95
|
|
|
94
|
-
`SmartInfoPreset` is the styled (preset) implementation: register it
|
|
96
|
+
`SmartInfoPreset` is the styled (preset) implementation: register it under the `'info'` key of `SmartProvider`'s `components`, render it directly in place of `SmartInfo`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
95
97
|
|
|
96
98
|
### The `useInfo` hook
|
|
97
99
|
|
|
@@ -33,6 +33,28 @@ All from `@smartsoft001/react`.
|
|
|
33
33
|
| `getInputErrorMessages` | function | The messages a field shows for its validation errors, in a fixed order. |
|
|
34
34
|
| `resolveInputFieldOptions` | function | The options of the field an input renders, merged with the options of the form's mode: a `<key>Confirm` control takes the options of `<key>`, and an array model is read through its first item. |
|
|
35
35
|
| `INPUT_PRESET_FIELD_COMPONENTS` | const | The Preline-styled field presets, by `FieldType`. |
|
|
36
|
+
| `LONG_TEXT_TOOLBAR` | const | The full menu of `SmartRichTextEditor` (its default `toolbar`), typed `SmartRichTextToolbar`. |
|
|
37
|
+
|
|
38
|
+
Every field component of the table under "Field types" is exported too (`SmartInputText`, `SmartInputTextPreset`, ...), with the hooks their standard and preset variants share. Use them in a custom field component of the same type.
|
|
39
|
+
|
|
40
|
+
| Hook / function | What it is |
|
|
41
|
+
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
42
|
+
| `useInputAddressPart` | Binds the input of one part of an `address` group to its control (value, dirty on change, touched on blur, disabled with the part) and gives an `id` for its label. |
|
|
43
|
+
| `useInputArray` | The `array` field: the item forms, `add()`, `remove(index)`, `move(from, to)`, `getItemDragProps(index)` and `isStatic` (`possibilities.static`). |
|
|
44
|
+
| `useInputCheck` | The `check` field: the possibilities (provider, input options, else the model field's), kept checked in line with the value, and `toggle(item)`. |
|
|
45
|
+
| `syncInputCheckPossibilities` | The possibilities with `checked` set from a value (what `useInputCheck` uses). |
|
|
46
|
+
| `useInputColor` | The `color` field: the shown colour, picking and clearing (`null`). |
|
|
47
|
+
| `useInputImage` | `useInput` and `useInputFile` plus the preview URL of the `image` field and the `logo` preset. |
|
|
48
|
+
| `useInputInts` | The `ints` field: one row per number plus a trailing row to add one. |
|
|
49
|
+
| `useInputNip` | `useInput` plus the `invalidNip` validator added to the control. |
|
|
50
|
+
| `useInputObject` | The `object` field: the options of the nested form, one tree level deeper. |
|
|
51
|
+
| `useInputPassword` | The `password` field: the strength rating and the `passwordStrength` validator it drives. |
|
|
52
|
+
| `useInputPhoneNumberPl` | `useInput` plus the `minLength(9)` / `maxLength(9)` validators. |
|
|
53
|
+
| `useInputRadio` | The `radio` field: the possibilities (provider, input options, else the model field's object map). |
|
|
54
|
+
| `getModelFieldPossibilitiesList` | The model field's `possibilities` object map as a list (the fallback of the radio and enum preset fields). |
|
|
55
|
+
| `useInputVideo` | `useInput` and `useInputFile` plus the player of the `video` fields. |
|
|
56
|
+
| `useInputFileDropZone` | The drop zone of the `pdf`, `video` and `attachment` presets (click / Enter / Space opens the picker, a drop uploads like a picked file); options `UseInputFileDropZoneOptions`. |
|
|
57
|
+
| `toNumberValue` | The value of a number `<input>`: empty is `null`, else `parseFloat`. |
|
|
36
58
|
|
|
37
59
|
The preset's class helpers (`getInputEmailPresetClasses`, `getInputEmailPresetLabelClasses`, `getInputNipPresetClasses`, `getInputNipPresetLabelClasses`, `getInputPhoneNumberPlPresetClasses`, `getInputPhoneNumberPlPresetLabelClasses`, `getInputPhoneNumberPlPresetWrapperClasses`, `getInputPhoneNumberPlPresetPrefixClasses`, `getInputPhoneNumberPresetClasses`, `getInputPhoneNumberPresetLabelClasses`, `getInputTextPresetClasses`, `getInputTextPresetLabelClasses`) are exported too, for a custom implementation that wants the preset look.
|
|
38
60
|
|
|
@@ -67,24 +89,26 @@ The props every field component receives from `<SmartInput>`: the input options
|
|
|
67
89
|
|
|
68
90
|
Props of the rich-text editor of `longText` fields.
|
|
69
91
|
|
|
70
|
-
| Prop | Type | Default
|
|
71
|
-
| -------------- | ------------------------ |
|
|
72
|
-
| `value?` | `string \| null` | —
|
|
73
|
-
| `placeholder?` | `string` | —
|
|
74
|
-
| `disabled?` | `boolean` | `false`
|
|
75
|
-
| `toolbar?` | `SmartRichTextToolbar` |
|
|
76
|
-
| `labelledBy?` | `string` | —
|
|
77
|
-
| `onChange?` | `(html: string) => void` | —
|
|
78
|
-
| `onBlur?` | `() => void` | —
|
|
92
|
+
| Prop | Type | Default | Description |
|
|
93
|
+
| -------------- | ------------------------ | ------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
94
|
+
| `value?` | `string \| null` | — | The HTML to edit; rendered sanitised when it does not come from here. |
|
|
95
|
+
| `placeholder?` | `string` | — | Placeholder of the empty editor. |
|
|
96
|
+
| `disabled?` | `boolean` | `false` | Makes the editor read-only. |
|
|
97
|
+
| `toolbar?` | `SmartRichTextToolbar` | `LONG_TEXT_TOOLBAR` | The menu groups; the full menu (formatting, lists, headings, link, image, colours, alignment) by default. |
|
|
98
|
+
| `labelledBy?` | `string` | — | The id of the element labelling the editor. |
|
|
99
|
+
| `onChange?` | `(html: string) => void` | — | Called with the HTML of the content after every change. |
|
|
100
|
+
| `onBlur?` | `() => void` | — | Called when the editor loses the focus. |
|
|
101
|
+
|
|
102
|
+
`SmartRichTextToolbar` is `SmartRichTextToolbarItem[][]`, one array per group of the menu. An item is a `SmartRichTextToggle` (`'bold'`, `'italic'`, `'underline'`, `'strike'`, `'code'`, `'blockquote'`, `'ordered_list'`, `'bullet_list'`, `'align_left'`, `'align_center'`, `'align_right'`, `'align_justify'`), a `SmartRichTextColorKind` (`'text_color'`, `'background_color'`), `'link'`, `'image'` or `{ heading: SmartRichTextHeading[] }` (`'h1'` to `'h6'`). All these types are exported.
|
|
79
103
|
|
|
80
104
|
### `IInputOptions`
|
|
81
105
|
|
|
82
|
-
| Field | Type | Default
|
|
83
|
-
| ---------------- | ------------------------- |
|
|
84
|
-
| `treeLevel` | `number` | required
|
|
85
|
-
| `control` | `SmartAbstractControl` | required
|
|
86
|
-
| `possibilities?` | `SmartPossibility[]` | —
|
|
87
|
-
| `component?` | `InputComponentType<any>` |
|
|
106
|
+
| Field | Type | Default | Description |
|
|
107
|
+
| ---------------- | ------------------------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
108
|
+
| `treeLevel` | `number` | required | Nesting depth (0 at the top; nested object / array forms go one deeper). |
|
|
109
|
+
| `control` | `SmartAbstractControl` | required | The control of the field (`form.controls[fieldKey]`). |
|
|
110
|
+
| `possibilities?` | `SmartPossibility[]` | — | The options of a `radio`, `check` or preset `enum` field: the model possibilities provider's win over them, they win over the field's own `possibilities`. The standard `enum` (the enum's keys) and the other types do not read them. |
|
|
111
|
+
| `component?` | `InputComponentType<any>` | the component of the field's type | A field component used instead of the type's one. |
|
|
88
112
|
|
|
89
113
|
### `IInputFromFieldOptions<T>`
|
|
90
114
|
|
|
@@ -121,7 +145,7 @@ Props of the rich-text editor of `longText` fields.
|
|
|
121
145
|
| `dateWithEdit` | `SmartInputDateWithEdit` | `SmartInputDateWithEditPreset` | `SmartDateEdit` (digit inputs) bound to the control. |
|
|
122
146
|
| `dateRange` | `SmartInputDateRange` | `SmartInputDateRangePreset` | `IDateRange` value; the standard uses `SmartDateRange`, the preset two native date inputs. |
|
|
123
147
|
| `nip` | `SmartInputNip` | `SmartInputNipPreset` | Adds the NIP check (`invalidNip`) to the control. |
|
|
124
|
-
| `pesel` | `SmartInputPesel` | `SmartInputPeselPreset` | **
|
|
148
|
+
| `pesel` | `SmartInputPesel` | `SmartInputPeselPreset` | The form factory adds the `pesel` check; **differs**: the preset adds its own `invalidPesel` check to the control too (same message). |
|
|
125
149
|
| `phoneNumber` | `SmartInputPhoneNumber` | `SmartInputPhoneNumberPreset` | `type="tel"`; the form factory adds the `phoneNumber` check. |
|
|
126
150
|
| `phoneNumberPl` | `SmartInputPhoneNumberPl` | `SmartInputPhoneNumberPlPreset` | Exactly 9 characters (`minlength` / `maxlength`); the preset shows a `+48` addon. |
|
|
127
151
|
| `color` | `SmartInputColor` | `SmartInputColorPreset` | Native colour picker with a clear button. |
|
|
@@ -137,11 +161,21 @@ Props of the rich-text editor of `longText` fields.
|
|
|
137
161
|
|
|
138
162
|
Uploading fields need a file service: give `SmartProvider` a `fileServiceConfig` (`{ apiUrl }`) or a `fileService`; without one, a picked file is not uploaded. Files go to `<apiUrl>/attachments`.
|
|
139
163
|
|
|
164
|
+
## Possibilities
|
|
165
|
+
|
|
166
|
+
The `radio` and `check` fields (standard and preset) and the preset `enum` list their possibilities from, in this order of precedence:
|
|
167
|
+
|
|
168
|
+
1. the model possibilities provider (`modelPossibilitiesProvider` on `SmartProvider`), asked with `{ type, key, instance }` (the model's class, the field key and the form's value) when the field mounts and again 500 ms after the form's value last changed, as long as it returns a list or a promise of one (a `null` or `undefined` result is ignored);
|
|
169
|
+
2. else `options.possibilities`;
|
|
170
|
+
3. else the field's own `possibilities` (read through the first item of an array model): an object map `{ text: id }`, such as an enum, as a list for `radio` and the preset `enum`, a list as it is for `check`.
|
|
171
|
+
|
|
172
|
+
The `check` fields check each possibility whose `id` is in the value (or equals it). The standard `enum` lists the keys of the enum in `fieldOptions.possibilities` and asks no provider. `useInputPossibilities` returns the first two sources (the provider's, else the input options'), so a custom field adds its own fallback.
|
|
173
|
+
|
|
140
174
|
## Labels, info and messages
|
|
141
175
|
|
|
142
176
|
- The label is the label provider's (`modelLabelProvider` on `SmartProvider`) or the translation of `MODEL.<key>` (see `react-provider`).
|
|
143
177
|
- A field with `info: '...'` shows a `SmartInfo` tooltip; a field with `hide: true` (for the mode) renders nothing.
|
|
144
|
-
- Messages are shown once the control is touched, from its errors, in a fixed order: `required` (which hides `confirm`), `confirm`, `invalidNip`, `invalidUnique`, `email`, `phoneNumber`, `pesel
|
|
178
|
+
- Messages are shown once the control is touched, from its errors, in a fixed order: `required` (which hides `confirm`), `confirm`, `invalidNip`, `invalidUnique`, `email`, `phoneNumber`, `pesel` or `invalidPesel` (one message), `minlength`, `maxlength`, `min`, `max`, and `customMessage` (its value is shown as is). The texts come from `INPUT.ERRORS.*` translations. `getInputErrorMessages(errors, t)` returns that list for a custom message component.
|
|
145
179
|
|
|
146
180
|
## Choosing the component of a field
|
|
147
181
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: react-components-list
|
|
3
|
-
description: SmartList React component API (@smartsoft001/react) — list of model records whose columns come from @Field({ list }) metadata, fed by an IListProvider (list, loading), in desktop/mobile/masonryGrid modes, with item navigation, confirmed remove, multi-select, pagination (single page or infinite scroll) and cell pipes; listModeComponents / LIST_PRESET_MODE_COMPONENTS, the 'list' registry key and the useList hook.
|
|
3
|
+
description: SmartList React component API (@smartsoft001/react) — list of model records whose columns come from @Field({ list }) metadata, fed by an IListProvider (list, loading), in desktop/mobile/masonryGrid modes, with item navigation, confirmed remove, multi-select, sortable headers, details in a modal, pagination (single page or infinite scroll) and cell pipes; listModeComponents / LIST_PRESET_MODE_COMPONENTS, the 'list' registry key and the useList hook.
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# List (`SmartList`)
|
|
8
8
|
|
|
9
|
-
`SmartList` renders records of a `@Model` class. Its columns are the model's fields marked `@Field({ list: ... })`, sorted by `list.order`; its rows come from `options.provider.list`, and `provider.loading` shows the loader (and suppresses the "no results" text). `options.mode` picks the layout: `ListMode.desktop` (a table, the default), `ListMode.mobile` (stacked rows) or `ListMode.masonryGrid` (image tiles). Row actions are opt-in: `item` adds a "go to item" action (navigate to `routingPrefix + id` through the navigation adapter, or call `select(id)`), `remove` a remove action confirmed with an alert, `select: 'multi'` a checkbox column. The list **does not fetch**: the provider's owner loads the data (CRUD screens wire all of this from a `CrudFullConfig`).
|
|
9
|
+
`SmartList` renders records of a `@Model` class. Its columns are the model's fields marked `@Field({ list: ... })`, sorted by `list.order`; its rows come from `options.provider.list`, and `provider.loading` shows the loader (and suppresses the "no results" text). `options.mode` picks the layout: `ListMode.desktop` (a table, the default), `ListMode.mobile` (stacked rows) or `ListMode.masonryGrid` (image tiles). Row actions are opt-in: `item` adds a "go to item" action (navigate to `routingPrefix + id` through the navigation adapter, or call `select(id)`), `remove` a remove action confirmed with an alert, `details` a details action that opens the record in a modal, `select: 'multi'` a checkbox column. With `sort` the desktop headers are sort buttons. The list **does not fetch**: the provider's owner loads the data, also sorted (`provider.getData`) or by pages (CRUD screens wire all of this from a `CrudFullConfig`).
|
|
10
10
|
|
|
11
11
|
## When to Use This Skill
|
|
12
12
|
|
|
13
13
|
- Showing records of a model with columns taken from `@Field({ list })`
|
|
14
|
-
- Row actions: navigate to an item, remove with confirmation, multi-select
|
|
14
|
+
- Row actions: navigate to an item, remove with confirmation, details in a modal, multi-select
|
|
15
|
+
- Sortable column headers (`sort`)
|
|
15
16
|
- Paging through a provider (`pagination`), single page or infinite scroll
|
|
16
17
|
- Choosing the layout per mode, or the preset table look (`presentation`)
|
|
17
18
|
- Replacing a mode's component (`listModeComponents`) or the whole list (`components.list`), building on `useList`
|
|
@@ -22,22 +23,27 @@ For data that is not a model (plain rows), use `SmartTable` or `SmartStackedList
|
|
|
22
23
|
|
|
23
24
|
All from `@smartsoft001/react`.
|
|
24
25
|
|
|
25
|
-
| Export
|
|
26
|
-
|
|
|
27
|
-
| `SmartList`
|
|
28
|
-
| `SmartListDesktop`
|
|
29
|
-
| `SmartListDesktopPreset`
|
|
30
|
-
| `SmartListMasonryGrid`
|
|
31
|
-
| `SmartListMasonryGridPreset`
|
|
32
|
-
| `SmartListMobile`
|
|
33
|
-
| `SmartListMobilePreset`
|
|
34
|
-
| `useListFileUrl`
|
|
35
|
-
| `useList`
|
|
36
|
-
| `
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
| Export | Kind | What it is |
|
|
27
|
+
| ------------------------------------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
28
|
+
| `SmartList` | component | Resolves the list `fields` of `options.type` (the fields with `list` options, sorted by `list.order`) and renders the implementation of `options.mode` (desktop by default): the one registered in `listModeComponents` on `SmartProvider` (e.g. `LIST_PRESET_MODE_COMPONENTS`), else `SmartListDesktop` / `SmartListMobile` / `SmartListMasonryGrid`. |
|
|
29
|
+
| `SmartListDesktop` | component | The desktop list: a table with one column per list field, plus the multi-select, details, remove and item columns, the `top` component factory above it and the paging below it (`PaginationMode.singlePage`); with `options.sort` the field headers are sort buttons. |
|
|
30
|
+
| `SmartListDesktopPreset` | component | Preline-styled desktop list variation. |
|
|
31
|
+
| `SmartListMasonryGrid` | component | The masonry-grid list: a grid of tiles with the item's image (the model's first image field, lazy loaded) over its non-image cells, the `top` component factory above it and the paging below it (`PaginationMode.singlePage`); with `options.details` every tile gets a details button. |
|
|
32
|
+
| `SmartListMasonryGridPreset` | component | Preline-styled masonry-grid list variation: keeps the masonry column layout and renders every item as a Preline card, the image on a rounded top, the first non-image column as the title and the others as text. |
|
|
33
|
+
| `SmartListMobile` | component | The mobile list: a stacked list with one paragraph per cell and the details / remove / item buttons, the `top` component factory above it and the paging below it (`PaginationMode.singlePage`). |
|
|
34
|
+
| `SmartListMobilePreset` | component | Preline-styled mobile list variation: a responsive grid of cards. |
|
|
35
|
+
| `useListFileUrl` | hook | The download URL of an image cell's attachment (`''` without a file service). |
|
|
36
|
+
| `useList` | hook | The behaviour every list mode shares: the column `keys` (permissions via `useAuthService()`, dynamic `__array` columns), the provider `list` and `loading`, the `sort` options, the remove flow (a confirm alert, then `remove.provider.invoke(id)`), item navigation (`useNavigation().navigate(routingPrefix + id)` or `item.options.select`), the details provider (`select` / `unselect`, `detailsComponent` and its props, `detailsHandler`), the sort (`sortBy`, `activeSort`) and the pagination (`loadNextPage` / `loadPrevPage`, `handlePageChange`, infinite scroll). |
|
|
37
|
+
| `SmartListDetailsModal` | component | What the details action opens through `ModalService`: the details component (`SmartDetailsPage` by default) with the list's current `IDetailsOptions` as `value`, read from a store the list keeps up to date. |
|
|
38
|
+
| `getListDefaultSort`, `getNextListSort`, `getListAriaSort`, `getListSortIndicator`, `isListSortableKey` | function | The sort helpers of `useList`: the start sort of a `sort` option, the sort after a header click, the `aria-sort` and the arrow of a header, whether a column sorts. |
|
|
39
|
+
| `isListImageKey` | function | Whether a column is an image field of the model. |
|
|
40
|
+
| `getListTitleKey` | function | The first non-image column (the card title of the mobile and masonry presets). |
|
|
41
|
+
| `LIST_PRESET_MODE_COMPONENTS` | const | Preline-styled list mode presets, keyed by `ListMode`. |
|
|
42
|
+
| `useListDesktop` | hook | The desktop table logic: `useList` plus the table columns (`desktopKeys`: `selectMulti`, the keys, `detailsAction`, `removeAction`, `itemAction`), the multi selection reported through `provider.onChangeMultiSelected` and cleared by `provider.onCleanMultiSelected$`, and the `top` component factory. |
|
|
43
|
+
| `useListMasonryGrid` | hook | The masonry-grid logic: `useList` plus `listWithImages`, every item paired with the value of the model's first image field. |
|
|
44
|
+
| `LIST_DESKTOP_STICKY_HEADER_STYLE` | const | The inline style of the sticky header cells of `SmartListDesktop` (`position: sticky`, `top: 0`). |
|
|
45
|
+
|
|
46
|
+
The preset's class helpers (`getListDesktopContainerClasses`, `getListDesktopTableClasses`, `getListDesktopHeaderRowClasses`, `getListDesktopHeaderCellClasses`, `getListDesktopSortButtonClasses`, `getListDesktopSortIndicatorClasses`, `getListDesktopRowClasses`, `getListDesktopCellClasses`) are exported too, for a custom implementation that wants the preset look.
|
|
41
47
|
|
|
42
48
|
## Props and Types
|
|
43
49
|
|
|
@@ -61,20 +67,20 @@ Props of a list mode implementation (`SmartListDesktop`, `SmartListMobile`, `Sma
|
|
|
61
67
|
|
|
62
68
|
### `IListOptions<T>`
|
|
63
69
|
|
|
64
|
-
| Field | Type | Default | Description
|
|
65
|
-
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------- |
|
|
66
|
-
| `provider` | `IListProvider<T>` | required | Where the rows come from (`list`, `loading`), and the multi-selection callbacks.
|
|
67
|
-
| `type` | `any` | required | The `@Model` class whose `list` fields are the columns.
|
|
68
|
-
| `mode?` | `ListMode` | — | `ListMode.desktop` (default), `ListMode.mobile` or `ListMode.masonryGrid`.
|
|
69
|
-
| `pagination?` | `IListPaginationOptions` | — | Paging state and loaders
|
|
70
|
-
| `cellPipe?` | `ICellPipe<T>` | — | Formats cells: `transform(item, key, translate?)` returns text (sanitised) or `trustHtml(html)`.
|
|
71
|
-
| `componentFactories?` | `IListComponentFactories<T>` | — | `top`: a component rendered above the rows.
|
|
72
|
-
| `sort?` | `\| boolean \| { default?: string; defaultDesc?: boolean; }` |
|
|
73
|
-
| `details?` | `\| boolean \| { provider?: IDetailsProvider<T>; componentFactories?: IDetailsComponentFactories<T>; component?: ComponentType<any>; }` | — |
|
|
74
|
-
| `item?` | `\| boolean \| { options?: ItemOptions; }` | — | Adds the item action: `{ options: { routingPrefix, edit } }` navigates to `routingPrefix + id`, `{ options: { select, edit } }` calls `select(id)`. Setting `item` without `options` throws.
|
|
75
|
-
| `remove?` | `\| boolean \| { provider?: IRemoveProvider<T>; }` | — | Adds the remove action: an alert (`OBJECT.confirmDelete`) then `provider.invoke(id)`; `provider.check(item)` hides it per row.
|
|
76
|
-
| `select?` | `'multi'` | — | `'multi'` adds a checkbox column (desktop); changes go to `provider.onChangeMultiSelected`.
|
|
77
|
-
| `presentation?` | `{ variant?: 'default' \| 'striped' \| 'bordered' \| 'borderless'; hoverable?: boolean; header?: 'default' \| 'muted' \| 'none'; }` | `{}` | Desktop preset look: `variant` (`default`, `striped`, `bordered`, `borderless`), `hoverable`, `header` (`default`, `muted`, `none`).
|
|
70
|
+
| Field | Type | Default | Description |
|
|
71
|
+
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
72
|
+
| `provider` | `IListProvider<T>` | required | Where the rows come from (`list`, `loading`), and the multi-selection callbacks. |
|
|
73
|
+
| `type` | `any` | required | The `@Model` class whose `list` fields are the columns. |
|
|
74
|
+
| `mode?` | `ListMode` | — | `ListMode.desktop` (default), `ListMode.mobile` or `ListMode.masonryGrid`. |
|
|
75
|
+
| `pagination?` | `IListPaginationOptions` | — | Paging state and loaders: with `PaginationMode.singlePage` the modes render the pager below the rows, with `PaginationMode.infiniteScroll` they load the next page when the end of the rows scrolls into view. |
|
|
76
|
+
| `cellPipe?` | `ICellPipe<T>` | — | Formats cells: `transform(item, key, translate?)` returns text (sanitised) or `trustHtml(html)`. |
|
|
77
|
+
| `componentFactories?` | `IListComponentFactories<T>` | — | `top`: a component rendered above the rows. |
|
|
78
|
+
| `sort?` | `\| boolean \| { default?: string; defaultDesc?: boolean; }` | — | Makes the field headers of the desktop modes sort buttons; `default` / `defaultDesc` is the sort they show at first (see [Sorting](#sorting)). |
|
|
79
|
+
| `details?` | `\| boolean \| { provider?: IDetailsProvider<T>; componentFactories?: IDetailsComponentFactories<T>; component?: ComponentType<any>; }` | — | Adds a details action (`show`) to every item that opens `component` (`SmartDetailsPage` by default) in a modal; requires a `provider` (`IDetailsProvider`). See [Details](#details). |
|
|
80
|
+
| `item?` | `\| boolean \| { options?: ItemOptions; }` | — | Adds the item action: `{ options: { routingPrefix, edit } }` navigates to `routingPrefix + id`, `{ options: { select, edit } }` calls `select(id)`. Setting `item` without `options` throws. |
|
|
81
|
+
| `remove?` | `\| boolean \| { provider?: IRemoveProvider<T>; }` | — | Adds the remove action: an alert (`OBJECT.confirmDelete`) then `provider.invoke(id)`; `provider.check(item)` hides it per row. |
|
|
82
|
+
| `select?` | `'multi'` | — | `'multi'` adds a checkbox column (desktop); changes go to `provider.onChangeMultiSelected`. |
|
|
83
|
+
| `presentation?` | `{ variant?: 'default' \| 'striped' \| 'bordered' \| 'borderless'; hoverable?: boolean; header?: 'default' \| 'muted' \| 'none'; }` | `{}` | Desktop preset look: `variant` (`default`, `striped`, `bordered`, `borderless`), `hoverable`, `header` (`default`, `muted`, `none`). |
|
|
78
84
|
|
|
79
85
|
### `IListInternalOptions<T>`
|
|
80
86
|
|
|
@@ -89,7 +95,7 @@ What mode components receive: `IListOptions` plus the resolved `fields`. Extends
|
|
|
89
95
|
| Field | Type | Default | Description |
|
|
90
96
|
| -------------- | ------------------------ | -------- | ----------------------------------------------------------------------- |
|
|
91
97
|
| `mode?` | `PaginationMode` | — | `PaginationMode.singlePage` (pager) or `PaginationMode.infiniteScroll`. |
|
|
92
|
-
| `limit` | `number` | required | Page size.
|
|
98
|
+
| `limit` | `number` | required | Page size, for the provider's owner; the list does not read it. |
|
|
93
99
|
| `loadNextPage` | `() => Promise<boolean>` | required | Loads the next page; resolves whether there is a further one. |
|
|
94
100
|
| `loadPrevPage` | `() => Promise<boolean>` | required | Loads the previous page; resolves whether there is a further one. |
|
|
95
101
|
| `page` | `number` | required | Current page. |
|
|
@@ -97,13 +103,13 @@ What mode components receive: `IListOptions` plus the resolved `fields`. Extends
|
|
|
97
103
|
|
|
98
104
|
### `IListProvider<T>`
|
|
99
105
|
|
|
100
|
-
| Field | Type | Default | Description
|
|
101
|
-
| ------------------------ | -------------------------- | -------- |
|
|
102
|
-
| `getData` | `(filter: any) => void` | required |
|
|
103
|
-
| `onChangeMultiSelected?` | `(list: Array<T>) => void` | — | Called with the selected records when `select: 'multi'`.
|
|
104
|
-
| `onCleanMultiSelected$?` | `SmartSubscribable<void>` | — | Clears the multi-selection whenever it emits.
|
|
105
|
-
| `list` | `T[]` | required | The records to show.
|
|
106
|
-
| `loading` | `boolean` | required | Shows the loader while `true`.
|
|
106
|
+
| Field | Type | Default | Description |
|
|
107
|
+
| ------------------------ | -------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
108
|
+
| `getData` | `(filter: any) => void` | required | Reads the data again with `filter` merged in; a sortable header calls it with `{ offset: 0, sortBy, sortDesc }`. |
|
|
109
|
+
| `onChangeMultiSelected?` | `(list: Array<T>) => void` | — | Called with the selected records when `select: 'multi'`. |
|
|
110
|
+
| `onCleanMultiSelected$?` | `SmartSubscribable<void>` | — | Clears the multi-selection whenever it emits. |
|
|
111
|
+
| `list` | `T[]` | required | The records to show. |
|
|
112
|
+
| `loading` | `boolean` | required | Shows the loader while `true`. |
|
|
107
113
|
|
|
108
114
|
### `ICellPipe<T>`
|
|
109
115
|
|
|
@@ -166,6 +172,13 @@ Anything with a `subscribe(listener)` that returns an `unsubscribe()` handle, e.
|
|
|
166
172
|
| `select` | `(id: string) => void` | required | Called with the id instead of navigating. |
|
|
167
173
|
| `edit` | `boolean` | required | Whether the target opens for editing (passed along). |
|
|
168
174
|
|
|
175
|
+
### `IListSortState` and `IListSortFilter`
|
|
176
|
+
|
|
177
|
+
| Type | Fields |
|
|
178
|
+
| ----------------- | -------------------------------------------------------------------------------------- |
|
|
179
|
+
| `IListSortState` | `key: string`, `desc: boolean`: the sort a list shows (`useList().activeSort`). |
|
|
180
|
+
| `IListSortFilter` | `offset: 0`, `sortBy: string`, `sortDesc: boolean`: what a header passes to `getData`. |
|
|
181
|
+
|
|
169
182
|
### Related types
|
|
170
183
|
|
|
171
184
|
- `ListMode` (enum): `mobile = 'mobile', desktop = 'desktop', masonryGrid = 'masonryGrid'` — The list layouts.
|
|
@@ -238,6 +251,20 @@ export function NoteList({
|
|
|
238
251
|
|
|
239
252
|
Memoise `options`: `SmartList` recomputes its internal options whenever the object changes.
|
|
240
253
|
|
|
254
|
+
## Sorting
|
|
255
|
+
|
|
256
|
+
With `sort` set (`true`, or `{ default?, defaultDesc? }`), every field header of `SmartListDesktop` and `SmartListDesktopPreset` is a sort button with an arrow: `↕` on the headers that do not sort the list, `↑` / `↓` on the active one, which also carries `aria-sort` (`ascending` / `descending`). A click on another column sorts by it in ascending order, a click on the active column turns the direction around. The list does not sort the rows itself: it calls `provider.getData({ offset: 0, sortBy, sortDesc })` and the provider loads the rows in that order, from the first page. The CRUD list page (`@smartsoft001/crud-shell-react`) merges that filter into its `ICrudFilter` and passes the filter's sort back as `sort`. The expanded columns of a `dynamic` field do not sort; the mobile and masonry modes have no headers.
|
|
257
|
+
|
|
258
|
+
`sort.default` and `sort.defaultDesc` only set the header shown at first. The clicked sort stays while other options change and starts over from `sort.default` when `sort` is a new object, so keep `sort` stable (a constant or a memoised value).
|
|
259
|
+
|
|
260
|
+
## Details
|
|
261
|
+
|
|
262
|
+
With `details: { provider }`, every item gets a details action, labelled with the `show` translation (`data-role="details"`): a column of the desktop table and a button in the mobile rows and the masonry tiles (standard and presets). `useList().detailsHandler(item)` clears the provider (`clearData()`), opens `SmartListDetailsModal` through `ModalService` (mode `'bottom'`, rendered by `SmartModalHost`, see `react-components-overlays`) around `details.component`, or `SmartDetailsPage` by default, and asks the provider for the item (`getData(id)`). The modal reads `detailsComponentProps` (`IDetailsOptions`: `item` and `loading` from the provider, `type`, the list's `itemHandler` / `removeHandler`, `details.componentFactories`) from a store the list updates, so it shows the item once the provider has loaded it. Without a `provider`, setting `details` throws `Must set details provider`.
|
|
263
|
+
|
|
264
|
+
## Infinite scroll
|
|
265
|
+
|
|
266
|
+
With `pagination.mode` set to `PaginationMode.infiniteScroll` and `page < totalPages`, every mode renders an empty `<div data-role="infinite-scroll" aria-hidden="true">` after its items, watched by an `IntersectionObserver`. When it scrolls into view the list calls `pagination.loadNextPage()` (never twice at the same time), and it watches it again after every page. On the last page the element is gone; without `IntersectionObserver` (server rendering) nothing loads. `pagination.limit` is not read by the list.
|
|
267
|
+
|
|
241
268
|
## Replacing the Implementation
|
|
242
269
|
|
|
243
270
|
- **Per mode**: `listModeComponents` on `SmartProvider` maps a `ListMode` to a component taking `SmartListModeProps` (merged over `SmartListDesktop` / `SmartListMobile` / `SmartListMasonryGrid`). `LIST_PRESET_MODE_COMPONENTS` registers the Preline-styled `SmartListDesktopPreset`, `SmartListMobilePreset` and `SmartListMasonryGridPreset`.
|
|
@@ -295,8 +322,9 @@ function useList<T extends IEntity<string>>({ options }: SmartListModeProps<T>);
|
|
|
295
322
|
| `removeHandler` | `((item: T) => void) \| null` | Confirms and removes a record (`null` without `remove`). |
|
|
296
323
|
| `checkRemoveHandler` | `((item: T) => boolean) \| undefined` | `remove.provider.check`. |
|
|
297
324
|
| `itemHandler` | `((id: string) => void) \| null` | Navigates to / selects an id (`null` without `item`). |
|
|
298
|
-
| `detailsComponent` | `ComponentType<any> \| null` | `details.component`, `null` without it.
|
|
299
|
-
| `detailsComponentProps` | `IDetailsOptions<T> \| null` | The `IDetailsOptions`
|
|
325
|
+
| `detailsComponent` | `ComponentType<any> \| null` | `details.component`, `null` without it (the details action then opens `SmartDetailsPage`). |
|
|
326
|
+
| `detailsComponentProps` | `IDetailsOptions<T> \| null` | The `IDetailsOptions` the details component gets as `value`, `null` without `details`. |
|
|
327
|
+
| `detailsHandler` | `((item: T) => void) \| null` | Opens the details of an item in a modal (`null` without `details`). |
|
|
300
328
|
| `select` | `((id: string) => void) \| undefined` | `details.provider.getData`. |
|
|
301
329
|
| `unselect` | `(() => void) \| undefined` | `details.provider.clearData`. |
|
|
302
330
|
| `detailsButtonOptions` | `IButtonOptions` | `IButtonOptions` that close the details (`unselect`). |
|
|
@@ -307,12 +335,18 @@ function useList<T extends IEntity<string>>({ options }: SmartListModeProps<T>);
|
|
|
307
335
|
| `handlePageChange` | `(nextPage: number) => void` | Moves to a page through the loaders (for `SmartPaging`'s `onPageChange`). |
|
|
308
336
|
| `infiniteScroll` | `boolean` | `true` with `PaginationMode.infiniteScroll` and a next page. |
|
|
309
337
|
| `infiniteScrollRef` | `RefObject<HTMLDivElement \| null>` | Attach to an element after the rows; the next page loads when it scrolls into view. |
|
|
338
|
+
| `sortable` | `boolean` | `true` with `options.sort`. |
|
|
339
|
+
| `activeSort` | `IListSortState \| null` | The sort the headers show. |
|
|
340
|
+
| `isSortable` | `(key: string) => boolean` | Whether the header of a column sorts. |
|
|
341
|
+
| `sortBy` | `(key: string) => void` | Sorts by a column through `provider.getData({ offset: 0, sortBy, sortDesc })`. |
|
|
342
|
+
| `getAriaSort` | `(key: string) => 'ascending' \| 'descending' \| null` | The `aria-sort` of a header (only the active one has it). |
|
|
343
|
+
| `getSortIndicator` | `(key: string) => string` | The arrow of a header: `↑`, `↓`, or `↕` when it is not active. |
|
|
310
344
|
|
|
311
345
|
```tsx
|
|
312
346
|
import type { IEntity } from '@smartsoft001/domain-core';
|
|
313
347
|
import { SmartListModeProps, SmartPaging, useList } from '@smartsoft001/react';
|
|
314
348
|
|
|
315
|
-
export function
|
|
349
|
+
export function CustomList<T extends IEntity<string>>(
|
|
316
350
|
props: SmartListModeProps<T>,
|
|
317
351
|
) {
|
|
318
352
|
const {
|
|
@@ -358,7 +392,7 @@ export function CardList<T extends IEntity<string>>(
|
|
|
358
392
|
}
|
|
359
393
|
```
|
|
360
394
|
|
|
361
|
-
Register it for one mode with `listModeComponents={{ [ListMode.
|
|
395
|
+
Register it for one mode with `listModeComponents={{ [ListMode.desktop]: CustomList }}`, or for every mode with `components={{ list: CustomList }}`.
|
|
362
396
|
|
|
363
397
|
## Styling
|
|
364
398
|
|
|
@@ -371,6 +405,8 @@ Source: `packages/shared/react/src/lib/components/list/` in the smartsoft001 rep
|
|
|
371
405
|
- `desktop/list-desktop.tsx`: `SmartListDesktop`
|
|
372
406
|
- `desktop/preset/list-desktop-preset.tsx`: `SmartListDesktopPreset`
|
|
373
407
|
- `desktop/use-list-desktop.ts`: `useListDesktop`, `LIST_DESKTOP_STICKY_HEADER_STYLE`
|
|
408
|
+
- `list-details-modal.tsx`: `SmartListDetailsModal`
|
|
409
|
+
- `list-sort.ts`: `IListSortState`, `IListSortFilter`, `getListDefaultSort`, `getNextListSort`, `getListAriaSort`, `getListSortIndicator`, `isListSortableKey`
|
|
374
410
|
- `list-title-key.ts`: `isListImageKey`, `getListTitleKey`
|
|
375
411
|
- `list.tsx`: `SmartList`
|
|
376
412
|
- `list.types.ts`: `SmartListProps`, `SmartListModeProps`
|
|
@@ -37,10 +37,10 @@ All from `@smartsoft001/react`.
|
|
|
37
37
|
|
|
38
38
|
### `IListContainerOptions`
|
|
39
39
|
|
|
40
|
-
| Field | Type | Default | Description
|
|
41
|
-
| -------------------- | --------------------------- | ------- |
|
|
42
|
-
| `variant?` | `SmartListContainerVariant` | — | Exposed as `data-variant
|
|
43
|
-
| `fullWidthOnMobile?` | `boolean` | — |
|
|
40
|
+
| Field | Type | Default | Description |
|
|
41
|
+
| -------------------- | --------------------------- | ------- | -------------------------------------------------------------------------------------------------------------- |
|
|
42
|
+
| `variant?` | `SmartListContainerVariant` | — | Exposed as `data-variant`, a hook for your CSS or a custom implementation; the standard adds no styles for it. |
|
|
43
|
+
| `fullWidthOnMobile?` | `boolean` | — | Not read by the built-in implementation; available to a custom implementation (edge-to-edge on small screens). |
|
|
44
44
|
|
|
45
45
|
### Related types
|
|
46
46
|
|
|
@@ -65,12 +65,12 @@ export function Team() {
|
|
|
65
65
|
|
|
66
66
|
`SmartListContainer` renders the component registered under the `'list-container'` key of `SmartProvider`'s `components`, and `SmartListContainerStandard` when nothing is registered there. Every `SmartListContainer` below the provider then renders the registered component, which receives the same props.
|
|
67
67
|
|
|
68
|
-
There is no preset for this component: register a component of your own that takes `SmartListContainerProps`, as shown below, as `components={{ 'list-container':
|
|
68
|
+
There is no preset for this component: register a component of your own that takes `SmartListContainerProps`, as shown below, as `components={{ 'list-container': CustomListContainer }}`. Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
69
69
|
|
|
70
70
|
```tsx
|
|
71
71
|
import { SmartListContainerProps } from '@smartsoft001/react';
|
|
72
72
|
|
|
73
|
-
export function
|
|
73
|
+
export function CustomListContainer({
|
|
74
74
|
options,
|
|
75
75
|
className,
|
|
76
76
|
children,
|
|
@@ -72,7 +72,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
|
|
|
72
72
|
}
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
`SmartLoaderPreset` is the styled (preset) implementation: register it
|
|
75
|
+
`SmartLoaderPreset` is the styled (preset) implementation: register it under the `'loader'` key of `SmartProvider`'s `components`, render it directly in place of `SmartLoader`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
76
76
|
|
|
77
77
|
### The `useLoader` hook
|
|
78
78
|
|
|
@@ -91,7 +91,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
|
|
|
91
91
|
}
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
`SmartMediaObjectPreset` is the styled (preset) implementation: register it
|
|
94
|
+
`SmartMediaObjectPreset` is the styled (preset) implementation: register it under the `'media-object'` key of `SmartProvider`'s `components`, render it directly in place of `SmartMediaObject`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
95
95
|
|
|
96
96
|
```tsx
|
|
97
97
|
import { SmartMediaObjectProps } from '@smartsoft001/react';
|