@glasshome/ui 1.21.0 → 1.21.2
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/use-is-mobile.d.ts +3 -1
- package/dist/solid/alert-dialog.d.ts +7 -1
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +7 -1
- package/dist/solid/dialog-parts.d.ts +3 -2
- package/dist/solid/dialog.d.ts +7 -1
- package/dist/solid/docked-panel.d.ts +7 -1
- package/dist/solid/index.d.ts +9 -9
- package/dist/solid/index.js +5456 -5447
- package/dist/solid/media-store.d.ts +4 -1
- package/dist/solid/option-card.d.ts +4 -1
- package/dist/solid/responsive-dialog.d.ts +7 -1
- package/dist/solid/sheet.d.ts +7 -1
- package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
- package/package.json +128 -126
- package/scripts/check-gallery.ts +142 -142
- package/scripts/check-pack.ts +13 -13
- package/scripts/check-structural-classes.ts +20 -20
- package/scripts/check-tokens.ts +27 -27
- package/scripts/check-ui-drift.mjs +103 -103
- package/src/index.ts +75 -80
- package/src/lib/alert-tones.ts +41 -41
- package/src/lib/anchor-placement.ts +21 -21
- package/src/lib/button-variants.ts +28 -28
- package/src/lib/card-classes.ts +9 -9
- package/src/lib/carousel-classes.ts +14 -14
- package/src/lib/glass-tone.ts +11 -11
- package/src/lib/input-classes.ts +6 -6
- package/src/lib/layers.ts +4 -4
- package/src/lib/logo-lockup.ts +8 -8
- package/src/lib/menu-classes.ts +2 -2
- package/src/lib/motion-classes.ts +8 -8
- package/src/lib/motion-window.ts +24 -24
- package/src/lib/overlay-classes.ts +6 -6
- package/src/lib/pill-classes.ts +3 -3
- package/src/lib/position-bar-classes.ts +1 -1
- package/src/lib/spotlight-geometry.ts +67 -67
- package/src/lib/thumb-classes.ts +2 -2
- package/src/lib/tier-badge.ts +16 -16
- package/src/lib/use-is-mobile.ts +17 -14
- package/src/lib/utils.ts +1 -1
- package/src/solid/accordion.tsx +41 -41
- package/src/solid/alert-dialog.tsx +95 -95
- package/src/solid/alert.tsx +88 -88
- package/src/solid/area-picker.tsx +204 -204
- package/src/solid/aspect-ratio.tsx +13 -13
- package/src/solid/avatar.tsx +27 -27
- package/src/solid/badge.tsx +49 -49
- package/src/solid/bottom-sheet/arbitration.ts +22 -22
- package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
- package/src/solid/bottom-sheet/drag-controller.ts +201 -201
- package/src/solid/bottom-sheet/focus-trap.ts +51 -47
- package/src/solid/bottom-sheet/index.ts +12 -12
- package/src/solid/bottom-sheet/keyboard.ts +25 -25
- package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
- package/src/solid/bottom-sheet/state-machine.ts +28 -28
- package/src/solid/bottom-sheet/velocity.ts +29 -29
- package/src/solid/breadcrumb.tsx +76 -76
- package/src/solid/button-group.tsx +46 -46
- package/src/solid/button.tsx +19 -19
- package/src/solid/card.tsx +67 -67
- package/src/solid/carousel.tsx +246 -246
- package/src/solid/charts.tsx +253 -253
- package/src/solid/checkbox.tsx +51 -51
- package/src/solid/collapsible.tsx +22 -22
- package/src/solid/color-disc.tsx +213 -213
- package/src/solid/color-slider.tsx +81 -81
- package/src/solid/color-wheel.tsx +61 -61
- package/src/solid/context-menu.tsx +63 -63
- package/src/solid/copy-button.tsx +31 -31
- package/src/solid/count-pill.tsx +11 -11
- package/src/solid/dashboard-preview.tsx +104 -104
- package/src/solid/data-table.tsx +228 -228
- package/src/solid/dialog-parts.tsx +129 -129
- package/src/solid/dialog.tsx +113 -113
- package/src/solid/dock-paging.ts +9 -9
- package/src/solid/dock.tsx +339 -338
- package/src/solid/docked-panel.tsx +35 -35
- package/src/solid/dropdown-menu.tsx +77 -77
- package/src/solid/empty.tsx +70 -70
- package/src/solid/entity-data.ts +38 -38
- package/src/solid/entity-selector.tsx +634 -634
- package/src/solid/field.tsx +205 -205
- package/src/solid/form.tsx +159 -159
- package/src/solid/hero-action.tsx +85 -85
- package/src/solid/hover-card.tsx +11 -11
- package/src/solid/icon-picker.tsx +401 -401
- package/src/solid/icon.tsx +101 -78
- package/src/solid/image-picker.tsx +416 -414
- package/src/solid/index.ts +265 -304
- package/src/solid/input-group.tsx +123 -123
- package/src/solid/input-otp.tsx +143 -143
- package/src/solid/input.tsx +4 -4
- package/src/solid/item.tsx +130 -130
- package/src/solid/kbd.tsx +20 -20
- package/src/solid/label.tsx +12 -12
- package/src/solid/list-reorder.ts +122 -122
- package/src/solid/logo.tsx +60 -60
- package/src/solid/media-copy.ts +21 -21
- package/src/solid/media-store.ts +60 -57
- package/src/solid/media-tile.tsx +85 -85
- package/src/solid/menu-parts.tsx +164 -164
- package/src/solid/number-field.tsx +56 -56
- package/src/solid/option-card.tsx +168 -165
- package/src/solid/ornament.tsx +43 -43
- package/src/solid/overlay.tsx +4 -4
- package/src/solid/page-header.tsx +75 -75
- package/src/solid/pagination.tsx +80 -80
- package/src/solid/password-input.tsx +51 -51
- package/src/solid/picker-row.tsx +83 -83
- package/src/solid/picker-search.tsx +65 -63
- package/src/solid/picker-trigger.tsx +59 -57
- package/src/solid/popover.tsx +54 -54
- package/src/solid/preview-tile.tsx +67 -67
- package/src/solid/progress.tsx +21 -21
- package/src/solid/radio-group.tsx +51 -51
- package/src/solid/resizable.tsx +128 -128
- package/src/solid/responsive-dialog.tsx +134 -134
- package/src/solid/schema-form.tsx +746 -739
- package/src/solid/scope-indicator.tsx +5 -5
- package/src/solid/scroll-area.tsx +16 -16
- package/src/solid/section-card.tsx +281 -281
- package/src/solid/select.tsx +101 -101
- package/src/solid/separator.tsx +25 -25
- package/src/solid/settings-row.tsx +122 -122
- package/src/solid/sheet.tsx +96 -96
- package/src/solid/skeleton.tsx +8 -8
- package/src/solid/slider.tsx +132 -132
- package/src/solid/sliding-indicator.tsx +280 -265
- package/src/solid/sonner.tsx +164 -164
- package/src/solid/spinner.tsx +12 -12
- package/src/solid/spotlight.tsx +140 -140
- package/src/solid/step-indicator.tsx +18 -18
- package/src/solid/swatch-picker.tsx +38 -38
- package/src/solid/switch.tsx +52 -52
- package/src/solid/table.tsx +63 -63
- package/src/solid/tabs.tsx +93 -93
- package/src/solid/textarea.tsx +8 -8
- package/src/solid/toggle-group.tsx +83 -83
- package/src/solid/toggle.tsx +33 -33
- package/src/solid/tooltip.tsx +16 -16
- package/src/solid/widget-card.tsx +90 -90
- package/src/solid/widget-identity.tsx +99 -99
- package/src/solid/widget-trust-badge.tsx +20 -20
- package/src/styles/globals.css +316 -319
- package/src/styles/theme.css +448 -448
- package/src/tokens/hex.ts +29 -29
- package/src/tokens/material.ts +75 -75
- package/src/tokens/presets.ts +303 -303
- package/src/tokens/readability.ts +32 -32
- package/src/tokens/theme-colors.ts +95 -95
- package/src/tokens/theme-css.ts +22 -22
- package/src/tokens/theme-recipe.ts +106 -106
|
@@ -12,45 +12,45 @@ import { createModalParts } from "./dialog-parts.js";
|
|
|
12
12
|
const DOCKED_PANEL = `fixed ${Z_CLASS.sheet} flex flex-col overflow-hidden ${OVERLAY_SURFACE_OPAQUE} text-popover-foreground animate-in fade-in duration-300 max-md:inset-x-0 max-md:bottom-0 max-md:max-h-[min(60dvh,38rem)] max-md:rounded-t-2xl max-md:slide-in-from-bottom-8 md:inset-y-3 md:right-3 md:w-[25rem] md:rounded-2xl md:slide-in-from-right-8 max-md:data-[collapsed]:[&_[data-slot=docked-panel-body]]:hidden max-md:data-[collapsed]:[&_[data-slot=docked-panel-footer]]:hidden [&_[data-slot=docked-panel-footer]]:flex-row`;
|
|
13
13
|
|
|
14
14
|
export function DockedPanel(props: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
open: boolean;
|
|
16
|
+
ariaLabel: string;
|
|
17
|
+
collapsed?: boolean;
|
|
18
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
19
|
+
class?: string;
|
|
20
|
+
children: JSX.Element;
|
|
21
21
|
}) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
22
|
+
return (
|
|
23
|
+
<Show when={props.open}>
|
|
24
|
+
<Portal>
|
|
25
|
+
<aside
|
|
26
|
+
data-slot="docked-panel"
|
|
27
|
+
aria-label={props.ariaLabel}
|
|
28
|
+
data-collapsed={props.collapsed ? "" : undefined}
|
|
29
|
+
class={cn(DOCKED_PANEL, props.class)}
|
|
30
|
+
>
|
|
31
|
+
<Show when={props.onCollapsedChange}>
|
|
32
|
+
<button
|
|
33
|
+
type="button"
|
|
34
|
+
data-slot="docked-panel-handle"
|
|
35
|
+
aria-label={props.collapsed ? "Show panel" : "Hide panel"}
|
|
36
|
+
aria-expanded={!props.collapsed}
|
|
37
|
+
class="mx-auto flex h-6 w-full shrink-0 items-center justify-center md:hidden"
|
|
38
|
+
onClick={() => props.onCollapsedChange?.(!props.collapsed)}
|
|
39
|
+
>
|
|
40
|
+
<span class="bg-foreground/25 h-1.5 w-10 rounded-full" />
|
|
41
|
+
</button>
|
|
42
|
+
</Show>
|
|
43
|
+
{props.children}
|
|
44
|
+
</aside>
|
|
45
|
+
</Portal>
|
|
46
|
+
</Show>
|
|
47
|
+
);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
Header: DockedPanelHeader,
|
|
52
|
+
Body: DockedPanelBody,
|
|
53
|
+
Footer: DockedPanelFooter,
|
|
54
54
|
} = createModalParts("docked-panel");
|
|
55
55
|
|
|
56
56
|
export { DockedPanelBody, DockedPanelFooter, DockedPanelHeader };
|
|
@@ -5,126 +5,126 @@ import { MORPH_MOTION } from "../lib/motion-classes.js";
|
|
|
5
5
|
import { anchorToTriggerTop } from "../lib/overlay-classes.js";
|
|
6
6
|
import { cn } from "../lib/utils.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
MENU_CONTENT_CLASS,
|
|
9
|
+
MenuCheckboxItemPart,
|
|
10
|
+
MenuContentIndicator,
|
|
11
|
+
MenuItemPart,
|
|
12
|
+
MenuLabelPart,
|
|
13
|
+
MenuRadioItemPart,
|
|
14
|
+
MenuSeparatorPart,
|
|
15
|
+
MenuSubContentPart,
|
|
16
|
+
MenuSubTriggerPart,
|
|
17
17
|
} from "./menu-parts.js";
|
|
18
18
|
|
|
19
19
|
/* The panel covers the trigger (see MORPH_MOTION); statics carried across so
|
|
20
20
|
* `DropdownMenu.Portal` keeps resolving. */
|
|
21
21
|
const DropdownMenuRoot: Component<ComponentProps<typeof DropdownMenuPrimitive>> = (props) => (
|
|
22
|
-
|
|
22
|
+
<DropdownMenuPrimitive gutter={0} getAnchorRect={anchorToTriggerTop} {...props} />
|
|
23
23
|
);
|
|
24
24
|
const DropdownMenu = Object.assign(DropdownMenuRoot, DropdownMenuPrimitive) as Component<
|
|
25
|
-
|
|
25
|
+
ComponentProps<typeof DropdownMenuPrimitive>
|
|
26
26
|
> &
|
|
27
|
-
|
|
27
|
+
typeof DropdownMenuPrimitive;
|
|
28
28
|
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
29
29
|
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
30
30
|
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
31
31
|
|
|
32
32
|
const DropdownMenuTrigger: Component<ComponentProps<typeof DropdownMenuPrimitive.Trigger>> = (
|
|
33
|
-
|
|
33
|
+
props,
|
|
34
34
|
) => {
|
|
35
|
-
|
|
35
|
+
return <DropdownMenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const DropdownMenuContent: Component<ComponentProps<typeof DropdownMenuPrimitive.Content>> = (
|
|
39
|
-
|
|
39
|
+
props,
|
|
40
40
|
) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
41
|
+
const [local, others] = splitProps(props, ["class", "children"]);
|
|
42
|
+
const menu = useMenuContext();
|
|
43
|
+
// The morph starts as the trigger's box: its height and radius are read
|
|
44
|
+
// from the trigger itself, its width is kobalte's anchor width.
|
|
45
|
+
const writeMorphStart = (el: HTMLElement) => {
|
|
46
|
+
const trigger = menu.triggerRef();
|
|
47
|
+
if (!trigger) return;
|
|
48
|
+
const height = trigger.getBoundingClientRect().height;
|
|
49
|
+
// A pill's radius is "infinite"; the rendered one is half its height.
|
|
50
|
+
const radius = Math.min(
|
|
51
|
+
Number.parseFloat(getComputedStyle(trigger).borderTopLeftRadius) || 0,
|
|
52
|
+
height / 2,
|
|
53
|
+
);
|
|
54
|
+
el.style.setProperty("--morph-h", `${height}px`);
|
|
55
|
+
el.style.setProperty("--morph-radius", `${radius}px`);
|
|
56
|
+
};
|
|
57
|
+
return (
|
|
58
|
+
<DropdownMenuPrimitive.Portal>
|
|
59
|
+
<DropdownMenuPrimitive.Content
|
|
60
|
+
ref={writeMorphStart}
|
|
61
|
+
data-slot="dropdown-menu-content"
|
|
62
|
+
class={cn(MENU_CONTENT_CLASS, MORPH_MOTION, local.class)}
|
|
63
|
+
{...others}
|
|
64
|
+
>
|
|
65
|
+
<MenuContentIndicator>{local.children}</MenuContentIndicator>
|
|
66
|
+
</DropdownMenuPrimitive.Content>
|
|
67
|
+
</DropdownMenuPrimitive.Portal>
|
|
68
|
+
);
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
const DropdownMenuItem: Component<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
73
|
+
inset?: boolean;
|
|
74
|
+
tone?: string;
|
|
75
|
+
/** @deprecated pass `tone="var(--destructive)"` instead */
|
|
76
|
+
variant?: "default" | "destructive";
|
|
77
|
+
}
|
|
78
78
|
> = (props) => <MenuItemPart slotName="dropdown-menu-item" {...props} />;
|
|
79
79
|
|
|
80
80
|
const DropdownMenuSubTrigger: ParentComponent<
|
|
81
|
-
|
|
81
|
+
ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & { inset?: boolean }
|
|
82
82
|
> = (props) => <MenuSubTriggerPart slotName="dropdown-menu-sub-trigger" {...props} />;
|
|
83
83
|
|
|
84
84
|
const DropdownMenuSubContent: ParentComponent<
|
|
85
|
-
|
|
85
|
+
ComponentProps<typeof DropdownMenuPrimitive.SubContent>
|
|
86
86
|
> = (props) => <MenuSubContentPart slotName="dropdown-menu-sub-content" {...props} />;
|
|
87
87
|
|
|
88
88
|
const DropdownMenuCheckboxItem: ParentComponent<
|
|
89
|
-
|
|
89
|
+
ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>
|
|
90
90
|
> = (props) => <MenuCheckboxItemPart slotName="dropdown-menu-checkbox-item" {...props} />;
|
|
91
91
|
|
|
92
92
|
const DropdownMenuRadioItem: ParentComponent<
|
|
93
|
-
|
|
93
|
+
ComponentProps<typeof DropdownMenuPrimitive.RadioItem>
|
|
94
94
|
> = (props) => <MenuRadioItemPart slotName="dropdown-menu-radio-item" {...props} />;
|
|
95
95
|
|
|
96
96
|
const DropdownMenuSeparator: Component<ComponentProps<typeof DropdownMenuPrimitive.Separator>> = (
|
|
97
|
-
|
|
97
|
+
props,
|
|
98
98
|
) => <MenuSeparatorPart slotName="dropdown-menu-separator" {...props} />;
|
|
99
99
|
|
|
100
100
|
const DropdownMenuLabel: Component<
|
|
101
|
-
|
|
101
|
+
ComponentProps<typeof DropdownMenuPrimitive.GroupLabel> & { inset?: boolean }
|
|
102
102
|
> = (props) => <MenuLabelPart slotName="dropdown-menu-label" {...props} />;
|
|
103
103
|
|
|
104
104
|
const DropdownMenuShortcut: Component<ComponentProps<"span">> = (props) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
105
|
+
const [local, others] = splitProps(props, ["class"]);
|
|
106
|
+
return (
|
|
107
|
+
<span
|
|
108
|
+
data-slot="dropdown-menu-shortcut"
|
|
109
|
+
class={cn("text-muted-foreground ml-auto text-xs tracking-widest", local.class)}
|
|
110
|
+
{...others}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
export {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
116
|
+
DropdownMenu,
|
|
117
|
+
DropdownMenuCheckboxItem,
|
|
118
|
+
DropdownMenuContent,
|
|
119
|
+
DropdownMenuGroup,
|
|
120
|
+
DropdownMenuItem,
|
|
121
|
+
DropdownMenuLabel,
|
|
122
|
+
DropdownMenuRadioGroup,
|
|
123
|
+
DropdownMenuRadioItem,
|
|
124
|
+
DropdownMenuSeparator,
|
|
125
|
+
DropdownMenuShortcut,
|
|
126
|
+
DropdownMenuSub,
|
|
127
|
+
DropdownMenuSubContent,
|
|
128
|
+
DropdownMenuSubTrigger,
|
|
129
|
+
DropdownMenuTrigger,
|
|
130
130
|
};
|
package/src/solid/empty.tsx
CHANGED
|
@@ -3,97 +3,97 @@ import { ICON_PILL } from "../lib/pill-classes.js";
|
|
|
3
3
|
import { cn } from "../lib/utils.js";
|
|
4
4
|
|
|
5
5
|
const Empty: Component<ComponentProps<"div">> = (props) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 rounded-lg p-6 text-center text-balance md:p-12",
|
|
12
|
+
local.class,
|
|
13
|
+
)}
|
|
14
|
+
{...rest}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const EmptyHeader: Component<ComponentProps<"div">> = (props) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
28
|
};
|
|
29
29
|
|
|
30
30
|
type EmptyMediaKind = "icon";
|
|
31
31
|
|
|
32
32
|
const EMPTY_MEDIA: Record<EmptyMediaKind, string> = {
|
|
33
|
-
|
|
33
|
+
icon: `${ICON_PILL} size-10 rounded-lg [&_svg:not([class*='size-'])]:size-6`,
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const EmptyMedia: Component<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
ComponentProps<"div"> & {
|
|
38
|
+
media?: EmptyMediaKind;
|
|
39
|
+
/** @deprecated `media` */
|
|
40
|
+
variant?: EmptyMediaKind | "default";
|
|
41
|
+
}
|
|
42
42
|
> = (props) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
58
|
};
|
|
59
59
|
|
|
60
60
|
const EmptyTitle: Component<ComponentProps<"div">> = (props) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
62
|
+
return (
|
|
63
|
+
<div
|
|
64
|
+
data-slot="empty-title"
|
|
65
|
+
class={cn("text-lg font-semibold tracking-tight", local.class)}
|
|
66
|
+
{...rest}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
const EmptyDescription: Component<ComponentProps<"div">> = (props) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
73
|
+
return (
|
|
74
|
+
<div
|
|
75
|
+
data-slot="empty-description"
|
|
76
|
+
class={cn(
|
|
77
|
+
"text-muted-foreground [&>a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4",
|
|
78
|
+
local.class,
|
|
79
|
+
)}
|
|
80
|
+
{...rest}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
const EmptyContent: Component<ComponentProps<"div">> = (props) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
87
|
+
return (
|
|
88
|
+
<div
|
|
89
|
+
data-slot="empty-content"
|
|
90
|
+
class={cn(
|
|
91
|
+
"flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance",
|
|
92
|
+
local.class,
|
|
93
|
+
)}
|
|
94
|
+
{...rest}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle };
|
package/src/solid/entity-data.ts
CHANGED
|
@@ -9,29 +9,29 @@ import { type Accessor, createContext, useContext } from "solid-js";
|
|
|
9
9
|
* demo data).
|
|
10
10
|
*/
|
|
11
11
|
export interface EntityViewLike {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
28
|
}
|
|
29
29
|
|
|
30
30
|
export interface AreaViewLike {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
icon: string | null;
|
|
34
|
+
entityIds: readonly string[];
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -40,14 +40,14 @@ export interface AreaViewLike {
|
|
|
40
40
|
* keyed on the id list, so a picker only subscribes to what it shows.
|
|
41
41
|
*/
|
|
42
42
|
export interface EntityDataAdapter {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
51
|
}
|
|
52
52
|
|
|
53
53
|
export const EntityDataContext = createContext<EntityDataAdapter>();
|
|
@@ -62,17 +62,17 @@ let defaultAdapter: EntityDataAdapter | undefined;
|
|
|
62
62
|
|
|
63
63
|
/** Host apps call this once at startup; EntityDataContext overrides it per-tree. */
|
|
64
64
|
export function provideEntityData(adapter: EntityDataAdapter): void {
|
|
65
|
-
|
|
65
|
+
defaultAdapter = adapter;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export function useEntityData(): EntityDataAdapter {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
78
|
}
|