@glasshome/ui 1.18.0 → 1.20.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 (78) hide show
  1. package/SPEC.md +84 -2
  2. package/dist/index.js +2 -2
  3. package/dist/lib/anchor-placement.d.ts +5 -0
  4. package/dist/lib/button-variants.d.ts +4 -1
  5. package/dist/lib/card-classes.d.ts +4 -4
  6. package/dist/lib/motion-classes.d.ts +2 -0
  7. package/dist/lib/overlay-classes.d.ts +4 -2
  8. package/dist/lib/spotlight-geometry.d.ts +22 -0
  9. package/dist/solid/button.d.ts +8 -3
  10. package/dist/solid/color-disc.d.ts +33 -0
  11. package/dist/solid/dashboard-preview.d.ts +24 -0
  12. package/dist/solid/dialog-parts.d.ts +1 -0
  13. package/dist/solid/dialog.d.ts +3 -0
  14. package/dist/solid/dock.d.ts +9 -0
  15. package/dist/solid/docked-panel.d.ts +11 -0
  16. package/dist/solid/image-picker.d.ts +3 -0
  17. package/dist/solid/index.d.ts +9 -3
  18. package/dist/solid/index.js +6254 -5475
  19. package/dist/solid/media-store.d.ts +10 -0
  20. package/dist/solid/option-card.d.ts +2 -1
  21. package/dist/solid/page-header.d.ts +2 -2
  22. package/dist/solid/preview-tile.d.ts +35 -0
  23. package/dist/solid/responsive-dialog.d.ts +2 -0
  24. package/dist/solid/schema-form.d.ts +6 -1
  25. package/dist/solid/sliding-indicator.d.ts +2 -0
  26. package/dist/solid/spotlight.d.ts +14 -0
  27. package/dist/solid/swatch-picker.d.ts +12 -0
  28. package/dist/solid/tabs.d.ts +4 -1
  29. package/dist/solid/toggle-group.d.ts +4 -1
  30. package/dist/solid/widget-identity.d.ts +2 -0
  31. package/dist/tokens/index.d.ts +1 -0
  32. package/dist/tokens/index.js +336 -118
  33. package/dist/tokens/material.d.ts +40 -0
  34. package/dist/tokens/presets.d.ts +3 -0
  35. package/dist/tokens/theme-colors.d.ts +13 -3
  36. package/dist/tokens/theme-recipe.d.ts +8 -0
  37. package/dist/{utils-COITV1s9.js → utils-CMk7R3zM.js} +488 -485
  38. package/package.json +2 -2
  39. package/scripts/check-ui-drift.mjs +5 -0
  40. package/src/lib/anchor-placement.ts +30 -0
  41. package/src/lib/button-variants.ts +13 -12
  42. package/src/lib/card-classes.ts +4 -3
  43. package/src/lib/motion-classes.ts +10 -0
  44. package/src/lib/overlay-classes.ts +10 -2
  45. package/src/lib/spotlight-geometry.ts +90 -0
  46. package/src/solid/bottom-sheet/bottom-sheet.tsx +8 -1
  47. package/src/solid/button.tsx +17 -2
  48. package/src/solid/color-disc.tsx +253 -0
  49. package/src/solid/dashboard-preview.tsx +128 -0
  50. package/src/solid/dialog-parts.tsx +5 -1
  51. package/src/solid/dialog.tsx +47 -5
  52. package/src/solid/dock.tsx +67 -9
  53. package/src/solid/docked-panel.tsx +56 -0
  54. package/src/solid/entity-selector.tsx +2 -2
  55. package/src/solid/hero-action.tsx +2 -2
  56. package/src/solid/image-picker.tsx +232 -147
  57. package/src/solid/index.ts +20 -2
  58. package/src/solid/media-store.ts +20 -1
  59. package/src/solid/option-card.tsx +27 -31
  60. package/src/solid/page-header.tsx +9 -16
  61. package/src/solid/preview-tile.tsx +89 -0
  62. package/src/solid/radio-group.tsx +7 -2
  63. package/src/solid/responsive-dialog.tsx +10 -2
  64. package/src/solid/schema-form.tsx +30 -4
  65. package/src/solid/section-card.tsx +4 -2
  66. package/src/solid/sliding-indicator.tsx +34 -17
  67. package/src/solid/spotlight.tsx +179 -0
  68. package/src/solid/swatch-picker.tsx +47 -0
  69. package/src/solid/tabs.tsx +20 -4
  70. package/src/solid/toggle-group.tsx +43 -8
  71. package/src/solid/widget-identity.tsx +3 -1
  72. package/src/styles/globals.css +166 -14
  73. package/src/styles/theme.css +25 -3
  74. package/src/tokens/index.ts +1 -0
  75. package/src/tokens/material.ts +116 -0
  76. package/src/tokens/presets.ts +195 -56
  77. package/src/tokens/theme-colors.ts +15 -3
  78. package/src/tokens/theme-recipe.ts +18 -4
@@ -10,7 +10,6 @@ import {
10
10
  useContext,
11
11
  } from "solid-js";
12
12
  import { CARD_SURFACE } from "../lib/card-classes.js";
13
- import { isNeutralTone, NEUTRAL_KNOBS } from "../lib/glass-tone.js";
14
13
  import { STAGGER } from "../lib/motion-classes.js";
15
14
  import { cn } from "../lib/utils.js";
16
15
  import { Icon } from "./icon.js";
@@ -18,13 +17,8 @@ import { Ornament } from "./ornament.js";
18
17
  import { PickerRow } from "./picker-row.js";
19
18
  import { RadioGroup, RadioGroupItem } from "./radio-group.js";
20
19
 
21
- /* The card is the affordance, so the radio's own control is suppressed and the
22
- * toned surface plus the check ornament carry the picked state; an accented card keeps its own tone at rest. Tone alone (no
23
- * .glass-tint) because a card is body copy: .glass-tint would mix the label
24
- * colour toward the tone, and toward `transparent` while nothing is picked.
25
- * Padding lives inside the label, not on the item, so the whole card is a
26
- * click target. */
27
- const OPTION_CARD_CHROME = `${CARD_SURFACE} group/option-card relative cursor-pointer overflow-hidden rounded-md transition-glass duration-200 hover:[--glass-base:color-mix(in_srgb,var(--card)_80%,transparent)] has-[:focus-visible]:[--glass-edge:var(--ring)] has-[:focus-visible]:ring-[3px] has-[:focus-visible]:ring-ring/50 [&:not([style*=--glass-tone])]:data-[checked]:[--glass-tone:var(--primary)] data-[checked]:[--glass-edge:color-mix(in_srgb,var(--primary)_45%,transparent)] data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`;
20
+ /* Tone without .glass-tint: the card holds body copy, which must stay foreground-coloured. */
21
+ const OPTION_CARD_CHROME = `${CARD_SURFACE} group/option-card relative cursor-pointer overflow-hidden rounded-xl transition-glass duration-200 [&:not([style*=--glass-tone])]:[--glass-tone:var(--primary)] [--glass-wash:9%] hover:[--glass-wash:16%] has-[:focus-visible]:[--glass-edge:var(--ring)] has-[:focus-visible]:ring-[3px] has-[:focus-visible]:ring-ring/50 data-[checked]:[--glass-wash:30%] data-[checked]:[--glass-edge:oklch(from_var(--glass-tone)_l_c_h/0.75)] data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`;
28
22
 
29
23
  /* Sub-options live inside the card: the card grows (a grid row morphing
30
24
  * 0fr -> 1fr on the morph token) while it is picked, and the content settles
@@ -37,7 +31,7 @@ const OPTION_CHOICE_ROW =
37
31
  "rounded-sm text-foreground/75 transition-colors hover:bg-foreground/5 aria-checked:text-foreground";
38
32
 
39
33
  const OPTION_CARD_DRAWER_CONTENT =
40
- "-translate-y-2 flex flex-col gap-0.5 pr-1 pb-2 pl-[calc(var(--spacing)*4+20px)] opacity-0 transition-[opacity,translate] duration-(--duration-expand) ease-(--ease-morph) group-data-[checked]/option-card:translate-y-0 group-data-[checked]/option-card:opacity-100 group-data-[checked]/option-card:delay-[80ms]";
34
+ "-translate-y-2 flex flex-col gap-0.5 pr-1 pb-2 pl-[calc(var(--spacing)*3.5+54px)] opacity-0 transition-[opacity,translate] duration-(--duration-expand) ease-(--ease-morph) group-data-[checked]/option-card:translate-y-0 group-data-[checked]/option-card:opacity-100 group-data-[checked]/option-card:delay-[80ms]";
41
35
 
42
36
  /* Sub-options are rows of the card, chosen in place: the same row a picker
43
37
  * list shows, flat on the card (a glass pill on a glass card is a layer too
@@ -85,6 +79,7 @@ export function OptionCardGroup(props: {
85
79
  value: string | null;
86
80
  onChange: (value: string) => void;
87
81
  "aria-label"?: string;
82
+ "aria-labelledby"?: string;
88
83
  class?: string;
89
84
  children: JSX.Element;
90
85
  }) {
@@ -94,6 +89,7 @@ export function OptionCardGroup(props: {
94
89
  value={props.value ?? undefined}
95
90
  onChange={props.onChange}
96
91
  aria-label={props["aria-label"]}
92
+ aria-labelledby={props["aria-labelledby"]}
97
93
  >
98
94
  {props.children}
99
95
  </RadioGroup>
@@ -106,7 +102,7 @@ export function OptionCard(props: {
106
102
  description?: string;
107
103
  icon?: string;
108
104
  iconImage?: string;
109
- /** Per-option tone at rest (setup's brand colours); neutral by default. */
105
+ /** Per-option tone (setup's brand colours); the theme primary when absent. */
110
106
  accentVar?: string;
111
107
  /** Drop the check when picking the card is itself the next step. */
112
108
  ornament?: "check" | "none";
@@ -140,7 +136,8 @@ export function OptionCard(props: {
140
136
  <div
141
137
  data-slot="option-card"
142
138
  data-checked={checked() ? "" : undefined}
143
- class={cn(OPTION_CARD_CHROME, isNeutralTone(props.accentVar) && NEUTRAL_KNOBS, props.class)}
139
+ data-disabled={props.disabled ? "" : undefined}
140
+ class={cn(OPTION_CARD_CHROME, props.class)}
144
141
  style={
145
142
  props.accentVar ? ({ "--glass-tone": props.accentVar } as JSX.CSSProperties) : undefined
146
143
  }
@@ -154,14 +151,10 @@ export function OptionCard(props: {
154
151
  >
155
152
  {/* On the header row, not the card: a grown card keeps its rows clear. */}
156
153
  <Ornament kind={props.ornament ?? "check"} />
157
- <div data-slot="option-card-row" class="flex w-full items-start gap-3 p-3">
158
- <Show when={props.iconImage} fallback={<OptionIcon icon={props.icon} />}>
159
- {(src) => (
160
- <img src={src()} alt="" aria-hidden="true" class="size-5 shrink-0 object-contain" />
161
- )}
162
- </Show>
154
+ <div data-slot="option-card-row" class="flex w-full items-center gap-3.5 p-3.5">
155
+ <OptionIconWell icon={props.icon} image={props.iconImage} />
163
156
  <div class="flex min-w-0 flex-1 flex-col gap-0.5">
164
- <span data-slot="option-card-title" class="font-medium text-sm leading-snug">
157
+ <span data-slot="option-card-title" class="font-semibold text-[15px] leading-snug">
165
158
  {props.title}
166
159
  </span>
167
160
  <Show when={props.description}>
@@ -196,20 +189,23 @@ export function OptionCard(props: {
196
189
  );
197
190
  }
198
191
 
199
- /* The icon sits on the title line, the mini form of HeroAction's big glyph,
200
- * in text colour: the tone belongs to the surface and the ornament. */
201
- function OptionIcon(props: { icon?: string }) {
192
+ function OptionIconWell(props: { icon?: string; image?: string }) {
202
193
  return (
203
- <Show when={props.icon}>
204
- {(icon) => (
205
- <Icon
206
- icon={icon()}
207
- width={20}
208
- height={20}
209
- aria-hidden="true"
210
- class="mt-px shrink-0 text-muted-foreground"
211
- />
212
- )}
194
+ <Show when={props.icon || props.image}>
195
+ <span
196
+ data-slot="option-card-icon"
197
+ aria-hidden="true"
198
+ class="grid size-10 shrink-0 place-items-center rounded-[14px] bg-[color-mix(in_oklab,var(--surface-tone)_80%,black)] [color:oklch(from_var(--surface-tone)_calc((0.75_-_l)*100)_0_0)]"
199
+ >
200
+ <Show
201
+ when={props.image}
202
+ fallback={
203
+ <Show when={props.icon}>{(icon) => <Icon icon={icon()} width={20} height={20} />}</Show>
204
+ }
205
+ >
206
+ {(src) => <img src={src()} alt="" class="size-5 object-contain" />}
207
+ </Show>
208
+ </span>
213
209
  </Show>
214
210
  );
215
211
  }
@@ -1,13 +1,13 @@
1
1
  import { type JSX, Show } from "solid-js";
2
2
  import { CARD_BLUR, CARD_SURFACE_BASE } from "../lib/card-classes.js";
3
+ import { SECTION_OUTER_RADIUS } from "../lib/section-tokens.js";
3
4
  import { cn } from "../lib/utils.js";
4
5
  import { CountPill } from "./count-pill.js";
5
- import { Icon } from "./icon.js";
6
- import { type GlassSurface, NOOP_GLASS } from "./section-card.js";
6
+ import { type GlassSurface, NOOP_GLASS, SectionIcon } from "./section-card.js";
7
7
 
8
8
  /**
9
- * Page banner header, shared by dash and hub: the card surface with a primary
10
- * glow and an optional logo watermark. Content is a superset API: icon/iconNode
9
+ * Page banner header, shared by dash and hub: the card surface with a display
10
+ * title and an optional logo watermark. Content is a superset API: icon/iconNode
11
11
  * + title + count pill + subtitle on the left, actions on the right. The caller
12
12
  * owns the space around it.
13
13
  *
@@ -36,14 +36,10 @@ export function PageHeader(props: {
36
36
  <div
37
37
  data-slot="page-header"
38
38
  ref={glass().ref}
39
- class={cn(CARD_SURFACE_BASE, "relative overflow-hidden rounded-xl")}
39
+ class={cn(CARD_SURFACE_BASE, SECTION_OUTER_RADIUS, "relative overflow-hidden")}
40
40
  classList={{ [CARD_BLUR]: !(glass().active?.() ?? false) }}
41
41
  style={glass().style?.() ?? {}}
42
42
  >
43
- <div
44
- data-slot="page-header-glow"
45
- class="pointer-events-none absolute top-0 left-0 h-48 w-72 -translate-x-1/3 -translate-y-1/2 rounded-full bg-primary/15 blur-3xl"
46
- />
47
43
  <Show when={props.logo}>
48
44
  {(logo) => (
49
45
  <img
@@ -54,27 +50,24 @@ export function PageHeader(props: {
54
50
  />
55
51
  )}
56
52
  </Show>
57
- <div
58
- data-slot="page-header-row"
59
- class="relative flex min-h-[64px] items-center gap-2.5 px-4 py-3 sm:min-h-[80px] sm:gap-4 sm:px-6 sm:py-5"
60
- >
53
+ <div data-slot="page-header-row" class="relative flex items-center gap-3 p-4 sm:gap-5 sm:p-6">
61
54
  <Show
62
55
  when={props.iconNode}
63
56
  fallback={
64
57
  <Show when={props.icon}>
65
58
  {(icon) => (
66
- <Icon icon={icon()} class="shrink-0 text-[28px] text-primary sm:text-[32px]" />
59
+ <SectionIcon icon={icon()} size="lg" tone="var(--primary)" class="shrink-0" />
67
60
  )}
68
61
  </Show>
69
62
  }
70
63
  >
71
64
  {props.iconNode}
72
65
  </Show>
73
- <div data-slot="page-header-headings" class="flex min-w-0 flex-1 flex-col gap-0.5">
66
+ <div data-slot="page-header-headings" class="flex min-w-0 flex-1 flex-col gap-1.5 sm:gap-2">
74
67
  <div data-slot="page-header-headline" class="flex min-w-0 items-center gap-2 sm:gap-3">
75
68
  <h1
76
69
  data-slot="page-header-title"
77
- class="min-w-0 truncate font-bold text-foreground text-xl tracking-[-0.02em] sm:text-2xl"
70
+ class="min-w-0 truncate pb-0.5 font-bold text-[1.75rem] text-foreground leading-none tracking-[-0.035em] sm:text-[2.5rem]"
78
71
  >
79
72
  {props.title}
80
73
  </h1>
@@ -0,0 +1,89 @@
1
+ import type { JSX } from "solid-js";
2
+ import { Show } from "solid-js";
3
+ import { cn } from "../lib/utils.js";
4
+ import { Icon } from "./icon.js";
5
+ import { RadioGroup, RadioGroupItem } from "./radio-group.js";
6
+
7
+ const COLUMNS = { 2: "grid-cols-2", 3: "grid-cols-3", 4: "grid-cols-4" } as const;
8
+
9
+ const SHAPE = { wide: "aspect-[16/10]", tile: "aspect-[5/4]" } as const;
10
+
11
+ /* The face is the affordance: the radio control is suppressed and a ring on
12
+ * the face carries the picked state, the focus ring rides the same edge. */
13
+ const TILE_FACE =
14
+ "relative w-full overflow-hidden rounded-lg border border-border/60 transition-glass duration-200 group-active/preview-tile:scale-[0.97] group-data-[checked]/preview-tile:border-transparent group-data-[checked]/preview-tile:ring-2 group-data-[checked]/preview-tile:ring-primary group-data-[checked]/preview-tile:ring-offset-2 group-data-[checked]/preview-tile:ring-offset-transparent group-has-[:focus-visible]/preview-tile:ring-[3px] group-has-[:focus-visible]/preview-tile:ring-ring/50";
15
+
16
+ export function PreviewTileGroup(props: {
17
+ value: string | null;
18
+ onChange: (value: string) => void;
19
+ "aria-label": string;
20
+ columns?: keyof typeof COLUMNS;
21
+ class?: string;
22
+ children: JSX.Element;
23
+ }) {
24
+ return (
25
+ <RadioGroup
26
+ data-slot="preview-tile-group"
27
+ class={cn("grid gap-2.5", COLUMNS[props.columns ?? 2], props.class)}
28
+ value={props.value ?? ""}
29
+ onChange={props.onChange}
30
+ aria-label={props["aria-label"]}
31
+ >
32
+ {props.children}
33
+ </RadioGroup>
34
+ );
35
+ }
36
+
37
+ /** A choice shown as what it produces: a picture, a preview card, a shape. */
38
+ export function PreviewTile(props: {
39
+ value: string;
40
+ label: string;
41
+ /** A quieter second line under the caption. */
42
+ meta?: string;
43
+ /** Off for pictures that name themselves; the label still reaches assistive tech. */
44
+ caption?: boolean;
45
+ icon?: string;
46
+ shape?: keyof typeof SHAPE;
47
+ disabled?: boolean;
48
+ class?: string;
49
+ /** Fires on every click, including a re-pick of the checked tile. */
50
+ onPick?: () => void;
51
+ children: JSX.Element;
52
+ }) {
53
+ return (
54
+ <RadioGroupItem
55
+ data-slot="preview-tile"
56
+ value={props.value}
57
+ disabled={props.disabled}
58
+ showControl={false}
59
+ onClick={() => !props.disabled && props.onPick?.()}
60
+ class={cn(
61
+ "group/preview-tile min-w-0 [&_[data-slot=radio-group-item-content]]:flex [&_[data-slot=radio-group-item-content]]:flex-col [&_[data-slot=radio-group-item-content]]:gap-1.5",
62
+ props.class,
63
+ )}
64
+ >
65
+ <div data-slot="preview-tile-face" class={cn(TILE_FACE, SHAPE[props.shape ?? "wide"])}>
66
+ {props.children}
67
+ </div>
68
+ <Show when={props.caption ?? true} fallback={<span class="sr-only">{props.label}</span>}>
69
+ <span
70
+ data-slot="preview-tile-caption"
71
+ class="flex items-center justify-center gap-1 text-muted-foreground text-xs group-data-[checked]/preview-tile:text-foreground"
72
+ >
73
+ <Show when={props.icon}>
74
+ {(icon) => <Icon icon={icon()} width={12} height={12} aria-hidden="true" />}
75
+ </Show>
76
+ {props.label}
77
+ </span>
78
+ <Show when={props.meta}>
79
+ <span
80
+ data-slot="preview-tile-meta"
81
+ class="-mt-1 text-center text-[11px] text-muted-foreground/80 leading-tight"
82
+ >
83
+ {props.meta}
84
+ </span>
85
+ </Show>
86
+ </Show>
87
+ </RadioGroupItem>
88
+ );
89
+ }
@@ -43,8 +43,13 @@ const RadioGroupItem: Component<
43
43
  that animates in. */}
44
44
  <RadioGroupPrimitive.ItemIndicator
45
45
  data-slot="radio-group-item-indicator"
46
- class="glass glass-tint zoom-in-50 fade-in absolute inset-0 animate-in rounded-full duration-200 [--glass-tone:var(--primary)]"
47
- />
46
+ class="glass glass-tint zoom-in-50 fade-in absolute inset-0 grid animate-in place-items-center rounded-full duration-200 [--glass-tone:var(--primary)] [--glass-wash:90%]"
47
+ >
48
+ <span
49
+ data-slot="radio-group-item-dot"
50
+ class="size-[36%] rounded-full [background:oklch(from_var(--primary)_calc((0.42_-_l)*100)_0_0)] dark:[background:oklch(from_var(--primary)_calc((0.6_-_l)*100)_0_0)]"
51
+ />
52
+ </RadioGroupPrimitive.ItemIndicator>
48
53
  </RadioGroupPrimitive.ItemControl>
49
54
  </Show>
50
55
  {local.children && (
@@ -95,17 +95,25 @@ type ResponsiveDialogContentProps = ComponentProps<"div"> & {
95
95
  size?: ModalSize;
96
96
  /** Names a panel that has no `ResponsiveDialogTitle`. */
97
97
  ariaLabel?: string;
98
+ /** Desktop only: opens the panel beside this element instead of centred. The mobile sheet ignores it. */
99
+ anchor?: HTMLElement;
98
100
  };
99
101
 
100
102
  const ResponsiveDialogContent: ParentComponent<ResponsiveDialogContentProps> = (props) => {
101
103
  const ctx = useResponsiveDialogContext();
102
- const [local, rest] = splitProps(props, ["class", "children", "size", "ariaLabel"]);
104
+ const [local, rest] = splitProps(props, ["class", "children", "size", "ariaLabel", "anchor"]);
103
105
 
104
106
  return (
105
107
  <Show
106
108
  when={ctx.isMobile()}
107
109
  fallback={
108
- <DialogContent class={local.class} size={local.size} ariaLabel={local.ariaLabel} {...rest}>
110
+ <DialogContent
111
+ class={local.class}
112
+ size={local.size}
113
+ ariaLabel={local.ariaLabel}
114
+ anchor={local.anchor}
115
+ {...rest}
116
+ >
109
117
  {local.children}
110
118
  </DialogContent>
111
119
  }
@@ -16,8 +16,9 @@ import { IconPicker, type IconPickerProps } from "./icon-picker.js";
16
16
  import { ImagePicker } from "./image-picker.js";
17
17
  import { Input } from "./input.js";
18
18
  import { createListReorder } from "./list-reorder.js";
19
- import { useMediaStore } from "./media-store.js";
19
+ import { type ImagePreset, imagePreset, useMediaStore } from "./media-store.js";
20
20
  import { NumberField } from "./number-field.js";
21
+ import { OptionCard, OptionCardGroup } from "./option-card.js";
21
22
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
22
23
  import { Switch } from "./switch.js";
23
24
  import { ToggleGroup, ToggleGroupItem } from "./toggle-group.js";
@@ -33,8 +34,12 @@ export interface ExtendedJSONSchema extends JSONSchema7 {
33
34
  deviceClass?: string;
34
35
  /** formType "variants": the property that selects the active branch. */
35
36
  discriminator?: string;
36
- /** formType "variants": kind → display name for the discriminator Select. */
37
+ /** Enum value → display name (field.choice, field.choices, the variants selector). */
37
38
  labels?: Record<string, string>;
39
+ /** field.choice: enum value → icon name; set, the choice renders as icon cards. */
40
+ icons?: Record<string, string>;
41
+ /** formType "image-picker": built-in pictures offered beside the uploads. */
42
+ presets?: Record<string, ImagePreset>;
38
43
  /** formType "list": add-button caption. */
39
44
  addLabel?: string;
40
45
  /** formType "list": item field whose value captions the collapsed row. */
@@ -372,6 +377,7 @@ function FieldControl(props: FieldProps) {
372
377
  <Match when={kind() === "image"}>
373
378
  <ImagePicker
374
379
  id={props.id}
380
+ presets={props.prop.presets}
375
381
  value={String(current() ?? "")}
376
382
  onChange={(val) => props.onChange(val)}
377
383
  />
@@ -383,6 +389,22 @@ function FieldControl(props: FieldProps) {
383
389
  onChange={(val) => props.onChange(val)}
384
390
  />
385
391
  </Match>
392
+ <Match when={kind() === "enum" && props.prop.icons}>
393
+ {(icons) => (
394
+ <OptionCardGroup
395
+ aria-labelledby={props.labelledBy}
396
+ value={String(current() ?? "")}
397
+ onChange={(val) => props.onChange(val)}
398
+ class="grid grid-cols-[repeat(auto-fill,minmax(9rem,1fr))]"
399
+ >
400
+ <For each={(props.prop.enum ?? []).map(String)}>
401
+ {(value) => (
402
+ <OptionCard value={value} title={enumLabel(value)} icon={icons()[value]} />
403
+ )}
404
+ </For>
405
+ </OptionCardGroup>
406
+ )}
407
+ </Match>
386
408
  <Match when={kind() === "enum"}>
387
409
  <Select
388
410
  value={String(current() ?? "")}
@@ -479,10 +501,14 @@ function ListControl(props: FieldProps) {
479
501
 
480
502
  const thumbUrl = (item: unknown) => {
481
503
  const key = imageKey();
482
- const store = mediaStore;
483
- if (key === undefined || !store) return undefined;
504
+ if (key === undefined) return undefined;
484
505
  const id = recordOf(item)[key];
485
506
  if (typeof id !== "string" || id === "") return undefined;
507
+ const preset = imagePreset(id);
508
+ if (preset !== undefined)
509
+ return propertiesOf(itemSchema()).find(([k]) => k === key)?.[1].presets?.[preset]?.thumb;
510
+ const store = mediaStore;
511
+ if (!store) return undefined;
486
512
  // A 32px row chip: the thumb variant, never the original.
487
513
  return store.url(id, "thumb");
488
514
  };
@@ -73,7 +73,9 @@ export function SectionCard(props: SectionCardProps) {
73
73
  data-slot="section-card-header"
74
74
  class={cn("flex items-center gap-2 sm:gap-3", props.headerClass)}
75
75
  >
76
- <Show when={props.icon}>{(icon) => <SectionIcon icon={icon()} />}</Show>
76
+ <Show when={props.icon}>
77
+ {(icon) => <SectionIcon icon={icon()} tone="var(--primary)" />}
78
+ </Show>
77
79
  <div data-slot="section-card-headings" class="flex min-w-0 flex-1 flex-col gap-0.5">
78
80
  <div data-slot="section-card-headline" class="flex min-w-0 items-center gap-2 sm:gap-3">
79
81
  <Show when={props.title}>
@@ -323,7 +325,7 @@ export function SectionGroup(props: {
323
325
  class="mb-2 flex flex-wrap items-center justify-between gap-2"
324
326
  >
325
327
  <div data-slot="section-group-heading" class="flex min-w-0 items-center gap-2">
326
- <SectionIcon icon={props.icon} size="sm" />
328
+ <SectionIcon icon={props.icon} size="sm" tone="var(--primary)" />
327
329
  <SectionHeading>{props.label}</SectionHeading>
328
330
  <Show when={props.count}>
329
331
  <CountPill>{props.count}</CountPill>
@@ -45,10 +45,12 @@ interface SlidingIndicatorProps extends ComponentProps<"div"> {
45
45
  indicatorTone?: string;
46
46
  /** Selector for the measurable items. Default: direct children (minus the indicator). */
47
47
  itemSelector?: string;
48
+ /** Items wrap onto rows: the indicator follows the active item's row as well as its place in it. */
49
+ wrapped?: boolean;
48
50
  children: JSX.Element;
49
51
  }
50
52
 
51
- type Pos = { offset: number; size: number; cross: number };
53
+ type Pos = { offset: number; size: number; cross: number; crossOffset: number };
52
54
 
53
55
  // One duration for both the slide (transform transition) and the scale dip, so
54
56
  // they always overlap exactly. Shorter = snappier.
@@ -73,6 +75,7 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
73
75
  "indicatorClass",
74
76
  "indicatorTone",
75
77
  "itemSelector",
78
+ "wrapped",
76
79
  "class",
77
80
  "children",
78
81
  "ref",
@@ -145,12 +148,8 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
145
148
  setPos(null);
146
149
  return;
147
150
  }
148
- // Not laid out yet: a hidden/collapsing popover, a display:none tab panel, a
149
- // portal measured before Kobalte positions it, or a dialog still running its
150
- // open transform. Measuring then would fling the indicator to a bogus offset
151
- // (a stray tinted blob a screenshot catches mid-open) or scale it by the
152
- // ancestor's in-flight transform, so hide until there is real geometry.
153
- // Rects, not clientWidth: a transformed ancestor leaves layout size intact.
151
+ // Not laid out yet: a hidden/collapsing popover, a display:none tab panel, or
152
+ // a portal measured before Kobalte positions it. Hide until real geometry.
154
153
  const er = el.getBoundingClientRect();
155
154
  const cr = containerRef.getBoundingClientRect();
156
155
  if (er.width === 0 || er.height === 0 || cr.width === 0 || cr.height === 0) {
@@ -166,18 +165,26 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
166
165
  // border so it aligns to the padding box (where the absolute indicator anchors).
167
166
  // A row arriving through gh-stagger is still translated: bounding rects
168
167
  // include that travel, its resting place does not.
168
+ // An ancestor mid-zoom (a dialog opening) scales every rect and ends without
169
+ // a resize, so rects convert back to layout pixels by the container's ratio.
170
+ const sx = containerRef.offsetWidth > 0 ? cr.width / containerRef.offsetWidth : 1;
171
+ const sy = containerRef.offsetHeight > 0 ? cr.height / containerRef.offsetHeight : 1;
169
172
  const [tx, ty] = readTranslate(el);
170
173
  setPos(
171
174
  horizontal()
172
175
  ? {
173
- offset: er.left - tx - cr.left - containerRef.clientLeft + containerRef.scrollLeft,
174
- size: er.width,
175
- cross: er.height,
176
+ offset:
177
+ (er.left - cr.left) / sx - tx - containerRef.clientLeft + containerRef.scrollLeft,
178
+ size: er.width / sx,
179
+ cross: er.height / sy,
180
+ crossOffset:
181
+ (er.top - cr.top) / sy - ty - containerRef.clientTop + containerRef.scrollTop,
176
182
  }
177
183
  : {
178
- offset: er.top - ty - cr.top - containerRef.clientTop + containerRef.scrollTop,
179
- size: er.height,
180
- cross: er.width,
184
+ offset: (er.top - cr.top) / sy - ty - containerRef.clientTop + containerRef.scrollTop,
185
+ size: er.height / sy,
186
+ cross: er.width / sx,
187
+ crossOffset: 0,
181
188
  },
182
189
  );
183
190
  };
@@ -274,16 +281,26 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
274
281
  aria-hidden="true"
275
282
  class={cn(
276
283
  "pointer-events-none absolute -z-10",
277
- horizontal() ? "inset-y-0 left-0" : "inset-x-0 top-0",
284
+ local.wrapped
285
+ ? "top-0 left-0"
286
+ : horizontal()
287
+ ? "inset-y-0 left-0"
288
+ : "inset-x-0 top-0",
278
289
  "glass glass-tint",
279
290
  local.indicatorClass ?? "rounded-lg",
280
291
  )}
281
292
  style={{
282
293
  transition: `transform ${SLIDE_MS}ms ease-in-out, width ${SLIDE_MS}ms ease-in-out, height ${SLIDE_MS}ms ease-in-out`,
283
294
  "--glass-tone": local.indicatorTone ?? "var(--primary)",
284
- ...(horizontal()
285
- ? { transform: `translateX(${p().offset}px)`, width: `${p().size}px` }
286
- : { transform: `translateY(${p().offset}px)`, height: `${p().size}px` }),
295
+ ...(local.wrapped && horizontal()
296
+ ? {
297
+ transform: `translate(${p().offset}px, ${p().crossOffset}px)`,
298
+ width: `${p().size}px`,
299
+ height: `${p().cross}px`,
300
+ }
301
+ : horizontal()
302
+ ? { transform: `translateX(${p().offset}px)`, width: `${p().size}px` }
303
+ : { transform: `translateY(${p().offset}px)`, height: `${p().size}px` }),
287
304
  }}
288
305
  />
289
306
  )}