@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_actions","_patterns","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useEntityPageActions","entityPageActions","entity","sdk","buildEntityPageActions","useCallback","buildAction","actionConfig","actionToResolve","baseParams","actionParams","type","createAction","action","customAction","hidden","resolvedAction","resolveAction","tooltip","icon","resolvedActionProps","prefixIcon","disabledDescription","handleActionsType","actions","item","actionGroups","groupActions","menu","items","subItems","map","group","filter","length","label","primaryActions","secondaryActions","createElement","Fragment","SecondaryActions","_extends2","__self","__source","fileName","lineNumber","columnNumber","undefined","PrimaryActions","exports"],"sources":["../../../src/hooks/useEntityPageActions.tsx"],"sourcesContent":["import React, { useCallback } from 'react';\nimport {\n ActionsSDK,\n EntityPageActionConfig,\n EntityPageConfig,\n EntityPagePrimaryActions,\n EntityPageSecondaryActions,\n ResolvedAction,\n} from '../types';\nimport {\n createAction,\n customAction,\n resolveAction,\n groupActions,\n} from '../utils/actions';\nimport { IconElement } from '@wix/design-system';\nimport { PrimaryActions, SecondaryActions } from '@wix/patterns';\n\nexport interface UseEntityPageActionsParams {\n entityPageActions: EntityPageConfig['actions'];\n entity: Record<string, any>;\n sdk: ActionsSDK;\n}\n\nexport const useEntityPageActions = ({\n entityPageActions,\n entity,\n sdk,\n}: UseEntityPageActionsParams) => {\n const buildEntityPageActions = useCallback(() => {\n if (!entityPageActions) {\n return;\n }\n\n const buildAction = (actionConfig: EntityPageActionConfig) => {\n let actionToResolve: Partial<ResolvedAction> | null = null;\n\n const baseParams = {\n actionParams: {\n entity,\n },\n sdk,\n };\n\n switch (actionConfig.type) {\n case 'create':\n actionToResolve = createAction({\n action: actionConfig,\n ...baseParams,\n });\n break;\n\n case 'custom':\n actionToResolve = customAction({\n action: actionConfig,\n ...baseParams,\n });\n break;\n\n default:\n return null;\n }\n\n if (!actionToResolve || actionToResolve.hidden) {\n return null;\n }\n\n const resolvedAction = resolveAction(actionConfig, actionToResolve);\n const { tooltip, icon, hidden, ...resolvedActionProps } = resolvedAction;\n\n return {\n ...resolvedActionProps,\n prefixIcon: icon as IconElement,\n disabledDescription: resolvedAction.tooltip,\n };\n };\n\n const handleActionsType = (\n actions: EntityPagePrimaryActions | EntityPageSecondaryActions,\n ) => {\n if (actions.type === 'action') {\n return buildAction(actions.action.item);\n }\n\n if (actions.type === 'menu') {\n const actionGroups = groupActions(actions.menu.items);\n const subItems = actionGroups\n .map((group) =>\n group.map(buildAction).filter((action) => action !== null),\n )\n .filter((group) => group.length > 0);\n\n if (!subItems.length) {\n return null;\n }\n\n return {\n label: actions.menu.label,\n subItems,\n };\n }\n\n return null;\n };\n\n const primaryActions =\n entityPageActions?.primaryActions &&\n handleActionsType(entityPageActions.primaryActions);\n\n const secondaryActions =\n entityPageActions?.secondaryActions &&\n handleActionsType(entityPageActions.secondaryActions);\n\n if (!primaryActions && !secondaryActions) {\n return;\n }\n\n return (\n <>\n {secondaryActions ? (\n <SecondaryActions {...secondaryActions} />\n ) : undefined}\n {primaryActions ? <PrimaryActions {...primaryActions} /> : undefined}\n </>\n );\n }, [entityPageActions, entity, sdk]);\n\n if (\n !entityPageActions?.primaryActions &&\n !entityPageActions?.secondaryActions\n ) {\n return null;\n }\n\n return buildEntityPageActions() ?? null;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE,SAAA,GAAAF,OAAA;AAAiE,IAAAG,YAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAA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AAC,YAAA;MAAA;IAAA,EAAG,CAAC,GACxCC,SAAS,EACZX,cAAc,gBAAG9D,MAAA,CAAAY,OAAA,CAAAoD,aAAA,CAAC5D,SAAA,CAAAsE,cAAc,MAAAP,SAAA,CAAAvD,OAAA,MAAKkD,cAAc;MAAAM,MAAA;MAAAC,QAAA;QAAAC,QAAA,EAAAjE,YAAA;QAAAkE,UAAA;QAAAC,YAAA;MAAA;IAAA,EAAG,CAAC,GAAGC,SAC3D,CAAC;EAEP,CAAC,EAAE,CAAC9C,iBAAiB,EAAEC,MAAM,EAAEC,GAAG,CAAC,CAAC;EAEpC,IACE,EAACF,iBAAiB,YAAjBA,iBAAiB,CAAEmC,cAAc,KAClC,EAACnC,iBAAiB,YAAjBA,iBAAiB,CAAEoC,gBAAgB,GACpC;IACA,OAAO,IAAI;EACb;EAEA,OAAOjC,sBAAsB,CAAC,CAAC,IAAI,IAAI;AACzC,CAAC;AAAC6C,OAAA,CAAAjD,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -19,6 +19,16 @@ function useEntityPageMoreActions(moreActions, entity, sdk, form) {
|
|
|
19
19
|
sdk
|
|
20
20
|
};
|
|
21
21
|
switch (actionConfig.type) {
|
|
22
|
+
case 'update':
|
|
23
|
+
actionToResolve = (0, _actions.updateAction)({
|
|
24
|
+
action: actionConfig,
|
|
25
|
+
...baseParams,
|
|
26
|
+
actionParams: {
|
|
27
|
+
...baseParams.actionParams,
|
|
28
|
+
item: entity
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
break;
|
|
22
32
|
case 'custom':
|
|
23
33
|
actionToResolve = (0, _actions.customAction)({
|
|
24
34
|
action: actionConfig,
|
|
@@ -28,7 +38,7 @@ function useEntityPageMoreActions(moreActions, entity, sdk, form) {
|
|
|
28
38
|
default:
|
|
29
39
|
return null;
|
|
30
40
|
}
|
|
31
|
-
if (!actionToResolve) {
|
|
41
|
+
if (!actionToResolve || actionToResolve.hidden) {
|
|
32
42
|
return null;
|
|
33
43
|
}
|
|
34
44
|
const resolved = (0, _actions.resolveAction)(actionConfig, actionToResolve);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_actions","require","_react","useEntityPageMoreActions","moreActions","entity","sdk","form","buildEntityPageActions","useCallback","buildAction","actionConfig","actionToResolve","baseParams","actionParams","type","
|
|
1
|
+
{"version":3,"names":["_actions","require","_react","useEntityPageMoreActions","moreActions","entity","sdk","form","buildEntityPageActions","useCallback","buildAction","actionConfig","actionToResolve","baseParams","actionParams","type","updateAction","action","item","customAction","hidden","resolved","resolveAction","onClick","text","label","prefixIcon","icon","disabled","actionGroups","groupActions","map","group","filter","Boolean","length"],"sources":["../../../src/hooks/useEntityPageMoreActions.ts"],"sourcesContent":["import { ActionsSDK, ResolvedAction } from '../types';\nimport {\n customAction,\n resolveAction,\n groupActions,\n updateAction,\n} from '../utils/actions';\nimport { useCallback } from 'react';\nimport { MoreActionsItem } from '@wix/patterns';\nimport { FieldValues, UseFormReturn } from '@wix/patterns/form';\nimport {\n CustomActionConfig,\n DividerActionConfig,\n UpdateActionConfig,\n} from '../types/actions/base';\n\nexport function useEntityPageMoreActions(\n moreActions:\n | (CustomActionConfig | UpdateActionConfig | DividerActionConfig)[]\n | undefined,\n entity: Record<string, any>,\n sdk: ActionsSDK,\n form?: UseFormReturn<FieldValues, any, undefined>,\n) {\n const buildEntityPageActions = useCallback(() => {\n if (!moreActions) {\n return;\n }\n\n const buildAction = (\n actionConfig: CustomActionConfig | UpdateActionConfig,\n ): MoreActionsItem | null => {\n let actionToResolve: Partial<ResolvedAction> | null = null;\n const baseParams = {\n actionParams: { entity, form },\n sdk,\n };\n\n switch (actionConfig.type) {\n case 'update':\n actionToResolve = updateAction({\n action: actionConfig,\n ...baseParams,\n actionParams: {\n ...baseParams.actionParams,\n item: entity,\n },\n });\n break;\n case 'custom':\n actionToResolve = customAction({\n action: actionConfig,\n ...baseParams,\n });\n break;\n default:\n return null;\n }\n\n if (!actionToResolve || actionToResolve.hidden) {\n return null;\n }\n\n const resolved = resolveAction(\n actionConfig,\n actionToResolve,\n ) as ResolvedAction;\n\n return {\n onClick: resolved.onClick,\n text: resolved.label,\n prefixIcon: resolved.icon,\n disabled: resolved.disabled,\n };\n };\n\n const actionGroups = groupActions(moreActions);\n return actionGroups\n .map((group) =>\n group\n .map(buildAction)\n .filter((action): action is MoreActionsItem => Boolean(action)),\n )\n .filter((group) => group.length > 0);\n }, [moreActions, sdk, entity, form]);\n\n return buildEntityPageActions() ?? [];\n}\n"],"mappings":";;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AASO,SAASE,wBAAwBA,CACtCC,WAEa,EACbC,MAA2B,EAC3BC,GAAe,EACfC,IAAiD,EACjD;EACA,MAAMC,sBAAsB,GAAG,IAAAC,kBAAW,EAAC,MAAM;IAC/C,IAAI,CAACL,WAAW,EAAE;MAChB;IACF;IAEA,MAAMM,WAAW,GACfC,YAAqD,IAC1B;MAC3B,IAAIC,eAA+C,GAAG,IAAI;MAC1D,MAAMC,UAAU,GAAG;QACjBC,YAAY,EAAE;UAAET,MAAM;UAAEE;QAAK,CAAC;QAC9BD;MACF,CAAC;MAED,QAAQK,YAAY,CAACI,IAAI;QACvB,KAAK,QAAQ;UACXH,eAAe,GAAG,IAAAI,qBAAY,EAAC;YAC7BC,MAAM,EAAEN,YAAY;YACpB,GAAGE,UAAU;YACbC,YAAY,EAAE;cACZ,GAAGD,UAAU,CAACC,YAAY;cAC1BI,IAAI,EAAEb;YACR;UACF,CAAC,CAAC;UACF;QACF,KAAK,QAAQ;UACXO,eAAe,GAAG,IAAAO,qBAAY,EAAC;YAC7BF,MAAM,EAAEN,YAAY;YACpB,GAAGE;UACL,CAAC,CAAC;UACF;QACF;UACE,OAAO,IAAI;MACf;MAEA,IAAI,CAACD,eAAe,IAAIA,eAAe,CAACQ,MAAM,EAAE;QAC9C,OAAO,IAAI;MACb;MAEA,MAAMC,QAAQ,GAAG,IAAAC,sBAAa,EAC5BX,YAAY,EACZC,eACF,CAAmB;MAEnB,OAAO;QACLW,OAAO,EAAEF,QAAQ,CAACE,OAAO;QACzBC,IAAI,EAAEH,QAAQ,CAACI,KAAK;QACpBC,UAAU,EAAEL,QAAQ,CAACM,IAAI;QACzBC,QAAQ,EAAEP,QAAQ,CAACO;MACrB,CAAC;IACH,CAAC;IAED,MAAMC,YAAY,GAAG,IAAAC,qBAAY,EAAC1B,WAAW,CAAC;IAC9C,OAAOyB,YAAY,CAChBE,GAAG,CAAEC,KAAK,IACTA,KAAK,CACFD,GAAG,CAACrB,WAAW,CAAC,CAChBuB,MAAM,CAAEhB,MAAM,IAAgCiB,OAAO,CAACjB,MAAM,CAAC,CAClE,CAAC,CACAgB,MAAM,CAAED,KAAK,IAAKA,KAAK,CAACG,MAAM,GAAG,CAAC,CAAC;EACxC,CAAC,EAAE,CAAC/B,WAAW,EAAEE,GAAG,EAAED,MAAM,EAAEE,IAAI,CAAC,CAAC;EAEpC,OAAOC,sBAAsB,CAAC,CAAC,IAAI,EAAE;AACvC","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useNavigateEditEntityAction = void 0;
|
|
5
|
+
var _react = require("react");
|
|
6
|
+
var _providers = require("../providers");
|
|
7
|
+
const useNavigateEditEntityAction = ({
|
|
8
|
+
displayName,
|
|
9
|
+
configuration
|
|
10
|
+
}) => {
|
|
11
|
+
var _configuration$action3;
|
|
12
|
+
const appConfig = (0, _providers.useAppConfigContext)();
|
|
13
|
+
const editPageId = (0, _react.useMemo)(() => {
|
|
14
|
+
// Find edit page by matching collectionId and looking for edit mode
|
|
15
|
+
const editPage = appConfig.pages.find(page => {
|
|
16
|
+
if (page.type !== 'entityPage') {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const entityPage = page.entityPage;
|
|
20
|
+
// Check if same collection and is edit mode (either no mode specified or mode: 'edit')
|
|
21
|
+
return entityPage.collectionId === configuration.collectionId && (!entityPage.mode || entityPage.mode === 'edit');
|
|
22
|
+
});
|
|
23
|
+
return editPage == null ? void 0 : editPage.id;
|
|
24
|
+
}, [appConfig.pages, configuration.collectionId]);
|
|
25
|
+
return (0, _react.useMemo)(() => {
|
|
26
|
+
var _configuration$action2;
|
|
27
|
+
// Don't show edit action if no edit page is found
|
|
28
|
+
if (!editPageId) {
|
|
29
|
+
var _configuration$action;
|
|
30
|
+
return ((_configuration$action = configuration.actions) == null ? void 0 : _configuration$action.moreActions) || [];
|
|
31
|
+
}
|
|
32
|
+
const navigateToEditAction = {
|
|
33
|
+
id: 'navigate-to-edit',
|
|
34
|
+
label: `Edit ${displayName}`,
|
|
35
|
+
type: 'update',
|
|
36
|
+
update: {
|
|
37
|
+
mode: 'page',
|
|
38
|
+
page: {
|
|
39
|
+
id: editPageId
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
if (!((_configuration$action2 = configuration.actions) != null && _configuration$action2.moreActions)) {
|
|
44
|
+
return [navigateToEditAction];
|
|
45
|
+
}
|
|
46
|
+
return [navigateToEditAction, ...configuration.actions.moreActions];
|
|
47
|
+
}, [(_configuration$action3 = configuration.actions) == null ? void 0 : _configuration$action3.moreActions, displayName, editPageId]);
|
|
48
|
+
};
|
|
49
|
+
exports.useNavigateEditEntityAction = useNavigateEditEntityAction;
|
|
50
|
+
//# sourceMappingURL=useNavigateEditEntityAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_providers","useNavigateEditEntityAction","displayName","configuration","_configuration$action3","appConfig","useAppConfigContext","editPageId","useMemo","editPage","pages","find","page","type","entityPage","collectionId","mode","id","_configuration$action2","_configuration$action","actions","moreActions","navigateToEditAction","label","update","exports"],"sources":["../../../src/hooks/useNavigateEditEntityAction.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { UpdateActionConfig, ViewEntityPageConfig } from '../types';\nimport { useAppConfigContext } from '../providers';\n\nexport const useNavigateEditEntityAction = ({\n displayName,\n configuration,\n}: {\n displayName: string;\n configuration: ViewEntityPageConfig;\n}) => {\n const appConfig = useAppConfigContext();\n\n const editPageId = useMemo(() => {\n // Find edit page by matching collectionId and looking for edit mode\n const editPage = appConfig.pages.find((page) => {\n if (page.type !== 'entityPage') {\n return false;\n }\n\n const entityPage = page.entityPage;\n // Check if same collection and is edit mode (either no mode specified or mode: 'edit')\n return (\n entityPage.collectionId === configuration.collectionId &&\n (!entityPage.mode || entityPage.mode === 'edit')\n );\n });\n\n return editPage?.id;\n }, [appConfig.pages, configuration.collectionId]);\n\n return useMemo(() => {\n // Don't show edit action if no edit page is found\n if (!editPageId) {\n return configuration.actions?.moreActions || [];\n }\n\n const navigateToEditAction: UpdateActionConfig = {\n id: 'navigate-to-edit',\n label: `Edit ${displayName}`,\n type: 'update',\n update: {\n mode: 'page',\n page: {\n id: editPageId,\n },\n },\n };\n\n if (!configuration.actions?.moreActions) {\n return [navigateToEditAction];\n }\n return [navigateToEditAction, ...configuration.actions.moreActions];\n }, [configuration.actions?.moreActions, displayName, editPageId]);\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEO,MAAME,2BAA2B,GAAGA,CAAC;EAC1CC,WAAW;EACXC;AAIF,CAAC,KAAK;EAAA,IAAAC,sBAAA;EACJ,MAAMC,SAAS,GAAG,IAAAC,8BAAmB,EAAC,CAAC;EAEvC,MAAMC,UAAU,GAAG,IAAAC,cAAO,EAAC,MAAM;IAC/B;IACA,MAAMC,QAAQ,GAAGJ,SAAS,CAACK,KAAK,CAACC,IAAI,CAAEC,IAAI,IAAK;MAC9C,IAAIA,IAAI,CAACC,IAAI,KAAK,YAAY,EAAE;QAC9B,OAAO,KAAK;MACd;MAEA,MAAMC,UAAU,GAAGF,IAAI,CAACE,UAAU;MAClC;MACA,OACEA,UAAU,CAACC,YAAY,KAAKZ,aAAa,CAACY,YAAY,KACrD,CAACD,UAAU,CAACE,IAAI,IAAIF,UAAU,CAACE,IAAI,KAAK,MAAM,CAAC;IAEpD,CAAC,CAAC;IAEF,OAAOP,QAAQ,oBAARA,QAAQ,CAAEQ,EAAE;EACrB,CAAC,EAAE,CAACZ,SAAS,CAACK,KAAK,EAAEP,aAAa,CAACY,YAAY,CAAC,CAAC;EAEjD,OAAO,IAAAP,cAAO,EAAC,MAAM;IAAA,IAAAU,sBAAA;IACnB;IACA,IAAI,CAACX,UAAU,EAAE;MAAA,IAAAY,qBAAA;MACf,OAAO,EAAAA,qBAAA,GAAAhB,aAAa,CAACiB,OAAO,qBAArBD,qBAAA,CAAuBE,WAAW,KAAI,EAAE;IACjD;IAEA,MAAMC,oBAAwC,GAAG;MAC/CL,EAAE,EAAE,kBAAkB;MACtBM,KAAK,EAAE,QAAQrB,WAAW,EAAE;MAC5BW,IAAI,EAAE,QAAQ;MACdW,MAAM,EAAE;QACNR,IAAI,EAAE,MAAM;QACZJ,IAAI,EAAE;UACJK,EAAE,EAAEV;QACN;MACF;IACF,CAAC;IAED,IAAI,GAAAW,sBAAA,GAACf,aAAa,CAACiB,OAAO,aAArBF,sBAAA,CAAuBG,WAAW,GAAE;MACvC,OAAO,CAACC,oBAAoB,CAAC;IAC/B;IACA,OAAO,CAACA,oBAAoB,EAAE,GAAGnB,aAAa,CAACiB,OAAO,CAACC,WAAW,CAAC;EACrE,CAAC,EAAE,EAAAjB,sBAAA,GAACD,aAAa,CAACiB,OAAO,qBAArBhB,sBAAA,CAAuBiB,WAAW,EAAEnB,WAAW,EAAEK,UAAU,CAAC,CAAC;AACnE,CAAC;AAACkB,OAAA,CAAAxB,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
@@ -9,7 +9,8 @@ var _reactRouterDom = require("react-router-dom");
|
|
|
9
9
|
var _usePagePath = require("./usePagePath");
|
|
10
10
|
const useNavigation = () => {
|
|
11
11
|
const {
|
|
12
|
-
navigateToEntityPage: navigateToEntityPagePatterns
|
|
12
|
+
navigateToEntityPage: navigateToEntityPagePatterns,
|
|
13
|
+
navigateToCollectionPage: navigateToCollectionPagePatterns
|
|
13
14
|
} = (0, _router.usePatternsNavigate)();
|
|
14
15
|
const appConfig = (0, _providers.useAppConfigContext)();
|
|
15
16
|
const {
|
|
@@ -42,11 +43,21 @@ const useNavigation = () => {
|
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
}, [appConfig, navigateToEntityPagePatterns, getSchema]);
|
|
46
|
+
const navigateToCollectionPage = (0, _react.useCallback)(parentPageId => {
|
|
47
|
+
const parentPagePath = getPagePath(parentPageId);
|
|
48
|
+
if (!parentPagePath) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
navigateToCollectionPagePatterns({
|
|
52
|
+
path: parentPagePath
|
|
53
|
+
});
|
|
54
|
+
}, [navigateToCollectionPagePatterns, getPagePath]);
|
|
45
55
|
const getParentPagePath = (0, _react.useCallback)(parentPageId => {
|
|
46
56
|
return getPagePath(parentPageId);
|
|
47
57
|
}, [getPagePath]);
|
|
48
58
|
return {
|
|
49
59
|
navigateToEntityPage,
|
|
60
|
+
navigateToCollectionPage,
|
|
50
61
|
getParentPagePath,
|
|
51
62
|
getPagePath
|
|
52
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_router","_providers","_reactRouterDom","_usePagePath","useNavigation","navigateToEntityPage","navigateToEntityPagePatterns","usePatternsNavigate","appConfig","useAppConfigContext","getSchema","useSchemaRegistry","getPagePath","usePagePath","useCallback","item","entityPageId","_route$params","entityPage","pages","find","page","id","route","collectionId","schema","path","params","generatePath","idField","entity","
|
|
1
|
+
{"version":3,"names":["_react","require","_router","_providers","_reactRouterDom","_usePagePath","useNavigation","navigateToEntityPage","navigateToEntityPagePatterns","navigateToCollectionPage","navigateToCollectionPagePatterns","usePatternsNavigate","appConfig","useAppConfigContext","getSchema","useSchemaRegistry","getPagePath","usePagePath","useCallback","item","entityPageId","_route$params","entityPage","pages","find","page","id","route","collectionId","schema","path","params","generatePath","idField","entity","parentPageId","parentPagePath","getParentPagePath","exports"],"sources":["../../../src/hooks/useNavigationUtils.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { usePatternsNavigate } from '@wix/patterns/router';\nimport { useAppConfigContext, useSchemaRegistry } from '../providers';\nimport { generatePath } from 'react-router-dom';\nimport { EntityPageConfig } from '../types';\nimport { usePagePath } from './usePagePath';\n\nexport type NavigateToEntityPageFunc = (args: {\n item: any;\n entityPageId?: string;\n}) => void;\n\nexport const useNavigation = () => {\n const {\n navigateToEntityPage: navigateToEntityPagePatterns,\n navigateToCollectionPage: navigateToCollectionPagePatterns,\n } = usePatternsNavigate();\n const appConfig = useAppConfigContext();\n const { getSchema } = useSchemaRegistry();\n const { getPagePath } = usePagePath(appConfig);\n\n const navigateToEntityPage = useCallback(\n ({ item, entityPageId }) => {\n const entityPage = entityPageId\n ? appConfig.pages.find((page) => page.id === entityPageId)\n : null;\n\n if (!entityPage) {\n return;\n }\n\n const { route, collectionId } = entityPage.entityPage as EntityPageConfig;\n const schema = getSchema(collectionId);\n if (route.path && route.params?.id && schema) {\n const path = generatePath(route.path, {\n [route.params.id]: item?.[schema.idField] ?? '',\n });\n navigateToEntityPagePatterns({\n path,\n entity: item,\n });\n }\n },\n [appConfig, navigateToEntityPagePatterns, getSchema],\n );\n\n const navigateToCollectionPage = useCallback(\n (parentPageId: string) => {\n const parentPagePath = getPagePath(parentPageId);\n if (!parentPagePath) {\n return;\n }\n navigateToCollectionPagePatterns({\n path: parentPagePath,\n });\n },\n [navigateToCollectionPagePatterns, getPagePath],\n );\n\n const getParentPagePath = useCallback(\n (parentPageId?: string): string | undefined => {\n return getPagePath(parentPageId);\n },\n [getPagePath],\n );\n\n return {\n navigateToEntityPage,\n navigateToCollectionPage,\n getParentPagePath,\n getPagePath,\n };\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,OAAA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AI;QACJI,MAAM,EAAEf;MACV,CAAC,CAAC;IACJ;EACF,CAAC,EACD,CAACP,SAAS,EAAEJ,4BAA4B,EAAEM,SAAS,CACrD,CAAC;EAED,MAAML,wBAAwB,GAAG,IAAAS,kBAAW,EACzCiB,YAAoB,IAAK;IACxB,MAAMC,cAAc,GAAGpB,WAAW,CAACmB,YAAY,CAAC;IAChD,IAAI,CAACC,cAAc,EAAE;MACnB;IACF;IACA1B,gCAAgC,CAAC;MAC/BoB,IAAI,EAAEM;IACR,CAAC,CAAC;EACJ,CAAC,EACD,CAAC1B,gCAAgC,EAAEM,WAAW,CAChD,CAAC;EAED,MAAMqB,iBAAiB,GAAG,IAAAnB,kBAAW,EAClCiB,YAAqB,IAAyB;IAC7C,OAAOnB,WAAW,CAACmB,YAAY,CAAC;EAClC,CAAC,EACD,CAACnB,WAAW,CACd,CAAC;EAED,OAAO;IACLT,oBAAoB;IACpBE,wBAAwB;IACxB4B,iBAAiB;IACjBrB;EACF,CAAC;AACH,CAAC;AAACsB,OAAA,CAAAhC,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.useError = exports.ErrorProvider = void 0;
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _patterns = require("@wix/patterns");
|
|
7
|
+
var _essentials = require("@wix/essentials");
|
|
7
8
|
var _jsxFileName = "/home/builduser/work/73d19ce3378ce4dd/packages/auto-patterns/dist/cjs/providers/ErrorContext.tsx";
|
|
8
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -29,12 +30,14 @@ const ErrorProvider = ({
|
|
|
29
30
|
});
|
|
30
31
|
}, []);
|
|
31
32
|
if (errorState.hasError && errorState.error) {
|
|
33
|
+
const subtitle = _essentials.errorHandler.getResolvedError(errorState.error).message;
|
|
32
34
|
return /*#__PURE__*/_react.default.createElement(_patterns.PageErrorState, {
|
|
33
|
-
subtitle:
|
|
35
|
+
subtitle: subtitle,
|
|
36
|
+
dataHook: "error-page",
|
|
34
37
|
__self: void 0,
|
|
35
38
|
__source: {
|
|
36
39
|
fileName: _jsxFileName,
|
|
37
|
-
lineNumber:
|
|
40
|
+
lineNumber: 57,
|
|
38
41
|
columnNumber: 12
|
|
39
42
|
}
|
|
40
43
|
});
|
|
@@ -47,7 +50,7 @@ const ErrorProvider = ({
|
|
|
47
50
|
__self: void 0,
|
|
48
51
|
__source: {
|
|
49
52
|
fileName: _jsxFileName,
|
|
50
|
-
lineNumber:
|
|
53
|
+
lineNumber: 61,
|
|
51
54
|
columnNumber: 5
|
|
52
55
|
}
|
|
53
56
|
}, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_patterns","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ErrorContext","createContext","undefined","ErrorProvider","children","errorState","setErrorState","useState","hasError","error","showError","useCallback","errorObj","Error","clearError","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_patterns","_essentials","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ErrorContext","createContext","undefined","ErrorProvider","children","errorState","setErrorState","useState","hasError","error","showError","useCallback","errorObj","Error","clearError","subtitle","errorHandler","getResolvedError","message","createElement","PageErrorState","dataHook","__self","__source","fileName","lineNumber","columnNumber","Provider","value","exports","useError","context","useContext"],"sources":["../../../src/providers/ErrorContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useState,\n useCallback,\n ReactNode,\n} from 'react';\nimport { PageErrorState } from '@wix/patterns';\nimport { errorHandler } from '@wix/essentials';\n\nexport interface ErrorResponse extends Error {\n details: {\n applicationError: {\n description: string;\n };\n };\n}\n\ninterface ErrorState {\n hasError: boolean;\n error: Error | null;\n}\n\ninterface ErrorContextType {\n showError: (error: Error) => void;\n clearError: () => void;\n}\n\nconst ErrorContext = createContext<ErrorContextType | undefined>(undefined);\n\nexport const ErrorProvider: React.FC<{ children: ReactNode }> = ({\n children,\n}) => {\n const [errorState, setErrorState] = useState<ErrorState>({\n hasError: false,\n error: null,\n });\n\n const showError = useCallback((error: Error | string) => {\n const errorObj = typeof error === 'string' ? new Error(error) : error;\n setErrorState({\n hasError: true,\n error: errorObj,\n });\n }, []);\n\n const clearError = useCallback(() => {\n setErrorState({\n hasError: false,\n error: null,\n });\n }, []);\n\n if (errorState.hasError && errorState.error) {\n const subtitle = errorHandler.getResolvedError(errorState.error).message;\n\n return <PageErrorState subtitle={subtitle} dataHook=\"error-page\" />;\n }\n\n return (\n <ErrorContext.Provider value={{ showError, clearError }}>\n {children}\n </ErrorContext.Provider>\n );\n};\n\nexport const useError = (): ErrorContextType => {\n const context = useContext(ErrorContext);\n if (!context) {\n throw new Error('useError must be used within an ErrorProvider');\n }\n return context;\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAA+C,IAAAG,YAAA;AAAA,SAAAC,yBAAAC,CAAA,6B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A,KAAwB;EAC9C,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAAChC,YAAY,CAAC;EACxC,IAAI,CAAC+B,OAAO,EAAE;IACZ,MAAM,IAAIlB,KAAK,CAAC,+CAA+C,CAAC;EAClE;EACA,OAAOkB,OAAO;AAChB,CAAC;AAACF,OAAA,CAAAC,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","PatternsWizardOverridesContext","createContext","undefined","PatternsWizardOverridesProvider","children","value","createElement","Provider","__self","__source","fileName","lineNumber","columnNumber","exports","usePatternsWizardOverridesContext","useContext"],"sources":["../../../src/providers/PatternsWizardOverridesContext.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode } from 'react';\nimport {\n CustomComponentProps,\n
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","PatternsWizardOverridesContext","createContext","undefined","PatternsWizardOverridesProvider","children","value","createElement","Provider","__self","__source","fileName","lineNumber","columnNumber","exports","usePatternsWizardOverridesContext","useContext"],"sources":["../../../src/providers/PatternsWizardOverridesContext.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode } from 'react';\nimport {\n CustomComponentProps,\n CustomActionCellPrimaryActionResolver,\n CustomActionCellSecondaryActionResolver,\n CustomEntityPageActionResolver,\n CustomBulkActionsActionResolver,\n CustomActionCollectionPageActionResolver,\n CustomActionCollectionPageActionOnRowClickResolver,\n IColumnValue,\n SchemaConfig,\n} from '../types';\n\nimport { Section } from '@wix/patterns';\n\nexport interface PatternsWizardOverridesContextProps {\n actions?: Record<\n string,\n | CustomActionCellPrimaryActionResolver\n | CustomActionCellSecondaryActionResolver\n | CustomBulkActionsActionResolver\n | CustomEntityPageActionResolver\n | CustomActionCollectionPageActionResolver\n | CustomActionCollectionPageActionOnRowClickResolver\n >;\n columns?: Record<string, (props: IColumnValue<any>) => void>;\n modals?: Record<string, React.FC<any>>;\n emptyState?: Record<string, () => void>;\n components?: Record<string, React.FC<CustomComponentProps>>;\n slots?: Record<string, React.FC>;\n customDataSources?: Record<\n string,\n (collectionId: string, context: any) => Promise<SchemaConfig>\n >;\n sections?: Record<string, (item: any) => Section>;\n}\n\nconst PatternsWizardOverridesContext = createContext<\n PatternsWizardOverridesContextProps | undefined\n>(undefined);\n\nexport const PatternsWizardOverridesProvider: React.FC<{\n children: ReactNode;\n value: PatternsWizardOverridesContextProps;\n}> = ({ children, value }) => {\n return (\n <PatternsWizardOverridesContext.Provider value={value}>\n {children}\n </PatternsWizardOverridesContext.Provider>\n );\n};\n\nexport const usePatternsWizardOverridesContext = ():\n | PatternsWizardOverridesContextProps\n | undefined => {\n return useContext(PatternsWizardOverridesContext);\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAoE,IAAAC,YAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAA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ig.ts"],"sourcesContent":["import { FieldValues, UseFormReturn } from '@wix/patterns/form';\nimport {
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/types/EntityPageConfig.ts"],"sourcesContent":["import { FieldValues, UseFormReturn } from '@wix/patterns/form';\nimport {\n EntityPageMoreActions,\n EntityPagePrimaryActions,\n EntityPageSecondaryActions,\n} from './actions/entityPageActions';\nimport { BaseCollectionConfig } from './types';\n\nexport type EntityPageBaseConfig = {\n route: {\n path: string;\n params: {\n id: string;\n };\n };\n title?: {\n text: string;\n };\n subtitle?: {\n text: string;\n learnMore?: {\n url: string;\n label?: string;\n };\n };\n parentPageId?: string;\n layout?: {\n main: CardLayout[];\n sidebar?: CardLayout[];\n };\n} & BaseCollectionConfig;\n\nexport type EditEntityPageConfig = EntityPageBaseConfig & {\n mode?: 'edit';\n actions?: {\n primaryActions?: never;\n secondaryActions?: never;\n moreActions?: EntityPageMoreActions;\n };\n};\n\nexport type ViewEntityPageConfig = EntityPageBaseConfig & {\n mode: 'view';\n actions?: {\n primaryActions?: EntityPagePrimaryActions;\n secondaryActions?: EntityPageSecondaryActions;\n moreActions?: EntityPageMoreActions;\n };\n};\n\nexport type EntityPageConfig = EditEntityPageConfig | ViewEntityPageConfig;\n\nexport interface CardLayout {\n type: 'card';\n card: {\n title: {\n text: string;\n };\n subtitle?: {\n text: string;\n };\n children: LayoutContent[];\n };\n}\n\nexport type LayoutContent =\n | FieldContent\n | ContainerContent\n | ComponentItemContent;\n\ninterface FieldContent {\n type: 'field';\n field: {\n span?: number;\n fieldId: string;\n };\n}\n\ninterface ContainerContent {\n type: 'container';\n container: {\n span?: number;\n children: LayoutContent[];\n };\n}\n\ninterface ComponentItemContent {\n type: 'component';\n component: {\n span?: number;\n componentId: string;\n };\n}\n\nexport interface CustomComponentProps {\n entity?: Record<string, any>;\n form?: UseFormReturn<FieldValues, any, undefined>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../../src/types/actions/actionCell.ts"],"sourcesContent":["import {\n CustomActionModalProps,\n CustomActionParams,\n ResolvedAction,\n} from '../../exports/types';\nimport {\n CustomActionConfig,\n DeleteActionConfig,\n UpdateActionConfig,\n DividerActionConfig,\n} from './base';\n\nexport type ActionCellItemConfig =\n | UpdateActionConfig\n | CustomActionConfig\n | DeleteActionConfig;\n\nexport interface ActionCellPrimaryAction {\n item: ActionCellItemConfig;\n alwaysVisible?: boolean;\n}\n\nexport interface ActionCellSecondaryActions {\n items: (ActionCellItemConfig | DividerActionConfig)[];\n inlineCount?: number;\n inlineAlwaysVisible?: boolean;\n}\n\nexport interface ActionCellConfig {\n primaryAction?: ActionCellPrimaryAction;\n secondaryActions?: ActionCellSecondaryActions;\n}\n\nexport interface ActionCellActionParams {\n item: any;\n}\n\nexport type CustomActionCellActionParams =\n CustomActionParams<ActionCellActionParams>;\n\nexport type
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/types/actions/actionCell.ts"],"sourcesContent":["import {\n CustomActionModalProps,\n CustomActionParams,\n ResolvedAction,\n} from '../../exports/types';\nimport {\n CustomActionConfig,\n DeleteActionConfig,\n UpdateActionConfig,\n DividerActionConfig,\n} from './base';\nimport { IconElement } from '@wix/design-system';\n\nexport type ActionCellItemConfig =\n | UpdateActionConfig\n | CustomActionConfig\n | DeleteActionConfig;\n\nexport interface ActionCellPrimaryAction {\n item: ActionCellItemConfig;\n alwaysVisible?: boolean;\n}\n\nexport interface ActionCellSecondaryActions {\n items: (ActionCellItemConfig | DividerActionConfig)[];\n inlineCount?: number;\n inlineAlwaysVisible?: boolean;\n}\n\nexport interface ActionCellConfig {\n primaryAction?: ActionCellPrimaryAction;\n secondaryActions?: ActionCellSecondaryActions;\n}\n\nexport interface ResolvedActionCellPrimaryAction\n extends Omit<ResolvedAction, 'icon'> {\n prefixIcon?: IconElement;\n suffixIcon?: IconElement;\n}\n\nexport interface ActionCellActionParams {\n item: any;\n}\n\nexport type CustomActionCellActionParams =\n CustomActionParams<ActionCellActionParams>;\n\nexport type CustomActionCellPrimaryActionResolver = (\n params: CustomActionCellActionParams,\n) => ResolvedActionCellPrimaryAction;\n\nexport type CustomActionCellSecondaryActionResolver = (\n params: CustomActionCellActionParams,\n) => ResolvedAction;\n\nexport interface CustomActionCellActionModalProps\n extends CustomActionModalProps {\n actionParams: ActionCellActionParams;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../../src/types/actions/entityPageActions.ts"],"sourcesContent":["import { FieldValues, UseFormReturn } from '@wix/patterns/form';\nimport { CustomActionParams, ResolvedAction } from '../..';\nimport {
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/types/actions/entityPageActions.ts"],"sourcesContent":["import { FieldValues, UseFormReturn } from '@wix/patterns/form';\nimport { CustomActionParams, ResolvedAction } from '../..';\nimport {\n CreateActionConfig,\n CustomActionConfig,\n DividerActionConfig,\n} from './base';\n\nexport type EntityPageMoreActions = (\n | CustomActionConfig\n | DividerActionConfig\n)[];\n\nexport type EntityPageActionConfig = CreateActionConfig | CustomActionConfig;\n\ntype EntityPageAction = {\n type: 'action';\n action: {\n item: EntityPageActionConfig;\n };\n menu?: never;\n};\n\ntype EntityPageMenu = {\n type: 'menu';\n menu: {\n label: string;\n items: (EntityPageActionConfig | DividerActionConfig)[];\n };\n action?: never;\n};\n\nexport type EntityPagePrimaryActions = EntityPageAction | EntityPageMenu;\nexport type EntityPageSecondaryActions = EntityPageAction | EntityPageMenu;\n\nexport interface EntityPageActionParams {\n entity: any;\n form?: UseFormReturn<FieldValues, any, undefined>;\n}\n\nexport type CustomEntityPageActionParams =\n CustomActionParams<EntityPageActionParams>;\n\nexport type CustomEntityPageActionResolver = (\n params: CustomEntityPageActionParams,\n) => ResolvedAction;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../../src/utils/actions/types.ts"],"sourcesContent":["import { ActionCellAPI, CollectionOptimisticActions } from '@wix/patterns';\nimport {\n UpdateActionConfig,\n CustomActionConfig,\n SchemaConfig,\n BulkDeleteActionConfig,\n DeleteActionConfig,\n CreateActionConfig,\n BaseSDK,\n} from '../../types';\nimport { IconElement } from '@wix/design-system';\n\nexport interface ResolvedAction {\n label: string;\n icon: IconElement;\n onClick: () => void;\n disabled?: boolean;\n tooltip?: string;\n skin?: string;\n}\n\nexport interface BaseContextParams {\n schema: SchemaConfig;\n}\n\nexport interface ActionsSDK extends BaseSDK {\n getSchema: (collectionId: string) => SchemaConfig | undefined;\n collectionId: string; // TODO: Why collectionId is needed here? getSchema with internal collectionId is enough\n getOptimisticActions: (\n collectionId: string,\n ) => CollectionOptimisticActions<any, any>;\n}\n\nexport interface BaseActionParams<T = Record<string, any>> {\n sdk: ActionsSDK;\n actionParams: T;\n}\n\nexport interface ActionCellBaseParams extends BaseActionParams {\n actionParams: {\n item: any;\n index: number;\n api: ActionCellAPI<any, any>;\n };\n}\n\nexport interface BulkDeleteActionParams extends BaseActionParams {\n action: BulkDeleteActionConfig;\n actionParams: {\n selectedValues: any[];\n total: number;\n };\n}\n\nexport interface DeleteActionParams extends ActionCellBaseParams {\n action: DeleteActionConfig;\n}\n\nexport interface UpdateActionParams extends
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/utils/actions/types.ts"],"sourcesContent":["import { ActionCellAPI, CollectionOptimisticActions } from '@wix/patterns';\nimport {\n UpdateActionConfig,\n CustomActionConfig,\n SchemaConfig,\n BulkDeleteActionConfig,\n DeleteActionConfig,\n CreateActionConfig,\n BaseSDK,\n} from '../../types';\nimport { IconElement } from '@wix/design-system';\n\nexport interface ResolvedAction {\n label: string;\n icon: IconElement;\n onClick: () => void;\n disabled?: boolean;\n hidden?: boolean;\n tooltip?: string;\n skin?: string;\n}\n\nexport interface BaseContextParams {\n schema: SchemaConfig;\n}\n\nexport interface ActionsSDK extends BaseSDK {\n getSchema: (collectionId: string) => SchemaConfig | undefined;\n collectionId: string; // TODO: Why collectionId is needed here? getSchema with internal collectionId is enough\n getOptimisticActions: (\n collectionId: string,\n ) => CollectionOptimisticActions<any, any>;\n}\n\nexport interface BaseActionParams<T = Record<string, any>> {\n sdk: ActionsSDK;\n actionParams: T;\n}\n\nexport interface ActionCellBaseParams extends BaseActionParams {\n actionParams: {\n item: any;\n index: number;\n api: ActionCellAPI<any, any>;\n };\n}\n\nexport interface BulkDeleteActionParams extends BaseActionParams {\n action: BulkDeleteActionConfig;\n actionParams: {\n selectedValues: any[];\n total: number;\n };\n}\n\nexport interface DeleteActionParams extends ActionCellBaseParams {\n action: DeleteActionConfig;\n}\n\nexport interface UpdateActionParams extends BaseActionParams {\n action: UpdateActionConfig;\n}\n\nexport interface CreateActionParams extends BaseActionParams {\n action: CreateActionConfig;\n}\n\nexport interface CustomActionParams<T> extends BaseActionParams<T> {\n action: CustomActionConfig;\n}\n\nexport interface ActionModalProps {\n modalParams: Record<string, any>;\n actionParams: Record<string, any>;\n sdk: ActionsSDK;\n}\n\nexport interface CustomActionModalProps extends ActionModalProps {\n modalParams: { id: string };\n}\n"],"mappings":"","ignoreList":[]}
|
package/dist/docs/action_cell.md
CHANGED
|
@@ -109,12 +109,12 @@ Custom actions execute JavaScript code that you define. These actions receive pa
|
|
|
109
109
|
|
|
110
110
|
2. Create your action handler in `downloadPetDetails.tsx` (note: the filename and function name MUST match your action id):
|
|
111
111
|
```typescript
|
|
112
|
-
import {
|
|
112
|
+
import { CustomActionCellSecondaryActionResolver } from '@wix/auto-patterns';
|
|
113
113
|
import { Download } from '@wix/wix-ui-icons-common';
|
|
114
114
|
import React from 'react';
|
|
115
115
|
|
|
116
116
|
// IMPORTANT: Function name MUST match the action id in your configuration
|
|
117
|
-
export const downloadPetDetails:
|
|
117
|
+
export const downloadPetDetails: CustomActionCellSecondaryActionResolver = (params) => {
|
|
118
118
|
const { actionParams, sdk } = params;
|
|
119
119
|
const { item } = actionParams;
|
|
120
120
|
|
|
@@ -131,11 +131,15 @@ Custom actions execute JavaScript code that you define. These actions receive pa
|
|
|
131
131
|
optimisticActions.updateOne(updatedItem, {
|
|
132
132
|
submit: async (items) => {
|
|
133
133
|
// Your download logic here + update server
|
|
134
|
-
|
|
134
|
+
// Handle potential undefined schema
|
|
135
|
+
if (schema) {
|
|
136
|
+
return await schema.actions.update(items[0]);
|
|
137
|
+
}
|
|
138
|
+
return items[0]; // fallback when schema is unavailable
|
|
135
139
|
},
|
|
136
140
|
successToast: 'Pet details downloaded',
|
|
137
141
|
errorToast: (err, {retry}) => ({
|
|
138
|
-
|
|
142
|
+
message: 'Download failed',
|
|
139
143
|
action: { text: 'Retry', onClick: retry }
|
|
140
144
|
})
|
|
141
145
|
});
|
|
@@ -186,7 +190,7 @@ Custom actions execute JavaScript code that you define. These actions receive pa
|
|
|
186
190
|
- The action `id` in the configuration MUST exactly match the function name exported from your actions folder
|
|
187
191
|
- The function name and file name should follow a consistent naming convention (e.g., camelCase)
|
|
188
192
|
- The implementation must be exported as a named export (not default export)
|
|
189
|
-
- The implementation must use
|
|
193
|
+
- The implementation must use either `CustomActionCellPrimaryActionResolver` or `CustomActionCellSecondaryActionResolver` type depending on your use case
|
|
190
194
|
|
|
191
195
|
#### Validation Rules for Custom Actions:
|
|
192
196
|
|
|
@@ -199,9 +203,10 @@ Custom actions execute JavaScript code that you define. These actions receive pa
|
|
|
199
203
|
- `label`: Text displayed for the action
|
|
200
204
|
- `icon`: An Icon component from "@wix/wix-ui-icons-common"
|
|
201
205
|
- `onClick`: Handler function for the action
|
|
206
|
+
- `hidden` (optional): Boolean to hide the action when true
|
|
202
207
|
|
|
203
208
|
3. The implementation must:
|
|
204
|
-
- Use the correct type: `
|
|
209
|
+
- Use the correct type: `CustomActionCellPrimaryActionResolver` for primary actions (with prefixIcon/suffixIcon) or `CustomActionCellSecondaryActionResolver` for secondary actions (with icon)
|
|
205
210
|
- Be exported as a named export
|
|
206
211
|
- Have a filename matching the function name
|
|
207
212
|
|
|
@@ -17,6 +17,13 @@
|
|
|
17
17
|
- Not designating exactly one page as `appMainPage: true`
|
|
18
18
|
- Missing or inconsistent page relationships (parentPageId/entityPageId)
|
|
19
19
|
- Setting `stickyColumns` to invalid values (negative, zero, or exceeding column count)
|
|
20
|
+
- **Missing custom property**: When `entityTypeSource: 'custom'`, forgetting to include the required `custom: { id: "..." }` property will cause TypeScript errors
|
|
21
|
+
- **Using incorrect field types**: Mismatching page type with configuration object (e.g., `type: 'entityPage'` with `collectionPage` field)
|
|
22
|
+
- **Including fields from wrong page type**: Adding both `collectionPage` and `entityPage` fields in the same page configuration
|
|
23
|
+
- **Missing action layout properties**: Not including `action` property when `type: 'action'` or `menu` property when `type: 'menu'`
|
|
24
|
+
- **Missing action type properties**: Not including `create`, `update`, `delete`, or `bulkDelete` properties when required by the action type
|
|
25
|
+
- **Including wrong action properties**: Adding properties from different action types in the same action configuration
|
|
26
|
+
- **Action type mismatches**: Using action cell types in collection actions, or bulk action types in regular actions
|
|
20
27
|
|
|
21
28
|
```ts
|
|
22
29
|
export interface AppConfig {
|
|
@@ -46,6 +53,9 @@ export interface AppConfig {
|
|
|
46
53
|
collection: {
|
|
47
54
|
collectionId: string; // ID of the Wix Data collection
|
|
48
55
|
entityTypeSource: 'cms' | 'custom'; // Data source type.
|
|
56
|
+
custom?: { // REQUIRED when entityTypeSource is 'custom'
|
|
57
|
+
id: string; // ID matching your custom data source identifier
|
|
58
|
+
};
|
|
49
59
|
};
|
|
50
60
|
create?: { // Required when type is 'create'
|
|
51
61
|
mode: 'page'; // Create mode
|
|
@@ -73,8 +83,8 @@ export interface AppConfig {
|
|
|
73
83
|
collection: {
|
|
74
84
|
collectionId: string; // ID of the Wix Data collection
|
|
75
85
|
entityTypeSource: 'cms' | 'custom'; // Data source type.
|
|
76
|
-
custom?: {
|
|
77
|
-
id: string;
|
|
86
|
+
custom?: { // REQUIRED when entityTypeSource is 'custom'
|
|
87
|
+
id: string; // ID matching your custom data source identifier
|
|
78
88
|
};
|
|
79
89
|
reflectQueryInUrl?: boolean; // Reflects query state (search, filters, sorting) in the browser URL. Default: false
|
|
80
90
|
selectAllScope?: 'page' | 'all'; // Controls "Select All" scope. 'all' selects entire collection, 'page' selects only visible items. Default: 'all'
|
|
@@ -295,6 +305,7 @@ export interface AppConfig {
|
|
|
295
305
|
]; // End of components array
|
|
296
306
|
};
|
|
297
307
|
entityPage?: {
|
|
308
|
+
mode?: 'edit' | 'view'; // Entity page mode. Default: 'edit'
|
|
298
309
|
route: {
|
|
299
310
|
path: string; // Route path for the entity page (e.g., '/product/:entityId')
|
|
300
311
|
params: {
|
|
@@ -307,6 +318,40 @@ export interface AppConfig {
|
|
|
307
318
|
subtitle?: {
|
|
308
319
|
text: string; // Entity page subtitle
|
|
309
320
|
};
|
|
321
|
+
actions?: { // Action configuration varies by mode
|
|
322
|
+
// Edit mode: only moreActions supported
|
|
323
|
+
// View mode: primaryActions, secondaryActions, and moreActions supported
|
|
324
|
+
primaryActions?: { // View mode only
|
|
325
|
+
type: 'action' | 'menu';
|
|
326
|
+
action?: {
|
|
327
|
+
item: {
|
|
328
|
+
id: string;
|
|
329
|
+
type: 'create' | 'custom';
|
|
330
|
+
label?: string;
|
|
331
|
+
create?: { // Required when type is 'create'
|
|
332
|
+
mode: 'page';
|
|
333
|
+
page: {
|
|
334
|
+
id: string; // Entity page ID to navigate to
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
menu?: {
|
|
340
|
+
label: string;
|
|
341
|
+
items: {}[]; // Array of action configurations, same structure as action.item, can include dividers
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
secondaryActions?: { // View mode only - same structure as primaryActions
|
|
345
|
+
type: 'action' | 'menu';
|
|
346
|
+
action?: {}; // Same structure as primaryActions.action
|
|
347
|
+
menu?: {}; // Same structure as primaryActions.menu
|
|
348
|
+
};
|
|
349
|
+
moreActions?: { // Both modes
|
|
350
|
+
id: string;
|
|
351
|
+
type: 'custom';
|
|
352
|
+
label?: string;
|
|
353
|
+
}[];
|
|
354
|
+
};
|
|
310
355
|
parentPageId?: string; // ID of the parent collection page
|
|
311
356
|
layout?: {
|
|
312
357
|
// Main layout section
|
|
@@ -338,8 +383,8 @@ export interface AppConfig {
|
|
|
338
383
|
};
|
|
339
384
|
collectionId: string; // Related collection ID
|
|
340
385
|
entityTypeSource: 'cms' | 'custom'; // Data source type.
|
|
341
|
-
custom?: {
|
|
342
|
-
id: string;
|
|
386
|
+
custom?: { // REQUIRED when entityTypeSource is 'custom'
|
|
387
|
+
id: string; // ID matching your custom data source identifier
|
|
343
388
|
};
|
|
344
389
|
};
|
|
345
390
|
}[];
|