@pretable/ui 0.0.14 → 0.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.
package/dist/grid.css CHANGED
@@ -125,10 +125,11 @@
125
125
 
126
126
  /* ---- Row grouping ---------------------------------------------------- */
127
127
 
128
- /* Group headers borrow the header fill so the eye reads them as structure
129
- rather than as another record. */
128
+ /* Group headers take a structural fill so the eye reads them as structure
129
+ rather than as another record. Its own token, not the header's: a theme
130
+ must be able to restyle group rows without restyling the header strip. */
130
131
  :where([data-pretable-group-row] [data-pretable-cell]) {
131
- background: var(--pretable-bg-header);
132
+ background: var(--pretable-bg-group-row);
132
133
  color: var(--pretable-text-header);
133
134
  font-weight: 600;
134
135
  }
@@ -194,20 +195,16 @@
194
195
  );
195
196
  }
196
197
 
197
- /* Hover */
198
- :where([data-pretable-row]:hover [data-pretable-cell]) {
199
- background: var(--pretable-bg-hover);
200
- }
201
-
202
- /* Pinned cells (sticky left) — reuse header background */
198
+ /* Pinned cells (sticky left) — an opaque fill so scrolled columns pass
199
+ underneath, on their own token rather than the header's. */
203
200
  :where([data-pretable-cell][data-pretable-pinned="left"]) {
204
- background: var(--pretable-bg-header);
201
+ background: var(--pretable-bg-pinned);
205
202
  z-index: 1;
206
203
  }
207
204
 
208
205
  /* Pinned cells (sticky right) — mirror of the left rule */
209
206
  :where([data-pretable-cell][data-pretable-pinned="right"]) {
210
- background: var(--pretable-bg-header);
207
+ background: var(--pretable-bg-pinned);
211
208
  z-index: 1;
212
209
  }
213
210
 
@@ -223,6 +220,26 @@
223
220
  var(--pretable-rule-vertical, var(--pretable-rule));
224
221
  }
225
222
 
223
+ /* Hover. Declared after the pinned surfaces on purpose: every selector here is
224
+ :where()-flattened to (0,0,0), so source order is the only cascade lever,
225
+ and a hover declared earlier loses on pinned cells — leaving a hovered row
226
+ visibly broken in half at the frozen edge. Selection follows this rule for
227
+ the same reason. */
228
+ :where([data-pretable-row]:hover [data-pretable-cell]) {
229
+ /* A background-IMAGE layer, not the background shorthand: the surface rules
230
+ that precede this one (base, zebra, group row, pinned) each set
231
+ `background-color`, and hover must tint that rather than replace it.
232
+ Replacing it is not cosmetic — `--pretable-bg-hover` is a translucent
233
+ state layer in both themes (Excel sets it to `transparent` outright), and
234
+ pinned cells are `position: sticky; z-index: 1` with unpinned cells
235
+ scrolling underneath. A hovered pinned cell that loses its opaque fill
236
+ lets the scrolled-under column print straight through it. */
237
+ background-image: linear-gradient(
238
+ var(--pretable-bg-hover),
239
+ var(--pretable-bg-hover)
240
+ );
241
+ }
242
+
226
243
  /* Selection text color. The selection FILL is drawn by the
227
244
  [role="gridcell"][aria-selected="true"] rule below: @pretable/react sets
228
245
  `aria-selected` and `data-pretable-selected` from the same condition, and
@@ -246,7 +263,17 @@
246
263
  * a usable visual.
247
264
  */
248
265
  :where([role="gridcell"][aria-selected="true"]) {
249
- background: var(--pretable-selection-bg);
266
+ /* A background-image layer for the same reason as hover above:
267
+ `--pretable-selection-bg` is a color-mix at 8% in both themes, so the
268
+ `background` shorthand would replace a pinned cell's opaque fill with a
269
+ 92%-transparent one and let the scrolled-under column show through.
270
+ This rule follows hover in source order, so on a cell that is both
271
+ hovered and selected the selection tint wins the background-image slot
272
+ outright — the same precedence the shorthand gave it, unchanged. */
273
+ background-image: linear-gradient(
274
+ var(--pretable-selection-bg),
275
+ var(--pretable-selection-bg)
276
+ );
250
277
  }
251
278
 
252
279
  :where([role="gridcell"][data-pretable-focused="true"]) {
@@ -300,6 +327,35 @@
300
327
  justify-content: center;
301
328
  padding: 0;
302
329
  }
330
+
331
+ /* Rows containing a wrapped cell top-align every cell, so each column's first
332
+ line shares a baseline instead of every cell centring independently against
333
+ a variable row height.
334
+ `data-pretable-wrap` comes from `column.wrap` — a COLUMN property — so it
335
+ marks "this column can wrap", not "this cell did wrap". The match is
336
+ therefore static, and alignment never flips as streaming content changes a
337
+ row's height. A true per-row signal would flip on every height change; do
338
+ not add one.
339
+ Placed AFTER the row-selection rule deliberately: every selector in this
340
+ file is :where()-flattened to (0,0,0), so source order is the only thing
341
+ that lets this reach the checkbox cell. Left centred, the checkbox floats
342
+ far below the row it selects once a cell wraps to three lines. */
343
+ :where(
344
+ [data-pretable-row]:has([data-pretable-wrap="true"]) [data-pretable-cell]
345
+ ) {
346
+ align-items: flex-start;
347
+ }
348
+
349
+ /* The checkbox cell zeroes its padding to centre a 16px control in the row.
350
+ Top-aligned it needs that vertical padding back, or it sits above the first
351
+ line of text instead of on it. */
352
+ :where(
353
+ [data-pretable-row]:has([data-pretable-wrap="true"])
354
+ [data-pretable-cell][data-pretable-row-select-cell="true"]
355
+ ) {
356
+ padding-top: var(--pretable-cell-padding-y);
357
+ }
358
+
303
359
  :where(
304
360
  button[data-pretable-row-select],
305
361
  button[data-pretable-row-select-all],
@@ -381,7 +437,7 @@
381
437
  position: fixed;
382
438
  pointer-events: none;
383
439
  background: var(--pretable-reorder-ghost-bg);
384
- box-shadow: var(--pretable-reorder-ghost-shadow);
440
+ box-shadow: var(--pretable-shadow-overlay);
385
441
  opacity: 0.6;
386
442
  z-index: 10;
387
443
  user-select: none;
@@ -408,7 +464,7 @@
408
464
  height: 18px;
409
465
  padding: 0;
410
466
  border: 0;
411
- border-radius: var(--pretable-radius);
467
+ border-radius: var(--pretable-radius-control);
412
468
  background: transparent;
413
469
  color: var(--pretable-text-dim);
414
470
  cursor: pointer;
@@ -438,7 +494,7 @@
438
494
  flex-direction: column;
439
495
  gap: 8px;
440
496
  padding: 10px;
441
- box-shadow: var(--pretable-reorder-ghost-shadow);
497
+ box-shadow: var(--pretable-shadow-overlay);
442
498
  font: inherit;
443
499
  /* Portaled into <body>, so the font-family declared on the scroll
444
500
  viewport is no longer inherited — declare it here. */
@@ -452,7 +508,7 @@
452
508
  box-sizing: border-box;
453
509
  padding: 5px 7px;
454
510
  border: 1px solid var(--pretable-rule);
455
- border-radius: var(--pretable-radius);
511
+ border-radius: var(--pretable-radius-control);
456
512
  background: var(--pretable-bg-grid);
457
513
  color: var(--pretable-text-cell);
458
514
  font: inherit;
@@ -583,7 +639,7 @@
583
639
  height: 14px;
584
640
  padding: 0;
585
641
  border: 0;
586
- border-radius: var(--pretable-radius);
642
+ border-radius: var(--pretable-radius-control);
587
643
  background: transparent;
588
644
  color: var(--pretable-text-dim);
589
645
  font-size: 10px;
@@ -619,7 +675,7 @@
619
675
  height: 18px;
620
676
  padding: 0;
621
677
  border: 0;
622
- border-radius: var(--pretable-radius);
678
+ border-radius: var(--pretable-radius-control);
623
679
  background: transparent;
624
680
  color: var(--pretable-text-dim);
625
681
  cursor: pointer;
@@ -640,7 +696,7 @@
640
696
  display: flex;
641
697
  flex-direction: column;
642
698
  padding: 4px;
643
- box-shadow: var(--pretable-reorder-ghost-shadow);
699
+ box-shadow: var(--pretable-shadow-overlay);
644
700
  /* Portaled into <body>, so nothing is inherited from the viewport. */
645
701
  font-family: var(--pretable-font-sans);
646
702
  font-size: var(--pretable-font-size-cell);
@@ -650,7 +706,7 @@
650
706
  width: 100%;
651
707
  padding: 6px 8px;
652
708
  border: 0;
653
- border-radius: var(--pretable-radius);
709
+ border-radius: var(--pretable-radius-control);
654
710
  background: transparent;
655
711
  color: var(--pretable-text-cell);
656
712
  font: inherit;
@@ -681,7 +737,7 @@
681
737
  background: var(--pretable-bg-grid);
682
738
  border: 1px solid var(--pretable-rule-strong);
683
739
  border-radius: var(--pretable-radius);
684
- box-shadow: var(--pretable-reorder-ghost-shadow);
740
+ box-shadow: var(--pretable-shadow-overlay);
685
741
  /* Portaled into <body> — see the filter menu above. */
686
742
  font-family: var(--pretable-font-sans);
687
743
  font-size: var(--pretable-font-size-cell);
@@ -719,7 +775,7 @@
719
775
  background: var(--pretable-bg-grid);
720
776
  border: 1px solid var(--pretable-rule-strong);
721
777
  border-radius: var(--pretable-radius);
722
- box-shadow: var(--pretable-reorder-ghost-shadow);
778
+ box-shadow: var(--pretable-shadow-overlay);
723
779
  /* Portaled into <body> — see the filter menu above. */
724
780
  font-family: var(--pretable-font-sans);
725
781
  font-size: var(--pretable-font-size-cell);
@@ -760,7 +816,7 @@
760
816
  :where([data-pretable-date-day]) {
761
817
  text-align: center;
762
818
  padding: 4px 0;
763
- border-radius: var(--pretable-radius);
819
+ border-radius: var(--pretable-radius-control);
764
820
  cursor: pointer;
765
821
  }
766
822
 
@@ -861,4 +917,50 @@
861
917
  font-family: var(--pretable-font-sans);
862
918
  font-size: var(--pretable-font-size-cell);
863
919
  }
920
+
921
+ /* Data-lifecycle body states. Austere by design: no spinner opinion and no
922
+ animation — a consumer who wants one supplies `renderBodyState`.
923
+ The boxes themselves are positioned from inline layout math (the overlay's
924
+ top inset is the resolved header + panel height, which CSS cannot derive). */
925
+ :where([data-pretable-body-state]) {
926
+ box-sizing: border-box;
927
+ padding: calc(var(--pretable-cell-padding-y) * 4)
928
+ var(--pretable-cell-padding-x);
929
+ background: var(--pretable-bg-grid);
930
+ color: var(--pretable-text-dim);
931
+ font-family: var(--pretable-font-sans);
932
+ font-size: var(--pretable-font-size-cell);
933
+ text-align: center;
934
+ }
935
+
936
+ /* Failures read left-aligned like prose, and in the theme's error color. */
937
+ :where([data-pretable-body-state="error"]),
938
+ :where([data-pretable-body-state="error-strip"]) {
939
+ color: var(--pretable-text-error);
940
+ text-align: start;
941
+ }
942
+
943
+ /* The strip is a card stacked on top of the box below it, so it carries that
944
+ box's border and rounds only its own top. `border-bottom: 0` is what stops
945
+ the seam being drawn twice. */
946
+ :where([data-pretable-body-state="error-strip"]) {
947
+ border: 1px solid var(--pretable-rule-strong);
948
+ border-bottom: 0;
949
+ border-radius: var(--pretable-radius) var(--pretable-radius) 0 0;
950
+ }
951
+
952
+ /* …and the box below squares the two corners that now meet in the middle,
953
+ the same rule the group panel needs one level up. With the panel enabled
954
+ the strip stacks on the panel, which is then the box that squares. */
955
+ :where(
956
+ [data-pretable-body-state="error-strip"] + [data-pretable-scroll-viewport]
957
+ ),
958
+ :where(
959
+ [data-pretable-body-state="error-strip"]
960
+ + [data-pretable-group-panel-wrapper]
961
+ [data-pretable-group-panel]
962
+ ) {
963
+ border-top-left-radius: 0;
964
+ border-top-right-radius: 0;
965
+ }
864
966
  }
package/dist/index.d.cts CHANGED
@@ -17,8 +17,11 @@ interface DensityHeights {
17
17
  *
18
18
  * SSR-safe: returns the fallback values when `document` is undefined.
19
19
  *
20
- * For non-React consumers, tests, custom virtualizers, and power users.
21
- * The reactive React hook (`useResolvedHeights`) lives in `@pretable/react`.
20
+ * For non-React consumers, tests, custom virtualizers, and power users. This
21
+ * is the only public way to read density into JavaScript: `@pretable/react`'s
22
+ * reactive equivalent is internal, so a React caller that needs the values to
23
+ * follow a theme or density swap wraps this in its own `useSyncExternalStore`
24
+ * — the docs at `/docs/grid/density-helpers` carry the recipe.
22
25
  *
23
26
  * @public
24
27
  */
package/dist/index.d.ts CHANGED
@@ -17,8 +17,11 @@ interface DensityHeights {
17
17
  *
18
18
  * SSR-safe: returns the fallback values when `document` is undefined.
19
19
  *
20
- * For non-React consumers, tests, custom virtualizers, and power users.
21
- * The reactive React hook (`useResolvedHeights`) lives in `@pretable/react`.
20
+ * For non-React consumers, tests, custom virtualizers, and power users. This
21
+ * is the only public way to read density into JavaScript: `@pretable/react`'s
22
+ * reactive equivalent is internal, so a React caller that needs the values to
23
+ * follow a theme or density swap wraps this in its own `useSyncExternalStore`
24
+ * — the docs at `/docs/grid/density-helpers` carry the recipe.
22
25
  *
23
26
  * @public
24
27
  */
@@ -12,6 +12,12 @@
12
12
  --pretable-bg-grid: #ffffff;
13
13
  --pretable-bg-grid-alt: #ffffff; /* No striping by default — Excel doesn't band */
14
14
  --pretable-bg-header: #f3f3f3; /* Excel-for-web header strip */
15
+ /* Pinned body cells and group rows historically borrowed --pretable-bg-header,
16
+ which made it impossible to restyle a frozen data column without also
17
+ restyling the header. They now have their own tokens, defaulted here to the
18
+ value this theme already resolved so nothing moves. */
19
+ --pretable-bg-pinned: var(--pretable-bg-header);
20
+ --pretable-bg-group-row: var(--pretable-bg-header);
15
21
  --pretable-bg-toolbar: #f3f3f3;
16
22
  --pretable-bg-tooltip: #ffffff;
17
23
 
@@ -30,6 +36,7 @@
30
36
  --pretable-rule-vertical: var(--pretable-rule);
31
37
  --pretable-rule-width: 1px;
32
38
  --pretable-radius: 0; /* Sharp edges — Excel never rounds */
39
+ --pretable-radius-control: 0; /* Buttons and menu items don't round either */
33
40
 
34
41
  /* State */
35
42
  --pretable-bg-hover: transparent; /* No row hover — iconic Excel; consumers opt in */
@@ -55,9 +62,18 @@
55
62
  --pretable-resize-handle: transparent;
56
63
  --pretable-resize-handle-hover: var(--pretable-accent);
57
64
  --pretable-reorder-ghost-bg: var(--pretable-bg-header);
58
- --pretable-reorder-ghost-shadow: 0 4px 12px rgb(0 0 0 / 0.12);
59
65
  --pretable-reorder-drop-indicator: var(--pretable-accent);
60
66
 
67
+ /* Elevation. Four of the five things that read a shadow are popovers, so the
68
+ scale is named for what is lifted, not for the drag ghost that happened to
69
+ need one first. */
70
+ --pretable-shadow-overlay: 0 4px 12px rgb(0 0 0 / 0.12);
71
+ /* No card shadow: this theme draws a frame instead. pretable.css uses it. */
72
+ --pretable-shadow-card: none;
73
+ /* The frozen-column edge. Spread must be <= -blur/2 or the blur bleeds above
74
+ and below each pinned cell and paints a dark band at every row boundary. */
75
+ --pretable-shadow-seam: 6px 0 10px -8px rgb(0 0 0 / 0.18);
76
+
61
77
  /* Density — natural default = compact (Excel "Compact" tier) */
62
78
  --pretable-row-height: 20px; /* 15pt at 96 DPI */
63
79
  --pretable-header-height: 24px;
@@ -10,6 +10,12 @@
10
10
  --pretable-bg-grid: #fcfcfc; /* N99 */
11
11
  --pretable-bg-grid-alt: #fcfcfc; /* No striping by default — Material list pattern */
12
12
  --pretable-bg-header: #f3f3f3; /* N96 — one tonal step up */
13
+ /* Pinned body cells and group rows historically borrowed --pretable-bg-header,
14
+ which made it impossible to restyle a frozen data column without also
15
+ restyling the header. They now have their own tokens, defaulted here to the
16
+ value this theme already resolved so nothing moves. */
17
+ --pretable-bg-pinned: var(--pretable-bg-header);
18
+ --pretable-bg-group-row: var(--pretable-bg-header);
13
19
  --pretable-bg-toolbar: #f3f3f3;
14
20
  --pretable-bg-tooltip: #f3f3f3;
15
21
 
@@ -29,6 +35,10 @@
29
35
  --pretable-rule-vertical: var(--pretable-rule);
30
36
  --pretable-rule-width: 1px;
31
37
  --pretable-radius: 12px; /* M3 medium shape scale (matches Card) */
38
+ /* Small affordances need their own step: the card radius applied to a 14–18px
39
+ control (funnel, ⋮ button, chip remove) rounds it into a circle. M3 small
40
+ shape scale. */
41
+ --pretable-radius-control: 6px;
32
42
 
33
43
  /* State */
34
44
  --pretable-bg-hover: rgba(
@@ -59,9 +69,18 @@
59
69
  --pretable-resize-handle: transparent;
60
70
  --pretable-resize-handle-hover: var(--pretable-accent);
61
71
  --pretable-reorder-ghost-bg: var(--pretable-bg-header);
62
- --pretable-reorder-ghost-shadow: 0 4px 12px rgb(0 0 0 / 0.12);
63
72
  --pretable-reorder-drop-indicator: var(--pretable-accent);
64
73
 
74
+ /* Elevation. Four of the five things that read a shadow are popovers, so the
75
+ scale is named for what is lifted, not for the drag ghost that happened to
76
+ need one first. */
77
+ --pretable-shadow-overlay: 0 4px 12px rgb(0 0 0 / 0.12);
78
+ /* No card shadow: this theme draws a frame instead. pretable.css uses it. */
79
+ --pretable-shadow-card: none;
80
+ /* The frozen-column edge. Spread must be <= -blur/2 or the blur bleeds above
81
+ and below each pinned cell and paints a dark band at every row boundary. */
82
+ --pretable-shadow-seam: 6px 0 10px -8px rgb(0 0 0 / 0.18);
83
+
65
84
  /* Density — natural default = standard */
66
85
  --pretable-row-height: 48px;
67
86
  --pretable-header-height: 52px;
@@ -127,4 +146,10 @@
127
146
  --pretable-text-error: #f2b8b5; /* M3 error (dark) */
128
147
 
129
148
  --pretable-accent: #9ecaff;
149
+
150
+ /* A 12%-black shadow on a #1c1c1c surface is invisible, so every dark-mode
151
+ popover read as flat until this override existed. Deeper and more opaque
152
+ rather than lighter: M3 keeps shadows black in dark mode and gets the
153
+ separation from the tonal surface, not from the shadow color. */
154
+ --pretable-shadow-overlay: 0 4px 12px rgb(0 0 0 / 0.5);
130
155
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pretable/ui",
3
- "version": "0.0.14",
3
+ "version": "0.2.0",
4
4
  "description": "CSS themes, tokens, and grid styles for Pretable.",
5
5
  "license": "MIT",
6
6
  "repository": {