@wix/auto-patterns 1.21.0 → 1.23.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 (110) hide show
  1. package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +109 -0
  2. package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -0
  3. package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +5 -14
  4. package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
  5. package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +19 -68
  6. package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
  7. package/dist/cjs/hooks/useActionCell.js +10 -2
  8. package/dist/cjs/hooks/useActionCell.js.map +1 -1
  9. package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
  10. package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
  11. package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
  12. package/dist/cjs/types/actions/actionCell.js.map +1 -1
  13. package/dist/cjs/types/actions/base.js.map +1 -1
  14. package/dist/docs/action_cell.md +13 -3
  15. package/dist/docs/app_config_structure.md +7 -4
  16. package/dist/docs/auto-patterns-guide.md +288 -35
  17. package/dist/docs/bulk_actions.md +1 -4
  18. package/dist/docs/custom_overrides.md +267 -24
  19. package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +71 -0
  20. package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -0
  21. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +1 -3
  22. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
  23. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +16 -48
  24. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
  25. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +8 -13
  26. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
  27. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js +6 -10
  28. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js.map +1 -1
  29. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js +16 -23
  30. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js.map +1 -1
  31. package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js +2 -3
  32. package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js.map +1 -1
  33. package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js +6 -9
  34. package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js.map +1 -1
  35. package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js +6 -8
  36. package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js.map +1 -1
  37. package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js +8 -10
  38. package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js.map +1 -1
  39. package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js +10 -12
  40. package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js.map +1 -1
  41. package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js +6 -8
  42. package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js.map +1 -1
  43. package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js +4 -7
  44. package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -1
  45. package/dist/esm/components/ModalRenderer.js +1 -2
  46. package/dist/esm/components/ModalRenderer.js.map +1 -1
  47. package/dist/esm/components/modals/actions/BulkDeleteModal.js +7 -12
  48. package/dist/esm/components/modals/actions/BulkDeleteModal.js.map +1 -1
  49. package/dist/esm/components/modals/actions/CreateModal.js +6 -11
  50. package/dist/esm/components/modals/actions/CreateModal.js.map +1 -1
  51. package/dist/esm/components/modals/actions/EditModal.js +6 -11
  52. package/dist/esm/components/modals/actions/EditModal.js.map +1 -1
  53. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +3 -4
  54. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  55. package/dist/esm/dataSourceAdapters/cms/filterUtils.js +1 -2
  56. package/dist/esm/dataSourceAdapters/cms/filterUtils.js.map +1 -1
  57. package/dist/esm/dataSourceAdapters/cms/sortUtils.js +2 -2
  58. package/dist/esm/dataSourceAdapters/cms/sortUtils.js.map +1 -1
  59. package/dist/esm/hooks/useActionCell.js +16 -12
  60. package/dist/esm/hooks/useActionCell.js.map +1 -1
  61. package/dist/esm/hooks/useBaseTableFeatures.js +1 -2
  62. package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
  63. package/dist/esm/hooks/useBulkActionToolbar.js +2 -2
  64. package/dist/esm/hooks/useBulkActionToolbar.js.map +1 -1
  65. package/dist/esm/hooks/useCollectionPageActions.js +3 -3
  66. package/dist/esm/hooks/useCollectionPageActions.js.map +1 -1
  67. package/dist/esm/hooks/useCollectionPageOnRowClickActions.js +1 -1
  68. package/dist/esm/hooks/useCollectionPageOnRowClickActions.js.map +1 -1
  69. package/dist/esm/hooks/useColumns.js +7 -12
  70. package/dist/esm/hooks/useColumns.js.map +1 -1
  71. package/dist/esm/hooks/useCommonCollectionFeatures.js +7 -8
  72. package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
  73. package/dist/esm/hooks/useEmptyStates.js +5 -6
  74. package/dist/esm/hooks/useEmptyStates.js.map +1 -1
  75. package/dist/esm/hooks/useFilters.js +7 -7
  76. package/dist/esm/hooks/useFilters.js.map +1 -1
  77. package/dist/esm/hooks/useNavigationUtils.js +2 -3
  78. package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
  79. package/dist/esm/hooks/usePagePath.js +3 -4
  80. package/dist/esm/hooks/usePagePath.js.map +1 -1
  81. package/dist/esm/hooks/useTableFeatures.js +1 -2
  82. package/dist/esm/hooks/useTableFeatures.js.map +1 -1
  83. package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
  84. package/dist/esm/providers/SchemaContext.js +2 -3
  85. package/dist/esm/providers/SchemaContext.js.map +1 -1
  86. package/dist/esm/providers/SchemaRegistryContext.js +1 -1
  87. package/dist/esm/providers/SchemaRegistryContext.js.map +1 -1
  88. package/dist/esm/types/CollectionPageConfig.js.map +1 -1
  89. package/dist/esm/types/actions/actionCell.js.map +1 -1
  90. package/dist/esm/types/actions/base.js.map +1 -1
  91. package/dist/esm/utils/actions/customAction.js +1 -2
  92. package/dist/esm/utils/actions/customAction.js.map +1 -1
  93. package/dist/esm/utils/actions/deleteAction.js +5 -10
  94. package/dist/esm/utils/actions/deleteAction.js.map +1 -1
  95. package/dist/esm/utils/filterCreators.js +11 -11
  96. package/dist/esm/utils/filterCreators.js.map +1 -1
  97. package/dist/types/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.d.ts +7 -0
  98. package/dist/types/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.d.ts.map +1 -0
  99. package/dist/types/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.d.ts.map +1 -1
  100. package/dist/types/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.d.ts.map +1 -1
  101. package/dist/types/hooks/useActionCell.d.ts.map +1 -1
  102. package/dist/types/providers/PatternsWizardOverridesContext.d.ts +3 -6
  103. package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
  104. package/dist/types/types/CollectionPageConfig.d.ts +7 -1
  105. package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
  106. package/dist/types/types/actions/actionCell.d.ts +1 -0
  107. package/dist/types/types/actions/actionCell.d.ts.map +1 -1
  108. package/dist/types/types/actions/base.d.ts +0 -4
  109. package/dist/types/types/actions/base.d.ts.map +1 -1
  110. package/package.json +11 -11
@@ -28,6 +28,10 @@ your-page/
28
28
  │ ├── index.tsx // Exports useColumns hook
29
29
  │ ├── name.ts
30
30
  │ └── date.ts
31
+ ├── slots/ // Custom slot components for collection pages
32
+ │ ├── index.tsx // Exports useSlots hook
33
+ │ ├── TopBannerComponent.tsx
34
+ │ └── BottomStatsComponent.tsx
31
35
  ├── customComponents/ // Custom entity page components
32
36
  │ ├── index.tsx // Exports useComponents hook
33
37
  │ ├── CustomNameField.tsx
@@ -35,16 +39,12 @@ your-page/
35
39
  ├── modals/ // Custom modals
36
40
  │ ├── index.tsx // Exports useModals hook
37
41
  │ └── myCustomModal.tsx
38
- └── customDataSources/ // Custom data sources
42
+ ├── customDataSources/ // Custom data sources
39
43
  │ ├── index.tsx // Exports useCustomDataSources hook
40
44
  │ └── myCustomDataSource.ts
41
- ├── sections/ // Section renderers
42
- │ ├── index.tsx
43
- │ └── groupByType.ts
44
- └── customComponents/ // Custom entity page components
45
+ └── sections/ // Section renderers
45
46
  ├── index.tsx
46
- ├── CustomNameField.tsx
47
- └── InfoCard.tsx
47
+ └── groupByType.ts
48
48
  ```
49
49
 
50
50
  ### Using Override Hooks in Your Page
@@ -54,6 +54,7 @@ In your page component, use the hook-based approach to access React context and
54
54
  ```tsx
55
55
  import { useActions } from '../components/actions';
56
56
  import { useColumns } from '../components/columns';
57
+ import { useSlots } from '../components/slots';
57
58
  import { useSections } from '../components/sections';
58
59
  import { useComponents } from '../components/customComponents';
59
60
  import { useModals } from '../components/modals';
@@ -62,13 +63,14 @@ import { useCustomDataSources } from '../components/customDataSources';
62
63
  export default function YourPage() {
63
64
  const actions = useActions();
64
65
  const columns = useColumns();
66
+ const slots = useSlots();
65
67
  const sections = useSections();
66
68
  const components = useComponents();
67
69
  const modals = useModals();
68
70
  const customDataSources = useCustomDataSources();
69
71
 
70
72
  return (
71
- <PatternsWizardOverridesProvider value={{ actions, columns, sections, components, modals, customDataSources }}>
73
+ <PatternsWizardOverridesProvider value={{ actions, columns, slots, sections, components, modals, customDataSources }}>
72
74
  <AutoPatternsApp configuration={config} />
73
75
  </PatternsWizardOverridesProvider>
74
76
  );
@@ -77,12 +79,13 @@ export default function YourPage() {
77
79
 
78
80
  ### Important: Updating Hook Index Files
79
81
 
80
- **When adding any new implementation (action, modal, column, section or component), you MUST update the corresponding hook in the `index.tsx` file to include your new implementation.** The main page component uses these hooks, so they serve as the central export point for each type of override.
82
+ **When adding any new implementation (action, modal, column, slot, section or component), you MUST update the corresponding hook in the `index.tsx` file to include your new implementation.** The main page component uses these hooks, so they serve as the central export point for each type of override.
81
83
 
82
84
  For example:
83
85
  - Adding a new action → Update `../components/actions/index.tsx` to include the new action in the `useActions` hook
84
86
  - Adding a new modal → Update `../components/modals/index.tsx` to include the new modal in the `useModals` hook
85
87
  - Adding a new column override → Update `../components/columns/index.tsx` to include the new column in the `useColumns` hook
88
+ - Adding a new slot component → Update `../components/slots/index.tsx` to include the new slot in the `useSlots` hook
86
89
  - Adding a new section renderer → Update `../components/sections/index.tsx` to include the new section in the `useSections` hook
87
90
  - Adding a new custom component → Update `../components/customComponents/index.tsx` to include the new component in the `useComponents` hook
88
91
  - Adding a new custom data source → Update `../components/customDataSources/index.tsx` to include the new data source in the `useCustomDataSources` hook
@@ -105,14 +108,73 @@ Each column in the table has a default rendering based on its field type. You ca
105
108
 
106
109
  ### Function Signature
107
110
 
111
+ For proper TypeScript support, use the `IColumnValue<T>` interface:
112
+
108
113
  ```typescript
109
- function columnOverride({ value, row }) {
110
- // value: The individual column value
111
- // row: The entire row object containing all field values
114
+ import { IColumnValue } from '@wix/auto-patterns/types';
115
+
116
+ function columnOverride(props: IColumnValue<string>) {
117
+ // props.value: The individual column value (typed)
118
+ // props.row: The entire row object containing all field values
112
119
  return <YourCustomRendering />;
113
120
  }
114
121
  ```
115
122
 
123
+ ### Type-Specific Examples
124
+
125
+ The generic type `T` in `IColumnValue<T>` should match your field's data type:
126
+
127
+ ```tsx
128
+ import React from 'react';
129
+ import { IColumnValue } from '@wix/auto-patterns/types';
130
+ import { Badge } from '@wix/design-system';
131
+
132
+ /* The `IColumnValue<T>` interface provides type safety for column override functions: */
133
+ interface IColumnValue<T> {
134
+ value: T; // The individual column value (strongly typed)
135
+ row: Record<string, any>; // The entire row object with all field values
136
+ }
137
+
138
+ // For TEXT fields
139
+ export function petName({ value, row }: IColumnValue<string>) {
140
+ return <span>{value?.toUpperCase()}</span>;
141
+ }
142
+
143
+ // For NUMBER fields
144
+ export function age({ value, row }: IColumnValue<number>) {
145
+ return (
146
+ <Badge skin={value > 5 ? 'warning' : 'success'}>
147
+ {value} years old
148
+ </Badge>
149
+ );
150
+ }
151
+
152
+ // For BOOLEAN fields
153
+ export function isVaccinated({ value, row }: IColumnValue<boolean>) {
154
+ return (
155
+ <Badge skin={value ? 'success' : 'danger'}>
156
+ {value ? '✓ Vaccinated' : '✗ Not Vaccinated'}
157
+ </Badge>
158
+ );
159
+ }
160
+
161
+ // For DATE/DATETIME fields
162
+ export function birthDate({ value, row }: IColumnValue<string | Date>) {
163
+ const date = value instanceof Date ? value : new Date(value);
164
+ return <span>{date.toLocaleDateString()}</span>;
165
+ }
166
+
167
+ // For IMAGE fields
168
+ export function profilePicture({ value, row }: IColumnValue<string>) {
169
+ return <img src={value} alt={row.name} width="48" height="48" />;
170
+ }
171
+
172
+ // For ARRAY fields
173
+ export function hobbies({ value, row }: IColumnValue<string[]>) {
174
+ return <span>{value?.join(', ') || 'No hobbies'}</span>;
175
+ }
176
+ ```
177
+
116
178
  ### Understanding Row Data
117
179
 
118
180
  **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.
@@ -153,22 +215,29 @@ export function myColumn({ value, row }) {
153
215
 
154
216
  In `components/columns/name.tsx`:
155
217
 
156
- ```ts
218
+ ```tsx
157
219
  import React from 'react';
220
+ import { IColumnValue } from '@wix/auto-patterns/types';
158
221
 
159
- export function name({ value, row }) {
160
- // Simple value formatting
222
+ export function name(props: IColumnValue<string>) {
223
+ // Simple value formatting with TypeScript typing
224
+ return <strong>{props.value}</strong>;
225
+ }
226
+
227
+ // Alternative: Destructured parameters with typing
228
+ export function nameAlt({ value, row }: IColumnValue<string>) {
161
229
  return <strong>{value}</strong>;
162
230
  }
163
231
  ```
164
232
 
165
233
  In `components/columns/petInfo.tsx`:
166
234
 
167
- ```ts
235
+ ```tsx
168
236
  import React from 'react';
169
237
  import { Box, Text } from '@wix/design-system';
238
+ import { IColumnValue } from '@wix/auto-patterns/types';
170
239
 
171
- export function petInfo({ value, row }) {
240
+ export function petInfo({ value, row }: IColumnValue<string>) {
172
241
  // Complex column combining multiple row values
173
242
  return (
174
243
  <Box direction="vertical" gap={1}>
@@ -186,11 +255,12 @@ export function petInfo({ value, row }) {
186
255
 
187
256
  In `components/columns/status.tsx`:
188
257
 
189
- ```ts
258
+ ```tsx
190
259
  import React from 'react';
191
260
  import { Badge } from '@wix/design-system';
261
+ import { IColumnValue } from '@wix/auto-patterns/types';
192
262
 
193
- export function status({ value, row }) {
263
+ export function status({ value, row }: IColumnValue<string>) {
194
264
  // Conditional rendering based on multiple row fields
195
265
  if (row.isVaccinated && row.age > 1) {
196
266
  return <Badge skin="success">Ready for Adoption</Badge>;
@@ -204,10 +274,11 @@ export function status({ value, row }) {
204
274
 
205
275
  In `components/columns/fullName.tsx`:
206
276
 
207
- ```ts
277
+ ```tsx
208
278
  import React from 'react';
279
+ import { IColumnValue } from '@wix/auto-patterns/types';
209
280
 
210
- export function fullName({ value, row }) {
281
+ export function fullName({ value, row }: IColumnValue<string>) {
211
282
  // Calculated column using multiple fields
212
283
  return `${row.name} (owned by ${row.owner})`;
213
284
  }
@@ -215,10 +286,11 @@ export function fullName({ value, row }) {
215
286
 
216
287
  In `components/columns/date.tsx`:
217
288
 
218
- ```ts
289
+ ```tsx
219
290
  import React from 'react';
291
+ import { IColumnValue } from '@wix/auto-patterns/types';
220
292
 
221
- export function date({ value, row }) {
293
+ export function date({ value, row }: IColumnValue<string>) {
222
294
  // Access to other row data for enhanced date formatting
223
295
  const isRecent = row.lastActivity && new Date(row.lastActivity) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
224
296
 
@@ -301,6 +373,8 @@ PatternsWizardOverridesProvider
301
373
 
302
374
  ### Important Guidelines
303
375
 
376
+ - **TypeScript Usage**: Always use `IColumnValue<T>` and import it from `@wix/auto-patterns/types`
377
+ - **Type Matching**: Ensure the generic type `T` matches your field's actual data type (string, number, boolean, etc.)
304
378
  - **Performance**: Remember that column functions are called for every row, so keep calculations lightweight
305
379
  - **Consistency**: When using row data, ensure the column header accurately represents what's displayed
306
380
  - **Accessibility**: Maintain proper semantic structure when combining multiple values
@@ -812,6 +886,10 @@ interface Section {
812
886
  prefixIcon?: React.ReactElement;
813
887
  onClick: () => void;
814
888
  };
889
+ badge?: {
890
+ visible: boolean;
891
+ skin?: 'light' | 'danger' | 'neutralLight';
892
+ };
815
893
  }
816
894
  ```
817
895
 
@@ -819,6 +897,7 @@ The section renderer receives an item and returns:
819
897
  - **id**: A unique identifier for the section (items with the same id are grouped together)
820
898
  - **title**: The text displayed in the section header
821
899
  - **primaryAction** (optional): An action button displayed in the section header
900
+ - **badge** (optional): A badge configuration displayed in the section header
822
901
 
823
902
  #### Example: Section Renderer Implementation
824
903
 
@@ -844,6 +923,10 @@ export function groupByType(item: any): Section {
844
923
  console.log(`Showing all ${petType}s`);
845
924
  },
846
925
  },
926
+ badge: {
927
+ visible: true,
928
+ skin: 'light',
929
+ },
847
930
  };
848
931
  }
849
932
  ```
@@ -866,16 +949,20 @@ export function groupByAgeAndVaccination(item: any): Section {
866
949
 
867
950
  let sectionId: string;
868
951
  let sectionTitle: string;
952
+ let badgeSkin: 'light' | 'danger' | 'neutralLight' = 'light';
869
953
 
870
954
  if (age < 1) {
871
955
  sectionId = 'puppies';
872
956
  sectionTitle = 'Puppies (Under 1 year)';
957
+ badgeSkin = 'neutralLight';
873
958
  } else if (age >= 1 && age <= 5) {
874
959
  sectionId = isVaccinated ? 'young-vaccinated' : 'young-unvaccinated';
875
960
  sectionTitle = `Young Adults (1-5 years) - ${isVaccinated ? 'Vaccinated' : 'Not Vaccinated'}`;
961
+ badgeSkin = isVaccinated ? 'light' : 'danger';
876
962
  } else {
877
963
  sectionId = 'seniors';
878
964
  sectionTitle = 'Senior Pets (5+ years)';
965
+ badgeSkin = 'light';
879
966
  }
880
967
 
881
968
  return {
@@ -888,6 +975,10 @@ export function groupByAgeAndVaccination(item: any): Section {
888
975
  // Show special care information for puppies
889
976
  },
890
977
  } : undefined,
978
+ badge: {
979
+ visible: true,
980
+ skin: badgeSkin,
981
+ },
891
982
  };
892
983
  }
893
984
  ```
@@ -902,7 +993,7 @@ import * as columns from './components/columns';
902
993
  import * as actions from './components/actions';
903
994
 
904
995
  <PatternsWizardOverridesProvider value={{ sections, columns, actions }}>
905
- <AutoPatternsApp configuration={config as AppConfig} />
996
+ <AutoPatternsApp configuration={config} />
906
997
  </PatternsWizardOverridesProvider>
907
998
  ```
908
999
 
@@ -915,3 +1006,155 @@ import * as actions from './components/actions';
915
1006
 
916
1007
 
917
1008
  By implementing sections, you can significantly improve the user experience when dealing with large datasets by providing logical groupings that make information easier to find and understand.
1009
+
1010
+ ## Slots
1011
+
1012
+ Slots allow you to inject custom React components into collection pages at specific points in the component hierarchy. Unlike other overrides that modify existing functionality, slots enable you to add entirely custom UI elements anywhere within the collection page components array.
1013
+
1014
+ Slots are useful for:
1015
+ - Adding custom banners or announcements above or below the table/grid
1016
+ - Inserting analytics widgets or dashboards
1017
+ - Adding custom promotional content
1018
+ - Implementing page-specific functionality that doesn't fit into standard patterns
1019
+
1020
+ ### Configuration Structure
1021
+
1022
+ Slots are configured in the collection page configuration using the `CustomComponentConfig` structure:
1023
+
1024
+ ```json
1025
+ {
1026
+ "type": "custom",
1027
+ "id": "myCustomSlot"
1028
+ }
1029
+ ```
1030
+
1031
+ **Key Properties:**
1032
+ - `type`: Must be set to `"custom"` to identify this as a slot component
1033
+ - `id`: A unique identifier that maps to your slot component implementation
1034
+
1035
+ ### Component Positioning
1036
+
1037
+ Slot components can be positioned anywhere within the `components` array of a collection page. They will be rendered in the exact order specified in the configuration:
1038
+
1039
+ ```json
1040
+ {
1041
+ "type": "collectionPage",
1042
+ "collectionPage": {
1043
+ "components": [
1044
+ {
1045
+ "type": "custom",
1046
+ "id": "topBanner"
1047
+ },
1048
+ {
1049
+ "type": "collection",
1050
+ "collection": {
1051
+ "collectionId": "MyCollection"
1052
+ },
1053
+ "layout": [...]
1054
+ },
1055
+ {
1056
+ "type": "custom",
1057
+ "id": "bottomStats"
1058
+ }
1059
+ ]
1060
+ }
1061
+ }
1062
+ ```
1063
+
1064
+ This configuration will render:
1065
+ 1. The custom `topBanner` component at the top
1066
+ 2. The main collection component (table/grid) in the middle
1067
+ 3. The custom `bottomStats` component at the bottom
1068
+
1069
+ ### Implementation Structure
1070
+
1071
+ #### Creating Slot Components
1072
+
1073
+ Slot components are standard React functional components that take no props:
1074
+
1075
+ ```tsx
1076
+ import React from 'react';
1077
+ import { Box, Card, Text, Button } from '@wix/design-system';
1078
+
1079
+ export const TopBannerComponent: React.FC = () => {
1080
+ return (
1081
+ <Card>
1082
+ <Card.Content>
1083
+ <Box direction="vertical" gap={2}>
1084
+ <Text size="large" weight="bold">Welcome to Pet Management</Text>
1085
+ <Text>Manage all your pets from this central dashboard.</Text>
1086
+ <Button size="small">Get Started</Button>
1087
+ </Box>
1088
+ </Card.Content>
1089
+ </Card>
1090
+ );
1091
+ };
1092
+
1093
+ export const BottomStatsComponent: React.FC = () => {
1094
+ return (
1095
+ <Card>
1096
+ <Card.Content>
1097
+ <Box direction="horizontal" gap={4}>
1098
+ <Box direction="vertical" gap={1}>
1099
+ <Text size="large" weight="bold">47</Text>
1100
+ <Text size="small">Total Pets</Text>
1101
+ </Box>
1102
+ <Box direction="vertical" gap={1}>
1103
+ <Text size="large" weight="bold">12</Text>
1104
+ <Text size="small">Available for Adoption</Text>
1105
+ </Box>
1106
+ </Box>
1107
+ </Card.Content>
1108
+ </Card>
1109
+ );
1110
+ };
1111
+ ```
1112
+
1113
+ #### Creating the Slots Hook
1114
+
1115
+ In `components/slots/index.tsx`:
1116
+
1117
+ ```tsx
1118
+ import { TopBannerComponent } from './TopBannerComponent';
1119
+ import { BottomStatsComponent } from './BottomStatsComponent';
1120
+
1121
+ export const useSlots = () => {
1122
+ // You can access React context and other hooks here
1123
+ return {
1124
+ topBanner: TopBannerComponent,
1125
+ bottomStats: BottomStatsComponent
1126
+ };
1127
+ };
1128
+ ```
1129
+
1130
+ **Important:** Every time you create a new slot component, you must import it and add it to the `useSlots` hook return object. The key in the return object must match the `id` specified in your JSON configuration.
1131
+
1132
+ #### Registering Slots in Your Page
1133
+
1134
+ In your main page component:
1135
+
1136
+ ```tsx
1137
+ import { useSlots } from '../components/slots';
1138
+
1139
+ export default function YourPage() {
1140
+ const slots = useSlots();
1141
+
1142
+ return (
1143
+ <PatternsWizardOverridesProvider value={{ slots }}>
1144
+ <AutoPatternsApp configuration={config} />
1145
+ </PatternsWizardOverridesProvider>
1146
+ );
1147
+ }
1148
+ ```
1149
+
1150
+ ### Important Guidelines for Slots
1151
+
1152
+ 1. **Component Signature**: Slot components must be React functional components with no props: `React.FC`
1153
+ 2. **Rendering Order**: Components render in the exact order specified in the `components` array
1154
+ 3. **Performance**: Slot components re-render with the page, so optimize for performance if needed
1155
+ 4. **Styling**: Follow the design system patterns and responsive design principles
1156
+
1157
+
1158
+ **Important:** Every time you create a new slot component, you must import it and add it to the `useSlots` hook return object in the `./components/slots/index.tsx` file. The key must match the `id` specified in your JSON configuration.
1159
+
1160
+ Slots provide a powerful way to enhance collection pages with custom functionality while maintaining the structure and features of the AutoPatterns system.
@@ -0,0 +1,71 @@
1
+ import { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';
2
+ import { AutoPatternsTable } from '../AutoPatternsTable';
3
+ import { AutoPatternsGrid } from '../AutoPatternsGrid';
4
+ import { SchemaProvider } from '../../providers';
5
+ import { SkeletonCollection } from '../AutoPatternsCollectionPageContent/SkeletonCollection';
6
+ import React, { useMemo } from 'react';
7
+ export const AutoPatternsCollectionComponent = _ref => {
8
+ let {
9
+ component,
10
+ index
11
+ } = _ref;
12
+ const {
13
+ layout,
14
+ ...sharedConfig
15
+ } = component;
16
+ const memoized = useMemo(() => {
17
+ if (!layout?.length) {
18
+ return {
19
+ componentToRender: null,
20
+ componentType: 'Table'
21
+ };
22
+ }
23
+ const tableConfig = layout.find(item => item.type === 'Table')?.table;
24
+ const gridConfig = layout.find(item => item.type === 'Grid')?.grid;
25
+ let componentType = 'Table';
26
+ let componentToRender = null;
27
+ if (tableConfig && gridConfig) {
28
+ const config = {
29
+ ...sharedConfig,
30
+ ...tableConfig,
31
+ ...gridConfig
32
+ };
33
+ componentToRender = /*#__PURE__*/React.createElement(AutoPatternsTableGridSwitch, {
34
+ configuration: config
35
+ });
36
+ } else if (tableConfig) {
37
+ const config = {
38
+ ...sharedConfig,
39
+ ...tableConfig
40
+ };
41
+ componentToRender = /*#__PURE__*/React.createElement(AutoPatternsTable, {
42
+ configuration: config
43
+ });
44
+ } else if (gridConfig) {
45
+ componentType = 'Grid';
46
+ const config = {
47
+ ...sharedConfig,
48
+ ...gridConfig
49
+ };
50
+ componentToRender = /*#__PURE__*/React.createElement(AutoPatternsGrid, {
51
+ configuration: config
52
+ });
53
+ }
54
+ return {
55
+ componentToRender,
56
+ componentType
57
+ };
58
+ }, [layout, sharedConfig]);
59
+ const {
60
+ componentToRender,
61
+ componentType
62
+ } = memoized;
63
+ return /*#__PURE__*/React.createElement(React.Fragment, null, componentToRender ? /*#__PURE__*/React.createElement(SchemaProvider, {
64
+ key: `${sharedConfig.collection.collectionId}-${index}`,
65
+ collection: sharedConfig.collection,
66
+ skeleton: /*#__PURE__*/React.createElement(SkeletonCollection, {
67
+ componentType: componentType
68
+ })
69
+ }, componentToRender) : null);
70
+ };
71
+ //# sourceMappingURL=AutoPatternsCollectionComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["AutoPatternsTableGridSwitch","AutoPatternsTable","AutoPatternsGrid","SchemaProvider","SkeletonCollection","React","useMemo","AutoPatternsCollectionComponent","_ref","component","index","layout","sharedConfig","memoized","length","componentToRender","componentType","tableConfig","find","item","type","table","gridConfig","grid","config","createElement","configuration","Fragment","key","collection","collectionId","skeleton"],"sources":["../../../../src/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.tsx"],"sourcesContent":["import { CollectionComponentConfig } from '../../types';\nimport { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';\nimport { AutoPatternsTable } from '../AutoPatternsTable';\nimport { AutoPatternsGrid } from '../AutoPatternsGrid';\nimport { SchemaProvider } from '../../providers';\nimport { SkeletonCollection } from '../AutoPatternsCollectionPageContent/SkeletonCollection';\nimport React, { useMemo } from 'react';\n\nexport const AutoPatternsCollectionComponent = ({\n component,\n index,\n}: {\n component: CollectionComponentConfig;\n index: number;\n}) => {\n const { layout, ...sharedConfig } = component;\n\n const memoized = useMemo(() => {\n if (!layout?.length) {\n return {\n componentToRender: null,\n componentType: 'Table' as 'Table' | 'Grid',\n };\n }\n\n const tableConfig = layout.find((item) => item.type === 'Table')?.table;\n const gridConfig = layout.find((item) => item.type === 'Grid')?.grid;\n\n let componentType: 'Table' | 'Grid' = 'Table';\n let componentToRender: React.ReactNode = null;\n\n if (tableConfig && gridConfig) {\n const config = {\n ...sharedConfig,\n ...tableConfig,\n ...gridConfig,\n };\n componentToRender = (\n <AutoPatternsTableGridSwitch configuration={config} />\n );\n } else if (tableConfig) {\n const config = { ...sharedConfig, ...tableConfig };\n componentToRender = <AutoPatternsTable configuration={config} />;\n } else if (gridConfig) {\n componentType = 'Grid';\n const config = { ...sharedConfig, ...gridConfig };\n componentToRender = <AutoPatternsGrid configuration={config} />;\n }\n\n return { componentToRender, componentType };\n }, [layout, sharedConfig]);\n\n const { componentToRender, componentType } = memoized;\n\n return (\n <>\n {componentToRender ? (\n <SchemaProvider\n key={`${sharedConfig.collection.collectionId}-${index}`}\n collection={sharedConfig.collection}\n skeleton={<SkeletonCollection componentType={componentType} />}\n >\n {componentToRender}\n </SchemaProvider>\n ) : null}\n </>\n );\n};\n"],"mappings":"AACA,SAASA,2BAA2B,QAAQ,4DAA4D;AACxG,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,kBAAkB,QAAQ,yDAAyD;AAC5F,OAAOC,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAEtC,OAAO,MAAMC,+BAA+B,GAAGC,IAAA,IAMzC;EAAA,IAN0C;IAC9CC,SAAS;IACTC;EAIF,CAAC,GAAAF,IAAA;EACC,MAAM;IAAEG,MAAM;IAAE,GAAGC;EAAa,CAAC,GAAGH,SAAS;EAE7C,MAAMI,QAAQ,GAAGP,OAAO,CAAC,MAAM;IAC7B,IAAI,CAACK,MAAM,EAAEG,MAAM,EAAE;MACnB,OAAO;QACLC,iBAAiB,EAAE,IAAI;QACvBC,aAAa,EAAE;MACjB,CAAC;IACH;IAEA,MAAMC,WAAW,GAAGN,MAAM,CAACO,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,OAAO,CAAC,EAAEC,KAAK;IACvE,MAAMC,UAAU,GAAGX,MAAM,CAACO,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,MAAM,CAAC,EAAEG,IAAI;IAEpE,IAAIP,aAA+B,GAAG,OAAO;IAC7C,IAAID,iBAAkC,GAAG,IAAI;IAE7C,IAAIE,WAAW,IAAIK,UAAU,EAAE;MAC7B,MAAME,MAAM,GAAG;QACb,GAAGZ,YAAY;QACf,GAAGK,WAAW;QACd,GAAGK;MACL,CAAC;MACDP,iBAAiB,gBACfV,KAAA,CAAAoB,aAAA,CAACzB,2BAA2B;QAAC0B,aAAa,EAAEF;MAAO,CAAE,CACtD;IACH,CAAC,MAAM,IAAIP,WAAW,EAAE;MACtB,MAAMO,MAAM,GAAG;QAAE,GAAGZ,YAAY;QAAE,GAAGK;MAAY,CAAC;MAClDF,iBAAiB,gBAAGV,KAAA,CAAAoB,aAAA,CAACxB,iBAAiB;QAACyB,aAAa,EAAEF;MAAO,CAAE,CAAC;IAClE,CAAC,MAAM,IAAIF,UAAU,EAAE;MACrBN,aAAa,GAAG,MAAM;MACtB,MAAMQ,MAAM,GAAG;QAAE,GAAGZ,YAAY;QAAE,GAAGU;MAAW,CAAC;MACjDP,iBAAiB,gBAAGV,KAAA,CAAAoB,aAAA,CAACvB,gBAAgB;QAACwB,aAAa,EAAEF;MAAO,CAAE,CAAC;IACjE;IAEA,OAAO;MAAET,iBAAiB;MAAEC;IAAc,CAAC;EAC7C,CAAC,EAAE,CAACL,MAAM,EAAEC,YAAY,CAAC,CAAC;EAE1B,MAAM;IAAEG,iBAAiB;IAAEC;EAAc,CAAC,GAAGH,QAAQ;EAErD,oBACER,KAAA,CAAAoB,aAAA,CAAApB,KAAA,CAAAsB,QAAA,QACGZ,iBAAiB,gBAChBV,KAAA,CAAAoB,aAAA,CAACtB,cAAc;IACbyB,GAAG,EAAE,GAAGhB,YAAY,CAACiB,UAAU,CAACC,YAAY,IAAIpB,KAAK,EAAG;IACxDmB,UAAU,EAAEjB,YAAY,CAACiB,UAAW;IACpCE,QAAQ,eAAE1B,KAAA,CAAAoB,aAAA,CAACrB,kBAAkB;MAACY,aAAa,EAAEA;IAAc,CAAE;EAAE,GAE9DD,iBACa,CAAC,GACf,IACJ,CAAC;AAEP,CAAC","ignoreList":[]}
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { CollectionPage } from '@wix/patterns/page';
3
3
  import { AutoPatternsCollectionPageContent } from '../AutoPatternsCollectionPageContent';
4
- import { usePatternsWizardOverridesContext } from '../../providers';
5
4
  import { useCollectionPageActions } from '../../hooks/useCollectionPageActions';
6
5
  export const AutoPatternsCollectionPage = _ref => {
7
6
  let {
@@ -14,7 +13,6 @@ export const AutoPatternsCollectionPage = _ref => {
14
13
  const actions = useCollectionPageActions({
15
14
  collectionPageActions: configuration.actions
16
15
  });
17
- const context = usePatternsWizardOverridesContext();
18
16
  return /*#__PURE__*/React.createElement(CollectionPage, {
19
17
  height: "100vh",
20
18
  dataHook: "auto-patterns-page"
@@ -23,7 +21,7 @@ export const AutoPatternsCollectionPage = _ref => {
23
21
  subtitle: subtitle,
24
22
  primaryAction: actions.primaryActions,
25
23
  secondaryActions: actions.secondaryActions
26
- }), /*#__PURE__*/React.createElement(CollectionPage.Content, null, context != null && context.HeaderAddon ? /*#__PURE__*/React.createElement(context.HeaderAddon, null) : null, /*#__PURE__*/React.createElement(AutoPatternsCollectionPageContent, {
24
+ }), /*#__PURE__*/React.createElement(CollectionPage.Content, null, /*#__PURE__*/React.createElement(AutoPatternsCollectionPageContent, {
27
25
  configuration: configuration
28
26
  })));
29
27
  };
@@ -1 +1 @@
1
- {"version":3,"names":["React","CollectionPage","AutoPatternsCollectionPageContent","usePatternsWizardOverridesContext","useCollectionPageActions","AutoPatternsCollectionPage","_ref","configuration","title","subtitle","actions","collectionPageActions","context","createElement","height","dataHook","Header","primaryAction","primaryActions","secondaryActions","Content","HeaderAddon"],"sources":["../../../../src/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.tsx"],"sourcesContent":["import React from 'react';\nimport { CollectionPage } from '@wix/patterns/page';\nimport { AutoPatternsCollectionPageContent } from '../AutoPatternsCollectionPageContent';\nimport { usePatternsWizardOverridesContext } from '../../providers';\nimport { CollectionPageConfig } from '../../types/CollectionPageConfig';\nimport { useCollectionPageActions } from '../../hooks/useCollectionPageActions';\n\nexport interface AutoPatternsCollectionPageProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPage: React.FC<\n AutoPatternsCollectionPageProps\n> = ({ configuration }) => {\n const { title, subtitle } = configuration;\n\n const actions = useCollectionPageActions({\n collectionPageActions: configuration.actions,\n });\n\n const context = usePatternsWizardOverridesContext();\n\n return (\n <CollectionPage height=\"100vh\" dataHook=\"auto-patterns-page\">\n <CollectionPage.Header\n title={title}\n subtitle={subtitle}\n primaryAction={actions.primaryActions}\n secondaryActions={actions.secondaryActions}\n />\n <CollectionPage.Content>\n {context?.HeaderAddon ? <context.HeaderAddon /> : null}\n <AutoPatternsCollectionPageContent configuration={configuration} />\n </CollectionPage.Content>\n </CollectionPage>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,iCAAiC,QAAQ,sCAAsC;AACxF,SAASC,iCAAiC,QAAQ,iBAAiB;AAEnE,SAASC,wBAAwB,QAAQ,sCAAsC;AAM/E,OAAO,MAAMC,0BAEZ,GAAGC,IAAA,IAAuB;EAAA,IAAtB;IAAEC;EAAc,CAAC,GAAAD,IAAA;EACpB,MAAM;IAAEE,KAAK;IAAEC;EAAS,CAAC,GAAGF,aAAa;EAEzC,MAAMG,OAAO,GAAGN,wBAAwB,CAAC;IACvCO,qBAAqB,EAAEJ,aAAa,CAACG;EACvC,CAAC,CAAC;EAEF,MAAME,OAAO,GAAGT,iCAAiC,CAAC,CAAC;EAEnD,oBACEH,KAAA,CAAAa,aAAA,CAACZ,cAAc;IAACa,MAAM,EAAC,OAAO;IAACC,QAAQ,EAAC;EAAoB,gBAC1Df,KAAA,CAAAa,aAAA,CAACZ,cAAc,CAACe,MAAM;IACpBR,KAAK,EAAEA,KAAM;IACbC,QAAQ,EAAEA,QAAS;IACnBQ,aAAa,EAAEP,OAAO,CAACQ,cAAe;IACtCC,gBAAgB,EAAET,OAAO,CAACS;EAAiB,CAC5C,CAAC,eACFnB,KAAA,CAAAa,aAAA,CAACZ,cAAc,CAACmB,OAAO,QACpBR,OAAO,YAAPA,OAAO,CAAES,WAAW,gBAAGrB,KAAA,CAAAa,aAAA,CAACD,OAAO,CAACS,WAAW,MAAE,CAAC,GAAG,IAAI,eACtDrB,KAAA,CAAAa,aAAA,CAACX,iCAAiC;IAACK,aAAa,EAAEA;EAAc,CAAE,CAC5C,CACV,CAAC;AAErB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","CollectionPage","AutoPatternsCollectionPageContent","useCollectionPageActions","AutoPatternsCollectionPage","_ref","configuration","title","subtitle","actions","collectionPageActions","createElement","height","dataHook","Header","primaryAction","primaryActions","secondaryActions","Content"],"sources":["../../../../src/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.tsx"],"sourcesContent":["import React from 'react';\nimport { CollectionPage } from '@wix/patterns/page';\nimport { AutoPatternsCollectionPageContent } from '../AutoPatternsCollectionPageContent';\nimport { CollectionPageConfig } from '../../types/CollectionPageConfig';\nimport { useCollectionPageActions } from '../../hooks/useCollectionPageActions';\n\nexport interface AutoPatternsCollectionPageProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPage: React.FC<\n AutoPatternsCollectionPageProps\n> = ({ configuration }) => {\n const { title, subtitle } = configuration;\n\n const actions = useCollectionPageActions({\n collectionPageActions: configuration.actions,\n });\n\n return (\n <CollectionPage height=\"100vh\" dataHook=\"auto-patterns-page\">\n <CollectionPage.Header\n title={title}\n subtitle={subtitle}\n primaryAction={actions.primaryActions}\n secondaryActions={actions.secondaryActions}\n />\n <CollectionPage.Content>\n <AutoPatternsCollectionPageContent configuration={configuration} />\n </CollectionPage.Content>\n </CollectionPage>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,iCAAiC,QAAQ,sCAAsC;AAExF,SAASC,wBAAwB,QAAQ,sCAAsC;AAM/E,OAAO,MAAMC,0BAEZ,GAAGC,IAAA,IAAuB;EAAA,IAAtB;IAAEC;EAAc,CAAC,GAAAD,IAAA;EACpB,MAAM;IAAEE,KAAK;IAAEC;EAAS,CAAC,GAAGF,aAAa;EAEzC,MAAMG,OAAO,GAAGN,wBAAwB,CAAC;IACvCO,qBAAqB,EAAEJ,aAAa,CAACG;EACvC,CAAC,CAAC;EAEF,oBACET,KAAA,CAAAW,aAAA,CAACV,cAAc;IAACW,MAAM,EAAC,OAAO;IAACC,QAAQ,EAAC;EAAoB,gBAC1Db,KAAA,CAAAW,aAAA,CAACV,cAAc,CAACa,MAAM;IACpBP,KAAK,EAAEA,KAAM;IACbC,QAAQ,EAAEA,QAAS;IACnBO,aAAa,EAAEN,OAAO,CAACO,cAAe;IACtCC,gBAAgB,EAAER,OAAO,CAACQ;EAAiB,CAC5C,CAAC,eACFjB,KAAA,CAAAW,aAAA,CAACV,cAAc,CAACiB,OAAO,qBACrBlB,KAAA,CAAAW,aAAA,CAACT,iCAAiC;IAACI,aAAa,EAAEA;EAAc,CAAE,CAC5C,CACV,CAAC;AAErB,CAAC","ignoreList":[]}
@@ -1,9 +1,6 @@
1
1
  import React from 'react';
2
- import { AutoPatternsTable } from '../AutoPatternsTable';
3
- import { AutoPatternsGrid } from '../AutoPatternsGrid';
4
- import { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';
5
- import { SchemaProvider } from '../../providers';
6
- import { SkeletonCollection } from './SkeletonCollection';
2
+ import { usePatternsWizardOverridesContext } from '../../providers';
3
+ import { AutoPatternsCollectionComponent } from '../AutoPatternsCollectionComponent/AutoPatternsCollectionComponent';
7
4
  export const AutoPatternsCollectionPageContent = _ref => {
8
5
  let {
9
6
  configuration
@@ -11,53 +8,24 @@ export const AutoPatternsCollectionPageContent = _ref => {
11
8
  const {
12
9
  components
13
10
  } = configuration;
11
+ const overrides = usePatternsWizardOverridesContext();
14
12
  return /*#__PURE__*/React.createElement(React.Fragment, null, components.map((component, index) => {
15
- var _layout$find, _layout$find2;
16
- const {
17
- layout,
18
- ...sharedConfig
19
- } = component;
20
- if (!(layout != null && layout.length)) {
21
- return null;
22
- }
23
- const tableConfig = (_layout$find = layout.find(item => item.type === 'Table')) == null ? void 0 : _layout$find.table;
24
- const gridConfig = (_layout$find2 = layout.find(item => item.type === 'Grid')) == null ? void 0 : _layout$find2.grid;
25
- let componentType = 'Table';
26
- let componentToRender = null;
27
- if (tableConfig && gridConfig) {
28
- const config = {
29
- ...sharedConfig,
30
- ...tableConfig,
31
- ...gridConfig
32
- };
33
- componentToRender = /*#__PURE__*/React.createElement(AutoPatternsTableGridSwitch, {
34
- configuration: config
35
- });
36
- } else if (tableConfig) {
37
- const config = {
38
- ...sharedConfig,
39
- ...tableConfig
40
- };
41
- componentToRender = /*#__PURE__*/React.createElement(AutoPatternsTable, {
42
- configuration: config
13
+ if (component.type === 'collection') {
14
+ return /*#__PURE__*/React.createElement(AutoPatternsCollectionComponent, {
15
+ key: `collection-${component.collection.collectionId}-${index}`,
16
+ component: component,
17
+ index: index
43
18
  });
44
- } else if (gridConfig) {
45
- componentType = 'Grid';
46
- const config = {
47
- ...sharedConfig,
48
- ...gridConfig
49
- };
50
- componentToRender = /*#__PURE__*/React.createElement(AutoPatternsGrid, {
51
- configuration: config
19
+ } else if (component.type === 'custom') {
20
+ const CustomComponent = overrides?.slots?.[component.id];
21
+ if (!CustomComponent) {
22
+ return null;
23
+ }
24
+ return /*#__PURE__*/React.createElement(CustomComponent, {
25
+ key: `custom-${component.id}-${index}`
52
26
  });
53
27
  }
54
- return componentToRender ? /*#__PURE__*/React.createElement(SchemaProvider, {
55
- key: `${sharedConfig.collection.collectionId}-${index}`,
56
- collection: sharedConfig.collection,
57
- skeleton: /*#__PURE__*/React.createElement(SkeletonCollection, {
58
- componentType: componentType
59
- })
60
- }, componentToRender) : null;
28
+ return null;
61
29
  }).filter(Boolean));
62
30
  };
63
31
  //# sourceMappingURL=AutoPatternsCollectionPageContent.js.map