@almadar/ui 5.13.2 → 5.14.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 +179 -119
- package/dist/avl/index.js +179 -119
- package/dist/components/index.cjs +431 -132
- package/dist/components/index.js +431 -133
- package/dist/components/molecules/Coachmark.d.ts +40 -0
- package/dist/components/molecules/OnboardingSpotlight.d.ts +27 -0
- package/dist/components/molecules/avl/avl-story-schemas.d.ts +1 -1
- package/dist/components/molecules/index.d.ts +2 -0
- package/dist/components/molecules/markdown/CodeBlock.d.ts +1 -1
- package/dist/providers/index.cjs +179 -119
- package/dist/providers/index.js +179 -119
- package/dist/runtime/index.cjs +179 -119
- package/dist/runtime/index.js +179 -119
- package/package.json +2 -2
- package/tailwind-preset.cjs +2 -0
package/dist/runtime/index.cjs
CHANGED
|
@@ -10,9 +10,9 @@ var LucideIcons2 = require('lucide-react');
|
|
|
10
10
|
var PhosphorIcons = require('@phosphor-icons/react');
|
|
11
11
|
var TablerIcons = require('@tabler/icons-react');
|
|
12
12
|
var FaIcons = require('react-icons/fa');
|
|
13
|
+
var reactDom = require('react-dom');
|
|
13
14
|
var evaluator = require('@almadar/evaluator');
|
|
14
15
|
var context = require('@almadar/ui/context');
|
|
15
|
-
var reactDom = require('react-dom');
|
|
16
16
|
var reactRouterDom = require('react-router-dom');
|
|
17
17
|
var ELK = require('elkjs/lib/elk.bundled.js');
|
|
18
18
|
var ReactMarkdown = require('react-markdown');
|
|
@@ -2276,7 +2276,7 @@ var init_Modal = __esm({
|
|
|
2276
2276
|
document.body.style.overflow = "";
|
|
2277
2277
|
};
|
|
2278
2278
|
}, [isOpen]);
|
|
2279
|
-
if (!isOpen) return null;
|
|
2279
|
+
if (!isOpen || typeof document === "undefined") return null;
|
|
2280
2280
|
const handleClose = () => {
|
|
2281
2281
|
if (closeEvent) eventBus.emit(`UI:${closeEvent}`, {});
|
|
2282
2282
|
onClose();
|
|
@@ -2286,124 +2286,127 @@ var init_Modal = __esm({
|
|
|
2286
2286
|
handleClose();
|
|
2287
2287
|
}
|
|
2288
2288
|
};
|
|
2289
|
-
return
|
|
2290
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
style: dragY > 0 ? {
|
|
2332
|
-
transform: `translateY(${dragY}px)`,
|
|
2333
|
-
transition: isDragging.current ? "none" : "transform 200ms ease-out"
|
|
2334
|
-
} : void 0,
|
|
2335
|
-
...title && { "aria-labelledby": "modal-title" },
|
|
2336
|
-
children: [
|
|
2337
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2338
|
-
Box,
|
|
2339
|
-
{
|
|
2340
|
-
className: "hidden max-sm:flex justify-center py-2 cursor-grab active:cursor-grabbing touch-none",
|
|
2341
|
-
onPointerDown: (e) => {
|
|
2342
|
-
if (!swipeDownToClose) return;
|
|
2343
|
-
dragStartY.current = e.clientY;
|
|
2344
|
-
isDragging.current = true;
|
|
2345
|
-
e.target.setPointerCapture(e.pointerId);
|
|
2346
|
-
},
|
|
2347
|
-
onPointerMove: (e) => {
|
|
2348
|
-
if (!isDragging.current) return;
|
|
2349
|
-
const dy = Math.max(0, e.clientY - dragStartY.current);
|
|
2350
|
-
setDragY(dy);
|
|
2351
|
-
},
|
|
2352
|
-
onPointerUp: () => {
|
|
2353
|
-
if (!isDragging.current) return;
|
|
2354
|
-
isDragging.current = false;
|
|
2355
|
-
if (dragY > 100) {
|
|
2356
|
-
handleClose();
|
|
2357
|
-
}
|
|
2358
|
-
setDragY(0);
|
|
2359
|
-
},
|
|
2360
|
-
onPointerCancel: () => {
|
|
2361
|
-
isDragging.current = false;
|
|
2362
|
-
setDragY(0);
|
|
2363
|
-
},
|
|
2364
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "w-10 h-1 rounded-full bg-border" })
|
|
2365
|
-
}
|
|
2289
|
+
return reactDom.createPortal(
|
|
2290
|
+
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2291
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2292
|
+
Overlay,
|
|
2293
|
+
{
|
|
2294
|
+
isVisible: isOpen,
|
|
2295
|
+
onClick: handleOverlayClick,
|
|
2296
|
+
className: "z-[1000]"
|
|
2297
|
+
}
|
|
2298
|
+
),
|
|
2299
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2300
|
+
Box,
|
|
2301
|
+
{
|
|
2302
|
+
className: cn(
|
|
2303
|
+
"fixed inset-0 z-[1001] pointer-events-none",
|
|
2304
|
+
"flex items-start justify-center px-4 pb-4 pt-[10vh]",
|
|
2305
|
+
"max-sm:items-stretch max-sm:p-0 max-sm:pt-0"
|
|
2306
|
+
),
|
|
2307
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2308
|
+
Dialog,
|
|
2309
|
+
{
|
|
2310
|
+
ref: modalRef,
|
|
2311
|
+
open: true,
|
|
2312
|
+
className: cn(
|
|
2313
|
+
// Reset browser-default dialog chrome — we own styling. `static`
|
|
2314
|
+
// overrides the user-agent `position: absolute` so the parent
|
|
2315
|
+
// flex container's `justify-center` actually centers the dialog
|
|
2316
|
+
// (without this, the dialog drops out of flex flow and `m-0`
|
|
2317
|
+
// kills the user-agent's `margin: auto` centering, pinning the
|
|
2318
|
+
// dialog to top-left).
|
|
2319
|
+
"static m-0 p-0 border-0 bg-transparent",
|
|
2320
|
+
// Pre-existing dialog frame
|
|
2321
|
+
"pointer-events-auto w-full flex flex-col bg-surface border shadow-elevation-dialog rounded-container",
|
|
2322
|
+
// Desktop sizing + viewport-aware floor.
|
|
2323
|
+
sizeClasses2[size],
|
|
2324
|
+
minWidthClasses[size],
|
|
2325
|
+
"max-h-[80vh]",
|
|
2326
|
+
// Mobile: take the entire screen. Override desktop max-w cap,
|
|
2327
|
+
// full height, no rounded corners, no min-width.
|
|
2328
|
+
"max-sm:max-w-none max-sm:max-h-none max-sm:w-full max-sm:h-full max-sm:rounded-none",
|
|
2329
|
+
lookStyles[look],
|
|
2330
|
+
className
|
|
2366
2331
|
),
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2332
|
+
style: dragY > 0 ? {
|
|
2333
|
+
transform: `translateY(${dragY}px)`,
|
|
2334
|
+
transition: isDragging.current ? "none" : "transform 200ms ease-out"
|
|
2335
|
+
} : void 0,
|
|
2336
|
+
...title && { "aria-labelledby": "modal-title" },
|
|
2337
|
+
children: [
|
|
2338
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2339
|
+
Box,
|
|
2340
|
+
{
|
|
2341
|
+
className: "hidden max-sm:flex justify-center py-2 cursor-grab active:cursor-grabbing touch-none",
|
|
2342
|
+
onPointerDown: (e) => {
|
|
2343
|
+
if (!swipeDownToClose) return;
|
|
2344
|
+
dragStartY.current = e.clientY;
|
|
2345
|
+
isDragging.current = true;
|
|
2346
|
+
e.target.setPointerCapture(e.pointerId);
|
|
2347
|
+
},
|
|
2348
|
+
onPointerMove: (e) => {
|
|
2349
|
+
if (!isDragging.current) return;
|
|
2350
|
+
const dy = Math.max(0, e.clientY - dragStartY.current);
|
|
2351
|
+
setDragY(dy);
|
|
2352
|
+
},
|
|
2353
|
+
onPointerUp: () => {
|
|
2354
|
+
if (!isDragging.current) return;
|
|
2355
|
+
isDragging.current = false;
|
|
2356
|
+
if (dragY > 100) {
|
|
2357
|
+
handleClose();
|
|
2385
2358
|
}
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2359
|
+
setDragY(0);
|
|
2360
|
+
},
|
|
2361
|
+
onPointerCancel: () => {
|
|
2362
|
+
isDragging.current = false;
|
|
2363
|
+
setDragY(0);
|
|
2364
|
+
},
|
|
2365
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "w-10 h-1 rounded-full bg-border" })
|
|
2366
|
+
}
|
|
2367
|
+
),
|
|
2368
|
+
(title || showCloseButton) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2369
|
+
Box,
|
|
2370
|
+
{
|
|
2371
|
+
className: cn(
|
|
2372
|
+
"px-6 py-4 flex items-center justify-between",
|
|
2373
|
+
"border-b-[length:var(--border-width)] border-border"
|
|
2374
|
+
),
|
|
2375
|
+
children: [
|
|
2376
|
+
title && /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h4", as: "h2", id: "modal-title", children: title }),
|
|
2377
|
+
showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2378
|
+
Button,
|
|
2379
|
+
{
|
|
2380
|
+
variant: "ghost",
|
|
2381
|
+
size: "sm",
|
|
2382
|
+
icon: "x",
|
|
2383
|
+
onClick: handleClose,
|
|
2384
|
+
"data-event": "CLOSE",
|
|
2385
|
+
"aria-label": "Close modal"
|
|
2386
|
+
}
|
|
2387
|
+
)
|
|
2388
|
+
]
|
|
2389
|
+
}
|
|
2390
|
+
),
|
|
2391
|
+
/* @__PURE__ */ jsxRuntime.jsx(Box, { className: "flex-1 overflow-y-auto p-6", children }),
|
|
2392
|
+
footer && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2393
|
+
Box,
|
|
2394
|
+
{
|
|
2395
|
+
className: cn(
|
|
2396
|
+
"px-6 py-4 bg-muted",
|
|
2397
|
+
"border-t-[length:var(--border-width)] border-border"
|
|
2398
|
+
),
|
|
2399
|
+
children: footer
|
|
2400
|
+
}
|
|
2401
|
+
)
|
|
2402
|
+
]
|
|
2403
|
+
}
|
|
2404
|
+
)
|
|
2405
|
+
}
|
|
2406
|
+
)
|
|
2407
|
+
] }),
|
|
2408
|
+
document.body
|
|
2409
|
+
);
|
|
2407
2410
|
};
|
|
2408
2411
|
Modal.displayName = "Modal";
|
|
2409
2412
|
}
|
|
@@ -13864,7 +13867,7 @@ var init_CodeBlock = __esm({
|
|
|
13864
13867
|
};
|
|
13865
13868
|
};
|
|
13866
13869
|
}, [errorLines]);
|
|
13867
|
-
const isFoldable = foldableProp ??
|
|
13870
|
+
const isFoldable = foldableProp ?? true;
|
|
13868
13871
|
const [collapsed, setCollapsed] = React85.useState(() => /* @__PURE__ */ new Set());
|
|
13869
13872
|
const foldRegions = React85.useMemo(
|
|
13870
13873
|
() => isFoldable ? computeFoldRegions(code) : [],
|
|
@@ -13887,6 +13890,8 @@ var init_CodeBlock = __esm({
|
|
|
13887
13890
|
collapsedRef.current = collapsed;
|
|
13888
13891
|
const foldStartMapRef = React85.useRef(foldStartMap);
|
|
13889
13892
|
foldStartMapRef.current = foldStartMap;
|
|
13893
|
+
const hiddenLinesRef = React85.useRef(hiddenLines);
|
|
13894
|
+
hiddenLinesRef.current = hiddenLines;
|
|
13890
13895
|
const toggleFold = React85.useCallback((lineNum) => {
|
|
13891
13896
|
setCollapsed((prev) => {
|
|
13892
13897
|
const next = new Set(prev);
|
|
@@ -13999,6 +14004,60 @@ var init_CodeBlock = __esm({
|
|
|
13999
14004
|
eventBus.emit("UI:COPY_CODE", { language, success: false });
|
|
14000
14005
|
}
|
|
14001
14006
|
};
|
|
14007
|
+
const handleSelectionCopy = React85.useCallback((e) => {
|
|
14008
|
+
if (hiddenLinesRef.current.size === 0) return;
|
|
14009
|
+
const sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
14010
|
+
if (!sel || sel.rangeCount === 0 || sel.isCollapsed) return;
|
|
14011
|
+
const lineOf = (node) => {
|
|
14012
|
+
const start = node instanceof HTMLElement ? node : node?.parentElement ?? null;
|
|
14013
|
+
const lineEl = start?.closest("[data-line]");
|
|
14014
|
+
if (!lineEl) return null;
|
|
14015
|
+
const n = parseInt(lineEl.getAttribute("data-line") ?? "", 10);
|
|
14016
|
+
return Number.isNaN(n) ? null : n;
|
|
14017
|
+
};
|
|
14018
|
+
const range = sel.getRangeAt(0);
|
|
14019
|
+
let a = lineOf(range.startContainer);
|
|
14020
|
+
let b = lineOf(range.endContainer);
|
|
14021
|
+
if (a === null || b === null) {
|
|
14022
|
+
const container = codeRef.current;
|
|
14023
|
+
if (!container) return;
|
|
14024
|
+
let min = Infinity, max = -Infinity;
|
|
14025
|
+
container.querySelectorAll("[data-line]").forEach((el) => {
|
|
14026
|
+
if (!sel.containsNode(el, true)) return;
|
|
14027
|
+
const n = parseInt(el.getAttribute("data-line") ?? "", 10);
|
|
14028
|
+
if (!Number.isNaN(n)) {
|
|
14029
|
+
min = Math.min(min, n);
|
|
14030
|
+
max = Math.max(max, n);
|
|
14031
|
+
}
|
|
14032
|
+
});
|
|
14033
|
+
if (min === Infinity) return;
|
|
14034
|
+
a = a ?? min;
|
|
14035
|
+
b = b ?? max;
|
|
14036
|
+
}
|
|
14037
|
+
if (a > b) [a, b] = [b, a];
|
|
14038
|
+
let touchesFold = false;
|
|
14039
|
+
for (let i = a; i <= b; i++) {
|
|
14040
|
+
if (hiddenLinesRef.current.has(i) || foldStartMapRef.current.has(i) && collapsedRef.current.has(i)) {
|
|
14041
|
+
touchesFold = true;
|
|
14042
|
+
break;
|
|
14043
|
+
}
|
|
14044
|
+
}
|
|
14045
|
+
if (!touchesFold) return;
|
|
14046
|
+
let endLine = b;
|
|
14047
|
+
let changed = true;
|
|
14048
|
+
while (changed) {
|
|
14049
|
+
changed = false;
|
|
14050
|
+
foldStartMapRef.current.forEach((region, start) => {
|
|
14051
|
+
if (start >= a && start <= endLine && collapsedRef.current.has(start) && region.end > endLine) {
|
|
14052
|
+
endLine = region.end;
|
|
14053
|
+
changed = true;
|
|
14054
|
+
}
|
|
14055
|
+
});
|
|
14056
|
+
}
|
|
14057
|
+
const full = code.split("\n").slice(a, endLine + 1).join("\n");
|
|
14058
|
+
e.clipboardData.setData("text/plain", full);
|
|
14059
|
+
e.preventDefault();
|
|
14060
|
+
}, [code]);
|
|
14002
14061
|
const hasHeader = showLanguageBadge || showCopyButton;
|
|
14003
14062
|
return /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: `relative group ${className || ""}`, style: { display: "flex", flexDirection: "column", height: "100%" }, children: [
|
|
14004
14063
|
hasHeader && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -14149,6 +14208,7 @@ var init_CodeBlock = __esm({
|
|
|
14149
14208
|
"div",
|
|
14150
14209
|
{
|
|
14151
14210
|
ref: scrollRef,
|
|
14211
|
+
onCopy: handleSelectionCopy,
|
|
14152
14212
|
style: {
|
|
14153
14213
|
flex: 1,
|
|
14154
14214
|
minHeight: 0,
|