@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.
@@ -6309,7 +6309,7 @@ var init_Modal = __esm({
6309
6309
  document.body.style.overflow = "";
6310
6310
  };
6311
6311
  }, [isOpen]);
6312
- if (!isOpen) return null;
6312
+ if (!isOpen || typeof document === "undefined") return null;
6313
6313
  const handleClose = () => {
6314
6314
  if (closeEvent) eventBus.emit(`UI:${closeEvent}`, {});
6315
6315
  onClose();
@@ -6319,124 +6319,127 @@ var init_Modal = __esm({
6319
6319
  handleClose();
6320
6320
  }
6321
6321
  };
6322
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6323
- /* @__PURE__ */ jsxRuntime.jsx(
6324
- exports.Overlay,
6325
- {
6326
- isVisible: isOpen,
6327
- onClick: handleOverlayClick,
6328
- className: "z-40"
6329
- }
6330
- ),
6331
- /* @__PURE__ */ jsxRuntime.jsx(
6332
- exports.Box,
6333
- {
6334
- className: cn(
6335
- "fixed inset-0 z-50 pointer-events-none",
6336
- "flex items-start justify-center px-4 pb-4 pt-[10vh]",
6337
- "max-sm:items-stretch max-sm:p-0 max-sm:pt-0"
6338
- ),
6339
- children: /* @__PURE__ */ jsxRuntime.jsxs(
6340
- exports.Dialog,
6341
- {
6342
- ref: modalRef,
6343
- open: true,
6344
- className: cn(
6345
- // Reset browser-default dialog chrome — we own styling. `static`
6346
- // overrides the user-agent `position: absolute` so the parent
6347
- // flex container's `justify-center` actually centers the dialog
6348
- // (without this, the dialog drops out of flex flow and `m-0`
6349
- // kills the user-agent's `margin: auto` centering, pinning the
6350
- // dialog to top-left).
6351
- "static m-0 p-0 border-0 bg-transparent",
6352
- // Pre-existing dialog frame
6353
- "pointer-events-auto w-full flex flex-col bg-surface border shadow-elevation-dialog rounded-container",
6354
- // Desktop sizing + viewport-aware floor.
6355
- sizeClasses5[size],
6356
- minWidthClasses[size],
6357
- "max-h-[80vh]",
6358
- // Mobile: take the entire screen. Override desktop max-w cap,
6359
- // full height, no rounded corners, no min-width.
6360
- "max-sm:max-w-none max-sm:max-h-none max-sm:w-full max-sm:h-full max-sm:rounded-none",
6361
- lookStyles2[look],
6362
- className
6363
- ),
6364
- style: dragY > 0 ? {
6365
- transform: `translateY(${dragY}px)`,
6366
- transition: isDragging.current ? "none" : "transform 200ms ease-out"
6367
- } : void 0,
6368
- ...title && { "aria-labelledby": "modal-title" },
6369
- children: [
6370
- /* @__PURE__ */ jsxRuntime.jsx(
6371
- exports.Box,
6372
- {
6373
- className: "hidden max-sm:flex justify-center py-2 cursor-grab active:cursor-grabbing touch-none",
6374
- onPointerDown: (e) => {
6375
- if (!swipeDownToClose) return;
6376
- dragStartY.current = e.clientY;
6377
- isDragging.current = true;
6378
- e.target.setPointerCapture(e.pointerId);
6379
- },
6380
- onPointerMove: (e) => {
6381
- if (!isDragging.current) return;
6382
- const dy = Math.max(0, e.clientY - dragStartY.current);
6383
- setDragY(dy);
6384
- },
6385
- onPointerUp: () => {
6386
- if (!isDragging.current) return;
6387
- isDragging.current = false;
6388
- if (dragY > 100) {
6389
- handleClose();
6390
- }
6391
- setDragY(0);
6392
- },
6393
- onPointerCancel: () => {
6394
- isDragging.current = false;
6395
- setDragY(0);
6396
- },
6397
- children: /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "w-10 h-1 rounded-full bg-border" })
6398
- }
6322
+ return reactDom.createPortal(
6323
+ /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6324
+ /* @__PURE__ */ jsxRuntime.jsx(
6325
+ exports.Overlay,
6326
+ {
6327
+ isVisible: isOpen,
6328
+ onClick: handleOverlayClick,
6329
+ className: "z-[1000]"
6330
+ }
6331
+ ),
6332
+ /* @__PURE__ */ jsxRuntime.jsx(
6333
+ exports.Box,
6334
+ {
6335
+ className: cn(
6336
+ "fixed inset-0 z-[1001] pointer-events-none",
6337
+ "flex items-start justify-center px-4 pb-4 pt-[10vh]",
6338
+ "max-sm:items-stretch max-sm:p-0 max-sm:pt-0"
6339
+ ),
6340
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
6341
+ exports.Dialog,
6342
+ {
6343
+ ref: modalRef,
6344
+ open: true,
6345
+ className: cn(
6346
+ // Reset browser-default dialog chrome we own styling. `static`
6347
+ // overrides the user-agent `position: absolute` so the parent
6348
+ // flex container's `justify-center` actually centers the dialog
6349
+ // (without this, the dialog drops out of flex flow and `m-0`
6350
+ // kills the user-agent's `margin: auto` centering, pinning the
6351
+ // dialog to top-left).
6352
+ "static m-0 p-0 border-0 bg-transparent",
6353
+ // Pre-existing dialog frame
6354
+ "pointer-events-auto w-full flex flex-col bg-surface border shadow-elevation-dialog rounded-container",
6355
+ // Desktop sizing + viewport-aware floor.
6356
+ sizeClasses5[size],
6357
+ minWidthClasses[size],
6358
+ "max-h-[80vh]",
6359
+ // Mobile: take the entire screen. Override desktop max-w cap,
6360
+ // full height, no rounded corners, no min-width.
6361
+ "max-sm:max-w-none max-sm:max-h-none max-sm:w-full max-sm:h-full max-sm:rounded-none",
6362
+ lookStyles2[look],
6363
+ className
6399
6364
  ),
6400
- (title || showCloseButton) && /* @__PURE__ */ jsxRuntime.jsxs(
6401
- exports.Box,
6402
- {
6403
- className: cn(
6404
- "px-6 py-4 flex items-center justify-between",
6405
- "border-b-[length:var(--border-width)] border-border"
6406
- ),
6407
- children: [
6408
- title && /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "h4", as: "h2", id: "modal-title", children: title }),
6409
- showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(
6410
- exports.Button,
6411
- {
6412
- variant: "ghost",
6413
- size: "sm",
6414
- icon: "x",
6415
- onClick: handleClose,
6416
- "data-event": "CLOSE",
6417
- "aria-label": "Close modal"
6365
+ style: dragY > 0 ? {
6366
+ transform: `translateY(${dragY}px)`,
6367
+ transition: isDragging.current ? "none" : "transform 200ms ease-out"
6368
+ } : void 0,
6369
+ ...title && { "aria-labelledby": "modal-title" },
6370
+ children: [
6371
+ /* @__PURE__ */ jsxRuntime.jsx(
6372
+ exports.Box,
6373
+ {
6374
+ className: "hidden max-sm:flex justify-center py-2 cursor-grab active:cursor-grabbing touch-none",
6375
+ onPointerDown: (e) => {
6376
+ if (!swipeDownToClose) return;
6377
+ dragStartY.current = e.clientY;
6378
+ isDragging.current = true;
6379
+ e.target.setPointerCapture(e.pointerId);
6380
+ },
6381
+ onPointerMove: (e) => {
6382
+ if (!isDragging.current) return;
6383
+ const dy = Math.max(0, e.clientY - dragStartY.current);
6384
+ setDragY(dy);
6385
+ },
6386
+ onPointerUp: () => {
6387
+ if (!isDragging.current) return;
6388
+ isDragging.current = false;
6389
+ if (dragY > 100) {
6390
+ handleClose();
6418
6391
  }
6419
- )
6420
- ]
6421
- }
6422
- ),
6423
- /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "flex-1 overflow-y-auto p-6", children }),
6424
- footer && /* @__PURE__ */ jsxRuntime.jsx(
6425
- exports.Box,
6426
- {
6427
- className: cn(
6428
- "px-6 py-4 bg-muted",
6429
- "border-t-[length:var(--border-width)] border-border"
6430
- ),
6431
- children: footer
6432
- }
6433
- )
6434
- ]
6435
- }
6436
- )
6437
- }
6438
- )
6439
- ] });
6392
+ setDragY(0);
6393
+ },
6394
+ onPointerCancel: () => {
6395
+ isDragging.current = false;
6396
+ setDragY(0);
6397
+ },
6398
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "w-10 h-1 rounded-full bg-border" })
6399
+ }
6400
+ ),
6401
+ (title || showCloseButton) && /* @__PURE__ */ jsxRuntime.jsxs(
6402
+ exports.Box,
6403
+ {
6404
+ className: cn(
6405
+ "px-6 py-4 flex items-center justify-between",
6406
+ "border-b-[length:var(--border-width)] border-border"
6407
+ ),
6408
+ children: [
6409
+ title && /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "h4", as: "h2", id: "modal-title", children: title }),
6410
+ showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(
6411
+ exports.Button,
6412
+ {
6413
+ variant: "ghost",
6414
+ size: "sm",
6415
+ icon: "x",
6416
+ onClick: handleClose,
6417
+ "data-event": "CLOSE",
6418
+ "aria-label": "Close modal"
6419
+ }
6420
+ )
6421
+ ]
6422
+ }
6423
+ ),
6424
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "flex-1 overflow-y-auto p-6", children }),
6425
+ footer && /* @__PURE__ */ jsxRuntime.jsx(
6426
+ exports.Box,
6427
+ {
6428
+ className: cn(
6429
+ "px-6 py-4 bg-muted",
6430
+ "border-t-[length:var(--border-width)] border-border"
6431
+ ),
6432
+ children: footer
6433
+ }
6434
+ )
6435
+ ]
6436
+ }
6437
+ )
6438
+ }
6439
+ )
6440
+ ] }),
6441
+ document.body
6442
+ );
6440
6443
  };
6441
6444
  exports.Modal.displayName = "Modal";
6442
6445
  }
@@ -12488,7 +12491,7 @@ var init_CodeBlock = __esm({
12488
12491
  };
12489
12492
  };
12490
12493
  }, [errorLines]);
12491
- const isFoldable = foldableProp ?? (language === "orb" || language === "json");
12494
+ const isFoldable = foldableProp ?? true;
12492
12495
  const [collapsed, setCollapsed] = React80.useState(() => /* @__PURE__ */ new Set());
12493
12496
  const foldRegions = React80.useMemo(
12494
12497
  () => isFoldable ? computeFoldRegions(code) : [],
@@ -16427,6 +16430,7 @@ function CalendarGrid({
16427
16430
  swipeRightEvent,
16428
16431
  dayWindow = "auto"
16429
16432
  }) {
16433
+ const evs = Array.isArray(events2) ? events2 : events2 ? [events2] : [];
16430
16434
  const eventBus = useEventBus();
16431
16435
  const longPressTimer = React80.useRef(null);
16432
16436
  const resolvedWeekStart = React80.useMemo(
@@ -16475,7 +16479,7 @@ function CalendarGrid({
16475
16479
  [onEventClick]
16476
16480
  );
16477
16481
  const eventsForDayCount = React80.useCallback(
16478
- (day) => events2.filter(
16482
+ (day) => evs.filter(
16479
16483
  (ev) => new Date(ev.startTime).toDateString() === day.toDateString()
16480
16484
  ).length,
16481
16485
  [events2]
@@ -16590,7 +16594,7 @@ function CalendarGrid({
16590
16594
  }
16591
16595
  ) }),
16592
16596
  visibleDays.map((day) => {
16593
- const slotEvents = events2.filter(
16597
+ const slotEvents = evs.filter(
16594
16598
  (ev) => eventInSlot(ev, day, time)
16595
16599
  );
16596
16600
  const isToday = day.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
@@ -29338,7 +29342,7 @@ function useSafeEventBus10() {
29338
29342
  }
29339
29343
  }
29340
29344
  function SortableListInner({
29341
- items: initialItems = EMPTY_ITEMS,
29345
+ items: initialItemsProp = EMPTY_ITEMS,
29342
29346
  renderItem,
29343
29347
  reorderEvent,
29344
29348
  reorderPayload,
@@ -29346,6 +29350,7 @@ function SortableListInner({
29346
29350
  className
29347
29351
  }) {
29348
29352
  const eventBus = useSafeEventBus10();
29353
+ const initialItems = Array.isArray(initialItemsProp) ? initialItemsProp : initialItemsProp ? [initialItemsProp] : [];
29349
29354
  const handleReorder = React80.useCallback(
29350
29355
  (fromIndex, toIndex, item) => {
29351
29356
  eventBus.emit(`UI:${reorderEvent}`, {
@@ -32842,9 +32847,10 @@ var init_ReplyTree = __esm({
32842
32847
  showActions = true,
32843
32848
  className
32844
32849
  }) => {
32850
+ const nodeList = Array.isArray(nodes) ? nodes : nodes ? [nodes] : [];
32845
32851
  const [collapsedSet, setCollapsedSet] = React80.useState(() => {
32846
32852
  const acc = /* @__PURE__ */ new Set();
32847
- collectInitiallyCollapsed(nodes, acc);
32853
+ collectInitiallyCollapsed(nodeList, acc);
32848
32854
  return acc;
32849
32855
  });
32850
32856
  const toggleCollapse = React80.useCallback((id) => {
@@ -32858,10 +32864,10 @@ var init_ReplyTree = __esm({
32858
32864
  return next;
32859
32865
  });
32860
32866
  }, []);
32861
- if (nodes.length === 0) {
32867
+ if (nodeList.length === 0) {
32862
32868
  return /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: cn("text-sm text-muted-foreground", className), children: "No replies yet." });
32863
32869
  }
32864
- return /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: cn("flex flex-col gap-2 min-w-0", className), children: nodes.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
32870
+ return /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: cn("flex flex-col gap-2 min-w-0", className), children: nodeList.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
32865
32871
  ReplyTreeNode,
32866
32872
  {
32867
32873
  node,