@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
package/dist/runtime/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React115 from 'react';
|
|
2
|
-
import React115__default, { createContext, useContext, useRef, useEffect, useCallback,
|
|
3
|
-
import { EventBusContext, OrbitalProvider, VerificationProvider } from '@almadar/ui/providers';
|
|
2
|
+
import React115__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, useState, Suspense, useLayoutEffect, lazy, useId } from 'react';
|
|
3
|
+
import { EventBusContext, useTraitScope, OrbitalProvider, TraitScopeProvider, VerificationProvider } from '@almadar/ui/providers';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -138,7 +138,23 @@ function getGlobalEventBus() {
|
|
|
138
138
|
}
|
|
139
139
|
function useEventBus() {
|
|
140
140
|
const context = useContext(EventBusContext);
|
|
141
|
-
|
|
141
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
142
|
+
const scope = useTraitScope();
|
|
143
|
+
return useMemo(() => {
|
|
144
|
+
if (!scope) return baseBus;
|
|
145
|
+
return {
|
|
146
|
+
...baseBus,
|
|
147
|
+
emit: (type, payload, source) => {
|
|
148
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
149
|
+
const tail = type.slice(3);
|
|
150
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
151
|
+
baseBus.emit(qualified, payload, source);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
baseBus.emit(type, payload, source);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}, [baseBus, scope]);
|
|
142
158
|
}
|
|
143
159
|
function useEventListener(event, handler) {
|
|
144
160
|
const eventBus = useEventBus();
|
|
@@ -740,6 +756,7 @@ var init_usePullToRefresh = __esm({
|
|
|
740
756
|
function EntitySchemaProvider({
|
|
741
757
|
entities,
|
|
742
758
|
traitLinkedEntities,
|
|
759
|
+
orbitalsByTrait,
|
|
743
760
|
children
|
|
744
761
|
}) {
|
|
745
762
|
const entitiesMap = useMemo(() => {
|
|
@@ -752,12 +769,16 @@ function EntitySchemaProvider({
|
|
|
752
769
|
const linkedMap = useMemo(() => {
|
|
753
770
|
return traitLinkedEntities ?? /* @__PURE__ */ new Map();
|
|
754
771
|
}, [traitLinkedEntities]);
|
|
772
|
+
const orbitalsMap = useMemo(() => {
|
|
773
|
+
return orbitalsByTrait ?? /* @__PURE__ */ new Map();
|
|
774
|
+
}, [orbitalsByTrait]);
|
|
755
775
|
const contextValue = useMemo(
|
|
756
776
|
() => ({
|
|
757
777
|
entities: entitiesMap,
|
|
758
|
-
traitLinkedEntities: linkedMap
|
|
778
|
+
traitLinkedEntities: linkedMap,
|
|
779
|
+
orbitalsByTrait: orbitalsMap
|
|
759
780
|
}),
|
|
760
|
-
[entitiesMap, linkedMap]
|
|
781
|
+
[entitiesMap, linkedMap, orbitalsMap]
|
|
761
782
|
);
|
|
762
783
|
return /* @__PURE__ */ jsx(EntitySchemaContext.Provider, { value: contextValue, children });
|
|
763
784
|
}
|
|
@@ -18506,8 +18527,7 @@ function formatValue(value, format) {
|
|
|
18506
18527
|
}
|
|
18507
18528
|
function DataGrid({
|
|
18508
18529
|
entity,
|
|
18509
|
-
fields
|
|
18510
|
-
columns: columnsProp,
|
|
18530
|
+
fields,
|
|
18511
18531
|
itemActions,
|
|
18512
18532
|
cols,
|
|
18513
18533
|
gap = "md",
|
|
@@ -18528,7 +18548,6 @@ function DataGrid({
|
|
|
18528
18548
|
const { t } = useTranslate();
|
|
18529
18549
|
const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
|
|
18530
18550
|
const [visibleCount, setVisibleCount] = useState(pageSize || Infinity);
|
|
18531
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
18532
18551
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
18533
18552
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
18534
18553
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -18871,8 +18890,7 @@ function groupData(items, field) {
|
|
|
18871
18890
|
}
|
|
18872
18891
|
function DataList({
|
|
18873
18892
|
entity,
|
|
18874
|
-
fields
|
|
18875
|
-
columns: columnsProp,
|
|
18893
|
+
fields,
|
|
18876
18894
|
itemActions,
|
|
18877
18895
|
gap = "none",
|
|
18878
18896
|
variant = "default",
|
|
@@ -18901,7 +18919,6 @@ function DataList({
|
|
|
18901
18919
|
const eventBus = useEventBus();
|
|
18902
18920
|
const { t } = useTranslate();
|
|
18903
18921
|
const [visibleCount, setVisibleCount] = React115__default.useState(pageSize || Infinity);
|
|
18904
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
18905
18922
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
18906
18923
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
18907
18924
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -37495,6 +37512,17 @@ function renderContainedPortal(slot, content, onDismiss) {
|
|
|
37495
37512
|
return /* @__PURE__ */ jsx(Box, { id: slotId, children: slotContent });
|
|
37496
37513
|
}
|
|
37497
37514
|
}
|
|
37515
|
+
function MaybeTraitScope({
|
|
37516
|
+
sourceTrait,
|
|
37517
|
+
children
|
|
37518
|
+
}) {
|
|
37519
|
+
const schemaCtx = useEntitySchemaOptional();
|
|
37520
|
+
const orbital = sourceTrait !== void 0 && schemaCtx !== null ? schemaCtx.orbitalsByTrait.get(sourceTrait) : void 0;
|
|
37521
|
+
if (sourceTrait !== void 0 && orbital !== void 0) {
|
|
37522
|
+
return /* @__PURE__ */ jsx(TraitScopeProvider, { orbital, trait: sourceTrait, children });
|
|
37523
|
+
}
|
|
37524
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
37525
|
+
}
|
|
37498
37526
|
function UISlotComponent({
|
|
37499
37527
|
slot,
|
|
37500
37528
|
portal = false,
|
|
@@ -37522,11 +37550,11 @@ function UISlotComponent({
|
|
|
37522
37550
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37523
37551
|
"data-pattern": pattern,
|
|
37524
37552
|
"data-source-trait": sourceTrait,
|
|
37525
|
-
children
|
|
37553
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37526
37554
|
}
|
|
37527
37555
|
);
|
|
37528
37556
|
}
|
|
37529
|
-
return /* @__PURE__ */ jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children });
|
|
37557
|
+
return /* @__PURE__ */ jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children }) });
|
|
37530
37558
|
}
|
|
37531
37559
|
return /* @__PURE__ */ jsx(
|
|
37532
37560
|
Box,
|
|
@@ -37535,7 +37563,7 @@ function UISlotComponent({
|
|
|
37535
37563
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37536
37564
|
"data-pattern": pattern,
|
|
37537
37565
|
"data-source-trait": sourceTrait,
|
|
37538
|
-
children
|
|
37566
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37539
37567
|
}
|
|
37540
37568
|
);
|
|
37541
37569
|
}
|
|
@@ -37581,7 +37609,7 @@ function UISlotComponent({
|
|
|
37581
37609
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37582
37610
|
"data-pattern": content.pattern,
|
|
37583
37611
|
"data-source-trait": content.sourceTrait,
|
|
37584
|
-
children: wrappedContent
|
|
37612
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: wrappedContent })
|
|
37585
37613
|
}
|
|
37586
37614
|
);
|
|
37587
37615
|
}
|
|
@@ -37689,7 +37717,7 @@ function SlotPortal({
|
|
|
37689
37717
|
});
|
|
37690
37718
|
if (!portalRoot) return null;
|
|
37691
37719
|
const slotId = `slot-${slot}`;
|
|
37692
|
-
const slotContent = /* @__PURE__ */ jsx(SlotContentRenderer, { content, onDismiss });
|
|
37720
|
+
const slotContent = /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: /* @__PURE__ */ jsx(SlotContentRenderer, { content, onDismiss }) });
|
|
37693
37721
|
let wrapper;
|
|
37694
37722
|
switch (slot) {
|
|
37695
37723
|
case "modal":
|
|
@@ -39259,6 +39287,24 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLoc
|
|
|
39259
39287
|
}
|
|
39260
39288
|
return map;
|
|
39261
39289
|
}, [schema]);
|
|
39290
|
+
const traitLinkedEntitiesMap = useMemo(() => {
|
|
39291
|
+
const map = /* @__PURE__ */ new Map();
|
|
39292
|
+
if (ir) {
|
|
39293
|
+
for (const page of ir.pages.values()) {
|
|
39294
|
+
for (const binding of page.traits) {
|
|
39295
|
+
if (binding.linkedEntity) {
|
|
39296
|
+
map.set(binding.trait.name, binding.linkedEntity);
|
|
39297
|
+
}
|
|
39298
|
+
}
|
|
39299
|
+
}
|
|
39300
|
+
}
|
|
39301
|
+
return map;
|
|
39302
|
+
}, [ir]);
|
|
39303
|
+
const orbitalsByTraitMap = useMemo(
|
|
39304
|
+
() => new Map(Object.entries(orbitalsByTrait)),
|
|
39305
|
+
[orbitalsByTrait]
|
|
39306
|
+
);
|
|
39307
|
+
const entitiesArray = useMemo(() => Array.from(allEntities.values()), [allEntities]);
|
|
39262
39308
|
const pageOrbitalNames = useMemo(() => {
|
|
39263
39309
|
const set = /* @__PURE__ */ new Set();
|
|
39264
39310
|
for (const binding of allPageTraits) {
|
|
@@ -39302,20 +39348,9 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLoc
|
|
|
39302
39348
|
const inner = /* @__PURE__ */ jsx(VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsx(SlotsProvider, { children: /* @__PURE__ */ jsxs(
|
|
39303
39349
|
EntitySchemaProvider,
|
|
39304
39350
|
{
|
|
39305
|
-
entities:
|
|
39306
|
-
traitLinkedEntities:
|
|
39307
|
-
|
|
39308
|
-
if (ir) {
|
|
39309
|
-
for (const page of ir.pages.values()) {
|
|
39310
|
-
for (const binding of page.traits) {
|
|
39311
|
-
if (binding.linkedEntity) {
|
|
39312
|
-
map.set(binding.trait.name, binding.linkedEntity);
|
|
39313
|
-
}
|
|
39314
|
-
}
|
|
39315
|
-
}
|
|
39316
|
-
}
|
|
39317
|
-
return map;
|
|
39318
|
-
})(),
|
|
39351
|
+
entities: entitiesArray,
|
|
39352
|
+
traitLinkedEntities: traitLinkedEntitiesMap,
|
|
39353
|
+
orbitalsByTrait: orbitalsByTraitMap,
|
|
39319
39354
|
children: [
|
|
39320
39355
|
/* @__PURE__ */ jsx(
|
|
39321
39356
|
TraitInitializer,
|