@wix/auto-patterns 1.26.0 → 1.27.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 +16 -7
- package/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.js.map +1 -1
- package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +2 -2
- package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +58 -4
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js +19 -5
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
- package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js +1 -1
- package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
- package/dist/cjs/hooks/index.js +19 -0
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/useGridFeatures.js +3 -0
- package/dist/cjs/hooks/useGridFeatures.js.map +1 -1
- package/dist/cjs/hooks/useNavigationUtils.js +21 -6
- package/dist/cjs/hooks/useNavigationUtils.js.map +1 -1
- package/dist/cjs/hooks/useTableFeatures.js +3 -0
- package/dist/cjs/hooks/useTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js +3 -0
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js.map +1 -1
- package/dist/cjs/hooks/useUpdateAppContextItems.js +18 -0
- package/dist/cjs/hooks/useUpdateAppContextItems.js.map +1 -0
- package/dist/cjs/providers/AppContext.js +58 -0
- package/dist/cjs/providers/AppContext.js.map +1 -0
- package/dist/cjs/providers/ItemsContext.js +37 -0
- package/dist/cjs/providers/ItemsContext.js.map +1 -0
- package/dist/cjs/providers/index.js +12 -0
- package/dist/cjs/providers/index.js.map +1 -1
- package/dist/cjs/types/types.js.map +1 -1
- package/dist/docs/auto-patterns-guide.md +119 -22
- package/dist/docs/bulk_actions.md +2 -5
- package/dist/docs/collection_page_actions.md +3 -12
- package/dist/docs/entity_page_actions.md +3 -3
- package/dist/docs/entity_page_view_actions.md +2 -2
- package/dist/docs/index.md +4 -0
- package/dist/docs/resolved_action.md +106 -0
- package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.js +5 -3
- package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +2 -2
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +24 -0
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js +8 -0
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsRoutes.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +1 -1
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
- package/dist/esm/hooks/index.js +2 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useGridFeatures.js +4 -1
- package/dist/esm/hooks/useGridFeatures.js.map +1 -1
- package/dist/esm/hooks/useNavigationUtils.js +21 -6
- package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
- package/dist/esm/hooks/useTableFeatures.js +4 -1
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useTableGridSwitchFeatures.js +4 -1
- package/dist/esm/hooks/useTableGridSwitchFeatures.js.map +1 -1
- package/dist/esm/hooks/useUpdateAppContextItems.js +13 -0
- package/dist/esm/hooks/useUpdateAppContextItems.js.map +1 -0
- package/dist/esm/providers/AppContext.js +31 -0
- package/dist/esm/providers/AppContext.js.map +1 -0
- package/dist/esm/providers/ItemsContext.js +23 -0
- package/dist/esm/providers/ItemsContext.js.map +1 -0
- package/dist/esm/providers/index.js +1 -0
- package/dist/esm/providers/index.js.map +1 -1
- package/dist/esm/types/types.js.map +1 -1
- package/dist/types/components/AutoPatternsApp/AutoPatternsApp.d.ts +1 -0
- package/dist/types/components/AutoPatternsApp/AutoPatternsApp.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsRoute/AutoPatternsRoutes.d.ts.map +1 -1
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/hooks/useGridFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useNavigationUtils.d.ts +5 -1
- package/dist/types/hooks/useNavigationUtils.d.ts.map +1 -1
- package/dist/types/hooks/useTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useUpdateAppContextItems.d.ts +2 -0
- package/dist/types/hooks/useUpdateAppContextItems.d.ts.map +1 -0
- package/dist/types/providers/AppContext.d.ts +11 -0
- package/dist/types/providers/AppContext.d.ts.map +1 -0
- package/dist/types/providers/ItemsContext.d.ts +11 -0
- package/dist/types/providers/ItemsContext.d.ts.map +1 -0
- package/dist/types/providers/index.d.ts +1 -0
- package/dist/types/providers/index.d.ts.map +1 -1
- package/dist/types/types/types.d.ts +1 -0
- package/dist/types/types/types.d.ts.map +1 -1
- package/package.json +14 -14
package/dist/docs/index.md
CHANGED
|
@@ -58,6 +58,10 @@ This index maps user requests to the appropriate section IDs for fetching releva
|
|
|
58
58
|
**Topics**: Entity page view mode actions, primaryActions, secondaryActions, collection-style actions
|
|
59
59
|
**Keywords**: view mode actions, primaryActions, secondaryActions, read-only entity actions, entity page view operations, collection-style entity actions, navigation actions
|
|
60
60
|
|
|
61
|
+
### ID: `resolved_action`
|
|
62
|
+
**Topics**: ResolvedAction interface, common return type for custom actions, field documentation
|
|
63
|
+
**Keywords**: ResolvedAction, action return type, custom action interface, action fields, label, icon, onClick, disabled, hidden, tooltip, skin
|
|
64
|
+
|
|
61
65
|
### ID: `installation`
|
|
62
66
|
**Topics**: Package installation, setup process, component integration, provider setup
|
|
63
67
|
**Keywords**: installation, setup, getting started, initial setup, package installation, dependencies, component integration, provider setup
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# ResolvedAction: Common Return Type for Custom Actions
|
|
2
|
+
|
|
3
|
+
All custom action resolvers in Auto Patterns must return a `ResolvedAction`. This applies to:
|
|
4
|
+
- Collection page actions (primary, secondary, menus) and `onRowClick`
|
|
5
|
+
- Entity page actions (view mode: primary/secondary/more; edit mode: moreActions)
|
|
6
|
+
- Bulk action toolbar actions
|
|
7
|
+
- Action Cell actions
|
|
8
|
+
|
|
9
|
+
## Type Definition
|
|
10
|
+
|
|
11
|
+
From `@wix/auto-patterns`:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
export interface ResolvedAction {
|
|
15
|
+
label: string;
|
|
16
|
+
icon: IconElement;
|
|
17
|
+
onClick: () => void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
hidden?: boolean;
|
|
20
|
+
tooltip?: string;
|
|
21
|
+
skin?: string;
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Field Reference
|
|
26
|
+
|
|
27
|
+
### Required Fields
|
|
28
|
+
|
|
29
|
+
- **`label`** (string): Text displayed in the button or menu item.
|
|
30
|
+
- **`icon`** (IconElement): An icon component, typically from `@wix/wix-ui-icons-common`. Example: `icon: <Delete />`.
|
|
31
|
+
- **`onClick`** (function): Handler function invoked when the user triggers the action. Can be async.
|
|
32
|
+
|
|
33
|
+
### Optional Fields
|
|
34
|
+
|
|
35
|
+
- **`disabled`** (boolean): When `true`, renders the action as disabled. Pair with `tooltip` to explain why the action is unavailable.
|
|
36
|
+
- **`hidden`** (boolean): When `true`, the action is completely omitted from the UI. Useful for permission-based or state-based visibility control.
|
|
37
|
+
- **`tooltip`** (string): Tooltip text displayed on hover. Especially useful when the action is disabled.
|
|
38
|
+
- **`skin`** (string): Visual style of the action button. Availability may vary by placement context. Recommended values:
|
|
39
|
+
- Primary actions: `"standard"`, `"inverted"`, `"premium"`
|
|
40
|
+
- Secondary/more/menu items: `"dark"`, `"destructive"`, `"premium"`
|
|
41
|
+
- If unsure, omit `skin` or use `"standard"` for primary actions and `"dark"` for secondary actions.
|
|
42
|
+
|
|
43
|
+
## Examples
|
|
44
|
+
|
|
45
|
+
### Minimal Example
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { Add } from '@wix/wix-ui-icons-common';
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
label: 'Create',
|
|
52
|
+
icon: <Add />,
|
|
53
|
+
onClick: () => {
|
|
54
|
+
// Your action logic here
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Complete Example with State Control
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { Download } from '@wix/wix-ui-icons-common';
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
label: 'Export',
|
|
66
|
+
icon: <Download />,
|
|
67
|
+
onClick: async () => {
|
|
68
|
+
try {
|
|
69
|
+
// Perform export logic using SDK
|
|
70
|
+
await performExport();
|
|
71
|
+
} catch (error) {
|
|
72
|
+
// Handle errors, show toast, etc.
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
disabled: total === 0,
|
|
76
|
+
tooltip: total === 0 ? 'Select at least one item to export' : undefined,
|
|
77
|
+
hidden: !userHasExportPermission,
|
|
78
|
+
skin: 'premium'
|
|
79
|
+
};
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Context-Specific Notes
|
|
83
|
+
|
|
84
|
+
### Collection Page Actions
|
|
85
|
+
- **onRowClick**: Access clicked item data via `actionParams.item`
|
|
86
|
+
- **Collection-level actions**: Access collection context via `actionParams.collectionId`
|
|
87
|
+
|
|
88
|
+
### Entity Page Actions
|
|
89
|
+
- **View/Edit mode**: Access entity data via `actionParams.entity`
|
|
90
|
+
- **Edit mode only**: Access form instance via `actionParams.form`
|
|
91
|
+
|
|
92
|
+
### Bulk Actions
|
|
93
|
+
- **Selection data**: Use `actionParams.selectedValues` and `actionParams.total`
|
|
94
|
+
- **State control**: Commonly use `disabled: selectedValues.length === 0`
|
|
95
|
+
|
|
96
|
+
### Action Cell Actions
|
|
97
|
+
- **Row context**: Access item and position via `actionParams.item` and `actionParams.index`
|
|
98
|
+
|
|
99
|
+
## See Also
|
|
100
|
+
|
|
101
|
+
- [Collection Page Actions](./collection_page_actions.md)
|
|
102
|
+
- [Entity Page Actions](./entity_page_actions.md) (edit mode)
|
|
103
|
+
- [Entity Page View Actions](./entity_page_view_actions.md)
|
|
104
|
+
- [Bulk Actions Toolbar](./bulk_actions.md)
|
|
105
|
+
- [Action Cell](./action_cell.md)
|
|
106
|
+
- [App Config Structure](./app_config_structure.md) (action item `skin` property)
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RootAppProvider } from '../../providers/RootAppProvider';
|
|
3
|
+
import { AppContextProvider } from '../../providers/AppContext';
|
|
3
4
|
import { AutoPatternsRoutes } from '../AutoPatternsRoute/AutoPatternsRoutes';
|
|
4
5
|
export const AutoPatternsApp = _ref => {
|
|
5
6
|
let {
|
|
6
|
-
configuration
|
|
7
|
+
configuration,
|
|
8
|
+
children
|
|
7
9
|
} = _ref;
|
|
8
|
-
return /*#__PURE__*/React.createElement(RootAppProvider, {
|
|
10
|
+
return /*#__PURE__*/React.createElement(AppContextProvider, null, /*#__PURE__*/React.createElement(RootAppProvider, {
|
|
9
11
|
appConfig: configuration
|
|
10
12
|
}, /*#__PURE__*/React.createElement(AutoPatternsRoutes, {
|
|
11
13
|
config: configuration
|
|
12
|
-
}));
|
|
14
|
+
})), children);
|
|
13
15
|
};
|
|
14
16
|
//# sourceMappingURL=AutoPatternsApp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","RootAppProvider","AutoPatternsRoutes","AutoPatternsApp","_ref","configuration","createElement","appConfig","config"],"sources":["../../../../src/components/AutoPatternsApp/AutoPatternsApp.tsx"],"sourcesContent":["import React from 'react';\nimport { AppConfig } from '../../types';\nimport { RootAppProvider } from '../../providers/RootAppProvider';\nimport { AutoPatternsRoutes } from '../AutoPatternsRoute/AutoPatternsRoutes';\n\nexport interface AutoPatternsAppProps {\n configuration: AppConfig;\n}\n\nexport const AutoPatternsApp: React.FC<AutoPatternsAppProps> = ({\n configuration,\n}) => {\n return (\n <RootAppProvider appConfig={configuration}>\n
|
|
1
|
+
{"version":3,"names":["React","RootAppProvider","AppContextProvider","AutoPatternsRoutes","AutoPatternsApp","_ref","configuration","children","createElement","appConfig","config"],"sources":["../../../../src/components/AutoPatternsApp/AutoPatternsApp.tsx"],"sourcesContent":["import React from 'react';\nimport { AppConfig } from '../../types';\nimport { RootAppProvider } from '../../providers/RootAppProvider';\nimport { AppContextProvider } from '../../providers/AppContext';\nimport { AutoPatternsRoutes } from '../AutoPatternsRoute/AutoPatternsRoutes';\n\nexport interface AutoPatternsAppProps {\n configuration: AppConfig;\n children?: React.ReactNode;\n}\n\nexport const AutoPatternsApp: React.FC<AutoPatternsAppProps> = ({\n configuration,\n children,\n}) => {\n return (\n <AppContextProvider>\n <RootAppProvider appConfig={configuration}>\n <AutoPatternsRoutes config={configuration} />\n </RootAppProvider>\n {children}\n </AppContextProvider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,kBAAkB,QAAQ,yCAAyC;AAO5E,OAAO,MAAMC,eAA+C,GAAGC,IAAA,IAGzD;EAAA,IAH0D;IAC9DC,aAAa;IACbC;EACF,CAAC,GAAAF,IAAA;EACC,oBACEL,KAAA,CAAAQ,aAAA,CAACN,kBAAkB,qBACjBF,KAAA,CAAAQ,aAAA,CAACP,eAAe;IAACQ,SAAS,EAAEH;EAAc,gBACxCN,KAAA,CAAAQ,aAAA,CAACL,kBAAkB;IAACO,MAAM,EAAEJ;EAAc,CAAE,CAC7B,CAAC,EACjBC,QACiB,CAAC;AAEzB,CAAC","ignoreList":[]}
|
package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';
|
|
2
|
-
import { AutoPatternsTable } from '../AutoPatternsTable';
|
|
3
|
-
import { AutoPatternsGrid } from '../AutoPatternsGrid';
|
|
2
|
+
import { AutoPatternsTable } from '../AutoPatternsTable/AutoPatternsTable';
|
|
3
|
+
import { AutoPatternsGrid } from '../AutoPatternsGrid/AutoPatternsGrid';
|
|
4
4
|
import { SchemaProvider } from '../../providers';
|
|
5
5
|
import { SkeletonCollection } from '../AutoPatternsCollectionPageContent/SkeletonCollection';
|
|
6
6
|
import React, { useMemo } from 'react';
|
package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AutoPatternsTableGridSwitch","AutoPatternsTable","AutoPatternsGrid","SchemaProvider","SkeletonCollection","React","useMemo","AutoPatternsCollectionComponent","_ref","component","index","layout","sharedConfig","memoized","_layout$find","_layout$find2","length","componentToRender","componentType","tableConfig","find","item","type","table","gridConfig","grid","config","createElement","configuration","Fragment","key","collection","collectionId","skeleton"],"sources":["../../../../src/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.tsx"],"sourcesContent":["import { CollectionComponentConfig } from '../../types';\nimport { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';\nimport { AutoPatternsTable } from '../AutoPatternsTable';\nimport { AutoPatternsGrid } from '../AutoPatternsGrid';\nimport { SchemaProvider } from '../../providers';\nimport { SkeletonCollection } from '../AutoPatternsCollectionPageContent/SkeletonCollection';\nimport React, { useMemo } from 'react';\n\nexport const AutoPatternsCollectionComponent = ({\n component,\n index,\n}: {\n component: CollectionComponentConfig;\n index: number;\n}) => {\n const { layout, ...sharedConfig } = component;\n\n const memoized = useMemo(() => {\n if (!layout?.length) {\n return {\n componentToRender: null,\n componentType: 'Table' as 'Table' | 'Grid',\n };\n }\n\n const tableConfig = layout.find((item) => item.type === 'Table')?.table;\n const gridConfig = layout.find((item) => item.type === 'Grid')?.grid;\n\n let componentType: 'Table' | 'Grid' = 'Table';\n let componentToRender: React.ReactNode = null;\n\n if (tableConfig && gridConfig) {\n const config = {\n ...sharedConfig,\n ...tableConfig,\n ...gridConfig,\n };\n componentToRender = (\n <AutoPatternsTableGridSwitch configuration={config} />\n );\n } else if (tableConfig) {\n const config = { ...sharedConfig, ...tableConfig };\n componentToRender = <AutoPatternsTable configuration={config} />;\n } else if (gridConfig) {\n componentType = 'Grid';\n const config = { ...sharedConfig, ...gridConfig };\n componentToRender = <AutoPatternsGrid configuration={config} />;\n }\n\n return { componentToRender, componentType };\n }, [layout, sharedConfig]);\n\n const { componentToRender, componentType } = memoized;\n\n return (\n <>\n {componentToRender ? (\n <SchemaProvider\n key={`${sharedConfig.collection.collectionId}-${index}`}\n collection={sharedConfig.collection}\n skeleton={<SkeletonCollection componentType={componentType} />}\n >\n {componentToRender}\n </SchemaProvider>\n ) : null}\n </>\n );\n};\n"],"mappings":"AACA,SAASA,2BAA2B,QAAQ,4DAA4D;AACxG,SAASC,iBAAiB,QAAQ,
|
|
1
|
+
{"version":3,"names":["AutoPatternsTableGridSwitch","AutoPatternsTable","AutoPatternsGrid","SchemaProvider","SkeletonCollection","React","useMemo","AutoPatternsCollectionComponent","_ref","component","index","layout","sharedConfig","memoized","_layout$find","_layout$find2","length","componentToRender","componentType","tableConfig","find","item","type","table","gridConfig","grid","config","createElement","configuration","Fragment","key","collection","collectionId","skeleton"],"sources":["../../../../src/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.tsx"],"sourcesContent":["import { CollectionComponentConfig } from '../../types';\nimport { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';\nimport { AutoPatternsTable } from '../AutoPatternsTable/AutoPatternsTable';\nimport { AutoPatternsGrid } from '../AutoPatternsGrid/AutoPatternsGrid';\nimport { SchemaProvider } from '../../providers';\nimport { SkeletonCollection } from '../AutoPatternsCollectionPageContent/SkeletonCollection';\nimport React, { useMemo } from 'react';\n\nexport const AutoPatternsCollectionComponent = ({\n component,\n index,\n}: {\n component: CollectionComponentConfig;\n index: number;\n}) => {\n const { layout, ...sharedConfig } = component;\n\n const memoized = useMemo(() => {\n if (!layout?.length) {\n return {\n componentToRender: null,\n componentType: 'Table' as 'Table' | 'Grid',\n };\n }\n\n const tableConfig = layout.find((item) => item.type === 'Table')?.table;\n const gridConfig = layout.find((item) => item.type === 'Grid')?.grid;\n\n let componentType: 'Table' | 'Grid' = 'Table';\n let componentToRender: React.ReactNode = null;\n\n if (tableConfig && gridConfig) {\n const config = {\n ...sharedConfig,\n ...tableConfig,\n ...gridConfig,\n };\n componentToRender = (\n <AutoPatternsTableGridSwitch configuration={config} />\n );\n } else if (tableConfig) {\n const config = { ...sharedConfig, ...tableConfig };\n componentToRender = <AutoPatternsTable configuration={config} />;\n } else if (gridConfig) {\n componentType = 'Grid';\n const config = { ...sharedConfig, ...gridConfig };\n componentToRender = <AutoPatternsGrid configuration={config} />;\n }\n\n return { componentToRender, componentType };\n }, [layout, sharedConfig]);\n\n const { componentToRender, componentType } = memoized;\n\n return (\n <>\n {componentToRender ? (\n <SchemaProvider\n key={`${sharedConfig.collection.collectionId}-${index}`}\n collection={sharedConfig.collection}\n skeleton={<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QAAC4B,aAAa,EAAEF;MAAO,CAAE,CACtD;IACH,CAAC,MAAM,IAAIP,WAAW,EAAE;MACtB,MAAMO,MAAM,GAAG;QAAE,GAAGd,YAAY;QAAE,GAAGO;MAAY,CAAC;MAClDF,iBAAiB,gBAAGZ,KAAA,CAAAsB,aAAA,CAAC1B,iBAAiB;QAAC2B,aAAa,EAAEF;MAAO,CAAE,CAAC;IAClE,CAAC,MAAM,IAAIF,UAAU,EAAE;MACrBN,aAAa,GAAG,MAAM;MACtB,MAAMQ,MAAM,GAAG;QAAE,GAAGd,YAAY;QAAE,GAAGY;MAAW,CAAC;MACjDP,iBAAiB,gBAAGZ,KAAA,CAAAsB,aAAA,CAACzB,gBAAgB;QAAC0B,aAAa,EAAEF;MAAO,CAAE,CAAC;IACjE;IAEA,OAAO;MAAET,iBAAiB;MAAEC;IAAc,CAAC;EAC7C,CAAC,EAAE,CAACP,MAAM,EAAEC,YAAY,CAAC,CAAC;EAE1B,MAAM;IAAEK,iBAAiB;IAAEC;EAAc,CAAC,GAAGL,QAAQ;EAErD,oBACER,KAAA,CAAAsB,aAAA,CAAAtB,KAAA,CAAAwB,QAAA,QACGZ,iBAAiB,gBAChBZ,KAAA,CAAAsB,aAAA,CAACxB,cAAc;IACb2B,GAAG,EAAE,GAAGlB,YAAY,CAACmB,UAAU,CAACC,YAAY,IAAItB,KAAK,EAAG;IACxDqB,UAAU,EAAEnB,YAAY,CAACmB,UAAW;IACpCE,QAAQ,eAAE5B,KAAA,CAAAsB,aAAA,CAACvB,kBAAkB;MAACc,aAAa,EAAEA;IAAc,CAAE;EAAE,GAE9DD,iBACa,CAAC,GACf,IACJ,CAAC;AAEP,CAAC","ignoreList":[]}
|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { CollectionPage } from '@wix/patterns/page';
|
|
3
3
|
import { AutoPatternsCollectionPageContent } from '../AutoPatternsCollectionPageContent';
|
|
4
4
|
import { useCollectionPageActions } from '../../hooks/useCollectionPageActions';
|
|
5
|
+
import { SidePanel, Box } from '@wix/design-system';
|
|
6
|
+
import { useAppConfigContext } from '../../providers';
|
|
5
7
|
export const AutoPatternsCollectionPage = _ref => {
|
|
6
8
|
let {
|
|
7
9
|
configuration
|
|
@@ -10,9 +12,31 @@ export const AutoPatternsCollectionPage = _ref => {
|
|
|
10
12
|
title,
|
|
11
13
|
subtitle
|
|
12
14
|
} = configuration;
|
|
15
|
+
const {
|
|
16
|
+
layout
|
|
17
|
+
} = useAppConfigContext();
|
|
13
18
|
const actions = useCollectionPageActions({
|
|
14
19
|
collectionPageActions: configuration.actions
|
|
15
20
|
});
|
|
21
|
+
|
|
22
|
+
// This is temporary until we have support on it on CollectionPage component of WixPatterns
|
|
23
|
+
if (layout === 'panel') {
|
|
24
|
+
return /*#__PURE__*/React.createElement(SidePanel, {
|
|
25
|
+
skin: "floating",
|
|
26
|
+
width: "360px"
|
|
27
|
+
}, /*#__PURE__*/React.createElement(SidePanel.Header, {
|
|
28
|
+
title: "Manage Content"
|
|
29
|
+
}), /*#__PURE__*/React.createElement(SidePanel.Content, {
|
|
30
|
+
noPadding: true,
|
|
31
|
+
stretchVertically: true
|
|
32
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
33
|
+
direction: "vertical",
|
|
34
|
+
width: "100%",
|
|
35
|
+
height: "490px"
|
|
36
|
+
}, /*#__PURE__*/React.createElement(AutoPatternsCollectionPageContent, {
|
|
37
|
+
configuration: configuration
|
|
38
|
+
}))));
|
|
39
|
+
}
|
|
16
40
|
return /*#__PURE__*/React.createElement(CollectionPage, {
|
|
17
41
|
height: "100vh",
|
|
18
42
|
dataHook: "auto-patterns-page"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","CollectionPage","AutoPatternsCollectionPageContent","useCollectionPageActions","AutoPatternsCollectionPage","_ref","configuration","title","subtitle","actions","collectionPageActions","createElement","
|
|
1
|
+
{"version":3,"names":["React","CollectionPage","AutoPatternsCollectionPageContent","useCollectionPageActions","SidePanel","Box","useAppConfigContext","AutoPatternsCollectionPage","_ref","configuration","title","subtitle","layout","actions","collectionPageActions","createElement","skin","width","Header","Content","noPadding","stretchVertically","direction","height","dataHook","primaryAction","primaryActions","secondaryActions"],"sources":["../../../../src/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.tsx"],"sourcesContent":["import React from 'react';\nimport { CollectionPage } from '@wix/patterns/page';\nimport { AutoPatternsCollectionPageContent } from '../AutoPatternsCollectionPageContent';\nimport { CollectionPageConfig } from '../../types/CollectionPageConfig';\nimport { useCollectionPageActions } from '../../hooks/useCollectionPageActions';\nimport { SidePanel, Box } from '@wix/design-system';\nimport { useAppConfigContext } from '../../providers';\n\nexport interface AutoPatternsCollectionPageProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPage: React.FC<\n AutoPatternsCollectionPageProps\n> = ({ configuration }) => {\n const { title, subtitle } = configuration;\n const { layout } = useAppConfigContext();\n\n const actions = useCollectionPageActions({\n collectionPageActions: configuration.actions,\n });\n\n // This is temporary until we have support on it on CollectionPage component of WixPatterns\n if (layout === 'panel') {\n return (\n <SidePanel skin=\"floating\" width=\"360px\">\n <SidePanel.Header title=\"Manage Content\" />\n <SidePanel.Content noPadding stretchVertically>\n <Box direction=\"vertical\" width=\"100%\" height=\"490px\">\n <AutoPatternsCollectionPageContent configuration={configuration} />\n </Box>\n </SidePanel.Content>\n </SidePanel>\n );\n }\n\n return (\n <CollectionPage height=\"100vh\" dataHook=\"auto-patterns-page\">\n <CollectionPage.Header\n title={title}\n subtitle={subtitle}\n primaryAction={actions.primaryActions}\n secondaryActions={actions.secondaryActions}\n />\n <CollectionPage.Content>\n <AutoPatternsCollectionPageContent configuration={configuration} />\n </CollectionPage.Content>\n </CollectionPage>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,iCAAiC,QAAQ,sCAAsC;AAExF,SAASC,wBAAwB,Q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,eACF3B,KAAA,CAAAe,aAAA,CAACd,cAAc,CAACkB,OAAO,qBACrBnB,KAAA,CAAAe,aAAA,CAACb,iCAAiC;IAACO,aAAa,EAAEA;EAAc,CAAE,CAC5C,CACV,CAAC;AAErB,CAAC","ignoreList":[]}
|
|
@@ -14,6 +14,14 @@ export const AutoPatternsRoutes = _ref => {
|
|
|
14
14
|
const {
|
|
15
15
|
getPagePath
|
|
16
16
|
} = usePagePath(config);
|
|
17
|
+
if (config.layout === 'panel') {
|
|
18
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, config.pages.map(page => {
|
|
19
|
+
return /*#__PURE__*/React.createElement(AutoPatternsPage, {
|
|
20
|
+
key: page.id,
|
|
21
|
+
pageConfig: page
|
|
22
|
+
});
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
17
25
|
const mainPage = config.pages.find(page => page.appMainPage);
|
|
18
26
|
const routes = config.pages.map(page => {
|
|
19
27
|
const routePath = getPagePath(page.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","usePagePath","PatternsReactRoute","PatternsReactRouter","AutoPatternsPage","Navigate","pageTypeToRouteType","collectionPage","entityPage","AutoPatternsRoutes","_ref","config","getPagePath","
|
|
1
|
+
{"version":3,"names":["React","usePagePath","PatternsReactRoute","PatternsReactRouter","AutoPatternsPage","Navigate","pageTypeToRouteType","collectionPage","entityPage","AutoPatternsRoutes","_ref","config","getPagePath","layout","createElement","Fragment","pages","map","page","key","id","pageConfig","mainPage","find","appMainPage","routes","routePath","type","path","element","filter","Boolean","mainPagePath","push","to"],"sources":["../../../../src/components/AutoPatternsRoute/AutoPatternsRoutes.tsx"],"sourcesContent":["import React from 'react';\nimport { usePagePath } from '../../hooks';\nimport { PatternsReactRoute, PatternsReactRouter } from '@wix/patterns/router';\nimport { AutoPatternsPage } from './AutoPatternsPage';\nimport type { RouteType } from '@wix/patterns/dist/types/components/Router/types';\nimport { Navigate } from 'react-router-dom';\nimport { AppConfig } from '../../types';\n\nconst pageTypeToRouteType: Record<string, RouteType> = {\n collectionPage: 'collection',\n entityPage: 'editEntity',\n};\n\nexport const AutoPatternsRoutes = ({ config }: { config: AppConfig }) => {\n const { getPagePath } = usePagePath(config);\n\n if (config.layout === 'panel') {\n return (\n <>\n {config.pages.map((page) => {\n return <AutoPatternsPage key={page.id} pageConfig={page} />;\n })}\n </>\n );\n }\n\n const mainPage = config.pages.find((page) => page.appMainPage);\n\n const routes = config.pages\n .map((page) => {\n const routePath = getPagePath(page.id);\n\n if (!routePath) {\n return null;\n }\n\n return (\n <PatternsReactRoute\n key={page.id}\n type={pageTypeToRouteType[page.type] ?? 'other'}\n path={routePath}\n element={<AutoPatternsPage pageConfig={page} />}\n />\n );\n })\n .filter(Boolean);\n\n if (mainPage) {\n const mainPagePath = getPagePath(mainPage.id);\n\n if (mainPagePath) {\n routes.push(\n <PatternsReactRoute\n key=\"main-redirect\"\n type=\"other\"\n path=\"/\"\n element={<Navigate to={mainPagePath} />}\n />,\n );\n }\n }\n\n return <PatternsReactRouter>{routes}</PatternsReactRouter>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASC,kBAAkB,EAAEC,mBAAmB,QAAQ,sBAAsB;AAC9E,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,QAAQ,QAAQ,kBAAkB;AAG3C,MAAMC,mBAA8C,GAAG;EACrDC,cAAc,EAAE,YAAY;EAC5BC,UAAU,EAAE;AACd,CAAC;AAED,OAAO,MAAMC,kBAAkB,GAAGC,IAAA,IAAuC;EAAA,IAAtC;IAAEC;EAA8B,CAAC,GAAAD,IAAA;EAClE,MAAM;IAAEE;EAAY,CAAC,GAAGX,WAAW,CAACU,MAAM,CAAC;EAE3C,IAAIA,MAAM,CAACE,MAAM,KAAK,OAAO,EAAE;IAC7B,oBACEb,KAAA,CAAAc,aAAA,CAAAd,KAAA,CAAAe,QAAA,QACGJ,MAAM,CA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A,CAAAc,aAAA,CAACX,mBAAmB,QAAEsB,MAA4B,CAAC;AAC5D,CAAC","ignoreList":[]}
|
|
@@ -19,7 +19,7 @@ export const CmsFieldTypeToPatternsFieldType = {
|
|
|
19
19
|
};
|
|
20
20
|
export async function fetchCmsSchema(collectionId) {
|
|
21
21
|
const schema = await errorHandler.withErrorHandler(async () => collections.getDataCollection(collectionId), {});
|
|
22
|
-
const transformedFields = schema.fields.reduce((acc, field) => {
|
|
22
|
+
const transformedFields = (schema.fields || []).reduce((acc, field) => {
|
|
23
23
|
var _field$capabilities, _field$capabilities2, _field$typeMetadata;
|
|
24
24
|
if (!field.key) {
|
|
25
25
|
return acc;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["collections","items","fetchCmsData","errorHandler","CmsFieldTypeToPatternsFieldType","Type","TEXT","DATE","DATETIME","NUMBER","BOOLEAN","URL","ADDRESS","OBJECT","RICH_TEXT","RICH_CONTENT","ARRAY","ARRAY_STRING","REFERENCE","IMAGE","fetchCmsSchema","collectionId","schema","withErrorHandler","getDataCollection","transformedFields","fields","reduce","acc","field","_field$capabilities","_field$capabilities2","_field$typeMetadata","key","fieldType","type","baseField","id","displayName","validation","numberRange","min","undefined","max","stringLengthRange","minLength","maxLength","required","capabilities","supportedQueryOperators","queryOperators","sortable","typeMetadata","reference","referencedCollectionId","referenceField","referenceMetadata","nonReferenceType","nonReferenceField","schemaConfig","displayField","idField","actions","get","entityId","create","entity","insert","update","delete","remove","bulkDelete","entityIds","bulkRemove","find","query","options"],"sources":["../../../../src/dataSourceAdapters/cms/cmsAdapter.ts"],"sourcesContent":["import { Field, SchemaConfig, PatternsFieldType } from '../../types';\nimport { collections, items } from '@wix/data';\nimport { fetchCmsData } from './fetchCmsData';\nimport { errorHandler } from '@wix/essentials';\n\nexport const CmsFieldTypeToPatternsFieldType: Partial<\n Record<collections.Type, PatternsFieldType>\n> = {\n [collections.Type.TEXT]: 'SHORT_TEXT',\n [collections.Type.DATE]: 'DATE',\n [collections.Type.DATETIME]: 'DATETIME',\n [collections.Type.NUMBER]: 'NUMBER',\n [collections.Type.BOOLEAN]: 'BOOLEAN',\n [collections.Type.URL]: 'URL',\n [collections.Type.ADDRESS]: 'SHORT_TEXT',\n [collections.Type.OBJECT]: 'LONG_TEXT',\n [collections.Type.RICH_TEXT]: 'LONG_TEXT',\n [collections.Type.RICH_CONTENT]: 'SHORT_TEXT',\n [collections.Type.ARRAY]: 'ARRAY',\n [collections.Type.ARRAY_STRING]: 'ARRAY',\n [collections.Type.REFERENCE]: 'REFERENCE',\n [collections.Type.IMAGE]: 'IMAGE',\n};\n\nexport async function fetchCmsSchema(\n collectionId: string,\n): Promise<SchemaConfig> {\n const schema = await errorHandler.withErrorHandler(\n async () => collections.getDataCollection(collectionId),\n {},\n );\n const transformedFields = schema.fields.reduce<Record<string, Field>>(\n (acc, field) => {\n if (!field.key) {\n return acc;\n }\n\n const fieldType = field.type\n ? CmsFieldTypeToPatternsFieldType[field.type] || 'SHORT_TEXT'\n : 'SHORT_TEXT';\n const baseField = {\n id: field.key,\n displayName: field.displayName || '',\n validation: {\n numberRange: field.numberRange\n ? {\n min: field.numberRange.min ?? undefined,\n max: field.numberRange.max ?? undefined,\n }\n : undefined,\n stringLengthRange: field.stringLengthRange\n ? {\n minLength: field.stringLengthRange.minLength ?? undefined,\n maxLength: field.stringLengthRange.maxLength ?? undefined,\n }\n : undefined,\n required: field.required ?? false,\n },\n capabilities: {\n supportedQueryOperators: field.capabilities?.queryOperators || [],\n sortable: field.capabilities?.sortable || false,\n },\n };\n\n if (\n fieldType === 'REFERENCE' &&\n field.typeMetadata?.reference?.referencedCollectionId\n ) {\n const referenceField: Field = {\n ...baseField,\n type: 'REFERENCE',\n referenceMetadata: {\n referencedCollectionId:\n field.typeMetadata.reference.referencedCollectionId,\n },\n };\n acc[field.key] = referenceField;\n } else {\n const nonReferenceType =\n fieldType === 'REFERENCE' ? 'SHORT_TEXT' : fieldType;\n const nonReferenceField: Field = {\n ...baseField,\n type: nonReferenceType,\n };\n acc[field.key] = nonReferenceField;\n }\n\n return acc;\n },\n {},\n );\n\n const schemaConfig: SchemaConfig = {\n id: collectionId,\n displayField: schema.displayField ?? '_id',\n idField: '_id',\n fields: transformedFields,\n actions: {\n get: (entityId: string) => {\n return items.get(collectionId, entityId);\n },\n create: (entity) => {\n return items.insert(collectionId, entity);\n },\n update: (entity) => {\n return items.update(collectionId, entity);\n },\n delete: (entityId) => {\n return items.remove(collectionId, entityId);\n },\n bulkDelete: (entityIds) => {\n return items.bulkRemove(collectionId, entityIds);\n },\n find: async (\n query,\n options: {\n searchableFieldIds?: string[];\n filterFieldMapping?: Record<string, { fieldId: string }>;\n } = {},\n ) => {\n return fetchCmsData(collectionId, query, transformedFields, options);\n },\n },\n };\n\n return schemaConfig;\n}\n"],"mappings":"AACA,SAASA,WAAW,EAAEC,KAAK,QAAQ,WAAW;AAC9C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,OAAO,MAAMC,+BAEZ,GAAG;EACF,CAACJ,WAAW,CAACK,IAAI,CAACC,IAAI,GAAG,YAAY;EACrC,CAACN,WAAW,CAACK,IAAI,CAACE,IAAI,GAAG,MAAM;EAC/B,CAACP,WAAW,CAACK,IAAI,CAACG,QAAQ,GAAG,UAAU;EACvC,CAACR,WAAW,CAACK,IAAI,CAACI,MAAM,GAAG,QAAQ;EACnC,CAACT,WAAW,CAACK,IAAI,CAACK,OAAO,GAAG,SAAS;EACrC,CAACV,WAAW,CAACK,IAAI,CAACM,GAAG,GAAG,KAAK;EAC7B,CAACX,WAAW,CAACK,IAAI,CAACO,OAAO,GAAG,YAAY;EACxC,CAACZ,WAAW,CAACK,IAAI,CAACQ,MAAM,GAAG,WAAW;EACtC,CAACb,WAAW,CAACK,IAAI,CAACS,SAAS,GAAG,WAAW;EACzC,CAACd,WAAW,CAACK,IAAI,CAACU,YAAY,GAAG,YAAY;EAC7C,CAACf,WAAW,CAACK,IAAI,CAACW,KAAK,GAAG,OAAO;EACjC,CAAChB,WAAW,CAACK,IAAI,CAACY,YAAY,GAAG,OAAO;EACxC,CAACjB,WAAW,CAACK,IAAI,CAACa,SAAS,GAAG,WAAW;EACzC,CAAClB,WAAW,CAACK,IAAI,CAACc,KAAK,GAAG;AAC5B,CAAC;AAED,OAAO,eAAeC,cAAcA,CAClCC,YAAoB,EACG;EACvB,MAAMC,MAAM,GAAG,MAAMnB,YAAY,CAACoB,gBAAgB,CAChD,YAAYvB,WAAW,CAACwB,iBAAiB,CAACH,YAAY,CAAC,EACvD,CAAC,CACH,CAAC;EACD,MAAMI,iBAAiB,
|
|
1
|
+
{"version":3,"names":["collections","items","fetchCmsData","errorHandler","CmsFieldTypeToPatternsFieldType","Type","TEXT","DATE","DATETIME","NUMBER","BOOLEAN","URL","ADDRESS","OBJECT","RICH_TEXT","RICH_CONTENT","ARRAY","ARRAY_STRING","REFERENCE","IMAGE","fetchCmsSchema","collectionId","schema","withErrorHandler","getDataCollection","transformedFields","fields","reduce","acc","field","_field$capabilities","_field$capabilities2","_field$typeMetadata","key","fieldType","type","baseField","id","displayName","validation","numberRange","min","undefined","max","stringLengthRange","minLength","maxLength","required","capabilities","supportedQueryOperators","queryOperators","sortable","typeMetadata","reference","referencedCollectionId","referenceField","referenceMetadata","nonReferenceType","nonReferenceField","schemaConfig","displayField","idField","actions","get","entityId","create","entity","insert","update","delete","remove","bulkDelete","entityIds","bulkRemove","find","query","options"],"sources":["../../../../src/dataSourceAdapters/cms/cmsAdapter.ts"],"sourcesContent":["import { Field, SchemaConfig, PatternsFieldType } from '../../types';\nimport { collections, items } from '@wix/data';\nimport { fetchCmsData } from './fetchCmsData';\nimport { errorHandler } from '@wix/essentials';\n\nexport const CmsFieldTypeToPatternsFieldType: Partial<\n Record<collections.Type, PatternsFieldType>\n> = {\n [collections.Type.TEXT]: 'SHORT_TEXT',\n [collections.Type.DATE]: 'DATE',\n [collections.Type.DATETIME]: 'DATETIME',\n [collections.Type.NUMBER]: 'NUMBER',\n [collections.Type.BOOLEAN]: 'BOOLEAN',\n [collections.Type.URL]: 'URL',\n [collections.Type.ADDRESS]: 'SHORT_TEXT',\n [collections.Type.OBJECT]: 'LONG_TEXT',\n [collections.Type.RICH_TEXT]: 'LONG_TEXT',\n [collections.Type.RICH_CONTENT]: 'SHORT_TEXT',\n [collections.Type.ARRAY]: 'ARRAY',\n [collections.Type.ARRAY_STRING]: 'ARRAY',\n [collections.Type.REFERENCE]: 'REFERENCE',\n [collections.Type.IMAGE]: 'IMAGE',\n};\n\nexport async function fetchCmsSchema(\n collectionId: string,\n): Promise<SchemaConfig> {\n const schema = await errorHandler.withErrorHandler(\n async () => collections.getDataCollection(collectionId),\n {},\n );\n const transformedFields = (schema.fields || []).reduce<Record<string, Field>>(\n (acc, field) => {\n if (!field.key) {\n return acc;\n }\n\n const fieldType = field.type\n ? CmsFieldTypeToPatternsFieldType[field.type] || 'SHORT_TEXT'\n : 'SHORT_TEXT';\n const baseField = {\n id: field.key,\n displayName: field.displayName || '',\n validation: {\n numberRange: field.numberRange\n ? {\n min: field.numberRange.min ?? undefined,\n max: field.numberRange.max ?? undefined,\n }\n : undefined,\n stringLengthRange: field.stringLengthRange\n ? {\n minLength: field.stringLengthRange.minLength ?? undefined,\n maxLength: field.stringLengthRange.maxLength ?? undefined,\n }\n : undefined,\n required: field.required ?? false,\n },\n capabilities: {\n supportedQueryOperators: field.capabilities?.queryOperators || [],\n sortable: field.capabilities?.sortable || false,\n },\n };\n\n if (\n fieldType === 'REFERENCE' &&\n field.typeMetadata?.reference?.referencedCollectionId\n ) {\n const referenceField: Field = {\n ...baseField,\n type: 'REFERENCE',\n referenceMetadata: {\n referencedCollectionId:\n field.typeMetadata.reference.referencedCollectionId,\n },\n };\n acc[field.key] = referenceField;\n } else {\n const nonReferenceType =\n fieldType === 'REFERENCE' ? 'SHORT_TEXT' : fieldType;\n const nonReferenceField: Field = {\n ...baseField,\n type: nonReferenceType,\n };\n acc[field.key] = nonReferenceField;\n }\n\n return acc;\n },\n {},\n );\n\n const schemaConfig: SchemaConfig = {\n id: collectionId,\n displayField: schema.displayField ?? '_id',\n idField: '_id',\n fields: transformedFields,\n actions: {\n get: (entityId: string) => {\n return items.get(collectionId, entityId);\n },\n create: (entity) => {\n return items.insert(collectionId, entity);\n },\n update: (entity) => {\n return items.update(collectionId, entity);\n },\n delete: (entityId) => {\n return items.remove(collectionId, entityId);\n },\n bulkDelete: (entityIds) => {\n return items.bulkRemove(collectionId, entityIds);\n },\n find: async (\n query,\n options: {\n searchableFieldIds?: string[];\n filterFieldMapping?: Record<string, { fieldId: string }>;\n } = {},\n ) => {\n return fetchCmsData(collectionId, query, transformedFields, options);\n },\n },\n };\n\n return schemaConfig;\n}\n"],"mappings":"AACA,SAASA,WAAW,EAAEC,KAAK,QAAQ,WAAW;AAC9C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,OAAO,MAAMC,+BAEZ,GAAG;EACF,CAACJ,WAAW,CAACK,IAAI,CAACC,IAAI,GAAG,YAAY;EACrC,CAACN,WAAW,CAACK,IAAI,CAACE,IAAI,GAAG,MAAM;EAC/B,CAACP,WAAW,CAACK,IAAI,CAACG,QAAQ,GAAG,UAAU;EACvC,CAACR,WAAW,CAACK,IAAI,CAACI,MAAM,GAAG,QAAQ;EACnC,CAACT,WAAW,CAACK,IAAI,CAACK,OAAO,GAAG,SAAS;EACrC,CAACV,WAAW,CAACK,IAAI,CAACM,GAAG,GAAG,KAAK;EAC7B,CAACX,WAAW,CAACK,IAAI,CAACO,OAAO,GAAG,YAAY;EACxC,CAACZ,WAAW,CAACK,IAAI,CAACQ,MAAM,GAAG,WAAW;EACtC,CAACb,WAAW,CAACK,IAAI,CAACS,SAAS,GAAG,WAAW;EACzC,CAACd,WAAW,CAACK,IAAI,CAACU,YAAY,GAAG,YAAY;EAC7C,CAACf,WAAW,CAACK,IAAI,CAACW,KAAK,GAAG,OA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YAAY,EAAE2C,QAAQ,CAAC;MAC1C,CAAC;MACDC,MAAM,EAAGC,MAAM,IAAK;QAClB,OAAOjE,KAAK,CAACkE,MAAM,CAAC9C,YAAY,EAAE6C,MAAM,CAAC;MAC3C,CAAC;MACDE,MAAM,EAAGF,MAAM,IAAK;QAClB,OAAOjE,KAAK,CAACmE,MAAM,CAAC/C,YAAY,EAAE6C,MAAM,CAAC;MAC3C,CAAC;MACDG,MAAM,EAAGL,QAAQ,IAAK;QACpB,OAAO/D,KAAK,CAACqE,MAAM,CAACjD,YAAY,EAAE2C,QAAQ,CAAC;MAC7C,CAAC;MACDO,UAAU,EAAGC,SAAS,IAAK;QACzB,OAAOvE,KAAK,CAACwE,UAAU,CAACpD,YAAY,EAAEmD,SAAS,CAAC;MAClD,CAAC;MACDE,IAAI,EAAE,eAAAA,CACJC,KAAK,EACLC,OAGC,EACE;QAAA,IAJHA,OAGC;UAHDA,OAGC,GAAG,CAAC,CAAC;QAAA;QAEN,OAAO1E,YAAY,CAACmB,YAAY,EAAEsD,KAAK,EAAElD,iBAAiB,EAAEmD,OAAO,CAAC;MACtE;IACF;EACF,CAAC;EAED,OAAOjB,YAAY;AACrB","ignoreList":[]}
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -4,4 +4,6 @@ export * from './useGridFeatures';
|
|
|
4
4
|
export * from './useNavigationUtils';
|
|
5
5
|
export * from './usePagePath';
|
|
6
6
|
export * from './useEntityPageHeaderTexts';
|
|
7
|
+
export * from './useUpdateAppContextItems';
|
|
8
|
+
export { useAppContext } from '../providers/AppContext';
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export * from './useTableFeatures';\nexport * from './useFilters';\nexport * from './useGridFeatures';\nexport * from './useNavigationUtils';\nexport * from './usePagePath';\nexport * from './useEntityPageHeaderTexts';\n"],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,sBAAsB;AACpC,cAAc,eAAe;AAC7B,cAAc,4BAA4B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useAppContext"],"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export * from './useTableFeatures';\nexport * from './useFilters';\nexport * from './useGridFeatures';\nexport * from './useNavigationUtils';\nexport * from './usePagePath';\nexport * from './useEntityPageHeaderTexts';\nexport * from './useUpdateAppContextItems';\nexport { useAppContext } from '../providers/AppContext';\n"],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,sBAAsB;AACpC,cAAc,eAAe;AAC7B,cAAc,4BAA4B;AAC1C,cAAc,4BAA4B;AAC1C,SAASA,aAAa,QAAQ,yBAAyB","ignoreList":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useFetchData } from './useFetchData';
|
|
2
|
-
import { useGridCollection } from '@wix/patterns';
|
|
2
|
+
import { useGridCollection, useSelector } from '@wix/patterns';
|
|
3
3
|
import { useCommonCollectionFeatures } from './useCommonCollectionFeatures';
|
|
4
4
|
import { useFilters } from './useFilters';
|
|
5
5
|
import { useSchema } from '../providers/SchemaContext';
|
|
6
6
|
import { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';
|
|
7
7
|
import { useBaseGridFeatures } from './useBaseGridFeatures';
|
|
8
|
+
import { useUpdateAppContextItems } from './useUpdateAppContextItems';
|
|
8
9
|
export const useGridFeatures = configuration => {
|
|
9
10
|
const {
|
|
10
11
|
collectionId,
|
|
@@ -49,6 +50,8 @@ export const useGridFeatures = configuration => {
|
|
|
49
50
|
disableAutoSelectAllCount: selectAllScope === 'page',
|
|
50
51
|
selectionConsistencyMode: selectionUpdateMode
|
|
51
52
|
});
|
|
53
|
+
const items = useSelector(() => state.collection.result.items);
|
|
54
|
+
useUpdateAppContextItems(items);
|
|
52
55
|
const optimisticActions = useAutoPatternsOptimisticActions(collectionId, state.collection);
|
|
53
56
|
const commonFeatures = useCommonCollectionFeatures({
|
|
54
57
|
...configuration,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useFetchData","useGridCollection","useCommonCollectionFeatures","useFilters","useSchema","useAutoPatternsOptimisticActions","useBaseGridFeatures","useGridFeatures","configuration","collectionId","limit","reflectQueryInUrl","selectAllScope","selectionUpdateMode","collection","renderItem","imagePlacement","preset","visibleFieldIds","filterComponent","filtersObject","filterFieldMapping","filters","fetchData","searchableFieldIds","schema","state","queryName","itemKey","gridItem","idField","itemName","displayField","toExtendedFields","extendedFields","fetchErrorMessage","_ref","err","String","persistQueryToUrl","disableAutoSelectAllCount","selectionConsistencyMode","optimisticActions","commonFeatures"],"sources":["../../../src/hooks/useGridFeatures.tsx"],"sourcesContent":["import { GridConfig } from '../types';\nimport { useFetchData } from './useFetchData';\nimport { useGridCollection } from '@wix/patterns';\nimport { useCommonCollectionFeatures } from './useCommonCollectionFeatures';\nimport { useFilters } from './useFilters';\nimport { useSchema } from '../providers/SchemaContext';\nimport { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';\nimport { useBaseGridFeatures } from './useBaseGridFeatures';\n\nexport const useGridFeatures = (configuration: GridConfig) => {\n const {\n collectionId,\n limit,\n reflectQueryInUrl,\n selectAllScope,\n selectionUpdateMode,\n } = configuration.collection;\n\n const { renderItem, imagePlacement, preset, visibleFieldIds } =\n useBaseGridFeatures(configuration);\n\n const { filterComponent, filtersObject, filterFieldMapping } = useFilters(\n configuration.filters,\n );\n\n const { fetchData } = useFetchData({\n searchableFieldIds: visibleFieldIds,\n filterFieldMapping,\n });\n\n const schema = useSchema();\n\n const state = useGridCollection<any>({\n queryName: `${collectionId}`,\n itemKey: (gridItem) => gridItem[schema.idField],\n itemName: (gridItem) => gridItem[schema.displayField],\n filters: filtersObject,\n toExtendedFields: (gridItem) => gridItem.extendedFields,\n fetchErrorMessage: ({ err }) => String(err),\n fetchData,\n limit,\n persistQueryToUrl: reflectQueryInUrl,\n disableAutoSelectAllCount: selectAllScope === 'page',\n selectionConsistencyMode: selectionUpdateMode,\n });\n\n const optimisticActions = useAutoPatternsOptimisticActions(\n collectionId,\n state.collection,\n );\n\n const commonFeatures = useCommonCollectionFeatures({\n ...configuration,\n optimisticActions,\n });\n\n return {\n ...commonFeatures,\n state,\n imagePlacement,\n preset,\n optimisticActions,\n renderItem,\n filters: filterComponent,\n };\n};\n"],"mappings":"AACA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,iBAAiB,QAAQ,eAAe;
|
|
1
|
+
{"version":3,"names":["useFetchData","useGridCollection","useSelector","useCommonCollectionFeatures","useFilters","useSchema","useAutoPatternsOptimisticActions","useBaseGridFeatures","useUpdateAppContextItems","useGridFeatures","configuration","collectionId","limit","reflectQueryInUrl","selectAllScope","selectionUpdateMode","collection","renderItem","imagePlacement","preset","visibleFieldIds","filterComponent","filtersObject","filterFieldMapping","filters","fetchData","searchableFieldIds","schema","state","queryName","itemKey","gridItem","idField","itemName","displayField","toExtendedFields","extendedFields","fetchErrorMessage","_ref","err","String","persistQueryToUrl","disableAutoSelectAllCount","selectionConsistencyMode","items","result","optimisticActions","commonFeatures"],"sources":["../../../src/hooks/useGridFeatures.tsx"],"sourcesContent":["import { GridConfig } from '../types';\nimport { useFetchData } from './useFetchData';\nimport { useGridCollection, useSelector } from '@wix/patterns';\nimport { useCommonCollectionFeatures } from './useCommonCollectionFeatures';\nimport { useFilters } from './useFilters';\nimport { useSchema } from '../providers/SchemaContext';\nimport { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';\nimport { useBaseGridFeatures } from './useBaseGridFeatures';\nimport { useUpdateAppContextItems } from './useUpdateAppContextItems';\n\nexport const useGridFeatures = (configuration: GridConfig) => {\n const {\n collectionId,\n limit,\n reflectQueryInUrl,\n selectAllScope,\n selectionUpdateMode,\n } = configuration.collection;\n\n const { renderItem, imagePlacement, preset, visibleFieldIds } =\n useBaseGridFeatures(configuration);\n\n const { filterComponent, filtersObject, filterFieldMapping } = useFilters(\n configuration.filters,\n );\n\n const { fetchData } = useFetchData({\n searchableFieldIds: visibleFieldIds,\n filterFieldMapping,\n });\n\n const schema = useSchema();\n\n const state = useGridCollection<any>({\n queryName: `${collectionId}`,\n itemKey: (gridItem) => gridItem[schema.idField],\n itemName: (gridItem) => gridItem[schema.displayField],\n filters: filtersObject,\n toExtendedFields: (gridItem) => gridItem.extendedFields,\n fetchErrorMessage: ({ err }) => String(err),\n fetchData,\n limit,\n persistQueryToUrl: reflectQueryInUrl,\n disableAutoSelectAllCount: selectAllScope === 'page',\n selectionConsistencyMode: selectionUpdateMode,\n });\n\n const items = useSelector(() => state.collection.result.items);\n useUpdateAppContextItems(items);\n\n const optimisticActions = useAutoPatternsOptimisticActions(\n collectionId,\n state.collection,\n );\n\n const commonFeatures = useCommonCollectionFeatures({\n ...configuration,\n optimisticActions,\n });\n\n return {\n ...commonFeatures,\n state,\n imagePlacement,\n preset,\n optimisticActions,\n renderItem,\n filters: filterComponent,\n };\n};\n"],"mappings":"AACA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,iBAAiB,EAAEC,WAAW,QAAQ,eAAe;AAC9D,SAASC,2BAA2B,QAAQ,+BAA+B;AAC3E,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,4BAA4B;AACtD,SAASC,gCAAgC,QAAQ,oCAAoC;AACrF,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,wBAAwB,QAAQ,4BAA4B;AAErE,OAAO,MAAMC,eAAe,GAAIC,aAAyB,IAAK;EAC5D,MAAM;IACJC,YAAY;IACZC,KAAK;IACLC,iBAAiB;IACjBC,cAAc;IACdC;EACF,CAAC,GAAGL,aAAa,CAACM,UAAU;EAE5B,MAAM;IAAEC,UAAU;IAAEC,cAAc;IAAEC,MAAM;IAAEC;EAAgB,CAAC,GAC3Db,mBAAmB,CAACG,aAAa,CAAC;EA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IACjB7B,UAAU;IACVO,OAAO,EAAEH;EACX,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -4,10 +4,19 @@ import { useAppConfigContext, useSchemaRegistry } from '../providers';
|
|
|
4
4
|
import { generatePath } from 'react-router-dom';
|
|
5
5
|
import { usePagePath } from './usePagePath';
|
|
6
6
|
export const useNavigation = () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
let navigateToEntityPagePatterns;
|
|
8
|
+
let navigateToCollectionPagePatterns;
|
|
9
|
+
let isNavigationAvailable = true;
|
|
10
|
+
try {
|
|
11
|
+
const navigation = usePatternsNavigate();
|
|
12
|
+
navigateToEntityPagePatterns = navigation.navigateToEntityPage;
|
|
13
|
+
navigateToCollectionPagePatterns = navigation.navigateToCollectionPage;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
// Navigation context not available (e.g., when rendering components without routes)
|
|
16
|
+
isNavigationAvailable = false;
|
|
17
|
+
navigateToEntityPagePatterns = () => {};
|
|
18
|
+
navigateToCollectionPagePatterns = () => {};
|
|
19
|
+
}
|
|
11
20
|
const appConfig = useAppConfigContext();
|
|
12
21
|
const {
|
|
13
22
|
getSchema
|
|
@@ -21,6 +30,9 @@ export const useNavigation = () => {
|
|
|
21
30
|
item,
|
|
22
31
|
entityPageId
|
|
23
32
|
} = _ref;
|
|
33
|
+
if (!isNavigationAvailable || !appConfig.pages) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
24
36
|
const entityPage = entityPageId ? appConfig.pages.find(page => page.id === entityPageId) : null;
|
|
25
37
|
if (!entityPage) {
|
|
26
38
|
return;
|
|
@@ -39,8 +51,11 @@ export const useNavigation = () => {
|
|
|
39
51
|
entity: item
|
|
40
52
|
});
|
|
41
53
|
}
|
|
42
|
-
}, [appConfig, navigateToEntityPagePatterns, getSchema]);
|
|
54
|
+
}, [appConfig, navigateToEntityPagePatterns, getSchema, isNavigationAvailable]);
|
|
43
55
|
const navigateToCollectionPage = useCallback(parentPageId => {
|
|
56
|
+
if (!isNavigationAvailable) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
44
59
|
const parentPagePath = getPagePath(parentPageId);
|
|
45
60
|
if (!parentPagePath) {
|
|
46
61
|
return;
|
|
@@ -48,7 +63,7 @@ export const useNavigation = () => {
|
|
|
48
63
|
navigateToCollectionPagePatterns({
|
|
49
64
|
path: parentPagePath
|
|
50
65
|
});
|
|
51
|
-
}, [navigateToCollectionPagePatterns, getPagePath]);
|
|
66
|
+
}, [navigateToCollectionPagePatterns, getPagePath, isNavigationAvailable]);
|
|
52
67
|
const getParentPagePath = useCallback(parentPageId => {
|
|
53
68
|
return getPagePath(parentPageId);
|
|
54
69
|
}, [getPagePath]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","usePatternsNavigate","useAppConfigContext","useSchemaRegistry","generatePath","usePagePath","useNavigation","
|
|
1
|
+
{"version":3,"names":["useCallback","usePatternsNavigate","useAppConfigContext","useSchemaRegistry","generatePath","usePagePath","useNavigation","navigateToEntityPagePatterns","navigateToCollectionPagePatterns","isNavigationAvailable","navigation","navigateToEntityPage","navigateToCollectionPage","error","appConfig","getSchema","getPagePath","_ref","_route$params","item","entityPageId","pages","entityPage","find","page","id","route","collectionId","schema","path","params","idField","entity","parentPageId","parentPagePath","getParentPagePath"],"sources":["../../../src/hooks/useNavigationUtils.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { usePatternsNavigate } from '@wix/patterns/router';\nimport { useAppConfigContext, useSchemaRegistry } from '../providers';\nimport { generatePath } from 'react-router-dom';\nimport { EntityPageConfig, EntityProps } from '../types';\nimport { usePagePath } from './usePagePath';\n\nexport type NavigateToEntityPageFunc = (args: {\n item: any;\n entityPageId?: string;\n}) => void;\n\nexport const useNavigation = () => {\n let navigateToEntityPagePatterns: ({\n path,\n entity,\n }: {\n path: string;\n entity: EntityProps;\n }) => void;\n let navigateToCollectionPagePatterns: ({ path }: { path: string }) => void;\n let isNavigationAvailable = true;\n\n try {\n const navigation = usePatternsNavigate();\n navigateToEntityPagePatterns = navigation.navigateToEntityPage;\n navigateToCollectionPagePatterns = navigation.navigateToCollectionPage;\n } catch (error) {\n // Navigation context not available (e.g., when rendering components without routes)\n isNavigationAvailable = false;\n navigateToEntityPagePatterns = () => {};\n navigateToCollectionPagePatterns = () => {};\n }\n\n const appConfig = useAppConfigContext();\n const { getSchema } = useSchemaRegistry();\n const { getPagePath } = usePagePath(appConfig);\n\n const navigateToEntityPage = useCallback(\n ({ item, entityPageId }: { item: EntityProps; entityPageId?: string }) => {\n if (!isNavigationAvailable || !appConfig.pages) {\n return;\n }\n\n const entityPage = entityPageId\n ? appConfig.pages.find((page) => page.id === entityPageId)\n : null;\n\n if (!entityPage) {\n return;\n }\n\n const { route, collectionId } = entityPage.entityPage as EntityPageConfig;\n const schema = getSchema(collectionId);\n if (route.path && route.params?.id && schema) {\n const path = generatePath(route.path, {\n [route.params.id]: item?.[schema.idField] ?? '',\n });\n navigateToEntityPagePatterns({\n path,\n entity: item,\n });\n }\n },\n [appConfig, navigateToEntityPagePatterns, getSchema, isNavigationAvailable],\n );\n\n const navigateToCollectionPage = useCallback(\n (parentPageId: string) => {\n if (!isNavigationAvailable) {\n return;\n }\n const parentPagePath = getPagePath(parentPageId);\n if (!parentPagePath) {\n return;\n }\n navigateToCollectionPagePatterns({\n path: parentPagePath,\n });\n },\n [navigateToCollectionPagePatterns, getPagePath, isNavigationAvailable],\n );\n\n const getParentPagePath = useCallback(\n (parentPageId?: string): string | undefined => {\n return getPagePath(parentPageId);\n },\n [getPagePath],\n );\n\n return {\n navigateToEntityPage,\n navigateToCollectionPage,\n getParentPagePath,\n getPagePath,\n };\n};\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,OAAO;AACnC,SAASC,mBAAmB,QAAQ,sBAAsB;AAC1D,SAASC,mBAAmB,EAAEC,iBAAiB,QAAQ,cAAc;AACrE,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,SAAS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AcO,EAAE,IAAIG,MAAM,EAAE;MAC5C,MAAMC,IAAI,GAAGzB,YAAY,CAACsB,KAAK,CAACG,IAAI,EAAE;QACpC,CAACH,KAAK,CAACI,MAAM,CAACL,EAAE,GAAG,CAAAN,IAAI,oBAAJA,IAAI,CAAGS,MAAM,CAACG,OAAO,CAAC,KAAI;MAC/C,CAAC,CAAC;MACFxB,4BAA4B,CAAC;QAC3BsB,IAAI;QACJG,MAAM,EAAEb;MACV,CAAC,CAAC;IACJ;EACF,CAAC,EACD,CAACL,SAAS,EAAEP,4BAA4B,EAAEQ,SAAS,EAAEN,qBAAqB,CAC5E,CAAC;EAED,MAAMG,wBAAwB,GAAGZ,WAAW,CACzCiC,YAAoB,IAAK;IACxB,IAAI,CAACxB,qBAAqB,EAAE;MAC1B;IACF;IACA,MAAMyB,cAAc,GAAGlB,WAAW,CAACiB,YAAY,CAAC;IAChD,IAAI,CAACC,cAAc,EAAE;MACnB;IACF;IACA1B,gCAAgC,CAAC;MAC/BqB,IAAI,EAAEK;IACR,CAAC,CAAC;EACJ,CAAC,EACD,CAAC1B,gCAAgC,EAAEQ,WAAW,EAAEP,qBAAqB,CACvE,CAAC;EAED,MAAM0B,iBAAiB,GAAGnC,WAAW,CAClCiC,YAAqB,IAAyB;IAC7C,OAAOjB,WAAW,CAACiB,YAAY,CAAC;EAClC,CAAC,EACD,CAACjB,WAAW,CACd,CAAC;EAED,OAAO;IACLL,oBAAoB;IACpBC,wBAAwB;IACxBuB,iBAAiB;IACjBnB;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useFetchData } from './useFetchData';
|
|
2
|
-
import { TableSections, useTableCollection } from '@wix/patterns';
|
|
2
|
+
import { TableSections, useSelector, useTableCollection } from '@wix/patterns';
|
|
3
3
|
import { useCommonCollectionFeatures } from './useCommonCollectionFeatures';
|
|
4
4
|
import { useFilters } from './useFilters';
|
|
5
5
|
import { useSchema } from '../providers/SchemaContext';
|
|
6
6
|
import { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';
|
|
7
7
|
import { useBaseTableFeatures } from './useBaseTableFeatures';
|
|
8
8
|
import { usePatternsWizardOverridesContext } from '../providers/PatternsWizardOverridesContext';
|
|
9
|
+
import { useUpdateAppContextItems } from './useUpdateAppContextItems';
|
|
9
10
|
export const useTableFeatures = configuration => {
|
|
10
11
|
var _configuration$sectio, _overrides$sections;
|
|
11
12
|
const {
|
|
@@ -55,6 +56,8 @@ export const useTableFeatures = configuration => {
|
|
|
55
56
|
disableAutoSelectAllCount: selectAllScope === 'page',
|
|
56
57
|
selectionConsistencyMode: selectionUpdateMode
|
|
57
58
|
});
|
|
59
|
+
const items = useSelector(() => state.collection.result.items);
|
|
60
|
+
useUpdateAppContextItems(items);
|
|
58
61
|
const optimisticActions = useAutoPatternsOptimisticActions(collectionId, state.collection);
|
|
59
62
|
const commonFeatures = useCommonCollectionFeatures({
|
|
60
63
|
...configuration,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useFetchData","TableSections","useTableCollection","useCommonCollectionFeatures","useFilters","useSchema","useAutoPatternsOptimisticActions","useBaseTableFeatures","usePatternsWizardOverridesContext","useTableFeatures","configuration","_configuration$sectio","_overrides$sections","collectionId","limit","reflectQueryInUrl","selectAllScope","selectionUpdateMode","collection","filterComponent","filtersObject","filterFieldMapping","filters","customColumns","visibleFieldIds","columns","onRowClick","stickyColumns","stickySelectionColumn","showTitleBar","fetchData","searchableFieldIds","schema","overrides","state","queryName","itemKey","item","idField","itemName","displayField","toExtendedFields","extendedFields","fetchErrorMessage","_ref","err","String","persistQueryToUrl","disableAutoSelectAllCount","selectionConsistencyMode","optimisticActions","commonFeatures","sections","id","renderSection","undefined"],"sources":["../../../src/hooks/useTableFeatures.tsx"],"sourcesContent":["import { TableConfig } from '../types';\nimport { useFetchData } from './useFetchData';\nimport { TableSections, useTableCollection } from '@wix/patterns';\nimport { useCommonCollectionFeatures } from './useCommonCollectionFeatures';\nimport { useFilters } from './useFilters';\nimport { useSchema } from '../providers/SchemaContext';\nimport { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';\nimport { useBaseTableFeatures } from './useBaseTableFeatures';\nimport { usePatternsWizardOverridesContext } from '../providers/PatternsWizardOverridesContext';\n\nexport const useTableFeatures = (configuration: TableConfig) => {\n const {\n collectionId,\n limit,\n reflectQueryInUrl,\n selectAllScope,\n selectionUpdateMode,\n } = configuration.collection;\n\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 schema = useSchema();\n const overrides = usePatternsWizardOverridesContext();\n\n const state = useTableCollection<any>({\n queryName: `${collectionId}`,\n itemKey: (item) => item[schema.idField],\n itemName: (item) => item[schema.displayField],\n filters: filtersObject,\n toExtendedFields: (item) => item.extendedFields,\n fetchErrorMessage: ({ err }) => String(err),\n fetchData,\n limit,\n persistQueryToUrl: reflectQueryInUrl,\n disableAutoSelectAllCount: selectAllScope === 'page',\n selectionConsistencyMode: selectionUpdateMode,\n });\n\n const optimisticActions = useAutoPatternsOptimisticActions(\n collectionId,\n state.collection,\n );\n\n const commonFeatures = useCommonCollectionFeatures({\n ...configuration,\n optimisticActions,\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 optimisticActions,\n customColumns,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n showTitleBar,\n sections,\n };\n};\n"],"mappings":"AACA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,eAAe;
|
|
1
|
+
{"version":3,"names":["useFetchData","TableSections","useSelector","useTableCollection","useCommonCollectionFeatures","useFilters","useSchema","useAutoPatternsOptimisticActions","useBaseTableFeatures","usePatternsWizardOverridesContext","useUpdateAppContextItems","useTableFeatures","configuration","_configuration$sectio","_overrides$sections","collectionId","limit","reflectQueryInUrl","selectAllScope","selectionUpdateMode","collection","filterComponent","filtersObject","filterFieldMapping","filters","customColumns","visibleFieldIds","columns","onRowClick","stickyColumns","stickySelectionColumn","showTitleBar","fetchData","searchableFieldIds","schema","overrides","state","queryName","itemKey","item","idField","itemName","displayField","toExtendedFields","extendedFields","fetchErrorMessage","_ref","err","String","persistQueryToUrl","disableAutoSelectAllCount","selectionConsistencyMode","items","result","optimisticActions","commonFeatures","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 { useSchema } from '../providers/SchemaContext';\nimport { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';\nimport { useBaseTableFeatures } from './useBaseTableFeatures';\nimport { usePatternsWizardOverridesContext } from '../providers/PatternsWizardOverridesContext';\nimport { useUpdateAppContextItems } from './useUpdateAppContextItems';\n\nexport const useTableFeatures = (configuration: TableConfig) => {\n const {\n collectionId,\n limit,\n reflectQueryInUrl,\n selectAllScope,\n selectionUpdateMode,\n } = configuration.collection;\n\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 schema = useSchema();\n const overrides = usePatternsWizardOverridesContext();\n\n const state = useTableCollection<any>({\n queryName: `${collectionId}`,\n itemKey: (item) => item[schema.idField],\n itemName: (item) => item[schema.displayField],\n filters: filtersObject,\n toExtendedFields: (item) => item.extendedFields,\n fetchErrorMessage: ({ err }) => String(err),\n fetchData,\n limit,\n persistQueryToUrl: reflectQueryInUrl,\n disableAutoSelectAllCount: selectAllScope === 'page',\n selectionConsistencyMode: selectionUpdateMode,\n });\n\n const items = useSelector(() => state.collection.result.items);\n useUpdateAppContextItems(items);\n\n const optimisticActions = useAutoPatternsOptimisticActions(\n collectionId,\n state.collection,\n );\n\n const commonFeatures = useCommonCollectionFeatures({\n ...configuration,\n optimisticActions,\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 optimisticActions,\n customColumns,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n showTitleBar,\n sections,\n };\n};\n"],"mappings":"AACA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,aAAa,EAAEC,WAAW,EAAEC,kBAAkB,QAAQ,eAAe;AAC9E,SAASC,2BAA2B,QAAQ,+BAA+B;AAC3E,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,4BAA4B;AACtD,SAASC,gCAAgC,QAAQ,oCAAoC;AACrF,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,iCAAiC,QAAQ,6CAA6C;AAC/F,SAASC,wBAAwB,QAAQ,4BAA4B;AAErE,OAAO,MAAMC,gBAAgB,GAAIC,aAA0B,IAAK;EAAA,IAAAC,qBAAA,EAAAC,mBAAA;EAC9D,MAAM;IACJC,YAAY;IACZC,KAAK;IACLC,iBAAiB;IACjBC,cAAc;IACdC;EACF,CAAC,GAAGP,aAAa,CAACQ,UAAU;EAE5B,MAAM;IAAEC,eAAe;IAAEC,aAAa;I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AGnD,2BAA2B,CAAC;IACjD,GAAGQ,aAAa;IAChB0C;EACF,CAAC,CAAC;EAEF,MAAME,QAAQ,GACZ,CAAA3C,qBAAA,GAAAD,aAAa,CAAC4C,QAAQ,aAAtB3C,qBAAA,CAAwB4C,EAAE,IAC1BtB,SAAS,aAAArB,mBAAA,GAATqB,SAAS,CAAEqB,QAAQ,aAAnB1C,mBAAA,CAAsBF,aAAa,CAAC4C,QAAQ,CAACC,EAAE,CAAC,GAC5C;IACEC,aAAa,EAAEvB,SAAS,CAACqB,QAAQ,CAAC5C,aAAa,CAAC4C,QAAQ,CAACC,EAAE,CAAC;IAC5DxD;EACF,CAAC,GACD0D,SAAS;EAEf,OAAO;IACL,GAAGJ,cAAc;IACjBnB,KAAK;IACLT,OAAO;IACPH,OAAO,EAAEH,eAAe;IACxBiC,iBAAiB;IACjB7B,aAAa;IACbG,UAAU;IACVC,aAAa;IACbC,qBAAqB;IACrBC,YAAY;IACZyB;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useFetchData } from './useFetchData';
|
|
2
|
-
import { useTableGridSwitchCollection } from '@wix/patterns';
|
|
2
|
+
import { useSelector, useTableGridSwitchCollection } from '@wix/patterns';
|
|
3
3
|
import { useCommonCollectionFeatures } from './useCommonCollectionFeatures';
|
|
4
4
|
import { useFilters } from './useFilters';
|
|
5
5
|
import { useSchema } from '../providers/SchemaContext';
|
|
6
6
|
import { useAutoPatternsOptimisticActions } from './useAutoPatternsOptimisticActions';
|
|
7
7
|
import { useBaseGridFeatures } from './useBaseGridFeatures';
|
|
8
8
|
import { useBaseTableFeatures } from './useBaseTableFeatures';
|
|
9
|
+
import { useUpdateAppContextItems } from './useUpdateAppContextItems';
|
|
9
10
|
export const useTableGridSwitchFeatures = config => {
|
|
10
11
|
const schema = useSchema();
|
|
11
12
|
const {
|
|
@@ -59,6 +60,8 @@ export const useTableGridSwitchFeatures = config => {
|
|
|
59
60
|
disableAutoSelectAllCount: selectAllScope === 'page',
|
|
60
61
|
selectionConsistencyMode: selectionUpdateMode
|
|
61
62
|
});
|
|
63
|
+
const items = useSelector(() => state.collection.result.items);
|
|
64
|
+
useUpdateAppContextItems(items);
|
|
62
65
|
const optimisticActions = useAutoPatternsOptimisticActions(collectionId, state.collection);
|
|
63
66
|
const commonFeatures = useCommonCollectionFeatures({
|
|
64
67
|
...config,
|