@gemologic/sheen 0.3.0 → 0.4.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/dist/index.d.ts +2 -0
- package/dist/index.js +68 -67
- package/dist/overlays.d.ts +2 -0
- package/dist/overlays.js +9 -8
- package/dist/primitives/Checkbox.d.ts +16 -2
- package/dist/primitives/Checkbox.js +45 -34
- package/dist/primitives/CommandPalette.d.ts +4 -0
- package/dist/primitives/CommandPalette.js +137 -113
- package/dist/primitives/Popover.d.ts +1 -0
- package/dist/primitives/Popover.js +12 -4
- package/dist/primitives/Switch.d.ts +2 -2
- package/dist/primitives/TooltipTrigger.d.ts +18 -0
- package/dist/primitives/TooltipTrigger.js +76 -0
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/overlays.ts +2 -0
- package/src/primitives/Checkbox.tsx +14 -7
- package/src/primitives/CommandPalette.tsx +11 -2
- package/src/primitives/Popover.tsx +5 -4
- package/src/primitives/Switch.tsx +2 -2
- package/src/primitives/TooltipTrigger.tsx +60 -0
- package/src/styles/forms.css +5 -3
- package/src/styles/overlays.css +3 -0
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export type { ShortcutProviderProps } from "./primitives/ShortcutProvider.tsx";
|
|
|
35
35
|
export type { PendingShortcut, ShortcutAction, ShortcutBinding, ShortcutDefinition, ShortcutInput, ShortcutRegistryOptions } from "./utils/shortcut-registry.ts";
|
|
36
36
|
export { LinkTooltip } from "./primitives/LinkTooltip.tsx";
|
|
37
37
|
export type { LinkTooltipProps } from "./primitives/LinkTooltip.tsx";
|
|
38
|
+
export { TooltipTrigger } from "./primitives/TooltipTrigger.tsx";
|
|
39
|
+
export type { TooltipTriggerProps, TooltipTriggerBindings } from "./primitives/TooltipTrigger.tsx";
|
|
38
40
|
export type { TooltipProps } from "./primitives/Tooltip.tsx";
|
|
39
41
|
export { Popover } from "./primitives/Popover.tsx";
|
|
40
42
|
export type { PopoverProps } from "./primitives/Popover.tsx";
|
package/dist/index.js
CHANGED
|
@@ -17,70 +17,71 @@ import { ShortcutSheet as w } from "./primitives/ShortcutSheet.js";
|
|
|
17
17
|
import { ShortcutPending as T } from "./primitives/ShortcutPending.js";
|
|
18
18
|
import { ShortcutScope as E } from "./primitives/ShortcutScope.js";
|
|
19
19
|
import { LinkTooltip as D } from "./primitives/LinkTooltip.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
84
|
-
import {
|
|
85
|
-
import {
|
|
86
|
-
|
|
20
|
+
import { TooltipTrigger as O } from "./primitives/TooltipTrigger.js";
|
|
21
|
+
import { Popover as k } from "./primitives/Popover.js";
|
|
22
|
+
import { DropdownMenu as A } from "./primitives/DropdownMenu.js";
|
|
23
|
+
import { ContextMenu as j } from "./primitives/ContextMenu.js";
|
|
24
|
+
import { CommandPalette as M, commandPaletteFilter as N } from "./primitives/CommandPalette.js";
|
|
25
|
+
import { cn as P } from "./utils/cn.js";
|
|
26
|
+
import { flashChange as F } from "./utils/change-motion.js";
|
|
27
|
+
import { useIsWindowFocused as I, useOnlineStatus as L } from "./utils/browser-status.js";
|
|
28
|
+
import { optimistic as R } from "./utils/optimistic.js";
|
|
29
|
+
import { createToaster as z } from "./primitives/create-toaster.js";
|
|
30
|
+
import { Toast as B } from "./primitives/Toast.js";
|
|
31
|
+
import { Toaster as V } from "./primitives/Toaster.js";
|
|
32
|
+
import { englishMessages as H } from "./theme/messages.js";
|
|
33
|
+
import { useDateFormatter as U, useNumberFormatter as W } from "./theme/intl.js";
|
|
34
|
+
import { Center as G, Container as K, Grid as q, Row as J, Spacer as Y, Stack as X } from "./layout/Layout.js";
|
|
35
|
+
import { Code as Z, Heading as Q, Kbd as ne, Prose as re, Text as ie } from "./primitives/Typography.js";
|
|
36
|
+
import { Glyph as ae, glyphNames as oe } from "./primitives/Glyph.js";
|
|
37
|
+
import { createMediaQuery as se, useBreakpoint as ce } from "./utils/media-query.js";
|
|
38
|
+
import { List as le, ListItem as ue } from "./primitives/List.js";
|
|
39
|
+
import { NumberText as de } from "./primitives/NumberText.js";
|
|
40
|
+
import { Badge as fe, Tag as pe } from "./primitives/Status.js";
|
|
41
|
+
import { Card as me, Surface as he } from "./primitives/Surface.js";
|
|
42
|
+
import { Separator as ge } from "./primitives/Separator.js";
|
|
43
|
+
import { Alert as _e, Banner as ve, Callout as ye } from "./primitives/Notice.js";
|
|
44
|
+
import { DescriptionDetails as be, DescriptionList as xe, DescriptionTerm as Se } from "./primitives/DescriptionList.js";
|
|
45
|
+
import { Skeleton as $ } from "./primitives/Skeleton.js";
|
|
46
|
+
import { EmptyState as Ce } from "./primitives/EmptyState.js";
|
|
47
|
+
import { Spinner as we } from "./primitives/Spinner.js";
|
|
48
|
+
import { Field as Te } from "./primitives/Field.js";
|
|
49
|
+
import { InputGroup as Ee } from "./primitives/InputGroup.js";
|
|
50
|
+
import { Form as De, FormActions as Oe, FormSection as ke } from "./primitives/Form.js";
|
|
51
|
+
import { SearchInput as Ae } from "./primitives/SearchInput.js";
|
|
52
|
+
import { Textarea as je } from "./primitives/Textarea.js";
|
|
53
|
+
import { EditableTextField as Me } from "./primitives/EditableTextField.js";
|
|
54
|
+
import { Checkbox as Ne } from "./primitives/Checkbox.js";
|
|
55
|
+
import { Switch as Pe } from "./primitives/Switch.js";
|
|
56
|
+
import { CheckboxGroup as Fe } from "./primitives/CheckboxGroup.js";
|
|
57
|
+
import { RadioGroup as Ie } from "./primitives/RadioGroup.js";
|
|
58
|
+
import { SegmentedControl as Le } from "./primitives/SegmentedControl.js";
|
|
59
|
+
import { TagInput as Re } from "./primitives/TagInput.js";
|
|
60
|
+
import { FileDropzone as ze } from "./primitives/FileDropzone.js";
|
|
61
|
+
import { ActivityTimeline as Be } from "./primitives/ActivityTimeline.js";
|
|
62
|
+
import { Stepper as Ve } from "./primitives/Stepper.js";
|
|
63
|
+
import { Select as He } from "./primitives/Select.js";
|
|
64
|
+
import { Combobox as Ue, MultiCombobox as We } from "./primitives/Combobox.js";
|
|
65
|
+
import { Table as Ge, TableBody as Ke, TableCaption as qe, TableCell as Je, TableFoot as Ye, TableHead as Xe, TableHeaderCell as Ze, TableRow as Qe } from "./primitives/Table.js";
|
|
66
|
+
import { Breadcrumb as $e } from "./primitives/Breadcrumb.js";
|
|
67
|
+
import { Collapsible as et } from "./primitives/Collapsible.js";
|
|
68
|
+
import { Accordion as tt, AccordionItem as nt } from "./primitives/Accordion.js";
|
|
69
|
+
import { Tabs as rt } from "./primitives/Tabs.js";
|
|
70
|
+
import { NavItem as it, NavList as at } from "./primitives/NavList.js";
|
|
71
|
+
import { ScrollArea as ot } from "./primitives/ScrollArea.js";
|
|
72
|
+
import { ButtonGroup as st } from "./primitives/ButtonGroup.js";
|
|
73
|
+
import { IconButton as ct } from "./primitives/IconButton.js";
|
|
74
|
+
import { Link as lt } from "./primitives/Link.js";
|
|
75
|
+
import { Pagination as ut } from "./primitives/Pagination.js";
|
|
76
|
+
import { Avatar as dt, AvatarGroup as ft } from "./primitives/Avatar.js";
|
|
77
|
+
import { Meter as pt, Progress as mt } from "./primitives/Progress.js";
|
|
78
|
+
import { NumberField as ht } from "./primitives/NumberField.js";
|
|
79
|
+
import { RangeSlider as gt, Slider as _t } from "./primitives/Slider.js";
|
|
80
|
+
import { Tree as vt, TreeItem as yt } from "./primitives/Tree.js";
|
|
81
|
+
import { Resizable as bt, ResizableHandle as xt, ResizablePanel as St } from "./primitives/Resizable.js";
|
|
82
|
+
import { PromptInput as Ct } from "./primitives/PromptInput.js";
|
|
83
|
+
import { Message as wt } from "./primitives/Message.js";
|
|
84
|
+
import { Conversation as Tt } from "./primitives/Conversation.js";
|
|
85
|
+
import { StreamingText as Et } from "./primitives/StreamingText.js";
|
|
86
|
+
import { breakpointNames as Dt, breakpointQuery as Ot, breakpoints as kt } from "@gemologic/sheen-tokens/catalog";
|
|
87
|
+
export { tt as Accordion, nt as AccordionItem, Be as ActivityTimeline, _e as Alert, f as AlertDialog, dt as Avatar, ft as AvatarGroup, fe as Badge, ve as Banner, $e as Breadcrumb, o as Button, st as ButtonGroup, ye as Callout, me as Card, G as Center, Ne as Checkbox, Fe as CheckboxGroup, J as Cluster, Z as Code, et as Collapsible, Ue as Combobox, M as CommandPalette, p as ConfirmDialog, K as Container, j as ContextMenu, Tt as Conversation, be as DescriptionDetails, xe as DescriptionList, Se as DescriptionTerm, l as Dialog, u as Drawer, A as DropdownMenu, Me as EditableTextField, Ce as EmptyState, Te as Field, ze as FileDropzone, De as Form, Oe as FormActions, ke as FormSection, ae as Glyph, q as Grid, Q as Heading, ct as IconButton, c as Input, Ee as InputGroup, ne as Kbd, lt as Link, D as LinkTooltip, le as List, ue as ListItem, wt as Message, pt as Meter, We as MultiCombobox, it as NavItem, at as NavList, ht as NumberField, de as NumberText, ut as Pagination, k as Popover, mt as Progress, Ct as PromptInput, re as Prose, Ie as RadioGroup, gt as RangeSlider, bt as Resizable, xt as ResizableHandle, St as ResizablePanel, J as Row, ot as ScrollArea, Ae as SearchInput, Le as SegmentedControl, He as Select, ge as Separator, d as Sheet, T as ShortcutPending, v as ShortcutProvider, E as ShortcutScope, w as ShortcutSheet, $ as Skeleton, _t as Slider, Y as Spacer, we as Spinner, X as Stack, Ve as Stepper, Et as StreamingText, he as Surface, Pe as Switch, Ge as Table, Ke as TableBody, qe as TableCaption, Je as TableCell, Ye as TableFoot, Xe as TableHead, Ze as TableHeaderCell, Qe as TableRow, rt as Tabs, pe as Tag, Re as TagInput, ie as Text, je as Textarea, ee as ThemeProvider, te as ThemeScope, B as Toast, V as Toaster, h as Tooltip, O as TooltipTrigger, vt as Tree, yt as TreeItem, Dt as breakpointNames, Ot as breakpointQuery, kt as breakpoints, s as buttonVariants, P as cn, N as commandPaletteFilter, m as createConfirm, a as createKeyboardHydrationScript, se as createMediaQuery, g as createShortcutRegistry, i as createThemeScript, z as createToaster, t as defaultThemeState, H as englishMessages, F as flashChange, _ as formatShortcut, oe as glyphNames, R as optimistic, n as readThemeState, r as resolveThemeState, ce as useBreakpoint, U as useDateFormatter, I as useIsWindowFocused, W as useNumberFormatter, L as useOnlineStatus, y as usePendingShortcut, b as useShortcut, x as useShortcutBindings, S as useShortcutCommands, C as useShortcutLabel, e as useTheme };
|
package/dist/overlays.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export { Tooltip } from "./primitives/Tooltip.tsx";
|
|
|
12
12
|
export type { TooltipProps } from "./primitives/Tooltip.tsx";
|
|
13
13
|
export { LinkTooltip } from "./primitives/LinkTooltip.tsx";
|
|
14
14
|
export type { LinkTooltipProps } from "./primitives/LinkTooltip.tsx";
|
|
15
|
+
export { TooltipTrigger } from "./primitives/TooltipTrigger.tsx";
|
|
16
|
+
export type { TooltipTriggerProps, TooltipTriggerBindings } from "./primitives/TooltipTrigger.tsx";
|
|
15
17
|
export { Popover } from "./primitives/Popover.tsx";
|
|
16
18
|
export type { PopoverProps } from "./primitives/Popover.tsx";
|
|
17
19
|
export { DropdownMenu } from "./primitives/DropdownMenu.tsx";
|
package/dist/overlays.js
CHANGED
|
@@ -5,11 +5,12 @@ import { ConfirmDialog as i } from "./primitives/ConfirmDialog.js";
|
|
|
5
5
|
import { createConfirm as a } from "./primitives/create-confirm.js";
|
|
6
6
|
import { Tooltip as o } from "./primitives/Tooltip.js";
|
|
7
7
|
import { LinkTooltip as s } from "./primitives/LinkTooltip.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
8
|
+
import { TooltipTrigger as c } from "./primitives/TooltipTrigger.js";
|
|
9
|
+
import { Popover as l } from "./primitives/Popover.js";
|
|
10
|
+
import { DropdownMenu as u } from "./primitives/DropdownMenu.js";
|
|
11
|
+
import { ContextMenu as d } from "./primitives/ContextMenu.js";
|
|
12
|
+
import { CommandPalette as f, commandPaletteFilter as p } from "./primitives/CommandPalette.js";
|
|
13
|
+
import { createToaster as m } from "./primitives/create-toaster.js";
|
|
14
|
+
import { Toast as h } from "./primitives/Toast.js";
|
|
15
|
+
import { Toaster as g } from "./primitives/Toaster.js";
|
|
16
|
+
export { r as AlertDialog, f as CommandPalette, i as ConfirmDialog, d as ContextMenu, e as Dialog, t as Drawer, u as DropdownMenu, s as LinkTooltip, l as Popover, n as Sheet, h as Toast, g as Toaster, o as Tooltip, c as TooltipTrigger, p as commandPaletteFilter, a as createConfirm, m as createToaster };
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import type { JSX } from "solid-js";
|
|
2
|
-
|
|
2
|
+
/** Exactly one accessible name source for the native input. */
|
|
3
|
+
export type BooleanControlName = {
|
|
4
|
+
label: string;
|
|
5
|
+
"aria-label"?: never;
|
|
6
|
+
"aria-labelledby"?: never;
|
|
7
|
+
} | {
|
|
8
|
+
label?: never;
|
|
9
|
+
"aria-label": string;
|
|
10
|
+
"aria-labelledby"?: never;
|
|
11
|
+
} | {
|
|
12
|
+
label?: never;
|
|
13
|
+
"aria-label"?: never;
|
|
14
|
+
"aria-labelledby": string;
|
|
15
|
+
};
|
|
16
|
+
export interface BooleanControlBaseProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children" | "onChange" | "id" | "ref" | "onPointerDown" | "aria-label" | "aria-labelledby" | `use:${string}`> {
|
|
3
17
|
id?: string;
|
|
4
18
|
ref?: HTMLDivElement | ((element: HTMLDivElement) => void);
|
|
5
19
|
onPointerDown?: NonNullable<JSX.HTMLAttributes<HTMLDivElement>["onPointerDown"]>;
|
|
6
|
-
label: string;
|
|
7
20
|
description?: string;
|
|
8
21
|
error?: string;
|
|
9
22
|
checked?: boolean;
|
|
@@ -18,5 +31,6 @@ export interface CheckboxProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>,
|
|
|
18
31
|
value?: string;
|
|
19
32
|
inputRef?: (element: HTMLInputElement) => void;
|
|
20
33
|
}
|
|
34
|
+
export type CheckboxProps = BooleanControlBaseProps & BooleanControlName;
|
|
21
35
|
export declare function createNativeBooleanControl(props: CheckboxProps, kind: "checkbox" | "switch"): JSX.Element;
|
|
22
36
|
export declare function Checkbox(props: CheckboxProps): JSX.Element;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { cn as e } from "../utils/cn.js";
|
|
2
2
|
import { createBooleanInputState as t } from "./boolean-input-state.js";
|
|
3
|
-
import { className as n, createComponent as r,
|
|
4
|
-
import { Show as
|
|
3
|
+
import { className as n, createComponent as r, effect as i, insert as a, mergeProps as o, setAttribute as s, spread as c, template as l, use as u } from "solid-js/web";
|
|
4
|
+
import { Show as d, createUniqueId as f, splitProps as p } from "solid-js";
|
|
5
5
|
// src/primitives/Checkbox.tsx
|
|
6
|
-
var
|
|
7
|
-
function b(
|
|
8
|
-
let [
|
|
6
|
+
var m = /*#__PURE__*/ l("<p>"), h = /*#__PURE__*/ l("<div><div><input type=checkbox><span aria-hidden=true>"), g = /*#__PURE__*/ l("<span class=sheen-checkbox-indicator><span class=sheen-checkbox-mark>"), _ = /*#__PURE__*/ l("<span class=sheen-switch-thumb>"), v = /*#__PURE__*/ l("<span aria-hidden=true> *"), y = /*#__PURE__*/ l("<label>");
|
|
7
|
+
function b(l, b) {
|
|
8
|
+
let [x, S, C] = p(l, [
|
|
9
9
|
"label",
|
|
10
|
+
"aria-label",
|
|
11
|
+
"aria-labelledby",
|
|
10
12
|
"description",
|
|
11
13
|
"error",
|
|
12
14
|
"class",
|
|
@@ -22,56 +24,64 @@ function b(i, u) {
|
|
|
22
24
|
"required",
|
|
23
25
|
"name",
|
|
24
26
|
"value"
|
|
25
|
-
]),
|
|
27
|
+
]), w = `sheen-${b}`, T = f(), E = `${T}-input`, D = () => [x.description ? `${T}-description` : "", x.error ? `${T}-error` : ""].filter(Boolean).join(" ") || void 0, { checked: O, requestChange: k, setInput: A } = t(S, (e) => x.onCheckedChange?.(e));
|
|
26
28
|
return (() => {
|
|
27
|
-
var t =
|
|
28
|
-
return
|
|
29
|
+
var t = h(), l = t.firstChild, f = l.firstChild, p = f.nextSibling;
|
|
30
|
+
return c(t, o(C, {
|
|
29
31
|
get class() {
|
|
30
|
-
return e(
|
|
32
|
+
return e(w, x.class);
|
|
31
33
|
},
|
|
32
34
|
get "data-checked"() {
|
|
33
35
|
return O() || void 0;
|
|
34
36
|
},
|
|
35
37
|
get "data-indeterminate"() {
|
|
36
|
-
return
|
|
38
|
+
return S.indeterminate || void 0;
|
|
37
39
|
},
|
|
38
40
|
get "data-disabled"() {
|
|
39
|
-
return
|
|
41
|
+
return S.disabled || void 0;
|
|
40
42
|
},
|
|
41
43
|
get "data-readonly"() {
|
|
42
|
-
return
|
|
44
|
+
return S.readOnly || void 0;
|
|
43
45
|
},
|
|
44
46
|
get "data-invalid"() {
|
|
45
|
-
return
|
|
47
|
+
return x.error ? "" : void 0;
|
|
46
48
|
}
|
|
47
|
-
}), !1, !0), n(
|
|
48
|
-
|
|
49
|
-
},
|
|
49
|
+
}), !1, !0), n(l, `${w}-row`), f.addEventListener("change", (e) => k(e.currentTarget)), u((e) => {
|
|
50
|
+
A(e), x.inputRef?.(e);
|
|
51
|
+
}, f), s(f, "id", E), s(f, "role", b === "switch" ? "switch" : void 0), n(f, `${w}-input`), n(p, `${w}-control`), a(p, b === "checkbox" ? g() : _()), a(l, r(d, {
|
|
50
52
|
get when() {
|
|
51
|
-
return x.
|
|
53
|
+
return x.label;
|
|
52
54
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
children: (e) => (() => {
|
|
56
|
+
var t = y();
|
|
57
|
+
return s(t, "for", E), n(t, `${w}-label`), a(t, e, null), a(t, r(d, {
|
|
58
|
+
get when() {
|
|
59
|
+
return S.required;
|
|
60
|
+
},
|
|
61
|
+
get children() {
|
|
62
|
+
return v();
|
|
63
|
+
}
|
|
64
|
+
}), null), t;
|
|
65
|
+
})()
|
|
66
|
+
}), null), a(t, r(d, {
|
|
57
67
|
get when() {
|
|
58
|
-
return
|
|
68
|
+
return x.description;
|
|
59
69
|
},
|
|
60
70
|
get children() {
|
|
61
|
-
var e =
|
|
62
|
-
return
|
|
71
|
+
var e = m();
|
|
72
|
+
return s(e, "id", `${T}-description`), n(e, `${w}-description`), a(e, () => x.description), e;
|
|
63
73
|
}
|
|
64
|
-
}), null),
|
|
74
|
+
}), null), a(t, r(d, {
|
|
65
75
|
get when() {
|
|
66
|
-
return
|
|
76
|
+
return x.error;
|
|
67
77
|
},
|
|
68
78
|
get children() {
|
|
69
|
-
var e =
|
|
70
|
-
return
|
|
79
|
+
var e = m();
|
|
80
|
+
return s(e, "id", `${T}-error`), n(e, `${w}-error`), a(e, () => x.error), e;
|
|
71
81
|
}
|
|
72
|
-
}), null),
|
|
73
|
-
var t =
|
|
74
|
-
return t !== e.e &&
|
|
82
|
+
}), null), i((e) => {
|
|
83
|
+
var t = S.name ?? "", n = x.form, r = S.disabled, i = S.required, a = S.readOnly, o = x["aria-label"], c = x["aria-labelledby"], l = S.readOnly || void 0, u = x.error ? "true" : void 0, d = D(), m = S.indeterminate || void 0;
|
|
84
|
+
return t !== e.e && s(f, "name", e.e = t), n !== e.t && s(f, "form", e.t = n), r !== e.a && (f.disabled = e.a = r), i !== e.o && (f.required = e.o = i), a !== e.i && (f.readOnly = e.i = a), o !== e.n && s(f, "aria-label", e.n = o), c !== e.s && s(f, "aria-labelledby", e.s = c), l !== e.h && s(f, "aria-readonly", e.h = l), u !== e.r && s(f, "aria-invalid", e.r = u), d !== e.d && s(f, "aria-describedby", e.d = d), m !== e.l && s(p, "data-indeterminate", e.l = m), e;
|
|
75
85
|
}, {
|
|
76
86
|
e: void 0,
|
|
77
87
|
t: void 0,
|
|
@@ -81,12 +91,13 @@ function b(i, u) {
|
|
|
81
91
|
n: void 0,
|
|
82
92
|
s: void 0,
|
|
83
93
|
h: void 0,
|
|
84
|
-
r: void 0
|
|
85
|
-
|
|
94
|
+
r: void 0,
|
|
95
|
+
d: void 0,
|
|
96
|
+
l: void 0
|
|
97
|
+
}), i(() => f.value = S.value), i(() => f.checked = O()), t;
|
|
86
98
|
})();
|
|
87
99
|
}
|
|
88
100
|
function x(e) {
|
|
89
101
|
return b(e, "checkbox");
|
|
90
102
|
}
|
|
91
|
-
i(["click"]);
|
|
92
103
|
export { x as Checkbox, b as createNativeBooleanControl };
|
|
@@ -5,6 +5,10 @@ export interface CommandPaletteCommand {
|
|
|
5
5
|
readonly group: string;
|
|
6
6
|
readonly keywords?: readonly string[];
|
|
7
7
|
readonly disabled?: boolean;
|
|
8
|
+
/** Renders decorative leading content, hidden from assistive technology. */
|
|
9
|
+
readonly icon?: () => JSX.Element;
|
|
10
|
+
/** Renders trailing content such as a shortcut hint or badge, exposed as the option's description. */
|
|
11
|
+
readonly trailing?: () => JSX.Element;
|
|
8
12
|
readonly run: () => void | Promise<void>;
|
|
9
13
|
}
|
|
10
14
|
export interface CommandPaletteStaticSource {
|
|
@@ -2,28 +2,28 @@ import { useTheme as e } from "../theme/ThemeProvider.js";
|
|
|
2
2
|
import { cn as t } from "../utils/cn.js";
|
|
3
3
|
import { useModalShortcutScope as n, useShortcut as r, useShortcutCommands as i } from "./ShortcutProvider.js";
|
|
4
4
|
import { Kbd as a, Text as o } from "./Typography.js";
|
|
5
|
-
import { createComponent as s, insert as c, mergeProps as l,
|
|
6
|
-
import { For as
|
|
7
|
-
import * as
|
|
8
|
-
import { Command as
|
|
5
|
+
import { createComponent as s, insert as c, mergeProps as l, setAttribute as u, template as d } from "solid-js/web";
|
|
6
|
+
import { For as f, Show as p, createEffect as m, createMemo as h, createSignal as g, createUniqueId as _, onCleanup as v, splitProps as y } from "solid-js";
|
|
7
|
+
import * as b from "#sheen-kobalte/dialog";
|
|
8
|
+
import { Command as x } from "#sheen-cmdk";
|
|
9
9
|
// src/primitives/CommandPalette.tsx
|
|
10
|
-
var
|
|
11
|
-
function
|
|
10
|
+
var S = /*#__PURE__*/ d("<span class=sheen-command-icon aria-hidden=true>"), C = /*#__PURE__*/ d("<span class=sheen-command-label>"), w = /*#__PURE__*/ d("<span class=sheen-command-trailing>"), T = /*#__PURE__*/ d("<div role=alert>");
|
|
11
|
+
function E(e, t) {
|
|
12
12
|
let n = e.trim();
|
|
13
13
|
if (!n) throw Error(`CommandPalette ${t} must be nonempty`);
|
|
14
14
|
return n;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function D(e, t) {
|
|
17
17
|
let n = /* @__PURE__ */ new Set();
|
|
18
18
|
return Object.freeze(e.map((e) => {
|
|
19
|
-
let r =
|
|
19
|
+
let r = E(e.id, `${t} command id`);
|
|
20
20
|
if (n.has(r)) throw Error(`CommandPalette ${t} has duplicate command id: ${r}`);
|
|
21
|
-
n.add(r),
|
|
22
|
-
for (let t of e.keywords ?? [])
|
|
21
|
+
n.add(r), E(e.label, `${r} label`), E(e.group, `${r} group`);
|
|
22
|
+
for (let t of e.keywords ?? []) E(t, `${r} keyword`);
|
|
23
23
|
return e;
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function O(e, t) {
|
|
27
27
|
let n = Array.from(e.toLocaleLowerCase("en-US")), r = Array.from(t.toLocaleLowerCase("en-US")), i = 0, a = 0;
|
|
28
28
|
for (let e of r) {
|
|
29
29
|
let t = n.indexOf(e, i);
|
|
@@ -32,24 +32,24 @@ function T(e, t) {
|
|
|
32
32
|
}
|
|
33
33
|
return Math.max(.1, .55 - a / Math.max(n.length, 1) * .2);
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function k(e, t, n = []) {
|
|
36
36
|
let r = t.trim().toLocaleLowerCase("en-US");
|
|
37
37
|
if (!r) return 1;
|
|
38
38
|
let i = [e, ...n].map((e) => e.toLocaleLowerCase("en-US")), a = 0;
|
|
39
|
-
for (let e of i) a = e === r ? Math.max(a, 1) : e.startsWith(r) ? Math.max(a, .9) : e.includes(r) ? Math.max(a, .7) : Math.max(a,
|
|
39
|
+
for (let e of i) a = e === r ? Math.max(a, 1) : e.startsWith(r) ? Math.max(a, .9) : e.includes(r) ? Math.max(a, .7) : Math.max(a, O(e, r));
|
|
40
40
|
return a;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function A(e) {
|
|
43
43
|
let t = /* @__PURE__ */ new Set();
|
|
44
44
|
for (let n of e) {
|
|
45
|
-
let e =
|
|
45
|
+
let e = E(n, "recent id");
|
|
46
46
|
if (t.has(e)) throw Error(`CommandPalette has duplicate recent id: ${e}`);
|
|
47
47
|
t.add(e);
|
|
48
48
|
}
|
|
49
49
|
return Object.freeze([...t]);
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
let
|
|
51
|
+
function j(d) {
|
|
52
|
+
let E = e(), O = i(), [j] = y(d, [
|
|
53
53
|
"sources",
|
|
54
54
|
"open",
|
|
55
55
|
"defaultOpen",
|
|
@@ -59,44 +59,44 @@ function O(u) {
|
|
|
59
59
|
"onSourceError",
|
|
60
60
|
"onCommandError",
|
|
61
61
|
"class"
|
|
62
|
-
]), [
|
|
63
|
-
e !==
|
|
64
|
-
},
|
|
62
|
+
]), [M, N] = g(j.defaultOpen ?? !1), [P, F] = g(""), [I, L] = g(!1), [R, z] = g(), [B, V] = g(A(j.recents?.initialIds ?? [])), H = j.sources.flatMap((e) => e.kind === "remote" ? e.initialCommands ?? [] : []), [U, W] = g(D(H, "initial remote results")), G = 0, K = () => j.open === void 0 ? M() : j.open, q = (e) => {
|
|
63
|
+
e !== K() && (j.open === void 0 && N(e), e || F(""), j.onOpenChange?.(e));
|
|
64
|
+
}, J = _();
|
|
65
65
|
r({
|
|
66
66
|
keys: "mod+k",
|
|
67
|
-
scope:
|
|
68
|
-
label:
|
|
67
|
+
scope: j.shortcutScope ?? "global",
|
|
68
|
+
label: E.messages().openCommandPalette,
|
|
69
69
|
group: "Navigation",
|
|
70
|
-
run: () =>
|
|
71
|
-
}), n(() => `command-palette:${
|
|
72
|
-
|
|
70
|
+
run: () => q(!K())
|
|
71
|
+
}), n(() => `command-palette:${J}`, K), m(() => {
|
|
72
|
+
K() && v(E.layers.register(J));
|
|
73
73
|
});
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
let e =
|
|
74
|
+
let Y = h((e) => K() ? E.layers.zIndex(J) : e ?? 100), ee = h(() => D(j.sources.flatMap((e) => e.kind === "static" ? e.commands : []), "static sources"));
|
|
75
|
+
m(() => {
|
|
76
|
+
let e = P().trim(), t = j.sources.flatMap((t) => t.kind === "remote" && e.length >= (t.minimumQueryLength ?? 1) ? [t] : []), n = ++G;
|
|
77
77
|
if (!t.length) {
|
|
78
|
-
|
|
78
|
+
L(!1), z(void 0);
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
let r = new AbortController();
|
|
82
|
-
|
|
82
|
+
L(!0), z(void 0), Promise.all(t.map(async (t) => ({
|
|
83
83
|
source: t,
|
|
84
84
|
commands: await t.search(e, r.signal)
|
|
85
85
|
}))).then((e) => {
|
|
86
|
-
if (n !==
|
|
87
|
-
let t = /* @__PURE__ */ new Set(), i = e.flatMap((e) =>
|
|
86
|
+
if (n !== G || r.signal.aborted) return;
|
|
87
|
+
let t = /* @__PURE__ */ new Set(), i = e.flatMap((e) => D(e.commands, `source ${e.source.id}`)).map((e) => {
|
|
88
88
|
if (t.has(e.id)) throw Error(`CommandPalette remote sources have duplicate command id: ${e.id}`);
|
|
89
89
|
return t.add(e.id), e;
|
|
90
90
|
});
|
|
91
|
-
|
|
91
|
+
W(Object.freeze(i)), L(!1);
|
|
92
92
|
}).catch((e) => {
|
|
93
|
-
if (!(n !==
|
|
94
|
-
|
|
95
|
-
for (let n of t)
|
|
93
|
+
if (!(n !== G || r.signal.aborted)) {
|
|
94
|
+
L(!1), z(E.messages().commandSourceFailed);
|
|
95
|
+
for (let n of t) j.onSourceError?.(n.id, e);
|
|
96
96
|
}
|
|
97
|
-
}),
|
|
97
|
+
}), v(() => r.abort());
|
|
98
98
|
});
|
|
99
|
-
let
|
|
99
|
+
let te = h(() => O.bindings().filter((e) => !e.shadowed && (e.keys !== "mod+k" || e.label !== E.messages().openCommandPalette)).map((e) => Object.freeze({
|
|
100
100
|
id: `shortcut:${e.id}`,
|
|
101
101
|
label: e.label,
|
|
102
102
|
group: e.group,
|
|
@@ -106,48 +106,48 @@ function O(u) {
|
|
|
106
106
|
e.scope
|
|
107
107
|
],
|
|
108
108
|
run: () => {
|
|
109
|
-
|
|
109
|
+
O.run(e.id);
|
|
110
110
|
}
|
|
111
|
-
}))),
|
|
111
|
+
}))), X = h(() => {
|
|
112
112
|
let e = [
|
|
113
|
-
...
|
|
114
|
-
...
|
|
115
|
-
...
|
|
113
|
+
...ee(),
|
|
114
|
+
...U(),
|
|
115
|
+
...te()
|
|
116
116
|
], t = /* @__PURE__ */ new Set();
|
|
117
117
|
for (let n of e) {
|
|
118
118
|
if (t.has(n.id)) throw Error(`CommandPalette has duplicate command id: ${n.id}`);
|
|
119
119
|
t.add(n.id);
|
|
120
120
|
}
|
|
121
121
|
return e;
|
|
122
|
-
}),
|
|
123
|
-
let t =
|
|
122
|
+
}), ne = h(() => new Map(X().map((e) => [e.id, e]))), Z = h(() => P().trim() ? [] : B().flatMap((e) => {
|
|
123
|
+
let t = ne().get(e);
|
|
124
124
|
return t && !t.disabled ? [t] : [];
|
|
125
|
-
})),
|
|
126
|
-
let t =
|
|
125
|
+
})), Q = h(() => new Set(Z().map((e) => e.id))), re = h(() => [...new Set(X().filter((e) => !Q().has(e.id)).map((e) => e.group))]), ie = (e) => {
|
|
126
|
+
let t = j.recents;
|
|
127
127
|
if (!t || e.startsWith("shortcut:")) return;
|
|
128
128
|
let n = t.limit ?? 5;
|
|
129
129
|
if (!Number.isSafeInteger(n) || n < 1) throw Error("CommandPalette recent limit must be a positive integer");
|
|
130
|
-
let r = Object.freeze([e, ...
|
|
131
|
-
|
|
130
|
+
let r = Object.freeze([e, ...B().filter((t) => t !== e)].slice(0, n));
|
|
131
|
+
V(r);
|
|
132
132
|
try {
|
|
133
133
|
let e = t.save(r);
|
|
134
134
|
e instanceof Promise && e.catch(t.onError);
|
|
135
135
|
} catch (e) {
|
|
136
136
|
t.onError(e);
|
|
137
137
|
}
|
|
138
|
-
},
|
|
138
|
+
}, ae = (e) => {
|
|
139
139
|
if (!e.disabled) {
|
|
140
|
-
|
|
140
|
+
q(!1), ie(e.id);
|
|
141
141
|
try {
|
|
142
142
|
let t = e.run();
|
|
143
|
-
t instanceof Promise && t.catch((t) =>
|
|
143
|
+
t instanceof Promise && t.catch((t) => j.onCommandError?.(e.id, t));
|
|
144
144
|
} catch (t) {
|
|
145
|
-
|
|
145
|
+
j.onCommandError?.(e.id, t);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
}, $ = (e) => {
|
|
149
|
-
let t = () =>
|
|
150
|
-
return s(
|
|
149
|
+
let t = () => O.bindings().find((t) => `shortcut:${t.id}` === e.id), n = _(), r = () => e.trailing !== void 0 || t() !== void 0;
|
|
150
|
+
return s(x.Item, l({
|
|
151
151
|
get value() {
|
|
152
152
|
return `${e.id} ${e.label}`;
|
|
153
153
|
},
|
|
@@ -155,105 +155,129 @@ function O(u) {
|
|
|
155
155
|
return [...e.keywords ?? []];
|
|
156
156
|
}
|
|
157
157
|
}, () => e.disabled === void 0 ? {} : { disabled: e.disabled }, {
|
|
158
|
-
onSelect: () =>
|
|
158
|
+
onSelect: () => ae(e),
|
|
159
|
+
"aria-labelledby": `${n}-label`,
|
|
160
|
+
get "aria-describedby"() {
|
|
161
|
+
return r() ? `${n}-trailing` : void 0;
|
|
162
|
+
},
|
|
159
163
|
get children() {
|
|
160
|
-
return [
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
164
|
+
return [
|
|
165
|
+
s(p, {
|
|
166
|
+
get when() {
|
|
167
|
+
return e.icon !== void 0;
|
|
168
|
+
},
|
|
169
|
+
get children() {
|
|
170
|
+
var t = S();
|
|
171
|
+
return c(t, () => e.icon?.()), t;
|
|
172
|
+
}
|
|
173
|
+
}),
|
|
174
|
+
(() => {
|
|
175
|
+
var t = C();
|
|
176
|
+
return u(t, "id", `${n}-label`), c(t, () => e.label), t;
|
|
177
|
+
})(),
|
|
178
|
+
s(p, {
|
|
179
|
+
get when() {
|
|
180
|
+
return r();
|
|
181
|
+
},
|
|
182
|
+
get children() {
|
|
183
|
+
var r = w();
|
|
184
|
+
return u(r, "id", `${n}-trailing`), c(r, () => e.trailing?.(), null), c(r, s(p, {
|
|
185
|
+
get when() {
|
|
186
|
+
return t();
|
|
187
|
+
},
|
|
188
|
+
children: (e) => s(a, { get children() {
|
|
189
|
+
return e().displayKeys;
|
|
190
|
+
} })
|
|
191
|
+
}), null), r;
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
];
|
|
171
195
|
}
|
|
172
196
|
}));
|
|
173
197
|
};
|
|
174
|
-
return s(
|
|
198
|
+
return s(b.Root, {
|
|
175
199
|
get open() {
|
|
176
|
-
return
|
|
200
|
+
return K();
|
|
177
201
|
},
|
|
178
|
-
onOpenChange:
|
|
202
|
+
onOpenChange: q,
|
|
179
203
|
get children() {
|
|
180
|
-
return s(
|
|
204
|
+
return s(p, {
|
|
181
205
|
get when() {
|
|
182
|
-
return
|
|
206
|
+
return E.portal();
|
|
183
207
|
},
|
|
184
|
-
children: (e) => s(
|
|
208
|
+
children: (e) => s(b.Portal, {
|
|
185
209
|
get mount() {
|
|
186
210
|
return e();
|
|
187
211
|
},
|
|
188
212
|
get children() {
|
|
189
|
-
return [s(
|
|
213
|
+
return [s(b.Overlay, {
|
|
190
214
|
class: "sheen-command-overlay",
|
|
191
215
|
get style() {
|
|
192
|
-
return { "z-index":
|
|
216
|
+
return { "z-index": Y() };
|
|
193
217
|
}
|
|
194
|
-
}), s(
|
|
218
|
+
}), s(b.Content, {
|
|
195
219
|
class: "sheen-command-dialog",
|
|
196
220
|
get style() {
|
|
197
|
-
return { "z-index":
|
|
221
|
+
return { "z-index": Y() + 1 };
|
|
198
222
|
},
|
|
199
223
|
get "aria-label"() {
|
|
200
|
-
return
|
|
224
|
+
return E.messages().commandPalette;
|
|
201
225
|
},
|
|
202
226
|
onEscapeKeyDown: (e) => {
|
|
203
|
-
|
|
227
|
+
E.layers.isTop(J) || e.preventDefault();
|
|
204
228
|
},
|
|
205
229
|
get children() {
|
|
206
|
-
return s(
|
|
230
|
+
return s(x, {
|
|
207
231
|
get class() {
|
|
208
|
-
return t("sheen-command-palette",
|
|
232
|
+
return t("sheen-command-palette", j.class);
|
|
209
233
|
},
|
|
210
234
|
get label() {
|
|
211
|
-
return
|
|
235
|
+
return E.messages().commandPalette;
|
|
212
236
|
},
|
|
213
|
-
filter: (e, t, n) =>
|
|
237
|
+
filter: (e, t, n) => k(e, t, n),
|
|
214
238
|
loop: !0,
|
|
215
239
|
get "data-refreshing"() {
|
|
216
|
-
return
|
|
240
|
+
return I() || void 0;
|
|
217
241
|
},
|
|
218
242
|
get children() {
|
|
219
|
-
return [s(
|
|
243
|
+
return [s(x.Input, {
|
|
220
244
|
get value() {
|
|
221
|
-
return
|
|
245
|
+
return P();
|
|
222
246
|
},
|
|
223
|
-
onValueChange:
|
|
247
|
+
onValueChange: F,
|
|
224
248
|
get placeholder() {
|
|
225
|
-
return
|
|
249
|
+
return E.messages().searchCommands;
|
|
226
250
|
},
|
|
227
251
|
get "aria-label"() {
|
|
228
|
-
return
|
|
252
|
+
return E.messages().searchCommands;
|
|
229
253
|
}
|
|
230
|
-
}), s(
|
|
254
|
+
}), s(x.List, {
|
|
231
255
|
get label() {
|
|
232
|
-
return
|
|
256
|
+
return E.messages().commandResults;
|
|
233
257
|
},
|
|
234
258
|
get children() {
|
|
235
259
|
return [
|
|
236
|
-
s(
|
|
260
|
+
s(p, {
|
|
237
261
|
get when() {
|
|
238
|
-
return
|
|
262
|
+
return I();
|
|
239
263
|
},
|
|
240
264
|
get children() {
|
|
241
|
-
return s(
|
|
265
|
+
return s(x.Loading, {
|
|
242
266
|
get label() {
|
|
243
|
-
return
|
|
267
|
+
return E.messages().loading;
|
|
244
268
|
},
|
|
245
269
|
get children() {
|
|
246
|
-
return
|
|
270
|
+
return E.messages().refreshingCommands;
|
|
247
271
|
}
|
|
248
272
|
});
|
|
249
273
|
}
|
|
250
274
|
}),
|
|
251
|
-
s(
|
|
275
|
+
s(p, {
|
|
252
276
|
get when() {
|
|
253
|
-
return
|
|
277
|
+
return R();
|
|
254
278
|
},
|
|
255
279
|
children: (e) => (() => {
|
|
256
|
-
var t =
|
|
280
|
+
var t = T();
|
|
257
281
|
return c(t, s(o, {
|
|
258
282
|
tone: "muted",
|
|
259
283
|
get children() {
|
|
@@ -262,22 +286,22 @@ function O(u) {
|
|
|
262
286
|
})), t;
|
|
263
287
|
})()
|
|
264
288
|
}),
|
|
265
|
-
s(
|
|
266
|
-
return
|
|
289
|
+
s(x.Empty, { get children() {
|
|
290
|
+
return E.messages().noResults;
|
|
267
291
|
} }),
|
|
268
|
-
s(
|
|
292
|
+
s(p, {
|
|
269
293
|
get when() {
|
|
270
|
-
return
|
|
294
|
+
return Z().length;
|
|
271
295
|
},
|
|
272
296
|
get children() {
|
|
273
|
-
return s(
|
|
297
|
+
return s(x.Group, {
|
|
274
298
|
get heading() {
|
|
275
|
-
return
|
|
299
|
+
return E.messages().recentCommands;
|
|
276
300
|
},
|
|
277
301
|
get children() {
|
|
278
|
-
return s(
|
|
302
|
+
return s(f, {
|
|
279
303
|
get each() {
|
|
280
|
-
return
|
|
304
|
+
return Z();
|
|
281
305
|
},
|
|
282
306
|
children: $
|
|
283
307
|
});
|
|
@@ -285,16 +309,16 @@ function O(u) {
|
|
|
285
309
|
});
|
|
286
310
|
}
|
|
287
311
|
}),
|
|
288
|
-
s(
|
|
312
|
+
s(f, {
|
|
289
313
|
get each() {
|
|
290
|
-
return
|
|
314
|
+
return re();
|
|
291
315
|
},
|
|
292
|
-
children: (e) => s(
|
|
316
|
+
children: (e) => s(x.Group, {
|
|
293
317
|
heading: e,
|
|
294
318
|
get children() {
|
|
295
|
-
return s(
|
|
319
|
+
return s(f, {
|
|
296
320
|
get each() {
|
|
297
|
-
return
|
|
321
|
+
return X().filter((t) => t.group === e && !Q().has(t.id));
|
|
298
322
|
},
|
|
299
323
|
children: $
|
|
300
324
|
});
|
|
@@ -314,4 +338,4 @@ function O(u) {
|
|
|
314
338
|
}
|
|
315
339
|
});
|
|
316
340
|
}
|
|
317
|
-
export {
|
|
341
|
+
export { j as CommandPalette, k as commandPaletteFilter };
|
|
@@ -6,6 +6,7 @@ export interface PopoverProps extends ParentProps {
|
|
|
6
6
|
open?: boolean;
|
|
7
7
|
defaultOpen?: boolean;
|
|
8
8
|
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
disabled?: boolean;
|
|
9
10
|
placement?: "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "right";
|
|
10
11
|
class?: string;
|
|
11
12
|
}
|
|
@@ -16,6 +16,9 @@ function v(t) {
|
|
|
16
16
|
},
|
|
17
17
|
variant: "outline",
|
|
18
18
|
"data-sheen-popover-trigger": "",
|
|
19
|
+
get disabled() {
|
|
20
|
+
return t.disabled;
|
|
21
|
+
},
|
|
19
22
|
"aria-haspopup": "dialog",
|
|
20
23
|
get "aria-expanded"() {
|
|
21
24
|
return n.isOpen();
|
|
@@ -33,7 +36,7 @@ function v(t) {
|
|
|
33
36
|
}
|
|
34
37
|
function y(o) {
|
|
35
38
|
let s = t(), c = p(), [y, b] = f(o.defaultOpen ?? !1), x = () => o.open === void 0 ? y() : o.open, S = (e) => {
|
|
36
|
-
e
|
|
39
|
+
e === x() || e && o.disabled || (o.open === void 0 && b(e), o.onOpenChange?.(e));
|
|
37
40
|
};
|
|
38
41
|
u(() => {
|
|
39
42
|
x() && m(s.layers.register(c));
|
|
@@ -49,9 +52,14 @@ function y(o) {
|
|
|
49
52
|
},
|
|
50
53
|
gutter: 6,
|
|
51
54
|
get children() {
|
|
52
|
-
return [i(v, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
return [i(v, {
|
|
56
|
+
get disabled() {
|
|
57
|
+
return o.disabled ?? !1;
|
|
58
|
+
},
|
|
59
|
+
get children() {
|
|
60
|
+
return o.trigger;
|
|
61
|
+
}
|
|
62
|
+
}), i(l, {
|
|
55
63
|
get when() {
|
|
56
64
|
return s.portal();
|
|
57
65
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { JSX } from "solid-js";
|
|
2
|
-
import type {
|
|
3
|
-
export type SwitchProps = Omit<
|
|
2
|
+
import type { BooleanControlBaseProps, BooleanControlName } from "./Checkbox.tsx";
|
|
3
|
+
export type SwitchProps = Omit<BooleanControlBaseProps, "indeterminate"> & BooleanControlName;
|
|
4
4
|
export declare function Switch(props: SwitchProps): JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
/** Spread onto the one focusable element that owns the tooltip. */
|
|
3
|
+
export interface TooltipTriggerBindings {
|
|
4
|
+
readonly ref: (element: HTMLElement) => void;
|
|
5
|
+
readonly "aria-describedby": string | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface TooltipTriggerProps {
|
|
8
|
+
content: string;
|
|
9
|
+
shortcut?: string;
|
|
10
|
+
tooltipDisabled?: boolean;
|
|
11
|
+
placement?: "top" | "bottom" | "left" | "right";
|
|
12
|
+
openDelay?: number;
|
|
13
|
+
closeDelay?: number;
|
|
14
|
+
"aria-describedby"?: string;
|
|
15
|
+
children: (trigger: TooltipTriggerBindings) => JSX.Element;
|
|
16
|
+
}
|
|
17
|
+
/** Hover/focus help attached to an existing focusable element, without rendering another control. */
|
|
18
|
+
export declare function TooltipTrigger(props: TooltipTriggerProps): JSX.Element;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { TooltipLayer as e, createTooltipLayer as t } from "./tooltip-layer.js";
|
|
2
|
+
import { useShortcutLabel as n } from "./ShortcutProvider.js";
|
|
3
|
+
import { createComponent as r } from "solid-js/web";
|
|
4
|
+
import { onCleanup as i, splitProps as a } from "solid-js";
|
|
5
|
+
import * as o from "#sheen-kobalte/tooltip";
|
|
6
|
+
// src/primitives/TooltipTrigger.tsx
|
|
7
|
+
function s(e, t) {
|
|
8
|
+
typeof e == "function" ? e(t) : Array.isArray(e) && typeof e[0] == "function" && e[0](e[1], t);
|
|
9
|
+
}
|
|
10
|
+
function c(c) {
|
|
11
|
+
let [l] = a(c, [
|
|
12
|
+
"content",
|
|
13
|
+
"shortcut",
|
|
14
|
+
"tooltipDisabled",
|
|
15
|
+
"placement",
|
|
16
|
+
"openDelay",
|
|
17
|
+
"closeDelay",
|
|
18
|
+
"aria-describedby",
|
|
19
|
+
"children"
|
|
20
|
+
]), u, d = t(() => u, () => l.tooltipDisabled ?? !1), f = n(() => l.shortcut), p = (e) => {
|
|
21
|
+
let t = [
|
|
22
|
+
["pointerenter", (t) => s(e.onPointerEnter, t)],
|
|
23
|
+
["pointerleave", (t) => s(e.onPointerLeave, t)],
|
|
24
|
+
["pointerdown", (t) => s(e.onPointerDown, t)],
|
|
25
|
+
["click", (t) => s(e.onClick, t)],
|
|
26
|
+
["focus", (t) => s(e.onFocus, t)],
|
|
27
|
+
["blur", (t) => s(e.onBlur, t)]
|
|
28
|
+
], n = () => {
|
|
29
|
+
for (let [e, n] of t) u?.removeEventListener(e, n);
|
|
30
|
+
};
|
|
31
|
+
return i(n), l.children({
|
|
32
|
+
ref: (r) => {
|
|
33
|
+
n(), u = r;
|
|
34
|
+
for (let [e, n] of t) r.addEventListener(e, n);
|
|
35
|
+
typeof e.ref == "function" && e.ref(r);
|
|
36
|
+
},
|
|
37
|
+
get "aria-describedby"() {
|
|
38
|
+
return [l["aria-describedby"], d.open() ? `${d.id}-content` : void 0].filter(Boolean).join(" ") || void 0;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
return r(o.Root, {
|
|
43
|
+
get open() {
|
|
44
|
+
return d.open();
|
|
45
|
+
},
|
|
46
|
+
get onOpenChange() {
|
|
47
|
+
return d.change;
|
|
48
|
+
},
|
|
49
|
+
get disabled() {
|
|
50
|
+
return l.tooltipDisabled ?? !1;
|
|
51
|
+
},
|
|
52
|
+
get placement() {
|
|
53
|
+
return l.placement ?? "top";
|
|
54
|
+
},
|
|
55
|
+
get openDelay() {
|
|
56
|
+
return l.openDelay ?? 500;
|
|
57
|
+
},
|
|
58
|
+
get closeDelay() {
|
|
59
|
+
return l.closeDelay ?? 100;
|
|
60
|
+
},
|
|
61
|
+
gutter: 6,
|
|
62
|
+
get children() {
|
|
63
|
+
return [r(o.Trigger, {
|
|
64
|
+
as: p,
|
|
65
|
+
"aria-describedby": void 0
|
|
66
|
+
}), r(e, {
|
|
67
|
+
state: d,
|
|
68
|
+
get content() {
|
|
69
|
+
return l.content;
|
|
70
|
+
},
|
|
71
|
+
shortcut: f
|
|
72
|
+
})];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
export { c as TooltipTrigger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gemologic/sheen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Accessible, themeable SolidJS components for application interfaces.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
"@atlaskit/pragmatic-drag-and-drop": "3.1.0",
|
|
159
159
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "3.1.0",
|
|
160
160
|
"@corvu/resizable": "0.2.5",
|
|
161
|
-
"@gemologic/sheen-tokens": "0.
|
|
161
|
+
"@gemologic/sheen-tokens": "0.4.0",
|
|
162
162
|
"@floating-ui/dom": "^1.5.1",
|
|
163
163
|
"@internationalized/number": "^3.2.1",
|
|
164
164
|
"@solid-primitives/event-listener": "^2.2.14",
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,8 @@ export type { ShortcutProviderProps } from "./primitives/ShortcutProvider.tsx";
|
|
|
35
35
|
export type { PendingShortcut, ShortcutAction, ShortcutBinding, ShortcutDefinition, ShortcutInput, ShortcutRegistryOptions } from "./utils/shortcut-registry.ts";
|
|
36
36
|
export { LinkTooltip } from "./primitives/LinkTooltip.tsx";
|
|
37
37
|
export type { LinkTooltipProps } from "./primitives/LinkTooltip.tsx";
|
|
38
|
+
export { TooltipTrigger } from "./primitives/TooltipTrigger.tsx";
|
|
39
|
+
export type { TooltipTriggerProps, TooltipTriggerBindings } from "./primitives/TooltipTrigger.tsx";
|
|
38
40
|
export type { TooltipProps } from "./primitives/Tooltip.tsx";
|
|
39
41
|
export { Popover } from "./primitives/Popover.tsx";
|
|
40
42
|
export type { PopoverProps } from "./primitives/Popover.tsx";
|
package/src/overlays.ts
CHANGED
|
@@ -12,6 +12,8 @@ export { Tooltip } from "./primitives/Tooltip.tsx";
|
|
|
12
12
|
export type { TooltipProps } from "./primitives/Tooltip.tsx";
|
|
13
13
|
export { LinkTooltip } from "./primitives/LinkTooltip.tsx";
|
|
14
14
|
export type { LinkTooltipProps } from "./primitives/LinkTooltip.tsx";
|
|
15
|
+
export { TooltipTrigger } from "./primitives/TooltipTrigger.tsx";
|
|
16
|
+
export type { TooltipTriggerProps, TooltipTriggerBindings } from "./primitives/TooltipTrigger.tsx";
|
|
15
17
|
export { Popover } from "./primitives/Popover.tsx";
|
|
16
18
|
export type { PopoverProps } from "./primitives/Popover.tsx";
|
|
17
19
|
export { DropdownMenu } from "./primitives/DropdownMenu.tsx";
|
|
@@ -3,11 +3,17 @@ import type { JSX } from "solid-js";
|
|
|
3
3
|
import { cn } from "../utils/cn.ts";
|
|
4
4
|
import { createBooleanInputState } from "./boolean-input-state.ts";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/** Exactly one accessible name source for the native input. */
|
|
7
|
+
export type BooleanControlName =
|
|
8
|
+
| { label: string; "aria-label"?: never; "aria-labelledby"?: never }
|
|
9
|
+
| { label?: never; "aria-label": string; "aria-labelledby"?: never }
|
|
10
|
+
| { label?: never; "aria-label"?: never; "aria-labelledby": string };
|
|
11
|
+
|
|
12
|
+
// Directives apply only to native elements, never through a component's props.
|
|
13
|
+
export interface BooleanControlBaseProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children" | "onChange" | "id" | "ref" | "onPointerDown" | "aria-label" | "aria-labelledby" | `use:${string}`> {
|
|
7
14
|
id?: string;
|
|
8
15
|
ref?: HTMLDivElement | ((element: HTMLDivElement) => void);
|
|
9
16
|
onPointerDown?: NonNullable<JSX.HTMLAttributes<HTMLDivElement>["onPointerDown"]>;
|
|
10
|
-
label: string;
|
|
11
17
|
description?: string;
|
|
12
18
|
error?: string;
|
|
13
19
|
checked?: boolean;
|
|
@@ -23,23 +29,24 @@ export interface CheckboxProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>,
|
|
|
23
29
|
inputRef?: (element: HTMLInputElement) => void;
|
|
24
30
|
}
|
|
25
31
|
|
|
32
|
+
export type CheckboxProps = BooleanControlBaseProps & BooleanControlName;
|
|
33
|
+
|
|
26
34
|
export function createNativeBooleanControl(props: CheckboxProps, kind: "checkbox" | "switch"): JSX.Element {
|
|
27
35
|
const [local, state, others] = splitProps(props,
|
|
28
|
-
["label", "description", "error", "class", "onCheckedChange", "inputRef", "form"],
|
|
36
|
+
["label", "aria-label", "aria-labelledby", "description", "error", "class", "onCheckedChange", "inputRef", "form"],
|
|
29
37
|
["checked", "defaultChecked", "indeterminate", "disabled", "readOnly", "required", "name", "value"]);
|
|
30
38
|
const prefix = `sheen-${kind}`;
|
|
31
39
|
const generatedId = createUniqueId();
|
|
32
40
|
const inputId = `${generatedId}-input`;
|
|
33
|
-
let input: HTMLInputElement | undefined;
|
|
34
41
|
const describedBy = () => [local.description ? `${generatedId}-description` : "", local.error ? `${generatedId}-error` : ""].filter(Boolean).join(" ") || undefined;
|
|
35
42
|
const { checked, requestChange, setInput } = createBooleanInputState(state, next => local.onCheckedChange?.(next));
|
|
36
43
|
return <div {...others} class={cn(prefix, local.class)} data-checked={checked() || undefined} data-indeterminate={state.indeterminate || undefined} data-disabled={state.disabled || undefined} data-readonly={state.readOnly || undefined} data-invalid={local.error ? "" : undefined}>
|
|
37
44
|
<div class={`${prefix}-row`}>
|
|
38
|
-
<input id={inputId} type="checkbox" role={kind === "switch" ? "switch" : undefined} name={state.name ?? ""} value={state.value} form={local.form} disabled={state.disabled} required={state.required} readOnly={state.readOnly} checked={checked()} aria-readonly={state.readOnly || undefined} aria-invalid={local.error ? "true" : undefined} aria-describedby={describedBy()} class={`${prefix}-input`} ref={element => {
|
|
39
|
-
<span class={`${prefix}-control`} data-indeterminate={state.indeterminate || undefined} aria-hidden="true"
|
|
45
|
+
<input id={inputId} type="checkbox" role={kind === "switch" ? "switch" : undefined} name={state.name ?? ""} value={state.value} form={local.form} disabled={state.disabled} required={state.required} readOnly={state.readOnly} checked={checked()} aria-label={local["aria-label"]} aria-labelledby={local["aria-labelledby"]} aria-readonly={state.readOnly || undefined} aria-invalid={local.error ? "true" : undefined} aria-describedby={describedBy()} class={`${prefix}-input`} ref={element => { setInput(element); local.inputRef?.(element); }} onChange={event => requestChange(event.currentTarget)} />
|
|
46
|
+
<span class={`${prefix}-control`} data-indeterminate={state.indeterminate || undefined} aria-hidden="true">
|
|
40
47
|
{kind === "checkbox" ? <span class="sheen-checkbox-indicator"><span class="sheen-checkbox-mark" /></span> : <span class="sheen-switch-thumb" />}
|
|
41
48
|
</span>
|
|
42
|
-
<label for={inputId} class={`${prefix}-label`}>{
|
|
49
|
+
<Show when={local.label}>{label => <label for={inputId} class={`${prefix}-label`}>{label()}<Show when={state.required}><span aria-hidden="true"> *</span></Show></label>}</Show>
|
|
43
50
|
</div>
|
|
44
51
|
<Show when={local.description}><p id={`${generatedId}-description`} class={`${prefix}-description`}>{local.description}</p></Show>
|
|
45
52
|
<Show when={local.error}><p id={`${generatedId}-error`} class={`${prefix}-error`}>{local.error}</p></Show>
|
|
@@ -12,6 +12,10 @@ export interface CommandPaletteCommand {
|
|
|
12
12
|
readonly group: string;
|
|
13
13
|
readonly keywords?: readonly string[];
|
|
14
14
|
readonly disabled?: boolean;
|
|
15
|
+
/** Renders decorative leading content, hidden from assistive technology. */
|
|
16
|
+
readonly icon?: () => JSX.Element;
|
|
17
|
+
/** Renders trailing content such as a shortcut hint or badge, exposed as the option's description. */
|
|
18
|
+
readonly trailing?: () => JSX.Element;
|
|
15
19
|
readonly run: () => void | Promise<void>;
|
|
16
20
|
}
|
|
17
21
|
|
|
@@ -208,9 +212,14 @@ export function CommandPalette(props: CommandPaletteProps): JSX.Element {
|
|
|
208
212
|
};
|
|
209
213
|
const item = (command: CommandPaletteCommand) => {
|
|
210
214
|
const binding = () => shortcuts.bindings().find(value => `shortcut:${value.id}` === command.id);
|
|
215
|
+
const id = createUniqueId();
|
|
216
|
+
const described = () => command.trailing !== undefined || binding() !== undefined;
|
|
211
217
|
return <Command.Item value={`${command.id} ${command.label}`} keywords={[...(command.keywords ?? [])]}
|
|
212
|
-
{...(command.disabled === undefined ? {} : { disabled: command.disabled })} onSelect={() => select(command)}
|
|
213
|
-
|
|
218
|
+
{...(command.disabled === undefined ? {} : { disabled: command.disabled })} onSelect={() => select(command)}
|
|
219
|
+
aria-labelledby={`${id}-label`} aria-describedby={described() ? `${id}-trailing` : undefined}>
|
|
220
|
+
<Show when={command.icon !== undefined}><span class="sheen-command-icon" aria-hidden="true">{command.icon?.()}</span></Show>
|
|
221
|
+
<span id={`${id}-label`} class="sheen-command-label">{command.label}</span>
|
|
222
|
+
<Show when={described()}><span id={`${id}-trailing`} class="sheen-command-trailing">{command.trailing?.()}<Show when={binding()}>{value => <Kbd>{value().displayKeys}</Kbd>}</Show></span></Show>
|
|
214
223
|
</Command.Item>;
|
|
215
224
|
};
|
|
216
225
|
|
|
@@ -13,13 +13,14 @@ export interface PopoverProps extends ParentProps {
|
|
|
13
13
|
open?: boolean;
|
|
14
14
|
defaultOpen?: boolean;
|
|
15
15
|
onOpenChange?: (open: boolean) => void;
|
|
16
|
+
disabled?: boolean;
|
|
16
17
|
placement?: "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "right";
|
|
17
18
|
class?: string;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
function PopoverTrigger(props: ParentProps): JSX.Element {
|
|
21
|
+
function PopoverTrigger(props: ParentProps<{ disabled: boolean }>): JSX.Element {
|
|
21
22
|
const context = Primitive.usePopoverContext();
|
|
22
|
-
return <Button ref={context.setTriggerRef} variant="outline" data-sheen-popover-trigger=""
|
|
23
|
+
return <Button ref={context.setTriggerRef} variant="outline" data-sheen-popover-trigger="" disabled={props.disabled}
|
|
23
24
|
aria-haspopup="dialog" aria-expanded={context.isOpen()} aria-controls={context.isOpen() ? context.contentId() : undefined}
|
|
24
25
|
onPointerDown={event => { if (event.pointerType === "mouse") event.preventDefault(); }}
|
|
25
26
|
onClick={() => context.toggle()} {...context.dataset()}>{props.children}</Button>;
|
|
@@ -31,14 +32,14 @@ export function Popover(props: PopoverProps): JSX.Element {
|
|
|
31
32
|
const [draft, setDraft] = createSignal(props.defaultOpen ?? false);
|
|
32
33
|
const open = () => props.open === undefined ? draft() : props.open;
|
|
33
34
|
const change = (next: boolean) => {
|
|
34
|
-
if (next === open()) return;
|
|
35
|
+
if (next === open() || (next && props.disabled)) return;
|
|
35
36
|
if (props.open === undefined) setDraft(next);
|
|
36
37
|
props.onOpenChange?.(next);
|
|
37
38
|
};
|
|
38
39
|
createEffect(() => { if (open()) onCleanup(theme.layers.register(id)); });
|
|
39
40
|
const layer = createMemo<number>(previous => open() ? theme.layers.zIndex(id) : previous ?? 100);
|
|
40
41
|
return <Primitive.Root open={open()} onOpenChange={change} placement={props.placement ?? "bottom"} gutter={6}>
|
|
41
|
-
<PopoverTrigger>{props.trigger}</PopoverTrigger>
|
|
42
|
+
<PopoverTrigger disabled={props.disabled ?? false}>{props.trigger}</PopoverTrigger>
|
|
42
43
|
<Show when={theme.portal()}>{target => <Primitive.Portal mount={target()}>
|
|
43
44
|
<Primitive.Content data-kb-top-layer="true" class={cn("sheen-popover", props.class)} aria-hidden={!open() || undefined} inert={!open()} style={{ "z-index": layer() }}
|
|
44
45
|
onEscapeKeyDown={event => { if (!theme.layers.isTop(id)) event.preventDefault(); }}>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { JSX } from "solid-js";
|
|
2
2
|
import { createNativeBooleanControl } from "./Checkbox.tsx";
|
|
3
|
-
import type {
|
|
3
|
+
import type { BooleanControlBaseProps, BooleanControlName } from "./Checkbox.tsx";
|
|
4
4
|
|
|
5
|
-
export type SwitchProps = Omit<
|
|
5
|
+
export type SwitchProps = Omit<BooleanControlBaseProps, "indeterminate"> & BooleanControlName;
|
|
6
6
|
|
|
7
7
|
export function Switch(props: SwitchProps): JSX.Element {
|
|
8
8
|
return createNativeBooleanControl(props, "switch");
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as Primitive from "#sheen-kobalte/tooltip";
|
|
2
|
+
import type { TooltipTriggerRenderProps } from "#sheen-kobalte/tooltip";
|
|
3
|
+
import { onCleanup, splitProps } from "solid-js";
|
|
4
|
+
import type { JSX } from "solid-js";
|
|
5
|
+
import { createTooltipLayer, TooltipLayer } from "./tooltip-layer.tsx";
|
|
6
|
+
import { useShortcutLabel } from "./ShortcutProvider.tsx";
|
|
7
|
+
|
|
8
|
+
/** Spread onto the one focusable element that owns the tooltip. */
|
|
9
|
+
export interface TooltipTriggerBindings {
|
|
10
|
+
readonly ref: (element: HTMLElement) => void;
|
|
11
|
+
readonly "aria-describedby": string | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TooltipTriggerProps {
|
|
15
|
+
content: string;
|
|
16
|
+
shortcut?: string;
|
|
17
|
+
tooltipDisabled?: boolean;
|
|
18
|
+
placement?: "top" | "bottom" | "left" | "right";
|
|
19
|
+
openDelay?: number;
|
|
20
|
+
closeDelay?: number;
|
|
21
|
+
"aria-describedby"?: string;
|
|
22
|
+
children: (trigger: TooltipTriggerBindings) => JSX.Element;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function callHandler(handler: unknown, event: Event): void {
|
|
26
|
+
if (typeof handler === "function") handler(event);
|
|
27
|
+
else if (Array.isArray(handler) && typeof handler[0] === "function") handler[0](handler[1], event);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Hover/focus help attached to an existing focusable element, without rendering another control. */
|
|
31
|
+
export function TooltipTrigger(props: TooltipTriggerProps): JSX.Element {
|
|
32
|
+
const [local] = splitProps(props, ["content", "shortcut", "tooltipDisabled", "placement", "openDelay", "closeDelay", "aria-describedby", "children"]);
|
|
33
|
+
let trigger: HTMLElement | undefined;
|
|
34
|
+
const state = createTooltipLayer(() => trigger, () => local.tooltipDisabled ?? false);
|
|
35
|
+
const shortcutLabel = useShortcutLabel(() => local.shortcut);
|
|
36
|
+
// Primitive handlers attach natively so the element keeps its own JSX event handlers.
|
|
37
|
+
const Target = (primitive: TooltipTriggerRenderProps): JSX.Element => {
|
|
38
|
+
const listeners: readonly (readonly [string, (event: Event) => void])[] = [
|
|
39
|
+
["pointerenter", event => callHandler(primitive.onPointerEnter, event)], ["pointerleave", event => callHandler(primitive.onPointerLeave, event)],
|
|
40
|
+
["pointerdown", event => callHandler(primitive.onPointerDown, event)], ["click", event => callHandler(primitive.onClick, event)],
|
|
41
|
+
["focus", event => callHandler(primitive.onFocus, event)], ["blur", event => callHandler(primitive.onBlur, event)],
|
|
42
|
+
];
|
|
43
|
+
const detach = () => { for (const [type, listener] of listeners) trigger?.removeEventListener(type, listener); };
|
|
44
|
+
onCleanup(detach);
|
|
45
|
+
return local.children({
|
|
46
|
+
ref: element => {
|
|
47
|
+
detach();
|
|
48
|
+
trigger = element;
|
|
49
|
+
for (const [type, listener] of listeners) element.addEventListener(type, listener);
|
|
50
|
+
if (typeof primitive.ref === "function") primitive.ref(element);
|
|
51
|
+
},
|
|
52
|
+
get "aria-describedby"() { return [local["aria-describedby"], state.open() ? `${state.id}-content` : undefined].filter(Boolean).join(" ") || undefined; },
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
return <Primitive.Root open={state.open()} onOpenChange={state.change} disabled={local.tooltipDisabled ?? false}
|
|
56
|
+
placement={local.placement ?? "top"} openDelay={local.openDelay ?? 500} closeDelay={local.closeDelay ?? 100} gutter={6}>
|
|
57
|
+
<Primitive.Trigger as={Target} aria-describedby={undefined} />
|
|
58
|
+
<TooltipLayer state={state} content={local.content} shortcut={shortcutLabel} />
|
|
59
|
+
</Primitive.Root>;
|
|
60
|
+
}
|
package/src/styles/forms.css
CHANGED
|
@@ -119,8 +119,10 @@
|
|
|
119
119
|
.sheen-checkbox { display: grid; gap: var(--sheen-space-block-xs); }
|
|
120
120
|
.sheen-checkbox[hidden] { display: none; }
|
|
121
121
|
.sheen-checkbox-row { display: flex; align-items: center; gap: var(--sheen-space-inline-md); min-block-size: var(--sheen-control-h-md); position: relative; }
|
|
122
|
-
.sheen-checkbox-input, .sheen-switch-input { position: absolute; inline-size: var(--sheen-icon-size-md); block-size: var(--sheen-icon-size-md); margin: 0; opacity: 0;
|
|
123
|
-
.sheen-
|
|
122
|
+
.sheen-checkbox-input, .sheen-switch-input { position: absolute; inline-size: var(--sheen-icon-size-md); block-size: var(--sheen-icon-size-md); margin: 0; opacity: 0; cursor: pointer; }
|
|
123
|
+
.sheen-switch-input { inline-size: calc(var(--sheen-icon-size-md) * 2); block-size: calc(var(--sheen-icon-size-md) + var(--sheen-space-inline-xs)); }
|
|
124
|
+
:is(.sheen-checkbox-input, .sheen-switch-input):disabled { cursor: default; }
|
|
125
|
+
.sheen-checkbox-control { pointer-events: none; display: grid; place-items: center; flex: 0 0 auto; box-sizing: border-box; inline-size: var(--sheen-icon-size-md); block-size: var(--sheen-icon-size-md); border: var(--sheen-control-border-width) solid var(--sheen-color-border-control); border-radius: var(--sheen-control-radius); background: var(--sheen-color-bg-inset); transition: background-color var(--sheen-duration-fast) var(--sheen-ease-standard), border-color var(--sheen-duration-fast) var(--sheen-ease-standard); }
|
|
124
126
|
:is(.sheen-checkbox-row, .sheen-radio-row):not(:hover, :focus-within, :active) :is(.sheen-checkbox-control, .sheen-radio-control) { transition-property: none; }
|
|
125
127
|
.sheen-checkbox-row:hover .sheen-checkbox-input:not(:disabled, :checked) + .sheen-checkbox-control, .sheen-radio-row:hover .sheen-radio-input:not(:disabled, :checked) + .sheen-radio-control, .sheen-switch-row:hover .sheen-switch-input:not(:disabled, :checked) + .sheen-switch-control { border-color: var(--sheen-color-fg-muted); }
|
|
126
128
|
.sheen-switch-row:not(:hover, :focus-within, :active) :is(.sheen-switch-control, .sheen-switch-thumb) { transition-property: none; }
|
|
@@ -138,7 +140,7 @@
|
|
|
138
140
|
.sheen-switch { display: grid; gap: var(--sheen-space-block-xs); }
|
|
139
141
|
.sheen-switch[hidden] { display: none; }
|
|
140
142
|
.sheen-switch-row { display: flex; align-items: center; gap: var(--sheen-space-inline-md); min-block-size: var(--sheen-control-h-md); position: relative; }
|
|
141
|
-
.sheen-switch-control { display: flex; align-items: center; flex: 0 0 auto; box-sizing: border-box; inline-size: calc(var(--sheen-icon-size-md) * 2); block-size: calc(var(--sheen-icon-size-md) + var(--sheen-space-inline-xs)); padding: var(--sheen-control-border-width); border: var(--sheen-control-border-width) solid var(--sheen-color-border-control); border-radius: calc(var(--sheen-control-radius) * 100); background: var(--sheen-color-bg-inset); transition: background-color var(--sheen-duration-normal) var(--sheen-ease-standard), border-color var(--sheen-duration-fast) var(--sheen-ease-standard); --sheen-switch-travel: calc(var(--sheen-icon-size-md) - var(--sheen-space-inline-xs)); }
|
|
143
|
+
.sheen-switch-control { pointer-events: none; display: flex; align-items: center; flex: 0 0 auto; box-sizing: border-box; inline-size: calc(var(--sheen-icon-size-md) * 2); block-size: calc(var(--sheen-icon-size-md) + var(--sheen-space-inline-xs)); padding: var(--sheen-control-border-width); border: var(--sheen-control-border-width) solid var(--sheen-color-border-control); border-radius: calc(var(--sheen-control-radius) * 100); background: var(--sheen-color-bg-inset); transition: background-color var(--sheen-duration-normal) var(--sheen-ease-standard), border-color var(--sheen-duration-fast) var(--sheen-ease-standard); --sheen-switch-travel: calc(var(--sheen-icon-size-md) - var(--sheen-space-inline-xs)); }
|
|
142
144
|
.sheen-switch-control:dir(rtl) { --sheen-switch-travel: calc(var(--sheen-space-inline-xs) - var(--sheen-icon-size-md)); }
|
|
143
145
|
.sheen-switch-thumb { display: block; block-size: 100%; aspect-ratio: 1; border-radius: calc(var(--sheen-control-radius) * 100); background: var(--sheen-color-fg-muted); box-shadow: 0 1px 2px #00000040; transition: translate var(--sheen-duration-normal) var(--sheen-ease-spring), background-color var(--sheen-duration-fast) var(--sheen-ease-standard), scale var(--sheen-duration-press) var(--sheen-ease-standard); }
|
|
144
146
|
.sheen-switch-row:active .sheen-switch-input:not(:disabled) + .sheen-switch-control .sheen-switch-thumb { scale: 0.9; }
|
package/src/styles/overlays.css
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
.sheen-command-palette [cmdk-list] { max-block-size: min(26rem, 60vh); overflow: auto; padding: var(--sheen-space-block-sm); scroll-padding-block: var(--sheen-space-block-sm); }
|
|
9
9
|
.sheen-command-palette [cmdk-group-heading] { padding-block: var(--sheen-space-block-sm) var(--sheen-space-block-xs); padding-inline: var(--sheen-space-inline-sm); color: var(--sheen-color-fg-muted); font-size: var(--sheen-text-ui-sm-size); font-weight: 600; }
|
|
10
10
|
.sheen-command-palette [cmdk-item] { display: flex; align-items: center; justify-content: space-between; gap: var(--sheen-space-inline-md); min-block-size: var(--sheen-control-h-md); padding-inline: var(--sheen-space-inline-sm); border-radius: var(--sheen-control-radius); cursor: default; }
|
|
11
|
+
.sheen-command-palette .sheen-command-icon { display: inline-flex; flex: none; align-items: center; color: var(--sheen-color-fg-muted); }
|
|
12
|
+
.sheen-command-palette .sheen-command-label { flex: 1 1 auto; min-inline-size: 0; overflow-wrap: anywhere; }
|
|
13
|
+
.sheen-command-palette .sheen-command-trailing { display: inline-flex; flex: none; align-items: center; gap: var(--sheen-space-inline-xs); color: var(--sheen-color-fg-muted); }
|
|
11
14
|
.sheen-command-palette [cmdk-item][data-selected="true"] { background: var(--sheen-color-bg-selected); }
|
|
12
15
|
.sheen-command-palette [cmdk-item][data-disabled="true"] { color: var(--sheen-color-fg-subtle); }
|
|
13
16
|
.sheen-command-palette [cmdk-empty], .sheen-command-palette [cmdk-loading], .sheen-command-palette [role="alert"] { padding: var(--sheen-space-block-lg) var(--sheen-space-inline-sm); color: var(--sheen-color-fg-muted); text-align: center; }
|