@glasshome/ui 1.10.0 → 1.11.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 (113) hide show
  1. package/SPEC.md +7 -0
  2. package/dist/index.js +1 -1
  3. package/dist/lib/menu-classes.d.ts +2 -2
  4. package/dist/solid/icon.d.ts +18 -12
  5. package/dist/solid/index.d.ts +1 -0
  6. package/dist/solid/index.js +3692 -3490
  7. package/dist/{utils-CIwpbaOd.js → utils-CdUh67Y9.js} +1 -1
  8. package/package.json +7 -3
  9. package/scripts/check-pack.ts +32 -0
  10. package/src/index.ts +111 -0
  11. package/src/lib/menu-classes.ts +1 -1
  12. package/src/solid/accordion.tsx +60 -0
  13. package/src/solid/alert-dialog.tsx +148 -0
  14. package/src/solid/alert.tsx +118 -0
  15. package/src/solid/area-picker.tsx +225 -0
  16. package/src/solid/aspect-ratio.tsx +21 -0
  17. package/src/solid/avatar.tsx +41 -0
  18. package/src/solid/badge.tsx +74 -0
  19. package/src/solid/bottom-sheet/arbitration.ts +40 -0
  20. package/src/solid/bottom-sheet/bottom-sheet.tsx +457 -0
  21. package/src/solid/bottom-sheet/constants.ts +8 -0
  22. package/src/solid/bottom-sheet/drag-controller.ts +221 -0
  23. package/src/solid/bottom-sheet/focus-trap.ts +56 -0
  24. package/src/solid/bottom-sheet/index.ts +14 -0
  25. package/src/solid/bottom-sheet/keyboard.ts +35 -0
  26. package/src/solid/bottom-sheet/scroll-lock.ts +64 -0
  27. package/src/solid/bottom-sheet/state-machine.ts +40 -0
  28. package/src/solid/bottom-sheet/velocity.ts +42 -0
  29. package/src/solid/breadcrumb.tsx +105 -0
  30. package/src/solid/button-group.tsx +66 -0
  31. package/src/solid/button.tsx +20 -0
  32. package/src/solid/card.tsx +101 -0
  33. package/src/solid/carousel.tsx +302 -0
  34. package/src/solid/charts.tsx +338 -0
  35. package/src/solid/checkbox.tsx +70 -0
  36. package/src/solid/collapsible.tsx +38 -0
  37. package/src/solid/color-slider.tsx +98 -0
  38. package/src/solid/color-wheel.tsx +77 -0
  39. package/src/solid/context-menu.tsx +109 -0
  40. package/src/solid/copy-button.tsx +46 -0
  41. package/src/solid/count-pill.tsx +24 -0
  42. package/src/solid/data-table.tsx +248 -0
  43. package/src/solid/dialog-parts.tsx +242 -0
  44. package/src/solid/dialog.tsx +121 -0
  45. package/src/solid/dock.tsx +186 -0
  46. package/src/solid/dropdown-menu.tsx +130 -0
  47. package/src/solid/empty.tsx +99 -0
  48. package/src/solid/entity-data.ts +78 -0
  49. package/src/solid/entity-selector.tsx +697 -0
  50. package/src/solid/field.tsx +253 -0
  51. package/src/solid/form.tsx +231 -0
  52. package/src/solid/hero-action.tsx +117 -0
  53. package/src/solid/hover-card.tsx +26 -0
  54. package/src/solid/icon-picker.tsx +432 -0
  55. package/src/solid/icon.tsx +126 -0
  56. package/src/solid/image-picker.tsx +380 -0
  57. package/src/solid/index.ts +413 -0
  58. package/src/solid/input-group.tsx +170 -0
  59. package/src/solid/input-otp.tsx +175 -0
  60. package/src/solid/input.tsx +12 -0
  61. package/src/solid/item.tsx +179 -0
  62. package/src/solid/kbd.tsx +30 -0
  63. package/src/solid/label.tsx +19 -0
  64. package/src/solid/list-reorder.ts +148 -0
  65. package/src/solid/logo.tsx +79 -0
  66. package/src/solid/media-copy.ts +37 -0
  67. package/src/solid/media-store.ts +110 -0
  68. package/src/solid/media-tile.tsx +100 -0
  69. package/src/solid/menu-parts.tsx +248 -0
  70. package/src/solid/number-field.tsx +72 -0
  71. package/src/solid/option-card.tsx +218 -0
  72. package/src/solid/ornament.tsx +53 -0
  73. package/src/solid/overlay.tsx +16 -0
  74. package/src/solid/page-header.tsx +102 -0
  75. package/src/solid/pagination.tsx +111 -0
  76. package/src/solid/password-input.tsx +69 -0
  77. package/src/solid/picker-row.tsx +102 -0
  78. package/src/solid/picker-search.tsx +78 -0
  79. package/src/solid/popover.tsx +103 -0
  80. package/src/solid/progress.tsx +31 -0
  81. package/src/solid/radio-group.tsx +60 -0
  82. package/src/solid/resizable.tsx +149 -0
  83. package/src/solid/responsive-dialog.tsx +180 -0
  84. package/src/solid/schema-form.tsx +830 -0
  85. package/src/solid/scope-indicator.tsx +13 -0
  86. package/src/solid/scroll-area.tsx +27 -0
  87. package/src/solid/section-card.tsx +358 -0
  88. package/src/solid/select.tsx +139 -0
  89. package/src/solid/separator.tsx +35 -0
  90. package/src/solid/settings-row.tsx +159 -0
  91. package/src/solid/sheet.tsx +157 -0
  92. package/src/solid/skeleton.tsx +15 -0
  93. package/src/solid/slider.tsx +148 -0
  94. package/src/solid/sliding-indicator.tsx +294 -0
  95. package/src/solid/sonner.tsx +217 -0
  96. package/src/solid/spinner.tsx +20 -0
  97. package/src/solid/step-indicator.tsx +30 -0
  98. package/src/solid/switch.tsx +62 -0
  99. package/src/solid/table.tsx +98 -0
  100. package/src/solid/tabs.tsx +86 -0
  101. package/src/solid/textarea.tsx +16 -0
  102. package/src/solid/toggle-group.tsx +102 -0
  103. package/src/solid/toggle.tsx +57 -0
  104. package/src/solid/tooltip.tsx +38 -0
  105. package/src/solid/widget-card.tsx +117 -0
  106. package/src/solid/widget-identity.tsx +135 -0
  107. package/src/solid/widget-trust-badge.tsx +37 -0
  108. package/src/styles/globals.css +7 -0
  109. package/src/styles/theme.css +8 -0
  110. package/src/tokens/hex.ts +50 -0
  111. package/src/tokens/index.ts +8 -0
  112. package/src/tokens/presets.ts +192 -0
  113. package/src/tokens/theme-colors.ts +147 -0
@@ -221,7 +221,7 @@ var Ae = "var(--muted-foreground)", je = "[--glass-wash:12%]", Me = (e) => e ===
221
221
  sub: "text-3xl",
222
222
  gap: "gap-2"
223
223
  }
224
- }, Be = "inline-flex items-end", Ve = "flex flex-col gap-0.5", He = "shrink-0", Ue = "whitespace-nowrap font-bold leading-none tracking-tight", We = "font-bold text-primary uppercase leading-none tracking-[0.18em]", Ge = "relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 text-sm outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&:not([data-tone])_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&>iconify-icon]:shrink-0 [&>iconify-icon]:text-[16px]", Ke = "px-2", qe = `${Ge} ${Ke}`, Je = "px-2 py-1.5 font-medium text-muted-foreground text-xs", Ye = "-mx-1 my-1 h-px bg-border", Xe = "glass glass-frost [--glass-rim:0.5] [--glass-lift:0.6] [--glass-light:0] [--glass-edge:color-mix(in_srgb,var(--border)_90%,transparent)]", Ze = "backdrop-blur-[var(--glass-blur,24px)] backdrop-saturate-[1.2]", Qe = `${Xe} [--glass-base:color-mix(in_srgb,var(--popover)_92%,transparent)]`, $e = `${Qe} ${Ze}`, et = `${Xe} [--glass-base:var(--popover)]`, tt = "bg-scrim backdrop-blur-md", nt = `${$e} relative ${Pe.overlay} rounded-md text-popover-foreground outline-hidden`, rt = (e) => {
224
+ }, Be = "inline-flex items-end", Ve = "flex flex-col gap-0.5", He = "shrink-0", Ue = "whitespace-nowrap font-bold leading-none tracking-tight", We = "font-bold text-primary uppercase leading-none tracking-[0.18em]", Ge = "relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 text-sm outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&:not([data-tone])_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:text-[16px]", Ke = "px-2", qe = `${Ge} ${Ke}`, Je = "px-2 py-1.5 font-medium text-muted-foreground text-xs", Ye = "-mx-1 my-1 h-px bg-border", Xe = "glass glass-frost [--glass-rim:0.5] [--glass-lift:0.6] [--glass-light:0] [--glass-edge:color-mix(in_srgb,var(--border)_90%,transparent)]", Ze = "backdrop-blur-[var(--glass-blur,24px)] backdrop-saturate-[1.2]", Qe = `${Xe} [--glass-base:color-mix(in_srgb,var(--popover)_92%,transparent)]`, $e = `${Qe} ${Ze}`, et = `${Xe} [--glass-base:var(--popover)]`, tt = "bg-scrim backdrop-blur-md", nt = `${$e} relative ${Pe.overlay} rounded-md text-popover-foreground outline-hidden`, rt = (e) => {
225
225
  let t = e?.getBoundingClientRect();
226
226
  return t ? {
227
227
  x: t.left,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/ui",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "SolidJS component library for GlassHome, built on Kobalte",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/glasshome/ui#readme",
@@ -51,8 +51,11 @@
51
51
  },
52
52
  "files": [
53
53
  "dist",
54
+ "src/index.ts",
54
55
  "src/lib",
56
+ "src/solid",
55
57
  "src/styles",
58
+ "src/tokens",
56
59
  "scripts",
57
60
  "SPEC.md"
58
61
  ],
@@ -63,7 +66,7 @@
63
66
  "check:styling": "fallow health --css",
64
67
  "check:tokens": "bun scripts/check-tokens.ts",
65
68
  "check:types": "tsc --noEmit -p tsconfig.test.json",
66
- "check:publish": "publint && attw --pack . --profile esm-only --exclude-entrypoints ./styles ./styles/theme",
69
+ "check:publish": "publint && attw --pack . --profile esm-only --exclude-entrypoints ./styles ./styles/theme && bun scripts/check-pack.ts",
67
70
  "dev": "tsc -b --force && vite build --watch",
68
71
  "lint": "biome check .",
69
72
  "test": "vitest run",
@@ -77,13 +80,14 @@
77
80
  "tw-animate-css": "^1.4.0"
78
81
  },
79
82
  "dependencies": {
83
+ "@iconify/types": "^2.0.0",
84
+ "@iconify/utils": "^3.1.4",
80
85
  "@kobalte/core": "^0.13.13",
81
86
  "clsx": "^2.1.1",
82
87
  "cva": "^1.0.0-beta.4",
83
88
  "embla-carousel": "^8.5.1",
84
89
  "embla-carousel-autoplay": "^8.5.1",
85
90
  "embla-carousel-fade": "^8.5.1",
86
- "iconify-icon": "^3.0.2",
87
91
  "solid-sonner": "^0.3.1",
88
92
  "tailwind-merge": "^3.4.0"
89
93
  },
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env bun
2
+ // publint and attw ignore custom conditions, so a `solid` target can point outside the tarball.
3
+ import pkg from "../package.json" with { type: "json" };
4
+
5
+ const root = new URL("..", import.meta.url).pathname;
6
+ const pack = Bun.spawnSync(["npm", "pack", "--dry-run", "--json", "--ignore-scripts"], {
7
+ cwd: root,
8
+ });
9
+ if (pack.exitCode !== 0) {
10
+ console.error(pack.stderr.toString());
11
+ process.exit(pack.exitCode ?? 1);
12
+ }
13
+ const files = new Set<string>(
14
+ (JSON.parse(pack.stdout.toString())[0].files as { path: string }[]).map((f) => f.path),
15
+ );
16
+
17
+ function targets(value: unknown): string[] {
18
+ if (typeof value === "string") return [value];
19
+ if (value && typeof value === "object") return Object.values(value).flatMap(targets);
20
+ return [];
21
+ }
22
+
23
+ const missing = [...new Set(targets(pkg.exports))]
24
+ .map((t) => t.replace(/^\.\//, ""))
25
+ .filter((t) =>
26
+ t.endsWith("/*") ? ![...files].some((f) => f.startsWith(t.slice(0, -1))) : !files.has(t),
27
+ );
28
+ if (missing.length > 0) {
29
+ console.error(`check-pack: exports point outside the tarball:\n ${missing.join("\n ")}`);
30
+ process.exit(1);
31
+ }
32
+ console.log(`check-pack: ${files.size} files, every export target present`);
package/src/index.ts ADDED
@@ -0,0 +1,111 @@
1
+ /* Framework-agnostic root. Components are the primary doors; surface recipes
2
+ * are exported here only for consumers that cannot run Solid (server .astro
3
+ * frontmatter) or that gate the blur themselves (performant-blur wrappers). */
4
+ export {
5
+ ALERT_CLASS,
6
+ ALERT_CONTENT_CLASS,
7
+ ALERT_DESCRIPTION_CLASS,
8
+ ALERT_ICON_BG_CLASS,
9
+ ALERT_ICON_CLASS,
10
+ ALERT_ICON_PATHS,
11
+ ALERT_TITLE_CLASS,
12
+ ALERT_TONES,
13
+ type AlertTone,
14
+ type AlertToneStyle,
15
+ alertBorder,
16
+ alertFill,
17
+ alertIconBgStyle,
18
+ alertIconFill,
19
+ } from "./lib/alert-tones.js";
20
+ export {
21
+ BUTTON_DEFAULT_CLASS,
22
+ BUTTON_OUTLINE_CLASS,
23
+ buttonVariants,
24
+ ICON_BUTTON_CLASS,
25
+ OUTLINE_SURFACE,
26
+ } from "./lib/button-variants.js";
27
+ export {
28
+ CARD_BLUR,
29
+ CARD_SURFACE,
30
+ CARD_SURFACE_BASE,
31
+ CARD_SURFACE_OPAQUE,
32
+ SECTION_ROW_SURFACE,
33
+ TRACK_SURFACE,
34
+ } from "./lib/card-classes.js";
35
+ export {
36
+ CAROUSEL_DOTS,
37
+ CAROUSEL_VIEWPORT,
38
+ type CarouselTransition,
39
+ carouselDot,
40
+ carouselItem,
41
+ carouselTrack,
42
+ } from "./lib/carousel-classes.js";
43
+ export { glassToneText, toneTextMix } from "./lib/glass-tone.js";
44
+ export {
45
+ CONTROL_H,
46
+ FIELD_CHROME,
47
+ FIELD_CONTROL,
48
+ FIELD_TEXT,
49
+ FOCUS_RING,
50
+ INPUT_CLASS,
51
+ INPUT_SURFACE,
52
+ INVALID_RING,
53
+ } from "./lib/input-classes.js";
54
+ export { Z, Z_CLASS } from "./lib/layers.js";
55
+ export {
56
+ LOGO_DEFAULT_SIZE,
57
+ LOGO_DEFAULT_SRC,
58
+ LOGO_DEFAULT_SUB,
59
+ LOGO_MARK_CLASS,
60
+ LOGO_MARK_PX,
61
+ LOGO_NAME_CLASS,
62
+ LOGO_ROOT_CLASS,
63
+ LOGO_SIZES,
64
+ LOGO_STACK_CLASS,
65
+ LOGO_SUB_CLASS,
66
+ type LogoSize,
67
+ } from "./lib/logo-lockup.js";
68
+ export {
69
+ MENU_ITEM,
70
+ MENU_ITEM_BASE,
71
+ MENU_ITEM_X,
72
+ MENU_LABEL,
73
+ MENU_SEPARATOR,
74
+ } from "./lib/menu-classes.js";
75
+ export {
76
+ FIELD_MOTION,
77
+ MODAL_MOTION,
78
+ MORPH_MOTION,
79
+ OVERLAY_MOTION,
80
+ PRESS_DIP,
81
+ SCRIM_MOTION,
82
+ SETTLE_MOTION,
83
+ STAGGER,
84
+ } from "./lib/motion-classes.js";
85
+ export {
86
+ anchorToTriggerTop,
87
+ FLOATING_PANEL,
88
+ OVERLAY_BLUR,
89
+ OVERLAY_SURFACE,
90
+ OVERLAY_SURFACE_BASE,
91
+ OVERLAY_SURFACE_OPAQUE,
92
+ SCRIM_CLASS,
93
+ } from "./lib/overlay-classes.js";
94
+ export { CONTROL_H_TOUCH, PICKER_LIST, PICKER_TRIGGER } from "./lib/picker-classes.js";
95
+ export { CHIP, ICON_PILL, ICON_PILL_TINT } from "./lib/pill-classes.js";
96
+ export { POSITION_BAR, POSITION_BAR_LIT } from "./lib/position-bar-classes.js";
97
+ export {
98
+ SECTION_INNER_RADIUS,
99
+ SECTION_OUTER_RADIUS,
100
+ SECTION_PADDING,
101
+ SECTION_ROW_CLASS,
102
+ } from "./lib/section-tokens.js";
103
+ export { SEGMENT_ITEM } from "./lib/segment-classes.js";
104
+ export {
105
+ THUMB_CLASS,
106
+ THUMB_RAIL_BLEED,
107
+ THUMB_RAIL_PAD,
108
+ THUMB_SIZE,
109
+ } from "./lib/thumb-classes.js";
110
+ export { createIsMobile, MOBILE_BREAKPOINT } from "./lib/use-is-mobile.js";
111
+ export { cn } from "./lib/utils.js";
@@ -10,7 +10,7 @@
10
10
  * would come down to CSS emit order. Such a row composes MENU_ITEM_BASE. */
11
11
  export const MENU_ITEM_BASE =
12
12
  // structural-ok: guards an svg color rule on a sibling data attribute this package always renders, not a class the consumer must also scan
13
- "relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 text-sm outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&:not([data-tone])_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&>iconify-icon]:shrink-0 [&>iconify-icon]:text-[16px]";
13
+ "relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 text-sm outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&:not([data-tone])_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:text-[16px]";
14
14
 
15
15
  export const MENU_ITEM_X = "px-2";
16
16
 
@@ -0,0 +1,60 @@
1
+ import { Accordion as AccordionPrimitive } from "@kobalte/core/accordion";
2
+ import { type Component, type ComponentProps, type ParentComponent, splitProps } from "solid-js";
3
+ import { cn } from "../lib/utils.js";
4
+ import { Icon } from "./icon.js";
5
+
6
+ const Accordion = AccordionPrimitive;
7
+
8
+ const AccordionItem: Component<ComponentProps<typeof AccordionPrimitive.Item>> = (props) => {
9
+ const [local, rest] = splitProps(props, ["class"]);
10
+ return (
11
+ <AccordionPrimitive.Item
12
+ data-slot="accordion-item"
13
+ class={cn("border-b last:border-b-0", local.class)}
14
+ {...rest}
15
+ />
16
+ );
17
+ };
18
+
19
+ const AccordionTrigger: ParentComponent<ComponentProps<typeof AccordionPrimitive.Trigger>> = (
20
+ props,
21
+ ) => {
22
+ const [local, rest] = splitProps(props, ["class", "children"]);
23
+ return (
24
+ <AccordionPrimitive.Header class="flex">
25
+ <AccordionPrimitive.Trigger
26
+ data-slot="accordion-trigger"
27
+ class={cn(
28
+ "flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left font-medium text-sm outline-none transition-all hover:underline focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&[data-expanded]>[data-slot=icon]]:rotate-180",
29
+ local.class,
30
+ )}
31
+ {...rest}
32
+ >
33
+ {local.children}
34
+ <Icon
35
+ icon="lucide:chevron-down"
36
+ width={16}
37
+ height={16}
38
+ class="pointer-events-none size-4 shrink-0 translate-y-0.5 text-muted-foreground transition-transform duration-200"
39
+ />
40
+ </AccordionPrimitive.Trigger>
41
+ </AccordionPrimitive.Header>
42
+ );
43
+ };
44
+
45
+ const AccordionContent: ParentComponent<ComponentProps<typeof AccordionPrimitive.Content>> = (
46
+ props,
47
+ ) => {
48
+ const [local, rest] = splitProps(props, ["class", "children"]);
49
+ return (
50
+ <AccordionPrimitive.Content
51
+ data-slot="accordion-content"
52
+ class="overflow-hidden text-sm data-[closed]:animate-accordion-up data-[expanded]:animate-accordion-down"
53
+ {...rest}
54
+ >
55
+ <div class={cn("pt-0 pb-4", local.class)}>{local.children}</div>
56
+ </AccordionPrimitive.Content>
57
+ );
58
+ };
59
+
60
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
@@ -0,0 +1,148 @@
1
+ import { AlertDialog as AlertDialogPrimitive } from "@kobalte/core/alert-dialog";
2
+ import { useDialogContext } from "@kobalte/core/dialog";
3
+ import type { VariantProps } from "cva";
4
+ import { type Component, type ComponentProps, type ParentComponent, splitProps } from "solid-js";
5
+ import { buttonVariants } from "../lib/button-variants.js";
6
+ import { cn } from "../lib/utils.js";
7
+ import {
8
+ createModalDismiss,
9
+ createModalParts,
10
+ MODAL_ANCHOR,
11
+ MODAL_DESCRIPTION,
12
+ MODAL_PANEL,
13
+ MODAL_SCRIM,
14
+ MODAL_TITLE,
15
+ MODAL_WIDTH,
16
+ type ModalDismissProps,
17
+ ModalScrollLock,
18
+ type ModalSize,
19
+ } from "./dialog-parts.js";
20
+
21
+ const AlertDialog: ParentComponent<ComponentProps<typeof AlertDialogPrimitive>> = (props) => (
22
+ <AlertDialogPrimitive {...props} preventScroll={false} />
23
+ );
24
+
25
+ const AlertDialogTrigger: Component<ComponentProps<typeof AlertDialogPrimitive.Trigger>> = (
26
+ props,
27
+ ) => <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />;
28
+
29
+ const AlertDialogOverlay: Component<ComponentProps<typeof AlertDialogPrimitive.Overlay>> = (
30
+ props,
31
+ ) => {
32
+ const [local, rest] = splitProps(props, ["class"]);
33
+ return (
34
+ <AlertDialogPrimitive.Overlay
35
+ data-slot="alert-dialog-overlay"
36
+ class={cn(MODAL_SCRIM, local.class)}
37
+ {...rest}
38
+ />
39
+ );
40
+ };
41
+
42
+ type AlertDialogContentProps = ComponentProps<typeof AlertDialogPrimitive.Content> & {
43
+ size?: ModalSize;
44
+ /** Names a panel that has no `AlertDialogTitle`. A registered Title wins. */
45
+ ariaLabel?: string;
46
+ };
47
+
48
+ const AlertDialogContent: ParentComponent<AlertDialogContentProps> = (props) => {
49
+ const [local, rest] = splitProps(props, ["class", "children", "size", "ariaLabel"]);
50
+ const context = useDialogContext();
51
+ return (
52
+ <AlertDialogPrimitive.Portal>
53
+ <ModalScrollLock />
54
+ <AlertDialogOverlay />
55
+ <AlertDialogPrimitive.Content
56
+ data-slot="alert-dialog-content"
57
+ role="alertdialog"
58
+ aria-label={context.titleId() ? undefined : local.ariaLabel}
59
+ class={cn(
60
+ MODAL_PANEL,
61
+ MODAL_WIDTH[local.size ?? "md"],
62
+ MODAL_ANCHOR[local.size ?? "md"],
63
+ local.class,
64
+ )}
65
+ {...rest}
66
+ >
67
+ {local.children}
68
+ </AlertDialogPrimitive.Content>
69
+ </AlertDialogPrimitive.Portal>
70
+ );
71
+ };
72
+
73
+ const {
74
+ Header: AlertDialogHeader,
75
+ Body: AlertDialogBody,
76
+ Footer: AlertDialogFooter,
77
+ } = createModalParts("alert-dialog");
78
+
79
+ const AlertDialogTitle: Component<ComponentProps<typeof AlertDialogPrimitive.Title>> = (props) => {
80
+ const [local, rest] = splitProps(props, ["class"]);
81
+ return (
82
+ <AlertDialogPrimitive.Title
83
+ data-slot="alert-dialog-title"
84
+ class={cn(MODAL_TITLE, local.class)}
85
+ {...rest}
86
+ />
87
+ );
88
+ };
89
+
90
+ const AlertDialogDescription: Component<ComponentProps<typeof AlertDialogPrimitive.Description>> = (
91
+ props,
92
+ ) => {
93
+ const [local, rest] = splitProps(props, ["class"]);
94
+ return (
95
+ <AlertDialogPrimitive.Description
96
+ data-slot="alert-dialog-description"
97
+ class={cn(MODAL_DESCRIPTION, local.class)}
98
+ {...rest}
99
+ />
100
+ );
101
+ };
102
+
103
+ type AlertDialogButtonProps = ModalDismissProps &
104
+ Partial<Pick<VariantProps<typeof buttonVariants>, "variant" | "size">>;
105
+
106
+ const ActionDismiss = createModalDismiss("alert-dialog-action");
107
+ const CancelDismiss = createModalDismiss("alert-dialog-cancel");
108
+
109
+ /** Confirming action. Pass `variant` (e.g. "destructive"); layering a second
110
+ * buttonVariants() call through `class` cannot work, because the variants
111
+ * carry tone as arbitrary custom properties that tailwind-merge keeps side by
112
+ * side, leaving the later stylesheet rule to win. */
113
+ const AlertDialogAction: ParentComponent<AlertDialogButtonProps> = (props) => {
114
+ const [local, rest] = splitProps(props, ["class", "variant", "size"] as const);
115
+ return (
116
+ <ActionDismiss
117
+ class={cn(buttonVariants({ variant: local.variant, size: local.size }), local.class)}
118
+ {...rest}
119
+ />
120
+ );
121
+ };
122
+
123
+ /** This family's Close: the outline button that dismisses without acting. */
124
+ const AlertDialogCancel: ParentComponent<AlertDialogButtonProps> = (props) => {
125
+ const [local, rest] = splitProps(props, ["class", "variant", "size"] as const);
126
+ return (
127
+ <CancelDismiss
128
+ class={cn(
129
+ buttonVariants({ variant: local.variant ?? "outline", size: local.size }),
130
+ local.class,
131
+ )}
132
+ {...rest}
133
+ />
134
+ );
135
+ };
136
+
137
+ export {
138
+ AlertDialog,
139
+ AlertDialogAction,
140
+ AlertDialogBody,
141
+ AlertDialogCancel,
142
+ AlertDialogContent,
143
+ AlertDialogDescription,
144
+ AlertDialogFooter,
145
+ AlertDialogHeader,
146
+ AlertDialogTitle,
147
+ AlertDialogTrigger,
148
+ };
@@ -0,0 +1,118 @@
1
+ import {
2
+ type Component,
3
+ type ComponentProps,
4
+ createContext,
5
+ type JSX,
6
+ Show,
7
+ splitProps,
8
+ useContext,
9
+ } from "solid-js";
10
+ import {
11
+ ALERT_CLASS,
12
+ ALERT_CONTENT_CLASS,
13
+ ALERT_DESCRIPTION_CLASS,
14
+ ALERT_ICON_BG_CLASS,
15
+ ALERT_ICON_PATHS,
16
+ ALERT_TITLE_CLASS,
17
+ ALERT_TONES,
18
+ type AlertTone,
19
+ alertIconBgStyle,
20
+ } from "../lib/alert-tones.js";
21
+ import { glassToneText } from "../lib/glass-tone.js";
22
+ import { cn } from "../lib/utils.js";
23
+
24
+ export type { AlertTone };
25
+
26
+ type AlertProps = ComponentProps<"div"> & {
27
+ tone?: AlertTone;
28
+ icon?: JSX.Element;
29
+ title?: JSX.Element;
30
+ action?: JSX.Element;
31
+ };
32
+
33
+ // Lets `AlertTitle`, used as a child, pick up the same tone colour the
34
+ // `title` prop gets. Without this an `<AlertTitle>` inside an `<Alert
35
+ // tone="destructive">` rendered in plain foreground: same markup, same slot,
36
+ // same size class, but colourless, because it had no way to see the tone its
37
+ // parent had already resolved.
38
+ const AlertToneContext = createContext<() => string>();
39
+
40
+ const Alert: Component<AlertProps> = (props) => {
41
+ const [local, rest] = splitProps(props, ["class", "tone", "icon", "title", "action", "children"]);
42
+ const toneKey = () => local.tone ?? "info";
43
+ const tone = () => ALERT_TONES[toneKey()];
44
+ return (
45
+ <div
46
+ data-slot="alert"
47
+ role={local.tone === "destructive" ? "alert" : "status"}
48
+ class={cn(ALERT_CLASS, "glass glass-tint", local.class)}
49
+ style={{ "--glass-tone": tone().color, color: "var(--foreground)" }}
50
+ {...rest}
51
+ >
52
+ <span class={ALERT_ICON_BG_CLASS} style={alertIconBgStyle(tone().color)} aria-hidden="true">
53
+ <Show
54
+ when={local.icon}
55
+ fallback={
56
+ <svg
57
+ xmlns="http://www.w3.org/2000/svg"
58
+ viewBox="0 0 24 24"
59
+ fill="none"
60
+ stroke="currentColor"
61
+ stroke-width="2"
62
+ stroke-linecap="round"
63
+ stroke-linejoin="round"
64
+ innerHTML={ALERT_ICON_PATHS[toneKey()]}
65
+ />
66
+ }
67
+ >
68
+ {local.icon}
69
+ </Show>
70
+ </span>
71
+ <div class={ALERT_CONTENT_CLASS}>
72
+ <AlertToneContext.Provider value={() => tone().color}>
73
+ <Show when={local.title}>
74
+ <p
75
+ data-slot="alert-title"
76
+ class={ALERT_TITLE_CLASS}
77
+ style={{ color: glassToneText(tone().color) }}
78
+ >
79
+ {local.title}
80
+ </p>
81
+ </Show>
82
+ <Show when={local.children}>
83
+ <div data-slot="alert-description" class={ALERT_DESCRIPTION_CLASS}>
84
+ {local.children}
85
+ </div>
86
+ </Show>
87
+ </AlertToneContext.Provider>
88
+ </div>
89
+ <Show when={local.action}>
90
+ {/* self-center: the row is items-start for the icon, which would strand
91
+ the action at the top of a multi-line body. */}
92
+ <div class="flex shrink-0 items-center self-center">{local.action}</div>
93
+ </Show>
94
+ </div>
95
+ );
96
+ };
97
+
98
+ const AlertTitle: Component<ComponentProps<"div">> = (props) => {
99
+ const [local, rest] = splitProps(props, ["class"]);
100
+ const toneColor = useContext(AlertToneContext);
101
+ return (
102
+ <div
103
+ data-slot="alert-title"
104
+ class={cn(ALERT_TITLE_CLASS, local.class)}
105
+ style={toneColor ? { color: glassToneText(toneColor()) } : undefined}
106
+ {...rest}
107
+ />
108
+ );
109
+ };
110
+
111
+ const AlertDescription: Component<ComponentProps<"div">> = (props) => {
112
+ const [local, rest] = splitProps(props, ["class"]);
113
+ return (
114
+ <div data-slot="alert-description" class={cn(ALERT_DESCRIPTION_CLASS, local.class)} {...rest} />
115
+ );
116
+ };
117
+
118
+ export { Alert, AlertDescription, AlertTitle };