@wix/auto-patterns 1.22.0 → 1.23.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/hooks/useActionCell.js.map +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/cjs/types/actions/base.js.map +1 -1
- package/dist/docs/app_config_structure.md +0 -3
- package/dist/docs/auto-patterns-guide.md +87 -22
- package/dist/docs/bulk_actions.md +1 -4
- package/dist/docs/custom_overrides.md +86 -15
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +3 -4
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +1 -2
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +8 -13
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js +6 -10
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js +16 -23
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js +2 -3
- package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js +6 -9
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js +6 -8
- package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js +8 -10
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js +10 -12
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js +6 -8
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js +4 -7
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -1
- package/dist/esm/components/ModalRenderer.js +1 -2
- package/dist/esm/components/ModalRenderer.js.map +1 -1
- package/dist/esm/components/modals/actions/BulkDeleteModal.js +7 -12
- package/dist/esm/components/modals/actions/BulkDeleteModal.js.map +1 -1
- package/dist/esm/components/modals/actions/CreateModal.js +6 -11
- package/dist/esm/components/modals/actions/CreateModal.js.map +1 -1
- package/dist/esm/components/modals/actions/EditModal.js +6 -11
- package/dist/esm/components/modals/actions/EditModal.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +3 -4
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js +1 -2
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/sortUtils.js +2 -2
- package/dist/esm/dataSourceAdapters/cms/sortUtils.js.map +1 -1
- package/dist/esm/hooks/useActionCell.js +8 -12
- package/dist/esm/hooks/useActionCell.js.map +1 -1
- package/dist/esm/hooks/useBaseTableFeatures.js +1 -2
- package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useBulkActionToolbar.js +2 -2
- package/dist/esm/hooks/useBulkActionToolbar.js.map +1 -1
- package/dist/esm/hooks/useCollectionPageActions.js +3 -3
- package/dist/esm/hooks/useCollectionPageActions.js.map +1 -1
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js +1 -1
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js.map +1 -1
- package/dist/esm/hooks/useColumns.js +7 -12
- package/dist/esm/hooks/useColumns.js.map +1 -1
- package/dist/esm/hooks/useCommonCollectionFeatures.js +7 -8
- package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
- package/dist/esm/hooks/useEmptyStates.js +5 -6
- package/dist/esm/hooks/useEmptyStates.js.map +1 -1
- package/dist/esm/hooks/useFilters.js +7 -7
- package/dist/esm/hooks/useFilters.js.map +1 -1
- package/dist/esm/hooks/useNavigationUtils.js +2 -3
- package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
- package/dist/esm/hooks/usePagePath.js +3 -4
- package/dist/esm/hooks/usePagePath.js.map +1 -1
- package/dist/esm/hooks/useTableFeatures.js +1 -2
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/esm/providers/SchemaContext.js +2 -3
- package/dist/esm/providers/SchemaContext.js.map +1 -1
- package/dist/esm/providers/SchemaRegistryContext.js +1 -1
- package/dist/esm/providers/SchemaRegistryContext.js.map +1 -1
- package/dist/esm/types/actions/base.js.map +1 -1
- package/dist/esm/utils/actions/customAction.js +1 -2
- package/dist/esm/utils/actions/customAction.js.map +1 -1
- package/dist/esm/utils/actions/deleteAction.js +5 -10
- package/dist/esm/utils/actions/deleteAction.js.map +1 -1
- package/dist/esm/utils/filterCreators.js +11 -11
- package/dist/esm/utils/filterCreators.js.map +1 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -5
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
- package/dist/types/types/actions/base.d.ts +0 -4
- package/dist/types/types/actions/base.d.ts.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_useActionsSDK","_actions","cleanupActionsWithDividers","actions","inlineCount","clean","a","filter","x","i","ar","_ar","divider","length","slice","useActionCell","config","collectionId","sdk","useActionsSDK","buildCellActions","useCallback","item","index","api","_config$primaryAction","_config$primaryAction2","_config$secondaryActi","_config$secondaryActi2","_config$secondaryActi3","_config$secondaryActi4","buildAction","actionConfig","type","actionToResolve","baseParams","actionParams","updateAction","action","deleteAction","customAction","resolvedAction","resolveAction","label","tooltip","resolvedActionProps","text","disabledDescription","primaryAction","undefined","primaryActionProps","alwaysVisible","visibility","rawSecondaryActions","secondaryActions","items","map","Boolean","numOfVisibleSecondaryActions","alwaysShowSecondaryActions","inlineAlwaysVisible","exports"],"sources":["../../../src/hooks/useActionCell.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport {\n ActionCellConfig,\n ActionCellItemConfig,\n ResolvedAction,\n} from '../types';\nimport { useActionsSDK } from './useActionsSDK';\nimport {\n updateAction,\n customAction,\n resolveAction,\n deleteAction,\n} from '../utils/actions';\nimport { DividerActionConfig } from '../types/actions/base';\n\nexport interface useActionCellParams {\n config?: ActionCellConfig;\n collectionId: string;\n}\n\nconst cleanupActionsWithDividers = (\n actions: any[],\n inlineCount?: number,\n): any[] => {\n const clean = (a: any[]) =>\n a.filter(\n (x, i, ar) =>\n x?.divider !== true ||\n (i > 0 && i < ar.length - 1 && ar[i - 1]?.divider !== true),\n );\n return !actions?.length || !inlineCount || inlineCount >= actions.length\n ? clean(actions || [])\n : [\n
|
|
1
|
+
{"version":3,"names":["_react","require","_useActionsSDK","_actions","cleanupActionsWithDividers","actions","inlineCount","clean","a","filter","x","i","ar","_ar","divider","length","slice","useActionCell","config","collectionId","sdk","useActionsSDK","buildCellActions","useCallback","item","index","api","_config$primaryAction","_config$primaryAction2","_config$secondaryActi","_config$secondaryActi2","_config$secondaryActi3","_config$secondaryActi4","buildAction","actionConfig","type","actionToResolve","baseParams","actionParams","updateAction","action","deleteAction","customAction","resolvedAction","resolveAction","label","tooltip","resolvedActionProps","text","disabledDescription","primaryAction","undefined","primaryActionProps","alwaysVisible","visibility","rawSecondaryActions","secondaryActions","items","map","Boolean","numOfVisibleSecondaryActions","alwaysShowSecondaryActions","inlineAlwaysVisible","exports"],"sources":["../../../src/hooks/useActionCell.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport {\n ActionCellConfig,\n ActionCellItemConfig,\n ResolvedAction,\n} from '../types';\nimport { useActionsSDK } from './useActionsSDK';\nimport {\n updateAction,\n customAction,\n resolveAction,\n deleteAction,\n} from '../utils/actions';\nimport { DividerActionConfig } from '../types/actions/base';\n\nexport interface useActionCellParams {\n config?: ActionCellConfig;\n collectionId: string;\n}\n\nconst cleanupActionsWithDividers = (\n actions: any[],\n inlineCount?: number,\n): any[] => {\n const clean = (a: any[]) =>\n a.filter(\n (x, i, ar) =>\n x?.divider !== true ||\n (i > 0 && i < ar.length - 1 && ar[i - 1]?.divider !== true),\n );\n return !actions?.length || !inlineCount || inlineCount >= actions.length\n ? clean(actions || [])\n : [\n ...clean(actions.slice(0, inlineCount)),\n ...clean(actions.slice(inlineCount)),\n ];\n};\n\nexport const useActionCell = ({\n config,\n collectionId,\n}: useActionCellParams) => {\n const sdk = useActionsSDK({\n collectionId,\n });\n\n const buildCellActions = useCallback(\n (item, index, api) => {\n const buildAction = (\n actionConfig: ActionCellItemConfig | DividerActionConfig,\n ) => {\n if (actionConfig.type === 'divider') {\n return { divider: true };\n }\n\n let actionToResolve: Partial<ResolvedAction> | null = null;\n\n const baseParams = {\n actionParams: { item, index, api },\n sdk,\n };\n\n switch (actionConfig.type) {\n case 'update':\n actionToResolve = updateAction({\n action: actionConfig,\n ...baseParams,\n });\n break;\n\n case 'delete':\n actionToResolve = deleteAction({\n action: actionConfig,\n ...baseParams,\n });\n break;\n\n case 'custom':\n actionToResolve = customAction({\n action: actionConfig,\n ...baseParams,\n });\n break;\n\n default:\n return null;\n }\n\n if (!actionToResolve) {\n return null;\n }\n\n const resolvedAction = resolveAction(actionConfig, actionToResolve);\n const { label, tooltip, ...resolvedActionProps } = resolvedAction;\n\n return {\n ...resolvedActionProps,\n text: resolvedAction.label,\n disabledDescription: resolvedAction.tooltip,\n };\n };\n\n const primaryAction = config?.primaryAction?.item\n ? buildAction(config.primaryAction.item)\n : undefined;\n\n const primaryActionProps = {\n ...(config?.primaryAction?.alwaysVisible\n ? { visibility: 'always' }\n : {}),\n };\n\n const rawSecondaryActions = config?.secondaryActions?.items.length\n ? config.secondaryActions.items.map(buildAction).filter(Boolean)\n : [];\n\n // Process secondary actions with inline count consideration\n const secondaryActions = cleanupActionsWithDividers(\n rawSecondaryActions,\n config?.secondaryActions?.inlineCount,\n );\n\n const numOfVisibleSecondaryActions =\n config?.secondaryActions?.inlineCount;\n const alwaysShowSecondaryActions =\n config?.secondaryActions?.inlineAlwaysVisible;\n\n if (!primaryAction && !secondaryActions.length) {\n return {};\n }\n\n return {\n ...(primaryAction\n ? {\n primaryAction: {\n ...primaryAction,\n ...primaryActionProps,\n },\n }\n : { primaryAction: undefined }),\n ...(secondaryActions.length && { secondaryActions }),\n numOfVisibleSecondaryActions,\n alwaysShowSecondaryActions,\n };\n },\n [config, sdk],\n );\n\n return buildCellActions;\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAaA,MAAMG,0BAA0B,GAAGA,CACjCC,OAAc,EACdC,WAAoB,KACV;EACV,MAAMC,KAAK,GAAIC,CAAQ,IACrBA,CAAC,CAACC,MAAM,CACN,CAACC,CAAC,EAAEC,CAAC,EAAEC,EAAE;IAAA,IAAAC,GAAA;IAAA,OACP,CAAAH,CAAC,oBAADA,CAAC,CAAEI,OAAO,MAAK,IAAI,IAClBH,CAAC,GAAG,CAAC,IAAIA,CAAC,GAAGC,EAAE,CAACG,MAAM,GAAG,CAAC,IAAI,EAAAF,GAAA,GAAAD,EAAE,CAACD,CAAC,GAAG,CAAC,CAAC,qBAATE,GAAA,CAAWC,OAAO,MAAK,IAAK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IAED,MAAMsD,4BAA4B,GAChC1C,MAAM,aAAAa,sBAAA,GAANb,MAAM,CAAEsC,gBAAgB,qBAAxBzB,sBAAA,CAA0BzB,WAAW;IACvC,MAAMuD,0BAA0B,GAC9B3C,MAAM,aAAAc,sBAAA,GAANd,MAAM,CAAEsC,gBAAgB,qBAAxBxB,sBAAA,CAA0B8B,mBAAmB;IAE/C,IAAI,CAACZ,aAAa,IAAI,CAACM,gBAAgB,CAACzC,MAAM,EAAE;MAC9C,OAAO,CAAC,CAAC;IACX;IAEA,OAAO;MACL,IAAImC,aAAa,GACb;QACEA,aAAa,EAAE;UACb,GAAGA,aAAa;UAChB,GAAGE;QACL;MACF,CAAC,GACD;QAAEF,aAAa,EAAEC;MAAU,CAAC,CAAC;MACjC,IAAIK,gBAAgB,CAACzC,MAAM,IAAI;QAAEyC;MAAiB,CAAC,CAAC;MACpDI,4BAA4B;MAC5BC;IACF,CAAC;EACH,CAAC,EACD,CAAC3C,MAAM,EAAEE,GAAG,CACd,CAAC;EAED,OAAOE,gBAAgB;AACzB,CAAC;AAACyC,OAAA,CAAA9C,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","PatternsWizardOverridesContext","createContext","undefined","PatternsWizardOverridesProvider","children","value","createElement","Provider","__self","__source","fileName","lineNumber","columnNumber","exports","usePatternsWizardOverridesContext","useContext"],"sources":["../../../src/providers/PatternsWizardOverridesContext.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode } from 'react';\nimport {\n CustomComponentProps,\n
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","PatternsWizardOverridesContext","createContext","undefined","PatternsWizardOverridesProvider","children","value","createElement","Provider","__self","__source","fileName","lineNumber","columnNumber","exports","usePatternsWizardOverridesContext","useContext"],"sources":["../../../src/providers/PatternsWizardOverridesContext.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode } from 'react';\nimport {\n CustomComponentProps,\n CustomActionCellActionResolver,\n CustomEntityPageMoreActionsActionResolver,\n CustomBulkActionsActionResolver,\n CustomActionCollectionPageActionResolver,\n CustomActionCollectionPageActionOnRowClickResolver,\n IColumnValue,\n SchemaConfig,\n} from '../types';\n\nimport { Section } from '@wix/patterns';\n\nexport interface PatternsWizardOverridesContextProps {\n actions?: Record<\n string,\n | CustomActionCellActionResolver\n | CustomBulkActionsActionResolver\n | CustomEntityPageMoreActionsActionResolver\n | CustomActionCollectionPageActionResolver\n | CustomActionCollectionPageActionOnRowClickResolver\n >;\n columns?: Record<string, (props: IColumnValue<any>) => void>;\n modals?: Record<string, React.FC<any>>;\n emptyState?: Record<string, () => void>;\n components?: Record<string, React.FC<CustomComponentProps>>;\n slots?: Record<string, React.FC>;\n customDataSources?: Record<\n string,\n (collectionId: string, context: any) => Promise<SchemaConfig>\n >;\n sections?: Record<string, (item: any) => Section>;\n}\n\nconst PatternsWizardOverridesContext = createContext<\n PatternsWizardOverridesContextProps | undefined\n>(undefined);\n\nexport const PatternsWizardOverridesProvider: React.FC<{\n children: ReactNode;\n value: PatternsWizardOverridesContextProps;\n}> = ({ children, value }) => {\n return (\n <PatternsWizardOverridesContext.Provider value={value}>\n {children}\n </PatternsWizardOverridesContext.Provider>\n );\n};\n\nexport const usePatternsWizardOverridesContext = ():\n | PatternsWizardOverridesContextProps\n | undefined => {\n return useContext(PatternsWizardOverridesContext);\n};\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAoE,IAAAC,YAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,m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B,CAACO,QAAQ;IAACF,KAAK,EAAEA,KAAM;IAAAG,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAA/B,YAAA;MAAAgC,UAAA;MAAAC,YAAA;IAAA;EAAA,GACnDR,QACsC,CAAC;AAE9C,CAAC;AAACS,OAAA,CAAAV,+BAAA,GAAAA,+BAAA;AAEK,MAAMW,iCAAiC,GAAGA,CAAA,KAEhC;EACf,OAAO,IAAAC,iBAAU,EAACf,8BAA8B,CAAC;AACnD,CAAC;AAACa,OAAA,CAAAC,iCAAA,GAAAA,iCAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../../src/types/actions/base.ts"],"sourcesContent":["export type DividerActionConfig = { type: 'divider' };\n\nexport type BaseActionItemConfig = {\n id: string;\n label?: string;\n skin?: string;\n};\n\nexport interface Feedback {\n successToast?: { text: string };\n errorToast?: { text: string };\n}\n\nexport interface BaseActionModal {\n title?: { text: string };\n actions?: {\n submit?: { text: string };\n cancel?: { text: string };\n };\n feedback?: Feedback;\n}\n\nexport interface ActionModalField {\n id: string;\n label?: string;\n}\n\nexport interface DeleteActionModal extends BaseActionModal {\n description?: { text: string };\n}\n\nexport interface BulkDeleteActionModal extends DeleteActionModal {}\n\nexport type BulkDeleteAction =\n | {\n mode: 'modal';\n modal: BulkDeleteActionModal;\n
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/types/actions/base.ts"],"sourcesContent":["export type DividerActionConfig = { type: 'divider' };\n\nexport type BaseActionItemConfig = {\n id: string;\n label?: string;\n skin?: string;\n};\n\nexport interface Feedback {\n successToast?: { text: string };\n errorToast?: { text: string };\n}\n\nexport interface BaseActionModal {\n title?: { text: string };\n actions?: {\n submit?: { text: string };\n cancel?: { text: string };\n };\n feedback?: Feedback;\n}\n\nexport interface ActionModalField {\n id: string;\n label?: string;\n}\n\nexport interface DeleteActionModal extends BaseActionModal {\n description?: { text: string };\n}\n\nexport interface BulkDeleteActionModal extends DeleteActionModal {}\n\nexport type BulkDeleteAction =\n | {\n mode: 'modal';\n modal: BulkDeleteActionModal;\n }\n | {\n mode: 'custom';\n modal?: never;\n };\n\nexport type DeleteAction = {\n mode: 'modal';\n modal: DeleteActionModal;\n};\n\nexport interface BaseActionPage {\n id: string;\n}\n\nexport interface ActionModalWithFields extends BaseActionModal {\n fields: ActionModalField[];\n}\n\nexport interface UpdateActionModal extends ActionModalWithFields {}\n\nexport interface CreateActionModal extends ActionModalWithFields {}\n\nexport interface UpdateActionPage extends BaseActionPage {}\n\nexport interface CreateActionPage extends BaseActionPage {}\n\nexport type UpdateAction = {\n mode: 'page';\n page: UpdateActionPage;\n};\n\nexport type CreateAction = {\n mode: 'page';\n page: CreateActionPage;\n};\n\nexport type CreateActionConfig = BaseActionItemConfig & {\n type: 'create';\n create: CreateAction;\n};\n\nexport type UpdateActionConfig = BaseActionItemConfig & {\n type: 'update';\n update: UpdateAction;\n};\n\nexport type DeleteActionConfig = BaseActionItemConfig & {\n type: 'delete';\n delete: DeleteAction;\n};\n\nexport type BulkDeleteActionConfig = BaseActionItemConfig & {\n type: 'bulkDelete';\n bulkDelete: BulkDeleteAction;\n};\n\nexport type CustomActionConfig = BaseActionItemConfig & {\n type: 'custom';\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -46,9 +46,6 @@ export interface AppConfig {
|
|
|
46
46
|
collection: {
|
|
47
47
|
collectionId: string; // ID of the Wix Data collection
|
|
48
48
|
entityTypeSource: 'cms' | 'custom'; // Data source type.
|
|
49
|
-
custom?: {
|
|
50
|
-
id: string;
|
|
51
|
-
};
|
|
52
49
|
};
|
|
53
50
|
create?: { // Required when type is 'create'
|
|
54
51
|
mode: 'page'; // Create mode
|
|
@@ -124,9 +124,6 @@ export interface AppConfig {
|
|
|
124
124
|
collection: {
|
|
125
125
|
collectionId: string; // ID of the Wix Data collection
|
|
126
126
|
entityTypeSource: 'cms' | 'custom'; // Data source type.
|
|
127
|
-
custom?: {
|
|
128
|
-
id: string;
|
|
129
|
-
};
|
|
130
127
|
};
|
|
131
128
|
create?: { // Required when type is 'create'
|
|
132
129
|
mode: 'page'; // Create mode
|
|
@@ -1805,10 +1802,7 @@ The bulk action toolbar uses a specific structure for organizing actions:
|
|
|
1805
1802
|
"item": {
|
|
1806
1803
|
"id": "bulkCustom",
|
|
1807
1804
|
"type": "custom",
|
|
1808
|
-
"label": "Custom Bulk"
|
|
1809
|
-
"custom": {
|
|
1810
|
-
"id": "MyCustomBulk"
|
|
1811
|
-
}
|
|
1805
|
+
"label": "Custom Bulk"
|
|
1812
1806
|
}
|
|
1813
1807
|
}
|
|
1814
1808
|
},
|
|
@@ -2259,14 +2253,73 @@ Each column in the table has a default rendering based on its field type. You ca
|
|
|
2259
2253
|
|
|
2260
2254
|
### Function Signature
|
|
2261
2255
|
|
|
2256
|
+
For proper TypeScript support, use the `IColumnValue<T>` interface:
|
|
2257
|
+
|
|
2262
2258
|
```typescript
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2259
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2260
|
+
|
|
2261
|
+
function columnOverride(props: IColumnValue<string>) {
|
|
2262
|
+
// props.value: The individual column value (typed)
|
|
2263
|
+
// props.row: The entire row object containing all field values
|
|
2266
2264
|
return <YourCustomRendering />;
|
|
2267
2265
|
}
|
|
2268
2266
|
```
|
|
2269
2267
|
|
|
2268
|
+
### Type-Specific Examples
|
|
2269
|
+
|
|
2270
|
+
The generic type `T` in `IColumnValue<T>` should match your field's data type:
|
|
2271
|
+
|
|
2272
|
+
```tsx
|
|
2273
|
+
import React from 'react';
|
|
2274
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2275
|
+
import { Badge } from '@wix/design-system';
|
|
2276
|
+
|
|
2277
|
+
/* The `IColumnValue<T>` interface provides type safety for column override functions: */
|
|
2278
|
+
interface IColumnValue<T> {
|
|
2279
|
+
value: T; // The individual column value (strongly typed)
|
|
2280
|
+
row: Record<string, any>; // The entire row object with all field values
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
// For TEXT fields
|
|
2284
|
+
export function petName({ value, row }: IColumnValue<string>) {
|
|
2285
|
+
return <span>{value?.toUpperCase()}</span>;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
// For NUMBER fields
|
|
2289
|
+
export function age({ value, row }: IColumnValue<number>) {
|
|
2290
|
+
return (
|
|
2291
|
+
<Badge skin={value > 5 ? 'warning' : 'success'}>
|
|
2292
|
+
{value} years old
|
|
2293
|
+
</Badge>
|
|
2294
|
+
);
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
// For BOOLEAN fields
|
|
2298
|
+
export function isVaccinated({ value, row }: IColumnValue<boolean>) {
|
|
2299
|
+
return (
|
|
2300
|
+
<Badge skin={value ? 'success' : 'danger'}>
|
|
2301
|
+
{value ? '✓ Vaccinated' : '✗ Not Vaccinated'}
|
|
2302
|
+
</Badge>
|
|
2303
|
+
);
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
// For DATE/DATETIME fields
|
|
2307
|
+
export function birthDate({ value, row }: IColumnValue<string | Date>) {
|
|
2308
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
2309
|
+
return <span>{date.toLocaleDateString()}</span>;
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
// For IMAGE fields
|
|
2313
|
+
export function profilePicture({ value, row }: IColumnValue<string>) {
|
|
2314
|
+
return <img src={value} alt={row.name} width="48" height="48" />;
|
|
2315
|
+
}
|
|
2316
|
+
|
|
2317
|
+
// For ARRAY fields
|
|
2318
|
+
export function hobbies({ value, row }: IColumnValue<string[]>) {
|
|
2319
|
+
return <span>{value?.join(', ') || 'No hobbies'}</span>;
|
|
2320
|
+
}
|
|
2321
|
+
```
|
|
2322
|
+
|
|
2270
2323
|
### Understanding Row Data
|
|
2271
2324
|
|
|
2272
2325
|
**Important**: The `row` object contains all field values from the entity, where each property corresponds to a **field ID** from the collection schema. To access specific field values, use the exact field ID as defined in your collection schema.
|
|
@@ -2307,22 +2360,29 @@ export function myColumn({ value, row }) {
|
|
|
2307
2360
|
|
|
2308
2361
|
In `components/columns/name.tsx`:
|
|
2309
2362
|
|
|
2310
|
-
```
|
|
2363
|
+
```tsx
|
|
2311
2364
|
import React from 'react';
|
|
2365
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2312
2366
|
|
|
2313
|
-
export function name(
|
|
2314
|
-
// Simple value formatting
|
|
2367
|
+
export function name(props: IColumnValue<string>) {
|
|
2368
|
+
// Simple value formatting with TypeScript typing
|
|
2369
|
+
return <strong>{props.value}</strong>;
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
// Alternative: Destructured parameters with typing
|
|
2373
|
+
export function nameAlt({ value, row }: IColumnValue<string>) {
|
|
2315
2374
|
return <strong>{value}</strong>;
|
|
2316
2375
|
}
|
|
2317
2376
|
```
|
|
2318
2377
|
|
|
2319
2378
|
In `components/columns/petInfo.tsx`:
|
|
2320
2379
|
|
|
2321
|
-
```
|
|
2380
|
+
```tsx
|
|
2322
2381
|
import React from 'react';
|
|
2323
2382
|
import { Box, Text } from '@wix/design-system';
|
|
2383
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2324
2384
|
|
|
2325
|
-
export function petInfo({ value, row }) {
|
|
2385
|
+
export function petInfo({ value, row }: IColumnValue<string>) {
|
|
2326
2386
|
// Complex column combining multiple row values
|
|
2327
2387
|
return (
|
|
2328
2388
|
<Box direction="vertical" gap={1}>
|
|
@@ -2340,11 +2400,12 @@ export function petInfo({ value, row }) {
|
|
|
2340
2400
|
|
|
2341
2401
|
In `components/columns/status.tsx`:
|
|
2342
2402
|
|
|
2343
|
-
```
|
|
2403
|
+
```tsx
|
|
2344
2404
|
import React from 'react';
|
|
2345
2405
|
import { Badge } from '@wix/design-system';
|
|
2406
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2346
2407
|
|
|
2347
|
-
export function status({ value, row }) {
|
|
2408
|
+
export function status({ value, row }: IColumnValue<string>) {
|
|
2348
2409
|
// Conditional rendering based on multiple row fields
|
|
2349
2410
|
if (row.isVaccinated && row.age > 1) {
|
|
2350
2411
|
return <Badge skin="success">Ready for Adoption</Badge>;
|
|
@@ -2358,10 +2419,11 @@ export function status({ value, row }) {
|
|
|
2358
2419
|
|
|
2359
2420
|
In `components/columns/fullName.tsx`:
|
|
2360
2421
|
|
|
2361
|
-
```
|
|
2422
|
+
```tsx
|
|
2362
2423
|
import React from 'react';
|
|
2424
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2363
2425
|
|
|
2364
|
-
export function fullName({ value, row }) {
|
|
2426
|
+
export function fullName({ value, row }: IColumnValue<string>) {
|
|
2365
2427
|
// Calculated column using multiple fields
|
|
2366
2428
|
return `${row.name} (owned by ${row.owner})`;
|
|
2367
2429
|
}
|
|
@@ -2369,10 +2431,11 @@ export function fullName({ value, row }) {
|
|
|
2369
2431
|
|
|
2370
2432
|
In `components/columns/date.tsx`:
|
|
2371
2433
|
|
|
2372
|
-
```
|
|
2434
|
+
```tsx
|
|
2373
2435
|
import React from 'react';
|
|
2436
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
2374
2437
|
|
|
2375
|
-
export function date({ value, row }) {
|
|
2438
|
+
export function date({ value, row }: IColumnValue<string>) {
|
|
2376
2439
|
// Access to other row data for enhanced date formatting
|
|
2377
2440
|
const isRecent = row.lastActivity && new Date(row.lastActivity) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
|
|
2378
2441
|
|
|
@@ -2455,6 +2518,8 @@ PatternsWizardOverridesProvider
|
|
|
2455
2518
|
|
|
2456
2519
|
### Important Guidelines
|
|
2457
2520
|
|
|
2521
|
+
- **TypeScript Usage**: Always use `IColumnValue<T>` and import it from `@wix/auto-patterns/types`
|
|
2522
|
+
- **Type Matching**: Ensure the generic type `T` matches your field's actual data type (string, number, boolean, etc.)
|
|
2458
2523
|
- **Performance**: Remember that column functions are called for every row, so keep calculations lightweight
|
|
2459
2524
|
- **Consistency**: When using row data, ensure the column header accurately represents what's displayed
|
|
2460
2525
|
- **Accessibility**: Maintain proper semantic structure when combining multiple values
|
|
@@ -3073,7 +3138,7 @@ import * as columns from './components/columns';
|
|
|
3073
3138
|
import * as actions from './components/actions';
|
|
3074
3139
|
|
|
3075
3140
|
<PatternsWizardOverridesProvider value={{ sections, columns, actions }}>
|
|
3076
|
-
<AutoPatternsApp configuration={config
|
|
3141
|
+
<AutoPatternsApp configuration={config} />
|
|
3077
3142
|
</PatternsWizardOverridesProvider>
|
|
3078
3143
|
```
|
|
3079
3144
|
|
|
@@ -194,10 +194,7 @@ The bulk action toolbar uses a specific structure for organizing actions:
|
|
|
194
194
|
"item": {
|
|
195
195
|
"id": "bulkCustom",
|
|
196
196
|
"type": "custom",
|
|
197
|
-
"label": "Custom Bulk"
|
|
198
|
-
"custom": {
|
|
199
|
-
"id": "MyCustomBulk"
|
|
200
|
-
}
|
|
197
|
+
"label": "Custom Bulk"
|
|
201
198
|
}
|
|
202
199
|
}
|
|
203
200
|
},
|
|
@@ -108,14 +108,73 @@ Each column in the table has a default rendering based on its field type. You ca
|
|
|
108
108
|
|
|
109
109
|
### Function Signature
|
|
110
110
|
|
|
111
|
+
For proper TypeScript support, use the `IColumnValue<T>` interface:
|
|
112
|
+
|
|
111
113
|
```typescript
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
115
|
+
|
|
116
|
+
function columnOverride(props: IColumnValue<string>) {
|
|
117
|
+
// props.value: The individual column value (typed)
|
|
118
|
+
// props.row: The entire row object containing all field values
|
|
115
119
|
return <YourCustomRendering />;
|
|
116
120
|
}
|
|
117
121
|
```
|
|
118
122
|
|
|
123
|
+
### Type-Specific Examples
|
|
124
|
+
|
|
125
|
+
The generic type `T` in `IColumnValue<T>` should match your field's data type:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import React from 'react';
|
|
129
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
130
|
+
import { Badge } from '@wix/design-system';
|
|
131
|
+
|
|
132
|
+
/* The `IColumnValue<T>` interface provides type safety for column override functions: */
|
|
133
|
+
interface IColumnValue<T> {
|
|
134
|
+
value: T; // The individual column value (strongly typed)
|
|
135
|
+
row: Record<string, any>; // The entire row object with all field values
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// For TEXT fields
|
|
139
|
+
export function petName({ value, row }: IColumnValue<string>) {
|
|
140
|
+
return <span>{value?.toUpperCase()}</span>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// For NUMBER fields
|
|
144
|
+
export function age({ value, row }: IColumnValue<number>) {
|
|
145
|
+
return (
|
|
146
|
+
<Badge skin={value > 5 ? 'warning' : 'success'}>
|
|
147
|
+
{value} years old
|
|
148
|
+
</Badge>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// For BOOLEAN fields
|
|
153
|
+
export function isVaccinated({ value, row }: IColumnValue<boolean>) {
|
|
154
|
+
return (
|
|
155
|
+
<Badge skin={value ? 'success' : 'danger'}>
|
|
156
|
+
{value ? '✓ Vaccinated' : '✗ Not Vaccinated'}
|
|
157
|
+
</Badge>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// For DATE/DATETIME fields
|
|
162
|
+
export function birthDate({ value, row }: IColumnValue<string | Date>) {
|
|
163
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
164
|
+
return <span>{date.toLocaleDateString()}</span>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// For IMAGE fields
|
|
168
|
+
export function profilePicture({ value, row }: IColumnValue<string>) {
|
|
169
|
+
return <img src={value} alt={row.name} width="48" height="48" />;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// For ARRAY fields
|
|
173
|
+
export function hobbies({ value, row }: IColumnValue<string[]>) {
|
|
174
|
+
return <span>{value?.join(', ') || 'No hobbies'}</span>;
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
119
178
|
### Understanding Row Data
|
|
120
179
|
|
|
121
180
|
**Important**: The `row` object contains all field values from the entity, where each property corresponds to a **field ID** from the collection schema. To access specific field values, use the exact field ID as defined in your collection schema.
|
|
@@ -156,22 +215,29 @@ export function myColumn({ value, row }) {
|
|
|
156
215
|
|
|
157
216
|
In `components/columns/name.tsx`:
|
|
158
217
|
|
|
159
|
-
```
|
|
218
|
+
```tsx
|
|
160
219
|
import React from 'react';
|
|
220
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
161
221
|
|
|
162
|
-
export function name(
|
|
163
|
-
// Simple value formatting
|
|
222
|
+
export function name(props: IColumnValue<string>) {
|
|
223
|
+
// Simple value formatting with TypeScript typing
|
|
224
|
+
return <strong>{props.value}</strong>;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Alternative: Destructured parameters with typing
|
|
228
|
+
export function nameAlt({ value, row }: IColumnValue<string>) {
|
|
164
229
|
return <strong>{value}</strong>;
|
|
165
230
|
}
|
|
166
231
|
```
|
|
167
232
|
|
|
168
233
|
In `components/columns/petInfo.tsx`:
|
|
169
234
|
|
|
170
|
-
```
|
|
235
|
+
```tsx
|
|
171
236
|
import React from 'react';
|
|
172
237
|
import { Box, Text } from '@wix/design-system';
|
|
238
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
173
239
|
|
|
174
|
-
export function petInfo({ value, row }) {
|
|
240
|
+
export function petInfo({ value, row }: IColumnValue<string>) {
|
|
175
241
|
// Complex column combining multiple row values
|
|
176
242
|
return (
|
|
177
243
|
<Box direction="vertical" gap={1}>
|
|
@@ -189,11 +255,12 @@ export function petInfo({ value, row }) {
|
|
|
189
255
|
|
|
190
256
|
In `components/columns/status.tsx`:
|
|
191
257
|
|
|
192
|
-
```
|
|
258
|
+
```tsx
|
|
193
259
|
import React from 'react';
|
|
194
260
|
import { Badge } from '@wix/design-system';
|
|
261
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
195
262
|
|
|
196
|
-
export function status({ value, row }) {
|
|
263
|
+
export function status({ value, row }: IColumnValue<string>) {
|
|
197
264
|
// Conditional rendering based on multiple row fields
|
|
198
265
|
if (row.isVaccinated && row.age > 1) {
|
|
199
266
|
return <Badge skin="success">Ready for Adoption</Badge>;
|
|
@@ -207,10 +274,11 @@ export function status({ value, row }) {
|
|
|
207
274
|
|
|
208
275
|
In `components/columns/fullName.tsx`:
|
|
209
276
|
|
|
210
|
-
```
|
|
277
|
+
```tsx
|
|
211
278
|
import React from 'react';
|
|
279
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
212
280
|
|
|
213
|
-
export function fullName({ value, row }) {
|
|
281
|
+
export function fullName({ value, row }: IColumnValue<string>) {
|
|
214
282
|
// Calculated column using multiple fields
|
|
215
283
|
return `${row.name} (owned by ${row.owner})`;
|
|
216
284
|
}
|
|
@@ -218,10 +286,11 @@ export function fullName({ value, row }) {
|
|
|
218
286
|
|
|
219
287
|
In `components/columns/date.tsx`:
|
|
220
288
|
|
|
221
|
-
```
|
|
289
|
+
```tsx
|
|
222
290
|
import React from 'react';
|
|
291
|
+
import { IColumnValue } from '@wix/auto-patterns/types';
|
|
223
292
|
|
|
224
|
-
export function date({ value, row }) {
|
|
293
|
+
export function date({ value, row }: IColumnValue<string>) {
|
|
225
294
|
// Access to other row data for enhanced date formatting
|
|
226
295
|
const isRecent = row.lastActivity && new Date(row.lastActivity) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
|
|
227
296
|
|
|
@@ -304,6 +373,8 @@ PatternsWizardOverridesProvider
|
|
|
304
373
|
|
|
305
374
|
### Important Guidelines
|
|
306
375
|
|
|
376
|
+
- **TypeScript Usage**: Always use `IColumnValue<T>` and import it from `@wix/auto-patterns/types`
|
|
377
|
+
- **Type Matching**: Ensure the generic type `T` matches your field's actual data type (string, number, boolean, etc.)
|
|
307
378
|
- **Performance**: Remember that column functions are called for every row, so keep calculations lightweight
|
|
308
379
|
- **Consistency**: When using row data, ensure the column header accurately represents what's displayed
|
|
309
380
|
- **Accessibility**: Maintain proper semantic structure when combining multiple values
|
|
@@ -922,7 +993,7 @@ import * as columns from './components/columns';
|
|
|
922
993
|
import * as actions from './components/actions';
|
|
923
994
|
|
|
924
995
|
<PatternsWizardOverridesProvider value={{ sections, columns, actions }}>
|
|
925
|
-
<AutoPatternsApp configuration={config
|
|
996
|
+
<AutoPatternsApp configuration={config} />
|
|
926
997
|
</PatternsWizardOverridesProvider>
|
|
927
998
|
```
|
|
928
999
|
|
package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js
CHANGED
|
@@ -14,15 +14,14 @@ export const AutoPatternsCollectionComponent = _ref => {
|
|
|
14
14
|
...sharedConfig
|
|
15
15
|
} = component;
|
|
16
16
|
const memoized = useMemo(() => {
|
|
17
|
-
|
|
18
|
-
if (!(layout != null && layout.length)) {
|
|
17
|
+
if (!layout?.length) {
|
|
19
18
|
return {
|
|
20
19
|
componentToRender: null,
|
|
21
20
|
componentType: 'Table'
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
|
-
const tableConfig =
|
|
25
|
-
const gridConfig =
|
|
23
|
+
const tableConfig = layout.find(item => item.type === 'Table')?.table;
|
|
24
|
+
const gridConfig = layout.find(item => item.type === 'Grid')?.grid;
|
|
26
25
|
let componentType = 'Table';
|
|
27
26
|
let componentToRender = null;
|
|
28
27
|
if (tableConfig && gridConfig) {
|
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","
|
|
1
|
+
{"version":3,"names":["AutoPatternsTableGridSwitch","AutoPatternsTable","AutoPatternsGrid","SchemaProvider","SkeletonCollection","React","useMemo","AutoPatternsCollectionComponent","_ref","component","index","layout","sharedConfig","memoized","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={<S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Z,YAAY;QAAE,GAAGK;MAAY,CAAC;MAClDF,iBAAiB,gBAAGV,KAAA,CAAAoB,aAAA,CAACxB,iBAAiB;QAACyB,aAAa,EAAEF;MAAO,CAAE,CAAC;IAClE,CAAC,MAAM,IAAIF,UAAU,EAAE;MACrBN,aAAa,GAAG,MAAM;MACtB,MAAMQ,MAAM,GAAG;QAAE,GAAGZ,YAAY;QAAE,GAAGU;MAAW,CAAC;MACjDP,iBAAiB,gBAAGV,KAAA,CAAAoB,aAAA,CAACvB,gBAAgB;QAACwB,aAAa,EAAEF;MAAO,CAAE,CAAC;IACjE;IAEA,OAAO;MAAET,iBAAiB;MAAEC;IAAc,CAAC;EAC7C,CAAC,EAAE,CAACL,MAAM,EAAEC,YAAY,CAAC,CAAC;EAE1B,MAAM;IAAEG,iBAAiB;IAAEC;EAAc,CAAC,GAAGH,QAAQ;EAErD,oBACER,KAAA,CAAAoB,aAAA,CAAApB,KAAA,CAAAsB,QAAA,QACGZ,iBAAiB,gBAChBV,KAAA,CAAAoB,aAAA,CAACtB,cAAc;IACbyB,GAAG,EAAE,GAAGhB,YAAY,CAACiB,UAAU,CAACC,YAAY,IAAIpB,KAAK,EAAG;IACxDmB,UAAU,EAAEjB,YAAY,CAACiB,UAAW;IACpCE,QAAQ,eAAE1B,KAAA,CAAAoB,aAAA,CAACrB,kBAAkB;MAACY,aAAa,EAAEA;IAAc,CAAE;EAAE,GAE9DD,iBACa,CAAC,GACf,IACJ,CAAC;AAEP,CAAC","ignoreList":[]}
|
package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js
CHANGED
|
@@ -17,8 +17,7 @@ export const AutoPatternsCollectionPageContent = _ref => {
|
|
|
17
17
|
index: index
|
|
18
18
|
});
|
|
19
19
|
} else if (component.type === 'custom') {
|
|
20
|
-
|
|
21
|
-
const CustomComponent = overrides == null || (_overrides$slots = overrides.slots) == null ? void 0 : _overrides$slots[component.id];
|
|
20
|
+
const CustomComponent = overrides?.slots?.[component.id];
|
|
22
21
|
if (!CustomComponent) {
|
|
23
22
|
return null;
|
|
24
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","usePatternsWizardOverridesContext","AutoPatternsCollectionComponent","AutoPatternsCollectionPageContent","_ref","configuration","components","overrides","createElement","Fragment","map","component","index","type","key","collection","collectionId","
|
|
1
|
+
{"version":3,"names":["React","usePatternsWizardOverridesContext","AutoPatternsCollectionComponent","AutoPatternsCollectionPageContent","_ref","configuration","components","overrides","createElement","Fragment","map","component","index","type","key","collection","collectionId","CustomComponent","slots","id","filter","Boolean"],"sources":["../../../../src/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.tsx"],"sourcesContent":["import React from 'react';\nimport { CollectionPageConfig } from '../../types';\nimport { usePatternsWizardOverridesContext } from '../../providers';\nimport { AutoPatternsCollectionComponent } from '../AutoPatternsCollectionComponent/AutoPatternsCollectionComponent';\n\nexport interface AutoPatternsCollectionPageContentProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPageContent = ({\n configuration,\n}: AutoPatternsCollectionPageContentProps) => {\n const { components } = configuration;\n const overrides = usePatternsWizardOverridesContext();\n\n return (\n <>\n {components\n .map((component, index) => {\n if (component.type === 'collection') {\n return (\n <AutoPatternsCollectionComponent\n key={`collection-${component.collection.collectionId}-${index}`}\n component={component}\n index={index}\n />\n );\n } else if (component.type === 'custom') {\n const CustomComponent = overrides?.slots?.[component.id];\n\n if (!CustomComponent) {\n return null;\n }\n\n return <CustomComponent key={`custom-${component.id}-${index}`} />;\n }\n\n return null;\n })\n .filter(Boolean)}\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,iCAAiC,QAAQ,iBAAiB;AACnE,SAASC,+BAA+B,QAAQ,oEAAoE;AAMpH,OAAO,MAAMC,iCAAiC,GAAGC,IAAA,IAEH;EAAA,IAFI;IAChDC;EACsC,CAAC,GAAAD,IAAA;EACvC,MAAM;IAAEE;EAAW,CAAC,GAAGD,aAAa;EACpC,MAAME,SAAS,GAAGN,iCAAiC,CAAC,CAAC;EAErD,oBACED,KAAA,CAAAQ,aAAA,CAAAR,KAAA,CAAAS,QAAA,QACGH,UAAU,CACRI,GAAG,CAAC,CAACC,SAAS,EAAEC,KAAK,KAAK;IACzB,IAAID,SAAS,CAACE,IAAI,KAAK,YAAY,EAAE;MACnC,oBACEb,KAAA,CAAAQ,aAAA,CAACN,+BAA+B;QAC9BY,GAAG,EAAE,cAAcH,SAAS,CAACI,UAAU,CAACC,YAAY,IAAIJ,KAAK,EAAG;QAChED,SAAS,EAAEA,SAAU;QACrBC,KAAK,EAAEA;MAAM,CACd,CAAC;IAEN,CAAC,MAAM,IAAID,SAAS,CAACE,IAAI,KAAK,QAAQ,EAAE;MACtC,MAAMI,eAAe,GAAGV,SAAS,EAAEW,KAAK,GAAGP,SAAS,CAACQ,EAAE,CAAC;MAExD,IAAI,CAACF,eAAe,EAAE;QACpB,OAAO,IAAI;MACb;MAEA,oBAAOjB,KAAA,CAAAQ,aAAA,CAACS,eAAe;QAACH,GAAG,EAAE,UAAUH,SAAS,CAACQ,EAAE,IAAIP,KAAK;MAAG,CAAE,CAAC;IACpE;IAEA,OAAO,IAAI;EACb,CAAC,CAAC,CACDQ,MAAM,CAACC,OAAO,CACjB,CAAC;AAEP,CAAC","ignoreList":[]}
|
|
@@ -10,7 +10,6 @@ import { usePatternsWizardOverridesContext } from '../../providers';
|
|
|
10
10
|
import { useEntityPageMoreActions } from '../../hooks/useEntityPageMoreActions';
|
|
11
11
|
import { useActionsSDK } from '../../hooks/useActionsSDK';
|
|
12
12
|
const RenderLayoutContent = _ref => {
|
|
13
|
-
var _content$container$ch, _overrides$components;
|
|
14
13
|
let {
|
|
15
14
|
content,
|
|
16
15
|
level,
|
|
@@ -39,7 +38,7 @@ const RenderLayoutContent = _ref => {
|
|
|
39
38
|
inputRef: ref => setInputRef(content.field.fieldId, ref)
|
|
40
39
|
}));
|
|
41
40
|
case 'container':
|
|
42
|
-
if (!
|
|
41
|
+
if (!content.container.children?.length) {
|
|
43
42
|
return null;
|
|
44
43
|
}
|
|
45
44
|
return /*#__PURE__*/React.createElement(Cell, {
|
|
@@ -57,7 +56,7 @@ const RenderLayoutContent = _ref => {
|
|
|
57
56
|
if (!content.component.componentId) {
|
|
58
57
|
return null;
|
|
59
58
|
}
|
|
60
|
-
const Component = overrides
|
|
59
|
+
const Component = overrides?.components?.[content.component.componentId];
|
|
61
60
|
if (!Component) {
|
|
62
61
|
return null;
|
|
63
62
|
}
|
|
@@ -72,7 +71,6 @@ const RenderLayoutContent = _ref => {
|
|
|
72
71
|
}
|
|
73
72
|
};
|
|
74
73
|
const RenderLayoutCard = _ref2 => {
|
|
75
|
-
var _layout$card$subtitle;
|
|
76
74
|
let {
|
|
77
75
|
layout,
|
|
78
76
|
sectionId,
|
|
@@ -85,7 +83,7 @@ const RenderLayoutCard = _ref2 => {
|
|
|
85
83
|
minHeight: "50px"
|
|
86
84
|
}, /*#__PURE__*/React.createElement(Card.Header, {
|
|
87
85
|
title: layout.card.title.text,
|
|
88
|
-
subtitle:
|
|
86
|
+
subtitle: layout.card.subtitle?.text
|
|
89
87
|
}), /*#__PURE__*/React.createElement(Card.Divider, null), /*#__PURE__*/React.createElement(Card.Content, null, /*#__PURE__*/React.createElement(Layout, null, layout.card.children.map((child, index) => /*#__PURE__*/React.createElement(RenderLayoutContent, {
|
|
90
88
|
key: `${sectionId}-card-${cardIndex}-content-${index}`,
|
|
91
89
|
content: child,
|
|
@@ -100,7 +98,6 @@ const RenderLayoutCard = _ref2 => {
|
|
|
100
98
|
}
|
|
101
99
|
};
|
|
102
100
|
export const AutoPatternsEntityPage = _ref3 => {
|
|
103
|
-
var _pageLayout$main, _pageLayout$sidebar;
|
|
104
101
|
let {
|
|
105
102
|
configuration
|
|
106
103
|
} = _ref3;
|
|
@@ -124,12 +121,10 @@ export const AutoPatternsEntityPage = _ref3 => {
|
|
|
124
121
|
};
|
|
125
122
|
const validate = () => {
|
|
126
123
|
const invalidFieldId = Object.keys(inputRefs.current).find(fieldId => {
|
|
127
|
-
|
|
128
|
-
return (_inputRefs$current$fi = inputRefs.current[fieldId]) == null ? void 0 : _inputRefs$current$fi.invalid;
|
|
124
|
+
return inputRefs.current[fieldId]?.invalid;
|
|
129
125
|
});
|
|
130
126
|
if (invalidFieldId) {
|
|
131
|
-
|
|
132
|
-
(_inputRefs$current$in = inputRefs.current[invalidFieldId]) == null || _inputRefs$current$in.focus == null || _inputRefs$current$in.focus();
|
|
127
|
+
inputRefs.current[invalidFieldId]?.focus?.();
|
|
133
128
|
throw new Error('Invalid form');
|
|
134
129
|
}
|
|
135
130
|
};
|
|
@@ -172,7 +167,7 @@ export const AutoPatternsEntityPage = _ref3 => {
|
|
|
172
167
|
} = useEntityPageHeaderTexts({
|
|
173
168
|
config: configuration,
|
|
174
169
|
isCreateMode,
|
|
175
|
-
entityDisplayName: entity
|
|
170
|
+
entityDisplayName: entity?.[schema.displayField]
|
|
176
171
|
});
|
|
177
172
|
const sdk = useActionsSDK({
|
|
178
173
|
collectionId
|
|
@@ -189,13 +184,13 @@ export const AutoPatternsEntityPage = _ref3 => {
|
|
|
189
184
|
}) : undefined
|
|
190
185
|
}), /*#__PURE__*/React.createElement(EntityPage.Content, null, /*#__PURE__*/React.createElement(EntityPage.MainContent, {
|
|
191
186
|
dataHook: "entity-page-main-content"
|
|
192
|
-
}, pageLayout
|
|
187
|
+
}, pageLayout?.main?.map((layout, layoutIndex) => /*#__PURE__*/React.createElement(RenderLayoutCard, {
|
|
193
188
|
key: `main-section-card-${layoutIndex}`,
|
|
194
189
|
layout: layout,
|
|
195
190
|
sectionId: "main",
|
|
196
191
|
cardIndex: layoutIndex,
|
|
197
192
|
setInputRef: setInputRef
|
|
198
|
-
}))), pageLayout
|
|
193
|
+
}))), pageLayout?.sidebar ? /*#__PURE__*/React.createElement(EntityPage.AdditionalContent, null, pageLayout.sidebar?.map((layout, layoutIndex) => /*#__PURE__*/React.createElement(RenderLayoutCard, {
|
|
199
194
|
key: `sidebar-section-card-${layoutIndex}`,
|
|
200
195
|
layout: layout,
|
|
201
196
|
sectionId: "sidebar",
|