@glasshome/ui 1.41.0 → 1.43.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 +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/lib/anchor-placement.d.ts +34 -0
- package/dist/lib/balance-rows.d.ts +10 -4
- package/dist/lib/behavior/anchored.d.ts +26 -0
- package/dist/lib/behavior/button-root.d.ts +7 -0
- package/dist/lib/behavior/collection.d.ts +32 -0
- package/dist/lib/behavior/controllable.d.ts +8 -0
- package/dist/lib/behavior/dismiss.d.ts +13 -0
- package/dist/lib/behavior/focus-scope.d.ts +24 -0
- package/dist/lib/behavior/hide-outside.d.ts +7 -0
- package/dist/lib/behavior/layer-stack.d.ts +34 -0
- package/dist/lib/behavior/menu.d.ts +59 -0
- package/dist/lib/behavior/modal-root.d.ts +68 -0
- package/dist/lib/behavior/polymorphic.d.ts +6 -0
- package/dist/lib/behavior/presence.d.ts +18 -0
- package/dist/lib/behavior/range.d.ts +44 -0
- package/dist/lib/behavior/solid.d.ts +13 -0
- package/dist/lib/color/color.d.ts +41 -0
- package/dist/lib/color/index.d.ts +2 -0
- package/dist/lib/color/intl.d.ts +40 -0
- package/dist/lib/dock-slot-classes.d.ts +2 -0
- package/dist/lib/hold.d.ts +1 -1
- package/dist/lib/locale.d.ts +3 -0
- package/dist/lib/menu-classes.d.ts +2 -0
- package/dist/lib/motion-classes.d.ts +5 -2
- package/dist/lib/overlay-classes.d.ts +4 -0
- package/dist/lib/page-cover.d.ts +8 -0
- package/dist/lib/scroll-track.d.ts +3 -2
- package/dist/lib/section-tokens.d.ts +1 -1
- package/dist/lib/segment-classes.d.ts +2 -0
- package/dist/lib/shadow-layer.d.ts +0 -43
- package/dist/lib/toggle-set.d.ts +44 -0
- package/dist/lib/visually-hidden.d.ts +3 -0
- package/dist/solid/accordion.d.ts +35 -11
- package/dist/solid/alert-dialog.d.ts +5 -8
- package/dist/solid/avatar.d.ts +8 -4
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +2 -2
- package/dist/solid/bottom-sheet/constants.d.ts +1 -1
- package/dist/solid/button.d.ts +5 -4
- package/dist/solid/charts.d.ts +1 -1
- package/dist/solid/checkbox.d.ts +14 -4
- package/dist/solid/collapsible.d.ts +33 -5
- package/dist/solid/color-disc.d.ts +1 -1
- package/dist/solid/color-slider.d.ts +1 -1
- package/dist/solid/color-wheel.d.ts +1 -1
- package/dist/solid/context-menu.d.ts +58 -24
- package/dist/solid/dialog-parts.d.ts +53 -16
- package/dist/solid/dialog.d.ts +7 -10
- package/dist/solid/dropdown-menu.d.ts +55 -24
- package/dist/solid/empty.d.ts +1 -1
- package/dist/solid/form.d.ts +5 -6
- package/dist/solid/hover-card.d.ts +65 -9
- package/dist/solid/index.d.ts +5 -2
- package/dist/solid/index.js +8671 -14317
- package/dist/solid/input-group.d.ts +6 -6
- package/dist/solid/item.d.ts +1 -1
- package/dist/solid/menu-parts.d.ts +175 -24
- package/dist/solid/option-card.d.ts +1 -4
- package/dist/solid/picker-row.d.ts +2 -0
- package/dist/solid/popover.d.ts +77 -12
- package/dist/solid/progress.d.ts +11 -3
- package/dist/solid/radio-group.d.ts +31 -6
- package/dist/solid/responsive-dialog.d.ts +3 -1
- package/dist/solid/scroll-area.d.ts +1 -1
- package/dist/solid/section-card.d.ts +2 -3
- package/dist/solid/select.d.ts +107 -10
- package/dist/solid/selection.d.ts +10 -1
- package/dist/solid/sheet.d.ts +6 -9
- package/dist/solid/sliding-indicator.d.ts +1 -1
- package/dist/solid/sonner.d.ts +1 -1
- package/dist/solid/stale-veil.d.ts +7 -0
- package/dist/solid/tabs.d.ts +28 -9
- package/dist/solid/toggle-group.d.ts +30 -5
- package/dist/solid/toggle.d.ts +11 -3
- package/dist/solid/tooltip.d.ts +71 -9
- package/dist/tokens/index.js +54 -51
- package/dist/{utils-CGN4X-2O.js → utils-3Codx-NZ.js} +848 -618
- package/package.json +6 -7
- package/src/index.ts +1 -0
- package/src/lib/anchor-placement.ts +77 -4
- package/src/lib/balance-rows.ts +115 -40
- package/src/lib/behavior/anchored.ts +106 -0
- package/src/lib/behavior/button-root.tsx +103 -0
- package/src/lib/behavior/collection.ts +218 -0
- package/src/lib/behavior/controllable.ts +22 -0
- package/src/lib/behavior/dismiss.ts +185 -0
- package/src/lib/behavior/focus-scope.ts +227 -0
- package/src/lib/behavior/hide-outside.ts +85 -0
- package/src/lib/behavior/layer-stack.ts +150 -0
- package/src/lib/behavior/menu.ts +470 -0
- package/src/lib/behavior/modal-root.tsx +452 -0
- package/src/lib/behavior/polymorphic.tsx +30 -0
- package/src/lib/behavior/presence.ts +89 -0
- package/src/lib/behavior/range.ts +212 -0
- package/src/lib/behavior/solid.ts +30 -0
- package/src/lib/clipboard.ts +4 -4
- package/src/lib/color/color.ts +746 -0
- package/src/lib/color/index.ts +2 -0
- package/src/lib/color/intl.ts +60 -0
- package/src/lib/dock-slot-classes.ts +3 -0
- package/src/lib/hold.ts +1 -1
- package/src/lib/locale.ts +62 -0
- package/src/lib/menu-classes.ts +3 -0
- package/src/lib/motion-classes.ts +33 -8
- package/src/lib/overlay-classes.ts +8 -3
- package/src/lib/page-cover.ts +47 -0
- package/src/lib/scroll-track.ts +11 -6
- package/src/lib/section-tokens.ts +1 -1
- package/src/lib/segment-classes.ts +3 -0
- package/src/lib/shadow-layer.ts +0 -136
- package/src/lib/toggle-set.ts +133 -0
- package/src/lib/visually-hidden.ts +15 -0
- package/src/solid/accordion.tsx +294 -20
- package/src/solid/alert-dialog.tsx +36 -85
- package/src/solid/area-picker.tsx +5 -3
- package/src/solid/avatar.tsx +98 -24
- package/src/solid/badge.tsx +5 -5
- package/src/solid/bottom-sheet/bottom-sheet.tsx +73 -129
- package/src/solid/bottom-sheet/constants.ts +3 -1
- package/src/solid/bottom-sheet/drag-controller.ts +11 -0
- package/src/solid/breadcrumb.tsx +4 -4
- package/src/solid/button-group.tsx +4 -4
- package/src/solid/button.tsx +12 -6
- package/src/solid/card.tsx +5 -4
- package/src/solid/charts.tsx +1 -1
- package/src/solid/checkbox.tsx +167 -44
- package/src/solid/collapsible.tsx +260 -12
- package/src/solid/color-disc.tsx +11 -12
- package/src/solid/color-slider.tsx +114 -47
- package/src/solid/color-wheel.tsx +137 -39
- package/src/solid/context-menu.tsx +287 -86
- package/src/solid/dialog-parts.tsx +135 -46
- package/src/solid/dialog.tsx +44 -76
- package/src/solid/dock-edit.tsx +5 -4
- package/src/solid/dock.tsx +6 -5
- package/src/solid/dropdown-menu.tsx +252 -107
- package/src/solid/empty.tsx +1 -1
- package/src/solid/entity-selector.tsx +5 -3
- package/src/solid/face-toggle.tsx +43 -18
- package/src/solid/form.tsx +9 -9
- package/src/solid/glyph-tile.tsx +48 -21
- package/src/solid/hover-card.tsx +288 -21
- package/src/solid/icon-picker.tsx +2 -1
- package/src/solid/image-picker.tsx +6 -5
- package/src/solid/index.ts +5 -4
- package/src/solid/input-group.tsx +7 -5
- package/src/solid/input-otp.tsx +2 -1
- package/src/solid/item.tsx +5 -5
- package/src/solid/logo.tsx +5 -4
- package/src/solid/menu-parts.tsx +619 -145
- package/src/solid/option-card.tsx +6 -10
- package/src/solid/picker-row.tsx +10 -5
- package/src/solid/picker-search.tsx +2 -1
- package/src/solid/popover.tsx +424 -71
- package/src/solid/preview-tile.tsx +1 -1
- package/src/solid/progress.tsx +84 -15
- package/src/solid/radio-group.tsx +271 -34
- package/src/solid/responsive-dialog.tsx +10 -10
- package/src/solid/schema-form.tsx +1 -6
- package/src/solid/scroll-area.tsx +1 -1
- package/src/solid/section-card.tsx +3 -4
- package/src/solid/select.tsx +950 -95
- package/src/solid/selection.tsx +142 -66
- package/src/solid/sheet.tsx +48 -80
- package/src/solid/slider.tsx +115 -65
- package/src/solid/sliding-indicator.tsx +1 -1
- package/src/solid/sonner.tsx +1 -1
- package/src/solid/spotlight.tsx +23 -11
- package/src/solid/stale-veil.tsx +20 -0
- package/src/solid/switch.tsx +8 -6
- package/src/solid/tabs.tsx +377 -52
- package/src/solid/term.tsx +3 -4
- package/src/solid/toggle-group.tsx +237 -95
- package/src/solid/toggle.tsx +43 -9
- package/src/solid/tooltip.tsx +285 -26
- package/src/styles/globals.css +64 -10
- package/src/styles/theme.css +12 -4
- package/src/tokens/material.ts +11 -2
- package/dist/lib/when-animations-settle.d.ts +0 -4
- package/dist/solid/bottom-sheet/focus-trap.d.ts +0 -6
- package/dist/solid/bottom-sheet/scroll-lock.d.ts +0 -2
- package/dist/solid/bottom-sheet/sheet-motion.d.ts +0 -1
- package/src/lib/when-animations-settle.ts +0 -12
- package/src/solid/bottom-sheet/focus-trap.ts +0 -63
- package/src/solid/bottom-sheet/scroll-lock.ts +0 -66
- package/src/solid/bottom-sheet/sheet-motion.ts +0 -4
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*
|
|
12
|
+
* Ported from @internationalized/color by way of Kobalte's colors module (MIT).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const COLOR_INTL_TRANSLATIONS = {
|
|
16
|
+
hue: "Hue",
|
|
17
|
+
saturation: "Saturation",
|
|
18
|
+
lightness: "Lightness",
|
|
19
|
+
brightness: "Brightness",
|
|
20
|
+
red: "Red",
|
|
21
|
+
green: "Green",
|
|
22
|
+
blue: "Blue",
|
|
23
|
+
alpha: "Alpha",
|
|
24
|
+
colorName: (lightness: string, chroma: string, hue: string) => `${lightness} ${chroma} ${hue}`,
|
|
25
|
+
transparentColorName: (
|
|
26
|
+
lightness: string,
|
|
27
|
+
chroma: string,
|
|
28
|
+
hue: string,
|
|
29
|
+
percentTransparent: string,
|
|
30
|
+
) => `${lightness} ${chroma} ${hue}, ${percentTransparent} transparent`,
|
|
31
|
+
"very dark": "very dark",
|
|
32
|
+
dark: "dark",
|
|
33
|
+
light: "light",
|
|
34
|
+
"very light": "very light",
|
|
35
|
+
pale: "pale",
|
|
36
|
+
grayish: "grayish",
|
|
37
|
+
vibrant: "vibrant",
|
|
38
|
+
black: "black",
|
|
39
|
+
white: "white",
|
|
40
|
+
gray: "gray",
|
|
41
|
+
pink: "pink",
|
|
42
|
+
"pink red": "pink red",
|
|
43
|
+
"red orange": "red orange",
|
|
44
|
+
brown: "brown",
|
|
45
|
+
orange: "orange",
|
|
46
|
+
"orange yellow": "orange yellow",
|
|
47
|
+
"brown yellow": "brown yellow",
|
|
48
|
+
yellow: "yellow",
|
|
49
|
+
"yellow green": "yellow green",
|
|
50
|
+
"green cyan": "green cyan",
|
|
51
|
+
cyan: "cyan",
|
|
52
|
+
"cyan blue": "cyan blue",
|
|
53
|
+
"blue purple": "blue purple",
|
|
54
|
+
purple: "purple",
|
|
55
|
+
"purple magenta": "purple magenta",
|
|
56
|
+
magenta: "magenta",
|
|
57
|
+
"magenta pink": "magenta pink",
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type ColorIntlTranslations = typeof COLOR_INTL_TRANSLATIONS;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/* The footprint of a dock slot: the dock's items, its add slot, and the slot buttons
|
|
2
2
|
* that stand for them in a form, so a pick looks like what lands in the dock. */
|
|
3
|
+
/** The rounded-lg in DOCK_SLOT_SHAPE, for a selection flyer that crosses slots. */
|
|
4
|
+
export const DOCK_SLOT_RADIUS = "var(--radius-lg)";
|
|
5
|
+
|
|
3
6
|
export const DOCK_SLOT_SHAPE =
|
|
4
7
|
"flex size-11 touch-manipulation items-center justify-center rounded-lg sm:size-12";
|
package/src/lib/hold.ts
CHANGED
|
@@ -28,7 +28,7 @@ function spendPress(): void {
|
|
|
28
28
|
|
|
29
29
|
/** A fired hold spends the press: the browser's own long press (text selection, context menu)
|
|
30
30
|
* must not land on what the hold opened under the finger. Lasts until the release.
|
|
31
|
-
* @deprecated
|
|
31
|
+
* @deprecated `createHold`; removed in 2.0.0. */
|
|
32
32
|
export function spendLongPress(): void {
|
|
33
33
|
spendPress();
|
|
34
34
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isServer } from "solid-js/web";
|
|
2
|
+
|
|
3
|
+
export type ReadingDirection = "ltr" | "rtl";
|
|
4
|
+
|
|
5
|
+
const RTL_SCRIPTS = new Set([
|
|
6
|
+
"Arab",
|
|
7
|
+
"Syrc",
|
|
8
|
+
"Samr",
|
|
9
|
+
"Mand",
|
|
10
|
+
"Thaa",
|
|
11
|
+
"Mend",
|
|
12
|
+
"Nkoo",
|
|
13
|
+
"Adlm",
|
|
14
|
+
"Rohg",
|
|
15
|
+
"Hebr",
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
const RTL_LANGS = new Set([
|
|
19
|
+
"ae",
|
|
20
|
+
"ar",
|
|
21
|
+
"arc",
|
|
22
|
+
"bcc",
|
|
23
|
+
"bqi",
|
|
24
|
+
"ckb",
|
|
25
|
+
"dv",
|
|
26
|
+
"fa",
|
|
27
|
+
"glk",
|
|
28
|
+
"he",
|
|
29
|
+
"ku",
|
|
30
|
+
"mzn",
|
|
31
|
+
"nqo",
|
|
32
|
+
"pnb",
|
|
33
|
+
"ps",
|
|
34
|
+
"sd",
|
|
35
|
+
"ug",
|
|
36
|
+
"ur",
|
|
37
|
+
"yi",
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
function directionOf(locale: string): ReadingDirection {
|
|
41
|
+
if (typeof Intl.Locale === "function") {
|
|
42
|
+
const script = new Intl.Locale(locale).maximize().script ?? "";
|
|
43
|
+
return RTL_SCRIPTS.has(script) ? "rtl" : "ltr";
|
|
44
|
+
}
|
|
45
|
+
return RTL_LANGS.has(locale.split("-")[0] ?? "") ? "rtl" : "ltr";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function browserLocale(): string {
|
|
49
|
+
const language = typeof navigator === "undefined" ? undefined : navigator.language;
|
|
50
|
+
if (!language) return "en-US";
|
|
51
|
+
try {
|
|
52
|
+
Intl.DateTimeFormat.supportedLocalesOf([language]);
|
|
53
|
+
return language;
|
|
54
|
+
} catch {
|
|
55
|
+
return "en-US";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// The server renders en-US, as Kobalte did.
|
|
60
|
+
export const locale: string = isServer ? "en-US" : browserLocale();
|
|
61
|
+
|
|
62
|
+
export const readingDirection: ReadingDirection = directionOf(locale);
|
package/src/lib/menu-classes.ts
CHANGED
|
@@ -12,6 +12,9 @@ export const MENU_ITEM_BASE =
|
|
|
12
12
|
// structural-ok: guards an svg color rule on a sibling data attribute this package always renders, not a class the consumer must also scan
|
|
13
13
|
"relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 text-sm outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&:not([data-tone])_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:text-[16px]";
|
|
14
14
|
|
|
15
|
+
/** The rounded-sm in MENU_ITEM_BASE, for a selection flyer that crosses rows. */
|
|
16
|
+
export const MENU_ITEM_RADIUS = "var(--radius-sm)";
|
|
17
|
+
|
|
15
18
|
export const MENU_ITEM_X = "px-2";
|
|
16
19
|
|
|
17
20
|
export const MENU_ITEM = `${MENU_ITEM_BASE} ${MENU_ITEM_X}`;
|
|
@@ -8,18 +8,17 @@ const LEAVE =
|
|
|
8
8
|
"data-[closed]:animate-out data-[closed]:duration-(--duration-micro) data-[closed]:ease-(--ease-contract)";
|
|
9
9
|
|
|
10
10
|
/* Anchored panels (menu, popover, tooltip, hover card): unfold from the
|
|
11
|
-
* trigger edge
|
|
11
|
+
* trigger edge; each panel sets its origin from data-side or the pointer. */
|
|
12
12
|
export const OVERLAY_MOTION = `origin-(--kb-popper-content-transform-origin) ${ARRIVE} data-[expanded]:fade-in-0 data-[expanded]:zoom-in-90 ${LEAVE} data-[closed]:fade-out-0 data-[closed]:zoom-out-95`;
|
|
13
13
|
|
|
14
|
-
/* Field pickers:
|
|
15
|
-
*
|
|
16
|
-
* dropping in. */
|
|
14
|
+
/* Field pickers: the clip-path reveal is what makes the panel read as the
|
|
15
|
+
* field expanding, not a box dropping in. */
|
|
17
16
|
export const FIELD_MOTION = "data-[closed]:animate-select-out data-[expanded]:animate-select-in";
|
|
18
17
|
|
|
19
18
|
/* Anchored panels that own their trigger (dropdown menu): the panel covers
|
|
20
|
-
* the trigger
|
|
19
|
+
* the trigger and unrolls out of the
|
|
21
20
|
* trigger's box; the content writes --morph-h/--morph-radius from the
|
|
22
|
-
* trigger it replaces, --morph-w is
|
|
21
|
+
* trigger it replaces, --morph-w is the anchor width the menu writes. */
|
|
23
22
|
export const MORPH_MOTION =
|
|
24
23
|
"[--morph-w:var(--kb-popper-anchor-width)] min-w-[var(--kb-popper-anchor-width)] data-[expanded]:animate-morph-in data-[closed]:animate-morph-out";
|
|
25
24
|
|
|
@@ -32,15 +31,26 @@ export const ANCHORED_MOTION =
|
|
|
32
31
|
* (globals.css): one door, no per-row index, mount-only. */
|
|
33
32
|
export const STAGGER = "gh-stagger";
|
|
34
33
|
|
|
34
|
+
/* An exit that holds its last frame: a closed surface still mounted (kept, or waiting
|
|
35
|
+
* for its unmount) rests invisible instead of snapping back. */
|
|
36
|
+
const REST_CLOSED = "data-[closed]:fill-mode-forwards";
|
|
37
|
+
|
|
35
38
|
/* Modals: rise into place. Sheets keep their slide. */
|
|
36
|
-
export const MODAL_MOTION = `${ARRIVE} data-[expanded]:fade-in-0 data-[expanded]:zoom-in-[0.94] data-[expanded]:slide-in-from-bottom-2 ${LEAVE} data-[closed]:fade-out-0 data-[closed]:zoom-out-[0.96]`;
|
|
39
|
+
export const MODAL_MOTION = `${ARRIVE} data-[expanded]:fade-in-0 data-[expanded]:zoom-in-[0.94] data-[expanded]:slide-in-from-bottom-2 ${LEAVE} ${REST_CLOSED} data-[closed]:fade-out-0 data-[closed]:zoom-out-[0.96]`;
|
|
37
40
|
|
|
38
|
-
export const SCRIM_MOTION = `${ARRIVE} data-[expanded]:fade-in-0 ${LEAVE} data-[closed]:fade-out-0`;
|
|
41
|
+
export const SCRIM_MOTION = `${ARRIVE} data-[expanded]:fade-in-0 ${LEAVE} ${REST_CLOSED} data-[closed]:fade-out-0`;
|
|
39
42
|
|
|
40
43
|
/* Content that swaps in place (tab panel, a row added to a list). */
|
|
41
44
|
export const SETTLE_MOTION =
|
|
42
45
|
"animate-in fade-in-0 slide-in-from-bottom-1 duration-(--duration-state) ease-(--ease-expand)";
|
|
43
46
|
|
|
47
|
+
/* A cover that fades in once and rests; the animation ends, nothing runs after. */
|
|
48
|
+
export const VEIL_MOTION =
|
|
49
|
+
"animate-in fade-in-0 duration-(--duration-state) ease-(--ease-emphasis) motion-reduce:animate-none in-[.reduce-motion]:animate-none";
|
|
50
|
+
|
|
51
|
+
/* The content a StaleVeil covers: black and white for as long as it is stale, no transition. */
|
|
52
|
+
export const STALE_CONTENT = "grayscale";
|
|
53
|
+
|
|
44
54
|
/* Every pressable dips the same amount. */
|
|
45
55
|
export const PRESS_DIP = "active:scale-[0.97]";
|
|
46
56
|
|
|
@@ -70,3 +80,18 @@ export const RISE_MOTION =
|
|
|
70
80
|
* spotlight's hole and bubble). */
|
|
71
81
|
export const TRAVEL_MOTION =
|
|
72
82
|
"transition-[translate,clip-path] duration-(--duration-morph) ease-(--ease-expand)";
|
|
83
|
+
|
|
84
|
+
/* The longest exit (delay plus duration) each door's data-[closed] classes run;
|
|
85
|
+
* tests/lib/motion-exit.test.tsx holds these to the computed styles. */
|
|
86
|
+
export const MOTION_EXIT_MS: Record<
|
|
87
|
+
"overlay" | "modal" | "anchored" | "scrim" | "field" | "sheet" | "disclosure",
|
|
88
|
+
number
|
|
89
|
+
> = {
|
|
90
|
+
overlay: 120,
|
|
91
|
+
modal: 120,
|
|
92
|
+
anchored: 150,
|
|
93
|
+
scrim: 120,
|
|
94
|
+
field: 120,
|
|
95
|
+
sheet: 500,
|
|
96
|
+
disclosure: 200,
|
|
97
|
+
};
|
|
@@ -25,6 +25,10 @@ export const OVERLAY_SURFACE_OPAQUE = `${OVERLAY_KNOBS} [--glass-base:var(--popo
|
|
|
25
25
|
/* Touch screens only dim: a full-screen blur over moving widgets re-blurs every frame on a tablet GPU. */
|
|
26
26
|
export const SCRIM_CLASS = "bg-scrim backdrop-blur-md pointer-coarse:backdrop-blur-none";
|
|
27
27
|
|
|
28
|
+
/* overflow-hidden makes the scrim a scroll container, so overscroll-behavior applies to it. */
|
|
29
|
+
export const SCROLL_CONTAIN = "overscroll-contain";
|
|
30
|
+
export const SCRIM_CONTAIN = `${SCROLL_CONTAIN} overflow-hidden`;
|
|
31
|
+
|
|
28
32
|
export const PANEL_TAIL = `${Z_CLASS.overlay} rounded-md text-popover-foreground outline-hidden`;
|
|
29
33
|
|
|
30
34
|
/* The floating panel surface, minus positioning: a caller that is not
|
|
@@ -36,12 +40,13 @@ export const FLOATING_PANEL_SURFACE = `${OVERLAY_SURFACE} ${PANEL_TAIL}`;
|
|
|
36
40
|
* menus add p-1, popovers p-4, pickers none. */
|
|
37
41
|
export const FLOATING_PANEL = `${OVERLAY_SURFACE} relative ${PANEL_TAIL}`;
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
* width bound to --kb-popper-anchor-width, the panel covers the trigger and
|
|
41
|
-
* grows downward from it. */
|
|
43
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
42
44
|
export const anchorToTriggerTop = (anchor?: HTMLElement) => {
|
|
43
45
|
const r = anchor?.getBoundingClientRect();
|
|
44
46
|
return r
|
|
45
47
|
? { x: r.left, y: r.top, width: r.width, height: 0 }
|
|
46
48
|
: { x: 0, y: 0, width: 0, height: 0 };
|
|
47
49
|
};
|
|
50
|
+
|
|
51
|
+
/* The modal layer's own root. Its box, containment and stacking never change, so going dormant only adds skipping. */
|
|
52
|
+
export const LAYER_ROOT = `pointer-events-none fixed inset-0 ${Z_CLASS.overlay} [contain:layout_paint_style] *:pointer-events-auto data-[dormant]:[content-visibility:hidden] not-supports-[content-visibility:hidden]:data-[dormant]:hidden`;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { watchMotion } from "./behavior/presence.js";
|
|
2
|
+
import { MOTION_EXIT_MS } from "./motion-classes.js";
|
|
3
|
+
|
|
4
|
+
/** On a modal's panel from the end of its open animation; the widget realm carries it out of a sealed widget. */
|
|
5
|
+
export const COVERING_ATTR = "data-covering";
|
|
6
|
+
|
|
7
|
+
let covers = 0;
|
|
8
|
+
const pageRoot = () => document.querySelector("[data-page]");
|
|
9
|
+
|
|
10
|
+
/** Pauses the page's ambient loops while a modal covers it: one attribute on the app's [data-page] root, never on html. Returns the release. */
|
|
11
|
+
export function coverPage(): () => void {
|
|
12
|
+
covers++;
|
|
13
|
+
if (covers === 1) pageRoot()?.setAttribute("data-covered", "");
|
|
14
|
+
let released = false;
|
|
15
|
+
return () => {
|
|
16
|
+
if (released) return;
|
|
17
|
+
released = true;
|
|
18
|
+
covers--;
|
|
19
|
+
if (covers === 0) pageRoot()?.removeAttribute("data-covered");
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A modal panel covers the page from now until the returned release runs. */
|
|
24
|
+
export function coverNow(panel: Element): () => void {
|
|
25
|
+
panel.setAttribute(COVERING_ATTR, "");
|
|
26
|
+
const release = coverPage();
|
|
27
|
+
return () => {
|
|
28
|
+
panel.removeAttribute(COVERING_ATTR);
|
|
29
|
+
release();
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** A modal panel covers the page once its open animation ends, if it is still open then, until the returned release runs. */
|
|
34
|
+
export function coverOnceOpen(panel: Element, open: () => boolean): () => void {
|
|
35
|
+
let release: (() => void) | undefined;
|
|
36
|
+
let done = false;
|
|
37
|
+
const stop = watchMotion(panel, MOTION_EXIT_MS.sheet, () => {
|
|
38
|
+
if (done || !open()) return;
|
|
39
|
+
release = coverNow(panel);
|
|
40
|
+
});
|
|
41
|
+
return () => {
|
|
42
|
+
if (done) return;
|
|
43
|
+
done = true;
|
|
44
|
+
stop();
|
|
45
|
+
release?.();
|
|
46
|
+
};
|
|
47
|
+
}
|
package/src/lib/scroll-track.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Accessor } from "solid-js";
|
|
2
|
+
import { effect } from "./behavior/solid.js";
|
|
3
|
+
|
|
1
4
|
/* A row of segments that scrolls sideways (tabs, a scrolling toggle group):
|
|
2
5
|
* the selected segment stays in view and a clipped edge fades out, so the row
|
|
3
6
|
* reads as "more this way" instead of ending mid-label. */
|
|
@@ -12,9 +15,13 @@ function writeClip(list: HTMLElement): void {
|
|
|
12
15
|
list.toggleAttribute("data-clip-end", end > 1);
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
/** Centres the segment matching `selected` whenever
|
|
18
|
+
/** Centres the segment matching `selected` whenever `selection` changes; drives
|
|
16
19
|
* scrollLeft, since scrollIntoView would scroll the page with it. */
|
|
17
|
-
export function trackScroll(
|
|
20
|
+
export function trackScroll(
|
|
21
|
+
list: HTMLElement,
|
|
22
|
+
selected: string,
|
|
23
|
+
selection: Accessor<unknown>,
|
|
24
|
+
): () => void {
|
|
18
25
|
const reveal = () => {
|
|
19
26
|
writeClip(list);
|
|
20
27
|
if (list.scrollWidth <= list.clientWidth) return;
|
|
@@ -29,18 +36,16 @@ export function trackScroll(list: HTMLElement, selected: string, attribute: stri
|
|
|
29
36
|
const clip = () => writeClip(list);
|
|
30
37
|
// A frame late: on mount the track has no width yet, and during a press
|
|
31
38
|
// the focus scroll cancels a smooth scroll started in the same task.
|
|
32
|
-
let frame =
|
|
33
|
-
|
|
39
|
+
let frame = 0;
|
|
40
|
+
effect(selection, () => {
|
|
34
41
|
cancelAnimationFrame(frame);
|
|
35
42
|
frame = requestAnimationFrame(reveal);
|
|
36
43
|
});
|
|
37
|
-
observer.observe(list, { attributes: true, attributeFilter: [attribute], subtree: true });
|
|
38
44
|
const resize = new ResizeObserver(clip);
|
|
39
45
|
resize.observe(list);
|
|
40
46
|
list.addEventListener("scroll", clip, { passive: true });
|
|
41
47
|
return () => {
|
|
42
48
|
cancelAnimationFrame(frame);
|
|
43
|
-
observer.disconnect();
|
|
44
49
|
resize.disconnect();
|
|
45
50
|
list.removeEventListener("scroll", clip);
|
|
46
51
|
};
|
|
@@ -9,5 +9,5 @@ export const SECTION_PADDING = "p-3";
|
|
|
9
9
|
* only for the deprecated class below. */
|
|
10
10
|
const LEGACY_SECTION_ROW_SURFACE = `${SECTION_INNER_RADIUS} border border-border/60 bg-card/60`;
|
|
11
11
|
|
|
12
|
-
/** @deprecated
|
|
12
|
+
/** @deprecated `SectionRow`, or `SECTION_ROW_SURFACE` from card-classes; removed in 2.0.0. */
|
|
13
13
|
export const SECTION_ROW_CLASS = `${LEGACY_SECTION_ROW_SURFACE} ${SECTION_PADDING}`;
|
|
@@ -4,4 +4,7 @@ import { CONTROL_H, FOCUS_RING } from "./input-classes.js";
|
|
|
4
4
|
* toggleVariants' base): both sit inside a TRACK_SURFACE track and pick one
|
|
5
5
|
* of a few siblings, so they share height, type and focus ring. Callers still
|
|
6
6
|
* layer their own variant/size classes on top through cn()'s tailwind-merge. */
|
|
7
|
+
/** The rounded-md of a segment (SEGMENT_ITEM, a toggle-group item), for a selection flyer that crosses segments. */
|
|
8
|
+
export const SEGMENT_RADIUS = "var(--radius-md)";
|
|
9
|
+
|
|
7
10
|
export const SEGMENT_ITEM = `inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md ${CONTROL_H.sm} px-3 font-medium text-sm outline-none transition-glass active:scale-[0.97] disabled:pointer-events-none disabled:opacity-50 ${FOCUS_RING}`;
|
package/src/lib/shadow-layer.ts
CHANGED
|
@@ -1,139 +1,3 @@
|
|
|
1
|
-
import { type Accessor, createEffect, onCleanup } from "solid-js";
|
|
2
|
-
import { type InitialFocus, trapFocus } from "../solid/bottom-sheet/focus-trap.js";
|
|
3
|
-
|
|
4
1
|
/** True for a node inside a shadow root, where page-level layer logic sees only the root's host. */
|
|
5
2
|
export const inShadowRoot = (node: Node | undefined): boolean =>
|
|
6
3
|
typeof ShadowRoot !== "undefined" && node?.getRootNode() instanceof ShadowRoot;
|
|
7
|
-
|
|
8
|
-
/** Layers open in each shadow root, oldest first: only the newest dismisses on a press, as Kobalte's own stack does. */
|
|
9
|
-
const stacks = new WeakMap<ShadowRoot, Element[]>();
|
|
10
|
-
|
|
11
|
-
type OutsideEvent = { target: EventTarget | null; preventDefault(): void };
|
|
12
|
-
type AutoFocusEvent = { preventDefault(): void };
|
|
13
|
-
|
|
14
|
-
export interface LayerHandlers {
|
|
15
|
-
onInteractOutside: (e: OutsideEvent) => void;
|
|
16
|
-
onCloseAutoFocus: (e: AutoFocusEvent) => void;
|
|
17
|
-
onOpenAutoFocus: (e: AutoFocusEvent) => void;
|
|
18
|
-
/** The shadow root's host while the layer is in one: what the page sees as the target of anything inside. */
|
|
19
|
-
host: () => Element | undefined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface ShadowLayerOptions {
|
|
23
|
-
content: Accessor<HTMLElement | undefined>;
|
|
24
|
-
open: Accessor<boolean>;
|
|
25
|
-
/** Absent for layers that close on pointer leave (tooltips, hover cards): they never join the stack. */
|
|
26
|
-
dismiss?: () => void;
|
|
27
|
-
/** A press on it is the trigger's own toggle, never an outside press. */
|
|
28
|
-
trigger?: Accessor<Element | undefined>;
|
|
29
|
-
/** Menus: any press outside the layer and the layers above it dismisses it, newest or not, as Kobalte's menus do. */
|
|
30
|
-
tree?: boolean;
|
|
31
|
-
/** The layer keeps Tab inside itself (dialogs); its initial focus is then ui's, not Kobalte's. */
|
|
32
|
-
trapsFocus?: boolean;
|
|
33
|
-
initialFocus?: InitialFocus;
|
|
34
|
-
consumer: {
|
|
35
|
-
onInteractOutside?: (e: never) => void;
|
|
36
|
-
onCloseAutoFocus?: (e: never) => void;
|
|
37
|
-
onOpenAutoFocus?: (e: never) => void;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Kobalte decides "outside" from the page, where a press or focus inside a shadow root is one on
|
|
43
|
-
* the root's host, so a layer portaled into a shadow root would dismiss on every press inside it.
|
|
44
|
-
* The handlers ignore those; while the layer is open in a shadow root, a press elsewhere in that
|
|
45
|
-
* root dismisses the newest layer from a listener on the root itself. Outside a shadow root the
|
|
46
|
-
* handlers only pass the consumer's own through.
|
|
47
|
-
*/
|
|
48
|
-
export function shadowLayer(options: ShadowLayerOptions): LayerHandlers {
|
|
49
|
-
let dismissedIn: ShadowRoot | undefined;
|
|
50
|
-
createEffect(() => {
|
|
51
|
-
const el = options.content();
|
|
52
|
-
const dismiss = options.dismiss;
|
|
53
|
-
if (options.open()) dismissedIn = undefined;
|
|
54
|
-
if (!el || !dismiss || !options.open() || !inShadowRoot(el)) return;
|
|
55
|
-
const root = el.getRootNode() as ShadowRoot;
|
|
56
|
-
const stack = stacks.get(root) ?? [];
|
|
57
|
-
stacks.set(root, stack);
|
|
58
|
-
stack.push(el);
|
|
59
|
-
const inside = (e: Event) => {
|
|
60
|
-
const path = e.composedPath();
|
|
61
|
-
const trigger = options.trigger?.();
|
|
62
|
-
if (path.includes(el) || (trigger && path.includes(trigger))) return true;
|
|
63
|
-
return stack.slice(stack.indexOf(el) + 1).some((above) => path.includes(above));
|
|
64
|
-
};
|
|
65
|
-
const dismisses = (e: Event) => (options.tree || stack[stack.length - 1] === el) && !inside(e);
|
|
66
|
-
const close = () => {
|
|
67
|
-
dismissedIn = root;
|
|
68
|
-
dismiss();
|
|
69
|
-
// The caller refused the close (a controlled `open`): the next close is not this one.
|
|
70
|
-
if (options.open()) dismissedIn = undefined;
|
|
71
|
-
};
|
|
72
|
-
let pendingClick: ((e: Event) => void) | undefined;
|
|
73
|
-
const dropPendingClick = () => {
|
|
74
|
-
if (pendingClick) root.removeEventListener("click", pendingClick);
|
|
75
|
-
pendingClick = undefined;
|
|
76
|
-
};
|
|
77
|
-
const onDown = (e: Event) => {
|
|
78
|
-
dropPendingClick();
|
|
79
|
-
if (!dismisses(e)) return;
|
|
80
|
-
// A touch dismisses on its own click, judged again then: a scroll never clicks.
|
|
81
|
-
if ((e as PointerEvent).pointerType === "touch") {
|
|
82
|
-
pendingClick = (click) => {
|
|
83
|
-
pendingClick = undefined;
|
|
84
|
-
if (dismisses(click)) close();
|
|
85
|
-
};
|
|
86
|
-
root.addEventListener("click", pendingClick, { once: true });
|
|
87
|
-
} else {
|
|
88
|
-
close();
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
// Listening only after the opening press has finished, as Kobalte's own layers do.
|
|
92
|
-
const timer = setTimeout(() => root.addEventListener("pointerdown", onDown, true), 0);
|
|
93
|
-
if (options.trapsFocus) {
|
|
94
|
-
const trap = trapFocus(el, options.initialFocus ?? "first");
|
|
95
|
-
onCleanup(() => trap.release());
|
|
96
|
-
}
|
|
97
|
-
onCleanup(() => {
|
|
98
|
-
clearTimeout(timer);
|
|
99
|
-
root.removeEventListener("pointerdown", onDown, true);
|
|
100
|
-
dropPendingClick();
|
|
101
|
-
stack.splice(stack.indexOf(el), 1);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
const shadowHost = () => {
|
|
105
|
-
const root = options.content()?.getRootNode();
|
|
106
|
-
return typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.host : undefined;
|
|
107
|
-
};
|
|
108
|
-
return {
|
|
109
|
-
host: shadowHost,
|
|
110
|
-
onInteractOutside: (e) => {
|
|
111
|
-
const host = shadowHost();
|
|
112
|
-
if (host && e.target === host) {
|
|
113
|
-
e.preventDefault();
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
options.consumer.onInteractOutside?.(e as never);
|
|
117
|
-
},
|
|
118
|
-
onCloseAutoFocus: (e) => {
|
|
119
|
-
const root = dismissedIn;
|
|
120
|
-
dismissedIn = undefined;
|
|
121
|
-
if (root) {
|
|
122
|
-
// Dismissed by a press elsewhere in the root: focus stays where that press put it, even
|
|
123
|
-
// for the Kobalte layers that focus their trigger past preventDefault.
|
|
124
|
-
e.preventDefault();
|
|
125
|
-
const kept = root.activeElement;
|
|
126
|
-
queueMicrotask(() => {
|
|
127
|
-
if (kept instanceof HTMLElement && kept.isConnected && root.activeElement !== kept) {
|
|
128
|
-
kept.focus();
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
options.consumer.onCloseAutoFocus?.(e as never);
|
|
133
|
-
},
|
|
134
|
-
onOpenAutoFocus: (e) => {
|
|
135
|
-
if (options.trapsFocus && shadowHost()) e.preventDefault();
|
|
136
|
-
options.consumer.onOpenAutoFocus?.(e as never);
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { type Accessor, createSignal, createUniqueId, onCleanup } from "solid-js";
|
|
2
|
+
import { type Collection, createCollection } from "./behavior/collection.js";
|
|
3
|
+
import { focusWithoutTracking, trackFocus } from "./behavior/focus-scope.js";
|
|
4
|
+
import { effect } from "./behavior/solid.js";
|
|
5
|
+
|
|
6
|
+
type Orientation = "horizontal" | "vertical";
|
|
7
|
+
|
|
8
|
+
export interface ToggleSet {
|
|
9
|
+
id: Accessor<string>;
|
|
10
|
+
orientation: Accessor<Orientation>;
|
|
11
|
+
isPressed: (value: string) => boolean;
|
|
12
|
+
toggle: (value: string) => void;
|
|
13
|
+
collection: Collection;
|
|
14
|
+
/** Changes as items mount and unmount. */
|
|
15
|
+
members: Accessor<number>;
|
|
16
|
+
joined: (delta: 1 | -1) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The shared core of a row of toggles: which are pressed, what a press does, and the roving focus between them. */
|
|
20
|
+
export function createToggleSet(options: {
|
|
21
|
+
root: Accessor<HTMLElement | undefined>;
|
|
22
|
+
itemSelector: string;
|
|
23
|
+
values: Accessor<readonly string[]>;
|
|
24
|
+
setValues: (next: string[]) => void;
|
|
25
|
+
multiple: Accessor<boolean>;
|
|
26
|
+
orientation?: Accessor<Orientation>;
|
|
27
|
+
id?: Accessor<string | undefined>;
|
|
28
|
+
disabledFocusable?: boolean;
|
|
29
|
+
}): ToggleSet {
|
|
30
|
+
const orientation = options.orientation ?? (() => "horizontal" as const);
|
|
31
|
+
const fallbackId = `group-${createUniqueId()}`;
|
|
32
|
+
const [members, setMembers] = createSignal(0);
|
|
33
|
+
const collection = createCollection({
|
|
34
|
+
root: options.root,
|
|
35
|
+
itemSelector: options.itemSelector,
|
|
36
|
+
orientation,
|
|
37
|
+
focus: "roving",
|
|
38
|
+
loop: () => true,
|
|
39
|
+
dir: () => (options.root()?.closest("[dir]")?.getAttribute("dir") === "rtl" ? "rtl" : "ltr"),
|
|
40
|
+
preferred: options.values,
|
|
41
|
+
disabledFocusable: options.disabledFocusable,
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
id: () => options.id?.() ?? fallbackId,
|
|
45
|
+
orientation,
|
|
46
|
+
isPressed: (value) => options.values().includes(value),
|
|
47
|
+
toggle: (value) => {
|
|
48
|
+
const current = options.values();
|
|
49
|
+
const pressed = current.includes(value);
|
|
50
|
+
if (options.multiple()) {
|
|
51
|
+
options.setValues(pressed ? current.filter((v) => v !== value) : [...current, value]);
|
|
52
|
+
} else options.setValues(pressed ? [] : [value]);
|
|
53
|
+
},
|
|
54
|
+
collection,
|
|
55
|
+
members,
|
|
56
|
+
joined: (delta) => setMembers((n) => n + delta),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** One toggle in a set: its ref, its pressed and roving-focus attributes, and its press, bound on the element so it works inside a closed shadow root. */
|
|
61
|
+
export function createToggleItem(
|
|
62
|
+
set: ToggleSet,
|
|
63
|
+
item: { value: Accessor<string>; disabled: Accessor<boolean>; locked?: Accessor<boolean> },
|
|
64
|
+
) {
|
|
65
|
+
const id = `${set.id()}-item-${createUniqueId()}`;
|
|
66
|
+
const [el, setEl] = createSignal<HTMLElement>();
|
|
67
|
+
effect(item.disabled, () => set.collection.refresh());
|
|
68
|
+
onCleanup(() => set.collection.refresh());
|
|
69
|
+
const pressed = () => set.isPressed(item.value());
|
|
70
|
+
|
|
71
|
+
effect(el, (node) => {
|
|
72
|
+
if (!node) return;
|
|
73
|
+
set.joined(1);
|
|
74
|
+
let mousePressed = false;
|
|
75
|
+
const focused = trackFocus(node);
|
|
76
|
+
const choose = () => {
|
|
77
|
+
if (item.disabled() || item.locked?.()) return;
|
|
78
|
+
set.toggle(item.value());
|
|
79
|
+
set.collection.highlight(item.value(), "pointer");
|
|
80
|
+
};
|
|
81
|
+
// A mouse toggles on press, so focus lands on an item already toggled and is announced so.
|
|
82
|
+
const pointerdown = (event: PointerEvent) => {
|
|
83
|
+
mousePressed = event.pointerType === "mouse" && event.button === 0;
|
|
84
|
+
if (mousePressed) choose();
|
|
85
|
+
};
|
|
86
|
+
const click = (event: MouseEvent) => {
|
|
87
|
+
// WebKit leaves a clicked button unfocused.
|
|
88
|
+
if (!item.disabled() && !focused.has()) focusWithoutTracking(node);
|
|
89
|
+
if (event.detail === 0 || !mousePressed) choose();
|
|
90
|
+
mousePressed = false;
|
|
91
|
+
};
|
|
92
|
+
const focus = () => set.collection.highlight(item.value(), "pointer");
|
|
93
|
+
node.addEventListener("pointerdown", pointerdown);
|
|
94
|
+
node.addEventListener("click", click);
|
|
95
|
+
node.addEventListener("focus", focus);
|
|
96
|
+
return () => {
|
|
97
|
+
set.joined(-1);
|
|
98
|
+
focused.stop();
|
|
99
|
+
node.removeEventListener("pointerdown", pointerdown);
|
|
100
|
+
node.removeEventListener("click", click);
|
|
101
|
+
node.removeEventListener("focus", focus);
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
ref: setEl,
|
|
107
|
+
pressed,
|
|
108
|
+
props: {
|
|
109
|
+
id,
|
|
110
|
+
get tabIndex() {
|
|
111
|
+
return set.collection.tabIndex(item.value());
|
|
112
|
+
},
|
|
113
|
+
get disabled() {
|
|
114
|
+
return item.disabled();
|
|
115
|
+
},
|
|
116
|
+
get "aria-pressed"() {
|
|
117
|
+
return pressed();
|
|
118
|
+
},
|
|
119
|
+
get "data-pressed"() {
|
|
120
|
+
return pressed() ? "" : undefined;
|
|
121
|
+
},
|
|
122
|
+
get "data-disabled"() {
|
|
123
|
+
return item.disabled() ? "" : undefined;
|
|
124
|
+
},
|
|
125
|
+
get "data-key"() {
|
|
126
|
+
return item.value();
|
|
127
|
+
},
|
|
128
|
+
get "data-orientation"() {
|
|
129
|
+
return set.orientation();
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
|
|
3
|
+
/** Kept for assistive tech and form submission, gone from sight and layout. */
|
|
4
|
+
export const VISUALLY_HIDDEN: JSX.CSSProperties = {
|
|
5
|
+
border: "0",
|
|
6
|
+
clip: "rect(0, 0, 0, 0)",
|
|
7
|
+
"clip-path": "inset(50%)",
|
|
8
|
+
height: "1px",
|
|
9
|
+
margin: "0 -1px -1px 0",
|
|
10
|
+
overflow: "hidden",
|
|
11
|
+
padding: "0",
|
|
12
|
+
position: "absolute",
|
|
13
|
+
width: "1px",
|
|
14
|
+
"white-space": "nowrap",
|
|
15
|
+
};
|