@wix/auto-patterns 1.42.0 → 1.44.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/AutoPatternsApp/AutoPatternsApp.js +19 -5
- package/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.js.map +1 -1
- package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +29 -74
- package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -1
- package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGrid.js +147 -25
- package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGrid.js.map +1 -1
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js +10 -27
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js +141 -40
- package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/cjs/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.js +169 -9
- package/dist/cjs/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.js.map +1 -1
- package/dist/cjs/hooks/getCommonCollectionFeaturesAsync.js +11 -0
- package/dist/cjs/hooks/getCommonCollectionFeaturesAsync.js.map +1 -0
- package/dist/cjs/hooks/getFilterComponent.js +52 -0
- package/dist/cjs/hooks/getFilterComponent.js.map +1 -0
- package/dist/cjs/hooks/index.js +4 -11
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/pluginsDynamicImports.js +25 -0
- package/dist/cjs/hooks/pluginsDynamicImports.js.map +1 -0
- package/dist/cjs/hooks/useAsyncFeaturesPromiseState.js +30 -0
- package/dist/cjs/hooks/useAsyncFeaturesPromiseState.js.map +1 -0
- package/dist/cjs/hooks/useBaseCollectionComponentReadyFeatures.js +62 -0
- package/dist/cjs/hooks/useBaseCollectionComponentReadyFeatures.js.map +1 -0
- package/dist/cjs/hooks/useBasePatternsStateParams.js +36 -0
- package/dist/cjs/hooks/useBasePatternsStateParams.js.map +1 -0
- package/dist/cjs/hooks/useCollectionInitAsyncDeps.js +15 -0
- package/dist/cjs/hooks/useCollectionInitAsyncDeps.js.map +1 -0
- package/dist/cjs/hooks/useCommonCollectionFeatures.js +14 -4
- package/dist/cjs/hooks/useCommonCollectionFeatures.js.map +1 -1
- package/dist/cjs/hooks/useFilters.js +17 -103
- package/dist/cjs/hooks/useFilters.js.map +1 -1
- package/dist/cjs/hooks/useFiltersState.js +112 -0
- package/dist/cjs/hooks/useFiltersState.js.map +1 -0
- package/dist/cjs/hooks/useGridFeaturesAsync.js +42 -0
- package/dist/cjs/hooks/useGridFeaturesAsync.js.map +1 -0
- package/dist/cjs/hooks/useGridVisibleFieldIds.js +17 -0
- package/dist/cjs/hooks/useGridVisibleFieldIds.js.map +1 -0
- package/dist/cjs/hooks/useSyncCollectionStateToAppContext.js +22 -0
- package/dist/cjs/hooks/useSyncCollectionStateToAppContext.js.map +1 -0
- package/dist/cjs/hooks/useTableFeaturesAsync.js +51 -0
- package/dist/cjs/hooks/useTableFeaturesAsync.js.map +1 -0
- package/dist/cjs/hooks/useTableGridSwitchFeaturesAsync.js +52 -0
- package/dist/cjs/hooks/useTableGridSwitchFeaturesAsync.js.map +1 -0
- package/dist/cjs/hooks/useTableSections.js +18 -0
- package/dist/cjs/hooks/useTableSections.js.map +1 -0
- package/dist/cjs/utils/filterCreators.js +16 -31
- package/dist/cjs/utils/filterCreators.js.map +1 -1
- package/dist/cjs/utils/minimalRequiredPatternsRuntimeCheck.js +18 -0
- package/dist/cjs/utils/minimalRequiredPatternsRuntimeCheck.js.map +1 -0
- package/dist/cjs/utils/minimalRequiredRuntimeCheck.js +21 -0
- package/dist/cjs/utils/minimalRequiredRuntimeCheck.js.map +1 -0
- package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.js +14 -1
- package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +23 -31
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -1
- package/dist/esm/components/AutoPatternsGrid/AutoPatternsGrid.js +134 -28
- package/dist/esm/components/AutoPatternsGrid/AutoPatternsGrid.js.map +1 -1
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js +3 -7
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js +126 -41
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/esm/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.js +155 -10
- package/dist/esm/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.js.map +1 -1
- package/dist/esm/hooks/getCommonCollectionFeaturesAsync.js +7 -0
- package/dist/esm/hooks/getCommonCollectionFeaturesAsync.js.map +1 -0
- package/dist/esm/hooks/getFilterComponent.js +48 -0
- package/dist/esm/hooks/getFilterComponent.js.map +1 -0
- package/dist/esm/hooks/index.js +1 -2
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/pluginsDynamicImports.js +13 -0
- package/dist/esm/hooks/pluginsDynamicImports.js.map +1 -0
- package/dist/esm/hooks/useAsyncFeaturesPromiseState.js +28 -0
- package/dist/esm/hooks/useAsyncFeaturesPromiseState.js.map +1 -0
- package/dist/esm/hooks/useBaseCollectionComponentReadyFeatures.js +58 -0
- package/dist/esm/hooks/useBaseCollectionComponentReadyFeatures.js.map +1 -0
- package/dist/esm/hooks/useBasePatternsStateParams.js +32 -0
- package/dist/esm/hooks/useBasePatternsStateParams.js.map +1 -0
- package/dist/esm/hooks/useCollectionInitAsyncDeps.js +11 -0
- package/dist/esm/hooks/useCollectionInitAsyncDeps.js.map +1 -0
- package/dist/esm/hooks/useCommonCollectionFeatures.js +1 -0
- package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
- package/dist/esm/hooks/useFilters.js +14 -100
- package/dist/esm/hooks/useFilters.js.map +1 -1
- package/dist/esm/hooks/useFiltersState.js +107 -0
- package/dist/esm/hooks/useFiltersState.js.map +1 -0
- package/dist/esm/hooks/useGridFeaturesAsync.js +37 -0
- package/dist/esm/hooks/useGridFeaturesAsync.js.map +1 -0
- package/dist/esm/hooks/useGridVisibleFieldIds.js +13 -0
- package/dist/esm/hooks/useGridVisibleFieldIds.js.map +1 -0
- package/dist/esm/hooks/useSyncCollectionStateToAppContext.js +18 -0
- package/dist/esm/hooks/useSyncCollectionStateToAppContext.js.map +1 -0
- package/dist/esm/hooks/useTableFeaturesAsync.js +46 -0
- package/dist/esm/hooks/useTableFeaturesAsync.js.map +1 -0
- package/dist/esm/hooks/useTableGridSwitchFeaturesAsync.js +47 -0
- package/dist/esm/hooks/useTableGridSwitchFeaturesAsync.js.map +1 -0
- package/dist/esm/hooks/useTableSections.js +14 -0
- package/dist/esm/hooks/useTableSections.js.map +1 -0
- package/dist/esm/utils/filterCreators.js +17 -32
- package/dist/esm/utils/filterCreators.js.map +1 -1
- package/dist/esm/utils/minimalRequiredPatternsRuntimeCheck.js +14 -0
- package/dist/esm/utils/minimalRequiredPatternsRuntimeCheck.js.map +1 -0
- package/dist/esm/utils/minimalRequiredRuntimeCheck.js +17 -0
- package/dist/esm/utils/minimalRequiredRuntimeCheck.js.map +1 -0
- package/dist/types/components/AutoPatternsApp/AutoPatternsApp.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.d.ts +6 -0
- package/dist/types/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsGrid/AutoPatternsGrid.d.ts +17 -2
- package/dist/types/components/AutoPatternsGrid/AutoPatternsGrid.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsRoute/AutoPatternsPage.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsTable/AutoPatternsTable.d.ts +17 -2
- package/dist/types/components/AutoPatternsTable/AutoPatternsTable.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.d.ts +18 -2
- package/dist/types/components/AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch.d.ts.map +1 -1
- package/dist/types/hooks/getCommonCollectionFeaturesAsync.d.ts +4 -0
- package/dist/types/hooks/getCommonCollectionFeaturesAsync.d.ts.map +1 -0
- package/dist/types/hooks/getFilterComponent.d.ts +4 -0
- package/dist/types/hooks/getFilterComponent.d.ts.map +1 -0
- package/dist/types/hooks/index.d.ts +1 -2
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/hooks/pluginsDynamicImports.d.ts +7 -0
- package/dist/types/hooks/pluginsDynamicImports.d.ts.map +1 -0
- package/dist/types/hooks/useAsyncFeaturesPromiseState.d.ts +6 -0
- package/dist/types/hooks/useAsyncFeaturesPromiseState.d.ts.map +1 -0
- package/dist/types/hooks/useBaseCollectionComponentReadyFeatures.d.ts +36 -0
- package/dist/types/hooks/useBaseCollectionComponentReadyFeatures.d.ts.map +1 -0
- package/dist/types/hooks/useBasePatternsStateParams.d.ts +31 -0
- package/dist/types/hooks/useBasePatternsStateParams.d.ts.map +1 -0
- package/dist/types/hooks/useCollectionInitAsyncDeps.d.ts +4 -0
- package/dist/types/hooks/useCollectionInitAsyncDeps.d.ts.map +1 -0
- package/dist/types/hooks/useCommonCollectionFeatures.d.ts +1 -0
- package/dist/types/hooks/useCommonCollectionFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useFilters.d.ts +9 -21
- package/dist/types/hooks/useFilters.d.ts.map +1 -1
- package/dist/types/hooks/useFiltersState.d.ts +26 -0
- package/dist/types/hooks/useFiltersState.d.ts.map +1 -0
- package/dist/types/hooks/useGridDragAndDrop.d.ts +1 -1
- package/dist/types/hooks/useGridFeaturesAsync.d.ts +26 -0
- package/dist/types/hooks/useGridFeaturesAsync.d.ts.map +1 -0
- package/dist/types/hooks/useGridVisibleFieldIds.d.ts +3 -0
- package/dist/types/hooks/useGridVisibleFieldIds.d.ts.map +1 -0
- package/dist/types/hooks/useSyncCollectionStateToAppContext.d.ts +6 -0
- package/dist/types/hooks/useSyncCollectionStateToAppContext.d.ts.map +1 -0
- package/dist/types/hooks/useTableFeaturesAsync.d.ts +29 -0
- package/dist/types/hooks/useTableFeaturesAsync.d.ts.map +1 -0
- package/dist/types/hooks/useTableGridSwitchDragAndDrop.d.ts +1 -1
- package/dist/types/hooks/useTableGridSwitchFeaturesAsync.d.ts +29 -0
- package/dist/types/hooks/useTableGridSwitchFeaturesAsync.d.ts.map +1 -0
- package/dist/types/hooks/useTableSections.d.ts +8 -0
- package/dist/types/hooks/useTableSections.d.ts.map +1 -0
- package/dist/types/utils/filterCreators.d.ts +10 -19
- package/dist/types/utils/filterCreators.d.ts.map +1 -1
- package/dist/types/utils/minimalRequiredPatternsRuntimeCheck.d.ts +5 -0
- package/dist/types/utils/minimalRequiredPatternsRuntimeCheck.d.ts.map +1 -0
- package/dist/types/utils/minimalRequiredRuntimeCheck.d.ts +9 -0
- package/dist/types/utils/minimalRequiredRuntimeCheck.d.ts.map +1 -0
- package/package.json +18 -17
- package/dist/cjs/hooks/useGridFeatures.js +0 -63
- package/dist/cjs/hooks/useGridFeatures.js.map +0 -1
- package/dist/cjs/hooks/useTableFeatures.js +0 -79
- package/dist/cjs/hooks/useTableFeatures.js.map +0 -1
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js +0 -83
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js.map +0 -1
- package/dist/esm/hooks/useGridFeatures.js +0 -58
- package/dist/esm/hooks/useGridFeatures.js.map +0 -1
- package/dist/esm/hooks/useTableFeatures.js +0 -74
- package/dist/esm/hooks/useTableFeatures.js.map +0 -1
- package/dist/esm/hooks/useTableGridSwitchFeatures.js +0 -78
- package/dist/esm/hooks/useTableGridSwitchFeatures.js.map +0 -1
- package/dist/types/hooks/useGridFeatures.d.ts +0 -43
- package/dist/types/hooks/useGridFeatures.d.ts.map +0 -1
- package/dist/types/hooks/useTableFeatures.d.ts +0 -27
- package/dist/types/hooks/useTableFeatures.d.ts.map +0 -1
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +0 -52
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.importTableSections = exports.importTableGridSwitchDragAndDrop = exports.importTableDragAndDrop = exports.importGridDragAndDrop = exports.importCommonCollectionFeatures = exports.importBaseTableFeatures = void 0;
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
7
|
+
const importTableDragAndDrop = () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "useTableDragAndDrop" */
|
|
8
|
+
'./useTableDragAndDrop')));
|
|
9
|
+
exports.importTableDragAndDrop = importTableDragAndDrop;
|
|
10
|
+
const importTableGridSwitchDragAndDrop = () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "useTableGridSwitchDragAndDrop" */
|
|
11
|
+
'./useTableGridSwitchDragAndDrop')));
|
|
12
|
+
exports.importTableGridSwitchDragAndDrop = importTableGridSwitchDragAndDrop;
|
|
13
|
+
const importGridDragAndDrop = () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "useGridDragAndDrop" */
|
|
14
|
+
'./useGridDragAndDrop')));
|
|
15
|
+
exports.importGridDragAndDrop = importGridDragAndDrop;
|
|
16
|
+
const importBaseTableFeatures = () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "useBaseTableFeatures" */
|
|
17
|
+
'./useBaseTableFeatures')));
|
|
18
|
+
exports.importBaseTableFeatures = importBaseTableFeatures;
|
|
19
|
+
const importCommonCollectionFeatures = () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "useCommonCollectionFeatures" */
|
|
20
|
+
'./useCommonCollectionFeatures')));
|
|
21
|
+
exports.importCommonCollectionFeatures = importCommonCollectionFeatures;
|
|
22
|
+
const importTableSections = () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "useTableSections" */
|
|
23
|
+
'./useTableSections')));
|
|
24
|
+
exports.importTableSections = importTableSections;
|
|
25
|
+
//# sourceMappingURL=pluginsDynamicImports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["importTableDragAndDrop","Promise","resolve","then","_interopRequireWildcard","require","exports","importTableGridSwitchDragAndDrop","importGridDragAndDrop","importBaseTableFeatures","importCommonCollectionFeatures","importTableSections"],"sources":["../../../src/hooks/pluginsDynamicImports.ts"],"sourcesContent":["export const importTableDragAndDrop = () =>\n import(\n /* webpackChunkName: \"useTableDragAndDrop\" */\n './useTableDragAndDrop'\n );\n\nexport const importTableGridSwitchDragAndDrop = () =>\n import(\n /* webpackChunkName: \"useTableGridSwitchDragAndDrop\" */\n './useTableGridSwitchDragAndDrop'\n );\n\nexport const importGridDragAndDrop = () =>\n import(\n /* webpackChunkName: \"useGridDragAndDrop\" */\n './useGridDragAndDrop'\n );\n\nexport const importBaseTableFeatures = () =>\n import(\n /* webpackChunkName: \"useBaseTableFeatures\" */\n './useBaseTableFeatures'\n );\n\nexport const importCommonCollectionFeatures = () =>\n import(\n /* webpackChunkName: \"useCommonCollectionFeatures\" */\n './useCommonCollectionFeatures'\n );\n\nexport const importTableSections = () =>\n import(\n /* webpackChunkName: \"useTableSections\" */\n './useTableSections'\n );\n"],"mappings":";;;;;;AAAO,MAAMA,sBAAsB,GAAGA,CAAA,KAAAC,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAAC,uBAAA,CAAAC,OAAA,CAElC;AACA,uBAAuB,GACxB;AAACC,OAAA,CAAAN,sBAAA,GAAAA,sBAAA;AAEG,MAAMO,gCAAgC,GAAGA,CAAA,KAAAN,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAAC,uBAAA,CAAAC,OAAA,CAE5C;AACA,iCAAiC,GAClC;AAACC,OAAA,CAAAC,gCAAA,GAAAA,gCAAA;AAEG,MAAMC,qBAAqB,GAAGA,CAAA,KAAAP,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAAC,uBAAA,CAAAC,OAAA,CAEjC;AACA,sBAAsB,GACvB;AAACC,OAAA,CAAAE,qBAAA,GAAAA,qBAAA;AAEG,MAAMC,uBAAuB,GAAGA,CAAA,KAAAR,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAAC,uBAAA,CAAAC,OAAA,CAEnC;AACA,wBAAwB,GACzB;AAACC,OAAA,CAAAG,uBAAA,GAAAA,uBAAA;AAEG,MAAMC,8BAA8B,GAAGA,CAAA,KAAAT,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAAC,uBAAA,CAAAC,OAAA,CAE1C;AACA,+BAA+B,GAChC;AAACC,OAAA,CAAAI,8BAAA,GAAAA,8BAAA;AAEG,MAAMC,mBAAmB,GAAGA,CAAA,KAAAV,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAAC,uBAAA,CAAAC,OAAA,CAE/B;AACA,oBAAoB,GACrB;AAACC,OAAA,CAAAK,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useAsyncFeaturesPromiseState = useAsyncFeaturesPromiseState;
|
|
5
|
+
var _core = require("@wix/patterns/core");
|
|
6
|
+
var _react = require("react");
|
|
7
|
+
function useAsyncFeaturesPromiseState(loaders) {
|
|
8
|
+
const [state] = (0, _react.useState)(() => {
|
|
9
|
+
const r = new _core.PromiseState({
|
|
10
|
+
createPromise: async () => {
|
|
11
|
+
const entries = await Promise.all(Object.entries(loaders).map(async ([key, loadFunc]) => {
|
|
12
|
+
if (loadFunc) {
|
|
13
|
+
const result = await loadFunc();
|
|
14
|
+
return [key, result];
|
|
15
|
+
} else {
|
|
16
|
+
return [key, null];
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
return entries.reduce((acc, [key, value]) => {
|
|
20
|
+
acc[key] = value;
|
|
21
|
+
return acc;
|
|
22
|
+
}, {});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
r.fetchOnce();
|
|
26
|
+
return r;
|
|
27
|
+
});
|
|
28
|
+
return state;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=useAsyncFeaturesPromiseState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_core","require","_react","useAsyncFeaturesPromiseState","loaders","state","useState","r","PromiseState","createPromise","entries","Promise","all","Object","map","key","loadFunc","result","reduce","acc","value","fetchOnce"],"sources":["../../../src/hooks/useAsyncFeaturesPromiseState.ts"],"sourcesContent":["import { PromiseState } from '@wix/patterns/core';\nimport { useState } from 'react';\n\nexport type AsyncFeaturesState<\n T extends Record<string, () => Promise<any> | null>,\n> = {\n [K in keyof T]: T[K] extends () => Promise<infer R> | null\n ? R | null | undefined\n : null | undefined;\n};\n\nexport function useAsyncFeaturesPromiseState<\n T extends Record<string, () => Promise<any> | null>,\n>(loaders: T): PromiseState<AsyncFeaturesState<T>> {\n const [state] = useState(() => {\n const r = new PromiseState({\n createPromise: async () => {\n const entries = await Promise.all(\n Object.entries(loaders).map(async ([key, loadFunc]) => {\n if (loadFunc) {\n const result = await loadFunc();\n return [key, result];\n } else {\n return [key, null];\n }\n }),\n );\n\n return entries.reduce((acc, [key, value]) => {\n acc[key as keyof AsyncFeaturesState<T>] = value;\n return acc;\n }, {} as AsyncFeaturesState<T>);\n },\n });\n\n r.fetchOnce();\n\n return r;\n });\n\n return state;\n}\n"],"mappings":";;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAUO,SAASE,4BAA4BA,CAE1CC,OAAU,EAAuC;EACjD,MAAM,CAACC,KAAK,CAAC,GAAG,IAAAC,eAAQ,EAAC,MAAM;IAC7B,MAAMC,CAAC,GAAG,IAAIC,kBAAY,CAAC;MACzBC,aAAa,EAAE,MAAAA,CAAA,KAAY;QACzB,MAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC/BC,MAAM,CAACH,OAAO,CAACN,OAAO,CAAC,CAACU,GAAG,CAAC,OAAO,CAACC,GAAG,EAAEC,QAAQ,CAAC,KAAK;UACrD,IAAIA,QAAQ,EAAE;YACZ,MAAMC,MAAM,GAAG,MAAMD,QAAQ,CAAC,CAAC;YAC/B,OAAO,CAACD,GAAG,EAAEE,MAAM,CAAC;UACtB,CAAC,MAAM;YACL,OAAO,CAACF,GAAG,EAAE,IAAI,CAAC;UACpB;QACF,CAAC,CACH,CAAC;QAED,OAAOL,OAAO,CAACQ,MAAM,CAAC,CAACC,GAAG,EAAE,CAACJ,GAAG,EAAEK,KAAK,CAAC,KAAK;UAC3CD,GAAG,CAACJ,GAAG,CAAgC,GAAGK,KAAK;UAC/C,OAAOD,GAAG;QACZ,CAAC,EAAE,CAAC,CAA0B,CAAC;MACjC;IACF,CAAC,CAAC;IAEFZ,CAAC,CAACc,SAAS,CAAC,CAAC;IAEb,OAAOd,CAAC;EACV,CAAC,CAAC;EAEF,OAAOF,KAAK;AACd","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useBaseCollectionComponentReadyFeatures = useBaseCollectionComponentReadyFeatures;
|
|
5
|
+
var _useSyncCollectionStateToAppContext = require("./useSyncCollectionStateToAppContext");
|
|
6
|
+
var _useCollectionInitAsyncDeps = require("./useCollectionInitAsyncDeps");
|
|
7
|
+
var _patterns = require("@wix/patterns");
|
|
8
|
+
/**
|
|
9
|
+
* useBaseCollectionComponentReadyFeatures - Step 5 (Shared Across All Flows)
|
|
10
|
+
*
|
|
11
|
+
* This is the shared hook used by all flows to prepare final collection features once async loading is complete.
|
|
12
|
+
* It handles the common functionality needed by all collection components regardless of display mode.
|
|
13
|
+
*
|
|
14
|
+
* Key Responsibilities:
|
|
15
|
+
* - Syncs collection state to app context for external consumption
|
|
16
|
+
* - Initializes async dependencies and connects them to the collection
|
|
17
|
+
* - Extracts and prepares common collection features (filters, search, actions, etc.)
|
|
18
|
+
* - Returns standardized props that all final components (Table/Grid/TableGridSwitch) can use
|
|
19
|
+
* - Provides consistent interface across all three rendering flows
|
|
20
|
+
*/
|
|
21
|
+
function useBaseCollectionComponentReadyFeatures(props) {
|
|
22
|
+
const {
|
|
23
|
+
collection,
|
|
24
|
+
config,
|
|
25
|
+
asyncFeaturesState,
|
|
26
|
+
baseStateParams
|
|
27
|
+
} = props;
|
|
28
|
+
|
|
29
|
+
// Extract loaded common features from async state (shared by all flows)
|
|
30
|
+
const {
|
|
31
|
+
commonCollectionFeatures
|
|
32
|
+
} = (0, _patterns.useSelector)(() => ({
|
|
33
|
+
...asyncFeaturesState.status.data
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
// STEP 5A: Sync the collection state to app context for external access
|
|
37
|
+
// This allows other parts of the app to access current collection state
|
|
38
|
+
(0, _useSyncCollectionStateToAppContext.useSyncCollectionStateToAppContext)({
|
|
39
|
+
collection
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// STEP 5B: Initialize async dependencies and connect them to the collection
|
|
43
|
+
// This ensures all loaded features are properly connected to the collection instance
|
|
44
|
+
(0, _useCollectionInitAsyncDeps.useCollectionInitAsyncDeps)(asyncFeaturesState, collection);
|
|
45
|
+
|
|
46
|
+
// STEP 5C: Prepare filter functionality if filters are loaded and configured
|
|
47
|
+
const filtersProps = commonCollectionFeatures == null ? void 0 : commonCollectionFeatures.useFilters(config.filters, baseStateParams);
|
|
48
|
+
|
|
49
|
+
// STEP 5D: Prepare common collection features (search, bulk actions, empty states, etc.)
|
|
50
|
+
const commonCollectionFeaturesProps = commonCollectionFeatures == null ? void 0 : commonCollectionFeatures.useCommonCollectionFeatures({
|
|
51
|
+
...config,
|
|
52
|
+
collectionState: collection
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// FINAL STEP: Return standardized props for use by final components
|
|
56
|
+
// These props are consumed by Table, Grid, and TableGridSwitch components
|
|
57
|
+
return {
|
|
58
|
+
...commonCollectionFeaturesProps,
|
|
59
|
+
filters: filtersProps == null ? void 0 : filtersProps.filterComponent
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=useBaseCollectionComponentReadyFeatures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_useSyncCollectionStateToAppContext","require","_useCollectionInitAsyncDeps","_patterns","useBaseCollectionComponentReadyFeatures","props","collection","config","asyncFeaturesState","baseStateParams","commonCollectionFeatures","useSelector","status","data","useSyncCollectionStateToAppContext","useCollectionInitAsyncDeps","filtersProps","useFilters","filters","commonCollectionFeaturesProps","useCommonCollectionFeatures","collectionState","filterComponent"],"sources":["../../../src/hooks/useBaseCollectionComponentReadyFeatures.ts"],"sourcesContent":["import { useSyncCollectionStateToAppContext } from './useSyncCollectionStateToAppContext';\nimport { useCollectionInitAsyncDeps } from './useCollectionInitAsyncDeps';\nimport { BaseCollectionComponentConfig } from '../types';\nimport { CollectionState, useSelector } from '@wix/patterns';\nimport { getCommonCollectionFeaturesAsync } from './getCommonCollectionFeaturesAsync';\nimport { useBasePatternsStateParams } from './useBasePatternsStateParams';\nimport { PromiseState } from '@wix/patterns/core';\nimport { AsyncFeaturesState } from './useAsyncFeaturesPromiseState';\n\nexport interface UseBaseCollectionComponentReadyFeaturesParams {\n config: BaseCollectionComponentConfig;\n collection: CollectionState<any>;\n asyncFeaturesState: PromiseState<\n AsyncFeaturesState<ReturnType<typeof getCommonCollectionFeaturesAsync>>\n >;\n baseStateParams: ReturnType<typeof useBasePatternsStateParams>;\n}\n\n/**\n * useBaseCollectionComponentReadyFeatures - Step 5 (Shared Across All Flows)\n *\n * This is the shared hook used by all flows to prepare final collection features once async loading is complete.\n * It handles the common functionality needed by all collection components regardless of display mode.\n *\n * Key Responsibilities:\n * - Syncs collection state to app context for external consumption\n * - Initializes async dependencies and connects them to the collection\n * - Extracts and prepares common collection features (filters, search, actions, etc.)\n * - Returns standardized props that all final components (Table/Grid/TableGridSwitch) can use\n * - Provides consistent interface across all three rendering flows\n */\nexport function useBaseCollectionComponentReadyFeatures(\n props: UseBaseCollectionComponentReadyFeaturesParams,\n) {\n const { collection, config, asyncFeaturesState, baseStateParams } = props;\n\n // Extract loaded common features from async state (shared by all flows)\n const { commonCollectionFeatures } = useSelector(() => ({\n ...asyncFeaturesState.status.data,\n }));\n\n // STEP 5A: Sync the collection state to app context for external access\n // This allows other parts of the app to access current collection state\n useSyncCollectionStateToAppContext({ collection });\n\n // STEP 5B: Initialize async dependencies and connect them to the collection\n // This ensures all loaded features are properly connected to the collection instance\n useCollectionInitAsyncDeps(asyncFeaturesState, collection);\n\n // STEP 5C: Prepare filter functionality if filters are loaded and configured\n const filtersProps = commonCollectionFeatures?.useFilters(\n config.filters,\n baseStateParams,\n );\n\n // STEP 5D: Prepare common collection features (search, bulk actions, empty states, etc.)\n const commonCollectionFeaturesProps =\n commonCollectionFeatures?.useCommonCollectionFeatures({\n ...config,\n collectionState: collection,\n });\n\n // FINAL STEP: Return standardized props for use by final components\n // These props are consumed by Table, Grid, and TableGridSwitch components\n return {\n ...commonCollectionFeaturesProps,\n filters: filtersProps?.filterComponent,\n };\n}\n"],"mappings":";;;;AAAA,IAAAA,mCAAA,GAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,uCAAuCA,CACrDC,KAAoD,EACpD;EACA,MAAM;IAAEC,UAAU;IAAEC,MAAM;IAAEC,kBAAkB;IAAEC;EAAgB,CAAC,GAAGJ,KAAK;;EAEzE;EACA,MAAM;IAAEK;EAAyB,CAAC,GAAG,IAAAC,qBAAW,EAAC,OAAO;IACtD,GAAGH,kBAAkB,CAACI,MAAM,CAACC;EAC/B,CAAC,CAAC,CAAC;;EAEH;EACA;EACA,IAAAC,sEAAkC,EAAC;IAAER;EAAW,CAAC,CAAC;;EAElD;EACA;EACA,IAAAS,sDAA0B,EAACP,kBAAkB,EAAEF,UAAU,CAAC;;EAE1D;EACA,MAAMU,YAAY,GAAGN,wBAAwB,oBAAxBA,wBAAwB,CAAEO,UAAU,CACvDV,MAAM,CAACW,OAAO,EACdT,eACF,CAAC;;EAED;EACA,MAAMU,6BAA6B,GACjCT,wBAAwB,oBAAxBA,wBAAwB,CAAEU,2BAA2B,CAAC;IACpD,GAAGb,MAAM;IACTc,eAAe,EAAEf;EACnB,CAAC,CAAC;;EAEJ;EACA;EACA,OAAO;IACL,GAAGa,6BAA6B;IAChCD,OAAO,EAAEF,YAAY,oBAAZA,YAAY,CAAEM;EACzB,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useBasePatternsStateParams = useBasePatternsStateParams;
|
|
5
|
+
var _useBaseCollectionParams = require("./useBaseCollectionParams");
|
|
6
|
+
var _useFetchData = require("./useFetchData");
|
|
7
|
+
var _useFiltersState = require("./useFiltersState");
|
|
8
|
+
function useBasePatternsStateParams(config, props) {
|
|
9
|
+
const {
|
|
10
|
+
visibleFieldIds
|
|
11
|
+
} = props;
|
|
12
|
+
const {
|
|
13
|
+
filterFieldMapping,
|
|
14
|
+
filtersObject,
|
|
15
|
+
filters
|
|
16
|
+
} = (0, _useFiltersState.useFiltersState)(config.filters);
|
|
17
|
+
const {
|
|
18
|
+
fetchData
|
|
19
|
+
} = (0, _useFetchData.useFetchData)({
|
|
20
|
+
searchableFieldIds: visibleFieldIds,
|
|
21
|
+
filterFieldMapping
|
|
22
|
+
});
|
|
23
|
+
const params = (0, _useBaseCollectionParams.useBaseCollectionParams)({
|
|
24
|
+
config: config.collection,
|
|
25
|
+
fetchData,
|
|
26
|
+
filters: filtersObject
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
params,
|
|
30
|
+
fetchData,
|
|
31
|
+
filterFieldMapping,
|
|
32
|
+
filtersObject,
|
|
33
|
+
filters
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=useBasePatternsStateParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_useBaseCollectionParams","require","_useFetchData","_useFiltersState","useBasePatternsStateParams","config","props","visibleFieldIds","filterFieldMapping","filtersObject","filters","useFiltersState","fetchData","useFetchData","searchableFieldIds","params","useBaseCollectionParams","collection"],"sources":["../../../src/hooks/useBasePatternsStateParams.ts"],"sourcesContent":["import { useBaseCollectionParams } from './useBaseCollectionParams';\nimport { useFetchData } from './useFetchData';\nimport { BaseCollectionComponentConfig } from '../types';\nimport { useFiltersState } from './useFiltersState';\n\nexport interface UseBasePatternsStateParamsProps {\n visibleFieldIds: string[];\n}\n\nexport function useBasePatternsStateParams(\n config: BaseCollectionComponentConfig,\n props: UseBasePatternsStateParamsProps,\n) {\n const { visibleFieldIds } = props;\n\n const { filterFieldMapping, filtersObject, filters } = useFiltersState(\n config.filters,\n );\n\n const { fetchData } = useFetchData({\n searchableFieldIds: visibleFieldIds,\n filterFieldMapping,\n });\n\n const params = useBaseCollectionParams({\n config: config.collection,\n fetchData,\n filters: filtersObject,\n });\n\n return {\n params,\n fetchData,\n filterFieldMapping,\n filtersObject,\n filters,\n };\n}\n"],"mappings":";;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAMO,SAASG,0BAA0BA,CACxCC,MAAqC,EACrCC,KAAsC,EACtC;EACA,MAAM;IAAEC;EAAgB,CAAC,GAAGD,KAAK;EAEjC,MAAM;IAAEE,kBAAkB;IAAEC,aAAa;IAAEC;EAAQ,CAAC,GAAG,IAAAC,gCAAe,EACpEN,MAAM,CAACK,OACT,CAAC;EAED,MAAM;IAAEE;EAAU,CAAC,GAAG,IAAAC,0BAAY,EAAC;IACjCC,kBAAkB,EAAEP,eAAe;IACnCC;EACF,CAAC,CAAC;EAEF,MAAMO,MAAM,GAAG,IAAAC,gDAAuB,EAAC;IACrCX,MAAM,EAAEA,MAAM,CAACY,UAAU;IACzBL,SAAS;IACTF,OAAO,EAAED;EACX,CAAC,CAAC;EAEF,OAAO;IACLM,MAAM;IACNH,SAAS;IACTJ,kBAAkB;IAClBC,aAAa;IACbC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useCollectionInitAsyncDeps = useCollectionInitAsyncDeps;
|
|
5
|
+
var _react = require("react");
|
|
6
|
+
function useCollectionInitAsyncDeps(asyncFeaturesState, collection) {
|
|
7
|
+
(0, _react.useState)(() => {
|
|
8
|
+
collection.hooks.addListener('beforeInitialFetch', () => {
|
|
9
|
+
if (asyncFeaturesState.status.isError) {
|
|
10
|
+
throw asyncFeaturesState.status.error;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=useCollectionInitAsyncDeps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","useCollectionInitAsyncDeps","asyncFeaturesState","collection","useState","hooks","addListener","status","isError","error"],"sources":["../../../src/hooks/useCollectionInitAsyncDeps.ts"],"sourcesContent":["import { useState } from 'react';\nimport { CollectionState } from '@wix/patterns';\nimport { PromiseState } from '@wix/patterns/core';\n\nexport function useCollectionInitAsyncDeps(\n asyncFeaturesState: PromiseState<any>,\n collection: CollectionState<any, {}>,\n) {\n useState(() => {\n collection.hooks.addListener('beforeInitialFetch', () => {\n if (asyncFeaturesState.status.isError) {\n throw asyncFeaturesState.status.error;\n }\n });\n });\n}\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIO,SAASC,0BAA0BA,CACxCC,kBAAqC,EACrCC,UAAoC,EACpC;EACA,IAAAC,eAAQ,EAAC,MAAM;IACbD,UAAU,CAACE,KAAK,CAACC,WAAW,CAAC,oBAAoB,EAAE,MAAM;MACvD,IAAIJ,kBAAkB,CAACK,MAAM,CAACC,OAAO,EAAE;QACrC,MAAMN,kBAAkB,CAACK,MAAM,CAACE,KAAK;MACvC;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
+
var _exportNames = {
|
|
6
|
+
useCommonCollectionFeatures: true
|
|
7
|
+
};
|
|
5
8
|
exports.useCommonCollectionFeatures = void 0;
|
|
6
9
|
var _react = _interopRequireDefault(require("react"));
|
|
7
10
|
var _useEmptyStates = require("./useEmptyStates");
|
|
@@ -11,6 +14,13 @@ var _useActionCell = require("./useActionCell");
|
|
|
11
14
|
var _useBulkActionToolbar = require("./useBulkActionToolbar");
|
|
12
15
|
var _useAutoPatternsOptimisticActions = require("./useAutoPatternsOptimisticActions");
|
|
13
16
|
var _useViews = require("./useViews");
|
|
17
|
+
var _useFilters = require("./useFilters");
|
|
18
|
+
Object.keys(_useFilters).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
21
|
+
if (key in exports && exports[key] === _useFilters[key]) return;
|
|
22
|
+
exports[key] = _useFilters[key];
|
|
23
|
+
});
|
|
14
24
|
var _jsxFileName = "/home/builduser/work/8f3ab5a55e62623a/packages/auto-patterns/dist/cjs/hooks/useCommonCollectionFeatures.tsx";
|
|
15
25
|
const useCommonCollectionFeatures = ({
|
|
16
26
|
actionCell: actionCellConfig,
|
|
@@ -52,7 +62,7 @@ const useCommonCollectionFeatures = ({
|
|
|
52
62
|
__self: void 0,
|
|
53
63
|
__source: {
|
|
54
64
|
fileName: _jsxFileName,
|
|
55
|
-
lineNumber:
|
|
65
|
+
lineNumber: 67,
|
|
56
66
|
columnNumber: 13
|
|
57
67
|
}
|
|
58
68
|
}, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
|
|
@@ -62,7 +72,7 @@ const useCommonCollectionFeatures = ({
|
|
|
62
72
|
__self: void 0,
|
|
63
73
|
__source: {
|
|
64
74
|
fileName: _jsxFileName,
|
|
65
|
-
lineNumber:
|
|
75
|
+
lineNumber: 68,
|
|
66
76
|
columnNumber: 15
|
|
67
77
|
}
|
|
68
78
|
}, (_toolbarTitle$subtitl4 = toolbarTitle.subtitle) == null || (_toolbarTitle$subtitl4 = _toolbarTitle$subtitl4.info) == null ? void 0 : _toolbarTitle$subtitl4.content.text), ((_toolbarTitle$subtitl5 = toolbarTitle.subtitle) == null || (_toolbarTitle$subtitl5 = _toolbarTitle$subtitl5.info) == null ? void 0 : _toolbarTitle$subtitl5.content.link) && /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
|
|
@@ -77,7 +87,7 @@ const useCommonCollectionFeatures = ({
|
|
|
77
87
|
__self: void 0,
|
|
78
88
|
__source: {
|
|
79
89
|
fileName: _jsxFileName,
|
|
80
|
-
lineNumber:
|
|
90
|
+
lineNumber: 76,
|
|
81
91
|
columnNumber: 17
|
|
82
92
|
}
|
|
83
93
|
}, (_toolbarTitle$subtitl7 = toolbarTitle.subtitle) == null || (_toolbarTitle$subtitl7 = _toolbarTitle$subtitl7.info) == null ? void 0 : _toolbarTitle$subtitl7.content.link.label))
|
|
@@ -88,7 +98,7 @@ const useCommonCollectionFeatures = ({
|
|
|
88
98
|
__self: void 0,
|
|
89
99
|
__source: {
|
|
90
100
|
fileName: _jsxFileName,
|
|
91
|
-
lineNumber:
|
|
101
|
+
lineNumber: 60,
|
|
92
102
|
columnNumber: 5
|
|
93
103
|
}
|
|
94
104
|
}) : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_useEmptyStates","_patterns","_designSystem","_useActionCell","_useBulkActionToolbar","_useAutoPatternsOptimisticActions","_useViews","_jsxFileName","useCommonCollectionFeatures","actionCell","actionCellConfig","bulkActionToolbar","bulkActionToolbarConfig","toolbarTitle","search","emptyState","emptyStateConfig","collection","collectionState","views","viewsConfig","_toolbarTitle$subtitl","_toolbarTitle$subtitl2","_toolbarTitle$subtitl3","_toolbarTitle$subtitl4","_toolbarTitle$subtitl5","_toolbarTitle$subtitl6","_toolbarTitle$subtitl7","optimisticActions","useAutoPatternsOptimisticActions","collectionConfig","useEmptyStates","useActionCell","config","collectionId","useBulkActionToolbar","useViews","shouldShowTitle","title","default","createElement","ToolbarTitle","subtitle","text","learnMore","info","content","Box","direction","gap","__self","__source","fileName","lineNumber","columnNumber","Text","dataHook","light","size","link","TextButton","underline","skin","as","rel","target","href","url","label","itemsLimit","showTotal","undefined","shown"
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_useEmptyStates","_patterns","_designSystem","_useActionCell","_useBulkActionToolbar","_useAutoPatternsOptimisticActions","_useViews","_useFilters","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","_jsxFileName","useCommonCollectionFeatures","actionCell","actionCellConfig","bulkActionToolbar","bulkActionToolbarConfig","toolbarTitle","search","emptyState","emptyStateConfig","collection","collectionState","views","viewsConfig","_toolbarTitle$subtitl","_toolbarTitle$subtitl2","_toolbarTitle$subtitl3","_toolbarTitle$subtitl4","_toolbarTitle$subtitl5","_toolbarTitle$subtitl6","_toolbarTitle$subtitl7","optimisticActions","useAutoPatternsOptimisticActions","collectionConfig","useEmptyStates","useActionCell","config","collectionId","useBulkActionToolbar","useViews","shouldShowTitle","title","default","createElement","ToolbarTitle","subtitle","text","learnMore","info","content","Box","direction","gap","__self","__source","fileName","lineNumber","columnNumber","Text","dataHook","light","size","link","TextButton","underline","skin","as","rel","target","href","url","label","itemsLimit","showTotal","undefined","shown"],"sources":["../../../src/hooks/useCommonCollectionFeatures.tsx"],"sourcesContent":["import React from 'react';\nimport { useEmptyStates } from './useEmptyStates';\n\nimport { CollectionState, ToolbarTitle } from '@wix/patterns';\n\nimport { Box, Text, TextButton } from '@wix/design-system';\nimport { BaseCollectionComponentConfig } from '../types';\nimport { useActionCell } from './useActionCell';\nimport { useBulkActionToolbar } from './useBulkActionToolbar';\nimport { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';\nimport { useViews } from './useViews';\n\nexport * from './useFilters';\n\nexport type UseCommonCollectionFeaturesParams = Pick<\n BaseCollectionComponentConfig,\n | 'actionCell'\n | 'toolbarTitle'\n | 'search'\n | 'emptyState'\n | 'collection'\n | 'bulkActionToolbar'\n | 'entityPageId'\n | 'views'\n> & {\n collectionState: CollectionState<any>;\n};\n\nexport const useCommonCollectionFeatures = ({\n actionCell: actionCellConfig,\n bulkActionToolbar: bulkActionToolbarConfig,\n toolbarTitle,\n search,\n emptyState: emptyStateConfig,\n collection,\n collectionState,\n views: viewsConfig,\n}: UseCommonCollectionFeaturesParams) => {\n const optimisticActions = useAutoPatternsOptimisticActions({\n collectionConfig: collection,\n collectionState,\n });\n\n const { emptyState } = useEmptyStates(emptyStateConfig);\n const actionCell = useActionCell({\n config: actionCellConfig,\n collectionId: collection.collectionId,\n });\n\n const bulkActionToolbar = useBulkActionToolbar({\n config: bulkActionToolbarConfig,\n collectionId: collection.collectionId,\n });\n\n const views = useViews(viewsConfig);\n\n const shouldShowTitle = toolbarTitle && !views;\n\n const title = shouldShowTitle ? (\n <ToolbarTitle\n title={toolbarTitle.title}\n subtitle={{\n text: toolbarTitle.subtitle?.text ?? '',\n learnMore: toolbarTitle.subtitle?.learnMore,\n info: toolbarTitle.subtitle?.info && {\n content: (\n <Box direction=\"vertical\" gap=\"6px\">\n <Text\n dataHook=\"toolbar-title-subtitle-info-content\"\n light\n size=\"small\"\n >\n {toolbarTitle.subtitle?.info?.content.text}\n </Text>\n {toolbarTitle.subtitle?.info?.content.link && (\n <TextButton\n dataHook=\"toolbar-title-subtitle-info-link\"\n size=\"small\"\n underline=\"always\"\n skin=\"light\"\n as=\"a\"\n rel=\"noopener\"\n target=\"_blank\"\n href={toolbarTitle.subtitle?.info?.content.link.url}\n >\n {toolbarTitle.subtitle?.info?.content.link.label}\n </TextButton>\n )}\n </Box>\n ),\n },\n }}\n itemsLimit={toolbarTitle.itemsLimit}\n showTotal={toolbarTitle.showTotal}\n />\n ) : undefined;\n\n return {\n search: search?.shown !== false,\n title,\n views,\n emptyState,\n actionCell,\n bulkActionToolbar,\n optimisticActions,\n };\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAEA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,qBAAA,GAAAL,OAAA;AACA,IAAAM,iCAA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
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _patterns = require("@wix/patterns");
|
|
9
|
-
var _SchemaContext = require("../providers/SchemaContext");
|
|
10
|
-
var _providers = require("../providers");
|
|
11
9
|
var _filters = require("../components/filters");
|
|
12
|
-
var
|
|
10
|
+
var _getFilterComponent = require("./getFilterComponent");
|
|
13
11
|
var _jsxFileName = "/home/builduser/work/8f3ab5a55e62623a/packages/auto-patterns/dist/cjs/hooks/useFilters.tsx";
|
|
14
|
-
const useFilters = configuration => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
id,
|
|
22
|
-
fieldId
|
|
23
|
-
} = filter;
|
|
24
|
-
const fieldDefinition = schema.fields[fieldId];
|
|
25
|
-
if (!fieldDefinition) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const label = filter.displayName || fieldDefinition.displayName;
|
|
29
|
-
const {
|
|
30
|
-
openByDefault,
|
|
31
|
-
tagLabel,
|
|
32
|
-
sectionTitle
|
|
33
|
-
} = filter;
|
|
34
|
-
const baseParams = {
|
|
35
|
-
id,
|
|
36
|
-
fieldId,
|
|
37
|
-
commonFilterProps: {
|
|
38
|
-
sectionTitle,
|
|
39
|
-
initiallyOpen: openByDefault,
|
|
40
|
-
accordionItemProps: {
|
|
41
|
-
label
|
|
42
|
-
},
|
|
43
|
-
toolbarItemProps: {
|
|
44
|
-
label
|
|
45
|
-
},
|
|
46
|
-
toolbarTagProps: {
|
|
47
|
-
label: tagLabel
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
switch (fieldDefinition.type) {
|
|
52
|
-
case 'DATE':
|
|
53
|
-
case 'DATETIME':
|
|
54
|
-
currFilters.push((0, _filterCreators.createDateTimeFilter)({
|
|
55
|
-
...baseParams,
|
|
56
|
-
config: filter.dateConfig
|
|
57
|
-
}));
|
|
58
|
-
break;
|
|
59
|
-
case 'BOOLEAN':
|
|
60
|
-
currFilters.push((0, _filterCreators.createBooleanFilter)({
|
|
61
|
-
...baseParams,
|
|
62
|
-
config: filter.booleanConfig
|
|
63
|
-
}));
|
|
64
|
-
break;
|
|
65
|
-
case 'NUMBER':
|
|
66
|
-
currFilters.push((0, _filterCreators.createNumberFilter)({
|
|
67
|
-
...baseParams,
|
|
68
|
-
config: filter.numberConfig
|
|
69
|
-
}));
|
|
70
|
-
break;
|
|
71
|
-
case 'REFERENCE':
|
|
72
|
-
{
|
|
73
|
-
const {
|
|
74
|
-
referencedCollectionId
|
|
75
|
-
} = fieldDefinition.referenceMetadata;
|
|
76
|
-
const referencedSchema = schemaRegistry.getSchema(referencedCollectionId);
|
|
77
|
-
if (referencedSchema) {
|
|
78
|
-
currFilters.push((0, _filterCreators.createReferenceFilter)({
|
|
79
|
-
...baseParams,
|
|
80
|
-
config: filter.dynamicOptionsConfig,
|
|
81
|
-
additionalParams: {
|
|
82
|
-
referencedSchema
|
|
83
|
-
}
|
|
84
|
-
}));
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
default:
|
|
89
|
-
if (filter != null && filter.enumConfig) {
|
|
90
|
-
currFilters.push((0, _filterCreators.createEnumFilter)({
|
|
91
|
-
...baseParams,
|
|
92
|
-
config: filter.enumConfig
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
return currFilters;
|
|
99
|
-
});
|
|
100
|
-
const filterFieldMapping = _react.default.useMemo(() => {
|
|
101
|
-
return configuration == null ? void 0 : configuration.items.reduce((acc, filter) => {
|
|
102
|
-
acc[filter.id] = filter;
|
|
103
|
-
return acc;
|
|
104
|
-
}, {});
|
|
105
|
-
}, [configuration == null ? void 0 : configuration.items]);
|
|
12
|
+
const useFilters = (configuration, filtersState) => {
|
|
13
|
+
const {
|
|
14
|
+
filters,
|
|
15
|
+
filterFieldMapping,
|
|
16
|
+
filtersObject
|
|
17
|
+
} = filtersState;
|
|
106
18
|
const collectionToolbarFiltersProps = _react.default.useMemo(() => ({
|
|
107
19
|
inline: (configuration == null ? void 0 : configuration.maxInlineFilters) || 0,
|
|
108
20
|
panelTitle: configuration == null ? void 0 : configuration.panelTitle
|
|
109
21
|
}), [configuration]);
|
|
110
|
-
const
|
|
111
|
-
|
|
22
|
+
const filtersWithComponents = filters.map(filter => ({
|
|
23
|
+
...filter,
|
|
24
|
+
component: (0, _getFilterComponent.getFilterComponent)(filter)
|
|
25
|
+
})).filter(filter => filter.component !== null);
|
|
26
|
+
const filtersData = filtersWithComponents.reduce((acc, filter) => {
|
|
112
27
|
acc.components.push(filter.collectionData ? /*#__PURE__*/_react.default.createElement(_filters.StaticCollectionFilter, (0, _extends2.default)({
|
|
113
28
|
filter: filter.filter,
|
|
114
29
|
key: filter.key,
|
|
@@ -118,7 +33,7 @@ const useFilters = configuration => {
|
|
|
118
33
|
__self: void 0,
|
|
119
34
|
__source: {
|
|
120
35
|
fileName: _jsxFileName,
|
|
121
|
-
lineNumber:
|
|
36
|
+
lineNumber: 56,
|
|
122
37
|
columnNumber: 11
|
|
123
38
|
}
|
|
124
39
|
})) : filter.collectionId ? /*#__PURE__*/_react.default.createElement(_filters.DynamicCollectionFilter, (0, _extends2.default)({
|
|
@@ -131,7 +46,7 @@ const useFilters = configuration => {
|
|
|
131
46
|
__self: void 0,
|
|
132
47
|
__source: {
|
|
133
48
|
fileName: _jsxFileName,
|
|
134
|
-
lineNumber:
|
|
49
|
+
lineNumber: 64,
|
|
135
50
|
columnNumber: 11
|
|
136
51
|
}
|
|
137
52
|
})) : /*#__PURE__*/_react.default.createElement(filter.component, (0, _extends2.default)({
|
|
@@ -141,24 +56,23 @@ const useFilters = configuration => {
|
|
|
141
56
|
__self: void 0,
|
|
142
57
|
__source: {
|
|
143
58
|
fileName: _jsxFileName,
|
|
144
|
-
lineNumber:
|
|
59
|
+
lineNumber: 73,
|
|
145
60
|
columnNumber: 11
|
|
146
61
|
}
|
|
147
62
|
})));
|
|
148
63
|
return acc;
|
|
149
64
|
}, {
|
|
150
|
-
filters: {},
|
|
151
65
|
components: [],
|
|
152
66
|
collectionToolbarFiltersProps
|
|
153
67
|
});
|
|
154
68
|
return {
|
|
155
69
|
filterFieldMapping,
|
|
156
|
-
filtersObject
|
|
70
|
+
filtersObject,
|
|
157
71
|
filterComponent: filtersData.components.length > 0 ? /*#__PURE__*/_react.default.createElement(_patterns.CollectionToolbarFilters, (0, _extends2.default)({}, collectionToolbarFiltersProps, {
|
|
158
72
|
__self: void 0,
|
|
159
73
|
__source: {
|
|
160
74
|
fileName: _jsxFileName,
|
|
161
|
-
lineNumber:
|
|
75
|
+
lineNumber: 91,
|
|
162
76
|
columnNumber: 9
|
|
163
77
|
}
|
|
164
78
|
}), filtersData.components) : undefined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_patterns","_SchemaContext","_providers","_filters","_filterCreators","_jsxFileName","useFilters","configuration","schema","useSchema","schemaRegistry","useSchemaRegistry","filters","React","useState","currFilters","items","forEach","filter","id","fieldId","fieldDefinition","fields","label","displayName","openByDefault","tagLabel","sectionTitle","baseParams","commonFilterProps","initiallyOpen","accordionItemProps","toolbarItemProps","toolbarTagProps","type","push","createDateTimeFilter","config","dateConfig","createBooleanFilter","booleanConfig","createNumberFilter","numberConfig","referencedCollectionId","referenceMetadata","referencedSchema","getSchema","createReferenceFilter","dynamicOptionsConfig","additionalParams","enumConfig","createEnumFilter","filterFieldMapping","useMemo","reduce","acc","collectionToolbarFiltersProps","inline","maxInlineFilters","panelTitle","filtersData","key","components","collectionData","default","createElement","StaticCollectionFilter","_extends2","component","props","__self","__source","fileName","lineNumber","columnNumber","collectionId","DynamicCollectionFilter","componentName","filtersObject","filterComponent","length","CollectionToolbarFilters","undefined","exports"],"sources":["../../../src/hooks/useFilters.tsx"],"sourcesContent":["import React from 'react';\nimport {\n CollectionToolbarFilters,\n CollectionToolbarFiltersProps,\n Filter,\n} from '@wix/patterns';\nimport { Filter as SchemaFilterType, FiltersConfig } from '../types';\nimport { useSchema } from '../providers/SchemaContext';\nimport { useSchemaRegistry } from '../providers';\nimport {\n StaticCollectionFilter,\n DynamicCollectionFilter,\n} from '../components/filters';\nimport {\n createDateTimeFilter,\n createBooleanFilter,\n createNumberFilter,\n createEnumFilter,\n createReferenceFilter,\n} from '../utils/filterCreators';\n\nexport interface FilterOptions {\n key: string;\n fieldId: string;\n filter: Filter<any>;\n component: React.ElementType;\n collectionData?: { id: string; name: string }[];\n collectionId?: string;\n componentName?: string;\n props: Record<string, any>;\n}\n\nexport interface ReturnValue {\n filters: { [key: string]: Filter<any> };\n components: React.JSX.Element[];\n collectionToolbarFiltersProps: Pick<\n CollectionToolbarFiltersProps,\n 'inline' | 'panelTitle' | 'useNewFilters'\n >;\n}\n\nexport const useFilters = (configuration?: FiltersConfig) => {\n const schema = useSchema();\n const schemaRegistry = useSchemaRegistry();\n const [filters] = React.useState(() => {\n const currFilters: FilterOptions[] = [];\n configuration?.items.forEach((filter) => {\n const { id, fieldId } = filter;\n const fieldDefinition = schema.fields[fieldId];\n if (!fieldDefinition) {\n return;\n }\n\n const label = filter.displayName || fieldDefinition.displayName;\n const { openByDefault, tagLabel, sectionTitle } = filter;\n\n const baseParams = {\n id,\n fieldId,\n commonFilterProps: {\n sectionTitle,\n initiallyOpen: openByDefault,\n accordionItemProps: { label },\n toolbarItemProps: { label },\n toolbarTagProps: { label: tagLabel },\n },\n };\n\n switch (fieldDefinition.type) {\n case 'DATE':\n case 'DATETIME':\n currFilters.push(\n createDateTimeFilter({\n ...baseParams,\n config: filter.dateConfig,\n }),\n );\n break;\n\n case 'BOOLEAN':\n currFilters.push(\n createBooleanFilter({\n ...baseParams,\n config: filter.booleanConfig,\n }),\n );\n break;\n\n case 'NUMBER':\n currFilters.push(\n createNumberFilter({\n ...baseParams,\n config: filter.numberConfig,\n }),\n );\n break;\n\n case 'REFERENCE': {\n const { referencedCollectionId } = fieldDefinition.referenceMetadata;\n const referencedSchema = schemaRegistry.getSchema(\n referencedCollectionId,\n );\n\n if (referencedSchema) {\n currFilters.push(\n createReferenceFilter({\n ...baseParams,\n config: filter.dynamicOptionsConfig,\n additionalParams: {\n referencedSchema,\n },\n }),\n );\n }\n break;\n }\n\n default:\n if (filter?.enumConfig) {\n currFilters.push(\n createEnumFilter({\n ...baseParams,\n config: filter.enumConfig,\n }),\n );\n }\n break;\n }\n });\n return currFilters;\n });\n\n const filterFieldMapping = React.useMemo(() => {\n return configuration?.items.reduce((acc, filter) => {\n acc[filter.id] = filter;\n return acc;\n }, {} as Record<string, SchemaFilterType>);\n }, [configuration?.items]);\n\n const collectionToolbarFiltersProps = React.useMemo<\n Pick<CollectionToolbarFiltersProps, 'inline' | 'panelTitle'>\n >(\n () => ({\n inline: configuration?.maxInlineFilters || 0,\n panelTitle: configuration?.panelTitle,\n }),\n [configuration],\n );\n\n const filtersData = filters.reduce<ReturnValue>(\n (acc, filter) => {\n acc.filters[filter.key] = filter.filter;\n acc.components.push(\n filter.collectionData ? (\n <StaticCollectionFilter\n filter={filter.filter}\n key={filter.key}\n component={filter.component}\n collectionData={filter.collectionData}\n {...filter.props}\n />\n ) : filter.collectionId ? (\n <DynamicCollectionFilter\n filter={filter.filter}\n key={filter.key}\n component={filter.component}\n collectionId={filter.collectionId}\n componentName={filter.props.componentName}\n {...filter.props}\n />\n ) : (\n <filter.component\n key={filter.key}\n filter={filter.filter}\n {...filter.props}\n />\n ),\n );\n\n return acc;\n },\n { filters: {}, components: [], collectionToolbarFiltersProps },\n );\n\n return {\n filterFieldMapping,\n filtersObject: filtersData.filters,\n filterComponent:\n filtersData.components.length > 0 ? (\n <CollectionToolbarFilters {...collectionToolbarFiltersProps}>\n {filtersData.components}\n </CollectionToolbarFilters>\n ) : undefined,\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GA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AM,CAACkD,SAAU;MAC5BO,YAAY,EAAEzD,MAAM,CAACyD,YAAa;MAClCE,aAAa,EAAE3D,MAAM,CAACmD,KAAK,CAACQ;IAAc,GACtC3D,MAAM,CAACmD,KAAK;MAAAC,MAAA;MAAAC,QAAA;QAAAC,QAAA,EAAAnE,YAAA;QAAAoE,UAAA;QAAAC,YAAA;MAAA;IAAA,EACjB,CAAC,gBAEF7E,MAAA,CAAAmE,OAAA,CAAAC,aAAA,CAAC/C,MAAM,CAACkD,SAAS,MAAAD,SAAA,CAAAH,OAAA;MACfH,GAAG,EAAE3C,MAAM,CAAC2C,GAAI;MAChB3C,MAAM,EAAEA,MAAM,CAACA;IAAO,GAClBA,MAAM,CAACmD,KAAK;MAAAC,MAAA;MAAAC,QAAA;QAAAC,QAAA,EAAAnE,YAAA;QAAAoE,UAAA;QAAAC,YAAA;MAAA;IAAA,EACjB,CAEL,CAAC;IAED,OAAOnB,GAAG;EACZ,CAAC,EACD;IAAE3C,OAAO,EAAE,CAAC,CAAC;IAAEkD,UAAU,EAAE,EAAE;IAAEN;EAA8B,CAC/D,CAAC;EAED,OAAO;IACLJ,kBAAkB;IAClB0B,aAAa,EAAElB,WAAW,CAAChD,OAAO;IAClCmE,eAAe,EACbnB,WAAW,CAACE,UAAU,CAACkB,MAAM,GAAG,CAAC,gBAC/BnF,MAAA,CAAAmE,OAAA,CAAAC,aAAA,CAACjE,SAAA,CAAAiF,wBAAwB,MAAAd,SAAA,CAAAH,OAAA,MAAKR,6BAA6B;MAAAc,MAAA;MAAAC,QAAA;QAAAC,QAAA,EAAAnE,YAAA;QAAAoE,UAAA;QAAAC,YAAA;MAAA;IAAA,IACxDd,WAAW,CAACE,UACW,CAAC,GACzBoB;EACR,CAAC;AACH,CAAC;AAACC,OAAA,CAAA7E,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_patterns","_filters","_getFilterComponent","_jsxFileName","useFilters","configuration","filtersState","filters","filterFieldMapping","filtersObject","collectionToolbarFiltersProps","React","useMemo","inline","maxInlineFilters","panelTitle","filtersWithComponents","map","filter","component","getFilterComponent","filtersData","reduce","acc","components","push","collectionData","default","createElement","StaticCollectionFilter","_extends2","key","props","__self","__source","fileName","lineNumber","columnNumber","collectionId","DynamicCollectionFilter","componentName","filterComponent","length","CollectionToolbarFilters","undefined","exports"],"sources":["../../../src/hooks/useFilters.tsx"],"sourcesContent":["import React, { ElementType } from 'react';\nimport {\n CollectionToolbarFilters,\n CollectionToolbarFiltersProps,\n} from '@wix/patterns';\nimport { FiltersConfig } from '../types';\nimport {\n DynamicCollectionFilter,\n StaticCollectionFilter,\n} from '../components/filters';\nimport { FilterOptions, useFiltersState } from './useFiltersState';\nimport { getFilterComponent } from './getFilterComponent';\n\nexport interface FilterOptionsWithComponent extends FilterOptions {\n component: ElementType;\n}\n\nexport interface ReturnValue {\n components: React.JSX.Element[];\n collectionToolbarFiltersProps: Pick<\n CollectionToolbarFiltersProps,\n 'inline' | 'panelTitle' | 'useNewFilters'\n >;\n}\n\nexport const useFilters = (\n configuration: FiltersConfig | undefined,\n filtersState: ReturnType<typeof useFiltersState>,\n) => {\n const { filters, filterFieldMapping, filtersObject } = filtersState;\n\n const collectionToolbarFiltersProps = React.useMemo<\n Pick<CollectionToolbarFiltersProps, 'inline' | 'panelTitle'>\n >(\n () => ({\n inline: configuration?.maxInlineFilters || 0,\n panelTitle: configuration?.panelTitle,\n }),\n [configuration],\n );\n\n const filtersWithComponents = filters\n .map((filter) => ({\n ...filter,\n component: getFilterComponent(filter),\n }))\n .filter(\n (filter): filter is FilterOptionsWithComponent =>\n filter.component !== null,\n );\n\n const filtersData = filtersWithComponents.reduce<ReturnValue>(\n (acc, filter) => {\n acc.components.push(\n filter.collectionData ? (\n <StaticCollectionFilter\n filter={filter.filter}\n key={filter.key}\n component={filter.component}\n collectionData={filter.collectionData}\n {...filter.props}\n />\n ) : filter.collectionId ? (\n <DynamicCollectionFilter\n filter={filter.filter}\n key={filter.key}\n component={filter.component}\n collectionId={filter.collectionId}\n componentName={filter.props.componentName}\n {...filter.props}\n />\n ) : (\n <filter.component\n key={filter.key}\n filter={filter.filter}\n {...filter.props}\n />\n ),\n );\n\n return acc;\n },\n { components: [], collectionToolbarFiltersProps },\n );\n\n return {\n filterFieldMapping,\n filtersObject,\n filterComponent:\n filtersData.components.length > 0 ? (\n <CollectionToolbarFilters {...collectionToolbarFiltersProps}>\n {filtersData.components}\n </CollectionToolbarFilters>\n ) : undefined,\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,mBAAA,GAAAH,OAAA;AAA0D,IAAAI,YAAA;AAcnD,MAAMC,UAAU,GAAGA,CACxBC,aAAwC,EACxCC,YAAgD,KAC7C;EACH,MAAM;IAAEC,OAAO;IAAEC,kBAAkB;IAAEC;EAAc,CAAC,GAAGH,YAAY;EAEnE,MAAMI,6BAA6B,GAAGC,cAAK,CAACC,OAAO,CAGjD,OAAO;IACLC,MAAM,EAAE,CAAAR,aAAa,oBAAbA,aAAa,CAAES,gBAAgB,KAAI,CAAC;IAC5CC,UAAU,EAAEV,aAAa,oBAAbA,aAAa,CAAEU;EAC7B,CAAC,CAAC,EACF,CAACV,aAAa,CAChB,CAAC;EAED,MAAMW,qBAAqB,GAAGT,OAAO,CAClCU,GAAG,CAAEC,MAAM,KAAM;IAChB,GAAGA,MAAM;IACTC,SAAS,EAAE,IAAAC,sCAAkB,EAACF,MAAM;EACtC,CAAC,CAAC,CAAC,CACFA,MAAM,CACJA,MAAM,IACLA,MAAM,CAACC,SAAS,KAAK,IACzB,CAAC;EAEH,MAAME,WAAW,GAAGL,qBAAqB,CAACM,MAAM,CAC9C,CAACC,GAAG,EAAEL,MAAM,KAAK;IACfK,GAAG,CAACC,UAAU,CAACC,IAAI,CACjBP,MAAM,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,EAAE;IAAEd;EAA8B,CAClD,CAAC;EAED,OAAO;IACLF,kBAAkB;IAClBC,aAAa;IACbgC,eAAe,EACbpB,WAAW,CAACG,UAAU,CAACkB,MAAM,GAAG,CAAC,gBAC/B7C,MAAA,CAAA8B,OAAA,CAAAC,aAAA,CAAC5B,SAAA,CAAA2C,wBAAwB,MAAAb,SAAA,CAAAH,OAAA,MAAKjB,6BAA6B;MAAAuB,MAAA;MAAAC,QAAA;QAAAC,QAAA,EAAAhC,YAAA;QAAAiC,UAAA;QAAAC,YAAA;MAAA;IAAA,IACxDhB,WAAW,CAACG,UACW,CAAC,GACzBoB;EACR,CAAC;AACH,CAAC;AAACC,OAAA,CAAAzC,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.useFiltersState = useFiltersState;
|
|
6
|
+
var _providers = require("../providers");
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _filterCreators = require("../utils/filterCreators");
|
|
9
|
+
function useFiltersState(config) {
|
|
10
|
+
const schema = (0, _providers.useSchema)();
|
|
11
|
+
const schemaRegistry = (0, _providers.useSchemaRegistry)();
|
|
12
|
+
const [filters] = _react.default.useState(() => {
|
|
13
|
+
const currFilters = [];
|
|
14
|
+
config == null || config.items.forEach(filter => {
|
|
15
|
+
const {
|
|
16
|
+
id,
|
|
17
|
+
fieldId
|
|
18
|
+
} = filter;
|
|
19
|
+
const fieldDefinition = schema.fields[fieldId];
|
|
20
|
+
if (!fieldDefinition) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const label = filter.displayName || fieldDefinition.displayName;
|
|
24
|
+
const {
|
|
25
|
+
openByDefault,
|
|
26
|
+
tagLabel,
|
|
27
|
+
sectionTitle
|
|
28
|
+
} = filter;
|
|
29
|
+
const baseParams = {
|
|
30
|
+
id,
|
|
31
|
+
fieldId,
|
|
32
|
+
fieldDefinition,
|
|
33
|
+
commonFilterProps: {
|
|
34
|
+
sectionTitle,
|
|
35
|
+
initiallyOpen: openByDefault,
|
|
36
|
+
accordionItemProps: {
|
|
37
|
+
label
|
|
38
|
+
},
|
|
39
|
+
toolbarItemProps: {
|
|
40
|
+
label
|
|
41
|
+
},
|
|
42
|
+
toolbarTagProps: {
|
|
43
|
+
label: tagLabel
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
switch (fieldDefinition.type) {
|
|
48
|
+
case 'DATE':
|
|
49
|
+
case 'DATETIME':
|
|
50
|
+
currFilters.push((0, _filterCreators.createDateTimeFilter)({
|
|
51
|
+
...baseParams,
|
|
52
|
+
config: filter.dateConfig
|
|
53
|
+
}));
|
|
54
|
+
break;
|
|
55
|
+
case 'BOOLEAN':
|
|
56
|
+
currFilters.push((0, _filterCreators.createBooleanFilter)({
|
|
57
|
+
...baseParams,
|
|
58
|
+
config: filter.booleanConfig
|
|
59
|
+
}));
|
|
60
|
+
break;
|
|
61
|
+
case 'NUMBER':
|
|
62
|
+
currFilters.push((0, _filterCreators.createNumberFilter)({
|
|
63
|
+
...baseParams,
|
|
64
|
+
config: filter.numberConfig
|
|
65
|
+
}));
|
|
66
|
+
break;
|
|
67
|
+
case 'REFERENCE':
|
|
68
|
+
{
|
|
69
|
+
const {
|
|
70
|
+
referencedCollectionId
|
|
71
|
+
} = fieldDefinition.referenceMetadata;
|
|
72
|
+
const referencedSchema = schemaRegistry.getSchema(referencedCollectionId);
|
|
73
|
+
if (referencedSchema) {
|
|
74
|
+
currFilters.push((0, _filterCreators.createReferenceFilter)({
|
|
75
|
+
...baseParams,
|
|
76
|
+
config: filter.dynamicOptionsConfig,
|
|
77
|
+
additionalParams: {
|
|
78
|
+
referencedSchema
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
default:
|
|
85
|
+
if (filter != null && filter.enumConfig) {
|
|
86
|
+
currFilters.push((0, _filterCreators.createEnumFilter)({
|
|
87
|
+
...baseParams,
|
|
88
|
+
config: filter.enumConfig
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return currFilters;
|
|
95
|
+
});
|
|
96
|
+
const filterFieldMapping = _react.default.useMemo(() => {
|
|
97
|
+
return config == null ? void 0 : config.items.reduce((acc, filter) => {
|
|
98
|
+
acc[filter.id] = filter;
|
|
99
|
+
return acc;
|
|
100
|
+
}, {});
|
|
101
|
+
}, [config == null ? void 0 : config.items]);
|
|
102
|
+
const filtersObject = filters.reduce((acc, filter) => {
|
|
103
|
+
acc[filter.key] = filter.filter;
|
|
104
|
+
return acc;
|
|
105
|
+
}, {});
|
|
106
|
+
return {
|
|
107
|
+
filters,
|
|
108
|
+
filterFieldMapping,
|
|
109
|
+
filtersObject
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=useFiltersState.js.map
|