@wix/auto-patterns 1.15.0 → 1.16.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 (78) 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/hooks/useBaseTableFeatures.js +7 -2
  12. package/dist/cjs/hooks/useBaseTableFeatures.js.map +1 -1
  13. package/dist/cjs/hooks/useCollectionPageOnRowClickActions.js +49 -0
  14. package/dist/cjs/hooks/useCollectionPageOnRowClickActions.js.map +1 -0
  15. package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
  16. package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
  17. package/dist/cjs/providers/SchemaContext.js +4 -3
  18. package/dist/cjs/providers/SchemaContext.js.map +1 -1
  19. package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
  20. package/dist/cjs/types/actions/collectionPageActions.js.map +1 -1
  21. package/dist/docs/action_cell.md +214 -0
  22. package/dist/docs/app_config_structure.md +355 -0
  23. package/dist/docs/auto-patterns-guide.md +2447 -0
  24. package/dist/docs/bulk_actions.md +266 -0
  25. package/dist/docs/collection_page.md +54 -0
  26. package/dist/docs/collection_page_actions.md +343 -0
  27. package/dist/docs/custom_overrides.md +511 -0
  28. package/dist/docs/entity_page.md +104 -0
  29. package/dist/docs/entity_page_actions.md +92 -0
  30. package/dist/docs/index.md +76 -0
  31. package/dist/docs/installation.md +55 -0
  32. package/dist/docs/introduction.md +74 -0
  33. package/dist/docs/pages_configuration.md +129 -0
  34. package/dist/docs/recipe-bulk-operations.md +1352 -0
  35. package/dist/docs/recipe-crud-operations.md +786 -0
  36. package/dist/docs/recipe-customization.md +1702 -0
  37. package/dist/docs/recipe-first-dashboard.md +794 -0
  38. package/dist/docs/sdk_and_schema.md +215 -0
  39. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +7 -1
  40. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
  41. package/dist/esm/components/AutoPatternsCollectionPageContent/SkeletonCollection.js +21 -0
  42. package/dist/esm/components/AutoPatternsCollectionPageContent/SkeletonCollection.js.map +1 -0
  43. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +3 -1
  44. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
  45. package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js +91 -0
  46. package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -0
  47. package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js +5 -1
  48. package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
  49. package/dist/esm/hooks/useBaseTableFeatures.js +6 -1
  50. package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
  51. package/dist/esm/hooks/useCollectionPageOnRowClickActions.js +45 -0
  52. package/dist/esm/hooks/useCollectionPageOnRowClickActions.js.map +1 -0
  53. package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
  54. package/dist/esm/providers/SchemaContext.js +3 -2
  55. package/dist/esm/providers/SchemaContext.js.map +1 -1
  56. package/dist/esm/types/CollectionPageConfig.js.map +1 -1
  57. package/dist/esm/types/actions/collectionPageActions.js.map +1 -1
  58. package/dist/types/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.d.ts.map +1 -1
  59. package/dist/types/components/AutoPatternsCollectionPageContent/SkeletonCollection.d.ts +5 -0
  60. package/dist/types/components/AutoPatternsCollectionPageContent/SkeletonCollection.d.ts.map +1 -0
  61. package/dist/types/components/AutoPatternsEntityPage/SkeletonEntity.d.ts +7 -0
  62. package/dist/types/components/AutoPatternsEntityPage/SkeletonEntity.d.ts.map +1 -0
  63. package/dist/types/components/AutoPatternsRoute/AutoPatternsPage.d.ts.map +1 -1
  64. package/dist/types/hooks/useBaseTableFeatures.d.ts +1 -1
  65. package/dist/types/hooks/useBaseTableFeatures.d.ts.map +1 -1
  66. package/dist/types/hooks/useCollectionPageOnRowClickActions.d.ts +7 -0
  67. package/dist/types/hooks/useCollectionPageOnRowClickActions.d.ts.map +1 -0
  68. package/dist/types/hooks/useTableFeatures.d.ts +1 -1
  69. package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +1 -1
  70. package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -2
  71. package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
  72. package/dist/types/providers/SchemaContext.d.ts +2 -1
  73. package/dist/types/providers/SchemaContext.d.ts.map +1 -1
  74. package/dist/types/types/CollectionPageConfig.d.ts +2 -1
  75. package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
  76. package/dist/types/types/actions/collectionPageActions.d.ts +8 -0
  77. package/dist/types/types/actions/collectionPageActions.d.ts.map +1 -1
  78. package/package.json +21 -16
@@ -0,0 +1,794 @@
1
+ # Recipe 1: Creating Your First Dashboard from Scratch
2
+
3
+ **Use Case**: "I want to create a complete dashboard to manage my collection (users, products, orders, etc.)"
4
+
5
+ ---
6
+
7
+ # AI Agent Instructions for AutoPatternsApp
8
+
9
+ 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.
10
+
11
+ ## AI Usage Guidelines
12
+
13
+ 1. **Configuration Generation Process**:
14
+
15
+ * First, analyze the schema requirements.
16
+ * Then, select appropriate fields based on data types.
17
+ * Finally, validate against the rules before output.
18
+
19
+ 2. **Required Validation Steps**:
20
+
21
+ * Verify exact page count (must be 2).
22
+ * Confirm proper field selection (max 3 columns initially).
23
+ * Check all mandatory fields are present.
24
+ * Ensure no unsupported fields are included.
25
+ * Verify that every collection page has a create action that navigates to the entity page.
26
+
27
+ 3. **Decision-Making Priority**:
28
+
29
+ * User explicit requirements override defaults.
30
+ * Schema structure guides field selection.
31
+ * Best practices determine presentation.
32
+
33
+ 4. **Enum Configuration Rule (CRITICAL)**:
34
+
35
+ * 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.
36
+ * 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").
37
+ * The AI is strictly prohibited from guessing, inventing, or assuming the enum values or their labels.
38
+
39
+ ---
40
+
41
+ # Core Rules
42
+
43
+ ## Configuration Rules
44
+
45
+ * Pages array MUST contain exactly two pages.
46
+ * Components array inside collectionPage MUST contain exactly one component with a layout array.
47
+ * Configuration MUST come only from a JSON file.
48
+ * DO NOT fill optional fields unless explicitly requested.
49
+ * Select up to 3 columns initially that best represent the entity.
50
+ * Every collection page MUST include a create action that allows users to create new entities by navigating to the entity page.
51
+
52
+ ## Type Binding Rules
53
+
54
+ * If `type: 'collectionPage'`, only `collectionPage` field should exist.
55
+ * If `type: 'entityPage'`, only `entityPage` field should exist.
56
+ * No cross-mixing of types is allowed.
57
+
58
+ ## Override Rules
59
+
60
+ * Custom overrides are restricted to documented areas only.
61
+ * Only override columns when specific rendering is required.
62
+
63
+ ## Validation Rules
64
+
65
+ * All configurations must align with AppConfig Structure.
66
+ * Remove any configuration entries not in the structure.
67
+ * Verify customColumns.enabled logic (>5 columns or explicit request).
68
+
69
+ ---
70
+
71
+ # Instruction Guide & Best Practices
72
+
73
+ This guide instructs on how to correctly integrate the `AutoPatternsApp` component from `@wix/auto-patterns` package into a Wix-based admin page.
74
+
75
+ ---
76
+
77
+ # Component Purpose
78
+
79
+ The `AutoPatternsApp` is a page-level component used to display a data collection either as a Table or Grid.
80
+ It is configured using a JSON file conforming to the `AppConfig` interface and supports overrides for advanced use-cases.
81
+
82
+ ---
83
+
84
+ # Installation & Setup
85
+
86
+ ## 1. Install Packages
87
+
88
+ Install if necessary and doesn't exists in package.json:
89
+
90
+ ```bash
91
+ npm install @wix/auto-patterns @wix/patterns @wix/design-system
92
+ ```
93
+
94
+ ## ⚠️ Critical Import Rules
95
+
96
+ - **Import `AutoPatternsApp` only from `@wix/auto-patterns`** - never from other packages
97
+ - **CRITICAL:** Always import `AppConfig` as a type import: `import type { AppConfig } from '@wix/auto-patterns/types'` - never import it as a value import
98
+
99
+ ## 2. Create AppConfig JSON
100
+
101
+ Save this configuration as a `{collectionName}Config.patterns.json` file in the same directory as your page.tsx component.
102
+
103
+ For example:
104
+ - For a "WixPets" collection: `petsConfig.patterns.json`
105
+ - For a "Products" collection: `productsConfig.patterns.json`
106
+ - For a "Users" collection: `usersConfig.patterns.json`
107
+
108
+ ## Render the Collection Page Component
109
+
110
+ 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.
111
+
112
+ ### Page Component Example:
113
+
114
+ ```tsx
115
+ import React, { type FC } from 'react';
116
+ import { WixDesignSystemProvider } from '@wix/design-system';
117
+ import '@wix/design-system/styles.global.css';
118
+ import { WixPatternsProvider } from '@wix/patterns/provider';
119
+ import { PatternsWizardOverridesProvider, AutoPatternsApp } from '@wix/auto-patterns';
120
+ import type { AppConfig } from '@wix/auto-patterns/types';
121
+ import { withDashboard } from '@wix/patterns';
122
+
123
+ import config from './MyCollectionConfig.patterns.json';
124
+
125
+ const Index: FC = () => {
126
+ return (
127
+ <WixDesignSystemProvider features={{ newColorsBranding: true }}>
128
+ <WixPatternsProvider>
129
+ <PatternsWizardOverridesProvider value={{ }}>
130
+ <AutoPatternsApp configuration={config as AppConfig} />
131
+ </PatternsWizardOverridesProvider>
132
+ </WixPatternsProvider>
133
+ </WixDesignSystemProvider>
134
+ );
135
+ };
136
+
137
+ export default withDashboard(Index);
138
+ ```
139
+
140
+ ---
141
+
142
+ # AppConfig Structure
143
+
144
+ ## ⚠️ Configuration Rules
145
+
146
+ - **Configuration must come only from a JSON file** - never inline or from other sources
147
+ - **DO NOT fill optional fields unless explicitly requested** - leave optional properties undefined to avoid unnecessary complexity
148
+ - **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
149
+ - **When generating config for the first time, select up to 3 columns from the schema that best represent the entity**
150
+
151
+ ## ⚠️ Common Configuration Mistakes to Avoid
152
+
153
+ - Adding more than two pages
154
+ - Mixing page types in a single configuration
155
+ - Including undefined optional fields
156
+ - Selecting too many initial columns
157
+ - Not designating exactly one page as `appMainPage: true`
158
+ - Missing or inconsistent page relationships (parentPageId/entityPageId)
159
+ - Setting `stickyColumns` to invalid values (negative, zero, or exceeding column count)
160
+
161
+ ```ts
162
+ export interface AppConfig {
163
+ pages: {
164
+ id: string; // Page unique identifier (must be unique across the app)
165
+ type: 'collectionPage' | 'entityPage'; // Defines page type
166
+ appMainPage?: boolean; // Designates this page as the main page (exactly one page must have this set to true)
167
+ collectionPage?: {
168
+ route: {
169
+ path: string; // Route path for the collection page (e.g., '/')
170
+ };
171
+ title: {
172
+ text: string; // Main page title
173
+ hideTotal?: boolean; // Hide total items in header. Default: true
174
+ };
175
+ subtitle?: {
176
+ text: string; // Optional page subtitle
177
+ };
178
+ actions?: { // Defines page-level actions for the collection page
179
+ primaryActions?: {
180
+ type: 'action' | 'menu'; // Type of primary actions layout
181
+ action?: { // Required when type is 'action'
182
+ item: {
183
+ id: string; // Unique identifier for the action
184
+ type: 'create' | 'custom'; // Action type
185
+ label?: string; // Text displayed for the action
186
+ collection: {
187
+ collectionId: string; // ID of the Wix Data collection
188
+ entityTypeSource: 'cms'; // Data source type. Always 'cms'
189
+ };
190
+ create?: { // Required when type is 'create'
191
+ mode: 'page'; // Create mode
192
+ page: {
193
+ id: string; // Entity page ID to navigate to for creation
194
+ };
195
+ };
196
+ };
197
+ };
198
+ menu?: { // Required when type is 'menu'
199
+ label: string; // Label for the group
200
+ items: {}[]; // Array of action configurations, same structure as action.item, can include dividers
201
+ };
202
+ };
203
+ secondaryActions?: {
204
+ type: 'action' | 'menu'; // Type of secondary actions layout, same structure as primaryActions
205
+ action?: {}; // Same structure as primaryActions.action
206
+ menu?: {}; // Same structure as primaryActions.menu
207
+ };
208
+ };
209
+ components: [
210
+ {
211
+ entityPageId?: string; // ID of the entity page to navigate to when clicking a row
212
+ collection: {
213
+ collectionId: string; // ID of the Wix Data collection
214
+ entityTypeSource: 'cms'; // Data source type. Always 'cms'
215
+ reflectQueryInUrl?: boolean; // Reflects query state (search, filters, sorting) in the browser URL. Default: false
216
+ selectAllScope?: 'page' | 'all'; // Controls "Select All" scope. 'all' selects entire collection, 'page' selects only visible items. Default: 'all'
217
+ selectionUpdateMode?: 'preserve' | 'clear'; // Controls selection behavior when data changes. 'preserve' maintains selections, 'clear' clears them. Default: 'clear'
218
+ };
219
+ filters?: {
220
+ panelTitle?: string; // Title of the filters panel
221
+ items: {
222
+ id: string; // Unique identifier for the filter item
223
+ fieldId: string; // ID of the field to filter by (must be a valid type: NUMBER, DATETIME, BOOLEAN, ARRAY, ARRAY_STRING)
224
+ displayName?: string; // Display name of the filter item
225
+ openByDefault?: boolean; // Whether the filter item is open by default in the panel (accordion is open)
226
+ sectionTitle?: string; // Title of the filter section. Required if more than one section exists to prevent confusion
227
+ tagLabel?: string; // Label shown in Tag component in the table/grid when the filter is applied (e.g., "Age: 7")
228
+ numberConfig?: {
229
+ min?: number; // Minimum value
230
+ max?: number; // Maximum value
231
+ allowedDecimals?: true; // Decimal precision allowed
232
+ };
233
+ dateConfig?: {
234
+ mode?: 'ONLY_PREDEFINED' | 'ONLY_CUSTOM' | 'COMBINE'; // Determines filter behavior
235
+ presets?: (
236
+ | 'SEVEN_DAYS'
237
+ | 'FOURTEEN_DAYS'
238
+ | 'MONTH'
239
+ | 'TODAY'
240
+ | 'TOMORROW'
241
+ | 'NEXT_THREE_DAYS'
242
+ | 'NEXT_SEVEN_DAYS'
243
+ | 'NEXT_THIRTY_DAYS'
244
+ )[]; // Shown only if mode includes predefined presets (COMBINE or ONLY_PREDEFINED)
245
+ includeTime?: boolean; // Whether to allow time selection. Default is true
246
+ };
247
+ booleanConfig?: {
248
+ trueLabel?: string; // Label shown for the true value
249
+ falseLabel?: string; // Label shown for the false value
250
+ };
251
+ enumConfig?: {
252
+ options: {
253
+ value: string; // Enum option value
254
+ label: string; // Enum option label
255
+ }[];
256
+ selectionMode: 'single' | 'multiple'; // Selection behavior
257
+ optionType?:
258
+ | 'checkbox'
259
+ | 'inlineCheckbox'
260
+ | 'radio'
261
+ | 'select'; // Option rendering style
262
+ };
263
+ }[];
264
+ };
265
+ actionCell?: {
266
+ primaryAction?: {
267
+ item: {
268
+ id: string; // Unique identifier for the action
269
+ type: 'update' | 'delete' | 'custom'; // Action type
270
+ label?: string; // Text displayed for the action
271
+ disabled?: boolean; // Whether the action is disabled
272
+ tooltip?: string; // Tooltip text shown on hover
273
+ update?: { // Required when type is 'update'
274
+ mode: 'page'; // Update mode
275
+ page?: { // Required when mode is 'page'
276
+ id: string; // Entity page ID to navigate to
277
+ };
278
+ };
279
+ delete?: { // Required when type is 'delete'
280
+ mode: 'modal'; // Currently only 'modal' is supported
281
+ modal: {
282
+ title?: {
283
+ text: string; // Modal title
284
+ };
285
+ description?: {
286
+ text: string; // Modal description
287
+ };
288
+ actions?: {
289
+ submit?: {
290
+ text: string; // Submit button text
291
+ };
292
+ cancel?: {
293
+ text: string; // Cancel button text
294
+ };
295
+ };
296
+ feedback?: {
297
+ successToast?: {
298
+ text: string; // Success message
299
+ };
300
+ errorToast?: {
301
+ text: string; // Error message
302
+ };
303
+ };
304
+ };
305
+ };
306
+ };
307
+ };
308
+ secondaryActions?: {
309
+ items: {}[]; // Array of action configurations, same structure as primaryAction.item, can include dividers
310
+ inlineCount?: number; // How many secondary actions to show inline before showing popover
311
+ inlineAlwaysVisible?: boolean; // Whether to always show inline actions (not just on hover)
312
+ };
313
+ };
314
+ bulkActionToolbar?: {
315
+ primaryActions?: ({
316
+ type: 'action' | 'menu'; // Type of bulk action item
317
+ action?: { // Required when type is 'action'
318
+ item: {
319
+ id: string; // Unique identifier for the bulk action
320
+ type: 'bulkDelete' | 'custom'; // Bulk action type
321
+ label?: string; // Text displayed for the action
322
+ bulkDelete?: { // Required when type is 'bulkDelete'
323
+ mode: 'modal'; // Currently only 'modal' is supported
324
+ modal: {
325
+ title?: {
326
+ text: string; // Modal title
327
+ };
328
+ description?: {
329
+ text: string; // Modal description
330
+ };
331
+ actions?: {
332
+ submit?: {
333
+ text: string; // Submit button text
334
+ };
335
+ cancel?: {
336
+ text: string; // Cancel button text
337
+ };
338
+ };
339
+ feedback?: {
340
+ successToast?: {
341
+ text: string; // Success message
342
+ };
343
+ errorToast?: {
344
+ text: string; // Error message
345
+ };
346
+ };
347
+ };
348
+ };
349
+ };
350
+ };
351
+ menu?: { // Required when type is 'menu'
352
+ label: string; // Label for the dropdown group
353
+ items: {}[] // Array of bulk actions configurations, same structure as action.item, can include dividers
354
+ };
355
+ })[];
356
+ secondaryActions?: {}[]; // Array of bulk actions configurations, same structure as primaryActions[].menu.items, can include dividers
357
+ };
358
+ toolbarTitle?: {
359
+ title: string; // Toolbar title above the table/grid
360
+ subtitle?: {
361
+ text: string; // Toolbar subtitle
362
+ };
363
+ showTotal?: boolean; // Show total items on toolbar. Default: false
364
+ };
365
+ search?: {
366
+ shown?: boolean; // Show/hide the search
367
+ };
368
+ emptyState?: {
369
+ title?: string; // Empty state title
370
+ subtitle?: string; // Empty state subtitle
371
+ image?: {
372
+ id: string; // Image ID for empty state
373
+ };
374
+ addNewCta?: {
375
+ id?: string; // Add New CTA ID
376
+ text?: string; // Add New CTA text
377
+ };
378
+ customCta?: {
379
+ id?: string; // Custom CTA ID
380
+ };
381
+ };
382
+ layout: [ // Array of layout items that define what components to render
383
+ {
384
+ type: 'Table'; // Layout item type for table rendering
385
+ table?: {
386
+ columns: {
387
+ id: string; // Field ID from the collection
388
+ name: string; // Column title displayed
389
+ width: string; // The width of the column (required in types)
390
+ sortable?: boolean; // If the column is sortable
391
+ defaultSortOrder?: 'asc' | 'desc'; // Optional default sort order
392
+ sortMode?: 'asc' | 'desc'; // Optional sorting mode
393
+ reorderDisabled?: boolean; // Whether column reordering is disabled
394
+ hideable?: boolean; // Whether column can be hidden
395
+ defaultHidden?: boolean; // Whether column is hidden by default
396
+ hiddenFromCustomColumnsSelection?: boolean; // Whether column is hidden from custom columns selection
397
+ }[];
398
+ customColumns?: {
399
+ enabled: boolean; // Enable user customization (hide/reorder columns)
400
+ };
401
+ stickyColumns?: number; // Number of columns to make sticky from the start. Sticky columns remain visible when horizontally scrolling.
402
+ };
403
+ },
404
+ {
405
+ type: 'Grid'; // Layout item type for grid rendering
406
+ grid?: {
407
+ item: {
408
+ titleFieldId: string; // Field ID to display as the item title
409
+ subtitleFieldId?: string; // Field ID for the item subtitle
410
+ imageFieldId?: string; // Field ID for the item image
411
+ /**
412
+ * Controls which content is shown in the card (preset):
413
+ * - 'full': Shows both title and subtitle.
414
+ * - 'title': Shows only the title.
415
+ * - 'empty': Hides both title and subtitle (card appears visually empty except for image or other content).
416
+ */
417
+ cardContentMode?: 'full' | 'title' | 'empty';
418
+ imagePlacement?: 'top' | 'side';
419
+ };
420
+ };
421
+ }
422
+ ]; // End of layout array
423
+ }
424
+ ]; // End of components array
425
+ };
426
+ entityPage?: {
427
+ route: {
428
+ path: string; // Route path for the entity page (e.g., '/product/:entityId')
429
+ params: {
430
+ id: string; // Maps dynamic parameter in path to its identifier
431
+ };
432
+ };
433
+ title?: {
434
+ text: string; // Entity page title
435
+ };
436
+ subtitle?: {
437
+ text: string; // Entity page subtitle
438
+ };
439
+ parentPageId?: string; // ID of the parent collection page
440
+ layout?: {
441
+ // Main layout section
442
+ main: {
443
+ type: 'card'; // Type of the card
444
+ card: {
445
+ title: {
446
+ text: string; // Title of the card
447
+ };
448
+ subtitle?: {
449
+ text: string; // Subtitle of the card
450
+ };
451
+ children: LayoutContent[]; // Array of content items that can be fields, nested containers, or components
452
+ };
453
+ }[];
454
+ // Sidebar layout section
455
+ sidebar?: {
456
+ type: 'card';
457
+ card: {
458
+ title: {
459
+ text: string; // Title of the card
460
+ };
461
+ subtitle?: {
462
+ text: string; // Subtitle of the card
463
+ };
464
+ children: LayoutContent[]; // Array of content items that can be fields, nested containers, or components
465
+ };
466
+ }[];
467
+ };
468
+ collectionId: string; // Related collection ID
469
+ entityTypeSource: 'cms'; // Data source type. Always 'cms'
470
+ };
471
+ }[];
472
+ }
473
+
474
+ type LayoutContent =
475
+ | {
476
+ type: 'field';
477
+ field: {
478
+ span?: number;
479
+ fieldId: string;
480
+ };
481
+ }
482
+ | {
483
+ type: 'container';
484
+ container: {
485
+ span?: number;
486
+ children: LayoutContent[];
487
+ };
488
+ }
489
+ | {
490
+ type: 'component';
491
+ component: {
492
+ span?: number;
493
+ componentId: string;
494
+ };
495
+ };
496
+ ```
497
+
498
+ ---
499
+
500
+ # Pages Configuration
501
+
502
+ ## ⚠️ Critical Page Rules
503
+
504
+ - **Pages array must contain exactly two pages** - one collectionPage and one entityPage
505
+ - **Exactly one page must have `appMainPage: true`** to designate it as the main page
506
+ - **All page IDs referenced in relationships must exist in the configuration** - validate all `parentPageId` and `entityPageId` references
507
+ - **Bind `type` strictly to matching fields** - if `type: 'collectionPage'`, only `collectionPage` field exists (no `entityPage` field), and vice versa
508
+
509
+ ## Default Generation
510
+
511
+ * **Always generate two pages**:
512
+
513
+ * One **collectionPage** (routePath: `/`)
514
+ * One **entityPage** (routePath: `/[segment]/:entityId`)
515
+
516
+ * Always use `entityId` as the dynamic URL parameter, not `id`.
517
+ * The route path **must** include a descriptive segment (e.g., `/product/:entityId`, `/pet/:entityId`)
518
+ * **Never use just `/:entityId`** - this conflicts with the collection page route and breaks routing
519
+
520
+ ## Type and Structure Binding
521
+
522
+ * If `type: 'collectionPage'`, then **only** `collectionPage` field exists (no `entityPage` field).
523
+ * If `type: 'entityPage'`, then **only** `entityPage` field exists (no `collectionPage` field).
524
+ * **No cross-mixing** allowed.
525
+
526
+ ## Page Connection Configuration
527
+
528
+ ### Main Page Designation
529
+
530
+ * One page must be designated as the main page using the `appMainPage` property:
531
+ * **Exactly one page** must have `appMainPage: true`
532
+ * When users navigate to the root path (`/`), they will be automatically redirected to this page
533
+ * This is typically set on the collection page, but can be any page based on your application's requirements
534
+
535
+ ### Collection-Entity Page Relationships
536
+
537
+ A two-way connection must be established between collection pages and entity pages:
538
+
539
+ 1. **From EntityPage to CollectionPage**:
540
+ * Each entity page must specify its parent collection page using `parentPageId`
541
+ * This property on the entity page references the `id` of its parent collection page
542
+
543
+ 2. **From CollectionPage to EntityPage**:
544
+ * Each collection page's component must reference its corresponding entity page:
545
+ * Inside the table or grid configuration (not directly in the collectionPage), specify `entityPageId` pointing to the entity page's `id`:
546
+ ```json
547
+ "components": [
548
+ {
549
+ "type": "Table", // or "Grid"
550
+ "table": { // or "grid"
551
+ "entityPageId": "my-entity-page-id",
552
+ // other table/grid configuration
553
+ }
554
+ }
555
+ ]
556
+ ```
557
+ * ⚠️ **IMPORTANT**: The `entityPageId` field is located within the specific component configuration (table or grid), not at the collection page level
558
+
559
+ ### Entity Page URL Configuration
560
+
561
+ * For entity pages (`type: "entityPage"`), the following URL configuration is **mandatory**:
562
+
563
+ 1. **Route Path Structure**:
564
+ * The `route.path` **must** include a relative path segment followed by a dynamic parameter (e.g., `/product/:entityId` or `/pets/:entityId`)
565
+ * **Never use just `/:entityId`** - this conflicts with the collection page route `/` and breaks routing
566
+ * The relative path segment should be descriptive of the entity type (e.g., `/product/`, `/pet/`, `/user/`)
567
+ * This parameter is typically named `:entityId` by convention, but any parameter name prefixed with `:` is valid
568
+
569
+ 2. **Route Parameters Mapping**:
570
+ * The `route.params` property is required and must map the dynamic parameter:
571
+ ```json
572
+ "route": {
573
+ "path": "/product/:entityId",
574
+ "params": {
575
+ "id": "entityId"
576
+ }
577
+ }
578
+ ```
579
+ * The `id` field in `route.params` must match the parameter name used in `route.path` (without the colon)
580
+
581
+
582
+ ### Key Rules for Page Connections
583
+
584
+ * **Main Page Requirement**: Exactly one page must have `appMainPage: true`
585
+ * **Reference Validity**: All page IDs referenced in `parentPageId` and `entityPageId` must exist in the configuration
586
+ * **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
587
+ * **Route Structure**: Entity pages must use `/[segment]/:entityId` format (e.g., `/product/:entityId` or `/pets/:entityId`), never just `/:entityId`
588
+ * **Route Parameters Configuration**: All entity pages must have both a dynamic parameter in `route.path` and a matching configuration in `route.params`
589
+
590
+ ## ⚠️ Common Type and Route Mistakes to Avoid
591
+
592
+ - Using incorrect field types
593
+ - Missing required fields
594
+ - Including fields from wrong page type
595
+ - Missing route.params for entity pages
596
+ - Using `/:entityId` instead of `/segment/:entityId` for entity page routes (causes routing conflicts)
597
+
598
+ # Sticky Columns Configuration
599
+
600
+ ## Overview
601
+
602
+ 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.
603
+
604
+ ## Configuration Properties
605
+
606
+ ### stickyColumns
607
+
608
+ - **Type**: `number` (optional)
609
+ - **Description**: Number of columns to make sticky from the start of the table
610
+ - **Behavior**: Sticky columns are always the **first N columns** in the `columns` array
611
+ - **Default**: `undefined` (no sticky columns)
612
+
613
+ ## Key Behavior Rules
614
+
615
+ ### 🔑 **Critical Rule: Position-Based Stickiness**
616
+ - `stickyColumns: 2` means "make the **first 2 columns** sticky" (positions 0 and 1 in the `columns` array)
617
+ - The sticky columns are determined by **array position**, not by column content
618
+ - If columns are reordered, the sticky behavior follows the new order
619
+
620
+ ### 🔒 **Important: Reorder Protection**
621
+ - To protect specific columns from being reordered away from their sticky positions, set `reorderDisabled: true` on those columns
622
+ - This allows `customColumns.enabled: true` while protecting sticky columns from being moved
623
+ - Without reorder protection, users can accidentally move intended sticky columns away from the beginning
624
+
625
+ ### ⚠️ **Validation Rules**
626
+ - `stickyColumns` must be a positive number
627
+ - `stickyColumns` should not exceed the total number of columns
628
+ - Invalid values are ignored (treated as `undefined`)
629
+
630
+ ---
631
+
632
+ # Collection Page Configuration
633
+
634
+ ## ⚠️ Collection Page Rules
635
+
636
+ - **Components array inside collectionPage must contain exactly one component with a layout array**
637
+ - **All collection pages with tables/grids must reference their corresponding entity page via `entityPageId`** in the collection configuration
638
+ - **Enable `customColumns` only based on strict logic** - enable if more than 5 columns are defined OR user explicitly requests it, otherwise disable
639
+ - **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
640
+ - **When generating config for first time, select up to 3 columns from the schema that best represent the entity**
641
+
642
+ ## Components Array
643
+
644
+ * Must include **exactly one item**.
645
+ * Each component must have:
646
+ * `collection`: Collection configuration with `collectionId` and `entityTypeSource: 'cms'`
647
+ * `layout`: Array of layout items that determine what components to render
648
+
649
+ ## Layout Array
650
+
651
+ The `layout` array contains the rendering components for the collection. Each layout item has:
652
+ * `type`: Either 'Table' or 'Grid'
653
+ * Component-specific configuration (`table` or `grid` object)
654
+
655
+ ### Layout Item Types:
656
+
657
+ 1. **Table Layout Item** (`type: 'Table'`):
658
+ * `table` field contains table-specific configuration
659
+ * Used for displaying collection in a **table view**
660
+ * Includes columns, actionCell, bulkActionToolbar, etc.
661
+
662
+ 2. **Grid Layout Item** (`type: 'Grid'`):
663
+ * `grid` field contains grid-specific configuration
664
+ * Used for **grid (card) view** of collection
665
+ * Includes item configuration for title/subtitle/image fields
666
+
667
+ ### Table/Grid View Switch Behavior:
668
+ * 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
669
+ * Users can toggle between table and grid views
670
+
671
+ ## Table Configuration
672
+
673
+ * Used for displaying collection in a **table view**.
674
+ * **customColumns.enabled** logic:
675
+ * Enable if:
676
+ * More than **5 columns** are defined
677
+ * OR user **explicitly** requests it
678
+ * Otherwise, **disable** (false)
679
+
680
+ ## Grid Configuration
681
+
682
+ * Used for **grid (card) view** of collection.
683
+ * `item.title`, `item.subtitle`, `item.image` fields are **Field IDs** from the schema.
684
+ * If the user does not specify, **select the most relevant fields automatically**.
685
+ * 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.
686
+
687
+ ---
688
+
689
+ # Entity Page Configuration
690
+
691
+ ## ⚠️ Entity Page Requirements
692
+
693
+ All entity pages must have:
694
+ - **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
695
+ - **A matching `route.params` configuration** that maps the dynamic parameter
696
+ - **A reference to their parent collection page via `parentPageId`**
697
+
698
+ ## Overview
699
+
700
+ * Displays details for a **single entity**.
701
+ * Always tied to a single Wix collection.
702
+ * `entityTypeSource` is always `'cms'`.
703
+
704
+ > The custom actions must be defined inside the `moreActions` array.
705
+
706
+ > 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.
707
+
708
+ ## Entity Page Layout Configuration
709
+
710
+ ### Grid System
711
+
712
+ - **12-Column Grid**: The layout uses a 12-column grid system.
713
+ - The `span` property controls how many columns an item occupies (1-12).
714
+ - When items in a row exceed 12 columns total, the next item wraps to a new line.
715
+ - Example: If an item has `span: 8` and the next has `span: 5`, the second item will start a new line.
716
+
717
+ ### Layout Structure
718
+
719
+ - **Main Section**: Contains primary entity information and most important fields.
720
+ - **Sidebar Section**: Contains secondary information, metadata, or supporting content.
721
+ - Both sections support cards that can contain fields, containers, and components.
722
+
723
+ ### Detailed Layout Content Types
724
+
725
+ 1. **Field Type**:
726
+ ```typescript
727
+ {
728
+ type: 'field';
729
+ field: {
730
+ span?: number; // How many columns this field occupies (1-12)
731
+ fieldId: string; // Must match a valid field ID from the collection schema
732
+ };
733
+ }
734
+ ```
735
+
736
+ 2. **Container Type** (for grouping related fields):
737
+ ```typescript
738
+ {
739
+ type: 'container';
740
+ container: {
741
+ span?: number; // How many columns this container occupies (1-12)
742
+ children: LayoutContent[]; // Can nest fields, other containers, or components
743
+ };
744
+ }
745
+ ```
746
+
747
+ 3. **Component Type** (for custom rendering):
748
+ ```typescript
749
+ {
750
+ type: 'component';
751
+ component: {
752
+ span?: number; // How many columns this component occupies (1-12)
753
+ componentId: string; // ID matching a component override implementation
754
+ };
755
+ }
756
+ ```
757
+
758
+ ### Layout Best Practices
759
+
760
+ 1. **Field Grouping**:
761
+ - Group related fields using containers
762
+ - Place frequently used fields at the top
763
+ - Consider the natural flow of data entry
764
+
765
+ 2. **Main vs. Sidebar Usage**:
766
+ - Main section: Put primary entity information
767
+ - Sidebar: Place secondary information and metadata
768
+
769
+ 3. **Responsive Considerations**:
770
+ - Use appropriate spans for different field types
771
+ - Text fields often benefit from larger spans
772
+ - Boolean fields can use smaller spans
773
+
774
+ 4. **Nested Containers**:
775
+ - Use containers to create logical groupings
776
+ - Don't nest containers too deeply for clarity
777
+ - Consider using cards for major sections instead of deeply nested containers
778
+
779
+ 5. **Image Handling**:
780
+ - For image fields, consider providing more space (larger span)
781
+ - Images are automatically rendered with proper controls when using the field type
782
+
783
+ ## ⚠️ Common Entity Page Layout Mistakes to Avoid
784
+
785
+ - Using incorrect span values causing unexpected layout breaks
786
+ - Referencing non-existent field IDs in the layout
787
+ - Creating overly complex nested container structures
788
+ - Failing to properly register component overrides
789
+ - Confusing main and sidebar section usage (putting main content in sidebar)
790
+ - Exceeding 12 total columns in a row without realizing content will wrap
791
+ - Forgetting to specify the `collectionPagePath` value
792
+ - Missing required `type: 'card'` structure in layout sections
793
+
794
+ ---