@wix/auto-patterns 1.36.0 → 1.38.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/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.js +1 -1
- package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageContent/SkeletonCollection.js +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageFooter/AutoPatternsCollectionPageFooter.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/EditModeEntityPage.js +13 -9
- package/dist/cjs/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/Checkbox.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/DateInput.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/DateTime.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/FormFieldInput.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/ImageInput.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/LongText.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/Number.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/ShortText.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/Url.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/SkeletonEntity.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.js +1 -1
- package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGrid.js +9 -6
- package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGrid.js.map +1 -1
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js +1 -1
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js +1 -1
- package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js +11 -6
- package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/cjs/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.js +1 -1
- package/dist/cjs/components/DynamicIcon.js +1 -1
- package/dist/cjs/components/ModalRenderer.js +1 -1
- package/dist/cjs/components/filters/DynamicCollectionFilter.js +1 -1
- package/dist/cjs/components/filters/StaticCollectionFilter.js +1 -1
- package/dist/cjs/components/modals/actions/BulkDeleteModal.js +32 -14
- package/dist/cjs/components/modals/actions/BulkDeleteModal.js.map +1 -1
- package/dist/cjs/components/modals/actions/CreateModal.js +1 -1
- package/dist/cjs/components/modals/actions/EditModal.js +1 -1
- package/dist/cjs/counter.js +1 -1
- package/dist/cjs/dataSourceAdapters/cms/filterUtils.js +3 -2
- package/dist/cjs/dataSourceAdapters/cms/filterUtils.js.map +1 -1
- package/dist/cjs/dataSourceAdapters/cms/sortUtils.js +2 -1
- package/dist/cjs/dataSourceAdapters/cms/sortUtils.js.map +1 -1
- package/dist/cjs/hooks/useBaseTableFeatures.js +6 -3
- package/dist/cjs/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useBulkActionToolbar.js +1 -1
- package/dist/cjs/hooks/useCollectionPageActions.js +1 -1
- package/dist/cjs/hooks/useColumns.js +6 -1
- package/dist/cjs/hooks/useColumns.js.map +1 -1
- package/dist/cjs/hooks/useCommonCollectionFeatures.js +1 -1
- package/dist/cjs/hooks/useDataExtensionProps.js +30 -0
- package/dist/cjs/hooks/useDataExtensionProps.js.map +1 -0
- package/dist/cjs/hooks/useDragAndDropBaseProps.js +30 -0
- package/dist/cjs/hooks/useDragAndDropBaseProps.js.map +1 -0
- package/dist/cjs/hooks/useEmptyStates.js +1 -1
- package/dist/cjs/hooks/useEntityPageActions.js +1 -1
- package/dist/cjs/hooks/useFilters.js +1 -1
- package/dist/cjs/hooks/useGridDragAndDrop.js +17 -0
- package/dist/cjs/hooks/useGridDragAndDrop.js.map +1 -0
- package/dist/cjs/hooks/useGridFeatures.js +4 -1
- package/dist/cjs/hooks/useGridFeatures.js.map +1 -1
- package/dist/cjs/hooks/useTableDragAndDrop.js +17 -0
- package/dist/cjs/hooks/useTableDragAndDrop.js.map +1 -0
- package/dist/cjs/hooks/useTableFeatures.js +7 -2
- package/dist/cjs/hooks/useTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useTableGridSwitchDragAndDrop.js +17 -0
- package/dist/cjs/hooks/useTableGridSwitchDragAndDrop.js.map +1 -0
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js +7 -2
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js.map +1 -1
- package/dist/cjs/providers/AppConfigContext.js +1 -1
- package/dist/cjs/providers/AppContext.js +1 -1
- package/dist/cjs/providers/AppContextData.js +1 -1
- package/dist/cjs/providers/AutoPatternsOverridesContext.js +2 -2
- package/dist/cjs/providers/AutoPatternsOverridesContext.js.map +1 -1
- package/dist/cjs/providers/ErrorContext.js +1 -1
- package/dist/cjs/providers/ItemsContext.js +1 -1
- package/dist/cjs/providers/ModalContext.js +1 -1
- package/dist/cjs/providers/OptimisticActionsContext.js +1 -1
- package/dist/cjs/providers/RootAppProvider.js +1 -1
- package/dist/cjs/providers/SchemaContext.js +1 -1
- package/dist/cjs/providers/SchemaRegistryContext.js +1 -1
- package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
- package/dist/cjs/types/DeepPartial.js +4 -0
- package/dist/cjs/types/DeepPartial.js.map +1 -0
- package/dist/cjs/types/actions/base.js.map +1 -1
- package/dist/cjs/types/types.js.map +1 -1
- package/dist/cjs/utils/actions/bulkDeleteAction.js +1 -1
- package/dist/cjs/utils/actions/createAction.js +1 -1
- package/dist/cjs/utils/actions/deleteAction.js +1 -1
- package/dist/cjs/utils/actions/updateAction.js +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/EditModeEntityPage.js +4 -0
- package/dist/esm/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsGrid/AutoPatternsGrid.js +7 -4
- package/dist/esm/components/AutoPatternsGrid/AutoPatternsGrid.js.map +1 -1
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js +9 -4
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/esm/components/modals/actions/BulkDeleteModal.js +25 -8
- package/dist/esm/components/modals/actions/BulkDeleteModal.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js +3 -2
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/sortUtils.js +2 -1
- package/dist/esm/dataSourceAdapters/cms/sortUtils.js.map +1 -1
- package/dist/esm/hooks/useBaseTableFeatures.js +4 -1
- package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useColumns.js +5 -0
- package/dist/esm/hooks/useColumns.js.map +1 -1
- package/dist/esm/hooks/useDataExtensionProps.js +18 -0
- package/dist/esm/hooks/useDataExtensionProps.js.map +1 -0
- package/dist/esm/hooks/useDragAndDropBaseProps.js +27 -0
- package/dist/esm/hooks/useDragAndDropBaseProps.js.map +1 -0
- package/dist/esm/hooks/useGridDragAndDrop.js +13 -0
- package/dist/esm/hooks/useGridDragAndDrop.js.map +1 -0
- package/dist/esm/hooks/useGridFeatures.js +4 -1
- package/dist/esm/hooks/useGridFeatures.js.map +1 -1
- package/dist/esm/hooks/useTableDragAndDrop.js +13 -0
- package/dist/esm/hooks/useTableDragAndDrop.js.map +1 -0
- package/dist/esm/hooks/useTableFeatures.js +7 -2
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useTableGridSwitchDragAndDrop.js +13 -0
- package/dist/esm/hooks/useTableGridSwitchDragAndDrop.js.map +1 -0
- package/dist/esm/hooks/useTableGridSwitchFeatures.js +7 -2
- package/dist/esm/hooks/useTableGridSwitchFeatures.js.map +1 -1
- package/dist/esm/providers/AutoPatternsOverridesContext.js.map +1 -1
- package/dist/esm/types/CollectionPageConfig.js.map +1 -1
- package/dist/esm/types/DeepPartial.js +2 -0
- package/dist/esm/types/DeepPartial.js.map +1 -0
- package/dist/esm/types/actions/base.js.map +1 -1
- package/dist/esm/types/types.js.map +1 -1
- package/dist/types/components/AutoPatternsEntityPage/EditModeEntityPage.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsGrid/AutoPatternsGrid.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsTable/AutoPatternsTable.d.ts.map +1 -1
- package/dist/types/components/modals/actions/BulkDeleteModal.d.ts.map +1 -1
- package/dist/types/hooks/useBaseTableFeatures.d.ts +10 -0
- package/dist/types/hooks/useBaseTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useColumns.d.ts.map +1 -1
- package/dist/types/hooks/useDataExtensionProps.d.ts +8 -0
- package/dist/types/hooks/useDataExtensionProps.d.ts.map +1 -0
- package/dist/types/hooks/useDragAndDropBaseProps.d.ts +4 -0
- package/dist/types/hooks/useDragAndDropBaseProps.d.ts.map +1 -0
- package/dist/types/hooks/useGridDragAndDrop.d.ts +24 -0
- package/dist/types/hooks/useGridDragAndDrop.d.ts.map +1 -0
- package/dist/types/hooks/useGridFeatures.d.ts +22 -0
- package/dist/types/hooks/useGridFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useTableDragAndDrop.d.ts +3 -0
- package/dist/types/hooks/useTableDragAndDrop.d.ts.map +1 -0
- package/dist/types/hooks/useTableFeatures.d.ts +2 -0
- package/dist/types/hooks/useTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useTableGridSwitchDragAndDrop.d.ts +27 -0
- package/dist/types/hooks/useTableGridSwitchDragAndDrop.d.ts.map +1 -0
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +24 -0
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts.map +1 -1
- package/dist/types/providers/AutoPatternsOverridesContext.d.ts +6 -0
- package/dist/types/providers/AutoPatternsOverridesContext.d.ts.map +1 -1
- package/dist/types/types/CollectionPageConfig.d.ts +19 -0
- package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
- package/dist/types/types/DeepPartial.d.ts +4 -0
- package/dist/types/types/DeepPartial.d.ts.map +1 -0
- package/dist/types/types/actions/base.d.ts +5 -0
- package/dist/types/types/actions/base.d.ts.map +1 -1
- package/dist/types/types/types.d.ts +24 -1
- package/dist/types/types/types.d.ts.map +1 -1
- package/docs/GETTING_STARTED.md +99 -2
- package/mcp-docs/app_config_structure.md +15 -1
- package/mcp-docs/auto-patterns-guide.md +317 -80
- package/mcp-docs/bulk_actions.md +60 -0
- package/mcp-docs/collection_page.md +34 -0
- package/mcp-docs/custom_overrides.md +134 -54
- package/mcp-docs/schema_config.md +74 -25
- package/mcp-docs/wix_fqdn_custom_data_source.md +66 -11
- package/package.json +12 -12
package/mcp-docs/bulk_actions.md
CHANGED
|
@@ -49,6 +49,66 @@ Bulk delete actions remove multiple entities with a confirmation modal.
|
|
|
49
49
|
2. `bulkDelete.modal` object must exist
|
|
50
50
|
3. The modal properties (title, description, actions, feedback) are all optional
|
|
51
51
|
|
|
52
|
+
#### Dynamic Modal Titles
|
|
53
|
+
|
|
54
|
+
Bulk delete modal titles can be made dynamic to reflect the number and type of selected items.
|
|
55
|
+
|
|
56
|
+
**Configuration**
|
|
57
|
+
|
|
58
|
+
Use the `title.id` property to reference a dynamic title resolver:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
bulkActionToolbar: {
|
|
62
|
+
primaryActions: [{
|
|
63
|
+
type: 'action',
|
|
64
|
+
action: {
|
|
65
|
+
item: {
|
|
66
|
+
id: 'bulkDelete',
|
|
67
|
+
type: 'bulkDelete',
|
|
68
|
+
bulkDelete: {
|
|
69
|
+
mode: 'modal',
|
|
70
|
+
modal: {
|
|
71
|
+
title: {
|
|
72
|
+
id: 'dynamicDeleteTitle' // References override function
|
|
73
|
+
},
|
|
74
|
+
// ... other modal config
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}]
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Implementation**
|
|
84
|
+
|
|
85
|
+
Create a title resolver function in your overrides:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const useBulkDeleteModalTitle = () => ({
|
|
89
|
+
dynamicDeleteTitle: ({ selectedCount, selectedValues }) => ({
|
|
90
|
+
text: `Delete ${selectedCount} ${selectedCount === 1 ? 'item' : 'items'}?`
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const bulkDeleteModalTitle = useBulkDeleteModalTitle();
|
|
95
|
+
// In your page component
|
|
96
|
+
<AutoPatternsOverridesProvider
|
|
97
|
+
value={{
|
|
98
|
+
bulkDeleteModalTitle,
|
|
99
|
+
// ... other overrides
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
<AutoPatternsApp configuration={config} />
|
|
103
|
+
</AutoPatternsOverridesProvider>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Parameters**
|
|
107
|
+
|
|
108
|
+
The title resolver function receives:
|
|
109
|
+
- `selectedCount: number` - Total number of selected items
|
|
110
|
+
- `selectedValues: any[]` - Array of selected item objects
|
|
111
|
+
|
|
52
112
|
### Custom Bulk Action Configuration
|
|
53
113
|
|
|
54
114
|
Custom bulk actions execute JavaScript code that you define for bulk operations. These actions receive parameters that give them access to selected entities data and utilities. Here's how to implement a custom bulk action:
|
|
@@ -52,3 +52,37 @@ The `layout` array contains the rendering components for the collection. Each la
|
|
|
52
52
|
* `item.title`, `item.subtitle`, `item.image` fields are **Field IDs** from the schema.
|
|
53
53
|
* If the user does not specify, **select the most relevant fields automatically**.
|
|
54
54
|
* For grid components, it is strongly recommended to implement a primary action cell with an `update` action that navigates to the entity page. This provides users with an intuitive way to access detailed information and edit individual entities directly from the grid view.
|
|
55
|
+
|
|
56
|
+
## Column Tooltips
|
|
57
|
+
|
|
58
|
+
Add tooltips to column headers using the `tooltipContent` property. When provided, an info icon appears next to the column header that users can hover over to see the tooltip content.
|
|
59
|
+
|
|
60
|
+
Use tooltips to provide:
|
|
61
|
+
- **Explanations** - Help users understand what the column represents
|
|
62
|
+
- **Tools** - Provide guidance on how to use or interpret the column data
|
|
63
|
+
- **Additional information** - Offer context about the column's purpose, data format, or usage
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"columns": [
|
|
68
|
+
{
|
|
69
|
+
"id": "name",
|
|
70
|
+
"name": "Name",
|
|
71
|
+
"width": "200px",
|
|
72
|
+
"tooltipContent": "The name of the pet"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "age",
|
|
76
|
+
"name": "Age",
|
|
77
|
+
"width": "100px",
|
|
78
|
+
"tooltipContent": "Age in years. Use this to filter pets by age range."
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"id": "lastVisit",
|
|
82
|
+
"name": "Last Visit",
|
|
83
|
+
"width": "150px",
|
|
84
|
+
"tooltipContent": "Date of the pet's last veterinary visit. Click to sort by most recent visits."
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
```
|
|
@@ -82,7 +82,19 @@ export default function YourPage() {
|
|
|
82
82
|
const entityPageHeaderBadges = useEntityPageHeaderBadges();
|
|
83
83
|
|
|
84
84
|
return (
|
|
85
|
-
<AutoPatternsOverridesProvider
|
|
85
|
+
<AutoPatternsOverridesProvider
|
|
86
|
+
value={{
|
|
87
|
+
actions,
|
|
88
|
+
columns,
|
|
89
|
+
slots,
|
|
90
|
+
sections,
|
|
91
|
+
components,
|
|
92
|
+
modals,
|
|
93
|
+
customDataSources,
|
|
94
|
+
entityPageHeaderSubtitle,
|
|
95
|
+
entityPageHeaderBadges,
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
86
98
|
<AutoPatternsApp configuration={config} />
|
|
87
99
|
</AutoPatternsOverridesProvider>
|
|
88
100
|
);
|
|
@@ -94,6 +106,7 @@ export default function YourPage() {
|
|
|
94
106
|
**When adding any new implementation (action, modal, column, slot, section or component), you MUST update the corresponding hook in the `index.tsx` file to include your new implementation.** The main page component uses these hooks, so they serve as the central export point for each type of override.
|
|
95
107
|
|
|
96
108
|
For example:
|
|
109
|
+
|
|
97
110
|
- Adding a new action → Update `../components/actions/index.tsx` to include the new action in the `useActions` hook
|
|
98
111
|
- Adding a new modal → Update `../components/modals/index.tsx` to include the new modal in the `useModals` hook
|
|
99
112
|
- Adding a new column override → Update `../components/columns/index.tsx` to include the new column in the `useColumns` hook
|
|
@@ -114,6 +127,38 @@ Without updating the hook index files, your implementations won't be available t
|
|
|
114
127
|
- Incorrect import paths or naming mismatches
|
|
115
128
|
- Forgetting to import and use the hook in the main page component
|
|
116
129
|
|
|
130
|
+
## Bulk Delete Modal Titles
|
|
131
|
+
|
|
132
|
+
Dynamic title generation for bulk delete confirmation modals.
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
bulkDeleteModalTitle?: Record<
|
|
136
|
+
string,
|
|
137
|
+
(params: { selectedCount: number; selectedValues: any[] }) => { text: string }
|
|
138
|
+
>;
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Usage Example:**
|
|
142
|
+
```typescript
|
|
143
|
+
const useBulkDeleteModalTitle = () => ({
|
|
144
|
+
dynamicProductDelete: ({ selectedCount }) => ({
|
|
145
|
+
text: `Delete ${selectedCount} ${selectedCount === 1 ? 'product' : 'products'}?`
|
|
146
|
+
}),
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Integration:**
|
|
151
|
+
```typescript
|
|
152
|
+
|
|
153
|
+
const bulkDeleteModalTitle = useBulkDeleteModalTitle();
|
|
154
|
+
|
|
155
|
+
<AutoPatternsOverridesProvider
|
|
156
|
+
value={{
|
|
157
|
+
bulkDeleteModalTitle,
|
|
158
|
+
}}
|
|
159
|
+
>
|
|
160
|
+
```
|
|
161
|
+
|
|
117
162
|
## Columns
|
|
118
163
|
|
|
119
164
|
Each column in the table has a default rendering based on its field type. You can override this rendering by providing a custom function for the `column.id`. This allows you to customize how specific columns are displayed.
|
|
@@ -145,8 +190,8 @@ import { Badge } from '@wix/design-system';
|
|
|
145
190
|
|
|
146
191
|
/* The `IColumnValue<T>` interface provides type safety for column override functions: */
|
|
147
192
|
interface IColumnValue<T> {
|
|
148
|
-
value: T;
|
|
149
|
-
row: Record<string, any>;
|
|
193
|
+
value: T; // The individual column value (strongly typed)
|
|
194
|
+
row: Record<string, any>; // The entire row object with all field values
|
|
150
195
|
}
|
|
151
196
|
|
|
152
197
|
// For TEXT fields
|
|
@@ -157,9 +202,7 @@ export function petName({ value, row }: IColumnValue<string>) {
|
|
|
157
202
|
// For NUMBER fields
|
|
158
203
|
export function age({ value, row }: IColumnValue<number>) {
|
|
159
204
|
return (
|
|
160
|
-
<Badge skin={value > 5 ? 'warning' : 'success'}>
|
|
161
|
-
{value} years old
|
|
162
|
-
</Badge>
|
|
205
|
+
<Badge skin={value > 5 ? 'warning' : 'success'}>{value} years old</Badge>
|
|
163
206
|
);
|
|
164
207
|
}
|
|
165
208
|
|
|
@@ -194,23 +237,29 @@ export function hobbies({ value, row }: IColumnValue<string[]>) {
|
|
|
194
237
|
**Important**: The `row` object contains all field values from the entity, where each property corresponds to a **field ID** from the collection schema. To access specific field values, use the exact field ID as defined in your collection schema.
|
|
195
238
|
|
|
196
239
|
For example, if your collection schema has these fields:
|
|
240
|
+
|
|
197
241
|
```json
|
|
198
242
|
{
|
|
199
243
|
"fields": [
|
|
200
244
|
{ "key": "name", "displayName": "Pet Name", "type": "TEXT" },
|
|
201
245
|
{ "key": "age", "displayName": "Age", "type": "NUMBER" },
|
|
202
246
|
{ "key": "isVaccinated", "displayName": "Vaccinated", "type": "BOOLEAN" },
|
|
203
|
-
{
|
|
247
|
+
{
|
|
248
|
+
"key": "lastActivity",
|
|
249
|
+
"displayName": "Last Activity",
|
|
250
|
+
"type": "DATETIME"
|
|
251
|
+
}
|
|
204
252
|
]
|
|
205
253
|
}
|
|
206
254
|
```
|
|
207
255
|
|
|
208
256
|
Then in your column override, you access these values using the field IDs:
|
|
257
|
+
|
|
209
258
|
```typescript
|
|
210
259
|
export function myColumn({ value, row }) {
|
|
211
260
|
// Access field values using their schema field IDs
|
|
212
|
-
const petName = row.name;
|
|
213
|
-
const petAge = row.age;
|
|
261
|
+
const petName = row.name; // "name" field ID
|
|
262
|
+
const petAge = row.age; // "age" field ID
|
|
214
263
|
const isVaccinated = row.isVaccinated; // "isVaccinated" field ID
|
|
215
264
|
const lastActivity = row.lastActivity; // "lastActivity" field ID
|
|
216
265
|
|
|
@@ -260,7 +309,9 @@ export function petInfo({ value, row }: IColumnValue<string>) {
|
|
|
260
309
|
{row.age} years old • {row.type}
|
|
261
310
|
</Text>
|
|
262
311
|
{row.isVaccinated && (
|
|
263
|
-
<Text size="tiny" skin="success"
|
|
312
|
+
<Text size="tiny" skin="success">
|
|
313
|
+
✓ Vaccinated
|
|
314
|
+
</Text>
|
|
264
315
|
)}
|
|
265
316
|
</Box>
|
|
266
317
|
);
|
|
@@ -306,7 +357,9 @@ import { IColumnValue } from '@wix/auto-patterns/types';
|
|
|
306
357
|
|
|
307
358
|
export function date({ value, row }: IColumnValue<string>) {
|
|
308
359
|
// Access to other row data for enhanced date formatting
|
|
309
|
-
const isRecent =
|
|
360
|
+
const isRecent =
|
|
361
|
+
row.lastActivity &&
|
|
362
|
+
new Date(row.lastActivity) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
|
|
310
363
|
|
|
311
364
|
return (
|
|
312
365
|
<span style={{ color: isRecent ? 'green' : 'inherit' }}>
|
|
@@ -333,7 +386,7 @@ export const useColumns = () => {
|
|
|
333
386
|
petInfo,
|
|
334
387
|
status,
|
|
335
388
|
fullName,
|
|
336
|
-
date
|
|
389
|
+
date,
|
|
337
390
|
};
|
|
338
391
|
};
|
|
339
392
|
```
|
|
@@ -411,6 +464,7 @@ These components can display custom UI elements like notifications, information
|
|
|
411
464
|
### 2. Field Rendering Overrides
|
|
412
465
|
|
|
413
466
|
You can use custom components to override the default rendering of one or more fields. This allows you to:
|
|
467
|
+
|
|
414
468
|
- Apply custom validation logic
|
|
415
469
|
- Create custom input components
|
|
416
470
|
- Combine multiple fields into a single UI component
|
|
@@ -425,6 +479,7 @@ import { useController } from '@wix/auto-patterns/form'; // Always import from t
|
|
|
425
479
|
```
|
|
426
480
|
|
|
427
481
|
The hook requires:
|
|
482
|
+
|
|
428
483
|
- **name**: The field name you want to edit (should match the schema field ID)
|
|
429
484
|
- **control**: Retrieved from `form.control`
|
|
430
485
|
- **defaultValue**: Set from `entity?.[fieldId]` when it exists
|
|
@@ -468,7 +523,6 @@ export const customNameField: FC<CustomComponentProps> = ({ form, entity }) => {
|
|
|
468
523
|
};
|
|
469
524
|
```
|
|
470
525
|
|
|
471
|
-
|
|
472
526
|
### Example: Standalone Component (Not Field-Specific)
|
|
473
527
|
|
|
474
528
|
Custom components can also be used to add UI elements not tied to specific fields:
|
|
@@ -485,8 +539,8 @@ export const infoCard: FC<CustomComponentProps> = ({ entity }) => {
|
|
|
485
539
|
<Box direction="vertical" gap={2}>
|
|
486
540
|
<Text weight="bold">Important Information</Text>
|
|
487
541
|
<Text>
|
|
488
|
-
This custom component can display additional information or
|
|
489
|
-
that isn't directly tied to a specific field.
|
|
542
|
+
This custom component can display additional information or
|
|
543
|
+
functionality that isn't directly tied to a specific field.
|
|
490
544
|
</Text>
|
|
491
545
|
{entity?.isVaccinated ? (
|
|
492
546
|
<Text skin="success">This pet is vaccinated</Text>
|
|
@@ -512,7 +566,7 @@ export const useComponents = () => {
|
|
|
512
566
|
// You can access React context and other hooks here
|
|
513
567
|
return {
|
|
514
568
|
customNameField,
|
|
515
|
-
infoCard
|
|
569
|
+
infoCard,
|
|
516
570
|
};
|
|
517
571
|
};
|
|
518
572
|
```
|
|
@@ -577,9 +631,7 @@ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
|
|
|
577
631
|
onChange={(e) => form.setValue('name', e.target.value)}
|
|
578
632
|
/>
|
|
579
633
|
|
|
580
|
-
{showSpecialMessage &&
|
|
581
|
-
<Text>Special message for special name!</Text>
|
|
582
|
-
)}
|
|
634
|
+
{showSpecialMessage && <Text>Special message for special name!</Text>}
|
|
583
635
|
</Box>
|
|
584
636
|
);
|
|
585
637
|
};
|
|
@@ -599,18 +651,16 @@ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
|
|
|
599
651
|
onChange={(e) => form.setValue('name', e.target.value)}
|
|
600
652
|
/>
|
|
601
653
|
|
|
602
|
-
{showSpecialMessage &&
|
|
603
|
-
<Text>Special message for special name!</Text>
|
|
604
|
-
)}
|
|
654
|
+
{showSpecialMessage && <Text>Special message for special name!</Text>}
|
|
605
655
|
</Box>
|
|
606
656
|
);
|
|
607
657
|
};
|
|
608
658
|
```
|
|
609
659
|
|
|
610
|
-
|
|
611
660
|
##### When to Use the Entity Object
|
|
612
661
|
|
|
613
662
|
The `entity` object is useful for:
|
|
663
|
+
|
|
614
664
|
- Setting initial values
|
|
615
665
|
- Accessing read-only data that doesn't change
|
|
616
666
|
- Comparing form state with original values (e.g., detecting if changes were made)
|
|
@@ -623,7 +673,7 @@ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
|
|
|
623
673
|
const controller = useController({
|
|
624
674
|
name: 'name', // Field ID from the schema
|
|
625
675
|
control: form.control,
|
|
626
|
-
defaultValue: entity?.name // Initialize from entity
|
|
676
|
+
defaultValue: entity?.name, // Initialize from entity
|
|
627
677
|
});
|
|
628
678
|
|
|
629
679
|
// Use watch for reactive updates
|
|
@@ -638,9 +688,7 @@ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
|
|
|
638
688
|
onChange={(e) => controller.field.onChange(e.target.value)}
|
|
639
689
|
/>
|
|
640
690
|
</FormField>
|
|
641
|
-
{hasChanges &&
|
|
642
|
-
<Text size="small">Original value: {entity?.name}</Text>
|
|
643
|
-
)}
|
|
691
|
+
{hasChanges && <Text size="small">Original value: {entity?.name}</Text>}
|
|
644
692
|
</Box>
|
|
645
693
|
);
|
|
646
694
|
};
|
|
@@ -685,6 +733,7 @@ When implementing a custom data source, you need to modify the `collection` conf
|
|
|
685
733
|
}
|
|
686
734
|
}
|
|
687
735
|
```
|
|
736
|
+
|
|
688
737
|
## Sections
|
|
689
738
|
|
|
690
739
|
Sections allow you to group table rows under section headers, making it easier to organize and navigate through large datasets. This feature is especially useful when you want to categorize entities by specific criteria.
|
|
@@ -722,6 +771,7 @@ To enable sections, add the `sections` configuration to your table configuration
|
|
|
722
771
|
```
|
|
723
772
|
|
|
724
773
|
**Key Properties:**
|
|
774
|
+
|
|
725
775
|
- `entityTypeSource`: Must be set to `"custom"` instead of `"cms"`
|
|
726
776
|
- `custom.id`: A unique identifier for your custom data source implementation
|
|
727
777
|
|
|
@@ -748,6 +798,7 @@ export default function YourPage() {
|
|
|
748
798
|
#### Custom Data Source Function
|
|
749
799
|
|
|
750
800
|
You must implement a custom data source function that:
|
|
801
|
+
|
|
751
802
|
- Takes `collectionId` and `context` parameters
|
|
752
803
|
- Returns a Promise that resolves to a `SchemaConfig` object
|
|
753
804
|
- The `SchemaConfig` object must include:
|
|
@@ -763,8 +814,12 @@ You must implement a custom data source function that:
|
|
|
763
814
|
### Example Implementation Structure
|
|
764
815
|
|
|
765
816
|
```tsx
|
|
817
|
+
import { SchemaConfig } from '@wix/auto-patterns/types';
|
|
766
818
|
// customDataSources/myCustomDataSource.ts
|
|
767
|
-
export const myCustomDataSource = async (
|
|
819
|
+
export const myCustomDataSource = async (
|
|
820
|
+
collectionId: string,
|
|
821
|
+
context: any,
|
|
822
|
+
): Promise<SchemaConfig> => {
|
|
768
823
|
return {
|
|
769
824
|
id: 'myCustomCollection',
|
|
770
825
|
fields: {
|
|
@@ -773,17 +828,31 @@ export const myCustomDataSource = async (collectionId: string, context: any) =>
|
|
|
773
828
|
displayField: 'name',
|
|
774
829
|
idField: '_id',
|
|
775
830
|
actions: {
|
|
776
|
-
get: async (entityId: string) => {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
831
|
+
get: async (entityId: string) => {
|
|
832
|
+
/* Implementation */
|
|
833
|
+
},
|
|
834
|
+
create: async (newEntity: any) => {
|
|
835
|
+
/* Implementation */
|
|
836
|
+
},
|
|
837
|
+
update: async (updatedEntity: any) => {
|
|
838
|
+
/* Implementation */
|
|
839
|
+
},
|
|
840
|
+
delete: async (entityId: string) => {
|
|
841
|
+
/* Implementation */
|
|
842
|
+
},
|
|
843
|
+
bulkDelete: async (entityIds: string[]) => {
|
|
844
|
+
/* Implementation */
|
|
845
|
+
},
|
|
846
|
+
find: async (query: Query, options?: any) => {
|
|
847
|
+
/* Implementation */
|
|
848
|
+
},
|
|
849
|
+
},
|
|
783
850
|
};
|
|
784
851
|
};
|
|
785
852
|
```
|
|
786
853
|
|
|
854
|
+
> This is a simplified example of a custom data source implementation, do not use it as-is. You must implement the actual logic to connect to the FQDN schema.
|
|
855
|
+
|
|
787
856
|
### Hook Implementation
|
|
788
857
|
|
|
789
858
|
In `components/customDataSources/index.tsx`:
|
|
@@ -794,7 +863,7 @@ import { myCustomDataSource } from './myCustomDataSource';
|
|
|
794
863
|
export const useCustomDataSources = () => {
|
|
795
864
|
// You can access React context and other hooks here
|
|
796
865
|
return {
|
|
797
|
-
myCustomDataSource
|
|
866
|
+
myCustomDataSource,
|
|
798
867
|
};
|
|
799
868
|
};
|
|
800
869
|
```
|
|
@@ -812,8 +881,6 @@ When implementing custom data sources, you need to map your data source field ty
|
|
|
812
881
|
- **Reference fields** → `'REFERENCE'`
|
|
813
882
|
- **URL fields** → `'URL'`
|
|
814
883
|
|
|
815
|
-
|
|
816
|
-
|
|
817
884
|
### Validation Requirements
|
|
818
885
|
|
|
819
886
|
- **Function Signature**: Custom data source must be a function with signature `(collectionId: string, context: any) => Promise<SchemaConfig>`
|
|
@@ -870,7 +937,7 @@ Section renderers are functions that determine how to group items and what infor
|
|
|
870
937
|
#### Function Signature
|
|
871
938
|
|
|
872
939
|
```tsx
|
|
873
|
-
function sectionRenderer(item: any): Section
|
|
940
|
+
function sectionRenderer(item: any): Section;
|
|
874
941
|
```
|
|
875
942
|
|
|
876
943
|
Where `Section` is the interface from @wix/patterns (re-exported from auto-patterns):
|
|
@@ -893,6 +960,7 @@ interface Section {
|
|
|
893
960
|
```
|
|
894
961
|
|
|
895
962
|
The section renderer receives an item and returns:
|
|
963
|
+
|
|
896
964
|
- **id**: A unique identifier for the section (items with the same id are grouped together)
|
|
897
965
|
- **title**: The text displayed in the section header
|
|
898
966
|
- **primaryAction** (optional): An action button displayed in the section header
|
|
@@ -956,7 +1024,9 @@ export function groupByAgeAndVaccination(item: any): Section {
|
|
|
956
1024
|
badgeSkin = 'neutralLight';
|
|
957
1025
|
} else if (age >= 1 && age <= 5) {
|
|
958
1026
|
sectionId = isVaccinated ? 'young-vaccinated' : 'young-unvaccinated';
|
|
959
|
-
sectionTitle = `Young Adults (1-5 years) - ${
|
|
1027
|
+
sectionTitle = `Young Adults (1-5 years) - ${
|
|
1028
|
+
isVaccinated ? 'Vaccinated' : 'Not Vaccinated'
|
|
1029
|
+
}`;
|
|
960
1030
|
badgeSkin = isVaccinated ? 'light' : 'danger';
|
|
961
1031
|
} else {
|
|
962
1032
|
sectionId = 'seniors';
|
|
@@ -967,13 +1037,16 @@ export function groupByAgeAndVaccination(item: any): Section {
|
|
|
967
1037
|
return {
|
|
968
1038
|
id: sectionId,
|
|
969
1039
|
title: sectionTitle,
|
|
970
|
-
primaryAction:
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1040
|
+
primaryAction:
|
|
1041
|
+
age < 1
|
|
1042
|
+
? {
|
|
1043
|
+
id: 'special-care',
|
|
1044
|
+
label: 'Special Care Info',
|
|
1045
|
+
onClick: () => {
|
|
1046
|
+
// Show special care information for puppies
|
|
1047
|
+
},
|
|
1048
|
+
}
|
|
1049
|
+
: undefined,
|
|
977
1050
|
badge: {
|
|
978
1051
|
visible: true,
|
|
979
1052
|
skin: badgeSkin,
|
|
@@ -993,7 +1066,7 @@ import * as actions from './components/actions';
|
|
|
993
1066
|
|
|
994
1067
|
<AutoPatternsOverridesProvider value={{ sections, columns, actions }}>
|
|
995
1068
|
<AutoPatternsApp configuration={config} />
|
|
996
|
-
</AutoPatternsOverridesProvider
|
|
1069
|
+
</AutoPatternsOverridesProvider>;
|
|
997
1070
|
```
|
|
998
1071
|
|
|
999
1072
|
### Important Notes
|
|
@@ -1003,7 +1076,6 @@ import * as actions from './components/actions';
|
|
|
1003
1076
|
- **Performance**: Section renderers are called for every item, so keep the logic lightweight.
|
|
1004
1077
|
- **TableGridSwitch**: Sections work in both table and grid views when using TableGridSwitch.
|
|
1005
1078
|
|
|
1006
|
-
|
|
1007
1079
|
By implementing sections, you can significantly improve the user experience when dealing with large datasets by providing logical groupings that make information easier to find and understand.
|
|
1008
1080
|
|
|
1009
1081
|
## Slots
|
|
@@ -1011,6 +1083,7 @@ By implementing sections, you can significantly improve the user experience when
|
|
|
1011
1083
|
Slots allow you to inject custom React components into collection pages at specific points in the component hierarchy. Unlike other overrides that modify existing functionality, slots enable you to add entirely custom UI elements anywhere within the collection page components array.
|
|
1012
1084
|
|
|
1013
1085
|
Slots are useful for:
|
|
1086
|
+
|
|
1014
1087
|
- Adding custom banners or announcements above or below the table/grid
|
|
1015
1088
|
- Inserting analytics widgets or dashboards
|
|
1016
1089
|
- Adding custom promotional content
|
|
@@ -1028,6 +1101,7 @@ Slots are configured in the collection page configuration using the `CustomCompo
|
|
|
1028
1101
|
```
|
|
1029
1102
|
|
|
1030
1103
|
**Key Properties:**
|
|
1104
|
+
|
|
1031
1105
|
- `type`: Must be set to `"custom"` to identify this as a slot component
|
|
1032
1106
|
- `id`: A unique identifier that maps to your slot component implementation
|
|
1033
1107
|
|
|
@@ -1061,6 +1135,7 @@ Slot components can be positioned anywhere within the `components` array of a co
|
|
|
1061
1135
|
```
|
|
1062
1136
|
|
|
1063
1137
|
This configuration will render:
|
|
1138
|
+
|
|
1064
1139
|
1. The custom `topBanner` component at the top
|
|
1065
1140
|
2. The main collection component (table/grid) in the middle
|
|
1066
1141
|
3. The custom `bottomStats` component at the bottom
|
|
@@ -1080,7 +1155,9 @@ export const TopBannerComponent: React.FC = () => {
|
|
|
1080
1155
|
<Card>
|
|
1081
1156
|
<Card.Content>
|
|
1082
1157
|
<Box direction="vertical" gap={2}>
|
|
1083
|
-
<Text size="large" weight="bold">
|
|
1158
|
+
<Text size="large" weight="bold">
|
|
1159
|
+
Welcome to Pet Management
|
|
1160
|
+
</Text>
|
|
1084
1161
|
<Text>Manage all your pets from this central dashboard.</Text>
|
|
1085
1162
|
<Button size="small">Get Started</Button>
|
|
1086
1163
|
</Box>
|
|
@@ -1095,11 +1172,15 @@ export const BottomStatsComponent: React.FC = () => {
|
|
|
1095
1172
|
<Card.Content>
|
|
1096
1173
|
<Box direction="horizontal" gap={4}>
|
|
1097
1174
|
<Box direction="vertical" gap={1}>
|
|
1098
|
-
<Text size="large" weight="bold">
|
|
1175
|
+
<Text size="large" weight="bold">
|
|
1176
|
+
47
|
|
1177
|
+
</Text>
|
|
1099
1178
|
<Text size="small">Total Pets</Text>
|
|
1100
1179
|
</Box>
|
|
1101
1180
|
<Box direction="vertical" gap={1}>
|
|
1102
|
-
<Text size="large" weight="bold">
|
|
1181
|
+
<Text size="large" weight="bold">
|
|
1182
|
+
12
|
|
1183
|
+
</Text>
|
|
1103
1184
|
<Text size="small">Available for Adoption</Text>
|
|
1104
1185
|
</Box>
|
|
1105
1186
|
</Box>
|
|
@@ -1121,7 +1202,7 @@ export const useSlots = () => {
|
|
|
1121
1202
|
// You can access React context and other hooks here
|
|
1122
1203
|
return {
|
|
1123
1204
|
topBanner: TopBannerComponent,
|
|
1124
|
-
bottomStats: BottomStatsComponent
|
|
1205
|
+
bottomStats: BottomStatsComponent,
|
|
1125
1206
|
};
|
|
1126
1207
|
};
|
|
1127
1208
|
```
|
|
@@ -1153,7 +1234,6 @@ export default function YourPage() {
|
|
|
1153
1234
|
3. **Performance**: Slot components re-render with the page, so optimize for performance if needed
|
|
1154
1235
|
4. **Styling**: Follow the design system patterns and responsive design principles
|
|
1155
1236
|
|
|
1156
|
-
|
|
1157
1237
|
**Important:** Every time you create a new slot component, you must import it and add it to the `useSlots` hook return object in the `./components/slots/index.tsx` file. The key must match the `id` specified in your JSON configuration.
|
|
1158
1238
|
|
|
1159
1239
|
Slots provide a powerful way to enhance collection pages with custom functionality while maintaining the structure and features of the AutoPatterns system.
|