@wix/auto-patterns 1.27.0 → 1.29.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/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +19 -58
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageFooter/AutoPatternsCollectionPageFooter.js +48 -0
- package/dist/cjs/components/AutoPatternsCollectionPageFooter/AutoPatternsCollectionPageFooter.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js.map +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js.map +1 -1
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js +11 -7
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
- package/dist/cjs/components/ModalRenderer.js +1 -1
- package/dist/cjs/components/ModalRenderer.js.map +1 -1
- package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js +5 -0
- package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
- package/dist/cjs/dataSourceAdapters/cms/fetchCmsData.js +1 -1
- package/dist/cjs/dataSourceAdapters/cms/fetchCmsData.js.map +1 -1
- package/dist/cjs/hooks/useAutoPatternsOptimisticActions.js +13 -6
- package/dist/cjs/hooks/useAutoPatternsOptimisticActions.js.map +1 -1
- package/dist/cjs/hooks/useBaseCollectionParams.js +38 -0
- package/dist/cjs/hooks/useBaseCollectionParams.js.map +1 -0
- package/dist/cjs/hooks/useBaseSDK.js +1 -1
- package/dist/cjs/hooks/useBaseSDK.js.map +1 -1
- package/dist/cjs/hooks/useColumns.js +1 -1
- package/dist/cjs/hooks/useColumns.js.map +1 -1
- package/dist/cjs/hooks/useCommonCollectionFeatures.js +13 -6
- package/dist/cjs/hooks/useCommonCollectionFeatures.js.map +1 -1
- package/dist/cjs/hooks/useEmptyStates.js +1 -1
- package/dist/cjs/hooks/useEmptyStates.js.map +1 -1
- package/dist/cjs/hooks/useEntityPageHeaderTexts.js +2 -2
- package/dist/cjs/hooks/useEntityPageHeaderTexts.js.map +1 -1
- package/dist/cjs/hooks/useFetchData.js +4 -5
- 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 +6 -26
- package/dist/cjs/hooks/useGridFeatures.js.map +1 -1
- package/dist/cjs/hooks/useTableFeatures.js +8 -28
- package/dist/cjs/hooks/useTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js +8 -28
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js.map +1 -1
- package/dist/cjs/providers/{PatternsWizardOverridesContext.js → AutoPatternsOverridesContext.js} +14 -11
- package/dist/cjs/providers/AutoPatternsOverridesContext.js.map +1 -0
- package/dist/cjs/providers/SchemaContext.js +24 -7
- package/dist/cjs/providers/SchemaContext.js.map +1 -1
- package/dist/cjs/providers/index.js +4 -4
- package/dist/cjs/providers/index.js.map +1 -1
- package/dist/cjs/types/BaseSDK.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/fetchData.js +4 -0
- package/dist/cjs/types/fetchData.js.map +1 -0
- package/dist/cjs/types/index.js +6 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/types.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/cjs/utils/vibe.js +11 -0
- package/dist/cjs/utils/vibe.js.map +1 -0
- package/dist/docs/action_cell.md +18 -8
- package/dist/docs/app_config_structure.md +37 -1
- package/dist/docs/app_context.md +45 -0
- package/dist/docs/auto-patterns-guide.md +331 -82
- package/dist/docs/bulk_actions.md +10 -5
- package/dist/docs/collection_page.md +1 -1
- package/dist/docs/collection_page_actions.md +16 -9
- package/dist/docs/custom_overrides.md +22 -36
- package/dist/docs/entity_page.md +10 -10
- package/dist/docs/entity_page_actions.md +11 -4
- package/dist/docs/error_handling.md +135 -0
- package/dist/docs/index.md +8 -0
- package/dist/docs/installation.md +3 -3
- package/dist/docs/resolved_action.md +6 -2
- package/dist/docs/schema_config.md +11 -3
- package/dist/docs/wix_fqdn_custom_data_source.md +51 -9
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +2 -25
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +2 -2
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionPageFooter/AutoPatternsCollectionPageFooter.js +29 -0
- package/dist/esm/components/AutoPatternsCollectionPageFooter/AutoPatternsCollectionPageFooter.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js +2 -2
- package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js +2 -2
- package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js.map +1 -1
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js +5 -1
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
- package/dist/esm/components/ModalRenderer.js +2 -2
- package/dist/esm/components/ModalRenderer.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +4 -0
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/fetchCmsData.js +1 -1
- package/dist/esm/dataSourceAdapters/cms/fetchCmsData.js.map +1 -1
- package/dist/esm/hooks/useAutoPatternsOptimisticActions.js +14 -9
- package/dist/esm/hooks/useAutoPatternsOptimisticActions.js.map +1 -1
- package/dist/esm/hooks/useBaseCollectionParams.js +37 -0
- package/dist/esm/hooks/useBaseCollectionParams.js.map +1 -0
- package/dist/esm/hooks/useBaseSDK.js +2 -2
- package/dist/esm/hooks/useBaseSDK.js.map +1 -1
- package/dist/esm/hooks/useColumns.js +2 -2
- package/dist/esm/hooks/useColumns.js.map +1 -1
- package/dist/esm/hooks/useCommonCollectionFeatures.js +9 -2
- package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
- package/dist/esm/hooks/useEmptyStates.js +2 -2
- package/dist/esm/hooks/useEmptyStates.js.map +1 -1
- package/dist/esm/hooks/useEntityPageHeaderTexts.js +2 -2
- package/dist/esm/hooks/useEntityPageHeaderTexts.js.map +1 -1
- package/dist/esm/hooks/useFetchData.js +2 -2
- 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 +6 -29
- package/dist/esm/hooks/useGridFeatures.js.map +1 -1
- package/dist/esm/hooks/useTableFeatures.js +8 -31
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useTableGridSwitchFeatures.js +8 -31
- package/dist/esm/hooks/useTableGridSwitchFeatures.js.map +1 -1
- package/dist/esm/providers/AutoPatternsOverridesContext.js +19 -0
- package/dist/esm/providers/AutoPatternsOverridesContext.js.map +1 -0
- package/dist/esm/providers/SchemaContext.js +23 -6
- package/dist/esm/providers/SchemaContext.js.map +1 -1
- package/dist/esm/providers/index.js +1 -1
- package/dist/esm/providers/index.js.map +1 -1
- package/dist/esm/types/BaseSDK.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/fetchData.js +2 -0
- package/dist/esm/types/fetchData.js.map +1 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/types.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/esm/utils/vibe.js +6 -0
- package/dist/esm/utils/vibe.js.map +1 -0
- package/dist/types/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsCollectionPageFooter/AutoPatternsCollectionPageFooter.d.ts +3 -0
- package/dist/types/components/AutoPatternsCollectionPageFooter/AutoPatternsCollectionPageFooter.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsRoute/AutoPatternsRoutes.d.ts.map +1 -1
- package/dist/types/dataSourceAdapters/cms/cmsAdapter.d.ts +2 -1
- package/dist/types/dataSourceAdapters/cms/cmsAdapter.d.ts.map +1 -1
- package/dist/types/hooks/useAutoPatternsOptimisticActions.d.ts +7 -1
- package/dist/types/hooks/useAutoPatternsOptimisticActions.d.ts.map +1 -1
- package/dist/types/hooks/useBaseCollectionParams.d.ts +27 -0
- package/dist/types/hooks/useBaseCollectionParams.d.ts.map +1 -0
- package/dist/types/hooks/useCommonCollectionFeatures.d.ts +4 -3
- package/dist/types/hooks/useCommonCollectionFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useEntityPageHeaderTexts.d.ts.map +1 -1
- package/dist/types/hooks/useFetchData.d.ts +3 -13
- package/dist/types/hooks/useFetchData.d.ts.map +1 -1
- package/dist/types/hooks/useGridFeatures.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 → AutoPatternsOverridesContext.d.ts} +14 -5
- package/dist/types/providers/AutoPatternsOverridesContext.d.ts.map +1 -0
- package/dist/types/providers/SchemaContext.d.ts.map +1 -1
- package/dist/types/providers/index.d.ts +1 -1
- package/dist/types/providers/index.d.ts.map +1 -1
- package/dist/types/types/BaseSDK.d.ts +2 -2
- package/dist/types/types/BaseSDK.d.ts.map +1 -1
- package/dist/types/types/CollectionPageConfig.d.ts +4 -0
- 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/fetchData.d.ts +21 -0
- package/dist/types/types/fetchData.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/types.d.ts +12 -7
- package/dist/types/types/types.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/dist/types/utils/vibe.d.ts +2 -0
- package/dist/types/utils/vibe.d.ts.map +1 -0
- package/package.json +10 -10
- package/dist/cjs/dataSourceAdapters/factory.js +0 -14
- package/dist/cjs/dataSourceAdapters/factory.js.map +0 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +0 -1
- package/dist/esm/dataSourceAdapters/factory.js +0 -10
- package/dist/esm/dataSourceAdapters/factory.js.map +0 -1
- package/dist/esm/providers/PatternsWizardOverridesContext.js +0 -15
- package/dist/esm/providers/PatternsWizardOverridesContext.js.map +0 -1
- package/dist/types/dataSourceAdapters/factory.d.ts +0 -3
- package/dist/types/dataSourceAdapters/factory.d.ts.map +0 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +0 -1
|
@@ -2,20 +2,12 @@ import { useFetchData } from './useFetchData';
|
|
|
2
2
|
import { TableSections, useSelector, useTableCollection } from '@wix/patterns';
|
|
3
3
|
import { useCommonCollectionFeatures } from './useCommonCollectionFeatures';
|
|
4
4
|
import { useFilters } from './useFilters';
|
|
5
|
-
import { useSchema } from '../providers/SchemaContext';
|
|
6
|
-
import { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';
|
|
7
5
|
import { useBaseTableFeatures } from './useBaseTableFeatures';
|
|
8
|
-
import {
|
|
6
|
+
import { useAutoPatternsOverridesContext } from '../providers/AutoPatternsOverridesContext';
|
|
7
|
+
import { useBaseCollectionParams } from './useBaseCollectionParams';
|
|
9
8
|
import { useUpdateAppContextItems } from './useUpdateAppContextItems';
|
|
10
9
|
export const useTableFeatures = configuration => {
|
|
11
10
|
var _configuration$sectio, _overrides$sections;
|
|
12
|
-
const {
|
|
13
|
-
collectionId,
|
|
14
|
-
limit,
|
|
15
|
-
reflectQueryInUrl,
|
|
16
|
-
selectAllScope,
|
|
17
|
-
selectionUpdateMode
|
|
18
|
-
} = configuration.collection;
|
|
19
11
|
const {
|
|
20
12
|
filterComponent,
|
|
21
13
|
filtersObject,
|
|
@@ -36,32 +28,18 @@ export const useTableFeatures = configuration => {
|
|
|
36
28
|
searchableFieldIds: visibleFieldIds,
|
|
37
29
|
filterFieldMapping
|
|
38
30
|
});
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
queryName: `${collectionId}`,
|
|
43
|
-
itemKey: item => item[schema.idField],
|
|
44
|
-
itemName: item => item[schema.displayField],
|
|
45
|
-
filters: filtersObject,
|
|
46
|
-
toExtendedFields: item => item.extendedFields,
|
|
47
|
-
fetchErrorMessage: _ref => {
|
|
48
|
-
let {
|
|
49
|
-
err
|
|
50
|
-
} = _ref;
|
|
51
|
-
return String(err);
|
|
52
|
-
},
|
|
31
|
+
const overrides = useAutoPatternsOverridesContext();
|
|
32
|
+
const params = useBaseCollectionParams({
|
|
33
|
+
config: configuration.collection,
|
|
53
34
|
fetchData,
|
|
54
|
-
|
|
55
|
-
persistQueryToUrl: reflectQueryInUrl,
|
|
56
|
-
disableAutoSelectAllCount: selectAllScope === 'page',
|
|
57
|
-
selectionConsistencyMode: selectionUpdateMode
|
|
35
|
+
filters: filtersObject
|
|
58
36
|
});
|
|
37
|
+
const state = useTableCollection(params);
|
|
59
38
|
const items = useSelector(() => state.collection.result.items);
|
|
60
39
|
useUpdateAppContextItems(items);
|
|
61
|
-
const optimisticActions = useAutoPatternsOptimisticActions(collectionId, state.collection);
|
|
62
40
|
const commonFeatures = useCommonCollectionFeatures({
|
|
63
41
|
...configuration,
|
|
64
|
-
|
|
42
|
+
collectionState: state.collection
|
|
65
43
|
});
|
|
66
44
|
const sections = (_configuration$sectio = configuration.sections) != null && _configuration$sectio.id && overrides != null && (_overrides$sections = overrides.sections) != null && _overrides$sections[configuration.sections.id] ? {
|
|
67
45
|
renderSection: overrides.sections[configuration.sections.id],
|
|
@@ -72,7 +50,6 @@ export const useTableFeatures = configuration => {
|
|
|
72
50
|
state,
|
|
73
51
|
columns,
|
|
74
52
|
filters: filterComponent,
|
|
75
|
-
optimisticActions,
|
|
76
53
|
customColumns,
|
|
77
54
|
onRowClick,
|
|
78
55
|
stickyColumns,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useFetchData","TableSections","useSelector","useTableCollection","useCommonCollectionFeatures","useFilters","
|
|
1
|
+
{"version":3,"names":["useFetchData","TableSections","useSelector","useTableCollection","useCommonCollectionFeatures","useFilters","useBaseTableFeatures","useAutoPatternsOverridesContext","useBaseCollectionParams","useUpdateAppContextItems","useTableFeatures","configuration","_configuration$sectio","_overrides$sections","filterComponent","filtersObject","filterFieldMapping","filters","customColumns","visibleFieldIds","columns","onRowClick","stickyColumns","stickySelectionColumn","showTitleBar","fetchData","searchableFieldIds","overrides","params","config","collection","state","items","result","commonFeatures","collectionState","sections","id","renderSection","undefined"],"sources":["../../../src/hooks/useTableFeatures.tsx"],"sourcesContent":["import { TableConfig } from '../types';\nimport { useFetchData } from './useFetchData';\nimport { TableSections, useSelector, useTableCollection } from '@wix/patterns';\nimport { useCommonCollectionFeatures } from './useCommonCollectionFeatures';\nimport { useFilters } from './useFilters';\nimport { useBaseTableFeatures } from './useBaseTableFeatures';\nimport { useAutoPatternsOverridesContext } from '../providers/AutoPatternsOverridesContext';\nimport { useBaseCollectionParams } from './useBaseCollectionParams';\nimport { useUpdateAppContextItems } from './useUpdateAppContextItems';\n\nexport const useTableFeatures = (configuration: TableConfig) => {\n const { filterComponent, filtersObject, filterFieldMapping } = useFilters(\n configuration.filters,\n );\n const {\n customColumns,\n visibleFieldIds,\n columns,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n showTitleBar,\n } = useBaseTableFeatures(configuration);\n\n const { fetchData } = useFetchData({\n searchableFieldIds: visibleFieldIds,\n filterFieldMapping,\n });\n\n const overrides = useAutoPatternsOverridesContext();\n\n const params = useBaseCollectionParams({\n config: configuration.collection,\n fetchData,\n filters: filtersObject,\n });\n\n const state = useTableCollection<any>(params);\n const items = useSelector(() => state.collection.result.items);\n useUpdateAppContextItems(items);\n\n const commonFeatures = useCommonCollectionFeatures({\n ...configuration,\n collectionState: state.collection,\n });\n\n const sections =\n configuration.sections?.id &&\n overrides?.sections?.[configuration.sections.id]\n ? {\n renderSection: overrides.sections[configuration.sections.id],\n TableSections,\n }\n : undefined;\n\n return {\n ...commonFeatures,\n state,\n columns,\n filters: filterComponent,\n customColumns,\n onRowClick,\n st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aAAa;IAChBwB,eAAe,EAAEJ,KAAK,CAACD;EACzB,CAAC,CAAC;EAEF,MAAMM,QAAQ,GACZ,CAAAxB,qBAAA,GAAAD,aAAa,CAACyB,QAAQ,aAAtBxB,qBAAA,CAAwByB,EAAE,IAC1BV,SAAS,aAAAd,mBAAA,GAATc,SAAS,CAAES,QAAQ,aAAnBvB,mBAAA,CAAsBF,aAAa,CAACyB,QAAQ,CAACC,EAAE,CAAC,GAC5C;IACEC,aAAa,EAAEX,SAAS,CAACS,QAAQ,CAACzB,aAAa,CAACyB,QAAQ,CAACC,EAAE,CAAC;IAC5DpC;EACF,CAAC,GACDsC,SAAS;EAEf,OAAO;IACL,GAAGL,cAAc;IACjBH,KAAK;IACLX,OAAO;IACPH,OAAO,EAAEH,eAAe;IACxBI,aAAa;IACbG,UAAU;IACVC,aAAa;IACbC,qBAAqB;IACrBC,YAAY;IACZY;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -2,20 +2,11 @@ import { useFetchData } from './useFetchData';
|
|
|
2
2
|
import { useSelector, useTableGridSwitchCollection } from '@wix/patterns';
|
|
3
3
|
import { useCommonCollectionFeatures } from './useCommonCollectionFeatures';
|
|
4
4
|
import { useFilters } from './useFilters';
|
|
5
|
-
import { useSchema } from '../providers/SchemaContext';
|
|
6
|
-
import { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';
|
|
7
5
|
import { useBaseGridFeatures } from './useBaseGridFeatures';
|
|
8
6
|
import { useBaseTableFeatures } from './useBaseTableFeatures';
|
|
7
|
+
import { useBaseCollectionParams } from './useBaseCollectionParams';
|
|
9
8
|
import { useUpdateAppContextItems } from './useUpdateAppContextItems';
|
|
10
9
|
export const useTableGridSwitchFeatures = config => {
|
|
11
|
-
const schema = useSchema();
|
|
12
|
-
const {
|
|
13
|
-
collectionId,
|
|
14
|
-
limit,
|
|
15
|
-
reflectQueryInUrl,
|
|
16
|
-
selectAllScope,
|
|
17
|
-
selectionUpdateMode
|
|
18
|
-
} = config.collection;
|
|
19
10
|
const {
|
|
20
11
|
filterComponent,
|
|
21
12
|
filtersObject,
|
|
@@ -37,42 +28,28 @@ export const useTableGridSwitchFeatures = config => {
|
|
|
37
28
|
showTitleBar
|
|
38
29
|
} = useBaseTableFeatures(config);
|
|
39
30
|
const {
|
|
40
|
-
fetchData
|
|
31
|
+
fetchData
|
|
41
32
|
} = useFetchData({
|
|
42
33
|
searchableFieldIds: Array.from(new Set([...tableVisibleFieldIds, ...gridVisibleFieldIds])),
|
|
43
34
|
filterFieldMapping
|
|
44
35
|
});
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
filters: filtersObject,
|
|
50
|
-
toExtendedFields: item => item.extendedFields,
|
|
51
|
-
fetchErrorMessage: _ref => {
|
|
52
|
-
let {
|
|
53
|
-
err
|
|
54
|
-
} = _ref;
|
|
55
|
-
return String(err);
|
|
56
|
-
},
|
|
57
|
-
fetchData: tableFetchData,
|
|
58
|
-
limit,
|
|
59
|
-
persistQueryToUrl: reflectQueryInUrl,
|
|
60
|
-
disableAutoSelectAllCount: selectAllScope === 'page',
|
|
61
|
-
selectionConsistencyMode: selectionUpdateMode
|
|
36
|
+
const params = useBaseCollectionParams({
|
|
37
|
+
config: config.collection,
|
|
38
|
+
fetchData,
|
|
39
|
+
filters: filtersObject
|
|
62
40
|
});
|
|
41
|
+
const state = useTableGridSwitchCollection(params);
|
|
63
42
|
const items = useSelector(() => state.collection.result.items);
|
|
64
43
|
useUpdateAppContextItems(items);
|
|
65
|
-
const optimisticActions = useAutoPatternsOptimisticActions(collectionId, state.collection);
|
|
66
44
|
const commonFeatures = useCommonCollectionFeatures({
|
|
67
45
|
...config,
|
|
68
|
-
|
|
46
|
+
collectionState: state.collection
|
|
69
47
|
});
|
|
70
48
|
return {
|
|
71
49
|
...commonFeatures,
|
|
72
50
|
state,
|
|
73
51
|
columns: tableColumns,
|
|
74
52
|
filters: filterComponent,
|
|
75
|
-
optimisticActions,
|
|
76
53
|
customColumns,
|
|
77
54
|
onRowClick,
|
|
78
55
|
stickyColumns,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useFetchData","useSelector","useTableGridSwitchCollection","useCommonCollectionFeatures","useFilters","
|
|
1
|
+
{"version":3,"names":["useFetchData","useSelector","useTableGridSwitchCollection","useCommonCollectionFeatures","useFilters","useBaseGridFeatures","useBaseTableFeatures","useBaseCollectionParams","useUpdateAppContextItems","useTableGridSwitchFeatures","config","filterComponent","filtersObject","filterFieldMapping","filters","preset","imagePlacement","visibleFieldIds","gridVisibleFieldIds","renderItem","customColumns","tableVisibleFieldIds","columns","tableColumns","onRowClick","stickyColumns","stickySelectionColumn","showTitleBar","fetchData","searchableFieldIds","Array","from","Set","params","collection","state","items","result","commonFeatures","collectionState","horizontalScroll"],"sources":["../../../src/hooks/useTableGridSwitchFeatures.tsx"],"sourcesContent":["import { TableGridSwitchConfig } from '../types';\nimport { useFetchData } from './useFetchData';\nimport { useSelector, useTableGridSwitchCollection } from '@wix/patterns';\nimport { useCommonCollectionFeatures } from './useCommonCollectionFeatures';\nimport { useFilters } from './useFilters';\nimport { useBaseGridFeatures } from './useBaseGridFeatures';\nimport { useBaseTableFeatures } from './useBaseTableFeatures';\nimport { useBaseCollectionParams } from './useBaseCollectionParams';\nimport { useUpdateAppContextItems } from './useUpdateAppContextItems';\n\nexport const useTableGridSwitchFeatures = (config: TableGridSwitchConfig) => {\n const { filterComponent, filtersObject, filterFieldMapping } = useFilters(\n config.filters,\n );\n\n const {\n preset,\n imagePlacement,\n visibleFieldIds: gridVisibleFieldIds,\n renderItem,\n } = useBaseGridFeatures(config);\n\n const {\n customColumns,\n visibleFieldIds: tableVisibleFieldIds,\n columns: tableColumns,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n showTitleBar,\n } = useBaseTableFeatures(config);\n\n const { fetchData } = useFetchData({\n searchableFieldIds: Array.from(\n new Set([...tableVisibleFieldIds, ...gridVisibleFieldIds]),\n ),\n filterFieldMapping,\n });\n\n const params = useBaseCollectionParams({\n config: config.collection,\n fetchData,\n filters: filtersObject,\n });\n\n const state = useTableGridSwitchCollection<any>(params);\n const items = useSelector(() => state.collection.result.items);\n useUpdateAppContextItems(items);\n\n const commonFeatures = useCommonCollectionFeatures({\n ...config,\n collectionState: state.collection,\n });\n\n return {\n ...commonFeatures,\n state,\n columns: tableColumns,\n filters: filterComponent,\n customColumns,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n horizontalScroll: true,\n // Grid specific features\n imagePlacement,\n preset,\n renderItem,\n showTitleBar,\n };\n};\n"],"mappings":"AACA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,WAAW,EAAEC,4BAA4B,QAAQ,eAAe;AACzE,SAASC,2BAA2B,QAAQ,+BAA+B;AAC3E,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,wBAAwB,QAAQ,4BAA4B;AAErE,OAAO,MAAMC,0BAA0B,GAAIC,MAA6B,IAAK;EAC3E,MAAM;IAAEC,eAAe;IAAEC,aAAa;IAAEC;EAAmB,CAAC,GAAGT,UAAU,CACvEM,MAAM,CAACI,OACT,CAAC;EAED,MAAM;IACJC,MAAM;IACNC,cAAc;IACdC,eAAe,EAAEC,mBAAmB;IACpCC;EACF,CAAC,GAAGd,mBAAmB,CAACK,MAAM,CAAC;EAE/B,MAAM;IACJU,aAAa;IACbH,eAAe,EAAEI,oBAAoB;IACrCC,OAAO,EAAEC,YAAY;IACrBC,UAAU;IACVC,aAAa;IACbC,qBAAqB;IACrBC;EACF,CAAC,GAAGrB,oBAAoB,CAACI,MAAM,CAAC;EAEhC,MAAM;IAAEkB;EAAU,CAAC,GAAG5B,YAAY,CAAC;IACjC6B,kBAAkB,EAAEC,KAAK,CAACC,IAAI,CAC5B,IAAIC,GAAG,CAAC,CAAC,GAAGX,oBAAoB,EAAE,GAAGH,mBAAmB,CAAC,CAC3D,CAAC;IACDL;EACF,CAAC,CAAC;EAEF,MAAMoB,MAAM,GAAG1B,uBAAuB,CAAC;IACrCG,MAAM,EAAEA,MAAM,CAACwB,UAAU;IACzBN,SAAS;IACTd,OAAO,EAAEF;EACX,CAAC,CAAC;EAEF,MAAMuB,KAAK,GAAGjC,4BAA4B,CAAM+B,MAAM,CAAC;EACvD,MAAMG,KAAK,GAAGnC,WAAW,CAAC,MAAMkC,KAAK,CAACD,UAAU,CAACG,MAAM,CAACD,KAAK,CAAC;EAC9D5B,wBAAwB,CAAC4B,KAAK,CAAC;EAE/B,MAAME,cAAc,GAAGnC,2BAA2B,CAAC;IACjD,GAAGO,MAAM;IACT6B,eAAe,EAAEJ,KAAK,CAACD;EACzB,CAAC,CAAC;EAEF,OAAO;IACL,GAAGI,cAAc;IACjBH,KAAK;IACLb,OAAO,EAAEC,YAAY;IACrBT,OAAO,EAAEH,eAAe;IACxBS,aAAa;IACbI,UAAU;IACVC,aAAa;IACbC,qBAAqB;IACrBc,gBAAgB,EAAE,IAAI;IACtB;IACAxB,cAAc;IACdD,MAAM;IACNI,UAAU;IACVQ;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
const AutoPatternsOverridesContext = /*#__PURE__*/createContext(undefined);
|
|
3
|
+
export const AutoPatternsOverridesProvider = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
children,
|
|
6
|
+
value
|
|
7
|
+
} = _ref;
|
|
8
|
+
return /*#__PURE__*/React.createElement(AutoPatternsOverridesContext.Provider, {
|
|
9
|
+
value: value
|
|
10
|
+
}, children);
|
|
11
|
+
};
|
|
12
|
+
export const useAutoPatternsOverridesContext = () => {
|
|
13
|
+
return useContext(AutoPatternsOverridesContext);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// For backwards compatibility
|
|
17
|
+
|
|
18
|
+
export const PatternsWizardOverridesProvider = AutoPatternsOverridesProvider;
|
|
19
|
+
//# sourceMappingURL=AutoPatternsOverridesContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","createContext","useContext","AutoPatternsOverridesContext","undefined","AutoPatternsOverridesProvider","_ref","children","value","createElement","Provider","useAutoPatternsOverridesContext","PatternsWizardOverridesProvider"],"sources":["../../../src/providers/AutoPatternsOverridesContext.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode } from 'react';\nimport {\n CustomComponentProps,\n CustomActionCellPrimaryActionResolver,\n CustomActionCellSecondaryActionResolver,\n CustomEntityPageActionResolver,\n CustomBulkActionsActionResolver,\n CustomActionCollectionPageActionResolver,\n CustomActionCollectionPageActionOnRowClickResolver,\n IColumnValue,\n SchemaConfig,\n} from '../types';\n\nimport { Section, useOptimisticActions } from '@wix/patterns';\nimport { BadgeSkin, IconElement } from '@wix/design-system';\nimport { collections } from '@wix/data';\n\nexport interface AutoPatternsOverridesContextProps {\n actions?: Record<\n string,\n | CustomActionCellPrimaryActionResolver\n | CustomActionCellSecondaryActionResolver\n | CustomBulkActionsActionResolver\n | CustomEntityPageActionResolver\n | CustomActionCollectionPageActionResolver\n | CustomActionCollectionPageActionOnRowClickResolver\n >;\n columns?: Record<string, (props: IColumnValue<any>) => void>;\n modals?: Record<string, React.FC<any>>;\n emptyState?: Record<string, () => void>;\n components?: Record<string, React.FC<CustomComponentProps>>;\n slots?: Record<string, React.FC>;\n entityPageHeaderSubtitle?: Record<\n string,\n (entity: Record<string, any>) => { text: string }\n >;\n entityPageHeaderBadges?: Record<\n string,\n (entity: Record<string, any>) => {\n text: string;\n skin?: BadgeSkin;\n prefixIcon?: IconElement;\n suffixIcon?: IconElement;\n }[]\n >;\n customDataSources?: Record<\n string,\n (collectionId: string, context: any) => Promise<SchemaConfig>\n >;\n cmsSchema?: Record<string, collections.DataCollection>;\n sections?: Record<string, (item: any) => Section>;\n optimisticActions?: Record<\n string,\n Parameters<typeof useOptimisticActions>[1]\n >;\n}\n\nconst AutoPatternsOverridesContext = createContext<\n AutoPatternsOverridesContextProps | undefined\n>(undefined);\n\nexport const AutoPatternsOverridesProvider: React.FC<{\n children: ReactNode;\n value: AutoPatternsOverridesContextProps;\n}> = ({ children, value }) => {\n return (\n <AutoPatternsOverridesContext.Provider value={value}>\n {children}\n </AutoPatternsOverridesContext.Provider>\n );\n};\n\nexport const useAutoPatternsOverridesContext = ():\n | AutoPatternsOverridesContextProps\n | undefined => {\n return useContext(AutoPatternsOverridesContext);\n};\n\n// For backwards compatibility\nexport interface PatternsWizardOverridesContextProps\n extends AutoPatternsOverridesContextProps {}\nexport const PatternsWizardOverridesProvider = AutoPatternsOverridesProvider;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,QAAmB,OAAO;AAyDnE,MAAMC,4BAA4B,gBAAGF,aAAa,CAEhDG,SAAS,CAAC;AAEZ,OAAO,MAAMC,6BAGX,GAAGC,IAAA,IAAyB;EAAA,IAAxB;IAAEC,QAAQ;IAAEC;EAAM,CAAC,GAAAF,IAAA;EACvB,oBACEN,KAAA,CAAAS,aAAA,CAACN,4BAA4B,CAACO,QAAQ;IAACF,KAAK,EAAEA;EAAM,GACjDD,QACoC,CAAC;AAE5C,CAAC;AAED,OAAO,MAAMI,+BAA+B,GAAGA,CAAA,KAE9B;EACf,OAAOT,UAAU,CAACC,4BAA4B,CAAC;AACjD,CAAC;;AAED;;AAGA,OAAO,MAAMS,+BAA+B,GAAGP,6BAA6B","ignoreList":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
2
|
-
import { getSchema } from '../dataSourceAdapters/factory';
|
|
3
2
|
import { useSchemaRegistry } from './SchemaRegistryContext';
|
|
4
|
-
import {
|
|
3
|
+
import { useAutoPatternsOverridesContext } from './AutoPatternsOverridesContext';
|
|
5
4
|
import { useWixPatternsContainer } from '@wix/patterns';
|
|
6
5
|
import { useError } from './ErrorContext';
|
|
6
|
+
import { fetchCmsSchema, transformCmsSchema } from '../dataSourceAdapters/cms/cmsAdapter';
|
|
7
7
|
const SchemaContext = /*#__PURE__*/createContext(null);
|
|
8
8
|
export const SchemaProvider = _ref => {
|
|
9
9
|
var _collection$custom;
|
|
@@ -26,14 +26,28 @@ export const SchemaProvider = _ref => {
|
|
|
26
26
|
} = useError();
|
|
27
27
|
const [schema, setSchema] = useState(null);
|
|
28
28
|
const [isLoading, setIsLoading] = useState(false);
|
|
29
|
-
const overrides =
|
|
29
|
+
const overrides = useAutoPatternsOverridesContext();
|
|
30
30
|
const {
|
|
31
31
|
httpClient
|
|
32
32
|
} = useWixPatternsContainer();
|
|
33
33
|
useEffect(() => {
|
|
34
|
+
const getSchema = async collectionConfig => {
|
|
35
|
+
var _collectionConfig$cms, _overrides$cmsSchema;
|
|
36
|
+
switch (collectionConfig.entityTypeSource) {
|
|
37
|
+
case 'cms':
|
|
38
|
+
const schemaInput = (_collectionConfig$cms = collectionConfig.cms) != null && (_collectionConfig$cms = _collectionConfig$cms.schema) != null && _collectionConfig$cms.id ? overrides == null || (_overrides$cmsSchema = overrides.cmsSchema) == null ? void 0 : _overrides$cmsSchema[collectionConfig.cms.schema.id] : null;
|
|
39
|
+
const currentSchema = schemaInput || (await fetchCmsSchema(collectionConfig.collectionId));
|
|
40
|
+
return transformCmsSchema(currentSchema);
|
|
41
|
+
default:
|
|
42
|
+
throw new Error(`Unsupported entityTypeSource: ${collectionConfig.entityTypeSource}`);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
34
45
|
const fetchSchemaForCollection = async (targetCollectionId, targetCustomDataSourceId) => {
|
|
35
|
-
if (entityTypeSource === 'custom'
|
|
36
|
-
|
|
46
|
+
if (entityTypeSource === 'custom') {
|
|
47
|
+
if (!targetCustomDataSourceId || !(overrides != null && overrides.customDataSources)) {
|
|
48
|
+
throw new Error('Custom data source not found');
|
|
49
|
+
}
|
|
50
|
+
const customSchemaProvider = overrides == null ? void 0 : overrides.customDataSources[targetCustomDataSourceId];
|
|
37
51
|
if (customSchemaProvider) {
|
|
38
52
|
return customSchemaProvider(targetCollectionId, {
|
|
39
53
|
httpClient
|
|
@@ -41,7 +55,10 @@ export const SchemaProvider = _ref => {
|
|
|
41
55
|
}
|
|
42
56
|
throw new Error(`Custom schema provider '${targetCustomDataSourceId}' not found`);
|
|
43
57
|
}
|
|
44
|
-
return getSchema(
|
|
58
|
+
return getSchema({
|
|
59
|
+
collectionId: targetCollectionId,
|
|
60
|
+
entityTypeSource
|
|
61
|
+
});
|
|
45
62
|
};
|
|
46
63
|
const fetchReferencedSchemas = async referencedSchema => {
|
|
47
64
|
const referencedCollectionIds = new Set();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","createContext","useContext","useEffect","useState","getSchema","useSchemaRegistry","usePatternsWizardOverridesContext","useWixPatternsContainer","useError","SchemaContext","SchemaProvider","_ref","_collection$custom","collection","children","skeleton","collectionId","entityTypeSource","customDataSourceId","custom","id","undefined","getSchemaFromRegistry","addSchema","addSchemaToRegistry","showError","schema","setSchema","isLoading","setIsLoading","overrides","httpClient","fetchSchemaForCollection","targetCollectionId","targetCustomDataSourceId","customDataSources","customSchemaProvider","Error","fetchReferencedSchemas","referencedSchema","referencedCollectionIds","Set","Object","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","useSchema","context"],"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';\nimport { useError } from './ErrorContext';\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 { showError } = useError();\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 showError(error);\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, [\n collectionId,\n entityTypeSource,\n customDataSourceId,\n addSchemaToRegistry,\n getSchemaFromRegistry,\n overrides,\n httpClient,\n showError,\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,OAAOA,KAAK,IACVC,aAAa,EACbC,UAAU,EACVC,SAAS,EACTC,QAAQ,QAEH,OAAO;AAGd,SAASC,SAAS,QAAQ,+BAA+B;AACzD,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,iCAAiC,QAAQ,kCAAkC;AACpF,SAASC,uBAAuB,QAAQ,eAAe;AACvD,SAASC,QAAQ,QAAQ,gBAAgB;AAEzC,MAAMC,aAAa,gBAAGT,aAAa,CAAsB,IAAI,CAAC;AAQ9D,OAAO,MAAMU,cAAc,GAAGC,IAAA,IAIH;EAAA,IAAAC,kBAAA;EAAA,IAJI;IAC7BC,UAAU;IACVC,QAAQ;IACRC;EACmB,CAAC,GAAAJ,IAAA;EACpB,MAAM;IAAEK,YAAY;IAAEC;EAAiB,CAAC,GA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a,CAAC;MAEhD,MAAM1B,sBAAsB,CAAC0B,aAAa,CAAC;IAC7C,CAAC,CAAC,CACDC,KAAK,CAAEP,KAAK,IAAK;MAChBC,OAAO,CAACD,KAAK,CAAC,+BAA+B,EAAEA,KAAK,CAAC;MACrDjC,SAAS,CAACiC,KAAK,CAAC;IAClB,CAAC,CAAC,CACDQ,OAAO,CAAC,MAAM;MACbrC,YAAY,CAAC,KAAK,CAAC;IACrB,CAAC,CAAC;EACN,CAAC,EAAE,CACDb,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBM,mBAAmB,EACnBF,qBAAqB,EACrBQ,SAAS,EACTC,UAAU,EACVN,SAAS,CACV,CAAC;EACF,IAAI,CAACC,MAAM,IAAIE,SAAS,EAAE;IACxB,OAAOb,QAAQ;EACjB;EAEA,oBACEhB,KAAA,CAAAoE,aAAA,CAAC1D,aAAa,CAAC2D,QAAQ;IAACC,KAAK,EAAE3C;EAAO,GAAEZ,QAAiC,CAAC;AAE9E,CAAC;AAED,OAAO,MAAMwD,SAAS,GAAGA,CAAA,KAAoB;EAC3C,MAAMC,OAAO,GAAGtE,UAAU,CAACQ,aAAa,CAAC;EACzC,IAAI,CAAC8D,OAAO,EAAE;IACZ,MAAM,IAAIlC,KAAK,CAAC,gDAAgD,CAAC;EACnE;EACA,OAAOkC,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","createContext","useContext","useEffect","useState","useSchemaRegistry","useAutoPatternsOverridesContext","useWixPatternsContainer","useError","fetchCmsSchema","transformCmsSchema","SchemaContext","SchemaProvider","_ref","_collection$custom","collection","children","skeleton","collectionId","entityTypeSource","customDataSourceId","custom","id","undefined","getSchema","getSchemaFromRegistry","addSchema","addSchemaToRegistry","showError","schema","setSchema","isLoading","setIsLoading","overrides","httpClient","collectionConfig","_collectionConfig$cms","_overrides$cmsSchema","schemaInput","cms","cmsSchema","currentSchema","Error","fetchSchemaForCollection","targetCollectionId","targetCustomDataSourceId","customDataSources","customSchemaProvider","fetchReferencedSchemas","referencedSchema","referencedCollectionIds","Set","Object","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","useSchema","context"],"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 { useSchemaRegistry } from './SchemaRegistryContext';\nimport { useAutoPatternsOverridesContext } from './AutoPatternsOverridesContext';\nimport { useWixPatternsContainer } from '@wix/patterns';\nimport { useError } from './ErrorContext';\nimport {\n fetchCmsSchema,\n transformCmsSchema,\n} from '../dataSourceAdapters/cms/cmsAdapter';\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 { showError } = useError();\n const [schema, setSchema] = useState<SchemaConfig | null>(null);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const overrides = useAutoPatternsOverridesContext();\n const { httpClient } = useWixPatternsContainer();\n\n useEffect(() => {\n const getSchema = async (\n collectionConfig: BaseCollectionConfig,\n ): Promise<SchemaConfig> => {\n switch (collectionConfig.entityTypeSource) {\n case 'cms':\n const schemaInput = collectionConfig.cms?.schema?.id\n ? overrides?.cmsSchema?.[collectionConfig.cms.schema.id]\n : null;\n\n const currentSchema =\n schemaInput ||\n (await fetchCmsSchema(collectionConfig.collectionId));\n\n return transformCmsSchema(currentSchema);\n default:\n throw new Error(\n `Unsupported entityTypeSource: ${collectionConfig.entityTypeSource}`,\n );\n }\n };\n\n const fetchSchemaForCollection = async (\n targetCollectionId: string,\n targetCustomDataSourceId?: string,\n ): Promise<SchemaConfig> => {\n if (entityTypeSource === 'custom') {\n if (!targetCustomDataSourceId || !overrides?.customDataSources) {\n throw new Error('Custom data source not found');\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({\n collectionId: targetCollectionId,\n entityTypeSource,\n });\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 showError(error);\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, [\n collectionId,\n entityTypeSource,\n customDataSourceId,\n addSchemaToRegistry,\n getSchemaFromRegistry,\n overrides,\n httpClient,\n showError,\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,OAAOA,KAAK,IACVC,aAAa,EACbC,UAAU,EACVC,SAAS,EACTC,QAAQ,QAEH,OAAO;AAGd,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,+BAA+B,QAAQ,gCAAgC;AAChF,SAASC,uBAAuB,QAAQ,eAAe;AACvD,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SACEC,cAAc,EACdC,kBAAkB,QACb,sCAAsC;AAE7C,MAAMC,aAAa,gBAAGV,aAAa,CAAsB,IAAI,CAAC;AAQ9D,OAAO,MAAMW,cAAc,GAAGC,IAAA,IAIH;EAAA,IAAAC,kBAAA;EAAA,IAJI;IAC7BC,UAAU;IACVC,QAAQ;IACRC;EACmB,CAAC,GAAAJ,IAAA;EACpB,MAAM;IAAEK,YAAY;IAAEC;EAAiB,CAAC,GAAGJ,UAAU;EACrD,MAAMK,kBAAkB,GACtBL,UAAU,CAACI,gBAAgB,KAAK,QAAQ,IAAI,QAAQ,IAAIJ,UAAU,IAAAD,kBAAA,GAC9DC,UAAU,CAACM,MAAM,qBAAjBP,kBAAA,CAAmBQ,EAAE,GACrBC,SAAS;EACf,MAAM;IAAEC,SAAS,EAAEC,qBAAqB;IAAEC,SAAS,EAAEC;EAAoB,CAAC,GACxEtB,iBAAiB,CAAC,CAAC;EACrB,MAAM;IAAEuB;EAAU,CAAC,GAAGpB,QAAQ,CAAC,CAAC;EAChC,MAAM,CAACqB,MAAM,EAAEC,SAAS,CAAC,GAAG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
|
|
1
|
-
{"version":3,"names":["useAppContext"],"sources":["../../../src/providers/index.ts"],"sourcesContent":["export * from './SchemaContext';\nexport * from './
|
|
1
|
+
{"version":3,"names":["useAppContext"],"sources":["../../../src/providers/index.ts"],"sourcesContent":["export * from './SchemaContext';\nexport * from './AutoPatternsOverridesContext';\nexport * from './ModalContext';\nexport * from './SchemaRegistryContext';\nexport * from './AppConfigContext';\nexport * from './ErrorContext';\nexport { useAppContext } from './AppContext';\n"],"mappings":"AAAA,cAAc,iBAAiB;AAC/B,cAAc,gCAAgC;AAC9C,cAAc,gBAAgB;AAC9B,cAAc,yBAAyB;AACvC,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAC9B,SAASA,aAAa,QAAQ,cAAc","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../src/types/BaseSDK.ts"],"sourcesContent":["import { ModalId } from '../providers/ModalContext';\nimport {
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/types/BaseSDK.ts"],"sourcesContent":["import { ModalId } from '../providers/ModalContext';\nimport { AutoPatternsOverridesContextProps } from '../providers';\nimport { AppConfig } from './types';\nimport { NavigateToEntityPageFunc } from '../hooks';\n\nexport interface BaseSDK {\n appConfig: AppConfig;\n openModal: (id: ModalId, props?: Record<string, any>) => void;\n closeModal: () => void;\n overrides?: AutoPatternsOverridesContextProps;\n navigateToEntityPage?: NavigateToEntityPageFunc;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ComponentTypeEnum"],"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 CollectionComponentConfig\n extends BaseCollectionComponentConfig {\n type: 'collection';\n layout: LayoutItemConfig[];\n}\n\nexport interface CustomComponentConfig {\n type: 'custom';\n id: string;\n}\n\nexport type ComponentConfig = CollectionComponentConfig | CustomComponentConfig;\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 showTitleBar?: boolean;\n sections?: {\n id: string;\n };\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"],"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 CollectionComponentConfig\n extends BaseCollectionComponentConfig {\n type: 'collection';\n layout: LayoutItemConfig[];\n}\n\nexport interface CustomComponentConfig {\n type: 'custom';\n id: string;\n}\n\nexport type ComponentConfig = CollectionComponentConfig | CustomComponentConfig;\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 showTitleBar?: boolean;\n sections?: {\n id: string;\n };\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 optimisticActions?: {\n id: string;\n };\n paginationMode?: 'cursor' | 'offset';\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":"AAkLA,WAAYA,iBAAiB,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 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 }\n | {\n mode: 'custom';\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 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};\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 biName?: 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 }\n | {\n mode: 'custom';\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 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};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/types/fetchData.ts"],"sourcesContent":["import { CursorQuery, OffsetQuery } from '@wix/patterns';\n\nexport type Mode = 'cursor' | 'offset';\n\nexport type UseFetchDataProps<M extends Mode> = {\n searchableFieldIds?: string[];\n filterFieldMapping?: Record<string, { fieldId: string }>;\n paginationMode?: M;\n};\n\nexport interface CursorQueryResult {\n items: any[];\n cursor?: string | undefined | null;\n total?: number | null;\n}\n\nexport interface OffsetQueryResult {\n items: any[];\n total?: number | null;\n hasNext?: boolean;\n}\n\nexport type FetchDataFn<M extends Mode> = M extends 'cursor'\n ? (q: CursorQuery<any>) => Promise<CursorQueryResult>\n : (q: OffsetQuery<any>) => Promise<OffsetQueryResult>;\n"],"mappings":"","ignoreList":[]}
|
package/dist/esm/types/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"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,cAAc,SAAS;AACvB,cAAc,wBAAwB;AACtC,cAAc,oBAAoB;AAClC,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,wBAAwB;AACtC,cAAc,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"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';\nexport * from './fetchData';\n"],"mappings":"AAAA,cAAc,SAAS;AACvB,cAAc,wBAAwB;AACtC,cAAc,oBAAoB;AAClC,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,wBAAwB;AACtC,cAAc,WAAW;AACzB,cAAc,aAAa","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../src/types/types.ts"],"sourcesContent":["import { EntityPageConfig } from './EntityPageConfig';\nimport { CollectionPageConfig } from './CollectionPageConfig';\n\ninterface BaseCollectionConfigCommon {\n collectionId: string;\n}\n\
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/types/types.ts"],"sourcesContent":["import { EntityPageConfig } from './EntityPageConfig';\nimport { CollectionPageConfig } from './CollectionPageConfig';\nimport { useOptimisticActions } from '@wix/patterns';\nimport { CursorQueryResult, OffsetQueryResult } from './fetchData';\n\ninterface BaseCollectionConfigCommon {\n collectionId: string;\n}\n\nexport interface CMSCollectionConfig extends BaseCollectionConfigCommon {\n entityTypeSource: 'cms';\n cms?: {\n schema?: { id: string };\n };\n custom?: never;\n}\n\ninterface CustomCollectionConfig extends BaseCollectionConfigCommon {\n entityTypeSource: 'custom';\n cms?: never;\n custom: {\n id: string;\n };\n}\n\nexport type BaseCollectionConfig = CMSCollectionConfig | 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 Query {\n limit: number;\n offset?: number;\n page: number;\n search?: string;\n cursor?: string | null;\n filters: Record<string, any>;\n sort?: {\n fieldName: string;\n order: 'asc' | 'desc';\n }[];\n}\nexport interface SchemaConfig {\n id: string;\n fields: Record<string, Field | undefined>;\n displayField: string;\n idField: 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: Query,\n options?: {\n searchableFieldIds?: string[];\n filterFieldMapping?: Record<string, { fieldId: string }>;\n },\n ) => Promise<CursorQueryResult | OffsetQueryResult>;\n };\n}\n\nexport type OptimisticActionsParams = Parameters<\n typeof useOptimisticActions\n>[1];\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["resolveAction","actionConfig","action","label","skin"],"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":"AAEA,OAAO,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;
|
|
1
|
+
{"version":3,"names":["resolveAction","actionConfig","action","label","skin","biName"],"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 biName: actionConfig.biName,\n };\n};\n"],"mappings":"AAEA,OAAO,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,IAAI;IACvBC,MAAM,EAAEJ,YAAY,CAACI;EACvB,CAAC;AACH,CAAC","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 hidden?: boolean;\n tooltip?: string;\n skin?: string;\n}\n\nexport interface BaseContextParams {\n schema: SchemaConfig;\n}\n\nexport interface ActionsSDK extends BaseSDK {\n getSchema: (collectionId: string) => SchemaConfig | undefined;\n collectionId: string; // TODO: Why collectionId is needed here? getSchema with internal collectionId is enough\n getOptimisticActions: (\n collectionId: string,\n ) => CollectionOptimisticActions<any, any>;\n}\n\nexport interface BaseActionParams<T = Record<string, any>> {\n sdk: ActionsSDK;\n actionParams: T;\n}\n\nexport interface ActionCellBaseParams extends BaseActionParams {\n actionParams: {\n item: any;\n index: number;\n api: ActionCellAPI<any, any>;\n };\n}\n\nexport interface BulkDeleteActionParams extends BaseActionParams {\n action: BulkDeleteActionConfig;\n actionParams: {\n selectedValues: any[];\n total: number;\n };\n}\n\nexport interface DeleteActionParams extends ActionCellBaseParams {\n action: DeleteActionConfig;\n}\n\nexport interface UpdateActionParams extends BaseActionParams {\n action: UpdateActionConfig;\n}\n\nexport interface CreateActionParams extends BaseActionParams {\n action: CreateActionConfig;\n}\n\nexport interface CustomActionParams<T> extends BaseActionParams<T> {\n action: CustomActionConfig;\n}\n\nexport interface ActionModalProps {\n modalParams: Record<string, any>;\n actionParams: Record<string, any>;\n sdk: ActionsSDK;\n}\n\nexport interface CustomActionModalProps extends ActionModalProps {\n modalParams: { id: string };\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/utils/actions/types.ts"],"sourcesContent":["import { ActionCellAPI, CollectionOptimisticActions } from '@wix/patterns';\nimport {\n UpdateActionConfig,\n CustomActionConfig,\n SchemaConfig,\n BulkDeleteActionConfig,\n DeleteActionConfig,\n CreateActionConfig,\n BaseSDK,\n} from '../../types';\nimport { IconElement } from '@wix/design-system';\n\nexport interface ResolvedAction {\n label: string;\n icon: IconElement;\n onClick: () => void;\n disabled?: boolean;\n hidden?: boolean;\n tooltip?: string;\n skin?: string;\n biName?: string;\n}\n\nexport interface BaseContextParams {\n schema: SchemaConfig;\n}\n\nexport interface ActionsSDK extends BaseSDK {\n getSchema: (collectionId: string) => SchemaConfig | undefined;\n collectionId: string; // TODO: Why collectionId is needed here? getSchema with internal collectionId is enough\n getOptimisticActions: (\n collectionId: string,\n ) => CollectionOptimisticActions<any, any>;\n}\n\nexport interface BaseActionParams<T = Record<string, any>> {\n sdk: ActionsSDK;\n actionParams: T;\n}\n\nexport interface ActionCellBaseParams extends BaseActionParams {\n actionParams: {\n item: any;\n index: number;\n api: ActionCellAPI<any, any>;\n };\n}\n\nexport interface BulkDeleteActionParams extends BaseActionParams {\n action: BulkDeleteActionConfig;\n actionParams: {\n selectedValues: any[];\n total: number;\n };\n}\n\nexport interface DeleteActionParams extends ActionCellBaseParams {\n action: DeleteActionConfig;\n}\n\nexport interface UpdateActionParams extends BaseActionParams {\n action: UpdateActionConfig;\n}\n\nexport interface CreateActionParams extends BaseActionParams {\n action: CreateActionConfig;\n}\n\nexport interface CustomActionParams<T> extends BaseActionParams<T> {\n action: CustomActionConfig;\n}\n\nexport interface ActionModalProps {\n modalParams: Record<string, any>;\n actionParams: Record<string, any>;\n sdk: ActionsSDK;\n}\n\nexport interface CustomActionModalProps extends ActionModalProps {\n modalParams: { id: string };\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Copied https://github.com/wix-private/picasso-giza-host/blob/7750022685df79e499194fc7f5225f5f49d62ee0/packages/picasso-common/src/services/metaSiteIdService.ts#L2
|
|
2
|
+
export const getMetasiteId = () => {
|
|
3
|
+
const match = window.location.href.match(/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i);
|
|
4
|
+
return match == null ? void 0 : match[0];
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=vibe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getMetasiteId","match","window","location","href"],"sources":["../../../src/utils/vibe.ts"],"sourcesContent":["// Copied https://github.com/wix-private/picasso-giza-host/blob/7750022685df79e499194fc7f5225f5f49d62ee0/packages/picasso-common/src/services/metaSiteIdService.ts#L2\nexport const getMetasiteId = () => {\n const match = window.location.href.match(\n /[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i,\n );\n return match?.[0];\n};\n"],"mappings":"AAAA;AACA,OAAO,MAAMA,aAAa,GAAGA,CAAA,KAAM;EACjC,MAAMC,KAAK,GAAGC,MAAM,CAACC,QAAQ,CAACC,IAAI,CAACH,KAAK,CACtC,0EACF,CAAC;EACD,OAAOA,KAAK,oBAALA,KAAK,CAAG,CAAC,CAAC;AACnB,CAAC","ignoreList":[]}
|
package/dist/types/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoPatternsCollectionPage.d.ts","sourceRoot":"","sources":["../../../../src/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"AutoPatternsCollectionPage.d.ts","sourceRoot":"","sources":["../../../../src/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAIxE,MAAM,WAAW,+BAA+B;IAC9C,aAAa,EAAE,oBAAoB,CAAC;CACrC;AAED,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,EAAE,CAC/C,+BAA+B,CAwBhC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoPatternsCollectionPageFooter.d.ts","sourceRoot":"","sources":["../../../../src/components/AutoPatternsCollectionPageFooter/AutoPatternsCollectionPageFooter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,eAAO,MAAM,gCAAgC,gCA4B5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoPatternsRoutes.d.ts","sourceRoot":"","sources":["../../../../src/components/AutoPatternsRoute/AutoPatternsRoutes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"AutoPatternsRoutes.d.ts","sourceRoot":"","sources":["../../../../src/components/AutoPatternsRoute/AutoPatternsRoutes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQxC,eAAO,MAAM,kBAAkB,GAAI,YAAY;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,sBAmDnE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SchemaConfig, PatternsFieldType } from '../../types';
|
|
2
2
|
import { collections } from '@wix/data';
|
|
3
3
|
export declare const CmsFieldTypeToPatternsFieldType: Partial<Record<collections.Type, PatternsFieldType>>;
|
|
4
|
-
export declare function fetchCmsSchema(collectionId: string): Promise<
|
|
4
|
+
export declare function fetchCmsSchema(collectionId: string): Promise<collections.DataCollection>;
|
|
5
|
+
export declare function transformCmsSchema(schema: collections.DataCollection): SchemaConfig;
|
|
5
6
|
//# sourceMappingURL=cmsAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmsAdapter.d.ts","sourceRoot":"","sources":["../../../../src/dataSourceAdapters/cms/cmsAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,WAAW,EAAS,MAAM,WAAW,CAAC;AAI/C,eAAO,MAAM,+BAA+B,EAAE,OAAO,CACnD,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAgB5C,CAAC;AAEF,wBAAsB,cAAc,CAClC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"cmsAdapter.d.ts","sourceRoot":"","sources":["../../../../src/dataSourceAdapters/cms/cmsAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,WAAW,EAAS,MAAM,WAAW,CAAC;AAI/C,eAAO,MAAM,+BAA+B,EAAE,OAAO,CACnD,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAgB5C,CAAC;AAEF,wBAAsB,cAAc,CAClC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAMrC;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,WAAW,CAAC,cAAc,GACjC,YAAY,CAkGd"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { CollectionState } from '@wix/patterns';
|
|
2
|
-
|
|
2
|
+
import { CollectionConfig } from '../types/CollectionPageConfig';
|
|
3
|
+
interface UseAutoPatternsOptimisticActionParams {
|
|
4
|
+
collectionConfig: CollectionConfig;
|
|
5
|
+
collectionState: CollectionState<any>;
|
|
6
|
+
}
|
|
7
|
+
export declare const useAutoPatternsOptimisticActions: ({ collectionConfig, collectionState, }: UseAutoPatternsOptimisticActionParams) => import("@wix/patterns").CollectionOptimisticActions<unknown, import("@wix/patterns").FiltersMap>;
|
|
8
|
+
export {};
|
|
3
9
|
//# sourceMappingURL=useAutoPatternsOptimisticActions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutoPatternsOptimisticActions.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAutoPatternsOptimisticActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAwB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"useAutoPatternsOptimisticActions.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAutoPatternsOptimisticActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAwB,MAAM,eAAe,CAAC;AAGtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,UAAU,qCAAqC;IAC7C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,eAAe,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;CACvC;AAED,eAAO,MAAM,gCAAgC,GAAI,wCAG9C,qCAAqC,qGAoBvC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Filter } from '@wix/patterns';
|
|
2
|
+
import { CollectionConfig, FetchDataFn } from '../types';
|
|
3
|
+
export declare const useBaseCollectionParams: ({ config, fetchData, filters, }: {
|
|
4
|
+
config: CollectionConfig;
|
|
5
|
+
fetchData: FetchDataFn<any>;
|
|
6
|
+
filters: {
|
|
7
|
+
[key: string]: Filter<any>;
|
|
8
|
+
};
|
|
9
|
+
}) => {
|
|
10
|
+
queryName: string;
|
|
11
|
+
paginationMode: any;
|
|
12
|
+
itemKey: (item: any) => any;
|
|
13
|
+
itemName: (item: any) => any;
|
|
14
|
+
toExtendedFields: (item: any) => any;
|
|
15
|
+
fetchErrorMessage: ({ err }: {
|
|
16
|
+
err: unknown;
|
|
17
|
+
}) => string;
|
|
18
|
+
fetchData: ((q: import("@wix/patterns").CursorQuery<any>) => Promise<import("../types").CursorQueryResult>) | ((q: import("@wix/patterns").OffsetQuery<any>) => Promise<import("../types").OffsetQueryResult>);
|
|
19
|
+
filters: {
|
|
20
|
+
[key: string]: Filter<any>;
|
|
21
|
+
};
|
|
22
|
+
limit: number | undefined;
|
|
23
|
+
persistQueryToUrl: boolean | undefined;
|
|
24
|
+
disableAutoSelectAllCount: boolean;
|
|
25
|
+
selectionConsistencyMode: "preserve" | "clear" | undefined;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useBaseCollectionParams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBaseCollectionParams.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBaseCollectionParams.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD,eAAO,MAAM,uBAAuB,GAAI,iCAIrC;IACD,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;KAC5B,CAAC;CACH;;oBAcqC,GAAG;oBACrB,GAAG;qBACF,GAAG;6BACK,GAAG;iCACC;QAAE,GAAG,EAAE,OAAO,CAAA;KAAE;;;;;;;;;CAQhD,CAAC"}
|