@wix/auto-patterns 1.15.0 → 1.17.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.
Files changed (100) hide show
  1. package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +16 -4
  2. package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
  3. package/dist/cjs/components/AutoPatternsCollectionPageContent/SkeletonCollection.js +34 -0
  4. package/dist/cjs/components/AutoPatternsCollectionPageContent/SkeletonCollection.js.map +1 -0
  5. package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +1 -0
  6. package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
  7. package/dist/cjs/components/AutoPatternsEntityPage/SkeletonEntity.js +198 -0
  8. package/dist/cjs/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -0
  9. package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js +13 -3
  10. package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
  11. package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js +4 -4
  12. package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
  13. package/dist/cjs/hooks/useBaseTableFeatures.js +7 -2
  14. package/dist/cjs/hooks/useBaseTableFeatures.js.map +1 -1
  15. package/dist/cjs/hooks/useCollectionPageOnRowClickActions.js +49 -0
  16. package/dist/cjs/hooks/useCollectionPageOnRowClickActions.js.map +1 -0
  17. package/dist/cjs/hooks/useNavigationUtils.js +2 -2
  18. package/dist/cjs/hooks/useNavigationUtils.js.map +1 -1
  19. package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
  20. package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
  21. package/dist/cjs/providers/SchemaContext.js +4 -3
  22. package/dist/cjs/providers/SchemaContext.js.map +1 -1
  23. package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
  24. package/dist/cjs/types/actions/base.js.map +1 -1
  25. package/dist/cjs/types/actions/collectionPageActions.js.map +1 -1
  26. package/dist/cjs/utils/actions/resolveAction.js +2 -1
  27. package/dist/cjs/utils/actions/resolveAction.js.map +1 -1
  28. package/dist/cjs/utils/actions/types.js.map +1 -1
  29. package/dist/docs/action_cell.md +233 -0
  30. package/dist/docs/app_config_structure.md +356 -0
  31. package/dist/docs/auto-patterns-guide.md +2467 -0
  32. package/dist/docs/bulk_actions.md +266 -0
  33. package/dist/docs/collection_page.md +54 -0
  34. package/dist/docs/collection_page_actions.md +343 -0
  35. package/dist/docs/custom_overrides.md +511 -0
  36. package/dist/docs/entity_page.md +104 -0
  37. package/dist/docs/entity_page_actions.md +92 -0
  38. package/dist/docs/index.md +76 -0
  39. package/dist/docs/installation.md +55 -0
  40. package/dist/docs/introduction.md +74 -0
  41. package/dist/docs/pages_configuration.md +129 -0
  42. package/dist/docs/recipe-bulk-operations.md +1352 -0
  43. package/dist/docs/recipe-crud-operations.md +805 -0
  44. package/dist/docs/recipe-customization.md +1703 -0
  45. package/dist/docs/recipe-first-dashboard.md +795 -0
  46. package/dist/docs/sdk_and_schema.md +215 -0
  47. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +7 -1
  48. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
  49. package/dist/esm/components/AutoPatternsCollectionPageContent/SkeletonCollection.js +21 -0
  50. package/dist/esm/components/AutoPatternsCollectionPageContent/SkeletonCollection.js.map +1 -0
  51. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +3 -1
  52. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
  53. package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js +91 -0
  54. package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -0
  55. package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js +5 -1
  56. package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
  57. package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js +1 -1
  58. package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
  59. package/dist/esm/hooks/useBaseTableFeatures.js +6 -1
  60. package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
  61. package/dist/esm/hooks/useCollectionPageOnRowClickActions.js +45 -0
  62. package/dist/esm/hooks/useCollectionPageOnRowClickActions.js.map +1 -0
  63. package/dist/esm/hooks/useNavigationUtils.js +1 -1
  64. package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
  65. package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
  66. package/dist/esm/providers/SchemaContext.js +3 -2
  67. package/dist/esm/providers/SchemaContext.js.map +1 -1
  68. package/dist/esm/types/CollectionPageConfig.js.map +1 -1
  69. package/dist/esm/types/actions/base.js.map +1 -1
  70. package/dist/esm/types/actions/collectionPageActions.js.map +1 -1
  71. package/dist/esm/utils/actions/resolveAction.js +2 -1
  72. package/dist/esm/utils/actions/resolveAction.js.map +1 -1
  73. package/dist/esm/utils/actions/types.js.map +1 -1
  74. package/dist/types/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.d.ts.map +1 -1
  75. package/dist/types/components/AutoPatternsCollectionPageContent/SkeletonCollection.d.ts +5 -0
  76. package/dist/types/components/AutoPatternsCollectionPageContent/SkeletonCollection.d.ts.map +1 -0
  77. package/dist/types/components/AutoPatternsEntityPage/SkeletonEntity.d.ts +7 -0
  78. package/dist/types/components/AutoPatternsEntityPage/SkeletonEntity.d.ts.map +1 -0
  79. package/dist/types/components/AutoPatternsRoute/AutoPatternsPage.d.ts.map +1 -1
  80. package/dist/types/hooks/useBaseTableFeatures.d.ts +1 -1
  81. package/dist/types/hooks/useBaseTableFeatures.d.ts.map +1 -1
  82. package/dist/types/hooks/useCollectionPageOnRowClickActions.d.ts +7 -0
  83. package/dist/types/hooks/useCollectionPageOnRowClickActions.d.ts.map +1 -0
  84. package/dist/types/hooks/useTableFeatures.d.ts +1 -1
  85. package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +1 -1
  86. package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -2
  87. package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
  88. package/dist/types/providers/SchemaContext.d.ts +2 -1
  89. package/dist/types/providers/SchemaContext.d.ts.map +1 -1
  90. package/dist/types/types/CollectionPageConfig.d.ts +2 -1
  91. package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
  92. package/dist/types/types/actions/base.d.ts +1 -0
  93. package/dist/types/types/actions/base.d.ts.map +1 -1
  94. package/dist/types/types/actions/collectionPageActions.d.ts +8 -0
  95. package/dist/types/types/actions/collectionPageActions.d.ts.map +1 -1
  96. package/dist/types/utils/actions/resolveAction.d.ts +1 -0
  97. package/dist/types/utils/actions/resolveAction.d.ts.map +1 -1
  98. package/dist/types/utils/actions/types.d.ts +1 -0
  99. package/dist/types/utils/actions/types.d.ts.map +1 -1
  100. package/package.json +26 -20
@@ -0,0 +1,2467 @@
1
+ # AI Agent Instructions for AutoPatternsApp
2
+
3
+ This document serves as a comprehensive guide for AI agents to correctly generate and validate configurations for the `AutoPatternsApp` component. Follow these instructions sequentially to ensure proper implementation.
4
+
5
+ ## AI Usage Guidelines
6
+
7
+ 1. **Configuration Generation Process**:
8
+
9
+ * First, analyze the schema requirements.
10
+ * Then, select appropriate fields based on data types.
11
+ * Finally, validate against the rules before output.
12
+
13
+ 2. **Required Validation Steps**:
14
+
15
+ * Verify exact page count (must be 2).
16
+ * Confirm proper field selection (max 3 columns initially).
17
+ * Check all mandatory fields are present.
18
+ * Ensure no unsupported fields are included.
19
+ * Verify that every collection page has a create action that navigates to the entity page.
20
+
21
+ 3. **Decision-Making Priority**:
22
+
23
+ * User explicit requirements override defaults.
24
+ * Schema structure guides field selection.
25
+ * Best practices determine presentation.
26
+
27
+ 4. **Enum Configuration Rule (CRITICAL)**:
28
+
29
+ * When generating `enumConfig` (whether implicitly as part of another rule or explicitly upon user request), the AI **must always ask the user to provide the possible option values** for the enum field.
30
+ * The `value` of each option can be **any string specified by the user**, and the `label` should be derived from the `value` (e.g., if `value` is "dog", the `label` can be "Dog").
31
+ * The AI is strictly prohibited from guessing, inventing, or assuming the enum values or their labels.
32
+
33
+ ---
34
+
35
+ # Core Rules
36
+
37
+ ## Configuration Rules
38
+
39
+ * Pages array MUST contain exactly two pages.
40
+ * Components array inside collectionPage MUST contain exactly one component with a layout array.
41
+ * Configuration MUST come only from a JSON file.
42
+ * DO NOT fill optional fields unless explicitly requested.
43
+ * Select up to 3 columns initially that best represent the entity.
44
+ * Every collection page MUST include a create action that allows users to create new entities by navigating to the entity page.
45
+
46
+ ## Type Binding Rules
47
+
48
+ * If `type: 'collectionPage'`, only `collectionPage` field should exist.
49
+ * If `type: 'entityPage'`, only `entityPage` field should exist.
50
+ * No cross-mixing of types is allowed.
51
+
52
+ ## Override Rules
53
+
54
+ * Custom overrides are restricted to documented areas only.
55
+ * Only override columns when specific rendering is required.
56
+
57
+ ## Validation Rules
58
+
59
+ * All configurations must align with AppConfig Structure.
60
+ * Remove any configuration entries not in the structure.
61
+ * Verify customColumns.enabled logic (>5 columns or explicit request).
62
+
63
+ ---
64
+
65
+ # Instruction Guide & Best Practices
66
+
67
+ This guide instructs on how to correctly integrate the `AutoPatternsApp` component from `@wix/auto-patterns` package into a Wix-based admin page.
68
+
69
+ ---
70
+
71
+ # Component Purpose
72
+
73
+ The `AutoPatternsApp` is a page-level component used to display a data collection either as a Table or Grid.
74
+ It is configured using a JSON file conforming to the `AppConfig` interface and supports overrides for advanced use-cases.
75
+
76
+ ---
77
+
78
+ # AppConfig Structure
79
+
80
+ ## ⚠️ Configuration Rules
81
+
82
+ - **Configuration must come only from a JSON file** - never inline or from other sources
83
+ - **DO NOT fill optional fields unless explicitly requested** - leave optional properties undefined to avoid unnecessary complexity
84
+ - **After each configuration change, verify that the configuration strictly aligns with the structure described below** - any configuration entries not defined in this structure must be removed
85
+ - **When generating config for the first time, select up to 3 columns from the schema that best represent the entity**
86
+
87
+ ## ⚠️ Common Configuration Mistakes to Avoid
88
+
89
+ - Adding more than two pages
90
+ - Mixing page types in a single configuration
91
+ - Including undefined optional fields
92
+ - Selecting too many initial columns
93
+ - Not designating exactly one page as `appMainPage: true`
94
+ - Missing or inconsistent page relationships (parentPageId/entityPageId)
95
+ - Setting `stickyColumns` to invalid values (negative, zero, or exceeding column count)
96
+
97
+ ```ts
98
+ export interface AppConfig {
99
+ pages: {
100
+ id: string; // Page unique identifier (must be unique across the app)
101
+ type: 'collectionPage' | 'entityPage'; // Defines page type
102
+ appMainPage?: boolean; // Designates this page as the main page (exactly one page must have this set to true)
103
+ collectionPage?: {
104
+ route: {
105
+ path: string; // Route path for the collection page (e.g., '/')
106
+ };
107
+ title: {
108
+ text: string; // Main page title
109
+ hideTotal?: boolean; // Hide total items in header. Default: true
110
+ };
111
+ subtitle?: {
112
+ text: string; // Optional page subtitle
113
+ };
114
+ actions?: { // Defines page-level actions for the collection page
115
+ primaryActions?: {
116
+ type: 'action' | 'menu'; // Type of primary actions layout
117
+ action?: { // Required when type is 'action'
118
+ item: {
119
+ id: string; // Unique identifier for the action
120
+ type: 'create' | 'custom'; // Action type
121
+ label?: string; // Text displayed for the action
122
+ collection: {
123
+ collectionId: string; // ID of the Wix Data collection
124
+ entityTypeSource: 'cms'; // Data source type. Always 'cms'
125
+ };
126
+ create?: { // Required when type is 'create'
127
+ mode: 'page'; // Create mode
128
+ page: {
129
+ id: string; // Entity page ID to navigate to for creation
130
+ };
131
+ };
132
+ };
133
+ };
134
+ menu?: { // Required when type is 'menu'
135
+ label: string; // Label for the group
136
+ items: {}[]; // Array of action configurations, same structure as action.item, can include dividers
137
+ };
138
+ };
139
+ secondaryActions?: {
140
+ type: 'action' | 'menu'; // Type of secondary actions layout, same structure as primaryActions
141
+ action?: {}; // Same structure as primaryActions.action
142
+ menu?: {}; // Same structure as primaryActions.menu
143
+ };
144
+ };
145
+ components: [
146
+ {
147
+ entityPageId?: string; // ID of the entity page to navigate to when clicking a row
148
+ collection: {
149
+ collectionId: string; // ID of the Wix Data collection
150
+ entityTypeSource: 'cms'; // Data source type. Always 'cms'
151
+ reflectQueryInUrl?: boolean; // Reflects query state (search, filters, sorting) in the browser URL. Default: false
152
+ selectAllScope?: 'page' | 'all'; // Controls "Select All" scope. 'all' selects entire collection, 'page' selects only visible items. Default: 'all'
153
+ selectionUpdateMode?: 'preserve' | 'clear'; // Controls selection behavior when data changes. 'preserve' maintains selections, 'clear' clears them. Default: 'clear'
154
+ };
155
+ filters?: {
156
+ panelTitle?: string; // Title of the filters panel
157
+ items: {
158
+ id: string; // Unique identifier for the filter item
159
+ fieldId: string; // ID of the field to filter by (must be a valid type: NUMBER, DATETIME, BOOLEAN, ARRAY, ARRAY_STRING)
160
+ displayName?: string; // Display name of the filter item
161
+ openByDefault?: boolean; // Whether the filter item is open by default in the panel (accordion is open)
162
+ sectionTitle?: string; // Title of the filter section. Required if more than one section exists to prevent confusion
163
+ tagLabel?: string; // Label shown in Tag component in the table/grid when the filter is applied (e.g., "Age: 7")
164
+ numberConfig?: {
165
+ min?: number; // Minimum value
166
+ max?: number; // Maximum value
167
+ allowedDecimals?: true; // Decimal precision allowed
168
+ };
169
+ dateConfig?: {
170
+ mode?: 'ONLY_PREDEFINED' | 'ONLY_CUSTOM' | 'COMBINE'; // Determines filter behavior
171
+ presets?: (
172
+ | 'SEVEN_DAYS'
173
+ | 'FOURTEEN_DAYS'
174
+ | 'MONTH'
175
+ | 'TODAY'
176
+ | 'TOMORROW'
177
+ | 'NEXT_THREE_DAYS'
178
+ | 'NEXT_SEVEN_DAYS'
179
+ | 'NEXT_THIRTY_DAYS'
180
+ )[]; // Shown only if mode includes predefined presets (COMBINE or ONLY_PREDEFINED)
181
+ includeTime?: boolean; // Whether to allow time selection. Default is true
182
+ };
183
+ booleanConfig?: {
184
+ trueLabel?: string; // Label shown for the true value
185
+ falseLabel?: string; // Label shown for the false value
186
+ };
187
+ enumConfig?: {
188
+ options: {
189
+ value: string; // Enum option value
190
+ label: string; // Enum option label
191
+ }[];
192
+ selectionMode: 'single' | 'multiple'; // Selection behavior
193
+ optionType?:
194
+ | 'checkbox'
195
+ | 'inlineCheckbox'
196
+ | 'radio'
197
+ | 'select'; // Option rendering style
198
+ };
199
+ }[];
200
+ };
201
+ actionCell?: {
202
+ primaryAction?: {
203
+ item: {
204
+ id: string; // Unique identifier for the action
205
+ type: 'update' | 'delete' | 'custom'; // Action type
206
+ label?: string; // Text displayed for the action
207
+ skin?: string; // Visual appearance of the action button (see Action Button Skin Values section)
208
+ disabled?: boolean; // Whether the action is disabled
209
+ tooltip?: string; // Tooltip text shown on hover
210
+ update?: { // Required when type is 'update'
211
+ mode: 'page'; // Update mode
212
+ page?: { // Required when mode is 'page'
213
+ id: string; // Entity page ID to navigate to
214
+ };
215
+ };
216
+ delete?: { // Required when type is 'delete'
217
+ mode: 'modal'; // Currently only 'modal' is supported
218
+ modal: {
219
+ title?: {
220
+ text: string; // Modal title
221
+ };
222
+ description?: {
223
+ text: string; // Modal description
224
+ };
225
+ actions?: {
226
+ submit?: {
227
+ text: string; // Submit button text
228
+ };
229
+ cancel?: {
230
+ text: string; // Cancel button text
231
+ };
232
+ };
233
+ feedback?: {
234
+ successToast?: {
235
+ text: string; // Success message
236
+ };
237
+ errorToast?: {
238
+ text: string; // Error message
239
+ };
240
+ };
241
+ };
242
+ };
243
+ };
244
+ };
245
+ secondaryActions?: {
246
+ items: {}[]; // Array of action configurations, same structure as primaryAction.item, can include dividers
247
+ inlineCount?: number; // How many secondary actions to show inline before showing popover
248
+ inlineAlwaysVisible?: boolean; // Whether to always show inline actions (not just on hover)
249
+ };
250
+ };
251
+ bulkActionToolbar?: {
252
+ primaryActions?: ({
253
+ type: 'action' | 'menu'; // Type of bulk action item
254
+ action?: { // Required when type is 'action'
255
+ item: {
256
+ id: string; // Unique identifier for the bulk action
257
+ type: 'bulkDelete' | 'custom'; // Bulk action type
258
+ label?: string; // Text displayed for the action
259
+ bulkDelete?: { // Required when type is 'bulkDelete'
260
+ mode: 'modal'; // Currently only 'modal' is supported
261
+ modal: {
262
+ title?: {
263
+ text: string; // Modal title
264
+ };
265
+ description?: {
266
+ text: string; // Modal description
267
+ };
268
+ actions?: {
269
+ submit?: {
270
+ text: string; // Submit button text
271
+ };
272
+ cancel?: {
273
+ text: string; // Cancel button text
274
+ };
275
+ };
276
+ feedback?: {
277
+ successToast?: {
278
+ text: string; // Success message
279
+ };
280
+ errorToast?: {
281
+ text: string; // Error message
282
+ };
283
+ };
284
+ };
285
+ };
286
+ };
287
+ };
288
+ menu?: { // Required when type is 'menu'
289
+ label: string; // Label for the dropdown group
290
+ items: {}[] // Array of bulk actions configurations, same structure as action.item, can include dividers
291
+ };
292
+ })[];
293
+ secondaryActions?: {}[]; // Array of bulk actions configurations, same structure as primaryActions[].menu.items, can include dividers
294
+ };
295
+ toolbarTitle?: {
296
+ title: string; // Toolbar title above the table/grid
297
+ subtitle?: {
298
+ text: string; // Toolbar subtitle
299
+ };
300
+ showTotal?: boolean; // Show total items on toolbar. Default: false
301
+ };
302
+ search?: {
303
+ shown?: boolean; // Show/hide the search
304
+ };
305
+ emptyState?: {
306
+ title?: string; // Empty state title
307
+ subtitle?: string; // Empty state subtitle
308
+ image?: {
309
+ id: string; // Image ID for empty state
310
+ };
311
+ addNewCta?: {
312
+ id?: string; // Add New CTA ID
313
+ text?: string; // Add New CTA text
314
+ };
315
+ customCta?: {
316
+ id?: string; // Custom CTA ID
317
+ };
318
+ };
319
+ layout: [ // Array of layout items that define what components to render
320
+ {
321
+ type: 'Table'; // Layout item type for table rendering
322
+ table?: {
323
+ columns: {
324
+ id: string; // Field ID from the collection
325
+ name: string; // Column title displayed
326
+ width: string; // The width of the column (required in types)
327
+ sortable?: boolean; // If the column is sortable
328
+ defaultSortOrder?: 'asc' | 'desc'; // Optional default sort order
329
+ sortMode?: 'asc' | 'desc'; // Optional sorting mode
330
+ reorderDisabled?: boolean; // Whether column reordering is disabled
331
+ hideable?: boolean; // Whether column can be hidden
332
+ defaultHidden?: boolean; // Whether column is hidden by default
333
+ hiddenFromCustomColumnsSelection?: boolean; // Whether column is hidden from custom columns selection
334
+ }[];
335
+ customColumns?: {
336
+ enabled: boolean; // Enable user customization (hide/reorder columns)
337
+ };
338
+ stickyColumns?: number; // Number of columns to make sticky from the start. Sticky columns remain visible when horizontally scrolling.
339
+ };
340
+ },
341
+ {
342
+ type: 'Grid'; // Layout item type for grid rendering
343
+ grid?: {
344
+ item: {
345
+ titleFieldId: string; // Field ID to display as the item title
346
+ subtitleFieldId?: string; // Field ID for the item subtitle
347
+ imageFieldId?: string; // Field ID for the item image
348
+ /**
349
+ * Controls which content is shown in the card (preset):
350
+ * - 'full': Shows both title and subtitle.
351
+ * - 'title': Shows only the title.
352
+ * - 'empty': Hides both title and subtitle (card appears visually empty except for image or other content).
353
+ */
354
+ cardContentMode?: 'full' | 'title' | 'empty';
355
+ imagePlacement?: 'top' | 'side';
356
+ };
357
+ };
358
+ }
359
+ ]; // End of layout array
360
+ }
361
+ ]; // End of components array
362
+ };
363
+ entityPage?: {
364
+ route: {
365
+ path: string; // Route path for the entity page (e.g., '/product/:entityId')
366
+ params: {
367
+ id: string; // Maps dynamic parameter in path to its identifier
368
+ };
369
+ };
370
+ title?: {
371
+ text: string; // Entity page title
372
+ };
373
+ subtitle?: {
374
+ text: string; // Entity page subtitle
375
+ };
376
+ parentPageId?: string; // ID of the parent collection page
377
+ layout?: {
378
+ // Main layout section
379
+ main: {
380
+ type: 'card'; // Type of the card
381
+ card: {
382
+ title: {
383
+ text: string; // Title of the card
384
+ };
385
+ subtitle?: {
386
+ text: string; // Subtitle of the card
387
+ };
388
+ children: LayoutContent[]; // Array of content items that can be fields, nested containers, or components
389
+ };
390
+ }[];
391
+ // Sidebar layout section
392
+ sidebar?: {
393
+ type: 'card';
394
+ card: {
395
+ title: {
396
+ text: string; // Title of the card
397
+ };
398
+ subtitle?: {
399
+ text: string; // Subtitle of the card
400
+ };
401
+ children: LayoutContent[]; // Array of content items that can be fields, nested containers, or components
402
+ };
403
+ }[];
404
+ };
405
+ collectionId: string; // Related collection ID
406
+ entityTypeSource: 'cms'; // Data source type. Always 'cms'
407
+ };
408
+ }[];
409
+ }
410
+
411
+ type LayoutContent =
412
+ | {
413
+ type: 'field';
414
+ field: {
415
+ span?: number;
416
+ fieldId: string;
417
+ };
418
+ }
419
+ | {
420
+ type: 'container';
421
+ container: {
422
+ span?: number;
423
+ children: LayoutContent[];
424
+ };
425
+ }
426
+ | {
427
+ type: 'component';
428
+ component: {
429
+ span?: number;
430
+ componentId: string;
431
+ };
432
+ };
433
+ ```
434
+
435
+ ---
436
+
437
+ # Pages Configuration
438
+
439
+ ## ⚠️ Critical Page Rules
440
+
441
+ - **Pages array must contain exactly two pages** - one collectionPage and one entityPage
442
+ - **Exactly one page must have `appMainPage: true`** to designate it as the main page
443
+ - **All page IDs referenced in relationships must exist in the configuration** - validate all `parentPageId` and `entityPageId` references
444
+ - **Bind `type` strictly to matching fields** - if `type: 'collectionPage'`, only `collectionPage` field exists (no `entityPage` field), and vice versa
445
+
446
+ ## Default Generation
447
+
448
+ * **Always generate two pages**:
449
+
450
+ * One **collectionPage** (routePath: `/`)
451
+ * One **entityPage** (routePath: `/[segment]/:entityId`)
452
+
453
+ * Always use `entityId` as the dynamic URL parameter, not `id`.
454
+ * The route path **must** include a descriptive segment (e.g., `/product/:entityId`, `/pet/:entityId`)
455
+ * **Never use just `/:entityId`** - this conflicts with the collection page route and breaks routing
456
+
457
+ ## Type and Structure Binding
458
+
459
+ * If `type: 'collectionPage'`, then **only** `collectionPage` field exists (no `entityPage` field).
460
+ * If `type: 'entityPage'`, then **only** `entityPage` field exists (no `collectionPage` field).
461
+ * **No cross-mixing** allowed.
462
+
463
+ ## Page Connection Configuration
464
+
465
+ ### Main Page Designation
466
+
467
+ * One page must be designated as the main page using the `appMainPage` property:
468
+ * **Exactly one page** must have `appMainPage: true`
469
+ * When users navigate to the root path (`/`), they will be automatically redirected to this page
470
+ * This is typically set on the collection page, but can be any page based on your application's requirements
471
+
472
+ ### Collection-Entity Page Relationships
473
+
474
+ A two-way connection must be established between collection pages and entity pages:
475
+
476
+ 1. **From EntityPage to CollectionPage**:
477
+ * Each entity page must specify its parent collection page using `parentPageId`
478
+ * This property on the entity page references the `id` of its parent collection page
479
+
480
+ 2. **From CollectionPage to EntityPage**:
481
+ * Each collection page's component must reference its corresponding entity page:
482
+ * Inside the table or grid configuration (not directly in the collectionPage), specify `entityPageId` pointing to the entity page's `id`:
483
+ ```json
484
+ "components": [
485
+ {
486
+ "type": "Table", // or "Grid"
487
+ "table": { // or "grid"
488
+ "entityPageId": "my-entity-page-id",
489
+ // other table/grid configuration
490
+ }
491
+ }
492
+ ]
493
+ ```
494
+ * ⚠️ **IMPORTANT**: The `entityPageId` field is located within the specific component configuration (table or grid), not at the collection page level
495
+
496
+ ### Entity Page URL Configuration
497
+
498
+ * For entity pages (`type: "entityPage"`), the following URL configuration is **mandatory**:
499
+
500
+ 1. **Route Path Structure**:
501
+ * The `route.path` **must** include a relative path segment followed by a dynamic parameter (e.g., `/product/:entityId` or `/pets/:entityId`)
502
+ * **Never use just `/:entityId`** - this conflicts with the collection page route `/` and breaks routing
503
+ * The relative path segment should be descriptive of the entity type (e.g., `/product/`, `/pet/`, `/user/`)
504
+ * This parameter is typically named `:entityId` by convention, but any parameter name prefixed with `:` is valid
505
+
506
+ 2. **Route Parameters Mapping**:
507
+ * The `route.params` property is required and must map the dynamic parameter:
508
+ ```json
509
+ "route": {
510
+ "path": "/product/:entityId",
511
+ "params": {
512
+ "id": "entityId"
513
+ }
514
+ }
515
+ ```
516
+ * The `id` field in `route.params` must match the parameter name used in `route.path` (without the colon)
517
+
518
+
519
+ ### Key Rules for Page Connections
520
+
521
+ * **Main Page Requirement**: Exactly one page must have `appMainPage: true`
522
+ * **Reference Validity**: All page IDs referenced in `parentPageId` and `entityPageId` must exist in the configuration
523
+ * **Relationship Consistency**: The two-way connection must be consistent - if entity page A points to collection page B, then collection page B must point to entity page A
524
+ * **Route Structure**: Entity pages must use `/[segment]/:entityId` format (e.g., `/product/:entityId` or `/pets/:entityId`), never just `/:entityId`
525
+ * **Route Parameters Configuration**: All entity pages must have both a dynamic parameter in `route.path` and a matching configuration in `route.params`
526
+
527
+ ## ⚠️ Common Type and Route Mistakes to Avoid
528
+
529
+ - Using incorrect field types
530
+ - Missing required fields
531
+ - Including fields from wrong page type
532
+ - Missing route.params for entity pages
533
+ - Using `/:entityId` instead of `/segment/:entityId` for entity page routes (causes routing conflicts)
534
+
535
+ # Sticky Columns Configuration
536
+
537
+ ## Overview
538
+
539
+ Sticky columns allow you to keep specific columns visible while users scroll horizontally through wide tables. This feature improves usability by ensuring important information (like names or IDs) remains accessible during scrolling.
540
+
541
+ ## Configuration Properties
542
+
543
+ ### stickyColumns
544
+
545
+ - **Type**: `number` (optional)
546
+ - **Description**: Number of columns to make sticky from the start of the table
547
+ - **Behavior**: Sticky columns are always the **first N columns** in the `columns` array
548
+ - **Default**: `undefined` (no sticky columns)
549
+
550
+ ## Key Behavior Rules
551
+
552
+ ### 🔑 **Critical Rule: Position-Based Stickiness**
553
+ - `stickyColumns: 2` means "make the **first 2 columns** sticky" (positions 0 and 1 in the `columns` array)
554
+ - The sticky columns are determined by **array position**, not by column content
555
+ - If columns are reordered, the sticky behavior follows the new order
556
+
557
+ ### 🔒 **Important: Reorder Protection**
558
+ - To protect specific columns from being reordered away from their sticky positions, set `reorderDisabled: true` on those columns
559
+ - This allows `customColumns.enabled: true` while protecting sticky columns from being moved
560
+ - Without reorder protection, users can accidentally move intended sticky columns away from the beginning
561
+
562
+ ### ⚠️ **Validation Rules**
563
+ - `stickyColumns` must be a positive number
564
+ - `stickyColumns` should not exceed the total number of columns
565
+ - Invalid values are ignored (treated as `undefined`)
566
+
567
+ ---
568
+
569
+ # Collection Page Configuration
570
+
571
+ ## ⚠️ Collection Page Rules
572
+
573
+ - **Components array inside collectionPage must contain exactly one component with a layout array**
574
+ - **All collection pages with tables/grids must reference their corresponding entity page via `entityPageId`** in the collection configuration
575
+ - **Enable `customColumns` only based on strict logic** - enable if more than 5 columns are defined OR user explicitly requests it, otherwise disable
576
+ - **Row click behavior**: By default, clicking a table row navigates to the entity page. Use `onRowClick` configuration only when custom row click behavior is explicitly required
577
+ - **When generating config for first time, select up to 3 columns from the schema that best represent the entity**
578
+
579
+ ## Components Array
580
+
581
+ * Must include **exactly one item**.
582
+ * Each component must have:
583
+ * `collection`: Collection configuration with `collectionId` and `entityTypeSource: 'cms'`
584
+ * `layout`: Array of layout items that determine what components to render
585
+
586
+ ## Layout Array
587
+
588
+ The `layout` array contains the rendering components for the collection. Each layout item has:
589
+ * `type`: Either 'Table' or 'Grid'
590
+ * Component-specific configuration (`table` or `grid` object)
591
+
592
+ ### Layout Item Types:
593
+
594
+ 1. **Table Layout Item** (`type: 'Table'`):
595
+ * `table` field contains table-specific configuration
596
+ * Used for displaying collection in a **table view**
597
+ * Includes columns, actionCell, bulkActionToolbar, etc.
598
+
599
+ 2. **Grid Layout Item** (`type: 'Grid'`):
600
+ * `grid` field contains grid-specific configuration
601
+ * Used for **grid (card) view** of collection
602
+ * Includes item configuration for title/subtitle/image fields
603
+
604
+ ### Table/Grid View Switch Behavior:
605
+ * When **both** Table and Grid layout items are present in the layout array, AutoPatterns automatically adds a Table/Grid view switch control so users can toggle between the two views
606
+ * Users can toggle between table and grid views
607
+
608
+ ## Table Configuration
609
+
610
+ * Used for displaying collection in a **table view**.
611
+ * **customColumns.enabled** logic:
612
+ * Enable if:
613
+ * More than **5 columns** are defined
614
+ * OR user **explicitly** requests it
615
+ * Otherwise, **disable** (false)
616
+
617
+ ## Grid Configuration
618
+
619
+ * Used for **grid (card) view** of collection.
620
+ * `item.title`, `item.subtitle`, `item.image` fields are **Field IDs** from the schema.
621
+ * If the user does not specify, **select the most relevant fields automatically**.
622
+ * 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.
623
+
624
+ ---
625
+
626
+ # Collection Page Actions
627
+
628
+ ## ⚠️ Required Actions
629
+
630
+ - **Every collection page must include a create action that navigates to the entity page for adding new entities** - this is essential for user workflow
631
+
632
+ The `actions` property is an optional object within the `collectionPage` configuration, but it is strongly recommended to always include primaryActions with a create action for better user experience.
633
+
634
+ ## `primaryActions` and `secondaryActions` Structure
635
+
636
+ Both `primaryActions` and `secondaryActions` are optional and share the same underlying structure for defining how actions are displayed. They can be configured in one of two ways:
637
+
638
+ ### A. Action Layout (`type: "action"`)
639
+ * **Description**: This layout is used to display a single, prominent page-level action. For example, a "Create New Item" button.
640
+ * **`action.item`**: Contains the configuration for the single action.
641
+
642
+ ### B. Action Menu Layout (`type: "menu"`)
643
+ * **Description**: This layout groups several page-level actions, often rendered as a dropdown menu or a set of related buttons under a common label.
644
+ * **`menu.label`**: A string that serves as the title or accessible label for the group of actions.
645
+ * **`menu.items`**: A flat array of action configurations, which can include divider objects for visual separation.
646
+
647
+ ## Individual Action Configuration
648
+
649
+ Each individual action, whether standalone in an `action` layout or part of an `items` array in a `menu` layout, is defined by the action item structure (see `AppConfig Structure`).
650
+
651
+ In addition to these common properties, each action item must specify a `type` which determines the action's behavior and additional required configuration.
652
+
653
+ ### 1. `type: "create"`
654
+ * **Purpose**: Navigates to an entity page, allowing the user to create a new item in the specified collection.
655
+ * **Details**:
656
+ * `create.mode`: Must be `'page'`.
657
+ * `create.page.id`: Must be the `id` of an existing `entityPage` in your `AppConfig`. This entity page should be set up to handle the creation of new entities for the `collection.collectionId`.
658
+
659
+ ### 2. `type: "custom"`
660
+ * **Purpose**: Executes custom JavaScript logic defined in your application's overrides.
661
+ * **Details**:
662
+ * The `custom` object in the configuration is typically empty. The functionality is determined by a custom action resolver function that you implement and register in the `actions` section of your `PatternsWizardOverridesProvider`. The `id` of this action item must exactly match the name (key) of the registered custom action resolver. The resolver will receive parameters including `collectionId`.
663
+
664
+ ### 3. `type: "divider"`
665
+ * **Purpose**: Creates a visual separator between action groups in menus and lists.
666
+ * **Details**:
667
+ * Divider actions require no additional configuration beyond `{ "type": "divider" }`.
668
+ * Used within flat arrays to create logical groupings.
669
+
670
+ ## Note on `secondaryActions`
671
+
672
+ `secondaryActions` follow the exact same structural rules (`type: "action"` or `type: "menu"`) and use the same action item options as `primaryActions`. They are typically used for less prominent or less frequently used page-level actions, often rendered in a secondary position or within a "more options" style menu.
673
+
674
+ ## Custom Collection Page Action Configuration
675
+
676
+ Custom collection page actions execute JavaScript code that you define for collection-level operations. These actions receive parameters that give them access to collection context and utilities. Here's how to implement a custom collection page action:
677
+
678
+ 1. First, create the actions folder structure in your page folder:
679
+ ```
680
+ your-page/
681
+ ├── page.tsx
682
+ └── components/
683
+ └── actions/
684
+ ├── index.tsx // Exports all actions
685
+ └── exportCollection.tsx // Your custom collection action
686
+ ```
687
+
688
+ 2. Create your collection action handler in `exportCollection.tsx`:
689
+ ```typescript
690
+ import { CustomActionCollectionPageActionResolver } from '@wix/auto-patterns';
691
+ import React from 'react';
692
+ import { Download } from '@wix/ui-icons-common';
693
+
694
+ // IMPORTANT: Function name MUST match the action id in your configuration
695
+ export const exportCollection: CustomActionCollectionPageActionResolver = (params) => {
696
+ const { actionParams, sdk } = params;
697
+ const { collectionId } = actionParams;
698
+
699
+ return {
700
+ label: 'Export Collection',
701
+ icon: <Download />,
702
+ onClick: () => {
703
+ // sdk is provided to custom action resolvers (see SDK Utilities section)
704
+ const optimisticActions = sdk.getOptimisticActions(collectionId);
705
+ const schema = sdk.getSchema(collectionId);
706
+
707
+ // Example: Mark entire collection as exported
708
+ optimisticActions.updateAll(
709
+ (item) => ({ lastExported: new Date() }),
710
+ {
711
+ submit: async () => {
712
+ // Your collection export logic here
713
+ console.log(`Exporting collection: ${collectionId}`);
714
+ // Export and update all items on server
715
+ return await schema.actions.bulkUpdate({ lastExported: new Date() });
716
+ },
717
+ successToast: 'Collection exported successfully',
718
+ errorToast: (err, {retry}) => ({
719
+ text: 'Export failed',
720
+ action: { text: 'Retry', onClick: retry }
721
+ })
722
+ }
723
+ );
724
+ },
725
+ };
726
+ };
727
+ ```
728
+
729
+ 3. Export your action in `actions/index.tsx`:
730
+ ```typescript
731
+ export * from './exportCollection';
732
+ ```
733
+
734
+ 4. Configure the action in your JSON configuration:
735
+ ```json
736
+ {
737
+ "id": "exportCollection", // MUST match the function name exactly
738
+ "type": "custom", // REQUIRED: Must be exactly "custom"
739
+ "label": "Export Collection", // Optional: Displayed text
740
+ "collection": {
741
+ "collectionId": "WixPets",
742
+ "entityTypeSource": "cms"
743
+ }
744
+ }
745
+ ```
746
+
747
+ 5. Register your action in the `PatternsWizardOverridesProvider`:
748
+ ```typescript
749
+ import * as actions from './components/actions';
750
+
751
+ <PatternsWizardOverridesProvider value={{ actions }}>
752
+ <AutoPatternsApp configuration={config as AppConfig} />
753
+ </PatternsWizardOverridesProvider>
754
+ ```
755
+
756
+ ## Key Points for Custom Collection Page Actions:
757
+ - The action `id` in the configuration MUST exactly match the function name exported from your actions folder
758
+ - The function name and file name should follow a consistent naming convention (e.g., camelCase)
759
+ - The implementation must be exported as a named export (not default export)
760
+ - The implementation must use the `CustomActionCollectionPageActionResolver` type
761
+ - Access collection context through `actionParams.collectionId`
762
+
763
+ ---
764
+
765
+ ## Custom Row Click Actions
766
+
767
+ In addition to page-level actions, you can also customize what happens when users click on individual rows in your collection table. By default, clicking a row navigates to the entity page, but you can override this behavior with custom logic.
768
+
769
+ **Before You Start:**
770
+ - Only configure `onRowClick` if you need custom behavior (e.g., opening modals, side panels, custom actions)
771
+ - If you just want navigation to entity page, don't configure `onRowClick` - it's the default behavior
772
+ - Once you configure `onRowClick`, you must provide a complete working implementation
773
+
774
+ ### Configuration
775
+
776
+ Row click actions are configured at the table level using the `onRowClick` property:
777
+
778
+ ```json
779
+ {
780
+ "type": "Table",
781
+ "table": {
782
+ "columns": [...],
783
+ "onRowClick": {
784
+ "id": "handleRowClick", // MUST match the function name exactly
785
+ "type": "custom", // REQUIRED: Must be exactly "custom"
786
+ }
787
+ }
788
+ }
789
+ ```
790
+
791
+ ### Implementation Requirements
792
+
793
+ ⚠️ **CRITICAL**: When you configure `onRowClick` in your JSON, you MUST provide a complete working implementation. The Auto Patterns framework cannot function without it.
794
+
795
+ Custom row click actions use the `CustomActionCollectionPageActionOnRowClickResolver` type and MUST return a `ResolvedAction` object with all required properties:
796
+
797
+ #### Required Return Object Structure:
798
+ ```typescript
799
+ return {
800
+ label: string, // REQUIRED: Action label
801
+ icon: ReactElement, // REQUIRED: Icon component
802
+ onClick: () => void // REQUIRED: Click handler function
803
+ };
804
+ ```
805
+
806
+ #### Complete Implementation Example:
807
+
808
+ ```typescript
809
+ import { CustomActionCollectionPageActionOnRowClickResolver } from '@wix/auto-patterns';
810
+ import React from 'react';
811
+ import { More } from '@wix/wix-ui-icons-common';
812
+
813
+ // IMPORTANT: Function name MUST match the action id in your configuration
814
+ export const handleRowClick: CustomActionCollectionPageActionOnRowClickResolver = (params) => {
815
+ const { actionParams, sdk } = params;
816
+ const { item } = actionParams; // The clicked row's data
817
+
818
+ return {
819
+ label: 'View Details', // REQUIRED
820
+ icon: <More />, // REQUIRED
821
+ onClick: () => { // REQUIRED
822
+ // Your custom row click logic here
823
+ console.log('Row clicked:', item);
824
+
825
+ // Example: Show a custom modal, perform an action, etc.
826
+ // You can access all SDK utilities here (see SDK Utilities section)
827
+ const optimisticActions = sdk.getOptimisticActions(sdk.collectionId);
828
+ const schema = sdk.getSchema(sdk.collectionId);
829
+
830
+ // Your custom logic...
831
+ },
832
+ };
833
+ };
834
+ ```
835
+
836
+ ### Common Use Cases and Complete Examples
837
+
838
+ #### 1. Opening a Side Panel Modal
839
+
840
+ This is a complete working example for opening a side panel when clicking a row:
841
+
842
+ **Step 1: Create the row click action** (`components/actions/openSidePanel.tsx`):
843
+ ```typescript
844
+ import { CustomActionCollectionPageActionOnRowClickResolver } from '@wix/auto-patterns';
845
+ import React from 'react';
846
+ import { More } from '@wix/wix-ui-icons-common';
847
+
848
+ export const openSidePanel: CustomActionCollectionPageActionOnRowClickResolver = (params) => {
849
+ const { actionParams, sdk } = params;
850
+ const { item } = actionParams;
851
+
852
+ return {
853
+ label: 'View Details',
854
+ icon: <More />,
855
+ onClick: () => {
856
+ // Open a custom modal with the item data
857
+ // You need to implement the modal opening mechanism
858
+ // This could be through a modal context, state management, etc.
859
+ console.log('Opening side panel for:', item);
860
+
861
+ // Example: Using a global modal state (you need to implement this)
862
+ // window.dispatchEvent(new CustomEvent('openSidePanel', { detail: item }));
863
+
864
+ // Or use a modal service/context that you've set up
865
+ // modalService.openSidePanel(item);
866
+ },
867
+ };
868
+ };
869
+ ```
870
+
871
+ **Step 2: Configure in JSON**:
872
+ ```json
873
+ {
874
+ "type": "Table",
875
+ "table": {
876
+ "onRowClick": {
877
+ "id": "openSidePanel",
878
+ "type": "custom"
879
+ },
880
+ "columns": [...]
881
+ }
882
+ }
883
+ ```
884
+
885
+ **Step 3: Export and Register**:
886
+ ```typescript
887
+ // components/actions/index.tsx
888
+ export * from './openSidePanel';
889
+
890
+ // page.tsx
891
+ import * as actions from './components/actions';
892
+
893
+ <PatternsWizardOverridesProvider value={{ actions }}>
894
+ <AutoPatternsApp configuration={config as AppConfig} />
895
+ </PatternsWizardOverridesProvider>
896
+ ```
897
+
898
+ #### 2. Direct Data Manipulation
899
+
900
+ ```typescript
901
+ export const quickToggle: CustomActionCollectionPageActionOnRowClickResolver = (params) => {
902
+ const { actionParams, sdk } = params;
903
+ const { item } = actionParams;
904
+
905
+ return {
906
+ label: 'Quick Toggle',
907
+ icon: <Toggle />,
908
+ onClick: () => {
909
+ const optimisticActions = sdk.getOptimisticActions(sdk.collectionId);
910
+ const schema = sdk.getSchema(sdk.collectionId);
911
+
912
+ // Example: Toggle a boolean field
913
+ const updatedItem = { ...item, isActive: !item.isActive };
914
+
915
+ optimisticActions.updateOne(updatedItem, {
916
+ submit: async (items) => schema.actions.update(items[0]),
917
+ successToast: `${item.name} toggled successfully`,
918
+ errorToast: (err, {retry}) => ({
919
+ text: 'Toggle failed',
920
+ action: { text: 'Retry', onClick: retry }
921
+ })
922
+ });
923
+ },
924
+ };
925
+ };
926
+ ```
927
+
928
+ ### Default vs Custom Behavior
929
+
930
+ **Default Behavior (when `onRowClick` is not configured):**
931
+ - Clicking a row automatically navigates to the entity page
932
+ - Uses the `entityPageId` configuration to determine the target page
933
+ - Passes the selected item's data to the entity page
934
+
935
+ **Custom Behavior (when `onRowClick` is configured):**
936
+ - Default navigation is **disabled**
937
+ - Your custom action function is executed instead
938
+ - You have complete control over the row click behavior
939
+ - You can still navigate to the entity page programmatically if needed using the SDK navigation utilities
940
+
941
+ ### Key Points for Custom Row Click Actions:
942
+ - **MANDATORY IMPLEMENTATION**: If you configure `onRowClick` in JSON, you MUST provide a complete working implementation - the framework cannot function without it
943
+ - The action `id` in the configuration MUST exactly match the function name exported from your actions folder
944
+ - The implementation must use the `CustomActionCollectionPageActionOnRowClickResolver` type
945
+ - **Required Return Object**: Must return an object with `label`, `icon`, and `onClick` properties - all are required
946
+ - Access the clicked item's data through `actionParams.item`
947
+ - The implementation must be exported as a named export and registered in your `PatternsWizardOverridesProvider`
948
+ - When `onRowClick` is configured, the default navigation to entity page is completely disabled
949
+ - **Complete Setup Required**: You need to create the action file, export it in the index, and register it in the provider - missing any step will cause errors
950
+
951
+ ## Validation Checklist for Collection Page Actions
952
+
953
+ ✓ Every collection page must include a create action.
954
+ ✓ `actions` is an optional property of `collectionPage`.
955
+ ✓ `primaryActions` and `secondaryActions` (if defined) have a valid `type` ("action" or "menu").
956
+ ✓ If `type: "action"`, `action.item` is a valid action item configuration.
957
+ ✓ If `type: "menu"`, `menu.items` is an array of valid action item configurations that can include dividers.
958
+ ✓ Each action item contains a unique `id`, and the full `collection` object (`collectionId`, `entityTypeSource: 'cms'`).
959
+ ✓ Each action item has a supported `type` (`create`, `custom`) and its corresponding configuration block (e.g., `create` block for `type: "create"`).
960
+ ✓ `create` actions specify a `create.page.id` that matches an existing `entityPage` ID in the configuration.
961
+ ✓ `custom` actions (identified by their main `id`) correspond to an action resolver function name registered in the `actions` override.
962
+ ✓ Divider actions use `{ "type": "divider" }` format and require no additional properties.
963
+ ✓ If `onRowClick` is configured in table layout, it must have a valid `id` and `type: "custom"`.
964
+ ✓ **CRITICAL**: Custom row click actions must have corresponding implementations registered in the `actions` override - configuration without implementation will cause errors.
965
+ ✓ Custom row click action implementations must return an object with `label`, `icon`, and `onClick` properties - all are required.
966
+ ✓ Custom row click action implementations must be exported as named exports and included in the actions index file.
967
+ ✓ `onRowClick` is optional - when not configured, rows navigate to entity page by default.
968
+ ✓ **IMPORTANT**: Configuring `onRowClick` completely disables default navigation - you must handle all row click logic in your custom implementation.
969
+
970
+ ---
971
+
972
+ ## SDK Utilities
973
+
974
+ The `sdk` parameter provides access to Auto Patterns utilities and context. Available in custom actions across all action types (ActionCell, BulkActions, CollectionPage actions, and EntityPage Actions).
975
+
976
+ ### Key SDK Utilities
977
+ The only functions exist in sdk are:
978
+
979
+ • **closeModal** - `closeModal(): void`
980
+ - Closes the currently open modal
981
+ - Example: `sdk.closeModal()` after saving or canceling
982
+
983
+ • **getOptimisticActions** - `getOptimisticActions(collectionId): OptimisticActions`
984
+ - Provides optimistic UI updates for immediate user feedback
985
+ - Supports create, update, delete operations with automatic rollback on failure
986
+ - Example: `sdk.getOptimisticActions(sdk.collectionId).updateOne(item, { ... })`
987
+
988
+ • **getSchema** - `getSchema(collectionId): SchemaConfig | undefined`
989
+ - Access to collection schema information (fields, types, validation)
990
+ - Useful for dynamic operations based on collection structure
991
+ - Example: `const schema = sdk.getSchema(sdk.collectionId)`
992
+
993
+ • **collectionId** - `string`
994
+ - Current collection context identifier
995
+ - Available in all action contexts for referencing the active collection
996
+ - Example: `sdk.collectionId` to get the current collection ID
997
+
998
+ ---
999
+
1000
+ ## OptimisticActions
1001
+
1002
+ Provides immediate UI updates with automatic server synchronization and error recovery.
1003
+
1004
+ ### Usage Rules
1005
+
1006
+ **Use OptimisticActions for:**
1007
+ - Data modification operations (create, update, delete)
1008
+ - Operations requiring immediate visual feedback
1009
+
1010
+ **Do NOT use for:**
1011
+ - Read-only operations
1012
+ - Operations requiring server confirmation first
1013
+
1014
+ ### Core Pattern
1015
+
1016
+ ```typescript
1017
+ // Get instances from SDK (see SDK Utilities section)
1018
+ const optimisticActions = sdk.getOptimisticActions(sdk.collectionId);
1019
+ const schema = sdk.getSchema(sdk.collectionId);
1020
+
1021
+ optimisticActions.operation(items, {
1022
+ submit: async (items) => schema.actions.serverMethod(items),
1023
+ successToast: 'Success message',
1024
+ errorToast: (err, {retry}) => ({ text: 'Error message', action: { text: 'Retry', onClick: retry }})
1025
+ });
1026
+ ```
1027
+
1028
+ ### Available Operations
1029
+
1030
+ #### Create Operations
1031
+ - `createOne(item: T, params: OptimisticParams<T>): void`
1032
+ - `createMany(items: T[], params: OptimisticParams<T>): void`
1033
+
1034
+ #### Update Operations
1035
+ - `updateOne(item: T, params: OptimisticParams<T>): void`
1036
+ - `updateMany(items: T[], params: OptimisticParams<T>): void`
1037
+ - `updateAll(transformFn: (item: T) => Partial<T>, params: OptimisticParams<T>): void`
1038
+
1039
+ #### Delete Operations
1040
+ - `deleteOne(item: T, params: OptimisticParams<T> & { showUndoToast: true }): void`
1041
+ - `deleteMany(items: T[], params: OptimisticParams<T> & { showUndoToast: true }): void`
1042
+ - `deleteAll(params: OptimisticParams<T> & { showUndoToast: true }): void`
1043
+
1044
+ ### Type Definitions
1045
+
1046
+ ```typescript
1047
+ interface OptimisticParams<T> {
1048
+ submit: (items: T[]) => Promise<any>;
1049
+ successToast: string | ToastConfig;
1050
+ errorToast: (error: Error, actions: { retry: () => void }) => ToastConfig | string;
1051
+ showUndoToast?: boolean; // Required: true for delete operations
1052
+ }
1053
+
1054
+ interface ToastConfig {
1055
+ text: string;
1056
+ action?: { text: string; onClick: () => void };
1057
+ }
1058
+ ```
1059
+
1060
+ ### Validation Requirements
1061
+
1062
+ **Before using optimistic actions:**
1063
+ - Verify `sdk.getOptimisticActions(collectionId)` returns valid instance
1064
+ - Verify `sdk.getSchema(collectionId)` returns valid schema
1065
+ - For delete operations: `showUndoToast: true` is mandatory
1066
+ - All `submit` functions must return a Promise
1067
+
1068
+ **SDK Parameter:** Available in custom actions and modals. See SDK Utilities section for complete interface.
1069
+
1070
+ ---
1071
+
1072
+ ## SchemaConfig Usage
1073
+
1074
+ SchemaConfig provides complete collection metadata and server actions. Essential for dynamic operations and accessing collection structure information.
1075
+
1076
+ ### Key Properties
1077
+
1078
+ • **id** - `string`
1079
+ - Collection identifier (e.g., "WixPets")
1080
+ - Example: `schema.id === "WixPets"`
1081
+
1082
+ • **idField** - `string`
1083
+ - Primary key field name (usually "_id")
1084
+ - Required for all update/delete operations
1085
+ - Example: `const id = item[schema.idField]`
1086
+
1087
+ • **displayField** - `string`
1088
+ - Main field for displaying items (name, title, etc.)
1089
+ - Used in UI components for item identification
1090
+ - Example: `const label = item[schema.displayField]`
1091
+
1092
+ • **fields** - `Record<string, Field | undefined>`
1093
+ - Complete field definitions with types and metadata
1094
+ - Useful for dynamic form generation or validation
1095
+ - Example: `schema.fields.name.type === 'TEXT'`
1096
+
1097
+ • **actions** - Server operation functions
1098
+ - Pre-configured API calls for CRUD operations
1099
+ - Use with optimistic actions for best UX
1100
+ - Example: `await schema.actions.update(item)`
1101
+
1102
+ ### Available Schema Actions
1103
+
1104
+ - schema.actions.create(item) // Create single item
1105
+ - schema.actions.update(item) // Update single item
1106
+ - schema.actions.delete(itemId) // Delete by ID
1107
+ - schema.actions.bulkUpdate(updates) // Update multiple items
1108
+ - schema.actions.bulkDelete(itemIds) // Delete multiple items
1109
+
1110
+ ### Schema Validation Checklist
1111
+
1112
+ Before using schema in operations:
1113
+
1114
+ ✓ Check if schema exists: `if (!schema) return;`
1115
+ ✓ Verify required fields exist on items
1116
+ ✓ Use `schema.idField` for ID operations
1117
+ ✓ Use `schema.displayField` for UI display
1118
+ ✓ Use `schema.actions` for server operations
1119
+
1120
+ ### Common Usage Patterns
1121
+
1122
+ - **ActionCell**: Use `schema.actions.update()` or `schema.actions.delete()` for single item operations
1123
+ - **BulkActions**: Use `schema.actions.bulkUpdate()` or `schema.actions.bulkDelete()` for multiple items
1124
+ - **Dynamic UI**: Use `schema.fields` to build forms or validate data
1125
+ - **Error Messages**: Use `schema.displayField` to create meaningful user feedback
1126
+
1127
+ ---
1128
+
1129
+ ## Filters Configuration Notes
1130
+
1131
+ To configure filters in a `collectionPage`, add a `filters` property inside the page's component configuration object. Each filter must reference a valid field by its `fieldId`, and the supported types are:
1132
+
1133
+ * `numberConfig`: used with fields of type `NUMBER`
1134
+ * `dateConfig`: used with fields of type `DATETIME`
1135
+ * `booleanConfig`: used with fields of type `BOOLEAN`
1136
+ * `enumConfig`: used with fields of type `ARRAY` or `ARRAY_STRING`
1137
+
1138
+ ### Enum Configuration Implementation
1139
+
1140
+ When implementing enum filters, you must ask the user to provide the possible option values. Never invent or assume enum values. Here's how to properly handle enumConfig:
1141
+
1142
+ #### Example: User-Provided Enum Implementation
1143
+
1144
+ 1. First, collect the possible values from the user:
1145
+ ```
1146
+ User requests: "I need a filter for pet types."
1147
+ You ask: "What are the possible values for pet types that should be available in the filter?"
1148
+ User responds: "dog, cat, bird, rabbit, fish"
1149
+ ```
1150
+
1151
+ 2. Then, create the `enumConfig` structure:
1152
+ ```json
1153
+ "enumConfig": {
1154
+ "options": [
1155
+ { "value": "dog", "label": "Dog" },
1156
+ { "value": "cat", "label": "Cat" },
1157
+ { "value": "bird", "label": "Bird" },
1158
+ { "value": "rabbit", "label": "Rabbit" },
1159
+ { "value": "fish", "label": "Fish" }
1160
+ ],
1161
+ "selectionMode": "multiple",
1162
+ "optionType": "checkbox"
1163
+ }
1164
+ ```
1165
+
1166
+ Notice how the `label` is derived from the `value` by capitalizing the first letter. The user's exact values become the `value` property.
1167
+
1168
+ ### Grouping Filters with Section Title
1169
+
1170
+ * Filters can be grouped by sections using the `sectionTitle` property.
1171
+ * If multiple filter items share the same `sectionTitle`, they will be displayed together in a grouped section in the UI.
1172
+ * Filters without a `sectionTitle` will appear in a default section or be displayed individually.
1173
+ * Grouping helps maintain clarity, especially when dealing with multiple filter options.
1174
+
1175
+ ### Key Guidelines
1176
+
1177
+ * **openByDefault**: Automatically expands the filter accordion when the filters panel is opened.
1178
+ * **tagLabel**: Specifies the label displayed in a Tag component on the table or grid once the filter is active. For example, if the tagLabel is "Age", the filter display might show: `Age: 7`.
1179
+ * **maxInlineFilters**: Limits the number of filters shown inline in the table toolbar. Others are accessible via the panel. Default is 0.
1180
+ * **dateConfig.mode**:
1181
+
1182
+ * `ONLY_PREDEFINED`: user can select only from preset options
1183
+ * `ONLY_CUSTOM`: user must select a custom date range manually (no presets)
1184
+ * `COMBINE`: both options available
1185
+ * **dateConfig.presets** must be omitted if mode is `ONLY_CUSTOM`.
1186
+ * **dateConfig.includeTime**: Controls whether time selection is also enabled alongside date (default is `true`).
1187
+
1188
+ ---
1189
+
1190
+ ## ActionCell Configuration
1191
+
1192
+ The ActionCell feature adds an interactive action column to collection tables or grid views, enabling users to perform operations on individual entities.
1193
+
1194
+ ### Placement and Structure
1195
+
1196
+ The ActionCell has a two-level structure:
1197
+ * `primaryAction`: A single prominent action shown directly in the table/grid row
1198
+ * `secondaryActions`: Additional actions shown in a dropdown menu
1199
+
1200
+ Both properties are optional, but at least one should be provided for the ActionCell to be useful.
1201
+
1202
+ ### Inline Secondary Actions
1203
+
1204
+ **New Feature**: By default, all secondary actions are hidden in a popover menu that appears when the user hovers over or clicks the "more actions" button. However, you can now configure some secondary actions to display inline directly in the table row for improved accessibility and reduced clicks.
1205
+
1206
+ ### Action Types Reference
1207
+
1208
+ 1. **Update Action** (`type: "update"`):
1209
+ - ✓ Use when: Editing entity fields or navigating to a detailed edit page
1210
+ - ✓ Common scenarios:
1211
+ - Full entity editing (use page mode)
1212
+ - ✓ Built-in functionality: No custom implementation needed
1213
+
1214
+ 2. **Delete Action** (`type: "delete"`):
1215
+ - ✓ Use when: Removing entities with confirmation
1216
+ - ✓ Common scenarios:
1217
+ - Deleting records with confirmation
1218
+ - Soft-delete with status update
1219
+ - ✓ Built-in functionality: No custom implementation needed
1220
+
1221
+ 3. **Custom Action** (`type: "custom"`):
1222
+ - ✓ Use when: Executing custom JavaScript without UI
1223
+ - ✓ Common scenarios:
1224
+ - API calls
1225
+ - Browser interactions (alerts, downloads)
1226
+ - Complex operations
1227
+ - ⚠️ Requires implementation: Must register action in overrides
1228
+
1229
+ ### Action Appearance: The `skin` Property
1230
+
1231
+ All action types support the optional `skin` property to customize the visual appearance of action buttons. The skin determines the button's color scheme and visual emphasis.
1232
+
1233
+ #### Skin Values by Action Type:
1234
+
1235
+ **Primary Actions** support these skin values:
1236
+ - `"standard"` - Default appearance (blue primary button)
1237
+ - `"inverted"` - Inverted color scheme
1238
+ - `"premium"` - Premium styling for premium features
1239
+
1240
+ **Secondary Actions** support these skin values:
1241
+ - `"dark"` - Dark appearance
1242
+ - `"destructive"` - Red appearance for dangerous actions (ideal for delete operations)
1243
+ - `"premium"` - Premium styling for premium features
1244
+
1245
+ ### Type Selection Decision Tree
1246
+
1247
+ When choosing an action type, follow this decision process:
1248
+
1249
+ 1. IF editing entity fields:
1250
+ → Use `type: "update"`
1251
+ a. IF complex edits → Use `mode: "page"`
1252
+
1253
+ 2. IF removing entities:
1254
+ → Use `type: "delete"`
1255
+
1256
+ 3. IF executing custom logic without UI:
1257
+ → Use `type: "custom"`
1258
+ - MUST implement action handler
1259
+ - MUST register with `actions` override
1260
+
1261
+ ### Update Action Configuration
1262
+
1263
+ Update actions edit entities by navigating to an entity page.
1264
+
1265
+ #### Validation Rules:
1266
+
1267
+ 1. If `update.mode` is `"page"`:
1268
+ - `update.page` must exist
1269
+ - `update.page.id` must match an entity page ID in the configuration
1270
+
1271
+ ### Delete Action Configuration
1272
+
1273
+ Delete actions remove entities with a confirmation modal.
1274
+
1275
+ #### Validation Rules:
1276
+
1277
+ 1. `delete.mode` must be `"modal"` (currently only modal is supported)
1278
+ 2. `delete.modal` object must exist
1279
+ 3. The modal properties (title, description, actions, feedback) are all optional
1280
+
1281
+ ### Custom Action Configuration
1282
+
1283
+ Custom actions execute JavaScript code that you define. These actions receive parameters that give them access to entity data and utilities. Here's how to implement a custom action:
1284
+
1285
+ 1. First, create the actions folder structure in your page folder:
1286
+ ```
1287
+ your-page/
1288
+ ├── page.tsx
1289
+ └── components/
1290
+ └── actions/
1291
+ ├── index.tsx // Exports all actions
1292
+ └── downloadPetDetails.tsx // Your custom action (name = action id)
1293
+ ```
1294
+
1295
+ 2. Create your action handler in `downloadPetDetails.tsx` (note: the filename and function name MUST match your action id):
1296
+ ```typescript
1297
+ import { CustomActionCellActionResolver } from '@wix/auto-patterns';
1298
+ import { Download } from '@wix/wix-ui-icons-common';
1299
+ import React from 'react';
1300
+
1301
+ // IMPORTANT: Function name MUST match the action id in your configuration
1302
+ export const downloadPetDetails: CustomActionCellActionResolver = (params) => {
1303
+ const { actionParams, sdk } = params;
1304
+ const { item } = actionParams;
1305
+
1306
+ return {
1307
+ label: 'Download Details',
1308
+ icon: <Download />,
1309
+ onClick: () => {
1310
+ // sdk is provided to custom action resolvers (see SDK Utilities section)
1311
+ const optimisticActions = sdk.getOptimisticActions(sdk.collectionId);
1312
+ const schema = sdk.getSchema(sdk.collectionId);
1313
+
1314
+ // Example: Mark pet as downloaded
1315
+ const updatedItem = { ...item, lastDownloaded: new Date() };
1316
+ optimisticActions.updateOne(updatedItem, {
1317
+ submit: async (items) => {
1318
+ // Your download logic here + update server
1319
+ return await schema.actions.update(items[0]);
1320
+ },
1321
+ successToast: 'Pet details downloaded',
1322
+ errorToast: (err, {retry}) => ({
1323
+ text: 'Download failed',
1324
+ action: { text: 'Retry', onClick: retry }
1325
+ })
1326
+ });
1327
+ },
1328
+ };
1329
+ };
1330
+ ```
1331
+
1332
+ 3. Export your action in `actions/index.tsx`:
1333
+ ```typescript
1334
+ export * from './downloadPetDetails';
1335
+ ```
1336
+
1337
+ **Important:** Every time you create a new action, you must add a corresponding export line to this `index.tsx` file. For example, if you create `sendEmail.tsx`, you must add `export * from './sendEmail';` to the index file.
1338
+
1339
+ 4. Configure the action in your JSON configuration:
1340
+ ```ts
1341
+ {
1342
+ "id": "downloadPetDetails", // MUST match the function name exactly
1343
+ "type": "custom", // REQUIRED: Must be exactly "custom"
1344
+ "label": "Download Details", // Optional: Displayed text
1345
+ }
1346
+ ```
1347
+
1348
+ 5. Register your action in the `PatternsWizardOverridesProvider`:
1349
+ ```typescript
1350
+ import * as actions from './components/actions';
1351
+
1352
+ <PatternsWizardOverridesProvider value={{ actions }}>
1353
+ <AutoPatternsApp configuration={config as AppConfig} />
1354
+ </PatternsWizardOverridesProvider>
1355
+ ```
1356
+
1357
+ ### Key Points for Custom Actions:
1358
+ - The action `id` in the configuration MUST exactly match the function name exported from your actions folder
1359
+ - The function name and file name should follow a consistent naming convention (e.g., camelCase)
1360
+ - The implementation must be exported as a named export (not default export)
1361
+ - The implementation must use the `CustomActionCellActionResolver` type
1362
+
1363
+ #### Validation Rules for Custom Actions:
1364
+
1365
+ 1. `id` must:
1366
+ - Match exactly the function name of the custom action implementation
1367
+ - Be registered in the `actions` property of your `PatternsWizardOverridesProvider`
1368
+ - Follow JavaScript identifier naming rules (camelCase recommended)
1369
+
1370
+ 2. The implementation must return an object with:
1371
+ - `label`: Text displayed for the action
1372
+ - `icon`: An Icon component from "@wix/wix-ui-icons-common"
1373
+ - `onClick`: Handler function for the action
1374
+
1375
+ 3. The implementation must:
1376
+ - Use the correct type: `CustomActionCellActionResolver`
1377
+ - Be exported as a named export
1378
+ - Have a filename matching the function name
1379
+
1380
+ ### Key Implementation Decisions
1381
+
1382
+ Follow this decision process when implementing ActionCell:
1383
+
1384
+ 1. **Basic Decision**: Decide which actions users need to perform on entities:
1385
+ - Edit entities? → Use `update` actions
1386
+ - Delete entities? → Use `delete` actions
1387
+ - Custom operations? → Use `custom` actions
1388
+
1389
+ 2. **Primary vs Secondary**: Choose the most common/important action as primary:
1390
+ - Most common operation (typically Edit) → Place in `primaryAction.item`
1391
+ - Less common operations → Place in `secondaryActions.items` array
1392
+
1393
+ 3. **Inline Secondary Actions Strategy**:
1394
+ - **Action Prioritization**: Order `secondaryActions.items` by frequency of use (most used first)
1395
+ - **Inline Count**: Use `inlineCount: 1-3` for optimal UX (avoid cluttering)
1396
+ - **Visibility Control**:
1397
+ - Use `inlineAlwaysVisible: false` (default) for cleaner visual appearance
1398
+ - Use `inlineAlwaysVisible: true` only for critical actions requiring constant visibility
1399
+
1400
+ 4. **Update Action Mode**:
1401
+ - Complex, full-entity edits → Use `mode: "page"` to navigate to entity page
1402
+
1403
+ 5. **Custom Implementation**:
1404
+ - For `custom` actions, you must provide implementations in your code and register them with `PatternsWizardOverridesProvider`
1405
+
1406
+ ### ActionCell Validation Checklist
1407
+
1408
+ AI agents should verify these requirements before generating ActionCell configurations:
1409
+
1410
+ ✓ ActionCell is placed directly inside `table` or `grid` configuration
1411
+ ✓ Each action has a unique `id` and correct `type` value
1412
+ ✓ Each action type only includes its required field(s)
1413
+ ✓ Update page action refers to a valid entity page ID
1414
+ ✓ Delete action has a modal configuration
1415
+ ✓ Custom actions match implementations in overrides
1416
+ ✓ At least one of `primaryAction` or `secondaryActions` is provided
1417
+ ✓ `inlineCount` (if specified) is a non-negative number ≤ total secondary actions count
1418
+ ✓ `inlineAlwaysVisible` (if specified) is a boolean value
1419
+ ✓ Inline secondary actions configuration is applied only when secondary actions exist
1420
+ ✓ `skin` property (if specified) uses valid skin values:
1421
+ - Primary actions: `"standard"`, `"inverted"`, `"premium"`
1422
+ - Secondary actions: `"dark"`, `"destructive"`, `"premium"`
1423
+
1424
+ ---
1425
+
1426
+ ## Bulk Action Toolbar Configuration
1427
+
1428
+ The Bulk Action Toolbar feature enables users to perform operations on multiple selected entities simultaneously in collection tables or grids. When configured, it adds checkboxes to each row and displays a toolbar with bulk actions when items are selected.
1429
+
1430
+ ### Placement and Structure
1431
+
1432
+ The Bulk Action Toolbar is configured within the table / grid / table-grid switch configuration using the `bulkActionToolbar` property. It has a two-level structure:
1433
+ * `primaryActions`: Actions shown directly in the bulk action toolbar
1434
+ * `secondaryActions`: Additional actions organized in sections, typically shown in a dropdown menu
1435
+
1436
+ Both properties are optional, but at least one should be provided for the bulk action toolbar to be functional.
1437
+
1438
+ ### Bulk Action Types Reference
1439
+
1440
+ 1. **Bulk Delete Action** (`type: "bulkDelete"`):
1441
+ - ✓ Use when: Removing multiple entities with confirmation
1442
+ - ✓ Common scenarios:
1443
+ - Mass deletion of records
1444
+ - Bulk cleanup operations
1445
+ - ✓ Built-in functionality: No custom implementation needed
1446
+
1447
+ 2. **Custom Action** (`type: "custom"`):
1448
+ - ✓ Use when: Executing custom JavaScript for bulk operations
1449
+ - ✓ Common scenarios:
1450
+ - Bulk API calls
1451
+ - Bulk exports/downloads
1452
+ - Complex bulk operations without UI
1453
+ - ⚠️ Requires implementation: Must register action in overrides
1454
+
1455
+ ### Type Selection Decision Tree
1456
+
1457
+ When choosing a bulk action type, follow this decision process:
1458
+
1459
+ 1. IF removing multiple entities:
1460
+ → Use `type: "bulkDelete"`
1461
+
1462
+ 2. IF executing custom logic for bulk operations without UI:
1463
+ → Use `type: "custom"`
1464
+ - MUST implement action handler
1465
+ - MUST register with `actions` override
1466
+
1467
+ ### Bulk Delete Action Configuration
1468
+
1469
+ Bulk delete actions remove multiple entities with a confirmation modal.
1470
+
1471
+ #### Validation Rules:
1472
+
1473
+ 1. `bulkDelete.mode` must be `"modal"` (currently only modal is supported)
1474
+ 2. `bulkDelete.modal` object must exist
1475
+ 3. The modal properties (title, description, actions, feedback) are all optional
1476
+
1477
+ ### Custom Bulk Action Configuration
1478
+
1479
+ 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:
1480
+
1481
+ 1. First, create the actions folder structure in your page folder:
1482
+ ```
1483
+ your-page/
1484
+ ├── page.tsx
1485
+ └── components/
1486
+ └── actions/
1487
+ ├── index.tsx // Exports all actions
1488
+ └── bulkExportPets.tsx // Your custom bulk action
1489
+ ```
1490
+
1491
+ 2. Create your bulk action handler in `bulkExportPets.tsx`:
1492
+ ```typescript
1493
+ import { CustomBulkActionsActionResolver } from '@wix/auto-patterns';
1494
+ import { Download } from '@wix/wix-ui-icons-common';
1495
+ import React from 'react';
1496
+
1497
+ // IMPORTANT: Function name MUST match the action id in your configuration
1498
+ export const bulkExportPets: CustomBulkActionsActionResolver = (params) => {
1499
+ const { actionParams, sdk } = params;
1500
+ const { selectedValues, total } = actionParams;
1501
+
1502
+ return {
1503
+ label: 'Export Selected',
1504
+ icon: <Download />,
1505
+ onClick: () => {
1506
+ // sdk is provided to custom action resolvers (see SDK Utilities section)
1507
+ const optimisticActions = sdk.getOptimisticActions(sdk.collectionId);
1508
+ const schema = sdk.getSchema(sdk.collectionId);
1509
+
1510
+ // Example: Mark pets as exported
1511
+ const updatedItems = selectedValues.map(item => ({
1512
+ ...item,
1513
+ lastExported: new Date()
1514
+ }));
1515
+ optimisticActions.updateMany(updatedItems, {
1516
+ submit: async (items) => {
1517
+ // Your export logic here + update server
1518
+ const exportData = items.map(pet => ({
1519
+ name: pet.name,
1520
+ age: pet.age,
1521
+ owner: pet.owner
1522
+ }));
1523
+
1524
+ // Create and download CSV
1525
+ const csv = exportData.map(row => Object.values(row).join(',')).join('\n');
1526
+ const blob = new Blob([csv], { type: 'text/csv' });
1527
+ const url = URL.createObjectURL(blob);
1528
+ const a = document.createElement('a');
1529
+ a.href = url;
1530
+ a.download = 'pets-export.csv';
1531
+ a.click();
1532
+
1533
+ // Update server with export timestamp
1534
+ return await schema.actions.update(items);
1535
+ },
1536
+ successToast: `${selectedValues.length} pets exported`,
1537
+ errorToast: (err, {retry}) => ({
1538
+ text: 'Export failed',
1539
+ action: { text: 'Retry', onClick: retry }
1540
+ })
1541
+ });
1542
+ },
1543
+ };
1544
+ };
1545
+ ```
1546
+
1547
+ 3. Export your action in `actions/index.tsx`:
1548
+ ```typescript
1549
+ export * from './bulkExportPets';
1550
+ ```
1551
+
1552
+ 4. Configure the action in your JSON configuration:
1553
+ ```json
1554
+ {
1555
+ "id": "bulkExportPets", // MUST match the function name exactly
1556
+ "type": "custom", // REQUIRED: Must be exactly "custom"
1557
+ "label": "Export Selected", // Optional: Displayed text
1558
+ }
1559
+ ```
1560
+
1561
+ 5. Register your action in the `PatternsWizardOverridesProvider`:
1562
+ ```typescript
1563
+ import * as actions from './components/actions';
1564
+
1565
+ <PatternsWizardOverridesProvider value={{ actions }}>
1566
+ <AutoPatternsApp configuration={config as AppConfig} />
1567
+ </PatternsWizardOverridesProvider>
1568
+ ```
1569
+
1570
+ ### Key Points for Custom Bulk Actions:
1571
+ - The action `id` in the configuration MUST exactly match the function name exported from your actions folder
1572
+ - The function name and file name should follow a consistent naming convention (e.g., camelCase)
1573
+ - The implementation must be exported as a named export (not default export)
1574
+ - The implementation must use the `CustomBulkActionsActionResolver` type
1575
+ - Access selected entities through `actionParams.selectedValues`
1576
+ - Access total count through `actionParams.total`
1577
+
1578
+ #### Validation Rules for Custom Bulk Actions:
1579
+
1580
+ 1. `id` must:
1581
+ - Match exactly the function name of the custom bulk action implementation
1582
+ - Be registered in the `actions` property of your `PatternsWizardOverridesProvider`
1583
+ - Follow JavaScript identifier naming rules (camelCase recommended)
1584
+
1585
+ 2. The implementation must return an object with:
1586
+ - `label`: Text displayed for the action
1587
+ - `icon`: An Icon component from "@wix/wix-ui-icons-common"
1588
+ - `onClick`: Handler function for the bulk action
1589
+
1590
+ 3. The implementation must:
1591
+ - Use the correct type: `CustomBulkActionsActionResolver`
1592
+ - Be exported as a named export
1593
+ - Have a filename matching the function name
1594
+
1595
+ ### Bulk Action Toolbar Structure
1596
+
1597
+ The bulk action toolbar uses a specific structure for organizing actions:
1598
+
1599
+ #### Primary Actions Structure:
1600
+ ```json
1601
+ "bulkActionToolbar": {
1602
+ "primaryActions": [
1603
+ {
1604
+ "type": "action",
1605
+ "action": {
1606
+ "item": {
1607
+ "id": "bulkCustom",
1608
+ "type": "custom",
1609
+ "label": "Custom Bulk",
1610
+ "custom": {
1611
+ "id": "MyCustomBulk"
1612
+ }
1613
+ }
1614
+ }
1615
+ },
1616
+ {
1617
+ "type": "menu",
1618
+ "menu": {
1619
+ "label": "More actions",
1620
+ "items": [
1621
+ {
1622
+ "id": "exportItems",
1623
+ "type": "custom",
1624
+ "label": "Export Items"
1625
+ },
1626
+ { "type": "divider" },
1627
+ {
1628
+ "id": "downloadItems",
1629
+ "type": "custom",
1630
+ "label": "Download Items"
1631
+ }
1632
+ ]
1633
+ }
1634
+ }
1635
+ ]
1636
+ }
1637
+ ```
1638
+
1639
+ #### Secondary Actions Structure:
1640
+ ```json
1641
+ "bulkActionToolbar": {
1642
+ "secondaryActions": [
1643
+ {
1644
+ "id": "bulkDeleteWithModal",
1645
+ "label": "Bulk Delete",
1646
+ "type": "bulkDelete",
1647
+ "bulkDelete": {
1648
+ "mode": "modal",
1649
+ "modal": {
1650
+ "title": { "text": "Delete items" },
1651
+ "description": { "text": "Are you sure?" }
1652
+ }
1653
+ }
1654
+ },
1655
+ {
1656
+ "id": "bulkExportPets",
1657
+ "type": "custom",
1658
+ "label": "Export Selected"
1659
+ }
1660
+ ]
1661
+ }
1662
+ ```
1663
+
1664
+ ### Key Implementation Decisions
1665
+
1666
+ Follow this decision process when implementing Bulk Action Toolbar:
1667
+
1668
+ 1. **Basic Decision**: Decide which bulk operations users need to perform:
1669
+ - Delete multiple entities? → Use `bulkDelete` actions
1670
+ - Custom bulk operations? → Use `custom` actions
1671
+
1672
+ 2. **Primary vs Secondary**: Choose the most common/important bulk action as primary:
1673
+ - Most common bulk operation → Place in `primaryActions.items` array
1674
+ - Less common bulk operations → Place in `secondaryActions` array
1675
+
1676
+ 3. **Custom Implementation**:
1677
+ - For `custom` bulk actions, you must provide implementations in your code and register them with `PatternsWizardOverridesProvider`
1678
+
1679
+ ### Bulk Action Toolbar Validation Checklist
1680
+
1681
+ AI agents should verify these requirements before generating Bulk Action Toolbar configurations:
1682
+
1683
+ ✓ Bulk Action Toolbar is placed directly inside `table` or `grid` configuration as `bulkActionToolbar`
1684
+ ✓ Each bulk action has a unique `id` and correct `type` value
1685
+ ✓ Each action type only includes its required field(s)
1686
+ ✓ Bulk delete actions have modal configuration
1687
+ ✓ Custom bulk actions match implementations in overrides
1688
+ ✓ At least one of `primaryActions` or `secondaryActions` is provided
1689
+ ✓ Primary actions use `action`/`menu` structure with proper `action` or `menu` properties
1690
+ ✓ Secondary actions are an array that can include dividers
1691
+ ✓ Menu items within primary actions is array that can include dividers
1692
+
1693
+ ---
1694
+
1695
+ # Entity Page Configuration
1696
+
1697
+ ## ⚠️ Entity Page Requirements
1698
+
1699
+ All entity pages must have:
1700
+ - **A route path with descriptive segment and dynamic parameter** (e.g., `/product/:entityId`, `/pet/:entityId`) - **never just `/:entityId`** as this conflicts with collection page routing
1701
+ - **A matching `route.params` configuration** that maps the dynamic parameter
1702
+ - **A reference to their parent collection page via `parentPageId`**
1703
+
1704
+ ## Overview
1705
+
1706
+ * Displays details for a **single entity**.
1707
+ * Always tied to a single Wix collection.
1708
+ * `entityTypeSource` is always `'cms'`.
1709
+
1710
+ > The custom actions must be defined inside the `moreActions` array.
1711
+
1712
+ > Note: You do not need to define a custom action to navigate to the entity page. This behavior is built-in — clicking on a row in the collection table automatically navigates to the corresponding entity page.
1713
+
1714
+ ## Entity Page Layout Configuration
1715
+
1716
+ ### Grid System
1717
+
1718
+ - **12-Column Grid**: The layout uses a 12-column grid system.
1719
+ - The `span` property controls how many columns an item occupies (1-12).
1720
+ - When items in a row exceed 12 columns total, the next item wraps to a new line.
1721
+ - Example: If an item has `span: 8` and the next has `span: 5`, the second item will start a new line.
1722
+
1723
+ ### Layout Structure
1724
+
1725
+ - **Main Section**: Contains primary entity information and most important fields.
1726
+ - **Sidebar Section**: Contains secondary information, metadata, or supporting content.
1727
+ - Both sections support cards that can contain fields, containers, and components.
1728
+
1729
+ ### Detailed Layout Content Types
1730
+
1731
+ 1. **Field Type**:
1732
+ ```typescript
1733
+ {
1734
+ type: 'field';
1735
+ field: {
1736
+ span?: number; // How many columns this field occupies (1-12)
1737
+ fieldId: string; // Must match a valid field ID from the collection schema
1738
+ };
1739
+ }
1740
+ ```
1741
+
1742
+ 2. **Container Type** (for grouping related fields):
1743
+ ```typescript
1744
+ {
1745
+ type: 'container';
1746
+ container: {
1747
+ span?: number; // How many columns this container occupies (1-12)
1748
+ children: LayoutContent[]; // Can nest fields, other containers, or components
1749
+ };
1750
+ }
1751
+ ```
1752
+
1753
+ 3. **Component Type** (for custom rendering):
1754
+ ```typescript
1755
+ {
1756
+ type: 'component';
1757
+ component: {
1758
+ span?: number; // How many columns this component occupies (1-12)
1759
+ componentId: string; // ID matching a component override implementation
1760
+ };
1761
+ }
1762
+ ```
1763
+
1764
+ ### Layout Best Practices
1765
+
1766
+ 1. **Field Grouping**:
1767
+ - Group related fields using containers
1768
+ - Place frequently used fields at the top
1769
+ - Consider the natural flow of data entry
1770
+
1771
+ 2. **Main vs. Sidebar Usage**:
1772
+ - Main section: Put primary entity information
1773
+ - Sidebar: Place secondary information and metadata
1774
+
1775
+ 3. **Responsive Considerations**:
1776
+ - Use appropriate spans for different field types
1777
+ - Text fields often benefit from larger spans
1778
+ - Boolean fields can use smaller spans
1779
+
1780
+ 4. **Nested Containers**:
1781
+ - Use containers to create logical groupings
1782
+ - Don't nest containers too deeply for clarity
1783
+ - Consider using cards for major sections instead of deeply nested containers
1784
+
1785
+ 5. **Image Handling**:
1786
+ - For image fields, consider providing more space (larger span)
1787
+ - Images are automatically rendered with proper controls when using the field type
1788
+
1789
+ ## ⚠️ Common Entity Page Layout Mistakes to Avoid
1790
+
1791
+ - Using incorrect span values causing unexpected layout breaks
1792
+ - Referencing non-existent field IDs in the layout
1793
+ - Creating overly complex nested container structures
1794
+ - Failing to properly register component overrides
1795
+ - Confusing main and sidebar section usage (putting main content in sidebar)
1796
+ - Exceeding 12 total columns in a row without realizing content will wrap
1797
+ - Forgetting to specify the `collectionPagePath` value
1798
+ - Missing required `type: 'card'` structure in layout sections
1799
+
1800
+ ---
1801
+
1802
+ ## Entity Page Actions: `moreActions` Support
1803
+
1804
+ Entity pages in AutoPatternsApp support not only a primary action (such as "Save" or "Delete") but also a flexible set of **more actions** (sometimes called "secondary actions" or `moreActions`). These allow you to provide additional contextual actions for the entity, such as custom logic, or grouped actions.
1805
+
1806
+ > **Note:** All custom actions for entity pages must be placed in the `moreActions` array. Do not place custom actions as primary actions on entity pages. The `moreActions` array is the only supported location for custom actions on entity pages.
1807
+
1808
+ ### Configuration Structure
1809
+
1810
+ - The `moreActions` property on the entity page is an **array** of action configurations that can include divider objects for visual separation.
1811
+ - Each action in `moreActions` is a Custom Action (type: "custom") or a Divider (type: "divider")
1812
+
1813
+ #### Example: Adding custom actions with dividers to an entity page
1814
+ ```json
1815
+ {
1816
+ "type": "entityPage",
1817
+ "entityPage": {
1818
+ // ... other config ...
1819
+ "moreActions": [
1820
+ {
1821
+ "id": "sendEmail",
1822
+ "type": "custom",
1823
+ "label": "Send Email"
1824
+ },
1825
+ {
1826
+ "id": "exportData",
1827
+ "type": "custom",
1828
+ "label": "Export Data"
1829
+ },
1830
+ { "type": "divider" },
1831
+ {
1832
+ "id": "archiveEntity",
1833
+ "type": "custom",
1834
+ "label": "Archive"
1835
+ }
1836
+ ]
1837
+ }
1838
+ }
1839
+ ```
1840
+
1841
+ ---
1842
+
1843
+ ### CustomEntityPageMoreActionsActionResolver
1844
+
1845
+ The `CustomEntityPageMoreActionsActionResolver` type is used to implement custom actions for the `moreActions` menu on entity pages in AutoPatternsApp. Each action in the `moreActions` array must have a corresponding resolver function registered in your overrides.
1846
+
1847
+ #### Function Signature
1848
+
1849
+ ```typescript
1850
+ import { CustomEntityPageMoreActionsActionResolver } from '@wix/auto-patterns/types';
1851
+
1852
+ export const myMoreAction: CustomEntityPageMoreActionsActionResolver = (params) => {
1853
+ const { actionParams: { entity, form } , sdk } = params;
1854
+
1855
+ return {
1856
+ label: 'My More Action',
1857
+ icon: <MyIcon />, // optional
1858
+ onClick: () => {
1859
+ // Your custom logic here
1860
+ },
1861
+ };
1862
+ };
1863
+ ```
1864
+
1865
+ - **entity**: The current entity data (all field values). In actionParams.
1866
+ - **form**: The react-hook-form instance for the entity page. In actionParams.
1867
+ - **sdk**: The AutoPatterns SDK (see SDK Utilities section).
1868
+
1869
+ ---
1870
+
1871
+ #### Key Points for CustomEntityPageMoreActionsActionResolver
1872
+
1873
+ - The action `id` in the configuration MUST exactly match the function name exported from your actions folder.
1874
+ - The implementation must use the `CustomEntityPageMoreActionsActionResolver` type.
1875
+ - The implementation must be exported as a named export (not default export).
1876
+ - The function receives `{ actionParams, sdk }` as parameters.
1877
+ - The returned object must include at least a `label` and an `onClick` handler (optionally an `icon`).
1878
+
1879
+ ---
1880
+
1881
+ #### Validation Checklist for More Actions
1882
+
1883
+ ✓ Each action in `moreActions` has a unique `id` and correct `type` value
1884
+ ✓ Each action type only includes its required field(s)
1885
+ ✓ Custom actions match implementations in overrides
1886
+ ✓ The resolver is exported and registered in the `actions` property of your `PatternsWizardOverridesProvider`
1887
+ ✓ The function signature matches `CustomEntityPageMoreActionsActionResolver`
1888
+ ✓ The returned object includes `label`, `onClick`, and optionally `icon`
1889
+
1890
+ ---
1891
+
1892
+ **Summary:**
1893
+ The `CustomEntityPageMoreActionsActionResolver` enables you to add custom, contextual actions to the "More Actions" menu on your entity pages. Implement the resolver, export it, and reference it by `id` in your config for seamless integration.
1894
+
1895
+ ---
1896
+
1897
+ # Installation & Setup
1898
+
1899
+ ## 1. Install Packages
1900
+
1901
+ Install if necessary and doesn't exists in package.json:
1902
+
1903
+ ```bash
1904
+ npm install @wix/auto-patterns @wix/patterns @wix/design-system
1905
+ ```
1906
+
1907
+ ## ⚠️ Critical Import Rules
1908
+
1909
+ - **Import `AutoPatternsApp` only from `@wix/auto-patterns`** - never from other packages
1910
+ - **CRITICAL:** Always import `AppConfig` as a type import: `import type { AppConfig } from '@wix/auto-patterns/types'` - never import it as a value import
1911
+
1912
+ ## 2. Create AppConfig JSON
1913
+
1914
+ Save this configuration as a `{collectionName}Config.patterns.json` file in the same directory as your page.tsx component.
1915
+
1916
+ For example:
1917
+ - For a "WixPets" collection: `petsConfig.patterns.json`
1918
+ - For a "Products" collection: `productsConfig.patterns.json`
1919
+ - For a "Users" collection: `usersConfig.patterns.json`
1920
+
1921
+ ## Render the Collection Page Component
1922
+
1923
+ Inside your page component, import the JSON configuration and use the `AutoPatternsApp` component. Since this is a page-level component, it should be the only component rendered on the page. Any other content or components should be removed to ensure proper functionality and avoid conflicts.
1924
+
1925
+ ### Page Component Example:
1926
+
1927
+ ```tsx
1928
+ import React, { type FC } from 'react';
1929
+ import { WixDesignSystemProvider } from '@wix/design-system';
1930
+ import '@wix/design-system/styles.global.css';
1931
+ import { WixPatternsProvider } from '@wix/patterns/provider';
1932
+ import { PatternsWizardOverridesProvider, AutoPatternsApp } from '@wix/auto-patterns';
1933
+ import type { AppConfig } from '@wix/auto-patterns/types';
1934
+ import { withDashboard } from '@wix/patterns';
1935
+
1936
+ import config from './MyCollectionConfig.patterns.json';
1937
+
1938
+ const Index: FC = () => {
1939
+ return (
1940
+ <WixDesignSystemProvider features={{ newColorsBranding: true }}>
1941
+ <WixPatternsProvider>
1942
+ <PatternsWizardOverridesProvider value={{ }}>
1943
+ <AutoPatternsApp configuration={config as AppConfig} />
1944
+ </PatternsWizardOverridesProvider>
1945
+ </WixPatternsProvider>
1946
+ </WixDesignSystemProvider>
1947
+ );
1948
+ };
1949
+
1950
+ export default withDashboard(Index);
1951
+ ```
1952
+
1953
+ ---
1954
+
1955
+ # Custom Overrides
1956
+
1957
+ ## ⚠️ Override Rules
1958
+
1959
+ - **Custom overrides are restricted to the defined areas only** - attempting to override or modify any other aspect of `AutoPatternsApp` is prohibited and can cause unexpected behavior
1960
+ - **Always verify override implementation** - when implementing custom overrides, you MUST ensure they are correctly imported and passed to the `PatternsWizardOverridesProvider`
1961
+
1962
+ The `PatternsWizardOverridesProvider` allows you to inject custom code to override default behaviors or add additional functionality. Below are the areas where overrides can be applied:
1963
+
1964
+ > **Note:** These are the only areas where overrides are supported. Avoid attempting to override or modify other parts of the system, as this is not supported and may lead to unexpected behavior.
1965
+
1966
+ ## Folder Structure Organization
1967
+
1968
+ All custom overrides (components, modals, actions, columns, and other customizations) should be created in a `components` folder inside your page directory, not in a global `/src/components` folder. This keeps page-specific customizations organized alongside their respective pages.
1969
+
1970
+ ### Recommended Structure:
1971
+
1972
+ ```
1973
+ your-page/
1974
+ ├── page.tsx // Your main page component
1975
+ ├── MyCollectionConfig.patterns.json // Configuration file
1976
+ └── components/ // Page-specific components folder
1977
+ ├── index.tsx // Exports all overrides for easy importing
1978
+ ├── actions/ // Custom actions
1979
+ │ ├── index.tsx
1980
+ │ └── myCustomAction.tsx
1981
+ ├── columns/ // Column overrides
1982
+ │ ├── index.tsx
1983
+ │ ├── name.ts
1984
+ │ └── date.ts
1985
+ └── customComponents/ // Custom entity page components
1986
+ ├── index.tsx
1987
+ ├── CustomNameField.tsx
1988
+ └── InfoCard.tsx
1989
+ ```
1990
+
1991
+ ### Importing Overrides in Your Page
1992
+
1993
+ In your page component, import from the local components folder:
1994
+
1995
+ ```tsx
1996
+ import * as modals from './components/modals';
1997
+ import * as actions from './components/actions';
1998
+ import * as columns from './components/columns';
1999
+ import * as components from './components/customComponents';
2000
+
2001
+ <PatternsWizardOverridesProvider value={{ modals, actions, columns, components }}>
2002
+ <AutoPatternsApp configuration={config as AppConfig} />
2003
+ </PatternsWizardOverridesProvider>
2004
+ ```
2005
+
2006
+ ### Important: Updating Index Files
2007
+
2008
+ **When adding any new implementation (action, modal, column, or component), you MUST update the corresponding `index.tsx` file to export your new implementation.** The main page component imports from these index files, so they serve as the central export point for each type of override.
2009
+
2010
+ For example:
2011
+ - Adding a new action → Update `./components/actions/index.tsx`
2012
+ - Adding a new modal → Update `./components/modals/index.tsx`
2013
+ - Adding a new column override → Update `./components/columns/index.tsx`
2014
+ - Adding a new custom component → Update `./components/customComponents/index.tsx`
2015
+
2016
+ Without updating the index files, your implementations won't be available to the `PatternsWizardOverridesProvider`.
2017
+
2018
+ ## ⚠️ Common Override Mistakes to Avoid
2019
+
2020
+ - Attempting to override unsupported areas
2021
+ - Invalid column rendering functions
2022
+ - Missing index file exports for new implementations
2023
+ - Incorrect import paths or naming mismatches
2024
+
2025
+ ## Columns
2026
+
2027
+ 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.
2028
+
2029
+ **Enhanced Column Overrides**: Column override can receive both the individual column `value` and the entire `row` data, enabling you to create complex columns that combine multiple field values from the same row.
2030
+
2031
+ ### Function Signature
2032
+
2033
+ ```typescript
2034
+ function columnOverride({ value, row }) {
2035
+ // value: The individual column value
2036
+ // row: The entire row object containing all field values
2037
+ return <YourCustomRendering />;
2038
+ }
2039
+ ```
2040
+
2041
+ ### Understanding Row Data
2042
+
2043
+ **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.
2044
+
2045
+ For example, if your collection schema has these fields:
2046
+ ```json
2047
+ {
2048
+ "fields": [
2049
+ { "key": "name", "displayName": "Pet Name", "type": "TEXT" },
2050
+ { "key": "age", "displayName": "Age", "type": "NUMBER" },
2051
+ { "key": "isVaccinated", "displayName": "Vaccinated", "type": "BOOLEAN" },
2052
+ { "key": "lastActivity", "displayName": "Last Activity", "type": "DATETIME" }
2053
+ ]
2054
+ }
2055
+ ```
2056
+
2057
+ Then in your column override, you access these values using the field IDs:
2058
+ ```typescript
2059
+ export function myColumn({ value, row }) {
2060
+ // Access field values using their schema field IDs
2061
+ const petName = row.name; // "name" field ID
2062
+ const petAge = row.age; // "age" field ID
2063
+ const isVaccinated = row.isVaccinated; // "isVaccinated" field ID
2064
+ const lastActivity = row.lastActivity; // "lastActivity" field ID
2065
+
2066
+ return <YourCustomRendering />;
2067
+ }
2068
+ ```
2069
+
2070
+ ### Use Cases for Row Data Access
2071
+
2072
+ 1. **Complex Display Columns**: Combine multiple fields into a single display (e.g., "Name (Age)" combining name and age fields)
2073
+ 2. **Conditional Rendering**: Show different content based on other field values in the same row
2074
+ 3. **Calculated Columns**: Create computed values using multiple row fields
2075
+ 4. **Cross-Field Validation Display**: Show validation status based on relationships between fields
2076
+
2077
+ ### Example: Defining and Using Column Overrides
2078
+
2079
+ In `components/columns/name.tsx`:
2080
+
2081
+ ```ts
2082
+ import React from 'react';
2083
+
2084
+ export function name({ value, row }) {
2085
+ // Simple value formatting
2086
+ return <strong>{value}</strong>;
2087
+ }
2088
+ ```
2089
+
2090
+ In `components/columns/petInfo.tsx`:
2091
+
2092
+ ```ts
2093
+ import React from 'react';
2094
+ import { Box, Text } from '@wix/design-system';
2095
+
2096
+ export function petInfo({ value, row }) {
2097
+ // Complex column combining multiple row values
2098
+ return (
2099
+ <Box direction="vertical" gap={1}>
2100
+ <Text weight="bold">{row.name}</Text>
2101
+ <Text size="small" skin="disabled">
2102
+ {row.age} years old • {row.type}
2103
+ </Text>
2104
+ {row.isVaccinated && (
2105
+ <Text size="tiny" skin="success">✓ Vaccinated</Text>
2106
+ )}
2107
+ </Box>
2108
+ );
2109
+ }
2110
+ ```
2111
+
2112
+ In `components/columns/status.tsx`:
2113
+
2114
+ ```ts
2115
+ import React from 'react';
2116
+ import { Badge } from '@wix/design-system';
2117
+
2118
+ export function status({ value, row }) {
2119
+ // Conditional rendering based on multiple row fields
2120
+ if (row.isVaccinated && row.age > 1) {
2121
+ return <Badge skin="success">Ready for Adoption</Badge>;
2122
+ } else if (!row.isVaccinated) {
2123
+ return <Badge skin="warning">Needs Vaccination</Badge>;
2124
+ } else {
2125
+ return <Badge skin="neutral">Too Young</Badge>;
2126
+ }
2127
+ }
2128
+ ```
2129
+
2130
+ In `components/columns/fullName.tsx`:
2131
+
2132
+ ```ts
2133
+ import React from 'react';
2134
+
2135
+ export function fullName({ value, row }) {
2136
+ // Calculated column using multiple fields
2137
+ return `${row.name} (owned by ${row.owner})`;
2138
+ }
2139
+ ```
2140
+
2141
+ In `components/columns/date.tsx`:
2142
+
2143
+ ```ts
2144
+ import React from 'react';
2145
+
2146
+ export function date({ value, row }) {
2147
+ // Access to other row data for enhanced date formatting
2148
+ const isRecent = row.lastActivity && new Date(row.lastActivity) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
2149
+
2150
+ return (
2151
+ <span style={{ color: isRecent ? 'green' : 'inherit' }}>
2152
+ <em>{new Date(value).toLocaleDateString()}</em>
2153
+ {isRecent && ' (Recent)'}
2154
+ </span>
2155
+ );
2156
+ }
2157
+ ```
2158
+
2159
+ In `components/columns/index.tsx`:
2160
+
2161
+ ```ts
2162
+ export * from './name';
2163
+ export * from './petInfo';
2164
+ export * from './status';
2165
+ export * from './fullName';
2166
+ export * from './date';
2167
+ ```
2168
+
2169
+ **Important:** Every time you add a new column override file, you must add a corresponding export line to this `index.tsx` file. For example, if you create `price.tsx`, you must add `export * from './price';` to the index file.
2170
+
2171
+ In the `PatternsWizardOverridesProvider`:
2172
+
2173
+ ```tsx
2174
+ import * as columns from './components/columns';
2175
+
2176
+ <PatternsWizardOverridesProvider value={{ columns }}>
2177
+ <AutoPatternsApp configuration={config as AppConfig} />
2178
+ </PatternsWizardOverridesProvider>
2179
+ ```
2180
+
2181
+ ### Visual Representation
2182
+
2183
+ ```
2184
+ your-page/
2185
+ └── components/
2186
+ └── columns/
2187
+ ├── index.tsx // Exports all column overrides
2188
+ ├── name.tsx // Simple value formatting
2189
+ ├── petInfo.tsx // Complex multi-field column
2190
+ ├── status.tsx // Conditional rendering column
2191
+ ├── fullName.tsx // Calculated column
2192
+ └── date.tsx // Enhanced formatting with row context
2193
+
2194
+ PatternsWizardOverridesProvider
2195
+ └── value.columns
2196
+ ├── name
2197
+ ├── petInfo
2198
+ ├── status
2199
+ ├── fullName
2200
+ └── date
2201
+ ```
2202
+
2203
+ ### Key Benefits of Row Data Access
2204
+
2205
+ 1. **Reduced Configuration Complexity**: Instead of adding multiple columns, create one complex column that shows related information
2206
+ 2. **Better User Experience**: Present related data together in a logical, readable format
2207
+ 3. **Dynamic Content**: Show different content based on the state of other fields
2208
+ 4. **Data Relationships**: Highlight relationships between different field values in the same entity
2209
+
2210
+ ### Important Guidelines
2211
+
2212
+ - **Performance**: Remember that column functions are called for every row, so keep calculations lightweight
2213
+ - **Consistency**: When using row data, ensure the column header accurately represents what's displayed
2214
+ - **Accessibility**: Maintain proper semantic structure when combining multiple values
2215
+
2216
+ ## Components
2217
+
2218
+ Components allow you to create custom rendering for specific elements in the entity page. Each component has a unique `componentId` that corresponds to the ID specified in the layout configuration.
2219
+
2220
+ The custom components receive two essential props:
2221
+
2222
+ 1. **form**: An instance of `UseFormReturn` from react-hook-form (re-exported through `@wix/auto-patterns/form`), giving you access to the form control, methods, and state.
2223
+ 2. **entity**: A key-value object where keys are field IDs from the collection schema and values are the current field values, providing access to the entity's data.
2224
+
2225
+ Custom components can serve two main purposes:
2226
+
2227
+ ### 1. Standalone Custom Components
2228
+
2229
+ These components can display custom UI elements like notifications, information cards, or any other custom content that isn't directly tied to specific fields. These are useful for adding unique UI elements that enhance the entity page experience.
2230
+
2231
+ ### 2. Field Rendering Overrides
2232
+
2233
+ You can use custom components to override the default rendering of one or more fields. This allows you to:
2234
+ - Apply custom validation logic
2235
+ - Create custom input components
2236
+ - Combine multiple fields into a single UI component
2237
+ - Add field-specific functionality not available in the default renderers
2238
+
2239
+ ### Using the useController Hook for Field Overrides
2240
+
2241
+ When creating field overrides, use the `useController` hook from `@wix/auto-patterns/form` (a re-export of react-hook-form's hook) to connect your custom component to the form state:
2242
+
2243
+ ```tsx
2244
+ import { useController } from '@wix/auto-patterns/form'; // Always import from this path, not react-hook-form
2245
+ ```
2246
+
2247
+ The hook requires:
2248
+ - **name**: The field name you want to edit (should match the schema field ID)
2249
+ - **control**: Retrieved from `form.control`
2250
+ - **defaultValue**: Set from `entity?.[fieldId]` when it exists
2251
+
2252
+ ### Example: Defining a Custom Component
2253
+
2254
+ Here's an example of a custom component that overrides the rendering of the "name" field:
2255
+
2256
+ ```tsx
2257
+ import React, { FC } from 'react';
2258
+ import { Box, Card, FormField, Input, Text } from '@wix/design-system';
2259
+ import { useController } from '@wix/auto-patterns/form';
2260
+ import { CustomComponentProps } from '@wix/auto-patterns/types';
2261
+
2262
+ export const customNameField: FC<CustomComponentProps> = ({ form, entity }) => {
2263
+ // Create a controller for the name field
2264
+ const controller = useController({
2265
+ name: 'name', // Field ID from the schema
2266
+ control: form.control, // Form control
2267
+ defaultValue: entity?.name, // Default value from entity
2268
+ });
2269
+
2270
+ return (
2271
+ <FormField
2272
+ label="Name"
2273
+ required={true}
2274
+ charCount={100}
2275
+ // Connect field state to UI
2276
+ status={controller.fieldState.invalid ? 'error' : undefined}
2277
+ statusMessage={controller.fieldState.error?.message}
2278
+ dataHook={`short-text-${controller.field.name}`}
2279
+ >
2280
+ <Input
2281
+ // Connect field value and onChange
2282
+ value={controller.field.value}
2283
+ onChange={(e) => controller.field.onChange(e.target.value)}
2284
+ dataHook={`short-text-${controller.field.name}`}
2285
+ />
2286
+ </FormField>
2287
+ );
2288
+ };
2289
+ ```
2290
+
2291
+
2292
+ ### Example: Standalone Component (Not Field-Specific)
2293
+
2294
+ Custom components can also be used to add UI elements not tied to specific fields:
2295
+
2296
+ ```tsx
2297
+ import React, { FC } from 'react';
2298
+ import { Box, Card, Text, Button } from '@wix/design-system';
2299
+ import { CustomComponentProps } from '@wix/auto-patterns/types';
2300
+
2301
+ export const infoCard: FC<CustomComponentProps> = ({ entity }) => {
2302
+ return (
2303
+ <Card>
2304
+ <Card.Content>
2305
+ <Box direction="vertical" gap={2}>
2306
+ <Text weight="bold">Important Information</Text>
2307
+ <Text>
2308
+ This custom component can display additional information or functionality
2309
+ that isn't directly tied to a specific field.
2310
+ </Text>
2311
+ {entity?.isVaccinated ? (
2312
+ <Text skin="success">This pet is vaccinated</Text>
2313
+ ) : (
2314
+ <Text skin="warning">This pet needs vaccination</Text>
2315
+ )}
2316
+ </Box>
2317
+ </Card.Content>
2318
+ </Card>
2319
+ );
2320
+ };
2321
+ ```
2322
+
2323
+ ### Connecting Components in the Provider
2324
+
2325
+ In your main page file, import and provide these components via the `PatternsWizardOverridesProvider`:
2326
+
2327
+ ```tsx
2328
+ import * as components from './components';
2329
+
2330
+ <PatternsWizardOverridesProvider value={{ components }}>
2331
+ <AutoPatternsApp configuration={config as AppConfig} />
2332
+ </PatternsWizardOverridesProvider>
2333
+ ```
2334
+
2335
+ ### Important Guidelines for Custom Components
2336
+
2337
+ 1. **Always import from `@wix/auto-patterns/form`** instead of directly from `react-hook-form`
2338
+ 2. **Follow react-hook-form best practices** - the underlying infrastructure is built on react-hook-form
2339
+ 3. **Handle form state properly**:
2340
+ - Use `controller.fieldState.invalid` for error state
2341
+ - Use `controller.fieldState.error?.message` for error messages
2342
+ - Connect `controller.field.value` to input values
2343
+ - Use `controller.field.onChange` for change handlers
2344
+ 4. **Component rendering**:
2345
+ - Choose appropriate design-system components based on the field type
2346
+ - For text fields: `Input`
2347
+ - For multi-line text: `InputArea`
2348
+ - For checkboxes: `Checkbox`
2349
+ - For dates: `DatePicker`
2350
+ - For dropdowns: `Dropdown`
2351
+
2352
+ **Important:** Every time you create a new custom component, you must add a corresponding export line to the `./components/customComponents/index.tsx` file. For example, if you create `StatusIndicator.tsx`, you must add `export * from './StatusIndicator';` to the index file.
2353
+
2354
+ ### Understanding Reactivity in Custom Components
2355
+
2356
+ 5. **Reactivity and field value changes (IMPORTANT)**:
2357
+ - **NEVER rely on the `entity` object for reactive UI** - it is not reactive to form changes
2358
+ - For any reactive UI that needs to respond to field value changes in real-time:
2359
+ - Use `form.watch('fieldName')` to observe field changes reactively
2360
+ - Use `useController` hook when you need both read and write access to a field
2361
+
2362
+ #### Common Reactivity Issues and Solutions
2363
+
2364
+ ##### Example: Conditional Display Based on Field Value
2365
+
2366
+ ```tsx
2367
+ // ❌ INCORRECT APPROACH (Non-reactive)
2368
+ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
2369
+ // This won't update when the user changes the name in the form
2370
+ const showSpecialMessage = entity?.name === 'special';
2371
+
2372
+ return (
2373
+ <Box>
2374
+ <Input
2375
+ value={form.getValues('name')}
2376
+ onChange={(e) => form.setValue('name', e.target.value)}
2377
+ />
2378
+
2379
+ {showSpecialMessage && (
2380
+ <Text>Special message for special name!</Text>
2381
+ )}
2382
+ </Box>
2383
+ );
2384
+ };
2385
+ ```
2386
+
2387
+ ```tsx
2388
+ // ✅ CORRECT APPROACH (Reactive)
2389
+ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
2390
+ // This WILL update whenever the name field changes
2391
+ const nameValue = form.watch('name');
2392
+ const showSpecialMessage = nameValue === 'special';
2393
+
2394
+ return (
2395
+ <Box>
2396
+ <Input
2397
+ value={nameValue}
2398
+ onChange={(e) => form.setValue('name', e.target.value)}
2399
+ />
2400
+
2401
+ {showSpecialMessage && (
2402
+ <Text>Special message for special name!</Text>
2403
+ )}
2404
+ </Box>
2405
+ );
2406
+ };
2407
+ ```
2408
+
2409
+
2410
+ ##### When to Use the Entity Object
2411
+
2412
+ The `entity` object is useful for:
2413
+ - Setting initial values
2414
+ - Accessing read-only data that doesn't change
2415
+ - Comparing form state with original values (e.g., detecting if changes were made)
2416
+ - Initializing form fields with useController's defaultValue parameter
2417
+
2418
+ ```tsx
2419
+ // Example: Proper use of entity object with useController
2420
+ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
2421
+ // Use entity for initialization via defaultValue
2422
+ const controller = useController({
2423
+ name: 'name', // Field ID from the schema
2424
+ control: form.control,
2425
+ defaultValue: entity?.name // Initialize from entity
2426
+ });
2427
+
2428
+ // Use watch for reactive updates
2429
+ const currentName = controller.field.value;
2430
+ const hasChanges = entity?.name !== currentName;
2431
+
2432
+ return (
2433
+ <Box>
2434
+ <FormField label="Name">
2435
+ <Input
2436
+ value={currentName}
2437
+ onChange={(e) => controller.field.onChange(e.target.value)}
2438
+ />
2439
+ </FormField>
2440
+ {hasChanges && (
2441
+ <Text size="small">Original value: {entity?.name}</Text>
2442
+ )}
2443
+ </Box>
2444
+ );
2445
+ };
2446
+ ```
2447
+
2448
+ ### Visual Representation
2449
+
2450
+ ```
2451
+ your-page/
2452
+ └── components/
2453
+ ├── index.tsx // Exports all component overrides
2454
+ ├── customNameField.tsx // Field override component
2455
+ ├── combinedNameFields.tsx // Multiple fields override
2456
+ └── infoCard.tsx // Standalone component
2457
+
2458
+ PatternsWizardOverridesProvider
2459
+ └── value.components
2460
+ ├── customNameField
2461
+ ├── combinedNameFields
2462
+ └── infoCard
2463
+ ```
2464
+
2465
+ By using these component overrides, you can tailor the behavior and appearance of your `AutoPatternsApp` to meet specific requirements beyond what the default rendering provides.
2466
+
2467
+ ---