@hanzo/ui 8.1.20 → 8.2.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.
@@ -269,24 +269,34 @@
269
269
  /* ─────────────────────────────────────────────────────────────────────────────
270
270
  Scrollbars, on the surfaces this package scrolls.
271
271
 
272
- A scroll region is a component decision, so its scrollbar is one too. Left to
273
- the platform it is not neutral: on Linux/GTK Chrome draws a wide track with
274
- STEPPER ARROWS at both ends, and a dark product grows two grey buttons per
275
- scroll region — visible in chat's thread, its source strip and the composer at
276
- the same time. Windows draws a wide light track. macOS overlays a thin one and
277
- hides it, which is the behaviour the other two should have had.
278
-
279
- So the package states it, and states it ONCE, for the five slots that actually
280
- scroll (measured, not guessed: textarea, fill, thread, sources-strip,
281
- composer-field). Scoping to our own slots is the point — a component library
282
- restyling the HOST's page scrollbars is taking a decision that is not its own.
283
-
284
- `::-webkit-scrollbar-button { display: none }` is the line that removes the
285
- steppers; without it the arrows survive every other rule here. The thumb sits
286
- on the same alpha ladder as every other edge, so it lifts with its surface
287
- instead of being a fixed grey that only suits one theme.
272
+ Left to the platform this is not neutral: Linux/GTK Chrome draws a wide track
273
+ with STEPPER ARROWS at both ends, so a dark product grows two grey buttons per
274
+ scroll region. Windows draws a wide light track. macOS overlays a thin one,
275
+ which is the behaviour the other two should have had.
276
+
277
+ THE TWO HALVES MUST NOT BE DECLARED TOGETHER, and that is the whole subtlety.
278
+ Chromium supports both the standard properties and the `::-webkit-scrollbar`
279
+ pseudo-elements — but the moment `scrollbar-width` or `scrollbar-color` is
280
+ anything other than `auto`, it takes the standard path and DISCARDS the entire
281
+ webkit block. Shipping both is how 8.1.19 removed nothing: measured headed on
282
+ Linux, as-shipped gave a 10px gutter with arrows, while the authored webkit
283
+ rule alone gives 8px with none. Isolated: webkit-only 8px no arrows;
284
+ standard-only 10px arrows; both together 10px arrows.
285
+
286
+ Neither half is redundant, so neither can simply be deleted — Firefox
287
+ implements ONLY the standard properties, Safari ONLY the webkit ones. They are
288
+ separated by engine instead: the webkit block applies wherever the selector is
289
+ understood, and the standard properties apply only where it is not.
290
+
291
+ And it is invisible headless. Chromium's headless shell paints OVERLAY
292
+ scrollbars, so nothing is drawn, `offsetWidth - clientWidth` is 0 on a blank
293
+ page, and `getComputedStyle(el, '::-webkit-scrollbar-button').display` happily
294
+ reports `none` for a rule that never ran. This must be checked headed.
288
295
  ───────────────────────────────────────────────────────────────────────────── */
289
- :where(
296
+
297
+ /* Firefox and anything else with no webkit pseudo-elements. */
298
+ @supports not selector(::-webkit-scrollbar) {
299
+ :where(
290
300
  [data-slot='fill'],
291
301
  [data-slot='thread'],
292
302
  [data-slot='sources-strip'],
@@ -295,12 +305,44 @@
295
305
  [data-slot='textarea'],
296
306
  [data-slot='composer-field']
297
307
  ) {
298
- /* Firefox — no pseudo-elements, two properties, same intent. */
299
- scrollbar-width: thin;
300
- scrollbar-color: rgb(255 255 255 / 0.18) transparent;
301
- }
308
+ scrollbar-width: thin;
309
+ scrollbar-color: rgb(255 255 255 / 0.18) transparent;
310
+ }
311
+ .t_light :where(
312
+ [data-slot='fill'],
313
+ [data-slot='thread'],
314
+ [data-slot='sources-strip'],
315
+ [data-slot='sidebar-scroll'],
316
+ [data-slot='scroll-area-viewport'],
317
+ [data-slot='textarea'],
318
+ [data-slot='composer-field']
319
+ ) { scrollbar-color: rgb(0 0 0 / 0.20) transparent; }
320
+ }
321
+
322
+ /* Chromium and Safari.
323
+ The first rule is the load-bearing one and it is a RESET, not a style.
324
+ @hanzo/design sets `scrollbar-color` and `scrollbar-width` on `:where(html)`
325
+ (theme.css), and both INHERIT — so every element in the document already
326
+ carries a non-`auto` value, Chromium takes the standard path, and the whole
327
+ webkit block below is discarded before it is read. Nothing declared here can
328
+ win until the inherited value is put back to `auto` on the element itself.
329
+ That is why the arrows survived 8.1.19: the competing declaration was one
330
+ level up and inherited, not a rule anyone would find in this file. */
331
+ @supports selector(::-webkit-scrollbar) {
332
+ :where(
333
+ [data-slot='fill'],
334
+ [data-slot='thread'],
335
+ [data-slot='sources-strip'],
336
+ [data-slot='sidebar-scroll'],
337
+ [data-slot='scroll-area-viewport'],
338
+ [data-slot='textarea'],
339
+ [data-slot='composer-field']
340
+ ) {
341
+ scrollbar-width: auto;
342
+ scrollbar-color: auto;
343
+ }
302
344
 
303
- :where(
345
+ :where(
304
346
  [data-slot='fill'],
305
347
  [data-slot='thread'],
306
348
  [data-slot='sources-strip'],
@@ -308,13 +350,11 @@
308
350
  [data-slot='scroll-area-viewport'],
309
351
  [data-slot='textarea'],
310
352
  [data-slot='composer-field']
311
- )::-webkit-scrollbar {
312
- width: 8px;
313
- height: 8px;
314
- }
353
+ )::-webkit-scrollbar { width: 8px; height: 8px; }
315
354
 
316
- /* The steppers. This is the rule that removes the arrows. */
317
- :where(
355
+ /* The steppers. This is the rule that removes the arrows, and the reason the
356
+ two halves had to be separated at all. */
357
+ :where(
318
358
  [data-slot='fill'],
319
359
  [data-slot='thread'],
320
360
  [data-slot='sources-strip'],
@@ -322,13 +362,9 @@
322
362
  [data-slot='scroll-area-viewport'],
323
363
  [data-slot='textarea'],
324
364
  [data-slot='composer-field']
325
- )::-webkit-scrollbar-button {
326
- display: none;
327
- width: 0;
328
- height: 0;
329
- }
365
+ )::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
330
366
 
331
- :where(
367
+ :where(
332
368
  [data-slot='fill'],
333
369
  [data-slot='thread'],
334
370
  [data-slot='sources-strip'],
@@ -336,11 +372,9 @@
336
372
  [data-slot='scroll-area-viewport'],
337
373
  [data-slot='textarea'],
338
374
  [data-slot='composer-field']
339
- )::-webkit-scrollbar-track {
340
- background: transparent;
341
- }
375
+ )::-webkit-scrollbar-track { background: transparent; }
342
376
 
343
- :where(
377
+ :where(
344
378
  [data-slot='fill'],
345
379
  [data-slot='thread'],
346
380
  [data-slot='sources-strip'],
@@ -349,16 +383,15 @@
349
383
  [data-slot='textarea'],
350
384
  [data-slot='composer-field']
351
385
  )::-webkit-scrollbar-thumb {
352
- background: rgb(255 255 255 / 0.18);
353
- border-radius: 999px;
354
- /* A transparent border with background-clip keeps the thumb off the very edge
355
- without a track colour doing it, which is what makes it read as an overlay
356
- rather than a channel. */
357
- border: 2px solid transparent;
358
- background-clip: content-box;
359
- }
360
-
361
- :where(
386
+ background: rgb(255 255 255 / 0.18);
387
+ border-radius: 999px;
388
+ /* A transparent border with background-clip keeps the thumb off the very
389
+ edge without a track colour doing it, so it reads as an overlay rather
390
+ than a channel. */
391
+ border: 2px solid transparent;
392
+ background-clip: content-box;
393
+ }
394
+ :where(
362
395
  [data-slot='fill'],
363
396
  [data-slot='thread'],
364
397
  [data-slot='sources-strip'],
@@ -367,12 +400,10 @@
367
400
  [data-slot='textarea'],
368
401
  [data-slot='composer-field']
369
402
  )::-webkit-scrollbar-thumb:hover {
370
- background: rgb(255 255 255 / 0.30);
371
- background-clip: content-box;
372
- }
373
-
374
- /* The light theme reads the same ladder from the other side. */
375
- .t_light :where(
403
+ background: rgb(255 255 255 / 0.30);
404
+ background-clip: content-box;
405
+ }
406
+ :where(
376
407
  [data-slot='fill'],
377
408
  [data-slot='thread'],
378
409
  [data-slot='sources-strip'],
@@ -380,11 +411,9 @@
380
411
  [data-slot='scroll-area-viewport'],
381
412
  [data-slot='textarea'],
382
413
  [data-slot='composer-field']
383
- ) {
384
- scrollbar-color: rgb(0 0 0 / 0.20) transparent;
385
- }
414
+ )::-webkit-scrollbar-corner { background: transparent; }
386
415
 
387
- .t_light :where(
416
+ .t_light :where(
388
417
  [data-slot='fill'],
389
418
  [data-slot='thread'],
390
419
  [data-slot='sources-strip'],
@@ -393,14 +422,12 @@
393
422
  [data-slot='textarea'],
394
423
  [data-slot='composer-field']
395
424
  )::-webkit-scrollbar-thumb {
396
- background: rgb(0 0 0 / 0.20);
397
- background-clip: content-box;
425
+ background: rgb(0 0 0 / 0.20);
426
+ background-clip: content-box;
427
+ }
398
428
  }
399
429
 
400
430
  /* The textarea's resize grip is the other platform artefact in the same family:
401
- a diagonal hatch in the corner of every Textarea and composer, drawn by the UA
402
- and matching nothing. A composer that grows with its content does not need a
403
- drag handle, and one that does not grow should not offer a broken one. */
404
- :where([data-slot='textarea'], [data-slot='composer-field']) {
405
- resize: none;
406
- }
431
+ a diagonal hatch drawn by the UA that matches nothing. A composer that grows
432
+ with its content does not need one. */
433
+ :where([data-slot='textarea'], [data-slot='composer-field']) { resize: none; }
package/dist/styles.css CHANGED
@@ -1957,24 +1957,34 @@
1957
1957
  /* ─────────────────────────────────────────────────────────────────────────────
1958
1958
  Scrollbars, on the surfaces this package scrolls.
1959
1959
 
1960
- A scroll region is a component decision, so its scrollbar is one too. Left to
1961
- the platform it is not neutral: on Linux/GTK Chrome draws a wide track with
1962
- STEPPER ARROWS at both ends, and a dark product grows two grey buttons per
1963
- scroll region — visible in chat's thread, its source strip and the composer at
1964
- the same time. Windows draws a wide light track. macOS overlays a thin one and
1965
- hides it, which is the behaviour the other two should have had.
1966
-
1967
- So the package states it, and states it ONCE, for the five slots that actually
1968
- scroll (measured, not guessed: textarea, fill, thread, sources-strip,
1969
- composer-field). Scoping to our own slots is the point — a component library
1970
- restyling the HOST's page scrollbars is taking a decision that is not its own.
1971
-
1972
- `::-webkit-scrollbar-button { display: none }` is the line that removes the
1973
- steppers; without it the arrows survive every other rule here. The thumb sits
1974
- on the same alpha ladder as every other edge, so it lifts with its surface
1975
- instead of being a fixed grey that only suits one theme.
1960
+ Left to the platform this is not neutral: Linux/GTK Chrome draws a wide track
1961
+ with STEPPER ARROWS at both ends, so a dark product grows two grey buttons per
1962
+ scroll region. Windows draws a wide light track. macOS overlays a thin one,
1963
+ which is the behaviour the other two should have had.
1964
+
1965
+ THE TWO HALVES MUST NOT BE DECLARED TOGETHER, and that is the whole subtlety.
1966
+ Chromium supports both the standard properties and the `::-webkit-scrollbar`
1967
+ pseudo-elements — but the moment `scrollbar-width` or `scrollbar-color` is
1968
+ anything other than `auto`, it takes the standard path and DISCARDS the entire
1969
+ webkit block. Shipping both is how 8.1.19 removed nothing: measured headed on
1970
+ Linux, as-shipped gave a 10px gutter with arrows, while the authored webkit
1971
+ rule alone gives 8px with none. Isolated: webkit-only 8px no arrows;
1972
+ standard-only 10px arrows; both together 10px arrows.
1973
+
1974
+ Neither half is redundant, so neither can simply be deleted — Firefox
1975
+ implements ONLY the standard properties, Safari ONLY the webkit ones. They are
1976
+ separated by engine instead: the webkit block applies wherever the selector is
1977
+ understood, and the standard properties apply only where it is not.
1978
+
1979
+ And it is invisible headless. Chromium's headless shell paints OVERLAY
1980
+ scrollbars, so nothing is drawn, `offsetWidth - clientWidth` is 0 on a blank
1981
+ page, and `getComputedStyle(el, '::-webkit-scrollbar-button').display` happily
1982
+ reports `none` for a rule that never ran. This must be checked headed.
1976
1983
  ───────────────────────────────────────────────────────────────────────────── */
1977
- :where(
1984
+
1985
+ /* Firefox and anything else with no webkit pseudo-elements. */
1986
+ @supports not selector(::-webkit-scrollbar) {
1987
+ :where(
1978
1988
  [data-slot='fill'],
1979
1989
  [data-slot='thread'],
1980
1990
  [data-slot='sources-strip'],
@@ -1983,12 +1993,44 @@
1983
1993
  [data-slot='textarea'],
1984
1994
  [data-slot='composer-field']
1985
1995
  ) {
1986
- /* Firefox — no pseudo-elements, two properties, same intent. */
1987
- scrollbar-width: thin;
1988
- scrollbar-color: rgb(255 255 255 / 0.18) transparent;
1989
- }
1996
+ scrollbar-width: thin;
1997
+ scrollbar-color: rgb(255 255 255 / 0.18) transparent;
1998
+ }
1999
+ .t_light :where(
2000
+ [data-slot='fill'],
2001
+ [data-slot='thread'],
2002
+ [data-slot='sources-strip'],
2003
+ [data-slot='sidebar-scroll'],
2004
+ [data-slot='scroll-area-viewport'],
2005
+ [data-slot='textarea'],
2006
+ [data-slot='composer-field']
2007
+ ) { scrollbar-color: rgb(0 0 0 / 0.20) transparent; }
2008
+ }
2009
+
2010
+ /* Chromium and Safari.
2011
+ The first rule is the load-bearing one and it is a RESET, not a style.
2012
+ @hanzo/design sets `scrollbar-color` and `scrollbar-width` on `:where(html)`
2013
+ (theme.css), and both INHERIT — so every element in the document already
2014
+ carries a non-`auto` value, Chromium takes the standard path, and the whole
2015
+ webkit block below is discarded before it is read. Nothing declared here can
2016
+ win until the inherited value is put back to `auto` on the element itself.
2017
+ That is why the arrows survived 8.1.19: the competing declaration was one
2018
+ level up and inherited, not a rule anyone would find in this file. */
2019
+ @supports selector(::-webkit-scrollbar) {
2020
+ :where(
2021
+ [data-slot='fill'],
2022
+ [data-slot='thread'],
2023
+ [data-slot='sources-strip'],
2024
+ [data-slot='sidebar-scroll'],
2025
+ [data-slot='scroll-area-viewport'],
2026
+ [data-slot='textarea'],
2027
+ [data-slot='composer-field']
2028
+ ) {
2029
+ scrollbar-width: auto;
2030
+ scrollbar-color: auto;
2031
+ }
1990
2032
 
1991
- :where(
2033
+ :where(
1992
2034
  [data-slot='fill'],
1993
2035
  [data-slot='thread'],
1994
2036
  [data-slot='sources-strip'],
@@ -1996,13 +2038,11 @@
1996
2038
  [data-slot='scroll-area-viewport'],
1997
2039
  [data-slot='textarea'],
1998
2040
  [data-slot='composer-field']
1999
- )::-webkit-scrollbar {
2000
- width: 8px;
2001
- height: 8px;
2002
- }
2041
+ )::-webkit-scrollbar { width: 8px; height: 8px; }
2003
2042
 
2004
- /* The steppers. This is the rule that removes the arrows. */
2005
- :where(
2043
+ /* The steppers. This is the rule that removes the arrows, and the reason the
2044
+ two halves had to be separated at all. */
2045
+ :where(
2006
2046
  [data-slot='fill'],
2007
2047
  [data-slot='thread'],
2008
2048
  [data-slot='sources-strip'],
@@ -2010,13 +2050,9 @@
2010
2050
  [data-slot='scroll-area-viewport'],
2011
2051
  [data-slot='textarea'],
2012
2052
  [data-slot='composer-field']
2013
- )::-webkit-scrollbar-button {
2014
- display: none;
2015
- width: 0;
2016
- height: 0;
2017
- }
2053
+ )::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
2018
2054
 
2019
- :where(
2055
+ :where(
2020
2056
  [data-slot='fill'],
2021
2057
  [data-slot='thread'],
2022
2058
  [data-slot='sources-strip'],
@@ -2024,11 +2060,9 @@
2024
2060
  [data-slot='scroll-area-viewport'],
2025
2061
  [data-slot='textarea'],
2026
2062
  [data-slot='composer-field']
2027
- )::-webkit-scrollbar-track {
2028
- background: transparent;
2029
- }
2063
+ )::-webkit-scrollbar-track { background: transparent; }
2030
2064
 
2031
- :where(
2065
+ :where(
2032
2066
  [data-slot='fill'],
2033
2067
  [data-slot='thread'],
2034
2068
  [data-slot='sources-strip'],
@@ -2037,16 +2071,15 @@
2037
2071
  [data-slot='textarea'],
2038
2072
  [data-slot='composer-field']
2039
2073
  )::-webkit-scrollbar-thumb {
2040
- background: rgb(255 255 255 / 0.18);
2041
- border-radius: 999px;
2042
- /* A transparent border with background-clip keeps the thumb off the very edge
2043
- without a track colour doing it, which is what makes it read as an overlay
2044
- rather than a channel. */
2045
- border: 2px solid transparent;
2046
- background-clip: content-box;
2047
- }
2048
-
2049
- :where(
2074
+ background: rgb(255 255 255 / 0.18);
2075
+ border-radius: 999px;
2076
+ /* A transparent border with background-clip keeps the thumb off the very
2077
+ edge without a track colour doing it, so it reads as an overlay rather
2078
+ than a channel. */
2079
+ border: 2px solid transparent;
2080
+ background-clip: content-box;
2081
+ }
2082
+ :where(
2050
2083
  [data-slot='fill'],
2051
2084
  [data-slot='thread'],
2052
2085
  [data-slot='sources-strip'],
@@ -2055,12 +2088,10 @@
2055
2088
  [data-slot='textarea'],
2056
2089
  [data-slot='composer-field']
2057
2090
  )::-webkit-scrollbar-thumb:hover {
2058
- background: rgb(255 255 255 / 0.30);
2059
- background-clip: content-box;
2060
- }
2061
-
2062
- /* The light theme reads the same ladder from the other side. */
2063
- .t_light :where(
2091
+ background: rgb(255 255 255 / 0.30);
2092
+ background-clip: content-box;
2093
+ }
2094
+ :where(
2064
2095
  [data-slot='fill'],
2065
2096
  [data-slot='thread'],
2066
2097
  [data-slot='sources-strip'],
@@ -2068,11 +2099,9 @@
2068
2099
  [data-slot='scroll-area-viewport'],
2069
2100
  [data-slot='textarea'],
2070
2101
  [data-slot='composer-field']
2071
- ) {
2072
- scrollbar-color: rgb(0 0 0 / 0.20) transparent;
2073
- }
2102
+ )::-webkit-scrollbar-corner { background: transparent; }
2074
2103
 
2075
- .t_light :where(
2104
+ .t_light :where(
2076
2105
  [data-slot='fill'],
2077
2106
  [data-slot='thread'],
2078
2107
  [data-slot='sources-strip'],
@@ -2081,17 +2110,15 @@
2081
2110
  [data-slot='textarea'],
2082
2111
  [data-slot='composer-field']
2083
2112
  )::-webkit-scrollbar-thumb {
2084
- background: rgb(0 0 0 / 0.20);
2085
- background-clip: content-box;
2113
+ background: rgb(0 0 0 / 0.20);
2114
+ background-clip: content-box;
2115
+ }
2086
2116
  }
2087
2117
 
2088
2118
  /* The textarea's resize grip is the other platform artefact in the same family:
2089
- a diagonal hatch in the corner of every Textarea and composer, drawn by the UA
2090
- and matching nothing. A composer that grows with its content does not need a
2091
- drag handle, and one that does not grow should not offer a broken one. */
2092
- :where([data-slot='textarea'], [data-slot='composer-field']) {
2093
- resize: none;
2094
- }
2119
+ a diagonal hatch drawn by the UA that matches nothing. A composer that grows
2120
+ with its content does not need one. */
2121
+ :where([data-slot='textarea'], [data-slot='composer-field']) { resize: none; }
2095
2122
 
2096
2123
  ._ovs-contain {overscroll-behavior:contain;}
2097
2124
  .t_unmounted .is_View, .t_unmounted .is_Text { transition: none !important; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/ui",
3
- "version": "8.1.20",
3
+ "version": "8.2.0",
4
4
  "type": "module",
5
5
  "description": "Hanzo UI — the one canonical Hanzo component library, on @hanzo/gui + @hanzo/design. ONE substrate: every component renders through @hanzo/gui primitives, so the same import works on web, native (expo) and desktop (Tauri). Self-contained (theme.css), presentational, host-agnostic, clean-room.",
6
6
  "exports": {
@@ -188,6 +188,11 @@
188
188
  "types": "./dist/dots.d.ts",
189
189
  "import": "./dist/dots.js",
190
190
  "require": "./dist/dots.cjs"
191
+ },
192
+ "./grid": {
193
+ "types": "./dist/grid.d.ts",
194
+ "import": "./dist/grid.js",
195
+ "require": "./dist/grid.cjs"
191
196
  }
192
197
  },
193
198
  "main": "./dist/index.cjs",
@@ -1,73 +0,0 @@
1
- 'use client';"use strict";
2
- 'use client';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Grid = void 0;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- /**
7
- * Grid — a real CSS grid whose tracks come from the CONTAINER, not the children.
8
- *
9
- * This exists to kill a specific shipped defect: hand-rolled
10
- * `width="calc(25% - 7.5px)"` grids that collapse asymmetrically. That shape is
11
- * broken by construction — each child computes its own width, so the row is only
12
- * even while every child agrees, and one long word or one `box-sizing` surprise
13
- * makes the row ragged. Nothing about it can be fixed by tuning the number.
14
- *
15
- * Here the parent declares the tracks once and the children have no say. Equal
16
- * columns are structural, not arithmetic, and no child can widen its own track.
17
- *
18
- * Why a plain div and not a gui YStack: gui's box model is Yoga, which is
19
- * flexbox and has no grid — a YStack would compile its own `display:flex`
20
- * atomic class and fight the grid. Inline styles, not a stylesheet class, so
21
- * there is no rule to fail to ship: this package's own checker exists because
22
- * "class with no rule" has shipped here three times.
23
- *
24
- * The two track formulas, both deliberate:
25
- *
26
- * auto repeat(auto-fill, minmax(min(Npx, 100%), 1fr))
27
- * The `min(Npx, 100%)` is what makes it safe below N: a bare
28
- * `minmax(240px, 1fr)` forces a 240px track inside a 200px phone and
29
- * overflows the viewport horizontally. Responsive with ZERO breakpoint
30
- * props — the wrap count follows the container, so the same tree is
31
- * right at 390 and at 1280.
32
- *
33
- * cols repeat(n, minmax(0, 1fr))
34
- * `1fr` alone means `minmax(auto, 1fr)`, and `auto` floors the track at
35
- * the content's min-content width — so one long unbroken string pushes
36
- * its own column wider and every sibling narrower. That IS the ragged
37
- * row. `minmax(0, 1fr)` is the fix.
38
- *
39
- * `[data-slot='grid'] > *` also gets `min-width: 0` in the stylesheet, for the
40
- * same reason: a grid item's default `min-width: auto` lets its content set the
41
- * floor and blow the track out.
42
- */
43
- const gui_1 = require("@hanzo/gui");
44
- /** `'$3'` -> 12. A raw number passes through as px. */
45
- const space = (v, fallback) => {
46
- if (v == null)
47
- return fallback;
48
- if (typeof v === 'number')
49
- return v;
50
- const t = (0, gui_1.getTokenValue)(v, 'space');
51
- return typeof t === 'number' ? t : fallback;
52
- };
53
- const Grid = ({ min = 240, cols, max, gap = '$3', style, ...props }) => {
54
- const g = space(gap, 12);
55
- // The track floor, capped. Without `max` it is `min(Npx, 100%)` — N wide, but
56
- // never wider than the container, which is what keeps a 900px min from
57
- // overflowing a 390px phone.
58
- //
59
- // With `max` the floor also has to be at least "one Mth of the row", so
60
- // auto-fill can never fit an (M+1)th track: subtract the M-1 gaps first, then
61
- // divide. Below that width the max() picks Npx again and the grid wraps
62
- // normally — so the cap costs nothing on small screens, which is the whole
63
- // point of expressing it as a floor rather than a breakpoint.
64
- const floor = max
65
- ? `max(min(${min}px, 100%), calc((100% - ${(max - 1) * g}px) / ${max}))`
66
- : `min(${min}px, 100%)`;
67
- const columns = cols
68
- ? `repeat(${cols}, minmax(0, 1fr))`
69
- : `repeat(auto-fill, minmax(${floor}, 1fr))`;
70
- const grid = { display: 'grid', gridTemplateColumns: columns, gap: g };
71
- return (0, jsx_runtime_1.jsx)("div", { "data-slot": "grid", style: { ...grid, ...style }, ...props });
72
- };
73
- exports.Grid = Grid;
@@ -1,25 +0,0 @@
1
- import type { ComponentProps, ReactNode } from 'react';
2
- export interface GridProps extends Omit<ComponentProps<'div'>, 'children'> {
3
- /**
4
- * Narrowest a column may get before the grid drops one. The whole responsive
5
- * story: no breakpoints, no props per screen size.
6
- */
7
- min?: number;
8
- /** Fixed column count. Overrides `min` — use it when the count is the design. */
9
- cols?: number;
10
- /**
11
- * Never exceed this many columns, while still wrapping down on narrow
12
- * screens. `<Grid min={160} max={4}>` is 2-up on a phone and 4-up on a
13
- * desktop, with nothing in between to configure.
14
- *
15
- * A single `min` cannot express that: 2-up at 390px needs min ~170, and that
16
- * same 170 gives SIX columns at 1280. Capping is the missing half.
17
- */
18
- max?: number;
19
- /** A `$n` space token or a raw px number. */
20
- gap?: number | string;
21
- children?: ReactNode;
22
- }
23
- declare const Grid: ({ min, cols, max, gap, style, ...props }: GridProps) => import("react/jsx-runtime").JSX.Element;
24
- export { Grid };
25
- //# sourceMappingURL=grid.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/grid.tsx"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAA;AAErE,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IACxE;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;;OAOG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAUD,QAAA,MAAM,IAAI,GAAI,0CAAuD,SAAS,4CAmB7E,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -1,71 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- /**
4
- * Grid — a real CSS grid whose tracks come from the CONTAINER, not the children.
5
- *
6
- * This exists to kill a specific shipped defect: hand-rolled
7
- * `width="calc(25% - 7.5px)"` grids that collapse asymmetrically. That shape is
8
- * broken by construction — each child computes its own width, so the row is only
9
- * even while every child agrees, and one long word or one `box-sizing` surprise
10
- * makes the row ragged. Nothing about it can be fixed by tuning the number.
11
- *
12
- * Here the parent declares the tracks once and the children have no say. Equal
13
- * columns are structural, not arithmetic, and no child can widen its own track.
14
- *
15
- * Why a plain div and not a gui YStack: gui's box model is Yoga, which is
16
- * flexbox and has no grid — a YStack would compile its own `display:flex`
17
- * atomic class and fight the grid. Inline styles, not a stylesheet class, so
18
- * there is no rule to fail to ship: this package's own checker exists because
19
- * "class with no rule" has shipped here three times.
20
- *
21
- * The two track formulas, both deliberate:
22
- *
23
- * auto repeat(auto-fill, minmax(min(Npx, 100%), 1fr))
24
- * The `min(Npx, 100%)` is what makes it safe below N: a bare
25
- * `minmax(240px, 1fr)` forces a 240px track inside a 200px phone and
26
- * overflows the viewport horizontally. Responsive with ZERO breakpoint
27
- * props — the wrap count follows the container, so the same tree is
28
- * right at 390 and at 1280.
29
- *
30
- * cols repeat(n, minmax(0, 1fr))
31
- * `1fr` alone means `minmax(auto, 1fr)`, and `auto` floors the track at
32
- * the content's min-content width — so one long unbroken string pushes
33
- * its own column wider and every sibling narrower. That IS the ragged
34
- * row. `minmax(0, 1fr)` is the fix.
35
- *
36
- * `[data-slot='grid'] > *` also gets `min-width: 0` in the stylesheet, for the
37
- * same reason: a grid item's default `min-width: auto` lets its content set the
38
- * floor and blow the track out.
39
- */
40
- import { getTokenValue } from '@hanzo/gui';
41
- /** `'$3'` -> 12. A raw number passes through as px. */
42
- const space = (v, fallback) => {
43
- if (v == null)
44
- return fallback;
45
- if (typeof v === 'number')
46
- return v;
47
- const t = getTokenValue(v, 'space');
48
- return typeof t === 'number' ? t : fallback;
49
- };
50
- const Grid = ({ min = 240, cols, max, gap = '$3', style, ...props }) => {
51
- const g = space(gap, 12);
52
- // The track floor, capped. Without `max` it is `min(Npx, 100%)` — N wide, but
53
- // never wider than the container, which is what keeps a 900px min from
54
- // overflowing a 390px phone.
55
- //
56
- // With `max` the floor also has to be at least "one Mth of the row", so
57
- // auto-fill can never fit an (M+1)th track: subtract the M-1 gaps first, then
58
- // divide. Below that width the max() picks Npx again and the grid wraps
59
- // normally — so the cap costs nothing on small screens, which is the whole
60
- // point of expressing it as a floor rather than a breakpoint.
61
- const floor = max
62
- ? `max(min(${min}px, 100%), calc((100% - ${(max - 1) * g}px) / ${max}))`
63
- : `min(${min}px, 100%)`;
64
- const columns = cols
65
- ? `repeat(${cols}, minmax(0, 1fr))`
66
- : `repeat(auto-fill, minmax(${floor}, 1fr))`;
67
- const grid = { display: 'grid', gridTemplateColumns: columns, gap: g };
68
- return _jsx("div", { "data-slot": "grid", style: { ...grid, ...style }, ...props });
69
- };
70
- export { Grid };
71
- //# sourceMappingURL=grid.js.map