@headless-adminapp/app 0.0.17-alpha.1 → 0.0.17-alpha.10

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 (78) hide show
  1. package/app/AuthWrapper.d.ts +7 -0
  2. package/app/AuthWrapper.js +23 -0
  3. package/app/LayoutProvider.d.ts +22 -0
  4. package/app/LayoutProvider.js +19 -0
  5. package/app/index.d.ts +1 -0
  6. package/app/index.js +3 -1
  7. package/builders/CommandBuilder/CommandBuilder.d.ts +10 -0
  8. package/builders/CommandBuilder/CommandBuilder.js +14 -0
  9. package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +81 -0
  10. package/builders/CommandBuilder/DefaultCommandBuilder.js +173 -0
  11. package/builders/CommandBuilder/FormCommandBuilder.d.ts +45 -0
  12. package/builders/CommandBuilder/FormCommandBuilder.js +145 -0
  13. package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +64 -0
  14. package/builders/CommandBuilder/SubgridCommandBuilder.js +170 -0
  15. package/builders/CommandBuilder/ViewCommandBuilder.d.ts +63 -0
  16. package/builders/CommandBuilder/ViewCommandBuilder.js +250 -0
  17. package/builders/CommandBuilder/index.d.ts +1 -0
  18. package/builders/CommandBuilder/index.js +5 -0
  19. package/builders/CommandBuilder/utils.d.ts +3 -0
  20. package/builders/CommandBuilder/utils.js +21 -0
  21. package/builders/SchemaExperienceBuilder.d.ts +2 -5
  22. package/builders/SchemaExperienceBuilder.js +16 -26
  23. package/builders/index.d.ts +1 -1
  24. package/builders/index.js +1 -2
  25. package/builders/utils.d.ts +28 -0
  26. package/builders/utils.js +185 -0
  27. package/command/hooks/useBaseCommandHandlerContext.js +9 -0
  28. package/command/hooks/useCommands.d.ts +1 -1
  29. package/command/hooks/useCommands.js +1 -1
  30. package/dataform/DataFormProvider/DataResolver.js +4 -4
  31. package/dataform/DataFormProvider/InitialValueResolver.js +0 -1
  32. package/dataform/DataFormProvider/index.js +3 -3
  33. package/dataform/hooks/useFormSave.js +2 -2
  34. package/dataform/hooks/useLoadFormGridPage.js +7 -1
  35. package/dataform/utils/index.d.ts +4 -3
  36. package/dataform/utils/index.js +23 -28
  37. package/datagrid/DataGridProvider/DataResolver.js +3 -48
  38. package/datagrid/DataGridProvider/transformViewColumns.js +4 -4
  39. package/datagrid/DataGridProvider/utils.d.ts +7 -2
  40. package/datagrid/DataGridProvider/utils.js +52 -2
  41. package/datagrid/context.d.ts +4 -6
  42. package/datagrid/hooks/useGridCommands.d.ts +3 -0
  43. package/datagrid/hooks/useGridCommands.js +3 -0
  44. package/datagrid/hooks/useMainGridCommands.d.ts +1 -13
  45. package/datagrid/hooks/useMainGridCommands.js +23 -146
  46. package/datagrid/hooks/useOpenRecord.d.ts +1 -0
  47. package/datagrid/hooks/useOpenRecord.js +34 -0
  48. package/datagrid/hooks/useSubGridCommands.js +15 -30
  49. package/hooks/useSystemColorScheme.d.ts +1 -1
  50. package/locale/LocaleProvider.js +1 -1
  51. package/locale/utils.d.ts +5 -0
  52. package/locale/utils.js +7 -0
  53. package/metadata/hooks/useExperienceViewCommands.js +7 -1
  54. package/metadata/hooks/useExperienceViewSubgridCommands.js +7 -1
  55. package/metadata/hooks/useMetadata.d.ts +1 -0
  56. package/metadata/hooks/useMetadata.js +2 -0
  57. package/metadata/hooks/useSchema.js +2 -2
  58. package/mutable/context.js +1 -1
  59. package/navigation/hooks/index.d.ts +1 -0
  60. package/{appearance → navigation}/hooks/index.js +1 -1
  61. package/navigation/hooks/useOpenForm.d.ts +2 -4
  62. package/navigation/hooks/useOpenForm.js +7 -3
  63. package/navigation/index.d.ts +1 -0
  64. package/{appearance → navigation}/index.js +0 -3
  65. package/package.json +12 -3
  66. package/recordset/RecordSetProvider.js +1 -1
  67. package/recordset/hooks/useRecordSetResult.js +1 -2
  68. package/store/SchemaExperienceStore.d.ts +3 -3
  69. package/appearance/context.d.ts +0 -7
  70. package/appearance/context.js +0 -5
  71. package/appearance/hooks/index.d.ts +0 -1
  72. package/appearance/hooks/useAppearanceContext.d.ts +0 -1
  73. package/appearance/hooks/useAppearanceContext.js +0 -12
  74. package/appearance/index.d.ts +0 -2
  75. package/builders/CommandBuilder.d.ts +0 -176
  76. package/builders/CommandBuilder.js +0 -474
  77. package/locale/types.d.ts +0 -2
  78. package/locale/types.js +0 -2
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformViewColumns = transformViewColumns;
4
- const CommandBuilder_1 = require("../../builders/CommandBuilder");
4
+ const utils_1 = require("../../locale/utils");
5
5
  function transformViewColumns(logicalName, columns, schemaStore, language) {
6
6
  const schema = schemaStore.getSchema(logicalName);
7
7
  return columns
8
- .map((column) => {
8
+ .map(column => {
9
9
  const attribute = schema.attributes[column.name];
10
10
  if (!attribute) {
11
11
  return null;
12
12
  }
13
- const label = (0, CommandBuilder_1.localizedLabel)(language, attribute);
13
+ const label = (0, utils_1.localizedLabel)(language, attribute);
14
14
  if (column.expandedKey) {
15
15
  if (attribute.type !== 'lookup') {
16
16
  return null;
@@ -20,7 +20,7 @@ function transformViewColumns(logicalName, columns, schemaStore, language) {
20
20
  if (!lookupAttribute) {
21
21
  return null;
22
22
  }
23
- const lookupLabel = (0, CommandBuilder_1.localizedLabel)(language, lookupAttribute);
23
+ const lookupLabel = (0, utils_1.localizedLabel)(language, lookupAttribute);
24
24
  return Object.assign(Object.assign({}, column), { id: `${column.name}.${column.expandedKey}`, label: `${lookupLabel} (${label})` });
25
25
  }
26
26
  return Object.assign(Object.assign({}, column), { id: column.name, label: label });
@@ -1,3 +1,8 @@
1
1
  import { ColumnCondition } from '@headless-adminapp/core/experience/view';
2
- import { Schema } from '@headless-adminapp/core/schema';
3
- export declare function transformColumnFilter(filter: Partial<Record<string, ColumnCondition>>, schema: Schema, getSchema: (logicalName: string) => Schema): Record<string, ColumnCondition> | null;
2
+ import { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
3
+ import { ISchemaStore } from '@headless-adminapp/core/store';
4
+ import { Filter } from '@headless-adminapp/core/transport';
5
+ import { TransformedViewColumn } from '../context';
6
+ export declare function transformColumnFilter<S extends SchemaAttributes = SchemaAttributes>(filter: Partial<Record<string, ColumnCondition>>, schema: Schema<S>, schemaStore: ISchemaStore): Record<string, ColumnCondition> | null;
7
+ export declare function mergeConditions<S extends SchemaAttributes = SchemaAttributes>(schema: Schema<S>, filter: Filter | null | undefined, extraFilter: Filter | null | undefined, columnFilters: Partial<Record<string, ColumnCondition>> | undefined, schemaStore: ISchemaStore): Filter | null;
8
+ export declare function collectExpandedKeys(columns: TransformedViewColumn<SchemaAttributes>[]): Record<string, string[]>;
@@ -4,8 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.transformColumnFilter = transformColumnFilter;
7
+ exports.mergeConditions = mergeConditions;
8
+ exports.collectExpandedKeys = collectExpandedKeys;
7
9
  const dayjs_1 = __importDefault(require("dayjs"));
8
- function transformColumnFilter(filter, schema, getSchema) {
10
+ function transformColumnFilter(filter, schema, schemaStore) {
9
11
  const transformedResult = Object.entries(filter).reduce((acc, [id, value]) => {
10
12
  const [key, extendedKey] = id.split('.');
11
13
  let attribute = schema.attributes[key];
@@ -16,7 +18,7 @@ function transformColumnFilter(filter, schema, getSchema) {
16
18
  if (attribute.type !== 'lookup') {
17
19
  throw new Error(`Invalid column filter key: ${id}. Key ${key} is not a lookup column.`);
18
20
  }
19
- const lookupSchema = getSchema(attribute.entity);
21
+ const lookupSchema = schemaStore.getSchema(attribute.entity);
20
22
  attribute = lookupSchema.attributes[extendedKey];
21
23
  }
22
24
  if (!attribute) {
@@ -72,3 +74,51 @@ function transformColumnFilter(filter, schema, getSchema) {
72
74
  }
73
75
  return transformedResult;
74
76
  }
77
+ function mergeConditions(schema, filter, extraFilter, columnFilters, schemaStore) {
78
+ const conditions = [];
79
+ if (filter) {
80
+ conditions.push(filter);
81
+ }
82
+ if (extraFilter) {
83
+ conditions.push(extraFilter);
84
+ }
85
+ if (columnFilters) {
86
+ const transformedColumnFilters = transformColumnFilter(columnFilters, schema, schemaStore);
87
+ if (transformedColumnFilters) {
88
+ conditions.push({
89
+ type: 'and',
90
+ conditions: Object.entries(transformedColumnFilters).map(([field, condition]) => {
91
+ return {
92
+ field,
93
+ operator: condition.operator,
94
+ value: condition.value,
95
+ extendedKey: condition.extendedKey,
96
+ };
97
+ }),
98
+ });
99
+ }
100
+ }
101
+ if (conditions.length === 0) {
102
+ return null;
103
+ }
104
+ if (conditions.length === 1) {
105
+ return conditions[0];
106
+ }
107
+ return {
108
+ type: 'and',
109
+ conditions,
110
+ };
111
+ }
112
+ function collectExpandedKeys(columns) {
113
+ return columns
114
+ .filter((x) => x.expandedKey)
115
+ .reduce((acc, x) => {
116
+ if (!acc[x.name]) {
117
+ acc[x.name] = [];
118
+ }
119
+ if (!acc[x.name].includes(x.expandedKey)) {
120
+ acc[x.name].push(x.expandedKey);
121
+ }
122
+ return acc;
123
+ }, {});
124
+ }
@@ -1,19 +1,17 @@
1
1
  import { LocalizedDataLookup } from '@headless-adminapp/core/attributes';
2
2
  import { CommandItemExperience } from '@headless-adminapp/core/experience/command';
3
- import { ColumnCondition, EntityMainGridCommandContext, EntitySubGridCommandContext, SortingState, View, ViewColumn } from '@headless-adminapp/core/experience/view';
3
+ import { ColumnCondition, EntityMainGridCommandContext, EntitySubGridCommandContext, SortingState, View } from '@headless-adminapp/core/experience/view';
4
+ import { type TransformedViewColumn } from '@headless-adminapp/core/experience/view/ViewColumn';
4
5
  import { InferredSchemaType, Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
5
6
  import { Filter, RetriveRecordsResult } from '@headless-adminapp/core/transport';
6
- export interface TransformedViewColumn<S extends SchemaAttributes = SchemaAttributes> extends ViewColumn<S> {
7
- id: string;
8
- label: string;
9
- }
7
+ export { type TransformedViewColumn } from '@headless-adminapp/core/experience/view/ViewColumn';
10
8
  export interface GridContextState<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext> {
11
9
  schema: Schema<S>;
12
10
  view: View<S>;
13
11
  viewLookup: LocalizedDataLookup[];
14
12
  onChangeView?: (viewId: string) => void;
15
13
  extraFilter?: Filter;
16
- commands: CommandItemExperience<CommandContext>[][];
14
+ commands?: CommandItemExperience<CommandContext>[][];
17
15
  maxRecords?: number;
18
16
  columns: TransformedViewColumn<S>[];
19
17
  searchText: string;
@@ -1,3 +1,6 @@
1
1
  import { CommandItemExperience } from '@headless-adminapp/core/experience/command';
2
2
  import { EntityMainGridCommandContext, EntitySubGridCommandContext } from '@headless-adminapp/core/experience/view';
3
+ /**
4
+ * @deprecated
5
+ */
3
6
  export declare function useGridCommands<CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext>(): CommandItemExperience<CommandContext>[][];
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useGridCommands = useGridCommands;
4
4
  const context_1 = require("../../mutable/context");
5
5
  const context_2 = require("../context");
6
+ /**
7
+ * @deprecated
8
+ */
6
9
  function useGridCommands() {
7
10
  const commands = (0, context_1.useContextSelector)(context_2.GridContext, (state) => state.commands);
8
11
  return commands;
@@ -1,19 +1,7 @@
1
1
  import { EntityMainGridCommandContext } from '@headless-adminapp/core/experience/view';
2
2
  import { CommandItemState, MenuItemCommandState, UtilityContextState } from '../../command/types';
3
3
  export declare function useUtility(): UtilityContextState;
4
- export declare function useGridControlContext(): {
5
- data: import("@headless-adminapp/core/transport").RetriveRecordsResult<import("@headless-adminapp/core/schema").InferredSchemaType<import("@headless-adminapp/core/schema").SchemaAttributes>> | null;
6
- logicalName: string;
7
- schema: import("@headless-adminapp/core/schema").Schema<import("@headless-adminapp/core/schema").SchemaAttributes>;
8
- refresh: () => void;
9
- searchText: string;
10
- selectedIds: string[];
11
- selectedRecords: import("@headless-adminapp/core/transport").Data<import("@headless-adminapp/core/schema").InferredSchemaType<import("@headless-adminapp/core/schema").SchemaAttributes>>[];
12
- view: import("@headless-adminapp/core/experience/view").View<import("@headless-adminapp/core/schema").SchemaAttributes>;
13
- viewId: string;
14
- columnFilter: Partial<Record<string, import("@headless-adminapp/core/experience/view").ColumnCondition>>;
15
- extraFilter: import("@headless-adminapp/core/transport").Filter | undefined;
16
- };
4
+ export declare function useGridControlContext(): EntityMainGridCommandContext['primaryControl'];
17
5
  export declare function useMainGridCommandHandlerContext(): EntityMainGridCommandContext;
18
6
  export declare function useMainGridCommands(): CommandItemState[][];
19
7
  export declare function useMainGridContextCommands(): MenuItemCommandState[][];
@@ -5,22 +5,23 @@ exports.useGridControlContext = useGridControlContext;
5
5
  exports.useMainGridCommandHandlerContext = useMainGridCommandHandlerContext;
6
6
  exports.useMainGridCommands = useMainGridCommands;
7
7
  exports.useMainGridContextCommands = useMainGridContextCommands;
8
- const react_query_1 = require("@tanstack/react-query");
8
+ const app_1 = require("@headless-adminapp/app/app");
9
+ const mutable_1 = require("@headless-adminapp/app/mutable");
9
10
  const react_1 = require("react");
10
11
  const command_1 = require("../../command");
11
12
  const hooks_1 = require("../../dialog/hooks");
12
- const useLocale_1 = require("../../locale/useLocale");
13
- const useMetadata_1 = require("../../metadata/hooks/useMetadata");
14
13
  const useProgressIndicator_1 = require("../../progress-indicator/hooks/useProgressIndicator");
15
14
  const useOpenToastNotification_1 = require("../../toast-notification/hooks/useOpenToastNotification");
16
- const transport_1 = require("../../transport");
15
+ const context_1 = require("../context");
17
16
  const useGridColumnFilter_1 = require("./useGridColumnFilter");
18
- const useGridCommands_1 = require("./useGridCommands");
17
+ const useGridColumns_1 = require("./useGridColumns");
19
18
  const useGridData_1 = require("./useGridData");
20
19
  const useGridExtraFilter_1 = require("./useGridExtraFilter");
21
20
  const useGridRefresh_1 = require("./useGridRefresh");
22
21
  const useGridSchema_1 = require("./useGridSchema");
23
22
  const useGridSelection_1 = require("./useGridSelection");
23
+ const useGridSorting_1 = require("./useGridSorting");
24
+ const useOpenRecord_1 = require("./useOpenRecord");
24
25
  const useSearchText_1 = require("./useSearchText");
25
26
  const useSelectedView_1 = require("./useSelectedView");
26
27
  function useUtility() {
@@ -49,6 +50,9 @@ function useGridControlContext() {
49
50
  const [columnFilter] = (0, useGridColumnFilter_1.useGridColumnFilter)();
50
51
  const extraFilter = (0, useGridExtraFilter_1.useGridExtraFilter)();
51
52
  const refresh = (0, useGridRefresh_1.useGridRefresh)();
53
+ const openRecord = (0, useOpenRecord_1.useOpenRecord)();
54
+ const gridColumns = (0, useGridColumns_1.useGridColumns)();
55
+ const [sorting] = (0, useGridSorting_1.useGridSorting)();
52
56
  const selectedIdsObj = (0, react_1.useMemo)(() => {
53
57
  const obj = {};
54
58
  selectedIds.forEach((id) => {
@@ -72,157 +76,30 @@ function useGridControlContext() {
72
76
  viewId: view.id,
73
77
  columnFilter,
74
78
  extraFilter,
79
+ openRecord,
80
+ gridColumns,
81
+ sorting,
75
82
  };
76
83
  }
77
84
  function useMainGridCommandHandlerContext() {
78
- const dataService = (0, transport_1.useDataService)();
79
- const queryClient = (0, react_query_1.useQueryClient)();
80
- const { appStore, experienceStore, schemaStore } = (0, useMetadata_1.useMetadata)();
81
- const utility = useUtility();
82
- const locale = (0, useLocale_1.useLocale)();
85
+ const baseHandlerContext = (0, command_1.useBaseCommandHandlerContext)();
83
86
  const primaryControl = useGridControlContext();
84
- return {
85
- dataService,
86
- queryClient,
87
- utility,
88
- primaryControl,
89
- stores: {
90
- appStore,
91
- experienceStore,
92
- schemaStore,
93
- },
94
- locale,
95
- };
87
+ return Object.assign(Object.assign({}, baseHandlerContext), { primaryControl });
88
+ }
89
+ const emptyCommands = [];
90
+ function useGridCommands() {
91
+ var _a;
92
+ const commands = (0, mutable_1.useContextSelector)(context_1.GridContext, (state) => state.commands);
93
+ const { app: { viewCommands: defaultCommands }, } = (0, app_1.useAppContext)();
94
+ return (_a = commands !== null && commands !== void 0 ? commands : defaultCommands) !== null && _a !== void 0 ? _a : emptyCommands;
96
95
  }
97
96
  function useMainGridCommands() {
98
- const commands = (0, useGridCommands_1.useGridCommands)();
97
+ const commands = useGridCommands();
99
98
  const handlerContext = useMainGridCommandHandlerContext();
100
- // console.log('temp. gc', commands);
101
99
  return (0, command_1.useCommands)(commands, handlerContext);
102
- // return [
103
- // [
104
- // {
105
- // type: 'button',
106
- // icon: 'Add',
107
- // text: 'Add',
108
- // },
109
- // {
110
- // type: 'button',
111
- // icon: 'Delete',
112
- // text: 'Delete',
113
- // danger: true,
114
- // },
115
- // {
116
- // type: 'button',
117
- // icon: 'Add',
118
- // text: 'Add',
119
- // },
120
- // {
121
- // type: 'button',
122
- // icon: 'Add',
123
- // text: 'Add',
124
- // },
125
- // ],
126
- // [
127
- // {
128
- // type: 'button',
129
- // icon: 'Add',
130
- // text: 'Add',
131
- // },
132
- // {
133
- // type: 'button',
134
- // icon: 'Add',
135
- // text: 'Add',
136
- // },
137
- // {
138
- // type: 'button',
139
- // icon: 'Add',
140
- // text: 'Add',
141
- // },
142
- // {
143
- // type: 'button',
144
- // icon: 'Add',
145
- // text: 'Add',
146
- // },
147
- // {
148
- // type: 'button',
149
- // icon: 'Add',
150
- // text: 'Add',
151
- // },
152
- // {
153
- // type: 'button',
154
- // icon: 'Add',
155
- // text: 'Add',
156
- // },
157
- // {
158
- // type: 'menu',
159
- // icon: 'Add',
160
- // text: 'Report',
161
- // danger: true,
162
- // handlerId: 'report',
163
- // items: [
164
- // {
165
- // icon: 'Add',
166
- // text: 'Export',
167
- // danger: true,
168
- // },
169
- // ],
170
- // },
171
- // {
172
- // type: 'menu',
173
- // icon: 'Add',
174
- // text: 'Report',
175
- // danger: true,
176
- // items: [
177
- // {
178
- // icon: 'Add',
179
- // text: 'Export',
180
- // danger: true,
181
- // },
182
- // ],
183
- // },
184
- // ],
185
- // [
186
- // {
187
- // type: 'button',
188
- // icon: 'Add',
189
- // text: 'Add',
190
- // },
191
- // {
192
- // type: 'button',
193
- // icon: 'Add',
194
- // text: 'Add',
195
- // },
196
- // {
197
- // type: 'button',
198
- // icon: 'Add',
199
- // text: 'Add',
200
- // },
201
- // {
202
- // type: 'button',
203
- // icon: 'Add',
204
- // text: 'Add',
205
- // },
206
- // {
207
- // type: 'button',
208
- // icon: 'Add',
209
- // text: 'Add',
210
- // },
211
- // {
212
- // type: 'button',
213
- // icon: 'Add',
214
- // text: 'Add',
215
- // },
216
- // {
217
- // type: 'button',
218
- // icon: 'Add',
219
- // text: 'Add',
220
- // },
221
- // ],
222
- // ];
223
100
  }
224
101
  function useMainGridContextCommands() {
225
- const commands = (0, useGridCommands_1.useGridCommands)();
102
+ const commands = useGridCommands();
226
103
  const handlerContext = useMainGridCommandHandlerContext();
227
104
  return (0, command_1.useCommands)(commands, handlerContext, (command) => { var _a; return (_a = ('isContextMenu' in command && command.isContextMenu)) !== null && _a !== void 0 ? _a : false; });
228
105
  }
@@ -0,0 +1 @@
1
+ export declare function useOpenRecord(): (id: string) => void;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useOpenRecord = useOpenRecord;
4
+ const recordset_1 = require("@headless-adminapp/app/recordset");
5
+ const route_1 = require("@headless-adminapp/app/route");
6
+ const app_1 = require("@headless-adminapp/core/experience/app");
7
+ const react_1 = require("react");
8
+ const useGridData_1 = require("./useGridData");
9
+ const useGridSchema_1 = require("./useGridSchema");
10
+ function useOpenRecord() {
11
+ const data = (0, useGridData_1.useGridData)();
12
+ const schema = (0, useGridSchema_1.useDataGridSchema)();
13
+ const routeResolver = (0, route_1.useRouteResolver)();
14
+ const router = (0, route_1.useRouter)();
15
+ const recordSetSetter = (0, recordset_1.useRecordSetSetter)();
16
+ const dataRef = (0, react_1.useRef)(data);
17
+ dataRef.current = data;
18
+ return (0, react_1.useCallback)((id) => {
19
+ var _a, _b;
20
+ const path = routeResolver({
21
+ logicalName: schema.logicalName,
22
+ type: app_1.PageType.EntityForm,
23
+ id,
24
+ });
25
+ recordSetSetter(schema.logicalName, (_b = (_a = dataRef.current) === null || _a === void 0 ? void 0 : _a.records.map((x) => x[schema.idAttribute])) !== null && _b !== void 0 ? _b : []);
26
+ router.push(path);
27
+ }, [
28
+ recordSetSetter,
29
+ routeResolver,
30
+ router,
31
+ schema.idAttribute,
32
+ schema.logicalName,
33
+ ]);
34
+ }
@@ -3,27 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSubGridCommandHandlerContext = useSubGridCommandHandlerContext;
4
4
  exports.useSubGridCommands = useSubGridCommands;
5
5
  exports.useSubGridContextCommands = useSubGridContextCommands;
6
- const react_query_1 = require("@tanstack/react-query");
6
+ const app_1 = require("@headless-adminapp/app/app");
7
+ const mutable_1 = require("@headless-adminapp/app/mutable");
7
8
  const react_1 = require("react");
8
9
  const command_1 = require("../../command");
9
10
  const useMainFormCommands_1 = require("../../dataform/hooks/useMainFormCommands");
10
- const useLocale_1 = require("../../locale/useLocale");
11
- const useMetadata_1 = require("../../metadata/hooks/useMetadata");
12
- const transport_1 = require("../../transport");
11
+ const context_1 = require("../context");
13
12
  const useGridColumnFilter_1 = require("./useGridColumnFilter");
14
- const useGridCommands_1 = require("./useGridCommands");
15
13
  const useGridData_1 = require("./useGridData");
16
14
  const useGridExtraFilter_1 = require("./useGridExtraFilter");
17
15
  const useGridRefresh_1 = require("./useGridRefresh");
18
16
  const useGridSchema_1 = require("./useGridSchema");
19
17
  const useGridSelection_1 = require("./useGridSelection");
20
- const useMainGridCommands_1 = require("./useMainGridCommands");
21
18
  const useSearchText_1 = require("./useSearchText");
22
19
  const useSelectedView_1 = require("./useSelectedView");
23
20
  function useSubGridCommandHandlerContext() {
24
- const dataService = (0, transport_1.useDataService)();
25
- const queryClient = (0, react_query_1.useQueryClient)();
26
- const { appStore, experienceStore, schemaStore } = (0, useMetadata_1.useMetadata)();
21
+ const baseHandlerContext = (0, command_1.useBaseCommandHandlerContext)();
27
22
  const data = (0, useGridData_1.useGridData)();
28
23
  const schema = (0, useGridSchema_1.useDataGridSchema)();
29
24
  const view = (0, useSelectedView_1.useSelectedView)();
@@ -43,16 +38,8 @@ function useSubGridCommandHandlerContext() {
43
38
  const [columnFilter] = (0, useGridColumnFilter_1.useGridColumnFilter)();
44
39
  const extraFilter = (0, useGridExtraFilter_1.useGridExtraFilter)();
45
40
  const refresh = (0, useGridRefresh_1.useGridRefresh)();
46
- const utility = (0, useMainGridCommands_1.useUtility)();
47
- const locale = (0, useLocale_1.useLocale)();
48
41
  const mainFormHandlerContext = (0, useMainFormCommands_1.useMainFormCommandHandlerContext)();
49
- // console.log('mainFormHandlerContext', mainFormHandlerContext);
50
- return {
51
- dataService,
52
- queryClient,
53
- utility,
54
- primaryControl: mainFormHandlerContext.primaryControl,
55
- secondaryControl: {
42
+ return Object.assign(Object.assign({}, baseHandlerContext), { primaryControl: mainFormHandlerContext.primaryControl, secondaryControl: {
56
43
  data,
57
44
  logicalName: schema.logicalName,
58
45
  schema,
@@ -64,24 +51,22 @@ function useSubGridCommandHandlerContext() {
64
51
  viewId: view.id,
65
52
  columnFilter,
66
53
  extraFilter,
67
- },
68
- stores: {
69
- appStore,
70
- experienceStore,
71
- schemaStore,
72
- },
73
- locale,
74
- };
54
+ } });
55
+ }
56
+ const emptyCommands = [];
57
+ function useGridCommands() {
58
+ var _a;
59
+ const commands = (0, mutable_1.useContextSelector)(context_1.GridContext, (state) => state.commands);
60
+ const { app: { subgridCommands: defaultCommands }, } = (0, app_1.useAppContext)();
61
+ return (_a = commands !== null && commands !== void 0 ? commands : defaultCommands) !== null && _a !== void 0 ? _a : emptyCommands;
75
62
  }
76
63
  function useSubGridCommands() {
77
- const commands = (0, useGridCommands_1.useGridCommands)();
64
+ const commands = useGridCommands();
78
65
  const handlerContext = useSubGridCommandHandlerContext();
79
- console.log('temp. commands (s)', commands);
80
- console.log('temp. handlerContext (s)', handlerContext);
81
66
  return (0, command_1.useCommands)(commands, handlerContext);
82
67
  }
83
68
  function useSubGridContextCommands() {
84
- const commands = (0, useGridCommands_1.useGridCommands)();
69
+ const commands = useGridCommands();
85
70
  const handlerContext = useSubGridCommandHandlerContext();
86
71
  return (0, command_1.useCommands)(commands, handlerContext, (command) => { var _a; return (_a = ('isContextMenu' in command && command.isContextMenu)) !== null && _a !== void 0 ? _a : false; });
87
72
  }
@@ -1 +1 @@
1
- export declare function useSystemColorScheme(): "light" | "dark";
1
+ export declare function useSystemColorScheme(): "dark" | "light";
@@ -8,7 +8,7 @@ const context_1 = require("./context");
8
8
  const LocaleProvider = ({ children, locale, options, }) => {
9
9
  const localeState = (0, react_1.useMemo)(() => {
10
10
  return (0, locale_1.getLocale)(locale, options);
11
- }, [locale]);
11
+ }, [locale, options]);
12
12
  return ((0, jsx_runtime_1.jsx)(context_1.LocaleContext.Provider, { value: localeState, children: children }));
13
13
  };
14
14
  exports.LocaleProvider = LocaleProvider;
@@ -0,0 +1,5 @@
1
+ import { Localized } from '@headless-adminapp/core/types';
2
+ export declare function localizedLabel<T extends {
3
+ label: string;
4
+ localizedLabels?: Localized<string>;
5
+ }>(language: string, value: T, fallback?: T): string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.localizedLabel = localizedLabel;
4
+ function localizedLabel(language, value, fallback) {
5
+ var _a, _b, _c, _d, _e;
6
+ return ((_e = (_d = (_b = (_a = value.localizedLabels) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : (_c = fallback === null || fallback === void 0 ? void 0 : fallback.localizedLabels) === null || _c === void 0 ? void 0 : _c[language]) !== null && _d !== void 0 ? _d : value.label) !== null && _e !== void 0 ? _e : fallback === null || fallback === void 0 ? void 0 : fallback.label);
7
+ }
@@ -10,15 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.useExperienceViewCommands = useExperienceViewCommands;
13
+ const app_1 = require("@headless-adminapp/app/app");
13
14
  const react_query_1 = require("@tanstack/react-query");
14
15
  const useExperienceStore_1 = require("./useExperienceStore");
15
16
  /** @todo move in different dir */
16
17
  function useExperienceViewCommands(logicalName) {
17
18
  const experienceStore = (0, useExperienceStore_1.useExperienceStore)();
19
+ const { app: { viewCommands }, } = (0, app_1.useAppContext)();
18
20
  const { data: commands } = (0, react_query_1.useQuery)({
19
21
  queryKey: ['experience-schema-view-commands', logicalName],
20
22
  queryFn: () => __awaiter(this, void 0, void 0, function* () {
21
- return experienceStore.getViewCommands(logicalName);
23
+ let commands = yield experienceStore.getViewCommands(logicalName);
24
+ if (!commands) {
25
+ commands = viewCommands;
26
+ }
27
+ return commands !== null && commands !== void 0 ? commands : [];
22
28
  }),
23
29
  initialData: [],
24
30
  });
@@ -10,15 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.useExperienceViewSubgridCommands = useExperienceViewSubgridCommands;
13
+ const app_1 = require("@headless-adminapp/app/app");
13
14
  const react_query_1 = require("@tanstack/react-query");
14
15
  const useExperienceStore_1 = require("./useExperienceStore");
15
16
  /** @todo move in different dir */
16
17
  function useExperienceViewSubgridCommands(logicalName) {
17
18
  const experienceStore = (0, useExperienceStore_1.useExperienceStore)();
19
+ const { app: { subgridCommands }, } = (0, app_1.useAppContext)();
18
20
  const { data: commands } = (0, react_query_1.useQuery)({
19
21
  queryKey: ['experience-schema-view-subgrid-commands', logicalName],
20
22
  queryFn: () => __awaiter(this, void 0, void 0, function* () {
21
- return experienceStore.getSubgridCommands(logicalName);
23
+ let commands = yield experienceStore.getSubgridCommands(logicalName);
24
+ if (!commands) {
25
+ commands = subgridCommands;
26
+ }
27
+ return commands !== null && commands !== void 0 ? commands : [];
22
28
  }),
23
29
  initialData: [],
24
30
  });
@@ -2,6 +2,7 @@ import { SchemaAttributes } from '@headless-adminapp/core/schema';
2
2
  export declare function useMetadata(): {
3
3
  schemas: Record<string, import("@headless-adminapp/core/schema").Schema<SchemaAttributes>>;
4
4
  schemaLoading: boolean;
5
+ /*** @deprecated */
5
6
  getSchema: <S extends SchemaAttributes = SchemaAttributes>(logicalName: string) => import("@headless-adminapp/core/schema").Schema<S>;
6
7
  schemaStore: import("@headless-adminapp/core/store").ISchemaStore<SchemaAttributes>;
7
8
  appStore: import("@headless-adminapp/core/store").IClientAppStore;
@@ -14,12 +14,14 @@ function useMetadata() {
14
14
  // );
15
15
  const schemaLoading = false;
16
16
  const schemas = schemaStore.getAllSchema();
17
+ /*** @deprecated */
17
18
  const getSchema = (0, react_1.useCallback)((logicalName) => {
18
19
  return schemaStore.getSchema(logicalName);
19
20
  }, [schemaStore]);
20
21
  return {
21
22
  schemas,
22
23
  schemaLoading,
24
+ /*** @deprecated */
23
25
  getSchema,
24
26
  schemaStore,
25
27
  appStore,
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSchema = useSchema;
4
4
  const useMetadata_1 = require("./useMetadata");
5
5
  function useSchema(logicalName) {
6
- const { getSchema } = (0, useMetadata_1.useMetadata)();
7
- return getSchema(logicalName);
6
+ const { schemaStore } = (0, useMetadata_1.useMetadata)();
7
+ return schemaStore.getSchema(logicalName);
8
8
  }
@@ -41,6 +41,6 @@ function useContextValueSetter(context, setter) {
41
41
  setterRef.current = setter;
42
42
  const setterWrapper = (0, react_1.useCallback)((...args) => {
43
43
  return setterRef.current(contextValue.setValue)(...args);
44
- }, []);
44
+ }, [contextValue.setValue]);
45
45
  return setterWrapper;
46
46
  }
@@ -0,0 +1 @@
1
+ export * from './useOpenForm';
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./useAppearanceContext"), exports);
17
+ __exportStar(require("./useOpenForm"), exports);