@judo/core 0.1.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 (59) hide show
  1. package/LICENSE +277 -0
  2. package/README.md +213 -0
  3. package/dist/contexts/application-context.d.ts +46 -0
  4. package/dist/contexts/application-context.d.ts.map +1 -0
  5. package/dist/contexts/customizations-context.d.ts +227 -0
  6. package/dist/contexts/customizations-context.d.ts.map +1 -0
  7. package/dist/contexts/data-context.d.ts +30 -0
  8. package/dist/contexts/data-context.d.ts.map +1 -0
  9. package/dist/contexts/dispatch-context.d.ts +39 -0
  10. package/dist/contexts/dispatch-context.d.ts.map +1 -0
  11. package/dist/contexts/index.d.ts +12 -0
  12. package/dist/contexts/index.d.ts.map +1 -0
  13. package/dist/contexts/mui-pro-context.d.ts +52 -0
  14. package/dist/contexts/mui-pro-context.d.ts.map +1 -0
  15. package/dist/contexts/navigation-context.d.ts +113 -0
  16. package/dist/contexts/navigation-context.d.ts.map +1 -0
  17. package/dist/contexts/page-context.d.ts +43 -0
  18. package/dist/contexts/page-context.d.ts.map +1 -0
  19. package/dist/contexts/refresh-signal-context.d.ts +18 -0
  20. package/dist/contexts/refresh-signal-context.d.ts.map +1 -0
  21. package/dist/contexts/runtime-config-context.d.ts +70 -0
  22. package/dist/contexts/runtime-config-context.d.ts.map +1 -0
  23. package/dist/contexts/selector-selection-context.d.ts +44 -0
  24. package/dist/contexts/selector-selection-context.d.ts.map +1 -0
  25. package/dist/contexts/validation-context.d.ts +57 -0
  26. package/dist/contexts/validation-context.d.ts.map +1 -0
  27. package/dist/hooks/index.d.ts +9 -0
  28. package/dist/hooks/index.d.ts.map +1 -0
  29. package/dist/hooks/use-data-selector.d.ts +51 -0
  30. package/dist/hooks/use-data-selector.d.ts.map +1 -0
  31. package/dist/hooks/use-debounced-callback.d.ts +36 -0
  32. package/dist/hooks/use-debounced-callback.d.ts.map +1 -0
  33. package/dist/hooks/use-edit-mode.d.ts +23 -0
  34. package/dist/hooks/use-edit-mode.d.ts.map +1 -0
  35. package/dist/hooks/use-element-disabled.d.ts +16 -0
  36. package/dist/hooks/use-element-disabled.d.ts.map +1 -0
  37. package/dist/hooks/use-element-visibility.d.ts +16 -0
  38. package/dist/hooks/use-element-visibility.d.ts.map +1 -0
  39. package/dist/hooks/use-validation.d.ts +32 -0
  40. package/dist/hooks/use-validation.d.ts.map +1 -0
  41. package/dist/hooks/use-visual-binding.d.ts +38 -0
  42. package/dist/hooks/use-visual-binding.d.ts.map +1 -0
  43. package/dist/hooks/use-visual-element.d.ts +13 -0
  44. package/dist/hooks/use-visual-element.d.ts.map +1 -0
  45. package/dist/index.d.ts +11 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +764 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/store/data-store.d.ts +168 -0
  50. package/dist/store/data-store.d.ts.map +1 -0
  51. package/dist/store/index.d.ts +3 -0
  52. package/dist/store/index.d.ts.map +1 -0
  53. package/dist/store/selectors.d.ts +58 -0
  54. package/dist/store/selectors.d.ts.map +1 -0
  55. package/dist/utils/deep-equal.d.ts +10 -0
  56. package/dist/utils/deep-equal.d.ts.map +1 -0
  57. package/dist/utils/index.d.ts +2 -0
  58. package/dist/utils/index.d.ts.map +1 -0
  59. package/package.json +58 -0
package/dist/index.js ADDED
@@ -0,0 +1,764 @@
1
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { DialogSize } from "@judo/model-api";
4
+ var ApplicationContext = createContext(null);
5
+ function useApplication() {
6
+ let e = useContext(ApplicationContext);
7
+ if (!e) throw Error("useApplication must be used within ApplicationProvider. Ensure model is loaded before rendering application.");
8
+ return e;
9
+ }
10
+ function useApplicationOptional() {
11
+ return useContext(ApplicationContext);
12
+ }
13
+ function ApplicationProvider({ children: e, registry: S }) {
14
+ let C = useCallback((e) => S.subscribe(e), [S]), w = useCallback(() => S.getSnapshot(), [S]), T = useSyncExternalStore(C, w, w);
15
+ if (!T.activeApplication) throw Error("No active application. Model must be loaded first.");
16
+ return /* @__PURE__ */ jsx(ApplicationContext.Provider, {
17
+ value: {
18
+ application: T.activeApplication,
19
+ applications: T.applications,
20
+ actorName: T.activeActorName,
21
+ switchActor: (e) => S.setActiveApplication(e),
22
+ switchActorWithNavigation: (e, x) => {
23
+ if (S.setActiveApplication(e), x) {
24
+ let e = S.getSnapshot();
25
+ e.activeApplication && x(e.activeApplication);
26
+ }
27
+ }
28
+ },
29
+ children: e
30
+ });
31
+ }
32
+ var NavigationContext = createContext(null);
33
+ function useNavigation() {
34
+ let e = useContext(NavigationContext);
35
+ if (!e) throw Error("useNavigation must be used within NavigationProvider");
36
+ return e;
37
+ }
38
+ function useNavigationOptional() {
39
+ return useContext(NavigationContext);
40
+ }
41
+ function NavigationProvider({ children: e, initialPage: S, navigate: C, getRouteForPage: w }) {
42
+ let [D, A] = useState({
43
+ pageStack: [],
44
+ currentPage: S ?? null,
45
+ dialogStack: []
46
+ }), j = useCallback((e, x) => {
47
+ if (A((S) => {
48
+ if (e.openInDialog) return N.current.push(null), {
49
+ ...S,
50
+ dialogStack: [...S.dialogStack, {
51
+ pageDefinition: e,
52
+ size: e.dialogSize || DialogSize.MD,
53
+ params: x
54
+ }]
55
+ };
56
+ N.current = [];
57
+ let C = S.currentPage ? [...S.pageStack, { pageDefinition: S.currentPage }] : S.pageStack;
58
+ return {
59
+ ...S,
60
+ pageStack: C,
61
+ currentPage: e,
62
+ dialogStack: []
63
+ };
64
+ }), !e.openInDialog && C && w) {
65
+ let S = w(e), T = x?.transfer;
66
+ C(T?.__signedIdentifier ? `${S}/${encodeURIComponent(T.__signedIdentifier)}` : S, { state: x });
67
+ }
68
+ }, [C, w]), M = useCallback(() => {
69
+ A((e) => {
70
+ if (e.dialogStack.length > 0) {
71
+ let x = N.current.pop() ?? null;
72
+ return x && x(void 0), {
73
+ ...e,
74
+ dialogStack: e.dialogStack.slice(0, -1)
75
+ };
76
+ }
77
+ if (e.pageStack.length === 0) return C && C(-1), e;
78
+ let x = [...e.pageStack], S = x.pop();
79
+ return C && w && C(w(S.pageDefinition), { state: S.params }), {
80
+ ...e,
81
+ pageStack: x,
82
+ currentPage: S.pageDefinition
83
+ };
84
+ });
85
+ }, [C, w]), N = useRef([]), F = useCallback((e, x, S) => {
86
+ N.current.push(S ?? null), A((S) => ({
87
+ ...S,
88
+ dialogStack: [...S.dialogStack, {
89
+ pageDefinition: e,
90
+ size: e.dialogSize || DialogSize.MD,
91
+ params: x
92
+ }]
93
+ }));
94
+ }, []), I = useCallback((e) => {
95
+ let x = N.current.pop() ?? null;
96
+ x && x(e), A((e) => ({
97
+ ...e,
98
+ dialogStack: e.dialogStack.slice(0, -1)
99
+ }));
100
+ }, []), L = useCallback((e, x) => {
101
+ N.current = [], A((x) => ({
102
+ ...x,
103
+ currentPage: e,
104
+ dialogStack: []
105
+ }));
106
+ }, []), R = useCallback(() => {
107
+ A((e) => ({
108
+ ...e,
109
+ pageStack: []
110
+ }));
111
+ }, []), z = D.dialogStack.length > 0 ? D.dialogStack[D.dialogStack.length - 1] : null, B = {
112
+ ...D,
113
+ dialog: z,
114
+ navigateTo: j,
115
+ goBack: M,
116
+ openDialog: F,
117
+ closeDialog: I,
118
+ replacePage: L,
119
+ clearStack: R,
120
+ canGoBack: D.pageStack.length > 0 || D.dialogStack.length > 0
121
+ };
122
+ return /* @__PURE__ */ jsx(NavigationContext.Provider, {
123
+ value: B,
124
+ children: e
125
+ });
126
+ }
127
+ function deepEqual(e, x) {
128
+ if (e === x) return !0;
129
+ if (e === null || x === null || e === void 0 || x === void 0) return e === x;
130
+ if (typeof e != typeof x) return !1;
131
+ if (typeof e != "object") return e === x;
132
+ if (Array.isArray(e) && Array.isArray(x)) {
133
+ if (e.length !== x.length) return !1;
134
+ for (let S = 0; S < e.length; S++) if (!deepEqual(e[S], x[S])) return !1;
135
+ return !0;
136
+ }
137
+ if (Array.isArray(e) || Array.isArray(x)) return !1;
138
+ if (e instanceof Date && x instanceof Date) return e.getTime() === x.getTime();
139
+ let S = e, C = x, w = Object.keys(S);
140
+ if (w.length !== Object.keys(C).length) return !1;
141
+ for (let e of w) if (!Object.prototype.hasOwnProperty.call(C, e) || !deepEqual(S[e], C[e])) return !1;
142
+ return !0;
143
+ }
144
+ function createEmptyTransferState() {
145
+ return {
146
+ data: null,
147
+ originalData: null,
148
+ isDirty: !1,
149
+ isLoading: !1,
150
+ error: null
151
+ };
152
+ }
153
+ var DataStore = class {
154
+ state = {
155
+ transfers: /* @__PURE__ */ new Map(),
156
+ version: 0
157
+ };
158
+ subscribers = /* @__PURE__ */ new Map();
159
+ selectorCache = /* @__PURE__ */ new Map();
160
+ subscribe(e, x) {
161
+ return this.subscribers.has(e) || (this.subscribers.set(e, /* @__PURE__ */ new Set()), this.selectorCache.set(e, e(this.state))), this.subscribers.get(e).add(x), () => {
162
+ let S = this.subscribers.get(e);
163
+ S && (S.delete(x), S.size === 0 && (this.subscribers.delete(e), this.selectorCache.delete(e)));
164
+ };
165
+ }
166
+ getSnapshot(e) {
167
+ return e(this.state);
168
+ }
169
+ getState() {
170
+ return this.state;
171
+ }
172
+ getTransfer(e) {
173
+ return this.state.transfers.get(e);
174
+ }
175
+ setTransferData(e, x) {
176
+ this.updateState((S) => {
177
+ let C = S.get(e) || createEmptyTransferState();
178
+ S.set(e, {
179
+ ...C,
180
+ data: x,
181
+ originalData: x,
182
+ isDirty: !1,
183
+ isLoading: !1,
184
+ error: null
185
+ });
186
+ });
187
+ }
188
+ updateTransferField(e, x, S) {
189
+ this.updateState((C) => {
190
+ let w = C.get(e);
191
+ if (w?.data) {
192
+ let T = {
193
+ ...w.data,
194
+ [x]: S
195
+ }, E = !deepEqual(T, w.originalData);
196
+ C.set(e, {
197
+ ...w,
198
+ data: T,
199
+ isDirty: E
200
+ });
201
+ } else {
202
+ let T = { [x]: S };
203
+ C.set(e, {
204
+ ...w || createEmptyTransferState(),
205
+ data: T,
206
+ originalData: null,
207
+ isDirty: !0,
208
+ isLoading: !1
209
+ });
210
+ }
211
+ });
212
+ }
213
+ setTransferLoading(e, x) {
214
+ this.updateState((S) => {
215
+ let C = S.get(e) || createEmptyTransferState();
216
+ S.set(e, {
217
+ ...C,
218
+ isLoading: x
219
+ });
220
+ });
221
+ }
222
+ setTransferError(e, x) {
223
+ this.updateState((S) => {
224
+ let C = S.get(e) || createEmptyTransferState();
225
+ S.set(e, {
226
+ ...C,
227
+ error: x,
228
+ isLoading: !1
229
+ });
230
+ });
231
+ }
232
+ resetTransfer(e) {
233
+ this.updateState((x) => {
234
+ let S = x.get(e);
235
+ S && x.set(e, {
236
+ ...S,
237
+ data: S.originalData,
238
+ isDirty: !1
239
+ });
240
+ });
241
+ }
242
+ clearTransfer(e) {
243
+ this.updateState((x) => {
244
+ x.delete(e);
245
+ });
246
+ }
247
+ clearAll() {
248
+ this.updateState((e) => {
249
+ e.clear();
250
+ });
251
+ }
252
+ updateTransferFields(e, x) {
253
+ this.updateState((S) => {
254
+ let C = S.get(e);
255
+ if (C?.data) {
256
+ let w = {
257
+ ...C.data,
258
+ ...x
259
+ }, T = !deepEqual(w, C.originalData);
260
+ S.set(e, {
261
+ ...C,
262
+ data: w,
263
+ isDirty: T
264
+ });
265
+ }
266
+ });
267
+ }
268
+ updateState(e) {
269
+ let x = this.state, S = new Map(this.state.transfers);
270
+ e(S), this.state = {
271
+ transfers: S,
272
+ version: this.state.version + 1
273
+ }, this.state !== x && this.notifySubscribers();
274
+ }
275
+ notifySubscribers() {
276
+ for (let [e, x] of this.subscribers) {
277
+ let S = this.selectorCache.get(e), C = e(this.state);
278
+ if (S !== C) {
279
+ this.selectorCache.set(e, C);
280
+ for (let e of x) e();
281
+ }
282
+ }
283
+ }
284
+ };
285
+ function selectTransfer(e) {
286
+ return (x) => x.transfers.get(e);
287
+ }
288
+ function selectTransferField(e, x) {
289
+ return (S) => S.transfers.get(e)?.data?.[x];
290
+ }
291
+ function selectTransferLoading(e) {
292
+ return (x) => x.transfers.get(e)?.isLoading ?? !1;
293
+ }
294
+ function selectTransferError(e) {
295
+ return (x) => x.transfers.get(e)?.error ?? null;
296
+ }
297
+ function selectTransferDirty(e) {
298
+ return (x) => x.transfers.get(e)?.isDirty ?? !1;
299
+ }
300
+ function selectTransferIds(e) {
301
+ return Array.from(e.transfers.keys());
302
+ }
303
+ function selectVersion(e) {
304
+ return e.version;
305
+ }
306
+ var DataContext = createContext(null);
307
+ function useDataStore() {
308
+ let e = useContext(DataContext);
309
+ if (!e) throw Error("useDataStore must be used within DataProvider");
310
+ return e;
311
+ }
312
+ function useDataStoreOptional() {
313
+ return useContext(DataContext);
314
+ }
315
+ function DataProvider({ children: e, store: x }) {
316
+ let [S] = useState(() => x ?? new DataStore());
317
+ return /* @__PURE__ */ jsx(DataContext.Provider, {
318
+ value: S,
319
+ children: e
320
+ });
321
+ }
322
+ var ValidationContext = createContext(null);
323
+ function useValidationContext() {
324
+ let e = useContext(ValidationContext);
325
+ if (!e) throw Error("useValidationContext must be used within ValidationProvider");
326
+ return e;
327
+ }
328
+ function useValidationContextOptional() {
329
+ return useContext(ValidationContext);
330
+ }
331
+ function ValidationProvider({ children: e }) {
332
+ let [S, C] = useState({
333
+ errors: /* @__PURE__ */ new Map(),
334
+ touched: /* @__PURE__ */ new Set()
335
+ }), w = {
336
+ getError: useCallback((e) => S.errors.get(e) || null, [S.errors]),
337
+ setError: useCallback((e, x) => {
338
+ C((S) => {
339
+ let C = new Map(S.errors);
340
+ return x ? C.set(e, x) : C.delete(e), {
341
+ ...S,
342
+ errors: C
343
+ };
344
+ });
345
+ }, []),
346
+ setErrors: useCallback((e) => {
347
+ C((x) => {
348
+ let S = new Map(x.errors);
349
+ for (let [x, C] of Object.entries(e)) C ? S.set(x, C) : S.delete(x);
350
+ return {
351
+ ...x,
352
+ errors: S
353
+ };
354
+ });
355
+ }, []),
356
+ touch: useCallback((e) => {
357
+ C((x) => {
358
+ let S = new Set(x.touched);
359
+ return S.add(e), {
360
+ ...x,
361
+ touched: S
362
+ };
363
+ });
364
+ }, []),
365
+ isTouched: useCallback((e) => S.touched.has(e), [S.touched]),
366
+ clearErrors: useCallback(() => {
367
+ C({
368
+ errors: /* @__PURE__ */ new Map(),
369
+ touched: /* @__PURE__ */ new Set()
370
+ });
371
+ }, []),
372
+ clearError: useCallback((e) => {
373
+ C((x) => {
374
+ let S = new Map(x.errors);
375
+ return S.delete(e), {
376
+ ...x,
377
+ errors: S
378
+ };
379
+ });
380
+ }, []),
381
+ validateAll: useCallback(() => S.errors.size === 0, [S.errors]),
382
+ getAllErrors: useCallback(() => new Map(S.errors), [S.errors]),
383
+ isValid: S.errors.size === 0
384
+ };
385
+ return /* @__PURE__ */ jsx(ValidationContext.Provider, {
386
+ value: w,
387
+ children: e
388
+ });
389
+ }
390
+ var PageContext = createContext(null);
391
+ function usePageContext() {
392
+ let e = useContext(PageContext);
393
+ if (!e) throw Error("usePageContext must be used within PageProvider");
394
+ return e;
395
+ }
396
+ function usePageContextOptional() {
397
+ return useContext(PageContext);
398
+ }
399
+ function PageProvider({ children: e, pageDefinition: x, transferId: S = null, params: C = {}, isDialog: w = !1 }) {
400
+ return /* @__PURE__ */ jsx(PageContext.Provider, {
401
+ value: {
402
+ pageDefinition: x,
403
+ transferId: S,
404
+ params: C,
405
+ isDialog: w
406
+ },
407
+ children: e
408
+ });
409
+ }
410
+ var RuntimeConfigContext = createContext(null);
411
+ function RuntimeConfigProvider({ config: e = {}, children: x }) {
412
+ return /* @__PURE__ */ jsx(RuntimeConfigContext.Provider, {
413
+ value: { config: e },
414
+ children: x
415
+ });
416
+ }
417
+ function useRuntimeConfig() {
418
+ let e = useContext(RuntimeConfigContext);
419
+ if (!e) throw Error("useRuntimeConfig must be used within RuntimeConfigProvider");
420
+ return e;
421
+ }
422
+ function useRuntimeConfigOptional() {
423
+ return useContext(RuntimeConfigContext);
424
+ }
425
+ var DispatchContext = createContext(null);
426
+ function useDispatch() {
427
+ let e = useContext(DispatchContext);
428
+ if (!e) throw Error("useDispatch must be used within DispatchProvider");
429
+ return e;
430
+ }
431
+ function useDispatchOptional() {
432
+ return useContext(DispatchContext);
433
+ }
434
+ function DispatchProvider({ children: e, dispatch: x }) {
435
+ return /* @__PURE__ */ jsx(DispatchContext.Provider, {
436
+ value: { dispatch: x },
437
+ children: e
438
+ });
439
+ }
440
+ var CustomizationsContext = createContext(null);
441
+ function useCustomizations() {
442
+ let e = useContext(CustomizationsContext);
443
+ if (!e) throw Error("useCustomizations must be used within CustomizationsProvider");
444
+ return e;
445
+ }
446
+ function useCustomizationsOptional() {
447
+ return useContext(CustomizationsContext);
448
+ }
449
+ function useComponentOverride(e) {
450
+ let x = useCustomizationsOptional();
451
+ if (!x) return null;
452
+ let S = e["xmi:id"];
453
+ return S ? x.getComponent(S) ?? null : null;
454
+ }
455
+ function useComponentInterceptor(e) {
456
+ let x = useCustomizationsOptional(), S = usePageContextOptional();
457
+ if (!x || !S) return null;
458
+ let C = e["@type"];
459
+ if (!C) return null;
460
+ let w = x.getComponentInterceptor(C);
461
+ return w ? w(e, S.pageDefinition) ?? null : null;
462
+ }
463
+ function useSubThemeProvider(e) {
464
+ let x = useCustomizationsOptional();
465
+ if (!x) return null;
466
+ let S = e.subTheme;
467
+ return S ? x.getSubThemeProvider(S) ?? null : null;
468
+ }
469
+ function usePageActionOverrides(e, x) {
470
+ let S = useCustomizationsOptional(), C = usePageContextOptional(), w = e ?? C?.pageDefinition;
471
+ if (!S || !w || !x) return null;
472
+ let T = w["xmi:id"];
473
+ return !T || !S.getPageCustomization(T)?.actions || x["xmi:id"], null;
474
+ }
475
+ function useVisualPropertyOverrides(e) {
476
+ let x = useContext(VisualPropertiesContext);
477
+ if (!x) return null;
478
+ let C = e["xmi:id"];
479
+ return C ? x[C] ?? null : null;
480
+ }
481
+ function useTypeaheadProvider(e) {
482
+ let x = useCustomizationsOptional(), S = usePageContextOptional();
483
+ if (!x || !S || !e) return;
484
+ let C = S.pageDefinition?.["xmi:id"];
485
+ if (C) return x.getPageCustomization(C)?.typeaheadProviders?.[e];
486
+ }
487
+ function useTableRowHighlighting(e) {
488
+ let x = useCustomizationsOptional(), S = usePageContextOptional();
489
+ if (!x || !S || !e) return;
490
+ let C = S.pageDefinition?.["xmi:id"];
491
+ if (C) return x.getPageCustomization(C)?.tableRowHighlighting?.[e];
492
+ }
493
+ function useEnumOptionFilter(e) {
494
+ let S = useCustomizationsOptional(), C = usePageContextOptional(), T = useDataStoreOptional(), E = S && C && e ? C.pageDefinition?.["xmi:id"] : void 0, O = E ? S?.getPageCustomization(E)?.enumOptionFilter?.[e] : void 0, k = C?.transferId ?? "", A = !!O, j = useCallback((e) => {
495
+ if (A) return e.transfers.get(k)?.data ?? void 0;
496
+ }, [k, A]), M = useCallback((e) => T ? T.subscribe(j, e) : () => {}, [T, j]), N = useCallback(() => T ? T.getSnapshot(j) : void 0, [T, j]), P = useSyncExternalStore(M, N, N);
497
+ return useMemo(() => {
498
+ if (O) return (e) => O(P, e);
499
+ }, [O, P]);
500
+ }
501
+ function useDateValidationProps(e) {
502
+ let S = useCustomizationsOptional(), C = usePageContextOptional(), T = useDataStoreOptional(), E = S && C && e ? C.pageDefinition?.["xmi:id"] : void 0, O = E ? S?.getPageCustomization(E)?.dateValidationProps?.[e] : void 0, k = C?.transferId ?? "", A = !!O, j = useCallback((e) => {
503
+ if (A) return e.transfers.get(k)?.data ?? void 0;
504
+ }, [k, A]), M = useCallback((e) => T ? T.subscribe(j, e) : () => {}, [T, j]), N = useCallback(() => T ? T.getSnapshot(j) : void 0, [T, j]), P = useSyncExternalStore(M, N, N);
505
+ return useMemo(() => {
506
+ if (O) return O(P);
507
+ }, [O, P]);
508
+ }
509
+ function useColumnCustomizers() {
510
+ let e = useCustomizationsOptional(), x = usePageContextOptional();
511
+ if (!e || !x) return;
512
+ let S = x.pageDefinition?.["xmi:id"];
513
+ if (S) return e.getPageCustomization(S)?.columnCustomizers;
514
+ }
515
+ function useItemContainerConfig(e) {
516
+ let x = useCustomizationsOptional(), S = usePageContextOptional();
517
+ if (!x || !S || !e) return;
518
+ let C = S.pageDefinition?.["xmi:id"];
519
+ if (C) return x.getPageCustomization(C)?.itemContainerConfigs?.[e];
520
+ }
521
+ var PageActionOverridesContext = createContext(null);
522
+ function useResolvedPageActionOverrides() {
523
+ return useContext(PageActionOverridesContext);
524
+ }
525
+ function useActionLifecycleOverrides(e) {
526
+ let x = useContext(PageActionOverridesContext);
527
+ return !x || !e ? null : x[e] ?? null;
528
+ }
529
+ function PageActionOverridesProvider({ children: e }) {
530
+ let x = useCustomizationsOptional(), S = usePageContextOptional()?.pageDefinition?.["xmi:id"], C = S ? x?.getPageCustomization(S)?.actions : void 0, w = C ? C() : null;
531
+ return /* @__PURE__ */ jsx(PageActionOverridesContext.Provider, {
532
+ value: w,
533
+ children: e
534
+ });
535
+ }
536
+ var VisualPropertiesContext = createContext(null);
537
+ function VisualPropertiesProvider({ children: e }) {
538
+ let x = useCustomizationsOptional(), S = usePageContextOptional()?.pageDefinition?.["xmi:id"], C = S ? x?.getPageCustomization(S)?.visualProperties : void 0, w = C ? C() : null;
539
+ return /* @__PURE__ */ jsx(VisualPropertiesContext.Provider, {
540
+ value: w,
541
+ children: e
542
+ });
543
+ }
544
+ function CustomizationsProvider({ children: e, customizations: x }) {
545
+ let S = useRef(x ?? null), [D, k] = useState(0);
546
+ useEffect(() => {
547
+ S.current = x ?? null, k((e) => e + 1);
548
+ }, [x]);
549
+ let A = useMemo(() => ({
550
+ version: D,
551
+ getPageCustomization: (e) => S.current?.pages?.[e],
552
+ getComponent: (e) => S.current?.components?.[e],
553
+ getComponentInterceptor: (e) => S.current?.componentInterceptors?.[e],
554
+ getSubThemeProvider: (e) => S.current?.subThemeProviders?.[e],
555
+ getRedirectHandler: () => S.current?.redirectHandler,
556
+ getCustomRoutes: () => S.current?.customRoutes,
557
+ getMenuCustomizer: () => S.current?.menuCustomizer,
558
+ getFooterText: () => S.current?.footerText,
559
+ getHeroComponent: () => S.current?.heroComponent,
560
+ getSettingsPage: () => S.current?.settingsPage,
561
+ getGuestComponent: () => S.current?.guestComponent
562
+ }), [D]);
563
+ return /* @__PURE__ */ jsx(CustomizationsContext.Provider, {
564
+ value: A,
565
+ children: e
566
+ });
567
+ }
568
+ var SelectorSelectionContext = createContext(null);
569
+ function useSelectorSelection() {
570
+ let e = useContext(SelectorSelectionContext);
571
+ if (!e) throw Error("useSelectorSelection must be used within SelectorSelectionProvider");
572
+ return e;
573
+ }
574
+ function useSelectorSelectionOptional() {
575
+ return useContext(SelectorSelectionContext);
576
+ }
577
+ function SelectorSelectionProvider({ children: e, ownerTransfer: x }) {
578
+ let S = {
579
+ selectedTransfersRef: useRef([]),
580
+ ownerTransfer: x
581
+ };
582
+ return /* @__PURE__ */ jsx(SelectorSelectionContext.Provider, {
583
+ value: S,
584
+ children: e
585
+ });
586
+ }
587
+ var MuiProContext = createContext(null);
588
+ function MuiProProvider({ isProEnabled: e, components: S = {}, children: C }) {
589
+ let T = useCallback((x) => e ? S[x] ?? null : null, [e, S]), E = useMemo(() => ({
590
+ isProEnabled: e,
591
+ getComponent: T
592
+ }), [e, T]);
593
+ return /* @__PURE__ */ jsx(MuiProContext.Provider, {
594
+ value: E,
595
+ children: C
596
+ });
597
+ }
598
+ function useMuiPro() {
599
+ let e = useContext(MuiProContext);
600
+ if (!e) throw Error("useMuiPro must be used within MuiProProvider");
601
+ return e;
602
+ }
603
+ function useMuiProOptional() {
604
+ return useContext(MuiProContext);
605
+ }
606
+ var RefreshSignalContext = createContext(0);
607
+ function useRefreshSignal() {
608
+ return useContext(RefreshSignalContext);
609
+ }
610
+ function RefreshSignalProvider({ children: e, signal: x }) {
611
+ return /* @__PURE__ */ jsx(RefreshSignalContext.Provider, {
612
+ value: x,
613
+ children: e
614
+ });
615
+ }
616
+ function getFieldId(e) {
617
+ return e.name ? e.name : e.sourceId || e["xmi:id"];
618
+ }
619
+ function useValidation(e) {
620
+ let x = useValidationContextOptional(), S = getFieldId(e);
621
+ if (!x) return {
622
+ error: null,
623
+ isTouched: !1,
624
+ touch: () => {},
625
+ setError: () => {},
626
+ clearError: () => {}
627
+ };
628
+ let C = x.isTouched(S);
629
+ return {
630
+ error: C ? x.getError(S) : null,
631
+ isTouched: C,
632
+ touch: () => x.touch(S),
633
+ setError: (e) => x.setError(S, e),
634
+ clearError: () => x.clearError(S)
635
+ };
636
+ }
637
+ function useFormValidation() {
638
+ return useValidationContext();
639
+ }
640
+ function isInput(e) {
641
+ return "attributeType" in e;
642
+ }
643
+ function useVisualBinding(e, S) {
644
+ let C = useDataStore(), w = usePageContext().transferId ?? "", E = S ?? (isInput(e) ? e.attributeType : void 0), O = E?.name, k = e.hiddenBy?.name, A = e.enabledBy?.name, j = e.requiredBy?.name, M = useRef({
645
+ value: void 0,
646
+ isDirty: !1,
647
+ isLoading: !1,
648
+ hiddenByValue: void 0,
649
+ enabledByValue: void 0,
650
+ requiredByValue: void 0
651
+ }), N = useCallback((e) => {
652
+ let x = e.transfers.get(w), S = x?.data, C;
653
+ return C = !O && !k && !A && !j ? {
654
+ value: void 0,
655
+ isDirty: !1,
656
+ isLoading: x?.isLoading ?? !1,
657
+ hiddenByValue: void 0,
658
+ enabledByValue: void 0,
659
+ requiredByValue: void 0
660
+ } : S ? {
661
+ value: O ? S[O] : void 0,
662
+ isDirty: x.isDirty,
663
+ isLoading: x.isLoading,
664
+ hiddenByValue: k ? S[k] : void 0,
665
+ enabledByValue: A ? S[A] : void 0,
666
+ requiredByValue: j ? S[j] : void 0
667
+ } : {
668
+ value: void 0,
669
+ isDirty: !1,
670
+ isLoading: x?.isLoading ?? !1,
671
+ hiddenByValue: void 0,
672
+ enabledByValue: void 0,
673
+ requiredByValue: void 0
674
+ }, deepEqual(M.current, C) ? M.current : (M.current = C, C);
675
+ }, [
676
+ w,
677
+ O,
678
+ k,
679
+ A,
680
+ j
681
+ ]), P = useCallback((e) => C.subscribe(N, e), [C, N]), F = useCallback(() => C.getSnapshot(N), [C, N]), { value: I, isDirty: L, isLoading: z, hiddenByValue: B, enabledByValue: V, requiredByValue: H } = useSyncExternalStore(P, F, F), U = useCallback((e) => {
682
+ O && C.updateTransferField(w, O, e);
683
+ }, [
684
+ C,
685
+ w,
686
+ O
687
+ ]), { error: W } = useValidation(e), G = (e, x) => typeof e == "boolean" ? e : e === "true" ? !0 : e === "false" ? !1 : x, K = G(e.disabled, !1), q = isInput(e) ? G(e.required, !1) || G(E?.isRequired, !1) : !1, J = e.label ?? E?.name ?? "", Y = e.readOnly, X = E?.isReadOnly, Z = G(Y ?? X, !1), Q = G(e.hidden, !1);
688
+ k && G(B, !1) && (Q = !0), A && (K = !G(V, !1)), j && G(H, !1) && (q = !0);
689
+ let $ = useVisualPropertyOverrides(e);
690
+ return {
691
+ value: I,
692
+ onChange: U,
693
+ error: W,
694
+ hidden: $?.hidden ?? Q,
695
+ disabled: $?.disabled ?? K,
696
+ required: $?.required ?? q,
697
+ label: $?.label ?? J,
698
+ readOnly: $?.readOnly ?? Z,
699
+ isLoading: z,
700
+ isDirty: L
701
+ };
702
+ }
703
+ function useDataSelector(e) {
704
+ let S = useDataStore(), C = useCallback((x) => S.subscribe(e, x), [S, e]), w = useCallback(() => S.getSnapshot(e), [S, e]);
705
+ return useSyncExternalStore(C, w, w);
706
+ }
707
+ function useTransferState(e) {
708
+ return useDataSelector(useCallback((x) => x.transfers.get(e), [e]));
709
+ }
710
+ function useTransferField(e, S) {
711
+ return useDataSelector(useCallback((x) => x.transfers.get(e)?.data?.[S], [e, S]));
712
+ }
713
+ function useTransferLoading(e) {
714
+ return useDataSelector(useCallback((x) => x.transfers.get(e)?.isLoading ?? !1, [e]));
715
+ }
716
+ function useTransferDirty(e) {
717
+ return useDataSelector(useCallback((x) => x.transfers.get(e)?.isDirty ?? !1, [e]));
718
+ }
719
+ function useEditMode() {
720
+ let e = usePageContextOptional()?.transferId ?? null, x = useTransferDirty(e ?? "");
721
+ return {
722
+ isEditMode: e !== null && x,
723
+ transferId: e
724
+ };
725
+ }
726
+ function getVisualElement(e, x) {
727
+ return e.resolveVisualElement(x);
728
+ }
729
+ var EMPTY_SNAPSHOT$1 = { hiddenByValue: void 0 };
730
+ function useElementVisibility(e) {
731
+ let S = useDataStoreOptional(), C = usePageContextOptional()?.transferId ?? "", w = e.hiddenBy?.name, E = useRef({ hiddenByValue: void 0 }), O = useCallback((e) => {
732
+ if (!w) return E.current;
733
+ let x = e.transfers.get(C)?.data, S = { hiddenByValue: x ? x[w] : void 0 };
734
+ return deepEqual(E.current, S) ? E.current : (E.current = S, S);
735
+ }, [C, w]), k = useCallback((e) => S ? S.subscribe(O, e) : () => {}, [S, O]), A = useCallback(() => S ? S.getSnapshot(O) : EMPTY_SNAPSHOT$1, [S, O]), { hiddenByValue: j } = useSyncExternalStore(k, A, A), M = (e, x) => typeof e == "boolean" ? e : e === "true" ? !0 : e === "false" ? !1 : x, N = M(e.hidden, !1);
736
+ w && M(j, !1) && (N = !0);
737
+ let P = useVisualPropertyOverrides(e);
738
+ return P?.hidden == null ? N : P.hidden;
739
+ }
740
+ var EMPTY_SNAPSHOT = { enabledByValue: void 0 };
741
+ function useElementDisabled(e) {
742
+ let S = useDataStoreOptional(), C = usePageContextOptional()?.transferId ?? "", w = e.enabledBy?.name, E = useRef({ enabledByValue: void 0 }), O = useCallback((e) => {
743
+ if (!w) return E.current;
744
+ let x = e.transfers.get(C)?.data, S = { enabledByValue: x ? x[w] : void 0 };
745
+ return deepEqual(E.current, S) ? E.current : (E.current = S, S);
746
+ }, [C, w]), k = useCallback((e) => S ? S.subscribe(O, e) : () => {}, [S, O]), A = useCallback(() => S ? S.getSnapshot(O) : EMPTY_SNAPSHOT, [S, O]), { enabledByValue: j } = useSyncExternalStore(k, A, A), M = (e, x) => typeof e == "boolean" ? e : e === "true" ? !0 : e === "false" ? !1 : x, N = M(e.disabled, !1);
747
+ w && (N = !M(j, !1));
748
+ let P = useVisualPropertyOverrides(e);
749
+ return P?.disabled == null ? N : P.disabled;
750
+ }
751
+ const DEFAULT_DEBOUNCE_MS = 300;
752
+ function useDebouncedCallback(e, S = 300) {
753
+ let w = useRef(null), E = useRef(e);
754
+ E.current = e;
755
+ let D = useCallback(() => {
756
+ w.current !== null && (clearTimeout(w.current), w.current = null);
757
+ }, []), O = useCallback((...e) => {
758
+ D(), w.current = setTimeout(() => {
759
+ w.current = null, E.current(...e);
760
+ }, S);
761
+ }, [S, D]);
762
+ return useEffect(() => D, [D]), Object.assign(O, { cancel: D });
763
+ }
764
+ export { ApplicationProvider, CustomizationsProvider, DEFAULT_DEBOUNCE_MS, DataProvider, DataStore, DispatchProvider, MuiProProvider, NavigationProvider, PageActionOverridesProvider, PageProvider, RefreshSignalProvider, RuntimeConfigProvider, SelectorSelectionProvider, ValidationProvider, VisualPropertiesProvider, createEmptyTransferState, deepEqual, getVisualElement, selectTransfer, selectTransferDirty, selectTransferError, selectTransferField, selectTransferIds, selectTransferLoading, selectVersion, useActionLifecycleOverrides, useApplication, useApplicationOptional, useColumnCustomizers, useComponentInterceptor, useComponentOverride, useCustomizations, useCustomizationsOptional, useDataSelector, useDataStore, useDataStoreOptional, useDateValidationProps, useDebouncedCallback, useDispatch, useDispatchOptional, useEditMode, useElementDisabled, useElementVisibility, useEnumOptionFilter, useFormValidation, useItemContainerConfig, useMuiPro, useMuiProOptional, useNavigation, useNavigationOptional, usePageActionOverrides, usePageContext, usePageContextOptional, useRefreshSignal, useResolvedPageActionOverrides, useRuntimeConfig, useRuntimeConfigOptional, useSelectorSelection, useSelectorSelectionOptional, useSubThemeProvider, useTableRowHighlighting, useTransferDirty, useTransferField, useTransferLoading, useTransferState, useTypeaheadProvider, useValidation, useValidationContext, useValidationContextOptional, useVisualBinding, useVisualPropertyOverrides };