@wix/auto-patterns 1.15.0 → 1.17.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/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +16 -4
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageContent/SkeletonCollection.js +34 -0
- package/dist/cjs/components/AutoPatternsCollectionPageContent/SkeletonCollection.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/SkeletonEntity.js +198 -0
- package/dist/cjs/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -0
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js +13 -3
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js +4 -4
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
- package/dist/cjs/hooks/useBaseTableFeatures.js +7 -2
- package/dist/cjs/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useCollectionPageOnRowClickActions.js +49 -0
- package/dist/cjs/hooks/useCollectionPageOnRowClickActions.js.map +1 -0
- package/dist/cjs/hooks/useNavigationUtils.js +2 -2
- package/dist/cjs/hooks/useNavigationUtils.js.map +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/cjs/providers/SchemaContext.js +4 -3
- package/dist/cjs/providers/SchemaContext.js.map +1 -1
- package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
- package/dist/cjs/types/actions/base.js.map +1 -1
- package/dist/cjs/types/actions/collectionPageActions.js.map +1 -1
- package/dist/cjs/utils/actions/resolveAction.js +2 -1
- package/dist/cjs/utils/actions/resolveAction.js.map +1 -1
- package/dist/cjs/utils/actions/types.js.map +1 -1
- package/dist/docs/action_cell.md +233 -0
- package/dist/docs/app_config_structure.md +356 -0
- package/dist/docs/auto-patterns-guide.md +2467 -0
- package/dist/docs/bulk_actions.md +266 -0
- package/dist/docs/collection_page.md +54 -0
- package/dist/docs/collection_page_actions.md +343 -0
- package/dist/docs/custom_overrides.md +511 -0
- package/dist/docs/entity_page.md +104 -0
- package/dist/docs/entity_page_actions.md +92 -0
- package/dist/docs/index.md +76 -0
- package/dist/docs/installation.md +55 -0
- package/dist/docs/introduction.md +74 -0
- package/dist/docs/pages_configuration.md +129 -0
- package/dist/docs/recipe-bulk-operations.md +1352 -0
- package/dist/docs/recipe-crud-operations.md +805 -0
- package/dist/docs/recipe-customization.md +1703 -0
- package/dist/docs/recipe-first-dashboard.md +795 -0
- package/dist/docs/sdk_and_schema.md +215 -0
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +7 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/SkeletonCollection.js +21 -0
- package/dist/esm/components/AutoPatternsCollectionPageContent/SkeletonCollection.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +3 -1
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js +91 -0
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -0
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js +5 -1
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js +1 -1
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
- package/dist/esm/hooks/useBaseTableFeatures.js +6 -1
- package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js +45 -0
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js.map +1 -0
- package/dist/esm/hooks/useNavigationUtils.js +1 -1
- package/dist/esm/hooks/useNavigationUtils.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/types/CollectionPageConfig.js.map +1 -1
- package/dist/esm/types/actions/base.js.map +1 -1
- package/dist/esm/types/actions/collectionPageActions.js.map +1 -1
- package/dist/esm/utils/actions/resolveAction.js +2 -1
- package/dist/esm/utils/actions/resolveAction.js.map +1 -1
- package/dist/esm/utils/actions/types.js.map +1 -1
- package/dist/types/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsCollectionPageContent/SkeletonCollection.d.ts +5 -0
- package/dist/types/components/AutoPatternsCollectionPageContent/SkeletonCollection.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/SkeletonEntity.d.ts +7 -0
- package/dist/types/components/AutoPatternsEntityPage/SkeletonEntity.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsRoute/AutoPatternsPage.d.ts.map +1 -1
- package/dist/types/hooks/useBaseTableFeatures.d.ts +1 -1
- package/dist/types/hooks/useBaseTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useCollectionPageOnRowClickActions.d.ts +7 -0
- package/dist/types/hooks/useCollectionPageOnRowClickActions.d.ts.map +1 -0
- package/dist/types/hooks/useTableFeatures.d.ts +1 -1
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +1 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -2
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
- package/dist/types/providers/SchemaContext.d.ts +2 -1
- package/dist/types/providers/SchemaContext.d.ts.map +1 -1
- package/dist/types/types/CollectionPageConfig.d.ts +2 -1
- package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
- package/dist/types/types/actions/base.d.ts +1 -0
- package/dist/types/types/actions/base.d.ts.map +1 -1
- package/dist/types/types/actions/collectionPageActions.d.ts +8 -0
- package/dist/types/types/actions/collectionPageActions.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 +1 -0
- package/dist/types/utils/actions/types.d.ts.map +1 -1
- package/package.json +26 -20
|
@@ -5,6 +5,7 @@ exports.useBaseTableFeatures = void 0;
|
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _useColumns = require("./useColumns");
|
|
7
7
|
var _patterns = require("@wix/patterns");
|
|
8
|
+
var _useCollectionPageOnRowClickActions = require("./useCollectionPageOnRowClickActions");
|
|
8
9
|
var _useNavigationUtils = require("./useNavigationUtils");
|
|
9
10
|
var _jsxFileName = "/home/builduser/work/73d19ce3378ce4dd/packages/auto-patterns/dist/cjs/hooks/useBaseTableFeatures.tsx";
|
|
10
11
|
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); }
|
|
@@ -17,7 +18,11 @@ const useBaseTableFeatures = configuration => {
|
|
|
17
18
|
const columns = (0, _useColumns.useColumns)(configuration.columns);
|
|
18
19
|
const visibleFieldIds = (0, _react.useMemo)(() => configuration.columns.map(column => column.id), [configuration]);
|
|
19
20
|
const entityPageId = configuration.entityPageId;
|
|
20
|
-
const
|
|
21
|
+
const onRowClickOverride = (0, _useCollectionPageOnRowClickActions.useCollectionPageOnRowClickActions)({
|
|
22
|
+
collectionPageOnRowClickActions: configuration.onRowClick,
|
|
23
|
+
collectionId: configuration.collection.collectionId
|
|
24
|
+
});
|
|
25
|
+
const onRowClick = configuration.onRowClick ? onRowClickOverride : item => navigateToEntityPage({
|
|
21
26
|
item,
|
|
22
27
|
entityPageId
|
|
23
28
|
});
|
|
@@ -32,7 +37,7 @@ const useBaseTableFeatures = configuration => {
|
|
|
32
37
|
__self: void 0,
|
|
33
38
|
__source: {
|
|
34
39
|
fileName: _jsxFileName,
|
|
35
|
-
lineNumber:
|
|
40
|
+
lineNumber: 39,
|
|
36
41
|
columnNumber: 7
|
|
37
42
|
}
|
|
38
43
|
}) : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_useColumns","_patterns","_useNavigationUtils","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useBaseTableFeatures","configuration","_configuration$custom","navigateToEntityPage","useNavigation","columns","useColumns","visibleFieldIds","useMemo","map","column","id","entityPageId","onRowClick","item","stickyColumns","stickySelectionColumn","customColumns","enabled","createElement","CustomColumns","__self","__source","fileName","lineNumber","columnNumber","undefined","exports"],"sources":["../../../src/hooks/useBaseTableFeatures.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { TableConfig } from '../types';\nimport { useColumns } from './useColumns';\nimport { CustomColumns } from '@wix/patterns';\nimport { useNavigation } from './useNavigationUtils';\n\nexport const useBaseTableFeatures = (configuration: TableConfig) => {\n const { navigateToEntityPage } = useNavigation();\n
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_useColumns","_patterns","_useCollectionPageOnRowClickActions","_useNavigationUtils","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useBaseTableFeatures","configuration","_configuration$custom","navigateToEntityPage","useNavigation","columns","useColumns","visibleFieldIds","useMemo","map","column","id","entityPageId","onRowClickOverride","useCollectionPageOnRowClickActions","collectionPageOnRowClickActions","onRowClick","collectionId","collection","item","stickyColumns","stickySelectionColumn","customColumns","enabled","createElement","CustomColumns","__self","__source","fileName","lineNumber","columnNumber","undefined","exports"],"sources":["../../../src/hooks/useBaseTableFeatures.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { TableConfig } from '../types';\nimport { useColumns } from './useColumns';\nimport { CustomColumns } from '@wix/patterns';\nimport { useCollectionPageOnRowClickActions } from './useCollectionPageOnRowClickActions';\nimport { useNavigation } from './useNavigationUtils';\n\nexport const useBaseTableFeatures = (configuration: TableConfig) => {\n const { navigateToEntityPage } = useNavigation();\n const columns = useColumns(configuration.columns);\n const visibleFieldIds = useMemo(\n () => configuration.columns.map((column) => column.id),\n [configuration],\n );\n\n const entityPageId = configuration.entityPageId;\n\n const onRowClickOverride = useCollectionPageOnRowClickActions({\n collectionPageOnRowClickActions: configuration.onRowClick,\n collectionId: configuration.collection.collectionId,\n });\n\n const onRowClick = configuration.onRowClick\n ? onRowClickOverride\n : (item: any) =>\n navigateToEntityPage({\n item,\n entityPageId,\n });\n\n const stickyColumns = configuration.stickyColumns;\n const stickySelectionColumn = !!stickyColumns; // Sticky selection column is true if stickyColumns is positive number\n\n return {\n columns,\n visibleFieldIds,\n onRowClick,\n customColumns: configuration.customColumns?.enabled ? (\n <CustomColumns />\n ) : undefined,\n stickyColumns,\n stickySelectionColumn,\n };\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,mCAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AAAqD,IAAAK,YAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CA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EAC7B,MAAMP,aAAa,CAACI,OAAO,CAACI,GAAG,CAAEC,MAAM,IAAKA,MAAM,CAACC,EAAE,CAAC,EACtD,CAACV,aAAa,CAChB,CAAC;EAED,MAAMW,YAAY,GAAGX,aAAa,CAACW,YAAY;EAE/C,MAAMC,kBAAkB,GAAG,IAAAC,sEAAkC,EAAC;IAC5DC,+BAA+B,EAAEd,aAAa,CAACe,UAAU;IACzDC,YAAY,EAAEhB,aAAa,CAACiB,UAAU,CAACD;EACzC,CAAC,CAAC;EAEF,MAAMD,UAAU,GAAGf,aAAa,CAACe,UAAU,GACvCH,kBAAkB,GACjBM,IAAS,IACRhB,oBAAoB,CAAC;IACnBgB,IAAI;IACJP;EACF,CAAC,CAAC;EAER,MAAMQ,aAAa,GAAGnB,aAAa,CAACmB,aAAa;EACjD,MAAMC,qBAAqB,GAAG,CAAC,CAACD,aAAa,CAAC,CAAC;;EAE/C,OAAO;IACLf,OAAO;IACPE,eAAe;IACfS,UAAU;IACVM,aAAa,EAAE,CAAApB,qBAAA,GAAAD,aAAa,CAACqB,aAAa,aAA3BpB,qBAAA,CAA6BqB,OAAO,gBACjDnD,MAAA,CAAAc,OAAA,CAAAsC,aAAA,CAAChD,SAAA,CAAAiD,aAAa;MAAAC,MAAA;MAAAC,QAAA;QAAAC,QAAA,EAAAjD,YAAA;QAAAkD,UAAA;QAAAC,YAAA;MAAA;IAAA,CAAE,CAAC,GACfC,SAAS;IACbX,aAAa;IACbC;EACF,CAAC;AACH,CAAC;AAACW,OAAA,CAAAhC,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useCollectionPageOnRowClickActions = void 0;
|
|
5
|
+
var _react = require("react");
|
|
6
|
+
var _actions = require("../utils/actions");
|
|
7
|
+
var _useActionsSDK = require("./useActionsSDK");
|
|
8
|
+
const useCollectionPageOnRowClickActions = ({
|
|
9
|
+
collectionPageOnRowClickActions,
|
|
10
|
+
collectionId
|
|
11
|
+
}) => {
|
|
12
|
+
const sdk = (0, _useActionsSDK.useActionsSDK)({
|
|
13
|
+
collectionId
|
|
14
|
+
});
|
|
15
|
+
const buildCollectionPageActions = (0, _react.useCallback)((item, index) => {
|
|
16
|
+
if (!collectionPageOnRowClickActions) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const buildAction = actionConfig => {
|
|
20
|
+
let actionToResolve = null;
|
|
21
|
+
const baseParams = {
|
|
22
|
+
actionParams: {
|
|
23
|
+
item,
|
|
24
|
+
index
|
|
25
|
+
},
|
|
26
|
+
sdk
|
|
27
|
+
};
|
|
28
|
+
switch (actionConfig.type) {
|
|
29
|
+
case 'custom':
|
|
30
|
+
actionToResolve = (0, _actions.customAction)({
|
|
31
|
+
action: actionConfig,
|
|
32
|
+
...baseParams
|
|
33
|
+
});
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (!actionToResolve) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const resolvedAction = (0, _actions.resolveAction)(actionConfig, actionToResolve);
|
|
42
|
+
return resolvedAction.onClick == null ? void 0 : resolvedAction.onClick();
|
|
43
|
+
};
|
|
44
|
+
return buildAction(collectionPageOnRowClickActions);
|
|
45
|
+
}, [collectionPageOnRowClickActions, sdk]);
|
|
46
|
+
return buildCollectionPageActions;
|
|
47
|
+
};
|
|
48
|
+
exports.useCollectionPageOnRowClickActions = useCollectionPageOnRowClickActions;
|
|
49
|
+
//# sourceMappingURL=useCollectionPageOnRowClickActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_actions","_useActionsSDK","useCollectionPageOnRowClickActions","collectionPageOnRowClickActions","collectionId","sdk","useActionsSDK","buildCollectionPageActions","useCallback","item","index","buildAction","actionConfig","actionToResolve","baseParams","actionParams","type","customAction","action","resolvedAction","resolveAction","onClick","exports"],"sources":["../../../src/hooks/useCollectionPageOnRowClickActions.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { CollectionPageOnRowClickActionConfig, ResolvedAction } from '../types';\nimport { customAction, resolveAction } from '../utils/actions';\nimport { useActionsSDK } from './useActionsSDK';\n\nexport interface UseCollectionPageOnRowClickActionsParams {\n collectionPageOnRowClickActions?: CollectionPageOnRowClickActionConfig;\n collectionId: string;\n}\n\nexport const useCollectionPageOnRowClickActions = ({\n collectionPageOnRowClickActions,\n collectionId,\n}: UseCollectionPageOnRowClickActionsParams) => {\n const sdk = useActionsSDK({\n collectionId,\n });\n const buildCollectionPageActions = useCallback(\n (item, index) => {\n if (!collectionPageOnRowClickActions) {\n return;\n }\n\n const buildAction = (\n actionConfig: CollectionPageOnRowClickActionConfig,\n ) => {\n let actionToResolve: Partial<ResolvedAction> | null = null;\n const baseParams = {\n actionParams: { item, index },\n sdk,\n };\n switch (actionConfig.type) {\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) {\n return null;\n }\n\n const resolvedAction = resolveAction(actionConfig, actionToResolve);\n\n return resolvedAction.onClick?.();\n };\n\n return buildAction(collectionPageOnRowClickActions);\n },\n [collectionPageOnRowClickActions, sdk],\n );\n\n return buildCollectionPageActions;\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAOO,MAAMG,kCAAkC,GAAGA,CAAC;EACjDC,+BAA+B;EAC/BC;AACwC,CAAC,KAAK;EAC9C,MAAMC,GAAG,GAAG,IAAAC,4BAAa,EAAC;IACxBF;EACF,CAAC,CAAC;EACF,MAAMG,0BAA0B,GAAG,IAAAC,kBAAW,EAC5C,CAACC,IAAI,EAAEC,KAAK,KAAK;IACf,IAAI,CAACP,+BAA+B,EAAE;MACpC;IACF;IAEA,MAAMQ,WAAW,GACfC,YAAkD,IAC/C;MACH,IAAIC,eAA+C,GAAG,IAAI;MAC1D,MAAMC,UAAU,GAAG;QACjBC,YAAY,EAAE;UAAEN,IAAI;UAAEC;QAAM,CAAC;QAC7BL;MACF,CAAC;MACD,QAAQO,YAAY,CAACI,IAAI;QACvB,KAAK,QAAQ;UACXH,eAAe,GAAG,IAAAI,qBAAY,EAAC;YAC7BC,MAAM,EAAEN,YAAY;YACpB,GAAGE;UACL,CAAC,CAAC;UACF;QAEF;UACE,OAAO,IAAI;MACf;MAEA,IAAI,CAACD,eAAe,EAAE;QACpB,OAAO,IAAI;MACb;MAEA,MAAMM,cAAc,GAAG,IAAAC,sBAAa,EAACR,YAAY,EAAEC,eAAe,CAAC;MAEnE,OAAOM,cAAc,CAACE,OAAO,oBAAtBF,cAAc,CAACE,OAAO,CAAG,CAAC;IACnC,CAAC;IAED,OAAOV,WAAW,CAACR,+BAA+B,CAAC;EACrD,CAAC,EACD,CAACA,+BAA+B,EAAEE,GAAG,CACvC,CAAC;EAED,OAAOE,0BAA0B;AACnC,CAAC;AAACe,OAAA,CAAApB,kCAAA,GAAAA,kCAAA","ignoreList":[]}
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.useNavigation = void 0;
|
|
5
5
|
var _react = require("react");
|
|
6
|
-
var
|
|
6
|
+
var _router = require("@wix/patterns/router");
|
|
7
7
|
var _providers = require("../providers");
|
|
8
8
|
var _reactRouterDom = require("react-router-dom");
|
|
9
9
|
var _usePagePath = require("./usePagePath");
|
|
10
10
|
const useNavigation = () => {
|
|
11
11
|
const {
|
|
12
12
|
navigateToEntityPage: navigateToEntityPagePatterns
|
|
13
|
-
} = (0,
|
|
13
|
+
} = (0, _router.usePatternsNavigate)();
|
|
14
14
|
const appConfig = (0, _providers.useAppConfigContext)();
|
|
15
15
|
const {
|
|
16
16
|
getSchema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","
|
|
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","getParentPagePath","parentPageId","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 { navigateToEntityPage: navigateToEntityPagePatterns } =\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 getParentPagePath = useCallback(\n (parentPageId?: string): string | undefined => {\n return getPagePath(parentPageId);\n },\n [getPagePath],\n );\n\n return {\n navigateToEntityPage,\n getParentPagePath,\n getPagePath,\n };\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA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AAEI,SAAS,CACrD,CAAC;EAED,MAAMqB,iBAAiB,GAAG,IAAAjB,kBAAW,EAClCkB,YAAqB,IAAyB;IAC7C,OAAOpB,WAAW,CAACoB,YAAY,CAAC;EAClC,CAAC,EACD,CAACpB,WAAW,CACd,CAAC;EAED,OAAO;IACLP,oBAAoB;IACpB0B,iBAAiB;IACjBnB;EACF,CAAC;AACH,CAAC;AAACqB,OAAA,CAAA7B,aAAA,GAAAA,aAAA","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 EntityPageMoreActionsActionParams,\n IColumnValue,\n SchemaConfig,\n} from '../types';\n\nimport { CustomActionParams, ResolvedAction } from '../utils/actions/types';\nimport {
|
|
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 EntityPageMoreActionsActionParams,\n IColumnValue,\n SchemaConfig,\n} from '../types';\n\nimport { CustomActionParams, ResolvedAction } from '../utils/actions/types';\nimport {\n CollectionPageActionOnRowClickParams,\n CollectionPageActionParams,\n} from '../types/actions/collectionPageActions';\nimport { ActionCellActionParams } from '../types/actions/actionCell';\n\nexport interface PatternsWizardOverridesContextProps {\n actions?: Record<\n string,\n (\n props: CustomActionParams<\n | EntityPageMoreActionsActionParams\n | CollectionPageActionParams\n | ActionCellActionParams\n | CollectionPageActionOnRowClickParams\n >,\n ) => ResolvedAction\n >;\n columns?: Record<string, (props: IColumnValue<any>) => void>;\n modals?: Record<string, React.FC<any>>;\n HeaderAddon?: React.FC;\n emptyState?: Record<string, () => void>;\n components?: Record<string, React.FC<CustomComponentProps>>;\n customDataSources?: Record<\n string,\n (collectionId: string, context: any) => Promise<SchemaConfig>\n >;\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,CA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CAAA,GAAAA,iCAAA","ignoreList":[]}
|
|
@@ -13,7 +13,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
13
13
|
const SchemaContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
14
14
|
const SchemaProvider = ({
|
|
15
15
|
collection,
|
|
16
|
-
children
|
|
16
|
+
children,
|
|
17
|
+
skeleton
|
|
17
18
|
}) => {
|
|
18
19
|
var _collection$custom;
|
|
19
20
|
const {
|
|
@@ -87,14 +88,14 @@ const SchemaProvider = ({
|
|
|
87
88
|
});
|
|
88
89
|
}, [collectionId, entityTypeSource, customDataSourceId, addSchemaToRegistry, getSchemaFromRegistry, overrides, httpClient]);
|
|
89
90
|
if (!schema || isLoading) {
|
|
90
|
-
return
|
|
91
|
+
return skeleton;
|
|
91
92
|
}
|
|
92
93
|
return /*#__PURE__*/_react.default.createElement(SchemaContext.Provider, {
|
|
93
94
|
value: schema,
|
|
94
95
|
__self: void 0,
|
|
95
96
|
__source: {
|
|
96
97
|
fileName: _jsxFileName,
|
|
97
|
-
lineNumber:
|
|
98
|
+
lineNumber: 135,
|
|
98
99
|
columnNumber: 5
|
|
99
100
|
}
|
|
100
101
|
}, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_factory","_SchemaRegistryContext","_PatternsWizardOverridesContext","_patterns","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SchemaContext","createContext","SchemaProvider","collection","children","_collection$custom","collectionId","entityTypeSource","customDataSourceId","custom","id","undefined","getSchema","getSchemaFromRegistry","addSchema","addSchemaToRegistry","useSchemaRegistry","schema","setSchema","useState","isLoading","setIsLoading","overrides","usePatternsWizardOverridesContext","httpClient","useWixPatternsContainer","useEffect","fetchSchemaForCollection","targetCollectionId","targetCustomDataSourceId","customDataSources","customSchemaProvider","Error","fetchReferencedSchemas","referencedSchema","referencedCollectionIds","Set","values","fields","forEach","field","type","referenceMetadata","referencedCollectionId","add","size","fetchPromises","Array","from","map","refCollectionId","refSchema","error","console","Promise","all","cachedSchema","then","fetchedSchema","catch","finally","createElement","Provider","value","__self","__source","fileName","lineNumber","columnNumber","exports","useSchema","context","useContext"],"sources":["../../../src/providers/SchemaContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useEffect,\n useState,\n ReactNode,\n} from 'react';\n\nimport { SchemaConfig, BaseCollectionConfig } from '../types';\nimport { getSchema } from '../dataSourceAdapters/factory';\nimport { useSchemaRegistry } from './SchemaRegistryContext';\nimport { usePatternsWizardOverridesContext } from './PatternsWizardOverridesContext';\nimport { useWixPatternsContainer } from '@wix/patterns';\n\nconst SchemaContext = createContext<SchemaConfig | null>(null);\n\ninterface SchemaProviderProps {\n collection: BaseCollectionConfig;\n children: ReactNode;\n}\n\nexport const SchemaProvider = ({\n collection,\n children,\n}: SchemaProviderProps) => {\n const { collectionId, entityTypeSource } = collection;\n const customDataSourceId =\n collection.entityTypeSource === 'custom' && 'custom' in collection\n ? collection.custom?.id\n : undefined;\n const { getSchema: getSchemaFromRegistry, addSchema: addSchemaToRegistry } =\n useSchemaRegistry();\n const [schema, setSchema] = useState<SchemaConfig | null>(null);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const overrides = usePatternsWizardOverridesContext();\n const { httpClient } = useWixPatternsContainer();\n\n useEffect(() => {\n const fetchSchemaForCollection = async (\n targetCollectionId: string,\n targetCustomDataSourceId?: string,\n ): Promise<SchemaConfig> => {\n if (\n entityTypeSource === 'custom' &&\n targetCustomDataSourceId &&\n overrides?.customDataSources\n ) {\n const customSchemaProvider =\n overrides.customDataSources[targetCustomDataSourceId];\n if (customSchemaProvider) {\n return customSchemaProvider(targetCollectionId, { httpClient });\n }\n throw new Error(\n `Custom schema provider '${targetCustomDataSourceId}' not found`,\n );\n }\n\n return getSchema(targetCollectionId, entityTypeSource);\n };\n\n const fetchReferencedSchemas = async (referencedSchema: SchemaConfig) => {\n const referencedCollectionIds = new Set<string>();\n\n Object.values(referencedSchema.fields).forEach((field) => {\n if (field && field.type === 'REFERENCE' && field.referenceMetadata) {\n const { referencedCollectionId } = field.referenceMetadata;\n if (\n referencedCollectionId &&\n !getSchemaFromRegistry(referencedCollectionId)\n ) {\n referencedCollectionIds.add(referencedCollectionId);\n }\n }\n });\n\n if (referencedCollectionIds.size === 0) {\n return;\n }\n\n const fetchPromises = Array.from(referencedCollectionIds).map(\n async (refCollectionId) => {\n try {\n const refSchema = await fetchSchemaForCollection(refCollectionId);\n\n addSchemaToRegistry(refCollectionId, refSchema);\n\n await fetchReferencedSchemas(refSchema);\n } catch (error) {\n console.error(\n `Error fetching referenced schema ${refCollectionId}:`,\n error,\n );\n }\n },\n );\n\n await Promise.all(fetchPromises);\n };\n\n const cachedSchema = getSchemaFromRegistry(collectionId);\n if (cachedSchema) {\n setSchema(cachedSchema);\n return;\n }\n setIsLoading(true);\n fetchSchemaForCollection(collectionId, customDataSourceId)\n .then(async (fetchedSchema) => {\n setSchema(fetchedSchema);\n addSchemaToRegistry(collectionId, fetchedSchema);\n\n await fetchReferencedSchemas(fetchedSchema);\n })\n .catch((error) => {\n console.error('Error fetching schema config:', error);\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, [\n collectionId,\n entityTypeSource,\n customDataSourceId,\n addSchemaToRegistry,\n getSchemaFromRegistry,\n overrides,\n httpClient,\n ]);\n if (!schema || isLoading) {\n return null;\n }\n\n return (\n <SchemaContext.Provider value={schema}>{children}</SchemaContext.Provider>\n );\n};\n\nexport const useSchema = (): SchemaConfig => {\n const context = useContext(SchemaContext);\n if (!context) {\n throw new Error('useSchema must be used within a SchemaProvider');\n }\n return context;\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG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AOC,aAAa,IAAK;MAC7BxC,SAAS,CAACwC,aAAa,CAAC;MACxB3C,mBAAmB,CAACT,YAAY,EAAEoD,aAAa,CAAC;MAEhD,MAAMzB,sBAAsB,CAACyB,aAAa,CAAC;IAC7C,CAAC,CAAC,CACDC,KAAK,CAAEP,KAAK,IAAK;MAChBC,OAAO,CAACD,KAAK,CAAC,+BAA+B,EAAEA,KAAK,CAAC;IACvD,CAAC,CAAC,CACDQ,OAAO,CAAC,MAAM;MACbvC,YAAY,CAAC,KAAK,CAAC;IACrB,CAAC,CAAC;EACN,CAAC,EAAE,CACDf,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBO,mBAAmB,EACnBF,qBAAqB,EACrBS,SAAS,EACTE,UAAU,CACX,CAAC;EACF,IAAI,CAACP,MAAM,IAAIG,SAAS,EAAE;IACxB,OAAO,IAAI;EACb;EAEA,oBACEhD,MAAA,CAAAc,OAAA,CAAA2E,aAAA,CAAC7D,aAAa,CAAC8D,QAAQ;IAACC,KAAK,EAAE9C,MAAO;IAAA+C,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAAvF,YAAA;MAAAwF,UAAA;MAAAC,YAAA;IAAA;EAAA,GAAEhE,QAAiC,CAAC;AAE9E,CAAC;AAACiE,OAAA,CAAAnE,cAAA,GAAAA,cAAA;AAEK,MAAMoE,SAAS,GAAGA,CAAA,KAAoB;EAC3C,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACxE,aAAa,CAAC;EACzC,IAAI,CAACuE,OAAO,EAAE;IACZ,MAAM,IAAIvC,KAAK,CAAC,gDAAgD,CAAC;EACnE;EACA,OAAOuC,OAAO;AAChB,CAAC;AAACF,OAAA,CAAAC,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_factory","_SchemaRegistryContext","_PatternsWizardOverridesContext","_patterns","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SchemaContext","createContext","SchemaProvider","collection","children","skeleton","_collection$custom","collectionId","entityTypeSource","customDataSourceId","custom","id","undefined","getSchema","getSchemaFromRegistry","addSchema","addSchemaToRegistry","useSchemaRegistry","schema","setSchema","useState","isLoading","setIsLoading","overrides","usePatternsWizardOverridesContext","httpClient","useWixPatternsContainer","useEffect","fetchSchemaForCollection","targetCollectionId","targetCustomDataSourceId","customDataSources","customSchemaProvider","Error","fetchReferencedSchemas","referencedSchema","referencedCollectionIds","Set","values","fields","forEach","field","type","referenceMetadata","referencedCollectionId","add","size","fetchPromises","Array","from","map","refCollectionId","refSchema","error","console","Promise","all","cachedSchema","then","fetchedSchema","catch","finally","createElement","Provider","value","__self","__source","fileName","lineNumber","columnNumber","exports","useSchema","context","useContext"],"sources":["../../../src/providers/SchemaContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useEffect,\n useState,\n ReactNode,\n} from 'react';\n\nimport { SchemaConfig, BaseCollectionConfig } from '../types';\nimport { getSchema } from '../dataSourceAdapters/factory';\nimport { useSchemaRegistry } from './SchemaRegistryContext';\nimport { usePatternsWizardOverridesContext } from './PatternsWizardOverridesContext';\nimport { useWixPatternsContainer } from '@wix/patterns';\n\nconst SchemaContext = createContext<SchemaConfig | null>(null);\n\ninterface SchemaProviderProps {\n collection: BaseCollectionConfig;\n children: ReactNode;\n skeleton: JSX.Element;\n}\n\nexport const SchemaProvider = ({\n collection,\n children,\n skeleton,\n}: SchemaProviderProps) => {\n const { collectionId, entityTypeSource } = collection;\n const customDataSourceId =\n collection.entityTypeSource === 'custom' && 'custom' in collection\n ? collection.custom?.id\n : undefined;\n const { getSchema: getSchemaFromRegistry, addSchema: addSchemaToRegistry } =\n useSchemaRegistry();\n const [schema, setSchema] = useState<SchemaConfig | null>(null);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const overrides = usePatternsWizardOverridesContext();\n const { httpClient } = useWixPatternsContainer();\n\n useEffect(() => {\n const fetchSchemaForCollection = async (\n targetCollectionId: string,\n targetCustomDataSourceId?: string,\n ): Promise<SchemaConfig> => {\n if (\n entityTypeSource === 'custom' &&\n targetCustomDataSourceId &&\n overrides?.customDataSources\n ) {\n const customSchemaProvider =\n overrides.customDataSources[targetCustomDataSourceId];\n if (customSchemaProvider) {\n return customSchemaProvider(targetCollectionId, { httpClient });\n }\n throw new Error(\n `Custom schema provider '${targetCustomDataSourceId}' not found`,\n );\n }\n\n return getSchema(targetCollectionId, entityTypeSource);\n };\n\n const fetchReferencedSchemas = async (referencedSchema: SchemaConfig) => {\n const referencedCollectionIds = new Set<string>();\n\n Object.values(referencedSchema.fields).forEach((field) => {\n if (field && field.type === 'REFERENCE' && field.referenceMetadata) {\n const { referencedCollectionId } = field.referenceMetadata;\n if (\n referencedCollectionId &&\n !getSchemaFromRegistry(referencedCollectionId)\n ) {\n referencedCollectionIds.add(referencedCollectionId);\n }\n }\n });\n\n if (referencedCollectionIds.size === 0) {\n return;\n }\n\n const fetchPromises = Array.from(referencedCollectionIds).map(\n async (refCollectionId) => {\n try {\n const refSchema = await fetchSchemaForCollection(refCollectionId);\n\n addSchemaToRegistry(refCollectionId, refSchema);\n\n await fetchReferencedSchemas(refSchema);\n } catch (error) {\n console.error(\n `Error fetching referenced schema ${refCollectionId}:`,\n error,\n );\n }\n },\n );\n\n await Promise.all(fetchPromises);\n };\n\n const cachedSchema = getSchemaFromRegistry(collectionId);\n if (cachedSchema) {\n setSchema(cachedSchema);\n return;\n }\n setIsLoading(true);\n fetchSchemaForCollection(collectionId, customDataSourceId)\n .then(async (fetchedSchema) => {\n setSchema(fetchedSchema);\n addSchemaToRegistry(collectionId, fetchedSchema);\n\n await fetchReferencedSchemas(fetchedSchema);\n })\n .catch((error) => {\n console.error('Error fetching schema config:', error);\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, [\n collectionId,\n entityTypeSource,\n customDataSourceId,\n addSchemaToRegistry,\n getSchemaFromRegistry,\n overrides,\n httpClient,\n ]);\n if (!schema || isLoading) {\n return skeleton;\n }\n\n return (\n <SchemaContext.Provider value={schema}>{children}</SchemaContext.Provider>\n );\n};\n\nexport const useSchema = (): SchemaConfig => {\n const context = useContext(SchemaContext);\n if (!context) {\n throw new Error('useSchema must be used within a SchemaProvider');\n }\n return context;\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,+BAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAAwD,IAAAK,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,SAAAR,wBAAAQ,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,C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AAG,IAAAC,iBAAU,EAACzE,aAAa,CAAC;EACzC,IAAI,CAACwE,OAAO,EAAE;IACZ,MAAM,IAAIvC,KAAK,CAAC,gDAAgD,CAAC;EACnE;EACA,OAAOuC,OAAO;AAChB,CAAC;AAACF,OAAA,CAAAC,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ComponentTypeEnum","exports"],"sources":["../../../src/types/CollectionPageConfig.ts"],"sourcesContent":["import { CollectionToolbarFiltersProps } from '@wix/patterns';\nimport { DateRangeFilterMode, DateRangeOptions } from '@wix/patterns/core';\nimport { BaseCollectionConfig } from './types';\nimport {\n ActionCellConfig,\n BulkActionsConfig,\n CollectionPagePrimaryActions,\n CollectionPageSecondaryActions,\n} from './actions';\n\nexport interface CollectionPageTitle {\n text: string;\n hideTotal?: boolean;\n}\n\nexport interface CollectionPageSubtitle {\n text: string;\n learnMore?: {\n url: string;\n label?: string;\n };\n}\n\nexport interface CollectionPageConfig {\n route: {\n path: string;\n };\n title: CollectionPageTitle;\n subtitle?: CollectionPageSubtitle;\n actions?: {\n primaryActions?: CollectionPagePrimaryActions;\n secondaryActions?: CollectionPageSecondaryActions;\n };\n components: ComponentConfig[];\n}\n\nexport interface ComponentConfig extends BaseCollectionComponentConfig {\n layout: LayoutItemConfig[];\n}\n\nexport interface LayoutItemConfig {\n type: 'Table' | 'Grid';\n table?: TableSpecificConfig;\n grid?: GridSpecificConfig;\n}\n\nexport type ColumnsConfig = Column[];\n\nexport interface TableSpecificConfig {\n columns: ColumnsConfig;\n customColumns?: {\n enabled: boolean;\n };\n stickyColumns?: number;\n}\n\nexport interface GridSpecificConfig {\n item: GridItem;\n}\n\nexport interface TableConfig\n extends BaseCollectionComponentConfig,\n TableSpecificConfig {}\nexport interface GridConfig\n extends BaseCollectionComponentConfig,\n GridSpecificConfig {}\nexport interface TableGridSwitchConfig\n extends BaseCollectionComponentConfig,\n TableSpecificConfig,\n GridSpecificConfig {}\n\nexport type CollectionConfig = BaseCollectionConfig & {\n limit?: number;\n reflectQueryInUrl?: boolean;\n selectAllScope?: 'page' | 'all';\n selectionUpdateMode?: 'preserve' | 'clear';\n};\n\nexport interface BaseCollectionComponentConfig {\n collection: CollectionConfig;\n entityPageId?: string;\n search?: { shown?: boolean };\n toolbarTitle?: ToolbarTitle;\n actionCell?: ActionCellConfig;\n emptyState?: EmptyState;\n filters?: FiltersConfig;\n bulkActionToolbar?: BulkActionsConfig;\n}\n\nexport interface ToolbarTitle {\n title: string;\n subtitle?: {\n text: string;\n info?: {\n content: {\n text: string;\n link?: {\n url: string;\n label: string;\n };\n };\n };\n learnMore?: {\n url: string;\n label?: string;\n };\n };\n showTotal?: boolean;\n itemsLimit?: number;\n}\n\nexport interface Column {\n id: string;\n name: string;\n width: string;\n sortable?: boolean;\n defaultSortOrder?: 'asc' | 'desc';\n sortMode?: 'asc' | 'desc';\n defaultHidden?: boolean;\n hiddenFromCustomColumnsSelection?: boolean;\n hideable?: boolean;\n reorderDisabled?: boolean;\n}\n\nexport interface GridItem {\n titleFieldId: string;\n subtitleFieldId?: string;\n imageFieldId?: string;\n cardContentMode?: 'full' | 'title' | 'empty'; // Footer is not supported in auto-patterns\n imagePlacement?: 'top' | 'side';\n}\n\nexport interface EmptyState {\n title?: string;\n subtitle?: string;\n image?: {\n id: string;\n };\n addNewCta?: {\n id?: string;\n text?: string;\n };\n customCta?: {\n id?: string;\n };\n}\n\nexport interface FilterOption {\n value: string;\n label: string;\n}\n\nexport type FilterSelectionMode = 'single' | 'multiple';\nexport type FilterOptionType =\n | 'checkbox'\n | 'inlineCheckbox'\n | 'radio'\n | 'select';\n\nexport enum ComponentTypeEnum {\n SINGLE = 'single',\n MULTI_SELECT = 'multi-select',\n RADIO_GROUP = 'radio-group',\n NUMBER = 'number',\n DATE_RANGE = 'date-range',\n}\n\nexport type FilterItems = Filter[];\nexport interface FiltersConfig {\n items: FilterItems;\n maxInlineFilters?: CollectionToolbarFiltersProps['inline'];\n panelTitle?: string;\n}\n\nexport interface BaseOptionsFilterConfig {\n selectionMode: FilterSelectionMode;\n}\n\nexport interface DateFilterConfig {\n mode?: DateRangeFilterMode;\n presets?: DateRangeOptions;\n includeTime?: boolean;\n}\n\nexport interface NumberFilterConfig {\n min?: number;\n max?: number;\n allowedDecimals?: boolean;\n}\n\nexport interface BooleanFilterConfig {\n trueLabel?: string;\n falseLabel?: string;\n}\n\nexport interface EnumFilterConfig extends BaseOptionsFilterConfig {\n options: FilterOption[];\n optionType?: FilterOptionType;\n}\n\nexport interface DynamicOptionsFilterConfig extends BaseOptionsFilterConfig {}\n\nexport interface Filter {\n id: string;\n fieldId: string;\n displayName?: string;\n sectionTitle?: string;\n openByDefault?: boolean;\n tagLabel?: string;\n numberConfig?: NumberFilterConfig;\n dateConfig?: DateFilterConfig;\n booleanConfig?: BooleanFilterConfig;\n enumConfig?: EnumFilterConfig;\n dynamicOptionsConfig?: DynamicOptionsFilterConfig;\n}\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"names":["ComponentTypeEnum","exports"],"sources":["../../../src/types/CollectionPageConfig.ts"],"sourcesContent":["import { CollectionToolbarFiltersProps } from '@wix/patterns';\nimport { DateRangeFilterMode, DateRangeOptions } from '@wix/patterns/core';\nimport { BaseCollectionConfig } from './types';\nimport {\n ActionCellConfig,\n BulkActionsConfig,\n CollectionPageOnRowClickActionConfig,\n CollectionPagePrimaryActions,\n CollectionPageSecondaryActions,\n} from './actions';\n\nexport interface CollectionPageTitle {\n text: string;\n hideTotal?: boolean;\n}\n\nexport interface CollectionPageSubtitle {\n text: string;\n learnMore?: {\n url: string;\n label?: string;\n };\n}\n\nexport interface CollectionPageConfig {\n route: {\n path: string;\n };\n title: CollectionPageTitle;\n subtitle?: CollectionPageSubtitle;\n actions?: {\n primaryActions?: CollectionPagePrimaryActions;\n secondaryActions?: CollectionPageSecondaryActions;\n };\n components: ComponentConfig[];\n}\n\nexport interface ComponentConfig extends BaseCollectionComponentConfig {\n layout: LayoutItemConfig[];\n}\n\nexport interface LayoutItemConfig {\n type: 'Table' | 'Grid';\n table?: TableSpecificConfig;\n grid?: GridSpecificConfig;\n}\n\nexport type ColumnsConfig = Column[];\n\nexport interface TableSpecificConfig {\n columns: ColumnsConfig;\n customColumns?: {\n enabled: boolean;\n };\n stickyColumns?: number;\n onRowClick?: CollectionPageOnRowClickActionConfig;\n}\n\nexport interface GridSpecificConfig {\n item: GridItem;\n}\n\nexport interface TableConfig\n extends BaseCollectionComponentConfig,\n TableSpecificConfig {}\nexport interface GridConfig\n extends BaseCollectionComponentConfig,\n GridSpecificConfig {}\nexport interface TableGridSwitchConfig\n extends BaseCollectionComponentConfig,\n TableSpecificConfig,\n GridSpecificConfig {}\n\nexport type CollectionConfig = BaseCollectionConfig & {\n limit?: number;\n reflectQueryInUrl?: boolean;\n selectAllScope?: 'page' | 'all';\n selectionUpdateMode?: 'preserve' | 'clear';\n};\n\nexport interface BaseCollectionComponentConfig {\n collection: CollectionConfig;\n entityPageId?: string;\n search?: { shown?: boolean };\n toolbarTitle?: ToolbarTitle;\n actionCell?: ActionCellConfig;\n emptyState?: EmptyState;\n filters?: FiltersConfig;\n bulkActionToolbar?: BulkActionsConfig;\n}\n\nexport interface ToolbarTitle {\n title: string;\n subtitle?: {\n text: string;\n info?: {\n content: {\n text: string;\n link?: {\n url: string;\n label: string;\n };\n };\n };\n learnMore?: {\n url: string;\n label?: string;\n };\n };\n showTotal?: boolean;\n itemsLimit?: number;\n}\n\nexport interface Column {\n id: string;\n name: string;\n width: string;\n sortable?: boolean;\n defaultSortOrder?: 'asc' | 'desc';\n sortMode?: 'asc' | 'desc';\n defaultHidden?: boolean;\n hiddenFromCustomColumnsSelection?: boolean;\n hideable?: boolean;\n reorderDisabled?: boolean;\n}\n\nexport interface GridItem {\n titleFieldId: string;\n subtitleFieldId?: string;\n imageFieldId?: string;\n cardContentMode?: 'full' | 'title' | 'empty'; // Footer is not supported in auto-patterns\n imagePlacement?: 'top' | 'side';\n}\n\nexport interface EmptyState {\n title?: string;\n subtitle?: string;\n image?: {\n id: string;\n };\n addNewCta?: {\n id?: string;\n text?: string;\n };\n customCta?: {\n id?: string;\n };\n}\n\nexport interface FilterOption {\n value: string;\n label: string;\n}\n\nexport type FilterSelectionMode = 'single' | 'multiple';\nexport type FilterOptionType =\n | 'checkbox'\n | 'inlineCheckbox'\n | 'radio'\n | 'select';\n\nexport enum ComponentTypeEnum {\n SINGLE = 'single',\n MULTI_SELECT = 'multi-select',\n RADIO_GROUP = 'radio-group',\n NUMBER = 'number',\n DATE_RANGE = 'date-range',\n}\n\nexport type FilterItems = Filter[];\nexport interface FiltersConfig {\n items: FilterItems;\n maxInlineFilters?: CollectionToolbarFiltersProps['inline'];\n panelTitle?: string;\n}\n\nexport interface BaseOptionsFilterConfig {\n selectionMode: FilterSelectionMode;\n}\n\nexport interface DateFilterConfig {\n mode?: DateRangeFilterMode;\n presets?: DateRangeOptions;\n includeTime?: boolean;\n}\n\nexport interface NumberFilterConfig {\n min?: number;\n max?: number;\n allowedDecimals?: boolean;\n}\n\nexport interface BooleanFilterConfig {\n trueLabel?: string;\n falseLabel?: string;\n}\n\nexport interface EnumFilterConfig extends BaseOptionsFilterConfig {\n options: FilterOption[];\n optionType?: FilterOptionType;\n}\n\nexport interface DynamicOptionsFilterConfig extends BaseOptionsFilterConfig {}\n\nexport interface Filter {\n id: string;\n fieldId: string;\n displayName?: string;\n sectionTitle?: string;\n openByDefault?: boolean;\n tagLabel?: string;\n numberConfig?: NumberFilterConfig;\n dateConfig?: DateFilterConfig;\n booleanConfig?: BooleanFilterConfig;\n enumConfig?: EnumFilterConfig;\n dynamicOptionsConfig?: DynamicOptionsFilterConfig;\n}\n"],"mappings":";;;;IAiKYA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../../src/types/actions/base.ts"],"sourcesContent":["export type DividerActionConfig = { type: 'divider' };\n\nexport type BaseActionItemConfig = {\n id: string;\n label?: string;\n};\n\nexport interface Feedback {\n successToast?: { text: string };\n errorToast?: { text: string };\n}\n\nexport interface BaseActionModal {\n title?: { text: string };\n actions?: {\n submit?: { text: string };\n cancel?: { text: string };\n };\n feedback?: Feedback;\n}\n\nexport interface ActionModalField {\n id: string;\n label?: string;\n}\n\nexport interface DeleteActionModal extends BaseActionModal {\n description?: { text: string };\n}\n\nexport interface BulkDeleteActionModal extends DeleteActionModal {}\n\nexport type BulkDeleteAction =\n | {\n mode: 'modal';\n modal: BulkDeleteActionModal;\n custom?: never;\n }\n | {\n mode: 'custom';\n custom: CustomAction;\n modal?: never;\n };\n\nexport type DeleteAction = {\n mode: 'modal';\n modal: DeleteActionModal;\n};\n\nexport interface BaseActionPage {\n id: string;\n}\n\nexport type CustomAction = {};\n\nexport interface ActionModalWithFields extends BaseActionModal {\n fields: ActionModalField[];\n}\n\nexport interface UpdateActionModal extends ActionModalWithFields {}\n\nexport interface CreateActionModal extends ActionModalWithFields {}\n\nexport interface UpdateActionPage extends BaseActionPage {}\n\nexport interface CreateActionPage extends BaseActionPage {}\n\nexport type UpdateAction = {\n mode: 'page';\n page: UpdateActionPage;\n};\n\nexport type CreateAction = {\n mode: 'page';\n page: CreateActionPage;\n};\n\nexport type CreateActionConfig = BaseActionItemConfig & {\n type: 'create';\n create: CreateAction;\n};\n\nexport type UpdateActionConfig = BaseActionItemConfig & {\n type: 'update';\n update: UpdateAction;\n};\n\nexport type DeleteActionConfig = BaseActionItemConfig & {\n type: 'delete';\n delete: DeleteAction;\n};\n\nexport type BulkDeleteActionConfig = BaseActionItemConfig & {\n type: 'bulkDelete';\n bulkDelete: BulkDeleteAction;\n};\n\nexport type CustomActionConfig = BaseActionItemConfig & {\n type: 'custom';\n custom: CustomAction;\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/types/actions/base.ts"],"sourcesContent":["export type DividerActionConfig = { type: 'divider' };\n\nexport type BaseActionItemConfig = {\n id: string;\n label?: string;\n skin?: string;\n};\n\nexport interface Feedback {\n successToast?: { text: string };\n errorToast?: { text: string };\n}\n\nexport interface BaseActionModal {\n title?: { text: string };\n actions?: {\n submit?: { text: string };\n cancel?: { text: string };\n };\n feedback?: Feedback;\n}\n\nexport interface ActionModalField {\n id: string;\n label?: string;\n}\n\nexport interface DeleteActionModal extends BaseActionModal {\n description?: { text: string };\n}\n\nexport interface BulkDeleteActionModal extends DeleteActionModal {}\n\nexport type BulkDeleteAction =\n | {\n mode: 'modal';\n modal: BulkDeleteActionModal;\n custom?: never;\n }\n | {\n mode: 'custom';\n custom: CustomAction;\n modal?: never;\n };\n\nexport type DeleteAction = {\n mode: 'modal';\n modal: DeleteActionModal;\n};\n\nexport interface BaseActionPage {\n id: string;\n}\n\nexport type CustomAction = {};\n\nexport interface ActionModalWithFields extends BaseActionModal {\n fields: ActionModalField[];\n}\n\nexport interface UpdateActionModal extends ActionModalWithFields {}\n\nexport interface CreateActionModal extends ActionModalWithFields {}\n\nexport interface UpdateActionPage extends BaseActionPage {}\n\nexport interface CreateActionPage extends BaseActionPage {}\n\nexport type UpdateAction = {\n mode: 'page';\n page: UpdateActionPage;\n};\n\nexport type CreateAction = {\n mode: 'page';\n page: CreateActionPage;\n};\n\nexport type CreateActionConfig = BaseActionItemConfig & {\n type: 'create';\n create: CreateAction;\n};\n\nexport type UpdateActionConfig = BaseActionItemConfig & {\n type: 'update';\n update: UpdateAction;\n};\n\nexport type DeleteActionConfig = BaseActionItemConfig & {\n type: 'delete';\n delete: DeleteAction;\n};\n\nexport type BulkDeleteActionConfig = BaseActionItemConfig & {\n type: 'bulkDelete';\n bulkDelete: BulkDeleteAction;\n};\n\nexport type CustomActionConfig = BaseActionItemConfig & {\n type: 'custom';\n custom: CustomAction;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../../src/types/actions/collectionPageActions.ts"],"sourcesContent":["import {\n CustomActionModalProps,\n CustomActionParams,\n ResolvedAction,\n} from '../../exports/types';\nimport {\n CreateActionConfig,\n CustomActionConfig,\n DividerActionConfig,\n} from './base';\n\nexport type CollectionPageActionConfig = (\n | CreateActionConfig\n | CustomActionConfig\n) & {\n collection: {\n collectionId: string;\n entityTypeSource: 'cms';\n };\n};\n\ntype CollectionPageAction = {\n type: 'action';\n action: {\n item: CollectionPageActionConfig;\n };\n menu?: never;\n};\n\ntype CollectionPageMenu = {\n type: 'menu';\n menu: {\n label: string;\n items: (CollectionPageActionConfig | DividerActionConfig)[];\n };\n action?: never;\n};\n\nexport type CollectionPagePrimaryActions =\n | CollectionPageAction\n | CollectionPageMenu;\n\nexport type CollectionPageSecondaryActions =\n | CollectionPageAction\n | CollectionPageMenu;\n\nexport interface CollectionPageActionParams {\n collectionId: string;\n}\n\nexport type CustomActionCollectionPageActionParams =\n CustomActionParams<CollectionPageActionParams>;\n\nexport type CustomActionCollectionPageActionResolver = (\n params: CustomActionCollectionPageActionParams,\n) => ResolvedAction;\n\nexport interface CustomActionCollectionPageActionModalProps\n extends CustomActionModalProps {\n actionParams: CollectionPageActionParams;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/types/actions/collectionPageActions.ts"],"sourcesContent":["import {\n CustomActionModalProps,\n CustomActionParams,\n ResolvedAction,\n} from '../../exports/types';\nimport {\n CreateActionConfig,\n CustomActionConfig,\n DividerActionConfig,\n} from './base';\n\nexport type CollectionPageActionConfig = (\n | CreateActionConfig\n | CustomActionConfig\n) & {\n collection: {\n collectionId: string;\n entityTypeSource: 'cms';\n };\n};\n\ntype CollectionPageAction = {\n type: 'action';\n action: {\n item: CollectionPageActionConfig;\n };\n menu?: never;\n};\n\ntype CollectionPageMenu = {\n type: 'menu';\n menu: {\n label: string;\n items: (CollectionPageActionConfig | DividerActionConfig)[];\n };\n action?: never;\n};\n\nexport type CollectionPagePrimaryActions =\n | CollectionPageAction\n | CollectionPageMenu;\n\nexport type CollectionPageSecondaryActions =\n | CollectionPageAction\n | CollectionPageMenu;\n\nexport interface CollectionPageActionParams {\n collectionId: string;\n}\n\nexport type CustomActionCollectionPageActionParams =\n CustomActionParams<CollectionPageActionParams>;\n\nexport type CustomActionCollectionPageActionResolver = (\n params: CustomActionCollectionPageActionParams,\n) => ResolvedAction;\n\nexport interface CustomActionCollectionPageActionModalProps\n extends CustomActionModalProps {\n actionParams: CollectionPageActionParams;\n}\n\nexport type CollectionPageOnRowClickActionConfig = CustomActionConfig & {\n item: any;\n};\n\nexport interface CollectionPageActionOnRowClickParams {\n item: any;\n}\n\nexport type CustomActionCollectionPageActionOnRowClickParams =\n CustomActionParams<CollectionPageActionOnRowClickParams>;\n\nexport type CustomActionCollectionPageActionOnRowClickResolver = (\n params: CustomActionCollectionPageActionOnRowClickParams,\n) => ResolvedAction;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -5,7 +5,8 @@ exports.resolveAction = void 0;
|
|
|
5
5
|
const resolveAction = (actionConfig, action) => {
|
|
6
6
|
return {
|
|
7
7
|
...action,
|
|
8
|
-
label: actionConfig.label ?? action.label
|
|
8
|
+
label: actionConfig.label ?? action.label,
|
|
9
|
+
skin: actionConfig.skin
|
|
9
10
|
};
|
|
10
11
|
};
|
|
11
12
|
exports.resolveAction = resolveAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["resolveAction","actionConfig","action","label","exports"],"sources":["../../../../src/utils/actions/resolveAction.ts"],"sourcesContent":["import { BaseActionItemConfig, ResolvedAction } from '../../types';\n\nexport const resolveAction = (\n actionConfig: BaseActionItemConfig,\n action: Partial<ResolvedAction>,\n) => {\n return {\n ...action,\n label: actionConfig.label ?? action.label,\n };\n};\n"],"mappings":";;;;AAEO,MAAMA,aAAa,GAAGA,CAC3BC,YAAkC,EAClCC,MAA+B,KAC5B;EACH,OAAO;IACL,GAAGA,MAAM;IACTC,KAAK,EAAEF,YAAY,CAACE,KAAK,IAAID,MAAM,CAACC;
|
|
1
|
+
{"version":3,"names":["resolveAction","actionConfig","action","label","skin","exports"],"sources":["../../../../src/utils/actions/resolveAction.ts"],"sourcesContent":["import { BaseActionItemConfig, ResolvedAction } from '../../types';\n\nexport const resolveAction = (\n actionConfig: BaseActionItemConfig,\n action: Partial<ResolvedAction>,\n) => {\n return {\n ...action,\n label: actionConfig.label ?? action.label,\n skin: actionConfig.skin,\n };\n};\n"],"mappings":";;;;AAEO,MAAMA,aAAa,GAAGA,CAC3BC,YAAkC,EAClCC,MAA+B,KAC5B;EACH,OAAO;IACL,GAAGA,MAAM;IACTC,KAAK,EAAEF,YAAY,CAACE,KAAK,IAAID,MAAM,CAACC,KAAK;IACzCC,IAAI,EAAEH,YAAY,CAACG;EACrB,CAAC;AACH,CAAC;AAACC,OAAA,CAAAL,aAAA,GAAAA,aAAA","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}\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 ActionCellBaseParams {\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":[]}
|
|
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 ActionCellBaseParams {\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":[]}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
## ActionCell Configuration
|
|
2
|
+
|
|
3
|
+
The ActionCell feature adds an interactive action column to collection tables or grid views, enabling users to perform operations on individual entities.
|
|
4
|
+
|
|
5
|
+
### Placement and Structure
|
|
6
|
+
|
|
7
|
+
The ActionCell has a two-level structure:
|
|
8
|
+
* `primaryAction`: A single prominent action shown directly in the table/grid row
|
|
9
|
+
* `secondaryActions`: Additional actions shown in a dropdown menu
|
|
10
|
+
|
|
11
|
+
Both properties are optional, but at least one should be provided for the ActionCell to be useful.
|
|
12
|
+
|
|
13
|
+
### Inline Secondary Actions
|
|
14
|
+
|
|
15
|
+
**New Feature**: By default, all secondary actions are hidden in a popover menu that appears when the user hovers over or clicks the "more actions" button. However, you can now configure some secondary actions to display inline directly in the table row for improved accessibility and reduced clicks.
|
|
16
|
+
|
|
17
|
+
### Action Types Reference
|
|
18
|
+
|
|
19
|
+
1. **Update Action** (`type: "update"`):
|
|
20
|
+
- ✓ Use when: Editing entity fields or navigating to a detailed edit page
|
|
21
|
+
- ✓ Common scenarios:
|
|
22
|
+
- Full entity editing (use page mode)
|
|
23
|
+
- ✓ Built-in functionality: No custom implementation needed
|
|
24
|
+
|
|
25
|
+
2. **Delete Action** (`type: "delete"`):
|
|
26
|
+
- ✓ Use when: Removing entities with confirmation
|
|
27
|
+
- ✓ Common scenarios:
|
|
28
|
+
- Deleting records with confirmation
|
|
29
|
+
- Soft-delete with status update
|
|
30
|
+
- ✓ Built-in functionality: No custom implementation needed
|
|
31
|
+
|
|
32
|
+
3. **Custom Action** (`type: "custom"`):
|
|
33
|
+
- ✓ Use when: Executing custom JavaScript without UI
|
|
34
|
+
- ✓ Common scenarios:
|
|
35
|
+
- API calls
|
|
36
|
+
- Browser interactions (alerts, downloads)
|
|
37
|
+
- Complex operations
|
|
38
|
+
- ⚠️ Requires implementation: Must register action in overrides
|
|
39
|
+
|
|
40
|
+
### Action Appearance: The `skin` Property
|
|
41
|
+
|
|
42
|
+
All action types support the optional `skin` property to customize the visual appearance of action buttons. The skin determines the button's color scheme and visual emphasis.
|
|
43
|
+
|
|
44
|
+
#### Skin Values by Action Type:
|
|
45
|
+
|
|
46
|
+
**Primary Actions** support these skin values:
|
|
47
|
+
- `"standard"` - Default appearance (blue primary button)
|
|
48
|
+
- `"inverted"` - Inverted color scheme
|
|
49
|
+
- `"premium"` - Premium styling for premium features
|
|
50
|
+
|
|
51
|
+
**Secondary Actions** support these skin values:
|
|
52
|
+
- `"dark"` - Dark appearance
|
|
53
|
+
- `"destructive"` - Red appearance for dangerous actions (ideal for delete operations)
|
|
54
|
+
- `"premium"` - Premium styling for premium features
|
|
55
|
+
|
|
56
|
+
### Type Selection Decision Tree
|
|
57
|
+
|
|
58
|
+
When choosing an action type, follow this decision process:
|
|
59
|
+
|
|
60
|
+
1. IF editing entity fields:
|
|
61
|
+
→ Use `type: "update"`
|
|
62
|
+
a. IF complex edits → Use `mode: "page"`
|
|
63
|
+
|
|
64
|
+
2. IF removing entities:
|
|
65
|
+
→ Use `type: "delete"`
|
|
66
|
+
|
|
67
|
+
3. IF executing custom logic without UI:
|
|
68
|
+
→ Use `type: "custom"`
|
|
69
|
+
- MUST implement action handler
|
|
70
|
+
- MUST register with `actions` override
|
|
71
|
+
|
|
72
|
+
### Update Action Configuration
|
|
73
|
+
|
|
74
|
+
Update actions edit entities by navigating to an entity page.
|
|
75
|
+
|
|
76
|
+
#### Validation Rules:
|
|
77
|
+
|
|
78
|
+
1. If `update.mode` is `"page"`:
|
|
79
|
+
- `update.page` must exist
|
|
80
|
+
- `update.page.id` must match an entity page ID in the configuration
|
|
81
|
+
|
|
82
|
+
### Delete Action Configuration
|
|
83
|
+
|
|
84
|
+
Delete actions remove entities with a confirmation modal.
|
|
85
|
+
|
|
86
|
+
#### Validation Rules:
|
|
87
|
+
|
|
88
|
+
1. `delete.mode` must be `"modal"` (currently only modal is supported)
|
|
89
|
+
2. `delete.modal` object must exist
|
|
90
|
+
3. The modal properties (title, description, actions, feedback) are all optional
|
|
91
|
+
|
|
92
|
+
### Custom Action Configuration
|
|
93
|
+
|
|
94
|
+
Custom actions execute JavaScript code that you define. These actions receive parameters that give them access to entity data and utilities. Here's how to implement a custom action:
|
|
95
|
+
|
|
96
|
+
1. First, create the actions folder structure in your page folder:
|
|
97
|
+
```
|
|
98
|
+
your-page/
|
|
99
|
+
├── page.tsx
|
|
100
|
+
└── components/
|
|
101
|
+
└── actions/
|
|
102
|
+
├── index.tsx // Exports all actions
|
|
103
|
+
└── downloadPetDetails.tsx // Your custom action (name = action id)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
2. Create your action handler in `downloadPetDetails.tsx` (note: the filename and function name MUST match your action id):
|
|
107
|
+
```typescript
|
|
108
|
+
import { CustomActionCellActionResolver } from '@wix/auto-patterns';
|
|
109
|
+
import { Download } from '@wix/wix-ui-icons-common';
|
|
110
|
+
import React from 'react';
|
|
111
|
+
|
|
112
|
+
// IMPORTANT: Function name MUST match the action id in your configuration
|
|
113
|
+
export const downloadPetDetails: CustomActionCellActionResolver = (params) => {
|
|
114
|
+
const { actionParams, sdk } = params;
|
|
115
|
+
const { item } = actionParams;
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
label: 'Download Details',
|
|
119
|
+
icon: <Download />,
|
|
120
|
+
onClick: () => {
|
|
121
|
+
// sdk is provided to custom action resolvers (see SDK Utilities section)
|
|
122
|
+
const optimisticActions = sdk.getOptimisticActions(sdk.collectionId);
|
|
123
|
+
const schema = sdk.getSchema(sdk.collectionId);
|
|
124
|
+
|
|
125
|
+
// Example: Mark pet as downloaded
|
|
126
|
+
const updatedItem = { ...item, lastDownloaded: new Date() };
|
|
127
|
+
optimisticActions.updateOne(updatedItem, {
|
|
128
|
+
submit: async (items) => {
|
|
129
|
+
// Your download logic here + update server
|
|
130
|
+
return await schema.actions.update(items[0]);
|
|
131
|
+
},
|
|
132
|
+
successToast: 'Pet details downloaded',
|
|
133
|
+
errorToast: (err, {retry}) => ({
|
|
134
|
+
text: 'Download failed',
|
|
135
|
+
action: { text: 'Retry', onClick: retry }
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
3. Export your action in `actions/index.tsx`:
|
|
144
|
+
```typescript
|
|
145
|
+
export * from './downloadPetDetails';
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Important:** Every time you create a new action, you must add a corresponding export line to this `index.tsx` file. For example, if you create `sendEmail.tsx`, you must add `export * from './sendEmail';` to the index file.
|
|
149
|
+
|
|
150
|
+
4. Configure the action in your JSON configuration:
|
|
151
|
+
```ts
|
|
152
|
+
{
|
|
153
|
+
"id": "downloadPetDetails", // MUST match the function name exactly
|
|
154
|
+
"type": "custom", // REQUIRED: Must be exactly "custom"
|
|
155
|
+
"label": "Download Details", // Optional: Displayed text
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
5. Register your action in the `PatternsWizardOverridesProvider`:
|
|
160
|
+
```typescript
|
|
161
|
+
import * as actions from './components/actions';
|
|
162
|
+
|
|
163
|
+
<PatternsWizardOverridesProvider value={{ actions }}>
|
|
164
|
+
<AutoPatternsApp configuration={config as AppConfig} />
|
|
165
|
+
</PatternsWizardOverridesProvider>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Key Points for Custom Actions:
|
|
169
|
+
- The action `id` in the configuration MUST exactly match the function name exported from your actions folder
|
|
170
|
+
- The function name and file name should follow a consistent naming convention (e.g., camelCase)
|
|
171
|
+
- The implementation must be exported as a named export (not default export)
|
|
172
|
+
- The implementation must use the `CustomActionCellActionResolver` type
|
|
173
|
+
|
|
174
|
+
#### Validation Rules for Custom Actions:
|
|
175
|
+
|
|
176
|
+
1. `id` must:
|
|
177
|
+
- Match exactly the function name of the custom action implementation
|
|
178
|
+
- Be registered in the `actions` property of your `PatternsWizardOverridesProvider`
|
|
179
|
+
- Follow JavaScript identifier naming rules (camelCase recommended)
|
|
180
|
+
|
|
181
|
+
2. The implementation must return an object with:
|
|
182
|
+
- `label`: Text displayed for the action
|
|
183
|
+
- `icon`: An Icon component from "@wix/wix-ui-icons-common"
|
|
184
|
+
- `onClick`: Handler function for the action
|
|
185
|
+
|
|
186
|
+
3. The implementation must:
|
|
187
|
+
- Use the correct type: `CustomActionCellActionResolver`
|
|
188
|
+
- Be exported as a named export
|
|
189
|
+
- Have a filename matching the function name
|
|
190
|
+
|
|
191
|
+
### Key Implementation Decisions
|
|
192
|
+
|
|
193
|
+
Follow this decision process when implementing ActionCell:
|
|
194
|
+
|
|
195
|
+
1. **Basic Decision**: Decide which actions users need to perform on entities:
|
|
196
|
+
- Edit entities? → Use `update` actions
|
|
197
|
+
- Delete entities? → Use `delete` actions
|
|
198
|
+
- Custom operations? → Use `custom` actions
|
|
199
|
+
|
|
200
|
+
2. **Primary vs Secondary**: Choose the most common/important action as primary:
|
|
201
|
+
- Most common operation (typically Edit) → Place in `primaryAction.item`
|
|
202
|
+
- Less common operations → Place in `secondaryActions.items` array
|
|
203
|
+
|
|
204
|
+
3. **Inline Secondary Actions Strategy**:
|
|
205
|
+
- **Action Prioritization**: Order `secondaryActions.items` by frequency of use (most used first)
|
|
206
|
+
- **Inline Count**: Use `inlineCount: 1-3` for optimal UX (avoid cluttering)
|
|
207
|
+
- **Visibility Control**:
|
|
208
|
+
- Use `inlineAlwaysVisible: false` (default) for cleaner visual appearance
|
|
209
|
+
- Use `inlineAlwaysVisible: true` only for critical actions requiring constant visibility
|
|
210
|
+
|
|
211
|
+
4. **Update Action Mode**:
|
|
212
|
+
- Complex, full-entity edits → Use `mode: "page"` to navigate to entity page
|
|
213
|
+
|
|
214
|
+
5. **Custom Implementation**:
|
|
215
|
+
- For `custom` actions, you must provide implementations in your code and register them with `PatternsWizardOverridesProvider`
|
|
216
|
+
|
|
217
|
+
### ActionCell Validation Checklist
|
|
218
|
+
|
|
219
|
+
AI agents should verify these requirements before generating ActionCell configurations:
|
|
220
|
+
|
|
221
|
+
✓ ActionCell is placed directly inside `table` or `grid` configuration
|
|
222
|
+
✓ Each action has a unique `id` and correct `type` value
|
|
223
|
+
✓ Each action type only includes its required field(s)
|
|
224
|
+
✓ Update page action refers to a valid entity page ID
|
|
225
|
+
✓ Delete action has a modal configuration
|
|
226
|
+
✓ Custom actions match implementations in overrides
|
|
227
|
+
✓ At least one of `primaryAction` or `secondaryActions` is provided
|
|
228
|
+
✓ `inlineCount` (if specified) is a non-negative number ≤ total secondary actions count
|
|
229
|
+
✓ `inlineAlwaysVisible` (if specified) is a boolean value
|
|
230
|
+
✓ Inline secondary actions configuration is applied only when secondary actions exist
|
|
231
|
+
✓ `skin` property (if specified) uses valid skin values:
|
|
232
|
+
- Primary actions: `"standard"`, `"inverted"`, `"premium"`
|
|
233
|
+
- Secondary actions: `"dark"`, `"destructive"`, `"premium"`
|