@wix/auto-patterns 1.22.0 → 1.24.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 (122) hide show
  1. package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +12 -323
  2. package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
  3. package/dist/cjs/components/AutoPatternsEntityPage/EditModeEntityPage.js +172 -0
  4. package/dist/cjs/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -0
  5. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js +78 -0
  6. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js.map +1 -0
  7. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js +119 -0
  8. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js.map +1 -0
  9. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js +79 -0
  10. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js.map +1 -0
  11. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/index.js +16 -0
  12. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/index.js.map +1 -0
  13. package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js +77 -0
  14. package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js.map +1 -0
  15. package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js +109 -0
  16. package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js.map +1 -0
  17. package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.js +196 -0
  18. package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.js.map +1 -0
  19. package/dist/cjs/components/AutoPatternsEntityPage/index.js +12 -0
  20. package/dist/cjs/components/AutoPatternsEntityPage/index.js.map +1 -1
  21. package/dist/cjs/hooks/useActionCell.js.map +1 -1
  22. package/dist/cjs/hooks/useEntityPageActions.js +105 -0
  23. package/dist/cjs/hooks/useEntityPageActions.js.map +1 -0
  24. package/dist/cjs/hooks/useEntityPageMoreActions.js +10 -0
  25. package/dist/cjs/hooks/useEntityPageMoreActions.js.map +1 -1
  26. package/dist/cjs/hooks/useNavigateEditEntityAction.js +50 -0
  27. package/dist/cjs/hooks/useNavigateEditEntityAction.js.map +1 -0
  28. package/dist/cjs/hooks/useNavigationUtils.js +12 -1
  29. package/dist/cjs/hooks/useNavigationUtils.js.map +1 -1
  30. package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
  31. package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
  32. package/dist/cjs/types/EntityPageConfig.js.map +1 -1
  33. package/dist/cjs/types/actions/base.js.map +1 -1
  34. package/dist/cjs/types/actions/entityPageActions.js.map +1 -1
  35. package/dist/cjs/utils/actions/types.js.map +1 -1
  36. package/dist/docs/action_cell.md +6 -2
  37. package/dist/docs/app_config_structure.md +48 -6
  38. package/dist/docs/auto-patterns-guide.md +391 -60
  39. package/dist/docs/bulk_actions.md +7 -6
  40. package/dist/docs/collection_page_actions.md +14 -4
  41. package/dist/docs/custom_overrides.md +86 -15
  42. package/dist/docs/entity_page.md +65 -1
  43. package/dist/docs/entity_page_actions.md +13 -11
  44. package/dist/docs/entity_page_view_actions.md +137 -0
  45. package/dist/docs/index.md +6 -2
  46. package/dist/docs/pages_configuration.md +1 -11
  47. package/dist/docs/sdk_utilities.md +11 -4
  48. package/dist/docs/wix_fqdn_custom_data_source.md +25 -5
  49. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +9 -201
  50. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
  51. package/dist/esm/components/AutoPatternsEntityPage/EditModeEntityPage.js +115 -0
  52. package/dist/esm/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -0
  53. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js +33 -0
  54. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js.map +1 -0
  55. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js +70 -0
  56. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js.map +1 -0
  57. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js +48 -0
  58. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js.map +1 -0
  59. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/index.js +3 -0
  60. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/index.js.map +1 -0
  61. package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js +31 -0
  62. package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js.map +1 -0
  63. package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js +66 -0
  64. package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js.map +1 -0
  65. package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.js +109 -0
  66. package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.js.map +1 -0
  67. package/dist/esm/components/AutoPatternsEntityPage/index.js +2 -0
  68. package/dist/esm/components/AutoPatternsEntityPage/index.js.map +1 -1
  69. package/dist/esm/hooks/useActionCell.js.map +1 -1
  70. package/dist/esm/hooks/useEntityPageActions.js +82 -0
  71. package/dist/esm/hooks/useEntityPageActions.js.map +1 -0
  72. package/dist/esm/hooks/useEntityPageMoreActions.js +11 -1
  73. package/dist/esm/hooks/useEntityPageMoreActions.js.map +1 -1
  74. package/dist/esm/hooks/useNavigateEditEntityAction.js +46 -0
  75. package/dist/esm/hooks/useNavigateEditEntityAction.js.map +1 -0
  76. package/dist/esm/hooks/useNavigationUtils.js +12 -1
  77. package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
  78. package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
  79. package/dist/esm/types/EntityPageConfig.js.map +1 -1
  80. package/dist/esm/types/actions/base.js.map +1 -1
  81. package/dist/esm/types/actions/entityPageActions.js.map +1 -1
  82. package/dist/esm/utils/actions/types.js.map +1 -1
  83. package/dist/types/components/AutoPatternsEntityPage/AutoPatternsEntityPage.d.ts.map +1 -1
  84. package/dist/types/components/AutoPatternsEntityPage/EditModeEntityPage.d.ts +6 -0
  85. package/dist/types/components/AutoPatternsEntityPage/EditModeEntityPage.d.ts.map +1 -0
  86. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.d.ts +11 -0
  87. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.d.ts.map +1 -0
  88. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.d.ts +13 -0
  89. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.d.ts.map +1 -0
  90. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.d.ts +8 -0
  91. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.d.ts.map +1 -0
  92. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/index.d.ts +3 -0
  93. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/index.d.ts.map +1 -0
  94. package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.d.ts +8 -0
  95. package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.d.ts.map +1 -0
  96. package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.d.ts +8 -0
  97. package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.d.ts.map +1 -0
  98. package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.d.ts +8 -0
  99. package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.d.ts.map +1 -0
  100. package/dist/types/components/AutoPatternsEntityPage/index.d.ts +2 -0
  101. package/dist/types/components/AutoPatternsEntityPage/index.d.ts.map +1 -1
  102. package/dist/types/hooks/useEntityPageActions.d.ts +9 -0
  103. package/dist/types/hooks/useEntityPageActions.d.ts.map +1 -0
  104. package/dist/types/hooks/useEntityPageHeaderTexts.d.ts.map +1 -1
  105. package/dist/types/hooks/useEntityPageMoreActions.d.ts +2 -2
  106. package/dist/types/hooks/useEntityPageMoreActions.d.ts.map +1 -1
  107. package/dist/types/hooks/useNavigateEditEntityAction.d.ts +6 -0
  108. package/dist/types/hooks/useNavigateEditEntityAction.d.ts.map +1 -0
  109. package/dist/types/hooks/useNavigationUtils.d.ts +1 -0
  110. package/dist/types/hooks/useNavigationUtils.d.ts.map +1 -1
  111. package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -5
  112. package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
  113. package/dist/types/types/EntityPageConfig.d.ts +20 -4
  114. package/dist/types/types/EntityPageConfig.d.ts.map +1 -1
  115. package/dist/types/types/actions/base.d.ts +0 -4
  116. package/dist/types/types/actions/base.d.ts.map +1 -1
  117. package/dist/types/types/actions/entityPageActions.d.ts +24 -5
  118. package/dist/types/types/actions/entityPageActions.d.ts.map +1 -1
  119. package/dist/types/utils/actions/types.d.ts +1 -1
  120. package/dist/types/utils/actions/types.d.ts.map +1 -1
  121. package/package.json +15 -15
  122. package/dist/docs/config_schema.md +0 -184
@@ -95,6 +95,13 @@ It is configured using a TypeScript file conforming to the `AppConfig` interface
95
95
  - Not designating exactly one page as `appMainPage: true`
96
96
  - Missing or inconsistent page relationships (parentPageId/entityPageId)
97
97
  - Setting `stickyColumns` to invalid values (negative, zero, or exceeding column count)
98
+ - **Missing custom property**: When `entityTypeSource: 'custom'`, forgetting to include the required `custom: { id: "..." }` property will cause TypeScript errors
99
+ - **Using incorrect field types**: Mismatching page type with configuration object (e.g., `type: 'entityPage'` with `collectionPage` field)
100
+ - **Including fields from wrong page type**: Adding both `collectionPage` and `entityPage` fields in the same page configuration
101
+ - **Missing action layout properties**: Not including `action` property when `type: 'action'` or `menu` property when `type: 'menu'`
102
+ - **Missing action type properties**: Not including `create`, `update`, `delete`, or `bulkDelete` properties when required by the action type
103
+ - **Including wrong action properties**: Adding properties from different action types in the same action configuration
104
+ - **Action type mismatches**: Using action cell types in collection actions, or bulk action types in regular actions
98
105
 
99
106
  ```ts
100
107
  export interface AppConfig {
@@ -124,8 +131,8 @@ export interface AppConfig {
124
131
  collection: {
125
132
  collectionId: string; // ID of the Wix Data collection
126
133
  entityTypeSource: 'cms' | 'custom'; // Data source type.
127
- custom?: {
128
- id: string;
134
+ custom?: { // REQUIRED when entityTypeSource is 'custom'
135
+ id: string; // ID matching your custom data source identifier
129
136
  };
130
137
  };
131
138
  create?: { // Required when type is 'create'
@@ -154,8 +161,8 @@ export interface AppConfig {
154
161
  collection: {
155
162
  collectionId: string; // ID of the Wix Data collection
156
163
  entityTypeSource: 'cms' | 'custom'; // Data source type.
157
- custom?: {
158
- id: string;
164
+ custom?: { // REQUIRED when entityTypeSource is 'custom'
165
+ id: string; // ID matching your custom data source identifier
159
166
  };
160
167
  reflectQueryInUrl?: boolean; // Reflects query state (search, filters, sorting) in the browser URL. Default: false
161
168
  selectAllScope?: 'page' | 'all'; // Controls "Select All" scope. 'all' selects entire collection, 'page' selects only visible items. Default: 'all'
@@ -376,6 +383,7 @@ export interface AppConfig {
376
383
  ]; // End of components array
377
384
  };
378
385
  entityPage?: {
386
+ mode?: 'edit' | 'view'; // Entity page mode. Default: 'edit'
379
387
  route: {
380
388
  path: string; // Route path for the entity page (e.g., '/product/:entityId')
381
389
  params: {
@@ -388,6 +396,40 @@ export interface AppConfig {
388
396
  subtitle?: {
389
397
  text: string; // Entity page subtitle
390
398
  };
399
+ actions?: { // Action configuration varies by mode
400
+ // Edit mode: only moreActions supported
401
+ // View mode: primaryActions, secondaryActions, and moreActions supported
402
+ primaryActions?: { // View mode only
403
+ type: 'action' | 'menu';
404
+ action?: {
405
+ item: {
406
+ id: string;
407
+ type: 'create' | 'custom';
408
+ label?: string;
409
+ create?: { // Required when type is 'create'
410
+ mode: 'page';
411
+ page: {
412
+ id: string; // Entity page ID to navigate to
413
+ };
414
+ };
415
+ };
416
+ };
417
+ menu?: {
418
+ label: string;
419
+ items: {}[]; // Array of action configurations, same structure as action.item, can include dividers
420
+ };
421
+ };
422
+ secondaryActions?: { // View mode only - same structure as primaryActions
423
+ type: 'action' | 'menu';
424
+ action?: {}; // Same structure as primaryActions.action
425
+ menu?: {}; // Same structure as primaryActions.menu
426
+ };
427
+ moreActions?: { // Both modes
428
+ id: string;
429
+ type: 'custom';
430
+ label?: string;
431
+ }[];
432
+ };
391
433
  parentPageId?: string; // ID of the parent collection page
392
434
  layout?: {
393
435
  // Main layout section
@@ -419,8 +461,8 @@ export interface AppConfig {
419
461
  };
420
462
  collectionId: string; // Related collection ID
421
463
  entityTypeSource: 'cms' | 'custom'; // Data source type.
422
- custom?: {
423
- id: string;
464
+ custom?: { // REQUIRED when entityTypeSource is 'custom'
465
+ id: string; // ID matching your custom data source identifier
424
466
  };
425
467
  };
426
468
  }[];
@@ -519,7 +561,6 @@ Notice how the `label` is derived from the `value` by capitalizing the first let
519
561
  - **Pages array must contain exactly two pages** - one collectionPage and one entityPage
520
562
  - **Exactly one page must have `appMainPage: true`** to designate it as the main page
521
563
  - **All page IDs referenced in relationships must exist in the configuration** - validate all `parentPageId` and `entityPageId` references
522
- - **Bind `type` strictly to matching fields** - if `type: 'collectionPage'`, only `collectionPage` field exists (no `entityPage` field), and vice versa
523
564
 
524
565
  ## Default Generation
525
566
 
@@ -532,12 +573,6 @@ Notice how the `label` is derived from the `value` by capitalizing the first let
532
573
  * The route path **must** include a descriptive segment (e.g., `/product/:entityId`, `/pet/:entityId`)
533
574
  * **Never use just `/:entityId`** - this conflicts with the collection page route and breaks routing
534
575
 
535
- ## Type and Structure Binding
536
-
537
- * If `type: 'collectionPage'`, then **only** `collectionPage` field exists (no `entityPage` field).
538
- * If `type: 'entityPage'`, then **only** `entityPage` field exists (no `collectionPage` field).
539
- * **No cross-mixing** allowed.
540
-
541
576
  ## Page Connection Configuration
542
577
 
543
578
  ### Main Page Designation
@@ -602,11 +637,8 @@ A two-way connection must be established between collection pages and entity pag
602
637
  * **Route Structure**: Entity pages must use `/[segment]/:entityId` format (e.g., `/product/:entityId` or `/pets/:entityId`), never just `/:entityId`
603
638
  * **Route Parameters Configuration**: All entity pages must have both a dynamic parameter in `route.path` and a matching configuration in `route.params`
604
639
 
605
- ## ⚠️ Common Type and Route Mistakes to Avoid
640
+ ## ⚠️ Common Route and Configuration Mistakes to Avoid
606
641
 
607
- - Using incorrect field types
608
- - Missing required fields
609
- - Including fields from wrong page type
610
642
  - Missing route.params for entity pages
611
643
  - Using `/:entityId` instead of `/segment/:entityId` for entity page routes (causes routing conflicts)
612
644
 
@@ -790,11 +822,15 @@ Custom collection page actions execute JavaScript code that you define for colle
790
822
  // Your collection export logic here
791
823
  console.log(`Exporting collection: ${collectionId}`);
792
824
  // Export and update all items on server
793
- return await schema.actions.bulkUpdate({ lastExported: new Date() });
825
+ // Handle potential undefined schema
826
+ if (schema) {
827
+ return await schema.actions.bulkUpdate({ lastExported: new Date() });
828
+ }
829
+ return Promise.resolve(); // fallback when schema is unavailable
794
830
  },
795
831
  successToast: 'Collection exported successfully',
796
832
  errorToast: (err, {retry}) => ({
797
- text: 'Export failed',
833
+ message: 'Export failed',
798
834
  action: { text: 'Retry', onClick: retry }
799
835
  })
800
836
  }
@@ -1017,10 +1053,16 @@ export const quickToggle: CustomActionCollectionPageActionOnRowClickResolver = (
1017
1053
  const updatedItem = { ...item, isActive: !item.isActive };
1018
1054
 
1019
1055
  optimisticActions.updateOne(updatedItem, {
1020
- submit: async (items) => schema.actions.update(items[0]),
1056
+ submit: async (items) => {
1057
+ // Handle potential undefined schema
1058
+ if (schema) {
1059
+ return await schema.actions.update(items[0]);
1060
+ }
1061
+ return items[0]; // fallback when schema is unavailable
1062
+ },
1021
1063
  successToast: `${item.name} toggled successfully`,
1022
1064
  errorToast: (err, {retry}) => ({
1023
- text: 'Toggle failed',
1065
+ message: 'Toggle failed',
1024
1066
  action: { text: 'Retry', onClick: retry }
1025
1067
  })
1026
1068
  });
@@ -1123,9 +1165,15 @@ const optimisticActions = sdk.getOptimisticActions(sdk.collectionId);
1123
1165
  const schema = sdk.getSchema(sdk.collectionId);
1124
1166
 
1125
1167
  optimisticActions.operation(items, {
1126
- submit: async (items) => schema.actions.serverMethod(items),
1168
+ submit: async (items) => {
1169
+ // Handle potential undefined schema
1170
+ if (schema) {
1171
+ return await schema.actions.serverMethod(items);
1172
+ }
1173
+ return items; // fallback when schema is unavailable
1174
+ },
1127
1175
  successToast: 'Success message',
1128
- errorToast: (err, {retry}) => ({ text: 'Error message', action: { text: 'Retry', onClick: retry }})
1176
+ errorToast: (err, {retry}) => ({ message: 'Error message', action: { text: 'Retry', onClick: retry }})
1129
1177
  });
1130
1178
  ```
1131
1179
 
@@ -1156,7 +1204,7 @@ interface OptimisticParams<T> {
1156
1204
  }
1157
1205
 
1158
1206
  interface ToastConfig {
1159
- text: string;
1207
+ message: string; // Note: Use 'message' property, not 'text'
1160
1208
  action?: { text: string; onClick: () => void };
1161
1209
  }
1162
1210
  ```
@@ -1165,9 +1213,10 @@ interface ToastConfig {
1165
1213
 
1166
1214
  **Before using optimistic actions:**
1167
1215
  - Verify `sdk.getOptimisticActions(collectionId)` returns valid instance
1168
- - Verify `sdk.getSchema(collectionId)` returns valid schema
1216
+ - **Always check for undefined schema**: `sdk.getSchema(collectionId)` can return `undefined` - handle this case in your submit functions
1169
1217
  - For delete operations: `showUndoToast: true` is mandatory
1170
1218
  - All `submit` functions must return a Promise
1219
+ - **Toast property**: Use `message` property in ToastConfig, not `text`
1171
1220
 
1172
1221
  **SDK Parameter:** Available in custom actions and modals. See SDK Utilities section for complete interface.
1173
1222
 
@@ -1483,11 +1532,15 @@ Custom actions execute JavaScript code that you define. These actions receive pa
1483
1532
  optimisticActions.updateOne(updatedItem, {
1484
1533
  submit: async (items) => {
1485
1534
  // Your download logic here + update server
1486
- return await schema.actions.update(items[0]);
1535
+ // Handle potential undefined schema
1536
+ if (schema) {
1537
+ return await schema.actions.update(items[0]);
1538
+ }
1539
+ return items[0]; // fallback when schema is unavailable
1487
1540
  },
1488
1541
  successToast: 'Pet details downloaded',
1489
1542
  errorToast: (err, {retry}) => ({
1490
- text: 'Download failed',
1543
+ message: 'Download failed',
1491
1544
  action: { text: 'Retry', onClick: retry }
1492
1545
  })
1493
1546
  });
@@ -1717,11 +1770,15 @@ Custom bulk actions execute JavaScript code that you define for bulk operations.
1717
1770
  a.click();
1718
1771
 
1719
1772
  // Update server with export timestamp
1720
- return await schema.actions.update(items);
1773
+ // Handle potential undefined schema
1774
+ if (schema) {
1775
+ return await schema.actions.update(items);
1776
+ }
1777
+ return items; // fallback when schema is unavailable
1721
1778
  },
1722
1779
  successToast: `${selectedValues.length} pets exported`,
1723
1780
  errorToast: (err, {retry}) => ({
1724
- text: 'Export failed',
1781
+ message: 'Export failed',
1725
1782
  action: { text: 'Retry', onClick: retry }
1726
1783
  })
1727
1784
  });
@@ -1805,10 +1862,7 @@ The bulk action toolbar uses a specific structure for organizing actions:
1805
1862
  "item": {
1806
1863
  "id": "bulkCustom",
1807
1864
  "type": "custom",
1808
- "label": "Custom Bulk",
1809
- "custom": {
1810
- "id": "MyCustomBulk"
1811
- }
1865
+ "label": "Custom Bulk"
1812
1866
  }
1813
1867
  }
1814
1868
  },
@@ -1904,8 +1958,72 @@ All entity pages must have:
1904
1958
 
1905
1959
  * Displays details for a **single entity**.
1906
1960
  * Always tied to a single Wix collection.
1961
+ * Supports **two distinct modes**: **view mode** and **edit mode** with separate page configurations.
1962
+
1963
+ ## Entity Page Modes
1964
+
1965
+ AutoPatterns supports two entity page modes that can be configured as separate pages:
1966
+
1967
+ ### Edit Mode (Default)
1968
+ - **Purpose**: Allows users to modify entity data
1969
+ - **UI**: Uses `@wix/patterns` `EntityPage` component with built-in Save/Cancel actions
1970
+ - **Actions**: Only supports `moreActions` (custom actions in the "more" menu)
1971
+ - **Default Mode**: When `mode` is not specified, defaults to edit mode
1972
+
1973
+ ### View Mode
1974
+ - **Purpose**: Displays entity data in read-only format with rich action capabilities
1975
+ - **Actions**: Supports `primaryActions`, `secondaryActions`, and `moreActions` (collection-style actions)
1976
+ - **Mode**: Must be explicitly set with `mode: 'view'`
1977
+
1978
+
1979
+ ## Routing Patterns
1980
+
1981
+ When implementing both view and edit modes for the same entity, use these routing patterns:
1982
+
1983
+ - **View Mode**: `/entity/:entityId` (e.g., `/product/:productId`)
1984
+ - **Edit Mode**: `/entity/edit/:entityId` (e.g., `/product/edit/:productId`)
1985
+
1986
+ This pattern allows:
1987
+ - Clear distinction between view and edit URLs
1988
+ - Natural navigation flow between modes
1989
+
1990
+ ## View Mode: Purpose and API
1991
+
1992
+ ### Purpose of View Mode
1993
+ View mode is primarily intended for **read-only entity presentation** with rich action capabilities by default; however, it also supports interactive or editable custom components if needed:
1994
+
1995
+ - **Data Display**: Present entity information in a clean, read-only format
1996
+ - **Action Hub**: Provide primary, secondary, and more actions for entity operations
1997
+ - **Navigation Center**: Enable seamless transitions to edit mode and other workflows
1998
+ - **Rich Content**: Display images, rich text, and complex data types optimally
1999
+
2000
+
2001
+ See [Entity Page View Actions](./entity_page_view_actions.md) for detailed action configuration.
1907
2002
 
1908
- > The custom actions must be defined inside the `moreActions` array.
2003
+ #### Out-of-the-Box Features
2004
+
2005
+ **Automatic Edit Navigation**: When a corresponding edit mode page exists, view mode automatically adds an "Edit [EntityName]" action to the more actions menu.
2006
+
2007
+ **Back Navigation**: Automatic "Back" button that navigates to the parent collection page.
2008
+
2009
+ ## Action Configuration
2010
+
2011
+ Entity page action configuration depends on the mode:
2012
+
2013
+ - **Edit Mode**: Supports only `moreActions`. See [Entity Page Actions](./entity_page_actions.md)
2014
+ - **View Mode**: Supports full action API (`primaryActions`, `secondaryActions`, `moreActions`). See [Entity Page View Actions](./entity_page_view_actions.md)
2015
+
2016
+ ### Edit Mode Actions
2017
+ - **Supported**: `moreActions` only
2018
+ - **Built-in**: Save and Cancel actions are automatically provided
2019
+ - **Custom Actions**: Must be defined in the `moreActions` array
2020
+
2021
+ ### View Mode Actions
2022
+ - **Supported**: `primaryActions`, `secondaryActions`, and `moreActions`
2023
+ - **Pattern**: Follows collection page action patterns
2024
+ - **Flexibility**: Full control over all action areas
2025
+
2026
+ > The custom actions must be defined inside the `moreActions` array for edit mode, but view mode supports actions in all areas.
1909
2027
 
1910
2028
  > 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.
1911
2029
 
@@ -1997,11 +2115,13 @@ All entity pages must have:
1997
2115
 
1998
2116
  ---
1999
2117
 
2000
- ## Entity Page Actions: `moreActions` Support
2118
+ ## Entity Page Edit Mode Actions: `moreActions` Support
2119
+
2120
+ Entity pages in **edit mode** support not only built-in actions (such as "Save" and "Cancel") 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.
2001
2121
 
2002
- 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.
2122
+ > **Note:** This documentation covers **edit mode** entity pages only. Edit mode supports only `moreActions`. For **view mode** entity pages that support `primaryActions`, `secondaryActions`, and `moreActions`, see [Entity Page View Actions](./entity_page_view_actions.md).
2003
2123
 
2004
- > **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.
2124
+ > **Edit Mode Limitation:** All custom actions for edit mode entity pages must be placed in the `moreActions` array. Do not place custom actions as primary actions on edit mode entity pages. The `moreActions` array is the only supported location for custom actions on edit mode entity pages.
2005
2125
 
2006
2126
  ### Configuration Structure
2007
2127
 
@@ -2038,16 +2158,16 @@ Entity pages in AutoPatternsApp support not only a primary action (such as "Save
2038
2158
 
2039
2159
  ---
2040
2160
 
2041
- ### CustomEntityPageMoreActionsActionResolver
2161
+ ### CustomEntityPageActionResolver
2042
2162
 
2043
- 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.
2163
+ The `CustomEntityPageActionResolver` 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.
2044
2164
 
2045
2165
  #### Function Signature
2046
2166
 
2047
2167
  ```typescript
2048
- import { CustomEntityPageMoreActionsActionResolver } from '@wix/auto-patterns/types';
2168
+ import { CustomEntityPageActionResolver } from '@wix/auto-patterns/types';
2049
2169
 
2050
- export const myMoreAction: CustomEntityPageMoreActionsActionResolver = (params) => {
2170
+ export const myMoreAction: CustomEntityPageActionResolver = (params) => {
2051
2171
  const { actionParams: { entity, form } , sdk } = params;
2052
2172
 
2053
2173
  return {
@@ -2066,10 +2186,10 @@ export const myMoreAction: CustomEntityPageMoreActionsActionResolver = (params)
2066
2186
 
2067
2187
  ---
2068
2188
 
2069
- #### Key Points for CustomEntityPageMoreActionsActionResolver
2189
+ #### Key Points for CustomEntityPageActionResolver
2070
2190
 
2071
2191
  - The action `id` in the configuration MUST exactly match the function name exported from your actions folder.
2072
- - The implementation must use the `CustomEntityPageMoreActionsActionResolver` type.
2192
+ - The implementation must use the `CustomEntityPageActionResolver` type.
2073
2193
  - The implementation must be exported as a named export (not default export).
2074
2194
  - The function receives `{ actionParams, sdk }` as parameters.
2075
2195
  - The returned object must include at least a `label` and an `onClick` handler (optionally an `icon`).
@@ -2082,13 +2202,153 @@ export const myMoreAction: CustomEntityPageMoreActionsActionResolver = (params)
2082
2202
  ✓ Each action type only includes its required field(s)
2083
2203
  ✓ Custom actions match implementations in overrides
2084
2204
  ✓ The resolver is exported and registered in the `actions` property of your `PatternsWizardOverridesProvider`
2085
- ✓ The function signature matches `CustomEntityPageMoreActionsActionResolver`
2205
+ ✓ The function signature matches `CustomEntityPageActionResolver`
2086
2206
  ✓ The returned object includes `label`, `onClick`, and optionally `icon`
2087
2207
 
2088
2208
  ---
2089
2209
 
2090
2210
  **Summary:**
2091
- 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.
2211
+ The `CustomEntityPageActionResolver` 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.
2212
+
2213
+ ---
2214
+
2215
+ # Entity Page View Mode Actions
2216
+
2217
+ View mode supports the complete collection-style actions API, providing maximum flexibility for entity operations.
2218
+
2219
+ ## Supported Action Types
2220
+
2221
+ ### Primary Actions
2222
+ The main call-to-action, typically for the most common operation:
2223
+
2224
+ ```typescript
2225
+ primaryActions: {
2226
+ type: 'action',
2227
+ action: {
2228
+ item: {
2229
+ id: 'createEntity',
2230
+ label: 'Create New',
2231
+ type: 'create',
2232
+ create: {
2233
+ mode: 'page',
2234
+ page: { id: 'EntityEditPageId' }
2235
+ }
2236
+ }
2237
+ }
2238
+ }
2239
+ ```
2240
+
2241
+ ### Secondary Actions
2242
+ Supporting actions displayed alongside primary actions:
2243
+
2244
+ ```typescript
2245
+ secondaryActions: {
2246
+ type: 'action',
2247
+ action: {
2248
+ item: {
2249
+ id: 'duplicateEntity',
2250
+ label: 'Duplicate',
2251
+ type: 'custom',
2252
+ }
2253
+ }
2254
+ }
2255
+ ```
2256
+
2257
+ ### More Actions
2258
+ Additional contextual actions in dropdown menu:
2259
+
2260
+ ```typescript
2261
+ moreActions: [
2262
+ {
2263
+ id: 'shareEntity',
2264
+ type: 'custom',
2265
+ label: 'Share',
2266
+ }
2267
+ ]
2268
+ ```
2269
+
2270
+ ## Action Menu Support
2271
+
2272
+ View mode also supports menu-style actions for grouping related operations:
2273
+
2274
+ ```typescript
2275
+ primaryActions: {
2276
+ type: 'menu',
2277
+ menu: {
2278
+ label: 'Actions',
2279
+ items: [
2280
+ {
2281
+ id: 'duplicateProduct',
2282
+ label: 'Duplicate',
2283
+ type: 'custom',
2284
+ },
2285
+ { type: 'divider' },
2286
+ {
2287
+ id: 'shareProduct',
2288
+ type: 'custom',
2289
+ label: 'Share'
2290
+ }
2291
+ ]
2292
+ }
2293
+ }
2294
+ ```
2295
+
2296
+ ## Automatic Edit Action
2297
+
2298
+ View mode automatically provides an "Edit [EntityName]" action in the more actions menu when:
2299
+ - An edit mode page exists for the same collection
2300
+ - The edit page has no explicit mode or `mode: 'edit'`
2301
+ - The view page has `mode: 'view'`
2302
+
2303
+ This action is automatically added and doesn't need to be configured manually.
2304
+
2305
+ ## Action Resolvers
2306
+
2307
+ View mode actions follow the same resolver patterns as collection page actions:
2308
+
2309
+ ### For Standard Actions (create)
2310
+ These actions are handled automatically by the AutoPatterns framework using the configuration provided.
2311
+
2312
+ ### For Custom Actions
2313
+ Custom actions require resolver implementations:
2314
+
2315
+ ```typescript
2316
+ import { CustomEntityPageActionResolver } from '@wix/auto-patterns/types';
2317
+
2318
+ export const duplicateProduct: CustomEntityPageActionResolver = (params) => {
2319
+ const { actionParams: { entity }, sdk } = params;
2320
+
2321
+ const schema = sdk.getSchema(sdk.collectionId);
2322
+ return {
2323
+ label: 'Duplicate Product',
2324
+ icon: <DuplicateIcon />, // optional
2325
+ onClick: async () => {
2326
+ // Your custom duplication logic here
2327
+ await schema.actions.create({
2328
+ ...entity,
2329
+ name: `${entity.name} (Copy)`
2330
+ });
2331
+ },
2332
+ };
2333
+ };
2334
+ ```
2335
+
2336
+ ## Best Practices
2337
+
2338
+ ### When to Use Each Action Type
2339
+
2340
+ **Primary Actions**: Use for the most common user action (typically "Create" or main workflow action)
2341
+
2342
+ **Secondary Actions**: Use for supporting workflows like "Duplicate"
2343
+
2344
+ **More Actions**: Use for:
2345
+ - Less common operations
2346
+ - Administrative functions
2347
+ - Actions that need confirmation
2348
+
2349
+ ### Navigation Patterns
2350
+
2351
+ 1. **View → Create**: Use primary actions with `type: 'create'`
2092
2352
 
2093
2353
  ---
2094
2354
 
@@ -2259,14 +2519,73 @@ Each column in the table has a default rendering based on its field type. You ca
2259
2519
 
2260
2520
  ### Function Signature
2261
2521
 
2522
+ For proper TypeScript support, use the `IColumnValue<T>` interface:
2523
+
2262
2524
  ```typescript
2263
- function columnOverride({ value, row }) {
2264
- // value: The individual column value
2265
- // row: The entire row object containing all field values
2525
+ import { IColumnValue } from '@wix/auto-patterns/types';
2526
+
2527
+ function columnOverride(props: IColumnValue<string>) {
2528
+ // props.value: The individual column value (typed)
2529
+ // props.row: The entire row object containing all field values
2266
2530
  return <YourCustomRendering />;
2267
2531
  }
2268
2532
  ```
2269
2533
 
2534
+ ### Type-Specific Examples
2535
+
2536
+ The generic type `T` in `IColumnValue<T>` should match your field's data type:
2537
+
2538
+ ```tsx
2539
+ import React from 'react';
2540
+ import { IColumnValue } from '@wix/auto-patterns/types';
2541
+ import { Badge } from '@wix/design-system';
2542
+
2543
+ /* The `IColumnValue<T>` interface provides type safety for column override functions: */
2544
+ interface IColumnValue<T> {
2545
+ value: T; // The individual column value (strongly typed)
2546
+ row: Record<string, any>; // The entire row object with all field values
2547
+ }
2548
+
2549
+ // For TEXT fields
2550
+ export function petName({ value, row }: IColumnValue<string>) {
2551
+ return <span>{value?.toUpperCase()}</span>;
2552
+ }
2553
+
2554
+ // For NUMBER fields
2555
+ export function age({ value, row }: IColumnValue<number>) {
2556
+ return (
2557
+ <Badge skin={value > 5 ? 'warning' : 'success'}>
2558
+ {value} years old
2559
+ </Badge>
2560
+ );
2561
+ }
2562
+
2563
+ // For BOOLEAN fields
2564
+ export function isVaccinated({ value, row }: IColumnValue<boolean>) {
2565
+ return (
2566
+ <Badge skin={value ? 'success' : 'danger'}>
2567
+ {value ? '✓ Vaccinated' : '✗ Not Vaccinated'}
2568
+ </Badge>
2569
+ );
2570
+ }
2571
+
2572
+ // For DATE/DATETIME fields
2573
+ export function birthDate({ value, row }: IColumnValue<string | Date>) {
2574
+ const date = value instanceof Date ? value : new Date(value);
2575
+ return <span>{date.toLocaleDateString()}</span>;
2576
+ }
2577
+
2578
+ // For IMAGE fields
2579
+ export function profilePicture({ value, row }: IColumnValue<string>) {
2580
+ return <img src={value} alt={row.name} width="48" height="48" />;
2581
+ }
2582
+
2583
+ // For ARRAY fields
2584
+ export function hobbies({ value, row }: IColumnValue<string[]>) {
2585
+ return <span>{value?.join(', ') || 'No hobbies'}</span>;
2586
+ }
2587
+ ```
2588
+
2270
2589
  ### Understanding Row Data
2271
2590
 
2272
2591
  **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.
@@ -2307,22 +2626,29 @@ export function myColumn({ value, row }) {
2307
2626
 
2308
2627
  In `components/columns/name.tsx`:
2309
2628
 
2310
- ```ts
2629
+ ```tsx
2311
2630
  import React from 'react';
2631
+ import { IColumnValue } from '@wix/auto-patterns/types';
2632
+
2633
+ export function name(props: IColumnValue<string>) {
2634
+ // Simple value formatting with TypeScript typing
2635
+ return <strong>{props.value}</strong>;
2636
+ }
2312
2637
 
2313
- export function name({ value, row }) {
2314
- // Simple value formatting
2638
+ // Alternative: Destructured parameters with typing
2639
+ export function nameAlt({ value, row }: IColumnValue<string>) {
2315
2640
  return <strong>{value}</strong>;
2316
2641
  }
2317
2642
  ```
2318
2643
 
2319
2644
  In `components/columns/petInfo.tsx`:
2320
2645
 
2321
- ```ts
2646
+ ```tsx
2322
2647
  import React from 'react';
2323
2648
  import { Box, Text } from '@wix/design-system';
2649
+ import { IColumnValue } from '@wix/auto-patterns/types';
2324
2650
 
2325
- export function petInfo({ value, row }) {
2651
+ export function petInfo({ value, row }: IColumnValue<string>) {
2326
2652
  // Complex column combining multiple row values
2327
2653
  return (
2328
2654
  <Box direction="vertical" gap={1}>
@@ -2340,11 +2666,12 @@ export function petInfo({ value, row }) {
2340
2666
 
2341
2667
  In `components/columns/status.tsx`:
2342
2668
 
2343
- ```ts
2669
+ ```tsx
2344
2670
  import React from 'react';
2345
2671
  import { Badge } from '@wix/design-system';
2672
+ import { IColumnValue } from '@wix/auto-patterns/types';
2346
2673
 
2347
- export function status({ value, row }) {
2674
+ export function status({ value, row }: IColumnValue<string>) {
2348
2675
  // Conditional rendering based on multiple row fields
2349
2676
  if (row.isVaccinated && row.age > 1) {
2350
2677
  return <Badge skin="success">Ready for Adoption</Badge>;
@@ -2358,10 +2685,11 @@ export function status({ value, row }) {
2358
2685
 
2359
2686
  In `components/columns/fullName.tsx`:
2360
2687
 
2361
- ```ts
2688
+ ```tsx
2362
2689
  import React from 'react';
2690
+ import { IColumnValue } from '@wix/auto-patterns/types';
2363
2691
 
2364
- export function fullName({ value, row }) {
2692
+ export function fullName({ value, row }: IColumnValue<string>) {
2365
2693
  // Calculated column using multiple fields
2366
2694
  return `${row.name} (owned by ${row.owner})`;
2367
2695
  }
@@ -2369,10 +2697,11 @@ export function fullName({ value, row }) {
2369
2697
 
2370
2698
  In `components/columns/date.tsx`:
2371
2699
 
2372
- ```ts
2700
+ ```tsx
2373
2701
  import React from 'react';
2702
+ import { IColumnValue } from '@wix/auto-patterns/types';
2374
2703
 
2375
- export function date({ value, row }) {
2704
+ export function date({ value, row }: IColumnValue<string>) {
2376
2705
  // Access to other row data for enhanced date formatting
2377
2706
  const isRecent = row.lastActivity && new Date(row.lastActivity) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
2378
2707
 
@@ -2455,6 +2784,8 @@ PatternsWizardOverridesProvider
2455
2784
 
2456
2785
  ### Important Guidelines
2457
2786
 
2787
+ - **TypeScript Usage**: Always use `IColumnValue<T>` and import it from `@wix/auto-patterns/types`
2788
+ - **Type Matching**: Ensure the generic type `T` matches your field's actual data type (string, number, boolean, etc.)
2458
2789
  - **Performance**: Remember that column functions are called for every row, so keep calculations lightweight
2459
2790
  - **Consistency**: When using row data, ensure the column header accurately represents what's displayed
2460
2791
  - **Accessibility**: Maintain proper semantic structure when combining multiple values
@@ -3073,7 +3404,7 @@ import * as columns from './components/columns';
3073
3404
  import * as actions from './components/actions';
3074
3405
 
3075
3406
  <PatternsWizardOverridesProvider value={{ sections, columns, actions }}>
3076
- <AutoPatternsApp configuration={config as AppConfig} />
3407
+ <AutoPatternsApp configuration={config} />
3077
3408
  </PatternsWizardOverridesProvider>
3078
3409
  ```
3079
3410