@wix/auto-patterns 1.14.0 → 1.16.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 +17 -6
- 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 +14 -5
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
- package/dist/cjs/components/filters/DynamicCollectionFilter.js +5 -11
- package/dist/cjs/components/filters/DynamicCollectionFilter.js.map +1 -1
- package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js +51 -88
- package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
- package/dist/cjs/dataSourceAdapters/cms/fetchCmsData.js +43 -0
- package/dist/cjs/dataSourceAdapters/cms/fetchCmsData.js.map +1 -0
- package/dist/cjs/dataSourceAdapters/cms/filterUtils.js +15 -15
- package/dist/cjs/dataSourceAdapters/cms/filterUtils.js.map +1 -1
- package/dist/cjs/dataSourceAdapters/cms/sortUtils.js +2 -2
- package/dist/cjs/dataSourceAdapters/cms/sortUtils.js.map +1 -1
- package/dist/cjs/dataSourceAdapters/factory.js +0 -20
- package/dist/cjs/dataSourceAdapters/factory.js.map +1 -1
- package/dist/cjs/hooks/useActionCell.js +0 -6
- package/dist/cjs/hooks/useActionCell.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/useBulkActionToolbar.js +1 -7
- package/dist/cjs/hooks/useBulkActionToolbar.js.map +1 -1
- package/dist/cjs/hooks/useCollectionPageActions.js +2 -8
- package/dist/cjs/hooks/useCollectionPageActions.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/useFetchData.js +9 -29
- package/dist/cjs/hooks/useFetchData.js.map +1 -1
- package/dist/cjs/hooks/useFilters.js +2 -2
- package/dist/cjs/hooks/useFilters.js.map +1 -1
- package/dist/cjs/hooks/useGridFeatures.js +3 -4
- package/dist/cjs/hooks/useGridFeatures.js.map +1 -1
- package/dist/cjs/hooks/useTableFeatures.js +3 -4
- package/dist/cjs/hooks/useTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js +3 -4
- package/dist/cjs/hooks/useTableGridSwitchFeatures.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 +32 -8
- package/dist/cjs/providers/SchemaContext.js.map +1 -1
- package/dist/cjs/types/CollectionPageConfig.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/base.js.map +1 -1
- package/dist/cjs/types/actions/bulkActions.js.map +1 -1
- package/dist/cjs/types/actions/collectionPageActions.js.map +1 -1
- package/dist/cjs/types/index.js +6 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/providers.js +4 -0
- package/dist/cjs/types/providers.js.map +1 -0
- package/dist/cjs/types/types.js.map +1 -1
- package/dist/cjs/utils/actions/index.js +0 -6
- package/dist/cjs/utils/actions/index.js.map +1 -1
- package/dist/cjs/utils/actions/types.js.map +1 -1
- package/dist/docs/action_cell.md +214 -0
- package/dist/docs/app_config_structure.md +355 -0
- package/dist/docs/auto-patterns-guide.md +2447 -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 +786 -0
- package/dist/docs/recipe-customization.md +1702 -0
- package/dist/docs/recipe-first-dashboard.md +794 -0
- package/dist/docs/sdk_and_schema.md +215 -0
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +7 -2
- 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 -2
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
- package/dist/esm/components/filters/DynamicCollectionFilter.js +4 -10
- package/dist/esm/components/filters/DynamicCollectionFilter.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +54 -88
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/fetchCmsData.js +42 -0
- package/dist/esm/dataSourceAdapters/cms/fetchCmsData.js.map +1 -0
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js +15 -15
- 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/dataSourceAdapters/factory.js +1 -21
- package/dist/esm/dataSourceAdapters/factory.js.map +1 -1
- package/dist/esm/hooks/useActionCell.js +1 -7
- package/dist/esm/hooks/useActionCell.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/useBulkActionToolbar.js +1 -7
- package/dist/esm/hooks/useBulkActionToolbar.js.map +1 -1
- package/dist/esm/hooks/useCollectionPageActions.js +1 -7
- package/dist/esm/hooks/useCollectionPageActions.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/useFetchData.js +9 -29
- package/dist/esm/hooks/useFetchData.js.map +1 -1
- package/dist/esm/hooks/useFilters.js +2 -2
- package/dist/esm/hooks/useFilters.js.map +1 -1
- package/dist/esm/hooks/useGridFeatures.js +3 -4
- package/dist/esm/hooks/useGridFeatures.js.map +1 -1
- package/dist/esm/hooks/useTableFeatures.js +3 -4
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useTableGridSwitchFeatures.js +3 -4
- package/dist/esm/hooks/useTableGridSwitchFeatures.js.map +1 -1
- package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/esm/providers/SchemaContext.js +31 -7
- package/dist/esm/providers/SchemaContext.js.map +1 -1
- package/dist/esm/types/CollectionPageConfig.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/base.js.map +1 -1
- package/dist/esm/types/actions/bulkActions.js.map +1 -1
- package/dist/esm/types/actions/collectionPageActions.js.map +1 -1
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/providers.js +2 -0
- package/dist/esm/types/providers.js.map +1 -0
- package/dist/esm/types/types.js.map +1 -1
- package/dist/esm/utils/actions/index.js +0 -2
- package/dist/esm/utils/actions/index.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/components/filters/DynamicCollectionFilter.d.ts.map +1 -1
- package/dist/types/dataSourceAdapters/cms/cmsAdapter.d.ts +1 -10
- package/dist/types/dataSourceAdapters/cms/cmsAdapter.d.ts.map +1 -1
- package/dist/types/dataSourceAdapters/cms/fetchCmsData.d.ts +13 -0
- package/dist/types/dataSourceAdapters/cms/fetchCmsData.d.ts.map +1 -0
- package/dist/types/dataSourceAdapters/cms/filterUtils.d.ts +9 -7
- package/dist/types/dataSourceAdapters/cms/filterUtils.d.ts.map +1 -1
- package/dist/types/dataSourceAdapters/cms/sortUtils.d.ts +2 -2
- package/dist/types/dataSourceAdapters/cms/sortUtils.d.ts.map +1 -1
- package/dist/types/dataSourceAdapters/factory.d.ts +1 -11
- package/dist/types/dataSourceAdapters/factory.d.ts.map +1 -1
- package/dist/types/hooks/useActionCell.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/useBulkActionToolbar.d.ts.map +1 -1
- package/dist/types/hooks/useCollectionPageActions.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/useEntityPageHeaderTexts.d.ts.map +1 -1
- package/dist/types/hooks/useFetchData.d.ts +13 -7
- package/dist/types/hooks/useFetchData.d.ts.map +1 -1
- package/dist/types/hooks/useFilters.d.ts +1 -1
- package/dist/types/hooks/useGridFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useTableFeatures.d.ts +1 -1
- package/dist/types/hooks/useTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +1 -1
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts.map +1 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts +4 -5
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
- package/dist/types/providers/SchemaContext.d.ts +4 -4
- package/dist/types/providers/SchemaContext.d.ts.map +1 -1
- package/dist/types/types/CollectionPageConfig.d.ts +4 -8
- package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
- package/dist/types/types/EntityPageConfig.d.ts +3 -4
- package/dist/types/types/EntityPageConfig.d.ts.map +1 -1
- package/dist/types/types/actions/actionCell.d.ts +2 -2
- package/dist/types/types/actions/actionCell.d.ts.map +1 -1
- package/dist/types/types/actions/base.d.ts +0 -7
- package/dist/types/types/actions/base.d.ts.map +1 -1
- package/dist/types/types/actions/bulkActions.d.ts +2 -2
- package/dist/types/types/actions/bulkActions.d.ts.map +1 -1
- package/dist/types/types/actions/collectionPageActions.d.ts +10 -2
- package/dist/types/types/actions/collectionPageActions.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/providers.d.ts +11 -0
- package/dist/types/types/providers.d.ts.map +1 -0
- package/dist/types/types/types.d.ts +25 -1
- package/dist/types/types/types.d.ts.map +1 -1
- package/dist/types/utils/actions/index.d.ts +0 -2
- package/dist/types/utils/actions/index.d.ts.map +1 -1
- package/dist/types/utils/actions/types.d.ts +1 -4
- package/dist/types/utils/actions/types.d.ts.map +1 -1
- package/package.json +21 -16
- package/dist/cjs/utils/actions/customModalAction.js +0 -22
- package/dist/cjs/utils/actions/customModalAction.js.map +0 -1
- package/dist/esm/utils/actions/customModalAction.js +0 -17
- package/dist/esm/utils/actions/customModalAction.js.map +0 -1
- package/dist/types/utils/actions/customModalAction.d.ts +0 -5
- package/dist/types/utils/actions/customModalAction.d.ts.map +0 -1
|
@@ -5,22 +5,46 @@ exports.useSchema = exports.SchemaProvider = void 0;
|
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _factory = require("../dataSourceAdapters/factory");
|
|
7
7
|
var _SchemaRegistryContext = require("./SchemaRegistryContext");
|
|
8
|
+
var _PatternsWizardOverridesContext = require("./PatternsWizardOverridesContext");
|
|
9
|
+
var _patterns = require("@wix/patterns");
|
|
8
10
|
var _jsxFileName = "/home/builduser/work/73d19ce3378ce4dd/packages/auto-patterns/dist/cjs/providers/SchemaContext.tsx";
|
|
9
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); }
|
|
10
12
|
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; }
|
|
11
13
|
const SchemaContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
12
14
|
const SchemaProvider = ({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
collection,
|
|
16
|
+
children,
|
|
17
|
+
skeleton
|
|
16
18
|
}) => {
|
|
19
|
+
var _collection$custom;
|
|
20
|
+
const {
|
|
21
|
+
collectionId,
|
|
22
|
+
entityTypeSource
|
|
23
|
+
} = collection;
|
|
24
|
+
const customDataSourceId = collection.entityTypeSource === 'custom' && 'custom' in collection ? (_collection$custom = collection.custom) == null ? void 0 : _collection$custom.id : undefined;
|
|
17
25
|
const {
|
|
18
26
|
getSchema: getSchemaFromRegistry,
|
|
19
27
|
addSchema: addSchemaToRegistry
|
|
20
28
|
} = (0, _SchemaRegistryContext.useSchemaRegistry)();
|
|
21
29
|
const [schema, setSchema] = (0, _react.useState)(null);
|
|
22
30
|
const [isLoading, setIsLoading] = (0, _react.useState)(false);
|
|
31
|
+
const overrides = (0, _PatternsWizardOverridesContext.usePatternsWizardOverridesContext)();
|
|
32
|
+
const {
|
|
33
|
+
httpClient
|
|
34
|
+
} = (0, _patterns.useWixPatternsContainer)();
|
|
23
35
|
(0, _react.useEffect)(() => {
|
|
36
|
+
const fetchSchemaForCollection = async (targetCollectionId, targetCustomDataSourceId) => {
|
|
37
|
+
if (entityTypeSource === 'custom' && targetCustomDataSourceId && overrides != null && overrides.customDataSources) {
|
|
38
|
+
const customSchemaProvider = overrides.customDataSources[targetCustomDataSourceId];
|
|
39
|
+
if (customSchemaProvider) {
|
|
40
|
+
return customSchemaProvider(targetCollectionId, {
|
|
41
|
+
httpClient
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Custom schema provider '${targetCustomDataSourceId}' not found`);
|
|
45
|
+
}
|
|
46
|
+
return (0, _factory.getSchema)(targetCollectionId, entityTypeSource);
|
|
47
|
+
};
|
|
24
48
|
const fetchReferencedSchemas = async referencedSchema => {
|
|
25
49
|
const referencedCollectionIds = new Set();
|
|
26
50
|
Object.values(referencedSchema.fields).forEach(field => {
|
|
@@ -38,7 +62,7 @@ const SchemaProvider = ({
|
|
|
38
62
|
}
|
|
39
63
|
const fetchPromises = Array.from(referencedCollectionIds).map(async refCollectionId => {
|
|
40
64
|
try {
|
|
41
|
-
const refSchema = await (
|
|
65
|
+
const refSchema = await fetchSchemaForCollection(refCollectionId);
|
|
42
66
|
addSchemaToRegistry(refCollectionId, refSchema);
|
|
43
67
|
await fetchReferencedSchemas(refSchema);
|
|
44
68
|
} catch (error) {
|
|
@@ -53,7 +77,7 @@ const SchemaProvider = ({
|
|
|
53
77
|
return;
|
|
54
78
|
}
|
|
55
79
|
setIsLoading(true);
|
|
56
|
-
(
|
|
80
|
+
fetchSchemaForCollection(collectionId, customDataSourceId).then(async fetchedSchema => {
|
|
57
81
|
setSchema(fetchedSchema);
|
|
58
82
|
addSchemaToRegistry(collectionId, fetchedSchema);
|
|
59
83
|
await fetchReferencedSchemas(fetchedSchema);
|
|
@@ -62,16 +86,16 @@ const SchemaProvider = ({
|
|
|
62
86
|
}).finally(() => {
|
|
63
87
|
setIsLoading(false);
|
|
64
88
|
});
|
|
65
|
-
}, [collectionId, entityTypeSource, addSchemaToRegistry, getSchemaFromRegistry]);
|
|
89
|
+
}, [collectionId, entityTypeSource, customDataSourceId, addSchemaToRegistry, getSchemaFromRegistry, overrides, httpClient]);
|
|
66
90
|
if (!schema || isLoading) {
|
|
67
|
-
return
|
|
91
|
+
return skeleton;
|
|
68
92
|
}
|
|
69
93
|
return /*#__PURE__*/_react.default.createElement(SchemaContext.Provider, {
|
|
70
94
|
value: schema,
|
|
71
95
|
__self: void 0,
|
|
72
96
|
__source: {
|
|
73
97
|
fileName: _jsxFileName,
|
|
74
|
-
lineNumber:
|
|
98
|
+
lineNumber: 135,
|
|
75
99
|
columnNumber: 5
|
|
76
100
|
}
|
|
77
101
|
}, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_factory","_SchemaRegistryContext","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SchemaContext","createContext","SchemaProvider","collectionId","entityTypeSource","children","getSchema","getSchemaFromRegistry","addSchema","addSchemaToRegistry","useSchemaRegistry","schema","setSchema","useState","isLoading","setIsLoading","useEffect","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","Error"],"sources":["../../../src/providers/SchemaContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useEffect,\n useState,\n ReactNode,\n} from 'react';\n\nimport { SchemaConfig } from '../types';\nimport { getSchema } from '../dataSourceAdapters/factory';\nimport { useSchemaRegistry } from './SchemaRegistryContext';\n\nconst SchemaContext = createContext<SchemaConfig | null>(null);\n\ninterface SchemaProviderProps {\n collectionId: string;\n entityTypeSource: string;\n children: ReactNode;\n}\n\nexport const SchemaProvider = ({\n collectionId,\n entityTypeSource,\n children,\n}: SchemaProviderProps) => {\n const { getSchema: getSchemaFromRegistry, addSchema: addSchemaToRegistry } =\n useSchemaRegistry();\n const [schema, setSchema] = useState<SchemaConfig | null>(null);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n\n useEffect(() => {\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 getSchema(\n refCollectionId,\n entityTypeSource,\n );\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\n setIsLoading(true);\n getSchema(collectionId, entityTypeSource)\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 addSchemaToRegistry,\n getSchemaFromRegistry,\n ]);\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;AAA4D,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,GAA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["_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,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QAAiC,CAAC;AAE9E,CAAC;AAACkE,OAAA,CAAApE,cAAA,GAAAA,cAAA;AAEK,MAAMqE,SAAS,GAAGA,CAAA,KAAoB;EAC3C,MAAMC,OAAO,GAAG,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
|
|
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/EntityPageConfig.ts"],"sourcesContent":["import { FieldValues, UseFormReturn } from '@wix/patterns/form';\nimport { EntityPageMoreActions } from './actions/entityPageActions';\n\nexport
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/types/EntityPageConfig.ts"],"sourcesContent":["import { FieldValues, UseFormReturn } from '@wix/patterns/form';\nimport { EntityPageMoreActions } from './actions/entityPageActions';\nimport { BaseCollectionConfig } from './types';\n\nexport type EntityPageConfig = {\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 moreActions?: EntityPageMoreActions;\n} & BaseCollectionConfig;\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
|
|
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}\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 CustomActionCellActionResolver = (\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/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
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../../src/types/actions/bulkActions.ts"],"sourcesContent":["import {\n BaseActionParams,\n CustomActionModalProps,\n ResolvedAction,\n} from '../../exports/types';\nimport {\n BulkDeleteActionConfig,\n CustomActionConfig,\n
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/types/actions/bulkActions.ts"],"sourcesContent":["import {\n BaseActionParams,\n CustomActionModalProps,\n ResolvedAction,\n} from '../../exports/types';\nimport {\n BulkDeleteActionConfig,\n CustomActionConfig,\n DividerActionConfig,\n} from './base';\n\nexport type BulkActionItemConfig = BulkDeleteActionConfig | CustomActionConfig;\n\ntype BulkActionItem = {\n type: 'action';\n action: {\n item: BulkActionItemConfig;\n };\n menu?: never;\n};\n\ntype BulkActionMenu = {\n type: 'menu';\n menu: {\n label: string;\n items: (BulkActionItemConfig | DividerActionConfig)[];\n };\n action?: never;\n};\n\nexport interface BulkActionsConfig {\n primaryActions?: (BulkActionItem | BulkActionMenu)[];\n secondaryActions?: (BulkActionItemConfig | DividerActionConfig)[];\n}\n\nexport interface BulkActionsActionParams {\n selectedValues: any[];\n total: number;\n}\n\nexport interface CustomBulkActionsActionParams extends BaseActionParams {\n actionParams: BulkActionsActionParams;\n}\nexport type CustomBulkActionsActionResolver = (\n params: CustomBulkActionsActionParams,\n) => ResolvedAction;\n\nexport interface CustomBulkActionsActionModalProps\n extends CustomActionModalProps {\n actionParams: BulkActionsActionParams;\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
|
|
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":[]}
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -19,6 +19,12 @@ Object.keys(_EntityPageConfig).forEach(function (key) {
|
|
|
19
19
|
if (key in exports && exports[key] === _EntityPageConfig[key]) return;
|
|
20
20
|
exports[key] = _EntityPageConfig[key];
|
|
21
21
|
});
|
|
22
|
+
var _providers = require("./providers");
|
|
23
|
+
Object.keys(_providers).forEach(function (key) {
|
|
24
|
+
if (key === "default" || key === "__esModule") return;
|
|
25
|
+
if (key in exports && exports[key] === _providers[key]) return;
|
|
26
|
+
exports[key] = _providers[key];
|
|
27
|
+
});
|
|
22
28
|
var _actions = require("./actions");
|
|
23
29
|
Object.keys(_actions).forEach(function (key) {
|
|
24
30
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","Object","keys","forEach","key","exports","_CollectionPageConfig","_EntityPageConfig","_actions","_types2","_BaseSDK"],"sources":["../../../src/types/index.ts"],"sourcesContent":["export * from './types';\nexport * from './CollectionPageConfig';\nexport * from './EntityPageConfig';\nexport * from './actions';\nexport * from '../utils/actions/types';\nexport * from './BaseSDK';\n"],"mappings":";;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAL,MAAA,CAAAK,GAAA;AAAA;AACA,IAAAE,qBAAA,GAAAN,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAI,qBAAA,EAAAH,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAE,qBAAA,CAAAF,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAE,qBAAA,CAAAF,GAAA;AAAA;AACA,IAAAG,iBAAA,GAAAP,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAK,iBAAA,EAAAJ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAG,iBAAA,CAAAH,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAG,iBAAA,CAAAH,GAAA;AAAA;AACA,IAAAI,
|
|
1
|
+
{"version":3,"names":["_types","require","Object","keys","forEach","key","exports","_CollectionPageConfig","_EntityPageConfig","_providers","_actions","_types2","_BaseSDK"],"sources":["../../../src/types/index.ts"],"sourcesContent":["export * from './types';\nexport * from './CollectionPageConfig';\nexport * from './EntityPageConfig';\nexport * from './providers';\nexport * from './actions';\nexport * from '../utils/actions/types';\nexport * from './BaseSDK';\n"],"mappings":";;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA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AL,GAAA;AAAA;AACA,IAAAM,OAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,OAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,OAAA,CAAAN,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAM,OAAA,CAAAN,GAAA;AAAA;AACA,IAAAO,QAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,QAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,QAAA,CAAAP,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAO,QAAA,CAAAP,GAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/types/providers.ts"],"sourcesContent":["import { SchemaConfig } from './types';\nimport { CollectionConfig } from '@wix/patterns';\n\nexport interface SchemaProviderConfig {\n id: string;\n}\n\nexport interface DataProviderConfig {\n id: string;\n}\n\nexport type ExternalSchemaProvider = (\n collectionId: string,\n context: any,\n) => Promise<SchemaConfig>;\n\nexport type ExternalDataProvider = (\n collectionId: string,\n context: any,\n) => CollectionConfig<any, any>['fetchData'];\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../src/types/types.ts"],"sourcesContent":["import { EntityPageConfig } from './EntityPageConfig';\nimport { CollectionPageConfig } from './CollectionPageConfig';\n\
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/types/types.ts"],"sourcesContent":["import { EntityPageConfig } from './EntityPageConfig';\nimport { CollectionPageConfig } from './CollectionPageConfig';\nimport { ComputedQuery } from '@wix/patterns';\n\ninterface BaseCollectionConfigCommon {\n collectionId: string;\n}\n\ninterface CMSCollectionConfig extends BaseCollectionConfigCommon {\n entityTypeSource: 'cms';\n custom?: never;\n}\n\ninterface WixCollectionConfig extends BaseCollectionConfigCommon {\n entityTypeSource: 'wix';\n custom?: never;\n}\n\ninterface CustomCollectionConfig extends BaseCollectionConfigCommon {\n entityTypeSource: 'custom';\n custom: {\n id: string;\n };\n}\n\nexport type BaseCollectionConfig =\n | CMSCollectionConfig\n | WixCollectionConfig\n | CustomCollectionConfig;\n\nexport type PatternsFieldType =\n | 'SHORT_TEXT'\n | 'LONG_TEXT'\n | 'NUMBER'\n | 'BOOLEAN'\n | 'DATE'\n | 'DATETIME'\n | 'URL'\n | 'ARRAY'\n | 'REFERENCE'\n | 'IMAGE';\n\nexport interface AppConfig {\n pages: PageConfig[];\n}\n\nexport interface BasePageConfig {\n id: string;\n appMainPage?: boolean;\n}\n\nexport interface CollectionPageConfigType extends BasePageConfig {\n type: 'collectionPage';\n collectionPage: CollectionPageConfig;\n entityPage?: never;\n}\n\nexport interface EntityPageConfigType extends BasePageConfig {\n type: 'entityPage';\n entityPage: EntityPageConfig;\n collectionPage?: never;\n}\n\nexport type PageConfig = CollectionPageConfigType | EntityPageConfigType;\n\nexport type EntityProps = { [key: string]: any };\n\nexport interface IMenuItem<T extends EntityProps = any> {\n item: T;\n}\nexport interface IColumnValue<T> {\n value: T;\n row: Record<string, any>;\n}\n\nexport type QueryOperator =\n | 'CONTAINS'\n | 'ENDS_WITH'\n | 'EQ'\n | 'EXISTS'\n | 'GT'\n | 'GTE'\n | 'HAS_ALL'\n | 'HAS_SOME'\n | 'LT'\n | 'LTE'\n | 'NE'\n | 'STARTS_WITH'\n | 'URLIZED';\n\ninterface BaseField {\n id: string;\n displayName: string;\n validation?: {\n numberRange?: NumberRange;\n stringLengthRange?: StringLengthRange;\n required: boolean;\n };\n capabilities: {\n supportedQueryOperators: QueryOperator[];\n sortable: boolean;\n };\n}\n\nexport interface ReferenceField extends BaseField {\n type: 'REFERENCE';\n referenceMetadata: {\n referencedCollectionId: string;\n };\n}\n\nexport interface NonReferenceField extends BaseField {\n type: Exclude<PatternsFieldType, 'REFERENCE'>;\n}\n\nexport type Field = ReferenceField | NonReferenceField;\n\nexport interface NumberRange {\n min?: number;\n max?: number;\n}\nexport interface StringLengthRange {\n minLength?: number;\n maxLength?: number;\n}\n\nexport interface SchemaConfig {\n id: string;\n fields: Record<string, Field | undefined>;\n displayField: string;\n idField: string;\n imageField?: string;\n actions: {\n get: (entityId: string) => Promise<any>;\n create: (newEntity: Partial<any>) => Promise<any>;\n update: (updatedEntity: any) => Promise<any>;\n delete: (entityId: string) => Promise<any>;\n bulkDelete: (entityIds: string[]) => Promise<any>;\n find: (\n query: ComputedQuery<any>,\n options?: {\n searchableFieldIds?: string[];\n filterFieldMapping?: Record<string, { fieldId: string }>;\n },\n ) => Promise<{ items: any[]; total: number }>;\n };\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -31,12 +31,6 @@ Object.keys(_customAction).forEach(function (key) {
|
|
|
31
31
|
if (key in exports && exports[key] === _customAction[key]) return;
|
|
32
32
|
exports[key] = _customAction[key];
|
|
33
33
|
});
|
|
34
|
-
var _customModalAction = require("./customModalAction");
|
|
35
|
-
Object.keys(_customModalAction).forEach(function (key) {
|
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (key in exports && exports[key] === _customModalAction[key]) return;
|
|
38
|
-
exports[key] = _customModalAction[key];
|
|
39
|
-
});
|
|
40
34
|
var _createAction = require("./createAction");
|
|
41
35
|
Object.keys(_createAction).forEach(function (key) {
|
|
42
36
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_resolveAction","require","Object","keys","forEach","key","exports","_bulkDeleteAction","_updateAction","_deleteAction","_customAction","
|
|
1
|
+
{"version":3,"names":["_resolveAction","require","Object","keys","forEach","key","exports","_bulkDeleteAction","_updateAction","_deleteAction","_customAction","_createAction","_groupActions"],"sources":["../../../../src/utils/actions/index.ts"],"sourcesContent":["export * from './resolveAction';\nexport * from './bulkDeleteAction';\nexport * from './updateAction';\nexport * from './deleteAction';\nexport * from './customAction';\nexport * from './createAction';\nexport * from './groupActions';\n"],"mappings":";;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,cAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,cAAA,CAAAK,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAL,cAAA,CAAAK,GAAA;AAAA;AACA,IAAAE,iBAAA,GAAAN,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAI,iBAAA,EAAAH,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAE,iBAAA,CAAAF,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAE,iBAAA,CAAAF,GAAA;AAAA;AACA,IAAAG,aAAA,GAAAP,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAK,aAAA,EAAAJ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAG,aAAA,CAAAH,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAG,aAAA,CAAAH,GAAA;AAAA;AACA,IAAAI,aAAA,GAAAR,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAM,aAAA,EAAAL,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAI,aAAA,CAAAJ,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAI,aAAA,CAAAJ,GAAA;AAAA;AACA,IAAAK,aAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,aAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,aAAA,CAAAL,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAK,aAAA,CAAAL,GAAA;AAAA;AACA,IAAAM,aAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,aAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,aAAA,CAAAN,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAM,aAAA,CAAAN,GAAA;AAAA;AACA,IAAAO,aAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,aAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,aAAA,CAAAP,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAO,aAAA,CAAAP,GAAA;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
|
|
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":[]}
|
|
@@ -0,0 +1,214 @@
|
|
|
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
|
+
### Type Selection Decision Tree
|
|
41
|
+
|
|
42
|
+
When choosing an action type, follow this decision process:
|
|
43
|
+
|
|
44
|
+
1. IF editing entity fields:
|
|
45
|
+
→ Use `type: "update"`
|
|
46
|
+
a. IF complex edits → Use `mode: "page"`
|
|
47
|
+
|
|
48
|
+
2. IF removing entities:
|
|
49
|
+
→ Use `type: "delete"`
|
|
50
|
+
|
|
51
|
+
3. IF executing custom logic without UI:
|
|
52
|
+
→ Use `type: "custom"`
|
|
53
|
+
- MUST implement action handler
|
|
54
|
+
- MUST register with `actions` override
|
|
55
|
+
|
|
56
|
+
### Update Action Configuration
|
|
57
|
+
|
|
58
|
+
Update actions edit entities by navigating to an entity page.
|
|
59
|
+
|
|
60
|
+
#### Validation Rules:
|
|
61
|
+
|
|
62
|
+
1. If `update.mode` is `"page"`:
|
|
63
|
+
- `update.page` must exist
|
|
64
|
+
- `update.page.id` must match an entity page ID in the configuration
|
|
65
|
+
|
|
66
|
+
### Delete Action Configuration
|
|
67
|
+
|
|
68
|
+
Delete actions remove entities with a confirmation modal.
|
|
69
|
+
|
|
70
|
+
#### Validation Rules:
|
|
71
|
+
|
|
72
|
+
1. `delete.mode` must be `"modal"` (currently only modal is supported)
|
|
73
|
+
2. `delete.modal` object must exist
|
|
74
|
+
3. The modal properties (title, description, actions, feedback) are all optional
|
|
75
|
+
|
|
76
|
+
### Custom Action Configuration
|
|
77
|
+
|
|
78
|
+
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:
|
|
79
|
+
|
|
80
|
+
1. First, create the actions folder structure in your page folder:
|
|
81
|
+
```
|
|
82
|
+
your-page/
|
|
83
|
+
├── page.tsx
|
|
84
|
+
└── components/
|
|
85
|
+
└── actions/
|
|
86
|
+
├── index.tsx // Exports all actions
|
|
87
|
+
└── downloadPetDetails.tsx // Your custom action (name = action id)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
2. Create your action handler in `downloadPetDetails.tsx` (note: the filename and function name MUST match your action id):
|
|
91
|
+
```typescript
|
|
92
|
+
import { CustomActionCellActionResolver } from '@wix/auto-patterns';
|
|
93
|
+
import { Download } from '@wix/wix-ui-icons-common';
|
|
94
|
+
import React from 'react';
|
|
95
|
+
|
|
96
|
+
// IMPORTANT: Function name MUST match the action id in your configuration
|
|
97
|
+
export const downloadPetDetails: CustomActionCellActionResolver = (params) => {
|
|
98
|
+
const { actionParams, sdk } = params;
|
|
99
|
+
const { item } = actionParams;
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
label: 'Download Details',
|
|
103
|
+
icon: <Download />,
|
|
104
|
+
onClick: () => {
|
|
105
|
+
// sdk is provided to custom action resolvers (see SDK Utilities section)
|
|
106
|
+
const optimisticActions = sdk.getOptimisticActions(sdk.collectionId);
|
|
107
|
+
const schema = sdk.getSchema(sdk.collectionId);
|
|
108
|
+
|
|
109
|
+
// Example: Mark pet as downloaded
|
|
110
|
+
const updatedItem = { ...item, lastDownloaded: new Date() };
|
|
111
|
+
optimisticActions.updateOne(updatedItem, {
|
|
112
|
+
submit: async (items) => {
|
|
113
|
+
// Your download logic here + update server
|
|
114
|
+
return await schema.actions.update(items[0]);
|
|
115
|
+
},
|
|
116
|
+
successToast: 'Pet details downloaded',
|
|
117
|
+
errorToast: (err, {retry}) => ({
|
|
118
|
+
text: 'Download failed',
|
|
119
|
+
action: { text: 'Retry', onClick: retry }
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
3. Export your action in `actions/index.tsx`:
|
|
128
|
+
```typescript
|
|
129
|
+
export * from './downloadPetDetails';
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**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.
|
|
133
|
+
|
|
134
|
+
4. Configure the action in your JSON configuration:
|
|
135
|
+
```ts
|
|
136
|
+
{
|
|
137
|
+
"id": "downloadPetDetails", // MUST match the function name exactly
|
|
138
|
+
"type": "custom", // REQUIRED: Must be exactly "custom"
|
|
139
|
+
"label": "Download Details", // Optional: Displayed text
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
5. Register your action in the `PatternsWizardOverridesProvider`:
|
|
144
|
+
```typescript
|
|
145
|
+
import * as actions from './components/actions';
|
|
146
|
+
|
|
147
|
+
<PatternsWizardOverridesProvider value={{ actions }}>
|
|
148
|
+
<AutoPatternsApp configuration={config as AppConfig} />
|
|
149
|
+
</PatternsWizardOverridesProvider>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Key Points for Custom Actions:
|
|
153
|
+
- The action `id` in the configuration MUST exactly match the function name exported from your actions folder
|
|
154
|
+
- The function name and file name should follow a consistent naming convention (e.g., camelCase)
|
|
155
|
+
- The implementation must be exported as a named export (not default export)
|
|
156
|
+
- The implementation must use the `CustomActionCellActionResolver` type
|
|
157
|
+
|
|
158
|
+
#### Validation Rules for Custom Actions:
|
|
159
|
+
|
|
160
|
+
1. `id` must:
|
|
161
|
+
- Match exactly the function name of the custom action implementation
|
|
162
|
+
- Be registered in the `actions` property of your `PatternsWizardOverridesProvider`
|
|
163
|
+
- Follow JavaScript identifier naming rules (camelCase recommended)
|
|
164
|
+
|
|
165
|
+
2. The implementation must return an object with:
|
|
166
|
+
- `label`: Text displayed for the action
|
|
167
|
+
- `icon`: An Icon component from "@wix/wix-ui-icons-common"
|
|
168
|
+
- `onClick`: Handler function for the action
|
|
169
|
+
|
|
170
|
+
3. The implementation must:
|
|
171
|
+
- Use the correct type: `CustomActionCellActionResolver`
|
|
172
|
+
- Be exported as a named export
|
|
173
|
+
- Have a filename matching the function name
|
|
174
|
+
|
|
175
|
+
### Key Implementation Decisions
|
|
176
|
+
|
|
177
|
+
Follow this decision process when implementing ActionCell:
|
|
178
|
+
|
|
179
|
+
1. **Basic Decision**: Decide which actions users need to perform on entities:
|
|
180
|
+
- Edit entities? → Use `update` actions
|
|
181
|
+
- Delete entities? → Use `delete` actions
|
|
182
|
+
- Custom operations? → Use `custom` actions
|
|
183
|
+
|
|
184
|
+
2. **Primary vs Secondary**: Choose the most common/important action as primary:
|
|
185
|
+
- Most common operation (typically Edit) → Place in `primaryAction.item`
|
|
186
|
+
- Less common operations → Place in `secondaryActions.items` array
|
|
187
|
+
|
|
188
|
+
3. **Inline Secondary Actions Strategy**:
|
|
189
|
+
- **Action Prioritization**: Order `secondaryActions.items` by frequency of use (most used first)
|
|
190
|
+
- **Inline Count**: Use `inlineCount: 1-3` for optimal UX (avoid cluttering)
|
|
191
|
+
- **Visibility Control**:
|
|
192
|
+
- Use `inlineAlwaysVisible: false` (default) for cleaner visual appearance
|
|
193
|
+
- Use `inlineAlwaysVisible: true` only for critical actions requiring constant visibility
|
|
194
|
+
|
|
195
|
+
4. **Update Action Mode**:
|
|
196
|
+
- Complex, full-entity edits → Use `mode: "page"` to navigate to entity page
|
|
197
|
+
|
|
198
|
+
5. **Custom Implementation**:
|
|
199
|
+
- For `custom` actions, you must provide implementations in your code and register them with `PatternsWizardOverridesProvider`
|
|
200
|
+
|
|
201
|
+
### ActionCell Validation Checklist
|
|
202
|
+
|
|
203
|
+
AI agents should verify these requirements before generating ActionCell configurations:
|
|
204
|
+
|
|
205
|
+
✓ ActionCell is placed directly inside `table` or `grid` configuration
|
|
206
|
+
✓ Each action has a unique `id` and correct `type` value
|
|
207
|
+
✓ Each action type only includes its required field(s)
|
|
208
|
+
✓ Update page action refers to a valid entity page ID
|
|
209
|
+
✓ Delete action has a modal configuration
|
|
210
|
+
✓ Custom actions match implementations in overrides
|
|
211
|
+
✓ At least one of `primaryAction` or `secondaryActions` is provided
|
|
212
|
+
✓ `inlineCount` (if specified) is a non-negative number ≤ total secondary actions count
|
|
213
|
+
✓ `inlineAlwaysVisible` (if specified) is a boolean value
|
|
214
|
+
✓ Inline secondary actions configuration is applied only when secondary actions exist
|