@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
|
@@ -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();
|
|
@@ -17335,8 +17351,7 @@ function formatValue(value, format) {
|
|
|
17335
17351
|
}
|
|
17336
17352
|
function DataGrid({
|
|
17337
17353
|
entity,
|
|
17338
|
-
fields
|
|
17339
|
-
columns: columnsProp,
|
|
17354
|
+
fields,
|
|
17340
17355
|
itemActions,
|
|
17341
17356
|
cols,
|
|
17342
17357
|
gap = "md",
|
|
@@ -17357,7 +17372,6 @@ function DataGrid({
|
|
|
17357
17372
|
const { t } = useTranslate();
|
|
17358
17373
|
const [selectedIds, setSelectedIds] = React111.useState(/* @__PURE__ */ new Set());
|
|
17359
17374
|
const [visibleCount, setVisibleCount] = React111.useState(pageSize || Infinity);
|
|
17360
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
17361
17375
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
17362
17376
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
17363
17377
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -17700,8 +17714,7 @@ function groupData(items, field) {
|
|
|
17700
17714
|
}
|
|
17701
17715
|
function DataList({
|
|
17702
17716
|
entity,
|
|
17703
|
-
fields
|
|
17704
|
-
columns: columnsProp,
|
|
17717
|
+
fields,
|
|
17705
17718
|
itemActions,
|
|
17706
17719
|
gap = "none",
|
|
17707
17720
|
variant = "default",
|
|
@@ -17730,7 +17743,6 @@ function DataList({
|
|
|
17730
17743
|
const eventBus = useEventBus();
|
|
17731
17744
|
const { t } = useTranslate();
|
|
17732
17745
|
const [visibleCount, setVisibleCount] = React111__namespace.default.useState(pageSize || Infinity);
|
|
17733
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
17734
17746
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
17735
17747
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
17736
17748
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -37345,6 +37357,17 @@ function renderContainedPortal(slot, content, onDismiss) {
|
|
|
37345
37357
|
return /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { id: slotId, children: slotContent });
|
|
37346
37358
|
}
|
|
37347
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
|
+
}
|
|
37348
37371
|
function UISlotComponent({
|
|
37349
37372
|
slot,
|
|
37350
37373
|
portal = false,
|
|
@@ -37372,11 +37395,11 @@ function UISlotComponent({
|
|
|
37372
37395
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37373
37396
|
"data-pattern": pattern,
|
|
37374
37397
|
"data-source-trait": sourceTrait,
|
|
37375
|
-
children
|
|
37398
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37376
37399
|
}
|
|
37377
37400
|
);
|
|
37378
37401
|
}
|
|
37379
|
-
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 }) });
|
|
37380
37403
|
}
|
|
37381
37404
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
37382
37405
|
exports.Box,
|
|
@@ -37385,7 +37408,7 @@ function UISlotComponent({
|
|
|
37385
37408
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37386
37409
|
"data-pattern": pattern,
|
|
37387
37410
|
"data-source-trait": sourceTrait,
|
|
37388
|
-
children
|
|
37411
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37389
37412
|
}
|
|
37390
37413
|
);
|
|
37391
37414
|
}
|
|
@@ -37431,7 +37454,7 @@ function UISlotComponent({
|
|
|
37431
37454
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37432
37455
|
"data-pattern": content.pattern,
|
|
37433
37456
|
"data-source-trait": content.sourceTrait,
|
|
37434
|
-
children: wrappedContent
|
|
37457
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: wrappedContent })
|
|
37435
37458
|
}
|
|
37436
37459
|
);
|
|
37437
37460
|
}
|
|
@@ -37539,7 +37562,7 @@ function SlotPortal({
|
|
|
37539
37562
|
});
|
|
37540
37563
|
if (!portalRoot) return null;
|
|
37541
37564
|
const slotId = `slot-${slot}`;
|
|
37542
|
-
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 }) });
|
|
37543
37566
|
let wrapper;
|
|
37544
37567
|
switch (slot) {
|
|
37545
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();
|
|
@@ -17290,8 +17306,7 @@ function formatValue(value, format) {
|
|
|
17290
17306
|
}
|
|
17291
17307
|
function DataGrid({
|
|
17292
17308
|
entity,
|
|
17293
|
-
fields
|
|
17294
|
-
columns: columnsProp,
|
|
17309
|
+
fields,
|
|
17295
17310
|
itemActions,
|
|
17296
17311
|
cols,
|
|
17297
17312
|
gap = "md",
|
|
@@ -17312,7 +17327,6 @@ function DataGrid({
|
|
|
17312
17327
|
const { t } = useTranslate();
|
|
17313
17328
|
const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
|
|
17314
17329
|
const [visibleCount, setVisibleCount] = useState(pageSize || Infinity);
|
|
17315
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
17316
17330
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
17317
17331
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
17318
17332
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -17655,8 +17669,7 @@ function groupData(items, field) {
|
|
|
17655
17669
|
}
|
|
17656
17670
|
function DataList({
|
|
17657
17671
|
entity,
|
|
17658
|
-
fields
|
|
17659
|
-
columns: columnsProp,
|
|
17672
|
+
fields,
|
|
17660
17673
|
itemActions,
|
|
17661
17674
|
gap = "none",
|
|
17662
17675
|
variant = "default",
|
|
@@ -17685,7 +17698,6 @@ function DataList({
|
|
|
17685
17698
|
const eventBus = useEventBus();
|
|
17686
17699
|
const { t } = useTranslate();
|
|
17687
17700
|
const [visibleCount, setVisibleCount] = React111__default.useState(pageSize || Infinity);
|
|
17688
|
-
const fields = fieldsProp ?? columnsProp ?? [];
|
|
17689
17701
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
17690
17702
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
17691
17703
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -37300,6 +37312,17 @@ function renderContainedPortal(slot, content, onDismiss) {
|
|
|
37300
37312
|
return /* @__PURE__ */ jsx(Box, { id: slotId, children: slotContent });
|
|
37301
37313
|
}
|
|
37302
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
|
+
}
|
|
37303
37326
|
function UISlotComponent({
|
|
37304
37327
|
slot,
|
|
37305
37328
|
portal = false,
|
|
@@ -37327,11 +37350,11 @@ function UISlotComponent({
|
|
|
37327
37350
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37328
37351
|
"data-pattern": pattern,
|
|
37329
37352
|
"data-source-trait": sourceTrait,
|
|
37330
|
-
children
|
|
37353
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37331
37354
|
}
|
|
37332
37355
|
);
|
|
37333
37356
|
}
|
|
37334
|
-
return /* @__PURE__ */ jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children });
|
|
37357
|
+
return /* @__PURE__ */ jsx(CompiledPortal, { slot, className, pattern, sourceTrait, children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children }) });
|
|
37335
37358
|
}
|
|
37336
37359
|
return /* @__PURE__ */ jsx(
|
|
37337
37360
|
Box,
|
|
@@ -37340,7 +37363,7 @@ function UISlotComponent({
|
|
|
37340
37363
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37341
37364
|
"data-pattern": pattern,
|
|
37342
37365
|
"data-source-trait": sourceTrait,
|
|
37343
|
-
children
|
|
37366
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait, children })
|
|
37344
37367
|
}
|
|
37345
37368
|
);
|
|
37346
37369
|
}
|
|
@@ -37386,7 +37409,7 @@ function UISlotComponent({
|
|
|
37386
37409
|
className: cn("ui-slot", `ui-slot-${slot}`, className),
|
|
37387
37410
|
"data-pattern": content.pattern,
|
|
37388
37411
|
"data-source-trait": content.sourceTrait,
|
|
37389
|
-
children: wrappedContent
|
|
37412
|
+
children: /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: wrappedContent })
|
|
37390
37413
|
}
|
|
37391
37414
|
);
|
|
37392
37415
|
}
|
|
@@ -37494,7 +37517,7 @@ function SlotPortal({
|
|
|
37494
37517
|
});
|
|
37495
37518
|
if (!portalRoot) return null;
|
|
37496
37519
|
const slotId = `slot-${slot}`;
|
|
37497
|
-
const slotContent = /* @__PURE__ */ jsx(SlotContentRenderer, { content, onDismiss });
|
|
37520
|
+
const slotContent = /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait: content.sourceTrait, children: /* @__PURE__ */ jsx(SlotContentRenderer, { content, onDismiss }) });
|
|
37498
37521
|
let wrapper;
|
|
37499
37522
|
switch (slot) {
|
|
37500
37523
|
case "modal":
|
|
@@ -57,8 +57,6 @@ export interface DataGridProps<T extends EntityRow = EntityRow> {
|
|
|
57
57
|
entity: T | readonly T[];
|
|
58
58
|
/** Field definitions for rendering each card */
|
|
59
59
|
fields: readonly DataGridField[];
|
|
60
|
-
/** Alias for fields (compiler generates `columns` for field definitions) */
|
|
61
|
-
columns?: readonly DataGridField[];
|
|
62
60
|
/** Per-item action buttons */
|
|
63
61
|
itemActions?: readonly DataGridItemAction[];
|
|
64
62
|
/** Number of columns (uses auto-fit if omitted) */
|
|
@@ -98,7 +96,7 @@ export interface DataGridProps<T extends EntityRow = EntityRow> {
|
|
|
98
96
|
/** Max items to show before "Show More" button. Defaults to 0 (disabled). */
|
|
99
97
|
pageSize?: number;
|
|
100
98
|
}
|
|
101
|
-
export declare function DataGrid<T extends EntityRow = EntityRow>({ entity, fields
|
|
99
|
+
export declare function DataGrid<T extends EntityRow = EntityRow>({ entity, fields, itemActions, cols, gap, minCardWidth, className, isLoading, error, imageField, selectable, selectionEvent, infiniteScroll, loadMoreEvent, hasMore, children, pageSize, }: DataGridProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
102
100
|
export declare namespace DataGrid {
|
|
103
101
|
var displayName: string;
|
|
104
102
|
}
|
|
@@ -47,8 +47,6 @@ export interface DataListProps<T extends EntityRow = EntityRow> {
|
|
|
47
47
|
entity: T | readonly T[];
|
|
48
48
|
/** Field definitions for rendering each row */
|
|
49
49
|
fields: readonly DataListField[];
|
|
50
|
-
/** Alias for fields (compiler may generate `columns` for field definitions) */
|
|
51
|
-
columns?: readonly DataListField[];
|
|
52
50
|
/** Per-item action buttons */
|
|
53
51
|
itemActions?: readonly DataListItemAction[];
|
|
54
52
|
/** Gap between rows */
|
|
@@ -112,7 +110,7 @@ export interface DataListProps<T extends EntityRow = EntityRow> {
|
|
|
112
110
|
/** Max items to show before "Show More" button. Defaults to 5. Set to 0 to disable. */
|
|
113
111
|
pageSize?: number;
|
|
114
112
|
}
|
|
115
|
-
export declare function DataList<T extends EntityRow = EntityRow>({ entity, fields
|
|
113
|
+
export declare function DataList<T extends EntityRow = EntityRow>({ entity, fields, itemActions, gap, variant, groupBy, senderField, currentUser, className, isLoading, error, reorderable: _reorderable, reorderEvent: _reorderEvent, swipeLeftEvent: _swipeLeftEvent, swipeLeftActions: _swipeLeftActions, swipeRightEvent: _swipeRightEvent, swipeRightActions: _swipeRightActions, longPressEvent: _longPressEvent, infiniteScroll, loadMoreEvent, hasMore, children, pageSize, }: DataListProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
116
114
|
export declare namespace DataList {
|
|
117
115
|
var displayName: string;
|
|
118
116
|
}
|
|
@@ -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);
|