@glasshome/ui 1.21.1 → 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/index.d.ts +9 -9
- package/dist/solid/index.js +5431 -5424
- 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 +127 -127
- package/src/solid/dialog.tsx +113 -113
- package/src/solid/dock-paging.ts +9 -9
- package/src/solid/dock.tsx +339 -339
- 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 +56 -56
- 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 +164 -164
- 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 +743 -743
- 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
package/src/solid/alert.tsx
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
type Component,
|
|
3
|
+
type ComponentProps,
|
|
4
|
+
createContext,
|
|
5
|
+
type JSX,
|
|
6
|
+
Show,
|
|
7
|
+
splitProps,
|
|
8
|
+
useContext,
|
|
9
9
|
} from "solid-js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
20
|
} from "../lib/alert-tones.js";
|
|
21
21
|
import { glassToneText } from "../lib/glass-tone.js";
|
|
22
22
|
import { cn } from "../lib/utils.js";
|
|
@@ -24,10 +24,10 @@ import { cn } from "../lib/utils.js";
|
|
|
24
24
|
export type { AlertTone };
|
|
25
25
|
|
|
26
26
|
type AlertProps = ComponentProps<"div"> & {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
tone?: AlertTone;
|
|
28
|
+
icon?: JSX.Element;
|
|
29
|
+
title?: JSX.Element;
|
|
30
|
+
action?: JSX.Element;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// Lets `AlertTitle`, used as a child, pick up the same tone colour the
|
|
@@ -38,81 +38,81 @@ type AlertProps = ComponentProps<"div"> & {
|
|
|
38
38
|
const AlertToneContext = createContext<() => string>();
|
|
39
39
|
|
|
40
40
|
const Alert: Component<AlertProps> = (props) => {
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
91
|
the action at the top of a multi-line body. */}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
<div class="flex shrink-0 items-center self-center">{local.action}</div>
|
|
93
|
+
</Show>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
const AlertTitle: Component<ComponentProps<"div">> = (props) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
109
|
};
|
|
110
110
|
|
|
111
111
|
const AlertDescription: Component<ComponentProps<"div">> = (props) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
116
|
};
|
|
117
117
|
|
|
118
118
|
export { Alert, AlertDescription, AlertTitle };
|
|
@@ -12,219 +12,219 @@ import { Popover, PopoverAnchor, PopoverContent } from "./popover.js";
|
|
|
12
12
|
import { SlidingIndicator } from "./sliding-indicator.js";
|
|
13
13
|
|
|
14
14
|
interface AreaPickerBaseProps {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
class?: string;
|
|
17
|
+
/** false: a re-tap on the picked area keeps it instead of clearing. */
|
|
18
|
+
allowClear?: boolean;
|
|
19
|
+
/** A read-only caller renders the real picker dimmed, never a plain text line. */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Id of the element naming the trigger, for forms that label it outside. */
|
|
22
|
+
"aria-labelledby"?: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
interface AreaPickerSingleProps extends AreaPickerBaseProps {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
value: string;
|
|
27
|
+
onChange: (value: string) => void;
|
|
28
|
+
values?: undefined;
|
|
29
|
+
onValuesChange?: undefined;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
interface AreaPickerMultiProps extends AreaPickerBaseProps {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
values: string[];
|
|
34
|
+
onValuesChange: (values: string[]) => void;
|
|
35
|
+
value?: undefined;
|
|
36
|
+
onChange?: undefined;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
type AreaPickerProps = AreaPickerSingleProps | AreaPickerMultiProps;
|
|
40
40
|
|
|
41
41
|
export function AreaPicker(props: AreaPickerProps) {
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
42
|
+
const data = useEntityData();
|
|
43
|
+
const [open, setOpen] = createSignal(false);
|
|
44
|
+
const [search, setSearch] = createSignal("");
|
|
45
|
+
|
|
46
|
+
const areas = data.useAreas();
|
|
47
|
+
|
|
48
|
+
const areaList = createMemo(() =>
|
|
49
|
+
areas().map((a) => ({
|
|
50
|
+
id: a.id,
|
|
51
|
+
name: a.name,
|
|
52
|
+
icon: a.icon,
|
|
53
|
+
entityCount: a.entityIds.length,
|
|
54
|
+
})),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const filtered = createMemo(() => {
|
|
58
|
+
const q = search().trim().toLowerCase();
|
|
59
|
+
if (!q) return areaList();
|
|
60
|
+
return areaList().filter(
|
|
61
|
+
(a) => a.name.toLowerCase().includes(q) || a.id.toLowerCase().includes(q),
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const multi = () => props.values !== undefined;
|
|
66
|
+
// Only ids the home still has: a stale grant shows as its own greyed row and
|
|
67
|
+
// leaves the value on the next toggle.
|
|
68
|
+
const selected = createMemo(() => {
|
|
69
|
+
const ids = props.values ?? [];
|
|
70
|
+
return ids.filter((id) => areaList().some((a) => a.id === id));
|
|
71
|
+
});
|
|
72
|
+
const missing = createMemo(() => {
|
|
73
|
+
const q = search().trim().toLowerCase();
|
|
74
|
+
return (props.values ?? [])
|
|
75
|
+
.filter((id) => !areaList().some((a) => a.id === id))
|
|
76
|
+
.filter((id) => !q || id.toLowerCase().includes(q));
|
|
77
|
+
});
|
|
78
|
+
const isSelected = (areaId: string) =>
|
|
79
|
+
multi() ? selected().includes(areaId) : props.value === areaId;
|
|
80
|
+
|
|
81
|
+
const triggerArea = createMemo(() => {
|
|
82
|
+
if (!multi()) {
|
|
83
|
+
const v = props.value;
|
|
84
|
+
return v ? areaList().find((a) => a.id === v) : undefined;
|
|
85
|
+
}
|
|
86
|
+
const only = selected();
|
|
87
|
+
return only.length === 1 ? areaList().find((a) => a.id === only[0]) : undefined;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// One glass pill (SlidingIndicator) tracks the highlighted row and animates
|
|
91
|
+
// between rows, exactly like the Select. Hover wins; otherwise the pill rests
|
|
92
|
+
// on a selected row, which in multi mode is the first one still listed.
|
|
93
|
+
const [hovered, setHovered] = createSignal<string | null>(null);
|
|
94
|
+
const restingId = createMemo(() => {
|
|
95
|
+
const list = filtered();
|
|
96
|
+
if (!multi()) return list.some((a) => a.id === props.value) ? (props.value ?? null) : null;
|
|
97
|
+
const ids = selected();
|
|
98
|
+
return list.find((a) => ids.includes(a.id))?.id ?? null;
|
|
99
|
+
});
|
|
100
|
+
const highlightedId = () => hovered() ?? restingId();
|
|
101
|
+
|
|
102
|
+
// A re-tap on the picked area clears it, the way every other picker toggles.
|
|
103
|
+
const selectArea = (areaId: string) => {
|
|
104
|
+
if (props.disabled) return;
|
|
105
|
+
props.onChange?.(areaId === props.value && props.allowClear !== false ? "" : areaId);
|
|
106
|
+
setOpen(false);
|
|
107
|
+
setSearch("");
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const showTriggerClear = () =>
|
|
111
|
+
props.allowClear !== false && (multi() ? selected().length > 0 : Boolean(props.value));
|
|
112
|
+
|
|
113
|
+
const clearSelection = () => {
|
|
114
|
+
if (props.disabled) return;
|
|
115
|
+
props.onChange?.("");
|
|
116
|
+
props.onValuesChange?.([]);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const toggleArea = (areaId: string) => {
|
|
120
|
+
if (props.disabled) return;
|
|
121
|
+
const current = selected();
|
|
122
|
+
props.onValuesChange?.(
|
|
123
|
+
current.includes(areaId) ? current.filter((id) => id !== areaId) : [...current, areaId],
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<Popover
|
|
129
|
+
surface="field"
|
|
130
|
+
open={open()}
|
|
131
|
+
onOpenChange={(isOpen) => {
|
|
132
|
+
if (!isOpen) {
|
|
133
|
+
setOpen(false);
|
|
134
|
+
setSearch("");
|
|
135
|
+
}
|
|
136
|
+
}}
|
|
137
|
+
modal
|
|
138
|
+
>
|
|
139
|
+
<PopoverAnchor as="div" class={props.class}>
|
|
140
|
+
<PickerTrigger
|
|
141
|
+
slot="area-picker-trigger"
|
|
142
|
+
open={open()}
|
|
143
|
+
onToggle={() => setOpen(!open())}
|
|
144
|
+
aria-labelledby={props["aria-labelledby"]}
|
|
145
|
+
disabled={props.disabled}
|
|
146
|
+
onClear={showTriggerClear() ? clearSelection : undefined}
|
|
147
|
+
clearLabel={multi() ? "Clear areas" : "Clear area"}
|
|
148
|
+
>
|
|
149
|
+
<Show
|
|
150
|
+
when={triggerArea()}
|
|
151
|
+
fallback={
|
|
152
|
+
<Show
|
|
153
|
+
when={selected().length > 1}
|
|
154
|
+
fallback={
|
|
155
|
+
<span class="text-muted-foreground flex-1 text-left">
|
|
156
|
+
{props.placeholder ?? (multi() ? "Select areas..." : "Select area...")}
|
|
157
|
+
</span>
|
|
158
|
+
}
|
|
159
|
+
>
|
|
160
|
+
<span class="flex-1 truncate text-left">{selected().length} rooms</span>
|
|
161
|
+
</Show>
|
|
162
|
+
}
|
|
163
|
+
>
|
|
164
|
+
{(area) => (
|
|
165
|
+
<>
|
|
166
|
+
<div class="flex size-4 shrink-0 items-center justify-center">
|
|
167
|
+
<Icon icon={area().icon || "mdi:home-floor-1"} width={16} height={16} />
|
|
168
|
+
</div>
|
|
169
|
+
<span class="flex-1 truncate text-left">{area().name}</span>
|
|
170
|
+
</>
|
|
171
|
+
)}
|
|
172
|
+
</Show>
|
|
173
|
+
</PickerTrigger>
|
|
174
|
+
</PopoverAnchor>
|
|
175
|
+
<PopoverContent
|
|
176
|
+
onOpenAutoFocus={(e) => e.preventDefault()}
|
|
177
|
+
onInteractOutside={() => setOpen(false)}
|
|
178
|
+
>
|
|
179
|
+
<div class="flex flex-col">
|
|
180
|
+
<PickerSearch
|
|
181
|
+
value={search()}
|
|
182
|
+
onValueChange={setSearch}
|
|
183
|
+
placeholder="Search areas..."
|
|
184
|
+
aria-label="Search areas"
|
|
185
|
+
/>
|
|
186
|
+
<SlidingIndicator
|
|
187
|
+
activeSelector="[data-highlighted]"
|
|
188
|
+
orientation="vertical"
|
|
189
|
+
indicatorClass="rounded-sm"
|
|
190
|
+
class={cn("flex flex-col gap-0.5 p-1", STAGGER, PICKER_LIST)}
|
|
191
|
+
onMouseLeave={() => setHovered(null)}
|
|
192
|
+
>
|
|
193
|
+
<Show when={filtered().length === 0 && missing().length === 0}>
|
|
194
|
+
<div class="text-muted-foreground py-4 text-center text-sm">No areas found</div>
|
|
195
|
+
</Show>
|
|
196
|
+
<For each={missing()}>
|
|
197
|
+
{(areaId) => (
|
|
198
|
+
<div
|
|
199
|
+
data-slot="area-picker-missing"
|
|
200
|
+
class={cn(MENU_ITEM, "text-muted-foreground/60")}
|
|
201
|
+
>
|
|
202
|
+
<span class="truncate">{areaId}</span>
|
|
203
|
+
<span class="shrink-0 text-xs">no longer exists</span>
|
|
204
|
+
</div>
|
|
205
|
+
)}
|
|
206
|
+
</For>
|
|
207
|
+
<For each={filtered()}>
|
|
208
|
+
{(area) => (
|
|
209
|
+
<PickerRow
|
|
210
|
+
as="button"
|
|
211
|
+
type="button"
|
|
212
|
+
data-slot="area-picker-row"
|
|
213
|
+
data-highlighted={highlightedId() === area.id || undefined}
|
|
214
|
+
aria-pressed={multi() ? isSelected(area.id) : undefined}
|
|
215
|
+
icon={area.icon || "mdi:home-floor-1"}
|
|
216
|
+
title={area.name}
|
|
217
|
+
subtitle={`${area.entityCount} ${area.entityCount === 1 ? "entity" : "entities"}`}
|
|
218
|
+
selected={isSelected(area.id)}
|
|
219
|
+
multi={multi()}
|
|
220
|
+
onMouseEnter={() => setHovered(area.id)}
|
|
221
|
+
onClick={() => (multi() ? toggleArea(area.id) : selectArea(area.id))}
|
|
222
|
+
/>
|
|
223
|
+
)}
|
|
224
|
+
</For>
|
|
225
|
+
</SlidingIndicator>
|
|
226
|
+
</div>
|
|
227
|
+
</PopoverContent>
|
|
228
|
+
</Popover>
|
|
229
|
+
);
|
|
230
230
|
}
|