@wix/auto-patterns 1.25.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/AutoPatternsEntityPage/EditModeEntityPage.js +10 -9
- package/dist/cjs/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.js +88 -36
- package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.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/useEntityPageHeaderTexts.js +48 -9
- package/dist/cjs/hooks/useEntityPageHeaderTexts.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/PatternsWizardOverridesContext.js +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/cjs/providers/index.js +12 -0
- package/dist/cjs/providers/index.js.map +1 -1
- package/dist/cjs/types/EntityPageConfig.js.map +1 -1
- package/dist/cjs/types/types.js.map +1 -1
- package/dist/docs/app_config_structure.md +6 -2
- package/dist/docs/auto-patterns-guide.md +466 -38
- package/dist/docs/bulk_actions.md +2 -5
- package/dist/docs/collection_page.md +1 -1
- package/dist/docs/collection_page_actions.md +4 -13
- package/dist/docs/custom_overrides.md +18 -6
- package/dist/docs/entity_page.md +294 -2
- package/dist/docs/entity_page_actions.md +3 -3
- package/dist/docs/entity_page_view_actions.md +2 -2
- package/dist/docs/index.md +12 -0
- package/dist/docs/installation.md +25 -2
- package/dist/docs/pages_configuration.md +2 -2
- 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/AutoPatternsEntityPage/EditModeEntityPage.js +2 -1
- package/dist/esm/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.js +45 -18
- package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.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/useEntityPageHeaderTexts.js +48 -9
- package/dist/esm/hooks/useEntityPageHeaderTexts.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/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/esm/providers/index.js +1 -0
- package/dist/esm/providers/index.js.map +1 -1
- package/dist/esm/types/EntityPageConfig.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/AutoPatternsEntityPage/EditModeEntityPage.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.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/useEntityPageHeaderTexts.d.ts +10 -1
- package/dist/types/hooks/useEntityPageHeaderTexts.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/PatternsWizardOverridesContext.d.ts +10 -0
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
- package/dist/types/providers/index.d.ts +1 -0
- package/dist/types/providers/index.d.ts.map +1 -1
- package/dist/types/types/EntityPageConfig.d.ts +5 -1
- package/dist/types/types/EntityPageConfig.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 +18 -18
|
@@ -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={<SkeletonCollection componentType={componentType} />}\n >\n {componentToRender}\n </SchemaProvider>\n ) : null}\n </>\n );\n};\n"],"mappings":"AACA,SAASA,2BAA2B,QAAQ,4DAA4D;AACxG,SAASC,iBAAiB,QAAQ,wCAAwC;AAC1E,SAASC,gBAAgB,QAAQ,sCAAsC;AACvE,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,kBAAkB,QAAQ,yDAAyD;AAC5F,OAAOC,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAEtC,OAAO,MAAMC,+BAA+B,GAAGC,IAAA,IAMzC;EAAA,IAN0C;IAC9CC,SAAS;IACTC;EAIF,CAAC,GAAAF,IAAA;EACC,MAAM;IAAEG,MAAM;IAAE,GAAGC;EAAa,CAAC,GAAGH,SAAS;EAE7C,MAAMI,QAAQ,GAAGP,OAAO,CAAC,MAAM;IAAA,IAAAQ,YAAA,EAAAC,aAAA;IAC7B,IAAI,EAACJ,MAAM,YAANA,MAAM,CAAEK,MAAM,GAAE;MACnB,OAAO;QACLC,iBAAiB,EAAE,IAAI;QACvBC,aAAa,EAAE;MACjB,CAAC;IACH;IAEA,MAAMC,WAAW,IAAAL,YAAA,GAAGH,MAAM,CAACS,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,OAAO,CAAC,qBAA5CR,YAAA,CAA8CS,KAAK;IACvE,MAAMC,UAAU,IAAAT,aAAA,GAAG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B,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,QAAQ,sCAAsC;AAC/E,SAASC,SAAS,EAAEC,GAAG,QAAQ,oBAAoB;AACnD,SAASC,mBAAmB,QAAQ,iBAAiB;AAMrD,OAAO,MAAMC,0BAEZ,GAAGC,IAAA,IAAuB;EAAA,IAAtB;IAAEC;EAAc,CAAC,GAAAD,IAAA;EACpB,MAAM;IAAEE,KAAK;IAAEC;EAAS,CAAC,GAAGF,aAAa;EACzC,MAAM;IAAEG;EAAO,CAAC,GAAGN,mBAAmB,CAAC,CAAC;EAExC,MAAMO,OAAO,GAAGV,wBAAwB,CAAC;IACvCW,qBAAqB,EAAEL,aAAa,CAACI;EACvC,CAAC,CAAC;;EAEF;EACA,IAAID,MAAM,KAAK,OAAO,EAAE;IACtB,oBACEZ,KAAA,CAAAe,aAAA,CAACX,SAAS;MAACY,IAAI,EAAC,UAAU;MAACC,KAAK,EAAC;IAAO,gBACtCjB,KAAA,CAAAe,aAAA,CAACX,SAAS,CAACc,MAAM;MAACR,KAAK,EAAC;IAAgB,CAAE,CAAC,eAC3CV,KAAA,CAAAe,aAAA,CAACX,SAAS,CAACe,OAAO;MAACC,SAAS;MAACC,iBAAiB;IAAA,gBAC5CrB,KAAA,CAAAe,aAAA,CAACV,GAAG;MAACiB,SAAS,EAAC,UAAU;MAACL,KAAK,EAAC,MAAM;MAACM,MAAM,EAAC;IAAO,gBACnDvB,KAAA,CAAAe,aAAA,CAACb,iCAAiC;MAACO,aAAa,EAAEA;IAAc,CAAE,CAC/D,CACY,CACV,CAAC;EAEhB;EAEA,oBACET,KAAA,CAAAe,aAAA,CAACd,cAAc;IAACsB,MAAM,EAAC,OAAO;IAACC,QAAQ,EAAC;EAAoB,gBAC1DxB,KAAA,CAAAe,aAAA,CAACd,cAAc,CAACiB,MAAM;IACpBR,KAAK,EAAEA,KAAM;IACbC,QAAQ,EAAEA,QAAS;IACnBc,aAAa,EAAEZ,OAAO,CAACa,cAAe;IACtCC,gBAAgB,EAAEd,OAAO,CAACc;EAAiB,CAC5C,CAAC,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":[]}
|
|
@@ -81,7 +81,8 @@ export const EditModeEntityPage = _ref => {
|
|
|
81
81
|
} = useEntityPageHeaderTexts({
|
|
82
82
|
config: configuration,
|
|
83
83
|
isCreateMode,
|
|
84
|
-
entityDisplayName: entity == null ? void 0 : entity[schema.displayField]
|
|
84
|
+
entityDisplayName: entity == null ? void 0 : entity[schema.displayField],
|
|
85
|
+
entity
|
|
85
86
|
});
|
|
86
87
|
const sdk = useActionsSDK({
|
|
87
88
|
collectionId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","useRef","EntityPage","useEntity","useEntityPage","MoreActions","useForm","useParams","useSchema","useEntityPageHeaderTexts","useNavigation","useEntityPageMoreActions","useActionsSDK","RenderLayoutCard","EditModeEntityPage","_ref","_pageLayout$main","_pageLayout$sidebar","configuration","layout","pageLayout","parentPageId","route","actions","collectionId","moreActions","form","mode","params","entityId","id","schema","isCreateMode","inputRefs","setInputRef","input","current","validate","invalidFieldId","Object","keys","find","fieldId","_inputRefs$current$fi","invalid","_inputRefs$current$in","focus","Error","getParentPagePath","parentPath","state","onSave","formValues","getValues","baseEntity","entity","updatedEntity","newEntity","update","create","fetch","undefined","get","title","subtitle","config","entityDisplayName","displayField","sdk","resolvedMoreActions","createElement","dataHook","Header","length","items","Content","MainContent","main","map","layoutIndex","key","sectionId","cardIndex","sidebar","AdditionalContent"],"sources":["../../../../src/components/AutoPatternsEntityPage/EditModeEntityPage.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport {\n EntityPage,\n EntityPageState,\n useEntity,\n useEntityPage,\n MoreActions,\n} from '@wix/patterns';\nimport { useForm } from '@wix/patterns/form';\nimport { useParams } from 'react-router-dom';\nimport { useSchema } from '../../providers/SchemaContext';\nimport { BaseInputRef } from './Fields/types';\nimport { useEntityPageHeaderTexts, useNavigation } from '../../hooks';\nimport { useEntityPageMoreActions } from '../../hooks/useEntityPageMoreActions';\nimport { useActionsSDK } from '../../hooks/useActionsSDK';\nimport { RenderLayoutCard } from './RenderLayout';\nimport { EditEntityPageConfig } from '../../types';\n\nexport const EditModeEntityPage: React.FC<{\n configuration: EditEntityPageConfig;\n}> = ({ configuration }) => {\n const {\n layout: pageLayout,\n parentPageId,\n route,\n actions,\n collectionId,\n } = configuration;\n\n const moreActions = actions?.moreActions;\n\n const form = useForm<any>({\n mode: 'onChange',\n });\n const params = useParams();\n const entityId = params[route.params.id];\n const schema = useSchema();\n const isCreateMode = !entityId;\n\n const inputRefs = useRef<{ [fieldId: string]: BaseInputRef }>({});\n\n const setInputRef = (id: string, input: BaseInputRef) => {\n inputRefs.current[id] = input;\n };\n\n const validate = () => {\n const invalidFieldId = Object.keys(inputRefs.current).find((fieldId) => {\n return inputRefs.current[fieldId]?.invalid;\n });\n\n if (invalidFieldId) {\n inputRefs.current[invalidFieldId]?.focus?.();\n throw new Error('Invalid form');\n }\n };\n const { getParentPagePath } = useNavigation();\n\n const parentPath = useMemo(\n () => getParentPagePath(parentPageId),\n [parentPageId, getParentPagePath],\n );\n\n const state: EntityPageState<any> = useEntityPage<any, any>({\n parentPath,\n form,\n onSave: async () => {\n validate();\n\n const formValues = form.getValues();\n const baseEntity = state.entity || {};\n const updatedEntity = {\n ...baseEntity,\n ...formValues,\n };\n\n const newEntity = entityId\n ? await schema.actions.update(updatedEntity)\n : await schema.actions.create(updatedEntity);\n\n return { updatedEntity: newEntity };\n },\n fetch: async () => {\n if (!entityId) {\n return { entity: undefined };\n }\n const entity = await schema.actions.get(entityId);\n return { entity };\n },\n });\n\n const entity = useEntity(state);\n\n const { title, subtitle } = useEntityPageHeaderTexts({\n config: configuration,\n isCreateMode,\n entityDisplayName: entity?.[schema.displayField],\n });\n\n const sdk = useActionsSDK({\n collectionId,\n });\n\n const resolvedMoreActions = useEntityPageMoreActions(\n moreActions,\n entity,\n sdk,\n form,\n );\n\n return (\n <EntityPage state={state} dataHook=\"auto-patterns-entity-page\">\n <EntityPage.Header\n title={title}\n subtitle={subtitle}\n moreActions={\n resolvedMoreActions.length > 0 ? (\n <MoreActions items={resolvedMoreActions} />\n ) : undefined\n }\n />\n <EntityPage.Content>\n <EntityPage.MainContent dataHook=\"entity-page-main-content\">\n {pageLayout?.main?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`main-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"main\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.MainContent>\n {pageLayout?.sidebar ? (\n <EntityPage.AdditionalContent>\n {pageLayout.sidebar?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`sidebar-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"sidebar\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.AdditionalContent>\n ) : null}\n </EntityPage.Content>\n </EntityPage>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC9C,SACEC,UAAU,EAEVC,SAAS,EACTC,aAAa,EACbC,WAAW,QACN,eAAe;AACtB,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAAS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AAO,CAAC;IACnB;EACF,CAAC,CAAC;EAEF,MAAMA,MAAM,GAAGpD,SAAS,CAAC+C,KAAK,CAAC;EAE/B,MAAM;IAAEa,KAAK;IAAEC;EAAS,CAAC,GAAGvD,wBAAwB,CAAC;IACnDwD,MAAM,EAAE/C,aAAa;IACrBc,YAAY;IACZkC,iBAAiB,EAAEX,MAAM,oBAANA,MAAM,CAAGxB,MAAM,CAACoC,YAAY;
|
|
1
|
+
{"version":3,"names":["React","useMemo","useRef","EntityPage","useEntity","useEntityPage","MoreActions","useForm","useParams","useSchema","useEntityPageHeaderTexts","useNavigation","useEntityPageMoreActions","useActionsSDK","RenderLayoutCard","EditModeEntityPage","_ref","_pageLayout$main","_pageLayout$sidebar","configuration","layout","pageLayout","parentPageId","route","actions","collectionId","moreActions","form","mode","params","entityId","id","schema","isCreateMode","inputRefs","setInputRef","input","current","validate","invalidFieldId","Object","keys","find","fieldId","_inputRefs$current$fi","invalid","_inputRefs$current$in","focus","Error","getParentPagePath","parentPath","state","onSave","formValues","getValues","baseEntity","entity","updatedEntity","newEntity","update","create","fetch","undefined","get","title","subtitle","config","entityDisplayName","displayField","sdk","resolvedMoreActions","createElement","dataHook","Header","length","items","Content","MainContent","main","map","layoutIndex","key","sectionId","cardIndex","sidebar","AdditionalContent"],"sources":["../../../../src/components/AutoPatternsEntityPage/EditModeEntityPage.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport {\n EntityPage,\n EntityPageState,\n useEntity,\n useEntityPage,\n MoreActions,\n} from '@wix/patterns';\nimport { useForm } from '@wix/patterns/form';\nimport { useParams } from 'react-router-dom';\nimport { useSchema } from '../../providers/SchemaContext';\nimport { BaseInputRef } from './Fields/types';\nimport { useEntityPageHeaderTexts, useNavigation } from '../../hooks';\nimport { useEntityPageMoreActions } from '../../hooks/useEntityPageMoreActions';\nimport { useActionsSDK } from '../../hooks/useActionsSDK';\nimport { RenderLayoutCard } from './RenderLayout';\nimport { EditEntityPageConfig } from '../../types';\n\nexport const EditModeEntityPage: React.FC<{\n configuration: EditEntityPageConfig;\n}> = ({ configuration }) => {\n const {\n layout: pageLayout,\n parentPageId,\n route,\n actions,\n collectionId,\n } = configuration;\n\n const moreActions = actions?.moreActions;\n\n const form = useForm<any>({\n mode: 'onChange',\n });\n const params = useParams();\n const entityId = params[route.params.id];\n const schema = useSchema();\n const isCreateMode = !entityId;\n\n const inputRefs = useRef<{ [fieldId: string]: BaseInputRef }>({});\n\n const setInputRef = (id: string, input: BaseInputRef) => {\n inputRefs.current[id] = input;\n };\n\n const validate = () => {\n const invalidFieldId = Object.keys(inputRefs.current).find((fieldId) => {\n return inputRefs.current[fieldId]?.invalid;\n });\n\n if (invalidFieldId) {\n inputRefs.current[invalidFieldId]?.focus?.();\n throw new Error('Invalid form');\n }\n };\n const { getParentPagePath } = useNavigation();\n\n const parentPath = useMemo(\n () => getParentPagePath(parentPageId),\n [parentPageId, getParentPagePath],\n );\n\n const state: EntityPageState<any> = useEntityPage<any, any>({\n parentPath,\n form,\n onSave: async () => {\n validate();\n\n const formValues = form.getValues();\n const baseEntity = state.entity || {};\n const updatedEntity = {\n ...baseEntity,\n ...formValues,\n };\n\n const newEntity = entityId\n ? await schema.actions.update(updatedEntity)\n : await schema.actions.create(updatedEntity);\n\n return { updatedEntity: newEntity };\n },\n fetch: async () => {\n if (!entityId) {\n return { entity: undefined };\n }\n const entity = await schema.actions.get(entityId);\n return { entity };\n },\n });\n\n const entity = useEntity(state);\n\n const { title, subtitle } = useEntityPageHeaderTexts({\n config: configuration,\n isCreateMode,\n entityDisplayName: entity?.[schema.displayField],\n entity,\n });\n\n const sdk = useActionsSDK({\n collectionId,\n });\n\n const resolvedMoreActions = useEntityPageMoreActions(\n moreActions,\n entity,\n sdk,\n form,\n );\n\n return (\n <EntityPage state={state} dataHook=\"auto-patterns-entity-page\">\n <EntityPage.Header\n title={title}\n subtitle={subtitle}\n moreActions={\n resolvedMoreActions.length > 0 ? (\n <MoreActions items={resolvedMoreActions} />\n ) : undefined\n }\n />\n <EntityPage.Content>\n <EntityPage.MainContent dataHook=\"entity-page-main-content\">\n {pageLayout?.main?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`main-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"main\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.MainContent>\n {pageLayout?.sidebar ? (\n <EntityPage.AdditionalContent>\n {pageLayout.sidebar?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`sidebar-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"sidebar\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.AdditionalContent>\n ) : null}\n </EntityPage.Content>\n </EntityPage>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC9C,SACEC,UAAU,EAEVC,SAAS,EACTC,aAAa,EACbC,WAAW,QACN,eAAe;AACtB,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,QAAQ,+BAA+B;AAEzD,SAASC,wBAAwB,EAAEC,aAAa,QAAQ,aAAa;AACrE,SAASC,wBAAwB,QAAQ,sCAAsC;AAC/E,SAASC,aAAa,QAAQ,2BAA2B;AACzD,SAASC,gBAAgB,QAAQ,gBAAgB;AAGjD,OAAO,MAAMC,kBAEX,GAAGC,IAAA,IAAuB;EAAA,IAAAC,gBAAA,EAAAC,mBAAA;EAAA,IAAtB;IAAEC;EAAc,CAAC,GAAAH,IAAA;EACrB,MAAM;IACJI,MAAM,EAAEC,UAAU;IAClBC,YAAY;IACZC,KAAK;IACLC,OAAO;IACPC;EACF,CAAC,GAAGN,aAAa;EAEjB,MAAMO,WAAW,GAAGF,OAAO,oBAAPA,OAAO,CAAEE,WAAW;EAExC,MAAMC,IAAI,GAAGpB,OAAO,CAAM;IACxBqB,IAAI,EAAE;EAC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 -1,17 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import { Page, Heading, Box, Layout, Cell, Badge } from '@wix/design-system';
|
|
4
4
|
import { useParams } from 'react-router-dom';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { RenderViewLayoutCard } from './ViewEntityPage/RenderViewLayoutCard';
|
|
6
|
+
import { useSchema } from '../../providers/SchemaContext';
|
|
7
|
+
import { useNavigation } from '../../hooks';
|
|
7
8
|
import { MoreActions } from '@wix/patterns';
|
|
8
9
|
import { useEntityPageActions } from '../../hooks/useEntityPageActions';
|
|
9
10
|
import { useEntityPageMoreActions } from '../../hooks/useEntityPageMoreActions';
|
|
10
11
|
import { useActionsSDK } from '../../hooks/useActionsSDK';
|
|
11
12
|
import { useNavigateEditEntityAction } from '../../hooks/useNavigateEditEntityAction';
|
|
13
|
+
import { useEntityPageHeaderTexts } from '../../hooks/useEntityPageHeaderTexts';
|
|
14
|
+
import { SkeletonEntity } from './SkeletonEntity';
|
|
12
15
|
// TODO: temp solution until we have a proper view mode entity page
|
|
13
16
|
export const ViewModeEntityPage = _ref => {
|
|
14
|
-
var
|
|
17
|
+
var _pageLayout$main, _pageLayout$sidebar;
|
|
15
18
|
let {
|
|
16
19
|
configuration
|
|
17
20
|
} = _ref;
|
|
@@ -45,14 +48,16 @@ export const ViewModeEntityPage = _ref => {
|
|
|
45
48
|
isMounted = false;
|
|
46
49
|
};
|
|
47
50
|
}, [entityId, schema]);
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
const {
|
|
52
|
+
title,
|
|
53
|
+
subtitle
|
|
54
|
+
} = useEntityPageHeaderTexts({
|
|
55
|
+
config: configuration,
|
|
56
|
+
isCreateMode: false,
|
|
57
|
+
isViewMode: true,
|
|
58
|
+
entityDisplayName: entity == null ? void 0 : entity[schema.displayField],
|
|
59
|
+
entity
|
|
60
|
+
});
|
|
56
61
|
const sdk = useActionsSDK({
|
|
57
62
|
collectionId: configuration.collectionId
|
|
58
63
|
});
|
|
@@ -68,14 +73,36 @@ export const ViewModeEntityPage = _ref => {
|
|
|
68
73
|
configuration
|
|
69
74
|
});
|
|
70
75
|
const resolvedMoreActions = useEntityPageMoreActions(moreActions, entity, sdk);
|
|
76
|
+
const renderTitle = () => {
|
|
77
|
+
const {
|
|
78
|
+
text,
|
|
79
|
+
badges
|
|
80
|
+
} = title;
|
|
81
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
82
|
+
gap: "SP2",
|
|
83
|
+
verticalAlign: "middle",
|
|
84
|
+
alignContent: "center"
|
|
85
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
86
|
+
size: "extraLarge"
|
|
87
|
+
}, text), badges && badges.length > 0 && /*#__PURE__*/React.createElement(Box, {
|
|
88
|
+
gap: "SP2"
|
|
89
|
+
}, badges.map((badge, index) => /*#__PURE__*/React.createElement(Badge, _extends({
|
|
90
|
+
key: index
|
|
91
|
+
}, badge, {
|
|
92
|
+
dataHook: `form-page-header-badge-${index}`
|
|
93
|
+
}), badge.text))));
|
|
94
|
+
};
|
|
95
|
+
if (!entity) {
|
|
96
|
+
return /*#__PURE__*/React.createElement(SkeletonEntity, {
|
|
97
|
+
entityPage: configuration
|
|
98
|
+
});
|
|
99
|
+
}
|
|
71
100
|
return /*#__PURE__*/React.createElement(Page, {
|
|
72
101
|
dataHook: "view-mode-entity-page"
|
|
73
102
|
}, /*#__PURE__*/React.createElement(Page.Header, {
|
|
74
103
|
dataHook: "view-mode-entity-page-header",
|
|
75
|
-
title:
|
|
76
|
-
|
|
77
|
-
}, title),
|
|
78
|
-
subtitle: subtitle,
|
|
104
|
+
title: renderTitle(),
|
|
105
|
+
subtitle: subtitle == null ? void 0 : subtitle.text,
|
|
79
106
|
showBackButton: true,
|
|
80
107
|
onBackClicked: () => navigateToCollectionPage(configuration.parentPageId),
|
|
81
108
|
actionsBar: /*#__PURE__*/React.createElement(Box, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useMemo","useState","Box","Cell","Heading","Layout","Page","RenderViewLayoutCard","useParams","useSchema","useNavigation","MoreActions","useEntityPageActions","useEntityPageMoreActions","useActionsSDK","useNavigateEditEntityAction","ViewModeEntityPage","_ref","_configuration$subtit","_pageLayout$main","_pageLayout$sidebar","configuration","route","params","entityId","id","schema","layout","pageLayout","navigateToCollectionPage","entity","setEntity","undefined","isMounted","fetchEntity","fetchedEntity","actions","get","title","text","displayField","subtitle","sdk","collectionId","entityPageActions","moreActions","displayName","resolvedMoreActions","createElement","dataHook","Header","size","showBackButton","onBackClicked","parentPageId","actionsBar","gap","length","items","Content","span","sidebar","direction","main","map","layoutIndex","key","sectionId","cardIndex"],"sources":["../../../../src/components/AutoPatternsEntityPage/ViewModeEntityPage.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport { ViewEntityPageConfig } from '../../types';\nimport { Box, Cell, Heading, Layout, Page } from '@wix/design-system';\nimport { RenderViewLayoutCard } from './ViewEntityPage/RenderViewLayoutCard';\nimport { useParams } from 'react-router-dom';\nimport { useSchema } from '../../providers';\nimport { useNavigation } from '../../hooks/useNavigationUtils';\nimport { MoreActions } from '@wix/patterns';\nimport { useEntityPageActions } from '../../hooks/useEntityPageActions';\nimport { useEntityPageMoreActions } from '../../hooks/useEntityPageMoreActions';\nimport { useActionsSDK } from '../../hooks/useActionsSDK';\nimport { useNavigateEditEntityAction } from '../../hooks/useNavigateEditEntityAction';\n\ninterface ViewModeEntityPageProps {\n configuration: ViewEntityPageConfig;\n}\n\n// TODO: temp solution until we have a proper view mode entity page\nexport const ViewModeEntityPage: React.FC<ViewModeEntityPageProps> = ({\n configuration,\n}) => {\n const { route } = configuration;\n const params = useParams();\n const entityId = params[route.params.id];\n const schema = useSchema();\n const { layout: pageLayout } = configuration;\n const { navigateToCollectionPage } = useNavigation();\n\n const [entity, setEntity] = useState<any>(undefined);\n\n useEffect(() => {\n let isMounted = true;\n const fetchEntity = async () => {\n if (!entityId) {\n setEntity(undefined);\n return;\n }\n const fetchedEntity = await schema.actions.get(entityId);\n if (isMounted) {\n setEntity(fetchedEntity);\n }\n };\n fetchEntity();\n return () => {\n isMounted = false;\n };\n }, [entityId, schema]);\n\n const title = useMemo(() => {\n if (configuration.title) {\n return configuration.title.text;\n } else {\n return entity?.[schema.displayField] ?? 'View Item';\n }\n }, [configuration.title, entity, schema.displayField]);\n\n const subtitle = configuration.subtitle?.text;\n\n const sdk = useActionsSDK({\n collectionId: configuration.collectionId,\n });\n\n const actions = useEntityPageActions({\n entityPageActions: configuration.actions,\n entity,\n sdk,\n });\n\n // add OOTB navigate to edit action\n const moreActions = useNavigateEditEntityAction({\n displayName: entity?.[schema.displayField],\n configuration,\n });\n\n const resolvedMoreActions = useEntityPageMoreActions(\n moreActions,\n entity,\n sdk,\n );\n\n return (\n <Page dataHook=\"view-mode-entity-page\">\n <Page.Header\n dataHook=\"view-mode-entity-page-header\"\n title={<Heading size=\"extraLarge\">{title}</Heading>}\n subtitle={subtitle}\n showBackButton\n onBackClicked={() =>\n navigateToCollectionPage(configuration.parentPageId!)\n }\n actionsBar={\n <Box gap=\"SP2\">\n {resolvedMoreActions.length > 0 ? (\n <MoreActions\n dataHook=\"view-mode-entity-page-more-actions\"\n items={resolvedMoreActions}\n />\n ) : undefined}\n {actions}\n </Box>\n }\n />\n <Page.Content>\n <Layout>\n <Cell span={pageLayout?.sidebar ? 8 : 12}>\n <Box direction=\"vertical\" gap=\"SP4\">\n {pageLayout?.main?.map((layout, layoutIndex) => (\n <RenderViewLayoutCard\n key={`main-section-card-${layoutIndex}`}\n entity={entity}\n layout={layout}\n sectionId=\"main\"\n cardIndex={layoutIndex}\n />\n ))}\n </Box>\n </Cell>\n {pageLayout?.sidebar ? (\n <Cell span={4}>\n <Box direction=\"vertical\" gap=\"SP4\">\n {pageLayout.sidebar?.map((layout, layoutIndex) => (\n <RenderViewLayoutCard\n key={`sidebar-section-card-${layoutIndex}`}\n entity={entity}\n layout={layout}\n sectionId=\"sidebar\"\n cardIndex={layoutIndex}\n />\n ))}\n </Box>\n </Cell>\n ) : null}\n </Layout>\n </Page.Content>\n </Page>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAE3D,SAASC,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAEC,IAAI,QAAQ,oBAAoB;AACrE,SAASC,oBAAoB,QAAQ,uCAAuC;AAC5E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,aAAa,QAAQ,gCAAgC;AAC9D,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,oBAAoB,QAAQ,kCAAkC;AACvE,SAASC,wBAAwB,QAAQ,sCAAsC;AAC/E,SAASC,aAAa,QAAQ,2BAA2B;AACzD,SAASC,2BAA2B,QAAQ,yCAAyC;AAMrF;AACA,OAAO,MAAMC,kBAAqD,GAAGC,IAAA,IAE/D;EAAA,IAAAC,qBAAA,EAAAC,gBAAA,EAAAC,mBAAA;EAAA,IAFgE;IACpEC;EACF,CAAC,GAAAJ,IAAA;EACC,MAAM;IAAEK;EAAM,CAAC,GAAGD,aAAa;EAC/B,MAAME,MAAM,GAAGf,SAAS,CAAC,CAAC;EAC1B,MAAMgB,QAAQ,GAAGD,MAAM,CAACD,KAAK,CAACC,MAAM,CAACE,EAAE,CAAC;EACxC,MAAMC,MAAM,GAAGjB,SAAS,CAAC,CAAC;EAC1B,MAAM;IAAEkB,MAAM,EAAEC;EAAW,CAAC,GAAGP,aAAa;EAC5C,MAAM;IAAEQ;EAAyB,CAAC,GAAGnB,aAAa,CAAC,CAAC;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AA,CAAkB6C,GAAG,CAAC,CAACrC,MAAM,EAAEsC,WAAW,kBACzCnE,KAAA,CAAAkD,aAAA,CAACzC,oBAAoB;IACnB2D,GAAG,EAAE,qBAAqBD,WAAW,EAAG;IACxCnC,MAAM,EAAEA,MAAO;IACfH,MAAM,EAAEA,MAAO;IACfwC,SAAS,EAAC,MAAM;IAChBC,SAAS,EAAEH;EAAY,CACxB,CACF,CACE,CACD,CAAC,EACNrC,UAAU,YAAVA,UAAU,CAAEiC,OAAO,gBAClB/D,KAAA,CAAAkD,aAAA,CAAC7C,IAAI;IAACyD,IAAI,EAAE;EAAE,gBACZ9D,KAAA,CAAAkD,aAAA,CAAC9C,GAAG;IAAC4D,SAAS,EAAC,UAAU;IAACN,GAAG,EAAC;EAAK,IAAApC,mBAAA,GAChCQ,UAAU,CAACiC,OAAO,qBAAlBzC,mBAAA,CAAoB4C,GAAG,CAAC,CAACrC,MAAM,EAAEsC,WAAW,kBAC3CnE,KAAA,CAAAkD,aAAA,CAACzC,oBAAoB;IACnB2D,GAAG,EAAE,wBAAwBD,WAAW,EAAG;IAC3CnC,MAAM,EAAEA,MAAO;IACfH,MAAM,EAAEA,MAAO;IACfwC,SAAS,EAAC,SAAS;IACnBC,SAAS,EAAEH;EAAY,CACxB,CACF,CACE,CACD,CAAC,GACL,IACE,CACI,CACV,CAAC;AAEX,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useState","useEffect","Page","Heading","Box","Layout","Cell","Badge","useParams","RenderViewLayoutCard","useSchema","useNavigation","MoreActions","useEntityPageActions","useEntityPageMoreActions","useActionsSDK","useNavigateEditEntityAction","useEntityPageHeaderTexts","SkeletonEntity","ViewModeEntityPage","_ref","_pageLayout$main","_pageLayout$sidebar","configuration","route","params","entityId","id","schema","layout","pageLayout","navigateToCollectionPage","entity","setEntity","undefined","isMounted","fetchEntity","fetchedEntity","actions","get","title","subtitle","config","isCreateMode","isViewMode","entityDisplayName","displayField","sdk","collectionId","entityPageActions","moreActions","displayName","resolvedMoreActions","renderTitle","text","badges","createElement","gap","verticalAlign","alignContent","size","length","map","badge","index","_extends","key","dataHook","entityPage","Header","showBackButton","onBackClicked","parentPageId","actionsBar","items","Content","span","sidebar","direction","main","layoutIndex","sectionId","cardIndex"],"sources":["../../../../src/components/AutoPatternsEntityPage/ViewModeEntityPage.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { Page, Heading, Box, Layout, Cell, Badge } from '@wix/design-system';\nimport { useParams } from 'react-router-dom';\nimport { RenderViewLayoutCard } from './ViewEntityPage/RenderViewLayoutCard';\nimport { useSchema } from '../../providers/SchemaContext';\nimport { useNavigation } from '../../hooks';\nimport { MoreActions } from '@wix/patterns';\nimport { useEntityPageActions } from '../../hooks/useEntityPageActions';\nimport { useEntityPageMoreActions } from '../../hooks/useEntityPageMoreActions';\nimport { useActionsSDK } from '../../hooks/useActionsSDK';\nimport { useNavigateEditEntityAction } from '../../hooks/useNavigateEditEntityAction';\nimport { useEntityPageHeaderTexts } from '../../hooks/useEntityPageHeaderTexts';\nimport { ViewEntityPageConfig } from '../../types';\nimport { SkeletonEntity } from './SkeletonEntity';\n\ninterface ViewModeEntityPageProps {\n configuration: ViewEntityPageConfig;\n}\n\n// TODO: temp solution until we have a proper view mode entity page\nexport const ViewModeEntityPage: React.FC<ViewModeEntityPageProps> = ({\n configuration,\n}) => {\n const { route } = configuration;\n const params = useParams();\n const entityId = params[route.params.id];\n const schema = useSchema();\n const { layout: pageLayout } = configuration;\n const { navigateToCollectionPage } = useNavigation();\n\n const [entity, setEntity] = useState<any>(undefined);\n\n useEffect(() => {\n let isMounted = true;\n const fetchEntity = async () => {\n if (!entityId) {\n setEntity(undefined);\n return;\n }\n const fetchedEntity = await schema.actions.get(entityId);\n if (isMounted) {\n setEntity(fetchedEntity);\n }\n };\n fetchEntity();\n return () => {\n isMounted = false;\n };\n }, [entityId, schema]);\n\n const { title, subtitle } = useEntityPageHeaderTexts({\n config: configuration,\n isCreateMode: false,\n isViewMode: true,\n entityDisplayName: entity?.[schema.displayField],\n entity,\n });\n\n const sdk = useActionsSDK({\n collectionId: configuration.collectionId,\n });\n\n const actions = useEntityPageActions({\n entityPageActions: configuration.actions,\n entity,\n sdk,\n });\n\n // add OOTB navigate to edit action\n const moreActions = useNavigateEditEntityAction({\n displayName: entity?.[schema.displayField],\n configuration,\n });\n\n const resolvedMoreActions = useEntityPageMoreActions(\n moreActions,\n entity,\n sdk,\n );\n\n const renderTitle = () => {\n const { text, badges } = title;\n\n return (\n <Box gap=\"SP2\" verticalAlign=\"middle\" alignContent=\"center\">\n <Heading size=\"extraLarge\">{text}</Heading>\n {badges && badges.length > 0 && (\n <Box gap=\"SP2\">\n {badges.map((badge, index) => (\n <Badge\n key={index}\n {...badge}\n dataHook={`form-page-header-badge-${index}`}\n >\n {badge.text}\n </Badge>\n ))}\n </Box>\n )}\n </Box>\n );\n };\n\n if (!entity) {\n return <SkeletonEntity entityPage={configuration} />;\n }\n return (\n <Page dataHook=\"view-mode-entity-page\">\n <Page.Header\n dataHook=\"view-mode-entity-page-header\"\n title={renderTitle()}\n subtitle={subtitle?.text}\n showBackButton\n onBackClicked={() =>\n navigateToCollectionPage(configuration.parentPageId!)\n }\n actionsBar={\n <Box gap=\"SP2\">\n {resolvedMoreActions.length > 0 ? (\n <MoreActions\n dataHook=\"view-mode-entity-page-more-actions\"\n items={resolvedMoreActions}\n />\n ) : undefined}\n {actions}\n </Box>\n }\n />\n <Page.Content>\n <Layout>\n <Cell span={pageLayout?.sidebar ? 8 : 12}>\n <Box direction=\"vertical\" gap=\"SP4\">\n {pageLayout?.main?.map((layout, layoutIndex) => (\n <RenderViewLayoutCard\n key={`main-section-card-${layoutIndex}`}\n entity={entity}\n layout={layout}\n sectionId=\"main\"\n cardIndex={layoutIndex}\n />\n ))}\n </Box>\n </Cell>\n {pageLayout?.sidebar ? (\n <Cell span={4}>\n <Box direction=\"vertical\" gap=\"SP4\">\n {pageLayout.sidebar?.map((layout, layoutIndex) => (\n <RenderViewLayoutCard\n key={`sidebar-section-card-${layoutIndex}`}\n entity={entity}\n layout={layout}\n sectionId=\"sidebar\"\n cardIndex={layoutIndex}\n />\n ))}\n </Box>\n </Cell>\n ) : null}\n </Layout>\n </Page.Content>\n </Page>\n );\n};\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,SAASC,IAAI,EAAEC,OAAO,EAAEC,GAAG,EAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,QAAQ,oBAAoB;AAC5E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,oBAAoB,QAAQ,uCAAuC;AAC5E,SAASC,SAAS,QAAQ,+BAA+B;AACzD,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,oBAAoB,QAAQ,kCAAkC;AACvE,SAASC,wBAAwB,QAAQ,sCAAsC;AAC/E,SAASC,aAAa,QAAQ,2BAA2B;AACzD,SAASC,2BAA2B,QAAQ,yCAAyC;AACrF,SAASC,wBAAwB,QAAQ,sCAAsC;AAE/E,SAASC,cAAc,QAAQ,kBAAkB;AAMjD;AACA,OAAO,MAAMC,kBAAqD,GAAGC,IAAA,IAE/D;EAAA,IAAAC,gBAAA,EAAAC,mBAAA;EAAA,IAFgE;IACpEC;EACF,CAAC,GAAAH,IAAA;EACC,MAAM;IAAEI;EAAM,CAAC,GAAGD,aAAa;EAC/B,MAAME,MAAM,GAAGjB,SAAS,CAAC,CAAC;EAC1B,MAAMkB,QAAQ,GAAGD,MAAM,CAACD,KAAK,CAACC,MAAM,CAACE,EAAE,CAAC;EACxC,MAAMC,MAAM,GAAGlB,SAAS,CAAC,CAAC;EAC1B,MAAM;IAAEmB,MAAM,EAAEC;EAAW,CAAC,GAAGP,aAAa;EAC5C,MAAM;IAAEQ;EAAyB,CAAC,GAAGpB,aAAa,CAAC,CAAC;EAEpD,MAAM,CAACqB,MAAM,EAAEC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3ChD,MAAM,EAAEA,MAAO;IACfH,MAAM,EAAEA,MAAO;IACfoD,SAAS,EAAC,SAAS;IACnBC,SAAS,EAAEF;EAAY,CACxB,CACF,CACE,CACD,CAAC,GACL,IACE,CACI,CACV,CAAC;AAEX,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,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OhC,KAAA,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,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CAAC1C,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,22 +1,61 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
+
import { usePatternsWizardOverridesContext } from '../providers/PatternsWizardOverridesContext';
|
|
2
3
|
export const useEntityPageHeaderTexts = _ref => {
|
|
4
|
+
var _config$title2;
|
|
3
5
|
let {
|
|
4
6
|
config,
|
|
5
7
|
isCreateMode,
|
|
6
|
-
|
|
8
|
+
isViewMode,
|
|
9
|
+
entityDisplayName,
|
|
10
|
+
entity
|
|
7
11
|
} = _ref;
|
|
8
|
-
const
|
|
12
|
+
const overrides = usePatternsWizardOverridesContext();
|
|
13
|
+
const titleText = useMemo(() => {
|
|
9
14
|
if (config.title) {
|
|
10
|
-
return config.title;
|
|
15
|
+
return config.title.text;
|
|
11
16
|
} else {
|
|
12
|
-
return
|
|
13
|
-
text: isCreateMode ? 'Create New Item' : entityDisplayName ?? 'Edit Item'
|
|
14
|
-
};
|
|
17
|
+
return isCreateMode ? 'Create New Item' : isViewMode ? entityDisplayName ?? 'View Item' : entityDisplayName ?? 'Edit Item';
|
|
15
18
|
}
|
|
16
|
-
}, [config.title, entityDisplayName, isCreateMode]);
|
|
17
|
-
const subtitle = useMemo(() =>
|
|
19
|
+
}, [config.title, entityDisplayName, isCreateMode, isViewMode]);
|
|
20
|
+
const subtitle = useMemo(() => {
|
|
21
|
+
if (!config.subtitle) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
if (entity && overrides != null && overrides.entityPageHeaderSubtitle && config.subtitle.id) {
|
|
25
|
+
const subtitleOverride = overrides.entityPageHeaderSubtitle[config.subtitle.id];
|
|
26
|
+
if (subtitleOverride) {
|
|
27
|
+
const overrideResult = subtitleOverride(entity);
|
|
28
|
+
return {
|
|
29
|
+
...config.subtitle,
|
|
30
|
+
...overrideResult
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
...config.subtitle,
|
|
36
|
+
text: config.subtitle.text ?? ''
|
|
37
|
+
};
|
|
38
|
+
}, [config.subtitle, entity, overrides == null ? void 0 : overrides.entityPageHeaderSubtitle]);
|
|
39
|
+
const badges = useMemo(() => {
|
|
40
|
+
var _config$title;
|
|
41
|
+
if (!((_config$title = config.title) != null && _config$title.badges)) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
// If badges has an id, try to resolve it dynamically
|
|
45
|
+
if (entity && overrides != null && overrides.entityPageHeaderBadges && config.title.badges.id) {
|
|
46
|
+
const badgesOverride = overrides.entityPageHeaderBadges[config.title.badges.id];
|
|
47
|
+
if (badgesOverride) {
|
|
48
|
+
const overrideBadges = badgesOverride(entity);
|
|
49
|
+
return overrideBadges;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}, [(_config$title2 = config.title) == null ? void 0 : _config$title2.badges, entity, overrides == null ? void 0 : overrides.entityPageHeaderBadges]);
|
|
18
54
|
return {
|
|
19
|
-
title
|
|
55
|
+
title: {
|
|
56
|
+
text: titleText,
|
|
57
|
+
badges
|
|
58
|
+
},
|
|
20
59
|
subtitle
|
|
21
60
|
};
|
|
22
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useEntityPageHeaderTexts","_ref","config","isCreateMode","entityDisplayName","title","text","subtitle"],"sources":["../../../src/hooks/useEntityPageHeaderTexts.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { EntityPageConfig } from '../types';\n\nexport const useEntityPageHeaderTexts = ({\n config,\n isCreateMode,\n entityDisplayName,\n}: {\n config: EntityPageConfig;\n isCreateMode: boolean;\n entityDisplayName?: string;\n}) => {\n const
|
|
1
|
+
{"version":3,"names":["useMemo","usePatternsWizardOverridesContext","useEntityPageHeaderTexts","_ref","_config$title2","config","isCreateMode","isViewMode","entityDisplayName","entity","overrides","titleText","title","text","subtitle","undefined","entityPageHeaderSubtitle","id","subtitleOverride","overrideResult","badges","_config$title","entityPageHeaderBadges","badgesOverride","overrideBadges"],"sources":["../../../src/hooks/useEntityPageHeaderTexts.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { EntityPageConfig } from '../types';\nimport { usePatternsWizardOverridesContext } from '../providers/PatternsWizardOverridesContext';\n\nexport const useEntityPageHeaderTexts = ({\n config,\n isCreateMode,\n isViewMode,\n entityDisplayName,\n entity,\n}: {\n config: EntityPageConfig;\n isCreateMode: boolean;\n isViewMode?: boolean;\n entityDisplayName?: string;\n entity?: Record<string, any>;\n}) => {\n const overrides = usePatternsWizardOverridesContext();\n\n const titleText = useMemo(() => {\n if (config.title) {\n return config.title.text;\n } else {\n return isCreateMode\n ? 'Create New Item'\n : isViewMode\n ? entityDisplayName ?? 'View Item'\n : entityDisplayName ?? 'Edit Item';\n }\n }, [config.title, entityDisplayName, isCreateMode, isViewMode]);\n\n const subtitle = useMemo(() => {\n if (!config.subtitle) {\n return undefined;\n }\n\n if (entity && overrides?.entityPageHeaderSubtitle && config.subtitle.id) {\n const subtitleOverride =\n overrides.entityPageHeaderSubtitle[config.subtitle.id];\n if (subtitleOverride) {\n const overrideResult = subtitleOverride(entity);\n return {\n ...config.subtitle,\n ...overrideResult,\n };\n }\n }\n\n return {\n ...config.subtitle,\n text: config.subtitle.text ?? '',\n };\n }, [config.subtitle, entity, overrides?.entityPageHeaderSubtitle]);\n\n const badges = useMemo(() => {\n if (!config.title?.badges) {\n return undefined;\n }\n // If badges has an id, try to resolve it dynamically\n if (entity && overrides?.entityPageHeaderBadges && config.title.badges.id) {\n const badgesOverride =\n overrides.entityPageHeaderBadges[config.title.badges.id];\n if (badgesOverride) {\n const overrideBadges = badgesOverride(entity);\n return overrideBadges;\n }\n }\n\n return undefined;\n }, [config.title?.badges, entity, overrides?.entityPageHeaderBadges]);\n\n return { title: { text: titleText, badges }, subtitle };\n};\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAE/B,SAASC,iCAAiC,QAAQ,6CAA6C;AAE/F,OAAO,MAAMC,wBAAwB,GAAGC,IAAA,IAYlC;EAAA,IAAAC,cAAA;EAAA,IAZmC;IACvCC,MAAM;IACNC,YAAY;IACZC,UAAU;IACVC,iBAAiB;IACjBC;EAOF,CAAC,GAAAN,IAAA;EACC,MAAMO,SAAS,GAAGT,iCAAiC,CAAC,CAAC;EAErD,MAAMU,SAAS,GAAGX,OAAO,CAAC,MAAM;IAC9B,IAAIK,MAAM,CAACO,KAAK,EAAE;MAChB,OAAOP,MAAM,CAACO,KAAK,CAACC,IAAI;IAC1B,CAAC,MAAM;MACL,OAAOP,YAAY,GACf,iBAAiB,GACjBC,UAAU,GACVC,iBAAiB,IAAI,WAAW,GAChCA,iBAAiB,IAAI,WAAW;IACtC;EACF,CAAC,EAAE,CAACH,MAAM,CAACO,KAAK,EAAEJ,iBAAiB,EAAEF,YAAY,EAAEC,UAAU,CAAC,CAAC;EAE/D,MAAMO,QAAQ,GAAGd,OAAO,CAAC,MAAM;IAC7B,IAAI,CAACK,MAAM,CAACS,QAAQ,EAAE;MACpB,OAAOC,SAAS;IAClB;IAEA,IAAIN,MAAM,IAAIC,SAAS,YAATA,SAAS,CAAEM,wBAAwB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AAEC,IAAI,EAAEF,SAAS;MAAES;IAAO,CAAC;IAAEN;EAAS,CAAC;AACzD,CAAC","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;EAEpC,MAAM;IAAEW,eAAe;IAAEC,aAAa;IAAEC;EAAmB,CAAC,GAAGnB,UAAU,CACvEM,aAAa,CAACc,OAChB,CAAC;EAED,MAAM;IAAEC;EAAU,CAAC,GAAGzB,YAAY,CAAC;IACjC0B,kBAAkB,EAAEN,eAAe;IACnCG;EACF,CAAC,CAAC;EAEF,MAAMI,MAAM,GAAGtB,SAAS,CAAC,CAAC;EAE1B,MAAMuB,KAAK,GAAG3B,iBAAiB,CAAM;IACnC4B,SAAS,EAAE,GAAGlB,YAAY,EAAE;IAC5BmB,OAAO,EAAGC,QAAQ,IAAKA,QAAQ,CAACJ,MAAM,CAACK,OAAO,CAAC;IAC/CC,QAAQ,EAAGF,QAAQ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