@wix/auto-patterns 1.22.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +12 -323
- package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/EditModeEntityPage.js +172 -0
- package/dist/cjs/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js +78 -0
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js +119 -0
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js +79 -0
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/index.js +16 -0
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/index.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js +77 -0
- package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js +109 -0
- package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.js +196 -0
- package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/index.js +12 -0
- package/dist/cjs/components/AutoPatternsEntityPage/index.js.map +1 -1
- package/dist/cjs/hooks/useActionCell.js.map +1 -1
- package/dist/cjs/hooks/useEntityPageActions.js +105 -0
- package/dist/cjs/hooks/useEntityPageActions.js.map +1 -0
- package/dist/cjs/hooks/useEntityPageMoreActions.js +10 -0
- package/dist/cjs/hooks/useEntityPageMoreActions.js.map +1 -1
- package/dist/cjs/hooks/useNavigateEditEntityAction.js +50 -0
- package/dist/cjs/hooks/useNavigateEditEntityAction.js.map +1 -0
- package/dist/cjs/hooks/useNavigationUtils.js +12 -1
- package/dist/cjs/hooks/useNavigationUtils.js.map +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/cjs/types/EntityPageConfig.js.map +1 -1
- package/dist/cjs/types/actions/base.js.map +1 -1
- package/dist/cjs/types/actions/entityPageActions.js.map +1 -1
- package/dist/cjs/utils/actions/types.js.map +1 -1
- package/dist/docs/action_cell.md +6 -2
- package/dist/docs/app_config_structure.md +48 -6
- package/dist/docs/auto-patterns-guide.md +391 -60
- package/dist/docs/bulk_actions.md +7 -6
- package/dist/docs/collection_page_actions.md +14 -4
- package/dist/docs/custom_overrides.md +86 -15
- package/dist/docs/entity_page.md +65 -1
- package/dist/docs/entity_page_actions.md +13 -11
- package/dist/docs/entity_page_view_actions.md +137 -0
- package/dist/docs/index.md +6 -2
- package/dist/docs/pages_configuration.md +1 -11
- package/dist/docs/sdk_utilities.md +11 -4
- package/dist/docs/wix_fqdn_custom_data_source.md +25 -5
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +9 -201
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/EditModeEntityPage.js +115 -0
- package/dist/esm/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js +33 -0
- package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js +70 -0
- package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js +48 -0
- package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/index.js +3 -0
- package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/index.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js +31 -0
- package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js +66 -0
- package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.js +109 -0
- package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/index.js +2 -0
- package/dist/esm/components/AutoPatternsEntityPage/index.js.map +1 -1
- package/dist/esm/hooks/useActionCell.js.map +1 -1
- package/dist/esm/hooks/useEntityPageActions.js +82 -0
- package/dist/esm/hooks/useEntityPageActions.js.map +1 -0
- package/dist/esm/hooks/useEntityPageMoreActions.js +11 -1
- package/dist/esm/hooks/useEntityPageMoreActions.js.map +1 -1
- package/dist/esm/hooks/useNavigateEditEntityAction.js +46 -0
- package/dist/esm/hooks/useNavigateEditEntityAction.js.map +1 -0
- package/dist/esm/hooks/useNavigationUtils.js +12 -1
- package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
- package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/esm/types/EntityPageConfig.js.map +1 -1
- package/dist/esm/types/actions/base.js.map +1 -1
- package/dist/esm/types/actions/entityPageActions.js.map +1 -1
- package/dist/esm/utils/actions/types.js.map +1 -1
- package/dist/types/components/AutoPatternsEntityPage/AutoPatternsEntityPage.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsEntityPage/EditModeEntityPage.d.ts +6 -0
- package/dist/types/components/AutoPatternsEntityPage/EditModeEntityPage.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.d.ts +11 -0
- package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.d.ts +13 -0
- package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.d.ts +8 -0
- package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/RenderLayout/index.d.ts +3 -0
- package/dist/types/components/AutoPatternsEntityPage/RenderLayout/index.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.d.ts +8 -0
- package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.d.ts +8 -0
- package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.d.ts +8 -0
- package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/index.d.ts +2 -0
- package/dist/types/components/AutoPatternsEntityPage/index.d.ts.map +1 -1
- package/dist/types/hooks/useEntityPageActions.d.ts +9 -0
- package/dist/types/hooks/useEntityPageActions.d.ts.map +1 -0
- package/dist/types/hooks/useEntityPageHeaderTexts.d.ts.map +1 -1
- package/dist/types/hooks/useEntityPageMoreActions.d.ts +2 -2
- package/dist/types/hooks/useEntityPageMoreActions.d.ts.map +1 -1
- package/dist/types/hooks/useNavigateEditEntityAction.d.ts +6 -0
- package/dist/types/hooks/useNavigateEditEntityAction.d.ts.map +1 -0
- package/dist/types/hooks/useNavigationUtils.d.ts +1 -0
- package/dist/types/hooks/useNavigationUtils.d.ts.map +1 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -5
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
- package/dist/types/types/EntityPageConfig.d.ts +20 -4
- package/dist/types/types/EntityPageConfig.d.ts.map +1 -1
- package/dist/types/types/actions/base.d.ts +0 -4
- package/dist/types/types/actions/base.d.ts.map +1 -1
- package/dist/types/types/actions/entityPageActions.d.ts +24 -5
- package/dist/types/types/actions/entityPageActions.d.ts.map +1 -1
- package/dist/types/utils/actions/types.d.ts +1 -1
- package/dist/types/utils/actions/types.d.ts.map +1 -1
- package/package.json +15 -15
- package/dist/docs/config_schema.md +0 -184
|
@@ -106,11 +106,15 @@ Custom bulk actions execute JavaScript code that you define for bulk operations.
|
|
|
106
106
|
a.click();
|
|
107
107
|
|
|
108
108
|
// Update server with export timestamp
|
|
109
|
-
|
|
109
|
+
// Handle potential undefined schema
|
|
110
|
+
if (schema) {
|
|
111
|
+
return await schema.actions.update(items);
|
|
112
|
+
}
|
|
113
|
+
return items; // fallback when schema is unavailable
|
|
110
114
|
},
|
|
111
115
|
successToast: `${selectedValues.length} pets exported`,
|
|
112
116
|
errorToast: (err, {retry}) => ({
|
|
113
|
-
|
|
117
|
+
message: 'Export failed',
|
|
114
118
|
action: { text: 'Retry', onClick: retry }
|
|
115
119
|
})
|
|
116
120
|
});
|
|
@@ -194,10 +198,7 @@ The bulk action toolbar uses a specific structure for organizing actions:
|
|
|
194
198
|
"item": {
|
|
195
199
|
"id": "bulkCustom",
|
|
196
200
|
"type": "custom",
|
|
197
|
-
"label": "Custom Bulk"
|
|
198
|
-
"custom": {
|
|
199
|
-
"id": "MyCustomBulk"
|
|
200
|
-
}
|
|
201
|
+
"label": "Custom Bulk"
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
204
|
},
|
|
@@ -87,11 +87,15 @@ Custom collection page actions execute JavaScript code that you define for colle
|
|
|
87
87
|
// Your collection export logic here
|
|
88
88
|
console.log(`Exporting collection: ${collectionId}`);
|
|
89
89
|
// Export and update all items on server
|
|
90
|
-
|
|
90
|
+
// Handle potential undefined schema
|
|
91
|
+
if (schema) {
|
|
92
|
+
return await schema.actions.bulkUpdate({ lastExported: new Date() });
|
|
93
|
+
}
|
|
94
|
+
return Promise.resolve(); // fallback when schema is unavailable
|
|
91
95
|
},
|
|
92
96
|
successToast: 'Collection exported successfully',
|
|
93
97
|
errorToast: (err, {retry}) => ({
|
|
94
|
-
|
|
98
|
+
message: 'Export failed',
|
|
95
99
|
action: { text: 'Retry', onClick: retry }
|
|
96
100
|
})
|
|
97
101
|
}
|
|
@@ -314,10 +318,16 @@ export const quickToggle: CustomActionCollectionPageActionOnRowClickResolver = (
|
|
|
314
318
|
const updatedItem = { ...item, isActive: !item.isActive };
|
|
315
319
|
|
|
316
320
|
optimisticActions.updateOne(updatedItem, {
|
|
317
|
-
submit: async (items) =>
|
|
321
|
+
submit: async (items) => {
|
|
322
|
+
// Handle potential undefined schema
|
|
323
|
+
if (schema) {
|
|
324
|
+
return await schema.actions.update(items[0]);
|
|
325
|
+
}
|
|
326
|
+
return items[0]; // fallback when schema is unavailable
|
|
327
|
+
},
|
|
318
328
|
successToast: `${item.name} toggled successfully`,
|
|
319
329
|
errorToast: (err, {retry}) => ({
|
|
320
|
-
|
|
330
|
+
message: 'Toggle failed',
|
|
321
331
|
action: { text: 'Retry', onClick: retry }
|
|
322
332
|
})
|
|
323
333
|
});
|
|
@@ -108,14 +108,73 @@ Each column in the table has a default rendering based on its field type. You ca
|
|
|
108
108
|
|
|
109
109
|
### Function Signature
|
|
110
110
|
|
|
111
|
+
For proper TypeScript support, use the `IColumnValue<T>` interface:
|
|
112
|
+
|
|
111
113
|
```typescript
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
115
|
+
|
|
116
|
+
function columnOverride(props: IColumnValue<string>) {
|
|
117
|
+
// props.value: The individual column value (typed)
|
|
118
|
+
// props.row: The entire row object containing all field values
|
|
115
119
|
return <YourCustomRendering />;
|
|
116
120
|
}
|
|
117
121
|
```
|
|
118
122
|
|
|
123
|
+
### Type-Specific Examples
|
|
124
|
+
|
|
125
|
+
The generic type `T` in `IColumnValue<T>` should match your field's data type:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import React from 'react';
|
|
129
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
130
|
+
import { Badge } from '@wix/design-system';
|
|
131
|
+
|
|
132
|
+
/* The `IColumnValue<T>` interface provides type safety for column override functions: */
|
|
133
|
+
interface IColumnValue<T> {
|
|
134
|
+
value: T; // The individual column value (strongly typed)
|
|
135
|
+
row: Record<string, any>; // The entire row object with all field values
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// For TEXT fields
|
|
139
|
+
export function petName({ value, row }: IColumnValue<string>) {
|
|
140
|
+
return <span>{value?.toUpperCase()}</span>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// For NUMBER fields
|
|
144
|
+
export function age({ value, row }: IColumnValue<number>) {
|
|
145
|
+
return (
|
|
146
|
+
<Badge skin={value > 5 ? 'warning' : 'success'}>
|
|
147
|
+
{value} years old
|
|
148
|
+
</Badge>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// For BOOLEAN fields
|
|
153
|
+
export function isVaccinated({ value, row }: IColumnValue<boolean>) {
|
|
154
|
+
return (
|
|
155
|
+
<Badge skin={value ? 'success' : 'danger'}>
|
|
156
|
+
{value ? '✓ Vaccinated' : '✗ Not Vaccinated'}
|
|
157
|
+
</Badge>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// For DATE/DATETIME fields
|
|
162
|
+
export function birthDate({ value, row }: IColumnValue<string | Date>) {
|
|
163
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
164
|
+
return <span>{date.toLocaleDateString()}</span>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// For IMAGE fields
|
|
168
|
+
export function profilePicture({ value, row }: IColumnValue<string>) {
|
|
169
|
+
return <img src={value} alt={row.name} width="48" height="48" />;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// For ARRAY fields
|
|
173
|
+
export function hobbies({ value, row }: IColumnValue<string[]>) {
|
|
174
|
+
return <span>{value?.join(', ') || 'No hobbies'}</span>;
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
119
178
|
### Understanding Row Data
|
|
120
179
|
|
|
121
180
|
**Important**: The `row` object contains all field values from the entity, where each property corresponds to a **field ID** from the collection schema. To access specific field values, use the exact field ID as defined in your collection schema.
|
|
@@ -156,22 +215,29 @@ export function myColumn({ value, row }) {
|
|
|
156
215
|
|
|
157
216
|
In `components/columns/name.tsx`:
|
|
158
217
|
|
|
159
|
-
```
|
|
218
|
+
```tsx
|
|
160
219
|
import React from 'react';
|
|
220
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
161
221
|
|
|
162
|
-
export function name(
|
|
163
|
-
// Simple value formatting
|
|
222
|
+
export function name(props: IColumnValue<string>) {
|
|
223
|
+
// Simple value formatting with TypeScript typing
|
|
224
|
+
return <strong>{props.value}</strong>;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Alternative: Destructured parameters with typing
|
|
228
|
+
export function nameAlt({ value, row }: IColumnValue<string>) {
|
|
164
229
|
return <strong>{value}</strong>;
|
|
165
230
|
}
|
|
166
231
|
```
|
|
167
232
|
|
|
168
233
|
In `components/columns/petInfo.tsx`:
|
|
169
234
|
|
|
170
|
-
```
|
|
235
|
+
```tsx
|
|
171
236
|
import React from 'react';
|
|
172
237
|
import { Box, Text } from '@wix/design-system';
|
|
238
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
173
239
|
|
|
174
|
-
export function petInfo({ value, row }) {
|
|
240
|
+
export function petInfo({ value, row }: IColumnValue<string>) {
|
|
175
241
|
// Complex column combining multiple row values
|
|
176
242
|
return (
|
|
177
243
|
<Box direction="vertical" gap={1}>
|
|
@@ -189,11 +255,12 @@ export function petInfo({ value, row }) {
|
|
|
189
255
|
|
|
190
256
|
In `components/columns/status.tsx`:
|
|
191
257
|
|
|
192
|
-
```
|
|
258
|
+
```tsx
|
|
193
259
|
import React from 'react';
|
|
194
260
|
import { Badge } from '@wix/design-system';
|
|
261
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
195
262
|
|
|
196
|
-
export function status({ value, row }) {
|
|
263
|
+
export function status({ value, row }: IColumnValue<string>) {
|
|
197
264
|
// Conditional rendering based on multiple row fields
|
|
198
265
|
if (row.isVaccinated && row.age > 1) {
|
|
199
266
|
return <Badge skin="success">Ready for Adoption</Badge>;
|
|
@@ -207,10 +274,11 @@ export function status({ value, row }) {
|
|
|
207
274
|
|
|
208
275
|
In `components/columns/fullName.tsx`:
|
|
209
276
|
|
|
210
|
-
```
|
|
277
|
+
```tsx
|
|
211
278
|
import React from 'react';
|
|
279
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
212
280
|
|
|
213
|
-
export function fullName({ value, row }) {
|
|
281
|
+
export function fullName({ value, row }: IColumnValue<string>) {
|
|
214
282
|
// Calculated column using multiple fields
|
|
215
283
|
return `${row.name} (owned by ${row.owner})`;
|
|
216
284
|
}
|
|
@@ -218,10 +286,11 @@ export function fullName({ value, row }) {
|
|
|
218
286
|
|
|
219
287
|
In `components/columns/date.tsx`:
|
|
220
288
|
|
|
221
|
-
```
|
|
289
|
+
```tsx
|
|
222
290
|
import React from 'react';
|
|
291
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
223
292
|
|
|
224
|
-
export function date({ value, row }) {
|
|
293
|
+
export function date({ value, row }: IColumnValue<string>) {
|
|
225
294
|
// Access to other row data for enhanced date formatting
|
|
226
295
|
const isRecent = row.lastActivity && new Date(row.lastActivity) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
|
|
227
296
|
|
|
@@ -304,6 +373,8 @@ PatternsWizardOverridesProvider
|
|
|
304
373
|
|
|
305
374
|
### Important Guidelines
|
|
306
375
|
|
|
376
|
+
- **TypeScript Usage**: Always use `IColumnValue<T>` and import it from `@wix/auto-patterns/types`
|
|
377
|
+
- **Type Matching**: Ensure the generic type `T` matches your field's actual data type (string, number, boolean, etc.)
|
|
307
378
|
- **Performance**: Remember that column functions are called for every row, so keep calculations lightweight
|
|
308
379
|
- **Consistency**: When using row data, ensure the column header accurately represents what's displayed
|
|
309
380
|
- **Accessibility**: Maintain proper semantic structure when combining multiple values
|
|
@@ -922,7 +993,7 @@ import * as columns from './components/columns';
|
|
|
922
993
|
import * as actions from './components/actions';
|
|
923
994
|
|
|
924
995
|
<PatternsWizardOverridesProvider value={{ sections, columns, actions }}>
|
|
925
|
-
<AutoPatternsApp configuration={config
|
|
996
|
+
<AutoPatternsApp configuration={config} />
|
|
926
997
|
</PatternsWizardOverridesProvider>
|
|
927
998
|
```
|
|
928
999
|
|
package/dist/docs/entity_page.md
CHANGED
|
@@ -11,8 +11,72 @@ All entity pages must have:
|
|
|
11
11
|
|
|
12
12
|
* Displays details for a **single entity**.
|
|
13
13
|
* Always tied to a single Wix collection.
|
|
14
|
+
* Supports **two distinct modes**: **view mode** and **edit mode** with separate page configurations.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
## Entity Page Modes
|
|
17
|
+
|
|
18
|
+
AutoPatterns supports two entity page modes that can be configured as separate pages:
|
|
19
|
+
|
|
20
|
+
### Edit Mode (Default)
|
|
21
|
+
- **Purpose**: Allows users to modify entity data
|
|
22
|
+
- **UI**: Uses `@wix/patterns` `EntityPage` component with built-in Save/Cancel actions
|
|
23
|
+
- **Actions**: Only supports `moreActions` (custom actions in the "more" menu)
|
|
24
|
+
- **Default Mode**: When `mode` is not specified, defaults to edit mode
|
|
25
|
+
|
|
26
|
+
### View Mode
|
|
27
|
+
- **Purpose**: Displays entity data in read-only format with rich action capabilities
|
|
28
|
+
- **Actions**: Supports `primaryActions`, `secondaryActions`, and `moreActions` (collection-style actions)
|
|
29
|
+
- **Mode**: Must be explicitly set with `mode: 'view'`
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Routing Patterns
|
|
33
|
+
|
|
34
|
+
When implementing both view and edit modes for the same entity, use these routing patterns:
|
|
35
|
+
|
|
36
|
+
- **View Mode**: `/entity/:entityId` (e.g., `/product/:productId`)
|
|
37
|
+
- **Edit Mode**: `/entity/edit/:entityId` (e.g., `/product/edit/:productId`)
|
|
38
|
+
|
|
39
|
+
This pattern allows:
|
|
40
|
+
- Clear distinction between view and edit URLs
|
|
41
|
+
- Natural navigation flow between modes
|
|
42
|
+
|
|
43
|
+
## View Mode: Purpose and API
|
|
44
|
+
|
|
45
|
+
### Purpose of View Mode
|
|
46
|
+
View mode is primarily intended for **read-only entity presentation** with rich action capabilities by default; however, it also supports interactive or editable custom components if needed:
|
|
47
|
+
|
|
48
|
+
- **Data Display**: Present entity information in a clean, read-only format
|
|
49
|
+
- **Action Hub**: Provide primary, secondary, and more actions for entity operations
|
|
50
|
+
- **Navigation Center**: Enable seamless transitions to edit mode and other workflows
|
|
51
|
+
- **Rich Content**: Display images, rich text, and complex data types optimally
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
See [Entity Page View Actions](./entity_page_view_actions.md) for detailed action configuration.
|
|
55
|
+
|
|
56
|
+
#### Out-of-the-Box Features
|
|
57
|
+
|
|
58
|
+
**Automatic Edit Navigation**: When a corresponding edit mode page exists, view mode automatically adds an "Edit [EntityName]" action to the more actions menu.
|
|
59
|
+
|
|
60
|
+
**Back Navigation**: Automatic "Back" button that navigates to the parent collection page.
|
|
61
|
+
|
|
62
|
+
## Action Configuration
|
|
63
|
+
|
|
64
|
+
Entity page action configuration depends on the mode:
|
|
65
|
+
|
|
66
|
+
- **Edit Mode**: Supports only `moreActions`. See [Entity Page Actions](./entity_page_actions.md)
|
|
67
|
+
- **View Mode**: Supports full action API (`primaryActions`, `secondaryActions`, `moreActions`). See [Entity Page View Actions](./entity_page_view_actions.md)
|
|
68
|
+
|
|
69
|
+
### Edit Mode Actions
|
|
70
|
+
- **Supported**: `moreActions` only
|
|
71
|
+
- **Built-in**: Save and Cancel actions are automatically provided
|
|
72
|
+
- **Custom Actions**: Must be defined in the `moreActions` array
|
|
73
|
+
|
|
74
|
+
### View Mode Actions
|
|
75
|
+
- **Supported**: `primaryActions`, `secondaryActions`, and `moreActions`
|
|
76
|
+
- **Pattern**: Follows collection page action patterns
|
|
77
|
+
- **Flexibility**: Full control over all action areas
|
|
78
|
+
|
|
79
|
+
> The custom actions must be defined inside the `moreActions` array for edit mode, but view mode supports actions in all areas.
|
|
16
80
|
|
|
17
81
|
> 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.
|
|
18
82
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
## Entity Page Actions: `moreActions` Support
|
|
1
|
+
## Entity Page Edit Mode Actions: `moreActions` Support
|
|
2
2
|
|
|
3
|
-
Entity pages in
|
|
3
|
+
Entity pages in **edit mode** support not only built-in actions (such as "Save" and "Cancel") but also a flexible set of **more actions** (sometimes called "secondary actions" or `moreActions`). These allow you to provide additional contextual actions for the entity, such as custom logic, or grouped actions.
|
|
4
4
|
|
|
5
|
-
> **Note:**
|
|
5
|
+
> **Note:** This documentation covers **edit mode** entity pages only. Edit mode supports only `moreActions`. For **view mode** entity pages that support `primaryActions`, `secondaryActions`, and `moreActions`, see [Entity Page View Actions](./entity_page_view_actions.md).
|
|
6
|
+
|
|
7
|
+
> **Edit Mode Limitation:** All custom actions for edit mode entity pages must be placed in the `moreActions` array. Do not place custom actions as primary actions on edit mode entity pages. The `moreActions` array is the only supported location for custom actions on edit mode entity pages.
|
|
6
8
|
|
|
7
9
|
### Configuration Structure
|
|
8
10
|
|
|
@@ -39,16 +41,16 @@ Entity pages in AutoPatternsApp support not only a primary action (such as "Save
|
|
|
39
41
|
|
|
40
42
|
---
|
|
41
43
|
|
|
42
|
-
###
|
|
44
|
+
### CustomEntityPageActionResolver
|
|
43
45
|
|
|
44
|
-
The `
|
|
46
|
+
The `CustomEntityPageActionResolver` type is used to implement custom actions for the `moreActions` menu on entity pages in AutoPatternsApp. Each action in the `moreActions` array must have a corresponding resolver function registered in your overrides.
|
|
45
47
|
|
|
46
48
|
#### Function Signature
|
|
47
49
|
|
|
48
50
|
```typescript
|
|
49
|
-
import {
|
|
51
|
+
import { CustomEntityPageActionResolver } from '@wix/auto-patterns/types';
|
|
50
52
|
|
|
51
|
-
export const myMoreAction:
|
|
53
|
+
export const myMoreAction: CustomEntityPageActionResolver = (params) => {
|
|
52
54
|
const { actionParams: { entity, form } , sdk } = params;
|
|
53
55
|
|
|
54
56
|
return {
|
|
@@ -67,10 +69,10 @@ export const myMoreAction: CustomEntityPageMoreActionsActionResolver = (params)
|
|
|
67
69
|
|
|
68
70
|
---
|
|
69
71
|
|
|
70
|
-
#### Key Points for
|
|
72
|
+
#### Key Points for CustomEntityPageActionResolver
|
|
71
73
|
|
|
72
74
|
- The action `id` in the configuration MUST exactly match the function name exported from your actions folder.
|
|
73
|
-
- The implementation must use the `
|
|
75
|
+
- The implementation must use the `CustomEntityPageActionResolver` type.
|
|
74
76
|
- The implementation must be exported as a named export (not default export).
|
|
75
77
|
- The function receives `{ actionParams, sdk }` as parameters.
|
|
76
78
|
- The returned object must include at least a `label` and an `onClick` handler (optionally an `icon`).
|
|
@@ -83,10 +85,10 @@ export const myMoreAction: CustomEntityPageMoreActionsActionResolver = (params)
|
|
|
83
85
|
✓ Each action type only includes its required field(s)
|
|
84
86
|
✓ Custom actions match implementations in overrides
|
|
85
87
|
✓ The resolver is exported and registered in the `actions` property of your `PatternsWizardOverridesProvider`
|
|
86
|
-
✓ The function signature matches `
|
|
88
|
+
✓ The function signature matches `CustomEntityPageActionResolver`
|
|
87
89
|
✓ The returned object includes `label`, `onClick`, and optionally `icon`
|
|
88
90
|
|
|
89
91
|
---
|
|
90
92
|
|
|
91
93
|
**Summary:**
|
|
92
|
-
The `
|
|
94
|
+
The `CustomEntityPageActionResolver` enables you to add custom, contextual actions to the "More Actions" menu on your entity pages. Implement the resolver, export it, and reference it by `id` in your config for seamless integration.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Entity Page View Mode Actions
|
|
2
|
+
|
|
3
|
+
View mode supports the complete collection-style actions API, providing maximum flexibility for entity operations.
|
|
4
|
+
|
|
5
|
+
## Supported Action Types
|
|
6
|
+
|
|
7
|
+
### Primary Actions
|
|
8
|
+
The main call-to-action, typically for the most common operation:
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
primaryActions: {
|
|
12
|
+
type: 'action',
|
|
13
|
+
action: {
|
|
14
|
+
item: {
|
|
15
|
+
id: 'createEntity',
|
|
16
|
+
label: 'Create New',
|
|
17
|
+
type: 'create',
|
|
18
|
+
create: {
|
|
19
|
+
mode: 'page',
|
|
20
|
+
page: { id: 'EntityEditPageId' }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Secondary Actions
|
|
28
|
+
Supporting actions displayed alongside primary actions:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
secondaryActions: {
|
|
32
|
+
type: 'action',
|
|
33
|
+
action: {
|
|
34
|
+
item: {
|
|
35
|
+
id: 'duplicateEntity',
|
|
36
|
+
label: 'Duplicate',
|
|
37
|
+
type: 'custom',
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### More Actions
|
|
44
|
+
Additional contextual actions in dropdown menu:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
moreActions: [
|
|
48
|
+
{
|
|
49
|
+
id: 'shareEntity',
|
|
50
|
+
type: 'custom',
|
|
51
|
+
label: 'Share',
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Action Menu Support
|
|
57
|
+
|
|
58
|
+
View mode also supports menu-style actions for grouping related operations:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
primaryActions: {
|
|
62
|
+
type: 'menu',
|
|
63
|
+
menu: {
|
|
64
|
+
label: 'Actions',
|
|
65
|
+
items: [
|
|
66
|
+
{
|
|
67
|
+
id: 'duplicateProduct',
|
|
68
|
+
label: 'Duplicate',
|
|
69
|
+
type: 'custom',
|
|
70
|
+
},
|
|
71
|
+
{ type: 'divider' },
|
|
72
|
+
{
|
|
73
|
+
id: 'shareProduct',
|
|
74
|
+
type: 'custom',
|
|
75
|
+
label: 'Share'
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Automatic Edit Action
|
|
83
|
+
|
|
84
|
+
View mode automatically provides an "Edit [EntityName]" action in the more actions menu when:
|
|
85
|
+
- An edit mode page exists for the same collection
|
|
86
|
+
- The edit page has no explicit mode or `mode: 'edit'`
|
|
87
|
+
- The view page has `mode: 'view'`
|
|
88
|
+
|
|
89
|
+
This action is automatically added and doesn't need to be configured manually.
|
|
90
|
+
|
|
91
|
+
## Action Resolvers
|
|
92
|
+
|
|
93
|
+
View mode actions follow the same resolver patterns as collection page actions:
|
|
94
|
+
|
|
95
|
+
### For Standard Actions (create)
|
|
96
|
+
These actions are handled automatically by the AutoPatterns framework using the configuration provided.
|
|
97
|
+
|
|
98
|
+
### For Custom Actions
|
|
99
|
+
Custom actions require resolver implementations:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { CustomEntityPageActionResolver } from '@wix/auto-patterns/types';
|
|
103
|
+
|
|
104
|
+
export const duplicateProduct: CustomEntityPageActionResolver = (params) => {
|
|
105
|
+
const { actionParams: { entity }, sdk } = params;
|
|
106
|
+
|
|
107
|
+
const schema = sdk.getSchema(sdk.collectionId);
|
|
108
|
+
return {
|
|
109
|
+
label: 'Duplicate Product',
|
|
110
|
+
icon: <DuplicateIcon />, // optional
|
|
111
|
+
onClick: async () => {
|
|
112
|
+
// Your custom duplication logic here
|
|
113
|
+
await schema.actions.create({
|
|
114
|
+
...entity,
|
|
115
|
+
name: `${entity.name} (Copy)`
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Best Practices
|
|
123
|
+
|
|
124
|
+
### When to Use Each Action Type
|
|
125
|
+
|
|
126
|
+
**Primary Actions**: Use for the most common user action (typically "Create" or main workflow action)
|
|
127
|
+
|
|
128
|
+
**Secondary Actions**: Use for supporting workflows like "Duplicate"
|
|
129
|
+
|
|
130
|
+
**More Actions**: Use for:
|
|
131
|
+
- Less common operations
|
|
132
|
+
- Administrative functions
|
|
133
|
+
- Actions that need confirmation
|
|
134
|
+
|
|
135
|
+
### Navigation Patterns
|
|
136
|
+
|
|
137
|
+
1. **View → Create**: Use primary actions with `type: 'create'`
|
package/dist/docs/index.md
CHANGED
|
@@ -43,8 +43,12 @@ This index maps user requests to the appropriate section IDs for fetching releva
|
|
|
43
43
|
**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
|
|
44
44
|
|
|
45
45
|
### ID: `entity_page_actions`
|
|
46
|
-
**Topics**: Entity page actions, moreActions, custom entity actions
|
|
47
|
-
**Keywords**: entity page actions,
|
|
46
|
+
**Topics**: Entity page edit mode actions, moreActions, custom entity actions
|
|
47
|
+
**Keywords**: entity page actions, edit mode actions, moreActions, custom entity actions, entity-specific operations, action menus
|
|
48
|
+
|
|
49
|
+
### ID: `entity_page_view_actions`
|
|
50
|
+
**Topics**: Entity page view mode actions, primaryActions, secondaryActions, collection-style actions
|
|
51
|
+
**Keywords**: view mode actions, primaryActions, secondaryActions, read-only entity actions, entity page view operations, collection-style entity actions, navigation actions
|
|
48
52
|
|
|
49
53
|
### ID: `installation`
|
|
50
54
|
**Topics**: Package installation, setup process, component integration, provider setup
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
- **Pages array must contain exactly two pages** - one collectionPage and one entityPage
|
|
6
6
|
- **Exactly one page must have `appMainPage: true`** to designate it as the main page
|
|
7
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
8
|
|
|
10
9
|
## Default Generation
|
|
11
10
|
|
|
@@ -18,12 +17,6 @@
|
|
|
18
17
|
* The route path **must** include a descriptive segment (e.g., `/product/:entityId`, `/pet/:entityId`)
|
|
19
18
|
* **Never use just `/:entityId`** - this conflicts with the collection page route and breaks routing
|
|
20
19
|
|
|
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
20
|
## Page Connection Configuration
|
|
28
21
|
|
|
29
22
|
### Main Page Designation
|
|
@@ -88,11 +81,8 @@ A two-way connection must be established between collection pages and entity pag
|
|
|
88
81
|
* **Route Structure**: Entity pages must use `/[segment]/:entityId` format (e.g., `/product/:entityId` or `/pets/:entityId`), never just `/:entityId`
|
|
89
82
|
* **Route Parameters Configuration**: All entity pages must have both a dynamic parameter in `route.path` and a matching configuration in `route.params`
|
|
90
83
|
|
|
91
|
-
## ⚠️ Common
|
|
84
|
+
## ⚠️ Common Route and Configuration Mistakes to Avoid
|
|
92
85
|
|
|
93
|
-
- Using incorrect field types
|
|
94
|
-
- Missing required fields
|
|
95
|
-
- Including fields from wrong page type
|
|
96
86
|
- Missing route.params for entity pages
|
|
97
87
|
- Using `/:entityId` instead of `/segment/:entityId` for entity page routes (causes routing conflicts)
|
|
98
88
|
|
|
@@ -48,9 +48,15 @@ const optimisticActions = sdk.getOptimisticActions(sdk.collectionId);
|
|
|
48
48
|
const schema = sdk.getSchema(sdk.collectionId);
|
|
49
49
|
|
|
50
50
|
optimisticActions.operation(items, {
|
|
51
|
-
submit: async (items) =>
|
|
51
|
+
submit: async (items) => {
|
|
52
|
+
// Handle potential undefined schema
|
|
53
|
+
if (schema) {
|
|
54
|
+
return await schema.actions.serverMethod(items);
|
|
55
|
+
}
|
|
56
|
+
return items; // fallback when schema is unavailable
|
|
57
|
+
},
|
|
52
58
|
successToast: 'Success message',
|
|
53
|
-
errorToast: (err, {retry}) => ({
|
|
59
|
+
errorToast: (err, {retry}) => ({ message: 'Error message', action: { text: 'Retry', onClick: retry }})
|
|
54
60
|
});
|
|
55
61
|
```
|
|
56
62
|
|
|
@@ -81,7 +87,7 @@ interface OptimisticParams<T> {
|
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
interface ToastConfig {
|
|
84
|
-
|
|
90
|
+
message: string; // Note: Use 'message' property, not 'text'
|
|
85
91
|
action?: { text: string; onClick: () => void };
|
|
86
92
|
}
|
|
87
93
|
```
|
|
@@ -90,8 +96,9 @@ interface ToastConfig {
|
|
|
90
96
|
|
|
91
97
|
**Before using optimistic actions:**
|
|
92
98
|
- Verify `sdk.getOptimisticActions(collectionId)` returns valid instance
|
|
93
|
-
-
|
|
99
|
+
- **Always check for undefined schema**: `sdk.getSchema(collectionId)` can return `undefined` - handle this case in your submit functions
|
|
94
100
|
- For delete operations: `showUndoToast: true` is mandatory
|
|
95
101
|
- All `submit` functions must return a Promise
|
|
102
|
+
- **Toast property**: Use `message` property in ToastConfig, not `text`
|
|
96
103
|
|
|
97
104
|
**SDK Parameter:** Available in custom actions and modals. See SDK Utilities section for complete interface.
|