@almadar/ui 4.7.0 → 4.9.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.
- package/dist/avl/index.cjs +1342 -1287
- package/dist/avl/index.js +249 -194
- package/dist/components/index.cjs +35 -12
- package/dist/components/index.js +37 -14
- package/dist/components/molecules/DataGrid.d.ts +1 -3
- package/dist/components/molecules/DataList.d.ts +1 -3
- package/dist/components/organisms/game/three/index.cjs +17 -1
- package/dist/components/organisms/game/three/index.js +18 -2
- package/dist/docs/index.cjs +54 -34
- package/dist/docs/index.js +32 -12
- package/dist/hooks/index.cjs +17 -1
- package/dist/hooks/index.js +18 -2
- package/dist/marketing/index.cjs +66 -46
- package/dist/marketing/index.js +37 -17
- package/dist/providers/TraitScopeProvider.d.ts +43 -0
- package/dist/providers/index.cjs +49 -12
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +50 -15
- package/dist/runtime/EntitySchemaContext.d.ts +16 -1
- package/dist/runtime/index.cjs +63 -28
- package/dist/runtime/index.js +65 -30
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TraitScopeProvider
|
|
3
|
+
*
|
|
4
|
+
* Wraps a trait's rendered subtree with its owning `{ orbital, trait }`
|
|
5
|
+
* pair. Pure components inside the subtree (Button, Form, etc.) keep
|
|
6
|
+
* calling `useEventBus().emit('UI:X', ...)` exactly as today; the
|
|
7
|
+
* scoped wrapper that `useEventBus` returns inside this provider
|
|
8
|
+
* rewrites bare `UI:X` keys into the qualified
|
|
9
|
+
* `UI:Orbital.Trait.X` form that `useTraitStateMachine` (and the rest
|
|
10
|
+
* of the post-Phase 4 subscriber side) listens on.
|
|
11
|
+
*
|
|
12
|
+
* Producer-side fix for the gap where Button-emitted bare keys never
|
|
13
|
+
* reached the trait state machine in the runtime path. The compiled
|
|
14
|
+
* path's codegen wraps each trait view with the same provider so both
|
|
15
|
+
* paths share the qualification contract.
|
|
16
|
+
*
|
|
17
|
+
* @packageDocumentation
|
|
18
|
+
*/
|
|
19
|
+
import React from 'react';
|
|
20
|
+
export interface TraitScope {
|
|
21
|
+
/** Owning orbital name (e.g. `"ContactOrbital"`). */
|
|
22
|
+
orbital: string;
|
|
23
|
+
/** Trait name within the orbital (e.g. `"ContactBrowse"`). */
|
|
24
|
+
trait: string;
|
|
25
|
+
}
|
|
26
|
+
export interface TraitScopeProviderProps {
|
|
27
|
+
orbital: string;
|
|
28
|
+
trait: string;
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Wrap a trait's rendered subtree to qualify bare `UI:*` emits with the
|
|
33
|
+
* trait's scope. Mount this at the slot-content boundary in runtime
|
|
34
|
+
* mode (UISlotRenderer) and at each generated trait view's outermost
|
|
35
|
+
* element in compiled mode (orbital-shell-typescript codegen).
|
|
36
|
+
*/
|
|
37
|
+
export declare function TraitScopeProvider({ orbital, trait, children, }: TraitScopeProviderProps): React.ReactElement;
|
|
38
|
+
/**
|
|
39
|
+
* Read the current trait scope. Returns `null` when called outside
|
|
40
|
+
* any `TraitScopeProvider` (e.g. Storybook, design-system catalog).
|
|
41
|
+
*/
|
|
42
|
+
export declare function useTraitScope(): TraitScope | null;
|
|
43
|
+
export default TraitScopeProvider;
|
package/dist/providers/index.cjs
CHANGED
|
@@ -436,7 +436,23 @@ function getGlobalEventBus() {
|
|
|
436
436
|
}
|
|
437
437
|
function useEventBus() {
|
|
438
438
|
const context = React116.useContext(providers.EventBusContext);
|
|
439
|
-
|
|
439
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
440
|
+
const scope = providers.useTraitScope();
|
|
441
|
+
return React116.useMemo(() => {
|
|
442
|
+
if (!scope) return baseBus;
|
|
443
|
+
return {
|
|
444
|
+
...baseBus,
|
|
445
|
+
emit: (type, payload, source) => {
|
|
446
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
447
|
+
const tail = type.slice(3);
|
|
448
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
449
|
+
baseBus.emit(qualified, payload, source);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
baseBus.emit(type, payload, source);
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
}, [baseBus, scope]);
|
|
440
456
|
}
|
|
441
457
|
function useEventListener(event, handler) {
|
|
442
458
|
const eventBus = useEventBus();
|
|
@@ -18651,8 +18667,7 @@ function formatValue(value, format) {
|
|
|
18651
18667
|
}
|
|
18652
18668
|
function DataGrid({
|
|
18653
18669
|
entity,
|
|
18654
|
-
fields
|
|
18655
|
-
columns: columnsProp,
|
|
18670
|
+
fields,
|
|
18656
18671
|
itemActions,
|
|
18657
18672
|
cols,
|
|
18658
18673
|
gap = "md",
|
|
@@ -18673,7 +18688,6 @@ function DataGrid({
|
|
|
18673
18688
|
const { t } = useTranslate();
|
|
18674
18689
|
const [selectedIds, setSelectedIds] = React116.useState(/* @__PURE__ */ new Set());
|
|
18675
18690
|
const [visibleCount, setVisibleCount] = React116.useState(pageSize || Infinity);
|
|
18676
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
18677
18691
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
18678
18692
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
18679
18693
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -19016,8 +19030,7 @@ function groupData(items, field) {
|
|
|
19016
19030
|
}
|
|
19017
19031
|
function DataList({
|
|
19018
19032
|
entity,
|
|
19019
|
-
fields
|
|
19020
|
-
columns: columnsProp,
|
|
19033
|
+
fields,
|
|
19021
19034
|
itemActions,
|
|
19022
19035
|
gap = "none",
|
|
19023
19036
|
variant = "default",
|
|
@@ -19046,7 +19059,6 @@ function DataList({
|
|
|
19046
19059
|
const eventBus = useEventBus();
|
|
19047
19060
|
const { t } = useTranslate();
|
|
19048
19061
|
const [visibleCount, setVisibleCount] = React116__namespace.default.useState(pageSize || Infinity);
|
|
19049
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
19050
19062
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
19051
19063
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
19052
19064
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -37858,6 +37870,17 @@ function renderContainedPortal(slot, content, onDismiss) {
|
|
|
37858
37870
|
return /* @__PURE__ */ jsxRuntime.jsx(Box, { id: slotId, children: slotContent });
|
|
37859
37871
|
}
|
|
37860
37872
|
}
|
|
37873
|
+
function MaybeTraitScope({
|
|
37874
|
+
sourceTrait,
|
|
37875
|
+
children
|
|
37876
|
+
}) {
|
|
37877
|
+
const schemaCtx = useEntitySchemaOptional();
|
|
37878
|
+
const orbital = sourceTrait !== void 0 && schemaCtx !== null ? schemaCtx.orbitalsByTrait.get(sourceTrait) : void 0;
|
|
37879
|
+
if (sourceTrait !== void 0 && orbital !== void 0) {
|
|
37880
|
+
return /* @__PURE__ */ jsxRuntime.jsx(providers.TraitScopeProvider, { orbital, trait: sourceTrait, children });
|
|
37881
|
+
}
|
|
37882
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
37883
|
+
}
|
|
37861
37884
|
function UISlotComponent({
|
|
37862
37885
|
slot,
|
|
37863
37886
|
portal = false,
|
|
@@ -37885,11 +37908,11 @@ function UISlotComponent({
|
|
|
37885
37908
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37886
37909
|
"data-pattern": pattern,
|
|
37887
37910
|
"data-source-trait": sourceTrait,
|
|
37888
|
-
children
|
|
37911
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37889
37912
|
}
|
|
37890
37913
|
);
|
|
37891
37914
|
}
|
|
37892
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children });
|
|
37915
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait, children }) });
|
|
37893
37916
|
}
|
|
37894
37917
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
37895
37918
|
Box,
|
|
@@ -37898,7 +37921,7 @@ function UISlotComponent({
|
|
|
37898
37921
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37899
37922
|
"data-pattern": pattern,
|
|
37900
37923
|
"data-source-trait": sourceTrait,
|
|
37901
|
-
children
|
|
37924
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37902
37925
|
}
|
|
37903
37926
|
);
|
|
37904
37927
|
}
|
|
@@ -37944,7 +37967,7 @@ function UISlotComponent({
|
|
|
37944
37967
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37945
37968
|
"data-pattern": content.pattern,
|
|
37946
37969
|
"data-source-trait": content.sourceTrait,
|
|
37947
|
-
children: wrappedContent
|
|
37970
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: wrappedContent })
|
|
37948
37971
|
}
|
|
37949
37972
|
);
|
|
37950
37973
|
}
|
|
@@ -38052,7 +38075,7 @@ function SlotPortal({
|
|
|
38052
38075
|
});
|
|
38053
38076
|
if (!portalRoot) return null;
|
|
38054
38077
|
const slotId = `slot-${slot}`;
|
|
38055
|
-
const slotContent = /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content, onDismiss });
|
|
38078
|
+
const slotContent = /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content, onDismiss }) });
|
|
38056
38079
|
let wrapper;
|
|
38057
38080
|
switch (slot) {
|
|
38058
38081
|
case "modal":
|
|
@@ -38884,6 +38907,18 @@ function OrbitalProvider({
|
|
|
38884
38907
|
);
|
|
38885
38908
|
}
|
|
38886
38909
|
OrbitalProvider.displayName = "OrbitalProvider";
|
|
38910
|
+
var TraitScopeContext = React116.createContext(null);
|
|
38911
|
+
function TraitScopeProvider2({
|
|
38912
|
+
orbital,
|
|
38913
|
+
trait,
|
|
38914
|
+
children
|
|
38915
|
+
}) {
|
|
38916
|
+
const value = React116.useMemo(() => ({ orbital, trait }), [orbital, trait]);
|
|
38917
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TraitScopeContext.Provider, { value, children });
|
|
38918
|
+
}
|
|
38919
|
+
function useTraitScope2() {
|
|
38920
|
+
return React116.useContext(TraitScopeContext);
|
|
38921
|
+
}
|
|
38887
38922
|
|
|
38888
38923
|
// providers/OfflineModeProvider.tsx
|
|
38889
38924
|
init_offline_executor();
|
|
@@ -38923,8 +38958,10 @@ exports.OfflineModeProvider = OfflineModeProvider;
|
|
|
38923
38958
|
exports.OrbitalProvider = OrbitalProvider;
|
|
38924
38959
|
exports.SelectionContext = SelectionContext;
|
|
38925
38960
|
exports.SelectionProvider = SelectionProvider;
|
|
38961
|
+
exports.TraitScopeProvider = TraitScopeProvider2;
|
|
38926
38962
|
exports.VerificationProvider = VerificationProvider;
|
|
38927
38963
|
exports.useOfflineMode = useOfflineMode;
|
|
38928
38964
|
exports.useOptionalOfflineMode = useOptionalOfflineMode;
|
|
38929
38965
|
exports.useSelection = useSelection;
|
|
38930
38966
|
exports.useSelectionOptional = useSelectionOptional;
|
|
38967
|
+
exports.useTraitScope = useTraitScope2;
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
export { OrbitalProvider, type OrbitalProviderProps } from './OrbitalProvider';
|
|
8
8
|
export type { ThemeDefinition } from '../context/ThemeContext';
|
|
9
9
|
export { EventBusProvider, EventBusContext } from './EventBusProvider';
|
|
10
|
+
export { TraitScopeProvider, useTraitScope } from './TraitScopeProvider';
|
|
11
|
+
export type { TraitScope, TraitScopeProviderProps } from './TraitScopeProvider';
|
|
10
12
|
export { SelectionProvider, SelectionContext, useSelection, useSelectionOptional } from './SelectionProvider';
|
|
11
13
|
export type { SelectionContextType } from './SelectionProvider';
|
|
12
14
|
export { VerificationProvider } from './VerificationProvider';
|
package/dist/providers/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React116 from 'react';
|
|
2
|
-
import React116__default, { createContext, useContext, useRef, useEffect, useCallback, Suspense, useState,
|
|
2
|
+
import React116__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, useLayoutEffect, lazy, useId } from 'react';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import { EventBusContext } from '@almadar/ui/providers';
|
|
4
|
+
import { EventBusContext, useTraitScope, TraitScopeProvider } from '@almadar/ui/providers';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
import * as LucideIcons from 'lucide-react';
|
|
@@ -391,7 +391,23 @@ function getGlobalEventBus() {
|
|
|
391
391
|
}
|
|
392
392
|
function useEventBus() {
|
|
393
393
|
const context = useContext(EventBusContext);
|
|
394
|
-
|
|
394
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
395
|
+
const scope = useTraitScope();
|
|
396
|
+
return useMemo(() => {
|
|
397
|
+
if (!scope) return baseBus;
|
|
398
|
+
return {
|
|
399
|
+
...baseBus,
|
|
400
|
+
emit: (type, payload, source) => {
|
|
401
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
402
|
+
const tail = type.slice(3);
|
|
403
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
404
|
+
baseBus.emit(qualified, payload, source);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
baseBus.emit(type, payload, source);
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
}, [baseBus, scope]);
|
|
395
411
|
}
|
|
396
412
|
function useEventListener(event, handler) {
|
|
397
413
|
const eventBus = useEventBus();
|
|
@@ -18606,8 +18622,7 @@ function formatValue(value, format) {
|
|
|
18606
18622
|
}
|
|
18607
18623
|
function DataGrid({
|
|
18608
18624
|
entity,
|
|
18609
|
-
fields
|
|
18610
|
-
columns: columnsProp,
|
|
18625
|
+
fields,
|
|
18611
18626
|
itemActions,
|
|
18612
18627
|
cols,
|
|
18613
18628
|
gap = "md",
|
|
@@ -18628,7 +18643,6 @@ function DataGrid({
|
|
|
18628
18643
|
const { t } = useTranslate();
|
|
18629
18644
|
const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
|
|
18630
18645
|
const [visibleCount, setVisibleCount] = useState(pageSize || Infinity);
|
|
18631
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
18632
18646
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
18633
18647
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
18634
18648
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -18971,8 +18985,7 @@ function groupData(items, field) {
|
|
|
18971
18985
|
}
|
|
18972
18986
|
function DataList({
|
|
18973
18987
|
entity,
|
|
18974
|
-
fields
|
|
18975
|
-
columns: columnsProp,
|
|
18988
|
+
fields,
|
|
18976
18989
|
itemActions,
|
|
18977
18990
|
gap = "none",
|
|
18978
18991
|
variant = "default",
|
|
@@ -19001,7 +19014,6 @@ function DataList({
|
|
|
19001
19014
|
const eventBus = useEventBus();
|
|
19002
19015
|
const { t } = useTranslate();
|
|
19003
19016
|
const [visibleCount, setVisibleCount] = React116__default.useState(pageSize || Infinity);
|
|
19004
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
19005
19017
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
19006
19018
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
19007
19019
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -37813,6 +37825,17 @@ function renderContainedPortal(slot, content, onDismiss) {
|
|
|
37813
37825
|
return /* @__PURE__ */ jsx(Box, { id: slotId, children: slotContent });
|
|
37814
37826
|
}
|
|
37815
37827
|
}
|
|
37828
|
+
function MaybeTraitScope({
|
|
37829
|
+
sourceTrait,
|
|
37830
|
+
children
|
|
37831
|
+
}) {
|
|
37832
|
+
const schemaCtx = useEntitySchemaOptional();
|
|
37833
|
+
const orbital = sourceTrait !== void 0 && schemaCtx !== null ? schemaCtx.orbitalsByTrait.get(sourceTrait) : void 0;
|
|
37834
|
+
if (sourceTrait !== void 0 && orbital !== void 0) {
|
|
37835
|
+
return /* @__PURE__ */ jsx(TraitScopeProvider, { orbital, trait: sourceTrait, children });
|
|
37836
|
+
}
|
|
37837
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
37838
|
+
}
|
|
37816
37839
|
function UISlotComponent({
|
|
37817
37840
|
slot,
|
|
37818
37841
|
portal = false,
|
|
@@ -37840,11 +37863,11 @@ function UISlotComponent({
|
|
|
37840
37863
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37841
37864
|
"data-pattern": pattern,
|
|
37842
37865
|
"data-source-trait": sourceTrait,
|
|
37843
|
-
children
|
|
37866
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37844
37867
|
}
|
|
37845
37868
|
);
|
|
37846
37869
|
}
|
|
37847
|
-
return /* @__PURE__ */ jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children });
|
|
37870
|
+
return /* @__PURE__ */ jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children }) });
|
|
37848
37871
|
}
|
|
37849
37872
|
return /* @__PURE__ */ jsx(
|
|
37850
37873
|
Box,
|
|
@@ -37853,7 +37876,7 @@ function UISlotComponent({
|
|
|
37853
37876
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37854
37877
|
"data-pattern": pattern,
|
|
37855
37878
|
"data-source-trait": sourceTrait,
|
|
37856
|
-
children
|
|
37879
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37857
37880
|
}
|
|
37858
37881
|
);
|
|
37859
37882
|
}
|
|
@@ -37899,7 +37922,7 @@ function UISlotComponent({
|
|
|
37899
37922
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37900
37923
|
"data-pattern": content.pattern,
|
|
37901
37924
|
"data-source-trait": content.sourceTrait,
|
|
37902
|
-
children: wrappedContent
|
|
37925
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: wrappedContent })
|
|
37903
37926
|
}
|
|
37904
37927
|
);
|
|
37905
37928
|
}
|
|
@@ -38007,7 +38030,7 @@ function SlotPortal({
|
|
|
38007
38030
|
});
|
|
38008
38031
|
if (!portalRoot) return null;
|
|
38009
38032
|
const slotId = `slot-${slot}`;
|
|
38010
|
-
const slotContent = /* @__PURE__ */ jsx(SlotContentRenderer, { content, onDismiss });
|
|
38033
|
+
const slotContent = /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: /* @__PURE__ */ jsx(SlotContentRenderer, { content, onDismiss }) });
|
|
38011
38034
|
let wrapper;
|
|
38012
38035
|
switch (slot) {
|
|
38013
38036
|
case "modal":
|
|
@@ -38839,6 +38862,18 @@ function OrbitalProvider({
|
|
|
38839
38862
|
);
|
|
38840
38863
|
}
|
|
38841
38864
|
OrbitalProvider.displayName = "OrbitalProvider";
|
|
38865
|
+
var TraitScopeContext = createContext(null);
|
|
38866
|
+
function TraitScopeProvider2({
|
|
38867
|
+
orbital,
|
|
38868
|
+
trait,
|
|
38869
|
+
children
|
|
38870
|
+
}) {
|
|
38871
|
+
const value = useMemo(() => ({ orbital, trait }), [orbital, trait]);
|
|
38872
|
+
return /* @__PURE__ */ jsx(TraitScopeContext.Provider, { value, children });
|
|
38873
|
+
}
|
|
38874
|
+
function useTraitScope2() {
|
|
38875
|
+
return useContext(TraitScopeContext);
|
|
38876
|
+
}
|
|
38842
38877
|
|
|
38843
38878
|
// providers/OfflineModeProvider.tsx
|
|
38844
38879
|
init_offline_executor();
|
|
@@ -38872,4 +38907,4 @@ function useOptionalOfflineMode() {
|
|
|
38872
38907
|
return useContext(OfflineModeContext);
|
|
38873
38908
|
}
|
|
38874
38909
|
|
|
38875
|
-
export { EventBusContext2 as EventBusContext, EventBusProvider, OfflineModeProvider, OrbitalProvider, SelectionContext, SelectionProvider, VerificationProvider, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional };
|
|
38910
|
+
export { EventBusContext2 as EventBusContext, EventBusProvider, OfflineModeProvider, OrbitalProvider, SelectionContext, SelectionProvider, TraitScopeProvider2 as TraitScopeProvider, VerificationProvider, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useTraitScope2 as useTraitScope };
|
|
@@ -29,6 +29,14 @@ export interface EntitySchemaContextValue {
|
|
|
29
29
|
* etc.) and an enum field renders as a plain text input. Closes VR3.
|
|
30
30
|
*/
|
|
31
31
|
traitLinkedEntities: ReadonlyMap<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Per-trait owning-orbital name. Same shape as `traitLinkedEntities`,
|
|
34
|
+
* built from `schema.orbitals[].traits[]`. UISlotRenderer uses this
|
|
35
|
+
* to wrap each slot's rendered subtree in `TraitScopeProvider` so
|
|
36
|
+
* descendant pure components (Button, etc.) emit qualified
|
|
37
|
+
* `UI:Orbital.Trait.EVENT` keys via the scoped useEventBus.
|
|
38
|
+
*/
|
|
39
|
+
orbitalsByTrait: ReadonlyMap<string, string>;
|
|
32
40
|
}
|
|
33
41
|
export interface EntitySchemaProviderProps {
|
|
34
42
|
/** Entity definitions from resolved schema */
|
|
@@ -40,6 +48,13 @@ export interface EntitySchemaProviderProps {
|
|
|
40
48
|
* legacy V1 string-entity-name lookup.
|
|
41
49
|
*/
|
|
42
50
|
traitLinkedEntities?: ReadonlyMap<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* Per-trait owning-orbital name. Required for the runtime path's
|
|
53
|
+
* trait-scoped event qualification (Button etc. emit qualified keys
|
|
54
|
+
* via TraitScopeProvider). Optional for back-compat with consumers
|
|
55
|
+
* that don't yet thread the orbital map through.
|
|
56
|
+
*/
|
|
57
|
+
orbitalsByTrait?: ReadonlyMap<string, string>;
|
|
43
58
|
/** Children */
|
|
44
59
|
children: React.ReactNode;
|
|
45
60
|
}
|
|
@@ -50,7 +65,7 @@ export interface EntitySchemaProviderProps {
|
|
|
50
65
|
* Actual entity rows arrive via `@payload.data` on the rendering trait's
|
|
51
66
|
* success transition — they do NOT live in this context.
|
|
52
67
|
*/
|
|
53
|
-
export declare function EntitySchemaProvider({ entities, traitLinkedEntities, children, }: EntitySchemaProviderProps): React.ReactElement;
|
|
68
|
+
export declare function EntitySchemaProvider({ entities, traitLinkedEntities, orbitalsByTrait, children, }: EntitySchemaProviderProps): React.ReactElement;
|
|
54
69
|
/**
|
|
55
70
|
* Access entity schema definitions.
|
|
56
71
|
* Use this for field metadata (form building, filter enrichment).
|
package/dist/runtime/index.cjs
CHANGED
|
@@ -183,7 +183,23 @@ function getGlobalEventBus() {
|
|
|
183
183
|
}
|
|
184
184
|
function useEventBus() {
|
|
185
185
|
const context = React115.useContext(providers.EventBusContext);
|
|
186
|
-
|
|
186
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
187
|
+
const scope = providers.useTraitScope();
|
|
188
|
+
return React115.useMemo(() => {
|
|
189
|
+
if (!scope) return baseBus;
|
|
190
|
+
return {
|
|
191
|
+
...baseBus,
|
|
192
|
+
emit: (type, payload, source) => {
|
|
193
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
194
|
+
const tail = type.slice(3);
|
|
195
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
196
|
+
baseBus.emit(qualified, payload, source);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
baseBus.emit(type, payload, source);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}, [baseBus, scope]);
|
|
187
203
|
}
|
|
188
204
|
function useEventListener(event, handler) {
|
|
189
205
|
const eventBus = useEventBus();
|
|
@@ -785,6 +801,7 @@ var init_usePullToRefresh = __esm({
|
|
|
785
801
|
function EntitySchemaProvider({
|
|
786
802
|
entities,
|
|
787
803
|
traitLinkedEntities,
|
|
804
|
+
orbitalsByTrait,
|
|
788
805
|
children
|
|
789
806
|
}) {
|
|
790
807
|
const entitiesMap = React115.useMemo(() => {
|
|
@@ -797,12 +814,16 @@ function EntitySchemaProvider({
|
|
|
797
814
|
const linkedMap = React115.useMemo(() => {
|
|
798
815
|
return traitLinkedEntities ?? /* @__PURE__ */ new Map();
|
|
799
816
|
}, [traitLinkedEntities]);
|
|
817
|
+
const orbitalsMap = React115.useMemo(() => {
|
|
818
|
+
return orbitalsByTrait ?? /* @__PURE__ */ new Map();
|
|
819
|
+
}, [orbitalsByTrait]);
|
|
800
820
|
const contextValue = React115.useMemo(
|
|
801
821
|
() => ({
|
|
802
822
|
entities: entitiesMap,
|
|
803
|
-
traitLinkedEntities: linkedMap
|
|
823
|
+
traitLinkedEntities: linkedMap,
|
|
824
|
+
orbitalsByTrait: orbitalsMap
|
|
804
825
|
}),
|
|
805
|
-
[entitiesMap, linkedMap]
|
|
826
|
+
[entitiesMap, linkedMap, orbitalsMap]
|
|
806
827
|
);
|
|
807
828
|
return /* @__PURE__ */ jsxRuntime.jsx(EntitySchemaContext.Provider, { value: contextValue, children });
|
|
808
829
|
}
|
|
@@ -18551,8 +18572,7 @@ function formatValue(value, format) {
|
|
|
18551
18572
|
}
|
|
18552
18573
|
function DataGrid({
|
|
18553
18574
|
entity,
|
|
18554
|
-
fields
|
|
18555
|
-
columns: columnsProp,
|
|
18575
|
+
fields,
|
|
18556
18576
|
itemActions,
|
|
18557
18577
|
cols,
|
|
18558
18578
|
gap = "md",
|
|
@@ -18573,7 +18593,6 @@ function DataGrid({
|
|
|
18573
18593
|
const { t } = useTranslate();
|
|
18574
18594
|
const [selectedIds, setSelectedIds] = React115.useState(/* @__PURE__ */ new Set());
|
|
18575
18595
|
const [visibleCount, setVisibleCount] = React115.useState(pageSize || Infinity);
|
|
18576
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
18577
18596
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
18578
18597
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
18579
18598
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -18916,8 +18935,7 @@ function groupData(items, field) {
|
|
|
18916
18935
|
}
|
|
18917
18936
|
function DataList({
|
|
18918
18937
|
entity,
|
|
18919
|
-
fields
|
|
18920
|
-
columns: columnsProp,
|
|
18938
|
+
fields,
|
|
18921
18939
|
itemActions,
|
|
18922
18940
|
gap = "none",
|
|
18923
18941
|
variant = "default",
|
|
@@ -18946,7 +18964,6 @@ function DataList({
|
|
|
18946
18964
|
const eventBus = useEventBus();
|
|
18947
18965
|
const { t } = useTranslate();
|
|
18948
18966
|
const [visibleCount, setVisibleCount] = React115__namespace.default.useState(pageSize || Infinity);
|
|
18949
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
18950
18967
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
18951
18968
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
18952
18969
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -37540,6 +37557,17 @@ function renderContainedPortal(slot, content, onDismiss) {
|
|
|
37540
37557
|
return /* @__PURE__ */ jsxRuntime.jsx(Box, { id: slotId, children: slotContent });
|
|
37541
37558
|
}
|
|
37542
37559
|
}
|
|
37560
|
+
function MaybeTraitScope({
|
|
37561
|
+
sourceTrait,
|
|
37562
|
+
children
|
|
37563
|
+
}) {
|
|
37564
|
+
const schemaCtx = useEntitySchemaOptional();
|
|
37565
|
+
const orbital = sourceTrait !== void 0 && schemaCtx !== null ? schemaCtx.orbitalsByTrait.get(sourceTrait) : void 0;
|
|
37566
|
+
if (sourceTrait !== void 0 && orbital !== void 0) {
|
|
37567
|
+
return /* @__PURE__ */ jsxRuntime.jsx(providers.TraitScopeProvider, { orbital, trait: sourceTrait, children });
|
|
37568
|
+
}
|
|
37569
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
37570
|
+
}
|
|
37543
37571
|
function UISlotComponent({
|
|
37544
37572
|
slot,
|
|
37545
37573
|
portal = false,
|
|
@@ -37567,11 +37595,11 @@ function UISlotComponent({
|
|
|
37567
37595
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37568
37596
|
"data-pattern": pattern,
|
|
37569
37597
|
"data-source-trait": sourceTrait,
|
|
37570
|
-
children
|
|
37598
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37571
37599
|
}
|
|
37572
37600
|
);
|
|
37573
37601
|
}
|
|
37574
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children });
|
|
37602
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait, children }) });
|
|
37575
37603
|
}
|
|
37576
37604
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
37577
37605
|
Box,
|
|
@@ -37580,7 +37608,7 @@ function UISlotComponent({
|
|
|
37580
37608
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37581
37609
|
"data-pattern": pattern,
|
|
37582
37610
|
"data-source-trait": sourceTrait,
|
|
37583
|
-
children
|
|
37611
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37584
37612
|
}
|
|
37585
37613
|
);
|
|
37586
37614
|
}
|
|
@@ -37626,7 +37654,7 @@ function UISlotComponent({
|
|
|
37626
37654
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37627
37655
|
"data-pattern": content.pattern,
|
|
37628
37656
|
"data-source-trait": content.sourceTrait,
|
|
37629
|
-
children: wrappedContent
|
|
37657
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: wrappedContent })
|
|
37630
37658
|
}
|
|
37631
37659
|
);
|
|
37632
37660
|
}
|
|
@@ -37734,7 +37762,7 @@ function SlotPortal({
|
|
|
37734
37762
|
});
|
|
37735
37763
|
if (!portalRoot) return null;
|
|
37736
37764
|
const slotId = `slot-${slot}`;
|
|
37737
|
-
const slotContent = /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content, onDismiss });
|
|
37765
|
+
const slotContent = /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content, onDismiss }) });
|
|
37738
37766
|
let wrapper;
|
|
37739
37767
|
switch (slot) {
|
|
37740
37768
|
case "modal":
|
|
@@ -39304,6 +39332,24 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLoc
|
|
|
39304
39332
|
}
|
|
39305
39333
|
return map;
|
|
39306
39334
|
}, [schema]);
|
|
39335
|
+
const traitLinkedEntitiesMap = React115.useMemo(() => {
|
|
39336
|
+
const map = /* @__PURE__ */ new Map();
|
|
39337
|
+
if (ir) {
|
|
39338
|
+
for (const page of ir.pages.values()) {
|
|
39339
|
+
for (const binding of page.traits) {
|
|
39340
|
+
if (binding.linkedEntity) {
|
|
39341
|
+
map.set(binding.trait.name, binding.linkedEntity);
|
|
39342
|
+
}
|
|
39343
|
+
}
|
|
39344
|
+
}
|
|
39345
|
+
}
|
|
39346
|
+
return map;
|
|
39347
|
+
}, [ir]);
|
|
39348
|
+
const orbitalsByTraitMap = React115.useMemo(
|
|
39349
|
+
() => new Map(Object.entries(orbitalsByTrait)),
|
|
39350
|
+
[orbitalsByTrait]
|
|
39351
|
+
);
|
|
39352
|
+
const entitiesArray = React115.useMemo(() => Array.from(allEntities.values()), [allEntities]);
|
|
39307
39353
|
const pageOrbitalNames = React115.useMemo(() => {
|
|
39308
39354
|
const set = /* @__PURE__ */ new Set();
|
|
39309
39355
|
for (const binding of allPageTraits) {
|
|
@@ -39347,20 +39393,9 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLoc
|
|
|
39347
39393
|
const inner = /* @__PURE__ */ jsxRuntime.jsx(providers.VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(SlotsProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
39348
39394
|
EntitySchemaProvider,
|
|
39349
39395
|
{
|
|
39350
|
-
entities:
|
|
39351
|
-
traitLinkedEntities:
|
|
39352
|
-
|
|
39353
|
-
if (ir) {
|
|
39354
|
-
for (const page of ir.pages.values()) {
|
|
39355
|
-
for (const binding of page.traits) {
|
|
39356
|
-
if (binding.linkedEntity) {
|
|
39357
|
-
map.set(binding.trait.name, binding.linkedEntity);
|
|
39358
|
-
}
|
|
39359
|
-
}
|
|
39360
|
-
}
|
|
39361
|
-
}
|
|
39362
|
-
return map;
|
|
39363
|
-
})(),
|
|
39396
|
+
entities: entitiesArray,
|
|
39397
|
+
traitLinkedEntities: traitLinkedEntitiesMap,
|
|
39398
|
+
orbitalsByTrait: orbitalsByTraitMap,
|
|
39364
39399
|
children: [
|
|
39365
39400
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39366
39401
|
TraitInitializer,
|