@wix/auto-patterns 1.19.0 → 1.20.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 (61) hide show
  1. package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js +4 -2
  2. package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
  3. package/dist/cjs/hooks/useTableFeatures.js +9 -1
  4. package/dist/cjs/hooks/useTableFeatures.js.map +1 -1
  5. package/dist/cjs/providers/ErrorContext.js +64 -0
  6. package/dist/cjs/providers/ErrorContext.js.map +1 -0
  7. package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
  8. package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
  9. package/dist/cjs/providers/RootAppProvider.js +16 -8
  10. package/dist/cjs/providers/RootAppProvider.js.map +1 -1
  11. package/dist/cjs/providers/SchemaContext.js +7 -2
  12. package/dist/cjs/providers/SchemaContext.js.map +1 -1
  13. package/dist/cjs/providers/index.js +6 -0
  14. package/dist/cjs/providers/index.js.map +1 -1
  15. package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
  16. package/dist/cjs/types/actions/collectionPageActions.js.map +1 -1
  17. package/dist/cjs/types/types.js.map +1 -1
  18. package/dist/docs/action_cell.md +21 -8
  19. package/dist/docs/app_config_structure.md +2 -1
  20. package/dist/docs/auto-patterns-guide.md +416 -116
  21. package/dist/docs/bulk_actions.md +20 -7
  22. package/dist/docs/collection_page_actions.md +44 -18
  23. package/dist/docs/custom_overrides.md +318 -71
  24. package/dist/docs/index.md +1 -1
  25. package/dist/docs/installation.md +8 -9
  26. package/dist/docs/introduction.md +3 -2
  27. package/dist/docs/wix_fqdn_custom_data_source.md +111 -54
  28. package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js +4 -2
  29. package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
  30. package/dist/esm/hooks/useTableFeatures.js +10 -2
  31. package/dist/esm/hooks/useTableFeatures.js.map +1 -1
  32. package/dist/esm/providers/ErrorContext.js +44 -0
  33. package/dist/esm/providers/ErrorContext.js.map +1 -0
  34. package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
  35. package/dist/esm/providers/RootAppProvider.js +2 -1
  36. package/dist/esm/providers/RootAppProvider.js.map +1 -1
  37. package/dist/esm/providers/SchemaContext.js +6 -1
  38. package/dist/esm/providers/SchemaContext.js.map +1 -1
  39. package/dist/esm/providers/index.js +1 -0
  40. package/dist/esm/providers/index.js.map +1 -1
  41. package/dist/esm/types/CollectionPageConfig.js.map +1 -1
  42. package/dist/esm/types/actions/collectionPageActions.js.map +1 -1
  43. package/dist/esm/types/types.js.map +1 -1
  44. package/dist/types/components/AutoPatternsTable/AutoPatternsTable.d.ts.map +1 -1
  45. package/dist/types/hooks/useTableFeatures.d.ts +6 -0
  46. package/dist/types/hooks/useTableFeatures.d.ts.map +1 -1
  47. package/dist/types/providers/ErrorContext.d.ts +11 -0
  48. package/dist/types/providers/ErrorContext.d.ts.map +1 -0
  49. package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -0
  50. package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
  51. package/dist/types/providers/RootAppProvider.d.ts.map +1 -1
  52. package/dist/types/providers/SchemaContext.d.ts.map +1 -1
  53. package/dist/types/providers/index.d.ts +1 -0
  54. package/dist/types/providers/index.d.ts.map +1 -1
  55. package/dist/types/types/CollectionPageConfig.d.ts +3 -0
  56. package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
  57. package/dist/types/types/actions/collectionPageActions.d.ts +7 -0
  58. package/dist/types/types/actions/collectionPageActions.d.ts.map +1 -1
  59. package/dist/types/types/types.d.ts +1 -5
  60. package/dist/types/types/types.d.ts.map +1 -1
  61. package/package.json +9 -9
@@ -11,67 +11,91 @@ The `PatternsWizardOverridesProvider` allows you to inject custom code to overri
11
11
 
12
12
  ## Folder Structure Organization
13
13
 
14
- All custom overrides (components, modals, actions, columns, and other customizations) should be created in a `components` folder inside your page directory, not in a global `/src/components` folder. This keeps page-specific customizations organized alongside their respective pages.
14
+ All custom overrides (components, modals, actions, columns, sections, and other customizations) should be created in a `components` folder inside your page directory, not in a global `/src/components` folder. This keeps page-specific customizations organized alongside their respective pages.
15
15
 
16
16
  ### Recommended Structure:
17
17
 
18
18
  ```
19
19
  your-page/
20
20
  ├── page.tsx // Your main page component
21
- ├── MyCollectionConfig.patterns.json // Configuration file
21
+ ├── MyCollectionConfig.patterns.ts // Configuration file
22
22
  └── components/ // Page-specific components folder
23
- ├── index.tsx // Exports all overrides for easy importing
23
+ ├── index.tsx // Exports all override hooks for easy importing
24
24
  ├── actions/ // Custom actions
25
- │ ├── index.tsx
25
+ │ ├── index.tsx // Exports useActions hook
26
26
  │ └── myCustomAction.tsx
27
27
  ├── columns/ // Column overrides
28
- │ ├── index.tsx
28
+ │ ├── index.tsx // Exports useColumns hook
29
29
  │ ├── name.ts
30
30
  │ └── date.ts
31
31
  ├── customComponents/ // Custom entity page components
32
- │ ├── index.tsx
32
+ │ ├── index.tsx // Exports useComponents hook
33
33
  │ ├── CustomNameField.tsx
34
34
  │ └── InfoCard.tsx
35
+ ├── modals/ // Custom modals
36
+ │ ├── index.tsx // Exports useModals hook
37
+ │ └── myCustomModal.tsx
35
38
  └── customDataSources/ // Custom data sources
39
+ │ ├── index.tsx // Exports useCustomDataSources hook
40
+ │ └── myCustomDataSource.ts
41
+ ├── sections/ // Section renderers
42
+ │ ├── index.tsx
43
+ │ └── groupByType.ts
44
+ └── customComponents/ // Custom entity page components
36
45
  ├── index.tsx
37
- └── myCustomDataSource.ts
46
+ ├── CustomNameField.tsx
47
+ └── InfoCard.tsx
38
48
  ```
39
49
 
40
- ### Importing Overrides in Your Page
50
+ ### Using Override Hooks in Your Page
41
51
 
42
- In your page component, import from the local components folder:
52
+ In your page component, use the hook-based approach to access React context and other hooks:
43
53
 
44
54
  ```tsx
45
- import * as modals from './components/modals';
46
- import * as actions from './components/actions';
47
- import * as columns from './components/columns';
48
- import * as components from './components/customComponents';
49
- import * as customDataSources from './components/customDataSources';
55
+ import { useActions } from '../components/actions';
56
+ import { useColumns } from '../components/columns';
57
+ import { useSections } from '../components/sections';
58
+ import { useComponents } from '../components/customComponents';
59
+ import { useModals } from '../components/modals';
60
+ import { useCustomDataSources } from '../components/customDataSources';
61
+
62
+ export default function YourPage() {
63
+ const actions = useActions();
64
+ const columns = useColumns();
65
+ const sections = useSections();
66
+ const components = useComponents();
67
+ const modals = useModals();
68
+ const customDataSources = useCustomDataSources();
50
69
 
51
- <PatternsWizardOverridesProvider value={{ modals, actions, columns, components, customDataSources }}>
52
- <AutoPatternsApp configuration={config as AppConfig} />
53
- </PatternsWizardOverridesProvider>
70
+ return (
71
+ <PatternsWizardOverridesProvider value={{ actions, columns, sections, components, modals, customDataSources }}>
72
+ <AutoPatternsApp configuration={config} />
73
+ </PatternsWizardOverridesProvider>
74
+ );
75
+ }
54
76
  ```
55
77
 
56
- ### Important: Updating Index Files
78
+ ### Important: Updating Hook Index Files
57
79
 
58
- **When adding any new implementation (action, modal, column, or component), you MUST update the corresponding `index.tsx` file to export your new implementation.** The main page component imports from these index files, so they serve as the central export point for each type of override.
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.
59
81
 
60
82
  For example:
61
- - Adding a new action → Update `./components/actions/index.tsx`
62
- - Adding a new modal → Update `./components/modals/index.tsx`
63
- - Adding a new column override → Update `./components/columns/index.tsx`
64
- - Adding a new custom component → Update `./components/customComponents/index.tsx`
65
- - Adding a new custom data source → Update `./components/customDataSources/index.tsx`
83
+ - Adding a new action → Update `../components/actions/index.tsx` to include the new action in the `useActions` hook
84
+ - Adding a new modal → Update `../components/modals/index.tsx` to include the new modal in the `useModals` hook
85
+ - Adding a new column override → Update `../components/columns/index.tsx` to include the new column in the `useColumns` hook
86
+ - Adding a new section renderer → Update `../components/sections/index.tsx` to include the new section in the `useSections` hook
87
+ - Adding a new custom component → Update `../components/customComponents/index.tsx` to include the new component in the `useComponents` hook
88
+ - Adding a new custom data source → Update `../components/customDataSources/index.tsx` to include the new data source in the `useCustomDataSources` hook
66
89
 
67
- Without updating the index files, your implementations won't be available to the `PatternsWizardOverridesProvider`.
90
+ Without updating the hook index files, your implementations won't be available to the `PatternsWizardOverridesProvider`.
68
91
 
69
92
  ## ⚠️ Common Override Mistakes to Avoid
70
93
 
71
94
  - Attempting to override unsupported areas
72
95
  - Invalid column rendering functions
73
- - Missing index file exports for new implementations
96
+ - Missing hook index file exports for new implementations
74
97
  - Incorrect import paths or naming mismatches
98
+ - Forgetting to import and use the hook in the main page component
75
99
 
76
100
  ## Columns
77
101
 
@@ -210,23 +234,40 @@ export function date({ value, row }) {
210
234
  In `components/columns/index.tsx`:
211
235
 
212
236
  ```ts
213
- export * from './name';
214
- export * from './petInfo';
215
- export * from './status';
216
- export * from './fullName';
217
- export * from './date';
237
+ import { name } from './name';
238
+ import { petInfo } from './petInfo';
239
+ import { status } from './status';
240
+ import { fullName } from './fullName';
241
+ import { date } from './date';
242
+
243
+ export const useColumns = () => {
244
+ // You can access React context and other hooks here
245
+ return {
246
+ name,
247
+ petInfo,
248
+ status,
249
+ fullName,
250
+ date
251
+ };
252
+ };
218
253
  ```
219
254
 
220
- **Important:** Every time you add a new column override file, you must add a corresponding export line to this `index.tsx` file. For example, if you create `price.tsx`, you must add `export * from './price';` to the index file.
255
+ **Important:** Every time you add a new column override file, you must import it and add it to the `useColumns` hook return object in this `index.tsx` file. For example, if you create `price.tsx`, you must add `import { price } from './price';` and include `price` in the return object.
221
256
 
222
- In the `PatternsWizardOverridesProvider`:
257
+ In the main page component:
223
258
 
224
259
  ```tsx
225
- import * as columns from './components/columns';
260
+ import { useColumns } from '../components/columns';
226
261
 
227
- <PatternsWizardOverridesProvider value={{ columns }}>
228
- <AutoPatternsApp configuration={config as AppConfig} />
229
- </PatternsWizardOverridesProvider>
262
+ export default function YourPage() {
263
+ const columns = useColumns();
264
+
265
+ return (
266
+ <PatternsWizardOverridesProvider value={{ columns }}>
267
+ <AutoPatternsApp configuration={config} />
268
+ </PatternsWizardOverridesProvider>
269
+ );
270
+ }
230
271
  ```
231
272
 
232
273
  ### Visual Representation
@@ -235,7 +276,7 @@ import * as columns from './components/columns';
235
276
  your-page/
236
277
  └── components/
237
278
  └── columns/
238
- ├── index.tsx // Exports all column overrides
279
+ ├── index.tsx // Exports useColumns hook
239
280
  ├── name.tsx // Simple value formatting
240
281
  ├── petInfo.tsx // Complex multi-field column
241
282
  ├── status.tsx // Conditional rendering column
@@ -243,7 +284,7 @@ your-page/
243
284
  └── date.tsx // Enhanced formatting with row context
244
285
 
245
286
  PatternsWizardOverridesProvider
246
- └── value.columns
287
+ └── value.columns (from useColumns hook)
247
288
  ├── name
248
289
  ├── petInfo
249
290
  ├── status
@@ -371,16 +412,37 @@ export const infoCard: FC<CustomComponentProps> = ({ entity }) => {
371
412
  };
372
413
  ```
373
414
 
374
- ### Connecting Components in the Provider
415
+ ### Connecting Components with Hooks
375
416
 
376
- In your main page file, import and provide these components via the `PatternsWizardOverridesProvider`:
417
+ In `components/customComponents/index.tsx`:
377
418
 
378
419
  ```tsx
379
- import * as components from './components';
420
+ import { customNameField } from './customNameField';
421
+ import { infoCard } from './infoCard';
380
422
 
381
- <PatternsWizardOverridesProvider value={{ components }}>
382
- <AutoPatternsApp configuration={config as AppConfig} />
383
- </PatternsWizardOverridesProvider>
423
+ export const useComponents = () => {
424
+ // You can access React context and other hooks here
425
+ return {
426
+ customNameField,
427
+ infoCard
428
+ };
429
+ };
430
+ ```
431
+
432
+ In your main page file:
433
+
434
+ ```tsx
435
+ import { useComponents } from '../components/customComponents';
436
+
437
+ export default function YourPage() {
438
+ const components = useComponents();
439
+
440
+ return (
441
+ <PatternsWizardOverridesProvider value={{ components }}>
442
+ <AutoPatternsApp configuration={config} />
443
+ </PatternsWizardOverridesProvider>
444
+ );
445
+ }
384
446
  ```
385
447
 
386
448
  ### Important Guidelines for Custom Components
@@ -400,7 +462,7 @@ import * as components from './components';
400
462
  - For dates: `DatePicker`
401
463
  - For dropdowns: `Dropdown`
402
464
 
403
- **Important:** Every time you create a new custom component, you must add a corresponding export line to the `./components/customComponents/index.tsx` file. For example, if you create `StatusIndicator.tsx`, you must add `export * from './StatusIndicator';` to the index file.
465
+ **Important:** Every time you create a new custom component, you must import it and add it to the `useComponents` hook return object in the `./components/customComponents/index.tsx` file. For example, if you create `StatusIndicator.tsx`, you must add `import { StatusIndicator } from './StatusIndicator';` and include `StatusIndicator` in the return object.
404
466
 
405
467
  ### Understanding Reactivity in Custom Components
406
468
 
@@ -501,13 +563,14 @@ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
501
563
  ```
502
564
  your-page/
503
565
  └── components/
504
- ├── index.tsx // Exports all component overrides
505
- ├── customNameField.tsx // Field override component
506
- ├── combinedNameFields.tsx // Multiple fields override
507
- └── infoCard.tsx // Standalone component
566
+ ├── customComponents/
567
+ ├── index.tsx // Exports useComponents hook
568
+ ├── customNameField.tsx // Field override component
569
+ │ ├── combinedNameFields.tsx // Multiple fields override
570
+ │ └── infoCard.tsx // Standalone component
508
571
 
509
572
  PatternsWizardOverridesProvider
510
- └── value.components
573
+ └── value.components (from useComponents hook)
511
574
  ├── customNameField
512
575
  ├── combinedNameFields
513
576
  └── infoCard
@@ -534,25 +597,62 @@ When implementing a custom data source, you need to modify the `collection` conf
534
597
  }
535
598
  }
536
599
  ```
600
+ ## Sections
601
+
602
+ Sections allow you to group table rows under section headers, making it easier to organize and navigate through large datasets. This feature is especially useful when you want to categorize entities by specific criteria.
603
+
604
+ The sections feature supports both Table and TableGridSwitch components. When enabled, the table will render section headers that group related rows together.
605
+
606
+ ### Configuring Sections
607
+
608
+ To enable sections, add the `sections` configuration to your table configuration:
609
+
610
+ ```json
611
+ {
612
+ "type": "collectionPage",
613
+ "collectionPage": {
614
+ "components": [
615
+ {
616
+ "collection": {
617
+ "collectionId": "WixPets"
618
+ },
619
+ "layout": [
620
+ {
621
+ "type": "Table",
622
+ "table": {
623
+ "columns": [...],
624
+ "sections": {
625
+ "id": "groupByType"
626
+ }
627
+ }
628
+ }
629
+ ]
630
+ }
631
+ ]
632
+ }
633
+ }
634
+ ```
537
635
 
538
636
  **Key Properties:**
539
637
  - `entityTypeSource`: Must be set to `"custom"` instead of `"cms"`
540
638
  - `custom.id`: A unique identifier for your custom data source implementation
541
639
 
542
- ### Custom Data Source Override Structure
640
+ ### Custom Data Source Hook Structure
543
641
 
544
- Custom data sources are implemented through the `customDataSources` property in your `PatternsWizardOverridesProvider`:
642
+ Custom data sources are implemented through the `useCustomDataSources` hook in your `PatternsWizardOverridesProvider`:
545
643
 
546
644
  ```tsx
547
- <PatternsWizardOverridesProvider value={{
548
- customDataSources: {
549
- myCustomDataSource: async (collectionId: string, context: any) => {
550
- return customSchemaConfig; // Must return a SchemaConfig object
551
- }
552
- }
553
- }}>
554
- <AutoPatternsApp configuration={config as AppConfig} />
555
- </PatternsWizardOverridesProvider>
645
+ import { useCustomDataSources } from '../components/customDataSources';
646
+
647
+ export default function YourPage() {
648
+ const customDataSources = useCustomDataSources();
649
+
650
+ return (
651
+ <PatternsWizardOverridesProvider value={{ customDataSources }}>
652
+ <AutoPatternsApp configuration={config} />
653
+ </PatternsWizardOverridesProvider>
654
+ );
655
+ }
556
656
  ```
557
657
 
558
658
  ### Implementation Components
@@ -596,6 +696,21 @@ export const myCustomDataSource = async (collectionId: string, context: any) =>
596
696
  };
597
697
  ```
598
698
 
699
+ ### Hook Implementation
700
+
701
+ In `components/customDataSources/index.tsx`:
702
+
703
+ ```tsx
704
+ import { myCustomDataSource } from './myCustomDataSource';
705
+
706
+ export const useCustomDataSources = () => {
707
+ // You can access React context and other hooks here
708
+ return {
709
+ myCustomDataSource
710
+ };
711
+ };
712
+ ```
713
+
599
714
  ### Field Type Mapping
600
715
 
601
716
  When implementing custom data sources, you need to map your data source field types to AutoPatterns field types:
@@ -641,30 +756,162 @@ actions: {
641
756
  ```
642
757
  your-page/
643
758
  ├── page.tsx // Your main page component
644
- ├── MyCollectionConfig.patterns.json // Configuration file
759
+ ├── MyCollectionConfig.patterns.ts // Configuration file
645
760
  └── components/ // Page-specific components folder
646
- ├── index.tsx // Exports all overrides for easy importing
761
+ ├── index.tsx // Exports all override hooks for easy importing
647
762
  ├── customDataSources/ // Custom data sources
648
- │ ├── index.tsx
763
+ │ ├── index.tsx // Exports useCustomDataSources hook
649
764
  │ └── myCustomDataSource.ts
650
765
  ├── actions/ // Custom actions
651
- │ ├── index.tsx
766
+ │ ├── index.tsx // Exports useActions hook
652
767
  │ └── myCustomAction.tsx
653
768
  └── columns/ // Column overrides
654
- ├── index.tsx
769
+ ├── index.tsx // Exports useColumns hook
655
770
  └── myColumn.tsx
656
771
  ```
657
772
 
658
773
  ### Registering Custom Data Sources
659
774
 
660
- In your page component, import and register your custom data sources:
775
+ In your page component, use the hook to access React context and other hooks:
776
+
777
+ ```tsx
778
+ import { useCustomDataSources } from '../components/customDataSources';
779
+
780
+ export default function YourPage() {
781
+ const customDataSources = useCustomDataSources();
782
+
783
+ return (
784
+ <PatternsWizardOverridesProvider value={{ customDataSources }}>
785
+ <AutoPatternsApp configuration={config} />
786
+ </PatternsWizardOverridesProvider>
787
+ );
788
+ }
789
+ ```
790
+
791
+ **Important:** Every time you create a new custom data source, you must import it and add it to the `useCustomDataSources` hook return object in the `./components/customDataSources/index.tsx` file. For example, if you create `myDataSource.ts`, you must add `import { myDataSource } from './myDataSource';` and include `myDataSource` in the return object.
792
+
793
+ ### Creating Section Renderers
794
+
795
+ Section renderers are functions that determine how to group items and what information to display in section headers. They must be provided through the `PatternsWizardOverridesProvider`.
796
+
797
+ #### Function Signature
798
+
799
+ ```tsx
800
+ function sectionRenderer(item: any): Section
801
+ ```
802
+
803
+ Where `Section` is the interface from @wix/patterns (re-exported from auto-patterns):
804
+
805
+ ```tsx
806
+ interface Section {
807
+ id: string;
808
+ title: string;
809
+ primaryAction?: {
810
+ id: string;
811
+ label: string;
812
+ prefixIcon?: React.ReactElement;
813
+ onClick: () => void;
814
+ };
815
+ }
816
+ ```
817
+
818
+ The section renderer receives an item and returns:
819
+ - **id**: A unique identifier for the section (items with the same id are grouped together)
820
+ - **title**: The text displayed in the section header
821
+ - **primaryAction** (optional): An action button displayed in the section header
822
+
823
+ #### Example: Section Renderer Implementation
824
+
825
+ In `components/sections/groupByType.ts`:
826
+
827
+ ```tsx
828
+ import { ChevronDown } from '@wix/wix-ui-icons-common';
829
+ import { Section } from '@wix/patterns';
830
+
831
+ // Section renderer function that returns the Section type
832
+ export function groupByType(item: any): Section {
833
+ const petType = item.type || 'other';
834
+
835
+ return {
836
+ id: petType.toLowerCase(),
837
+ title: `${petType.charAt(0).toUpperCase()}${petType.slice(1)}s`,
838
+ primaryAction: {
839
+ id: 'show-all-pets',
840
+ label: 'Show All',
841
+ prefixIcon: <ChevronDown />,
842
+ onClick: () => {
843
+ // Custom action when section header is clicked
844
+ console.log(`Showing all ${petType}s`);
845
+ },
846
+ },
847
+ };
848
+ }
849
+ ```
850
+
851
+ In `components/sections/index.tsx`:
852
+
853
+ ```tsx
854
+ export * from './groupByType';
855
+ ```
856
+
857
+ #### Advanced Example: Multi-Field Grouping
661
858
 
662
859
  ```tsx
663
- import * as customDataSources from './components/customDataSources';
860
+ import { Badge } from '@wix/design-system';
861
+ import { Section } from '@wix/patterns';
664
862
 
665
- <PatternsWizardOverridesProvider value={{ customDataSources }}>
863
+ export function groupByAgeAndVaccination(item: any): Section {
864
+ const age = item.age || 0;
865
+ const isVaccinated = item.isVaccinated || false;
866
+
867
+ let sectionId: string;
868
+ let sectionTitle: string;
869
+
870
+ if (age < 1) {
871
+ sectionId = 'puppies';
872
+ sectionTitle = 'Puppies (Under 1 year)';
873
+ } else if (age >= 1 && age <= 5) {
874
+ sectionId = isVaccinated ? 'young-vaccinated' : 'young-unvaccinated';
875
+ sectionTitle = `Young Adults (1-5 years) - ${isVaccinated ? 'Vaccinated' : 'Not Vaccinated'}`;
876
+ } else {
877
+ sectionId = 'seniors';
878
+ sectionTitle = 'Senior Pets (5+ years)';
879
+ }
880
+
881
+ return {
882
+ id: sectionId,
883
+ title: sectionTitle,
884
+ primaryAction: age < 1 ? {
885
+ id: 'special-care',
886
+ label: 'Special Care Info',
887
+ onClick: () => {
888
+ // Show special care information for puppies
889
+ },
890
+ } : undefined,
891
+ };
892
+ }
893
+ ```
894
+
895
+ ### Using Sections in Your Page
896
+
897
+ Import and register your section renderers:
898
+
899
+ ```tsx
900
+ import * as sections from './components/sections';
901
+ import * as columns from './components/columns';
902
+ import * as actions from './components/actions';
903
+
904
+ <PatternsWizardOverridesProvider value={{ sections, columns, actions }}>
666
905
  <AutoPatternsApp configuration={config as AppConfig} />
667
906
  </PatternsWizardOverridesProvider>
668
907
  ```
669
908
 
670
- **Important:** Every time you create a new custom data source, you must add a corresponding export line to the `./components/customDataSources/index.tsx` file. For example, if you create `myDataSource.ts`, you must add `export * from './myDataSource';` to the index file.
909
+ ### Important Notes
910
+
911
+ - **Grouping Logic**: Items are grouped by the `id` returned from the section renderer. Items with the same `id` will appear under the same section header.
912
+ - **Section Order**: Sections appear in the order they first appear in the data, not alphabetically.
913
+ - **Performance**: Section renderers are called for every item, so keep the logic lightweight.
914
+ - **TableGridSwitch**: Sections work in both table and grid views when using TableGridSwitch.
915
+
916
+
917
+ 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.
@@ -14,7 +14,7 @@ This index maps user requests to the appropriate section IDs for fetching releva
14
14
 
15
15
  ### ID: `app_config_structure`
16
16
  **Topics**: Complete AppConfig interface, data structure, type definitions, field specifications
17
- **Keywords**: configuration structure, JSON schema, properties, types, filters, bulkActionToolbar, actionCell, modal configuration, route configuration, data types, interface definitions
17
+ **Keywords**: configuration structure, TypeScript schema, properties, types, filters, bulkActionToolbar, actionCell, modal configuration, route configuration, data types, interface definitions
18
18
 
19
19
  ---
20
20
 
@@ -13,18 +13,18 @@ npm install @wix/auto-patterns @wix/patterns @wix/design-system
13
13
  - **Import `AutoPatternsApp` only from `@wix/auto-patterns`** - never from other packages
14
14
  - **CRITICAL:** Always import `AppConfig` as a type import: `import type { AppConfig } from '@wix/auto-patterns/types'` - never import it as a value import
15
15
 
16
- ## 2. Create AppConfig JSON
16
+ ## 2. Create AppConfig TypeScript File
17
17
 
18
- Save this configuration as a `{collectionName}Config.patterns.json` file in the same directory as your page.tsx component.
18
+ Save this configuration as a `{collectionName}Config.patterns.ts` file in the same directory as your page.tsx component.
19
19
 
20
20
  For example:
21
- - For a "WixPets" collection: `petsConfig.patterns.json`
22
- - For a "Products" collection: `productsConfig.patterns.json`
23
- - For a "Users" collection: `usersConfig.patterns.json`
21
+ - For a "WixPets" collection: `petsConfig.patterns.ts`
22
+ - For a "Products" collection: `productsConfig.patterns.ts`
23
+ - For a "Users" collection: `usersConfig.patterns.ts`
24
24
 
25
25
  ## Render the Collection Page Component
26
26
 
27
- 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.
27
+ Inside your page component, import the TypeScript 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.
28
28
 
29
29
  ### Page Component Example:
30
30
 
@@ -34,17 +34,16 @@ import { WixDesignSystemProvider } from '@wix/design-system';
34
34
  import '@wix/design-system/styles.global.css';
35
35
  import { WixPatternsProvider } from '@wix/patterns/provider';
36
36
  import { PatternsWizardOverridesProvider, AutoPatternsApp } from '@wix/auto-patterns';
37
- import type { AppConfig } from '@wix/auto-patterns/types';
38
37
  import { withDashboard } from '@wix/patterns';
39
38
 
40
- import config from './MyCollectionConfig.patterns.json';
39
+ import { config } from './MyCollectionConfig.patterns';
41
40
 
42
41
  const Index: FC = () => {
43
42
  return (
44
43
  <WixDesignSystemProvider features={{ newColorsBranding: true }}>
45
44
  <WixPatternsProvider>
46
45
  <PatternsWizardOverridesProvider value={{ }}>
47
- <AutoPatternsApp configuration={config as AppConfig} />
46
+ <AutoPatternsApp configuration={config} />
48
47
  </PatternsWizardOverridesProvider>
49
48
  </WixPatternsProvider>
50
49
  </WixDesignSystemProvider>
@@ -38,7 +38,7 @@ This document serves as a comprehensive guide for AI agents to correctly generat
38
38
 
39
39
  * Pages array MUST contain exactly two pages.
40
40
  * Components array inside collectionPage MUST contain exactly one component with a layout array.
41
- * Configuration MUST come only from a JSON file.
41
+ * Configuration MUST come only from a TypeScript file.
42
42
  * DO NOT fill optional fields unless explicitly requested.
43
43
  * Select up to 3 columns initially that best represent the entity.
44
44
  * Every collection page MUST include a create action that allows users to create new entities by navigating to the entity page.
@@ -71,4 +71,5 @@ This guide instructs on how to correctly integrate the `AutoPatternsApp` compone
71
71
  # Component Purpose
72
72
 
73
73
  The `AutoPatternsApp` is a page-level component used to display a data collection either as a Table or Grid.
74
- It is configured using a JSON file conforming to the `AppConfig` interface and supports overrides for advanced use-cases.
74
+ It is configured using a TypeScript file conforming to the `AppConfig` interface and supports overrides for advanced use-cases.
75
+