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