@headless-adminapp/app 0.0.17-alpha.3 → 0.0.17-alpha.32

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.
Files changed (109) hide show
  1. package/app/AuthWrapper.d.ts +1 -1
  2. package/app/AuthWrapper.js +4 -1
  3. package/app/LayoutProvider.d.ts +9 -14
  4. package/app/LayoutProvider.js +37 -4
  5. package/app/index.d.ts +1 -0
  6. package/app/index.js +3 -1
  7. package/auth/AuthProvider.d.ts +1 -1
  8. package/auth/AuthProvider.js +20 -2
  9. package/builders/CommandBuilder/CommandBuilder.d.ts +10 -0
  10. package/builders/CommandBuilder/CommandBuilder.js +14 -0
  11. package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +88 -0
  12. package/builders/CommandBuilder/DefaultCommandBuilder.js +191 -0
  13. package/builders/CommandBuilder/FormCommandBuilder.d.ts +46 -0
  14. package/builders/CommandBuilder/FormCommandBuilder.js +171 -0
  15. package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +45 -0
  16. package/builders/CommandBuilder/SubgridCommandBuilder.js +240 -0
  17. package/builders/CommandBuilder/ViewCommandBuilder.d.ts +63 -0
  18. package/builders/CommandBuilder/ViewCommandBuilder.js +242 -0
  19. package/builders/CommandBuilder/index.d.ts +1 -0
  20. package/builders/CommandBuilder/index.js +5 -0
  21. package/builders/CommandBuilder/utils.d.ts +3 -0
  22. package/builders/CommandBuilder/utils.js +21 -0
  23. package/builders/SchemaExperienceBuilder.d.ts +2 -5
  24. package/builders/SchemaExperienceBuilder.js +16 -16
  25. package/builders/index.d.ts +1 -1
  26. package/builders/index.js +1 -2
  27. package/builders/utils.d.ts +28 -0
  28. package/builders/utils.js +185 -0
  29. package/command/hooks/useBaseCommandHandlerContext.js +22 -4
  30. package/command/hooks/useCommands.d.ts +1 -1
  31. package/command/hooks/useCommands.js +1 -1
  32. package/dataform/DataFormProvider/DataResolver.js +6 -6
  33. package/dataform/DataFormProvider/index.js +3 -3
  34. package/dataform/hooks/useFormSave.js +9 -2
  35. package/dataform/hooks/useLoadFormGridPage.js +7 -1
  36. package/dataform/hooks/useMainFormCommands.d.ts +1 -12
  37. package/dataform/hooks/useMainFormCommands.js +9 -1
  38. package/dataform/utils/index.d.ts +4 -3
  39. package/dataform/utils/index.js +24 -6
  40. package/datagrid/DataGridProvider/DataResolver.js +9 -49
  41. package/datagrid/DataGridProvider/index.d.ts +5 -0
  42. package/datagrid/DataGridProvider/index.js +8 -0
  43. package/datagrid/DataGridProvider/transformViewColumns.js +4 -4
  44. package/datagrid/DataGridProvider/utils.d.ts +7 -2
  45. package/datagrid/DataGridProvider/utils.js +52 -2
  46. package/datagrid/column-filter/constants.js +38 -3
  47. package/datagrid/context.d.ts +9 -6
  48. package/datagrid/hooks/useGridCommands.d.ts +3 -0
  49. package/datagrid/hooks/useGridCommands.js +3 -0
  50. package/datagrid/hooks/useMainGridCommands.d.ts +1 -13
  51. package/datagrid/hooks/useMainGridCommands.js +38 -26
  52. package/datagrid/hooks/useOpenRecord.d.ts +1 -0
  53. package/datagrid/hooks/useOpenRecord.js +34 -0
  54. package/datagrid/hooks/useSubGridCommands.js +25 -65
  55. package/defaults.d.ts +2 -0
  56. package/defaults.js +5 -0
  57. package/form/FormValidationStringContext.d.ts +1 -0
  58. package/form/FormValidationStringContext.js +1 -0
  59. package/hooks/useSystemColorScheme.d.ts +1 -1
  60. package/locale/LocaleProvider.d.ts +2 -1
  61. package/locale/LocaleProvider.js +3 -3
  62. package/locale/index.d.ts +1 -0
  63. package/locale/index.js +1 -0
  64. package/locale/useCurrencySymbol.d.ts +1 -0
  65. package/locale/useCurrencySymbol.js +13 -0
  66. package/locale/utils.d.ts +5 -0
  67. package/locale/utils.js +7 -0
  68. package/metadata/MetadataProvider.d.ts +8 -4
  69. package/metadata/MetadataProvider.js +23 -16
  70. package/metadata/hooks/useExperienceViewCommands.js +7 -1
  71. package/metadata/hooks/useExperienceViewSubgridCommands.js +7 -1
  72. package/metadata/hooks/useMetadata.d.ts +1 -0
  73. package/metadata/hooks/useMetadata.js +4 -2
  74. package/metadata/hooks/useSchema.js +2 -2
  75. package/mutable/context.js +1 -1
  76. package/navigation/hooks/index.d.ts +1 -0
  77. package/{appearance → navigation}/hooks/index.js +1 -1
  78. package/navigation/hooks/useOpenForm.d.ts +2 -4
  79. package/navigation/hooks/useOpenForm.js +7 -3
  80. package/navigation/index.d.ts +1 -0
  81. package/{appearance → navigation}/index.js +0 -3
  82. package/package.json +12 -3
  83. package/recordset/RecordSetProvider.js +1 -1
  84. package/recordset/hooks/useRecordSetResult.js +1 -1
  85. package/route/RouteProvider.d.ts +2 -2
  86. package/route/RouteProvider.js +4 -1
  87. package/store/ComponentStore.d.ts +1 -1
  88. package/store/ComponentStore.js +5 -9
  89. package/store/SchemaExperienceStore.d.ts +3 -3
  90. package/transport/RestDataService/index.d.ts +1 -1
  91. package/transport/RestDataService/index.js +17 -16
  92. package/transport/context.d.ts +3 -1
  93. package/transport/context.js +16 -1
  94. package/transport/hooks/index.d.ts +1 -0
  95. package/transport/hooks/index.js +1 -0
  96. package/transport/hooks/useFileService.d.ts +1 -0
  97. package/transport/hooks/useFileService.js +12 -0
  98. package/utils/getAttributeFormattedValue.d.ts +1 -0
  99. package/utils/getAttributeFormattedValue.js +12 -4
  100. package/appearance/context.d.ts +0 -7
  101. package/appearance/context.js +0 -5
  102. package/appearance/hooks/index.d.ts +0 -1
  103. package/appearance/hooks/useAppearanceContext.d.ts +0 -1
  104. package/appearance/hooks/useAppearanceContext.js +0 -12
  105. package/appearance/index.d.ts +0 -2
  106. package/builders/CommandBuilder.d.ts +0 -176
  107. package/builders/CommandBuilder.js +0 -474
  108. package/locale/types.d.ts +0 -2
  109. package/locale/types.js +0 -2
@@ -1,7 +1,7 @@
1
1
  import { FC, PropsWithChildren } from 'react';
2
2
  import { AuthProviderPlaceholderProps } from '../auth';
3
3
  interface AuthWrapperProps {
4
- Placeholder: FC<AuthProviderPlaceholderProps>;
4
+ Placeholder?: FC<AuthProviderPlaceholderProps>;
5
5
  }
6
6
  export declare const AuthWrapper: FC<PropsWithChildren<AuthWrapperProps>>;
7
7
  export {};
@@ -4,7 +4,10 @@ exports.AuthWrapper = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const auth_1 = require("../auth");
6
6
  const mutable_1 = require("../mutable");
7
- const AuthWrapper = ({ children, Placeholder, }) => {
7
+ const DefaultPlaceHolder = () => {
8
+ return null;
9
+ };
10
+ const AuthWrapper = ({ children, Placeholder = DefaultPlaceHolder, }) => {
8
11
  const state = (0, mutable_1.useContextSelector)(auth_1.AuthContext, (state) => state);
9
12
  if (state.loadError) {
10
13
  return (0, jsx_runtime_1.jsx)(Placeholder, { loadingError: true, retry: state.loadSession });
@@ -1,28 +1,23 @@
1
- import { IDataService } from '@headless-adminapp/core/transport';
1
+ import { IDataService, IFileService } from '@headless-adminapp/core/transport';
2
2
  import { QueryClient } from '@tanstack/react-query';
3
- import { Dispatch, FC, PropsWithChildren, SetStateAction } from 'react';
4
- import { AppearanceContextState } from '../appearance';
3
+ import { FC, PropsWithChildren } from 'react';
5
4
  import { AuthProviderPlaceholderProps, AuthProviderProps } from '../auth';
6
5
  import { LocaleProviderProps } from '../locale';
7
6
  import { MetadataProviderProps } from '../metadata/MetadataProvider';
8
7
  import { RouteProviderProps } from '../route/RouteProvider';
9
8
  export interface LayoutProviderProps {
10
9
  routeProps: RouteProviderProps;
11
- queryClient: QueryClient;
12
- appearanceState: [
13
- AppearanceContextState,
14
- Dispatch<SetStateAction<AppearanceContextState>>
15
- ];
16
- localeProps: LocaleProviderProps;
17
- dataService: IDataService;
18
- authProps: AuthProviderProps;
19
- authPlaceholder: FC<AuthProviderPlaceholderProps>;
20
- metadataProps: MetadataProviderProps;
10
+ queryClient?: QueryClient;
11
+ localeProps?: LocaleProviderProps;
12
+ dataService?: IDataService;
13
+ fileService?: IFileService;
14
+ authProps?: AuthProviderProps;
15
+ authPlaceholder?: FC<AuthProviderPlaceholderProps>;
16
+ metadataProps?: MetadataProviderProps;
21
17
  containers: {
22
18
  DialogContainer: FC;
23
19
  ProgressIndicatorContainer: FC;
24
20
  ToastNotificationContainer: FC;
25
21
  };
26
22
  }
27
- /** @todo: move to app */
28
23
  export declare const LayoutProvider: FC<PropsWithChildren<LayoutProviderProps>>;
@@ -1,10 +1,19 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.LayoutProvider = void 0;
4
13
  const jsx_runtime_1 = require("react/jsx-runtime");
5
14
  const react_query_1 = require("@tanstack/react-query");
6
- const appearance_1 = require("../appearance");
7
15
  const auth_1 = require("../auth");
16
+ const defaults_1 = require("../defaults");
8
17
  const dialog_1 = require("../dialog");
9
18
  const locale_1 = require("../locale");
10
19
  const metadata_1 = require("../metadata");
@@ -13,9 +22,33 @@ const recordset_1 = require("../recordset");
13
22
  const route_1 = require("../route");
14
23
  const toast_notification_1 = require("../toast-notification");
15
24
  const transport_1 = require("../transport");
25
+ const context_1 = require("../transport/context");
16
26
  const AuthWrapper_1 = require("./AuthWrapper");
17
- /** @todo: move to app */
18
- const LayoutProvider = ({ appearanceState, authPlaceholder, authProps, dataService, localeProps, metadataProps, queryClient, routeProps, children, containers: { DialogContainer, ProgressIndicatorContainer, ToastNotificationContainer, }, }) => {
19
- return ((0, jsx_runtime_1.jsx)(route_1.RouteProvider, Object.assign({}, routeProps, { children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(appearance_1.AppearanceContext.Provider, { value: appearanceState, children: (0, jsx_runtime_1.jsx)(locale_1.LocaleProvider, Object.assign({}, localeProps, { children: (0, jsx_runtime_1.jsx)(metadata_1.MetadataProvider, Object.assign({}, metadataProps, { children: (0, jsx_runtime_1.jsx)(transport_1.DataServiceContext.Provider, { value: dataService, children: (0, jsx_runtime_1.jsx)(dialog_1.DialogProvider, { children: (0, jsx_runtime_1.jsx)(progress_indicator_1.ProgressIndicatorProvider, { children: (0, jsx_runtime_1.jsxs)(toast_notification_1.ToastNotificationProvider, { children: [(0, jsx_runtime_1.jsx)(DialogContainer, {}), (0, jsx_runtime_1.jsx)(ProgressIndicatorContainer, {}), (0, jsx_runtime_1.jsx)(ToastNotificationContainer, {}), (0, jsx_runtime_1.jsx)(auth_1.AuthProvider, Object.assign({}, authProps, { children: (0, jsx_runtime_1.jsx)(AuthWrapper_1.AuthWrapper, { Placeholder: authPlaceholder, children: (0, jsx_runtime_1.jsx)(recordset_1.RecordSetProvider, { children: children }) }) }))] }) }) }) }) })) })) }) }) })));
27
+ const dataServiceNotProvidedError = new Error('No data service provided');
28
+ const defaultDataService = {
29
+ createRecord: () => __awaiter(void 0, void 0, void 0, function* () {
30
+ throw dataServiceNotProvidedError;
31
+ }),
32
+ deleteRecord: () => __awaiter(void 0, void 0, void 0, function* () {
33
+ throw dataServiceNotProvidedError;
34
+ }),
35
+ customAction: () => __awaiter(void 0, void 0, void 0, function* () {
36
+ throw dataServiceNotProvidedError;
37
+ }),
38
+ retriveAggregate: () => __awaiter(void 0, void 0, void 0, function* () {
39
+ throw dataServiceNotProvidedError;
40
+ }),
41
+ retriveRecord: () => __awaiter(void 0, void 0, void 0, function* () {
42
+ throw dataServiceNotProvidedError;
43
+ }),
44
+ retriveRecords: () => __awaiter(void 0, void 0, void 0, function* () {
45
+ throw dataServiceNotProvidedError;
46
+ }),
47
+ updateRecord: () => __awaiter(void 0, void 0, void 0, function* () {
48
+ throw dataServiceNotProvidedError;
49
+ }),
50
+ };
51
+ const LayoutProvider = ({ authPlaceholder, authProps, dataService = defaultDataService, fileService, localeProps, metadataProps, queryClient = defaults_1.queryClient, routeProps, children, containers: { DialogContainer, ProgressIndicatorContainer, ToastNotificationContainer, }, }) => {
52
+ return ((0, jsx_runtime_1.jsx)(route_1.RouteProvider, Object.assign({}, routeProps, { children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(locale_1.LocaleProvider, Object.assign({}, localeProps, { children: (0, jsx_runtime_1.jsx)(metadata_1.MetadataProvider, Object.assign({}, metadataProps, { children: (0, jsx_runtime_1.jsx)(transport_1.DataServiceContext.Provider, { value: dataService, children: (0, jsx_runtime_1.jsx)(context_1.FileServiceContext.Provider, { value: fileService !== null && fileService !== void 0 ? fileService : context_1.noopFileService, children: (0, jsx_runtime_1.jsx)(dialog_1.DialogProvider, { children: (0, jsx_runtime_1.jsx)(progress_indicator_1.ProgressIndicatorProvider, { children: (0, jsx_runtime_1.jsxs)(toast_notification_1.ToastNotificationProvider, { children: [(0, jsx_runtime_1.jsx)(DialogContainer, {}), (0, jsx_runtime_1.jsx)(ProgressIndicatorContainer, {}), (0, jsx_runtime_1.jsx)(ToastNotificationContainer, {}), (0, jsx_runtime_1.jsx)(auth_1.AuthProvider, Object.assign({}, authProps, { children: (0, jsx_runtime_1.jsx)(AuthWrapper_1.AuthWrapper, { Placeholder: authPlaceholder, children: (0, jsx_runtime_1.jsx)(recordset_1.RecordSetProvider, { children: children }) }) }))] }) }) }) }) }) })) })) }) })));
20
53
  };
21
54
  exports.LayoutProvider = LayoutProvider;
package/app/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { AppContext } from './context';
2
2
  export { useAppContext } from './hooks';
3
3
  export { AppProvider } from './AppProvider';
4
+ export { LayoutProvider } from './LayoutProvider';
package/app/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppProvider = exports.useAppContext = exports.AppContext = void 0;
3
+ exports.LayoutProvider = exports.AppProvider = exports.useAppContext = exports.AppContext = void 0;
4
4
  var context_1 = require("./context");
5
5
  Object.defineProperty(exports, "AppContext", { enumerable: true, get: function () { return context_1.AppContext; } });
6
6
  var hooks_1 = require("./hooks");
7
7
  Object.defineProperty(exports, "useAppContext", { enumerable: true, get: function () { return hooks_1.useAppContext; } });
8
8
  var AppProvider_1 = require("./AppProvider");
9
9
  Object.defineProperty(exports, "AppProvider", { enumerable: true, get: function () { return AppProvider_1.AppProvider; } });
10
+ var LayoutProvider_1 = require("./LayoutProvider");
11
+ Object.defineProperty(exports, "LayoutProvider", { enumerable: true, get: function () { return LayoutProvider_1.LayoutProvider; } });
@@ -2,6 +2,6 @@ import { FC, PropsWithChildren } from 'react';
2
2
  import { SessionResolver, UnauthorizeReason } from './types';
3
3
  export interface AuthProviderProps {
4
4
  onUnauthenticated?: (reason: UnauthorizeReason) => void;
5
- sessionResolver: SessionResolver;
5
+ sessionResolver?: SessionResolver;
6
6
  }
7
7
  export declare const AuthProvider: FC<PropsWithChildren<AuthProviderProps>>;
@@ -11,16 +11,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AuthProvider = void 0;
13
13
  const jsx_runtime_1 = require("react/jsx-runtime");
14
+ const react_query_1 = require("@tanstack/react-query");
14
15
  const react_1 = require("react");
15
16
  const context_1 = require("../mutable/context");
16
17
  const context_2 = require("./context");
17
- const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
18
+ const defaultSessionResolver = () => __awaiter(void 0, void 0, void 0, function* () {
19
+ return {
20
+ email: 'demo@example.com',
21
+ fullName: 'Demo User',
22
+ exp: Date.now() / 1000 + 60 * 60 * 24,
23
+ };
24
+ });
25
+ const AuthProvider = ({ sessionResolver = defaultSessionResolver, onUnauthenticated, children, }) => {
18
26
  const onUnauthenticatedRef = (0, react_1.useRef)(onUnauthenticated);
19
27
  onUnauthenticatedRef.current = onUnauthenticated;
28
+ const queryClient = (0, react_query_1.useQueryClient)();
20
29
  const onUnauthenticatedInternal = (0, react_1.useCallback)((reason) => {
21
30
  var _a;
22
31
  (_a = onUnauthenticatedRef.current) === null || _a === void 0 ? void 0 : _a.call(onUnauthenticatedRef, reason);
23
- }, []);
32
+ queryClient.clear();
33
+ queryClient.removeQueries({
34
+ queryKey: ['data'],
35
+ });
36
+ queryClient
37
+ .invalidateQueries({
38
+ queryKey: ['data'],
39
+ })
40
+ .catch(console.error);
41
+ }, [queryClient]);
24
42
  const contextValue = (0, context_1.useCreateContextStore)({
25
43
  loading: true,
26
44
  loadError: false,
@@ -0,0 +1,10 @@
1
+ import { DefaultCommandBuilder } from './DefaultCommandBuilder';
2
+ import { FormCommandBuilder } from './FormCommandBuilder';
3
+ import { SubgridCommandBuilder } from './SubgridCommandBuilder';
4
+ import { ViewCommandBuilder } from './ViewCommandBuilder';
5
+ export declare namespace CommandBuilder {
6
+ const View: typeof ViewCommandBuilder;
7
+ const Form: typeof FormCommandBuilder;
8
+ const Subgrid: typeof SubgridCommandBuilder;
9
+ const Default: typeof DefaultCommandBuilder;
10
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandBuilder = void 0;
4
+ const DefaultCommandBuilder_1 = require("./DefaultCommandBuilder");
5
+ const FormCommandBuilder_1 = require("./FormCommandBuilder");
6
+ const SubgridCommandBuilder_1 = require("./SubgridCommandBuilder");
7
+ const ViewCommandBuilder_1 = require("./ViewCommandBuilder");
8
+ var CommandBuilder;
9
+ (function (CommandBuilder) {
10
+ CommandBuilder.View = ViewCommandBuilder_1.ViewCommandBuilder;
11
+ CommandBuilder.Form = FormCommandBuilder_1.FormCommandBuilder;
12
+ CommandBuilder.Subgrid = SubgridCommandBuilder_1.SubgridCommandBuilder;
13
+ CommandBuilder.Default = DefaultCommandBuilder_1.DefaultCommandBuilder;
14
+ })(CommandBuilder || (exports.CommandBuilder = CommandBuilder = {}));
@@ -0,0 +1,88 @@
1
+ import { EntityMainFormCommandItemExperience } from '@headless-adminapp/core/experience/form';
2
+ import { EntityMainGridCommandItemExperience, SubGridCommandItemExperience } from '@headless-adminapp/core/experience/view';
3
+ import { Localized } from '@headless-adminapp/core/types';
4
+ import { Icon } from '@headless-adminapp/icons';
5
+ import { FormCommandBuilder } from './FormCommandBuilder';
6
+ import { ViewCommandBuilder } from './ViewCommandBuilder';
7
+ export declare namespace DefaultCommandBuilder {
8
+ interface CreateDefaultViewCommandStrings {
9
+ new: string;
10
+ edit: string;
11
+ delete: string;
12
+ refresh: string;
13
+ export: string;
14
+ exportCsv: string;
15
+ exportExcel: string;
16
+ deleteRecordCommandStringSet: ViewCommandBuilder.DeleteRecordCommandStringSet;
17
+ }
18
+ export const defaultViewCommandStrings: CreateDefaultViewCommandStrings;
19
+ interface CreateDefaultViewCommandOptions {
20
+ icons: {
21
+ New: Icon;
22
+ Edit: Icon;
23
+ Delete: Icon;
24
+ Refresh: Icon;
25
+ Export: Icon;
26
+ ExportCsv: Icon;
27
+ ExportExcel: Icon;
28
+ };
29
+ strings?: CreateDefaultViewCommandStrings;
30
+ localizedSrings?: Localized<CreateDefaultViewCommandStrings>;
31
+ }
32
+ export function createDefaultViewCommands({ icons, strings, localizedSrings, }: CreateDefaultViewCommandOptions): EntityMainGridCommandItemExperience[][];
33
+ interface CreateDefaultFormCommandStrings {
34
+ save: string;
35
+ saveAndClose: string;
36
+ refresh: string;
37
+ delete: string;
38
+ deleteRecordCommandStringSet: FormCommandBuilder.DeleteRecordCommandStringSet;
39
+ }
40
+ interface CreateDefaultFormCommandOptions {
41
+ icons: {
42
+ Save: Icon;
43
+ SaveAndClose: Icon;
44
+ Refresh: Icon;
45
+ Delete: Icon;
46
+ };
47
+ strings?: CreateDefaultFormCommandStrings;
48
+ localizedSrings?: Localized<CreateDefaultFormCommandStrings>;
49
+ }
50
+ export const defaultFormCommandStrings: CreateDefaultFormCommandStrings;
51
+ export function createDefaultFormCommands({ icons, strings, localizedSrings, }: CreateDefaultFormCommandOptions): EntityMainFormCommandItemExperience[][];
52
+ interface CreateDefaultSubgridCommandStrings {
53
+ new: string;
54
+ edit: string;
55
+ delete: string;
56
+ refresh: string;
57
+ export: string;
58
+ exportCsv: string;
59
+ exportExcel: string;
60
+ deleteRecordCommandStringSet: ViewCommandBuilder.DeleteRecordCommandStringSet;
61
+ }
62
+ interface CreateDefaultSubgridCommandOptions {
63
+ icons: {
64
+ New: Icon;
65
+ Edit: Icon;
66
+ Delete: Icon;
67
+ Refresh: Icon;
68
+ Export: Icon;
69
+ ExportCsv: Icon;
70
+ ExportExcel: Icon;
71
+ };
72
+ strings?: CreateDefaultSubgridCommandStrings;
73
+ localizedSrings?: Localized<CreateDefaultSubgridCommandStrings>;
74
+ }
75
+ export function createDefaultSubgridCommands({ icons, strings, localizedSrings, }: CreateDefaultSubgridCommandOptions): SubGridCommandItemExperience[][];
76
+ type CreateDefaultCommandStrings = CreateDefaultViewCommandStrings & CreateDefaultFormCommandStrings & CreateDefaultSubgridCommandStrings;
77
+ interface CreateDefaultCommandOptions {
78
+ icons: CreateDefaultViewCommandOptions['icons'] & CreateDefaultFormCommandOptions['icons'] & CreateDefaultSubgridCommandOptions['icons'];
79
+ strings?: CreateDefaultCommandStrings;
80
+ localizedSrings?: Localized<CreateDefaultCommandStrings>;
81
+ }
82
+ export function createDefaultCommands({ icons, strings, localizedSrings, }: CreateDefaultCommandOptions): {
83
+ view: EntityMainGridCommandItemExperience[][];
84
+ form: EntityMainFormCommandItemExperience[][];
85
+ subgrid: SubGridCommandItemExperience[][];
86
+ };
87
+ export {};
88
+ }
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultCommandBuilder = void 0;
4
+ const FormCommandBuilder_1 = require("./FormCommandBuilder");
5
+ const SubgridCommandBuilder_1 = require("./SubgridCommandBuilder");
6
+ const ViewCommandBuilder_1 = require("./ViewCommandBuilder");
7
+ var DefaultCommandBuilder;
8
+ (function (DefaultCommandBuilder) {
9
+ DefaultCommandBuilder.defaultViewCommandStrings = {
10
+ new: 'New',
11
+ edit: 'Edit',
12
+ delete: 'Delete',
13
+ deleteRecordCommandStringSet: ViewCommandBuilder_1.ViewCommandBuilder.defaultDeleteRecordStringSet,
14
+ refresh: 'Refresh',
15
+ export: 'Export',
16
+ exportCsv: 'CSV',
17
+ exportExcel: 'Excel',
18
+ };
19
+ function extractLocalizedStrings(localizedStrings, selector) {
20
+ if (!localizedStrings) {
21
+ return;
22
+ }
23
+ return Object.keys(localizedStrings).reduce((p, key) => {
24
+ p[key] = selector(localizedStrings[key]);
25
+ return p;
26
+ }, {});
27
+ }
28
+ function createDefaultViewCommands({ icons, strings = DefaultCommandBuilder.defaultViewCommandStrings, localizedSrings, }) {
29
+ return [
30
+ [
31
+ ViewCommandBuilder_1.ViewCommandBuilder.createNewRecordCommand({
32
+ Icon: icons.New,
33
+ text: strings.new,
34
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.new),
35
+ }),
36
+ ViewCommandBuilder_1.ViewCommandBuilder.createEditRecordCommand({
37
+ Icon: icons.Edit,
38
+ text: strings.edit,
39
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.edit),
40
+ }),
41
+ ViewCommandBuilder_1.ViewCommandBuilder.createDeleteRecordCommand({
42
+ Icon: icons.Delete,
43
+ text: strings.delete,
44
+ localizedText: extractLocalizedStrings(localizedSrings, (x) => x.delete),
45
+ stringSet: strings.deleteRecordCommandStringSet,
46
+ localizedStringSet: extractLocalizedStrings(localizedSrings, (x) => x.deleteRecordCommandStringSet),
47
+ }),
48
+ ViewCommandBuilder_1.ViewCommandBuilder.createRefreshCommand({
49
+ Icon: icons.Refresh,
50
+ text: strings.refresh,
51
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.refresh),
52
+ }),
53
+ ],
54
+ [
55
+ ViewCommandBuilder_1.ViewCommandBuilder.createExportCommand({
56
+ button: {
57
+ Icon: icons.Export,
58
+ text: strings.export,
59
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.export),
60
+ },
61
+ csv: {
62
+ Icon: icons.ExportCsv,
63
+ text: strings.exportCsv,
64
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportCsv),
65
+ },
66
+ excel: {
67
+ Icon: icons.ExportExcel,
68
+ text: strings.exportExcel,
69
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportExcel),
70
+ },
71
+ }),
72
+ ],
73
+ ];
74
+ }
75
+ DefaultCommandBuilder.createDefaultViewCommands = createDefaultViewCommands;
76
+ DefaultCommandBuilder.defaultFormCommandStrings = {
77
+ save: 'Save',
78
+ saveAndClose: 'Save & Close',
79
+ refresh: 'Refresh',
80
+ delete: 'Delete',
81
+ deleteRecordCommandStringSet: FormCommandBuilder_1.FormCommandBuilder.defaultDeleteRecordStringSet,
82
+ };
83
+ function createDefaultFormCommands({ icons, strings = DefaultCommandBuilder.defaultFormCommandStrings, localizedSrings, }) {
84
+ return [
85
+ [
86
+ FormCommandBuilder_1.FormCommandBuilder.createSaveCommand({
87
+ Icon: icons.Save,
88
+ text: strings.save,
89
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.save),
90
+ }),
91
+ FormCommandBuilder_1.FormCommandBuilder.createSaveAndCloseCommand({
92
+ Icon: icons.SaveAndClose,
93
+ text: strings.saveAndClose,
94
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.saveAndClose),
95
+ }),
96
+ FormCommandBuilder_1.FormCommandBuilder.createRefreshCommand({
97
+ Icon: icons.Refresh,
98
+ text: strings.refresh,
99
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.refresh),
100
+ }),
101
+ FormCommandBuilder_1.FormCommandBuilder.createDeleteCommand({
102
+ Icon: icons.Delete,
103
+ text: 'Delete',
104
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.delete),
105
+ stringSet: strings.deleteRecordCommandStringSet,
106
+ localizedStringSet: extractLocalizedStrings(localizedSrings, (x) => x.deleteRecordCommandStringSet),
107
+ }),
108
+ ],
109
+ ];
110
+ }
111
+ DefaultCommandBuilder.createDefaultFormCommands = createDefaultFormCommands;
112
+ const defaultSubgridCommandStrings = {
113
+ new: 'New',
114
+ edit: 'Edit',
115
+ delete: 'Delete',
116
+ refresh: 'Refresh',
117
+ export: 'Export',
118
+ exportCsv: 'CSV',
119
+ exportExcel: 'Excel',
120
+ deleteRecordCommandStringSet: ViewCommandBuilder_1.ViewCommandBuilder.defaultDeleteRecordStringSet,
121
+ };
122
+ function createDefaultSubgridCommands({ icons, strings = defaultSubgridCommandStrings, localizedSrings, }) {
123
+ return [
124
+ [
125
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createNewRecordCommand({
126
+ Icon: icons.New,
127
+ text: strings.new,
128
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.new),
129
+ }),
130
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createEditRecordCommand({
131
+ Icon: icons.Edit,
132
+ text: strings.edit,
133
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.edit),
134
+ }),
135
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createDeleteRecordCommand({
136
+ Icon: icons.Delete,
137
+ text: strings.delete,
138
+ localizedText: extractLocalizedStrings(localizedSrings, (x) => x.delete),
139
+ stringSet: strings.deleteRecordCommandStringSet,
140
+ localizedStringSet: extractLocalizedStrings(localizedSrings, (x) => x.deleteRecordCommandStringSet),
141
+ }),
142
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createRefreshCommand({
143
+ Icon: icons.Refresh,
144
+ text: strings.refresh,
145
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.refresh),
146
+ }),
147
+ ],
148
+ [
149
+ SubgridCommandBuilder_1.SubgridCommandBuilder.createExportCommand({
150
+ button: {
151
+ Icon: icons.Export,
152
+ text: strings.export,
153
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.export),
154
+ },
155
+ csv: {
156
+ Icon: icons.ExportCsv,
157
+ text: strings.exportCsv,
158
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportCsv),
159
+ },
160
+ excel: {
161
+ Icon: icons.ExportExcel,
162
+ text: strings.exportExcel,
163
+ localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.exportExcel),
164
+ },
165
+ }),
166
+ ],
167
+ ];
168
+ }
169
+ DefaultCommandBuilder.createDefaultSubgridCommands = createDefaultSubgridCommands;
170
+ const defaultCreateCommandStrings = Object.assign(Object.assign(Object.assign({}, DefaultCommandBuilder.defaultViewCommandStrings), DefaultCommandBuilder.defaultFormCommandStrings), defaultSubgridCommandStrings);
171
+ function createDefaultCommands({ icons, strings = defaultCreateCommandStrings, localizedSrings, }) {
172
+ return {
173
+ view: createDefaultViewCommands({
174
+ icons,
175
+ strings,
176
+ localizedSrings,
177
+ }),
178
+ form: createDefaultFormCommands({
179
+ icons,
180
+ strings,
181
+ localizedSrings,
182
+ }),
183
+ subgrid: createDefaultSubgridCommands({
184
+ icons,
185
+ strings,
186
+ localizedSrings,
187
+ }),
188
+ };
189
+ }
190
+ DefaultCommandBuilder.createDefaultCommands = createDefaultCommands;
191
+ })(DefaultCommandBuilder || (exports.DefaultCommandBuilder = DefaultCommandBuilder = {}));
@@ -0,0 +1,46 @@
1
+ import { EntityMainFormCommandItemExperience } from '@headless-adminapp/core/experience/form';
2
+ import { Localized } from '@headless-adminapp/core/types';
3
+ import { Icon } from '@headless-adminapp/icons';
4
+ export declare namespace FormCommandBuilder {
5
+ function createSaveCommand({ Icon, text, localizedTexts, }: {
6
+ Icon: Icon;
7
+ text: string;
8
+ localizedTexts?: Record<string, string>;
9
+ }): EntityMainFormCommandItemExperience;
10
+ function createSaveAndCloseCommand({ Icon, text, localizedTexts, }: {
11
+ Icon: Icon;
12
+ text: string;
13
+ localizedTexts?: Record<string, string>;
14
+ }): EntityMainFormCommandItemExperience;
15
+ interface DeleteRecordCommandStringSet {
16
+ confirmation: {
17
+ title: string | [string, string];
18
+ text: string | [string, string];
19
+ buttonCancel: string;
20
+ buttonConfirm: string;
21
+ };
22
+ status: {
23
+ deleting: string | [string, string];
24
+ };
25
+ successNotification: {
26
+ title: string | [string, string];
27
+ text: string | [string, string];
28
+ };
29
+ errorNotification: {
30
+ title: string;
31
+ };
32
+ }
33
+ const defaultDeleteRecordStringSet: DeleteRecordCommandStringSet;
34
+ function createDeleteCommand({ Icon, text, localizedTexts, stringSet, localizedStringSet, }: {
35
+ Icon: Icon;
36
+ text: string;
37
+ localizedTexts?: Record<string, string>;
38
+ stringSet: DeleteRecordCommandStringSet;
39
+ localizedStringSet?: Localized<DeleteRecordCommandStringSet>;
40
+ }): EntityMainFormCommandItemExperience;
41
+ function createRefreshCommand({ Icon, text, localizedTexts, }: {
42
+ Icon: Icon;
43
+ text: string;
44
+ localizedTexts?: Record<string, string>;
45
+ }): EntityMainFormCommandItemExperience;
46
+ }