@almadar/ui 5.13.2 → 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) : [],
@@ -10,9 +10,9 @@ import { Loader2, X, List, Printer, ChevronRight, ChevronLeft, GitBranch, Pencil
10
10
  import * as PhosphorIcons from '@phosphor-icons/react';
11
11
  import * as TablerIcons from '@tabler/icons-react';
12
12
  import * as FaIcons from 'react-icons/fa';
13
+ import { createPortal } from 'react-dom';
13
14
  import { evaluate, createMinimalContext } from '@almadar/evaluator';
14
15
  import { useUISlots } from '@almadar/ui/context';
15
- import { createPortal } from 'react-dom';
16
16
  import { Link, Outlet, useLocation } from 'react-router-dom';
17
17
  import ELK from 'elkjs/lib/elk.bundled.js';
18
18
  import ReactMarkdown from 'react-markdown';
@@ -1992,7 +1992,7 @@ var init_Modal = __esm({
1992
1992
  document.body.style.overflow = "";
1993
1993
  };
1994
1994
  }, [isOpen]);
1995
- if (!isOpen) return null;
1995
+ if (!isOpen || typeof document === "undefined") return null;
1996
1996
  const handleClose = () => {
1997
1997
  if (closeEvent) eventBus.emit(`UI:${closeEvent}`, {});
1998
1998
  onClose();
@@ -2002,124 +2002,127 @@ var init_Modal = __esm({
2002
2002
  handleClose();
2003
2003
  }
2004
2004
  };
2005
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2006
- /* @__PURE__ */ jsx(
2007
- Overlay,
2008
- {
2009
- isVisible: isOpen,
2010
- onClick: handleOverlayClick,
2011
- className: "z-40"
2012
- }
2013
- ),
2014
- /* @__PURE__ */ jsx(
2015
- Box,
2016
- {
2017
- className: cn(
2018
- "fixed inset-0 z-50 pointer-events-none",
2019
- "flex items-start justify-center px-4 pb-4 pt-[10vh]",
2020
- "max-sm:items-stretch max-sm:p-0 max-sm:pt-0"
2021
- ),
2022
- children: /* @__PURE__ */ jsxs(
2023
- Dialog,
2024
- {
2025
- ref: modalRef,
2026
- open: true,
2027
- className: cn(
2028
- // Reset browser-default dialog chrome — we own styling. `static`
2029
- // overrides the user-agent `position: absolute` so the parent
2030
- // flex container's `justify-center` actually centers the dialog
2031
- // (without this, the dialog drops out of flex flow and `m-0`
2032
- // kills the user-agent's `margin: auto` centering, pinning the
2033
- // dialog to top-left).
2034
- "static m-0 p-0 border-0 bg-transparent",
2035
- // Pre-existing dialog frame
2036
- "pointer-events-auto w-full flex flex-col bg-surface border shadow-elevation-dialog rounded-container",
2037
- // Desktop sizing + viewport-aware floor.
2038
- sizeClasses2[size],
2039
- minWidthClasses[size],
2040
- "max-h-[80vh]",
2041
- // Mobile: take the entire screen. Override desktop max-w cap,
2042
- // full height, no rounded corners, no min-width.
2043
- "max-sm:max-w-none max-sm:max-h-none max-sm:w-full max-sm:h-full max-sm:rounded-none",
2044
- lookStyles[look],
2045
- className
2046
- ),
2047
- style: dragY > 0 ? {
2048
- transform: `translateY(${dragY}px)`,
2049
- transition: isDragging.current ? "none" : "transform 200ms ease-out"
2050
- } : void 0,
2051
- ...title && { "aria-labelledby": "modal-title" },
2052
- children: [
2053
- /* @__PURE__ */ jsx(
2054
- Box,
2055
- {
2056
- className: "hidden max-sm:flex justify-center py-2 cursor-grab active:cursor-grabbing touch-none",
2057
- onPointerDown: (e) => {
2058
- if (!swipeDownToClose) return;
2059
- dragStartY.current = e.clientY;
2060
- isDragging.current = true;
2061
- e.target.setPointerCapture(e.pointerId);
2062
- },
2063
- onPointerMove: (e) => {
2064
- if (!isDragging.current) return;
2065
- const dy = Math.max(0, e.clientY - dragStartY.current);
2066
- setDragY(dy);
2067
- },
2068
- onPointerUp: () => {
2069
- if (!isDragging.current) return;
2070
- isDragging.current = false;
2071
- if (dragY > 100) {
2072
- handleClose();
2073
- }
2074
- setDragY(0);
2075
- },
2076
- onPointerCancel: () => {
2077
- isDragging.current = false;
2078
- setDragY(0);
2079
- },
2080
- children: /* @__PURE__ */ jsx(Box, { className: "w-10 h-1 rounded-full bg-border" })
2081
- }
2005
+ return createPortal(
2006
+ /* @__PURE__ */ jsxs(Fragment, { children: [
2007
+ /* @__PURE__ */ jsx(
2008
+ Overlay,
2009
+ {
2010
+ isVisible: isOpen,
2011
+ onClick: handleOverlayClick,
2012
+ className: "z-[1000]"
2013
+ }
2014
+ ),
2015
+ /* @__PURE__ */ jsx(
2016
+ Box,
2017
+ {
2018
+ className: cn(
2019
+ "fixed inset-0 z-[1001] pointer-events-none",
2020
+ "flex items-start justify-center px-4 pb-4 pt-[10vh]",
2021
+ "max-sm:items-stretch max-sm:p-0 max-sm:pt-0"
2022
+ ),
2023
+ children: /* @__PURE__ */ jsxs(
2024
+ Dialog,
2025
+ {
2026
+ ref: modalRef,
2027
+ open: true,
2028
+ className: cn(
2029
+ // Reset browser-default dialog chrome we own styling. `static`
2030
+ // overrides the user-agent `position: absolute` so the parent
2031
+ // flex container's `justify-center` actually centers the dialog
2032
+ // (without this, the dialog drops out of flex flow and `m-0`
2033
+ // kills the user-agent's `margin: auto` centering, pinning the
2034
+ // dialog to top-left).
2035
+ "static m-0 p-0 border-0 bg-transparent",
2036
+ // Pre-existing dialog frame
2037
+ "pointer-events-auto w-full flex flex-col bg-surface border shadow-elevation-dialog rounded-container",
2038
+ // Desktop sizing + viewport-aware floor.
2039
+ sizeClasses2[size],
2040
+ minWidthClasses[size],
2041
+ "max-h-[80vh]",
2042
+ // Mobile: take the entire screen. Override desktop max-w cap,
2043
+ // full height, no rounded corners, no min-width.
2044
+ "max-sm:max-w-none max-sm:max-h-none max-sm:w-full max-sm:h-full max-sm:rounded-none",
2045
+ lookStyles[look],
2046
+ className
2082
2047
  ),
2083
- (title || showCloseButton) && /* @__PURE__ */ jsxs(
2084
- Box,
2085
- {
2086
- className: cn(
2087
- "px-6 py-4 flex items-center justify-between",
2088
- "border-b-[length:var(--border-width)] border-border"
2089
- ),
2090
- children: [
2091
- title && /* @__PURE__ */ jsx(Typography, { variant: "h4", as: "h2", id: "modal-title", children: title }),
2092
- showCloseButton && /* @__PURE__ */ jsx(
2093
- Button,
2094
- {
2095
- variant: "ghost",
2096
- size: "sm",
2097
- icon: "x",
2098
- onClick: handleClose,
2099
- "data-event": "CLOSE",
2100
- "aria-label": "Close modal"
2048
+ style: dragY > 0 ? {
2049
+ transform: `translateY(${dragY}px)`,
2050
+ transition: isDragging.current ? "none" : "transform 200ms ease-out"
2051
+ } : void 0,
2052
+ ...title && { "aria-labelledby": "modal-title" },
2053
+ children: [
2054
+ /* @__PURE__ */ jsx(
2055
+ Box,
2056
+ {
2057
+ className: "hidden max-sm:flex justify-center py-2 cursor-grab active:cursor-grabbing touch-none",
2058
+ onPointerDown: (e) => {
2059
+ if (!swipeDownToClose) return;
2060
+ dragStartY.current = e.clientY;
2061
+ isDragging.current = true;
2062
+ e.target.setPointerCapture(e.pointerId);
2063
+ },
2064
+ onPointerMove: (e) => {
2065
+ if (!isDragging.current) return;
2066
+ const dy = Math.max(0, e.clientY - dragStartY.current);
2067
+ setDragY(dy);
2068
+ },
2069
+ onPointerUp: () => {
2070
+ if (!isDragging.current) return;
2071
+ isDragging.current = false;
2072
+ if (dragY > 100) {
2073
+ handleClose();
2101
2074
  }
2102
- )
2103
- ]
2104
- }
2105
- ),
2106
- /* @__PURE__ */ jsx(Box, { className: "flex-1 overflow-y-auto p-6", children }),
2107
- footer && /* @__PURE__ */ jsx(
2108
- Box,
2109
- {
2110
- className: cn(
2111
- "px-6 py-4 bg-muted",
2112
- "border-t-[length:var(--border-width)] border-border"
2113
- ),
2114
- children: footer
2115
- }
2116
- )
2117
- ]
2118
- }
2119
- )
2120
- }
2121
- )
2122
- ] });
2075
+ setDragY(0);
2076
+ },
2077
+ onPointerCancel: () => {
2078
+ isDragging.current = false;
2079
+ setDragY(0);
2080
+ },
2081
+ children: /* @__PURE__ */ jsx(Box, { className: "w-10 h-1 rounded-full bg-border" })
2082
+ }
2083
+ ),
2084
+ (title || showCloseButton) && /* @__PURE__ */ jsxs(
2085
+ Box,
2086
+ {
2087
+ className: cn(
2088
+ "px-6 py-4 flex items-center justify-between",
2089
+ "border-b-[length:var(--border-width)] border-border"
2090
+ ),
2091
+ children: [
2092
+ title && /* @__PURE__ */ jsx(Typography, { variant: "h4", as: "h2", id: "modal-title", children: title }),
2093
+ showCloseButton && /* @__PURE__ */ jsx(
2094
+ Button,
2095
+ {
2096
+ variant: "ghost",
2097
+ size: "sm",
2098
+ icon: "x",
2099
+ onClick: handleClose,
2100
+ "data-event": "CLOSE",
2101
+ "aria-label": "Close modal"
2102
+ }
2103
+ )
2104
+ ]
2105
+ }
2106
+ ),
2107
+ /* @__PURE__ */ jsx(Box, { className: "flex-1 overflow-y-auto p-6", children }),
2108
+ footer && /* @__PURE__ */ jsx(
2109
+ Box,
2110
+ {
2111
+ className: cn(
2112
+ "px-6 py-4 bg-muted",
2113
+ "border-t-[length:var(--border-width)] border-border"
2114
+ ),
2115
+ children: footer
2116
+ }
2117
+ )
2118
+ ]
2119
+ }
2120
+ )
2121
+ }
2122
+ )
2123
+ ] }),
2124
+ document.body
2125
+ );
2123
2126
  };
2124
2127
  Modal.displayName = "Modal";
2125
2128
  }
@@ -13915,7 +13918,7 @@ var init_CodeBlock = __esm({
13915
13918
  };
13916
13919
  };
13917
13920
  }, [errorLines]);
13918
- const isFoldable = foldableProp ?? (language === "orb" || language === "json");
13921
+ const isFoldable = foldableProp ?? true;
13919
13922
  const [collapsed, setCollapsed] = useState(() => /* @__PURE__ */ new Set());
13920
13923
  const foldRegions = useMemo(
13921
13924
  () => isFoldable ? computeFoldRegions(code) : [],