@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
@@ -0,0 +1,99 @@
1
+ import { type Component, type ComponentProps, splitProps } from "solid-js";
2
+ import { ICON_PILL } from "../lib/pill-classes.js";
3
+ import { cn } from "../lib/utils.js";
4
+
5
+ const Empty: Component<ComponentProps<"div">> = (props) => {
6
+ const [local, rest] = splitProps(props, ["class"]);
7
+ return (
8
+ <div
9
+ data-slot="empty"
10
+ class={cn(
11
+ "flex min-w-0 flex-1 flex-col items-center justify-center gap-6 text-balance rounded-lg border border-border/60 border-dashed p-6 text-center md:p-12",
12
+ local.class,
13
+ )}
14
+ {...rest}
15
+ />
16
+ );
17
+ };
18
+
19
+ const EmptyHeader: Component<ComponentProps<"div">> = (props) => {
20
+ const [local, rest] = splitProps(props, ["class"]);
21
+ return (
22
+ <div
23
+ data-slot="empty-header"
24
+ class={cn("flex max-w-sm flex-col items-center gap-2 text-center", local.class)}
25
+ {...rest}
26
+ />
27
+ );
28
+ };
29
+
30
+ type EmptyMediaKind = "icon";
31
+
32
+ const EMPTY_MEDIA: Record<EmptyMediaKind, string> = {
33
+ icon: `${ICON_PILL} size-10 rounded-lg [&_svg:not([class*='size-'])]:size-6`,
34
+ };
35
+
36
+ const EmptyMedia: Component<
37
+ ComponentProps<"div"> & {
38
+ media?: EmptyMediaKind;
39
+ /** @deprecated `media` */
40
+ variant?: EmptyMediaKind | "default";
41
+ }
42
+ > = (props) => {
43
+ const [local, rest] = splitProps(props, ["class", "media", "variant"] as const);
44
+ const media = () => local.media ?? (local.variant === "default" ? undefined : local.variant);
45
+ return (
46
+ <div
47
+ data-slot="empty-media"
48
+ data-media={media()}
49
+ data-variant={local.variant ?? media() ?? "default"}
50
+ class={cn(
51
+ "flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
52
+ media() && EMPTY_MEDIA[media() as EmptyMediaKind],
53
+ local.class,
54
+ )}
55
+ {...rest}
56
+ />
57
+ );
58
+ };
59
+
60
+ const EmptyTitle: Component<ComponentProps<"div">> = (props) => {
61
+ const [local, rest] = splitProps(props, ["class"]);
62
+ return (
63
+ <div
64
+ data-slot="empty-title"
65
+ class={cn("font-semibold text-lg tracking-tight", local.class)}
66
+ {...rest}
67
+ />
68
+ );
69
+ };
70
+
71
+ const EmptyDescription: Component<ComponentProps<"div">> = (props) => {
72
+ const [local, rest] = splitProps(props, ["class"]);
73
+ return (
74
+ <div
75
+ data-slot="empty-description"
76
+ class={cn(
77
+ "text-muted-foreground text-sm/relaxed [&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",
78
+ local.class,
79
+ )}
80
+ {...rest}
81
+ />
82
+ );
83
+ };
84
+
85
+ const EmptyContent: Component<ComponentProps<"div">> = (props) => {
86
+ const [local, rest] = splitProps(props, ["class"]);
87
+ return (
88
+ <div
89
+ data-slot="empty-content"
90
+ class={cn(
91
+ "flex w-full min-w-0 max-w-sm flex-col items-center gap-4 text-balance text-sm",
92
+ local.class,
93
+ )}
94
+ {...rest}
95
+ />
96
+ );
97
+ };
98
+
99
+ export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle };
@@ -0,0 +1,78 @@
1
+ import { type Accessor, createContext, useContext } from "solid-js";
2
+
3
+ /**
4
+ * Structural view types for the smart-home pickers (EntitySelector,
5
+ * AreaPicker). They are subsets of @glasshome/sync-layer's EntityView /
6
+ * AreaView, owned here so the design system carries no dependency on the HA
7
+ * data runtime: the host supplies a live implementation through
8
+ * EntityDataContext (dash wires sync-layer in; the dev gallery wires static
9
+ * demo data).
10
+ */
11
+ export interface EntityViewLike {
12
+ id: string;
13
+ /** Current state value (e.g. "on", "21.5"). */
14
+ state: string;
15
+ /** Entity name (registry name or friendly_name). */
16
+ name: string;
17
+ friendlyName: string;
18
+ aliases: readonly string[];
19
+ areaId: string | null;
20
+ /** Resolved icon name (e.g. "mdi:lightbulb"). */
21
+ icon: string | null;
22
+ /** "config" | "diagnostic" for non-primary entities, null for regular ones. */
23
+ entityCategory: string | null;
24
+ isHidden: boolean;
25
+ isDisabled: boolean;
26
+ deviceClass?: string | null;
27
+ unitOfMeasurement?: string | null;
28
+ }
29
+
30
+ export interface AreaViewLike {
31
+ id: string;
32
+ name: string;
33
+ icon: string | null;
34
+ entityIds: readonly string[];
35
+ }
36
+
37
+ /**
38
+ * Live entity/area data source provided by the host app. All members are
39
+ * reactive under Solid tracking scopes; `useEntities` is a lazy subscription
40
+ * keyed on the id list, so a picker only subscribes to what it shows.
41
+ */
42
+ export interface EntityDataAdapter {
43
+ /** Entity ids grouped by domain (e.g. { light: ["light.kitchen"] }). */
44
+ entityIdsByDomain: Accessor<Record<string, string[]>>;
45
+ /** Subscribe to live views for a reactive id list. */
46
+ useEntities(entityIds: Accessor<string[]>): Accessor<EntityViewLike[]>;
47
+ /** Point read of one entity's live view; reactive when called in a tracking scope. */
48
+ getEntityView(entityId: string): EntityViewLike | undefined;
49
+ /** All areas of the home. */
50
+ useAreas(): Accessor<AreaViewLike[]>;
51
+ }
52
+
53
+ export const EntityDataContext = createContext<EntityDataAdapter>();
54
+
55
+ /**
56
+ * Module-level fallback for render roots the host's context provider cannot
57
+ * reach: widget sandboxes mount their own Solid roots (and render SchemaForm /
58
+ * EntitySelector inside them), but they resolve this module through the host
59
+ * import map, so it is the same singleton the host registered into.
60
+ */
61
+ let defaultAdapter: EntityDataAdapter | undefined;
62
+
63
+ /** Host apps call this once at startup; EntityDataContext overrides it per-tree. */
64
+ export function provideEntityData(adapter: EntityDataAdapter): void {
65
+ defaultAdapter = adapter;
66
+ }
67
+
68
+ export function useEntityData(): EntityDataAdapter {
69
+ const adapter = useContext(EntityDataContext) ?? defaultAdapter;
70
+ if (!adapter) {
71
+ throw new Error(
72
+ "useEntityData: no entity data source. Call provideEntityData(adapter) " +
73
+ "at app startup or wrap the tree in <EntityDataContext.Provider> " +
74
+ "(dash registers a @glasshome/sync-layer-backed adapter).",
75
+ );
76
+ }
77
+ return adapter;
78
+ }