@glasshome/ui 1.37.2 → 1.38.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/ui",
3
- "version": "1.37.2",
3
+ "version": "1.38.0",
4
4
  "description": "SolidJS component library for GlassHome, built on Kobalte",
5
5
  "keywords": [
6
6
  "components",
@@ -140,5 +140,8 @@
140
140
  },
141
141
  "engines": {
142
142
  "node": ">=20"
143
+ },
144
+ "patchedDependencies": {
145
+ "@kobalte/core@0.13.13": "patches/@kobalte%2Fcore@0.13.13.patch"
143
146
  }
144
147
  }
@@ -0,0 +1,5 @@
1
+ export const busyProps = {
2
+ "aria-busy": true,
3
+ "aria-disabled": true,
4
+ onClick: (event: MouseEvent) => event.preventDefault(),
5
+ } as const;
@@ -17,7 +17,7 @@ export const buttonVariants = cva({
17
17
  // structural-ok: the [&_svg]: utilities stay in Tailwind's utility layer so a
18
18
  // caller's own [&_svg]:size-* override can still win; unlayered real CSS in
19
19
  // globals.css would beat every consumer utility regardless of specificity.
20
- base: "transition-glass focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-lg text-sm font-medium whitespace-nowrap outline-none focus-visible:ring-[3px] active:scale-[0.97] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
20
+ base: "transition-glass focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-lg text-sm font-medium whitespace-nowrap outline-none focus-visible:ring-[3px] active:scale-[0.97] disabled:pointer-events-none disabled:opacity-50 aria-busy:cursor-progress aria-busy:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
21
21
  variants: {
22
22
  variant: {
23
23
  default: `glass glass-tint ${CONTROL_GLASS} dark:text-primary-foreground dark:color-calc:[color:oklch(from_var(--glass-tone)_calc((0.74_-_l)*100)_0_0)] dark:color-calc:[--glass-tone:oklch(from_var(--material-accent)_calc(l_+_clamp(0,(l_-_0.74)*10,0.1))_c_h)] [--glass-text:0%] [--glass-tone:var(--material-accent)] [--glass-wash:55%] hover:[--glass-edge:color-mix(in_srgb,var(--material-accent)_60%,transparent)] hover:[--glass-wash:65%] dark:[--glass-wash:62%] dark:hover:[--glass-wash:70%]`,
package/src/lib/layers.ts CHANGED
@@ -10,3 +10,8 @@ export const Z_CLASS = {
10
10
  sheet: "z-40",
11
11
  overlay: "z-50",
12
12
  } as const satisfies Record<keyof typeof Z, string>;
13
+
14
+ /** Kobalte's hide-outside of a modal below walks every portal that mounts later and hides it, a focused list included, unless the content carries its top-layer marker. */
15
+ export const nestedLayerAttrs = (modal: boolean) => ({
16
+ "data-kb-top-layer": modal ? undefined : "",
17
+ });
@@ -1,19 +1,25 @@
1
1
  import { Button as KobalteButton } from "@kobalte/core/button";
2
2
  import type { VariantProps } from "cva";
3
3
  import { type ComponentProps, type JSX, splitProps } from "solid-js";
4
+ import { busyProps } from "../lib/busy.js";
4
5
  import { buttonVariants } from "../lib/button-variants.js";
5
6
  import { cn } from "../lib/utils.js";
6
7
  import { Icon } from "./icon.js";
7
8
 
8
- type ButtonProps = ComponentProps<typeof KobalteButton> & VariantProps<typeof buttonVariants>;
9
+ type ButtonProps = ComponentProps<typeof KobalteButton> &
10
+ VariantProps<typeof buttonVariants> & {
11
+ /** Presses do nothing; unlike `disabled` it keeps focus, so the popover or dialog around it stays. */
12
+ busy?: boolean;
13
+ };
9
14
 
10
15
  function Button(props: ButtonProps) {
11
- const [local, others] = splitProps(props, ["class", "variant", "size"] as const);
16
+ const [local, others] = splitProps(props, ["class", "variant", "size", "busy"] as const);
12
17
  return (
13
18
  <KobalteButton
14
19
  data-slot="button"
15
- class={cn(buttonVariants({ variant: local.variant, size: local.size }), local.class)}
16
20
  {...others}
21
+ class={cn(buttonVariants({ variant: local.variant, size: local.size }), local.class)}
22
+ {...(local.busy ? busyProps : undefined)}
17
23
  />
18
24
  );
19
25
  }
@@ -328,12 +328,7 @@ export function TableLoadMore(props: {
328
328
  class={cn("flex justify-center py-3", props.class)}
329
329
  >
330
330
  <Show when={props.hasMore}>
331
- <Button
332
- variant="ghost"
333
- size="sm"
334
- disabled={props.loading}
335
- onClick={() => props.onLoadMore()}
336
- >
331
+ <Button variant="ghost" size="sm" busy={props.loading} onClick={() => props.onLoadMore()}>
337
332
  {props.loading ? "Loading…" : (props.label ?? "Show more")}
338
333
  </Button>
339
334
  </Show>
@@ -18,6 +18,7 @@ import {
18
18
  type ValidComponent,
19
19
  } from "solid-js";
20
20
  import { Dynamic } from "solid-js/web";
21
+ import { busyProps } from "../lib/busy.js";
21
22
  import { Z_CLASS } from "../lib/layers.js";
22
23
  import { ANCHORED_MOTION, MODAL_MOTION, SCRIM_MOTION } from "../lib/motion-classes.js";
23
24
  import { OVERLAY_SURFACE, SCRIM_CLASS } from "../lib/overlay-classes.js";
@@ -187,7 +188,10 @@ export function callEventHandler<T, E extends Event>(
187
188
  else handler[0](handler[1], event);
188
189
  }
189
190
 
190
- export type ModalDismissProps = ComponentProps<typeof KobalteButton>;
191
+ export type ModalDismissProps = ComponentProps<typeof KobalteButton> & {
192
+ /** Presses do nothing, the dialog stays open and focus stays put; see Button. */
193
+ busy?: boolean;
194
+ };
191
195
 
192
196
  /* Not kobalte's own CloseButton: that one hard-defaults aria-label to its
193
197
  * "Dismiss" translation, and an aria-label outranks the visible text, so every
@@ -196,7 +200,7 @@ export type ModalDismissProps = ComponentProps<typeof KobalteButton>;
196
200
  * one factory serves both families. */
197
201
  export function createModalDismiss(slot: string): ParentComponent<ModalDismissProps> {
198
202
  return (props) => {
199
- const [local, rest] = splitProps(props, ["onClick"]);
203
+ const [local, rest] = splitProps(props, ["onClick", "busy"]);
200
204
  const context = useDialogContext();
201
205
  return (
202
206
  <KobalteButton
@@ -206,6 +210,7 @@ export function createModalDismiss(slot: string): ParentComponent<ModalDismissPr
206
210
  context.close();
207
211
  }}
208
212
  {...rest}
213
+ {...(local.busy ? busyProps : undefined)}
209
214
  />
210
215
  );
211
216
  };
@@ -236,7 +236,6 @@ function ImageGallery(
236
236
 
237
237
  const handleUpload = async (file: File) => {
238
238
  setError(undefined);
239
- holdFocus();
240
239
  setUploading(true);
241
240
  try {
242
241
  if (!store) return;
@@ -247,7 +246,6 @@ function ImageGallery(
247
246
  fail(cause);
248
247
  } finally {
249
248
  setUploading(false);
250
- if (focused() === panel) uploadButton?.focus({ preventScroll: true });
251
249
  }
252
250
  };
253
251
 
@@ -492,7 +490,7 @@ function ImageGallery(
492
490
  size="sm"
493
491
  ref={uploadButton}
494
492
  data-slot="image-picker-upload"
495
- disabled={uploading()}
493
+ busy={uploading()}
496
494
  onClick={() => fileInput?.click()}
497
495
  >
498
496
  <Icon icon="lucide:upload" width={14} height={14} />
@@ -110,6 +110,8 @@ export function OptionCard(props: {
110
110
  * which the group's `onChange` alone never reports. */
111
111
  onPick?: () => void;
112
112
  disabled?: boolean;
113
+ /** Picks do nothing while the pick's work runs; unlike `disabled` it keeps focus. */
114
+ busy?: boolean;
113
115
  class?: string;
114
116
  /** The current sub-option (an OptionChoice value). */
115
117
  subValue?: string;
@@ -145,9 +147,10 @@ export function OptionCard(props: {
145
147
  <RadioGroupItem
146
148
  value={props.value}
147
149
  disabled={props.disabled}
150
+ busy={props.busy}
148
151
  showControl={false}
149
152
  onClick={(event: MouseEvent) =>
150
- !props.disabled && isItemActivation(event) && props.onPick?.()
153
+ !props.disabled && !props.busy && isItemActivation(event) && props.onPick?.()
151
154
  }
152
155
  class="relative w-full cursor-pointer overflow-hidden rounded-[inherit] text-left"
153
156
  >
@@ -10,7 +10,7 @@ import {
10
10
  } from "solid-js";
11
11
  import { INPUT_SURFACE } from "../lib/input-classes.js";
12
12
  import { inShadowRoot, shadowLayer } from "../lib/shadow-layer.js";
13
- import { Z_CLASS } from "../lib/layers.js";
13
+ import { nestedLayerAttrs, Z_CLASS } from "../lib/layers.js";
14
14
  import { FIELD_MOTION, MORPH_MOTION, STAGGER } from "../lib/motion-classes.js";
15
15
  import { anchorToTriggerTop, FLOATING_PANEL } from "../lib/overlay-classes.js";
16
16
  import { cn } from "../lib/utils.js";
@@ -115,6 +115,7 @@ const PopoverContent: Component<PopoverContentProps> = (props) => {
115
115
  onCloseAutoFocus={layer.onCloseAutoFocus}
116
116
  data-slot="popover-content"
117
117
  data-surface={surface()}
118
+ {...nestedLayerAttrs(popover.isModal())}
118
119
  class={cn(surface() === "field" ? FIELD_PANEL : OVERLAY_PANEL, local.class)}
119
120
  {...rest}
120
121
  />
@@ -7,6 +7,7 @@ import {
7
7
  Show,
8
8
  splitProps,
9
9
  } from "solid-js";
10
+ import { busyProps } from "../lib/busy.js";
10
11
  import { FIELD_CHROME } from "../lib/input-classes.js";
11
12
  import { cn } from "../lib/utils.js";
12
13
 
@@ -34,16 +35,16 @@ const RadioGroupItemContent: ParentComponent = (props) => {
34
35
  };
35
36
 
36
37
  const RadioGroupItem: Component<
37
- ComponentProps<typeof RadioGroupPrimitive.Item> & { showControl?: boolean }
38
+ ComponentProps<typeof RadioGroupPrimitive.Item> & { showControl?: boolean; busy?: boolean }
38
39
  > = (props) => {
39
- const [local, rest] = splitProps(props, ["class", "children", "showControl"]);
40
+ const [local, rest] = splitProps(props, ["class", "children", "showControl", "busy"]);
40
41
  return (
41
42
  <RadioGroupPrimitive.Item
42
43
  data-slot="radio-group-item"
43
44
  class={cn("flex", local.class)}
44
45
  {...rest}
45
46
  >
46
- <RadioGroupPrimitive.ItemInput class="peer" />
47
+ <RadioGroupPrimitive.ItemInput class="peer" {...(local.busy ? busyProps : undefined)} />
47
48
  <RadioGroupPrimitive.ItemLabel
48
49
  data-slot="radio-group-item-label"
49
50
  class="flex flex-1 cursor-pointer items-center gap-2.5 select-none data-[disabled]:cursor-not-allowed"
@@ -9,7 +9,7 @@ import {
9
9
  } from "solid-js";
10
10
  import { shadowLayer } from "../lib/shadow-layer.js";
11
11
  import { CONTROL_H, INPUT_SURFACE } from "../lib/input-classes.js";
12
- import { Z_CLASS } from "../lib/layers.js";
12
+ import { nestedLayerAttrs, Z_CLASS } from "../lib/layers.js";
13
13
  import { MENU_ITEM, MENU_LABEL, MENU_SEPARATOR } from "../lib/menu-classes.js";
14
14
  import { FIELD_MOTION, STAGGER } from "../lib/motion-classes.js";
15
15
  import { ignoreOpeningRelease } from "../lib/opening-release.js";
@@ -86,6 +86,7 @@ const SelectContent: ParentComponent<
86
86
  onInteractOutside={layer.onInteractOutside}
87
87
  onCloseAutoFocus={layer.onCloseAutoFocus}
88
88
  data-slot="select-content"
89
+ {...nestedLayerAttrs(select.isModal())}
89
90
  class={cn(
90
91
  // Same concave surface as the trigger: opening reads as the input
91
92
  // expanding, not a separate floating panel.