@headless-adminapp/app 0.0.17-alpha.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/app/AppProvider.d.ts +0 -3
  2. package/app/AppProvider.js +10 -33
  3. package/app/AuthWrapper.d.ts +1 -1
  4. package/app/AuthWrapper.js +4 -1
  5. package/app/LayoutProvider.d.ts +8 -7
  6. package/app/LayoutProvider.js +28 -2
  7. package/app/context.d.ts +1 -1
  8. package/auth/AuthProvider.d.ts +1 -1
  9. package/auth/AuthProvider.js +30 -23
  10. package/auth/context.d.ts +2 -0
  11. package/auth/hooks/useIsSkipAuthCheck.d.ts +1 -0
  12. package/auth/hooks/useIsSkipAuthCheck.js +8 -0
  13. package/auth/hooks/useLogout.js +1 -1
  14. package/board/BoardColumnDataResolver.d.ts +1 -0
  15. package/board/BoardColumnDataResolver.js +64 -0
  16. package/board/BoardColumnProvider.d.ts +7 -0
  17. package/board/BoardColumnProvider.js +36 -0
  18. package/board/context.d.ts +19 -0
  19. package/board/context.js +6 -0
  20. package/board/hooks/index.d.ts +6 -0
  21. package/board/hooks/index.js +15 -0
  22. package/board/hooks/useBoardColumnConfig.d.ts +2 -0
  23. package/board/hooks/useBoardColumnConfig.js +8 -0
  24. package/board/hooks/useBoardColumnData.d.ts +3 -0
  25. package/board/hooks/useBoardColumnData.js +9 -0
  26. package/board/hooks/useBoardColumnDataState.d.ts +5 -0
  27. package/board/hooks/useBoardColumnDataState.js +9 -0
  28. package/board/hooks/useBoardConfig.d.ts +3 -0
  29. package/board/hooks/useBoardConfig.js +8 -0
  30. package/board/hooks/useBoardSchema.d.ts +2 -0
  31. package/board/hooks/useBoardSchema.js +7 -0
  32. package/board/hooks/useSearchText.d.ts +1 -0
  33. package/board/hooks/useSearchText.js +14 -0
  34. package/board/types.d.ts +47 -0
  35. package/board/utils.d.ts +3 -0
  36. package/board/utils.js +6 -0
  37. package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +15 -6
  38. package/builders/CommandBuilder/DefaultCommandBuilder.js +42 -20
  39. package/builders/CommandBuilder/FormCommandBuilder.d.ts +14 -13
  40. package/builders/CommandBuilder/FormCommandBuilder.js +66 -52
  41. package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +8 -27
  42. package/builders/CommandBuilder/SubgridCommandBuilder.js +115 -57
  43. package/builders/CommandBuilder/ViewCommandBuilder.js +32 -52
  44. package/builders/CommandBuilder/utils.js +1 -1
  45. package/builders/DefineFormExperience.d.ts +27 -0
  46. package/builders/DefineFormExperience.js +99 -0
  47. package/builders/DefineViewExperience.d.ts +13 -0
  48. package/builders/DefineViewExperience.js +33 -0
  49. package/builders/SchemaExperienceBuilder.d.ts +9 -7
  50. package/builders/SchemaExperienceBuilder.js +62 -40
  51. package/builders/utils.js +30 -44
  52. package/calendar/baseEventAttributes.d.ts +35 -0
  53. package/calendar/baseEventAttributes.js +38 -0
  54. package/calendar/context.d.ts +6 -0
  55. package/calendar/context.js +5 -0
  56. package/calendar/hooks/index.d.ts +1 -0
  57. package/{appearance → calendar}/hooks/index.js +1 -1
  58. package/calendar/hooks/useConfig.d.ts +3 -0
  59. package/calendar/hooks/useConfig.js +8 -0
  60. package/calendar/types.d.ts +41 -0
  61. package/calendar/types.js +2 -0
  62. package/calendar/utils.d.ts +3 -0
  63. package/calendar/utils.js +6 -0
  64. package/command/hooks/useBaseCommandHandlerContext.js +15 -6
  65. package/command/hooks/useCommands.js +1 -1
  66. package/command/utils/index.js +34 -9
  67. package/components/ScrollView/index.d.ts +1 -1
  68. package/components/ScrollView/index.js +2 -2
  69. package/components/ScrollbarWithMoreDataRequest/index.d.ts +9 -0
  70. package/components/ScrollbarWithMoreDataRequest/index.js +32 -0
  71. package/dataform/DataFormProvider/CustomHookExecuter.d.ts +5 -0
  72. package/dataform/DataFormProvider/CustomHookExecuter.js +14 -0
  73. package/dataform/DataFormProvider/DataResolver.d.ts +6 -4
  74. package/dataform/DataFormProvider/DataResolver.js +11 -94
  75. package/dataform/DataFormProvider/InitialValueResolver.js +3 -2
  76. package/dataform/DataFormProvider/ReadonlyInfoResolver.js +2 -3
  77. package/dataform/DataFormProvider/getRecord.d.ts +3 -0
  78. package/dataform/DataFormProvider/getRecord.js +56 -0
  79. package/dataform/DataFormProvider/index.d.ts +4 -0
  80. package/dataform/DataFormProvider/index.js +34 -12
  81. package/dataform/DataFormProvider/types.d.ts +13 -0
  82. package/dataform/DataFormProvider/types.js +2 -0
  83. package/dataform/DataFormProvider/utils.d.ts +23 -0
  84. package/dataform/DataFormProvider/utils.js +105 -0
  85. package/dataform/FormManager.d.ts +57 -0
  86. package/dataform/FormManager.js +247 -0
  87. package/dataform/constants.d.ts +1 -0
  88. package/dataform/constants.js +4 -0
  89. package/dataform/context.d.ts +26 -1
  90. package/dataform/hooks/index.d.ts +11 -0
  91. package/dataform/hooks/index.js +11 -0
  92. package/dataform/hooks/useContextKey.d.ts +1 -0
  93. package/dataform/hooks/useContextKey.js +8 -0
  94. package/dataform/hooks/useDisabledControlsManager.d.ts +6 -0
  95. package/dataform/hooks/useDisabledControlsManager.js +46 -0
  96. package/dataform/hooks/useEventManager.d.ts +1 -0
  97. package/dataform/hooks/useEventManager.js +8 -0
  98. package/dataform/hooks/useFormManager.d.ts +2 -0
  99. package/dataform/hooks/useFormManager.js +13 -0
  100. package/dataform/hooks/useFormNotifications.js +2 -2
  101. package/dataform/hooks/useFormSave.js +28 -31
  102. package/dataform/hooks/useHiddenControlsManager.d.ts +7 -0
  103. package/dataform/hooks/useHiddenControlsManager.js +50 -0
  104. package/dataform/hooks/useIsControlDisabled.d.ts +1 -0
  105. package/dataform/hooks/useIsControlDisabled.js +27 -0
  106. package/dataform/hooks/useIsControlHiddenByAttributeName.d.ts +1 -0
  107. package/dataform/hooks/useIsControlHiddenByAttributeName.js +17 -0
  108. package/dataform/hooks/useIsControlHiddenByKey.d.ts +1 -0
  109. package/dataform/hooks/useIsControlHiddenByKey.js +17 -0
  110. package/dataform/hooks/useIsFieldRequired.d.ts +1 -0
  111. package/dataform/hooks/useIsFieldRequired.js +25 -0
  112. package/dataform/hooks/useLoadFormGridPage.js +8 -17
  113. package/dataform/hooks/useMainFormCommands.d.ts +1 -12
  114. package/dataform/hooks/useMainFormCommands.js +13 -3
  115. package/dataform/hooks/useOnFieldValueChangeListener.d.ts +1 -0
  116. package/dataform/hooks/useOnFieldValueChangeListener.js +30 -0
  117. package/dataform/hooks/useProcessFlowSteps.d.ts +1 -0
  118. package/dataform/hooks/useProcessFlowSteps.js +45 -0
  119. package/dataform/hooks/useRecordTitle.d.ts +3 -1
  120. package/dataform/hooks/useRecordTitle.js +12 -5
  121. package/dataform/hooks/useRequiredFieldManager.d.ts +6 -0
  122. package/dataform/hooks/useRequiredFieldManager.js +49 -0
  123. package/dataform/test.d.ts +57 -0
  124. package/dataform/test.js +247 -0
  125. package/dataform/utils/defaultParameters.d.ts +6 -0
  126. package/dataform/utils/defaultParameters.js +54 -0
  127. package/dataform/utils/index.d.ts +6 -24
  128. package/dataform/utils/index.js +164 -190
  129. package/dataform/utils/saveRecord.d.ts +27 -0
  130. package/dataform/utils/saveRecord.js +163 -0
  131. package/datagrid/DataGridProvider/DataResolver.js +38 -109
  132. package/datagrid/DataGridProvider/index.d.ts +6 -0
  133. package/datagrid/DataGridProvider/index.js +18 -8
  134. package/datagrid/DataGridProvider/transformViewColumns.js +10 -2
  135. package/datagrid/DataGridProvider/utils.js +8 -8
  136. package/datagrid/column-filter/constants.js +38 -3
  137. package/datagrid/column-filter/utils.js +7 -1
  138. package/datagrid/context.d.ts +6 -0
  139. package/datagrid/hooks/useChangeView.js +1 -1
  140. package/datagrid/hooks/useGridColumnFilter.js +4 -1
  141. package/datagrid/hooks/useGridDisabled.d.ts +1 -0
  142. package/datagrid/hooks/useGridDisabled.js +8 -0
  143. package/datagrid/hooks/useLoadMainGridPage.js +1 -1
  144. package/datagrid/hooks/useMainGridCommands.js +23 -9
  145. package/datagrid/hooks/useOpenRecord.js +2 -2
  146. package/datagrid/hooks/useSubGridCommands.js +23 -45
  147. package/defaults.d.ts +2 -0
  148. package/defaults.js +5 -0
  149. package/dialog/hooks/useCloseDialog.js +17 -15
  150. package/dialog/hooks/useOpenAlertDialog.js +8 -3
  151. package/dialog/hooks/useOpenConfirmDialog.js +10 -4
  152. package/dialog/hooks/useOpenDialog.js +7 -5
  153. package/dialog/hooks/useOpenErrorDialog.js +8 -3
  154. package/dialog/hooks/useOpenPromptDialog.js +10 -4
  155. package/form/FormValidationStringContext.d.ts +1 -0
  156. package/form/FormValidationStringContext.js +1 -0
  157. package/hooks/index.d.ts +1 -0
  158. package/hooks/index.js +3 -0
  159. package/hooks/useDebouncedValue.js +0 -1
  160. package/hooks/useElementLayout.js +1 -1
  161. package/hooks/useIsMobile.js +0 -1
  162. package/hooks/useItemsWithKey.d.ts +7 -0
  163. package/hooks/useItemsWithKey.js +13 -0
  164. package/hooks/useStorageState.js +1 -2
  165. package/hooks/useSystemColorScheme.d.ts +1 -1
  166. package/hooks/useSystemColorScheme.js +0 -1
  167. package/insights/InsightsProvider.d.ts +8 -0
  168. package/insights/InsightsProvider.js +27 -0
  169. package/locale/LocaleProvider.d.ts +2 -1
  170. package/locale/LocaleProvider.js +3 -3
  171. package/locale/index.d.ts +1 -0
  172. package/locale/index.js +1 -0
  173. package/locale/useCurrencySymbol.d.ts +1 -0
  174. package/locale/useCurrencySymbol.js +12 -0
  175. package/locale/utils.js +4 -2
  176. package/metadata/MetadataProvider.d.ts +8 -4
  177. package/metadata/MetadataProvider.js +23 -17
  178. package/metadata/context.d.ts +3 -2
  179. package/metadata/hooks/index.d.ts +1 -1
  180. package/metadata/hooks/index.js +1 -1
  181. package/metadata/hooks/useAppExperience.d.ts +1 -0
  182. package/metadata/hooks/useAppExperience.js +8 -0
  183. package/metadata/hooks/useAppStore.d.ts +1 -1
  184. package/metadata/hooks/useAppStore.js +3 -3
  185. package/metadata/hooks/useExperienceView.js +2 -11
  186. package/metadata/hooks/useExperienceViewCommands.d.ts +1 -1
  187. package/metadata/hooks/useExperienceViewCommands.js +5 -14
  188. package/metadata/hooks/useExperienceViewLookup.js +2 -11
  189. package/metadata/hooks/useExperienceViewSubgridCommands.d.ts +1 -1
  190. package/metadata/hooks/useExperienceViewSubgridCommands.js +5 -14
  191. package/metadata/hooks/useMetadata.d.ts +11 -10
  192. package/metadata/hooks/useMetadata.js +4 -16
  193. package/metadata/hooks/useSchema.d.ts +1 -1
  194. package/metadata/hooks/useSchema.js +3 -0
  195. package/mutable/context.d.ts +3 -0
  196. package/mutable/context.js +8 -0
  197. package/mutable/utils.js +5 -12
  198. package/navigation/hooks/useOpenForm.js +4 -0
  199. package/package.json +6 -10
  200. package/providers/PageEntityFormProvider/index.d.ts +5 -1
  201. package/providers/PageEntityFormProvider/index.js +2 -2
  202. package/recordset/hooks/useRecordSetResult.js +4 -14
  203. package/route/RouteProvider.d.ts +2 -2
  204. package/route/RouteProvider.js +4 -1
  205. package/store/ClientAppStore.js +7 -20
  206. package/store/ComponentStore.d.ts +1 -1
  207. package/store/ComponentStore.js +6 -12
  208. package/store/EventManager.d.ts +2 -2
  209. package/store/EventManager.js +13 -29
  210. package/store/SchemaExperienceStore.js +179 -215
  211. package/store/index.d.ts +0 -1
  212. package/store/index.js +0 -1
  213. package/toast-notification/hooks/useCloseToastNotification.js +17 -15
  214. package/toast-notification/hooks/useOpenToastNotification.js +7 -5
  215. package/transport/InMemoryDataService/index.js +54 -77
  216. package/transport/RestDataService/index.d.ts +3 -3
  217. package/transport/RestDataService/index.js +68 -91
  218. package/transport/context.d.ts +2 -1
  219. package/transport/context.js +7 -1
  220. package/transport/hooks/index.d.ts +1 -0
  221. package/transport/hooks/index.js +1 -0
  222. package/transport/hooks/useFileService.d.ts +1 -0
  223. package/transport/hooks/useFileService.js +9 -0
  224. package/transport/hooks/useRetriveRecords.d.ts +33 -0
  225. package/transport/hooks/useRetriveRecords.js +110 -0
  226. package/utils/calculateColumnWidths.js +1 -1
  227. package/utils/color.d.ts +1 -0
  228. package/utils/color.js +14 -0
  229. package/utils/getAttributeFormattedValue.d.ts +4 -1
  230. package/utils/getAttributeFormattedValue.js +109 -54
  231. package/utils/phone.d.ts +13 -0
  232. package/utils/phone.js +33 -0
  233. package/appearance/context.d.ts +0 -7
  234. package/appearance/context.js +0 -5
  235. package/appearance/hooks/index.d.ts +0 -1
  236. package/appearance/hooks/useAppearanceContext.d.ts +0 -1
  237. package/appearance/hooks/useAppearanceContext.js +0 -12
  238. package/appearance/index.d.ts +0 -2
  239. package/appearance/index.js +0 -20
  240. package/builders/CommandBuilder.d.ts +0 -176
  241. package/builders/CommandBuilder.js +0 -567
  242. package/locale/types.d.ts +0 -2
  243. /package/{locale → board}/types.js +0 -0
@@ -1,155 +1,84 @@
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
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.DataResolver = DataResolver;
13
- const react_query_1 = require("@tanstack/react-query");
14
4
  const react_1 = require("react");
15
5
  const useDebouncedValue_1 = require("../../hooks/useDebouncedValue");
16
6
  const useMetadata_1 = require("../../metadata/hooks/useMetadata");
17
7
  const context_1 = require("../../mutable/context");
18
- const transport_1 = require("../../transport");
8
+ const useRetriveRecords_1 = require("../../transport/hooks/useRetriveRecords");
19
9
  const context_2 = require("../context");
20
10
  const hooks_1 = require("../hooks");
11
+ const useGridDisabled_1 = require("../hooks/useGridDisabled");
21
12
  const utils_1 = require("./utils");
22
- const ROWS_PER_PAGE = 100;
23
13
  const MAX_RECORDS = 10000;
24
14
  function DataResolver() {
25
- var _a;
26
15
  const schema = (0, hooks_1.useDataGridSchema)();
27
16
  const view = (0, hooks_1.useSelectedView)();
28
- const dataService = (0, transport_1.useDataService)();
29
17
  const [sorting] = (0, hooks_1.useGridSorting)();
30
18
  const [searchText] = (0, hooks_1.useSearchText)();
31
19
  const extraFilter = (0, hooks_1.useGridExtraFilter)();
32
20
  const [columnFilters] = (0, hooks_1.useGridColumnFilter)();
33
21
  const gridColumns = (0, hooks_1.useGridColumns)();
34
- const maxRecords = (_a = (0, hooks_1.useMaxRecords)()) !== null && _a !== void 0 ? _a : MAX_RECORDS;
22
+ const maxRecords = (0, hooks_1.useMaxRecords)() ?? MAX_RECORDS;
23
+ const [selectedIds] = (0, hooks_1.useGridSelection)();
24
+ const disabled = (0, useGridDisabled_1.useGridDisabled)();
35
25
  const { schemaStore } = (0, useMetadata_1.useMetadata)();
26
+ const selectedIdsRef = (0, react_1.useRef)(selectedIds);
27
+ selectedIdsRef.current = selectedIds;
36
28
  const setState = (0, context_1.useContextSetValue)(context_2.GridContext);
37
29
  const [search] = (0, useDebouncedValue_1.useDebouncedValue)(searchText, 500);
38
- const columns = (0, react_1.useMemo)(() => Array.from(new Set([
39
- ...gridColumns.filter((x) => !x.expandedKey).map((x) => x.name),
40
- schema.primaryAttribute,
41
- ])), [gridColumns, schema.primaryAttribute]);
30
+ const columns = (0, react_1.useMemo)(() => {
31
+ const set = new Set([
32
+ ...gridColumns.filter((x) => !x.expandedKey).map((x) => x.name),
33
+ schema.primaryAttribute,
34
+ ]);
35
+ if (schema.avatarAttribute) {
36
+ set.add(schema.avatarAttribute);
37
+ }
38
+ return Array.from(set);
39
+ }, [gridColumns, schema.avatarAttribute, schema.primaryAttribute]);
42
40
  const expand = (0, react_1.useMemo)(() => (0, utils_1.collectExpandedKeys)(gridColumns), [gridColumns]);
43
- const queryKey = (0, react_1.useMemo)(() => [
44
- 'data',
45
- 'retriveRecords',
46
- schema.logicalName,
47
- search,
48
- view.experience.filter,
49
- extraFilter,
50
- sorting,
51
- columnFilters,
41
+ const filter = (0, react_1.useMemo)(() => {
42
+ return (0, utils_1.mergeConditions)(schema, view.experience.filter, extraFilter, columnFilters, schemaStore);
43
+ }, [columnFilters, extraFilter, schema, schemaStore, view.experience.filter]);
44
+ const queryKey = (0, useRetriveRecords_1.useRetrieveRecordsKey)({
52
45
  columns,
53
46
  expand,
47
+ filter,
54
48
  maxRecords,
55
- ], [
56
- columnFilters,
49
+ schema,
50
+ search,
51
+ sorting,
52
+ });
53
+ (0, useRetriveRecords_1.useClearDataExceptFirstPage)(queryKey);
54
+ const { fetchNextPage, data, hasNextPage, isFetching, isFetchingNextPage } = (0, useRetriveRecords_1.useRetriveRecords)(queryKey, {
57
55
  columns,
58
56
  expand,
59
- extraFilter,
60
- schema.logicalName,
57
+ filter,
58
+ maxRecords,
59
+ schema,
61
60
  search,
62
61
  sorting,
63
- view.experience.filter,
64
- maxRecords,
65
- ]);
66
- const queryClient = (0, react_query_1.useQueryClient)();
67
- (0, react_1.useEffect)(() => {
68
- return () => {
69
- // Clear all pages except the first one when the component is unmounted
70
- queryClient.setQueryData(queryKey, (oldData) => {
71
- if (!oldData) {
72
- return oldData;
73
- }
74
- if (!oldData.pageParams.length || !oldData.pages.length) {
75
- return oldData;
76
- }
77
- return {
78
- pageParams: [oldData.pageParams[0]],
79
- pages: [oldData.pages[0]],
80
- };
81
- });
82
- };
83
- }, [queryClient, queryKey]);
84
- const { data, isFetching, hasNextPage, fetchNextPage, isFetchingNextPage } = (0, react_query_1.useInfiniteQuery)({
85
- queryKey: queryKey,
86
- queryFn: (queryContext) => __awaiter(this, void 0, void 0, function* () {
87
- var _a;
88
- const params = (_a = queryContext.pageParam) !== null && _a !== void 0 ? _a : {
89
- pageIndex: 0,
90
- };
91
- const skip = params.pageIndex * ROWS_PER_PAGE;
92
- const limit = Math.min(ROWS_PER_PAGE, Math.max(0, maxRecords - skip));
93
- if (limit <= 0) {
94
- return {
95
- params: params,
96
- data: {
97
- logicalName: schema.logicalName,
98
- count: 0,
99
- records: [],
100
- },
101
- };
102
- }
103
- const result = yield dataService.retriveRecords({
104
- logicalName: schema.logicalName,
105
- search,
106
- columns: columns,
107
- expand,
108
- filter: (0, utils_1.mergeConditions)(schema, view.experience.filter, extraFilter, columnFilters, schemaStore),
109
- skip,
110
- limit,
111
- sort: sorting,
112
- });
113
- return {
114
- params: params,
115
- data: result,
116
- };
117
- }),
118
- getNextPageParam: (lastPage) => {
119
- if (lastPage.data.count <
120
- ROWS_PER_PAGE * (lastPage.params.pageIndex + 1)) {
121
- return undefined;
122
- }
123
- return {
124
- pageIndex: lastPage.params.pageIndex + 1,
125
- };
126
- },
127
- initialPageParam: {
128
- pageIndex: 0,
129
- },
62
+ disabled,
130
63
  });
131
64
  (0, react_1.useEffect)(() => {
132
65
  setState({
133
- fetchNextPage: fetchNextPage,
66
+ fetchNextPage: () => fetchNextPage,
134
67
  });
135
68
  }, [fetchNextPage, setState]);
136
69
  (0, react_1.useEffect)(() => {
137
- var _a, _b, _c, _d;
138
- if (!(data === null || data === void 0 ? void 0 : data.pages.length)) {
70
+ if (!data) {
139
71
  setState({
140
72
  data: null,
141
73
  });
142
74
  return;
143
75
  }
144
- const finalData = {
145
- logicalName: (_a = data === null || data === void 0 ? void 0 : data.pages) === null || _a === void 0 ? void 0 : _a[0].data.logicalName,
146
- count: (_c = (_b = data === null || data === void 0 ? void 0 : data.pages) === null || _b === void 0 ? void 0 : _b[0].data.count) !== null && _c !== void 0 ? _c : 0,
147
- records: (_d = data === null || data === void 0 ? void 0 : data.pages.map((x) => x.data.records).flat()) !== null && _d !== void 0 ? _d : [],
148
- };
76
+ const selectedIds = selectedIdsRef.current.filter((x) => data.records.some((y) => y[schema.idAttribute] === x));
149
77
  setState({
150
- data: finalData,
78
+ data,
79
+ selectedIds,
151
80
  });
152
- }, [data, setState]);
81
+ }, [data, setState, schema.idAttribute]);
153
82
  (0, react_1.useEffect)(() => {
154
83
  setState({
155
84
  dataState: {
@@ -12,7 +12,13 @@ export interface DataGridProviderProps<S extends SchemaAttributes = SchemaAttrib
12
12
  commands: CommandItemExperience<CommandContext>[][];
13
13
  onChangeView?: (viewId: string) => void;
14
14
  isSubGrid?: boolean;
15
+ associated?: false | {
16
+ logicalName: string;
17
+ id: string;
18
+ refAttributeName: string;
19
+ };
15
20
  allowViewSelection?: boolean;
16
21
  maxRecords?: number;
22
+ disabled?: boolean;
17
23
  }
18
24
  export declare function DataGridProvider<S extends SchemaAttributes = SchemaAttributes, CommandContext extends EntityMainGridCommandContext | EntitySubGridCommandContext = EntityMainGridCommandContext>(props: PropsWithChildren<DataGridProviderProps<S, CommandContext>>): import("react/jsx-runtime").JSX.Element;
@@ -10,14 +10,12 @@ const context_2 = require("../context");
10
10
  const DataResolver_1 = require("./DataResolver");
11
11
  const transformViewColumns_1 = require("./transformViewColumns");
12
12
  function DataGridProvider(props) {
13
- var _a, _b, _c;
14
13
  const onChangeViewRef = (0, react_1.useRef)(props.onChangeView);
15
14
  onChangeViewRef.current = props.onChangeView;
16
15
  const { schemaStore } = (0, useMetadata_1.useMetadata)();
17
16
  const { language } = (0, useLocale_1.useLocale)();
18
17
  const handleViewChange = (0, react_1.useCallback)((viewId) => {
19
- var _a;
20
- (_a = onChangeViewRef.current) === null || _a === void 0 ? void 0 : _a.call(onChangeViewRef, viewId);
18
+ onChangeViewRef.current?.(viewId);
21
19
  }, []);
22
20
  const contextValue = (0, context_1.useCreateContextStore)({
23
21
  schema: props.schema,
@@ -29,7 +27,7 @@ function DataGridProvider(props) {
29
27
  },
30
28
  searchText: '',
31
29
  selectedIds: [],
32
- sorting: (_a = props.view.experience.defaultSorting) !== null && _a !== void 0 ? _a : [],
30
+ sorting: props.view.experience.defaultSorting ?? [],
33
31
  view: props.view,
34
32
  commands: props.commands,
35
33
  columns: (0, transformViewColumns_1.transformViewColumns)(props.view.logicalName, props.view.experience.grid.columns, schemaStore, language),
@@ -42,17 +40,18 @@ function DataGridProvider(props) {
42
40
  },
43
41
  fetchNextPage: () => { },
44
42
  onChangeView: handleViewChange,
45
- isSubGrid: (_b = props.isSubGrid) !== null && _b !== void 0 ? _b : false,
46
- allowViewSelection: (_c = props.allowViewSelection) !== null && _c !== void 0 ? _c : false,
43
+ isSubGrid: props.isSubGrid ?? false,
44
+ allowViewSelection: props.allowViewSelection ?? false,
47
45
  maxRecords: props.maxRecords,
46
+ associated: props.associated,
47
+ disabled: props.disabled ?? false,
48
48
  });
49
49
  (0, react_1.useEffect)(() => {
50
- var _a;
51
50
  contextValue.setValue({
52
51
  view: props.view,
53
52
  searchText: '',
54
53
  selectedIds: [],
55
- sorting: (_a = props.view.experience.defaultSorting) !== null && _a !== void 0 ? _a : [],
54
+ sorting: props.view.experience.defaultSorting ?? [],
56
55
  columns: (0, transformViewColumns_1.transformViewColumns)(props.view.logicalName, props.view.experience.grid.columns, schemaStore, language),
57
56
  maxRecords: props.maxRecords,
58
57
  });
@@ -74,5 +73,16 @@ function DataGridProvider(props) {
74
73
  commands: props.commands,
75
74
  });
76
75
  }, [props.commands, contextValue]);
76
+ (0, react_1.useEffect)(() => {
77
+ contextValue.setValue({
78
+ isSubGrid: props.isSubGrid ?? false,
79
+ associated: props.associated,
80
+ });
81
+ }, [props.isSubGrid, props.associated, contextValue]);
82
+ (0, react_1.useEffect)(() => {
83
+ contextValue.setValue({
84
+ disabled: props.disabled ?? false,
85
+ });
86
+ }, [props.disabled, contextValue]);
77
87
  return ((0, jsx_runtime_1.jsxs)(context_2.GridContext.Provider, { value: contextValue, children: [(0, jsx_runtime_1.jsx)(DataResolver_1.DataResolver, {}), props.children] }));
78
88
  }
@@ -21,9 +21,17 @@ function transformViewColumns(logicalName, columns, schemaStore, language) {
21
21
  return null;
22
22
  }
23
23
  const lookupLabel = (0, utils_1.localizedLabel)(language, lookupAttribute);
24
- return Object.assign(Object.assign({}, column), { id: `${column.name}.${column.expandedKey}`, label: `${lookupLabel} (${label})` });
24
+ return {
25
+ ...column,
26
+ id: `${column.name}.${column.expandedKey}`,
27
+ label: `${lookupLabel} (${label})`,
28
+ };
25
29
  }
26
- return Object.assign(Object.assign({}, column), { id: column.name, label: label });
30
+ return {
31
+ ...column,
32
+ id: column.name,
33
+ label: label,
34
+ };
27
35
  })
28
36
  .filter(Boolean);
29
37
  }
@@ -75,17 +75,17 @@ function transformColumnFilter(filter, schema, schemaStore) {
75
75
  return transformedResult;
76
76
  }
77
77
  function mergeConditions(schema, filter, extraFilter, columnFilters, schemaStore) {
78
- const conditions = [];
78
+ const filters = [];
79
79
  if (filter) {
80
- conditions.push(filter);
80
+ filters.push(filter);
81
81
  }
82
82
  if (extraFilter) {
83
- conditions.push(extraFilter);
83
+ filters.push(extraFilter);
84
84
  }
85
85
  if (columnFilters) {
86
86
  const transformedColumnFilters = transformColumnFilter(columnFilters, schema, schemaStore);
87
87
  if (transformedColumnFilters) {
88
- conditions.push({
88
+ filters.push({
89
89
  type: 'and',
90
90
  conditions: Object.entries(transformedColumnFilters).map(([field, condition]) => {
91
91
  return {
@@ -98,15 +98,15 @@ function mergeConditions(schema, filter, extraFilter, columnFilters, schemaStore
98
98
  });
99
99
  }
100
100
  }
101
- if (conditions.length === 0) {
101
+ if (filters.length === 0) {
102
102
  return null;
103
103
  }
104
- if (conditions.length === 1) {
105
- return conditions[0];
104
+ if (filters.length === 1) {
105
+ return filters[0];
106
106
  }
107
107
  return {
108
108
  type: 'and',
109
- conditions,
109
+ filters: filters,
110
110
  };
111
111
  }
112
112
  function collectExpandedKeys(columns) {
@@ -463,8 +463,42 @@ const booleanOperatorOptions = [
463
463
  controls: [],
464
464
  },
465
465
  ];
466
- const idOperatorOptions = [];
467
- const attachmentOperatorOptions = [];
466
+ const idOperatorOptions = [
467
+ {
468
+ value: 'not-null',
469
+ labelKey: 'containsData',
470
+ controls: [],
471
+ },
472
+ {
473
+ value: 'null',
474
+ labelKey: 'doesNotContainData',
475
+ controls: [],
476
+ },
477
+ ];
478
+ const attachmentOperatorOptions = [
479
+ {
480
+ value: 'not-null',
481
+ labelKey: 'containsData',
482
+ controls: [],
483
+ },
484
+ {
485
+ value: 'null',
486
+ labelKey: 'doesNotContainData',
487
+ controls: [],
488
+ },
489
+ ];
490
+ const mixedOperatorOptions = [
491
+ {
492
+ value: 'not-null',
493
+ labelKey: 'containsData',
494
+ controls: [],
495
+ },
496
+ {
497
+ value: 'null',
498
+ labelKey: 'doesNotContainData',
499
+ controls: [],
500
+ },
501
+ ];
468
502
  exports.operatorOptions = {
469
503
  id: idOperatorOptions,
470
504
  boolean: booleanOperatorOptions,
@@ -476,7 +510,8 @@ exports.operatorOptions = {
476
510
  number: numberOperatorOptions,
477
511
  string: stringOperatorOptions,
478
512
  attachment: attachmentOperatorOptions,
479
- mixed: [],
513
+ attachments: [],
514
+ mixed: mixedOperatorOptions,
480
515
  daterange: [],
481
516
  lookups: [],
482
517
  };
@@ -3,6 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLocalizedOperatorOptions = void 0;
4
4
  const constants_1 = require("./constants");
5
5
  const getLocalizedOperatorOptions = (strings) => {
6
- return Object.entries(constants_1.operatorOptions).reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [key]: value.map((option) => (Object.assign(Object.assign({}, option), { label: strings[option.labelKey] }))) })), {});
6
+ return Object.entries(constants_1.operatorOptions).reduce((acc, [key, value]) => ({
7
+ ...acc,
8
+ [key]: value.map((option) => ({
9
+ ...option,
10
+ label: strings[option.labelKey],
11
+ })),
12
+ }), {});
7
13
  };
8
14
  exports.getLocalizedOperatorOptions = getLocalizedOperatorOptions;
@@ -13,6 +13,12 @@ export interface GridContextState<S extends SchemaAttributes = SchemaAttributes,
13
13
  extraFilter?: Filter;
14
14
  commands?: CommandItemExperience<CommandContext>[][];
15
15
  maxRecords?: number;
16
+ disabled?: boolean;
17
+ associated?: false | {
18
+ logicalName: string;
19
+ id: string;
20
+ refAttributeName: string;
21
+ };
16
22
  columns: TransformedViewColumn<S>[];
17
23
  searchText: string;
18
24
  columnFilters: Partial<Record<keyof S, ColumnCondition>>;
@@ -7,6 +7,6 @@ const context_2 = require("../context");
7
7
  function useChangeView() {
8
8
  const onChangeView = (0, context_1.useContextSelector)(context_2.GridContext, (state) => state.onChangeView);
9
9
  return (0, react_1.useCallback)((viewId) => {
10
- onChangeView === null || onChangeView === void 0 ? void 0 : onChangeView(viewId);
10
+ onChangeView?.(viewId);
11
11
  }, [onChangeView]);
12
12
  }
@@ -9,7 +9,10 @@ function useGridColumnFilter() {
9
9
  const setValue = (0, context_1.useContextSetValue)(context_2.GridContext);
10
10
  const setColumnFilter = (0, react_1.useCallback)((columnName, value) => {
11
11
  setValue((state) => ({
12
- columnFilters: Object.assign(Object.assign({}, state.columnFilters), { [columnName]: value }),
12
+ columnFilters: {
13
+ ...state.columnFilters,
14
+ [columnName]: value,
15
+ },
13
16
  }));
14
17
  }, [setValue]);
15
18
  return [columnFilters, setColumnFilter];
@@ -0,0 +1 @@
1
+ export declare function useGridDisabled(): boolean | undefined;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGridDisabled = useGridDisabled;
4
+ const mutable_1 = require("../../mutable");
5
+ const context_1 = require("../context");
6
+ function useGridDisabled() {
7
+ return (0, mutable_1.useContextSelector)(context_1.GridContext, (state) => state.disabled);
8
+ }
@@ -15,7 +15,7 @@ function useLoadMainGridPage(logicalName, viewId) {
15
15
  loading: false,
16
16
  error: true,
17
17
  title: 'Schema not found',
18
- message: 'The schema was not found',
18
+ message: `The schema "${logicalName}" was not found`,
19
19
  };
20
20
  }
21
21
  if (!view) {
@@ -61,10 +61,9 @@ function useGridControlContext() {
61
61
  return obj;
62
62
  }, [selectedIds]);
63
63
  const selectedRecords = (0, react_1.useMemo)(() => {
64
- var _a;
65
- return ((_a = data === null || data === void 0 ? void 0 : data.records) !== null && _a !== void 0 ? _a : []).filter((record) => selectedIdsObj[record[schema.idAttribute]]);
64
+ return (data?.records ?? []).filter((record) => selectedIdsObj[record[schema.idAttribute]]);
66
65
  }, [data, schema, selectedIdsObj]);
67
- return {
66
+ return (0, react_1.useMemo)(() => ({
68
67
  data,
69
68
  logicalName: schema.logicalName,
70
69
  schema,
@@ -79,19 +78,34 @@ function useGridControlContext() {
79
78
  openRecord,
80
79
  gridColumns,
81
80
  sorting,
82
- };
81
+ }), [
82
+ columnFilter,
83
+ data,
84
+ extraFilter,
85
+ gridColumns,
86
+ openRecord,
87
+ refresh,
88
+ schema,
89
+ searchText,
90
+ selectedIds,
91
+ selectedRecords,
92
+ sorting,
93
+ view,
94
+ ]);
83
95
  }
84
96
  function useMainGridCommandHandlerContext() {
85
97
  const baseHandlerContext = (0, command_1.useBaseCommandHandlerContext)();
86
98
  const primaryControl = useGridControlContext();
87
- return Object.assign(Object.assign({}, baseHandlerContext), { primaryControl });
99
+ return (0, react_1.useMemo)(() => ({
100
+ ...baseHandlerContext,
101
+ primaryControl,
102
+ }), [baseHandlerContext, primaryControl]);
88
103
  }
89
104
  const emptyCommands = [];
90
105
  function useGridCommands() {
91
- var _a;
92
106
  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;
107
+ const { appExperience: { viewCommands: defaultCommands }, } = (0, app_1.useAppContext)();
108
+ return commands ?? defaultCommands ?? emptyCommands;
95
109
  }
96
110
  function useMainGridCommands() {
97
111
  const commands = useGridCommands();
@@ -101,5 +115,5 @@ function useMainGridCommands() {
101
115
  function useMainGridContextCommands() {
102
116
  const commands = useGridCommands();
103
117
  const handlerContext = useMainGridCommandHandlerContext();
104
- return (0, command_1.useCommands)(commands, handlerContext, (command) => { var _a; return (_a = ('isContextMenu' in command && command.isContextMenu)) !== null && _a !== void 0 ? _a : false; });
118
+ return (0, command_1.useCommands)(commands, handlerContext, (command) => ('isContextMenu' in command && command.isContextMenu) ?? false);
105
119
  }
@@ -16,13 +16,13 @@ function useOpenRecord() {
16
16
  const dataRef = (0, react_1.useRef)(data);
17
17
  dataRef.current = data;
18
18
  return (0, react_1.useCallback)((id) => {
19
- var _a, _b;
20
19
  const path = routeResolver({
21
20
  logicalName: schema.logicalName,
22
21
  type: app_1.PageType.EntityForm,
23
22
  id,
24
23
  });
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 : []);
24
+ recordSetSetter(schema.logicalName, dataRef.current?.records.map((x) => x[schema.idAttribute]) ??
25
+ []);
26
26
  router.push(path);
27
27
  }, [
28
28
  recordSetSetter,
@@ -4,61 +4,39 @@ exports.useSubGridCommandHandlerContext = useSubGridCommandHandlerContext;
4
4
  exports.useSubGridCommands = useSubGridCommands;
5
5
  exports.useSubGridContextCommands = useSubGridContextCommands;
6
6
  const app_1 = require("@headless-adminapp/app/app");
7
+ const dataform_1 = require("@headless-adminapp/app/dataform");
7
8
  const mutable_1 = require("@headless-adminapp/app/mutable");
8
- const react_1 = require("react");
9
9
  const command_1 = require("../../command");
10
10
  const useMainFormCommands_1 = require("../../dataform/hooks/useMainFormCommands");
11
11
  const context_1 = require("../context");
12
- const useGridColumnFilter_1 = require("./useGridColumnFilter");
13
- const useGridData_1 = require("./useGridData");
14
- const useGridExtraFilter_1 = require("./useGridExtraFilter");
15
- const useGridRefresh_1 = require("./useGridRefresh");
16
- const useGridSchema_1 = require("./useGridSchema");
17
- const useGridSelection_1 = require("./useGridSelection");
18
- const useSearchText_1 = require("./useSearchText");
19
- const useSelectedView_1 = require("./useSelectedView");
12
+ const useMainGridCommands_1 = require("./useMainGridCommands");
20
13
  function useSubGridCommandHandlerContext() {
21
14
  const baseHandlerContext = (0, command_1.useBaseCommandHandlerContext)();
22
- const data = (0, useGridData_1.useGridData)();
23
- const schema = (0, useGridSchema_1.useDataGridSchema)();
24
- const view = (0, useSelectedView_1.useSelectedView)();
25
- const [searchText] = (0, useSearchText_1.useSearchText)();
26
- const [selectedIds] = (0, useGridSelection_1.useGridSelection)();
27
- const selectedIdsObj = (0, react_1.useMemo)(() => {
28
- const obj = {};
29
- selectedIds.forEach((id) => {
30
- obj[id] = true;
31
- });
32
- return obj;
33
- }, [selectedIds]);
34
- const selectedRecords = (0, react_1.useMemo)(() => {
35
- var _a;
36
- return ((_a = data === null || data === void 0 ? void 0 : data.records) !== null && _a !== void 0 ? _a : []).filter((record) => selectedIdsObj[record[schema.idAttribute]]);
37
- }, [data, schema, selectedIdsObj]);
38
- const [columnFilter] = (0, useGridColumnFilter_1.useGridColumnFilter)();
39
- const extraFilter = (0, useGridExtraFilter_1.useGridExtraFilter)();
40
- const refresh = (0, useGridRefresh_1.useGridRefresh)();
41
15
  const mainFormHandlerContext = (0, useMainFormCommands_1.useMainFormCommandHandlerContext)();
42
- return Object.assign(Object.assign({}, baseHandlerContext), { primaryControl: mainFormHandlerContext.primaryControl, secondaryControl: {
43
- data,
44
- logicalName: schema.logicalName,
45
- schema,
46
- refresh,
47
- searchText,
48
- selectedIds,
49
- selectedRecords,
50
- view,
51
- viewId: view.id,
52
- columnFilter,
53
- extraFilter,
54
- } });
16
+ const gridControl = (0, useMainGridCommands_1.useGridControlContext)();
17
+ const associated = (0, mutable_1.useContextSelector)(context_1.GridContext, (state) => state.associated);
18
+ const [recordTitle] = (0, dataform_1.useRecordTitle)();
19
+ return {
20
+ ...baseHandlerContext,
21
+ primaryControl: mainFormHandlerContext.primaryControl,
22
+ secondaryControl: {
23
+ ...gridControl,
24
+ associated: !associated
25
+ ? false
26
+ : {
27
+ id: associated.id,
28
+ logicalName: associated.logicalName,
29
+ name: recordTitle,
30
+ refAttributeName: associated.refAttributeName,
31
+ },
32
+ },
33
+ };
55
34
  }
56
35
  const emptyCommands = [];
57
36
  function useGridCommands() {
58
- var _a;
59
37
  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;
38
+ const { appExperience: { subgridCommands: defaultCommands }, } = (0, app_1.useAppContext)();
39
+ return commands ?? defaultCommands ?? emptyCommands;
62
40
  }
63
41
  function useSubGridCommands() {
64
42
  const commands = useGridCommands();
@@ -68,5 +46,5 @@ function useSubGridCommands() {
68
46
  function useSubGridContextCommands() {
69
47
  const commands = useGridCommands();
70
48
  const handlerContext = useSubGridCommandHandlerContext();
71
- return (0, command_1.useCommands)(commands, handlerContext, (command) => { var _a; return (_a = ('isContextMenu' in command && command.isContextMenu)) !== null && _a !== void 0 ? _a : false; });
49
+ return (0, command_1.useCommands)(commands, handlerContext, (command) => ('isContextMenu' in command && command.isContextMenu) ?? false);
72
50
  }
package/defaults.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ export declare const queryClient: QueryClient;
package/defaults.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.queryClient = void 0;
4
+ const react_query_1 = require("@tanstack/react-query");
5
+ exports.queryClient = new react_query_1.QueryClient();