@almadar/ui 5.12.1 → 5.13.3

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.
@@ -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 /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2290
- /* @__PURE__ */ jsxRuntime.jsx(
2291
- Overlay,
2292
- {
2293
- isVisible: isOpen,
2294
- onClick: handleOverlayClick,
2295
- className: "z-40"
2296
- }
2297
- ),
2298
- /* @__PURE__ */ jsxRuntime.jsx(
2299
- Box,
2300
- {
2301
- className: cn(
2302
- "fixed inset-0 z-50 pointer-events-none",
2303
- "flex items-start justify-center px-4 pb-4 pt-[10vh]",
2304
- "max-sm:items-stretch max-sm:p-0 max-sm:pt-0"
2305
- ),
2306
- children: /* @__PURE__ */ jsxRuntime.jsxs(
2307
- Dialog,
2308
- {
2309
- ref: modalRef,
2310
- open: true,
2311
- className: cn(
2312
- // Reset browser-default dialog chrome — we own styling. `static`
2313
- // overrides the user-agent `position: absolute` so the parent
2314
- // flex container's `justify-center` actually centers the dialog
2315
- // (without this, the dialog drops out of flex flow and `m-0`
2316
- // kills the user-agent's `margin: auto` centering, pinning the
2317
- // dialog to top-left).
2318
- "static m-0 p-0 border-0 bg-transparent",
2319
- // Pre-existing dialog frame
2320
- "pointer-events-auto w-full flex flex-col bg-surface border shadow-elevation-dialog rounded-container",
2321
- // Desktop sizing + viewport-aware floor.
2322
- sizeClasses2[size],
2323
- minWidthClasses[size],
2324
- "max-h-[80vh]",
2325
- // Mobile: take the entire screen. Override desktop max-w cap,
2326
- // full height, no rounded corners, no min-width.
2327
- "max-sm:max-w-none max-sm:max-h-none max-sm:w-full max-sm:h-full max-sm:rounded-none",
2328
- lookStyles[look],
2329
- className
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
- (title || showCloseButton) && /* @__PURE__ */ jsxRuntime.jsxs(
2368
- Box,
2369
- {
2370
- className: cn(
2371
- "px-6 py-4 flex items-center justify-between",
2372
- "border-b-[length:var(--border-width)] border-border"
2373
- ),
2374
- children: [
2375
- title && /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h4", as: "h2", id: "modal-title", children: title }),
2376
- showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(
2377
- Button,
2378
- {
2379
- variant: "ghost",
2380
- size: "sm",
2381
- icon: "x",
2382
- onClick: handleClose,
2383
- "data-event": "CLOSE",
2384
- "aria-label": "Close modal"
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
- /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "flex-1 overflow-y-auto p-6", children }),
2391
- footer && /* @__PURE__ */ jsxRuntime.jsx(
2392
- Box,
2393
- {
2394
- className: cn(
2395
- "px-6 py-4 bg-muted",
2396
- "border-t-[length:var(--border-width)] border-border"
2397
- ),
2398
- children: footer
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 ?? (language === "orb" || language === "json");
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) : [],
@@ -17686,6 +17689,7 @@ function CalendarGrid({
17686
17689
  swipeRightEvent,
17687
17690
  dayWindow = "auto"
17688
17691
  }) {
17692
+ const evs = Array.isArray(events2) ? events2 : events2 ? [events2] : [];
17689
17693
  const eventBus = useEventBus();
17690
17694
  const longPressTimer = React85.useRef(null);
17691
17695
  const resolvedWeekStart = React85.useMemo(
@@ -17734,7 +17738,7 @@ function CalendarGrid({
17734
17738
  [onEventClick]
17735
17739
  );
17736
17740
  const eventsForDayCount = React85.useCallback(
17737
- (day) => events2.filter(
17741
+ (day) => evs.filter(
17738
17742
  (ev) => new Date(ev.startTime).toDateString() === day.toDateString()
17739
17743
  ).length,
17740
17744
  [events2]
@@ -17849,7 +17853,7 @@ function CalendarGrid({
17849
17853
  }
17850
17854
  ) }),
17851
17855
  visibleDays.map((day) => {
17852
- const slotEvents = events2.filter(
17856
+ const slotEvents = evs.filter(
17853
17857
  (ev) => eventInSlot(ev, day, time)
17854
17858
  );
17855
17859
  const isToday = day.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
@@ -29923,7 +29927,7 @@ function useSafeEventBus10() {
29923
29927
  }
29924
29928
  }
29925
29929
  function SortableListInner({
29926
- items: initialItems = EMPTY_ITEMS,
29930
+ items: initialItemsProp = EMPTY_ITEMS,
29927
29931
  renderItem,
29928
29932
  reorderEvent,
29929
29933
  reorderPayload,
@@ -29931,6 +29935,7 @@ function SortableListInner({
29931
29935
  className
29932
29936
  }) {
29933
29937
  const eventBus = useSafeEventBus10();
29938
+ const initialItems = Array.isArray(initialItemsProp) ? initialItemsProp : initialItemsProp ? [initialItemsProp] : [];
29934
29939
  const handleReorder = React85.useCallback(
29935
29940
  (fromIndex, toIndex, item) => {
29936
29941
  eventBus.emit(`UI:${reorderEvent}`, {
@@ -33362,9 +33367,10 @@ var init_ReplyTree = __esm({
33362
33367
  showActions = true,
33363
33368
  className
33364
33369
  }) => {
33370
+ const nodeList = Array.isArray(nodes) ? nodes : nodes ? [nodes] : [];
33365
33371
  const [collapsedSet, setCollapsedSet] = React85.useState(() => {
33366
33372
  const acc = /* @__PURE__ */ new Set();
33367
- collectInitiallyCollapsed(nodes, acc);
33373
+ collectInitiallyCollapsed(nodeList, acc);
33368
33374
  return acc;
33369
33375
  });
33370
33376
  const toggleCollapse = React85.useCallback((id) => {
@@ -33378,10 +33384,10 @@ var init_ReplyTree = __esm({
33378
33384
  return next;
33379
33385
  });
33380
33386
  }, []);
33381
- if (nodes.length === 0) {
33387
+ if (nodeList.length === 0) {
33382
33388
  return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: cn("text-sm text-muted-foreground", className), children: "No replies yet." });
33383
33389
  }
33384
- return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: cn("flex flex-col gap-2 min-w-0", className), children: nodes.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
33390
+ return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: cn("flex flex-col gap-2 min-w-0", className), children: nodeList.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
33385
33391
  ReplyTreeNode,
33386
33392
  {
33387
33393
  node,