@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/dock.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
type Component,
|
|
3
|
+
type ComponentProps,
|
|
4
|
+
createEffect,
|
|
5
|
+
createMemo,
|
|
6
|
+
createSignal,
|
|
7
|
+
Index,
|
|
8
|
+
type JSX,
|
|
9
|
+
on,
|
|
10
|
+
onCleanup,
|
|
11
|
+
onMount,
|
|
12
|
+
Show,
|
|
13
|
+
splitProps,
|
|
14
14
|
} from "solid-js";
|
|
15
15
|
import { Dynamic } from "solid-js/web";
|
|
16
16
|
import { CARD_SURFACE } from "../lib/card-classes.js";
|
|
@@ -22,357 +22,357 @@ import { SlidingIndicator } from "./sliding-indicator.js";
|
|
|
22
22
|
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
23
23
|
|
|
24
24
|
interface DockItem {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
id: string;
|
|
26
|
+
icon: Component<{ class?: string }> | JSX.Element;
|
|
27
|
+
label: string;
|
|
28
|
+
onClick?: () => void;
|
|
29
|
+
isActive?: boolean;
|
|
30
|
+
/** Optional count badge on the item (e.g. pending updates). */
|
|
31
|
+
badge?: number;
|
|
32
|
+
/** Something dragged is held over this item and will land here on release. */
|
|
33
|
+
isDropTarget?: boolean;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
interface DockProps extends ComponentProps<"div"> {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
items: DockItem[];
|
|
38
|
+
dockMode?: "floating" | "docked";
|
|
39
|
+
/** Where a hold started, relative to the surface; `fired` once it has triggered. */
|
|
40
|
+
hold?: { x: number; y: number; fired: boolean } | null;
|
|
41
|
+
/** A rim light that orbits for as long as a mode is on. */
|
|
42
|
+
glow?: boolean;
|
|
43
|
+
/** Where a drag from outside the dock is pointing, in client coordinates. */
|
|
44
|
+
dragPoint?: { x: number; y: number } | null;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
interface DockIconButtonProps extends ComponentProps<"button"> {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
icon: Component<{ class?: string }> | JSX.Element;
|
|
49
|
+
label: string;
|
|
50
|
+
isActive?: boolean;
|
|
51
|
+
/** Sits on the sliding pill: the active item, or the one a drag would land on. */
|
|
52
|
+
lit?: boolean;
|
|
53
|
+
badge?: number;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const DockIconButton: Component<DockIconButtonProps> = (props) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
// Kobalte's button root narrows `type`; Solid's ComponentProps<"button"> also
|
|
58
|
+
// admits "menu", so it is split off rather than spread.
|
|
59
|
+
const [local, rest] = splitProps(props, [
|
|
60
|
+
"icon",
|
|
61
|
+
"label",
|
|
62
|
+
"class",
|
|
63
|
+
"isActive",
|
|
64
|
+
"badge",
|
|
65
|
+
"type",
|
|
66
|
+
"lit",
|
|
67
|
+
]);
|
|
68
|
+
const isElement = () => typeof local.icon !== "function";
|
|
69
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
|
-
|
|
70
|
+
return (
|
|
71
|
+
<Tooltip openDelay={150} placement="top">
|
|
72
|
+
<TooltipTrigger
|
|
73
|
+
type="button"
|
|
74
|
+
data-slot="dock-item"
|
|
75
|
+
class={cn(
|
|
76
|
+
"group relative flex size-11 touch-manipulation items-center justify-center rounded-lg transition-transform duration-(--duration-micro) sm:size-12",
|
|
77
|
+
PRESS_DIP,
|
|
78
|
+
local.class,
|
|
79
|
+
)}
|
|
80
|
+
aria-label={local.label}
|
|
81
|
+
aria-current={local.isActive ? "page" : undefined}
|
|
82
|
+
{...rest}
|
|
83
|
+
>
|
|
84
|
+
<div
|
|
85
|
+
data-slot="dock-item-icon"
|
|
86
|
+
class={cn(
|
|
87
|
+
"flex items-center justify-center transition-colors duration-(--duration-state)",
|
|
88
|
+
local.lit ? "text-primary" : "text-foreground group-hover:text-primary/80",
|
|
89
|
+
)}
|
|
90
|
+
>
|
|
91
|
+
{isElement() ? (
|
|
92
|
+
(local.icon as JSX.Element)
|
|
93
|
+
) : (
|
|
94
|
+
<Dynamic
|
|
95
|
+
component={local.icon as Component<{ class?: string }>}
|
|
96
|
+
class="h-5 w-5 sm:h-6 sm:w-6"
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
99
|
+
</div>
|
|
100
|
+
<Show when={typeof local.badge === "number" && local.badge > 0}>
|
|
101
|
+
{/* Inside the item box: an overhanging badge inflates the bar's
|
|
102
|
+
* scrollWidth and trips the overflow-to-scroll check below. */}
|
|
103
|
+
<Badge
|
|
104
|
+
role="status"
|
|
105
|
+
tone="var(--primary)"
|
|
106
|
+
class="absolute top-0 right-0 h-4 min-w-4 justify-center px-1 pt-0.5 pb-0 font-mono text-[9px] leading-none font-medium tabular-nums"
|
|
107
|
+
aria-label={`${local.badge} pending`}
|
|
108
|
+
>
|
|
109
|
+
{local.badge != null && local.badge > 9 ? "9+" : local.badge}
|
|
110
|
+
</Badge>
|
|
111
|
+
</Show>
|
|
112
|
+
</TooltipTrigger>
|
|
113
|
+
<TooltipContent class="hidden sm:block">{local.label}</TooltipContent>
|
|
114
|
+
</Tooltip>
|
|
115
|
+
);
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
const Dock: Component<DockProps> = (props) => {
|
|
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
|
-
|
|
119
|
+
const [local, rest] = splitProps(props, [
|
|
120
|
+
"items",
|
|
121
|
+
"class",
|
|
122
|
+
"dockMode",
|
|
123
|
+
"hold",
|
|
124
|
+
"glow",
|
|
125
|
+
"dragPoint",
|
|
126
|
+
]);
|
|
127
|
+
// The drain plays where the fill grew, so the point outlives the hold.
|
|
128
|
+
const [holdPoint, setHoldPoint] = createSignal({ x: 0, y: 0, r: 0 });
|
|
129
|
+
let surfaceRef: HTMLDivElement | undefined;
|
|
130
|
+
createEffect(() => {
|
|
131
|
+
const h = local.hold;
|
|
132
|
+
if (!h) return;
|
|
133
|
+
const w = surfaceRef?.clientWidth ?? 0;
|
|
134
|
+
const ht = surfaceRef?.clientHeight ?? 0;
|
|
135
|
+
// Reaches the farthest corner exactly at full scale, so the fill ends as the hold does.
|
|
136
|
+
setHoldPoint({
|
|
137
|
+
x: h.x,
|
|
138
|
+
y: h.y,
|
|
139
|
+
r: Math.hypot(Math.max(h.x, w - h.x), Math.max(h.y, ht - h.y)),
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
const dockMode = () => local.dockMode ?? "floating";
|
|
143
|
+
let containerRef!: HTMLDivElement;
|
|
144
|
+
const [needsScroll, setNeedsScroll] = createSignal(false);
|
|
145
|
+
const [pages, setPages] = createSignal(1);
|
|
146
|
+
const [page, setPage] = createSignal(0);
|
|
147
|
+
const [viewportWidth, setViewportWidth] = createSignal(0);
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
149
|
+
// The moving background: the shared SlidingIndicator tracks the active item.
|
|
150
|
+
// A memo: the items list is rebuilt on every hover change, and only a new active item may scroll the strip.
|
|
151
|
+
const activeIndex = createMemo(() => {
|
|
152
|
+
const i = local.items.findIndex((it) => it.isActive);
|
|
153
|
+
return i < 0 ? null : i;
|
|
154
|
+
});
|
|
155
|
+
// A drag borrows the pill: it slides to where the drop would land and back when the drag leaves.
|
|
156
|
+
const pillIndex = createMemo(() => {
|
|
157
|
+
const i = local.items.findIndex((it) => it.isDropTarget);
|
|
158
|
+
return i < 0 ? activeIndex() : i;
|
|
159
|
+
});
|
|
160
160
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
const gapWidth = () =>
|
|
162
|
+
containerRef ? Number.parseFloat(getComputedStyle(containerRef).columnGap) || 0 : 0;
|
|
163
|
+
const itemWidth = () =>
|
|
164
|
+
containerRef?.querySelector('[data-slot="dock-item"]')?.getBoundingClientRect().width ?? 0;
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
166
|
+
const padX = (el: Element) => {
|
|
167
|
+
const style = getComputedStyle(el);
|
|
168
|
+
return (
|
|
169
|
+
(Number.parseFloat(style.paddingLeft) || 0) + (Number.parseFloat(style.paddingRight) || 0)
|
|
170
|
+
);
|
|
171
|
+
};
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
173
|
+
// The width the app gave the dock. Never the surface: it shrink-wraps this strip,
|
|
174
|
+
// so measuring it asks the strip how wide the strip is.
|
|
175
|
+
const availableWidth = () => {
|
|
176
|
+
const box = containerRef?.closest<HTMLElement>('[data-slot="dock"]');
|
|
177
|
+
if (!box || !surfaceRef) return 0;
|
|
178
|
+
return box.clientWidth - padX(box) - padX(surfaceRef);
|
|
179
|
+
};
|
|
180
180
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
181
|
+
const checkOverflow = () => {
|
|
182
|
+
if (!containerRef) return;
|
|
183
|
+
const available = availableWidth();
|
|
184
|
+
const overflowing = available > 0 && containerRef.scrollWidth > available + 1;
|
|
185
|
+
if (overflowing) {
|
|
186
|
+
const trimmed = stripWidth(available, itemWidth(), gapWidth());
|
|
187
|
+
if (trimmed > 0) containerRef.style.width = `${trimmed}px`;
|
|
188
|
+
} else if (containerRef.style.width) {
|
|
189
|
+
containerRef.style.width = "";
|
|
190
|
+
}
|
|
191
|
+
setNeedsScroll(overflowing);
|
|
192
|
+
const viewport = containerRef.clientWidth;
|
|
193
|
+
setViewportWidth(viewport);
|
|
194
|
+
setPages(pageCount(containerRef.scrollWidth, viewport));
|
|
195
|
+
setPage(pageOf(containerRef.scrollLeft, viewport));
|
|
196
|
+
};
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
198
|
+
const goToPage = (next: number) => {
|
|
199
|
+
if (!containerRef) return;
|
|
200
|
+
containerRef.scrollTo({
|
|
201
|
+
left: pageOffset(next, viewportWidth(), containerRef.scrollWidth),
|
|
202
|
+
behavior: "smooth",
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
206
|
+
// A drag cannot click a page dot, so resting on the dot row turns to the page under it.
|
|
207
|
+
createEffect(() => {
|
|
208
|
+
const point = local.dragPoint;
|
|
209
|
+
if (!point || pages() < 2 || !surfaceRef || !containerRef) return;
|
|
210
|
+
const strip = containerRef.getBoundingClientRect();
|
|
211
|
+
const surface = surfaceRef.getBoundingClientRect();
|
|
212
|
+
const onDotRow =
|
|
213
|
+
point.y > strip.bottom &&
|
|
214
|
+
point.y <= surface.bottom &&
|
|
215
|
+
point.x >= surface.left &&
|
|
216
|
+
point.x <= surface.right;
|
|
217
|
+
if (!onDotRow) return;
|
|
218
|
+
const target = Math.min(
|
|
219
|
+
pages() - 1,
|
|
220
|
+
Math.floor(((point.x - surface.left) / surface.width) * pages()),
|
|
221
|
+
);
|
|
222
|
+
if (target === page()) return;
|
|
223
|
+
const timer = setTimeout(() => goToPage(target), 300);
|
|
224
|
+
onCleanup(() => clearTimeout(timer));
|
|
225
|
+
});
|
|
226
226
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
227
|
+
// The active dashboard may sit on another page after a switch elsewhere.
|
|
228
|
+
createEffect(() => {
|
|
229
|
+
const i = activeIndex();
|
|
230
|
+
if (i === null || !containerRef || !needsScroll()) return;
|
|
231
|
+
const item = containerRef.querySelectorAll('[data-slot="dock-item"]')[i];
|
|
232
|
+
if (!item || viewportWidth() <= 0) return;
|
|
233
|
+
// The strip only: scrollIntoView would also scroll the page and any frame embedding it.
|
|
234
|
+
const left =
|
|
235
|
+
item.getBoundingClientRect().left -
|
|
236
|
+
containerRef.getBoundingClientRect().left +
|
|
237
|
+
containerRef.scrollLeft;
|
|
238
|
+
goToPage(Math.floor(left / viewportWidth()));
|
|
239
|
+
});
|
|
240
240
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
241
|
+
// Measured in the next frame's callbacks, which run before it paints: the first
|
|
242
|
+
// dock anyone sees already has its pages, so the dot row never shifts it later.
|
|
243
|
+
onMount(() => {
|
|
244
|
+
let resizeFrame = 0;
|
|
245
|
+
const onResize = () => {
|
|
246
|
+
cancelAnimationFrame(resizeFrame);
|
|
247
|
+
resizeFrame = requestAnimationFrame(checkOverflow);
|
|
248
|
+
};
|
|
249
|
+
window.addEventListener("resize", onResize);
|
|
250
|
+
onCleanup(() => {
|
|
251
|
+
cancelAnimationFrame(resizeFrame);
|
|
252
|
+
window.removeEventListener("resize", onResize);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
255
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
256
|
+
// The box pads by mode, so switching it changes the room the strip has.
|
|
257
|
+
createEffect(
|
|
258
|
+
on([() => local.items.length, dockMode], () => {
|
|
259
|
+
const frame = requestAnimationFrame(checkOverflow);
|
|
260
|
+
onCleanup(() => cancelAnimationFrame(frame));
|
|
261
|
+
}),
|
|
262
|
+
);
|
|
263
263
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
264
|
+
return (
|
|
265
|
+
<div
|
|
266
|
+
data-slot="dock"
|
|
267
|
+
class={cn(
|
|
268
|
+
"flex max-w-full items-center justify-center",
|
|
269
|
+
dockMode() === "floating" ? "p-1 sm:p-2" : "",
|
|
270
|
+
local.class,
|
|
271
|
+
)}
|
|
272
|
+
{...rest}
|
|
273
|
+
>
|
|
274
|
+
<div
|
|
275
|
+
ref={surfaceRef}
|
|
276
|
+
data-slot="dock-surface"
|
|
277
|
+
class={cn(
|
|
278
|
+
// isolate: the layers behind the icons stay inside the dock even with blur off.
|
|
279
|
+
"pointer-events-auto relative isolate flex max-w-full items-center justify-center p-1.5 sm:p-2",
|
|
280
|
+
// Room for the page dots inside the glass; outside it they sit on
|
|
281
|
+
// the screen edge and get clipped.
|
|
282
|
+
pages() > 1 && "pb-4 sm:pb-5",
|
|
283
|
+
CARD_SURFACE,
|
|
284
|
+
"[--glass-lift:0.55]",
|
|
285
|
+
dockMode() === "floating" ? "rounded-xl" : "rounded-t-xl",
|
|
286
|
+
)}
|
|
287
|
+
>
|
|
288
|
+
<div
|
|
289
|
+
aria-hidden="true"
|
|
290
|
+
class="pointer-events-none absolute inset-0 -z-10 overflow-hidden rounded-[inherit]"
|
|
291
|
+
>
|
|
292
|
+
<span
|
|
293
|
+
data-slot="dock-flood"
|
|
294
|
+
data-hold={local.hold && !local.hold.fired ? "" : undefined}
|
|
295
|
+
data-fired={local.hold?.fired ? "" : undefined}
|
|
296
|
+
class={cn(
|
|
297
|
+
"bg-primary/45 absolute -translate-x-1/2 -translate-y-1/2 rounded-full",
|
|
298
|
+
HOLD_MOTION,
|
|
299
|
+
)}
|
|
300
|
+
style={{
|
|
301
|
+
left: `${holdPoint().x}px`,
|
|
302
|
+
top: `${holdPoint().y}px`,
|
|
303
|
+
width: `${holdPoint().r * 2}px`,
|
|
304
|
+
height: `${holdPoint().r * 2}px`,
|
|
305
|
+
}}
|
|
306
|
+
/>
|
|
307
|
+
</div>
|
|
308
|
+
<Show when={local.glow}>
|
|
309
|
+
<div
|
|
310
|
+
data-slot="dock-glow"
|
|
311
|
+
aria-hidden="true"
|
|
312
|
+
class="glass-edge-orbit fade-in-0 animate-in duration-(--duration-state)"
|
|
313
|
+
>
|
|
314
|
+
<div />
|
|
315
|
+
</div>
|
|
316
|
+
</Show>
|
|
317
|
+
<div
|
|
318
|
+
ref={containerRef}
|
|
319
|
+
data-slot="dock-bar"
|
|
320
|
+
onScroll={() => {
|
|
321
|
+
if (containerRef) setPage(pageOf(containerRef.scrollLeft, viewportWidth()));
|
|
322
|
+
}}
|
|
323
|
+
class={cn(
|
|
324
|
+
"flex items-center gap-0.5 sm:gap-1",
|
|
325
|
+
needsScroll()
|
|
326
|
+
? "scrollbar-hide snap-x snap-mandatory overflow-x-auto overscroll-x-contain scroll-smooth"
|
|
327
|
+
: "overflow-visible",
|
|
328
|
+
!needsScroll() && "justify-center",
|
|
329
|
+
)}
|
|
330
|
+
style={{
|
|
331
|
+
"min-width": needsScroll() ? "auto" : "fit-content",
|
|
332
|
+
}}
|
|
333
|
+
>
|
|
334
|
+
<SlidingIndicator active={pillIndex()} class="flex items-center gap-0.5 sm:gap-1">
|
|
335
|
+
<Index each={local.items}>
|
|
336
|
+
{(item, i) => (
|
|
337
|
+
<DockIconButton
|
|
338
|
+
class={needsScroll() ? "snap-start" : undefined}
|
|
339
|
+
icon={item().icon}
|
|
340
|
+
label={item().label}
|
|
341
|
+
onClick={item().onClick}
|
|
342
|
+
isActive={item().isActive}
|
|
343
|
+
lit={i === pillIndex()}
|
|
344
|
+
badge={item().badge}
|
|
345
|
+
data-drop-target={item().isDropTarget ? "" : undefined}
|
|
346
|
+
data-dock-id={item().id}
|
|
347
|
+
/>
|
|
348
|
+
)}
|
|
349
|
+
</Index>
|
|
350
|
+
</SlidingIndicator>
|
|
351
|
+
</div>
|
|
352
|
+
<Show when={pages() > 1}>
|
|
353
|
+
<div
|
|
354
|
+
data-slot="dock-pages"
|
|
355
|
+
class="pointer-events-auto absolute inset-x-0 bottom-1.5 flex justify-center gap-1.5"
|
|
356
|
+
>
|
|
357
|
+
<Index each={Array.from({ length: pages() })}>
|
|
358
|
+
{(_, i) => (
|
|
359
|
+
<button
|
|
360
|
+
type="button"
|
|
361
|
+
aria-label={`Page ${i + 1}`}
|
|
362
|
+
aria-current={page() === i ? "true" : undefined}
|
|
363
|
+
onClick={() => goToPage(i)}
|
|
364
|
+
class={cn(
|
|
365
|
+
"transition-glass h-1.5 rounded-full",
|
|
366
|
+
page() === i ? "bg-foreground/70 w-4" : "bg-foreground/25 w-1.5",
|
|
367
|
+
)}
|
|
368
|
+
/>
|
|
369
|
+
)}
|
|
370
|
+
</Index>
|
|
371
|
+
</div>
|
|
372
|
+
</Show>
|
|
373
|
+
</div>
|
|
374
|
+
</div>
|
|
375
|
+
);
|
|
376
376
|
};
|
|
377
377
|
|
|
378
378
|
export type { DockIconButtonProps, DockItem, DockProps };
|