@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,26 +1,17 @@
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
- export class ClientAppStore {
11
- constructor() {
12
- this.apps = {};
13
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientAppStore = void 0;
4
+ class ClientAppStore {
5
+ apps = {};
14
6
  register(app) {
15
7
  this.apps[app.id] = app;
16
8
  }
17
- getApp(id) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- const app = this.apps[id];
20
- if (!app) {
21
- throw new Error(`App Experience for ${id} not found`);
22
- }
23
- return app;
24
- });
9
+ async getApp(id) {
10
+ const app = this.apps[id];
11
+ if (!app) {
12
+ throw new Error(`App Experience for ${id} not found`);
13
+ }
14
+ return app;
25
15
  }
26
16
  }
17
+ exports.ClientAppStore = ClientAppStore;
@@ -1,7 +1,8 @@
1
- export class ComponentStore {
2
- constructor() {
3
- this.components = {};
4
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComponentStore = void 0;
4
+ class ComponentStore {
5
+ components = {};
5
6
  registerComponent(name, component) {
6
7
  this.components[name] = component;
7
8
  }
@@ -13,3 +14,4 @@ export class ComponentStore {
13
14
  return self.components[name];
14
15
  }
15
16
  }
17
+ exports.ComponentStore = ComponentStore;
@@ -1,38 +1,26 @@
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
- export class EventManager {
11
- constructor() {
12
- this.handlers = {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventManager = void 0;
4
+ class EventManager {
5
+ handlers = {};
6
+ async on(key, handler) {
7
+ if (!this.handlers[key]) {
8
+ this.handlers[key] = [];
9
+ }
10
+ this.handlers[key].push(handler);
13
11
  }
14
- on(key, handler) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- if (!this.handlers[key]) {
17
- this.handlers[key] = [];
18
- }
19
- this.handlers[key].push(handler);
20
- });
21
- }
22
- off(key, handler) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- if (!this.handlers[key]) {
25
- return;
26
- }
27
- this.handlers[key] = this.handlers[key].filter((h) => h !== handler);
28
- if (this.handlers[key].length === 0) {
29
- delete this.handlers[key];
30
- }
31
- });
12
+ async off(key, handler) {
13
+ if (!this.handlers[key]) {
14
+ return;
15
+ }
16
+ this.handlers[key] = this.handlers[key].filter((h) => h !== handler);
17
+ if (this.handlers[key].length === 0) {
18
+ delete this.handlers[key];
19
+ }
32
20
  }
33
21
  emit(key, ...args) {
34
- var _a;
35
- const handlers = ((_a = this.handlers[key]) !== null && _a !== void 0 ? _a : []);
22
+ const handlers = (this.handlers[key] ?? []);
36
23
  return handlers.map((handler) => handler(...args));
37
24
  }
38
25
  }
26
+ exports.EventManager = EventManager;
@@ -1,21 +1,17 @@
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
- export function getDefaultCardView(schema) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaExperienceStore = void 0;
4
+ exports.getDefaultCardView = getDefaultCardView;
5
+ function getDefaultCardView(schema) {
11
6
  return {
12
7
  primaryColumn: schema.primaryAttribute,
13
8
  };
14
9
  }
15
- export class SchemaExperienceStore {
10
+ class SchemaExperienceStore {
11
+ options;
12
+ experiences = {};
16
13
  constructor(options) {
17
14
  this.options = options;
18
- this.experiences = {};
19
15
  }
20
16
  register(experience) {
21
17
  for (const view of Object.values(experience.views)) {
@@ -31,209 +27,183 @@ export class SchemaExperienceStore {
31
27
  }
32
28
  this.experiences[experience.logicalName] = experience;
33
29
  }
34
- getExperience(logicalName) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const experience = this.experiences[logicalName];
37
- if (!experience) {
38
- throw new Error(`Experience for ${logicalName} not found`);
39
- }
40
- return experience;
41
- });
42
- }
43
- getPublicViewLookup(logicalName, viewIds) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const experience = yield this.getExperience(logicalName);
46
- let views = experience.views;
47
- if (viewIds === null || viewIds === void 0 ? void 0 : viewIds.length) {
48
- views = views.filter((view) => viewIds.includes(view.id));
49
- }
50
- if (!views.length) {
51
- views = experience.views.filter((x) => x.id === experience.defaultViewId);
52
- }
53
- return views.map((view) => ({
54
- id: view.id,
55
- name: view.name,
56
- localizedNames: view.localizedNames,
57
- }));
58
- });
59
- }
60
- getAssociatedViewLookup(logicalName, viewIds) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const experience = yield this.getExperience(logicalName);
63
- let associatedViews = experience.associatedViews;
64
- if (viewIds === null || viewIds === void 0 ? void 0 : viewIds.length) {
65
- associatedViews = associatedViews.filter((view) => viewIds.includes(view.id));
66
- }
67
- if (!associatedViews.length) {
68
- associatedViews = experience.associatedViews.filter((x) => x.id === experience.defaultAssociatedViewId);
69
- }
70
- return associatedViews.map((view) => ({
71
- id: view.id,
72
- name: view.name,
73
- localizedNames: view.localizedNames,
74
- }));
75
- });
76
- }
77
- getPublicView(logicalName, viewId, viewIds) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- const experience = yield this.getExperience(logicalName);
80
- const availableViewLookup = yield this.getPublicViewLookup(logicalName, viewIds);
81
- let validViewIds = availableViewLookup.map((x) => x.id);
82
- if (!validViewIds.length) {
83
- validViewIds = [experience.defaultViewId];
84
- }
85
- if (!viewId) {
86
- viewId = experience.defaultViewId;
87
- }
88
- if (!validViewIds.includes(viewId)) {
89
- viewId = validViewIds[0];
90
- }
91
- let view = experience.views.find((v) => v.id === viewId);
92
- if (!view) {
93
- throw new Error(`View ${viewId} not found`);
94
- }
95
- let viewExperience = view.experience;
96
- if (typeof viewExperience === 'function') {
97
- viewExperience = yield viewExperience();
98
- }
99
- if (!viewExperience.card) {
100
- viewExperience.card = getDefaultCardView(this.options.schemaStore.getSchema(logicalName));
101
- }
102
- return {
103
- id: view.id,
104
- name: view.name,
105
- logicalName: view.logicalName,
106
- localizedNames: view.localizedNames,
107
- experience: viewExperience,
108
- };
109
- });
110
- }
111
- getAssociatedView(logicalName, viewId, viewIds) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- const experience = yield this.getExperience(logicalName);
114
- const availableViewLookup = yield this.getAssociatedViewLookup(logicalName, viewIds);
115
- let validViewIds = availableViewLookup.map((x) => x.id);
116
- if (!validViewIds.length) {
117
- validViewIds = [experience.defaultViewId];
118
- }
119
- if (!viewId) {
120
- viewId = experience.defaultAssociatedViewId;
121
- }
122
- if (!validViewIds.includes(viewId)) {
123
- viewId = validViewIds[0];
124
- }
125
- let view = experience.associatedViews.find((v) => v.id === viewId);
126
- if (!view) {
127
- throw new Error(`View ${viewId} not found`);
128
- }
129
- let viewExperience = view.experience;
130
- if (typeof viewExperience === 'function') {
131
- viewExperience = yield viewExperience();
132
- }
133
- if (!viewExperience.card) {
134
- viewExperience.card = getDefaultCardView(this.options.schemaStore.getSchema(logicalName));
135
- }
136
- return {
137
- id: view.id,
138
- name: view.name,
139
- logicalName: view.logicalName,
140
- localizedNames: view.localizedNames,
141
- experience: viewExperience,
142
- };
143
- });
144
- }
145
- getViewLookupV2(logicalName, viewId) {
146
- return __awaiter(this, void 0, void 0, function* () {
147
- const experience = yield this.getExperience(logicalName);
148
- if (!viewId) {
149
- viewId = experience.defaultViewId;
150
- }
151
- const view = experience.lookups.find((v) => v.id === viewId);
152
- if (!view) {
153
- throw new Error(`Lookup ${viewId} not found`);
154
- }
155
- let viewExperience = view.experience;
156
- if (typeof viewExperience === 'function') {
157
- viewExperience = yield viewExperience();
158
- }
159
- return {
160
- id: view.id,
161
- name: view.name,
162
- logicalName: view.logicalName,
163
- experience: viewExperience,
164
- };
165
- });
166
- }
167
- getDefaultViewId(logicalName) {
168
- return __awaiter(this, void 0, void 0, function* () {
169
- const experience = yield this.getExperience(logicalName);
170
- return experience.defaultViewId;
171
- });
30
+ async getExperience(logicalName) {
31
+ const experience = this.experiences[logicalName];
32
+ if (!experience) {
33
+ throw new Error(`Experience for ${logicalName} not found`);
34
+ }
35
+ return experience;
172
36
  }
173
- getDefaultViewLookupId(logicalName) {
174
- return __awaiter(this, void 0, void 0, function* () {
175
- const experience = yield this.getExperience(logicalName);
176
- return experience.defaultLookupId;
177
- });
37
+ async getPublicViewLookup(logicalName, viewIds) {
38
+ const experience = await this.getExperience(logicalName);
39
+ let views = experience.views;
40
+ if (viewIds?.length) {
41
+ views = views.filter((view) => viewIds.includes(view.id));
42
+ }
43
+ if (!views.length) {
44
+ views = experience.views.filter((x) => x.id === experience.defaultViewId);
45
+ }
46
+ return views.map((view) => ({
47
+ id: view.id,
48
+ name: view.name,
49
+ localizedNames: view.localizedNames,
50
+ }));
178
51
  }
179
- getForm(logicalName, formId) {
180
- return __awaiter(this, void 0, void 0, function* () {
181
- const experience = yield this.getExperience(logicalName);
182
- if (!formId) {
183
- formId = experience.defaultFormId;
184
- }
185
- const form = experience.forms.find((f) => f.id === formId);
186
- if (!form) {
187
- throw new Error(`Form ${formId} not found`);
188
- }
189
- let formExperience = form.experience;
190
- if (typeof formExperience === 'function') {
191
- formExperience = yield formExperience();
192
- }
193
- return {
194
- id: form.id,
195
- name: form.name,
196
- logicalName: form.logicalName,
197
- experience: formExperience,
198
- };
199
- });
52
+ async getAssociatedViewLookup(logicalName, viewIds) {
53
+ const experience = await this.getExperience(logicalName);
54
+ let associatedViews = experience.associatedViews;
55
+ if (viewIds?.length) {
56
+ associatedViews = associatedViews.filter((view) => viewIds.includes(view.id));
57
+ }
58
+ if (!associatedViews.length) {
59
+ associatedViews = experience.associatedViews.filter((x) => x.id === experience.defaultAssociatedViewId);
60
+ }
61
+ return associatedViews.map((view) => ({
62
+ id: view.id,
63
+ name: view.name,
64
+ localizedNames: view.localizedNames,
65
+ }));
200
66
  }
201
- getQuickCreateForm(logicalName, formId) {
202
- return __awaiter(this, void 0, void 0, function* () {
203
- const experience = yield this.getExperience(logicalName);
204
- const form = experience.quickCreateForms.find((f) => f.id === formId);
205
- if (!form) {
206
- throw new Error(`Quick create form ${formId} not found`);
207
- }
208
- let formExperience = form.experience;
209
- if (typeof formExperience === 'function') {
210
- formExperience = yield formExperience();
211
- }
212
- return {
213
- id: form.id,
214
- name: form.name,
215
- logicalName: form.logicalName,
216
- experience: formExperience,
217
- };
218
- });
67
+ async getPublicView(logicalName, viewId, viewIds) {
68
+ const experience = await this.getExperience(logicalName);
69
+ const availableViewLookup = await this.getPublicViewLookup(logicalName, viewIds);
70
+ let validViewIds = availableViewLookup.map((x) => x.id);
71
+ if (!validViewIds.length) {
72
+ validViewIds = [experience.defaultViewId];
73
+ }
74
+ if (!viewId) {
75
+ viewId = experience.defaultViewId;
76
+ }
77
+ if (!validViewIds.includes(viewId)) {
78
+ viewId = validViewIds[0];
79
+ }
80
+ let view = experience.views.find((v) => v.id === viewId);
81
+ if (!view) {
82
+ throw new Error(`View ${viewId} not found`);
83
+ }
84
+ let viewExperience = view.experience;
85
+ if (typeof viewExperience === 'function') {
86
+ viewExperience = await viewExperience();
87
+ }
88
+ if (!viewExperience.card) {
89
+ viewExperience.card = getDefaultCardView(this.options.schemaStore.getSchema(logicalName));
90
+ }
91
+ return {
92
+ id: view.id,
93
+ name: view.name,
94
+ logicalName: view.logicalName,
95
+ localizedNames: view.localizedNames,
96
+ experience: viewExperience,
97
+ };
98
+ }
99
+ async getAssociatedView(logicalName, viewId, viewIds) {
100
+ const experience = await this.getExperience(logicalName);
101
+ const availableViewLookup = await this.getAssociatedViewLookup(logicalName, viewIds);
102
+ let validViewIds = availableViewLookup.map((x) => x.id);
103
+ if (!validViewIds.length) {
104
+ validViewIds = [experience.defaultViewId];
105
+ }
106
+ if (!viewId) {
107
+ viewId = experience.defaultAssociatedViewId;
108
+ }
109
+ if (!validViewIds.includes(viewId)) {
110
+ viewId = validViewIds[0];
111
+ }
112
+ let view = experience.associatedViews.find((v) => v.id === viewId);
113
+ if (!view) {
114
+ throw new Error(`View ${viewId} not found`);
115
+ }
116
+ let viewExperience = view.experience;
117
+ if (typeof viewExperience === 'function') {
118
+ viewExperience = await viewExperience();
119
+ }
120
+ if (!viewExperience.card) {
121
+ viewExperience.card = getDefaultCardView(this.options.schemaStore.getSchema(logicalName));
122
+ }
123
+ return {
124
+ id: view.id,
125
+ name: view.name,
126
+ logicalName: view.logicalName,
127
+ localizedNames: view.localizedNames,
128
+ experience: viewExperience,
129
+ };
130
+ }
131
+ async getViewLookupV2(logicalName, viewId) {
132
+ const experience = await this.getExperience(logicalName);
133
+ if (!viewId) {
134
+ viewId = experience.defaultViewId;
135
+ }
136
+ const view = experience.lookups.find((v) => v.id === viewId);
137
+ if (!view) {
138
+ throw new Error(`Lookup ${viewId} not found`);
139
+ }
140
+ let viewExperience = view.experience;
141
+ if (typeof viewExperience === 'function') {
142
+ viewExperience = await viewExperience();
143
+ }
144
+ return {
145
+ id: view.id,
146
+ name: view.name,
147
+ logicalName: view.logicalName,
148
+ experience: viewExperience,
149
+ };
150
+ }
151
+ async getDefaultViewId(logicalName) {
152
+ const experience = await this.getExperience(logicalName);
153
+ return experience.defaultViewId;
154
+ }
155
+ async getDefaultViewLookupId(logicalName) {
156
+ const experience = await this.getExperience(logicalName);
157
+ return experience.defaultLookupId;
158
+ }
159
+ async getForm(logicalName, formId) {
160
+ const experience = await this.getExperience(logicalName);
161
+ if (!formId) {
162
+ formId = experience.defaultFormId;
163
+ }
164
+ const form = experience.forms.find((f) => f.id === formId);
165
+ if (!form) {
166
+ throw new Error(`Form ${formId} not found`);
167
+ }
168
+ let formExperience = form.experience;
169
+ if (typeof formExperience === 'function') {
170
+ formExperience = await formExperience();
171
+ }
172
+ return {
173
+ id: form.id,
174
+ name: form.name,
175
+ logicalName: form.logicalName,
176
+ experience: formExperience,
177
+ };
178
+ }
179
+ async getQuickCreateForm(logicalName, formId) {
180
+ const experience = await this.getExperience(logicalName);
181
+ const form = experience.quickCreateForms.find((f) => f.id === formId);
182
+ if (!form) {
183
+ throw new Error(`Quick create form ${formId} not found`);
184
+ }
185
+ let formExperience = form.experience;
186
+ if (typeof formExperience === 'function') {
187
+ formExperience = await formExperience();
188
+ }
189
+ return {
190
+ id: form.id,
191
+ name: form.name,
192
+ logicalName: form.logicalName,
193
+ experience: formExperience,
194
+ };
219
195
  }
220
- getViewCommands(logicalName) {
221
- return __awaiter(this, void 0, void 0, function* () {
222
- const experience = yield this.getExperience(logicalName);
223
- return experience.viewCommands;
224
- });
196
+ async getViewCommands(logicalName) {
197
+ const experience = await this.getExperience(logicalName);
198
+ return experience.viewCommands;
225
199
  }
226
- getFormCommands(logicalName) {
227
- return __awaiter(this, void 0, void 0, function* () {
228
- const experience = yield this.getExperience(logicalName);
229
- return experience.formCommands;
230
- });
200
+ async getFormCommands(logicalName) {
201
+ const experience = await this.getExperience(logicalName);
202
+ return experience.formCommands;
231
203
  }
232
- getSubgridCommands(logicalName) {
233
- return __awaiter(this, void 0, void 0, function* () {
234
- const experience = yield this.getExperience(logicalName);
235
- return experience.subgridCommands;
236
- });
204
+ async getSubgridCommands(logicalName) {
205
+ const experience = await this.getExperience(logicalName);
206
+ return experience.subgridCommands;
237
207
  }
238
208
  getSchemaMetadataList() {
239
209
  const schemas = this.options.schemaStore.getAllSchema();
@@ -247,13 +217,12 @@ export class SchemaExperienceStore {
247
217
  localizedPluralLabels: schema.localizedPluralLabels,
248
218
  }));
249
219
  }
250
- getExperienceSchemaMetadatList() {
251
- return __awaiter(this, void 0, void 0, function* () {
252
- const schemaMetadatas = this.getSchemaMetadataList();
253
- return schemaMetadatas.map((schemaMetadata) => {
254
- var _a;
255
- return (Object.assign(Object.assign({}, schemaMetadata), { icon: (_a = this.experiences[schemaMetadata.logicalName]) === null || _a === void 0 ? void 0 : _a.icon }));
256
- });
257
- });
220
+ async getExperienceSchemaMetadatList() {
221
+ const schemaMetadatas = this.getSchemaMetadataList();
222
+ return schemaMetadatas.map((schemaMetadata) => ({
223
+ ...schemaMetadata,
224
+ icon: this.experiences[schemaMetadata.logicalName]?.icon,
225
+ }));
258
226
  }
259
227
  }
228
+ exports.SchemaExperienceStore = SchemaExperienceStore;
package/store/index.js CHANGED
@@ -1,4 +1,20 @@
1
- export * from './ClientAppStore';
2
- export * from './ComponentStore';
3
- export * from './EventManager';
4
- export * from './SchemaExperienceStore';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ClientAppStore"), exports);
18
+ __exportStar(require("./ComponentStore"), exports);
19
+ __exportStar(require("./EventManager"), exports);
20
+ __exportStar(require("./SchemaExperienceStore"), exports);
@@ -1,9 +1,13 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useCreateContextStore } from '../mutable/context';
3
- import { ToastNotificationContext, } from './context';
4
- export const ToastNotificationProvider = ({ children }) => {
5
- const contextState = useCreateContextStore({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ToastNotificationProvider = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const context_1 = require("../mutable/context");
6
+ const context_2 = require("./context");
7
+ const ToastNotificationProvider = ({ children }) => {
8
+ const contextState = (0, context_1.useCreateContextStore)({
6
9
  items: [],
7
10
  });
8
- return (_jsx(ToastNotificationContext.Provider, { value: contextState, children: children }));
11
+ return ((0, jsx_runtime_1.jsx)(context_2.ToastNotificationContext.Provider, { value: contextState, children: children }));
9
12
  };
13
+ exports.ToastNotificationProvider = ToastNotificationProvider;
@@ -12,4 +12,4 @@ export interface ToastNotificationItem {
12
12
  export interface ToastNotificationContextState {
13
13
  items: ToastNotificationItem[];
14
14
  }
15
- export declare const ToastNotificationContext: import("react").Context<import("../mutable").ContextValue<ToastNotificationContextState>>;
15
+ export declare const ToastNotificationContext: import("react").Context<import("../mutable/context").ContextValue<ToastNotificationContextState>>;
@@ -1,2 +1,5 @@
1
- import { createContext } from '../mutable/context';
2
- export const ToastNotificationContext = createContext();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ToastNotificationContext = void 0;
4
+ const context_1 = require("../mutable/context");
5
+ exports.ToastNotificationContext = (0, context_1.createContext)();
@@ -1,3 +1,19 @@
1
- export * from './useCloseToastNotification';
2
- export * from './useOpenToastNotification';
3
- export * from './useToastNotificationItems';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useCloseToastNotification"), exports);
18
+ __exportStar(require("./useOpenToastNotification"), exports);
19
+ __exportStar(require("./useToastNotificationItems"), exports);