@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.
- package/SPEC.md +7 -0
- package/dist/index.js +1 -1
- package/dist/lib/menu-classes.d.ts +2 -2
- package/dist/solid/icon.d.ts +18 -12
- package/dist/solid/index.d.ts +1 -0
- package/dist/solid/index.js +3692 -3490
- package/dist/{utils-CIwpbaOd.js → utils-CdUh67Y9.js} +1 -1
- package/package.json +7 -3
- package/scripts/check-pack.ts +32 -0
- package/src/index.ts +111 -0
- package/src/lib/menu-classes.ts +1 -1
- package/src/solid/accordion.tsx +60 -0
- package/src/solid/alert-dialog.tsx +148 -0
- package/src/solid/alert.tsx +118 -0
- package/src/solid/area-picker.tsx +225 -0
- package/src/solid/aspect-ratio.tsx +21 -0
- package/src/solid/avatar.tsx +41 -0
- package/src/solid/badge.tsx +74 -0
- package/src/solid/bottom-sheet/arbitration.ts +40 -0
- package/src/solid/bottom-sheet/bottom-sheet.tsx +457 -0
- package/src/solid/bottom-sheet/constants.ts +8 -0
- package/src/solid/bottom-sheet/drag-controller.ts +221 -0
- package/src/solid/bottom-sheet/focus-trap.ts +56 -0
- package/src/solid/bottom-sheet/index.ts +14 -0
- package/src/solid/bottom-sheet/keyboard.ts +35 -0
- package/src/solid/bottom-sheet/scroll-lock.ts +64 -0
- package/src/solid/bottom-sheet/state-machine.ts +40 -0
- package/src/solid/bottom-sheet/velocity.ts +42 -0
- package/src/solid/breadcrumb.tsx +105 -0
- package/src/solid/button-group.tsx +66 -0
- package/src/solid/button.tsx +20 -0
- package/src/solid/card.tsx +101 -0
- package/src/solid/carousel.tsx +302 -0
- package/src/solid/charts.tsx +338 -0
- package/src/solid/checkbox.tsx +70 -0
- package/src/solid/collapsible.tsx +38 -0
- package/src/solid/color-slider.tsx +98 -0
- package/src/solid/color-wheel.tsx +77 -0
- package/src/solid/context-menu.tsx +109 -0
- package/src/solid/copy-button.tsx +46 -0
- package/src/solid/count-pill.tsx +24 -0
- package/src/solid/data-table.tsx +248 -0
- package/src/solid/dialog-parts.tsx +242 -0
- package/src/solid/dialog.tsx +121 -0
- package/src/solid/dock.tsx +186 -0
- package/src/solid/dropdown-menu.tsx +130 -0
- package/src/solid/empty.tsx +99 -0
- package/src/solid/entity-data.ts +78 -0
- package/src/solid/entity-selector.tsx +697 -0
- package/src/solid/field.tsx +253 -0
- package/src/solid/form.tsx +231 -0
- package/src/solid/hero-action.tsx +117 -0
- package/src/solid/hover-card.tsx +26 -0
- package/src/solid/icon-picker.tsx +432 -0
- package/src/solid/icon.tsx +126 -0
- package/src/solid/image-picker.tsx +380 -0
- package/src/solid/index.ts +413 -0
- package/src/solid/input-group.tsx +170 -0
- package/src/solid/input-otp.tsx +175 -0
- package/src/solid/input.tsx +12 -0
- package/src/solid/item.tsx +179 -0
- package/src/solid/kbd.tsx +30 -0
- package/src/solid/label.tsx +19 -0
- package/src/solid/list-reorder.ts +148 -0
- package/src/solid/logo.tsx +79 -0
- package/src/solid/media-copy.ts +37 -0
- package/src/solid/media-store.ts +110 -0
- package/src/solid/media-tile.tsx +100 -0
- package/src/solid/menu-parts.tsx +248 -0
- package/src/solid/number-field.tsx +72 -0
- package/src/solid/option-card.tsx +218 -0
- package/src/solid/ornament.tsx +53 -0
- package/src/solid/overlay.tsx +16 -0
- package/src/solid/page-header.tsx +102 -0
- package/src/solid/pagination.tsx +111 -0
- package/src/solid/password-input.tsx +69 -0
- package/src/solid/picker-row.tsx +102 -0
- package/src/solid/picker-search.tsx +78 -0
- package/src/solid/popover.tsx +103 -0
- package/src/solid/progress.tsx +31 -0
- package/src/solid/radio-group.tsx +60 -0
- package/src/solid/resizable.tsx +149 -0
- package/src/solid/responsive-dialog.tsx +180 -0
- package/src/solid/schema-form.tsx +830 -0
- package/src/solid/scope-indicator.tsx +13 -0
- package/src/solid/scroll-area.tsx +27 -0
- package/src/solid/section-card.tsx +358 -0
- package/src/solid/select.tsx +139 -0
- package/src/solid/separator.tsx +35 -0
- package/src/solid/settings-row.tsx +159 -0
- package/src/solid/sheet.tsx +157 -0
- package/src/solid/skeleton.tsx +15 -0
- package/src/solid/slider.tsx +148 -0
- package/src/solid/sliding-indicator.tsx +294 -0
- package/src/solid/sonner.tsx +217 -0
- package/src/solid/spinner.tsx +20 -0
- package/src/solid/step-indicator.tsx +30 -0
- package/src/solid/switch.tsx +62 -0
- package/src/solid/table.tsx +98 -0
- package/src/solid/tabs.tsx +86 -0
- package/src/solid/textarea.tsx +16 -0
- package/src/solid/toggle-group.tsx +102 -0
- package/src/solid/toggle.tsx +57 -0
- package/src/solid/tooltip.tsx +38 -0
- package/src/solid/widget-card.tsx +117 -0
- package/src/solid/widget-identity.tsx +135 -0
- package/src/solid/widget-trust-badge.tsx +37 -0
- package/src/styles/globals.css +7 -0
- package/src/styles/theme.css +8 -0
- package/src/tokens/hex.ts +50 -0
- package/src/tokens/index.ts +8 -0
- package/src/tokens/presets.ts +192 -0
- package/src/tokens/theme-colors.ts +147 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { useRadioGroupContext } from "@kobalte/core/radio-group";
|
|
2
|
+
import {
|
|
3
|
+
children,
|
|
4
|
+
createContext,
|
|
5
|
+
createSignal,
|
|
6
|
+
type JSX,
|
|
7
|
+
onCleanup,
|
|
8
|
+
onMount,
|
|
9
|
+
Show,
|
|
10
|
+
useContext,
|
|
11
|
+
} from "solid-js";
|
|
12
|
+
import { CARD_SURFACE } from "../lib/card-classes.js";
|
|
13
|
+
import { isNeutralTone, NEUTRAL_KNOBS } from "../lib/glass-tone.js";
|
|
14
|
+
import { STAGGER } from "../lib/motion-classes.js";
|
|
15
|
+
import { cn } from "../lib/utils.js";
|
|
16
|
+
import { Icon } from "./icon.js";
|
|
17
|
+
import { Ornament } from "./ornament.js";
|
|
18
|
+
import { PickerRow } from "./picker-row.js";
|
|
19
|
+
import { RadioGroup, RadioGroupItem } from "./radio-group.js";
|
|
20
|
+
|
|
21
|
+
/* The card is the affordance, so the radio's own control is suppressed and the
|
|
22
|
+
* toned surface plus the check ornament carry the picked state; an accented card keeps its own tone at rest. Tone alone (no
|
|
23
|
+
* .glass-tint) because a card is body copy: .glass-tint would mix the label
|
|
24
|
+
* colour toward the tone, and toward `transparent` while nothing is picked.
|
|
25
|
+
* Padding lives inside the label, not on the item, so the whole card is a
|
|
26
|
+
* click target. */
|
|
27
|
+
const OPTION_CARD_CHROME = `${CARD_SURFACE} group/option-card relative cursor-pointer overflow-hidden rounded-md transition-glass duration-200 hover:[--glass-base:color-mix(in_srgb,var(--card)_80%,transparent)] has-[:focus-visible]:[--glass-edge:var(--ring)] has-[:focus-visible]:ring-[3px] has-[:focus-visible]:ring-ring/50 [&:not([style*=--glass-tone])]:data-[checked]:[--glass-tone:var(--primary)] data-[checked]:[--glass-edge:color-mix(in_srgb,var(--primary)_45%,transparent)] data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`;
|
|
28
|
+
|
|
29
|
+
/* Sub-options live inside the card: the card grows (a grid row morphing
|
|
30
|
+
* 0fr -> 1fr on the morph token) while it is picked, and the content settles
|
|
31
|
+
* in behind the growing edge. Nothing appears below the card. */
|
|
32
|
+
const OPTION_CARD_DRAWER =
|
|
33
|
+
"grid grid-rows-[0fr] transition-[grid-template-rows] duration-(--duration-morph) ease-(--ease-morph) group-data-[checked]/option-card:grid-rows-[1fr]";
|
|
34
|
+
/* Flat: hover is a tint, the current row is the check plus full text colour.
|
|
35
|
+
* The rows start under the title text (card pad + icon + gap, less the row's own pad). */
|
|
36
|
+
const OPTION_CHOICE_ROW =
|
|
37
|
+
"rounded-sm text-foreground/75 transition-colors hover:bg-foreground/5 aria-checked:text-foreground";
|
|
38
|
+
|
|
39
|
+
const OPTION_CARD_DRAWER_CONTENT =
|
|
40
|
+
"-translate-y-2 flex flex-col gap-0.5 pr-1 pb-2 pl-[calc(var(--spacing)*4+20px)] opacity-0 transition-[opacity,translate] duration-(--duration-expand) ease-(--ease-morph) group-data-[checked]/option-card:translate-y-0 group-data-[checked]/option-card:opacity-100 group-data-[checked]/option-card:delay-[80ms]";
|
|
41
|
+
|
|
42
|
+
/* Sub-options are rows of the card, chosen in place: the same row a picker
|
|
43
|
+
* list shows, flat on the card (a glass pill on a glass card is a layer too
|
|
44
|
+
* many), the check and text weight marking the current one. The card owns the
|
|
45
|
+
* value (`subValue` / `onSubChange`); a choice registers so the card knows
|
|
46
|
+
* it has rows to name as a radiogroup. */
|
|
47
|
+
type ChoiceContext = {
|
|
48
|
+
subValue: () => string | undefined;
|
|
49
|
+
pick: (value: string) => void;
|
|
50
|
+
register: (value: string) => () => void;
|
|
51
|
+
};
|
|
52
|
+
const OptionChoiceContext = createContext<ChoiceContext>();
|
|
53
|
+
|
|
54
|
+
export function OptionChoice(props: {
|
|
55
|
+
value: string;
|
|
56
|
+
label: string;
|
|
57
|
+
hint?: string;
|
|
58
|
+
icon?: string;
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
}) {
|
|
61
|
+
const card = useContext(OptionChoiceContext);
|
|
62
|
+
if (!card) throw new Error("OptionChoice renders inside an OptionCard");
|
|
63
|
+
onMount(() => onCleanup(card.register(props.value)));
|
|
64
|
+
const selected = () => card.subValue() === props.value;
|
|
65
|
+
return (
|
|
66
|
+
<PickerRow
|
|
67
|
+
as="button"
|
|
68
|
+
type="button"
|
|
69
|
+
role="radio"
|
|
70
|
+
aria-checked={selected()}
|
|
71
|
+
data-slot="option-choice"
|
|
72
|
+
class={OPTION_CHOICE_ROW}
|
|
73
|
+
disabled={props.disabled}
|
|
74
|
+
icon={props.icon}
|
|
75
|
+
title={props.label}
|
|
76
|
+
subtitle={props.hint}
|
|
77
|
+
selected={selected()}
|
|
78
|
+
multi={false}
|
|
79
|
+
onClick={() => !props.disabled && card.pick(props.value)}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function OptionCardGroup(props: {
|
|
85
|
+
value: string | null;
|
|
86
|
+
onChange: (value: string) => void;
|
|
87
|
+
"aria-label"?: string;
|
|
88
|
+
class?: string;
|
|
89
|
+
children: JSX.Element;
|
|
90
|
+
}) {
|
|
91
|
+
return (
|
|
92
|
+
<RadioGroup
|
|
93
|
+
class={cn("gap-2", props.class)}
|
|
94
|
+
value={props.value ?? undefined}
|
|
95
|
+
onChange={props.onChange}
|
|
96
|
+
aria-label={props["aria-label"]}
|
|
97
|
+
>
|
|
98
|
+
{props.children}
|
|
99
|
+
</RadioGroup>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function OptionCard(props: {
|
|
104
|
+
value: string;
|
|
105
|
+
title: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
icon?: string;
|
|
108
|
+
iconImage?: string;
|
|
109
|
+
/** Per-option tone at rest (setup's brand colours); neutral by default. */
|
|
110
|
+
accentVar?: string;
|
|
111
|
+
/** Drop the check when picking the card is itself the next step. */
|
|
112
|
+
ornament?: "check" | "none";
|
|
113
|
+
/** Fires on every click, including a re-pick of the already-checked card,
|
|
114
|
+
* which the group's `onChange` alone never reports. */
|
|
115
|
+
onPick?: () => void;
|
|
116
|
+
disabled?: boolean;
|
|
117
|
+
class?: string;
|
|
118
|
+
/** The current sub-option (an OptionChoice value). */
|
|
119
|
+
subValue?: string;
|
|
120
|
+
onSubChange?: (value: string) => void;
|
|
121
|
+
/** Sub-options (OptionChoice rows) or a custom body. The card grows to
|
|
122
|
+
* reveal them while it is picked. */
|
|
123
|
+
children?: JSX.Element;
|
|
124
|
+
}) {
|
|
125
|
+
const group = useRadioGroupContext();
|
|
126
|
+
const checked = () => group.isSelectedValue(props.value);
|
|
127
|
+
const [choices, setChoices] = createSignal<string[]>([]);
|
|
128
|
+
const choice: ChoiceContext = {
|
|
129
|
+
subValue: () => props.subValue,
|
|
130
|
+
pick: (value) => props.onSubChange?.(value),
|
|
131
|
+
register: (value) => {
|
|
132
|
+
setChoices((list) => [...list, value]);
|
|
133
|
+
return () => setChoices((list) => list.filter((v) => v !== value));
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
const kids = children(() => (
|
|
137
|
+
<OptionChoiceContext.Provider value={choice}>{props.children}</OptionChoiceContext.Provider>
|
|
138
|
+
));
|
|
139
|
+
return (
|
|
140
|
+
<div
|
|
141
|
+
data-slot="option-card"
|
|
142
|
+
data-checked={checked() ? "" : undefined}
|
|
143
|
+
class={cn(OPTION_CARD_CHROME, isNeutralTone(props.accentVar) && NEUTRAL_KNOBS, props.class)}
|
|
144
|
+
style={
|
|
145
|
+
props.accentVar ? ({ "--glass-tone": props.accentVar } as JSX.CSSProperties) : undefined
|
|
146
|
+
}
|
|
147
|
+
>
|
|
148
|
+
<RadioGroupItem
|
|
149
|
+
value={props.value}
|
|
150
|
+
disabled={props.disabled}
|
|
151
|
+
showControl={false}
|
|
152
|
+
onClick={() => !props.disabled && props.onPick?.()}
|
|
153
|
+
class="relative w-full cursor-pointer overflow-hidden rounded-[inherit] text-left"
|
|
154
|
+
>
|
|
155
|
+
{/* On the header row, not the card: a grown card keeps its rows clear. */}
|
|
156
|
+
<Ornament kind={props.ornament ?? "check"} />
|
|
157
|
+
<div data-slot="option-card-row" class="flex w-full items-start gap-3 p-3">
|
|
158
|
+
<Show when={props.iconImage} fallback={<OptionIcon icon={props.icon} />}>
|
|
159
|
+
{(src) => (
|
|
160
|
+
<img src={src()} alt="" aria-hidden="true" class="size-5 shrink-0 object-contain" />
|
|
161
|
+
)}
|
|
162
|
+
</Show>
|
|
163
|
+
<div class="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
164
|
+
<span data-slot="option-card-title" class="font-medium text-sm leading-snug">
|
|
165
|
+
{props.title}
|
|
166
|
+
</span>
|
|
167
|
+
<Show when={props.description}>
|
|
168
|
+
{(description) => (
|
|
169
|
+
<span
|
|
170
|
+
data-slot="option-card-description"
|
|
171
|
+
class="text-muted-foreground text-sm leading-normal"
|
|
172
|
+
>
|
|
173
|
+
{description()}
|
|
174
|
+
</span>
|
|
175
|
+
)}
|
|
176
|
+
</Show>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
</RadioGroupItem>
|
|
180
|
+
<Show when={kids.toArray().length > 0}>
|
|
181
|
+
<div data-slot="option-card-drawer" class={OPTION_CARD_DRAWER}>
|
|
182
|
+
<div class="min-h-0 overflow-hidden">
|
|
183
|
+
{/* biome-ignore lint/a11y/useAriaPropsSupportedByRole: the role is always radiogroup or group, both take aria-label */}
|
|
184
|
+
<div
|
|
185
|
+
role={choices().length > 0 ? "radiogroup" : "group"}
|
|
186
|
+
aria-label={`${props.title} options`}
|
|
187
|
+
class={OPTION_CARD_DRAWER_CONTENT}
|
|
188
|
+
classList={{ [STAGGER]: checked() }}
|
|
189
|
+
>
|
|
190
|
+
{kids()}
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
</Show>
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* The icon sits on the title line, the mini form of HeroAction's big glyph,
|
|
200
|
+
* in text colour: the tone belongs to the surface and the ornament. */
|
|
201
|
+
function OptionIcon(props: { icon?: string }) {
|
|
202
|
+
return (
|
|
203
|
+
<Show when={props.icon}>
|
|
204
|
+
{(icon) => (
|
|
205
|
+
<Icon
|
|
206
|
+
icon={icon()}
|
|
207
|
+
width={20}
|
|
208
|
+
height={20}
|
|
209
|
+
aria-hidden="true"
|
|
210
|
+
class="mt-px shrink-0 text-muted-foreground"
|
|
211
|
+
/>
|
|
212
|
+
)}
|
|
213
|
+
</Show>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** @deprecated OptionCard carries the same props; HeroOption is an alias. */
|
|
218
|
+
export const HeroOption = OptionCard;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Match, Switch } from "solid-js";
|
|
2
|
+
import { ALERT_ICON_BG_CLASS, alertIconBgStyle, iconBgMaskStyle } from "../lib/alert-tones.js";
|
|
3
|
+
|
|
4
|
+
/* The big glyph bleeding out of a card's lower-right corner (HeroAction,
|
|
5
|
+
* HeroOption, OptionCard). "arrow" is always on, in the card's tone, and
|
|
6
|
+
* nudges on hover; "check" is the selection mark, in the card's tone as
|
|
7
|
+
* well, fading in while an ancestor carries data-checked. Absolutely positioned, a sibling of the
|
|
8
|
+
* card's row, so it never competes for row gap. */
|
|
9
|
+
export function Ornament(props: { kind: "arrow" | "check" | "none" }) {
|
|
10
|
+
return (
|
|
11
|
+
<Switch>
|
|
12
|
+
<Match when={props.kind === "arrow"}>
|
|
13
|
+
<span
|
|
14
|
+
data-slot="ornament-arrow"
|
|
15
|
+
class={`${ALERT_ICON_BG_CLASS} transition-transform duration-(--duration-state) group-hover:translate-x-1`}
|
|
16
|
+
style={alertIconBgStyle("var(--surface-tone)")}
|
|
17
|
+
aria-hidden="true"
|
|
18
|
+
>
|
|
19
|
+
<svg
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
fill="none"
|
|
23
|
+
stroke="currentColor"
|
|
24
|
+
stroke-linecap="round"
|
|
25
|
+
stroke-linejoin="round"
|
|
26
|
+
>
|
|
27
|
+
<path d="M5 12h14" />
|
|
28
|
+
<path d="m12 5 7 7-7 7" />
|
|
29
|
+
</svg>
|
|
30
|
+
</span>
|
|
31
|
+
</Match>
|
|
32
|
+
<Match when={props.kind === "check"}>
|
|
33
|
+
<span
|
|
34
|
+
data-slot="ornament-check"
|
|
35
|
+
class={`${ALERT_ICON_BG_CLASS} opacity-0 transition-opacity duration-(--duration-state) [[data-checked]_&]:opacity-[0.32]`}
|
|
36
|
+
style={iconBgMaskStyle("var(--surface-tone)")}
|
|
37
|
+
aria-hidden="true"
|
|
38
|
+
>
|
|
39
|
+
<svg
|
|
40
|
+
aria-hidden="true"
|
|
41
|
+
viewBox="0 0 24 24"
|
|
42
|
+
fill="none"
|
|
43
|
+
stroke="currentColor"
|
|
44
|
+
stroke-linecap="round"
|
|
45
|
+
stroke-linejoin="round"
|
|
46
|
+
>
|
|
47
|
+
<path d="M20 6 9 17l-5-5" />
|
|
48
|
+
</svg>
|
|
49
|
+
</span>
|
|
50
|
+
</Match>
|
|
51
|
+
</Switch>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
2
|
+
import { OVERLAY_MOTION } from "../lib/motion-classes.js";
|
|
3
|
+
import { FLOATING_PANEL } from "../lib/overlay-classes.js";
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
|
|
6
|
+
/* The floating glass panel material, for custom floating surfaces that are not
|
|
7
|
+
* a Popover/Menu primitive. Radius and motion come from FLOATING_PANEL/
|
|
8
|
+
* OVERLAY_MOTION; caller owns padding and positioning. */
|
|
9
|
+
const Overlay: Component<ComponentProps<"div">> = (props) => {
|
|
10
|
+
const [local, others] = splitProps(props, ["class"]);
|
|
11
|
+
return (
|
|
12
|
+
<div data-slot="overlay" class={cn(FLOATING_PANEL, OVERLAY_MOTION, local.class)} {...others} />
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { Overlay };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type JSX, Show } from "solid-js";
|
|
2
|
+
import { CARD_BLUR, CARD_SURFACE_BASE } from "../lib/card-classes.js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { CountPill } from "./count-pill.js";
|
|
5
|
+
import { Icon } from "./icon.js";
|
|
6
|
+
import { type GlassSurface, NOOP_GLASS } from "./section-card.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Page banner header, shared by dash and hub: the card surface with a primary
|
|
10
|
+
* glow and an optional logo watermark. Content is a superset API: icon/iconNode
|
|
11
|
+
* + title + count pill + subtitle on the left, actions on the right. The caller
|
|
12
|
+
* owns the space around it.
|
|
13
|
+
*
|
|
14
|
+
* `glass` is dash's performant-blur injection (like SectionCard); omit (hub) for
|
|
15
|
+
* a normal frosted banner. `logo` is the watermark image src; omit for no
|
|
16
|
+
* watermark (the package ships no asset).
|
|
17
|
+
*/
|
|
18
|
+
export function PageHeader(props: {
|
|
19
|
+
/** Iconify icon name for the banner glyph. */
|
|
20
|
+
icon?: string;
|
|
21
|
+
/** Custom glyph, overrides `icon`. */
|
|
22
|
+
iconNode?: JSX.Element;
|
|
23
|
+
title: JSX.Element;
|
|
24
|
+
subtitle?: JSX.Element;
|
|
25
|
+
/** Small count pill next to the title. Rendered only when not null/undefined. */
|
|
26
|
+
count?: number | string;
|
|
27
|
+
/** Right-side actions. */
|
|
28
|
+
actions?: JSX.Element;
|
|
29
|
+
/** Watermark image src (e.g. the app logo). Omit for no watermark. */
|
|
30
|
+
logo?: string;
|
|
31
|
+
/** Performant-blur injection (dash). Omit for a normal frosted banner. */
|
|
32
|
+
glass?: GlassSurface;
|
|
33
|
+
}) {
|
|
34
|
+
const glass = () => props.glass ?? NOOP_GLASS;
|
|
35
|
+
return (
|
|
36
|
+
<div
|
|
37
|
+
data-slot="page-header"
|
|
38
|
+
ref={glass().ref}
|
|
39
|
+
class={cn(CARD_SURFACE_BASE, "relative overflow-hidden rounded-xl")}
|
|
40
|
+
classList={{ [CARD_BLUR]: !(glass().active?.() ?? false) }}
|
|
41
|
+
style={glass().style?.() ?? {}}
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
data-slot="page-header-glow"
|
|
45
|
+
class="pointer-events-none absolute top-0 left-0 h-48 w-72 -translate-x-1/3 -translate-y-1/2 rounded-full bg-primary/15 blur-3xl"
|
|
46
|
+
/>
|
|
47
|
+
<Show when={props.logo}>
|
|
48
|
+
{(logo) => (
|
|
49
|
+
<img
|
|
50
|
+
data-slot="page-header-watermark"
|
|
51
|
+
src={logo()}
|
|
52
|
+
alt=""
|
|
53
|
+
class="pointer-events-none absolute -top-4 -right-8 size-48 rotate-[14deg] opacity-[0.13] [mask-image:radial-gradient(circle_at_70%_30%,black,transparent_80%)]"
|
|
54
|
+
/>
|
|
55
|
+
)}
|
|
56
|
+
</Show>
|
|
57
|
+
<div
|
|
58
|
+
data-slot="page-header-row"
|
|
59
|
+
class="relative flex min-h-[64px] items-center gap-2.5 px-4 py-3 sm:min-h-[80px] sm:gap-4 sm:px-6 sm:py-5"
|
|
60
|
+
>
|
|
61
|
+
<Show
|
|
62
|
+
when={props.iconNode}
|
|
63
|
+
fallback={
|
|
64
|
+
<Show when={props.icon}>
|
|
65
|
+
{(icon) => (
|
|
66
|
+
<Icon icon={icon()} class="shrink-0 text-[28px] text-primary sm:text-[32px]" />
|
|
67
|
+
)}
|
|
68
|
+
</Show>
|
|
69
|
+
}
|
|
70
|
+
>
|
|
71
|
+
{props.iconNode}
|
|
72
|
+
</Show>
|
|
73
|
+
<div data-slot="page-header-headings" class="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
74
|
+
<div data-slot="page-header-headline" class="flex min-w-0 items-center gap-2 sm:gap-3">
|
|
75
|
+
<h1
|
|
76
|
+
data-slot="page-header-title"
|
|
77
|
+
class="min-w-0 truncate font-bold text-foreground text-xl tracking-[-0.02em] sm:text-2xl"
|
|
78
|
+
>
|
|
79
|
+
{props.title}
|
|
80
|
+
</h1>
|
|
81
|
+
<Show when={props.count != null}>
|
|
82
|
+
<CountPill>{props.count}</CountPill>
|
|
83
|
+
</Show>
|
|
84
|
+
</div>
|
|
85
|
+
<Show when={props.subtitle}>
|
|
86
|
+
<div
|
|
87
|
+
data-slot="page-header-subtitle"
|
|
88
|
+
class="flex items-center gap-2 text-muted-foreground text-sm"
|
|
89
|
+
>
|
|
90
|
+
{props.subtitle}
|
|
91
|
+
</div>
|
|
92
|
+
</Show>
|
|
93
|
+
</div>
|
|
94
|
+
<Show when={props.actions}>
|
|
95
|
+
<div data-slot="page-header-actions" class="flex shrink-0 items-center gap-2">
|
|
96
|
+
{props.actions}
|
|
97
|
+
</div>
|
|
98
|
+
</Show>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { buttonVariants } from "./button.js";
|
|
4
|
+
import { Icon } from "./icon.js";
|
|
5
|
+
|
|
6
|
+
const Pagination: Component<ComponentProps<"nav">> = (props) => {
|
|
7
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
8
|
+
return (
|
|
9
|
+
<nav
|
|
10
|
+
aria-label="pagination"
|
|
11
|
+
data-slot="pagination"
|
|
12
|
+
class={cn("mx-auto flex w-full justify-center", local.class)}
|
|
13
|
+
{...rest}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const PaginationContent: Component<ComponentProps<"ul">> = (props) => {
|
|
19
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
20
|
+
return (
|
|
21
|
+
<ul
|
|
22
|
+
data-slot="pagination-content"
|
|
23
|
+
class={cn("flex flex-row items-center gap-1", local.class)}
|
|
24
|
+
{...rest}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const PaginationItem: Component<ComponentProps<"li">> = (props) => {
|
|
30
|
+
return <li data-slot="pagination-item" {...props} />;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type PaginationLinkProps = ComponentProps<"a"> & {
|
|
34
|
+
isActive?: boolean;
|
|
35
|
+
size?: "default" | "sm" | "lg" | "icon";
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const PaginationLink: Component<PaginationLinkProps> = (props) => {
|
|
39
|
+
const [local, rest] = splitProps(props, ["class", "isActive", "size"]);
|
|
40
|
+
const size = () => local.size ?? "icon";
|
|
41
|
+
return (
|
|
42
|
+
<a
|
|
43
|
+
aria-current={local.isActive ? "page" : undefined}
|
|
44
|
+
data-slot="pagination-link"
|
|
45
|
+
data-active={local.isActive}
|
|
46
|
+
class={cn(
|
|
47
|
+
buttonVariants({
|
|
48
|
+
variant: local.isActive ? "outline" : "ghost",
|
|
49
|
+
size: size(),
|
|
50
|
+
}),
|
|
51
|
+
local.class,
|
|
52
|
+
)}
|
|
53
|
+
{...rest}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const PaginationPrevious: Component<PaginationLinkProps> = (props) => {
|
|
59
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
60
|
+
return (
|
|
61
|
+
<PaginationLink
|
|
62
|
+
aria-label="Go to previous page"
|
|
63
|
+
size="default"
|
|
64
|
+
class={cn("gap-1 px-2.5 sm:pl-2.5", local.class)}
|
|
65
|
+
{...rest}
|
|
66
|
+
>
|
|
67
|
+
<Icon icon="lucide:chevron-left" width={16} height={16} />
|
|
68
|
+
<span class="hidden sm:block">Previous</span>
|
|
69
|
+
</PaginationLink>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const PaginationNext: Component<PaginationLinkProps> = (props) => {
|
|
74
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
75
|
+
return (
|
|
76
|
+
<PaginationLink
|
|
77
|
+
aria-label="Go to next page"
|
|
78
|
+
size="default"
|
|
79
|
+
class={cn("gap-1 px-2.5 sm:pr-2.5", local.class)}
|
|
80
|
+
{...rest}
|
|
81
|
+
>
|
|
82
|
+
<span class="hidden sm:block">Next</span>
|
|
83
|
+
<Icon icon="lucide:chevron-right" width={16} height={16} />
|
|
84
|
+
</PaginationLink>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const PaginationEllipsis: Component<ComponentProps<"span">> = (props) => {
|
|
89
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
90
|
+
return (
|
|
91
|
+
<span
|
|
92
|
+
aria-hidden
|
|
93
|
+
data-slot="pagination-ellipsis"
|
|
94
|
+
class={cn("flex size-9 items-center justify-center", local.class)}
|
|
95
|
+
{...rest}
|
|
96
|
+
>
|
|
97
|
+
<Icon icon="lucide:ellipsis" width={16} height={16} class="size-4" />
|
|
98
|
+
<span class="sr-only">More pages</span>
|
|
99
|
+
</span>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
Pagination,
|
|
105
|
+
PaginationContent,
|
|
106
|
+
PaginationEllipsis,
|
|
107
|
+
PaginationItem,
|
|
108
|
+
PaginationLink,
|
|
109
|
+
PaginationNext,
|
|
110
|
+
PaginationPrevious,
|
|
111
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Component,
|
|
3
|
+
type ComponentProps,
|
|
4
|
+
createSignal,
|
|
5
|
+
type JSX,
|
|
6
|
+
Show,
|
|
7
|
+
splitProps,
|
|
8
|
+
} from "solid-js";
|
|
9
|
+
import { cn } from "../lib/utils.js";
|
|
10
|
+
import { Icon } from "./icon.js";
|
|
11
|
+
import { Input } from "./input.js";
|
|
12
|
+
|
|
13
|
+
/* Both affordances sit absolutely over the field, so their icons never reprint
|
|
14
|
+
* layout; each is one w-10 column and the input reserves exactly that. */
|
|
15
|
+
const AFFORDANCE_COLUMN = "w-10";
|
|
16
|
+
const LEADING_RESERVE = "pl-10";
|
|
17
|
+
const TOGGLE_RESERVE = "pr-10";
|
|
18
|
+
|
|
19
|
+
const PasswordInput: Component<
|
|
20
|
+
Omit<ComponentProps<typeof Input>, "type"> & {
|
|
21
|
+
/** Rendered left-aligned inside the field (e.g. a lock glyph). */
|
|
22
|
+
leading?: JSX.Element;
|
|
23
|
+
showLabel?: string;
|
|
24
|
+
hideLabel?: string;
|
|
25
|
+
}
|
|
26
|
+
> = (props) => {
|
|
27
|
+
const [local, rest] = splitProps(props, ["class", "leading", "showLabel", "hideLabel"]);
|
|
28
|
+
const [visible, setVisible] = createSignal(false);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div data-slot="password-input" class="relative">
|
|
32
|
+
<Show when={local.leading}>
|
|
33
|
+
<span
|
|
34
|
+
data-slot="password-input-leading"
|
|
35
|
+
class={cn(
|
|
36
|
+
"pointer-events-none absolute inset-y-0 left-0 z-10 flex items-center justify-center text-primary/70",
|
|
37
|
+
AFFORDANCE_COLUMN,
|
|
38
|
+
)}
|
|
39
|
+
aria-hidden="true"
|
|
40
|
+
>
|
|
41
|
+
{local.leading}
|
|
42
|
+
</span>
|
|
43
|
+
</Show>
|
|
44
|
+
<Input
|
|
45
|
+
type={visible() ? "text" : "password"}
|
|
46
|
+
// Caller class first, affordance padding last: a caller-supplied px-*
|
|
47
|
+
// must never win the merge and reclaim a button's space.
|
|
48
|
+
class={cn(local.class, local.leading && LEADING_RESERVE, TOGGLE_RESERVE)}
|
|
49
|
+
{...rest}
|
|
50
|
+
/>
|
|
51
|
+
<button
|
|
52
|
+
type="button"
|
|
53
|
+
data-slot="password-input-toggle"
|
|
54
|
+
aria-label={
|
|
55
|
+
visible() ? (local.hideLabel ?? "Hide password") : (local.showLabel ?? "Show password")
|
|
56
|
+
}
|
|
57
|
+
onClick={() => setVisible((v) => !v)}
|
|
58
|
+
class={cn(
|
|
59
|
+
"absolute inset-y-0 right-0 z-10 flex items-center justify-center text-muted-foreground/70 transition-colors hover:text-foreground",
|
|
60
|
+
AFFORDANCE_COLUMN,
|
|
61
|
+
)}
|
|
62
|
+
>
|
|
63
|
+
<Icon icon={visible() ? "lucide:eye-off" : "lucide:eye"} width={20} aria-hidden="true" />
|
|
64
|
+
</button>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { PasswordInput };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type ComponentProps, type JSX, Show, splitProps, type ValidComponent } from "solid-js";
|
|
2
|
+
import { Dynamic } from "solid-js/web";
|
|
3
|
+
import { MENU_ITEM } from "../lib/menu-classes.js";
|
|
4
|
+
import { ICON_PILL, ICON_PILL_TINT } from "../lib/pill-classes.js";
|
|
5
|
+
import { cn } from "../lib/utils.js";
|
|
6
|
+
import { Checkbox } from "./checkbox.js";
|
|
7
|
+
import { Icon } from "./icon.js";
|
|
8
|
+
|
|
9
|
+
/* One row for every picker that lists things with an icon (entities, areas):
|
|
10
|
+
* icon well, title over a muted line, optional meta, and the selection
|
|
11
|
+
* control (a presentation-only Checkbox when picking many, a check when
|
|
12
|
+
* picking one). The row owns the click; the control never does. */
|
|
13
|
+
export const PICKER_ROW_HEIGHT = 52;
|
|
14
|
+
|
|
15
|
+
type PickerRowProps = Omit<ComponentProps<"button">, "title"> & {
|
|
16
|
+
as?: ValidComponent;
|
|
17
|
+
icon?: string;
|
|
18
|
+
title: JSX.Element;
|
|
19
|
+
subtitle?: JSX.Element;
|
|
20
|
+
meta?: JSX.Element;
|
|
21
|
+
selected: boolean;
|
|
22
|
+
multi: boolean;
|
|
23
|
+
dimmed?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function PickerRow(props: PickerRowProps) {
|
|
27
|
+
const [local, rest] = splitProps(props, [
|
|
28
|
+
"as",
|
|
29
|
+
"icon",
|
|
30
|
+
"title",
|
|
31
|
+
"subtitle",
|
|
32
|
+
"meta",
|
|
33
|
+
"selected",
|
|
34
|
+
"multi",
|
|
35
|
+
"dimmed",
|
|
36
|
+
"class",
|
|
37
|
+
]);
|
|
38
|
+
return (
|
|
39
|
+
<Dynamic
|
|
40
|
+
component={local.as ?? "div"}
|
|
41
|
+
class={cn(
|
|
42
|
+
MENU_ITEM,
|
|
43
|
+
"w-full cursor-pointer gap-3 py-0 text-left",
|
|
44
|
+
local.selected && "text-foreground",
|
|
45
|
+
local.class,
|
|
46
|
+
)}
|
|
47
|
+
style={{ "min-height": `${PICKER_ROW_HEIGHT}px` }}
|
|
48
|
+
{...rest}
|
|
49
|
+
>
|
|
50
|
+
<Show when={local.icon}>
|
|
51
|
+
{(icon) => (
|
|
52
|
+
<div
|
|
53
|
+
class={cn(
|
|
54
|
+
"size-8 rounded-lg",
|
|
55
|
+
local.selected
|
|
56
|
+
? `${ICON_PILL_TINT} text-foreground [--glass-tone:var(--primary)]`
|
|
57
|
+
: ICON_PILL,
|
|
58
|
+
local.dimmed && "opacity-50",
|
|
59
|
+
)}
|
|
60
|
+
>
|
|
61
|
+
<Icon icon={icon()} width={18} height={18} />
|
|
62
|
+
</div>
|
|
63
|
+
)}
|
|
64
|
+
</Show>
|
|
65
|
+
<div class={cn("min-w-0 flex-1", local.dimmed && "opacity-60")}>
|
|
66
|
+
<div class="truncate font-medium">{local.title}</div>
|
|
67
|
+
<Show when={local.subtitle}>
|
|
68
|
+
<div class="truncate text-muted-foreground text-xs">{local.subtitle}</div>
|
|
69
|
+
</Show>
|
|
70
|
+
</div>
|
|
71
|
+
<Show when={local.meta}>
|
|
72
|
+
<span
|
|
73
|
+
class={cn(
|
|
74
|
+
"max-w-24 shrink-0 truncate text-muted-foreground text-xs",
|
|
75
|
+
local.dimmed && "italic",
|
|
76
|
+
)}
|
|
77
|
+
>
|
|
78
|
+
{local.meta}
|
|
79
|
+
</span>
|
|
80
|
+
</Show>
|
|
81
|
+
<Show
|
|
82
|
+
when={local.multi}
|
|
83
|
+
fallback={
|
|
84
|
+
<div class="flex size-4 shrink-0 items-center justify-center">
|
|
85
|
+
<Show when={local.selected}>
|
|
86
|
+
<Icon icon="lucide:check" width={16} height={16} class="text-primary" />
|
|
87
|
+
</Show>
|
|
88
|
+
</div>
|
|
89
|
+
}
|
|
90
|
+
>
|
|
91
|
+
<div aria-hidden="true" class="pointer-events-none shrink-0">
|
|
92
|
+
<Checkbox
|
|
93
|
+
checked={local.selected}
|
|
94
|
+
disabled
|
|
95
|
+
size="sm"
|
|
96
|
+
class="cursor-pointer opacity-100"
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
</Show>
|
|
100
|
+
</Dynamic>
|
|
101
|
+
);
|
|
102
|
+
}
|