@wix/auto-patterns 1.23.0 → 1.25.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 +198 -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/dataSourceAdapters/cms/cmsAdapter.js +2 -1
- package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
- package/dist/cjs/hooks/useActionCell.js +2 -1
- package/dist/cjs/hooks/useActionCell.js.map +1 -1
- package/dist/cjs/hooks/useBulkActionToolbar.js +2 -1
- package/dist/cjs/hooks/useBulkActionToolbar.js.map +1 -1
- package/dist/cjs/hooks/useCollectionPageActions.js +2 -1
- package/dist/cjs/hooks/useCollectionPageActions.js.map +1 -1
- package/dist/cjs/hooks/useEntityPageActions.js +106 -0
- package/dist/cjs/hooks/useEntityPageActions.js.map +1 -0
- package/dist/cjs/hooks/useEntityPageMoreActions.js +11 -1
- 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/ErrorContext.js +6 -3
- package/dist/cjs/providers/ErrorContext.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/actionCell.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 +11 -6
- package/dist/docs/app_config_structure.md +49 -4
- package/dist/docs/auto-patterns-guide.md +311 -43
- package/dist/docs/bulk_actions.md +7 -2
- package/dist/docs/collection_page_actions.md +14 -4
- 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/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +4 -3
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +2 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +9 -196
- 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/Fields/DateInput.js +10 -6
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js +23 -16
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js +3 -2
- package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js +9 -6
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js +8 -6
- package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js +10 -8
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js +12 -10
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js +8 -6
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js.map +1 -1
- 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/SkeletonEntity.js +7 -4
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -1
- 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 +111 -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/components/ModalRenderer.js +2 -1
- package/dist/esm/components/ModalRenderer.js.map +1 -1
- package/dist/esm/components/modals/actions/BulkDeleteModal.js +12 -7
- package/dist/esm/components/modals/actions/BulkDeleteModal.js.map +1 -1
- package/dist/esm/components/modals/actions/CreateModal.js +11 -6
- package/dist/esm/components/modals/actions/CreateModal.js.map +1 -1
- package/dist/esm/components/modals/actions/EditModal.js +11 -6
- package/dist/esm/components/modals/actions/EditModal.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +6 -4
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js +2 -1
- 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 +14 -9
- package/dist/esm/hooks/useActionCell.js.map +1 -1
- package/dist/esm/hooks/useBaseTableFeatures.js +2 -1
- package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useBulkActionToolbar.js +4 -3
- package/dist/esm/hooks/useBulkActionToolbar.js.map +1 -1
- package/dist/esm/hooks/useCollectionPageActions.js +5 -4
- 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 +12 -7
- package/dist/esm/hooks/useColumns.js.map +1 -1
- package/dist/esm/hooks/useCommonCollectionFeatures.js +8 -7
- package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
- package/dist/esm/hooks/useEmptyStates.js +6 -5
- package/dist/esm/hooks/useEmptyStates.js.map +1 -1
- package/dist/esm/hooks/useEntityPageActions.js +83 -0
- package/dist/esm/hooks/useEntityPageActions.js.map +1 -0
- package/dist/esm/hooks/useEntityPageMoreActions.js +12 -2
- package/dist/esm/hooks/useEntityPageMoreActions.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/useNavigateEditEntityAction.js +46 -0
- package/dist/esm/hooks/useNavigateEditEntityAction.js.map +1 -0
- package/dist/esm/hooks/useNavigationUtils.js +15 -3
- package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
- package/dist/esm/hooks/usePagePath.js +4 -3
- package/dist/esm/hooks/usePagePath.js.map +1 -1
- package/dist/esm/hooks/useTableFeatures.js +2 -1
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/providers/ErrorContext.js +4 -1
- package/dist/esm/providers/ErrorContext.js.map +1 -1
- package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/esm/providers/SchemaContext.js +3 -2
- package/dist/esm/providers/SchemaContext.js.map +1 -1
- package/dist/esm/providers/SchemaRegistryContext.js +1 -1
- package/dist/esm/providers/SchemaRegistryContext.js.map +1 -1
- package/dist/esm/types/EntityPageConfig.js.map +1 -1
- package/dist/esm/types/actions/actionCell.js.map +1 -1
- package/dist/esm/types/actions/entityPageActions.js.map +1 -1
- package/dist/esm/utils/actions/customAction.js +2 -1
- package/dist/esm/utils/actions/customAction.js.map +1 -1
- package/dist/esm/utils/actions/deleteAction.js +10 -5
- package/dist/esm/utils/actions/deleteAction.js.map +1 -1
- package/dist/esm/utils/actions/types.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/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/dataSourceAdapters/cms/cmsAdapter.d.ts.map +1 -1
- package/dist/types/hooks/useActionCell.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/ErrorContext.d.ts +7 -0
- package/dist/types/providers/ErrorContext.d.ts.map +1 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -2
- 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/actionCell.d.ts +7 -1
- package/dist/types/types/actions/actionCell.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/customAction.d.ts +1 -1
- package/dist/types/utils/actions/customAction.d.ts.map +1 -1
- package/dist/types/utils/actions/resolveAction.d.ts +1 -0
- package/dist/types/utils/actions/resolveAction.d.ts.map +1 -1
- package/dist/types/utils/actions/types.d.ts +2 -1
- package/dist/types/utils/actions/types.d.ts.map +1 -1
- package/package.json +16 -15
- package/dist/docs/config_schema.md +0 -184
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.
|
|
@@ -1,26 +1,41 @@
|
|
|
1
1
|
# FQDN-Based Custom Data Source Implementation
|
|
2
2
|
|
|
3
|
+
**🛑 CRITICAL PREREQUISITE**: This guide explains a specialized feature that exists within the broader auto-patterns framework. You **CANNOT** implement this guide without first having the complete content of the WixAutoPatternsGuide.
|
|
4
|
+
|
|
5
|
+
**📋 MANDATORY FIRST STEP**: Before proceeding with this FQDN-specific implementation:
|
|
6
|
+
1. **You MUST call the `WixAutoPatternsGuide` tool first** to get the foundational auto-patterns knowledge
|
|
7
|
+
2. **This document is NOT standalone** - it's an advanced feature guide that builds upon the core auto-patterns concepts
|
|
8
|
+
3. **Without the WixAutoPatternsGuide content**, you will not understand the basic concepts, component structure, or implementation patterns required for this FQDN implementation
|
|
9
|
+
|
|
3
10
|
When implementing a custom data source based on a Wix Business API FQDN, you'll need to understand several key concepts and follow specific implementation patterns. This guide covers the complete process from schema extraction to creating a foundation structure that **you will need to complete**.
|
|
4
11
|
|
|
5
12
|
**⚠️ IMPORTANT**: This guide creates a foundation with helpful comments and unimplemented actions that throw exceptions. The actual data source implementation (CRUD operations) must be completed by you using the appropriate Wix Business API client library.
|
|
6
13
|
|
|
7
14
|
**📝 MINIMAL IMPLEMENTATION APPROACH**: This guide focuses on creating a basic, functional dashboard page. Custom overrides (actions, columns, components, etc.) should only be implemented when explicitly requested by the user. A simple dashboard page requires only the core custom data source implementation without any additional overrides.
|
|
8
15
|
|
|
9
|
-
## Prerequisites: Required Tools
|
|
16
|
+
## Prerequisites: Required Tools and Knowledge
|
|
17
|
+
|
|
18
|
+
**🛑 ABSOLUTE REQUIREMENT - WixAutoPatternsGuide Content**:
|
|
19
|
+
- **You MUST have the complete WixAutoPatternsGuide content** before starting this implementation
|
|
20
|
+
- **This FQDN guide is NOT self-contained** - it's a specialized extension of the main auto-patterns guide
|
|
21
|
+
- **If you haven't called the `WixAutoPatternsGuide` tool yet**, stop now and call it first
|
|
22
|
+
- **This guide will reference concepts, components, and patterns** that are only explained in the main guide
|
|
10
23
|
|
|
11
24
|
**🛑 CRITICAL**: Before proceeding with this guide, you must have the following tools available:
|
|
12
|
-
- `
|
|
25
|
+
- `WixAutoPatternsGuide` tool for understanding auto-patterns fundamentals and implementation patterns (**MANDATORY FIRST STEP**)
|
|
13
26
|
- `fqdn_schema` tool for extracting schema information from FQDNs
|
|
14
27
|
- `client_lib` tool for determining the correct client library package
|
|
15
28
|
|
|
16
29
|
**If these tools are not available, you CANNOT continue with this guide.**
|
|
17
30
|
|
|
18
31
|
**Auto-Patterns Context Requirement:**
|
|
19
|
-
If you haven't already used the `
|
|
32
|
+
If you haven't already used the `WixAutoPatternsGuide` tool in this conversation, you MUST call it first to understand:
|
|
20
33
|
- How AutoPatternsApp works
|
|
21
34
|
- AppConfig structure and requirements
|
|
22
35
|
- Custom data source implementation patterns
|
|
23
36
|
- Best practices for auto-patterns development
|
|
37
|
+
- Basic component structure and routing
|
|
38
|
+
- Provider setup and configuration
|
|
24
39
|
|
|
25
40
|
**Without this foundational knowledge, you cannot successfully implement FQDN-based custom data sources.**
|
|
26
41
|
|
|
@@ -65,7 +80,10 @@ This will tell you which library to import for your custom data source implement
|
|
|
65
80
|
|
|
66
81
|
Transform the FQDN schema from Step 1 into a AutoPatterns-compatible SchemaConfig by mapping the FQDN field types to AutoPatterns field types. Identify appropriate fields for `displayField` and `idField` based on your FQDN schema.
|
|
67
82
|
|
|
68
|
-
|
|
83
|
+
**🛑 MANDATORY - Query Operators Must Be Empty Array**: When implementing a custom data source, you **MUST** set `supportedQueryOperators: []` (empty array) for all fields. This is required because:
|
|
84
|
+
- Custom data sources handle all query operations directly through your implementation
|
|
85
|
+
- You don't need to specify individual operators for each field
|
|
86
|
+
- The custom data source `find` action will receive all queries regardless of declared operators
|
|
69
87
|
|
|
70
88
|
### ⚠️ CRITICAL: Field ID Conversion from snake_case to camelCase
|
|
71
89
|
|
|
@@ -112,7 +130,7 @@ export const myCustomDataSource = async (collectionId: string, context: any) =>
|
|
|
112
130
|
// Field definitions based on your FQDN schema mapping
|
|
113
131
|
},
|
|
114
132
|
displayField: 'name',
|
|
115
|
-
idField: '
|
|
133
|
+
idField: 'id',
|
|
116
134
|
actions: {
|
|
117
135
|
get: async (entityId: string) => {
|
|
118
136
|
// TODO: Implement using your FQDN client library
|
|
@@ -218,6 +236,7 @@ If the user specifically requests custom actions for your FQDN-based data source
|
|
|
218
236
|
✅ **Schema Extraction**: Used fqdn_schema tool to understand entity structure
|
|
219
237
|
✅ **Client Library**: Used client_lib tool to identify correct SDK package
|
|
220
238
|
✅ **Field Mapping**: Mapped FQDN field types to AutoPatterns field types
|
|
239
|
+
✅ **🛑 MANDATORY: Empty Query Operators**: Set `supportedQueryOperators: []` for ALL fields to avoid TypeScript errors
|
|
221
240
|
✅ **⚠️ CRITICAL: Field ID Conversion**: Converted individual field segments from snake_case to camelCase while preserving field path structure in SchemaConfig and AppConfig
|
|
222
241
|
✅ **AppConfig Update**: Set `entityTypeSource: "custom"` and provided custom.id
|
|
223
242
|
✅ **Custom Data Source Structure**: Followed "Custom Overrides" section for folder structure and registration
|
|
@@ -235,6 +254,7 @@ If the user specifically requests custom actions for your FQDN-based data source
|
|
|
235
254
|
- **⚠️ CRITICAL: Implementing Unnecessary Overrides**: Do NOT implement custom actions, column overrides, or custom components unless explicitly requested by the user - a basic dashboard page only needs the core custom data source
|
|
236
255
|
- **⚠️ CRITICAL: Inconsistent Field ID Casing**: Failing to convert individual field segments from snake_case to camelCase while preserving field path structure in SchemaConfig and AppConfig - this is the most common mistake and will cause field mapping failures
|
|
237
256
|
- **⚠️ CRITICAL: Implementing Actions**: DO NOT implement the schema actions - they should contain helpful comments and throw unimplemented exceptions for the user to complete
|
|
257
|
+
- **🛑 CRITICAL: Query Operators MUST Be Empty Array**: You **MUST** use `supportedQueryOperators: []` (empty array) for all fields - attempting to specify actual operators will cause TypeScript compilation errors and is not supported for custom data sources
|
|
238
258
|
- **Mismatched Field Types**: Ensure FQDN field types are correctly mapped to AutoPatterns types
|
|
239
259
|
- **Wrong Client Library**: Use the exact client library returned by the client_lib tool
|
|
240
260
|
- **ID Field Confusion**: Ensure the idField matches what your FQDN API actually uses (often `_id` for Wix APIs)
|
package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js
CHANGED
|
@@ -14,14 +14,15 @@ export const AutoPatternsCollectionComponent = _ref => {
|
|
|
14
14
|
...sharedConfig
|
|
15
15
|
} = component;
|
|
16
16
|
const memoized = useMemo(() => {
|
|
17
|
-
|
|
17
|
+
var _layout$find, _layout$find2;
|
|
18
|
+
if (!(layout != null && layout.length)) {
|
|
18
19
|
return {
|
|
19
20
|
componentToRender: null,
|
|
20
21
|
componentType: 'Table'
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
const tableConfig = layout.find(item => item.type === 'Table')
|
|
24
|
-
const gridConfig = layout.find(item => item.type === 'Grid')
|
|
24
|
+
const tableConfig = (_layout$find = layout.find(item => item.type === 'Table')) == null ? void 0 : _layout$find.table;
|
|
25
|
+
const gridConfig = (_layout$find2 = layout.find(item => item.type === 'Grid')) == null ? void 0 : _layout$find2.grid;
|
|
25
26
|
let componentType = 'Table';
|
|
26
27
|
let componentToRender = null;
|
|
27
28
|
if (tableConfig && gridConfig) {
|
package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AutoPatternsTableGridSwitch","AutoPatternsTable","AutoPatternsGrid","SchemaProvider","SkeletonCollection","React","useMemo","AutoPatternsCollectionComponent","_ref","component","index","layout","sharedConfig","memoized","length","componentToRender","componentType","tableConfig","find","item","type","table","gridConfig","grid","config","createElement","configuration","Fragment","key","collection","collectionId","skeleton"],"sources":["../../../../src/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.tsx"],"sourcesContent":["import { CollectionComponentConfig } from '../../types';\nimport { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';\nimport { AutoPatternsTable } from '../AutoPatternsTable';\nimport { AutoPatternsGrid } from '../AutoPatternsGrid';\nimport { SchemaProvider } from '../../providers';\nimport { SkeletonCollection } from '../AutoPatternsCollectionPageContent/SkeletonCollection';\nimport React, { useMemo } from 'react';\n\nexport const AutoPatternsCollectionComponent = ({\n component,\n index,\n}: {\n component: CollectionComponentConfig;\n index: number;\n}) => {\n const { layout, ...sharedConfig } = component;\n\n const memoized = useMemo(() => {\n if (!layout?.length) {\n return {\n componentToRender: null,\n componentType: 'Table' as 'Table' | 'Grid',\n };\n }\n\n const tableConfig = layout.find((item) => item.type === 'Table')?.table;\n const gridConfig = layout.find((item) => item.type === 'Grid')?.grid;\n\n let componentType: 'Table' | 'Grid' = 'Table';\n let componentToRender: React.ReactNode = null;\n\n if (tableConfig && gridConfig) {\n const config = {\n ...sharedConfig,\n ...tableConfig,\n ...gridConfig,\n };\n componentToRender = (\n <AutoPatternsTableGridSwitch configuration={config} />\n );\n } else if (tableConfig) {\n const config = { ...sharedConfig, ...tableConfig };\n componentToRender = <AutoPatternsTable configuration={config} />;\n } else if (gridConfig) {\n componentType = 'Grid';\n const config = { ...sharedConfig, ...gridConfig };\n componentToRender = <AutoPatternsGrid configuration={config} />;\n }\n\n return { componentToRender, componentType };\n }, [layout, sharedConfig]);\n\n const { componentToRender, componentType } = memoized;\n\n return (\n <>\n {componentToRender ? (\n <SchemaProvider\n key={`${sharedConfig.collection.collectionId}-${index}`}\n collection={sharedConfig.collection}\n skeleton={<SkeletonCollection componentType={componentType} />}\n >\n {componentToRender}\n </SchemaProvider>\n ) : null}\n </>\n );\n};\n"],"mappings":"AACA,SAASA,2BAA2B,QAAQ,4DAA4D;AACxG,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,kBAAkB,QAAQ,yDAAyD;AAC5F,OAAOC,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAEtC,OAAO,MAAMC,+BAA+B,GAAGC,IAAA,IAMzC;EAAA,IAN0C;IAC9CC,SAAS;IACTC;EAIF,CAAC,GAAAF,IAAA;EACC,MAAM;IAAEG,MAAM;IAAE,GAAGC;EAAa,CAAC,GAAGH,SAAS;EAE7C,MAAMI,QAAQ,GAAGP,OAAO,CAAC,MAAM;IAC7B,IAAI,
|
|
1
|
+
{"version":3,"names":["AutoPatternsTableGridSwitch","AutoPatternsTable","AutoPatternsGrid","SchemaProvider","SkeletonCollection","React","useMemo","AutoPatternsCollectionComponent","_ref","component","index","layout","sharedConfig","memoized","_layout$find","_layout$find2","length","componentToRender","componentType","tableConfig","find","item","type","table","gridConfig","grid","config","createElement","configuration","Fragment","key","collection","collectionId","skeleton"],"sources":["../../../../src/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.tsx"],"sourcesContent":["import { CollectionComponentConfig } from '../../types';\nimport { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';\nimport { AutoPatternsTable } from '../AutoPatternsTable';\nimport { AutoPatternsGrid } from '../AutoPatternsGrid';\nimport { SchemaProvider } from '../../providers';\nimport { SkeletonCollection } from '../AutoPatternsCollectionPageContent/SkeletonCollection';\nimport React, { useMemo } from 'react';\n\nexport const AutoPatternsCollectionComponent = ({\n component,\n index,\n}: {\n component: CollectionComponentConfig;\n index: number;\n}) => {\n const { layout, ...sharedConfig } = component;\n\n const memoized = useMemo(() => {\n if (!layout?.length) {\n return {\n componentToRender: null,\n componentType: 'Table' as 'Table' | 'Grid',\n };\n }\n\n const tableConfig = layout.find((item) => item.type === 'Table')?.table;\n const gridConfig = layout.find((item) => item.type === 'Grid')?.grid;\n\n let componentType: 'Table' | 'Grid' = 'Table';\n let componentToRender: React.ReactNode = null;\n\n if (tableConfig && gridConfig) {\n const config = {\n ...sharedConfig,\n ...tableConfig,\n ...gridConfig,\n };\n componentToRender = (\n <AutoPatternsTableGridSwitch configuration={config} />\n );\n } else if (tableConfig) {\n const config = { ...sharedConfig, ...tableConfig };\n componentToRender = <AutoPatternsTable configuration={config} />;\n } else if (gridConfig) {\n componentType = 'Grid';\n const config = { ...sharedConfig, ...gridConfig };\n componentToRender = <AutoPatternsGrid configuration={config} />;\n }\n\n return { componentToRender, componentType };\n }, [layout, sharedConfig]);\n\n const { componentToRender, componentType } = memoized;\n\n return (\n <>\n {componentToRender ? (\n <SchemaProvider\n key={`${sharedConfig.collection.collectionId}-${index}`}\n collection={sharedConfig.collection}\n skeleton={<SkeletonCollection componentType={componentType} />}\n >\n {componentToRender}\n </SchemaProvider>\n ) : null}\n </>\n );\n};\n"],"mappings":"AACA,SAASA,2BAA2B,QAAQ,4DAA4D;AACxG,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,kBAAkB,QAAQ,yDAAyD;AAC5F,OAAOC,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAEtC,OAAO,MAAMC,+BAA+B,GAAGC,IAAA,IAMzC;EAAA,IAN0C;IAC9CC,SAAS;IACTC;EAIF,CAAC,GAAAF,IAAA;EACC,MAAM;IAAEG,MAAM;IAAE,GAAGC;EAAa,CAAC,GAAGH,SAAS;EAE7C,MAAMI,QAAQ,GAAGP,OAAO,CAAC,MAAM;IAAA,IAAAQ,YAAA,EAAAC,aAAA;IAC7B,IAAI,EAACJ,MAAM,YAANA,MAAM,CAAEK,MAAM,GAAE;MACnB,OAAO;QACLC,iBAAiB,EAAE,IAAI;QACvBC,aAAa,EAAE;MACjB,CAAC;IACH;IAEA,MAAMC,WAAW,IAAAL,YAAA,GAAGH,MAAM,CAACS,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,OAAO,CAAC,qBAA5CR,YAAA,CAA8CS,KAAK;IACvE,MAAMC,UAAU,IAAAT,aAAA,GAAGJ,MAAM,CAACS,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,MAAM,CAAC,qBAA3CP,aAAA,CAA6CU,IAAI;IAEpE,IAAIP,aAA+B,GAAG,OAAO;IAC7C,IAAID,iBAAkC,GAAG,IAAI;IAE7C,IAAIE,WAAW,IAAIK,UAAU,EAAE;MAC7B,MAAME,MAAM,GAAG;QACb,GAAGd,YAAY;QACf,GAAGO,WAAW;QACd,GAAGK;MACL,CAAC;MACDP,iBAAiB,gBACfZ,KAAA,CAAAsB,aAAA,CAAC3B,2BAA2B;QAAC4B,aAAa,EAAEF;MAAO,CAAE,CACtD;IACH,CAAC,MAAM,IAAIP,WAAW,EAAE;MACtB,MAAMO,MAAM,GAAG;QAAE,GAAGd,YAAY;QAAE,GAAGO;MAAY,CAAC;MAClDF,iBAAiB,gBAAGZ,KAAA,CAAAsB,aAAA,CAAC1B,iBAAiB;QAAC2B,aAAa,EAAEF;MAAO,CAAE,CAAC;IAClE,CAAC,MAAM,IAAIF,UAAU,EAAE;MACrBN,aAAa,GAAG,MAAM;MACtB,MAAMQ,MAAM,GAAG;QAAE,GAAGd,YAAY;QAAE,GAAGY;MAAW,CAAC;MACjDP,iBAAiB,gBAAGZ,KAAA,CAAAsB,aAAA,CAACzB,gBAAgB;QAAC0B,aAAa,EAAEF;MAAO,CAAE,CAAC;IACjE;IAEA,OAAO;MAAET,iBAAiB;MAAEC;IAAc,CAAC;EAC7C,CAAC,EAAE,CAACP,MAAM,EAAEC,YAAY,CAAC,CAAC;EAE1B,MAAM;IAAEK,iBAAiB;IAAEC;EAAc,CAAC,GAAGL,QAAQ;EAErD,oBACER,KAAA,CAAAsB,aAAA,CAAAtB,KAAA,CAAAwB,QAAA,QACGZ,iBAAiB,gBAChBZ,KAAA,CAAAsB,aAAA,CAACxB,cAAc;IACb2B,GAAG,EAAE,GAAGlB,YAAY,CAACmB,UAAU,CAACC,YAAY,IAAItB,KAAK,EAAG;IACxDqB,UAAU,EAAEnB,YAAY,CAACmB,UAAW;IACpCE,QAAQ,eAAE5B,KAAA,CAAAsB,aAAA,CAACvB,kBAAkB;MAACc,aAAa,EAAEA;IAAc,CAAE;EAAE,GAE9DD,iBACa,CAAC,GACf,IACJ,CAAC;AAEP,CAAC","ignoreList":[]}
|
package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js
CHANGED
|
@@ -17,7 +17,8 @@ export const AutoPatternsCollectionPageContent = _ref => {
|
|
|
17
17
|
index: index
|
|
18
18
|
});
|
|
19
19
|
} else if (component.type === 'custom') {
|
|
20
|
-
|
|
20
|
+
var _overrides$slots;
|
|
21
|
+
const CustomComponent = overrides == null || (_overrides$slots = overrides.slots) == null ? void 0 : _overrides$slots[component.id];
|
|
21
22
|
if (!CustomComponent) {
|
|
22
23
|
return null;
|
|
23
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","usePatternsWizardOverridesContext","AutoPatternsCollectionComponent","AutoPatternsCollectionPageContent","_ref","configuration","components","overrides","createElement","Fragment","map","component","index","type","key","collection","collectionId","CustomComponent","slots","id","filter","Boolean"],"sources":["../../../../src/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.tsx"],"sourcesContent":["import React from 'react';\nimport { CollectionPageConfig } from '../../types';\nimport { usePatternsWizardOverridesContext } from '../../providers';\nimport { AutoPatternsCollectionComponent } from '../AutoPatternsCollectionComponent/AutoPatternsCollectionComponent';\n\nexport interface AutoPatternsCollectionPageContentProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPageContent = ({\n configuration,\n}: AutoPatternsCollectionPageContentProps) => {\n const { components } = configuration;\n const overrides = usePatternsWizardOverridesContext();\n\n return (\n <>\n {components\n .map((component, index) => {\n if (component.type === 'collection') {\n return (\n <AutoPatternsCollectionComponent\n key={`collection-${component.collection.collectionId}-${index}`}\n component={component}\n index={index}\n />\n );\n } else if (component.type === 'custom') {\n const CustomComponent = overrides?.slots?.[component.id];\n\n if (!CustomComponent) {\n return null;\n }\n\n return <CustomComponent key={`custom-${component.id}-${index}`} />;\n }\n\n return null;\n })\n .filter(Boolean)}\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,iCAAiC,QAAQ,iBAAiB;AACnE,SAASC,+BAA+B,QAAQ,oEAAoE;AAMpH,OAAO,MAAMC,iCAAiC,GAAGC,IAAA,IAEH;EAAA,IAFI;IAChDC;EACsC,CAAC,GAAAD,IAAA;EACvC,MAAM;IAAEE;EAAW,CAAC,GAAGD,aAAa;EACpC,MAAME,SAAS,GAAGN,iCAAiC,CAAC,CAAC;EAErD,oBACED,KAAA,CAAAQ,aAAA,CAAAR,KAAA,CAAAS,QAAA,QACGH,UAAU,CACRI,GAAG,CAAC,CAACC,SAAS,EAAEC,KAAK,KAAK;IACzB,IAAID,SAAS,CAACE,IAAI,KAAK,YAAY,EAAE;MACnC,oBACEb,KAAA,CAAAQ,aAAA,CAACN,+BAA+B;QAC9BY,GAAG,EAAE,cAAcH,SAAS,CAACI,UAAU,CAACC,YAAY,IAAIJ,KAAK,EAAG;QAChED,SAAS,EAAEA,SAAU;QACrBC,KAAK,EAAEA;MAAM,CACd,CAAC;IAEN,CAAC,MAAM,IAAID,SAAS,CAACE,IAAI,KAAK,QAAQ,EAAE;MACtC,
|
|
1
|
+
{"version":3,"names":["React","usePatternsWizardOverridesContext","AutoPatternsCollectionComponent","AutoPatternsCollectionPageContent","_ref","configuration","components","overrides","createElement","Fragment","map","component","index","type","key","collection","collectionId","_overrides$slots","CustomComponent","slots","id","filter","Boolean"],"sources":["../../../../src/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.tsx"],"sourcesContent":["import React from 'react';\nimport { CollectionPageConfig } from '../../types';\nimport { usePatternsWizardOverridesContext } from '../../providers';\nimport { AutoPatternsCollectionComponent } from '../AutoPatternsCollectionComponent/AutoPatternsCollectionComponent';\n\nexport interface AutoPatternsCollectionPageContentProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPageContent = ({\n configuration,\n}: AutoPatternsCollectionPageContentProps) => {\n const { components } = configuration;\n const overrides = usePatternsWizardOverridesContext();\n\n return (\n <>\n {components\n .map((component, index) => {\n if (component.type === 'collection') {\n return (\n <AutoPatternsCollectionComponent\n key={`collection-${component.collection.collectionId}-${index}`}\n component={component}\n index={index}\n />\n );\n } else if (component.type === 'custom') {\n const CustomComponent = overrides?.slots?.[component.id];\n\n if (!CustomComponent) {\n return null;\n }\n\n return <CustomComponent key={`custom-${component.id}-${index}`} />;\n }\n\n return null;\n })\n .filter(Boolean)}\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,iCAAiC,QAAQ,iBAAiB;AACnE,SAASC,+BAA+B,QAAQ,oEAAoE;AAMpH,OAAO,MAAMC,iCAAiC,GAAGC,IAAA,IAEH;EAAA,IAFI;IAChDC;EACsC,CAAC,GAAAD,IAAA;EACvC,MAAM;IAAEE;EAAW,CAAC,GAAGD,aAAa;EACpC,MAAME,SAAS,GAAGN,iCAAiC,CAAC,CAAC;EAErD,oBACED,KAAA,CAAAQ,aAAA,CAAAR,KAAA,CAAAS,QAAA,QACGH,UAAU,CACRI,GAAG,CAAC,CAACC,SAAS,EAAEC,KAAK,KAAK;IACzB,IAAID,SAAS,CAACE,IAAI,KAAK,YAAY,EAAE;MACnC,oBACEb,KAAA,CAAAQ,aAAA,CAACN,+BAA+B;QAC9BY,GAAG,EAAE,cAAcH,SAAS,CAACI,UAAU,CAACC,YAAY,IAAIJ,KAAK,EAAG;QAChED,SAAS,EAAEA,SAAU;QACrBC,KAAK,EAAEA;MAAM,CACd,CAAC;IAEN,CAAC,MAAM,IAAID,SAAS,CAACE,IAAI,KAAK,QAAQ,EAAE;MAAA,IAAAI,gBAAA;MACtC,MAAMC,eAAe,GAAGX,SAAS,aAAAU,gBAAA,GAATV,SAAS,CAAEY,KAAK,qBAAhBF,gBAAA,CAAmBN,SAAS,CAACS,EAAE,CAAC;MAExD,IAAI,CAACF,eAAe,EAAE;QACpB,OAAO,IAAI;MACb;MAEA,oBAAOlB,KAAA,CAAAQ,aAAA,CAACU,eAAe;QAACJ,GAAG,EAAE,UAAUH,SAAS,CAACS,EAAE,IAAIR,KAAK;MAAG,CAAE,CAAC;IACpE;IAEA,OAAO,IAAI;EACb,CAAC,CAAC,CACDS,MAAM,CAACC,OAAO,CACjB,CAAC;AAEP,CAAC","ignoreList":[]}
|