@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');
@@ -2041,7 +2041,7 @@ var init_Modal = __esm({
2041
2041
  document.body.style.overflow = "";
2042
2042
  };
2043
2043
  }, [isOpen]);
2044
- if (!isOpen) return null;
2044
+ if (!isOpen || typeof document === "undefined") return null;
2045
2045
  const handleClose = () => {
2046
2046
  if (closeEvent) eventBus.emit(`UI:${closeEvent}`, {});
2047
2047
  onClose();
@@ -2051,124 +2051,127 @@ var init_Modal = __esm({
2051
2051
  handleClose();
2052
2052
  }
2053
2053
  };
2054
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2055
- /* @__PURE__ */ jsxRuntime.jsx(
2056
- Overlay,
2057
- {
2058
- isVisible: isOpen,
2059
- onClick: handleOverlayClick,
2060
- className: "z-40"
2061
- }
2062
- ),
2063
- /* @__PURE__ */ jsxRuntime.jsx(
2064
- Box,
2065
- {
2066
- className: cn(
2067
- "fixed inset-0 z-50 pointer-events-none",
2068
- "flex items-start justify-center px-4 pb-4 pt-[10vh]",
2069
- "max-sm:items-stretch max-sm:p-0 max-sm:pt-0"
2070
- ),
2071
- children: /* @__PURE__ */ jsxRuntime.jsxs(
2072
- Dialog,
2073
- {
2074
- ref: modalRef,
2075
- open: true,
2076
- className: cn(
2077
- // Reset browser-default dialog chrome — we own styling. `static`
2078
- // overrides the user-agent `position: absolute` so the parent
2079
- // flex container's `justify-center` actually centers the dialog
2080
- // (without this, the dialog drops out of flex flow and `m-0`
2081
- // kills the user-agent's `margin: auto` centering, pinning the
2082
- // dialog to top-left).
2083
- "static m-0 p-0 border-0 bg-transparent",
2084
- // Pre-existing dialog frame
2085
- "pointer-events-auto w-full flex flex-col bg-surface border shadow-elevation-dialog rounded-container",
2086
- // Desktop sizing + viewport-aware floor.
2087
- sizeClasses2[size],
2088
- minWidthClasses[size],
2089
- "max-h-[80vh]",
2090
- // Mobile: take the entire screen. Override desktop max-w cap,
2091
- // full height, no rounded corners, no min-width.
2092
- "max-sm:max-w-none max-sm:max-h-none max-sm:w-full max-sm:h-full max-sm:rounded-none",
2093
- lookStyles[look],
2094
- className
2095
- ),
2096
- style: dragY > 0 ? {
2097
- transform: `translateY(${dragY}px)`,
2098
- transition: isDragging.current ? "none" : "transform 200ms ease-out"
2099
- } : void 0,
2100
- ...title && { "aria-labelledby": "modal-title" },
2101
- children: [
2102
- /* @__PURE__ */ jsxRuntime.jsx(
2103
- Box,
2104
- {
2105
- className: "hidden max-sm:flex justify-center py-2 cursor-grab active:cursor-grabbing touch-none",
2106
- onPointerDown: (e) => {
2107
- if (!swipeDownToClose) return;
2108
- dragStartY.current = e.clientY;
2109
- isDragging.current = true;
2110
- e.target.setPointerCapture(e.pointerId);
2111
- },
2112
- onPointerMove: (e) => {
2113
- if (!isDragging.current) return;
2114
- const dy = Math.max(0, e.clientY - dragStartY.current);
2115
- setDragY(dy);
2116
- },
2117
- onPointerUp: () => {
2118
- if (!isDragging.current) return;
2119
- isDragging.current = false;
2120
- if (dragY > 100) {
2121
- handleClose();
2122
- }
2123
- setDragY(0);
2124
- },
2125
- onPointerCancel: () => {
2126
- isDragging.current = false;
2127
- setDragY(0);
2128
- },
2129
- children: /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "w-10 h-1 rounded-full bg-border" })
2130
- }
2054
+ return reactDom.createPortal(
2055
+ /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2056
+ /* @__PURE__ */ jsxRuntime.jsx(
2057
+ Overlay,
2058
+ {
2059
+ isVisible: isOpen,
2060
+ onClick: handleOverlayClick,
2061
+ className: "z-[1000]"
2062
+ }
2063
+ ),
2064
+ /* @__PURE__ */ jsxRuntime.jsx(
2065
+ Box,
2066
+ {
2067
+ className: cn(
2068
+ "fixed inset-0 z-[1001] pointer-events-none",
2069
+ "flex items-start justify-center px-4 pb-4 pt-[10vh]",
2070
+ "max-sm:items-stretch max-sm:p-0 max-sm:pt-0"
2071
+ ),
2072
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
2073
+ Dialog,
2074
+ {
2075
+ ref: modalRef,
2076
+ open: true,
2077
+ className: cn(
2078
+ // Reset browser-default dialog chrome we own styling. `static`
2079
+ // overrides the user-agent `position: absolute` so the parent
2080
+ // flex container's `justify-center` actually centers the dialog
2081
+ // (without this, the dialog drops out of flex flow and `m-0`
2082
+ // kills the user-agent's `margin: auto` centering, pinning the
2083
+ // dialog to top-left).
2084
+ "static m-0 p-0 border-0 bg-transparent",
2085
+ // Pre-existing dialog frame
2086
+ "pointer-events-auto w-full flex flex-col bg-surface border shadow-elevation-dialog rounded-container",
2087
+ // Desktop sizing + viewport-aware floor.
2088
+ sizeClasses2[size],
2089
+ minWidthClasses[size],
2090
+ "max-h-[80vh]",
2091
+ // Mobile: take the entire screen. Override desktop max-w cap,
2092
+ // full height, no rounded corners, no min-width.
2093
+ "max-sm:max-w-none max-sm:max-h-none max-sm:w-full max-sm:h-full max-sm:rounded-none",
2094
+ lookStyles[look],
2095
+ className
2131
2096
  ),
2132
- (title || showCloseButton) && /* @__PURE__ */ jsxRuntime.jsxs(
2133
- Box,
2134
- {
2135
- className: cn(
2136
- "px-6 py-4 flex items-center justify-between",
2137
- "border-b-[length:var(--border-width)] border-border"
2138
- ),
2139
- children: [
2140
- title && /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h4", as: "h2", id: "modal-title", children: title }),
2141
- showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(
2142
- Button,
2143
- {
2144
- variant: "ghost",
2145
- size: "sm",
2146
- icon: "x",
2147
- onClick: handleClose,
2148
- "data-event": "CLOSE",
2149
- "aria-label": "Close modal"
2097
+ style: dragY > 0 ? {
2098
+ transform: `translateY(${dragY}px)`,
2099
+ transition: isDragging.current ? "none" : "transform 200ms ease-out"
2100
+ } : void 0,
2101
+ ...title && { "aria-labelledby": "modal-title" },
2102
+ children: [
2103
+ /* @__PURE__ */ jsxRuntime.jsx(
2104
+ Box,
2105
+ {
2106
+ className: "hidden max-sm:flex justify-center py-2 cursor-grab active:cursor-grabbing touch-none",
2107
+ onPointerDown: (e) => {
2108
+ if (!swipeDownToClose) return;
2109
+ dragStartY.current = e.clientY;
2110
+ isDragging.current = true;
2111
+ e.target.setPointerCapture(e.pointerId);
2112
+ },
2113
+ onPointerMove: (e) => {
2114
+ if (!isDragging.current) return;
2115
+ const dy = Math.max(0, e.clientY - dragStartY.current);
2116
+ setDragY(dy);
2117
+ },
2118
+ onPointerUp: () => {
2119
+ if (!isDragging.current) return;
2120
+ isDragging.current = false;
2121
+ if (dragY > 100) {
2122
+ handleClose();
2150
2123
  }
2151
- )
2152
- ]
2153
- }
2154
- ),
2155
- /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "flex-1 overflow-y-auto p-6", children }),
2156
- footer && /* @__PURE__ */ jsxRuntime.jsx(
2157
- Box,
2158
- {
2159
- className: cn(
2160
- "px-6 py-4 bg-muted",
2161
- "border-t-[length:var(--border-width)] border-border"
2162
- ),
2163
- children: footer
2164
- }
2165
- )
2166
- ]
2167
- }
2168
- )
2169
- }
2170
- )
2171
- ] });
2124
+ setDragY(0);
2125
+ },
2126
+ onPointerCancel: () => {
2127
+ isDragging.current = false;
2128
+ setDragY(0);
2129
+ },
2130
+ children: /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "w-10 h-1 rounded-full bg-border" })
2131
+ }
2132
+ ),
2133
+ (title || showCloseButton) && /* @__PURE__ */ jsxRuntime.jsxs(
2134
+ Box,
2135
+ {
2136
+ className: cn(
2137
+ "px-6 py-4 flex items-center justify-between",
2138
+ "border-b-[length:var(--border-width)] border-border"
2139
+ ),
2140
+ children: [
2141
+ title && /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h4", as: "h2", id: "modal-title", children: title }),
2142
+ showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(
2143
+ Button,
2144
+ {
2145
+ variant: "ghost",
2146
+ size: "sm",
2147
+ icon: "x",
2148
+ onClick: handleClose,
2149
+ "data-event": "CLOSE",
2150
+ "aria-label": "Close modal"
2151
+ }
2152
+ )
2153
+ ]
2154
+ }
2155
+ ),
2156
+ /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "flex-1 overflow-y-auto p-6", children }),
2157
+ footer && /* @__PURE__ */ jsxRuntime.jsx(
2158
+ Box,
2159
+ {
2160
+ className: cn(
2161
+ "px-6 py-4 bg-muted",
2162
+ "border-t-[length:var(--border-width)] border-border"
2163
+ ),
2164
+ children: footer
2165
+ }
2166
+ )
2167
+ ]
2168
+ }
2169
+ )
2170
+ }
2171
+ )
2172
+ ] }),
2173
+ document.body
2174
+ );
2172
2175
  };
2173
2176
  Modal.displayName = "Modal";
2174
2177
  }
@@ -13964,7 +13967,7 @@ var init_CodeBlock = __esm({
13964
13967
  };
13965
13968
  };
13966
13969
  }, [errorLines]);
13967
- const isFoldable = foldableProp ?? (language === "orb" || language === "json");
13970
+ const isFoldable = foldableProp ?? true;
13968
13971
  const [collapsed, setCollapsed] = React86.useState(() => /* @__PURE__ */ new Set());
13969
13972
  const foldRegions = React86.useMemo(
13970
13973
  () => isFoldable ? computeFoldRegions(code) : [],
@@ -17903,6 +17906,7 @@ function CalendarGrid({
17903
17906
  swipeRightEvent,
17904
17907
  dayWindow = "auto"
17905
17908
  }) {
17909
+ const evs = Array.isArray(events2) ? events2 : events2 ? [events2] : [];
17906
17910
  const eventBus = useEventBus();
17907
17911
  const longPressTimer = React86.useRef(null);
17908
17912
  const resolvedWeekStart = React86.useMemo(
@@ -17951,7 +17955,7 @@ function CalendarGrid({
17951
17955
  [onEventClick]
17952
17956
  );
17953
17957
  const eventsForDayCount = React86.useCallback(
17954
- (day) => events2.filter(
17958
+ (day) => evs.filter(
17955
17959
  (ev) => new Date(ev.startTime).toDateString() === day.toDateString()
17956
17960
  ).length,
17957
17961
  [events2]
@@ -18066,7 +18070,7 @@ function CalendarGrid({
18066
18070
  }
18067
18071
  ) }),
18068
18072
  visibleDays.map((day) => {
18069
- const slotEvents = events2.filter(
18073
+ const slotEvents = evs.filter(
18070
18074
  (ev) => eventInSlot(ev, day, time)
18071
18075
  );
18072
18076
  const isToday = day.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
@@ -30291,7 +30295,7 @@ function useSafeEventBus10() {
30291
30295
  }
30292
30296
  }
30293
30297
  function SortableListInner({
30294
- items: initialItems = EMPTY_ITEMS,
30298
+ items: initialItemsProp = EMPTY_ITEMS,
30295
30299
  renderItem,
30296
30300
  reorderEvent,
30297
30301
  reorderPayload,
@@ -30299,6 +30303,7 @@ function SortableListInner({
30299
30303
  className
30300
30304
  }) {
30301
30305
  const eventBus = useSafeEventBus10();
30306
+ const initialItems = Array.isArray(initialItemsProp) ? initialItemsProp : initialItemsProp ? [initialItemsProp] : [];
30302
30307
  const handleReorder = React86.useCallback(
30303
30308
  (fromIndex, toIndex, item) => {
30304
30309
  eventBus.emit(`UI:${reorderEvent}`, {
@@ -33795,9 +33800,10 @@ var init_ReplyTree = __esm({
33795
33800
  showActions = true,
33796
33801
  className
33797
33802
  }) => {
33803
+ const nodeList = Array.isArray(nodes) ? nodes : nodes ? [nodes] : [];
33798
33804
  const [collapsedSet, setCollapsedSet] = React86.useState(() => {
33799
33805
  const acc = /* @__PURE__ */ new Set();
33800
- collectInitiallyCollapsed(nodes, acc);
33806
+ collectInitiallyCollapsed(nodeList, acc);
33801
33807
  return acc;
33802
33808
  });
33803
33809
  const toggleCollapse = React86.useCallback((id) => {
@@ -33811,10 +33817,10 @@ var init_ReplyTree = __esm({
33811
33817
  return next;
33812
33818
  });
33813
33819
  }, []);
33814
- if (nodes.length === 0) {
33820
+ if (nodeList.length === 0) {
33815
33821
  return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: cn("text-sm text-muted-foreground", className), children: "No replies yet." });
33816
33822
  }
33817
- return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: cn("flex flex-col gap-2 min-w-0", className), children: nodes.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
33823
+ return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: cn("flex flex-col gap-2 min-w-0", className), children: nodeList.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
33818
33824
  ReplyTreeNode,
33819
33825
  {
33820
33826
  node,