@wix/auto-patterns 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +16 -4
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageContent/SkeletonCollection.js +34 -0
- package/dist/cjs/components/AutoPatternsCollectionPageContent/SkeletonCollection.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/SkeletonEntity.js +198 -0
- package/dist/cjs/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -0
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js +13 -3
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
- package/dist/cjs/hooks/useBaseTableFeatures.js +7 -2
- package/dist/cjs/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useCollectionPageOnRowClickActions.js +49 -0
- package/dist/cjs/hooks/useCollectionPageOnRowClickActions.js.map +1 -0
- package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/cjs/providers/SchemaContext.js +4 -3
- package/dist/cjs/providers/SchemaContext.js.map +1 -1
- package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
- package/dist/cjs/types/actions/collectionPageActions.js.map +1 -1
- package/dist/docs/action_cell.md +214 -0
- package/dist/docs/app_config_structure.md +355 -0
- package/dist/docs/auto-patterns-guide.md +2447 -0
- package/dist/docs/bulk_actions.md +266 -0
- package/dist/docs/collection_page.md +54 -0
- package/dist/docs/collection_page_actions.md +343 -0
- package/dist/docs/custom_overrides.md +511 -0
- package/dist/docs/entity_page.md +104 -0
- package/dist/docs/entity_page_actions.md +92 -0
- package/dist/docs/index.md +76 -0
- package/dist/docs/installation.md +55 -0
- package/dist/docs/introduction.md +74 -0
- package/dist/docs/pages_configuration.md +129 -0
- package/dist/docs/recipe-bulk-operations.md +1352 -0
- package/dist/docs/recipe-crud-operations.md +786 -0
- package/dist/docs/recipe-customization.md +1702 -0
- package/dist/docs/recipe-first-dashboard.md +794 -0
- package/dist/docs/sdk_and_schema.md +215 -0
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +7 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/SkeletonCollection.js +21 -0
- package/dist/esm/components/AutoPatternsCollectionPageContent/SkeletonCollection.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +3 -1
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js +91 -0
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -0
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js +5 -1
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
- package/dist/esm/hooks/useBaseTableFeatures.js +6 -1
- package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js +45 -0
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js.map +1 -0
- package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/esm/providers/SchemaContext.js +3 -2
- package/dist/esm/providers/SchemaContext.js.map +1 -1
- package/dist/esm/types/CollectionPageConfig.js.map +1 -1
- package/dist/esm/types/actions/collectionPageActions.js.map +1 -1
- package/dist/types/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsCollectionPageContent/SkeletonCollection.d.ts +5 -0
- package/dist/types/components/AutoPatternsCollectionPageContent/SkeletonCollection.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/SkeletonEntity.d.ts +7 -0
- package/dist/types/components/AutoPatternsEntityPage/SkeletonEntity.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsRoute/AutoPatternsPage.d.ts.map +1 -1
- package/dist/types/hooks/useBaseTableFeatures.d.ts +1 -1
- package/dist/types/hooks/useBaseTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useCollectionPageOnRowClickActions.d.ts +7 -0
- package/dist/types/hooks/useCollectionPageOnRowClickActions.d.ts.map +1 -0
- package/dist/types/hooks/useTableFeatures.d.ts +1 -1
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +1 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -2
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
- package/dist/types/providers/SchemaContext.d.ts +2 -1
- package/dist/types/providers/SchemaContext.d.ts.map +1 -1
- package/dist/types/types/CollectionPageConfig.d.ts +2 -1
- package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
- package/dist/types/types/actions/collectionPageActions.d.ts +8 -0
- package/dist/types/types/actions/collectionPageActions.d.ts.map +1 -1
- package/package.json +21 -16
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
## Entity Page Actions: `moreActions` Support
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
> **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.
|
|
6
|
+
|
|
7
|
+
### Configuration Structure
|
|
8
|
+
|
|
9
|
+
- The `moreActions` property on the entity page is an **array** of action configurations that can include divider objects for visual separation.
|
|
10
|
+
- Each action in `moreActions` is a Custom Action (type: "custom") or a Divider (type: "divider")
|
|
11
|
+
|
|
12
|
+
#### Example: Adding custom actions with dividers to an entity page
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"type": "entityPage",
|
|
16
|
+
"entityPage": {
|
|
17
|
+
// ... other config ...
|
|
18
|
+
"moreActions": [
|
|
19
|
+
{
|
|
20
|
+
"id": "sendEmail",
|
|
21
|
+
"type": "custom",
|
|
22
|
+
"label": "Send Email"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": "exportData",
|
|
26
|
+
"type": "custom",
|
|
27
|
+
"label": "Export Data"
|
|
28
|
+
},
|
|
29
|
+
{ "type": "divider" },
|
|
30
|
+
{
|
|
31
|
+
"id": "archiveEntity",
|
|
32
|
+
"type": "custom",
|
|
33
|
+
"label": "Archive"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### CustomEntityPageMoreActionsActionResolver
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
#### Function Signature
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { CustomEntityPageMoreActionsActionResolver } from '@wix/auto-patterns/types';
|
|
50
|
+
|
|
51
|
+
export const myMoreAction: CustomEntityPageMoreActionsActionResolver = (params) => {
|
|
52
|
+
const { actionParams: { entity, form } , sdk } = params;
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
label: 'My More Action',
|
|
56
|
+
icon: <MyIcon />, // optional
|
|
57
|
+
onClick: () => {
|
|
58
|
+
// Your custom logic here
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- **entity**: The current entity data (all field values). In actionParams.
|
|
65
|
+
- **form**: The react-hook-form instance for the entity page. In actionParams.
|
|
66
|
+
- **sdk**: The AutoPatterns SDK (see SDK Utilities section).
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
#### Key Points for CustomEntityPageMoreActionsActionResolver
|
|
71
|
+
|
|
72
|
+
- The action `id` in the configuration MUST exactly match the function name exported from your actions folder.
|
|
73
|
+
- The implementation must use the `CustomEntityPageMoreActionsActionResolver` type.
|
|
74
|
+
- The implementation must be exported as a named export (not default export).
|
|
75
|
+
- The function receives `{ actionParams, sdk }` as parameters.
|
|
76
|
+
- The returned object must include at least a `label` and an `onClick` handler (optionally an `icon`).
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
#### Validation Checklist for More Actions
|
|
81
|
+
|
|
82
|
+
✓ Each action in `moreActions` has a unique `id` and correct `type` value
|
|
83
|
+
✓ Each action type only includes its required field(s)
|
|
84
|
+
✓ Custom actions match implementations in overrides
|
|
85
|
+
✓ The resolver is exported and registered in the `actions` property of your `PatternsWizardOverridesProvider`
|
|
86
|
+
✓ The function signature matches `CustomEntityPageMoreActionsActionResolver`
|
|
87
|
+
✓ The returned object includes `label`, `onClick`, and optionally `icon`
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
**Summary:**
|
|
92
|
+
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.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Auto Patterns Documentation Index
|
|
2
|
+
|
|
3
|
+
This index maps user requests to the appropriate section IDs for fetching relevant content. Match user keywords/intent to section topics to determine which sections to read.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Core Section IDs
|
|
8
|
+
|
|
9
|
+
### ID: `introduction`
|
|
10
|
+
**Topics**: AI agent instructions, core rules, configuration validation, enum handling
|
|
11
|
+
**Keywords**: getting started, basic rules, validation, enum configuration, page count, component purpose
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
### ID: `app_config_structure`
|
|
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
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
### ID: `pages_configuration`
|
|
22
|
+
**Topics**: Page setup, relationships, routing, URL configuration, sticky columns
|
|
23
|
+
**Keywords**: page configuration, page relationships, routing, URL structure, entityPage, collectionPage, navigation, appMainPage, sticky columns, parentPageId, entityPageId, route parameters
|
|
24
|
+
|
|
25
|
+
### ID: `collection_page`
|
|
26
|
+
**Topics**: Collection page components, table/grid layouts, column configuration
|
|
27
|
+
**Keywords**: collection page, table/grid configuration, layout arrays, Table/Grid layouts, column setup, customColumns, view switching, displaying collections, list views
|
|
28
|
+
|
|
29
|
+
### ID: `collection_page_actions`
|
|
30
|
+
**Topics**: Page-level actions, create actions, custom collection actions, action menus
|
|
31
|
+
**Keywords**: page-level actions, collection actions, create actions, adding new items, primaryActions, secondaryActions, action menus, custom actions, navigation
|
|
32
|
+
|
|
33
|
+
### ID: `sdk_and_schema`
|
|
34
|
+
**Topics**: SDK utilities, optimistic actions, schema usage, filters, server operations
|
|
35
|
+
**Keywords**: SDK utilities, programmatic operations, optimistic actions, immediate UI updates, schema access, collection metadata, server operations, data manipulation, filters configuration, error handling, toast notifications
|
|
36
|
+
|
|
37
|
+
### ID: `action_cell`
|
|
38
|
+
**Topics**: Row-level actions, update/delete actions, custom row actions, action cell configuration
|
|
39
|
+
**Keywords**: row actions, item-level operations, edit, delete, actionCell, row-level operations, update actions, delete confirmations, custom row actions, inline actions, secondary actions
|
|
40
|
+
|
|
41
|
+
### ID: `bulk_actions`
|
|
42
|
+
**Topics**: Bulk operations, bulk delete, bulk action toolbar, multi-select actions
|
|
43
|
+
**Keywords**: bulk operations, multi-select actions, bulk delete, mass operations, bulkActionToolbar, selection-based actions, custom bulk operations
|
|
44
|
+
|
|
45
|
+
### ID: `entity_page`
|
|
46
|
+
**Topics**: Entity page layout, grid system, field layout, containers, components
|
|
47
|
+
**Keywords**: entity page layout, detail page configuration, field arrangement, layout structure, grid system, column spans, main/sidebar sections, field grouping, container usage, custom components, 12-column grid
|
|
48
|
+
|
|
49
|
+
### ID: `entity_page_actions`
|
|
50
|
+
**Topics**: Entity page actions, moreActions, custom entity actions
|
|
51
|
+
**Keywords**: entity page actions, detail page operations, moreActions, secondary actions, custom entity actions, entity-specific operations, action menus
|
|
52
|
+
|
|
53
|
+
### ID: `installation`
|
|
54
|
+
**Topics**: Package installation, setup process, component integration, provider setup
|
|
55
|
+
**Keywords**: installation, setup, getting started, initial setup, package installation, dependencies, component integration, provider setup
|
|
56
|
+
|
|
57
|
+
### ID: `custom_overrides`
|
|
58
|
+
**Topics**: Customization, overrides, custom components, column customization, folder structure
|
|
59
|
+
**Keywords**: customization, custom functionality, overrides, extending functionality, custom components, custom rendering, column overrides, folder structure, organization, row data access
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Recipe Section IDs (Step-by-Step Guides)
|
|
64
|
+
|
|
65
|
+
| Recipe Topic | Section ID | Use Case |
|
|
66
|
+
|--------------|------------|----------|
|
|
67
|
+
| 🚀 First Dashboard | `recipe-first-dashboard` | Complete setup from scratch |
|
|
68
|
+
| ⚡ CRUD Operations | `recipe-crud-operations` | Add Create/Edit/Delete functionality |
|
|
69
|
+
| 📦 Bulk Operations | `recipe-bulk-operations` | Multi-select and bulk actions |
|
|
70
|
+
| 🎨 Complete Customization | `recipe-customization` | Basic to advanced customization and integrations |
|
|
71
|
+
|
|
72
|
+
## LLM Usage Instructions
|
|
73
|
+
|
|
74
|
+
**Step 1**: Match user keywords to section topics/keywords above
|
|
75
|
+
**Step 2**: Choose relevant section ID(s) to read
|
|
76
|
+
**Step 3**: For comprehensive guides, prioritize recipe sections over individual sections
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Installation & Setup
|
|
2
|
+
|
|
3
|
+
## 1. Install Packages
|
|
4
|
+
|
|
5
|
+
Install if necessary and doesn't exists in package.json:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @wix/auto-patterns @wix/patterns @wix/design-system
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## ⚠️ Critical Import Rules
|
|
12
|
+
|
|
13
|
+
- **Import `AutoPatternsApp` only from `@wix/auto-patterns`** - never from other packages
|
|
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
|
+
|
|
16
|
+
## 2. Create AppConfig JSON
|
|
17
|
+
|
|
18
|
+
Save this configuration as a `{collectionName}Config.patterns.json` file in the same directory as your page.tsx component.
|
|
19
|
+
|
|
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`
|
|
24
|
+
|
|
25
|
+
## Render the Collection Page Component
|
|
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.
|
|
28
|
+
|
|
29
|
+
### Page Component Example:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import React, { type FC } from 'react';
|
|
33
|
+
import { WixDesignSystemProvider } from '@wix/design-system';
|
|
34
|
+
import '@wix/design-system/styles.global.css';
|
|
35
|
+
import { WixPatternsProvider } from '@wix/patterns/provider';
|
|
36
|
+
import { PatternsWizardOverridesProvider, AutoPatternsApp } from '@wix/auto-patterns';
|
|
37
|
+
import type { AppConfig } from '@wix/auto-patterns/types';
|
|
38
|
+
import { withDashboard } from '@wix/patterns';
|
|
39
|
+
|
|
40
|
+
import config from './MyCollectionConfig.patterns.json';
|
|
41
|
+
|
|
42
|
+
const Index: FC = () => {
|
|
43
|
+
return (
|
|
44
|
+
<WixDesignSystemProvider features={{ newColorsBranding: true }}>
|
|
45
|
+
<WixPatternsProvider>
|
|
46
|
+
<PatternsWizardOverridesProvider value={{ }}>
|
|
47
|
+
<AutoPatternsApp configuration={config as AppConfig} />
|
|
48
|
+
</PatternsWizardOverridesProvider>
|
|
49
|
+
</WixPatternsProvider>
|
|
50
|
+
</WixDesignSystemProvider>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default withDashboard(Index);
|
|
55
|
+
```
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# AI Agent Instructions for AutoPatternsApp
|
|
2
|
+
|
|
3
|
+
This document serves as a comprehensive guide for AI agents to correctly generate and validate configurations for the `AutoPatternsApp` component. Follow these instructions sequentially to ensure proper implementation.
|
|
4
|
+
|
|
5
|
+
## AI Usage Guidelines
|
|
6
|
+
|
|
7
|
+
1. **Configuration Generation Process**:
|
|
8
|
+
|
|
9
|
+
* First, analyze the schema requirements.
|
|
10
|
+
* Then, select appropriate fields based on data types.
|
|
11
|
+
* Finally, validate against the rules before output.
|
|
12
|
+
|
|
13
|
+
2. **Required Validation Steps**:
|
|
14
|
+
|
|
15
|
+
* Verify exact page count (must be 2).
|
|
16
|
+
* Confirm proper field selection (max 3 columns initially).
|
|
17
|
+
* Check all mandatory fields are present.
|
|
18
|
+
* Ensure no unsupported fields are included.
|
|
19
|
+
* Verify that every collection page has a create action that navigates to the entity page.
|
|
20
|
+
|
|
21
|
+
3. **Decision-Making Priority**:
|
|
22
|
+
|
|
23
|
+
* User explicit requirements override defaults.
|
|
24
|
+
* Schema structure guides field selection.
|
|
25
|
+
* Best practices determine presentation.
|
|
26
|
+
|
|
27
|
+
4. **Enum Configuration Rule (CRITICAL)**:
|
|
28
|
+
|
|
29
|
+
* When generating `enumConfig` (whether implicitly as part of another rule or explicitly upon user request), the AI **must always ask the user to provide the possible option values** for the enum field.
|
|
30
|
+
* The `value` of each option can be **any string specified by the user**, and the `label` should be derived from the `value` (e.g., if `value` is "dog", the `label` can be "Dog").
|
|
31
|
+
* The AI is strictly prohibited from guessing, inventing, or assuming the enum values or their labels.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
# Core Rules
|
|
36
|
+
|
|
37
|
+
## Configuration Rules
|
|
38
|
+
|
|
39
|
+
* Pages array MUST contain exactly two pages.
|
|
40
|
+
* Components array inside collectionPage MUST contain exactly one component with a layout array.
|
|
41
|
+
* Configuration MUST come only from a JSON file.
|
|
42
|
+
* DO NOT fill optional fields unless explicitly requested.
|
|
43
|
+
* Select up to 3 columns initially that best represent the entity.
|
|
44
|
+
* Every collection page MUST include a create action that allows users to create new entities by navigating to the entity page.
|
|
45
|
+
|
|
46
|
+
## Type Binding Rules
|
|
47
|
+
|
|
48
|
+
* If `type: 'collectionPage'`, only `collectionPage` field should exist.
|
|
49
|
+
* If `type: 'entityPage'`, only `entityPage` field should exist.
|
|
50
|
+
* No cross-mixing of types is allowed.
|
|
51
|
+
|
|
52
|
+
## Override Rules
|
|
53
|
+
|
|
54
|
+
* Custom overrides are restricted to documented areas only.
|
|
55
|
+
* Only override columns when specific rendering is required.
|
|
56
|
+
|
|
57
|
+
## Validation Rules
|
|
58
|
+
|
|
59
|
+
* All configurations must align with AppConfig Structure.
|
|
60
|
+
* Remove any configuration entries not in the structure.
|
|
61
|
+
* Verify customColumns.enabled logic (>5 columns or explicit request).
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
# Instruction Guide & Best Practices
|
|
66
|
+
|
|
67
|
+
This guide instructs on how to correctly integrate the `AutoPatternsApp` component from `@wix/auto-patterns` package into a Wix-based admin page.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
# Component Purpose
|
|
72
|
+
|
|
73
|
+
The `AutoPatternsApp` is a page-level component used to display a data collection either as a Table or Grid.
|
|
74
|
+
It is configured using a JSON file conforming to the `AppConfig` interface and supports overrides for advanced use-cases.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Pages Configuration
|
|
2
|
+
|
|
3
|
+
## ⚠️ Critical Page Rules
|
|
4
|
+
|
|
5
|
+
- **Pages array must contain exactly two pages** - one collectionPage and one entityPage
|
|
6
|
+
- **Exactly one page must have `appMainPage: true`** to designate it as the main page
|
|
7
|
+
- **All page IDs referenced in relationships must exist in the configuration** - validate all `parentPageId` and `entityPageId` references
|
|
8
|
+
- **Bind `type` strictly to matching fields** - if `type: 'collectionPage'`, only `collectionPage` field exists (no `entityPage` field), and vice versa
|
|
9
|
+
|
|
10
|
+
## Default Generation
|
|
11
|
+
|
|
12
|
+
* **Always generate two pages**:
|
|
13
|
+
|
|
14
|
+
* One **collectionPage** (routePath: `/`)
|
|
15
|
+
* One **entityPage** (routePath: `/[segment]/:entityId`)
|
|
16
|
+
|
|
17
|
+
* Always use `entityId` as the dynamic URL parameter, not `id`.
|
|
18
|
+
* The route path **must** include a descriptive segment (e.g., `/product/:entityId`, `/pet/:entityId`)
|
|
19
|
+
* **Never use just `/:entityId`** - this conflicts with the collection page route and breaks routing
|
|
20
|
+
|
|
21
|
+
## Type and Structure Binding
|
|
22
|
+
|
|
23
|
+
* If `type: 'collectionPage'`, then **only** `collectionPage` field exists (no `entityPage` field).
|
|
24
|
+
* If `type: 'entityPage'`, then **only** `entityPage` field exists (no `collectionPage` field).
|
|
25
|
+
* **No cross-mixing** allowed.
|
|
26
|
+
|
|
27
|
+
## Page Connection Configuration
|
|
28
|
+
|
|
29
|
+
### Main Page Designation
|
|
30
|
+
|
|
31
|
+
* One page must be designated as the main page using the `appMainPage` property:
|
|
32
|
+
* **Exactly one page** must have `appMainPage: true`
|
|
33
|
+
* When users navigate to the root path (`/`), they will be automatically redirected to this page
|
|
34
|
+
* This is typically set on the collection page, but can be any page based on your application's requirements
|
|
35
|
+
|
|
36
|
+
### Collection-Entity Page Relationships
|
|
37
|
+
|
|
38
|
+
A two-way connection must be established between collection pages and entity pages:
|
|
39
|
+
|
|
40
|
+
1. **From EntityPage to CollectionPage**:
|
|
41
|
+
* Each entity page must specify its parent collection page using `parentPageId`
|
|
42
|
+
* This property on the entity page references the `id` of its parent collection page
|
|
43
|
+
|
|
44
|
+
2. **From CollectionPage to EntityPage**:
|
|
45
|
+
* Each collection page's component must reference its corresponding entity page:
|
|
46
|
+
* Inside the table or grid configuration (not directly in the collectionPage), specify `entityPageId` pointing to the entity page's `id`:
|
|
47
|
+
```json
|
|
48
|
+
"components": [
|
|
49
|
+
{
|
|
50
|
+
"type": "Table", // or "Grid"
|
|
51
|
+
"table": { // or "grid"
|
|
52
|
+
"entityPageId": "my-entity-page-id",
|
|
53
|
+
// other table/grid configuration
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
```
|
|
58
|
+
* ⚠️ **IMPORTANT**: The `entityPageId` field is located within the specific component configuration (table or grid), not at the collection page level
|
|
59
|
+
|
|
60
|
+
### Entity Page URL Configuration
|
|
61
|
+
|
|
62
|
+
* For entity pages (`type: "entityPage"`), the following URL configuration is **mandatory**:
|
|
63
|
+
|
|
64
|
+
1. **Route Path Structure**:
|
|
65
|
+
* The `route.path` **must** include a relative path segment followed by a dynamic parameter (e.g., `/product/:entityId` or `/pets/:entityId`)
|
|
66
|
+
* **Never use just `/:entityId`** - this conflicts with the collection page route `/` and breaks routing
|
|
67
|
+
* The relative path segment should be descriptive of the entity type (e.g., `/product/`, `/pet/`, `/user/`)
|
|
68
|
+
* This parameter is typically named `:entityId` by convention, but any parameter name prefixed with `:` is valid
|
|
69
|
+
|
|
70
|
+
2. **Route Parameters Mapping**:
|
|
71
|
+
* The `route.params` property is required and must map the dynamic parameter:
|
|
72
|
+
```json
|
|
73
|
+
"route": {
|
|
74
|
+
"path": "/product/:entityId",
|
|
75
|
+
"params": {
|
|
76
|
+
"id": "entityId"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
* The `id` field in `route.params` must match the parameter name used in `route.path` (without the colon)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Key Rules for Page Connections
|
|
84
|
+
|
|
85
|
+
* **Main Page Requirement**: Exactly one page must have `appMainPage: true`
|
|
86
|
+
* **Reference Validity**: All page IDs referenced in `parentPageId` and `entityPageId` must exist in the configuration
|
|
87
|
+
* **Relationship Consistency**: The two-way connection must be consistent - if entity page A points to collection page B, then collection page B must point to entity page A
|
|
88
|
+
* **Route Structure**: Entity pages must use `/[segment]/:entityId` format (e.g., `/product/:entityId` or `/pets/:entityId`), never just `/:entityId`
|
|
89
|
+
* **Route Parameters Configuration**: All entity pages must have both a dynamic parameter in `route.path` and a matching configuration in `route.params`
|
|
90
|
+
|
|
91
|
+
## ⚠️ Common Type and Route Mistakes to Avoid
|
|
92
|
+
|
|
93
|
+
- Using incorrect field types
|
|
94
|
+
- Missing required fields
|
|
95
|
+
- Including fields from wrong page type
|
|
96
|
+
- Missing route.params for entity pages
|
|
97
|
+
- Using `/:entityId` instead of `/segment/:entityId` for entity page routes (causes routing conflicts)
|
|
98
|
+
|
|
99
|
+
# Sticky Columns Configuration
|
|
100
|
+
|
|
101
|
+
## Overview
|
|
102
|
+
|
|
103
|
+
Sticky columns allow you to keep specific columns visible while users scroll horizontally through wide tables. This feature improves usability by ensuring important information (like names or IDs) remains accessible during scrolling.
|
|
104
|
+
|
|
105
|
+
## Configuration Properties
|
|
106
|
+
|
|
107
|
+
### stickyColumns
|
|
108
|
+
|
|
109
|
+
- **Type**: `number` (optional)
|
|
110
|
+
- **Description**: Number of columns to make sticky from the start of the table
|
|
111
|
+
- **Behavior**: Sticky columns are always the **first N columns** in the `columns` array
|
|
112
|
+
- **Default**: `undefined` (no sticky columns)
|
|
113
|
+
|
|
114
|
+
## Key Behavior Rules
|
|
115
|
+
|
|
116
|
+
### 🔑 **Critical Rule: Position-Based Stickiness**
|
|
117
|
+
- `stickyColumns: 2` means "make the **first 2 columns** sticky" (positions 0 and 1 in the `columns` array)
|
|
118
|
+
- The sticky columns are determined by **array position**, not by column content
|
|
119
|
+
- If columns are reordered, the sticky behavior follows the new order
|
|
120
|
+
|
|
121
|
+
### 🔒 **Important: Reorder Protection**
|
|
122
|
+
- To protect specific columns from being reordered away from their sticky positions, set `reorderDisabled: true` on those columns
|
|
123
|
+
- This allows `customColumns.enabled: true` while protecting sticky columns from being moved
|
|
124
|
+
- Without reorder protection, users can accidentally move intended sticky columns away from the beginning
|
|
125
|
+
|
|
126
|
+
### ⚠️ **Validation Rules**
|
|
127
|
+
- `stickyColumns` must be a positive number
|
|
128
|
+
- `stickyColumns` should not exceed the total number of columns
|
|
129
|
+
- Invalid values are ignored (treated as `undefined`)
|