@almadar/ui 4.8.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 +1340 -1281
- package/dist/avl/index.js +247 -188
- package/dist/components/index.cjs +33 -6
- package/dist/components/index.js +35 -8
- 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 +47 -6
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +48 -9
- package/dist/runtime/EntitySchemaContext.d.ts +16 -1
- package/dist/runtime/index.cjs +61 -22
- package/dist/runtime/index.js +63 -24
- package/package.json +1 -1
|
@@ -189,7 +189,23 @@ function getGlobalEventBus() {
|
|
|
189
189
|
}
|
|
190
190
|
function useEventBus() {
|
|
191
191
|
const context = React111.useContext(providers.EventBusContext);
|
|
192
|
-
|
|
192
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
193
|
+
const scope = providers.useTraitScope();
|
|
194
|
+
return React111.useMemo(() => {
|
|
195
|
+
if (!scope) return baseBus;
|
|
196
|
+
return {
|
|
197
|
+
...baseBus,
|
|
198
|
+
emit: (type, payload, source) => {
|
|
199
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
200
|
+
const tail = type.slice(3);
|
|
201
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
202
|
+
baseBus.emit(qualified, payload, source);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
baseBus.emit(type, payload, source);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}, [baseBus, scope]);
|
|
193
209
|
}
|
|
194
210
|
function useEventListener(event, handler) {
|
|
195
211
|
const eventBus = useEventBus();
|
|
@@ -37341,6 +37357,17 @@ function renderContainedPortal(slot, content, onDismiss) {
|
|
|
37341
37357
|
return /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { id: slotId, children: slotContent });
|
|
37342
37358
|
}
|
|
37343
37359
|
}
|
|
37360
|
+
function MaybeTraitScope({
|
|
37361
|
+
sourceTrait,
|
|
37362
|
+
children
|
|
37363
|
+
}) {
|
|
37364
|
+
const schemaCtx = useEntitySchemaOptional();
|
|
37365
|
+
const orbital = sourceTrait !== void 0 && schemaCtx !== null ? schemaCtx.orbitalsByTrait.get(sourceTrait) : void 0;
|
|
37366
|
+
if (sourceTrait !== void 0 && orbital !== void 0) {
|
|
37367
|
+
return /* @__PURE__ */ jsxRuntime.jsx(providers.TraitScopeProvider, { orbital, trait: sourceTrait, children });
|
|
37368
|
+
}
|
|
37369
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
37370
|
+
}
|
|
37344
37371
|
function UISlotComponent({
|
|
37345
37372
|
slot,
|
|
37346
37373
|
portal = false,
|
|
@@ -37368,11 +37395,11 @@ function UISlotComponent({
|
|
|
37368
37395
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37369
37396
|
"data-pattern": pattern,
|
|
37370
37397
|
"data-source-trait": sourceTrait,
|
|
37371
|
-
children
|
|
37398
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37372
37399
|
}
|
|
37373
37400
|
);
|
|
37374
37401
|
}
|
|
37375
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children });
|
|
37402
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait, children }) });
|
|
37376
37403
|
}
|
|
37377
37404
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
37378
37405
|
exports.Box,
|
|
@@ -37381,7 +37408,7 @@ function UISlotComponent({
|
|
|
37381
37408
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37382
37409
|
"data-pattern": pattern,
|
|
37383
37410
|
"data-source-trait": sourceTrait,
|
|
37384
|
-
children
|
|
37411
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37385
37412
|
}
|
|
37386
37413
|
);
|
|
37387
37414
|
}
|
|
@@ -37427,7 +37454,7 @@ function UISlotComponent({
|
|
|
37427
37454
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37428
37455
|
"data-pattern": content.pattern,
|
|
37429
37456
|
"data-source-trait": content.sourceTrait,
|
|
37430
|
-
children: wrappedContent
|
|
37457
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: wrappedContent })
|
|
37431
37458
|
}
|
|
37432
37459
|
);
|
|
37433
37460
|
}
|
|
@@ -37535,7 +37562,7 @@ function SlotPortal({
|
|
|
37535
37562
|
});
|
|
37536
37563
|
if (!portalRoot) return null;
|
|
37537
37564
|
const slotId = `slot-${slot}`;
|
|
37538
|
-
const slotContent = /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content, onDismiss });
|
|
37565
|
+
const slotContent = /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content, onDismiss }) });
|
|
37539
37566
|
let wrapper;
|
|
37540
37567
|
switch (slot) {
|
|
37541
37568
|
case "modal":
|
package/dist/components/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import { twMerge } from 'tailwind-merge';
|
|
3
3
|
import * as React111 from 'react';
|
|
4
|
-
import React111__default, { useContext, useRef, useEffect, useCallback, createContext, useState, Suspense,
|
|
5
|
-
import { EventBusContext } from '@almadar/ui/providers';
|
|
4
|
+
import React111__default, { useContext, useMemo, useRef, useEffect, useCallback, createContext, useState, Suspense, lazy, useSyncExternalStore, useLayoutEffect, useId } from 'react';
|
|
5
|
+
import { EventBusContext, useTraitScope, TraitScopeProvider } from '@almadar/ui/providers';
|
|
6
6
|
import * as LucideIcons from 'lucide-react';
|
|
7
7
|
import { Loader2, X, AlertTriangle, Info, AlertCircle, CheckCircle, ChevronDown, List, Printer, ChevronRight, ChevronLeft, XCircle, Wrench, RotateCcw, Send, Code, FileText, WrapText, Check, Copy, Zap, Sword, Move, Heart, Shield, Trash2, Settings, Menu as Menu$1, Search, Bell, LogOut, ChevronUp, MoreHorizontal, Bug, ZoomOut, ZoomIn, Download, Pause, Play, Package, Calendar, Pencil, Eye, Image as Image$1, Upload, ArrowRight, ArrowLeft, Eraser, SkipForward, TrendingUp, TrendingDown, Minus, ArrowUp, ArrowDown, MoreVertical, Circle, Clock, CheckCircle2, HelpCircle, FileQuestion, Inbox, Plus, User, Filter, Star, FileWarning, Tag, DollarSign, Sun, Moon } from 'lucide-react';
|
|
8
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -144,7 +144,23 @@ function getGlobalEventBus() {
|
|
|
144
144
|
}
|
|
145
145
|
function useEventBus() {
|
|
146
146
|
const context = useContext(EventBusContext);
|
|
147
|
-
|
|
147
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
148
|
+
const scope = useTraitScope();
|
|
149
|
+
return useMemo(() => {
|
|
150
|
+
if (!scope) return baseBus;
|
|
151
|
+
return {
|
|
152
|
+
...baseBus,
|
|
153
|
+
emit: (type, payload, source) => {
|
|
154
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
155
|
+
const tail = type.slice(3);
|
|
156
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
157
|
+
baseBus.emit(qualified, payload, source);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
baseBus.emit(type, payload, source);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}, [baseBus, scope]);
|
|
148
164
|
}
|
|
149
165
|
function useEventListener(event, handler) {
|
|
150
166
|
const eventBus = useEventBus();
|
|
@@ -37296,6 +37312,17 @@ function renderContainedPortal(slot, content, onDismiss) {
|
|
|
37296
37312
|
return /* @__PURE__ */ jsx(Box, { id: slotId, children: slotContent });
|
|
37297
37313
|
}
|
|
37298
37314
|
}
|
|
37315
|
+
function MaybeTraitScope({
|
|
37316
|
+
sourceTrait,
|
|
37317
|
+
children
|
|
37318
|
+
}) {
|
|
37319
|
+
const schemaCtx = useEntitySchemaOptional();
|
|
37320
|
+
const orbital = sourceTrait !== void 0 && schemaCtx !== null ? schemaCtx.orbitalsByTrait.get(sourceTrait) : void 0;
|
|
37321
|
+
if (sourceTrait !== void 0 && orbital !== void 0) {
|
|
37322
|
+
return /* @__PURE__ */ jsx(TraitScopeProvider, { orbital, trait: sourceTrait, children });
|
|
37323
|
+
}
|
|
37324
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
37325
|
+
}
|
|
37299
37326
|
function UISlotComponent({
|
|
37300
37327
|
slot,
|
|
37301
37328
|
portal = false,
|
|
@@ -37323,11 +37350,11 @@ function UISlotComponent({
|
|
|
37323
37350
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37324
37351
|
"data-pattern": pattern,
|
|
37325
37352
|
"data-source-trait": sourceTrait,
|
|
37326
|
-
children
|
|
37353
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37327
37354
|
}
|
|
37328
37355
|
);
|
|
37329
37356
|
}
|
|
37330
|
-
return /* @__PURE__ */ jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children });
|
|
37357
|
+
return /* @__PURE__ */ jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children }) });
|
|
37331
37358
|
}
|
|
37332
37359
|
return /* @__PURE__ */ jsx(
|
|
37333
37360
|
Box,
|
|
@@ -37336,7 +37363,7 @@ function UISlotComponent({
|
|
|
37336
37363
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37337
37364
|
"data-pattern": pattern,
|
|
37338
37365
|
"data-source-trait": sourceTrait,
|
|
37339
|
-
children
|
|
37366
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37340
37367
|
}
|
|
37341
37368
|
);
|
|
37342
37369
|
}
|
|
@@ -37382,7 +37409,7 @@ function UISlotComponent({
|
|
|
37382
37409
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37383
37410
|
"data-pattern": content.pattern,
|
|
37384
37411
|
"data-source-trait": content.sourceTrait,
|
|
37385
|
-
children: wrappedContent
|
|
37412
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: wrappedContent })
|
|
37386
37413
|
}
|
|
37387
37414
|
);
|
|
37388
37415
|
}
|
|
@@ -37490,7 +37517,7 @@ function SlotPortal({
|
|
|
37490
37517
|
});
|
|
37491
37518
|
if (!portalRoot) return null;
|
|
37492
37519
|
const slotId = `slot-${slot}`;
|
|
37493
|
-
const slotContent = /* @__PURE__ */ jsx(SlotContentRenderer, { content, onDismiss });
|
|
37520
|
+
const slotContent = /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: /* @__PURE__ */ jsx(SlotContentRenderer, { content, onDismiss }) });
|
|
37494
37521
|
let wrapper;
|
|
37495
37522
|
switch (slot) {
|
|
37496
37523
|
case "modal":
|
|
@@ -1499,7 +1499,23 @@ var fallbackEventBus = {
|
|
|
1499
1499
|
};
|
|
1500
1500
|
function useEventBus() {
|
|
1501
1501
|
const context = React21.useContext(providers.EventBusContext);
|
|
1502
|
-
|
|
1502
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
1503
|
+
const scope = providers.useTraitScope();
|
|
1504
|
+
return React21.useMemo(() => {
|
|
1505
|
+
if (!scope) return baseBus;
|
|
1506
|
+
return {
|
|
1507
|
+
...baseBus,
|
|
1508
|
+
emit: (type, payload, source) => {
|
|
1509
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
1510
|
+
const tail = type.slice(3);
|
|
1511
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
1512
|
+
baseBus.emit(qualified, payload, source);
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
baseBus.emit(type, payload, source);
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
}, [baseBus, scope]);
|
|
1503
1519
|
}
|
|
1504
1520
|
function useEmitEvent() {
|
|
1505
1521
|
const eventBus = useEventBus();
|
|
@@ -8,7 +8,7 @@ import { GLTFLoader as GLTFLoader$1 } from 'three/examples/jsm/loaders/GLTFLoade
|
|
|
8
8
|
import { OrbitControls as OrbitControls$1 } from 'three/examples/jsm/controls/OrbitControls.js';
|
|
9
9
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
10
10
|
import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader.js';
|
|
11
|
-
import { EventBusContext } from '@almadar/ui/providers';
|
|
11
|
+
import { EventBusContext, useTraitScope } from '@almadar/ui/providers';
|
|
12
12
|
import { clsx } from 'clsx';
|
|
13
13
|
import { twMerge } from 'tailwind-merge';
|
|
14
14
|
import { EffectComposer, Bloom, DepthOfField, Vignette } from '@react-three/postprocessing';
|
|
@@ -1475,7 +1475,23 @@ var fallbackEventBus = {
|
|
|
1475
1475
|
};
|
|
1476
1476
|
function useEventBus() {
|
|
1477
1477
|
const context = useContext(EventBusContext);
|
|
1478
|
-
|
|
1478
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
1479
|
+
const scope = useTraitScope();
|
|
1480
|
+
return useMemo(() => {
|
|
1481
|
+
if (!scope) return baseBus;
|
|
1482
|
+
return {
|
|
1483
|
+
...baseBus,
|
|
1484
|
+
emit: (type, payload, source) => {
|
|
1485
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
1486
|
+
const tail = type.slice(3);
|
|
1487
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
1488
|
+
baseBus.emit(qualified, payload, source);
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1491
|
+
baseBus.emit(type, payload, source);
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1494
|
+
}, [baseBus, scope]);
|
|
1479
1495
|
}
|
|
1480
1496
|
function useEmitEvent() {
|
|
1481
1497
|
const eventBus = useEventBus();
|
package/dist/docs/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React5 = require('react');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var LucideIcons = require('lucide-react');
|
|
6
6
|
|
|
@@ -24,7 +24,7 @@ function _interopNamespace(e) {
|
|
|
24
24
|
return Object.freeze(n);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var React5__default = /*#__PURE__*/_interopDefault(React5);
|
|
28
28
|
var LucideIcons__namespace = /*#__PURE__*/_interopNamespace(LucideIcons);
|
|
29
29
|
|
|
30
30
|
// node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
@@ -2556,7 +2556,11 @@ function createLogger(namespace) {
|
|
|
2556
2556
|
}
|
|
2557
2557
|
createLogger("almadar:eventbus");
|
|
2558
2558
|
createLogger("almadar:eventbus:subscribe");
|
|
2559
|
-
var EventBusContext =
|
|
2559
|
+
var EventBusContext = React5.createContext(null);
|
|
2560
|
+
var TraitScopeContext = React5.createContext(null);
|
|
2561
|
+
function useTraitScope() {
|
|
2562
|
+
return React5.useContext(TraitScopeContext);
|
|
2563
|
+
}
|
|
2560
2564
|
|
|
2561
2565
|
// hooks/useEventBus.ts
|
|
2562
2566
|
var log = createLogger("almadar:eventbus");
|
|
@@ -2632,8 +2636,24 @@ var fallbackEventBus = {
|
|
|
2632
2636
|
}
|
|
2633
2637
|
};
|
|
2634
2638
|
function useEventBus() {
|
|
2635
|
-
const context =
|
|
2636
|
-
|
|
2639
|
+
const context = React5.useContext(EventBusContext);
|
|
2640
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
2641
|
+
const scope = useTraitScope();
|
|
2642
|
+
return React5.useMemo(() => {
|
|
2643
|
+
if (!scope) return baseBus;
|
|
2644
|
+
return {
|
|
2645
|
+
...baseBus,
|
|
2646
|
+
emit: (type, payload, source) => {
|
|
2647
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
2648
|
+
const tail = type.slice(3);
|
|
2649
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
2650
|
+
baseBus.emit(qualified, payload, source);
|
|
2651
|
+
return;
|
|
2652
|
+
}
|
|
2653
|
+
baseBus.emit(type, payload, source);
|
|
2654
|
+
}
|
|
2655
|
+
};
|
|
2656
|
+
}, [baseBus, scope]);
|
|
2637
2657
|
}
|
|
2638
2658
|
var paddingStyles = {
|
|
2639
2659
|
none: "p-0",
|
|
@@ -2737,7 +2757,7 @@ var positionStyles = {
|
|
|
2737
2757
|
fixed: "fixed",
|
|
2738
2758
|
sticky: "sticky"
|
|
2739
2759
|
};
|
|
2740
|
-
var Box =
|
|
2760
|
+
var Box = React5__default.default.forwardRef(
|
|
2741
2761
|
({
|
|
2742
2762
|
padding,
|
|
2743
2763
|
paddingX,
|
|
@@ -2767,20 +2787,20 @@ var Box = React4__default.default.forwardRef(
|
|
|
2767
2787
|
...rest
|
|
2768
2788
|
}, ref) => {
|
|
2769
2789
|
const eventBus = useEventBus();
|
|
2770
|
-
const handleClick =
|
|
2790
|
+
const handleClick = React5.useCallback((e) => {
|
|
2771
2791
|
if (action) {
|
|
2772
2792
|
e.stopPropagation();
|
|
2773
2793
|
eventBus.emit(`UI:${action}`, actionPayload ?? {});
|
|
2774
2794
|
}
|
|
2775
2795
|
onClick?.(e);
|
|
2776
2796
|
}, [action, actionPayload, eventBus, onClick]);
|
|
2777
|
-
const handleMouseEnter =
|
|
2797
|
+
const handleMouseEnter = React5.useCallback((e) => {
|
|
2778
2798
|
if (hoverEvent) {
|
|
2779
2799
|
eventBus.emit(`UI:${hoverEvent}`, { hovered: true });
|
|
2780
2800
|
}
|
|
2781
2801
|
onMouseEnter?.(e);
|
|
2782
2802
|
}, [hoverEvent, eventBus, onMouseEnter]);
|
|
2783
|
-
const handleMouseLeave =
|
|
2803
|
+
const handleMouseLeave = React5.useCallback((e) => {
|
|
2784
2804
|
if (hoverEvent) {
|
|
2785
2805
|
eventBus.emit(`UI:${hoverEvent}`, { hovered: false });
|
|
2786
2806
|
}
|
|
@@ -3166,7 +3186,7 @@ function resolveIconProp(value, sizeClass) {
|
|
|
3166
3186
|
const IconComp = value;
|
|
3167
3187
|
return /* @__PURE__ */ jsxRuntime.jsx(IconComp, { className: sizeClass });
|
|
3168
3188
|
}
|
|
3169
|
-
if (
|
|
3189
|
+
if (React5__default.default.isValidElement(value)) {
|
|
3170
3190
|
return value;
|
|
3171
3191
|
}
|
|
3172
3192
|
if (typeof value === "object" && value !== null && "render" in value) {
|
|
@@ -3175,7 +3195,7 @@ function resolveIconProp(value, sizeClass) {
|
|
|
3175
3195
|
}
|
|
3176
3196
|
return value;
|
|
3177
3197
|
}
|
|
3178
|
-
var Button =
|
|
3198
|
+
var Button = React5__default.default.forwardRef(
|
|
3179
3199
|
({
|
|
3180
3200
|
className,
|
|
3181
3201
|
variant = "primary",
|
|
@@ -3278,7 +3298,7 @@ var shadowStyles2 = {
|
|
|
3278
3298
|
md: "shadow",
|
|
3279
3299
|
lg: "shadow-lg"
|
|
3280
3300
|
};
|
|
3281
|
-
var Card =
|
|
3301
|
+
var Card = React5__default.default.forwardRef(
|
|
3282
3302
|
({
|
|
3283
3303
|
className,
|
|
3284
3304
|
variant = "bordered",
|
|
@@ -3314,9 +3334,9 @@ var Card = React4__default.default.forwardRef(
|
|
|
3314
3334
|
}
|
|
3315
3335
|
);
|
|
3316
3336
|
Card.displayName = "Card";
|
|
3317
|
-
var CardHeader =
|
|
3337
|
+
var CardHeader = React5__default.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("mb-4", className), ...props }));
|
|
3318
3338
|
CardHeader.displayName = "CardHeader";
|
|
3319
|
-
var CardTitle =
|
|
3339
|
+
var CardTitle = React5__default.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3320
3340
|
"h3",
|
|
3321
3341
|
{
|
|
3322
3342
|
ref,
|
|
@@ -3329,11 +3349,11 @@ var CardTitle = React4__default.default.forwardRef(({ className, ...props }, ref
|
|
|
3329
3349
|
}
|
|
3330
3350
|
));
|
|
3331
3351
|
CardTitle.displayName = "CardTitle";
|
|
3332
|
-
var CardContent =
|
|
3352
|
+
var CardContent = React5__default.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("", className), ...props }));
|
|
3333
3353
|
CardContent.displayName = "CardContent";
|
|
3334
3354
|
var CardBody = CardContent;
|
|
3335
3355
|
CardBody.displayName = "CardBody";
|
|
3336
|
-
var CardFooter =
|
|
3356
|
+
var CardFooter = React5__default.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3337
3357
|
"div",
|
|
3338
3358
|
{
|
|
3339
3359
|
ref,
|
|
@@ -3412,7 +3432,7 @@ var Divider = ({
|
|
|
3412
3432
|
);
|
|
3413
3433
|
};
|
|
3414
3434
|
Divider.displayName = "Divider";
|
|
3415
|
-
var Input =
|
|
3435
|
+
var Input = React5__default.default.forwardRef(
|
|
3416
3436
|
({
|
|
3417
3437
|
className,
|
|
3418
3438
|
inputType,
|
|
@@ -3525,7 +3545,7 @@ var Input = React4__default.default.forwardRef(
|
|
|
3525
3545
|
);
|
|
3526
3546
|
Input.displayName = "Input";
|
|
3527
3547
|
var DocSidebarCategory = ({ item, depth }) => {
|
|
3528
|
-
const [expanded, setExpanded] =
|
|
3548
|
+
const [expanded, setExpanded] = React5.useState(
|
|
3529
3549
|
() => item.items?.some(function hasActive(child) {
|
|
3530
3550
|
if (child.active) return true;
|
|
3531
3551
|
return child.items?.some(hasActive) ?? false;
|
|
@@ -3680,7 +3700,7 @@ var DocBreadcrumb = ({
|
|
|
3680
3700
|
"aria-label": "Breadcrumb",
|
|
3681
3701
|
children: /* @__PURE__ */ jsxRuntime.jsx(HStack, { gap: "xs", align: "center", wrap: true, children: items.map((item, idx) => {
|
|
3682
3702
|
const isLast = idx === items.length - 1;
|
|
3683
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3703
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React5__default.default.Fragment, { children: [
|
|
3684
3704
|
idx > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3685
3705
|
Icon,
|
|
3686
3706
|
{
|
|
@@ -3732,8 +3752,8 @@ function DocCodeBlock({
|
|
|
3732
3752
|
showLineNumbers = false,
|
|
3733
3753
|
className
|
|
3734
3754
|
}) {
|
|
3735
|
-
const [copied, setCopied] =
|
|
3736
|
-
const handleCopy =
|
|
3755
|
+
const [copied, setCopied] = React5.useState(false);
|
|
3756
|
+
const handleCopy = React5.useCallback(() => {
|
|
3737
3757
|
void navigator.clipboard.writeText(code).then(() => {
|
|
3738
3758
|
setCopied(true);
|
|
3739
3759
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -3898,13 +3918,13 @@ function DocSearch({
|
|
|
3898
3918
|
onSearch,
|
|
3899
3919
|
className
|
|
3900
3920
|
}) {
|
|
3901
|
-
const [query, setQuery] =
|
|
3902
|
-
const [results, setResults] =
|
|
3903
|
-
const [isOpen, setIsOpen] =
|
|
3904
|
-
const [activeIndex, setActiveIndex] =
|
|
3905
|
-
const containerRef =
|
|
3906
|
-
const debounceRef =
|
|
3907
|
-
|
|
3921
|
+
const [query, setQuery] = React5.useState("");
|
|
3922
|
+
const [results, setResults] = React5.useState([]);
|
|
3923
|
+
const [isOpen, setIsOpen] = React5.useState(false);
|
|
3924
|
+
const [activeIndex, setActiveIndex] = React5.useState(-1);
|
|
3925
|
+
const containerRef = React5.useRef(null);
|
|
3926
|
+
const debounceRef = React5.useRef(void 0);
|
|
3927
|
+
React5.useEffect(() => {
|
|
3908
3928
|
function handleClickOutside(e) {
|
|
3909
3929
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
3910
3930
|
setIsOpen(false);
|
|
@@ -3913,7 +3933,7 @@ function DocSearch({
|
|
|
3913
3933
|
document.addEventListener("mousedown", handleClickOutside);
|
|
3914
3934
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
3915
3935
|
}, []);
|
|
3916
|
-
const performSearch =
|
|
3936
|
+
const performSearch = React5.useCallback(
|
|
3917
3937
|
(value) => {
|
|
3918
3938
|
if (!onSearch || !value.trim()) {
|
|
3919
3939
|
setResults([]);
|
|
@@ -3935,7 +3955,7 @@ function DocSearch({
|
|
|
3935
3955
|
},
|
|
3936
3956
|
[onSearch]
|
|
3937
3957
|
);
|
|
3938
|
-
const handleChange =
|
|
3958
|
+
const handleChange = React5.useCallback(
|
|
3939
3959
|
(e) => {
|
|
3940
3960
|
const value = e.target.value;
|
|
3941
3961
|
setQuery(value);
|
|
@@ -3948,18 +3968,18 @@ function DocSearch({
|
|
|
3948
3968
|
},
|
|
3949
3969
|
[performSearch]
|
|
3950
3970
|
);
|
|
3951
|
-
const handleFocus =
|
|
3971
|
+
const handleFocus = React5.useCallback(() => {
|
|
3952
3972
|
if (results.length > 0) {
|
|
3953
3973
|
setIsOpen(true);
|
|
3954
3974
|
}
|
|
3955
3975
|
}, [results]);
|
|
3956
|
-
const navigateTo =
|
|
3976
|
+
const navigateTo = React5.useCallback((href) => {
|
|
3957
3977
|
setIsOpen(false);
|
|
3958
3978
|
setQuery("");
|
|
3959
3979
|
setResults([]);
|
|
3960
3980
|
window.location.href = href;
|
|
3961
3981
|
}, []);
|
|
3962
|
-
const handleKeyDown =
|
|
3982
|
+
const handleKeyDown = React5.useCallback(
|
|
3963
3983
|
(e) => {
|
|
3964
3984
|
if (e.key === "Escape") {
|
|
3965
3985
|
setIsOpen(false);
|
|
@@ -3986,7 +4006,7 @@ function DocSearch({
|
|
|
3986
4006
|
},
|
|
3987
4007
|
[isOpen, results, activeIndex, navigateTo]
|
|
3988
4008
|
);
|
|
3989
|
-
|
|
4009
|
+
React5.useEffect(() => {
|
|
3990
4010
|
return () => {
|
|
3991
4011
|
if (debounceRef.current) {
|
|
3992
4012
|
clearTimeout(debounceRef.current);
|
package/dist/docs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React5, { createContext, useCallback, useContext, useMemo, useState, useRef, useEffect } from 'react';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import * as LucideIcons from 'lucide-react';
|
|
4
4
|
import { Loader2, ChevronDown, X } from 'lucide-react';
|
|
@@ -2533,6 +2533,10 @@ function createLogger(namespace) {
|
|
|
2533
2533
|
createLogger("almadar:eventbus");
|
|
2534
2534
|
createLogger("almadar:eventbus:subscribe");
|
|
2535
2535
|
var EventBusContext = createContext(null);
|
|
2536
|
+
var TraitScopeContext = createContext(null);
|
|
2537
|
+
function useTraitScope() {
|
|
2538
|
+
return useContext(TraitScopeContext);
|
|
2539
|
+
}
|
|
2536
2540
|
|
|
2537
2541
|
// hooks/useEventBus.ts
|
|
2538
2542
|
var log = createLogger("almadar:eventbus");
|
|
@@ -2609,7 +2613,23 @@ var fallbackEventBus = {
|
|
|
2609
2613
|
};
|
|
2610
2614
|
function useEventBus() {
|
|
2611
2615
|
const context = useContext(EventBusContext);
|
|
2612
|
-
|
|
2616
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
2617
|
+
const scope = useTraitScope();
|
|
2618
|
+
return useMemo(() => {
|
|
2619
|
+
if (!scope) return baseBus;
|
|
2620
|
+
return {
|
|
2621
|
+
...baseBus,
|
|
2622
|
+
emit: (type, payload, source) => {
|
|
2623
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
2624
|
+
const tail = type.slice(3);
|
|
2625
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
2626
|
+
baseBus.emit(qualified, payload, source);
|
|
2627
|
+
return;
|
|
2628
|
+
}
|
|
2629
|
+
baseBus.emit(type, payload, source);
|
|
2630
|
+
}
|
|
2631
|
+
};
|
|
2632
|
+
}, [baseBus, scope]);
|
|
2613
2633
|
}
|
|
2614
2634
|
var paddingStyles = {
|
|
2615
2635
|
none: "p-0",
|
|
@@ -2713,7 +2733,7 @@ var positionStyles = {
|
|
|
2713
2733
|
fixed: "fixed",
|
|
2714
2734
|
sticky: "sticky"
|
|
2715
2735
|
};
|
|
2716
|
-
var Box =
|
|
2736
|
+
var Box = React5.forwardRef(
|
|
2717
2737
|
({
|
|
2718
2738
|
padding,
|
|
2719
2739
|
paddingX,
|
|
@@ -3142,7 +3162,7 @@ function resolveIconProp(value, sizeClass) {
|
|
|
3142
3162
|
const IconComp = value;
|
|
3143
3163
|
return /* @__PURE__ */ jsx(IconComp, { className: sizeClass });
|
|
3144
3164
|
}
|
|
3145
|
-
if (
|
|
3165
|
+
if (React5.isValidElement(value)) {
|
|
3146
3166
|
return value;
|
|
3147
3167
|
}
|
|
3148
3168
|
if (typeof value === "object" && value !== null && "render" in value) {
|
|
@@ -3151,7 +3171,7 @@ function resolveIconProp(value, sizeClass) {
|
|
|
3151
3171
|
}
|
|
3152
3172
|
return value;
|
|
3153
3173
|
}
|
|
3154
|
-
var Button =
|
|
3174
|
+
var Button = React5.forwardRef(
|
|
3155
3175
|
({
|
|
3156
3176
|
className,
|
|
3157
3177
|
variant = "primary",
|
|
@@ -3254,7 +3274,7 @@ var shadowStyles2 = {
|
|
|
3254
3274
|
md: "shadow",
|
|
3255
3275
|
lg: "shadow-lg"
|
|
3256
3276
|
};
|
|
3257
|
-
var Card =
|
|
3277
|
+
var Card = React5.forwardRef(
|
|
3258
3278
|
({
|
|
3259
3279
|
className,
|
|
3260
3280
|
variant = "bordered",
|
|
@@ -3290,9 +3310,9 @@ var Card = React4.forwardRef(
|
|
|
3290
3310
|
}
|
|
3291
3311
|
);
|
|
3292
3312
|
Card.displayName = "Card";
|
|
3293
|
-
var CardHeader =
|
|
3313
|
+
var CardHeader = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("mb-4", className), ...props }));
|
|
3294
3314
|
CardHeader.displayName = "CardHeader";
|
|
3295
|
-
var CardTitle =
|
|
3315
|
+
var CardTitle = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
3296
3316
|
"h3",
|
|
3297
3317
|
{
|
|
3298
3318
|
ref,
|
|
@@ -3305,11 +3325,11 @@ var CardTitle = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__
|
|
|
3305
3325
|
}
|
|
3306
3326
|
));
|
|
3307
3327
|
CardTitle.displayName = "CardTitle";
|
|
3308
|
-
var CardContent =
|
|
3328
|
+
var CardContent = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("", className), ...props }));
|
|
3309
3329
|
CardContent.displayName = "CardContent";
|
|
3310
3330
|
var CardBody = CardContent;
|
|
3311
3331
|
CardBody.displayName = "CardBody";
|
|
3312
|
-
var CardFooter =
|
|
3332
|
+
var CardFooter = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
3313
3333
|
"div",
|
|
3314
3334
|
{
|
|
3315
3335
|
ref,
|
|
@@ -3388,7 +3408,7 @@ var Divider = ({
|
|
|
3388
3408
|
);
|
|
3389
3409
|
};
|
|
3390
3410
|
Divider.displayName = "Divider";
|
|
3391
|
-
var Input =
|
|
3411
|
+
var Input = React5.forwardRef(
|
|
3392
3412
|
({
|
|
3393
3413
|
className,
|
|
3394
3414
|
inputType,
|
|
@@ -3656,7 +3676,7 @@ var DocBreadcrumb = ({
|
|
|
3656
3676
|
"aria-label": "Breadcrumb",
|
|
3657
3677
|
children: /* @__PURE__ */ jsx(HStack, { gap: "xs", align: "center", wrap: true, children: items.map((item, idx) => {
|
|
3658
3678
|
const isLast = idx === items.length - 1;
|
|
3659
|
-
return /* @__PURE__ */ jsxs(
|
|
3679
|
+
return /* @__PURE__ */ jsxs(React5.Fragment, { children: [
|
|
3660
3680
|
idx > 0 && /* @__PURE__ */ jsx(
|
|
3661
3681
|
Icon,
|
|
3662
3682
|
{
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -991,7 +991,23 @@ var fallbackEventBus = {
|
|
|
991
991
|
};
|
|
992
992
|
function useEventBus() {
|
|
993
993
|
const context = react.useContext(providers.EventBusContext);
|
|
994
|
-
|
|
994
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
995
|
+
const scope = providers.useTraitScope();
|
|
996
|
+
return react.useMemo(() => {
|
|
997
|
+
if (!scope) return baseBus;
|
|
998
|
+
return {
|
|
999
|
+
...baseBus,
|
|
1000
|
+
emit: (type, payload, source) => {
|
|
1001
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
1002
|
+
const tail = type.slice(3);
|
|
1003
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
1004
|
+
baseBus.emit(qualified, payload, source);
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
baseBus.emit(type, payload, source);
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
}, [baseBus, scope]);
|
|
995
1011
|
}
|
|
996
1012
|
function useEventListener(event, handler) {
|
|
997
1013
|
const eventBus = useEventBus();
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, useCallback, useState, useEffect, useMemo, useContext, useRef, useSyncExternalStore } from 'react';
|
|
2
|
-
import { EventBusContext } from '@almadar/ui/providers';
|
|
2
|
+
import { EventBusContext, useTraitScope } from '@almadar/ui/providers';
|
|
3
3
|
import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
5
|
function useOrbitalHistory(options) {
|
|
@@ -989,7 +989,23 @@ var fallbackEventBus = {
|
|
|
989
989
|
};
|
|
990
990
|
function useEventBus() {
|
|
991
991
|
const context = useContext(EventBusContext);
|
|
992
|
-
|
|
992
|
+
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
993
|
+
const scope = useTraitScope();
|
|
994
|
+
return useMemo(() => {
|
|
995
|
+
if (!scope) return baseBus;
|
|
996
|
+
return {
|
|
997
|
+
...baseBus,
|
|
998
|
+
emit: (type, payload, source) => {
|
|
999
|
+
if (typeof type === "string" && type.startsWith("UI:")) {
|
|
1000
|
+
const tail = type.slice(3);
|
|
1001
|
+
const qualified = tail.includes(".") ? type : `UI:${scope.orbital}.${scope.trait}.${tail}`;
|
|
1002
|
+
baseBus.emit(qualified, payload, source);
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
baseBus.emit(type, payload, source);
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
}, [baseBus, scope]);
|
|
993
1009
|
}
|
|
994
1010
|
function useEventListener(event, handler) {
|
|
995
1011
|
const eventBus = useEventBus();
|