@wix/auto-patterns 1.37.0 → 1.38.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/AutoPatternsApp/AutoPatternsApp.js +1 -1
- package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageContent/SkeletonCollection.js +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageFooter/AutoPatternsCollectionPageFooter.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/EditModeEntityPage.js +13 -9
- package/dist/cjs/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/Checkbox.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/DateInput.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/DateTime.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/FormFieldInput.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/ImageInput.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/LongText.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/Number.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/ShortText.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/Url.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/SkeletonEntity.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.js +1 -1
- package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGrid.js +9 -6
- package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGrid.js.map +1 -1
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js +1 -1
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js +1 -1
- package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js +11 -6
- package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/cjs/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.js +1 -1
- package/dist/cjs/components/DynamicIcon.js +1 -1
- package/dist/cjs/components/ModalRenderer.js +1 -1
- package/dist/cjs/components/filters/DynamicCollectionFilter.js +1 -1
- package/dist/cjs/components/filters/StaticCollectionFilter.js +1 -1
- package/dist/cjs/components/modals/actions/BulkDeleteModal.js +28 -10
- package/dist/cjs/components/modals/actions/BulkDeleteModal.js.map +1 -1
- package/dist/cjs/components/modals/actions/CreateModal.js +1 -1
- package/dist/cjs/components/modals/actions/EditModal.js +1 -1
- package/dist/cjs/counter.js +1 -1
- package/dist/cjs/dataSourceAdapters/cms/filterUtils.js +3 -2
- package/dist/cjs/dataSourceAdapters/cms/filterUtils.js.map +1 -1
- package/dist/cjs/dataSourceAdapters/cms/sortUtils.js +2 -1
- package/dist/cjs/dataSourceAdapters/cms/sortUtils.js.map +1 -1
- package/dist/cjs/hooks/useBaseTableFeatures.js +6 -3
- package/dist/cjs/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useBulkActionToolbar.js +1 -1
- package/dist/cjs/hooks/useCollectionPageActions.js +1 -1
- package/dist/cjs/hooks/useColumns.js +1 -1
- package/dist/cjs/hooks/useCommonCollectionFeatures.js +1 -1
- package/dist/cjs/hooks/useDataExtensionProps.js +30 -0
- package/dist/cjs/hooks/useDataExtensionProps.js.map +1 -0
- package/dist/cjs/hooks/useDragAndDropBaseProps.js +30 -0
- package/dist/cjs/hooks/useDragAndDropBaseProps.js.map +1 -0
- package/dist/cjs/hooks/useEmptyStates.js +1 -1
- package/dist/cjs/hooks/useEntityPageActions.js +1 -1
- package/dist/cjs/hooks/useFilters.js +1 -1
- package/dist/cjs/hooks/useGridDragAndDrop.js +17 -0
- package/dist/cjs/hooks/useGridDragAndDrop.js.map +1 -0
- package/dist/cjs/hooks/useGridFeatures.js +4 -1
- package/dist/cjs/hooks/useGridFeatures.js.map +1 -1
- package/dist/cjs/hooks/useTableDragAndDrop.js +17 -0
- package/dist/cjs/hooks/useTableDragAndDrop.js.map +1 -0
- package/dist/cjs/hooks/useTableFeatures.js +7 -2
- package/dist/cjs/hooks/useTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useTableGridSwitchDragAndDrop.js +17 -0
- package/dist/cjs/hooks/useTableGridSwitchDragAndDrop.js.map +1 -0
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js +7 -2
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js.map +1 -1
- package/dist/cjs/providers/AppConfigContext.js +1 -1
- package/dist/cjs/providers/AppContext.js +1 -1
- package/dist/cjs/providers/AppContextData.js +1 -1
- package/dist/cjs/providers/AutoPatternsOverridesContext.js +2 -2
- package/dist/cjs/providers/AutoPatternsOverridesContext.js.map +1 -1
- package/dist/cjs/providers/ErrorContext.js +1 -1
- package/dist/cjs/providers/ItemsContext.js +1 -1
- package/dist/cjs/providers/ModalContext.js +1 -1
- package/dist/cjs/providers/OptimisticActionsContext.js +1 -1
- package/dist/cjs/providers/RootAppProvider.js +1 -1
- package/dist/cjs/providers/SchemaContext.js +1 -1
- package/dist/cjs/providers/SchemaRegistryContext.js +1 -1
- package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
- package/dist/cjs/types/DeepPartial.js +4 -0
- package/dist/cjs/types/DeepPartial.js.map +1 -0
- package/dist/cjs/types/actions/base.js.map +1 -1
- package/dist/cjs/types/types.js.map +1 -1
- package/dist/cjs/utils/actions/bulkDeleteAction.js +1 -1
- package/dist/cjs/utils/actions/createAction.js +1 -1
- package/dist/cjs/utils/actions/deleteAction.js +1 -1
- package/dist/cjs/utils/actions/updateAction.js +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/EditModeEntityPage.js +4 -0
- package/dist/esm/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsGrid/AutoPatternsGrid.js +7 -4
- package/dist/esm/components/AutoPatternsGrid/AutoPatternsGrid.js.map +1 -1
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js +9 -4
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/esm/components/modals/actions/BulkDeleteModal.js +20 -3
- package/dist/esm/components/modals/actions/BulkDeleteModal.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js +3 -2
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/sortUtils.js +2 -1
- package/dist/esm/dataSourceAdapters/cms/sortUtils.js.map +1 -1
- package/dist/esm/hooks/useBaseTableFeatures.js +4 -1
- package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useDataExtensionProps.js +18 -0
- package/dist/esm/hooks/useDataExtensionProps.js.map +1 -0
- package/dist/esm/hooks/useDragAndDropBaseProps.js +27 -0
- package/dist/esm/hooks/useDragAndDropBaseProps.js.map +1 -0
- package/dist/esm/hooks/useGridDragAndDrop.js +13 -0
- package/dist/esm/hooks/useGridDragAndDrop.js.map +1 -0
- package/dist/esm/hooks/useGridFeatures.js +4 -1
- package/dist/esm/hooks/useGridFeatures.js.map +1 -1
- package/dist/esm/hooks/useTableDragAndDrop.js +13 -0
- package/dist/esm/hooks/useTableDragAndDrop.js.map +1 -0
- package/dist/esm/hooks/useTableFeatures.js +7 -2
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useTableGridSwitchDragAndDrop.js +13 -0
- package/dist/esm/hooks/useTableGridSwitchDragAndDrop.js.map +1 -0
- package/dist/esm/hooks/useTableGridSwitchFeatures.js +7 -2
- package/dist/esm/hooks/useTableGridSwitchFeatures.js.map +1 -1
- package/dist/esm/providers/AutoPatternsOverridesContext.js.map +1 -1
- package/dist/esm/types/CollectionPageConfig.js.map +1 -1
- package/dist/esm/types/DeepPartial.js +2 -0
- package/dist/esm/types/DeepPartial.js.map +1 -0
- package/dist/esm/types/actions/base.js.map +1 -1
- package/dist/esm/types/types.js.map +1 -1
- package/dist/types/components/AutoPatternsEntityPage/EditModeEntityPage.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsGrid/AutoPatternsGrid.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsTable/AutoPatternsTable.d.ts.map +1 -1
- package/dist/types/components/modals/actions/BulkDeleteModal.d.ts.map +1 -1
- package/dist/types/hooks/useBaseTableFeatures.d.ts +10 -0
- package/dist/types/hooks/useBaseTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useDataExtensionProps.d.ts +8 -0
- package/dist/types/hooks/useDataExtensionProps.d.ts.map +1 -0
- package/dist/types/hooks/useDragAndDropBaseProps.d.ts +4 -0
- package/dist/types/hooks/useDragAndDropBaseProps.d.ts.map +1 -0
- package/dist/types/hooks/useGridDragAndDrop.d.ts +24 -0
- package/dist/types/hooks/useGridDragAndDrop.d.ts.map +1 -0
- package/dist/types/hooks/useGridFeatures.d.ts +22 -0
- package/dist/types/hooks/useGridFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useTableDragAndDrop.d.ts +3 -0
- package/dist/types/hooks/useTableDragAndDrop.d.ts.map +1 -0
- package/dist/types/hooks/useTableFeatures.d.ts +2 -0
- package/dist/types/hooks/useTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useTableGridSwitchDragAndDrop.d.ts +27 -0
- package/dist/types/hooks/useTableGridSwitchDragAndDrop.d.ts.map +1 -0
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +24 -0
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts.map +1 -1
- package/dist/types/providers/AutoPatternsOverridesContext.d.ts +6 -0
- package/dist/types/providers/AutoPatternsOverridesContext.d.ts.map +1 -1
- package/dist/types/types/CollectionPageConfig.d.ts +15 -0
- package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
- package/dist/types/types/DeepPartial.d.ts +4 -0
- package/dist/types/types/DeepPartial.d.ts.map +1 -0
- package/dist/types/types/actions/base.d.ts +5 -0
- package/dist/types/types/actions/base.d.ts.map +1 -1
- package/dist/types/types/types.d.ts +24 -1
- package/dist/types/types/types.d.ts.map +1 -1
- package/docs/GETTING_STARTED.md +6 -2
- package/mcp-docs/app_config_structure.md +14 -1
- package/mcp-docs/auto-patterns-guide.md +282 -80
- package/mcp-docs/bulk_actions.md +60 -0
- package/mcp-docs/custom_overrides.md +134 -54
- package/mcp-docs/schema_config.md +74 -25
- package/mcp-docs/wix_fqdn_custom_data_source.md +66 -11
- package/package.json +12 -12
|
@@ -311,7 +311,8 @@ export interface AppConfig {
|
|
|
311
311
|
mode: 'modal'; // Currently only 'modal' is supported
|
|
312
312
|
modal: {
|
|
313
313
|
title?: {
|
|
314
|
-
text
|
|
314
|
+
text?: string; // Static modal title
|
|
315
|
+
id?: string; // Dynamic title resolver ID
|
|
315
316
|
};
|
|
316
317
|
description?: {
|
|
317
318
|
text: string; // Modal description
|
|
@@ -367,6 +368,15 @@ export interface AppConfig {
|
|
|
367
368
|
id?: string; // Custom CTA ID
|
|
368
369
|
};
|
|
369
370
|
};
|
|
371
|
+
/**
|
|
372
|
+
* Drag and drop configuration.
|
|
373
|
+
*/
|
|
374
|
+
dragAndDrop?: {
|
|
375
|
+
/**
|
|
376
|
+
* Whether drag and drop is enabled. When enabled, the [schema](./schema_config.md) must support a "move" action.
|
|
377
|
+
*/
|
|
378
|
+
enabled: boolean;
|
|
379
|
+
};
|
|
370
380
|
layout: [ // Array of layout items that define what components to render
|
|
371
381
|
{
|
|
372
382
|
type: 'Table'; // Layout item type for table rendering
|
|
@@ -387,6 +397,9 @@ export interface AppConfig {
|
|
|
387
397
|
customColumns?: {
|
|
388
398
|
enabled: boolean; // Enable user customization (hide/reorder columns)
|
|
389
399
|
};
|
|
400
|
+
dataExtension?: {
|
|
401
|
+
enabled: boolean; // Enable data extension
|
|
402
|
+
};
|
|
390
403
|
stickyColumns?: number; // Number of columns to make sticky from the start. Sticky columns remain visible when horizontally scrolling.
|
|
391
404
|
showTitleBar?: boolean; // Whether to show the table column headers. Default: true
|
|
392
405
|
};
|
|
@@ -1385,19 +1398,47 @@ export interface SchemaConfig {
|
|
|
1385
1398
|
| { items: any[]; cursor?: string | null; total?: number | null }
|
|
1386
1399
|
| { items: any[]; hasNext?: boolean; total?: number | null }
|
|
1387
1400
|
>;
|
|
1401
|
+
/**
|
|
1402
|
+
* Reorder an entity within the collection.
|
|
1403
|
+
* @param id The ID of the entity to move.
|
|
1404
|
+
* @param params.moveAfterId The ID of the entity that should precede the moved entity, or null/undefined to move to start.
|
|
1405
|
+
*/
|
|
1406
|
+
move?: (
|
|
1407
|
+
id: string,
|
|
1408
|
+
params: {
|
|
1409
|
+
moveAfterId: string | null | undefined;
|
|
1410
|
+
},
|
|
1411
|
+
) => Promise<void>;
|
|
1388
1412
|
};
|
|
1413
|
+
/**
|
|
1414
|
+
* Whether the entity supports data extensions
|
|
1415
|
+
* Maps to `info.extensible` in the collection schema - map only properties that are relevant or `null` if not extensible
|
|
1416
|
+
*/
|
|
1417
|
+
extensible: {
|
|
1418
|
+
/**
|
|
1419
|
+
* Whether the entity supports filtering on data extensions
|
|
1420
|
+
* Maps to `info.extensible.filterable` in the collection schema
|
|
1421
|
+
*/
|
|
1422
|
+
filterable?: boolean;
|
|
1423
|
+
} | null;
|
|
1424
|
+
/**
|
|
1425
|
+
* Whether the schema contains personally identifiable information (PII).
|
|
1426
|
+
* Maps to `info.containsPii` in the collection schema
|
|
1427
|
+
*/
|
|
1428
|
+
containsPii: boolean;
|
|
1389
1429
|
}
|
|
1390
1430
|
|
|
1391
1431
|
export interface Query {
|
|
1392
|
-
limit: number;
|
|
1393
|
-
offset?: number;
|
|
1394
|
-
page: number;
|
|
1395
|
-
search?: string;
|
|
1396
|
-
cursor?: string | null;
|
|
1397
|
-
filters: Record<string, any>;
|
|
1398
|
-
sort?: {
|
|
1399
|
-
|
|
1400
|
-
|
|
1432
|
+
limit: number; // Maximum number of items to return per request (controls page size)
|
|
1433
|
+
offset?: number; // Number of items to skip from the beginning (for pagination)
|
|
1434
|
+
page: number; // Current page number (1-based, works with limit for pagination)
|
|
1435
|
+
search?: string; // Text search query applied to searchable fields
|
|
1436
|
+
cursor?: string | null; // Cursor-based pagination token (alternative to offset-based pagination)
|
|
1437
|
+
filters: Record<string, any>; // Field-specific filter conditions (keys = field IDs, values = filter criteria)
|
|
1438
|
+
sort?: {
|
|
1439
|
+
// Sorting configuration for result ordering
|
|
1440
|
+
fieldName: string; // Field ID to sort by (must be sortable per field capabilities)
|
|
1441
|
+
order: 'asc' | 'desc'; // Sort direction
|
|
1401
1442
|
}[];
|
|
1402
1443
|
}
|
|
1403
1444
|
```
|
|
@@ -1448,43 +1489,63 @@ export type Field = ReferenceField | NonReferenceField;
|
|
|
1448
1489
|
### Key Properties
|
|
1449
1490
|
|
|
1450
1491
|
• **id** - `string`
|
|
1451
|
-
|
|
1452
|
-
|
|
1492
|
+
|
|
1493
|
+
- Collection identifier (e.g., "WixPets")
|
|
1494
|
+
- Example: `schema.id === "WixPets"`
|
|
1453
1495
|
|
|
1454
1496
|
• **idField** - `string`
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1497
|
+
|
|
1498
|
+
- Primary key field name (usually "\_id")
|
|
1499
|
+
- Required for all update/delete operations
|
|
1500
|
+
- Example: `const id = item[schema.idField]`
|
|
1458
1501
|
|
|
1459
1502
|
• **displayField** - `string`
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1503
|
+
|
|
1504
|
+
- Main field for displaying items (name, title, etc.)
|
|
1505
|
+
- Used in UI components for item identification
|
|
1506
|
+
- Example: `const label = item[schema.displayField]`
|
|
1463
1507
|
|
|
1464
1508
|
• **fields** - `Record<string, Field | undefined>`
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1509
|
+
|
|
1510
|
+
- Complete field definitions with types and metadata
|
|
1511
|
+
- Useful for dynamic form generation or validation
|
|
1512
|
+
- Each field contains type information, validation rules, and capabilities
|
|
1513
|
+
- Example: `schema.fields.name.type === 'SHORT_TEXT'`
|
|
1469
1514
|
|
|
1470
1515
|
• **actions** - Server operation functions
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1516
|
+
|
|
1517
|
+
- Pre-configured API calls for CRUD operations
|
|
1518
|
+
- Use with optimistic actions for best UX
|
|
1519
|
+
- All actions return Promises and handle server communication
|
|
1520
|
+
- Example: `await schema.actions.update(item)`
|
|
1521
|
+
|
|
1522
|
+
• **extensible** - `object | null`
|
|
1523
|
+
|
|
1524
|
+
- Indicates if the entity supports data extensions
|
|
1525
|
+
|
|
1526
|
+
• **extensible.filterable** - `boolean | undefined`
|
|
1527
|
+
|
|
1528
|
+
- Indicates if filtering on data extensions is supported
|
|
1529
|
+
|
|
1530
|
+
• **containsPii** - `boolean`
|
|
1531
|
+
|
|
1532
|
+
- Indicates if the schema contains personally identifiable information (PII)
|
|
1475
1533
|
|
|
1476
1534
|
### Available Schema Actions
|
|
1477
1535
|
|
|
1478
1536
|
#### Individual Entity Operations
|
|
1537
|
+
|
|
1479
1538
|
- **schema.actions.get(entityId)** - Retrieve a single entity by ID
|
|
1480
1539
|
- **schema.actions.create(newEntity)** - Create a new entity
|
|
1481
1540
|
- **schema.actions.update(updatedEntity)** - Update an existing entity
|
|
1482
1541
|
- **schema.actions.delete(entityId)** - Delete a single entity by ID
|
|
1483
1542
|
|
|
1484
1543
|
#### Bulk Operations
|
|
1544
|
+
|
|
1485
1545
|
- **schema.actions.bulkDelete(entityIds)** - Delete multiple entities by their IDs
|
|
1486
1546
|
|
|
1487
1547
|
#### Query Operations
|
|
1548
|
+
|
|
1488
1549
|
- **schema.actions.find(query, options)** - Search and filter entities
|
|
1489
1550
|
- `query`: Query object with pagination, filtering, sorting, and search criteria (see Query Interface section)
|
|
1490
1551
|
- `options.searchableFieldIds`: Array of field IDs that support text search
|
|
@@ -1511,6 +1572,7 @@ Each field in the `fields` record contains:
|
|
|
1511
1572
|
### Reference Fields
|
|
1512
1573
|
|
|
1513
1574
|
Reference fields have additional metadata:
|
|
1575
|
+
|
|
1514
1576
|
- **referenceMetadata.referencedCollectionId**: ID of the collection being referenced
|
|
1515
1577
|
- Used for establishing relationships between different collections
|
|
1516
1578
|
|
|
@@ -1912,6 +1974,66 @@ Bulk delete actions remove multiple entities with a confirmation modal.
|
|
|
1912
1974
|
2. `bulkDelete.modal` object must exist
|
|
1913
1975
|
3. The modal properties (title, description, actions, feedback) are all optional
|
|
1914
1976
|
|
|
1977
|
+
#### Dynamic Modal Titles
|
|
1978
|
+
|
|
1979
|
+
Bulk delete modal titles can be made dynamic to reflect the number and type of selected items.
|
|
1980
|
+
|
|
1981
|
+
**Configuration**
|
|
1982
|
+
|
|
1983
|
+
Use the `title.id` property to reference a dynamic title resolver:
|
|
1984
|
+
|
|
1985
|
+
```typescript
|
|
1986
|
+
bulkActionToolbar: {
|
|
1987
|
+
primaryActions: [{
|
|
1988
|
+
type: 'action',
|
|
1989
|
+
action: {
|
|
1990
|
+
item: {
|
|
1991
|
+
id: 'bulkDelete',
|
|
1992
|
+
type: 'bulkDelete',
|
|
1993
|
+
bulkDelete: {
|
|
1994
|
+
mode: 'modal',
|
|
1995
|
+
modal: {
|
|
1996
|
+
title: {
|
|
1997
|
+
id: 'dynamicDeleteTitle' // References override function
|
|
1998
|
+
},
|
|
1999
|
+
// ... other modal config
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
}]
|
|
2005
|
+
}
|
|
2006
|
+
```
|
|
2007
|
+
|
|
2008
|
+
**Implementation**
|
|
2009
|
+
|
|
2010
|
+
Create a title resolver function in your overrides:
|
|
2011
|
+
|
|
2012
|
+
```typescript
|
|
2013
|
+
const useBulkDeleteModalTitle = () => ({
|
|
2014
|
+
dynamicDeleteTitle: ({ selectedCount, selectedValues }) => ({
|
|
2015
|
+
text: `Delete ${selectedCount} ${selectedCount === 1 ? 'item' : 'items'}?`
|
|
2016
|
+
}),
|
|
2017
|
+
});
|
|
2018
|
+
|
|
2019
|
+
const bulkDeleteModalTitle = useBulkDeleteModalTitle();
|
|
2020
|
+
// In your page component
|
|
2021
|
+
<AutoPatternsOverridesProvider
|
|
2022
|
+
value={{
|
|
2023
|
+
bulkDeleteModalTitle,
|
|
2024
|
+
// ... other overrides
|
|
2025
|
+
}}
|
|
2026
|
+
>
|
|
2027
|
+
<AutoPatternsApp configuration={config} />
|
|
2028
|
+
</AutoPatternsOverridesProvider>
|
|
2029
|
+
```
|
|
2030
|
+
|
|
2031
|
+
**Parameters**
|
|
2032
|
+
|
|
2033
|
+
The title resolver function receives:
|
|
2034
|
+
- `selectedCount: number` - Total number of selected items
|
|
2035
|
+
- `selectedValues: any[]` - Array of selected item objects
|
|
2036
|
+
|
|
1915
2037
|
### Custom Bulk Action Configuration
|
|
1916
2038
|
|
|
1917
2039
|
Custom bulk actions execute JavaScript code that you define for bulk operations. These actions receive parameters that give them access to selected entities data and utilities. Here's how to implement a custom bulk action:
|
|
@@ -3377,7 +3499,19 @@ export default function YourPage() {
|
|
|
3377
3499
|
const entityPageHeaderBadges = useEntityPageHeaderBadges();
|
|
3378
3500
|
|
|
3379
3501
|
return (
|
|
3380
|
-
<AutoPatternsOverridesProvider
|
|
3502
|
+
<AutoPatternsOverridesProvider
|
|
3503
|
+
value={{
|
|
3504
|
+
actions,
|
|
3505
|
+
columns,
|
|
3506
|
+
slots,
|
|
3507
|
+
sections,
|
|
3508
|
+
components,
|
|
3509
|
+
modals,
|
|
3510
|
+
customDataSources,
|
|
3511
|
+
entityPageHeaderSubtitle,
|
|
3512
|
+
entityPageHeaderBadges,
|
|
3513
|
+
}}
|
|
3514
|
+
>
|
|
3381
3515
|
<AutoPatternsApp configuration={config} />
|
|
3382
3516
|
</AutoPatternsOverridesProvider>
|
|
3383
3517
|
);
|
|
@@ -3389,6 +3523,7 @@ export default function YourPage() {
|
|
|
3389
3523
|
**When adding any new implementation (action, modal, column, slot, section or component), you MUST update the corresponding hook in the `index.tsx` file to include your new implementation.** The main page component uses these hooks, so they serve as the central export point for each type of override.
|
|
3390
3524
|
|
|
3391
3525
|
For example:
|
|
3526
|
+
|
|
3392
3527
|
- Adding a new action → Update `../components/actions/index.tsx` to include the new action in the `useActions` hook
|
|
3393
3528
|
- Adding a new modal → Update `../components/modals/index.tsx` to include the new modal in the `useModals` hook
|
|
3394
3529
|
- Adding a new column override → Update `../components/columns/index.tsx` to include the new column in the `useColumns` hook
|
|
@@ -3409,6 +3544,38 @@ Without updating the hook index files, your implementations won't be available t
|
|
|
3409
3544
|
- Incorrect import paths or naming mismatches
|
|
3410
3545
|
- Forgetting to import and use the hook in the main page component
|
|
3411
3546
|
|
|
3547
|
+
## Bulk Delete Modal Titles
|
|
3548
|
+
|
|
3549
|
+
Dynamic title generation for bulk delete confirmation modals.
|
|
3550
|
+
|
|
3551
|
+
```typescript
|
|
3552
|
+
bulkDeleteModalTitle?: Record<
|
|
3553
|
+
string,
|
|
3554
|
+
(params: { selectedCount: number; selectedValues: any[] }) => { text: string }
|
|
3555
|
+
>;
|
|
3556
|
+
```
|
|
3557
|
+
|
|
3558
|
+
**Usage Example:**
|
|
3559
|
+
```typescript
|
|
3560
|
+
const useBulkDeleteModalTitle = () => ({
|
|
3561
|
+
dynamicProductDelete: ({ selectedCount }) => ({
|
|
3562
|
+
text: `Delete ${selectedCount} ${selectedCount === 1 ? 'product' : 'products'}?`
|
|
3563
|
+
}),
|
|
3564
|
+
});
|
|
3565
|
+
```
|
|
3566
|
+
|
|
3567
|
+
**Integration:**
|
|
3568
|
+
```typescript
|
|
3569
|
+
|
|
3570
|
+
const bulkDeleteModalTitle = useBulkDeleteModalTitle();
|
|
3571
|
+
|
|
3572
|
+
<AutoPatternsOverridesProvider
|
|
3573
|
+
value={{
|
|
3574
|
+
bulkDeleteModalTitle,
|
|
3575
|
+
}}
|
|
3576
|
+
>
|
|
3577
|
+
```
|
|
3578
|
+
|
|
3412
3579
|
## Columns
|
|
3413
3580
|
|
|
3414
3581
|
Each column in the table has a default rendering based on its field type. You can override this rendering by providing a custom function for the `column.id`. This allows you to customize how specific columns are displayed.
|
|
@@ -3440,8 +3607,8 @@ import { Badge } from '@wix/design-system';
|
|
|
3440
3607
|
|
|
3441
3608
|
/* The `IColumnValue<T>` interface provides type safety for column override functions: */
|
|
3442
3609
|
interface IColumnValue<T> {
|
|
3443
|
-
value: T;
|
|
3444
|
-
row: Record<string, any>;
|
|
3610
|
+
value: T; // The individual column value (strongly typed)
|
|
3611
|
+
row: Record<string, any>; // The entire row object with all field values
|
|
3445
3612
|
}
|
|
3446
3613
|
|
|
3447
3614
|
// For TEXT fields
|
|
@@ -3452,9 +3619,7 @@ export function petName({ value, row }: IColumnValue<string>) {
|
|
|
3452
3619
|
// For NUMBER fields
|
|
3453
3620
|
export function age({ value, row }: IColumnValue<number>) {
|
|
3454
3621
|
return (
|
|
3455
|
-
<Badge skin={value > 5 ? 'warning' : 'success'}>
|
|
3456
|
-
{value} years old
|
|
3457
|
-
</Badge>
|
|
3622
|
+
<Badge skin={value > 5 ? 'warning' : 'success'}>{value} years old</Badge>
|
|
3458
3623
|
);
|
|
3459
3624
|
}
|
|
3460
3625
|
|
|
@@ -3489,23 +3654,29 @@ export function hobbies({ value, row }: IColumnValue<string[]>) {
|
|
|
3489
3654
|
**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.
|
|
3490
3655
|
|
|
3491
3656
|
For example, if your collection schema has these fields:
|
|
3657
|
+
|
|
3492
3658
|
```json
|
|
3493
3659
|
{
|
|
3494
3660
|
"fields": [
|
|
3495
3661
|
{ "key": "name", "displayName": "Pet Name", "type": "TEXT" },
|
|
3496
3662
|
{ "key": "age", "displayName": "Age", "type": "NUMBER" },
|
|
3497
3663
|
{ "key": "isVaccinated", "displayName": "Vaccinated", "type": "BOOLEAN" },
|
|
3498
|
-
{
|
|
3664
|
+
{
|
|
3665
|
+
"key": "lastActivity",
|
|
3666
|
+
"displayName": "Last Activity",
|
|
3667
|
+
"type": "DATETIME"
|
|
3668
|
+
}
|
|
3499
3669
|
]
|
|
3500
3670
|
}
|
|
3501
3671
|
```
|
|
3502
3672
|
|
|
3503
3673
|
Then in your column override, you access these values using the field IDs:
|
|
3674
|
+
|
|
3504
3675
|
```typescript
|
|
3505
3676
|
export function myColumn({ value, row }) {
|
|
3506
3677
|
// Access field values using their schema field IDs
|
|
3507
|
-
const petName = row.name;
|
|
3508
|
-
const petAge = row.age;
|
|
3678
|
+
const petName = row.name; // "name" field ID
|
|
3679
|
+
const petAge = row.age; // "age" field ID
|
|
3509
3680
|
const isVaccinated = row.isVaccinated; // "isVaccinated" field ID
|
|
3510
3681
|
const lastActivity = row.lastActivity; // "lastActivity" field ID
|
|
3511
3682
|
|
|
@@ -3555,7 +3726,9 @@ export function petInfo({ value, row }: IColumnValue<string>) {
|
|
|
3555
3726
|
{row.age} years old • {row.type}
|
|
3556
3727
|
</Text>
|
|
3557
3728
|
{row.isVaccinated && (
|
|
3558
|
-
<Text size="tiny" skin="success"
|
|
3729
|
+
<Text size="tiny" skin="success">
|
|
3730
|
+
✓ Vaccinated
|
|
3731
|
+
</Text>
|
|
3559
3732
|
)}
|
|
3560
3733
|
</Box>
|
|
3561
3734
|
);
|
|
@@ -3601,7 +3774,9 @@ import { IColumnValue } from '@wix/auto-patterns/types';
|
|
|
3601
3774
|
|
|
3602
3775
|
export function date({ value, row }: IColumnValue<string>) {
|
|
3603
3776
|
// Access to other row data for enhanced date formatting
|
|
3604
|
-
const isRecent =
|
|
3777
|
+
const isRecent =
|
|
3778
|
+
row.lastActivity &&
|
|
3779
|
+
new Date(row.lastActivity) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
|
|
3605
3780
|
|
|
3606
3781
|
return (
|
|
3607
3782
|
<span style={{ color: isRecent ? 'green' : 'inherit' }}>
|
|
@@ -3628,7 +3803,7 @@ export const useColumns = () => {
|
|
|
3628
3803
|
petInfo,
|
|
3629
3804
|
status,
|
|
3630
3805
|
fullName,
|
|
3631
|
-
date
|
|
3806
|
+
date,
|
|
3632
3807
|
};
|
|
3633
3808
|
};
|
|
3634
3809
|
```
|
|
@@ -3706,6 +3881,7 @@ These components can display custom UI elements like notifications, information
|
|
|
3706
3881
|
### 2. Field Rendering Overrides
|
|
3707
3882
|
|
|
3708
3883
|
You can use custom components to override the default rendering of one or more fields. This allows you to:
|
|
3884
|
+
|
|
3709
3885
|
- Apply custom validation logic
|
|
3710
3886
|
- Create custom input components
|
|
3711
3887
|
- Combine multiple fields into a single UI component
|
|
@@ -3720,6 +3896,7 @@ import { useController } from '@wix/auto-patterns/form'; // Always import from t
|
|
|
3720
3896
|
```
|
|
3721
3897
|
|
|
3722
3898
|
The hook requires:
|
|
3899
|
+
|
|
3723
3900
|
- **name**: The field name you want to edit (should match the schema field ID)
|
|
3724
3901
|
- **control**: Retrieved from `form.control`
|
|
3725
3902
|
- **defaultValue**: Set from `entity?.[fieldId]` when it exists
|
|
@@ -3763,7 +3940,6 @@ export const customNameField: FC<CustomComponentProps> = ({ form, entity }) => {
|
|
|
3763
3940
|
};
|
|
3764
3941
|
```
|
|
3765
3942
|
|
|
3766
|
-
|
|
3767
3943
|
### Example: Standalone Component (Not Field-Specific)
|
|
3768
3944
|
|
|
3769
3945
|
Custom components can also be used to add UI elements not tied to specific fields:
|
|
@@ -3780,8 +3956,8 @@ export const infoCard: FC<CustomComponentProps> = ({ entity }) => {
|
|
|
3780
3956
|
<Box direction="vertical" gap={2}>
|
|
3781
3957
|
<Text weight="bold">Important Information</Text>
|
|
3782
3958
|
<Text>
|
|
3783
|
-
This custom component can display additional information or
|
|
3784
|
-
that isn't directly tied to a specific field.
|
|
3959
|
+
This custom component can display additional information or
|
|
3960
|
+
functionality that isn't directly tied to a specific field.
|
|
3785
3961
|
</Text>
|
|
3786
3962
|
{entity?.isVaccinated ? (
|
|
3787
3963
|
<Text skin="success">This pet is vaccinated</Text>
|
|
@@ -3807,7 +3983,7 @@ export const useComponents = () => {
|
|
|
3807
3983
|
// You can access React context and other hooks here
|
|
3808
3984
|
return {
|
|
3809
3985
|
customNameField,
|
|
3810
|
-
infoCard
|
|
3986
|
+
infoCard,
|
|
3811
3987
|
};
|
|
3812
3988
|
};
|
|
3813
3989
|
```
|
|
@@ -3872,9 +4048,7 @@ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
|
|
|
3872
4048
|
onChange={(e) => form.setValue('name', e.target.value)}
|
|
3873
4049
|
/>
|
|
3874
4050
|
|
|
3875
|
-
{showSpecialMessage &&
|
|
3876
|
-
<Text>Special message for special name!</Text>
|
|
3877
|
-
)}
|
|
4051
|
+
{showSpecialMessage && <Text>Special message for special name!</Text>}
|
|
3878
4052
|
</Box>
|
|
3879
4053
|
);
|
|
3880
4054
|
};
|
|
@@ -3894,18 +4068,16 @@ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
|
|
|
3894
4068
|
onChange={(e) => form.setValue('name', e.target.value)}
|
|
3895
4069
|
/>
|
|
3896
4070
|
|
|
3897
|
-
{showSpecialMessage &&
|
|
3898
|
-
<Text>Special message for special name!</Text>
|
|
3899
|
-
)}
|
|
4071
|
+
{showSpecialMessage && <Text>Special message for special name!</Text>}
|
|
3900
4072
|
</Box>
|
|
3901
4073
|
);
|
|
3902
4074
|
};
|
|
3903
4075
|
```
|
|
3904
4076
|
|
|
3905
|
-
|
|
3906
4077
|
##### When to Use the Entity Object
|
|
3907
4078
|
|
|
3908
4079
|
The `entity` object is useful for:
|
|
4080
|
+
|
|
3909
4081
|
- Setting initial values
|
|
3910
4082
|
- Accessing read-only data that doesn't change
|
|
3911
4083
|
- Comparing form state with original values (e.g., detecting if changes were made)
|
|
@@ -3918,7 +4090,7 @@ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
|
|
|
3918
4090
|
const controller = useController({
|
|
3919
4091
|
name: 'name', // Field ID from the schema
|
|
3920
4092
|
control: form.control,
|
|
3921
|
-
defaultValue: entity?.name // Initialize from entity
|
|
4093
|
+
defaultValue: entity?.name, // Initialize from entity
|
|
3922
4094
|
});
|
|
3923
4095
|
|
|
3924
4096
|
// Use watch for reactive updates
|
|
@@ -3933,9 +4105,7 @@ const CustomComponent: FC<CustomComponentProps> = ({ form, entity }) => {
|
|
|
3933
4105
|
onChange={(e) => controller.field.onChange(e.target.value)}
|
|
3934
4106
|
/>
|
|
3935
4107
|
</FormField>
|
|
3936
|
-
{hasChanges &&
|
|
3937
|
-
<Text size="small">Original value: {entity?.name}</Text>
|
|
3938
|
-
)}
|
|
4108
|
+
{hasChanges && <Text size="small">Original value: {entity?.name}</Text>}
|
|
3939
4109
|
</Box>
|
|
3940
4110
|
);
|
|
3941
4111
|
};
|
|
@@ -3980,6 +4150,7 @@ When implementing a custom data source, you need to modify the `collection` conf
|
|
|
3980
4150
|
}
|
|
3981
4151
|
}
|
|
3982
4152
|
```
|
|
4153
|
+
|
|
3983
4154
|
## Sections
|
|
3984
4155
|
|
|
3985
4156
|
Sections allow you to group table rows under section headers, making it easier to organize and navigate through large datasets. This feature is especially useful when you want to categorize entities by specific criteria.
|
|
@@ -4017,6 +4188,7 @@ To enable sections, add the `sections` configuration to your table configuration
|
|
|
4017
4188
|
```
|
|
4018
4189
|
|
|
4019
4190
|
**Key Properties:**
|
|
4191
|
+
|
|
4020
4192
|
- `entityTypeSource`: Must be set to `"custom"` instead of `"cms"`
|
|
4021
4193
|
- `custom.id`: A unique identifier for your custom data source implementation
|
|
4022
4194
|
|
|
@@ -4043,6 +4215,7 @@ export default function YourPage() {
|
|
|
4043
4215
|
#### Custom Data Source Function
|
|
4044
4216
|
|
|
4045
4217
|
You must implement a custom data source function that:
|
|
4218
|
+
|
|
4046
4219
|
- Takes `collectionId` and `context` parameters
|
|
4047
4220
|
- Returns a Promise that resolves to a `SchemaConfig` object
|
|
4048
4221
|
- The `SchemaConfig` object must include:
|
|
@@ -4058,8 +4231,12 @@ You must implement a custom data source function that:
|
|
|
4058
4231
|
### Example Implementation Structure
|
|
4059
4232
|
|
|
4060
4233
|
```tsx
|
|
4234
|
+
import { SchemaConfig } from '@wix/auto-patterns/types';
|
|
4061
4235
|
// customDataSources/myCustomDataSource.ts
|
|
4062
|
-
export const myCustomDataSource = async (
|
|
4236
|
+
export const myCustomDataSource = async (
|
|
4237
|
+
collectionId: string,
|
|
4238
|
+
context: any,
|
|
4239
|
+
): Promise<SchemaConfig> => {
|
|
4063
4240
|
return {
|
|
4064
4241
|
id: 'myCustomCollection',
|
|
4065
4242
|
fields: {
|
|
@@ -4068,17 +4245,31 @@ export const myCustomDataSource = async (collectionId: string, context: any) =>
|
|
|
4068
4245
|
displayField: 'name',
|
|
4069
4246
|
idField: '_id',
|
|
4070
4247
|
actions: {
|
|
4071
|
-
get: async (entityId: string) => {
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4248
|
+
get: async (entityId: string) => {
|
|
4249
|
+
/* Implementation */
|
|
4250
|
+
},
|
|
4251
|
+
create: async (newEntity: any) => {
|
|
4252
|
+
/* Implementation */
|
|
4253
|
+
},
|
|
4254
|
+
update: async (updatedEntity: any) => {
|
|
4255
|
+
/* Implementation */
|
|
4256
|
+
},
|
|
4257
|
+
delete: async (entityId: string) => {
|
|
4258
|
+
/* Implementation */
|
|
4259
|
+
},
|
|
4260
|
+
bulkDelete: async (entityIds: string[]) => {
|
|
4261
|
+
/* Implementation */
|
|
4262
|
+
},
|
|
4263
|
+
find: async (query: Query, options?: any) => {
|
|
4264
|
+
/* Implementation */
|
|
4265
|
+
},
|
|
4266
|
+
},
|
|
4078
4267
|
};
|
|
4079
4268
|
};
|
|
4080
4269
|
```
|
|
4081
4270
|
|
|
4271
|
+
> This is a simplified example of a custom data source implementation, do not use it as-is. You must implement the actual logic to connect to the FQDN schema.
|
|
4272
|
+
|
|
4082
4273
|
### Hook Implementation
|
|
4083
4274
|
|
|
4084
4275
|
In `components/customDataSources/index.tsx`:
|
|
@@ -4089,7 +4280,7 @@ import { myCustomDataSource } from './myCustomDataSource';
|
|
|
4089
4280
|
export const useCustomDataSources = () => {
|
|
4090
4281
|
// You can access React context and other hooks here
|
|
4091
4282
|
return {
|
|
4092
|
-
myCustomDataSource
|
|
4283
|
+
myCustomDataSource,
|
|
4093
4284
|
};
|
|
4094
4285
|
};
|
|
4095
4286
|
```
|
|
@@ -4107,8 +4298,6 @@ When implementing custom data sources, you need to map your data source field ty
|
|
|
4107
4298
|
- **Reference fields** → `'REFERENCE'`
|
|
4108
4299
|
- **URL fields** → `'URL'`
|
|
4109
4300
|
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
4301
|
### Validation Requirements
|
|
4113
4302
|
|
|
4114
4303
|
- **Function Signature**: Custom data source must be a function with signature `(collectionId: string, context: any) => Promise<SchemaConfig>`
|
|
@@ -4165,7 +4354,7 @@ Section renderers are functions that determine how to group items and what infor
|
|
|
4165
4354
|
#### Function Signature
|
|
4166
4355
|
|
|
4167
4356
|
```tsx
|
|
4168
|
-
function sectionRenderer(item: any): Section
|
|
4357
|
+
function sectionRenderer(item: any): Section;
|
|
4169
4358
|
```
|
|
4170
4359
|
|
|
4171
4360
|
Where `Section` is the interface from @wix/patterns (re-exported from auto-patterns):
|
|
@@ -4188,6 +4377,7 @@ interface Section {
|
|
|
4188
4377
|
```
|
|
4189
4378
|
|
|
4190
4379
|
The section renderer receives an item and returns:
|
|
4380
|
+
|
|
4191
4381
|
- **id**: A unique identifier for the section (items with the same id are grouped together)
|
|
4192
4382
|
- **title**: The text displayed in the section header
|
|
4193
4383
|
- **primaryAction** (optional): An action button displayed in the section header
|
|
@@ -4251,7 +4441,9 @@ export function groupByAgeAndVaccination(item: any): Section {
|
|
|
4251
4441
|
badgeSkin = 'neutralLight';
|
|
4252
4442
|
} else if (age >= 1 && age <= 5) {
|
|
4253
4443
|
sectionId = isVaccinated ? 'young-vaccinated' : 'young-unvaccinated';
|
|
4254
|
-
sectionTitle = `Young Adults (1-5 years) - ${
|
|
4444
|
+
sectionTitle = `Young Adults (1-5 years) - ${
|
|
4445
|
+
isVaccinated ? 'Vaccinated' : 'Not Vaccinated'
|
|
4446
|
+
}`;
|
|
4255
4447
|
badgeSkin = isVaccinated ? 'light' : 'danger';
|
|
4256
4448
|
} else {
|
|
4257
4449
|
sectionId = 'seniors';
|
|
@@ -4262,13 +4454,16 @@ export function groupByAgeAndVaccination(item: any): Section {
|
|
|
4262
4454
|
return {
|
|
4263
4455
|
id: sectionId,
|
|
4264
4456
|
title: sectionTitle,
|
|
4265
|
-
primaryAction:
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4457
|
+
primaryAction:
|
|
4458
|
+
age < 1
|
|
4459
|
+
? {
|
|
4460
|
+
id: 'special-care',
|
|
4461
|
+
label: 'Special Care Info',
|
|
4462
|
+
onClick: () => {
|
|
4463
|
+
// Show special care information for puppies
|
|
4464
|
+
},
|
|
4465
|
+
}
|
|
4466
|
+
: undefined,
|
|
4272
4467
|
badge: {
|
|
4273
4468
|
visible: true,
|
|
4274
4469
|
skin: badgeSkin,
|
|
@@ -4288,7 +4483,7 @@ import * as actions from './components/actions';
|
|
|
4288
4483
|
|
|
4289
4484
|
<AutoPatternsOverridesProvider value={{ sections, columns, actions }}>
|
|
4290
4485
|
<AutoPatternsApp configuration={config} />
|
|
4291
|
-
</AutoPatternsOverridesProvider
|
|
4486
|
+
</AutoPatternsOverridesProvider>;
|
|
4292
4487
|
```
|
|
4293
4488
|
|
|
4294
4489
|
### Important Notes
|
|
@@ -4298,7 +4493,6 @@ import * as actions from './components/actions';
|
|
|
4298
4493
|
- **Performance**: Section renderers are called for every item, so keep the logic lightweight.
|
|
4299
4494
|
- **TableGridSwitch**: Sections work in both table and grid views when using TableGridSwitch.
|
|
4300
4495
|
|
|
4301
|
-
|
|
4302
4496
|
By implementing sections, you can significantly improve the user experience when dealing with large datasets by providing logical groupings that make information easier to find and understand.
|
|
4303
4497
|
|
|
4304
4498
|
## Slots
|
|
@@ -4306,6 +4500,7 @@ By implementing sections, you can significantly improve the user experience when
|
|
|
4306
4500
|
Slots allow you to inject custom React components into collection pages at specific points in the component hierarchy. Unlike other overrides that modify existing functionality, slots enable you to add entirely custom UI elements anywhere within the collection page components array.
|
|
4307
4501
|
|
|
4308
4502
|
Slots are useful for:
|
|
4503
|
+
|
|
4309
4504
|
- Adding custom banners or announcements above or below the table/grid
|
|
4310
4505
|
- Inserting analytics widgets or dashboards
|
|
4311
4506
|
- Adding custom promotional content
|
|
@@ -4323,6 +4518,7 @@ Slots are configured in the collection page configuration using the `CustomCompo
|
|
|
4323
4518
|
```
|
|
4324
4519
|
|
|
4325
4520
|
**Key Properties:**
|
|
4521
|
+
|
|
4326
4522
|
- `type`: Must be set to `"custom"` to identify this as a slot component
|
|
4327
4523
|
- `id`: A unique identifier that maps to your slot component implementation
|
|
4328
4524
|
|
|
@@ -4356,6 +4552,7 @@ Slot components can be positioned anywhere within the `components` array of a co
|
|
|
4356
4552
|
```
|
|
4357
4553
|
|
|
4358
4554
|
This configuration will render:
|
|
4555
|
+
|
|
4359
4556
|
1. The custom `topBanner` component at the top
|
|
4360
4557
|
2. The main collection component (table/grid) in the middle
|
|
4361
4558
|
3. The custom `bottomStats` component at the bottom
|
|
@@ -4375,7 +4572,9 @@ export const TopBannerComponent: React.FC = () => {
|
|
|
4375
4572
|
<Card>
|
|
4376
4573
|
<Card.Content>
|
|
4377
4574
|
<Box direction="vertical" gap={2}>
|
|
4378
|
-
<Text size="large" weight="bold">
|
|
4575
|
+
<Text size="large" weight="bold">
|
|
4576
|
+
Welcome to Pet Management
|
|
4577
|
+
</Text>
|
|
4379
4578
|
<Text>Manage all your pets from this central dashboard.</Text>
|
|
4380
4579
|
<Button size="small">Get Started</Button>
|
|
4381
4580
|
</Box>
|
|
@@ -4390,11 +4589,15 @@ export const BottomStatsComponent: React.FC = () => {
|
|
|
4390
4589
|
<Card.Content>
|
|
4391
4590
|
<Box direction="horizontal" gap={4}>
|
|
4392
4591
|
<Box direction="vertical" gap={1}>
|
|
4393
|
-
<Text size="large" weight="bold">
|
|
4592
|
+
<Text size="large" weight="bold">
|
|
4593
|
+
47
|
|
4594
|
+
</Text>
|
|
4394
4595
|
<Text size="small">Total Pets</Text>
|
|
4395
4596
|
</Box>
|
|
4396
4597
|
<Box direction="vertical" gap={1}>
|
|
4397
|
-
<Text size="large" weight="bold">
|
|
4598
|
+
<Text size="large" weight="bold">
|
|
4599
|
+
12
|
|
4600
|
+
</Text>
|
|
4398
4601
|
<Text size="small">Available for Adoption</Text>
|
|
4399
4602
|
</Box>
|
|
4400
4603
|
</Box>
|
|
@@ -4416,7 +4619,7 @@ export const useSlots = () => {
|
|
|
4416
4619
|
// You can access React context and other hooks here
|
|
4417
4620
|
return {
|
|
4418
4621
|
topBanner: TopBannerComponent,
|
|
4419
|
-
bottomStats: BottomStatsComponent
|
|
4622
|
+
bottomStats: BottomStatsComponent,
|
|
4420
4623
|
};
|
|
4421
4624
|
};
|
|
4422
4625
|
```
|
|
@@ -4448,7 +4651,6 @@ export default function YourPage() {
|
|
|
4448
4651
|
3. **Performance**: Slot components re-render with the page, so optimize for performance if needed
|
|
4449
4652
|
4. **Styling**: Follow the design system patterns and responsive design principles
|
|
4450
4653
|
|
|
4451
|
-
|
|
4452
4654
|
**Important:** Every time you create a new slot component, you must import it and add it to the `useSlots` hook return object in the `./components/slots/index.tsx` file. The key must match the `id` specified in your JSON configuration.
|
|
4453
4655
|
|
|
4454
4656
|
Slots provide a powerful way to enhance collection pages with custom functionality while maintaining the structure and features of the AutoPatterns system.
|