@headless-adminapp/app 0.0.17-alpha.54 → 0.0.17-alpha.55

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 (220) hide show
  1. package/app/AppProvider.js +24 -32
  2. package/app/AuthWrapper.js +13 -9
  3. package/app/LayoutProvider.js +34 -39
  4. package/app/context.js +5 -2
  5. package/app/hooks/index.js +17 -1
  6. package/app/hooks/useAppContext.js +7 -4
  7. package/app/index.js +11 -4
  8. package/auth/AuthProvider.js +27 -36
  9. package/auth/context.d.ts +1 -1
  10. package/auth/context.js +5 -2
  11. package/auth/hooks/index.js +18 -2
  12. package/auth/hooks/useAuthSession.js +7 -4
  13. package/auth/hooks/useIsSkipAuthCheck.js +7 -4
  14. package/auth/hooks/useLogout.js +11 -8
  15. package/auth/index.js +23 -4
  16. package/auth/types.js +2 -1
  17. package/board/BoardColumnDataResolver.js +23 -20
  18. package/board/BoardColumnProvider.js +14 -10
  19. package/board/context.d.ts +2 -2
  20. package/board/context.js +6 -3
  21. package/board/hooks/index.js +15 -6
  22. package/board/hooks/useBoardColumnConfig.js +7 -4
  23. package/board/hooks/useBoardColumnData.d.ts +3 -1
  24. package/board/hooks/useBoardColumnData.js +7 -4
  25. package/board/hooks/useBoardColumnDataState.js +7 -4
  26. package/board/hooks/useBoardConfig.js +7 -4
  27. package/board/hooks/useBoardSchema.js +6 -3
  28. package/board/hooks/useSearchText.js +10 -7
  29. package/board/types.js +2 -1
  30. package/board/utils.js +4 -1
  31. package/builders/CommandBuilder/CommandBuilder.js +13 -10
  32. package/builders/CommandBuilder/DefaultCommandBuilder.js +30 -23
  33. package/builders/CommandBuilder/FormCommandBuilder.js +29 -38
  34. package/builders/CommandBuilder/SubgridCommandBuilder.js +27 -36
  35. package/builders/CommandBuilder/ViewCommandBuilder.js +29 -38
  36. package/builders/CommandBuilder/index.js +5 -1
  37. package/builders/CommandBuilder/utils.js +7 -3
  38. package/builders/SchemaExperienceBuilder.js +55 -31
  39. package/builders/index.js +7 -2
  40. package/builders/utils.js +59 -44
  41. package/command/hooks/index.js +18 -2
  42. package/command/hooks/useBaseCommandHandlerContext.js +29 -25
  43. package/command/hooks/useCommands.js +9 -6
  44. package/command/index.js +18 -2
  45. package/command/types.js +2 -1
  46. package/command/utils/index.js +41 -13
  47. package/components/ScrollView/index.js +11 -4
  48. package/components/ScrollbarWithMoreDataRequest/index.js +14 -11
  49. package/dataform/DataFormProvider/DataResolver.js +81 -89
  50. package/dataform/DataFormProvider/InitialValueResolver.js +22 -20
  51. package/dataform/DataFormProvider/ReadonlyInfoResolver.js +14 -12
  52. package/dataform/DataFormProvider/index.js +26 -32
  53. package/dataform/context.js +5 -2
  54. package/dataform/hooks/index.js +29 -13
  55. package/dataform/hooks/useFormInstance.js +6 -3
  56. package/dataform/hooks/useFormIsDirty.js +6 -3
  57. package/dataform/hooks/useFormIsReadonly.js +7 -4
  58. package/dataform/hooks/useFormNotifications.js +12 -9
  59. package/dataform/hooks/useFormRecord.js +7 -4
  60. package/dataform/hooks/useFormSave.js +40 -46
  61. package/dataform/hooks/useFormSchema.js +7 -4
  62. package/dataform/hooks/useLoadFormGridPage.js +19 -25
  63. package/dataform/hooks/useMainFormCommands.js +37 -30
  64. package/dataform/hooks/useProcessFlowSteps.js +27 -23
  65. package/dataform/hooks/useRecordId.js +7 -4
  66. package/dataform/hooks/useRecordTitle.js +12 -9
  67. package/dataform/hooks/useSelectedForm.js +7 -4
  68. package/dataform/index.js +23 -4
  69. package/dataform/utils/defaultParameters.js +16 -6
  70. package/dataform/utils/index.js +90 -56
  71. package/dataform/utils/saveRecord.js +99 -104
  72. package/datagrid/DataGridProvider/DataResolver.js +36 -34
  73. package/datagrid/DataGridProvider/index.js +31 -32
  74. package/datagrid/DataGridProvider/transformViewColumns.js +17 -6
  75. package/datagrid/DataGridProvider/utils.js +13 -5
  76. package/datagrid/column-filter/constants.js +5 -2
  77. package/datagrid/column-filter/index.js +7 -2
  78. package/datagrid/column-filter/types.js +2 -1
  79. package/datagrid/column-filter/utils.js +13 -3
  80. package/datagrid/context.d.ts +1 -1
  81. package/datagrid/context.js +5 -2
  82. package/datagrid/hooks/index.js +36 -20
  83. package/datagrid/hooks/useChangeView.js +10 -7
  84. package/datagrid/hooks/useGridColumnFilter.js +14 -8
  85. package/datagrid/hooks/useGridColumns.js +7 -4
  86. package/datagrid/hooks/useGridCommands.js +7 -4
  87. package/datagrid/hooks/useGridData.js +7 -4
  88. package/datagrid/hooks/useGridDataState.js +7 -4
  89. package/datagrid/hooks/useGridExtraFilter.js +7 -4
  90. package/datagrid/hooks/useGridOptions.js +4 -1
  91. package/datagrid/hooks/useGridPagination.js +4 -1
  92. package/datagrid/hooks/useGridRefresh.js +10 -7
  93. package/datagrid/hooks/useGridSchema.js +7 -4
  94. package/datagrid/hooks/useGridSelection.js +10 -7
  95. package/datagrid/hooks/useGridSorting.js +10 -7
  96. package/datagrid/hooks/useGridViewLookupData.js +7 -4
  97. package/datagrid/hooks/useLoadMainGridPage.js +12 -9
  98. package/datagrid/hooks/useMainGridCommands.js +62 -54
  99. package/datagrid/hooks/useMaxRecords.js +7 -4
  100. package/datagrid/hooks/useOpenRecord.js +20 -17
  101. package/datagrid/hooks/useSearchText.js +10 -7
  102. package/datagrid/hooks/useSelectedView.js +7 -4
  103. package/datagrid/hooks/useSubGridCommands.js +34 -23
  104. package/datagrid/index.js +27 -5
  105. package/defaults.js +5 -2
  106. package/dialog/DialogProvider.js +10 -6
  107. package/dialog/context.d.ts +1 -1
  108. package/dialog/context.js +5 -2
  109. package/dialog/hooks/index.js +24 -8
  110. package/dialog/hooks/useCloseDialog.js +10 -7
  111. package/dialog/hooks/useDialogItem.d.ts +1 -1
  112. package/dialog/hooks/useDialogItem.js +7 -4
  113. package/dialog/hooks/useDialogItems.d.ts +1 -1
  114. package/dialog/hooks/useDialogItems.js +7 -4
  115. package/dialog/hooks/useOpenAlertDialog.js +16 -8
  116. package/dialog/hooks/useOpenConfirmDialog.js +18 -9
  117. package/dialog/hooks/useOpenDialog.js +18 -11
  118. package/dialog/hooks/useOpenErrorDialog.js +16 -8
  119. package/dialog/hooks/useOpenPromptDialog.js +18 -9
  120. package/dialog/index.js +22 -3
  121. package/form/FormValidationStringContext.js +9 -5
  122. package/form/index.js +7 -1
  123. package/hooks/index.js +24 -6
  124. package/hooks/useDebouncedValue.js +11 -8
  125. package/hooks/useElementLayout.js +7 -4
  126. package/hooks/useIsMobile.js +12 -6
  127. package/hooks/useItemsWithKey.js +8 -5
  128. package/hooks/useStorageState.js +7 -5
  129. package/hooks/useSystemColorScheme.js +7 -4
  130. package/insights/InsightsProvider.js +13 -10
  131. package/insights/context.d.ts +1 -1
  132. package/insights/context.js +5 -2
  133. package/insights/hooks/index.js +7 -4
  134. package/insights/index.js +20 -2
  135. package/locale/LocaleProvider.js +12 -8
  136. package/locale/context.js +5 -2
  137. package/locale/index.js +23 -4
  138. package/locale/useCurrencySymbol.js +10 -8
  139. package/locale/useLocale.js +7 -4
  140. package/locale/utils.js +8 -3
  141. package/metadata/MetadataProvider.js +21 -17
  142. package/metadata/context.d.ts +1 -1
  143. package/metadata/context.js +5 -2
  144. package/metadata/hooks/index.js +24 -8
  145. package/metadata/hooks/useAppStore.js +7 -4
  146. package/metadata/hooks/useExperienceStore.js +7 -4
  147. package/metadata/hooks/useExperienceView.js +11 -17
  148. package/metadata/hooks/useExperienceViewCommands.js +14 -20
  149. package/metadata/hooks/useExperienceViewLookup.js +10 -16
  150. package/metadata/hooks/useExperienceViewSubgridCommands.js +14 -20
  151. package/metadata/hooks/useMetadata.js +11 -8
  152. package/metadata/hooks/useSchema.js +6 -3
  153. package/metadata/index.js +22 -3
  154. package/mutable/context.js +25 -17
  155. package/mutable/index.js +27 -3
  156. package/mutable/state.js +10 -6
  157. package/mutable/type.js +2 -1
  158. package/mutable/utils.js +12 -8
  159. package/navigation/hooks/index.js +17 -1
  160. package/navigation/hooks/useOpenForm.js +14 -11
  161. package/navigation/index.js +17 -1
  162. package/package.json +4 -12
  163. package/progress-indicator/ProgressIndicatorProvider.js +16 -12
  164. package/progress-indicator/context.js +5 -2
  165. package/progress-indicator/hooks/index.js +17 -1
  166. package/progress-indicator/hooks/useProgressIndicator.d.ts +1 -1
  167. package/progress-indicator/hooks/useProgressIndicator.js +7 -4
  168. package/progress-indicator/index.js +22 -3
  169. package/providers/PageEntityFormProvider/index.js +7 -4
  170. package/providers/PageEntityViewProvider/index.js +7 -4
  171. package/recordset/RecordSetProvider.js +16 -12
  172. package/recordset/context.d.ts +1 -1
  173. package/recordset/context.js +5 -2
  174. package/recordset/hooks/index.js +19 -3
  175. package/recordset/hooks/useRecordSetResult.js +22 -29
  176. package/recordset/hooks/useRecordSetSetter.js +9 -6
  177. package/recordset/hooks/useRecordSetVisibility.js +10 -7
  178. package/recordset/index.js +22 -3
  179. package/route/RouteProvider.js +18 -14
  180. package/route/context.js +9 -6
  181. package/route/hooks/index.js +22 -6
  182. package/route/hooks/useBasePath.js +7 -4
  183. package/route/hooks/useIsRouteActive.js +7 -4
  184. package/route/hooks/usePathname.js +7 -4
  185. package/route/hooks/useRouteResolver.js +7 -4
  186. package/route/hooks/useRouter.js +7 -4
  187. package/route/hooks/useSearchParams.js +7 -4
  188. package/route/index.js +20 -2
  189. package/route/types.js +2 -1
  190. package/store/ClientAppStore.js +12 -21
  191. package/store/ComponentStore.js +6 -4
  192. package/store/EventManager.js +20 -32
  193. package/store/SchemaExperienceStore.js +186 -217
  194. package/store/index.js +20 -4
  195. package/toast-notification/ToastNotificationProvider.js +10 -6
  196. package/toast-notification/context.d.ts +1 -1
  197. package/toast-notification/context.js +5 -2
  198. package/toast-notification/hooks/index.js +19 -3
  199. package/toast-notification/hooks/useCloseToastNotification.js +10 -7
  200. package/toast-notification/hooks/useOpenToastNotification.js +18 -11
  201. package/toast-notification/hooks/useToastNotificationItems.d.ts +1 -1
  202. package/toast-notification/hooks/useToastNotificationItems.js +7 -4
  203. package/toast-notification/index.js +22 -3
  204. package/transport/InMemoryDataService/index.js +59 -78
  205. package/transport/RestDataService/index.d.ts +2 -2
  206. package/transport/RestDataService/index.js +72 -91
  207. package/transport/context.js +9 -15
  208. package/transport/hooks/index.js +18 -2
  209. package/transport/hooks/useDataService.js +7 -4
  210. package/transport/hooks/useFileService.js +7 -4
  211. package/transport/hooks/useRetriveRecords.d.ts +1 -1
  212. package/transport/hooks/useRetriveRecords.js +25 -31
  213. package/transport/index.js +20 -2
  214. package/utils/calculateColumnWidths.js +5 -2
  215. package/utils/color.js +4 -1
  216. package/utils/getAttributeFormattedValue.js +38 -40
  217. package/utils/index.js +18 -2
  218. package/widget/context.js +5 -2
  219. package/widget/hooks/index.js +7 -4
  220. package/widget/index.js +5 -1
@@ -1,30 +1,21 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { exportRecordsCSV, exportRecordsXLS, retriveRecords } from '../utils';
11
- import { createLocalizedSelector } from './utils';
12
- import { ViewCommandBuilder } from './ViewCommandBuilder';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubgridCommandBuilder = void 0;
4
+ const utils_1 = require("../utils");
5
+ const utils_2 = require("./utils");
6
+ const ViewCommandBuilder_1 = require("./ViewCommandBuilder");
13
7
  var EnabledRules;
14
8
  (function (EnabledRules) {
15
9
  function HasCreatePermisssion(context) {
16
- var _a;
17
- return !((_a = context.secondaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableCreate);
10
+ return !context.secondaryControl.schema.restrictions?.disableCreate;
18
11
  }
19
12
  EnabledRules.HasCreatePermisssion = HasCreatePermisssion;
20
13
  function HasUpdatePermission(context) {
21
- var _a;
22
- return !((_a = context.secondaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableUpdate);
14
+ return !context.secondaryControl.schema.restrictions?.disableUpdate;
23
15
  }
24
16
  EnabledRules.HasUpdatePermission = HasUpdatePermission;
25
17
  function HasDeletePermission(context) {
26
- var _a;
27
- return !((_a = context.secondaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableDelete);
18
+ return !context.secondaryControl.schema.restrictions?.disableDelete;
28
19
  }
29
20
  EnabledRules.HasDeletePermission = HasDeletePermission;
30
21
  function HasSingleRecordSelected(context) {
@@ -36,7 +27,7 @@ var EnabledRules;
36
27
  }
37
28
  EnabledRules.HasAtLeastOneRecordSelected = HasAtLeastOneRecordSelected;
38
29
  })(EnabledRules || (EnabledRules = {}));
39
- export var SubgridCommandBuilder;
30
+ var SubgridCommandBuilder;
40
31
  (function (SubgridCommandBuilder) {
41
32
  function createNewRecordCommand({ Icon, text, localizedTexts, }) {
42
33
  return {
@@ -86,11 +77,11 @@ export var SubgridCommandBuilder;
86
77
  plural = singular[1];
87
78
  singular = singular[0];
88
79
  }
89
- let msg = count === 1 ? singular : plural !== null && plural !== void 0 ? plural : singular;
80
+ let msg = count === 1 ? singular : plural ?? singular;
90
81
  msg = msg.replace('{count}', count.toString());
91
82
  return msg;
92
83
  }
93
- function createDeleteRecordCommand({ Icon, localizedText, text, stringSet = ViewCommandBuilder.defaultDeleteRecordStringSet, localizedStringSet, }) {
84
+ function createDeleteRecordCommand({ Icon, localizedText, text, stringSet = ViewCommandBuilder_1.ViewCommandBuilder.defaultDeleteRecordStringSet, localizedStringSet, }) {
94
85
  return {
95
86
  type: 'button',
96
87
  Icon,
@@ -98,25 +89,25 @@ export var SubgridCommandBuilder;
98
89
  localizedText,
99
90
  danger: true,
100
91
  isContextMenu: true,
101
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
92
+ onClick: async (context) => {
102
93
  const recordIds = context.secondaryControl.selectedIds;
103
94
  if (!recordIds.length) {
104
95
  return;
105
96
  }
106
- const localizeSelector = createLocalizedSelector(stringSet, localizedStringSet, context.locale.language);
97
+ const localizeSelector = (0, utils_2.createLocalizedSelector)(stringSet, localizedStringSet, context.locale.language);
107
98
  try {
108
- const confirmResult = yield context.utility.openConfirmDialog({
99
+ const confirmResult = await context.utility.openConfirmDialog({
109
100
  title: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.title)),
110
101
  text: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.text)),
111
102
  cancelButtonLabel: localizeSelector((s) => s.confirmation.buttonCancel),
112
103
  confirmButtonLabel: localizeSelector((s) => s.confirmation.buttonConfirm),
113
104
  });
114
- if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
105
+ if (!confirmResult?.confirmed) {
115
106
  return;
116
107
  }
117
108
  context.utility.showProgressIndicator(plurialize(recordIds.length, localizeSelector((s) => s.status.deleting)) + '...');
118
109
  for (const recordId of recordIds) {
119
- yield context.dataService.deleteRecord(context.secondaryControl.logicalName, recordId);
110
+ await context.dataService.deleteRecord(context.secondaryControl.logicalName, recordId);
120
111
  }
121
112
  context.utility.showNotification({
122
113
  title: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.title)),
@@ -135,7 +126,7 @@ export var SubgridCommandBuilder;
135
126
  finally {
136
127
  context.utility.hideProgressIndicator();
137
128
  }
138
- }),
129
+ },
139
130
  hidden: [
140
131
  (context) => !EnabledRules.HasAtLeastOneRecordSelected(context),
141
132
  (context) => !EnabledRules.HasDeletePermission(context),
@@ -167,10 +158,10 @@ export var SubgridCommandBuilder;
167
158
  Icon: excel.Icon,
168
159
  text: excel.text,
169
160
  localizedTexts: excel.localizedTexts,
170
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
161
+ onClick: async (context) => {
171
162
  context.utility.showProgressIndicator('Exporting to Excel...');
172
163
  try {
173
- const result = yield retriveRecords({
164
+ const result = await (0, utils_1.retriveRecords)({
174
165
  columnFilters: context.secondaryControl.columnFilter,
175
166
  dataService: context.dataService,
176
167
  gridColumns: context.secondaryControl.gridColumns,
@@ -183,7 +174,7 @@ export var SubgridCommandBuilder;
183
174
  skip: 0,
184
175
  limit: 5000,
185
176
  });
186
- yield exportRecordsXLS({
177
+ await (0, utils_1.exportRecordsXLS)({
187
178
  fileName: context.secondaryControl.view.name + '.xlsx',
188
179
  gridColumns: context.secondaryControl.gridColumns,
189
180
  records: result.records,
@@ -194,16 +185,16 @@ export var SubgridCommandBuilder;
194
185
  finally {
195
186
  context.utility.hideProgressIndicator();
196
187
  }
197
- }),
188
+ },
198
189
  },
199
190
  {
200
191
  Icon: csv.Icon,
201
192
  text: csv.text,
202
193
  localizedTexts: csv.localizedTexts,
203
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
194
+ onClick: async (context) => {
204
195
  context.utility.showProgressIndicator('Exporting to CSV...');
205
196
  try {
206
- const result = yield retriveRecords({
197
+ const result = await (0, utils_1.retriveRecords)({
207
198
  columnFilters: context.secondaryControl.columnFilter,
208
199
  dataService: context.dataService,
209
200
  gridColumns: context.secondaryControl.gridColumns,
@@ -216,7 +207,7 @@ export var SubgridCommandBuilder;
216
207
  skip: 0,
217
208
  limit: 5000,
218
209
  });
219
- yield exportRecordsCSV({
210
+ await (0, utils_1.exportRecordsCSV)({
220
211
  fileName: context.secondaryControl.view.name + '.csv',
221
212
  gridColumns: context.secondaryControl.gridColumns,
222
213
  records: result.records,
@@ -227,11 +218,11 @@ export var SubgridCommandBuilder;
227
218
  finally {
228
219
  context.utility.hideProgressIndicator();
229
220
  }
230
- }),
221
+ },
231
222
  },
232
223
  ],
233
224
  ],
234
225
  };
235
226
  }
236
227
  SubgridCommandBuilder.createExportCommand = createExportCommand;
237
- })(SubgridCommandBuilder || (SubgridCommandBuilder = {}));
228
+ })(SubgridCommandBuilder || (exports.SubgridCommandBuilder = SubgridCommandBuilder = {}));
@@ -1,29 +1,20 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { exportRecordsCSV, exportRecordsXLS, retriveRecords } from '../utils';
11
- import { createLocalizedSelector, plurialize } from './utils';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ViewCommandBuilder = void 0;
4
+ const utils_1 = require("../utils");
5
+ const utils_2 = require("./utils");
12
6
  var EnabledRules;
13
7
  (function (EnabledRules) {
14
8
  function HasCreatePermisssion(context) {
15
- var _a;
16
- return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableCreate);
9
+ return !context.primaryControl.schema.restrictions?.disableCreate;
17
10
  }
18
11
  EnabledRules.HasCreatePermisssion = HasCreatePermisssion;
19
12
  function HasUpdatePermission(context) {
20
- var _a;
21
- return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableUpdate);
13
+ return !context.primaryControl.schema.restrictions?.disableUpdate;
22
14
  }
23
15
  EnabledRules.HasUpdatePermission = HasUpdatePermission;
24
16
  function HasDeletePermission(context) {
25
- var _a;
26
- return !((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableDelete);
17
+ return !context.primaryControl.schema.restrictions?.disableDelete;
27
18
  }
28
19
  EnabledRules.HasDeletePermission = HasDeletePermission;
29
20
  function HasSingleRecordSelected(context) {
@@ -35,7 +26,7 @@ var EnabledRules;
35
26
  }
36
27
  EnabledRules.HasAtLeastOneRecordSelected = HasAtLeastOneRecordSelected;
37
28
  })(EnabledRules || (EnabledRules = {}));
38
- export var ViewCommandBuilder;
29
+ var ViewCommandBuilder;
39
30
  (function (ViewCommandBuilder) {
40
31
  function createNewRecordCommand({ Icon, text, localizedTexts, }) {
41
32
  return {
@@ -100,29 +91,29 @@ export var ViewCommandBuilder;
100
91
  localizedText,
101
92
  danger: true,
102
93
  isContextMenu: true,
103
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
94
+ onClick: async (context) => {
104
95
  const recordIds = context.primaryControl.selectedIds;
105
96
  if (!recordIds.length) {
106
97
  return;
107
98
  }
108
- const localizeSelector = createLocalizedSelector(stringSet, localizedStringSet, context.locale.language);
99
+ const localizeSelector = (0, utils_2.createLocalizedSelector)(stringSet, localizedStringSet, context.locale.language);
109
100
  try {
110
- const confirmResult = yield context.utility.openConfirmDialog({
111
- title: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.title)),
112
- text: plurialize(recordIds.length, localizeSelector((s) => s.confirmation.text)),
101
+ const confirmResult = await context.utility.openConfirmDialog({
102
+ title: (0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.confirmation.title)),
103
+ text: (0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.confirmation.text)),
113
104
  cancelButtonLabel: localizeSelector((s) => s.confirmation.buttonCancel),
114
105
  confirmButtonLabel: localizeSelector((s) => s.confirmation.buttonConfirm),
115
106
  });
116
- if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
107
+ if (!confirmResult?.confirmed) {
117
108
  return;
118
109
  }
119
- context.utility.showProgressIndicator(plurialize(recordIds.length, localizeSelector((s) => s.status.deleting)) + '...');
110
+ context.utility.showProgressIndicator((0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.status.deleting)) + '...');
120
111
  for (const recordId of recordIds) {
121
- yield context.dataService.deleteRecord(context.primaryControl.logicalName, recordId);
112
+ await context.dataService.deleteRecord(context.primaryControl.logicalName, recordId);
122
113
  }
123
114
  context.utility.showNotification({
124
- title: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.title)),
125
- text: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.text)),
115
+ title: (0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.successNotification.title)),
116
+ text: (0, utils_2.plurialize)(recordIds.length, localizeSelector((s) => s.successNotification.text)),
126
117
  type: 'success',
127
118
  });
128
119
  context.primaryControl.refresh();
@@ -137,7 +128,7 @@ export var ViewCommandBuilder;
137
128
  finally {
138
129
  context.utility.hideProgressIndicator();
139
130
  }
140
- }),
131
+ },
141
132
  hidden: [
142
133
  (context) => !EnabledRules.HasAtLeastOneRecordSelected(context),
143
134
  (context) => !EnabledRules.HasDeletePermission(context),
@@ -169,10 +160,10 @@ export var ViewCommandBuilder;
169
160
  Icon: excel.Icon,
170
161
  text: excel.text,
171
162
  localizedTexts: excel.localizedTexts,
172
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
163
+ onClick: async (context) => {
173
164
  context.utility.showProgressIndicator('Exporting to Excel...');
174
165
  try {
175
- const result = yield retriveRecords({
166
+ const result = await (0, utils_1.retriveRecords)({
176
167
  columnFilters: context.primaryControl.columnFilter,
177
168
  dataService: context.dataService,
178
169
  gridColumns: context.primaryControl.gridColumns,
@@ -185,7 +176,7 @@ export var ViewCommandBuilder;
185
176
  skip: 0,
186
177
  limit: 5000,
187
178
  });
188
- yield exportRecordsXLS({
179
+ await (0, utils_1.exportRecordsXLS)({
189
180
  fileName: context.primaryControl.view.name + '.xlsx',
190
181
  gridColumns: context.primaryControl.gridColumns,
191
182
  records: result.records,
@@ -196,16 +187,16 @@ export var ViewCommandBuilder;
196
187
  finally {
197
188
  context.utility.hideProgressIndicator();
198
189
  }
199
- }),
190
+ },
200
191
  },
201
192
  {
202
193
  Icon: csv.Icon,
203
194
  text: csv.text,
204
195
  localizedTexts: csv.localizedTexts,
205
- onClick: (context) => __awaiter(this, void 0, void 0, function* () {
196
+ onClick: async (context) => {
206
197
  context.utility.showProgressIndicator('Exporting to CSV...');
207
198
  try {
208
- const result = yield retriveRecords({
199
+ const result = await (0, utils_1.retriveRecords)({
209
200
  columnFilters: context.primaryControl.columnFilter,
210
201
  dataService: context.dataService,
211
202
  gridColumns: context.primaryControl.gridColumns,
@@ -218,7 +209,7 @@ export var ViewCommandBuilder;
218
209
  skip: 0,
219
210
  limit: 5000,
220
211
  });
221
- yield exportRecordsCSV({
212
+ await (0, utils_1.exportRecordsCSV)({
222
213
  fileName: context.primaryControl.view.name + '.csv',
223
214
  gridColumns: context.primaryControl.gridColumns,
224
215
  records: result.records,
@@ -229,11 +220,11 @@ export var ViewCommandBuilder;
229
220
  finally {
230
221
  context.utility.hideProgressIndicator();
231
222
  }
232
- }),
223
+ },
233
224
  },
234
225
  ],
235
226
  ],
236
227
  };
237
228
  }
238
229
  ViewCommandBuilder.createExportCommand = createExportCommand;
239
- })(ViewCommandBuilder || (ViewCommandBuilder = {}));
230
+ })(ViewCommandBuilder || (exports.ViewCommandBuilder = ViewCommandBuilder = {}));
@@ -1 +1,5 @@
1
- export { CommandBuilder } from './CommandBuilder';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandBuilder = void 0;
4
+ var CommandBuilder_1 = require("./CommandBuilder");
5
+ Object.defineProperty(exports, "CommandBuilder", { enumerable: true, get: function () { return CommandBuilder_1.CommandBuilder; } });
@@ -1,4 +1,8 @@
1
- export function createLocalizedSelector(stringSet, localizedStringSet, language) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLocalizedSelector = createLocalizedSelector;
4
+ exports.plurialize = plurialize;
5
+ function createLocalizedSelector(stringSet, localizedStringSet, language) {
2
6
  return function selectLocalized(selector) {
3
7
  if (localizedStringSet && localizedStringSet[language]) {
4
8
  return selector(localizedStringSet[language]);
@@ -6,12 +10,12 @@ export function createLocalizedSelector(stringSet, localizedStringSet, language)
6
10
  return selector(stringSet);
7
11
  };
8
12
  }
9
- export function plurialize(count, singular, plural) {
13
+ function plurialize(count, singular, plural) {
10
14
  if (Array.isArray(singular)) {
11
15
  plural = singular[1];
12
16
  singular = singular[0];
13
17
  }
14
- let msg = count === 1 ? singular : plural !== null && plural !== void 0 ? plural : singular;
18
+ let msg = count === 1 ? singular : plural ?? singular;
15
19
  msg = msg.replace('{count}', count.toString());
16
20
  return msg;
17
21
  }
@@ -1,15 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaExperienceBuilder = void 0;
1
4
  class BaseSchemaExperienceBuilder {
5
+ logicalName;
6
+ views = [];
7
+ forms = [];
8
+ lookups = [];
9
+ quickCreateForms = [];
10
+ defaultViewId = null;
11
+ defaultFormId = null;
12
+ defaultLookupId = null;
13
+ defaultQuickCreateFormId = null;
14
+ locked = false;
2
15
  constructor(logicalName) {
3
16
  this.logicalName = logicalName;
4
- this.views = [];
5
- this.forms = [];
6
- this.lookups = [];
7
- this.quickCreateForms = [];
8
- this.defaultViewId = null;
9
- this.defaultFormId = null;
10
- this.defaultLookupId = null;
11
- this.defaultQuickCreateFormId = null;
12
- this.locked = false;
13
17
  }
14
18
  reset() {
15
19
  this.views = [];
@@ -62,7 +66,10 @@ class BaseSchemaExperienceBuilder {
62
66
  return formExperience;
63
67
  }
64
68
  }
65
- export class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
69
+ class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
70
+ schema;
71
+ defaults;
72
+ options;
66
73
  constructor(schema, defaults, options) {
67
74
  super(schema.logicalName);
68
75
  this.schema = schema;
@@ -70,10 +77,13 @@ export class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
70
77
  this.options = options;
71
78
  }
72
79
  defineViewExperience(viewExperience) {
73
- var _a, _b;
74
- const cardView = (_a = viewExperience.card) !== null && _a !== void 0 ? _a : this.defineDefaultViewCard();
75
- const gridView = (_b = viewExperience.grid) !== null && _b !== void 0 ? _b : this.defineDefaultViewGrid();
76
- return Object.assign(Object.assign({}, viewExperience), { grid: gridView, card: cardView });
80
+ const cardView = viewExperience.card ?? this.defineDefaultViewCard();
81
+ const gridView = viewExperience.grid ?? this.defineDefaultViewGrid();
82
+ return {
83
+ ...viewExperience,
84
+ grid: gridView,
85
+ card: cardView,
86
+ };
77
87
  }
78
88
  defineDefaultViewGrid() {
79
89
  const columns = [];
@@ -152,16 +162,15 @@ export class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
152
162
  };
153
163
  }
154
164
  getLocalizedViewNames() {
155
- var _a;
156
165
  const langugesSet = new Set();
157
166
  this.schema.localizedPluralLabels &&
158
167
  Object.keys(this.schema.localizedPluralLabels).forEach((key) => langugesSet.add(key));
159
- ((_a = this.defaults) === null || _a === void 0 ? void 0 : _a.localizedViewNames) &&
168
+ this.defaults?.localizedViewNames &&
160
169
  Object.keys(this.defaults.localizedViewNames).forEach((key) => langugesSet.add(key));
161
170
  const localizedLabels = Array.from(langugesSet).reduce((acc, key) => {
162
- var _a, _b, _c, _d, _e, _f;
163
- const localizedPluralName = (_c = (_b = (_a = this.schema.localizedPluralLabels) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : this.schema.pluralLabel.toLowerCase();
164
- const localizedPlaceholder = (_f = (_e = (_d = this.defaults) === null || _d === void 0 ? void 0 : _d.localizedViewNames) === null || _e === void 0 ? void 0 : _e[key]) !== null && _f !== void 0 ? _f : `All {label}`;
171
+ const localizedPluralName = this.schema.localizedPluralLabels?.[key]?.toLowerCase() ??
172
+ this.schema.pluralLabel.toLowerCase();
173
+ const localizedPlaceholder = this.defaults?.localizedViewNames?.[key] ?? `All {label}`;
165
174
  const localeName = localizedPlaceholder.replace('{label}', localizedPluralName);
166
175
  acc[key] = localeName;
167
176
  return acc;
@@ -181,12 +190,11 @@ export class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
181
190
  return defaultId;
182
191
  }
183
192
  defineExperience(experience) {
184
- var _a, _b, _c, _d, _e, _f, _g, _h;
185
193
  let lookups = experience.lookups;
186
194
  let views = experience.views;
187
195
  let forms = experience.forms;
188
196
  let associatedViews = experience.associatedViews;
189
- if (!(lookups === null || lookups === void 0 ? void 0 : lookups.length)) {
197
+ if (!lookups?.length) {
190
198
  lookups = [
191
199
  {
192
200
  id: 'default',
@@ -195,7 +203,7 @@ export class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
195
203
  },
196
204
  ];
197
205
  }
198
- if (!(views === null || views === void 0 ? void 0 : views.length)) {
206
+ if (!views?.length) {
199
207
  views = [
200
208
  {
201
209
  id: 'default',
@@ -205,7 +213,7 @@ export class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
205
213
  },
206
214
  ];
207
215
  }
208
- if (!(associatedViews === null || associatedViews === void 0 ? void 0 : associatedViews.length)) {
216
+ if (!associatedViews?.length) {
209
217
  associatedViews = [
210
218
  {
211
219
  id: 'default',
@@ -215,7 +223,7 @@ export class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
215
223
  },
216
224
  ];
217
225
  }
218
- if (!(forms === null || forms === void 0 ? void 0 : forms.length)) {
226
+ if (!forms?.length) {
219
227
  forms = [
220
228
  {
221
229
  id: 'default',
@@ -229,8 +237,8 @@ export class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
229
237
  const defaultLookupId = this.resolveDefaultId(lookups, experience.defaultLookupId);
230
238
  const defaultAssociatedViewId = this.resolveDefaultId(associatedViews, experience.defaultAssociatedViewId);
231
239
  let defaultQuickCreateFormId = null;
232
- if ((_a = experience.quickCreateForms) === null || _a === void 0 ? void 0 : _a.length) {
233
- defaultQuickCreateFormId = this.resolveDefaultId((_b = experience.quickCreateForms) !== null && _b !== void 0 ? _b : [], experience.defaultQuickCreateFormId);
240
+ if (experience.quickCreateForms?.length) {
241
+ defaultQuickCreateFormId = this.resolveDefaultId(experience.quickCreateForms ?? [], experience.defaultQuickCreateFormId);
234
242
  }
235
243
  return {
236
244
  logicalName: this.logicalName,
@@ -240,14 +248,30 @@ export class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
240
248
  defaultViewId,
241
249
  defaultLookupId,
242
250
  defaultAssociatedViewId,
243
- quickCreateForms: (_d = (_c = experience.quickCreateForms) === null || _c === void 0 ? void 0 : _c.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _d !== void 0 ? _d : [],
244
- views: (_e = views.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _e !== void 0 ? _e : [],
245
- forms: (_f = forms.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _f !== void 0 ? _f : [],
246
- lookups: (_g = lookups.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _g !== void 0 ? _g : [],
247
- associatedViews: (_h = associatedViews.map((x) => (Object.assign(Object.assign({}, x), { logicalName: this.logicalName })))) !== null && _h !== void 0 ? _h : [],
251
+ quickCreateForms: experience.quickCreateForms?.map((x) => ({
252
+ ...x,
253
+ logicalName: this.logicalName,
254
+ })) ?? [],
255
+ views: views.map((x) => ({
256
+ ...x,
257
+ logicalName: this.logicalName,
258
+ })) ?? [],
259
+ forms: forms.map((x) => ({
260
+ ...x,
261
+ logicalName: this.logicalName,
262
+ })) ?? [],
263
+ lookups: lookups.map((x) => ({
264
+ ...x,
265
+ logicalName: this.logicalName,
266
+ })) ?? [],
267
+ associatedViews: associatedViews.map((x) => ({
268
+ ...x,
269
+ logicalName: this.logicalName,
270
+ })) ?? [],
248
271
  formCommands: experience.formCommands,
249
272
  subgridCommands: experience.subgridCommands,
250
273
  viewCommands: experience.viewCommands,
251
274
  };
252
275
  }
253
276
  }
277
+ exports.SchemaExperienceBuilder = SchemaExperienceBuilder;
package/builders/index.js CHANGED
@@ -1,2 +1,7 @@
1
- export { SchemaExperienceBuilder, } from './SchemaExperienceBuilder';
2
- export { CommandBuilder } from './CommandBuilder';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandBuilder = exports.SchemaExperienceBuilder = void 0;
4
+ var SchemaExperienceBuilder_1 = require("./SchemaExperienceBuilder");
5
+ Object.defineProperty(exports, "SchemaExperienceBuilder", { enumerable: true, get: function () { return SchemaExperienceBuilder_1.SchemaExperienceBuilder; } });
6
+ var CommandBuilder_1 = require("./CommandBuilder");
7
+ Object.defineProperty(exports, "CommandBuilder", { enumerable: true, get: function () { return CommandBuilder_1.CommandBuilder; } });