@justanarthur/modo-ui 2.4.0 → 2.6.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.
Files changed (62) hide show
  1. package/blocks/desktop-shell/index.tsx +3 -2
  2. package/components/data-display/diff/index.tsx +5 -4
  3. package/components/data-display/markdown/index.tsx +6 -6
  4. package/components/navigation/sidebar/index.tsx +48 -1
  5. package/components/navigation/tabs/list.tsx +1 -5
  6. package/dist/blocks/desktop-shell/index.js +5 -5
  7. package/dist/blocks/sidebar-app/index.js +6 -6
  8. package/dist/components/containers/accordion/index.js +2 -2
  9. package/dist/components/containers/card/index.js +2 -2
  10. package/dist/components/data-display/diff/index.d.ts +2 -1
  11. package/dist/components/data-display/diff/index.js +3 -2
  12. package/dist/components/data-display/markdown/index.js +5 -5
  13. package/dist/components/data-display/table/index.js +2 -2
  14. package/dist/components/inputs/combobox/index.js +3 -2
  15. package/dist/components/inputs/search/index.js +4 -3
  16. package/dist/components/inputs/select/index.js +3 -2
  17. package/dist/components/inputs/textarea/index.js +3 -3
  18. package/dist/components/navigation/breadcrumb/index.js +4 -4
  19. package/dist/components/navigation/sidebar/index.js +3 -3
  20. package/dist/components/navigation/tabs/index.js +1 -1
  21. package/dist/components/overlays/command/index.js +3 -2
  22. package/dist/components/overlays/context-menu/index.js +4 -4
  23. package/dist/components/overlays/dropdown/index.js +3 -3
  24. package/dist/docs/index.js +4 -4
  25. package/dist/index.d.ts +15 -7
  26. package/dist/index.js +22 -22
  27. package/dist/lib/use-autosize-textarea.d.ts +6 -4
  28. package/dist/lib/use-autosize-textarea.js +1 -1
  29. package/dist/primitives/content/code/index.d.ts +3 -1
  30. package/dist/primitives/content/code/index.js +3 -2
  31. package/dist/primitives/layout/resizable/index.js +1 -1
  32. package/dist/primitives/layout/scroll-area/index.d.ts +4 -1
  33. package/dist/primitives/layout/scroll-area/index.js +2 -1
  34. package/dist/shared/{components-8xe4h118.js → components-3fg6vabb.js} +1 -4
  35. package/dist/shared/{components-esy5nsvc.js → components-5fet4gqt.js} +71 -7
  36. package/dist/shared/{components-y4gsk1jt.js → components-60tf8tfa.js} +10 -6
  37. package/dist/shared/components-7v6ncqfc.js +80 -0
  38. package/dist/shared/{components-sh8j39z3.js → components-8swhfkqn.js} +1 -1
  39. package/dist/shared/{components-pwsqp2np.js → components-94vd4ck1.js} +1 -1
  40. package/dist/shared/{components-rgdspnth.js → components-9c3m65ft.js} +1 -1
  41. package/dist/shared/{components-xq8j9c2f.js → components-a8bcq2yc.js} +1 -1
  42. package/dist/shared/{components-cc9kfhkb.js → components-bkg1k36x.js} +46 -11
  43. package/dist/shared/{components-qmkfpcw0.js → components-faym1xm6.js} +1 -1
  44. package/dist/shared/{components-gr82tz50.js → components-fbs2602j.js} +4 -3
  45. package/dist/shared/{components-ypxst3cn.js → components-ftvy33w9.js} +1 -1
  46. package/dist/shared/{components-0bvxny7s.js → components-hhwv5mcm.js} +5 -4
  47. package/dist/shared/{components-pw6gzev8.js → components-s0c8gngv.js} +6 -6
  48. package/dist/shared/{components-fv9y76b0.js → components-swh0v27s.js} +4 -2
  49. package/dist/shared/{components-s0megs1g.js → components-whfr55xn.js} +3 -3
  50. package/dist/shared/{components-greka6z2.js → components-z6wx8fzj.js} +1 -1
  51. package/dist/shared/{components-hjdv4y8d.js → components-zjeh9zk2.js} +1 -1
  52. package/dist/styles.css +2 -1
  53. package/lib/use-autosize-textarea.ts +65 -18
  54. package/package.json +6 -1
  55. package/primitives/content/code/index.tsx +11 -6
  56. package/primitives/layout/resizable/index.tsx +15 -6
  57. package/primitives/layout/scroll-area/examples.mdx +16 -0
  58. package/primitives/layout/scroll-area/index.tsx +89 -9
  59. package/dist/shared/components-vpkh6j83.js +0 -42
  60. /package/dist/shared/{components-v1zzr668.js → components-arg4h26d.js} +0 -0
  61. /package/dist/shared/{components-0ep66sg9.js → components-dx8f797z.js} +0 -0
  62. /package/dist/shared/{components-rtwfh1gc.js → components-fzmjcn38.js} +0 -0
@@ -1,5 +1,9 @@
1
1
  "use client";
2
2
 
3
+ import {
4
+ mergeRefs2,
5
+ useMergeRefs2
6
+ } from "./components-bkwjvvkh.js";
3
7
  import {
4
8
  useControllableState2
5
9
  } from "./components-wwd093xg.js";
@@ -10,12 +14,11 @@ import {
10
14
  useShape2
11
15
  } from "./components-kxpcj2ry.js";
12
16
  import {
13
- ScrollArea2
14
- } from "./components-esy5nsvc.js";
17
+ useIsoLayoutEffect2
18
+ } from "./components-v2j3jx89.js";
15
19
  import {
16
- mergeRefs2,
17
- useMergeRefs2
18
- } from "./components-bkwjvvkh.js";
20
+ ScrollArea2
21
+ } from "./components-5fet4gqt.js";
19
22
  import {
20
23
  useReduceMotion2
21
24
  } from "./components-tz0axc0f.js";
@@ -60,9 +63,6 @@ import {
60
63
  import {
61
64
  FocusRing2
62
65
  } from "./components-5wykqxph.js";
63
- import {
64
- useIsoLayoutEffect2
65
- } from "./components-v2j3jx89.js";
66
66
  import {
67
67
  inertProps2
68
68
  } from "./components-2myjk2zf.js";
@@ -86,7 +86,8 @@ import {
86
86
  import {
87
87
  forwardRef as forwardRef10,
88
88
  useEffect as useEffect6,
89
- useMemo as useMemo5
89
+ useMemo as useMemo5,
90
+ useRef as useRef10
90
91
  } from "react";
91
92
 
92
93
  // components/navigation/sidebar/menu-scope.tsx
@@ -1826,8 +1827,42 @@ var Sidebar2 = forwardRef10(({
1826
1827
  });
1827
1828
  });
1828
1829
  Sidebar2.displayName = "Sidebar";
1830
+ function usePauseHoverWhileScrolling(ref, enabled) {
1831
+ useEffect6(() => {
1832
+ const content = enabled ? ref.current : null;
1833
+ const scroller = content?.closest('[data-slot="scroll-area-viewport"]');
1834
+ if (!content || !scroller)
1835
+ return;
1836
+ let timer;
1837
+ const resume = () => {
1838
+ clearTimeout(timer);
1839
+ content.removeAttribute("data-scrolling");
1840
+ };
1841
+ const onScroll = () => {
1842
+ if (!content.hasAttribute("data-scrolling"))
1843
+ content.setAttribute("data-scrolling", "");
1844
+ clearTimeout(timer);
1845
+ timer = setTimeout(resume, 150);
1846
+ };
1847
+ const onPointerMove = (e) => {
1848
+ const { movementX, movementY } = e;
1849
+ if ((movementX || movementY) && content.hasAttribute("data-scrolling"))
1850
+ resume();
1851
+ };
1852
+ scroller.addEventListener("scroll", onScroll, { passive: true });
1853
+ scroller.addEventListener("pointermove", onPointerMove, { passive: true });
1854
+ return () => {
1855
+ resume();
1856
+ scroller.removeEventListener("scroll", onScroll);
1857
+ scroller.removeEventListener("pointermove", onPointerMove);
1858
+ };
1859
+ }, [ref, enabled]);
1860
+ }
1829
1861
  var SidebarContent2 = forwardRef10(({ className, viewportClassName, children, ...props }, ref) => {
1830
1862
  const { isMobile } = useSidebar2();
1863
+ const contentRef = useRef10(null);
1864
+ const mergedRef = useMergeRefs2(ref, contentRef);
1865
+ usePauseHoverWhileScrolling(contentRef, !isMobile);
1831
1866
  if (isMobile) {
1832
1867
  return /* @__PURE__ */ jsx13("div", {
1833
1868
  className: "scroll-divider [--scroll-divider-inset:8px] flex min-h-0 w-full flex-1 flex-col",
@@ -1844,9 +1879,9 @@ var SidebarContent2 = forwardRef10(({ className, viewportClassName, children, ..
1844
1879
  className: cn2("scroll-divider min-h-0 w-full flex-1", className),
1845
1880
  viewportClassName: cn2("scroll-fade [&>div]:!block [&>div]:!min-w-0", viewportClassName),
1846
1881
  children: /* @__PURE__ */ jsx13("div", {
1847
- ref,
1882
+ ref: mergedRef,
1848
1883
  "data-sidebar": "content",
1849
- className: "flex w-full min-w-0 flex-col",
1884
+ className: "flex w-full min-w-0 flex-col data-[scrolling]:pointer-events-none",
1850
1885
  ...props,
1851
1886
  children
1852
1887
  })
@@ -76,7 +76,7 @@ import {
76
76
  } from "./components-eawe4nxm.js";
77
77
  import {
78
78
  ScrollArea2
79
- } from "./components-esy5nsvc.js";
79
+ } from "./components-5fet4gqt.js";
80
80
 
81
81
  // components/inputs/combobox/index.tsx
82
82
  import { Combobox as ComboboxPrimitive3 } from "@base-ui/react/combobox";
@@ -180,16 +180,17 @@ var Resizable2 = forwardRef(({ direction = "horizontal", sizes, onSizesChange, s
180
180
  const id = useId();
181
181
  const items = Children.toArray(children);
182
182
  const panels = items.filter((child) => isValidElement(child) && child.type === ResizablePanel2);
183
- const limits = panels.map(({ props }) => ({
183
+ const limitKey = panels.map(({ props }) => `${props.minSize}:${props.maxSize}:${props.collapsible}`).join();
184
+ const limits = useMemo(() => panels.map(({ props }) => ({
184
185
  min: props.minSize ?? 0,
185
186
  max: props.maxSize ?? 100,
186
187
  collapsible: props.collapsible ?? false
187
- }));
188
+ })), [limitKey]);
188
189
  const sizeKey = panels.map(({ props }) => props.defaultSize).join();
189
190
  const defaults = useMemo(() => defaultSizes(panels.map(({ props }) => props.defaultSize)), [sizeKey]);
190
191
  const [current, setCurrent] = useControllableState2(sizes, defaults, onSizesChange);
191
192
  const [dragging, setDragging] = useState(false);
192
- const group = { id, direction, sizes: current, limits, defaults, step, setSizes: setCurrent, dragging, setDragging };
193
+ const group = useMemo(() => ({ id, direction, sizes: current, limits, defaults, step, setSizes: setCurrent, dragging, setDragging }), [id, direction, current, limits, defaults, step, setCurrent, dragging]);
193
194
  let panel = -1;
194
195
  const indexed = items.map((child) => {
195
196
  if (!isValidElement(child))
@@ -12,7 +12,7 @@ import {
12
12
  } from "./components-bkwjvvkh.js";
13
13
  import {
14
14
  useAutosizeTextarea2
15
- } from "./components-vpkh6j83.js";
15
+ } from "./components-7v6ncqfc.js";
16
16
  import {
17
17
  useControllableState2
18
18
  } from "./components-wwd093xg.js";
@@ -29,7 +29,7 @@ import {
29
29
  import {
30
30
  useSidebarShortcut,
31
31
  sidebar_default
32
- } from "./components-cc9kfhkb.js";
32
+ } from "./components-bkg1k36x.js";
33
33
  import {
34
34
  inertProps2
35
35
  } from "./components-2myjk2zf.js";
@@ -41,10 +41,10 @@ import {
41
41
  } from "./components-7rn454aq.js";
42
42
  import {
43
43
  resizable_default
44
- } from "./components-gr82tz50.js";
44
+ } from "./components-fbs2602j.js";
45
45
 
46
46
  // blocks/desktop-shell/index.tsx
47
- import { useCallback, useLayoutEffect, useRef, useState } from "react";
47
+ import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
48
48
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
49
49
  var CORNER_CLEARANCE = {
50
50
  default: "[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:pt-9",
@@ -165,6 +165,7 @@ function DesktopShell2({
165
165
  const hasRight = right !== undefined;
166
166
  const paneOpen = hasRight && rightOpen;
167
167
  const inCard = titleBar === "card";
168
+ const paneSizes = useMemo(() => paneOpen ? [100 - paneSize, paneSize] : [100, 0], [paneOpen, paneSize]);
168
169
  const root = useRef(null);
169
170
  const [narrow, setNarrow] = useState(false);
170
171
  useLayoutEffect(() => {
@@ -271,7 +272,7 @@ function DesktopShell2({
271
272
  /* @__PURE__ */ jsx("div", {
272
273
  className: cn2("flex min-h-0 min-w-0 flex-1 py-2 pl-2 transition-[padding] duration-fast", hasLeft && leftOpen && "pl-0", (!hasRight || narrow) && "pr-2"),
273
274
  children: !hasRight || narrow ? card(narrow && paneOpen ? right : main) : /* @__PURE__ */ jsxs(resizable_default, {
274
- sizes: paneOpen ? [100 - paneSize, paneSize] : [100, 0],
275
+ sizes: paneSizes,
275
276
  onSizesChange,
276
277
  children: [
277
278
  /* @__PURE__ */ jsx(resizable_default.Panel, {
@@ -8,10 +8,10 @@ import {
8
8
  } from "./components-xnp09586.js";
9
9
  import {
10
10
  Code2
11
- } from "./components-y4gsk1jt.js";
11
+ } from "./components-60tf8tfa.js";
12
12
  import {
13
13
  table_default
14
- } from "./components-0ep66sg9.js";
14
+ } from "./components-dx8f797z.js";
15
15
 
16
16
  // components/data-display/markdown/index.tsx
17
17
  import { Lexer } from "marked";
@@ -236,12 +236,12 @@ function MarkdownProse2({ children, className }) {
236
236
  });
237
237
  }
238
238
  var Markdown2 = Object.assign(function Markdown({ children, streaming = false, className }) {
239
- const tokens = useMemo(() => Lexer.lex(streaming ? settle(children) : children), [children, streaming]);
239
+ const blocks = useMemo(() => /* @__PURE__ */ jsx(Blocks, {
240
+ tokens: Lexer.lex(streaming ? settle(children) : children)
241
+ }), [children, streaming]);
240
242
  return /* @__PURE__ */ jsx(MarkdownProse2, {
241
243
  className,
242
- children: /* @__PURE__ */ jsx(Blocks, {
243
- tokens
244
- })
244
+ children: blocks
245
245
  });
246
246
  }, { Prose: MarkdownProse2 });
247
247
  var markdown_default = Markdown2;
@@ -14,9 +14,10 @@ import {
14
14
  } from "./components-xnp09586.js";
15
15
  import {
16
16
  scroll_area_default
17
- } from "./components-esy5nsvc.js";
17
+ } from "./components-5fet4gqt.js";
18
18
 
19
19
  // components/data-display/diff/index.tsx
20
+ import { useMemo } from "react";
20
21
  import { jsx, jsxs } from "react/jsx-runtime";
21
22
  var ROW = {
22
23
  add: "bg-status-success/16",
@@ -70,7 +71,7 @@ function parsePatch2(patch) {
70
71
  function Diff2({ patch, path, lineNumbers = true, wrap = false, actions, className }) {
71
72
  const level = useLift2(1);
72
73
  const FileIcon = useIcon2("file-diff");
73
- const lines = parsePatch2(patch);
74
+ const lines = useMemo(() => parsePatch2(patch), [patch]);
74
75
  const added = lines.filter((l) => l.kind === "add").length;
75
76
  const removed = lines.filter((l) => l.kind === "remove").length;
76
77
  const body = /* @__PURE__ */ jsx("div", {
@@ -144,6 +145,7 @@ function Diff2({ patch, path, lineNumbers = true, wrap = false, actions, classNa
144
145
  ]
145
146
  }),
146
147
  wrap ? body : /* @__PURE__ */ jsx(scroll_area_default, {
148
+ native: true,
147
149
  orientation: "horizontal",
148
150
  viewportClassName: "scroll-fade-x",
149
151
  children: body
@@ -22,7 +22,7 @@ import {
22
22
  SidebarInput2,
23
23
  SidebarTrigger2,
24
24
  sidebar_default
25
- } from "./components-cc9kfhkb.js";
25
+ } from "./components-bkg1k36x.js";
26
26
  import {
27
27
  tooltip_default
28
28
  } from "./components-7rn454aq.js";
@@ -31,10 +31,10 @@ import {
31
31
  DropdownMenu2,
32
32
  DropdownTrigger2,
33
33
  DropdownContent2
34
- } from "./components-pwsqp2np.js";
34
+ } from "./components-94vd4ck1.js";
35
35
  import {
36
36
  card_default
37
- } from "./components-rtwfh1gc.js";
37
+ } from "./components-fzmjcn38.js";
38
38
  import {
39
39
  badge_default
40
40
  } from "./components-jw45ck66.js";
@@ -30,7 +30,7 @@ import {
30
30
  } from "./components-q0hs5rqn.js";
31
31
  import {
32
32
  ScrollArea2
33
- } from "./components-esy5nsvc.js";
33
+ } from "./components-5fet4gqt.js";
34
34
  import {
35
35
  DialogTrigger2,
36
36
  DialogContent2,
@@ -18,7 +18,7 @@ import {
18
18
  DropdownSubTrigger2,
19
19
  DropdownSubContent2,
20
20
  DropdownSeparator2
21
- } from "./components-pwsqp2np.js";
21
+ } from "./components-94vd4ck1.js";
22
22
 
23
23
  // components/overlays/context-menu/index.tsx
24
24
  import { ContextMenu as ContextMenuPrimitive } from "@base-ui/react/context-menu";
package/dist/styles.css CHANGED
@@ -62,7 +62,7 @@
62
62
  }
63
63
  /* layer: theme */
64
64
  @layer theme{
65
- :root, :host { --spacing: 0.25rem; --radius-3xl: 1.5rem; --radius-xl: 0.75rem; --default-transition-timingFunction: cubic-bezier(0.4, 0, 0.2, 1); --default-transition-duration: 150ms; --ease-DEFAULT: cubic-bezier(0.4, 0, 0.2, 1); --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace; --container-sm: 24rem; --radius-DEFAULT: 0.25rem; --radius-none: 0; --leading-tight: 1.25; --radius-md: 0.375rem; --font-sans: 'Inter Variable', ui-sans-serif, system-ui, sans-serif; --ease-out: cubic-bezier(0, 0, 0.2, 1); --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1); --radius-sm: 0.25rem; --radius-2xl: 1rem; --radius-xs: 0.125rem; --leading-relaxed: 1.625; --leading-snug: 1.375; --leading-normal: 1.5; --container-2xl: 42rem; --radius-lg: 0.5rem; --leading-none: 1; --default-font-family: var(--font-sans); --default-monoFont-family: var(--font-mono); }
65
+ :root, :host { --spacing: 0.25rem; --default-transition-timingFunction: cubic-bezier(0.4, 0, 0.2, 1); --default-transition-duration: 150ms; --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace; --container-sm: 24rem; --ease-out: cubic-bezier(0, 0, 0.2, 1); --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1); --radius-xl: 0.75rem; --leading-relaxed: 1.625; --radius-none: 0; --font-sans: 'Inter Variable', ui-sans-serif, system-ui, sans-serif; --radius-md: 0.375rem; --radius-DEFAULT: 0.25rem; --radius-3xl: 1.5rem; --leading-tight: 1.25; --ease-DEFAULT: cubic-bezier(0.4, 0, 0.2, 1); --radius-xs: 0.125rem; --leading-snug: 1.375; --leading-normal: 1.5; --radius-sm: 0.25rem; --radius-2xl: 1rem; --radius-lg: 0.5rem; --leading-none: 1; --container-2xl: 42rem; --default-font-family: var(--font-sans); --default-monoFont-family: var(--font-mono); }
66
66
  }
67
67
  /* layer: base */
68
68
  @layer base{
@@ -716,6 +716,7 @@
716
716
  .\[\&_\*\]\:pointer-events-none *,
717
717
  .aria-disabled\:pointer-events-none[aria-disabled="true"],
718
718
  .data-\[disabled\]\:pointer-events-none[data-disabled],
719
+ .data-\[scrolling\]\:pointer-events-none[data-scrolling],
719
720
  .pointer-events-none{pointer-events:none;}
720
721
  .disabled\:pointer-events-none:disabled{pointer-events:none;}
721
722
  .resize{resize:both;}
@@ -15,50 +15,97 @@ interface AutosizeRows {
15
15
  maxRows: number
16
16
  }
17
17
 
18
+ // `field-sizing: content` (WebKit 26, Chromium 123) sizes the box inside the
19
+ // browser's own layout: no measure, no observer.
20
+ const nativeSizing = typeof CSS !== 'undefined' && CSS.supports('field-sizing', 'content')
21
+
18
22
  function lineHeightOf(el: HTMLElement) {
19
23
  const style = getComputedStyle(el)
20
24
  // `line-height: normal` computes to the keyword, which parses to NaN.
21
25
  return Number.parseFloat(style.lineHeight) || Number.parseFloat(style.fontSize) * 1.2
22
26
  }
23
27
 
28
+ function fit(el: HTMLTextAreaElement, height: number, max: number) {
29
+ const next = `${Math.min(height, max)}px`
30
+ const overflow = height > max ? 'auto' : 'hidden'
31
+ if (el.style.height !== next) el.style.height = next
32
+ if (el.style.overflowY !== overflow) el.style.overflowY = overflow
33
+ }
34
+
24
35
  /**
25
36
  * Sizes the textarea to its content between `minRows` and `maxRows`, then
26
- * scrolls. It measures before paint whenever `deps` change (pass the value
27
- * and anything else that changes the text's height, such as the size step),
28
- * and again when the textarea's width changes. Returns the measure, for a
29
- * caller that changes the content outside React.
37
+ * scrolls. Where the browser supports `field-sizing: content`, the box sizes
38
+ * itself between a `min-height` and `max-height` in line units. Elsewhere it
39
+ * measures before paint whenever `deps` change (pass the value and anything
40
+ * else that changes the text's height, such as the size step), and when the
41
+ * textarea's width changes. Returns the measure, for a caller that changes
42
+ * the content outside React.
30
43
  */
31
44
  export function useAutosizeTextarea(
32
45
  ref: RefObject<HTMLTextAreaElement | null>,
33
46
  { minRows, maxRows }: AutosizeRows,
34
47
  deps: DependencyList,
35
48
  ) {
36
- const resize = useCallback(() => {
49
+ // `grow` reads the text's height off the current box, which only holds
50
+ // while the text is at least as tall as the box.
51
+ const measure = useCallback(
52
+ (grow: boolean) => {
53
+ const el = ref.current
54
+ if (!el || nativeSizing) return
55
+ const line = lineHeightOf(el)
56
+ const floor = line * minRows
57
+ const max = line * Math.max(maxRows, minRows)
58
+ // An empty box is one line at most: the floor holds it unmeasured.
59
+ if (el.value === '' && minRows >= 1) return fit(el, floor, max)
60
+ if (!grow) el.style.height = 'auto'
61
+ fit(el, Math.max(el.scrollHeight, floor), max)
62
+ },
63
+ [ref, minRows, maxRows],
64
+ )
65
+ const resize = useCallback(() => measure(false), [measure])
66
+
67
+ useIsoLayoutEffect(() => {
37
68
  const el = ref.current
38
- if (!el) return
39
- el.style.height = 'auto'
40
- const line = lineHeightOf(el)
41
- const max = line * Math.max(maxRows, minRows)
42
- el.style.height = `${Math.min(Math.max(el.scrollHeight, line * minRows), max)}px`
43
- el.style.overflowY = el.scrollHeight > max ? 'auto' : 'hidden'
69
+ if (!el || !nativeSizing) return
70
+ el.style.setProperty('field-sizing', 'content')
71
+ el.style.minHeight = `${minRows}lh`
72
+ el.style.maxHeight = `${Math.max(maxRows, minRows)}lh`
73
+ el.style.overflowY = 'auto'
44
74
  }, [ref, minRows, maxRows])
45
75
 
46
76
  useIsoLayoutEffect(resize, [resize, ...deps])
47
77
 
48
78
  // The first measure can run while an ancestor is still at (near-)zero
49
- // width. Width-gated, so the observer never loops on its own height writes.
79
+ // width, and a pane drag changes the width every frame. Narrower text can
80
+ // only grow, which the box's own scrollHeight shows without a re-layout;
81
+ // wider text may shrink, which needs the full measure, once per frame.
82
+ // Gated on width, so the observer never loops on its own height writes.
50
83
  useEffect(() => {
51
84
  const el = ref.current
52
- if (!el) return
85
+ if (!el || nativeSizing) return
53
86
  let width = el.offsetWidth
87
+ let frame = 0
54
88
  const observer = new ResizeObserver(() => {
55
- if (el.offsetWidth === width) return
56
- width = el.offsetWidth
57
- resize()
89
+ const next = el.offsetWidth
90
+ const wider = next > width
91
+ if (next === width) return
92
+ width = next
93
+ if (el.value === '') return
94
+ if (!wider) {
95
+ if (el.scrollHeight > el.clientHeight) measure(true)
96
+ return
97
+ }
98
+ frame ||= requestAnimationFrame(() => {
99
+ frame = 0
100
+ resize()
101
+ })
58
102
  })
59
103
  observer.observe(el)
60
- return () => observer.disconnect()
61
- }, [ref, resize])
104
+ return () => {
105
+ observer.disconnect()
106
+ cancelAnimationFrame(frame)
107
+ }
108
+ }, [ref, measure, resize])
62
109
 
63
110
  return resize
64
111
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justanarthur/modo-ui",
3
3
  "type": "module",
4
- "version": "2.4.0",
4
+ "version": "2.6.0",
5
5
  "description": "Fluid Functionalism (Base UI flavor, MIT © 2026 Micka Touillaud) ported to UnoCSS: motion springs, fluid hover, a two-step size ladder and an eight-level elevated surface system. Documented with modo.",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -50,6 +50,11 @@
50
50
  "engines": {
51
51
  "node": ">=20"
52
52
  },
53
+ "sideEffects": [
54
+ "**/*.css",
55
+ "**/*.ts",
56
+ "**/*.tsx"
57
+ ],
53
58
  "module": "./dist/index.js",
54
59
  "types": "./dist/index.d.ts",
55
60
  "exports": {
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
 
3
- import { Fragment } from 'react'
3
+ import { Fragment, useMemo } from 'react'
4
4
  import type { TokenType } from 'sugar-high'
5
5
  import { parse } from 'sugar-high/core'
6
6
  import { type Language, lang, languages } from 'sugar-high/lang'
@@ -45,7 +45,9 @@ function highlight(source: string, language: Language['id']) {
45
45
  *
46
46
  * sugar-high tokenizes; each token type takes a `--syntax-*` token from
47
47
  * tokens/colors.css, so code follows light and dark like everything else.
48
- * Long lines scroll sideways under a fading edge instead of wrapping. It is
48
+ * Long lines scroll sideways under a fading edge instead of wrapping, on the
49
+ * platform's own scrollbar (ScrollArea's `native`), so hundreds of blocks
50
+ * cost nothing while their column resizes. It is
49
51
  * also the docs chrome's Code slot: every example's source and every fenced
50
52
  * block on these pages renders through it.
51
53
  *
@@ -64,17 +66,20 @@ export default function Code({
64
66
  className?: string
65
67
  }) {
66
68
  const level = useLift(1)
67
- const source = children.trim()
68
69
  const id = lang(language)
70
+ // The same element on every render, so React skips the token spans.
71
+ const code = useMemo(() => {
72
+ const source = children.trim()
73
+ return <code>{id && id !== 'plaintext' ? highlight(source, id) : source}</code>
74
+ }, [children, id])
69
75
  return (
70
76
  <ScrollArea
77
+ native
71
78
  orientation="horizontal"
72
79
  viewportClassName="scroll-fade-x"
73
80
  className={cn('rounded-xl', SURFACE_BG[level], className)}
74
81
  >
75
- <pre className="m-0 w-max min-w-full p-4 font-mono text-caption leading-relaxed text-foreground">
76
- <code>{id && id !== 'plaintext' ? highlight(source, id) : source}</code>
77
- </pre>
82
+ <pre className="m-0 w-max min-w-full p-4 font-mono text-caption leading-relaxed text-foreground">{code}</pre>
78
83
  </ScrollArea>
79
84
  )
80
85
  }
@@ -312,16 +312,25 @@ const Resizable = forwardRef<HTMLDivElement, ResizableProps>(
312
312
  const panels = items.filter(
313
313
  (child): child is ReactElement<ResizablePanelProps> => isValidElement(child) && child.type === ResizablePanel,
314
314
  )
315
- const limits = panels.map(({ props }) => ({
316
- min: props.minSize ?? 0,
317
- max: props.maxSize ?? 100,
318
- collapsible: props.collapsible ?? false,
319
- }))
315
+ const limitKey = panels.map(({ props }) => `${props.minSize}:${props.maxSize}:${props.collapsible}`).join()
316
+ const limits = useMemo(
317
+ () =>
318
+ panels.map(({ props }) => ({
319
+ min: props.minSize ?? 0,
320
+ max: props.maxSize ?? 100,
321
+ collapsible: props.collapsible ?? false,
322
+ })),
323
+ [limitKey],
324
+ )
320
325
  const sizeKey = panels.map(({ props }) => props.defaultSize).join()
321
326
  const defaults = useMemo(() => defaultSizes(panels.map(({ props }) => props.defaultSize)), [sizeKey])
322
327
  const [current, setCurrent] = useControllableState(sizes, defaults, onSizesChange)
323
328
  const [dragging, setDragging] = useState(false)
324
- const group = { id, direction, sizes: current, limits, defaults, step, setSizes: setCurrent, dragging, setDragging }
329
+ // A new context value walks the whole subtree for consumers, so it changes only with what it holds.
330
+ const group = useMemo(
331
+ () => ({ id, direction, sizes: current, limits, defaults, step, setSizes: setCurrent, dragging, setDragging }),
332
+ [id, direction, current, limits, defaults, step, setCurrent, dragging],
333
+ )
325
334
 
326
335
  let panel = -1
327
336
  const indexed = items.map(child => {
@@ -31,6 +31,22 @@ content keep its natural width instead of squeezing in.
31
31
  </div>
32
32
  </ScrollArea>
33
33
 
34
+ # Native
35
+
36
+ `native` scrolls on the platform's own scrollbar (an overlay one on macOS)
37
+ with no observers behind it, for scrollers that come by the hundred: every
38
+ Code block is one. The fade stays the same.
39
+
40
+ <ScrollArea native orientation="horizontal" viewportClassName="scroll-fade-x" className="w-full">
41
+ <div className="flex gap-2 p-3 w-max">
42
+ {['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'].map((month) => (
43
+ <div key={month} className="flex items-center justify-center h-20 w-28 shrink-0 border border-border rounded-lg text-body text-foreground">
44
+ {month}
45
+ </div>
46
+ ))}
47
+ </div>
48
+ </ScrollArea>
49
+
34
50
  # Double overflow
35
51
 
36
52
  A grid taller and wider than its box. `orientation="both"` adds both