@wix/auto-patterns 1.21.0 → 1.23.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/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +109 -0
- package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -0
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +5 -14
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +19 -68
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/cjs/hooks/useActionCell.js +10 -2
- package/dist/cjs/hooks/useActionCell.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/CollectionPageConfig.js.map +1 -1
- package/dist/cjs/types/actions/actionCell.js.map +1 -1
- package/dist/cjs/types/actions/base.js.map +1 -1
- package/dist/docs/action_cell.md +13 -3
- package/dist/docs/app_config_structure.md +7 -4
- package/dist/docs/auto-patterns-guide.md +288 -35
- package/dist/docs/bulk_actions.md +1 -4
- package/dist/docs/custom_overrides.md +267 -24
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +71 -0
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -0
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +1 -3
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +16 -48
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +8 -13
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js +6 -10
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js +16 -23
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js +2 -3
- package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js +6 -9
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js +6 -8
- package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js +8 -10
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js +10 -12
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js +6 -8
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js +4 -7
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -1
- package/dist/esm/components/ModalRenderer.js +1 -2
- package/dist/esm/components/ModalRenderer.js.map +1 -1
- package/dist/esm/components/modals/actions/BulkDeleteModal.js +7 -12
- package/dist/esm/components/modals/actions/BulkDeleteModal.js.map +1 -1
- package/dist/esm/components/modals/actions/CreateModal.js +6 -11
- package/dist/esm/components/modals/actions/CreateModal.js.map +1 -1
- package/dist/esm/components/modals/actions/EditModal.js +6 -11
- package/dist/esm/components/modals/actions/EditModal.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +3 -4
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js +1 -2
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/sortUtils.js +2 -2
- package/dist/esm/dataSourceAdapters/cms/sortUtils.js.map +1 -1
- package/dist/esm/hooks/useActionCell.js +16 -12
- package/dist/esm/hooks/useActionCell.js.map +1 -1
- package/dist/esm/hooks/useBaseTableFeatures.js +1 -2
- package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useBulkActionToolbar.js +2 -2
- package/dist/esm/hooks/useBulkActionToolbar.js.map +1 -1
- package/dist/esm/hooks/useCollectionPageActions.js +3 -3
- package/dist/esm/hooks/useCollectionPageActions.js.map +1 -1
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js +1 -1
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js.map +1 -1
- package/dist/esm/hooks/useColumns.js +7 -12
- package/dist/esm/hooks/useColumns.js.map +1 -1
- package/dist/esm/hooks/useCommonCollectionFeatures.js +7 -8
- package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
- package/dist/esm/hooks/useEmptyStates.js +5 -6
- package/dist/esm/hooks/useEmptyStates.js.map +1 -1
- package/dist/esm/hooks/useFilters.js +7 -7
- package/dist/esm/hooks/useFilters.js.map +1 -1
- package/dist/esm/hooks/useNavigationUtils.js +2 -3
- package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
- package/dist/esm/hooks/usePagePath.js +3 -4
- package/dist/esm/hooks/usePagePath.js.map +1 -1
- package/dist/esm/hooks/useTableFeatures.js +1 -2
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/esm/providers/SchemaContext.js +2 -3
- package/dist/esm/providers/SchemaContext.js.map +1 -1
- package/dist/esm/providers/SchemaRegistryContext.js +1 -1
- package/dist/esm/providers/SchemaRegistryContext.js.map +1 -1
- package/dist/esm/types/CollectionPageConfig.js.map +1 -1
- package/dist/esm/types/actions/actionCell.js.map +1 -1
- package/dist/esm/types/actions/base.js.map +1 -1
- package/dist/esm/utils/actions/customAction.js +1 -2
- package/dist/esm/utils/actions/customAction.js.map +1 -1
- package/dist/esm/utils/actions/deleteAction.js +5 -10
- package/dist/esm/utils/actions/deleteAction.js.map +1 -1
- package/dist/esm/utils/filterCreators.js +11 -11
- package/dist/esm/utils/filterCreators.js.map +1 -1
- package/dist/types/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.d.ts +7 -0
- package/dist/types/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.d.ts.map +1 -1
- package/dist/types/hooks/useActionCell.d.ts.map +1 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts +3 -6
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
- package/dist/types/types/CollectionPageConfig.d.ts +7 -1
- package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
- package/dist/types/types/actions/actionCell.d.ts +1 -0
- package/dist/types/types/actions/actionCell.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/package.json +11 -11
|
@@ -124,9 +124,6 @@ export interface AppConfig {
|
|
|
124
124
|
collection: {
|
|
125
125
|
collectionId: string; // ID of the Wix Data collection
|
|
126
126
|
entityTypeSource: 'cms' | 'custom'; // Data source type.
|
|
127
|
-
custom?: {
|
|
128
|
-
id: string;
|
|
129
|
-
};
|
|
130
127
|
};
|
|
131
128
|
create?: { // Required when type is 'create'
|
|
132
129
|
mode: 'page'; // Create mode
|
|
@@ -147,8 +144,9 @@ export interface AppConfig {
|
|
|
147
144
|
menu?: {}; // Same structure as primaryActions.menu
|
|
148
145
|
};
|
|
149
146
|
};
|
|
150
|
-
components: [
|
|
147
|
+
components: [ // Array of component configurations that can be collection components or custom slot components
|
|
151
148
|
{
|
|
149
|
+
type: 'collection'; // Component type for collection rendering (table/grid with full features)
|
|
152
150
|
entityPageId?: string; // ID of the entity page to navigate to when clicking a row
|
|
153
151
|
collection: {
|
|
154
152
|
collectionId: string; // ID of the Wix Data collection
|
|
@@ -249,6 +247,7 @@ export interface AppConfig {
|
|
|
249
247
|
};
|
|
250
248
|
};
|
|
251
249
|
};
|
|
250
|
+
alwaysVisible?: boolean; // Whether to always show the primary action (not just on hover)
|
|
252
251
|
};
|
|
253
252
|
secondaryActions?: {
|
|
254
253
|
items: {}[]; // Array of action configurations, same structure as primaryAction.item, can include dividers
|
|
@@ -366,6 +365,10 @@ export interface AppConfig {
|
|
|
366
365
|
};
|
|
367
366
|
}
|
|
368
367
|
]; // End of layout array
|
|
368
|
+
} |
|
|
369
|
+
{
|
|
370
|
+
type: 'custom'; // Component type for custom slot components
|
|
371
|
+
id: string; // Unique identifier that maps to a custom React component provided through PatternsWizardOverridesProvider slots
|
|
369
372
|
}
|
|
370
373
|
]; // End of components array
|
|
371
374
|
};
|
|
@@ -1356,6 +1359,10 @@ The ActionCell has a two-level structure:
|
|
|
1356
1359
|
|
|
1357
1360
|
Both properties are optional, but at least one should be provided for the ActionCell to be useful.
|
|
1358
1361
|
|
|
1362
|
+
### Primary Action Visibility Control
|
|
1363
|
+
|
|
1364
|
+
**New Feature**: Primary actions now support visibility control through the `alwaysVisible` property. By default, primary actions follow standard table interaction patterns (typically visible on hover), but you can configure them to be always visible for improved accessibility and user discovery.
|
|
1365
|
+
|
|
1359
1366
|
### Inline Secondary Actions
|
|
1360
1367
|
|
|
1361
1368
|
**New Feature**: By default, all secondary actions are hidden in a popover menu that appears when the user hovers over or clicks the "more actions" button. However, you can now configure some secondary actions to display inline directly in the table row for improved accessibility and reduced clicks.
|
|
@@ -1560,17 +1567,21 @@ Follow this decision process when implementing ActionCell:
|
|
|
1560
1567
|
- Most common operation (typically Edit) → Place in `primaryAction.item`
|
|
1561
1568
|
- Less common operations → Place in `secondaryActions.items` array
|
|
1562
1569
|
|
|
1563
|
-
3. **
|
|
1570
|
+
3. **Primary Action Visibility Strategy**:
|
|
1571
|
+
- **Standard Visibility** (`alwaysVisible: false` or omitted): Use for most cases where actions appear on interaction
|
|
1572
|
+
- **Always Visible** (`alwaysVisible: true`): Use for critical actions that need constant visibility or when user discovery is important
|
|
1573
|
+
|
|
1574
|
+
4. **Inline Secondary Actions Strategy**:
|
|
1564
1575
|
- **Action Prioritization**: Order `secondaryActions.items` by frequency of use (most used first)
|
|
1565
1576
|
- **Inline Count**: Use `inlineCount: 1-3` for optimal UX (avoid cluttering)
|
|
1566
1577
|
- **Visibility Control**:
|
|
1567
1578
|
- Use `inlineAlwaysVisible: false` (default) for cleaner visual appearance
|
|
1568
1579
|
- Use `inlineAlwaysVisible: true` only for critical actions requiring constant visibility
|
|
1569
1580
|
|
|
1570
|
-
|
|
1581
|
+
5. **Update Action Mode**:
|
|
1571
1582
|
- Complex, full-entity edits → Use `mode: "page"` to navigate to entity page
|
|
1572
1583
|
|
|
1573
|
-
|
|
1584
|
+
6. **Custom Implementation**:
|
|
1574
1585
|
- For `custom` actions, you must provide implementations in your code and register them with `PatternsWizardOverridesProvider`
|
|
1575
1586
|
|
|
1576
1587
|
### ActionCell Validation Checklist
|
|
@@ -1584,6 +1595,8 @@ AI agents should verify these requirements before generating ActionCell configur
|
|
|
1584
1595
|
✓ Delete action has a modal configuration
|
|
1585
1596
|
✓ Custom actions match implementations in overrides
|
|
1586
1597
|
✓ At least one of `primaryAction` or `secondaryActions` is provided
|
|
1598
|
+
✓ `alwaysVisible` property on primary actions (if specified) is a boolean value
|
|
1599
|
+
✓ Primary action visibility is properly considered for UX (use `alwaysVisible: true` for critical actions)
|
|
1587
1600
|
✓ `inlineCount` (if specified) is a non-negative number ≤ total secondary actions count
|
|
1588
1601
|
✓ `inlineAlwaysVisible` (if specified) is a boolean value
|
|
1589
1602
|
✓ Inline secondary actions configuration is applied only when secondary actions exist
|
|
@@ -1789,10 +1802,7 @@ The bulk action toolbar uses a specific structure for organizing actions:
|
|
|
1789
1802
|
"item": {
|
|
1790
1803
|
"id": "bulkCustom",
|
|
1791
1804
|
"type": "custom",
|
|
1792
|
-
"label": "Custom Bulk"
|
|
1793
|
-
"custom": {
|
|
1794
|
-
"id": "MyCustomBulk"
|
|
1795
|
-
}
|
|
1805
|
+
"label": "Custom Bulk"
|
|
1796
1806
|
}
|
|
1797
1807
|
}
|
|
1798
1808
|
},
|
|
@@ -2163,6 +2173,10 @@ your-page/
|
|
|
2163
2173
|
│ ├── index.tsx // Exports useColumns hook
|
|
2164
2174
|
│ ├── name.ts
|
|
2165
2175
|
│ └── date.ts
|
|
2176
|
+
├── slots/ // Custom slot components for collection pages
|
|
2177
|
+
│ ├── index.tsx // Exports useSlots hook
|
|
2178
|
+
│ ├── TopBannerComponent.tsx
|
|
2179
|
+
│ └── BottomStatsComponent.tsx
|
|
2166
2180
|
├── customComponents/ // Custom entity page components
|
|
2167
2181
|
│ ├── index.tsx // Exports useComponents hook
|
|
2168
2182
|
│ ├── CustomNameField.tsx
|
|
@@ -2170,16 +2184,12 @@ your-page/
|
|
|
2170
2184
|
├── modals/ // Custom modals
|
|
2171
2185
|
│ ├── index.tsx // Exports useModals hook
|
|
2172
2186
|
│ └── myCustomModal.tsx
|
|
2173
|
-
|
|
2187
|
+
├── customDataSources/ // Custom data sources
|
|
2174
2188
|
│ ├── index.tsx // Exports useCustomDataSources hook
|
|
2175
2189
|
│ └── myCustomDataSource.ts
|
|
2176
|
-
|
|
2177
|
-
│ ├── index.tsx
|
|
2178
|
-
│ └── groupByType.ts
|
|
2179
|
-
└── customComponents/ // Custom entity page components
|
|
2190
|
+
└── sections/ // Section renderers
|
|
2180
2191
|
├── index.tsx
|
|
2181
|
-
|
|
2182
|
-
└── InfoCard.tsx
|
|
2192
|
+
└── groupByType.ts
|
|
2183
2193
|
```
|
|
2184
2194
|
|
|
2185
2195
|
### Using Override Hooks in Your Page
|
|
@@ -2189,6 +2199,7 @@ In your page component, use the hook-based approach to access React context and
|
|
|
2189
2199
|
```tsx
|
|
2190
2200
|
import { useActions } from '../components/actions';
|
|
2191
2201
|
import { useColumns } from '../components/columns';
|
|
2202
|
+
import { useSlots } from '../components/slots';
|
|
2192
2203
|
import { useSections } from '../components/sections';
|
|
2193
2204
|
import { useComponents } from '../components/customComponents';
|
|
2194
2205
|
import { useModals } from '../components/modals';
|
|
@@ -2197,13 +2208,14 @@ import { useCustomDataSources } from '../components/customDataSources';
|
|
|
2197
2208
|
export default function YourPage() {
|
|
2198
2209
|
const actions = useActions();
|
|
2199
2210
|
const columns = useColumns();
|
|
2211
|
+
const slots = useSlots();
|
|
2200
2212
|
const sections = useSections();
|
|
2201
2213
|
const components = useComponents();
|
|
2202
2214
|
const modals = useModals();
|
|
2203
2215
|
const customDataSources = useCustomDataSources();
|
|
2204
2216
|
|
|
2205
2217
|
return (
|
|
2206
|
-
<PatternsWizardOverridesProvider value={{ actions, columns, sections, components, modals, customDataSources }}>
|
|
2218
|
+
<PatternsWizardOverridesProvider value={{ actions, columns, slots, sections, components, modals, customDataSources }}>
|
|
2207
2219
|
<AutoPatternsApp configuration={config} />
|
|
2208
2220
|
</PatternsWizardOverridesProvider>
|
|
2209
2221
|
);
|
|
@@ -2212,12 +2224,13 @@ export default function YourPage() {
|
|
|
2212
2224
|
|
|
2213
2225
|
### Important: Updating Hook Index Files
|
|
2214
2226
|
|
|
2215
|
-
**When adding any new implementation (action, modal, column, section or component), you MUST update the corresponding hook in the `index.tsx` file to include your new implementation.** The main page component uses these hooks, so they serve as the central export point for each type of override.
|
|
2227
|
+
**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.
|
|
2216
2228
|
|
|
2217
2229
|
For example:
|
|
2218
2230
|
- Adding a new action → Update `../components/actions/index.tsx` to include the new action in the `useActions` hook
|
|
2219
2231
|
- Adding a new modal → Update `../components/modals/index.tsx` to include the new modal in the `useModals` hook
|
|
2220
2232
|
- Adding a new column override → Update `../components/columns/index.tsx` to include the new column in the `useColumns` hook
|
|
2233
|
+
- Adding a new slot component → Update `../components/slots/index.tsx` to include the new slot in the `useSlots` hook
|
|
2221
2234
|
- Adding a new section renderer → Update `../components/sections/index.tsx` to include the new section in the `useSections` hook
|
|
2222
2235
|
- Adding a new custom component → Update `../components/customComponents/index.tsx` to include the new component in the `useComponents` hook
|
|
2223
2236
|
- Adding a new custom data source → Update `../components/customDataSources/index.tsx` to include the new data source in the `useCustomDataSources` hook
|
|
@@ -2240,14 +2253,73 @@ Each column in the table has a default rendering based on its field type. You ca
|
|
|
2240
2253
|
|
|
2241
2254
|
### Function Signature
|
|
2242
2255
|
|
|
2256
|
+
For proper TypeScript support, use the `IColumnValue<T>` interface:
|
|
2257
|
+
|
|
2243
2258
|
```typescript
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2259
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2260
|
+
|
|
2261
|
+
function columnOverride(props: IColumnValue<string>) {
|
|
2262
|
+
// props.value: The individual column value (typed)
|
|
2263
|
+
// props.row: The entire row object containing all field values
|
|
2247
2264
|
return <YourCustomRendering />;
|
|
2248
2265
|
}
|
|
2249
2266
|
```
|
|
2250
2267
|
|
|
2268
|
+
### Type-Specific Examples
|
|
2269
|
+
|
|
2270
|
+
The generic type `T` in `IColumnValue<T>` should match your field's data type:
|
|
2271
|
+
|
|
2272
|
+
```tsx
|
|
2273
|
+
import React from 'react';
|
|
2274
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2275
|
+
import { Badge } from '@wix/design-system';
|
|
2276
|
+
|
|
2277
|
+
/* The `IColumnValue<T>` interface provides type safety for column override functions: */
|
|
2278
|
+
interface IColumnValue<T> {
|
|
2279
|
+
value: T; // The individual column value (strongly typed)
|
|
2280
|
+
row: Record<string, any>; // The entire row object with all field values
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
// For TEXT fields
|
|
2284
|
+
export function petName({ value, row }: IColumnValue<string>) {
|
|
2285
|
+
return <span>{value?.toUpperCase()}</span>;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
// For NUMBER fields
|
|
2289
|
+
export function age({ value, row }: IColumnValue<number>) {
|
|
2290
|
+
return (
|
|
2291
|
+
<Badge skin={value > 5 ? 'warning' : 'success'}>
|
|
2292
|
+
{value} years old
|
|
2293
|
+
</Badge>
|
|
2294
|
+
);
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
// For BOOLEAN fields
|
|
2298
|
+
export function isVaccinated({ value, row }: IColumnValue<boolean>) {
|
|
2299
|
+
return (
|
|
2300
|
+
<Badge skin={value ? 'success' : 'danger'}>
|
|
2301
|
+
{value ? '✓ Vaccinated' : '✗ Not Vaccinated'}
|
|
2302
|
+
</Badge>
|
|
2303
|
+
);
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
// For DATE/DATETIME fields
|
|
2307
|
+
export function birthDate({ value, row }: IColumnValue<string | Date>) {
|
|
2308
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
2309
|
+
return <span>{date.toLocaleDateString()}</span>;
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
// For IMAGE fields
|
|
2313
|
+
export function profilePicture({ value, row }: IColumnValue<string>) {
|
|
2314
|
+
return <img src={value} alt={row.name} width="48" height="48" />;
|
|
2315
|
+
}
|
|
2316
|
+
|
|
2317
|
+
// For ARRAY fields
|
|
2318
|
+
export function hobbies({ value, row }: IColumnValue<string[]>) {
|
|
2319
|
+
return <span>{value?.join(', ') || 'No hobbies'}</span>;
|
|
2320
|
+
}
|
|
2321
|
+
```
|
|
2322
|
+
|
|
2251
2323
|
### Understanding Row Data
|
|
2252
2324
|
|
|
2253
2325
|
**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.
|
|
@@ -2288,22 +2360,29 @@ export function myColumn({ value, row }) {
|
|
|
2288
2360
|
|
|
2289
2361
|
In `components/columns/name.tsx`:
|
|
2290
2362
|
|
|
2291
|
-
```
|
|
2363
|
+
```tsx
|
|
2292
2364
|
import React from 'react';
|
|
2365
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2293
2366
|
|
|
2294
|
-
export function name(
|
|
2295
|
-
// Simple value formatting
|
|
2367
|
+
export function name(props: IColumnValue<string>) {
|
|
2368
|
+
// Simple value formatting with TypeScript typing
|
|
2369
|
+
return <strong>{props.value}</strong>;
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
// Alternative: Destructured parameters with typing
|
|
2373
|
+
export function nameAlt({ value, row }: IColumnValue<string>) {
|
|
2296
2374
|
return <strong>{value}</strong>;
|
|
2297
2375
|
}
|
|
2298
2376
|
```
|
|
2299
2377
|
|
|
2300
2378
|
In `components/columns/petInfo.tsx`:
|
|
2301
2379
|
|
|
2302
|
-
```
|
|
2380
|
+
```tsx
|
|
2303
2381
|
import React from 'react';
|
|
2304
2382
|
import { Box, Text } from '@wix/design-system';
|
|
2383
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2305
2384
|
|
|
2306
|
-
export function petInfo({ value, row }) {
|
|
2385
|
+
export function petInfo({ value, row }: IColumnValue<string>) {
|
|
2307
2386
|
// Complex column combining multiple row values
|
|
2308
2387
|
return (
|
|
2309
2388
|
<Box direction="vertical" gap={1}>
|
|
@@ -2321,11 +2400,12 @@ export function petInfo({ value, row }) {
|
|
|
2321
2400
|
|
|
2322
2401
|
In `components/columns/status.tsx`:
|
|
2323
2402
|
|
|
2324
|
-
```
|
|
2403
|
+
```tsx
|
|
2325
2404
|
import React from 'react';
|
|
2326
2405
|
import { Badge } from '@wix/design-system';
|
|
2406
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2327
2407
|
|
|
2328
|
-
export function status({ value, row }) {
|
|
2408
|
+
export function status({ value, row }: IColumnValue<string>) {
|
|
2329
2409
|
// Conditional rendering based on multiple row fields
|
|
2330
2410
|
if (row.isVaccinated && row.age > 1) {
|
|
2331
2411
|
return <Badge skin="success">Ready for Adoption</Badge>;
|
|
@@ -2339,10 +2419,11 @@ export function status({ value, row }) {
|
|
|
2339
2419
|
|
|
2340
2420
|
In `components/columns/fullName.tsx`:
|
|
2341
2421
|
|
|
2342
|
-
```
|
|
2422
|
+
```tsx
|
|
2343
2423
|
import React from 'react';
|
|
2424
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2344
2425
|
|
|
2345
|
-
export function fullName({ value, row }) {
|
|
2426
|
+
export function fullName({ value, row }: IColumnValue<string>) {
|
|
2346
2427
|
// Calculated column using multiple fields
|
|
2347
2428
|
return `${row.name} (owned by ${row.owner})`;
|
|
2348
2429
|
}
|
|
@@ -2350,10 +2431,11 @@ export function fullName({ value, row }) {
|
|
|
2350
2431
|
|
|
2351
2432
|
In `components/columns/date.tsx`:
|
|
2352
2433
|
|
|
2353
|
-
```
|
|
2434
|
+
```tsx
|
|
2354
2435
|
import React from 'react';
|
|
2436
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2355
2437
|
|
|
2356
|
-
export function date({ value, row }) {
|
|
2438
|
+
export function date({ value, row }: IColumnValue<string>) {
|
|
2357
2439
|
// Access to other row data for enhanced date formatting
|
|
2358
2440
|
const isRecent = row.lastActivity && new Date(row.lastActivity) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
|
|
2359
2441
|
|
|
@@ -2436,6 +2518,8 @@ PatternsWizardOverridesProvider
|
|
|
2436
2518
|
|
|
2437
2519
|
### Important Guidelines
|
|
2438
2520
|
|
|
2521
|
+
- **TypeScript Usage**: Always use `IColumnValue<T>` and import it from `@wix/auto-patterns/types`
|
|
2522
|
+
- **Type Matching**: Ensure the generic type `T` matches your field's actual data type (string, number, boolean, etc.)
|
|
2439
2523
|
- **Performance**: Remember that column functions are called for every row, so keep calculations lightweight
|
|
2440
2524
|
- **Consistency**: When using row data, ensure the column header accurately represents what's displayed
|
|
2441
2525
|
- **Accessibility**: Maintain proper semantic structure when combining multiple values
|
|
@@ -2947,6 +3031,10 @@ interface Section {
|
|
|
2947
3031
|
prefixIcon?: React.ReactElement;
|
|
2948
3032
|
onClick: () => void;
|
|
2949
3033
|
};
|
|
3034
|
+
badge?: {
|
|
3035
|
+
visible: boolean;
|
|
3036
|
+
skin?: 'light' | 'danger' | 'neutralLight';
|
|
3037
|
+
};
|
|
2950
3038
|
}
|
|
2951
3039
|
```
|
|
2952
3040
|
|
|
@@ -2954,6 +3042,7 @@ The section renderer receives an item and returns:
|
|
|
2954
3042
|
- **id**: A unique identifier for the section (items with the same id are grouped together)
|
|
2955
3043
|
- **title**: The text displayed in the section header
|
|
2956
3044
|
- **primaryAction** (optional): An action button displayed in the section header
|
|
3045
|
+
- **badge** (optional): A badge configuration displayed in the section header
|
|
2957
3046
|
|
|
2958
3047
|
#### Example: Section Renderer Implementation
|
|
2959
3048
|
|
|
@@ -2979,6 +3068,10 @@ export function groupByType(item: any): Section {
|
|
|
2979
3068
|
console.log(`Showing all ${petType}s`);
|
|
2980
3069
|
},
|
|
2981
3070
|
},
|
|
3071
|
+
badge: {
|
|
3072
|
+
visible: true,
|
|
3073
|
+
skin: 'light',
|
|
3074
|
+
},
|
|
2982
3075
|
};
|
|
2983
3076
|
}
|
|
2984
3077
|
```
|
|
@@ -3001,16 +3094,20 @@ export function groupByAgeAndVaccination(item: any): Section {
|
|
|
3001
3094
|
|
|
3002
3095
|
let sectionId: string;
|
|
3003
3096
|
let sectionTitle: string;
|
|
3097
|
+
let badgeSkin: 'light' | 'danger' | 'neutralLight' = 'light';
|
|
3004
3098
|
|
|
3005
3099
|
if (age < 1) {
|
|
3006
3100
|
sectionId = 'puppies';
|
|
3007
3101
|
sectionTitle = 'Puppies (Under 1 year)';
|
|
3102
|
+
badgeSkin = 'neutralLight';
|
|
3008
3103
|
} else if (age >= 1 && age <= 5) {
|
|
3009
3104
|
sectionId = isVaccinated ? 'young-vaccinated' : 'young-unvaccinated';
|
|
3010
3105
|
sectionTitle = `Young Adults (1-5 years) - ${isVaccinated ? 'Vaccinated' : 'Not Vaccinated'}`;
|
|
3106
|
+
badgeSkin = isVaccinated ? 'light' : 'danger';
|
|
3011
3107
|
} else {
|
|
3012
3108
|
sectionId = 'seniors';
|
|
3013
3109
|
sectionTitle = 'Senior Pets (5+ years)';
|
|
3110
|
+
badgeSkin = 'light';
|
|
3014
3111
|
}
|
|
3015
3112
|
|
|
3016
3113
|
return {
|
|
@@ -3023,6 +3120,10 @@ export function groupByAgeAndVaccination(item: any): Section {
|
|
|
3023
3120
|
// Show special care information for puppies
|
|
3024
3121
|
},
|
|
3025
3122
|
} : undefined,
|
|
3123
|
+
badge: {
|
|
3124
|
+
visible: true,
|
|
3125
|
+
skin: badgeSkin,
|
|
3126
|
+
},
|
|
3026
3127
|
};
|
|
3027
3128
|
}
|
|
3028
3129
|
```
|
|
@@ -3037,7 +3138,7 @@ import * as columns from './components/columns';
|
|
|
3037
3138
|
import * as actions from './components/actions';
|
|
3038
3139
|
|
|
3039
3140
|
<PatternsWizardOverridesProvider value={{ sections, columns, actions }}>
|
|
3040
|
-
<AutoPatternsApp configuration={config
|
|
3141
|
+
<AutoPatternsApp configuration={config} />
|
|
3041
3142
|
</PatternsWizardOverridesProvider>
|
|
3042
3143
|
```
|
|
3043
3144
|
|
|
@@ -3051,4 +3152,156 @@ import * as actions from './components/actions';
|
|
|
3051
3152
|
|
|
3052
3153
|
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.
|
|
3053
3154
|
|
|
3155
|
+
## Slots
|
|
3156
|
+
|
|
3157
|
+
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.
|
|
3158
|
+
|
|
3159
|
+
Slots are useful for:
|
|
3160
|
+
- Adding custom banners or announcements above or below the table/grid
|
|
3161
|
+
- Inserting analytics widgets or dashboards
|
|
3162
|
+
- Adding custom promotional content
|
|
3163
|
+
- Implementing page-specific functionality that doesn't fit into standard patterns
|
|
3164
|
+
|
|
3165
|
+
### Configuration Structure
|
|
3166
|
+
|
|
3167
|
+
Slots are configured in the collection page configuration using the `CustomComponentConfig` structure:
|
|
3168
|
+
|
|
3169
|
+
```json
|
|
3170
|
+
{
|
|
3171
|
+
"type": "custom",
|
|
3172
|
+
"id": "myCustomSlot"
|
|
3173
|
+
}
|
|
3174
|
+
```
|
|
3175
|
+
|
|
3176
|
+
**Key Properties:**
|
|
3177
|
+
- `type`: Must be set to `"custom"` to identify this as a slot component
|
|
3178
|
+
- `id`: A unique identifier that maps to your slot component implementation
|
|
3179
|
+
|
|
3180
|
+
### Component Positioning
|
|
3181
|
+
|
|
3182
|
+
Slot components can be positioned anywhere within the `components` array of a collection page. They will be rendered in the exact order specified in the configuration:
|
|
3183
|
+
|
|
3184
|
+
```json
|
|
3185
|
+
{
|
|
3186
|
+
"type": "collectionPage",
|
|
3187
|
+
"collectionPage": {
|
|
3188
|
+
"components": [
|
|
3189
|
+
{
|
|
3190
|
+
"type": "custom",
|
|
3191
|
+
"id": "topBanner"
|
|
3192
|
+
},
|
|
3193
|
+
{
|
|
3194
|
+
"type": "collection",
|
|
3195
|
+
"collection": {
|
|
3196
|
+
"collectionId": "MyCollection"
|
|
3197
|
+
},
|
|
3198
|
+
"layout": [...]
|
|
3199
|
+
},
|
|
3200
|
+
{
|
|
3201
|
+
"type": "custom",
|
|
3202
|
+
"id": "bottomStats"
|
|
3203
|
+
}
|
|
3204
|
+
]
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
```
|
|
3208
|
+
|
|
3209
|
+
This configuration will render:
|
|
3210
|
+
1. The custom `topBanner` component at the top
|
|
3211
|
+
2. The main collection component (table/grid) in the middle
|
|
3212
|
+
3. The custom `bottomStats` component at the bottom
|
|
3213
|
+
|
|
3214
|
+
### Implementation Structure
|
|
3215
|
+
|
|
3216
|
+
#### Creating Slot Components
|
|
3217
|
+
|
|
3218
|
+
Slot components are standard React functional components that take no props:
|
|
3219
|
+
|
|
3220
|
+
```tsx
|
|
3221
|
+
import React from 'react';
|
|
3222
|
+
import { Box, Card, Text, Button } from '@wix/design-system';
|
|
3223
|
+
|
|
3224
|
+
export const TopBannerComponent: React.FC = () => {
|
|
3225
|
+
return (
|
|
3226
|
+
<Card>
|
|
3227
|
+
<Card.Content>
|
|
3228
|
+
<Box direction="vertical" gap={2}>
|
|
3229
|
+
<Text size="large" weight="bold">Welcome to Pet Management</Text>
|
|
3230
|
+
<Text>Manage all your pets from this central dashboard.</Text>
|
|
3231
|
+
<Button size="small">Get Started</Button>
|
|
3232
|
+
</Box>
|
|
3233
|
+
</Card.Content>
|
|
3234
|
+
</Card>
|
|
3235
|
+
);
|
|
3236
|
+
};
|
|
3237
|
+
|
|
3238
|
+
export const BottomStatsComponent: React.FC = () => {
|
|
3239
|
+
return (
|
|
3240
|
+
<Card>
|
|
3241
|
+
<Card.Content>
|
|
3242
|
+
<Box direction="horizontal" gap={4}>
|
|
3243
|
+
<Box direction="vertical" gap={1}>
|
|
3244
|
+
<Text size="large" weight="bold">47</Text>
|
|
3245
|
+
<Text size="small">Total Pets</Text>
|
|
3246
|
+
</Box>
|
|
3247
|
+
<Box direction="vertical" gap={1}>
|
|
3248
|
+
<Text size="large" weight="bold">12</Text>
|
|
3249
|
+
<Text size="small">Available for Adoption</Text>
|
|
3250
|
+
</Box>
|
|
3251
|
+
</Box>
|
|
3252
|
+
</Card.Content>
|
|
3253
|
+
</Card>
|
|
3254
|
+
);
|
|
3255
|
+
};
|
|
3256
|
+
```
|
|
3257
|
+
|
|
3258
|
+
#### Creating the Slots Hook
|
|
3259
|
+
|
|
3260
|
+
In `components/slots/index.tsx`:
|
|
3261
|
+
|
|
3262
|
+
```tsx
|
|
3263
|
+
import { TopBannerComponent } from './TopBannerComponent';
|
|
3264
|
+
import { BottomStatsComponent } from './BottomStatsComponent';
|
|
3265
|
+
|
|
3266
|
+
export const useSlots = () => {
|
|
3267
|
+
// You can access React context and other hooks here
|
|
3268
|
+
return {
|
|
3269
|
+
topBanner: TopBannerComponent,
|
|
3270
|
+
bottomStats: BottomStatsComponent
|
|
3271
|
+
};
|
|
3272
|
+
};
|
|
3273
|
+
```
|
|
3274
|
+
|
|
3275
|
+
**Important:** Every time you create a new slot component, you must import it and add it to the `useSlots` hook return object. The key in the return object must match the `id` specified in your JSON configuration.
|
|
3276
|
+
|
|
3277
|
+
#### Registering Slots in Your Page
|
|
3278
|
+
|
|
3279
|
+
In your main page component:
|
|
3280
|
+
|
|
3281
|
+
```tsx
|
|
3282
|
+
import { useSlots } from '../components/slots';
|
|
3283
|
+
|
|
3284
|
+
export default function YourPage() {
|
|
3285
|
+
const slots = useSlots();
|
|
3286
|
+
|
|
3287
|
+
return (
|
|
3288
|
+
<PatternsWizardOverridesProvider value={{ slots }}>
|
|
3289
|
+
<AutoPatternsApp configuration={config} />
|
|
3290
|
+
</PatternsWizardOverridesProvider>
|
|
3291
|
+
);
|
|
3292
|
+
}
|
|
3293
|
+
```
|
|
3294
|
+
|
|
3295
|
+
### Important Guidelines for Slots
|
|
3296
|
+
|
|
3297
|
+
1. **Component Signature**: Slot components must be React functional components with no props: `React.FC`
|
|
3298
|
+
2. **Rendering Order**: Components render in the exact order specified in the `components` array
|
|
3299
|
+
3. **Performance**: Slot components re-render with the page, so optimize for performance if needed
|
|
3300
|
+
4. **Styling**: Follow the design system patterns and responsive design principles
|
|
3301
|
+
|
|
3302
|
+
|
|
3303
|
+
**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.
|
|
3304
|
+
|
|
3305
|
+
Slots provide a powerful way to enhance collection pages with custom functionality while maintaining the structure and features of the AutoPatterns system.
|
|
3306
|
+
|
|
3054
3307
|
---
|
|
@@ -194,10 +194,7 @@ The bulk action toolbar uses a specific structure for organizing actions:
|
|
|
194
194
|
"item": {
|
|
195
195
|
"id": "bulkCustom",
|
|
196
196
|
"type": "custom",
|
|
197
|
-
"label": "Custom Bulk"
|
|
198
|
-
"custom": {
|
|
199
|
-
"id": "MyCustomBulk"
|
|
200
|
-
}
|
|
197
|
+
"label": "Custom Bulk"
|
|
201
198
|
}
|
|
202
199
|
}
|
|
203
200
|
},
|