@webiny/app-admin 6.5.2-beta.1 → 6.5.2-beta.3
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/base/Base/FieldRenderers/ObjectRenderer/KeyValueTagsRenderer.js.map +1 -1
- package/base/Base/FieldRenderers/ObjectRenderer/MultiValueDynamicZone/MultiValueDynamicZone.js.map +1 -1
- package/base/Base/FieldRenderers/ObjectRenderer/ObjectAccordionMultipleRenderer.js.map +1 -1
- package/base/Base/FieldRenderers/ObjectRenderer/ObjectFieldComponents.js.map +1 -1
- package/base/Base/LexicalPreset.js +1 -1
- package/base/Base/LexicalPreset.js.map +1 -1
- package/base/Base/Menus.js.map +1 -1
- package/base/Base/RoutesConfig.js.map +1 -1
- package/base/Base/Tenant.js.map +1 -1
- package/base/Base/UserMenu.js.map +1 -1
- package/base/Base.js.map +1 -1
- package/base/ui/Brand.js.map +1 -1
- package/base/ui/Dashboard.js.map +1 -1
- package/base/ui/FileManager.js.map +1 -1
- package/base/ui/LoginScreen.js.map +1 -1
- package/base/ui/Logo.js.map +1 -1
- package/base/ui/Navigation.js.map +1 -1
- package/base/ui/NotFound.js.map +1 -1
- package/base/ui/Tags.js.map +1 -1
- package/base/ui/TenantSelector.js.map +1 -1
- package/base/ui/UserMenu/UserMenu.js.map +1 -1
- package/base/ui/UserMenu/UserMenuHandle.js.map +1 -1
- package/base/ui/UserMenu.js.map +1 -1
- package/components/Buttons/useButtons.js.map +1 -1
- package/components/Dialogs/DialogParamsContext.js.map +1 -1
- package/components/Dialogs/DialogsContext.js.map +1 -1
- package/components/Drawers/DrawerParamsContext.js.map +1 -1
- package/components/Drawers/DrawersContext.js.map +1 -1
- package/components/Filters/FiltersToggle.js.map +1 -1
- package/components/IconPicker/IconPickerPresenterProvider.js.map +1 -1
- package/components/IconPicker/IconPickerTab.js.map +1 -1
- package/components/IconPicker/IconRenderer.js.map +1 -1
- package/components/IconPicker/config/IconType.js.map +1 -1
- package/components/IconPicker/config/index.js.map +1 -1
- package/components/IconPicker/plugins/customPlugin.js.map +1 -1
- package/components/IconPicker/plugins/emojisPlugin.js.map +1 -1
- package/components/IconPicker/plugins/iconsPlugin.js.map +1 -1
- package/components/IconPicker/types.js.map +1 -1
- package/components/LexicalEditor/DefaultLexicalEditorConfig.js +1 -1
- package/components/LexicalEditor/DefaultLexicalEditorConfig.js.map +1 -1
- package/components/LexicalEditor/LexicalLinkForm.js.map +1 -1
- package/components/ListView/ListViewBottomBar.js.map +1 -1
- package/components/ListView/ListViewHeader.js.map +1 -1
- package/components/OptionsMenu/useOptionsMenuItem.js.map +1 -1
- package/components/Table/useTableRow.js.map +1 -1
- package/components/Wcp.js +6 -6
- package/components/Wcp.js.map +1 -1
- package/config/AdminConfig/LexicalTheme/Typography.js +4 -4
- package/config/AdminConfig/LexicalTheme/Typography.js.map +1 -1
- package/config/AdminConfig/Menu.js.map +1 -1
- package/config/AdminConfig/Theme.js +1 -1
- package/config/AdminConfig/Theme.js.map +1 -1
- package/config/AdminConfig.js +2 -2
- package/config/AdminConfig.js.map +1 -1
- package/config/createAdminConfig.js.map +1 -1
- package/features/accessManagement/constants.js.map +1 -1
- package/features/formModel/FormView.js.map +1 -1
- package/features/formModel/createFieldRenderer.js.map +1 -1
- package/features/formModel/demo/FormModelDemo.js.map +1 -1
- package/features/formModel/fieldTypes/dateLimits.js.map +1 -1
- package/modules/AccessManagementExtension.js +1 -1
- package/modules/AccessManagementExtension.js.map +1 -1
- package/package.json +26 -26
- package/permissions/PermissionRenderer.js.map +1 -1
- package/permissions/PermissionValueContext.js.map +1 -1
- package/presentation/accessManagement/SecurityPermissions.js +1 -1
- package/presentation/accessManagement/SecurityPermissions.js.map +1 -1
- package/presentation/accessManagement/apiKeys/components/ApiKeysView.js.map +1 -1
- package/presentation/accessManagement/roles/components/RolesView.js.map +1 -1
- package/presentation/accessManagement/teams/components/TeamsView.js.map +1 -1
- package/presentation/installation/components/SystemInstaller/steps/AdminUserStep.js.map +1 -1
- package/presentation/installation/components/SystemInstaller/steps/BasicInfoStep.js.map +1 -1
- package/presentation/trashBin/components/TrashBinConfigs.js +1 -1
- package/presentation/trashBin/components/TrashBinConfigs.js.map +1 -1
- package/presentation/trashBin/components/TrashBinOverlay.js.map +1 -1
- package/presentation/trashBin/configs/Browser/BulkAction.js +1 -1
- package/presentation/trashBin/configs/Browser/BulkAction.js.map +1 -1
- package/presentation/trashBin/hooks/useTrashBinItem.js +1 -1
- package/presentation/trashBin/hooks/useTrashBinItem.js.map +1 -1
- package/presentation/trashBin/hooks/useTrashBinPresenter.js +1 -1
- package/presentation/trashBin/hooks/useTrashBinPresenter.js.map +1 -1
package/config/AdminConfig.js
CHANGED
|
@@ -53,7 +53,7 @@ const useAdminConfig = ()=>{
|
|
|
53
53
|
const Public = ({ children })=>/*#__PURE__*/ react.createElement(base.PublicConfig, null, children);
|
|
54
54
|
const Private = ({ children })=>/*#__PURE__*/ react.createElement(base.PrivateConfig, null, children);
|
|
55
55
|
const AdminConfig = Object.assign(Private, {
|
|
56
|
-
Public
|
|
56
|
+
Public,
|
|
57
57
|
Theme: Theme,
|
|
58
58
|
Menu: Menu,
|
|
59
59
|
Route: Route,
|
|
@@ -66,7 +66,7 @@ const AdminConfig = Object.assign(Private, {
|
|
|
66
66
|
Dialog: Dialog,
|
|
67
67
|
Drawer: Drawer,
|
|
68
68
|
Form: Form,
|
|
69
|
-
useAdminConfig
|
|
69
|
+
useAdminConfig
|
|
70
70
|
});
|
|
71
71
|
export { AdminConfig, AdminConfigPlugin, AdminConfig_AdminConfigProvider as AdminConfigProvider, AdminWithConfig, Private, Public, useAdminConfig };
|
|
72
72
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config/AdminConfig.js","sources":["../../src/config/AdminConfig.tsx"],"sourcesContent":["import React from \"react\";\nimport { createProvider } from \"@webiny/app\";\nimport { Menu, type MenuConfig } from \"./AdminConfig/Menu.js\";\nimport type { TenantConfig } from \"./AdminConfig/Tenant.js\";\nimport { Tenant } from \"./AdminConfig/Tenant.js\";\nimport type { SupportMenuConfig } from \"./AdminConfig/Menu/SupportMenu.js\";\nimport type { UserMenuConfig } from \"./AdminConfig/Menu/UserMenu.js\";\nimport { Route } from \"./AdminConfig/Route.js\";\nimport { Theme } from \"./AdminConfig/Theme.js\";\nimport { Dashboard } from \"./AdminConfig/Dashboard.js\";\nimport { type WidgetConfig } from \"./AdminConfig/Widget.js\";\nimport { Security } from \"./AdminConfig/Security.js\";\nimport type { PermissionRendererConfig } from \"../permissions/types.js\";\nimport { LexicalTheme } from \"./AdminConfig/LexicalTheme.js\";\nimport { Title } from \"./AdminConfig/Title.js\";\nimport { Logo } from \"./AdminConfig/Logo.js\";\nimport { Dialog } from \"./AdminConfig/Dialog.js\";\nimport type { DialogConfig } from \"./AdminConfig/Dialog.js\";\nimport { Drawer } from \"./AdminConfig/Drawer.js\";\nimport type { DrawerConfig } from \"./AdminConfig/Drawer.js\";\nimport { Form } from \"./AdminConfig/Form.js\";\nimport type { FieldRendererConfig } from \"./AdminConfig/FieldRenderer.js\";\nimport type { LayoutRendererConfig } from \"./AdminConfig/LayoutRenderer.js\";\nimport { createAdminConfig } from \"./createAdminConfig.js\";\nimport type { EditorTheme } from \"@webiny/lexical-theme\";\nimport { createLexicalTokens } from \"@webiny/lexical-theme/createLexicalEditorTokens.js\";\n\nconst base = createAdminConfig<AdminConfig>();\n\nexport const AdminWithConfig = Object.assign(base.WithConfig, {\n displayName: \"AdminWithConfig\"\n});\n\ninterface AdminConfig {\n menus: MenuConfig[];\n supportMenus: SupportMenuConfig[];\n userMenus: UserMenuConfig[];\n tenant: TenantConfig;\n title: string;\n squareLogo: React.ReactNode;\n horizontalLogo: React.ReactNode;\n widgets: WidgetConfig[];\n permissionRenderers: PermissionRendererConfig[];\n lexicalTheme: EditorTheme;\n dialogs: DialogConfig[];\n drawers: DrawerConfig[];\n fieldRenderers: FieldRendererConfig[];\n layoutRenderers: LayoutRendererConfig[];\n}\n\n/* Once the app fully renders (after the LoginScreen), apply protected configs. */\nexport const AdminConfigPlugin = <base.ApplyProtectedConfig />;\n\nexport const AdminConfigProvider = createProvider(Original => {\n return function AdminConfigProvider({ children }) {\n return (\n <AdminWithConfig>\n <base.ApplyPublicConfig />\n <Original>{children}</Original>\n </AdminWithConfig>\n );\n };\n});\n\nconst lexicalTokens = createLexicalTokens(\"wa-lx-\");\n\nexport const useAdminConfig = () => {\n const baseConfig = base.useConfig();\n\n const lexicalTheme: EditorTheme = {\n colors: baseConfig.lexicalTheme?.colors,\n typography: baseConfig.lexicalTheme?.typography || {},\n fontSizes: [],\n tokens: lexicalTokens,\n allowCustomColors: baseConfig.lexicalTheme?.allowCustomColors ?? false\n };\n\n return {\n menus: baseConfig.menus ?? [],\n userMenus: baseConfig.userMenus ?? [],\n supportMenus: baseConfig.supportMenus ?? [],\n title: baseConfig.title,\n logo: {\n squareLogo: baseConfig.squareLogo,\n horizontalLogo: baseConfig.horizontalLogo\n },\n widgets: baseConfig.widgets ?? [],\n permissionRenderers: baseConfig.permissionRenderers ?? [],\n lexicalTheme,\n dialogs: baseConfig.dialogs ?? [],\n drawers: baseConfig.drawers ?? [],\n fieldRenderers: baseConfig.fieldRenderers ?? [],\n layoutRenderers: baseConfig.layoutRenderers ?? []\n };\n};\n\nexport interface PublicProps {\n children: React.ReactNode;\n}\n\nexport const Public = ({ children }: PublicProps) => {\n return <base.PublicConfig>{children}</base.PublicConfig>;\n};\n\nexport interface PrivateProps {\n children: React.ReactNode;\n}\n\nexport const Private = ({ children }: PrivateProps) => {\n return <base.PrivateConfig>{children}</base.PrivateConfig>;\n};\n\nexport const AdminConfig = Object.assign(Private, {\n Public,\n Theme,\n Menu,\n Route,\n Tenant,\n Title,\n Logo,\n Dashboard,\n Security,\n LexicalTheme,\n Dialog,\n Drawer,\n Form,\n useAdminConfig\n});\n"],"names":["base","createAdminConfig","AdminWithConfig","Object","AdminConfigPlugin","AdminConfigProvider","createProvider","Original","children","lexicalTokens","createLexicalTokens","useAdminConfig","baseConfig","lexicalTheme","Public","Private","AdminConfig","Theme","Menu","Route","Tenant","Title","Logo","Dashboard","Security","LexicalTheme","Dialog","Drawer","Form"],"mappings":";;;;;;;;;;;;;;;;AA2BA,MAAMA,OAAOC;AAEN,MAAMC,kBAAkBC,OAAO,MAAM,CAACH,KAAK,UAAU,EAAE;IAC1D,aAAa;AACjB;AAoBO,MAAMI,oBAAoB,
|
|
1
|
+
{"version":3,"file":"config/AdminConfig.js","sources":["../../src/config/AdminConfig.tsx"],"sourcesContent":["import React from \"react\";\nimport { createProvider } from \"@webiny/app\";\nimport { Menu, type MenuConfig } from \"./AdminConfig/Menu.js\";\nimport type { TenantConfig } from \"./AdminConfig/Tenant.js\";\nimport { Tenant } from \"./AdminConfig/Tenant.js\";\nimport type { SupportMenuConfig } from \"./AdminConfig/Menu/SupportMenu.js\";\nimport type { UserMenuConfig } from \"./AdminConfig/Menu/UserMenu.js\";\nimport { Route } from \"./AdminConfig/Route.js\";\nimport { Theme } from \"./AdminConfig/Theme.js\";\nimport { Dashboard } from \"./AdminConfig/Dashboard.js\";\nimport { type WidgetConfig } from \"./AdminConfig/Widget.js\";\nimport { Security } from \"./AdminConfig/Security.js\";\nimport type { PermissionRendererConfig } from \"../permissions/types.js\";\nimport { LexicalTheme } from \"./AdminConfig/LexicalTheme.js\";\nimport { Title } from \"./AdminConfig/Title.js\";\nimport { Logo } from \"./AdminConfig/Logo.js\";\nimport { Dialog } from \"./AdminConfig/Dialog.js\";\nimport type { DialogConfig } from \"./AdminConfig/Dialog.js\";\nimport { Drawer } from \"./AdminConfig/Drawer.js\";\nimport type { DrawerConfig } from \"./AdminConfig/Drawer.js\";\nimport { Form } from \"./AdminConfig/Form.js\";\nimport type { FieldRendererConfig } from \"./AdminConfig/FieldRenderer.js\";\nimport type { LayoutRendererConfig } from \"./AdminConfig/LayoutRenderer.js\";\nimport { createAdminConfig } from \"./createAdminConfig.js\";\nimport type { EditorTheme } from \"@webiny/lexical-theme\";\nimport { createLexicalTokens } from \"@webiny/lexical-theme/createLexicalEditorTokens.js\";\n\nconst base = createAdminConfig<AdminConfig>();\n\nexport const AdminWithConfig = Object.assign(base.WithConfig, {\n displayName: \"AdminWithConfig\"\n});\n\ninterface AdminConfig {\n menus: MenuConfig[];\n supportMenus: SupportMenuConfig[];\n userMenus: UserMenuConfig[];\n tenant: TenantConfig;\n title: string;\n squareLogo: React.ReactNode;\n horizontalLogo: React.ReactNode;\n widgets: WidgetConfig[];\n permissionRenderers: PermissionRendererConfig[];\n lexicalTheme: EditorTheme;\n dialogs: DialogConfig[];\n drawers: DrawerConfig[];\n fieldRenderers: FieldRendererConfig[];\n layoutRenderers: LayoutRendererConfig[];\n}\n\n/* Once the app fully renders (after the LoginScreen), apply protected configs. */\nexport const AdminConfigPlugin = <base.ApplyProtectedConfig />;\n\nexport const AdminConfigProvider = createProvider(Original => {\n return function AdminConfigProvider({ children }) {\n return (\n <AdminWithConfig>\n <base.ApplyPublicConfig />\n <Original>{children}</Original>\n </AdminWithConfig>\n );\n };\n});\n\nconst lexicalTokens = createLexicalTokens(\"wa-lx-\");\n\nexport const useAdminConfig = () => {\n const baseConfig = base.useConfig();\n\n const lexicalTheme: EditorTheme = {\n colors: baseConfig.lexicalTheme?.colors,\n typography: baseConfig.lexicalTheme?.typography || {},\n fontSizes: [],\n tokens: lexicalTokens,\n allowCustomColors: baseConfig.lexicalTheme?.allowCustomColors ?? false\n };\n\n return {\n menus: baseConfig.menus ?? [],\n userMenus: baseConfig.userMenus ?? [],\n supportMenus: baseConfig.supportMenus ?? [],\n title: baseConfig.title,\n logo: {\n squareLogo: baseConfig.squareLogo,\n horizontalLogo: baseConfig.horizontalLogo\n },\n widgets: baseConfig.widgets ?? [],\n permissionRenderers: baseConfig.permissionRenderers ?? [],\n lexicalTheme,\n dialogs: baseConfig.dialogs ?? [],\n drawers: baseConfig.drawers ?? [],\n fieldRenderers: baseConfig.fieldRenderers ?? [],\n layoutRenderers: baseConfig.layoutRenderers ?? []\n };\n};\n\nexport interface PublicProps {\n children: React.ReactNode;\n}\n\nexport const Public = ({ children }: PublicProps) => {\n return <base.PublicConfig>{children}</base.PublicConfig>;\n};\n\nexport interface PrivateProps {\n children: React.ReactNode;\n}\n\nexport const Private = ({ children }: PrivateProps) => {\n return <base.PrivateConfig>{children}</base.PrivateConfig>;\n};\n\nexport const AdminConfig = Object.assign(Private, {\n Public,\n Theme,\n Menu,\n Route,\n Tenant,\n Title,\n Logo,\n Dashboard,\n Security,\n LexicalTheme,\n Dialog,\n Drawer,\n Form,\n useAdminConfig\n});\n"],"names":["base","createAdminConfig","AdminWithConfig","Object","AdminConfigPlugin","AdminConfigProvider","createProvider","Original","children","lexicalTokens","createLexicalTokens","useAdminConfig","baseConfig","lexicalTheme","Public","Private","AdminConfig","Theme","Menu","Route","Tenant","Title","Logo","Dashboard","Security","LexicalTheme","Dialog","Drawer","Form"],"mappings":";;;;;;;;;;;;;;;;AA2BA,MAAMA,OAAOC;AAEN,MAAMC,kBAAkBC,OAAO,MAAM,CAACH,KAAK,UAAU,EAAE;IAC1D,aAAa;AACjB;AAoBO,MAAMI,oBAAoB,WAApBA,GAAoB,oBAACJ,KAAK,oBAAoB;AAEpD,MAAMK,kCAAsBC,eAAeC,CAAAA,WACvC,SAA6B,EAAEC,QAAQ,EAAE;QAC5C,OAAO,WAAP,GACI,oBAACN,iBAAAA,MAAAA,WAAAA,GACG,oBAACF,KAAK,iBAAiB,uBACvB,oBAACO,UAAAA,MAAUC;IAGvB;AAGJ,MAAMC,gBAAgBC,oBAAoB;AAEnC,MAAMC,iBAAiB;IAC1B,MAAMC,aAAaZ,KAAK,SAAS;IAEjC,MAAMa,eAA4B;QAC9B,QAAQD,WAAW,YAAY,EAAE;QACjC,YAAYA,WAAW,YAAY,EAAE,cAAc,CAAC;QACpD,WAAW,EAAE;QACb,QAAQH;QACR,mBAAmBG,WAAW,YAAY,EAAE,qBAAqB;IACrE;IAEA,OAAO;QACH,OAAOA,WAAW,KAAK,IAAI,EAAE;QAC7B,WAAWA,WAAW,SAAS,IAAI,EAAE;QACrC,cAAcA,WAAW,YAAY,IAAI,EAAE;QAC3C,OAAOA,WAAW,KAAK;QACvB,MAAM;YACF,YAAYA,WAAW,UAAU;YACjC,gBAAgBA,WAAW,cAAc;QAC7C;QACA,SAASA,WAAW,OAAO,IAAI,EAAE;QACjC,qBAAqBA,WAAW,mBAAmB,IAAI,EAAE;QACzDC;QACA,SAASD,WAAW,OAAO,IAAI,EAAE;QACjC,SAASA,WAAW,OAAO,IAAI,EAAE;QACjC,gBAAgBA,WAAW,cAAc,IAAI,EAAE;QAC/C,iBAAiBA,WAAW,eAAe,IAAI,EAAE;IACrD;AACJ;AAMO,MAAME,SAAS,CAAC,EAAEN,QAAQ,EAAe,GACrC,WAAP,GAAO,oBAACR,KAAK,YAAY,QAAEQ;AAOxB,MAAMO,UAAU,CAAC,EAAEP,QAAQ,EAAgB,GACvC,WAAP,GAAO,oBAACR,KAAK,aAAa,QAAEQ;AAGzB,MAAMQ,cAAcb,OAAO,MAAM,CAACY,SAAS;IAC9CD;IACAG,OAAKA;IACLC,MAAIA;IACJC,OAAKA;IACLC,QAAMA;IACNC,OAAKA;IACLC,MAAIA;IACJC,WAASA;IACTC,UAAQA;IACRC,cAAYA;IACZC,QAAMA;IACNC,QAAMA;IACNC,MAAIA;IACJjB;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config/createAdminConfig.js","sources":["../../src/config/createAdminConfig.tsx"],"sourcesContent":["import React, { useContext, useEffect, useMemo, useState } from \"react\";\nimport type { Decorator } from \"@webiny/react-composition\";\nimport { Compose, makeDecoratable } from \"@webiny/react-composition\";\nimport type { GenericComponent } from \"@webiny/react-composition/types.js\";\nimport type { Property } from \"@webiny/react-properties\";\nimport { Properties, toObject, useDebugConfig } from \"@webiny/react-properties\";\n\nconst createHOC = (\n newChildren: React.ReactNode\n): Decorator<GenericComponent<{ children?: React.ReactNode }>> => {\n return BaseComponent => {\n return function ConfigHOC({ children }) {\n return (\n <BaseComponent>\n {newChildren}\n {children}\n </BaseComponent>\n );\n };\n };\n};\n\nexport interface WithConfigProps {\n children: React.ReactNode;\n onProperties?(properties: Property[]): void;\n}\n\ninterface ConfigApplyProps {\n children?: React.ReactNode;\n}\n\nexport interface ConfigProps {\n children: React.ReactNode;\n}\n\nconst name = \"AdminConfig\";\n\nexport function createAdminConfig<TConfig>() {\n /**\n * This component is used when we want to mount all composed configs.\n */\n const ApplyPublicConfig = makeDecoratable(\n `${name}Apply<Public>`,\n ({ children }: ConfigApplyProps) => {\n return <>{children}</>;\n }\n );\n\n const ApplyProtectedConfig = makeDecoratable(\n `${name}Apply<Protected>`,\n ({ children }: ConfigApplyProps) => {\n return <>{children}</>;\n }\n );\n\n /**\n * This component is used to configure the component (it can be mounted many times).\n */\n const PublicConfig = ({ children }: ConfigProps) => {\n return <Compose component={ApplyPublicConfig} with={createHOC(children)} />;\n };\n\n const ProtectedConfig = ({ children }: ConfigProps) => {\n return <Compose component={ApplyProtectedConfig} with={createHOC(children)} />;\n };\n\n interface ViewContext {\n name: string;\n properties: Property[];\n }\n\n const defaultContext = { name, properties: [] };\n\n const ViewContext = React.createContext<ViewContext>(defaultContext);\n\n const WithConfig = ({ onProperties, children }: WithConfigProps) => {\n const [properties, setProperties] = useState<Property[]>([]);\n useDebugConfig(name, properties);\n const context = { name, properties };\n\n useEffect(() => {\n if (typeof onProperties === \"function\") {\n onProperties(properties);\n }\n }, [properties]);\n\n const stateUpdater = (properties: Property[]) => {\n setProperties(properties);\n };\n\n return (\n <ViewContext.Provider value={context}>\n <Properties onChange={stateUpdater} name={name}>\n {children}\n </Properties>\n </ViewContext.Provider>\n );\n };\n\n function useConfig<TExtra extends object>(): TConfig & TExtra {\n const { properties } = useContext(ViewContext);\n return useMemo(() => toObject<TConfig & TExtra>(properties), [properties]);\n }\n\n return {\n WithConfig,\n PrivateConfig: ProtectedConfig,\n PublicConfig,\n ApplyPublicConfig,\n ApplyProtectedConfig,\n useConfig\n };\n}\n"],"names":["createHOC","newChildren","BaseComponent","children","name","createAdminConfig","ApplyPublicConfig","makeDecoratable","ApplyProtectedConfig","PublicConfig","Compose","ProtectedConfig","defaultContext","ViewContext","React","WithConfig","onProperties","properties","setProperties","useState","useDebugConfig","context","useEffect","stateUpdater","Properties","useConfig","useContext","useMemo","toObject"],"mappings":";;;AAOA,MAAMA,YAAY,CACdC,cAEOC,CAAAA,gBACI,SAAmB,EAAEC,QAAQ,EAAE;YAClC,OAAO,WAAP,GACI,oBAACD,eAAAA,MACID,aACAE;QAGb;AAiBR,MAAMC,yBAAO;AAEN,SAASC;IAIZ,MAAMC,oBAAoBC,gBACtB,GAAGH,uBAAK,aAAa,CAAC,EACtB,CAAC,EAAED,QAAQ,EAAoB,GACpB,WAAP,GAAO,0CAAGA;IAIlB,MAAMK,uBAAuBD,gBACzB,GAAGH,uBAAK,gBAAgB,CAAC,EACzB,CAAC,EAAED,QAAQ,EAAoB,GACpB,WAAP,GAAO,0CAAGA;IAOlB,MAAMM,eAAe,CAAC,EAAEN,QAAQ,EAAe,GACpC,WAAP,GAAO,oBAACO,SAAOA;YAAC,WAAWJ;YAAmB,MAAMN,UAAUG;;IAGlE,MAAMQ,kBAAkB,CAAC,EAAER,QAAQ,EAAe,GACvC,WAAP,GAAO,oBAACO,SAAOA;YAAC,WAAWF;YAAsB,MAAMR,UAAUG;;IAQrE,MAAMS,iBAAiB;QAAER,
|
|
1
|
+
{"version":3,"file":"config/createAdminConfig.js","sources":["../../src/config/createAdminConfig.tsx"],"sourcesContent":["import React, { useContext, useEffect, useMemo, useState } from \"react\";\nimport type { Decorator } from \"@webiny/react-composition\";\nimport { Compose, makeDecoratable } from \"@webiny/react-composition\";\nimport type { GenericComponent } from \"@webiny/react-composition/types.js\";\nimport type { Property } from \"@webiny/react-properties\";\nimport { Properties, toObject, useDebugConfig } from \"@webiny/react-properties\";\n\nconst createHOC = (\n newChildren: React.ReactNode\n): Decorator<GenericComponent<{ children?: React.ReactNode }>> => {\n return BaseComponent => {\n return function ConfigHOC({ children }) {\n return (\n <BaseComponent>\n {newChildren}\n {children}\n </BaseComponent>\n );\n };\n };\n};\n\nexport interface WithConfigProps {\n children: React.ReactNode;\n onProperties?(properties: Property[]): void;\n}\n\ninterface ConfigApplyProps {\n children?: React.ReactNode;\n}\n\nexport interface ConfigProps {\n children: React.ReactNode;\n}\n\nconst name = \"AdminConfig\";\n\nexport function createAdminConfig<TConfig>() {\n /**\n * This component is used when we want to mount all composed configs.\n */\n const ApplyPublicConfig = makeDecoratable(\n `${name}Apply<Public>`,\n ({ children }: ConfigApplyProps) => {\n return <>{children}</>;\n }\n );\n\n const ApplyProtectedConfig = makeDecoratable(\n `${name}Apply<Protected>`,\n ({ children }: ConfigApplyProps) => {\n return <>{children}</>;\n }\n );\n\n /**\n * This component is used to configure the component (it can be mounted many times).\n */\n const PublicConfig = ({ children }: ConfigProps) => {\n return <Compose component={ApplyPublicConfig} with={createHOC(children)} />;\n };\n\n const ProtectedConfig = ({ children }: ConfigProps) => {\n return <Compose component={ApplyProtectedConfig} with={createHOC(children)} />;\n };\n\n interface ViewContext {\n name: string;\n properties: Property[];\n }\n\n const defaultContext = { name, properties: [] };\n\n const ViewContext = React.createContext<ViewContext>(defaultContext);\n\n const WithConfig = ({ onProperties, children }: WithConfigProps) => {\n const [properties, setProperties] = useState<Property[]>([]);\n useDebugConfig(name, properties);\n const context = { name, properties };\n\n useEffect(() => {\n if (typeof onProperties === \"function\") {\n onProperties(properties);\n }\n }, [properties]);\n\n const stateUpdater = (properties: Property[]) => {\n setProperties(properties);\n };\n\n return (\n <ViewContext.Provider value={context}>\n <Properties onChange={stateUpdater} name={name}>\n {children}\n </Properties>\n </ViewContext.Provider>\n );\n };\n\n function useConfig<TExtra extends object>(): TConfig & TExtra {\n const { properties } = useContext(ViewContext);\n return useMemo(() => toObject<TConfig & TExtra>(properties), [properties]);\n }\n\n return {\n WithConfig,\n PrivateConfig: ProtectedConfig,\n PublicConfig,\n ApplyPublicConfig,\n ApplyProtectedConfig,\n useConfig\n };\n}\n"],"names":["createHOC","newChildren","BaseComponent","children","name","createAdminConfig","ApplyPublicConfig","makeDecoratable","ApplyProtectedConfig","PublicConfig","Compose","ProtectedConfig","defaultContext","ViewContext","React","WithConfig","onProperties","properties","setProperties","useState","useDebugConfig","context","useEffect","stateUpdater","Properties","useConfig","useContext","useMemo","toObject"],"mappings":";;;AAOA,MAAMA,YAAY,CACdC,cAEOC,CAAAA,gBACI,SAAmB,EAAEC,QAAQ,EAAE;YAClC,OAAO,WAAP,GACI,oBAACD,eAAAA,MACID,aACAE;QAGb;AAiBR,MAAMC,yBAAO;AAEN,SAASC;IAIZ,MAAMC,oBAAoBC,gBACtB,GAAGH,uBAAK,aAAa,CAAC,EACtB,CAAC,EAAED,QAAQ,EAAoB,GACpB,WAAP,GAAO,0CAAGA;IAIlB,MAAMK,uBAAuBD,gBACzB,GAAGH,uBAAK,gBAAgB,CAAC,EACzB,CAAC,EAAED,QAAQ,EAAoB,GACpB,WAAP,GAAO,0CAAGA;IAOlB,MAAMM,eAAe,CAAC,EAAEN,QAAQ,EAAe,GACpC,WAAP,GAAO,oBAACO,SAAOA;YAAC,WAAWJ;YAAmB,MAAMN,UAAUG;;IAGlE,MAAMQ,kBAAkB,CAAC,EAAER,QAAQ,EAAe,GACvC,WAAP,GAAO,oBAACO,SAAOA;YAAC,WAAWF;YAAsB,MAAMR,UAAUG;;IAQrE,MAAMS,iBAAiB;QAAER,MAAIA;QAAE,YAAY,EAAE;IAAC;IAE9C,MAAMS,cAAc,WAAdA,GAAcC,MAAAA,aAAmB,CAAcF;IAErD,MAAMG,aAAa,CAAC,EAAEC,YAAY,EAAEb,QAAQ,EAAmB;QAC3D,MAAM,CAACc,YAAYC,cAAc,GAAGC,SAAqB,EAAE;QAC3DC,eAAehB,wBAAMa;QACrB,MAAMI,UAAU;YAAEjB,MAAIA;YAAEa;QAAW;QAEnCK,UAAU;YACN,IAAI,AAAwB,cAAxB,OAAON,cACPA,aAAaC;QAErB,GAAG;YAACA;SAAW;QAEf,MAAMM,eAAe,CAACN;YAClBC,cAAcD;QAClB;QAEA,OAAO,WAAP,GACI,oBAACJ,YAAY,QAAQ;YAAC,OAAOQ;yBACzB,oBAACG,YAAUA;YAAC,UAAUD;YAAc,MAAMnB;WACrCD;IAIjB;IAEA,SAASsB;QACL,MAAM,EAAER,UAAU,EAAE,GAAGS,WAAWb;QAClC,OAAOc,QAAQ,IAAMC,SAA2BX,aAAa;YAACA;SAAW;IAC7E;IAEA,OAAO;QACHF;QACA,eAAeJ;QACfF;QACAH;QACAE;QACAiB;IACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/accessManagement/constants.js","sources":["../../../src/features/accessManagement/constants.ts"],"sourcesContent":["export enum Permission {\n Roles = \"security.role\",\n Teams = \"security.team\",\n ApiKeys = \"security.apiKey\"\n}\n"],"names":["Permission"],"mappings":"AAAO,IAAKA,uBAAUA,WAAAA,GAAAA,
|
|
1
|
+
{"version":3,"file":"features/accessManagement/constants.js","sources":["../../../src/features/accessManagement/constants.ts"],"sourcesContent":["export enum Permission {\n Roles = \"security.role\",\n Teams = \"security.team\",\n ApiKeys = \"security.apiKey\"\n}\n"],"names":["Permission"],"mappings":"AAAO,IAAKA,uBAAUA,WAAAA,GAAAA,SAAAA,UAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/formModel/FormView.js","sources":["../../../src/features/formModel/FormView.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport {\n Alert,\n Grid,\n IconButton,\n Separator,\n Tabs,\n Text,\n Tooltip,\n useToast\n} from \"@webiny/admin-ui\";\nimport { ReactComponent as CopyIcon } from \"@webiny/icons/content_copy.svg\";\nimport { ReactComponent as PasteIcon } from \"@webiny/icons/content_paste.svg\";\nimport { DevToolsSection } from \"@webiny/react-properties\";\nimport type {\n IFormVM,\n LayoutNodeVM,\n IRowNodeVM,\n IFieldVM,\n ITabsNodeVM,\n ISeparatorNodeVM,\n IAlertNodeVM,\n IElementNodeVM\n} from \"./abstractions.js\";\nimport type { Icon } from \"~/components/IconPicker/types.js\";\nimport type { IconProp } from \"@fortawesome/fontawesome-svg-core\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport { DeveloperMode } from \"~/components/DeveloperMode/DeveloperMode.js\";\nimport { useFieldRenderers } from \"~/features/formModel/useFieldRenderers.js\";\nimport { useLayoutRenderers } from \"~/features/formModel/useLayoutRenderers.js\";\n\nexport function renderTabIcon(icon: Icon | undefined): React.ReactElement | undefined {\n if (!icon || typeof icon.name !== \"string\") {\n return undefined;\n }\n return <FontAwesomeIcon icon={icon.name.split(\"/\") as IconProp} />;\n}\n\n/**\n * A field renderer component receives a FieldVM and renders the appropriate UI.\n */\nexport type FieldRendererComponent = React.ComponentType<{ field: IFieldVM }>;\n\n/**\n * Map of renderer keys to React components for fields.\n * Lookup order: `{type}:{renderer}` → `{type}`.\n */\nexport type FieldRenderers = Record<string, FieldRendererComponent>;\n\n/**\n * Map of renderer keys to React components for layout nodes.\n */\nexport type LayoutRenderers = Record<string, React.ComponentType<any>>;\n\ninterface FormViewRenderers {\n fieldRenderers: FieldRenderers;\n layoutRenderers: LayoutRenderers;\n}\n\nconst FormViewRenderersContext = createContext<FormViewRenderers | null>(null);\n\nconst useFormViewRenderers = (): FormViewRenderers => {\n const ctx = useContext(FormViewRenderersContext);\n if (!ctx) {\n throw new Error(\"useFormViewRenderers must be used within a FormView.\");\n }\n return ctx;\n};\n\nexport { useFormViewRenderers };\n\ninterface FormViewProps {\n name: string;\n form: IFormVM;\n renderers?: FieldRenderers;\n layoutRenderers?: LayoutRenderers;\n}\n\n/**\n * Generic form view that walks layout nodes and renders fields.\n * This component is stateless — it reads from the FormVM and delegates to renderers.\n */\nexport const FormView = observer(({ name, form, renderers, layoutRenderers }: FormViewProps) => {\n const defaultFieldRenderers = useFieldRenderers();\n const defaultLayoutRenderers = useLayoutRenderers();\n\n const value = useMemo(\n () => ({\n fieldRenderers: renderers ?? defaultFieldRenderers,\n layoutRenderers: layoutRenderers ?? defaultLayoutRenderers\n }),\n [renderers, defaultFieldRenderers, layoutRenderers, defaultLayoutRenderers]\n );\n\n return (\n <FormViewRenderersContext.Provider value={value}>\n <DevToolsSection name={name} group=\"Forms\" data={form.getData()} views={\"raw\"} />\n <div className=\"w-full relative flex flex-col gap-4\">\n <DevModeTools form={form} />\n {form.layout.map((node, index) => (\n <LayoutNodeRenderer key={index} node={node} />\n ))}\n </div>\n </FormViewRenderersContext.Provider>\n );\n});\n\nexport const LayoutNodeRenderer = observer(({ node }: { node: LayoutNodeVM }) => {\n switch (node.type) {\n case \"row\":\n return <RowNodeRenderer node={node} />;\n case \"separator\":\n return <SeparatorNodeRenderer node={node} />;\n case \"alert\":\n return <AlertNodeRenderer node={node} />;\n case \"tabs\":\n return <TabsNodeRenderer node={node} />;\n case \"element\":\n return <ElementNodeRenderer node={node} />;\n default:\n return null;\n }\n});\n\nconst RowNodeRenderer = observer(({ node }: { node: IRowNodeVM }) => {\n const { fieldRenderers } = useFormViewRenderers();\n\n return (\n <Grid>\n {node.fields.map(field => {\n const span = Math.floor(12 / node.fields.length) as React.ComponentProps<\n typeof Grid.Column\n >[\"span\"];\n\n return (\n <Grid.Column key={field.name} span={span}>\n <FieldRenderer field={field} renderers={fieldRenderers} />\n </Grid.Column>\n );\n })}\n </Grid>\n );\n});\n\ninterface FieldRendererProps {\n field: IFieldVM;\n renderers: FieldRenderers;\n}\n\nconst FieldRenderer = observer(({ field, renderers }: FieldRendererProps) => {\n const Renderer = field.renderer ? renderers[field.renderer] : undefined;\n\n if (!Renderer) {\n if (process.env.NODE_ENV === \"development\") {\n console.warn(\n `[FormView] No renderer found for field \"${field.name}\" (renderer: \"${field.renderer || \"none\"}\").`\n );\n }\n return null;\n }\n\n return <Renderer field={field} />;\n});\n\nconst SeparatorNodeRenderer = observer(function SeparatorNodeRenderer({\n node\n}: {\n node: ISeparatorNodeVM;\n}) {\n if (node.title) {\n return (\n <div>\n <Separator variant={\"accent\"} labelPosition={\"start\"}>\n {node.title}\n </Separator>\n {node.description ? (\n <Text size={\"sm\"} className={\"mt-xs\"}>\n {node.description}\n </Text>\n ) : null}\n </div>\n );\n }\n return <Separator variant={\"dimmed\"} />;\n});\n\nconst AlertNodeRenderer = observer(function AlertNodeRenderer({ node }: { node: IAlertNodeVM }) {\n if (!node.message) {\n return null;\n }\n return <Alert type={node.alertType}>{node.message}</Alert>;\n});\n\nexport interface TabsNodeRendererProps {\n node: ITabsNodeVM;\n}\n\nconst TabsNodeRenderer = observer(({ node }: TabsNodeRendererProps) => {\n const { layoutRenderers } = useFormViewRenderers();\n\n if (node.renderer) {\n const CustomRenderer = layoutRenderers[node.renderer];\n if (CustomRenderer) {\n return <CustomRenderer node={node} />;\n }\n }\n\n return (\n <Tabs\n value={node.activeTabId}\n onValueChange={id => node.setActiveTab(id)}\n tabs={node.tabs.map(tab => (\n <Tabs.Tab\n key={tab.id}\n value={tab.id}\n icon={renderTabIcon(tab.icon)}\n trigger={\n <>\n {tab.label}\n {tab.hasErrors && (\n <span className=\"ml-1 text-destructive-default text-xs\">*</span>\n )}\n </>\n }\n disabled={tab.disabled}\n content={\n <div className={\"flex flex-col gap-4 mt-md\"}>\n {tab.layout.map((childNode, index) => (\n <LayoutNodeRenderer key={index} node={childNode} />\n ))}\n </div>\n }\n />\n ))}\n />\n );\n});\n\nconst ElementNodeRenderer = observer(({ node }: { node: IElementNodeVM }) => {\n const { fieldRenderers } = useFormViewRenderers();\n const Renderer = fieldRenderers[`element:${node.renderer}`];\n\n if (!Renderer) {\n if (process.env.NODE_ENV === \"development\") {\n console.warn(`[FormView] No renderer found for element \"${node.renderer}\".`);\n }\n return null;\n }\n\n return <Renderer field={{ ...node.props } as any} />;\n});\n\ninterface DevModelToolsProps {\n form: IFormVM;\n}\n\nconst DevModeTools = ({ form }: DevModelToolsProps) => {\n const toast = useToast();\n\n const handleCopy = () => {\n const data = form.getData();\n navigator.clipboard.writeText(JSON.stringify(data, null, 2));\n toast.showSuccessToast({ title: \"Form data copied to clipboard.\" });\n };\n\n const handlePaste = async () => {\n try {\n const text = await navigator.clipboard.readText();\n const data = JSON.parse(text);\n form.setData(data);\n toast.showSuccessToast({ title: \"Form data imported from clipboard.\" });\n } catch {\n toast.showWarningToast({\n title: \"Failed to import. Make sure clipboard contains valid JSON.\"\n });\n }\n };\n return (\n <DeveloperMode>\n <div className=\"absolute top-0 right-0 w-[200px] h-[80px] z-10 group/devtools\">\n <div className=\"absolute top-0 right-0 flex gap-xs opacity-0 group-hover/devtools:opacity-100 transition-opacity\">\n <Tooltip\n content=\"Copy form data to clipboard\"\n trigger={\n <IconButton\n variant={\"secondary\"}\n icon={<CopyIcon />}\n onClick={handleCopy}\n size=\"sm\"\n />\n }\n />\n <Tooltip\n content=\"Paste form data from clipboard\"\n trigger={\n <IconButton\n variant={\"secondary\"}\n icon={<PasteIcon />}\n onClick={handlePaste}\n size=\"sm\"\n />\n }\n />\n </div>\n </div>\n </DeveloperMode>\n );\n};\n"],"names":["renderTabIcon","icon","FontAwesomeIcon","FormViewRenderersContext","createContext","useFormViewRenderers","ctx","useContext","Error","FormView","observer","name","form","renderers","layoutRenderers","defaultFieldRenderers","useFieldRenderers","defaultLayoutRenderers","useLayoutRenderers","value","useMemo","DevToolsSection","DevModeTools","node","index","LayoutNodeRenderer","RowNodeRenderer","SeparatorNodeRenderer","AlertNodeRenderer","TabsNodeRenderer","ElementNodeRenderer","fieldRenderers","Grid","field","span","Math","FieldRenderer","Renderer","undefined","process","console","Separator","Text","Alert","CustomRenderer","Tabs","id","tab","childNode","toast","useToast","handleCopy","data","navigator","JSON","handlePaste","text","DeveloperMode","Tooltip","IconButton","CopyIcon","PasteIcon"],"mappings":";;;;;;;;;;AAgCO,SAASA,cAAcC,IAAsB;IAChD,IAAI,CAAC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,QAAQ,EAAE,CAAC;IAE3D,IAAI,CAACc,UAAU;QACX,IAAIE,AAAyB,kBAAzBA,QAAQ,GAAG,CAAC,QAAQ,EACpBC,QAAQ,IAAI,CAAC,CAAC,0CAA0C,EAAEjB,KAAK,QAAQ,CAAC,EAAE,CAAC;QAE/E,OAAO;IACX;IAEA,OAAO,WAAP,GAAO,oBAACc,UAAAA;QAAS,OAAO;YAAE,GAAGd,KAAK,KAAK;QAAC;;AAC5C;AAMA,MAAMD,eAAe,CAAC,EAAEV,IAAI,EAAsB;IAC9C,MAAMqC,QAAQC;IAEd,MAAMC,aAAa;QACf,MAAMC,OAAOxC,KAAK,OAAO;QACzByC,UAAU,SAAS,CAAC,SAAS,CAACC,KAAK,SAAS,CAACF,MAAM,MAAM;QACzDH,MAAM,gBAAgB,CAAC;YAAE,OAAO;QAAiC;IACrE;IAEA,MAAMM,cAAc;QAChB,IAAI;YACA,MAAMC,OAAO,MAAMH,UAAU,SAAS,CAAC,QAAQ;YAC/C,MAAMD,OAAOE,KAAK,KAAK,CAACE;YACxB5C,KAAK,OAAO,CAACwC;YACbH,MAAM,gBAAgB,CAAC;gBAAE,OAAO;YAAqC;QACzE,EAAE,OAAM;YACJA,MAAM,gBAAgB,CAAC;gBACnB,OAAO;YACX;QACJ;IACJ;IACA,OAAO,WAAP,GACI,oBAACQ,eAAaA,MAAAA,WAAAA,GACV,oBAAC;QAAI,WAAU;qBACX,oBAAC;QAAI,WAAU;qBACX,oBAACC,SAAOA;QACJ,SAAQ;QACR,uBACI,oBAACC,YAAUA;YACP,SAAS;YACT,oBAAM,oBAACC,gBAAQA;YACf,SAAST;YACT,MAAK;;sBAIjB,oBAACO,SAAOA;QACJ,SAAQ;QACR,uBACI,oBAACC,YAAUA;YACP,SAAS;YACT,oBAAM,oBAACE,kCAASA;YAChB,SAASN;YACT,MAAK;;;AAQrC"}
|
|
1
|
+
{"version":3,"file":"features/formModel/FormView.js","sources":["../../../src/features/formModel/FormView.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport {\n Alert,\n Grid,\n IconButton,\n Separator,\n Tabs,\n Text,\n Tooltip,\n useToast\n} from \"@webiny/admin-ui\";\nimport { ReactComponent as CopyIcon } from \"@webiny/icons/content_copy.svg\";\nimport { ReactComponent as PasteIcon } from \"@webiny/icons/content_paste.svg\";\nimport { DevToolsSection } from \"@webiny/react-properties\";\nimport type {\n IFormVM,\n LayoutNodeVM,\n IRowNodeVM,\n IFieldVM,\n ITabsNodeVM,\n ISeparatorNodeVM,\n IAlertNodeVM,\n IElementNodeVM\n} from \"./abstractions.js\";\nimport type { Icon } from \"~/components/IconPicker/types.js\";\nimport type { IconProp } from \"@fortawesome/fontawesome-svg-core\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport { DeveloperMode } from \"~/components/DeveloperMode/DeveloperMode.js\";\nimport { useFieldRenderers } from \"~/features/formModel/useFieldRenderers.js\";\nimport { useLayoutRenderers } from \"~/features/formModel/useLayoutRenderers.js\";\n\nexport function renderTabIcon(icon: Icon | undefined): React.ReactElement | undefined {\n if (!icon || typeof icon.name !== \"string\") {\n return undefined;\n }\n return <FontAwesomeIcon icon={icon.name.split(\"/\") as IconProp} />;\n}\n\n/**\n * A field renderer component receives a FieldVM and renders the appropriate UI.\n */\nexport type FieldRendererComponent = React.ComponentType<{ field: IFieldVM }>;\n\n/**\n * Map of renderer keys to React components for fields.\n * Lookup order: `{type}:{renderer}` → `{type}`.\n */\nexport type FieldRenderers = Record<string, FieldRendererComponent>;\n\n/**\n * Map of renderer keys to React components for layout nodes.\n */\nexport type LayoutRenderers = Record<string, React.ComponentType<any>>;\n\ninterface FormViewRenderers {\n fieldRenderers: FieldRenderers;\n layoutRenderers: LayoutRenderers;\n}\n\nconst FormViewRenderersContext = createContext<FormViewRenderers | null>(null);\n\nconst useFormViewRenderers = (): FormViewRenderers => {\n const ctx = useContext(FormViewRenderersContext);\n if (!ctx) {\n throw new Error(\"useFormViewRenderers must be used within a FormView.\");\n }\n return ctx;\n};\n\nexport { useFormViewRenderers };\n\ninterface FormViewProps {\n name: string;\n form: IFormVM;\n renderers?: FieldRenderers;\n layoutRenderers?: LayoutRenderers;\n}\n\n/**\n * Generic form view that walks layout nodes and renders fields.\n * This component is stateless — it reads from the FormVM and delegates to renderers.\n */\nexport const FormView = observer(({ name, form, renderers, layoutRenderers }: FormViewProps) => {\n const defaultFieldRenderers = useFieldRenderers();\n const defaultLayoutRenderers = useLayoutRenderers();\n\n const value = useMemo(\n () => ({\n fieldRenderers: renderers ?? defaultFieldRenderers,\n layoutRenderers: layoutRenderers ?? defaultLayoutRenderers\n }),\n [renderers, defaultFieldRenderers, layoutRenderers, defaultLayoutRenderers]\n );\n\n return (\n <FormViewRenderersContext.Provider value={value}>\n <DevToolsSection name={name} group=\"Forms\" data={form.getData()} views={\"raw\"} />\n <div className=\"w-full relative flex flex-col gap-4\">\n <DevModeTools form={form} />\n {form.layout.map((node, index) => (\n <LayoutNodeRenderer key={index} node={node} />\n ))}\n </div>\n </FormViewRenderersContext.Provider>\n );\n});\n\nexport const LayoutNodeRenderer = observer(({ node }: { node: LayoutNodeVM }) => {\n switch (node.type) {\n case \"row\":\n return <RowNodeRenderer node={node} />;\n case \"separator\":\n return <SeparatorNodeRenderer node={node} />;\n case \"alert\":\n return <AlertNodeRenderer node={node} />;\n case \"tabs\":\n return <TabsNodeRenderer node={node} />;\n case \"element\":\n return <ElementNodeRenderer node={node} />;\n default:\n return null;\n }\n});\n\nconst RowNodeRenderer = observer(({ node }: { node: IRowNodeVM }) => {\n const { fieldRenderers } = useFormViewRenderers();\n\n return (\n <Grid>\n {node.fields.map(field => {\n const span = Math.floor(12 / node.fields.length) as React.ComponentProps<\n typeof Grid.Column\n >[\"span\"];\n\n return (\n <Grid.Column key={field.name} span={span}>\n <FieldRenderer field={field} renderers={fieldRenderers} />\n </Grid.Column>\n );\n })}\n </Grid>\n );\n});\n\ninterface FieldRendererProps {\n field: IFieldVM;\n renderers: FieldRenderers;\n}\n\nconst FieldRenderer = observer(({ field, renderers }: FieldRendererProps) => {\n const Renderer = field.renderer ? renderers[field.renderer] : undefined;\n\n if (!Renderer) {\n if (process.env.NODE_ENV === \"development\") {\n console.warn(\n `[FormView] No renderer found for field \"${field.name}\" (renderer: \"${field.renderer || \"none\"}\").`\n );\n }\n return null;\n }\n\n return <Renderer field={field} />;\n});\n\nconst SeparatorNodeRenderer = observer(function SeparatorNodeRenderer({\n node\n}: {\n node: ISeparatorNodeVM;\n}) {\n if (node.title) {\n return (\n <div>\n <Separator variant={\"accent\"} labelPosition={\"start\"}>\n {node.title}\n </Separator>\n {node.description ? (\n <Text size={\"sm\"} className={\"mt-xs\"}>\n {node.description}\n </Text>\n ) : null}\n </div>\n );\n }\n return <Separator variant={\"dimmed\"} />;\n});\n\nconst AlertNodeRenderer = observer(function AlertNodeRenderer({ node }: { node: IAlertNodeVM }) {\n if (!node.message) {\n return null;\n }\n return <Alert type={node.alertType}>{node.message}</Alert>;\n});\n\nexport interface TabsNodeRendererProps {\n node: ITabsNodeVM;\n}\n\nconst TabsNodeRenderer = observer(({ node }: TabsNodeRendererProps) => {\n const { layoutRenderers } = useFormViewRenderers();\n\n if (node.renderer) {\n const CustomRenderer = layoutRenderers[node.renderer];\n if (CustomRenderer) {\n return <CustomRenderer node={node} />;\n }\n }\n\n return (\n <Tabs\n value={node.activeTabId}\n onValueChange={id => node.setActiveTab(id)}\n tabs={node.tabs.map(tab => (\n <Tabs.Tab\n key={tab.id}\n value={tab.id}\n icon={renderTabIcon(tab.icon)}\n trigger={\n <>\n {tab.label}\n {tab.hasErrors && (\n <span className=\"ml-1 text-destructive-default text-xs\">*</span>\n )}\n </>\n }\n disabled={tab.disabled}\n content={\n <div className={\"flex flex-col gap-4 mt-md\"}>\n {tab.layout.map((childNode, index) => (\n <LayoutNodeRenderer key={index} node={childNode} />\n ))}\n </div>\n }\n />\n ))}\n />\n );\n});\n\nconst ElementNodeRenderer = observer(({ node }: { node: IElementNodeVM }) => {\n const { fieldRenderers } = useFormViewRenderers();\n const Renderer = fieldRenderers[`element:${node.renderer}`];\n\n if (!Renderer) {\n if (process.env.NODE_ENV === \"development\") {\n console.warn(`[FormView] No renderer found for element \"${node.renderer}\".`);\n }\n return null;\n }\n\n return <Renderer field={{ ...node.props } as any} />;\n});\n\ninterface DevModelToolsProps {\n form: IFormVM;\n}\n\nconst DevModeTools = ({ form }: DevModelToolsProps) => {\n const toast = useToast();\n\n const handleCopy = () => {\n const data = form.getData();\n navigator.clipboard.writeText(JSON.stringify(data, null, 2));\n toast.showSuccessToast({ title: \"Form data copied to clipboard.\" });\n };\n\n const handlePaste = async () => {\n try {\n const text = await navigator.clipboard.readText();\n const data = JSON.parse(text);\n form.setData(data);\n toast.showSuccessToast({ title: \"Form data imported from clipboard.\" });\n } catch {\n toast.showWarningToast({\n title: \"Failed to import. Make sure clipboard contains valid JSON.\"\n });\n }\n };\n return (\n <DeveloperMode>\n <div className=\"absolute top-0 right-0 w-[200px] h-[80px] z-10 group/devtools\">\n <div className=\"absolute top-0 right-0 flex gap-xs opacity-0 group-hover/devtools:opacity-100 transition-opacity\">\n <Tooltip\n content=\"Copy form data to clipboard\"\n trigger={\n <IconButton\n variant={\"secondary\"}\n icon={<CopyIcon />}\n onClick={handleCopy}\n size=\"sm\"\n />\n }\n />\n <Tooltip\n content=\"Paste form data from clipboard\"\n trigger={\n <IconButton\n variant={\"secondary\"}\n icon={<PasteIcon />}\n onClick={handlePaste}\n size=\"sm\"\n />\n }\n />\n </div>\n </div>\n </DeveloperMode>\n );\n};\n"],"names":["renderTabIcon","icon","FontAwesomeIcon","FormViewRenderersContext","createContext","useFormViewRenderers","ctx","useContext","Error","FormView","observer","name","form","renderers","layoutRenderers","defaultFieldRenderers","useFieldRenderers","defaultLayoutRenderers","useLayoutRenderers","value","useMemo","DevToolsSection","DevModeTools","node","index","LayoutNodeRenderer","RowNodeRenderer","SeparatorNodeRenderer","AlertNodeRenderer","TabsNodeRenderer","ElementNodeRenderer","fieldRenderers","Grid","field","span","Math","FieldRenderer","Renderer","undefined","process","console","Separator","Text","Alert","CustomRenderer","Tabs","id","tab","childNode","toast","useToast","handleCopy","data","navigator","JSON","handlePaste","text","DeveloperMode","Tooltip","IconButton","CopyIcon","PasteIcon"],"mappings":";;;;;;;;;;AAgCO,SAASA,cAAcC,IAAsB;IAChD,IAAI,CAACA,QAAQ,AAAqB,YAArB,OAAOA,KAAK,IAAI,EACzB;IAEJ,OAAO,WAAP,GAAO,oBAACC,iBAAeA;QAAC,MAAMD,KAAK,IAAI,CAAC,KAAK,CAAC;;AAClD;AAuBA,MAAME,2BAA2B,WAA3BA,GAA2BC,cAAwC;AAEzE,MAAMC,uBAAuB;IACzB,MAAMC,MAAMC,WAAWJ;IACvB,IAAI,CAACG,KACD,MAAM,IAAIE,MAAM;IAEpB,OAAOF;AACX;AAeO,MAAMG,WAAWC,SAAS,CAAC,EAAEC,IAAI,EAAEC,IAAI,EAAEC,SAAS,EAAEC,eAAe,EAAiB;IACvF,MAAMC,wBAAwBC;IAC9B,MAAMC,yBAAyBC;IAE/B,MAAMC,QAAQC,QACV,IAAO;YACH,gBAAgBP,aAAaE;YAC7B,iBAAiBD,mBAAmBG;QACxC,IACA;QAACJ;QAAWE;QAAuBD;QAAiBG;KAAuB;IAG/E,OAAO,WAAP,GACI,oBAACd,yBAAyB,QAAQ;QAAC,OAAOgB;qBACtC,oBAACE,iBAAeA;QAAC,MAAMV;QAAM,OAAM;QAAQ,MAAMC,KAAK,OAAO;QAAI,OAAO;sBACxE,oBAAC;QAAI,WAAU;qBACX,oBAACU,cAAAA;QAAa,MAAMV;QACnBA,KAAK,MAAM,CAAC,GAAG,CAAC,CAACW,MAAMC,QAAAA,WAAAA,GACpB,oBAACC,oBAAAA;YAAmB,KAAKD;YAAO,MAAMD;;AAK1D;AAEO,MAAME,qBAAqBf,SAAS,CAAC,EAAEa,IAAI,EAA0B;IACxE,OAAQA,K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P,SAAS;YACT,oBAAM,oBAACC,gBAAQA;YACf,SAAST;YACT,MAAK;;sBAIjB,oBAACO,SAAOA;QACJ,SAAQ;QACR,uBACI,oBAACC,YAAUA;YACP,SAAS;YACT,oBAAM,oBAACE,kCAASA;YAChB,SAASN;YACT,MAAK;;;AAQrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/formModel/createFieldRenderer.js","sources":["../../../src/features/formModel/createFieldRenderer.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport type { IFieldVM, IObjectFieldVM, FieldRendererSettings } from \"./abstractions.js\";\n\n/**\n * Decoratable wrapper rendered around every leaf field's content. Features can decorate it to\n * inject per-field UI (e.g. a comment marker) keyed on `field.qualifiedName`, without forking\n * the form. By default it renders the field content unchanged.\n */\nexport const FormFieldWrapper = makeDecoratable(\n \"FormFieldWrapper\",\n ({ children }: { field: IFieldVM; children?: React.ReactNode }) => {\n return <>{children}</>;\n }\n);\n\ntype RendererField<TName extends string> = IFieldVM & {\n rendererSettings: FieldRendererSettings<TName>;\n};\n\ntype ObjectRendererField<TName extends string> = IObjectFieldVM & {\n rendererSettings: FieldRendererSettings<TName>;\n};\n\ntype FieldRendererFn<TName extends string> = (props: {\n field: RendererField<TName>;\n}) => React.ReactNode;\n\n// How long the field stays visually highlighted after focus lands, so the user's eye is drawn\n// to where \"jump to field\" (a comment locator, a form error) scrolled to.\nconst FOCUS_HIGHLIGHT_MS = 1800;\n\n// A 6px tint around the field, then a 2px ring outside it.\nconst FOCUS_HIGHLIGHT_SHADOW = \"0 0 0 6px var(--color-primary-100), 0 0 0 8px var(--color-primary)\";\n\nconst ScrollOnFocus = observer(\n ({ field, children }: { field: IFieldVM; children: React.ReactNode }) => {\n const ref = useRef<HTMLDivElement>(null);\n const [highlighted, setHighlighted] = useState(false);\n const highlightTimer = useRef<number | null>(null);\n\n useEffect(() => {\n if (field.focusRequested && ref.current) {\n setTimeout(() => {\n ref.current?.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n }, 150);\n // Flash a highlight ring so it's obvious where focus landed. The timer is kept in a\n // ref (not tied to the effect cleanup) so clearing the focus request below — which\n // re-runs this effect — doesn't cut the highlight short.\n setHighlighted(true);\n if (highlightTimer.current) {\n window.clearTimeout(highlightTimer.current);\n }\n highlightTimer.current = window.setTimeout(\n () => setHighlighted(false),\n FOCUS_HIGHLIGHT_MS\n );\n }\n field.clearFocusRequest();\n }, [field.focusRequested]);\n\n useEffect(() => {\n return () => {\n if (highlightTimer.current) {\n window.clearTimeout(highlightTimer.current);\n }\n };\n }, []);\n\n return (\n <div\n ref={ref}\n data-field-path={field.qualifiedName}\n style={{\n /*\n * The highlight is drawn with shadows, which paint around the field without\n * taking up room. Padding with a matching negative margin looked the same, but\n * the padded box still stuck out of the field, so a scroll area around a form\n * always had 6px to scroll.\n */\n borderRadius: 2,\n transition: \"box-shadow .35s ease, background-color .35s ease\",\n boxShadow: highlighted ? FOCUS_HIGHLIGHT_SHADOW : undefined,\n backgroundColor: highlighted ? \"var(--color-primary-100)\" : undefined\n }}\n >\n <FormFieldWrapper field={field}>{children}</FormFieldWrapper>\n </div>\n );\n }\n);\n\nexport function createFieldRenderer<TName extends string = string>(\n render: FieldRendererFn<TName>\n): React.ComponentType<{ field: IFieldVM }> {\n const Inner = observer(render as FieldRendererFn<string>) as unknown as React.ComponentType<{\n field: IFieldVM;\n }>;\n\n const Wrapper = observer(({ field }: { field: IFieldVM }) => (\n <ScrollOnFocus field={field}>\n <Inner field={field} />\n </ScrollOnFocus>\n ));\n\n return Wrapper as unknown as React.ComponentType<{ field: IFieldVM }>;\n}\n\nexport function createObjectFieldRenderer<TName extends string = string>(\n render: (props: { field: ObjectRendererField<TName> }) => React.ReactNode\n): React.ComponentType<{ field: IFieldVM }> {\n const Wrapped = (props: { field: IFieldVM }) => {\n if (props.field.type !== \"object\") {\n return null;\n }\n return (render as (p: { field: IFieldVM }) => React.ReactNode)(props);\n };\n return observer(Wrapped) as unknown as React.ComponentType<{ field: IFieldVM }>;\n}\n"],"names":["FormFieldWrapper","makeDecoratable","children","FOCUS_HIGHLIGHT_MS","FOCUS_HIGHLIGHT_SHADOW","ScrollOnFocus","observer","field","ref","useRef","highlighted","setHighlighted","useState","highlightTimer","useEffect","setTimeout","window","undefined","createFieldRenderer","render","Inner","Wrapper","createObjectFieldRenderer","Wrapped","props"],"mappings":";;;AAUO,MAAMA,mBAAmBC,gBAC5B,oBACA,CAAC,EAAEC,QAAQ,EAAmD,GACnD,WAAP,GAAO,0CAAGA;AAkBlB,MAAMC,qBAAqB;AAG3B,MAAMC,yBAAyB;AAE/B,MAAMC,gBAAgBC,SAClB,CAAC,EAAEC,KAAK,EAAEL,QAAQ,EAAkD;IAChE,MAAMM,MAAMC,OAAuB;IACnC,MAAM,CAACC,aAAaC,eAAe,GAAGC,SAAS;IAC/C,MAAMC,iBAAiBJ,OAAsB;IAE7CK,UAAU;QACN,IAAIP,MAAM,cAAc,IAAIC,IAAI,OAAO,EAAE;YACrCO,WAAW;gBACPP,IAAI,OAAO,EAAE,eAAe;oBAAE,UAAU;oBAAU,OAAO;gBAAS;YACtE,GAAG;YAIHG,eAAe;YACf,IAAIE,eAAe,OAAO,EACtBG,OAAO,YAAY,CAACH,eAAe,OAAO;YAE9CA,eAAe,OAAO,GAAGG,OAAO,UAAU,CACtC,IAAML,eAAe,QACrBR;QAER;QACAI,MAAM,iBAAiB;IAC3B,GAAG;QAACA,MAAM,cAAc;KAAC;IAEzBO,UAAU,IACC;YACH,IAAID,eAAe,OAAO,EACtBG,OAAO,YAAY,CAACH,eAAe,OAAO;QAElD,GACD,EAAE;IAEL,OAAO,WAAP,GACI,oBAAC;QACG,KAAKL;QACL,mBAAiBD,MAAM,aAAa;QACpC,OAAO;YAOH,cAAc;YACd,YAAY;YACZ,WAAWG,cAAcN,yBAAyBa;YAClD,iBAAiBP,cAAc,6BAA6BO;QAChE;qBAEA,oBAACjB,
|
|
1
|
+
{"version":3,"file":"features/formModel/createFieldRenderer.js","sources":["../../../src/features/formModel/createFieldRenderer.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport type { IFieldVM, IObjectFieldVM, FieldRendererSettings } from \"./abstractions.js\";\n\n/**\n * Decoratable wrapper rendered around every leaf field's content. Features can decorate it to\n * inject per-field UI (e.g. a comment marker) keyed on `field.qualifiedName`, without forking\n * the form. By default it renders the field content unchanged.\n */\nexport const FormFieldWrapper = makeDecoratable(\n \"FormFieldWrapper\",\n ({ children }: { field: IFieldVM; children?: React.ReactNode }) => {\n return <>{children}</>;\n }\n);\n\ntype RendererField<TName extends string> = IFieldVM & {\n rendererSettings: FieldRendererSettings<TName>;\n};\n\ntype ObjectRendererField<TName extends string> = IObjectFieldVM & {\n rendererSettings: FieldRendererSettings<TName>;\n};\n\ntype FieldRendererFn<TName extends string> = (props: {\n field: RendererField<TName>;\n}) => React.ReactNode;\n\n// How long the field stays visually highlighted after focus lands, so the user's eye is drawn\n// to where \"jump to field\" (a comment locator, a form error) scrolled to.\nconst FOCUS_HIGHLIGHT_MS = 1800;\n\n// A 6px tint around the field, then a 2px ring outside it.\nconst FOCUS_HIGHLIGHT_SHADOW = \"0 0 0 6px var(--color-primary-100), 0 0 0 8px var(--color-primary)\";\n\nconst ScrollOnFocus = observer(\n ({ field, children }: { field: IFieldVM; children: React.ReactNode }) => {\n const ref = useRef<HTMLDivElement>(null);\n const [highlighted, setHighlighted] = useState(false);\n const highlightTimer = useRef<number | null>(null);\n\n useEffect(() => {\n if (field.focusRequested && ref.current) {\n setTimeout(() => {\n ref.current?.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n }, 150);\n // Flash a highlight ring so it's obvious where focus landed. The timer is kept in a\n // ref (not tied to the effect cleanup) so clearing the focus request below — which\n // re-runs this effect — doesn't cut the highlight short.\n setHighlighted(true);\n if (highlightTimer.current) {\n window.clearTimeout(highlightTimer.current);\n }\n highlightTimer.current = window.setTimeout(\n () => setHighlighted(false),\n FOCUS_HIGHLIGHT_MS\n );\n }\n field.clearFocusRequest();\n }, [field.focusRequested]);\n\n useEffect(() => {\n return () => {\n if (highlightTimer.current) {\n window.clearTimeout(highlightTimer.current);\n }\n };\n }, []);\n\n return (\n <div\n ref={ref}\n data-field-path={field.qualifiedName}\n style={{\n /*\n * The highlight is drawn with shadows, which paint around the field without\n * taking up room. Padding with a matching negative margin looked the same, but\n * the padded box still stuck out of the field, so a scroll area around a form\n * always had 6px to scroll.\n */\n borderRadius: 2,\n transition: \"box-shadow .35s ease, background-color .35s ease\",\n boxShadow: highlighted ? FOCUS_HIGHLIGHT_SHADOW : undefined,\n backgroundColor: highlighted ? \"var(--color-primary-100)\" : undefined\n }}\n >\n <FormFieldWrapper field={field}>{children}</FormFieldWrapper>\n </div>\n );\n }\n);\n\nexport function createFieldRenderer<TName extends string = string>(\n render: FieldRendererFn<TName>\n): React.ComponentType<{ field: IFieldVM }> {\n const Inner = observer(render as FieldRendererFn<string>) as unknown as React.ComponentType<{\n field: IFieldVM;\n }>;\n\n const Wrapper = observer(({ field }: { field: IFieldVM }) => (\n <ScrollOnFocus field={field}>\n <Inner field={field} />\n </ScrollOnFocus>\n ));\n\n return Wrapper as unknown as React.ComponentType<{ field: IFieldVM }>;\n}\n\nexport function createObjectFieldRenderer<TName extends string = string>(\n render: (props: { field: ObjectRendererField<TName> }) => React.ReactNode\n): React.ComponentType<{ field: IFieldVM }> {\n const Wrapped = (props: { field: IFieldVM }) => {\n if (props.field.type !== \"object\") {\n return null;\n }\n return (render as (p: { field: IFieldVM }) => React.ReactNode)(props);\n };\n return observer(Wrapped) as unknown as React.ComponentType<{ field: IFieldVM }>;\n}\n"],"names":["FormFieldWrapper","makeDecoratable","children","FOCUS_HIGHLIGHT_MS","FOCUS_HIGHLIGHT_SHADOW","ScrollOnFocus","observer","field","ref","useRef","highlighted","setHighlighted","useState","highlightTimer","useEffect","setTimeout","window","undefined","createFieldRenderer","render","Inner","Wrapper","createObjectFieldRenderer","Wrapped","props"],"mappings":";;;AAUO,MAAMA,mBAAmBC,gBAC5B,oBACA,CAAC,EAAEC,QAAQ,EAAmD,GACnD,WAAP,GAAO,0CAAGA;AAkBlB,MAAMC,qBAAqB;AAG3B,MAAMC,yBAAyB;AAE/B,MAAMC,gBAAgBC,SAClB,CAAC,EAAEC,KAAK,EAAEL,QAAQ,EAAkD;IAChE,MAAMM,MAAMC,OAAuB;IACnC,MAAM,CAACC,aAAaC,eAAe,GAAGC,SAAS;IAC/C,MAAMC,iBAAiBJ,OAAsB;IAE7CK,UAAU;QACN,IAAIP,MAAM,cAAc,IAAIC,IAAI,OAAO,EAAE;YACrCO,WAAW;gBACPP,IAAI,OAAO,EAAE,eAAe;oBAAE,UAAU;oBAAU,OAAO;gBAAS;YACtE,GAAG;YAIHG,eAAe;YACf,IAAIE,eAAe,OAAO,EACtBG,OAAO,YAAY,CAACH,eAAe,OAAO;YAE9CA,eAAe,OAAO,GAAGG,OAAO,UAAU,CACtC,IAAML,eAAe,QACrBR;QAER;QACAI,MAAM,iBAAiB;IAC3B,GAAG;QAACA,MAAM,cAAc;KAAC;IAEzBO,UAAU,IACC;YACH,IAAID,eAAe,OAAO,EACtBG,OAAO,YAAY,CAACH,eAAe,OAAO;QAElD,GACD,EAAE;IAEL,OAAO,WAAP,GACI,oBAAC;QACG,KAAKL;QACL,mBAAiBD,MAAM,aAAa;QACpC,OAAO;YAOH,cAAc;YACd,YAAY;YACZ,WAAWG,cAAcN,yBAAyBa;YAClD,iBAAiBP,cAAc,6BAA6BO;QAChE;qBAEA,oBAACjB,kBAAAA;QAAiB,OAAOO;OAAQL;AAG7C;AAGG,SAASgB,oBACZC,MAA8B;IAE9B,MAAMC,QAAQd,SAASa;IAIvB,MAAME,UAAUf,SAAS,CAAC,EAAEC,KAAK,EAAuB,iBACpD,oBAACF,eAAAA;YAAc,OAAOE;yBAClB,oBAACa,OAAAA;YAAM,OAAOb;;IAItB,OAAOc;AACX;AAEO,SAASC,0BACZH,MAAyE;IAEzE,MAAMI,UAAU,CAACC;QACb,IAAIA,AAAqB,aAArBA,MAAM,KAAK,CAAC,IAAI,EAChB,OAAO;QAEX,OAAQL,OAAuDK;IACnE;IACA,OAAOlB,SAASiB;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/formModel/demo/FormModelDemo.js","sources":["../../../../src/features/formModel/demo/FormModelDemo.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useFeature } from \"@webiny/app\";\nimport { Button } from \"@webiny/admin-ui\";\nimport { FormView } from \"../FormView.js\";\nimport { FormModelFeature } from \"../feature.js\";\nimport { FieldRenderersDemoPresenter } from \"./FieldRenderersDemoPresenter.js\";\nimport { FormModelDemoPresenter } from \"./FormModelDemoPresenter.js\";\nimport { FormModelPhase8c1Presenter } from \"./FormModelPhase8c1Presenter.js\";\nimport { FormModelPhase11Presenter } from \"./FormModelPhase11Presenter.js\";\n\nexport const FormModelDemo = observer(() => {\n const { formModelFactory } = useFeature(FormModelFeature);\n const presenter = useMemo(\n () => new FormModelDemoPresenter(formModelFactory),\n [formModelFactory]\n );\n\n const { form, data, lastSubmitted, isSubmitting, runtimeTemplateAdded, textTemplateRemoved } =\n presenter.vm;\n\n return (\n <div className={\"p-lg flex flex-col gap-2xl max-w-4xl mx-auto\"}>\n <FieldRenderersSection />\n\n <div className={\"flex flex-col gap-lg\"}>\n <div className={\"flex flex-col gap-sm\"}>\n <h2 className={\"text-xl font-semibold\"}>FormModel Demo — Phase 8</h2>\n <p className={\"text-sm text-neutral-strong\"}>\n Exercises the full Phase 8 surface: single-object templates ("Content\n Block"), templated lists ("Page Sections"), per-template\n layouts (Hero spans two rows; Rich Text uses a single row; templates without\n a layout entry fall back to default), and runtime template management via{\" \"}\n <code>field.templates.add/remove</code>. Change Plan to{\" \"}\n <code>enterprise</code> to reveal the "Premium Widget" template in\n the Content Block picker.\n </p>\n </div>\n\n <FormView name=\"Demo\" form={form} />\n\n <div className={\"flex flex-wrap gap-sm\"}>\n <Button\n text={isSubmitting ? \"Submitting…\" : \"Submit\"}\n variant={\"primary\"}\n onClick={() => presenter.submit()}\n disabled={isSubmitting}\n />\n <Button\n text={\"Reset\"}\n variant={\"secondary\"}\n onClick={() => presenter.reset()}\n disabled={isSubmitting}\n />\n <Button\n text={\n runtimeTemplateAdded\n ? 'Remove \"Runtime Banner\" from sections'\n : 'Add \"Runtime Banner\" to sections'\n }\n variant={\"tertiary\"}\n onClick={() => presenter.toggleRuntimeTemplate()}\n />\n <Button\n text={\n textTemplateRemoved\n ? 'Restore \"Rich Text\" on content'\n : 'Remove \"Rich Text\" from content'\n }\n variant={\"tertiary\"}\n onClick={() => presenter.toggleTextTemplate()}\n />\n </div>\n\n <div className={\"grid grid-cols-2 gap-md\"}>\n <DataPanel title={\"Current getData()\"} data={data} />\n <DataPanel title={\"Last submitted\"} data={lastSubmitted} />\n </div>\n </div>\n\n <Phase8c1Section />\n\n <Phase11Section />\n </div>\n );\n});\n\nconst FieldRenderersSection = observer(() => {\n const { formModelFactory } = useFeature(FormModelFeature);\n const presenter = useMemo(\n () => new FieldRenderersDemoPresenter(formModelFactory),\n [formModelFactory]\n );\n\n const { form, data, lastSubmitted, isSubmitting, formErrors } = presenter.vm;\n\n return (\n <div className={\"flex flex-col gap-lg\"}>\n <div className={\"flex flex-col gap-sm\"}>\n <h2 className={\"text-xl font-semibold\"}>Field Renderers Showcase</h2>\n <p className={\"text-sm text-neutral-strong\"}>\n All field renderer variants: text, number, boolean, select\n (dropdown/radio/checkboxes), date/time (4 variants), tags, textarea, multi-value\n lists, hidden, and dynamic zones. Renderers not yet implemented show nothing\n (console warning).\n </p>\n </div>\n\n <FormView name=\"Demo\" form={form} />\n\n {formErrors.length > 0 && (\n <div className={\"flex flex-col gap-xs\"}>\n <div className={\"text-sm font-medium\"}>Form errors</div>\n <ul className={\"text-xs text-error-strong list-disc pl-md\"}>\n {formErrors.map((e, i) => (\n <li key={i}>\n {e.path ? (\n <button\n type={\"button\"}\n className={\n \"underline cursor-pointer hover:text-error-default\"\n }\n onClick={() => presenter.focusField(e.path)}\n >\n <code>{e.path}</code>\n </button>\n ) : null}{\" \"}\n {e.message}\n </li>\n ))}\n </ul>\n </div>\n )}\n\n <div className={\"flex flex-wrap gap-sm\"}>\n <Button\n text={isSubmitting ? \"Submitting…\" : \"Submit\"}\n variant={\"primary\"}\n onClick={() => presenter.submit()}\n disabled={isSubmitting}\n />\n <Button\n text={\"Reset\"}\n variant={\"secondary\"}\n onClick={() => presenter.reset()}\n disabled={isSubmitting}\n />\n </div>\n\n <div className={\"grid grid-cols-2 gap-md\"}>\n <DataPanel title={\"Current getData()\"} data={data} />\n <DataPanel title={\"Last submitted\"} data={lastSubmitted} />\n </div>\n </div>\n );\n});\n\nconst Phase8c1Section = observer(() => {\n const { formModelFactory } = useFeature(FormModelFeature);\n const presenter = useMemo(\n () => new FormModelPhase8c1Presenter(formModelFactory),\n [formModelFactory]\n );\n\n const { form, data, lastSubmitted, isSubmitting } = presenter.vm;\n\n return (\n <div className={\"flex flex-col gap-lg border-t border-neutral-dimmed pt-lg\"}>\n <div className={\"flex flex-col gap-sm\"}>\n <h2 className={\"text-xl font-semibold\"}>FormModel Demo — Phase 8c.1</h2>\n <p className={\"text-sm text-neutral-strong\"}>\n Nested object layouts. A top-level <code>page</code> object whose inner layout\n is split across tabs (General / SEO). The SEO tab contains a nested{\" \"}\n <code>layout.object("seo", ...)</code> with its own row layout, and\n the SEO object itself contains another nested{\" \"}\n <code>layout.object("og", ...)</code> for the Open Graph fields. Phase\n 8c.1 walks the inner layout (including across tabs) and forwards each nested{\" \"}\n <code>layout.object()</code> to the matching child at build time.\n </p>\n </div>\n\n <FormView name=\"Demo\" form={form} />\n\n <div className={\"flex flex-wrap gap-sm\"}>\n <Button\n text={isSubmitting ? \"Submitting…\" : \"Submit\"}\n variant={\"primary\"}\n onClick={() => presenter.submit()}\n disabled={isSubmitting}\n />\n <Button\n text={\"Reset\"}\n variant={\"secondary\"}\n onClick={() => presenter.reset()}\n disabled={isSubmitting}\n />\n </div>\n\n <div className={\"grid grid-cols-2 gap-md\"}>\n <DataPanel title={\"Current getData()\"} data={data} />\n <DataPanel title={\"Last submitted\"} data={lastSubmitted} />\n </div>\n </div>\n );\n});\n\nconst Phase11Section = observer(() => {\n const { formModelFactory } = useFeature(FormModelFeature);\n const presenter = useMemo(\n () => new FormModelPhase11Presenter(formModelFactory),\n [formModelFactory]\n );\n\n const { form, data, lastSubmitted, isSubmitting, formErrors } = presenter.vm;\n\n return (\n <div className={\"flex flex-col gap-lg border-t border-neutral-dimmed pt-lg\"}>\n <div className={\"flex flex-col gap-sm\"}>\n <h2 className={\"text-xl font-semibold\"}>FormModel Demo — Phase 11</h2>\n <p className={\"text-sm text-neutral-strong\"}>\n Conditional required (<code>requiredWhen</code> on Seats — chained builder +\n modifier rules), derived fields (<code>computed</code> Full Name and{\" \"}\n <code>computedUntilDirty</code> Slug), modifier-style child addition via{\" \"}\n <code>field.as("object").fields()</code> adding Company/Bio to\n Profile, form-level rules (<code>addRule</code> with a Zod refinement for\n password match plus an imperative slug-length rule), and a layout assembled via{\" \"}\n <code>setLayout</code>.\n </p>\n </div>\n\n <FormView name=\"Demo\" form={form} />\n\n {formErrors.length > 0 && (\n <div className={\"flex flex-col gap-xs\"}>\n <div className={\"text-sm font-medium\"}>Form errors</div>\n <ul className={\"text-xs text-error-strong list-disc pl-md\"}>\n {formErrors.map((e, i) => (\n <li key={i}>\n {e.path ? <code>{e.path}</code> : null} {e.message}\n </li>\n ))}\n </ul>\n </div>\n )}\n\n <div className={\"flex flex-wrap gap-sm\"}>\n <Button\n text={isSubmitting ? \"Submitting…\" : \"Submit\"}\n variant={\"primary\"}\n onClick={() => presenter.submit()}\n disabled={isSubmitting}\n />\n <Button\n text={\"Reset\"}\n variant={\"secondary\"}\n onClick={() => presenter.reset()}\n disabled={isSubmitting}\n />\n </div>\n\n <div className={\"grid grid-cols-2 gap-md\"}>\n <DataPanel title={\"Current getData()\"} data={data} />\n <DataPanel title={\"Last submitted\"} data={lastSubmitted} />\n </div>\n </div>\n );\n});\n\nconst DataPanel = ({ title, data }: { title: string; data: unknown }) => {\n return (\n <div className={\"flex flex-col gap-xs\"}>\n <div className={\"text-sm font-medium\"}>{title}</div>\n <pre\n className={\n \"text-xs bg-neutral-subtle p-sm rounded border border-neutral-dimmed overflow-auto\"\n }\n >\n {data === null ? \"null\" : JSON.stringify(data, null, 2)}\n </pre>\n </div>\n );\n};\n"],"names":["FormModelDemo","observer","formModelFactory","useFeature","FormModelFeature","presenter","useMemo","FormModelDemoPresenter","form","data","lastSubmitted","isSubmitting","runtimeTemplateAdded","textTemplateRemoved","FieldRenderersSection","FormView","Button","DataPanel","Phase8c1Section","Phase11Section","FieldRenderersDemoPresenter","formErrors","e","i","FormModelPhase8c1Presenter","FormModelPhase11Presenter","title","JSON"],"mappings":";;;;;;;;;;AAWO,MAAMA,gBAAgBC,SAAS;IAClC,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,WAAWC;IACxC,MAAMC,YAAYC,QACd,IAAM,IAAIC,uBAAuBL,mBACjC;QAACA;KAAiB;IAGtB,MAAM,EAAEM,IAAI,EAAEC,IAAI,EAAEC,aAAa,EAAEC,YAAY,EAAEC,oBAAoB,EAAEC,mBAAmB,EAAE,GACxFR,UAAU,EAAE;IAEhB,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACS,uBAAqBA,OAAAA,WAAAA,GAEtB,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAG,WAAW;OAAyB,2CACxC,oBAAC;QAAE,WAAW;OAA+B,yRAIiC,mBAC1E,oBAAC,cAAK,+BAAiC,oBAAiB,mBACxD,oBAAC,cAAK,eAAiB,yFAK/B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A;QACH,MAAML,eAAe,gBAAgB;QACrC,SAAS;QACT,SAAS,IAAMN,UAAU,MAAM;QAC/B,UAAUM;sBAEd,oBAACK,QAAMA;QACH,MAAM;QACN,SAAS;QACT,SAAS,IAAMX,UAAU,KAAK;QAC9B,UAAUM;uBAIlB,oBAAC;QAAI,WAAW;qBACZ,oBAACM,WAASA;QAAC,OAAO;QAAqB,MAAMR;sBAC7C,oBAACQ,WAASA;QAAC,OAAO;QAAkB,MAAMP;;AAI1D;AAEA,MAAMO,YAAY,CAAC,EAAES,KAAK,EAAEjB,IAAI,EAAoC,GACzD,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAI,WAAW;OAAwBiB,QAAAA,WAAAA,GACxC,oBAAC;QACG,WACI;OAGHjB,AAAS,SAATA,OAAgB,SAASkB,KAAK,SAAS,CAAClB,MAAM,MAAM"}
|
|
1
|
+
{"version":3,"file":"features/formModel/demo/FormModelDemo.js","sources":["../../../../src/features/formModel/demo/FormModelDemo.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useFeature } from \"@webiny/app\";\nimport { Button } from \"@webiny/admin-ui\";\nimport { FormView } from \"../FormView.js\";\nimport { FormModelFeature } from \"../feature.js\";\nimport { FieldRenderersDemoPresenter } from \"./FieldRenderersDemoPresenter.js\";\nimport { FormModelDemoPresenter } from \"./FormModelDemoPresenter.js\";\nimport { FormModelPhase8c1Presenter } from \"./FormModelPhase8c1Presenter.js\";\nimport { FormModelPhase11Presenter } from \"./FormModelPhase11Presenter.js\";\n\nexport const FormModelDemo = observer(() => {\n const { formModelFactory } = useFeature(FormModelFeature);\n const presenter = useMemo(\n () => new FormModelDemoPresenter(formModelFactory),\n [formModelFactory]\n );\n\n const { form, data, lastSubmitted, isSubmitting, runtimeTemplateAdded, textTemplateRemoved } =\n presenter.vm;\n\n return (\n <div className={\"p-lg flex flex-col gap-2xl max-w-4xl mx-auto\"}>\n <FieldRenderersSection />\n\n <div className={\"flex flex-col gap-lg\"}>\n <div className={\"flex flex-col gap-sm\"}>\n <h2 className={\"text-xl font-semibold\"}>FormModel Demo — Phase 8</h2>\n <p className={\"text-sm text-neutral-strong\"}>\n Exercises the full Phase 8 surface: single-object templates ("Content\n Block"), templated lists ("Page Sections"), per-template\n layouts (Hero spans two rows; Rich Text uses a single row; templates without\n a layout entry fall back to default), and runtime template management via{\" \"}\n <code>field.templates.add/remove</code>. Change Plan to{\" \"}\n <code>enterprise</code> to reveal the "Premium Widget" template in\n the Content Block picker.\n </p>\n </div>\n\n <FormView name=\"Demo\" form={form} />\n\n <div className={\"flex flex-wrap gap-sm\"}>\n <Button\n text={isSubmitting ? \"Submitting…\" : \"Submit\"}\n variant={\"primary\"}\n onClick={() => presenter.submit()}\n disabled={isSubmitting}\n />\n <Button\n text={\"Reset\"}\n variant={\"secondary\"}\n onClick={() => presenter.reset()}\n disabled={isSubmitting}\n />\n <Button\n text={\n runtimeTemplateAdded\n ? 'Remove \"Runtime Banner\" from sections'\n : 'Add \"Runtime Banner\" to sections'\n }\n variant={\"tertiary\"}\n onClick={() => presenter.toggleRuntimeTemplate()}\n />\n <Button\n text={\n textTemplateRemoved\n ? 'Restore \"Rich Text\" on content'\n : 'Remove \"Rich Text\" from content'\n }\n variant={\"tertiary\"}\n onClick={() => presenter.toggleTextTemplate()}\n />\n </div>\n\n <div className={\"grid grid-cols-2 gap-md\"}>\n <DataPanel title={\"Current getData()\"} data={data} />\n <DataPanel title={\"Last submitted\"} data={lastSubmitted} />\n </div>\n </div>\n\n <Phase8c1Section />\n\n <Phase11Section />\n </div>\n );\n});\n\nconst FieldRenderersSection = observer(() => {\n const { formModelFactory } = useFeature(FormModelFeature);\n const presenter = useMemo(\n () => new FieldRenderersDemoPresenter(formModelFactory),\n [formModelFactory]\n );\n\n const { form, data, lastSubmitted, isSubmitting, formErrors } = presenter.vm;\n\n return (\n <div className={\"flex flex-col gap-lg\"}>\n <div className={\"flex flex-col gap-sm\"}>\n <h2 className={\"text-xl font-semibold\"}>Field Renderers Showcase</h2>\n <p className={\"text-sm text-neutral-strong\"}>\n All field renderer variants: text, number, boolean, select\n (dropdown/radio/checkboxes), date/time (4 variants), tags, textarea, multi-value\n lists, hidden, and dynamic zones. Renderers not yet implemented show nothing\n (console warning).\n </p>\n </div>\n\n <FormView name=\"Demo\" form={form} />\n\n {formErrors.length > 0 && (\n <div className={\"flex flex-col gap-xs\"}>\n <div className={\"text-sm font-medium\"}>Form errors</div>\n <ul className={\"text-xs text-error-strong list-disc pl-md\"}>\n {formErrors.map((e, i) => (\n <li key={i}>\n {e.path ? (\n <button\n type={\"button\"}\n className={\n \"underline cursor-pointer hover:text-error-default\"\n }\n onClick={() => presenter.focusField(e.path)}\n >\n <code>{e.path}</code>\n </button>\n ) : null}{\" \"}\n {e.message}\n </li>\n ))}\n </ul>\n </div>\n )}\n\n <div className={\"flex flex-wrap gap-sm\"}>\n <Button\n text={isSubmitting ? \"Submitting…\" : \"Submit\"}\n variant={\"primary\"}\n onClick={() => presenter.submit()}\n disabled={isSubmitting}\n />\n <Button\n text={\"Reset\"}\n variant={\"secondary\"}\n onClick={() => presenter.reset()}\n disabled={isSubmitting}\n />\n </div>\n\n <div className={\"grid grid-cols-2 gap-md\"}>\n <DataPanel title={\"Current getData()\"} data={data} />\n <DataPanel title={\"Last submitted\"} data={lastSubmitted} />\n </div>\n </div>\n );\n});\n\nconst Phase8c1Section = observer(() => {\n const { formModelFactory } = useFeature(FormModelFeature);\n const presenter = useMemo(\n () => new FormModelPhase8c1Presenter(formModelFactory),\n [formModelFactory]\n );\n\n const { form, data, lastSubmitted, isSubmitting } = presenter.vm;\n\n return (\n <div className={\"flex flex-col gap-lg border-t border-neutral-dimmed pt-lg\"}>\n <div className={\"flex flex-col gap-sm\"}>\n <h2 className={\"text-xl font-semibold\"}>FormModel Demo — Phase 8c.1</h2>\n <p className={\"text-sm text-neutral-strong\"}>\n Nested object layouts. A top-level <code>page</code> object whose inner layout\n is split across tabs (General / SEO). The SEO tab contains a nested{\" \"}\n <code>layout.object("seo", ...)</code> with its own row layout, and\n the SEO object itself contains another nested{\" \"}\n <code>layout.object("og", ...)</code> for the Open Graph fields. Phase\n 8c.1 walks the inner layout (including across tabs) and forwards each nested{\" \"}\n <code>layout.object()</code> to the matching child at build time.\n </p>\n </div>\n\n <FormView name=\"Demo\" form={form} />\n\n <div className={\"flex flex-wrap gap-sm\"}>\n <Button\n text={isSubmitting ? \"Submitting…\" : \"Submit\"}\n variant={\"primary\"}\n onClick={() => presenter.submit()}\n disabled={isSubmitting}\n />\n <Button\n text={\"Reset\"}\n variant={\"secondary\"}\n onClick={() => presenter.reset()}\n disabled={isSubmitting}\n />\n </div>\n\n <div className={\"grid grid-cols-2 gap-md\"}>\n <DataPanel title={\"Current getData()\"} data={data} />\n <DataPanel title={\"Last submitted\"} data={lastSubmitted} />\n </div>\n </div>\n );\n});\n\nconst Phase11Section = observer(() => {\n const { formModelFactory } = useFeature(FormModelFeature);\n const presenter = useMemo(\n () => new FormModelPhase11Presenter(formModelFactory),\n [formModelFactory]\n );\n\n const { form, data, lastSubmitted, isSubmitting, formErrors } = presenter.vm;\n\n return (\n <div className={\"flex flex-col gap-lg border-t border-neutral-dimmed pt-lg\"}>\n <div className={\"flex flex-col gap-sm\"}>\n <h2 className={\"text-xl font-semibold\"}>FormModel Demo — Phase 11</h2>\n <p className={\"text-sm text-neutral-strong\"}>\n Conditional required (<code>requiredWhen</code> on Seats — chained builder +\n modifier rules), derived fields (<code>computed</code> Full Name and{\" \"}\n <code>computedUntilDirty</code> Slug), modifier-style child addition via{\" \"}\n <code>field.as("object").fields()</code> adding Company/Bio to\n Profile, form-level rules (<code>addRule</code> with a Zod refinement for\n password match plus an imperative slug-length rule), and a layout assembled via{\" \"}\n <code>setLayout</code>.\n </p>\n </div>\n\n <FormView name=\"Demo\" form={form} />\n\n {formErrors.length > 0 && (\n <div className={\"flex flex-col gap-xs\"}>\n <div className={\"text-sm font-medium\"}>Form errors</div>\n <ul className={\"text-xs text-error-strong list-disc pl-md\"}>\n {formErrors.map((e, i) => (\n <li key={i}>\n {e.path ? <code>{e.path}</code> : null} {e.message}\n </li>\n ))}\n </ul>\n </div>\n )}\n\n <div className={\"flex flex-wrap gap-sm\"}>\n <Button\n text={isSubmitting ? \"Submitting…\" : \"Submit\"}\n variant={\"primary\"}\n onClick={() => presenter.submit()}\n disabled={isSubmitting}\n />\n <Button\n text={\"Reset\"}\n variant={\"secondary\"}\n onClick={() => presenter.reset()}\n disabled={isSubmitting}\n />\n </div>\n\n <div className={\"grid grid-cols-2 gap-md\"}>\n <DataPanel title={\"Current getData()\"} data={data} />\n <DataPanel title={\"Last submitted\"} data={lastSubmitted} />\n </div>\n </div>\n );\n});\n\nconst DataPanel = ({ title, data }: { title: string; data: unknown }) => {\n return (\n <div className={\"flex flex-col gap-xs\"}>\n <div className={\"text-sm font-medium\"}>{title}</div>\n <pre\n className={\n \"text-xs bg-neutral-subtle p-sm rounded border border-neutral-dimmed overflow-auto\"\n }\n >\n {data === null ? \"null\" : JSON.stringify(data, null, 2)}\n </pre>\n </div>\n );\n};\n"],"names":["FormModelDemo","observer","formModelFactory","useFeature","FormModelFeature","presenter","useMemo","FormModelDemoPresenter","form","data","lastSubmitted","isSubmitting","runtimeTemplateAdded","textTemplateRemoved","FieldRenderersSection","FormView","Button","DataPanel","Phase8c1Section","Phase11Section","FieldRenderersDemoPresenter","formErrors","e","i","FormModelPhase8c1Presenter","FormModelPhase11Presenter","title","JSON"],"mappings":";;;;;;;;;;AAWO,MAAMA,gBAAgBC,SAAS;IAClC,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,WAAWC;IACxC,MAAMC,YAAYC,QACd,IAAM,IAAIC,uBAAuBL,mBACjC;QAACA;KAAiB;IAGtB,MAAM,EAAEM,IAAI,EAAEC,IAAI,EAAEC,aAAa,EAAEC,YAAY,EAAEC,oBAAoB,EAAEC,mBAAmB,EAAE,GACxFR,UAAU,EAAE;IAEhB,OAA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,oBAAC;QAAI,WAAW;OAAuB,8BACvC,oBAAC;QAAG,WAAW;OACVA,WAAW,GAAG,CAAC,CAACC,GAAGC,IAAAA,WAAAA,GAChB,oBAAC;YAAG,KAAKA;WACJD,EAAE,IAAI,GAAG,WAAH,GAAG,oBAAC,cAAMA,EAAE,IAAI,IAAW,MAAK,KAAEA,EAAE,OAAO,oBAOtE,oBAAC;QAAI,WAAW;qBACZ,oBAACN,QAAMA;QACH,MAAML,eAAe,gBAAgB;QACrC,SAAS;QACT,SAAS,IAAMN,UAAU,MAAM;QAC/B,UAAUM;sBAEd,oBAACK,QAAMA;QACH,MAAM;QACN,SAAS;QACT,SAAS,IAAMX,UAAU,KAAK;QAC9B,UAAUM;uBAIlB,oBAAC;QAAI,WAAW;qBACZ,oBAACM,WAAAA;QAAU,OAAO;QAAqB,MAAMR;sBAC7C,oBAACQ,WAAAA;QAAU,OAAO;QAAkB,MAAMP;;AAI1D;AAEA,MAAMO,YAAY,CAAC,EAAES,KAAK,EAAEjB,IAAI,EAAoC,GACzD,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAI,WAAW;OAAwBiB,QAAAA,WAAAA,GACxC,oBAAC;QACG,WACI;OAGHjB,AAAS,SAATA,OAAgB,SAASkB,KAAK,SAAS,CAAClB,MAAM,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/formModel/fieldTypes/dateLimits.js","sources":["../../../../src/features/formModel/fieldTypes/dateLimits.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { getLocalToday, resolveDateBound, type DateBound } from \"@webiny/utils\";\n\nexport type { DateBound };\n\nexport interface IDateLimit {\n bound: DateBound;\n message?: string;\n}\n\n/** A field's date limits, as `datetime()` hands them to its renderer in `rendererSettings`. */\nexport interface IDateLimits {\n gte: DateBound[];\n lte: DateBound[];\n}\n\n/** The resolved limits: the latest lower limit and the earliest upper one. */\nexport interface IResolvedDateLimits {\n min?: string;\n max?: string;\n}\n\nconst describeBound = (bound: DateBound) =>\n typeof bound === \"string\" ? bound : `\"${bound.expression}\"`;\n\n/**\n * A field's limits as dates, with expressions worked out against `today` (the editor's local\n * date by default). An expression that can't be read is left out.\n */\nexport function resolveDateLimits(\n limits: IDateLimits | undefined,\n today: string = getLocalToday()\n): IResolvedDateLimits {\n const resolve = (bounds: DateBound[] = []) =>\n bounds.flatMap(bound => {\n try {\n return [resolveDateBound(bound, today)];\n } catch {\n return [];\n }\n });\n const gte = resolve(limits?.gte);\n const lte = resolve(limits?.lte);\n return {\n min: gte.length ? gte.reduce((a, b) => (a > b ? a : b)) : undefined,\n max: lte.length ? lte.reduce((a, b) => (a < b ? a : b)) : undefined\n };\n}\n\n/** Reads the limits `datetime()` put into a field's renderer settings. */\nexport function getDateLimits(rendererSettings: unknown): IDateLimits | undefined {\n if (!rendererSettings || typeof rendererSettings !== \"object\") {\n return undefined;\n }\n return (rendererSettings as { dateLimits?: IDateLimits }).dateLimits;\n}\n\n/** Shows a worked-out limit in a message; by default as it is stored (`2008-10-19`). */\nexport type DateLimitFormatter = (date: string) => string;\n\n/** The message when a limit has none of its own. */\nexport const DEFAULT_DATE_GTE_MESSAGE = \"Must be on or after {date}.\";\nexport const DEFAULT_DATE_LTE_MESSAGE = \"Must be on or before {date}.\";\n\n/** Puts the worked-out limit into a message's `{date}`. */\nexport function formatDateLimitMessage(message: string, date: string): string {\n return message.replace(/\\{date}/g, date);\n}\n\n/**\n * A schema that checks a value, or each value of a list, against the limits. Expressions are\n * worked out against the editor's local date at the moment of the check, so a form left open\n * overnight checks against the new day. A message's `{date}` is the worked-out limit.\n */\nexport function createDateLimitsSchema(\n gte: IDateLimit[],\n lte: IDateLimit[],\n formatDate: DateLimitFormatter = date => date\n): z.ZodTypeAny {\n return z.any().superRefine((value, ctx) => {\n const values = (Array.isArray(value) ? value : [value]).filter(\n v => v !== null && v !== undefined && v !== \"\"\n );\n if (values.length === 0) {\n return;\n }\n const today = getLocalToday();\n const check = (limit: IDateLimit, kind: \"gte\" | \"lte\") => {\n let date: string;\n try {\n date = resolveDateBound(limit.bound, today);\n } catch {\n ctx.addIssue({\n code: \"custom\",\n message: `Invalid date limit ${describeBound(limit.bound)}.`\n });\n return false;\n }\n const ok = values.every(v => (kind === \"gte\" ? String(v) >= date : String(v) <= date));\n if (!ok) {\n const message =\n limit.message ||\n (kind === \"gte\" ? DEFAULT_DATE_GTE_MESSAGE : DEFAULT_DATE_LTE_MESSAGE);\n ctx.addIssue({\n code: \"custom\",\n message: formatDateLimitMessage(message, formatDate(date))\n });\n }\n return ok;\n };\n for (const limit of gte) {\n if (!check(limit, \"gte\")) {\n return;\n }\n }\n for (const limit of lte) {\n if (!check(limit, \"lte\")) {\n return;\n }\n }\n });\n}\n"],"names":["describeBound","bound","resolveDateLimits","limits","today","getLocalToday","resolve","bounds","resolveDateBound","gte","lte","a","b","undefined","getDateLimits","rendererSettings","DEFAULT_DATE_GTE_MESSAGE","DEFAULT_DATE_LTE_MESSAGE","formatDateLimitMessage","message","date","createDateLimitsSchema","formatDate","z","value","ctx","values","Array","v","check","limit","kind","ok","String"],"mappings":";;AAsBA,MAAMA,gBAAgB,CAACC,QACnB,AAAiB,YAAjB,OAAOA,QAAqBA,QAAQ,CAAC,CAAC,EAAEA,MAAM,UAAU,CAAC,CAAC,CAAC;AAMxD,SAASC,kBACZC,MAA+B,EAC/BC,QAAgBC,eAAe;IAE/B,MAAMC,UAAU,CAACC,SAAsB,EAAE,GACrCA,OAAO,OAAO,CAACN,CAAAA;YACX,IAAI;gBACA,OAAO;oBAACO,iBAAiBP,OAAOG;iBAAO;YAC3C,EAAE,OAAM;gBACJ,OAAO,EAAE;YACb;QACJ;IACJ,MAAMK,MAAMH,QAAQH,QAAQ;IAC5B,MAAMO,MAAMJ,QAAQH,QAAQ;IAC5B,OAAO;QACH,KAAKM,IAAI,MAAM,GAAGA,IAAI,MAAM,CAAC,CAACE,GAAGC,IAAOD,IAAIC,IAAID,IAAIC,KAAMC;QAC1D,KAAKH,IAAI,MAAM,GAAGA,IAAI,MAAM,CAAC,CAACC,GAAGC,IAAOD,IAAIC,IAAID,IAAIC,KAAMC;IAC9D;AACJ;AAGO,SAASC,cAAcC,gBAAyB;IACnD,IAAI,CAACA,oBAAoB,AAA4B,YAA5B,OAAOA,kBAC5B;IAEJ,OAAQA,iBAAkD,UAAU;AACxE;AAMO,MAAMC,2BAA2B;AACjC,MAAMC,2BAA2B;AAGjC,SAASC,uBAAuBC,OAAe,EAAEC,IAAY;IAChE,OAAOD,QAAQ,OAAO,CAAC,YAAYC;AACvC;AAOO,SAASC,uBACZZ,GAAiB,EACjBC,GAAiB,EACjBY,aAAiCF,CAAAA,OAAQA,IAAI;IAE7C,OAAOG,EAAE,GAAG,GAAG,WAAW,CAAC,CAACC,OAAOC;QAC/B,MAAMC,SAAUC,AAAAA,CAAAA,MAAM,OAAO,CAACH,SAASA,QAAQ;YAACA;SAAK,
|
|
1
|
+
{"version":3,"file":"features/formModel/fieldTypes/dateLimits.js","sources":["../../../../src/features/formModel/fieldTypes/dateLimits.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { getLocalToday, resolveDateBound, type DateBound } from \"@webiny/utils\";\n\nexport type { DateBound };\n\nexport interface IDateLimit {\n bound: DateBound;\n message?: string;\n}\n\n/** A field's date limits, as `datetime()` hands them to its renderer in `rendererSettings`. */\nexport interface IDateLimits {\n gte: DateBound[];\n lte: DateBound[];\n}\n\n/** The resolved limits: the latest lower limit and the earliest upper one. */\nexport interface IResolvedDateLimits {\n min?: string;\n max?: string;\n}\n\nconst describeBound = (bound: DateBound) =>\n typeof bound === \"string\" ? bound : `\"${bound.expression}\"`;\n\n/**\n * A field's limits as dates, with expressions worked out against `today` (the editor's local\n * date by default). An expression that can't be read is left out.\n */\nexport function resolveDateLimits(\n limits: IDateLimits | undefined,\n today: string = getLocalToday()\n): IResolvedDateLimits {\n const resolve = (bounds: DateBound[] = []) =>\n bounds.flatMap(bound => {\n try {\n return [resolveDateBound(bound, today)];\n } catch {\n return [];\n }\n });\n const gte = resolve(limits?.gte);\n const lte = resolve(limits?.lte);\n return {\n min: gte.length ? gte.reduce((a, b) => (a > b ? a : b)) : undefined,\n max: lte.length ? lte.reduce((a, b) => (a < b ? a : b)) : undefined\n };\n}\n\n/** Reads the limits `datetime()` put into a field's renderer settings. */\nexport function getDateLimits(rendererSettings: unknown): IDateLimits | undefined {\n if (!rendererSettings || typeof rendererSettings !== \"object\") {\n return undefined;\n }\n return (rendererSettings as { dateLimits?: IDateLimits }).dateLimits;\n}\n\n/** Shows a worked-out limit in a message; by default as it is stored (`2008-10-19`). */\nexport type DateLimitFormatter = (date: string) => string;\n\n/** The message when a limit has none of its own. */\nexport const DEFAULT_DATE_GTE_MESSAGE = \"Must be on or after {date}.\";\nexport const DEFAULT_DATE_LTE_MESSAGE = \"Must be on or before {date}.\";\n\n/** Puts the worked-out limit into a message's `{date}`. */\nexport function formatDateLimitMessage(message: string, date: string): string {\n return message.replace(/\\{date}/g, date);\n}\n\n/**\n * A schema that checks a value, or each value of a list, against the limits. Expressions are\n * worked out against the editor's local date at the moment of the check, so a form left open\n * overnight checks against the new day. A message's `{date}` is the worked-out limit.\n */\nexport function createDateLimitsSchema(\n gte: IDateLimit[],\n lte: IDateLimit[],\n formatDate: DateLimitFormatter = date => date\n): z.ZodTypeAny {\n return z.any().superRefine((value, ctx) => {\n const values = (Array.isArray(value) ? value : [value]).filter(\n v => v !== null && v !== undefined && v !== \"\"\n );\n if (values.length === 0) {\n return;\n }\n const today = getLocalToday();\n const check = (limit: IDateLimit, kind: \"gte\" | \"lte\") => {\n let date: string;\n try {\n date = resolveDateBound(limit.bound, today);\n } catch {\n ctx.addIssue({\n code: \"custom\",\n message: `Invalid date limit ${describeBound(limit.bound)}.`\n });\n return false;\n }\n const ok = values.every(v => (kind === \"gte\" ? String(v) >= date : String(v) <= date));\n if (!ok) {\n const message =\n limit.message ||\n (kind === \"gte\" ? DEFAULT_DATE_GTE_MESSAGE : DEFAULT_DATE_LTE_MESSAGE);\n ctx.addIssue({\n code: \"custom\",\n message: formatDateLimitMessage(message, formatDate(date))\n });\n }\n return ok;\n };\n for (const limit of gte) {\n if (!check(limit, \"gte\")) {\n return;\n }\n }\n for (const limit of lte) {\n if (!check(limit, \"lte\")) {\n return;\n }\n }\n });\n}\n"],"names":["describeBound","bound","resolveDateLimits","limits","today","getLocalToday","resolve","bounds","resolveDateBound","gte","lte","a","b","undefined","getDateLimits","rendererSettings","DEFAULT_DATE_GTE_MESSAGE","DEFAULT_DATE_LTE_MESSAGE","formatDateLimitMessage","message","date","createDateLimitsSchema","formatDate","z","value","ctx","values","Array","v","check","limit","kind","ok","String"],"mappings":";;AAsBA,MAAMA,gBAAgB,CAACC,QACnB,AAAiB,YAAjB,OAAOA,QAAqBA,QAAQ,CAAC,CAAC,EAAEA,MAAM,UAAU,CAAC,CAAC,CAAC;AAMxD,SAASC,kBACZC,MAA+B,EAC/BC,QAAgBC,eAAe;IAE/B,MAAMC,UAAU,CAACC,SAAsB,EAAE,GACrCA,OAAO,OAAO,CAACN,CAAAA;YACX,IAAI;gBACA,OAAO;oBAACO,iBAAiBP,OAAOG;iBAAO;YAC3C,EAAE,OAAM;gBACJ,OAAO,EAAE;YACb;QACJ;IACJ,MAAMK,MAAMH,QAAQH,QAAQ;IAC5B,MAAMO,MAAMJ,QAAQH,QAAQ;IAC5B,OAAO;QACH,KAAKM,IAAI,MAAM,GAAGA,IAAI,MAAM,CAAC,CAACE,GAAGC,IAAOD,IAAIC,IAAID,IAAIC,KAAMC;QAC1D,KAAKH,IAAI,MAAM,GAAGA,IAAI,MAAM,CAAC,CAACC,GAAGC,IAAOD,IAAIC,IAAID,IAAIC,KAAMC;IAC9D;AACJ;AAGO,SAASC,cAAcC,gBAAyB;IACnD,IAAI,CAACA,oBAAoB,AAA4B,YAA5B,OAAOA,kBAC5B;IAEJ,OAAQA,iBAAkD,UAAU;AACxE;AAMO,MAAMC,2BAA2B;AACjC,MAAMC,2BAA2B;AAGjC,SA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KeysView } from "../presentation/accessManagement/apiKeys/components/ApiKeysView.js";
|
|
32
32
|
import { ApiKeysPresenterFeature } from "../presentation/accessManagement/apiKeys/feature.js";
|
|
33
33
|
import { TeamsPresenterFeature } from "../presentation/accessManagement/teams/feature.js";
|
|
34
|
-
const { Menu
|
|
34
|
+
const { Menu, Route } = AdminConfig;
|
|
35
35
|
const AccessManagementExtension = ()=>{
|
|
36
36
|
const router = useRouter();
|
|
37
37
|
return /*#__PURE__*/ react.createElement(Fragment, null, /*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules/AccessManagementExtension.js","sources":["../../src/modules/AccessManagementExtension.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport { useRouter } from \"@webiny/app\";\nimport { RegisterFeature } from \"~/components/RegisterFeature.js\";\nimport { AdminConfig } from \"~/config/AdminConfig.js\";\nimport { AdminLayout } from \"~/components/AdminLayout.js\";\nimport { HasPermission } from \"~/presentation/security/components/HasPermission.js\";\nimport { Wcp } from \"~/components/Wcp.js\";\nimport { Permission } from \"~/features/accessManagement/constants.js\";\nimport { SecurityPermissionsFeature } from \"~/features/accessManagement/permissions/feature.js\";\nimport { ListRolesFeature } from \"~/features/accessManagement/roles/listRoles/feature.js\";\nimport { GetRoleFeature } from \"~/features/accessManagement/roles/getRole/feature.js\";\nimport { CreateRoleFeature } from \"~/features/accessManagement/roles/createRole/feature.js\";\nimport { UpdateRoleFeature } from \"~/features/accessManagement/roles/updateRole/feature.js\";\nimport { DeleteRoleFeature } from \"~/features/accessManagement/roles/deleteRole/feature.js\";\nimport { ListTeamsFeature } from \"~/features/accessManagement/teams/listTeams/feature.js\";\nimport { GetTeamFeature } from \"~/features/accessManagement/teams/getTeam/feature.js\";\nimport { CreateTeamFeature } from \"~/features/accessManagement/teams/createTeam/feature.js\";\nimport { UpdateTeamFeature } from \"~/features/accessManagement/teams/updateTeam/feature.js\";\nimport { DeleteTeamFeature } from \"~/features/accessManagement/teams/deleteTeam/feature.js\";\nimport { ListApiKeysFeature } from \"~/features/accessManagement/apiKeys/listApiKeys/feature.js\";\nimport { GetApiKeyFeature } from \"~/features/accessManagement/apiKeys/getApiKey/feature.js\";\nimport { CreateApiKeyFeature } from \"~/features/accessManagement/apiKeys/createApiKey/feature.js\";\nimport { UpdateApiKeyFeature } from \"~/features/accessManagement/apiKeys/updateApiKey/feature.js\";\nimport { DeleteApiKeyFeature } from \"~/features/accessManagement/apiKeys/deleteApiKey/feature.js\";\nimport { ListPresenterFeature } from \"~/presentation/listPresenter/feature.js\";\nimport { RolesPresenterFeature } from \"~/presentation/accessManagement/roles/feature.js\";\nimport { SecurityPermissions } from \"~/presentation/accessManagement/SecurityPermissions.js\";\nimport { Routes } from \"~/presentation/accessManagement/routes.js\";\nimport { RolesView } from \"~/presentation/accessManagement/roles/components/RolesView.js\";\nimport { TeamsView } from \"~/presentation/accessManagement/teams/components/TeamsView.js\";\nimport { ApiKeysView } from \"~/presentation/accessManagement/apiKeys/components/ApiKeysView.js\";\nimport { ApiKeysPresenterFeature } from \"~/presentation/accessManagement/apiKeys/feature.js\";\nimport { TeamsPresenterFeature } from \"~/presentation/accessManagement/teams/feature.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nexport const AccessManagementExtension = () => {\n const router = useRouter();\n\n return (\n <Fragment>\n <RegisterFeature feature={SecurityPermissionsFeature} />\n <RegisterFeature feature={ListPresenterFeature} />\n <RegisterFeature feature={ListRolesFeature} />\n <RegisterFeature feature={GetRoleFeature} />\n <RegisterFeature feature={CreateRoleFeature} />\n <RegisterFeature feature={UpdateRoleFeature} />\n <RegisterFeature feature={DeleteRoleFeature} />\n <RegisterFeature feature={RolesPresenterFeature} />\n <RegisterFeature feature={ListTeamsFeature} />\n <RegisterFeature feature={GetTeamFeature} />\n <RegisterFeature feature={CreateTeamFeature} />\n <RegisterFeature feature={UpdateTeamFeature} />\n <RegisterFeature feature={DeleteTeamFeature} />\n <RegisterFeature feature={TeamsPresenterFeature} />\n <RegisterFeature feature={ListApiKeysFeature} />\n <RegisterFeature feature={GetApiKeyFeature} />\n <RegisterFeature feature={CreateApiKeyFeature} />\n <RegisterFeature feature={UpdateApiKeyFeature} />\n <RegisterFeature feature={DeleteApiKeyFeature} />\n <RegisterFeature feature={ApiKeysPresenterFeature} />\n <SecurityPermissions />\n <AdminConfig>\n <HasPermission name={Permission.Roles}>\n <Route\n route={Routes.Roles.List}\n element={\n <AdminLayout title={\"Access Management - Roles\"}>\n <RolesView />\n </AdminLayout>\n }\n />\n </HasPermission>\n <Wcp.CanUseTeams>\n <HasPermission name={Permission.Teams}>\n <Route\n route={Routes.Teams.List}\n element={\n <AdminLayout title={\"Access Management - Teams\"}>\n <TeamsView />\n </AdminLayout>\n }\n />\n </HasPermission>\n </Wcp.CanUseTeams>\n <HasPermission name={Permission.ApiKeys}>\n <Route\n route={Routes.ApiKeys.List}\n element={\n <AdminLayout title={\"Access Management - API Keys\"}>\n <ApiKeysView />\n </AdminLayout>\n }\n />\n </HasPermission>\n\n <HasPermission any={[Permission.Roles, Permission.ApiKeys, Permission.Teams]}>\n <Menu\n name={\"settings.security\"}\n parent={\"settings\"}\n element={<Menu.Group text={\"Access Management\"} collapsible={false} />}\n />\n </HasPermission>\n <HasPermission name={Permission.Roles}>\n <Menu\n name={\"security.roles\"}\n parent={\"settings.security\"}\n element={\n <Menu.Link\n text={\"Roles\"}\n to={router.getLink(Routes.Roles.List)}\n pinnable={true}\n />\n }\n />\n </HasPermission>\n <Wcp.CanUseTeams>\n <HasPermission name={Permission.Teams}>\n <Menu\n name={\"security.teams\"}\n parent={\"settings.security\"}\n element={\n <Menu.Link\n text={\"Teams\"}\n to={router.getLink(Routes.Teams.List)}\n pinnable={true}\n />\n }\n />\n </HasPermission>\n </Wcp.CanUseTeams>\n <HasPermission name={Permission.ApiKeys}>\n <Menu\n name={\"security.apiKeys\"}\n parent={\"settings.security\"}\n element={\n <Menu.Link\n text={\"API Keys\"}\n to={router.getLink(Routes.ApiKeys.List)}\n pinnable={true}\n />\n }\n />\n </HasPermission>\n </AdminConfig>\n </Fragment>\n );\n};\n"],"names":["Menu","Route","AdminConfig","AccessManagementExtension","router","useRouter","Fragment","RegisterFeature","SecurityPermissionsFeature","ListPresenterFeature","ListRolesFeature","GetRoleFeature","CreateRoleFeature","UpdateRoleFeature","DeleteRoleFeature","RolesPresenterFeature","ListTeamsFeature","GetTeamFeature","CreateTeamFeature","UpdateTeamFeature","DeleteTeamFeature","TeamsPresenterFeature","ListApiKeysFeature","GetApiKeyFeature","CreateApiKeyFeature","UpdateApiKeyFeature","DeleteApiKeyFeature","ApiKeysPresenterFeature","SecurityPermissions","HasPermission","Permission","Routes","AdminLayout","RolesView","Wcp","TeamsView","ApiKeysView"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,OAAAA,KAAK,EAAE,GAAGC;AAEjB,MAAMC,4BAA4B;IACrC,MAAMC,SAASC;IAEf,OAAO,WAAP,GACI,oBAACC,UAAQA,MAAAA,WAAAA,GACL,oBAACC,iBAAeA;QAAC,SAASC;sBAC1B,oBAACD,iBAAeA;QAAC,SAASE;sBAC1B,oBAACF,iBAAeA;QAAC,SAASG;sBAC1B,oBAACH,iBAAeA;QAAC,SAASI;sBAC1B,oBAACJ,iBAAeA;QAAC,SAASK;sBAC1B,oBAACL,iBAAeA;QAAC,SAASM;sBAC1B,oBAACN,iBAAeA;QAAC,SAASO;sBAC1B,oBAACP,iBAAeA;QAAC,SAASQ;sBAC1B,oBAACR,iBAAeA;QAAC,SAASS;sBAC1B,oBAACT,iBAAeA;QAAC,SAASU;sBAC1B,oBAACV,iBAAeA;QAAC,SAASW;sBAC1B,oBAACX,iBAAeA;QAAC,SAASY;sBAC1B,oBAACZ,iBAAeA;QAAC,SAASa;sBAC1B,oBAACb,iBAAeA;QAAC,SAASc;sBAC1B,oBAACd,iBAAeA;QAAC,SAASe;sBAC1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sBACZ,oBAACL,eAAaA;QAAC,MAAMC,WAAW,KAAK;qBACjC,oBAAC9B,MAAIA;QACD,MAAM;QACN,QAAQ;QACR,uBACI,oBAACA,KAAK,IAAI;YACN,MAAM;YACN,IAAII,OAAO,OAAO,CAAC2B,OAAO,KAAK,CAAC,IAAI;YACpC,UAAU;;wBAM9B,oBAACF,eAAaA;QAAC,MAAMC,WAAW,OAAO;qBACnC,oBAAC9B,MAAIA;QACD,MAAM;QACN,QAAQ;QACR,uBACI,oBAACA,KAAK,IAAI;YACN,MAAM;YACN,IAAII,OAAO,OAAO,CAAC2B,OAAO,OAAO,CAAC,IAAI;YACtC,UAAU;;;AAQ1C"}
|
|
1
|
+
{"version":3,"file":"modules/AccessManagementExtension.js","sources":["../../src/modules/AccessManagementExtension.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport { useRouter } from \"@webiny/app\";\nimport { RegisterFeature } from \"~/components/RegisterFeature.js\";\nimport { AdminConfig } from \"~/config/AdminConfig.js\";\nimport { AdminLayout } from \"~/components/AdminLayout.js\";\nimport { HasPermission } from \"~/presentation/security/components/HasPermission.js\";\nimport { Wcp } from \"~/components/Wcp.js\";\nimport { Permission } from \"~/features/accessManagement/constants.js\";\nimport { SecurityPermissionsFeature } from \"~/features/accessManagement/permissions/feature.js\";\nimport { ListRolesFeature } from \"~/features/accessManagement/roles/listRoles/feature.js\";\nimport { GetRoleFeature } from \"~/features/accessManagement/roles/getRole/feature.js\";\nimport { CreateRoleFeature } from \"~/features/accessManagement/roles/createRole/feature.js\";\nimport { UpdateRoleFeature } from \"~/features/accessManagement/roles/updateRole/feature.js\";\nimport { DeleteRoleFeature } from \"~/features/accessManagement/roles/deleteRole/feature.js\";\nimport { ListTeamsFeature } from \"~/features/accessManagement/teams/listTeams/feature.js\";\nimport { GetTeamFeature } from \"~/features/accessManagement/teams/getTeam/feature.js\";\nimport { CreateTeamFeature } from \"~/features/accessManagement/teams/createTeam/feature.js\";\nimport { UpdateTeamFeature } from \"~/features/accessManagement/teams/updateTeam/feature.js\";\nimport { DeleteTeamFeature } from \"~/features/accessManagement/teams/deleteTeam/feature.js\";\nimport { ListApiKeysFeature } from \"~/features/accessManagement/apiKeys/listApiKeys/feature.js\";\nimport { GetApiKeyFeature } from \"~/features/accessManagement/apiKeys/getApiKey/feature.js\";\nimport { CreateApiKeyFeature } from \"~/features/accessManagement/apiKeys/createApiKey/feature.js\";\nimport { UpdateApiKeyFeature } from \"~/features/accessManagement/apiKeys/updateApiKey/feature.js\";\nimport { DeleteApiKeyFeature } from \"~/features/accessManagement/apiKeys/deleteApiKey/feature.js\";\nimport { ListPresenterFeature } from \"~/presentation/listPresenter/feature.js\";\nimport { RolesPresenterFeature } from \"~/presentation/accessManagement/roles/feature.js\";\nimport { SecurityPermissions } from \"~/presentation/accessManagement/SecurityPermissions.js\";\nimport { Routes } from \"~/presentation/accessManagement/routes.js\";\nimport { RolesView } from \"~/presentation/accessManagement/roles/components/RolesView.js\";\nimport { TeamsView } from \"~/presentation/accessManagement/teams/components/TeamsView.js\";\nimport { ApiKeysView } from \"~/presentation/accessManagement/apiKeys/components/ApiKeysView.js\";\nimport { ApiKeysPresenterFeature } from \"~/presentation/accessManagement/apiKeys/feature.js\";\nimport { TeamsPresenterFeature } from \"~/presentation/accessManagement/teams/feature.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nexport const AccessManagementExtension = () => {\n const router = useRouter();\n\n return (\n <Fragment>\n <RegisterFeature feature={SecurityPermissionsFeature} />\n <RegisterFeature feature={ListPresenterFeature} />\n <RegisterFeature feature={ListRolesFeature} />\n <RegisterFeature feature={GetRoleFeature} />\n <RegisterFeature feature={CreateRoleFeature} />\n <RegisterFeature feature={UpdateRoleFeature} />\n <RegisterFeature feature={DeleteRoleFeature} />\n <RegisterFeature feature={RolesPresenterFeature} />\n <RegisterFeature feature={ListTeamsFeature} />\n <RegisterFeature feature={GetTeamFeature} />\n <RegisterFeature feature={CreateTeamFeature} />\n <RegisterFeature feature={UpdateTeamFeature} />\n <RegisterFeature feature={DeleteTeamFeature} />\n <RegisterFeature feature={TeamsPresenterFeature} />\n <RegisterFeature feature={ListApiKeysFeature} />\n <RegisterFeature feature={GetApiKeyFeature} />\n <RegisterFeature feature={CreateApiKeyFeature} />\n <RegisterFeature feature={UpdateApiKeyFeature} />\n <RegisterFeature feature={DeleteApiKeyFeature} />\n <RegisterFeature feature={ApiKeysPresenterFeature} />\n <SecurityPermissions />\n <AdminConfig>\n <HasPermission name={Permission.Roles}>\n <Route\n route={Routes.Roles.List}\n element={\n <AdminLayout title={\"Access Management - Roles\"}>\n <RolesView />\n </AdminLayout>\n }\n />\n </HasPermission>\n <Wcp.CanUseTeams>\n <HasPermission name={Permission.Teams}>\n <Route\n route={Routes.Teams.List}\n element={\n <AdminLayout title={\"Access Management - Teams\"}>\n <TeamsView />\n </AdminLayout>\n }\n />\n </HasPermission>\n </Wcp.CanUseTeams>\n <HasPermission name={Permission.ApiKeys}>\n <Route\n route={Routes.ApiKeys.List}\n element={\n <AdminLayout title={\"Access Management - API Keys\"}>\n <ApiKeysView />\n </AdminLayout>\n }\n />\n </HasPermission>\n\n <HasPermission any={[Permission.Roles, Permission.ApiKeys, Permission.Teams]}>\n <Menu\n name={\"settings.security\"}\n parent={\"settings\"}\n element={<Menu.Group text={\"Access Management\"} collapsible={false} />}\n />\n </HasPermission>\n <HasPermission name={Permission.Roles}>\n <Menu\n name={\"security.roles\"}\n parent={\"settings.security\"}\n element={\n <Menu.Link\n text={\"Roles\"}\n to={router.getLink(Routes.Roles.List)}\n pinnable={true}\n />\n }\n />\n </HasPermission>\n <Wcp.CanUseTeams>\n <HasPermission name={Permission.Teams}>\n <Menu\n name={\"security.teams\"}\n parent={\"settings.security\"}\n element={\n <Menu.Link\n text={\"Teams\"}\n to={router.getLink(Routes.Teams.List)}\n pinnable={true}\n />\n }\n />\n </HasPermission>\n </Wcp.CanUseTeams>\n <HasPermission name={Permission.ApiKeys}>\n <Menu\n name={\"security.apiKeys\"}\n parent={\"settings.security\"}\n element={\n <Menu.Link\n text={\"API Keys\"}\n to={router.getLink(Routes.ApiKeys.List)}\n pinnable={true}\n />\n }\n />\n </HasPermission>\n </AdminConfig>\n </Fragment>\n );\n};\n"],"names":["Menu","Route","AdminConfig","AccessManagementExtension","router","useRouter","Fragment","RegisterFeature","SecurityPermissionsFeature","ListPresenterFeature","ListRolesFeature","GetRoleFeature","CreateRoleFeature","UpdateRoleFeature","DeleteRoleFeature","RolesPresenterFeature","ListTeamsFeature","GetTeamFeature","CreateTeamFeature","UpdateTeamFeature","DeleteTeamFeature","TeamsPresenterFeature","ListApiKeysFeature","GetApiKeyFeature","CreateApiKeyFeature","UpdateApiKeyFeature","DeleteApiKeyFeature","ApiKeysPresenterFeature","SecurityPermissions","HasPermission","Permission","Routes","AdminLayout","RolesView","Wcp","TeamsView","ApiKeysView"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,EAAEA,IAAI,EAAEC,KAAK,EAAE,GAAGC;AAEjB,MAAMC,4BAA4B;IACrC,MAAMC,SAASC;IAEf,OAAO,WAAP,GACI,oBAACC,UAAQA,MAAAA,WAAAA,GACL,oBAACC,iBAAeA;QAAC,SAASC;sBAC1B,oBAACD,iBAAeA;QAAC,SAASE;sBAC1B,oBAACF,iBAAeA;QAAC,SAASG;sBAC1B,oBAACH,iBAAeA;QAAC,SAASI;sBAC1B,oBAACJ,iBAAeA;QAAC,SAASK;sBAC1B,oBAACL,iBAAeA;QAAC,SAASM;sBAC1B,oBAACN,iBAAeA;QAAC,SAASO;sBAC1B,oBAACP,iBAAeA;QAAC,SAASQ;sBAC1B,oBAACR,iBAAeA;QAAC,SAASS;sBAC1B,oBAACT,iBAAeA;QAAC,SAASU;sBAC1B,oBAACV,iBAAeA;QAAC,SAASW;sBAC1B,oBAACX,iBAAeA;QAAC,SAASY;sBAC1B,oBAACZ,iBAAeA;QAAC,SAASa;sBAC1B,oBAACb,iBAAeA;QAAC,SAASc;sB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ACpC,UAAU;;uBAK1B,oBAACG,IAAI,WAAW,sBACZ,oBAACL,eAAaA;QAAC,MAAMC,WAAW,KAAK;qBACjC,oBAAC9B,MAAAA;QACG,MAAM;QACN,QAAQ;QACR,uBACI,oBAACA,KAAK,IAAI;YACN,MAAM;YACN,IAAII,OAAO,OAAO,CAAC2B,OAAO,KAAK,CAAC,IAAI;YACpC,UAAU;;wBAM9B,oBAACF,eAAaA;QAAC,MAAMC,WAAW,OAAO;qBACnC,oBAAC9B,MAAAA;QACG,MAAM;QACN,QAAQ;QACR,uBACI,oBAACA,KAAK,IAAI;YACN,MAAM;YACN,IAAII,OAAO,OAAO,CAAC2B,OAAO,OAAO,CAAC,IAAI;YACtC,UAAU;;;AAQ1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-admin",
|
|
3
|
-
"version": "6.5.2-beta.
|
|
3
|
+
"version": "6.5.2-beta.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -23,27 +23,27 @@
|
|
|
23
23
|
"@emotion/styled": "11.14.1",
|
|
24
24
|
"@fortawesome/fontawesome-svg-core": "7.3.1",
|
|
25
25
|
"@fortawesome/react-fontawesome": "3.5.0",
|
|
26
|
-
"@iconify/json": "2.2.
|
|
26
|
+
"@iconify/json": "2.2.555",
|
|
27
27
|
"@lexical/utils": "0.53.0",
|
|
28
28
|
"@types/react": "18.3.31",
|
|
29
|
-
"@webiny/admin-ui": "6.5.2-beta.
|
|
30
|
-
"@webiny/app": "6.5.2-beta.
|
|
29
|
+
"@webiny/admin-ui": "6.5.2-beta.3",
|
|
30
|
+
"@webiny/app": "6.5.2-beta.3",
|
|
31
31
|
"@webiny/di": "1.1.0",
|
|
32
|
-
"@webiny/feature": "6.5.2-beta.
|
|
33
|
-
"@webiny/form": "6.5.2-beta.
|
|
34
|
-
"@webiny/icons": "6.5.2-beta.
|
|
35
|
-
"@webiny/lexical-converter": "6.5.2-beta.
|
|
36
|
-
"@webiny/lexical-editor": "6.5.2-beta.
|
|
37
|
-
"@webiny/lexical-nodes": "6.5.2-beta.
|
|
38
|
-
"@webiny/lexical-theme": "6.5.2-beta.
|
|
39
|
-
"@webiny/plugins": "6.5.2-beta.
|
|
40
|
-
"@webiny/react-composition": "6.5.2-beta.
|
|
41
|
-
"@webiny/react-properties": "6.5.2-beta.
|
|
42
|
-
"@webiny/sdk": "6.5.2-beta.
|
|
43
|
-
"@webiny/telemetry": "6.5.2-beta.
|
|
44
|
-
"@webiny/utils": "6.5.2-beta.
|
|
45
|
-
"@webiny/validation": "6.5.2-beta.
|
|
46
|
-
"@webiny/wcp": "6.5.2-beta.
|
|
32
|
+
"@webiny/feature": "6.5.2-beta.3",
|
|
33
|
+
"@webiny/form": "6.5.2-beta.3",
|
|
34
|
+
"@webiny/icons": "6.5.2-beta.3",
|
|
35
|
+
"@webiny/lexical-converter": "6.5.2-beta.3",
|
|
36
|
+
"@webiny/lexical-editor": "6.5.2-beta.3",
|
|
37
|
+
"@webiny/lexical-nodes": "6.5.2-beta.3",
|
|
38
|
+
"@webiny/lexical-theme": "6.5.2-beta.3",
|
|
39
|
+
"@webiny/plugins": "6.5.2-beta.3",
|
|
40
|
+
"@webiny/react-composition": "6.5.2-beta.3",
|
|
41
|
+
"@webiny/react-properties": "6.5.2-beta.3",
|
|
42
|
+
"@webiny/sdk": "6.5.2-beta.3",
|
|
43
|
+
"@webiny/telemetry": "6.5.2-beta.3",
|
|
44
|
+
"@webiny/utils": "6.5.2-beta.3",
|
|
45
|
+
"@webiny/validation": "6.5.2-beta.3",
|
|
46
|
+
"@webiny/wcp": "6.5.2-beta.3",
|
|
47
47
|
"apollo-cache": "1.3.5",
|
|
48
48
|
"apollo-client": "2.6.10",
|
|
49
49
|
"apollo-link": "1.2.14",
|
|
@@ -51,16 +51,16 @@
|
|
|
51
51
|
"apollo-utilities": "1.3.4",
|
|
52
52
|
"bytes": "3.1.2",
|
|
53
53
|
"classnames": "2.5.1",
|
|
54
|
-
"graphql": "16.
|
|
54
|
+
"graphql": "16.15.0",
|
|
55
55
|
"graphql-tag": "2.12.7",
|
|
56
56
|
"history": "5.3.0",
|
|
57
57
|
"is-hotkey": "0.2.1",
|
|
58
58
|
"lexical": "0.53.0",
|
|
59
59
|
"lodash": "4.18.1",
|
|
60
|
-
"markdown-to-jsx": "9.10.
|
|
60
|
+
"markdown-to-jsx": "9.10.6",
|
|
61
61
|
"mime": "4.1.2",
|
|
62
|
-
"minimatch": "11.0.
|
|
63
|
-
"mobx": "7.1.
|
|
62
|
+
"minimatch": "11.0.5",
|
|
63
|
+
"mobx": "7.1.5",
|
|
64
64
|
"mobx-react-lite": "5.1.2",
|
|
65
65
|
"monaco-editor": "0.53.0",
|
|
66
66
|
"react": "18.3.1",
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"@types/react-transition-group": "4.4.12",
|
|
84
84
|
"@types/store": "2.0.5",
|
|
85
85
|
"@types/tinycolor2": "1.4.6",
|
|
86
|
-
"@webiny/build-tools": "6.5.2-beta.
|
|
87
|
-
"rimraf": "6.1.
|
|
86
|
+
"@webiny/build-tools": "6.5.2-beta.3",
|
|
87
|
+
"rimraf": "6.1.4",
|
|
88
88
|
"typescript": "7.0.2",
|
|
89
|
-
"vitest": "5.0
|
|
89
|
+
"vitest": "5.1.0"
|
|
90
90
|
},
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions/PermissionRenderer.js","sources":["../../src/permissions/PermissionRenderer.tsx"],"sourcesContent":["import React, { Fragment, useCallback, useMemo } from \"react\";\nimport { CheckboxGroup, Grid, Select } from \"@webiny/admin-ui\";\nimport { Form } from \"@webiny/form\";\nimport type { BindComponent } from \"@webiny/form\";\nimport {\n CannotUseAaclAlert,\n PermissionInfo,\n PermissionsGroup\n} from \"../components/Permissions/index.js\";\nimport { usePermissionForm } from \"./usePermissionForm.js\";\nimport type { AaclPermission } from \"../features/wcp/types.js\";\nimport type { ActionDefinition, PermissionSchema, EntityDefinition } from \"./types.js\";\nimport { usePermissionValue } from \"./PermissionValueContext.js\";\nimport { useAuthentication } from \"~/exports/admin/security.js\";\n\nexport interface PermissionRendererProps {\n schema: PermissionSchema;\n}\n\nconst NO_ACCESS = \"no\";\nconst FULL_ACCESS = \"full\";\nconst READ_ONLY_ACCESS = \"read-only\";\nconst CUSTOM_ACCESS = \"custom\";\n\nconst RWD_OPTIONS = [\n { value: \"r\", label: \"Read\" },\n { value: \"rw\", label: \"Read, write\" },\n { value: \"rwd\", label: \"Read, write, delete\" }\n];\n\nconst PW_OPTIONS = [\n { value: \"p\", label: \"Publish\" },\n { value: \"u\", label: \"Unpublish\" }\n];\n\nfunction hasAction(entity: EntityDefinition, name: string): boolean {\n return entity.actions?.some(a => a.name === name) ?? false;\n}\n\nfunction buildScopeOptions(entity: EntityDefinition) {\n const options = [{ value: NO_ACCESS, label: \"No access\" }];\n\n if (entity.scopes.includes(\"full\")) {\n options.push({ value: FULL_ACCESS, label: \"Full access\" });\n }\n\n if (entity.scopes.includes(\"own\")) {\n options.push({ value: \"own\", label: \"Only entries created by the user\" });\n }\n\n return options;\n}\n\nconst BUILTIN_ACTIONS = new Set([\"rwd\", \"pw\"]);\n\nfunction getCustomActions(entity: EntityDefinition): ActionDefinition[] {\n return (entity.actions ?? []).filter(a => !BUILTIN_ACTIONS.has(a.name));\n}\n\ninterface EntitySectionProps {\n entity: EntityDefinition;\n data: Record<string, any>;\n cannotUseAAcl: boolean;\n Bind: BindComponent;\n setValue: (name: string, value: any) => void;\n}\n\nfunction EntitySection({ entity, data, cannotUseAAcl, Bind, setValue }: EntitySectionProps) {\n const scopeField = `${entity.id}AccessScope`;\n const currentScope = data[scopeField];\n const scopeDisabled = cannotUseAAcl || !currentScope || currentScope === NO_ACCESS;\n const customActions = useMemo(() => getCustomActions(entity), [entity]);\n\n // Derive the selected values array from individual boolean form fields.\n const customActionsValue = useMemo(() => {\n return customActions.filter(a => data[`${entity.id}Action_${a.name}`]).map(a => a.name);\n }, [data, customActions, entity.id]);\n\n const onCustomActionsChange = useCallback(\n (selected: string[]) => {\n const selectedSet = new Set(selected);\n for (const action of customActions) {\n setValue(`${entity.id}Action_${action.name}`, selectedSet.has(action.name));\n }\n },\n [customActions, entity.id, setValue]\n );\n\n const columns = [\n <Grid.Column span={12} key={\"access\"}>\n <Bind\n name={scopeField}\n beforeChange={(value: string, cb: (v: string) => void) => {\n if (value === \"own\" && hasAction(entity, \"rwd\")) {\n setValue(`${entity.id}RWD`, \"rwd\");\n }\n cb(value);\n }}\n >\n <Select\n label={\"Access Scope\"}\n disabled={cannotUseAAcl}\n options={buildScopeOptions(entity)}\n />\n </Bind>\n </Grid.Column>\n ];\n\n if (hasAction(entity, \"rwd\")) {\n columns.push(\n <Grid.Column span={12} key={\"rwd\"}>\n <Bind name={`${entity.id}RWD`}>\n <Select\n label={\"Primary Actions\"}\n disabled={scopeDisabled || currentScope === \"own\"}\n options={RWD_OPTIONS}\n />\n </Bind>\n </Grid.Column>\n );\n }\n\n if (hasAction(entity, \"pw\")) {\n columns.push(\n <Grid.Column span={12} key={\"pw\"}>\n <Bind name={`${entity.id}PW`}>\n <CheckboxGroup\n label={\"Publishing actions\"}\n description={\"Publishing-related actions that can be performed on entries.\"}\n items={PW_OPTIONS.map(opt => ({\n ...opt,\n disabled: scopeDisabled\n }))}\n />\n </Bind>\n </Grid.Column>\n );\n }\n\n if (customActions.length > 0) {\n columns.push(\n <Grid.Column span={12} key={\"other\"}>\n <CheckboxGroup\n label={\"Other Actions\"}\n value={customActionsValue}\n onChange={onCustomActionsChange}\n items={customActions.map(action => ({\n value: action.name,\n label: action.label || action.name,\n disabled: scopeDisabled\n }))}\n />\n </Grid.Column>\n );\n }\n\n return (\n <PermissionsGroup title={entity.title || entity.id}>\n <Grid>{columns}</Grid>\n </PermissionsGroup>\n );\n}\n\nexport const PermissionRenderer = ({ schema }: PermissionRendererProps) => {\n const { value, onChange } = usePermissionValue();\n const { identity } = useAuthentication();\n\n const cannotUseAAcl = useMemo(() => {\n return !identity.getPermission<AaclPermission>(\"aacl\", true);\n }, []);\n\n const { formData, onFormChange } = usePermissionForm(schema, { value, onChange });\n\n const entities = schema.entities || [];\n const hasEntities = entities.length > 0;\n\n const accessLevelOptions = useMemo(() => {\n const options = [{ value: NO_ACCESS, label: \"No access\" }];\n\n if (schema.readOnlyAccess) {\n options.push({ value: READ_ONLY_ACCESS, label: \"Read-only access\" });\n }\n\n options.push({ value: FULL_ACCESS, label: \"Full access\" });\n\n if (hasEntities) {\n options.push({ value: CUSTOM_ACCESS, label: \"Custom access\" });\n }\n\n return options;\n }, [schema, hasEntities]);\n\n return (\n <Form data={formData} onChange={onFormChange}>\n {({ data, Bind, setValue }) => (\n <Fragment>\n <Grid className={\"pt-md\"}>\n <Grid.Column span={12}>\n {data.accessLevel === CUSTOM_ACCESS && cannotUseAAcl && (\n <CannotUseAaclAlert />\n )}\n </Grid.Column>\n </Grid>\n <Grid className={\"pt-md\"}>\n <Grid.Column span={6}>\n <PermissionInfo title={\"Access Level\"} />\n </Grid.Column>\n <Grid.Column span={6}>\n <Bind name={\"accessLevel\"}>\n <Select options={accessLevelOptions} />\n </Bind>\n </Grid.Column>\n </Grid>\n {data.accessLevel === CUSTOM_ACCESS && hasEntities && (\n <div className={\"mt-lg\"}>\n {entities.map(entity => (\n <EntitySection\n key={entity.id}\n entity={entity}\n data={data}\n cannotUseAAcl={cannotUseAAcl}\n Bind={Bind}\n setValue={setValue}\n />\n ))}\n </div>\n )}\n </Fragment>\n )}\n </Form>\n );\n};\n"],"names":["NO_ACCESS","FULL_ACCESS","READ_ONLY_ACCESS","CUSTOM_ACCESS","RWD_OPTIONS","PW_OPTIONS","hasAction","entity","name","a","buildScopeOptions","options","BUILTIN_ACTIONS","Set","getCustomActions","EntitySection","data","cannotUseAAcl","Bind","setValue","scopeField","currentScope","scopeDisabled","customActions","useMemo","customActionsValue","onCustomActionsChange","useCallback","selected","selectedSet","action","columns","Grid","value","cb","Select","CheckboxGroup","opt","PermissionsGroup","PermissionRenderer","schema","onChange","usePermissionValue","identity","useAuthentication","formData","onFormChange","usePermissionForm","entities","hasEntities","accessLevelOptions","Form","Fragment","CannotUseAaclAlert","PermissionInfo"],"mappings":";;;;;;;AAmBA,MAAMA,YAAY;AAClB,MAAMC,cAAc;AACpB,MAAMC,mBAAmB;AACzB,MAAMC,gBAAgB;AAEtB,MAAMC,cAAc;IAChB;QAAE,OAAO;QAAK,OAAO;IAAO;IAC5B;QAAE,OAAO;QAAM,OAAO;IAAc;IACpC;QAAE,OAAO;QAAO,OAAO;IAAsB;CAChD;AAED,MAAMC,aAAa;IACf;QAAE,OAAO;QAAK,OAAO;IAAU;IAC/B;QAAE,OAAO;QAAK,OAAO;IAAY;CACpC;AAED,SAASC,UAAUC,MAAwB,EAAEC,IAAY;IACrD,OAAOD,OAAO,OAAO,EAAE,KAAKE,CAAAA,IAAKA,EAAE,IAAI,KAAKD,SAAS;AACzD;AAEA,SAASE,kBAAkBH,MAAwB;IAC/C,MAAMI,UAAU;QAAC;YAAE,OAAOX;YAAW,OAAO;QAAY;KAAE;IAE1D,IAAIO,OAAO,MAAM,CAAC,QAAQ,CAAC,SACvBI,QAAQ,IAAI,CAAC;QAAE,OAAOV;QAAa,OAAO;IAAc;IAG5D,IAAIM,OAAO,MAAM,CAAC,QAAQ,CAAC,QACvBI,QAAQ,IAAI,CAAC;QAAE,OAAO;QAAO,OAAO;IAAmC;IAG3E,OAAOA;AACX;AAEA,MAAMC,kBAAkB,IAAIC,IAAI;IAAC;IAAO;CAAK;AAE7C,SAASC,iBAAiBP,MAAwB;IAC9C,OAAQA,AAAAA,CAAAA,OAAO,OAAO,IAAI,EAAC,EAAG,MAAM,CAACE,CAAAA,IAAK,CAACG,gBAAgB,GAAG,CAACH,EAAE,IAAI;AACzE;AAUA,SAASM,cAAc,EAAER,MAAM,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"file":"permissions/PermissionRenderer.js","sources":["../../src/permissions/PermissionRenderer.tsx"],"sourcesContent":["import React, { Fragment, useCallback, useMemo } from \"react\";\nimport { CheckboxGroup, Grid, Select } from \"@webiny/admin-ui\";\nimport { Form } from \"@webiny/form\";\nimport type { BindComponent } from \"@webiny/form\";\nimport {\n CannotUseAaclAlert,\n PermissionInfo,\n PermissionsGroup\n} from \"../components/Permissions/index.js\";\nimport { usePermissionForm } from \"./usePermissionForm.js\";\nimport type { AaclPermission } from \"../features/wcp/types.js\";\nimport type { ActionDefinition, PermissionSchema, EntityDefinition } from \"./types.js\";\nimport { usePermissionValue } from \"./PermissionValueContext.js\";\nimport { useAuthentication } from \"~/exports/admin/security.js\";\n\nexport interface PermissionRendererProps {\n schema: PermissionSchema;\n}\n\nconst NO_ACCESS = \"no\";\nconst FULL_ACCESS = \"full\";\nconst READ_ONLY_ACCESS = \"read-only\";\nconst CUSTOM_ACCESS = \"custom\";\n\nconst RWD_OPTIONS = [\n { value: \"r\", label: \"Read\" },\n { value: \"rw\", label: \"Read, write\" },\n { value: \"rwd\", label: \"Read, write, delete\" }\n];\n\nconst PW_OPTIONS = [\n { value: \"p\", label: \"Publish\" },\n { value: \"u\", label: \"Unpublish\" }\n];\n\nfunction hasAction(entity: EntityDefinition, name: string): boolean {\n return entity.actions?.some(a => a.name === name) ?? false;\n}\n\nfunction buildScopeOptions(entity: EntityDefinition) {\n const options = [{ value: NO_ACCESS, label: \"No access\" }];\n\n if (entity.scopes.includes(\"full\")) {\n options.push({ value: FULL_ACCESS, label: \"Full access\" });\n }\n\n if (entity.scopes.includes(\"own\")) {\n options.push({ value: \"own\", label: \"Only entries created by the user\" });\n }\n\n return options;\n}\n\nconst BUILTIN_ACTIONS = new Set([\"rwd\", \"pw\"]);\n\nfunction getCustomActions(entity: EntityDefinition): ActionDefinition[] {\n return (entity.actions ?? []).filter(a => !BUILTIN_ACTIONS.has(a.name));\n}\n\ninterface EntitySectionProps {\n entity: EntityDefinition;\n data: Record<string, any>;\n cannotUseAAcl: boolean;\n Bind: BindComponent;\n setValue: (name: string, value: any) => void;\n}\n\nfunction EntitySection({ entity, data, cannotUseAAcl, Bind, setValue }: EntitySectionProps) {\n const scopeField = `${entity.id}AccessScope`;\n const currentScope = data[scopeField];\n const scopeDisabled = cannotUseAAcl || !currentScope || currentScope === NO_ACCESS;\n const customActions = useMemo(() => getCustomActions(entity), [entity]);\n\n // Derive the selected values array from individual boolean form fields.\n const customActionsValue = useMemo(() => {\n return customActions.filter(a => data[`${entity.id}Action_${a.name}`]).map(a => a.name);\n }, [data, customActions, entity.id]);\n\n const onCustomActionsChange = useCallback(\n (selected: string[]) => {\n const selectedSet = new Set(selected);\n for (const action of customActions) {\n setValue(`${entity.id}Action_${action.name}`, selectedSet.has(action.name));\n }\n },\n [customActions, entity.id, setValue]\n );\n\n const columns = [\n <Grid.Column span={12} key={\"access\"}>\n <Bind\n name={scopeField}\n beforeChange={(value: string, cb: (v: string) => void) => {\n if (value === \"own\" && hasAction(entity, \"rwd\")) {\n setValue(`${entity.id}RWD`, \"rwd\");\n }\n cb(value);\n }}\n >\n <Select\n label={\"Access Scope\"}\n disabled={cannotUseAAcl}\n options={buildScopeOptions(entity)}\n />\n </Bind>\n </Grid.Column>\n ];\n\n if (hasAction(entity, \"rwd\")) {\n columns.push(\n <Grid.Column span={12} key={\"rwd\"}>\n <Bind name={`${entity.id}RWD`}>\n <Select\n label={\"Primary Actions\"}\n disabled={scopeDisabled || currentScope === \"own\"}\n options={RWD_OPTIONS}\n />\n </Bind>\n </Grid.Column>\n );\n }\n\n if (hasAction(entity, \"pw\")) {\n columns.push(\n <Grid.Column span={12} key={\"pw\"}>\n <Bind name={`${entity.id}PW`}>\n <CheckboxGroup\n label={\"Publishing actions\"}\n description={\"Publishing-related actions that can be performed on entries.\"}\n items={PW_OPTIONS.map(opt => ({\n ...opt,\n disabled: scopeDisabled\n }))}\n />\n </Bind>\n </Grid.Column>\n );\n }\n\n if (customActions.length > 0) {\n columns.push(\n <Grid.Column span={12} key={\"other\"}>\n <CheckboxGroup\n label={\"Other Actions\"}\n value={customActionsValue}\n onChange={onCustomActionsChange}\n items={customActions.map(action => ({\n value: action.name,\n label: action.label || action.name,\n disabled: scopeDisabled\n }))}\n />\n </Grid.Column>\n );\n }\n\n return (\n <PermissionsGroup title={entity.title || entity.id}>\n <Grid>{columns}</Grid>\n </PermissionsGroup>\n );\n}\n\nexport const PermissionRenderer = ({ schema }: PermissionRendererProps) => {\n const { value, onChange } = usePermissionValue();\n const { identity } = useAuthentication();\n\n const cannotUseAAcl = useMemo(() => {\n return !identity.getPermission<AaclPermission>(\"aacl\", true);\n }, []);\n\n const { formData, onFormChange } = usePermissionForm(schema, { value, onChange });\n\n const entities = schema.entities || [];\n const hasEntities = entities.length > 0;\n\n const accessLevelOptions = useMemo(() => {\n const options = [{ value: NO_ACCESS, label: \"No access\" }];\n\n if (schema.readOnlyAccess) {\n options.push({ value: READ_ONLY_ACCESS, label: \"Read-only access\" });\n }\n\n options.push({ value: FULL_ACCESS, label: \"Full access\" });\n\n if (hasEntities) {\n options.push({ value: CUSTOM_ACCESS, label: \"Custom access\" });\n }\n\n return options;\n }, [schema, hasEntities]);\n\n return (\n <Form data={formData} onChange={onFormChange}>\n {({ data, Bind, setValue }) => (\n <Fragment>\n <Grid className={\"pt-md\"}>\n <Grid.Column span={12}>\n {data.accessLevel === CUSTOM_ACCESS && cannotUseAAcl && (\n <CannotUseAaclAlert />\n )}\n </Grid.Column>\n </Grid>\n <Grid className={\"pt-md\"}>\n <Grid.Column span={6}>\n <PermissionInfo title={\"Access Level\"} />\n </Grid.Column>\n <Grid.Column span={6}>\n <Bind name={\"accessLevel\"}>\n <Select options={accessLevelOptions} />\n </Bind>\n </Grid.Column>\n </Grid>\n {data.accessLevel === CUSTOM_ACCESS && hasEntities && (\n <div className={\"mt-lg\"}>\n {entities.map(entity => (\n <EntitySection\n key={entity.id}\n entity={entity}\n data={data}\n cannotUseAAcl={cannotUseAAcl}\n Bind={Bind}\n setValue={setValue}\n />\n ))}\n </div>\n )}\n </Fragment>\n )}\n </Form>\n );\n};\n"],"names":["NO_ACCESS","FULL_ACCESS","READ_ONLY_ACCESS","CUSTOM_ACCESS","RWD_OPTIONS","PW_OPTIONS","hasAction","entity","name","a","buildScopeOptions","options","BUILTIN_ACTIONS","Set","getCustomActions","EntitySection","data","cannotUseAAcl","Bind","setValue","scopeField","currentScope","scopeDisabled","customActions","useMemo","customActionsValue","onCustomActionsChange","useCallback","selected","selectedSet","action","columns","Grid","value","cb","Select","CheckboxGroup","opt","PermissionsGroup","PermissionRenderer","schema","onChange","usePermissionValue","identity","useAuthentication","formData","onFormChange","usePermissionForm","entities","hasEntities","accessLevelOptions","Form","Fragment","CannotUseAaclAlert","PermissionInfo"],"mappings":";;;;;;;AAmBA,MAAMA,YAAY;AAClB,MAAMC,cAAc;AACpB,MAAMC,mBAAmB;AACzB,MAAMC,gBAAgB;AAEtB,MAAMC,cAAc;IAChB;QAAE,OAAO;QAAK,OAAO;IAAO;IAC5B;QAAE,OAAO;QAAM,OAAO;IAAc;IACpC;QAAE,OAAO;QAAO,OAAO;IAAsB;CAChD;AAED,MAAMC,aAAa;IACf;QAAE,OAAO;QAAK,OAAO;IAAU;IAC/B;QAAE,OAAO;QAAK,OAAO;IAAY;CACpC;AAED,SAASC,UAAUC,MAAwB,EAAEC,IAAY;IACrD,OAAOD,OAAO,OAAO,EAAE,KAAKE,CAAAA,IAAKA,EAAE,IAAI,KAAKD,SAAS;AACzD;AAEA,SAASE,kBAAkBH,MAAwB;IAC/C,MAAMI,UAAU;QAAC;YAAE,OAAOX;YAAW,OAAO;QAAY;KAAE;IAE1D,IAAIO,OAAO,MAAM,CAAC,QAAQ,CAAC,SACvBI,QAAQ,IAAI,CAAC;QAAE,OAAOV;QAAa,OAAO;IAAc;IAG5D,IAAIM,OAAO,MAAM,CAAC,QAAQ,CAAC,QACvBI,QAAQ,IAAI,CAAC;QAAE,OAAO;QAAO,OAAO;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;eAI5BlC,KAAK,WAAW,KAAKb,iBAAiB8C,eAAe,WAAfA,GACnC,oBAAC;YAAI,WAAW;WACXD,SAAS,GAAG,CAACzC,CAAAA,SAAAA,WAAAA,GACV,oBAACQ,eAAAA;gBACG,KAAKR,OAAO,EAAE;gBACd,QAAQA;gBACR,MAAMS;gBACN,eAAeC;gBACf,MAAMC;gBACN,UAAUC;;AAS9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions/PermissionValueContext.js","sources":["../../src/permissions/PermissionValueContext.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport type { Permission } from \"./types.js\";\n\ninterface PermissionValueContextValue {\n value: Permission[];\n onChange: (value: Permission[]) => void;\n}\n\nconst PermissionValueContext = React.createContext<PermissionValueContextValue | null>(null);\n\nexport const PermissionValueProvider = ({\n value,\n onChange,\n children\n}: PermissionValueContextValue & { children: React.ReactNode }) => {\n return (\n <PermissionValueContext.Provider value={{ value, onChange }}>\n {children}\n </PermissionValueContext.Provider>\n );\n};\n\nexport function usePermissionValue(): PermissionValueContextValue {\n const ctx = useContext(PermissionValueContext);\n if (!ctx) {\n throw new Error(\"usePermissionValue must be used within a PermissionValueProvider\");\n }\n return ctx;\n}\n"],"names":["PermissionValueContext","React","PermissionValueProvider","value","onChange","children","usePermissionValue","ctx","useContext","Error"],"mappings":";AAQA,MAAMA,yBAAyB,
|
|
1
|
+
{"version":3,"file":"permissions/PermissionValueContext.js","sources":["../../src/permissions/PermissionValueContext.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport type { Permission } from \"./types.js\";\n\ninterface PermissionValueContextValue {\n value: Permission[];\n onChange: (value: Permission[]) => void;\n}\n\nconst PermissionValueContext = React.createContext<PermissionValueContextValue | null>(null);\n\nexport const PermissionValueProvider = ({\n value,\n onChange,\n children\n}: PermissionValueContextValue & { children: React.ReactNode }) => {\n return (\n <PermissionValueContext.Provider value={{ value, onChange }}>\n {children}\n </PermissionValueContext.Provider>\n );\n};\n\nexport function usePermissionValue(): PermissionValueContextValue {\n const ctx = useContext(PermissionValueContext);\n if (!ctx) {\n throw new Error(\"usePermissionValue must be used within a PermissionValueProvider\");\n }\n return ctx;\n}\n"],"names":["PermissionValueContext","React","PermissionValueProvider","value","onChange","children","usePermissionValue","ctx","useContext","Error"],"mappings":";AAQA,MAAMA,yBAAyB,WAAzBA,GAAyBC,MAAAA,aAAmB,CAAqC;AAEhF,MAAMC,0BAA0B,CAAC,EACpCC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACkD,GACnD,WAAP,GACI,oBAACL,uBAAuB,QAAQ;QAAC,OAAO;YAAEG;YAAOC;QAAS;OACrDC;AAKN,SAASC;IACZ,MAAMC,MAAMC,WAAWR;IACvB,IAAI,CAACO,KACD,MAAM,IAAIE,MAAM;IAEpB,OAAOF;AACX"}
|