@gemologic/sheen 0.1.0-rc.2 → 0.2.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 +42 -41
- package/dist/primitives/NumberText.d.ts +7 -0
- package/dist/primitives/NumberText.js +56 -0
- package/dist/primitives/Popover.js +57 -38
- package/dist/primitives/tooltip-layer.js +5 -3
- package/dist/theme/ThemeProvider.js +134 -123
- package/dist/theme/messages.d.ts +3 -0
- package/dist/theme/number-format-cache.d.ts +5 -0
- package/dist/theme/number-format-cache.js +41 -0
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/primitives/NumberText.tsx +36 -0
- package/src/primitives/Popover.tsx +9 -1
- package/src/primitives/tooltip-layer.tsx +8 -5
- package/src/styles.css +5 -2
- package/src/theme/ThemeProvider.tsx +7 -4
- package/src/theme/messages.ts +3 -0
- package/src/theme/number-format-cache.ts +42 -0
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,8 @@ export { useNumberFormatter, useDateFormatter } from "./theme/intl.ts";
|
|
|
59
59
|
export { Stack, Row, Row as Cluster, Grid, Container, Center, Spacer } from "./layout/Layout.tsx";
|
|
60
60
|
export type { StackProps, RowProps, GridProps, ContainerProps, CenterProps, SpacerProps, Spacing, Alignment, Justification } from "./layout/Layout.tsx";
|
|
61
61
|
export { Text, Heading, Code, Kbd } from "./primitives/Typography.tsx";
|
|
62
|
+
export { NumberText } from "./primitives/NumberText.tsx";
|
|
63
|
+
export type { NumberTextProps } from "./primitives/NumberText.tsx";
|
|
62
64
|
export type { TextProps, HeadingProps, CodeProps, KbdProps } from "./primitives/Typography.tsx";
|
|
63
65
|
export { Badge, Tag } from "./primitives/Status.tsx";
|
|
64
66
|
export type { BadgeProps, TagProps, StatusTone } from "./primitives/Status.tsx";
|
package/dist/index.js
CHANGED
|
@@ -32,44 +32,45 @@ import { Toast as H } from "./primitives/Toast.js";
|
|
|
32
32
|
import { Toaster as U } from "./primitives/Toaster.js";
|
|
33
33
|
import { useDateFormatter as W, useNumberFormatter as G } from "./theme/intl.js";
|
|
34
34
|
import { Center as K, Container as q, Grid as J, Row as Y, Spacer as X, Stack as Z } from "./layout/Layout.js";
|
|
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
|
-
|
|
35
|
+
import { NumberText as Q } from "./primitives/NumberText.js";
|
|
36
|
+
import { Badge as ne, Tag as re } from "./primitives/Status.js";
|
|
37
|
+
import { Card as ie, Surface as ae } from "./primitives/Surface.js";
|
|
38
|
+
import { Separator as oe } from "./primitives/Separator.js";
|
|
39
|
+
import { Alert as $, Callout as se } from "./primitives/Notice.js";
|
|
40
|
+
import { DescriptionDetails as ce, DescriptionList as le, DescriptionTerm as ue } from "./primitives/DescriptionList.js";
|
|
41
|
+
import { Skeleton as de } from "./primitives/Skeleton.js";
|
|
42
|
+
import { EmptyState as fe } from "./primitives/EmptyState.js";
|
|
43
|
+
import { Spinner as pe } from "./primitives/Spinner.js";
|
|
44
|
+
import { InputGroup as me } from "./primitives/InputGroup.js";
|
|
45
|
+
import { SearchInput as he } from "./primitives/SearchInput.js";
|
|
46
|
+
import { Textarea as ge } from "./primitives/Textarea.js";
|
|
47
|
+
import { EditableTextField as _e } from "./primitives/EditableTextField.js";
|
|
48
|
+
import { Checkbox as ve } from "./primitives/Checkbox.js";
|
|
49
|
+
import { Switch as ye } from "./primitives/Switch.js";
|
|
50
|
+
import { CheckboxGroup as be } from "./primitives/CheckboxGroup.js";
|
|
51
|
+
import { RadioGroup as xe } from "./primitives/RadioGroup.js";
|
|
52
|
+
import { SegmentedControl as Se } from "./primitives/SegmentedControl.js";
|
|
53
|
+
import { TagInput as Ce } from "./primitives/TagInput.js";
|
|
54
|
+
import { Meter as we, Progress as Te } from "./primitives/Progress.js";
|
|
55
|
+
import { FileDropzone as Ee } from "./primitives/FileDropzone.js";
|
|
56
|
+
import { ActivityTimeline as De } from "./primitives/ActivityTimeline.js";
|
|
57
|
+
import { Link as Oe } from "./primitives/Link.js";
|
|
58
|
+
import { Stepper as ke } from "./primitives/Stepper.js";
|
|
59
|
+
import { Select as Ae } from "./primitives/Select.js";
|
|
60
|
+
import { Combobox as je, MultiCombobox as Me } from "./primitives/Combobox.js";
|
|
61
|
+
import { Table as Ne, TableBody as Pe, TableCaption as Fe, TableCell as Ie, TableFoot as Le, TableHead as Re, TableHeaderCell as ze, TableRow as Be } from "./primitives/Table.js";
|
|
62
|
+
import { Breadcrumb as Ve } from "./primitives/Breadcrumb.js";
|
|
63
|
+
import { Collapsible as He } from "./primitives/Collapsible.js";
|
|
64
|
+
import { Accordion as Ue, AccordionItem as We } from "./primitives/Accordion.js";
|
|
65
|
+
import { Tabs as Ge } from "./primitives/Tabs.js";
|
|
66
|
+
import { NavItem as Ke, NavList as qe } from "./primitives/NavList.js";
|
|
67
|
+
import { ScrollArea as Je } from "./primitives/ScrollArea.js";
|
|
68
|
+
import { ButtonGroup as Ye } from "./primitives/ButtonGroup.js";
|
|
69
|
+
import { IconButton as Xe } from "./primitives/IconButton.js";
|
|
70
|
+
import { Pagination as Ze } from "./primitives/Pagination.js";
|
|
71
|
+
import { Avatar as Qe, AvatarGroup as $e } from "./primitives/Avatar.js";
|
|
72
|
+
import { NumberField as et } from "./primitives/NumberField.js";
|
|
73
|
+
import { RangeSlider as tt, Slider as nt } from "./primitives/Slider.js";
|
|
74
|
+
import { Tree as rt, TreeItem as it } from "./primitives/Tree.js";
|
|
75
|
+
import { Resizable as at, ResizableHandle as ot, ResizablePanel as st } from "./primitives/Resizable.js";
|
|
76
|
+
export { Ue as Accordion, We as AccordionItem, De as ActivityTimeline, $ as Alert, x as AlertDialog, Qe as Avatar, $e as AvatarGroup, ne as Badge, Ve as Breadcrumb, h as Button, Ye as ButtonGroup, se as Callout, ie as Card, K as Center, ve as Checkbox, be as CheckboxGroup, Y as Cluster, w as Code, He as Collapsible, je as Combobox, I as CommandPalette, S as ConfirmDialog, q as Container, F as ContextMenu, ce as DescriptionDetails, le as DescriptionList, ue as DescriptionTerm, v as Dialog, y as Drawer, P as DropdownMenu, _e as EditableTextField, fe as EmptyState, g as Field, Ee as FileDropzone, J as Grid, T as Heading, Xe as IconButton, _ as Input, me as InputGroup, E as Kbd, Oe as Link, M as LinkTooltip, we as Meter, Me as MultiCombobox, Ke as NavItem, qe as NavList, et as NumberField, Q as NumberText, Ze as Pagination, N as Popover, Te as Progress, xe as RadioGroup, tt as RangeSlider, at as Resizable, ot as ResizableHandle, st as ResizablePanel, Y as Row, Je as ScrollArea, he as SearchInput, Se as SegmentedControl, Ae as Select, oe as Separator, b as Sheet, A as ShortcutPending, u as ShortcutProvider, j as ShortcutScope, k as ShortcutSheet, de as Skeleton, nt as Slider, X as Spacer, pe as Spinner, Z as Stack, ke as Stepper, ae as Surface, ye as Switch, Ne as Table, Pe as TableBody, Fe as TableCaption, Ie as TableCell, Le as TableFoot, Re as TableHead, ze as TableHeaderCell, Be as TableRow, Ge as Tabs, re as Tag, Ce as TagInput, D as Text, ge as Textarea, r as ThemeProvider, i as ThemeScope, H as Toast, U as Toaster, O as Tooltip, rt as Tree, it as TreeItem, c as buttonVariants, s as cn, L as commandPaletteFilter, C as createConfirm, o as createKeyboardHydrationScript, l as createShortcutRegistry, t as createThemeScript, V as createToaster, ee as defaultThemeState, n as englishMessages, B as optimistic, te as readThemeState, e as resolveThemeState, W as useDateFormatter, R as useIsWindowFocused, G as useNumberFormatter, z as useOnlineStatus, d as usePendingShortcut, f as useShortcut, p as useShortcutBindings, m as useShortcutCommands, a as useTheme };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
export interface NumberTextProps extends Omit<JSX.HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
3
|
+
value: number;
|
|
4
|
+
format?: Intl.NumberFormatOptions;
|
|
5
|
+
}
|
|
6
|
+
/** Keep locale ordering and punctuation intact while quieting fractional digits and units. */
|
|
7
|
+
export declare function NumberText(props: NumberTextProps): JSX.Element;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NumberFormatContext as e } from "../theme/number-format-cache.js";
|
|
2
|
+
import { useTheme as t } from "../theme/ThemeProvider.js";
|
|
3
|
+
import { cn as n } from "../utils/cn.js";
|
|
4
|
+
import { createComponent as r, effect as i, insert as a, mergeProps as o, setAttribute as s, spread as c, template as l } from "solid-js/web";
|
|
5
|
+
import { Index as u, Show as d, createMemo as f, splitProps as p, useContext as m } from "solid-js";
|
|
6
|
+
//#region src/primitives/NumberText.tsx
|
|
7
|
+
var h = /*#__PURE__*/ l("<span>"), g = /* @__PURE__ */ new Set([
|
|
8
|
+
"decimal",
|
|
9
|
+
"fraction",
|
|
10
|
+
"unit",
|
|
11
|
+
"percentSign",
|
|
12
|
+
"currency",
|
|
13
|
+
"compact"
|
|
14
|
+
]);
|
|
15
|
+
function _(l) {
|
|
16
|
+
let [_, v] = p(l, [
|
|
17
|
+
"value",
|
|
18
|
+
"format",
|
|
19
|
+
"class"
|
|
20
|
+
]), y = t(), b = m(e), x = f(() => y.state().locale), S = f(() => b ? b(x(), _.format) : new Intl.NumberFormat(x(), _.format)), C = f(() => {
|
|
21
|
+
if (!Number.isFinite(_.value)) throw Error("NumberText requires a finite value");
|
|
22
|
+
let e = [];
|
|
23
|
+
for (let t of S().formatToParts(_.value)) {
|
|
24
|
+
let n = e.at(-1);
|
|
25
|
+
!g.has(t.type) && n?.type === "literal" ? n.value += t.value : e.push(g.has(t.type) ? t : {
|
|
26
|
+
type: "literal",
|
|
27
|
+
value: t.value
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return e;
|
|
31
|
+
});
|
|
32
|
+
return (() => {
|
|
33
|
+
var e = h();
|
|
34
|
+
return c(e, o(v, { get class() {
|
|
35
|
+
return n("sheen-number-text", _.class);
|
|
36
|
+
} }), !1, !0), a(e, r(u, {
|
|
37
|
+
get each() {
|
|
38
|
+
return C();
|
|
39
|
+
},
|
|
40
|
+
children: (e) => r(d, {
|
|
41
|
+
get when() {
|
|
42
|
+
return g.has(e().type);
|
|
43
|
+
},
|
|
44
|
+
get fallback() {
|
|
45
|
+
return e().value;
|
|
46
|
+
},
|
|
47
|
+
get children() {
|
|
48
|
+
var t = h();
|
|
49
|
+
return a(t, () => e().value), i(() => s(t, "data-number-part", e().type)), t;
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
})), e;
|
|
53
|
+
})();
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { _ as NumberText };
|
|
@@ -1,92 +1,111 @@
|
|
|
1
1
|
import { useTheme as e } from "../theme/ThemeProvider.js";
|
|
2
2
|
import { cn as t } from "../utils/cn.js";
|
|
3
3
|
import { Button as n } from "./Button.js";
|
|
4
|
-
import { createComponent as r, insert as i,
|
|
5
|
-
import { Show as
|
|
6
|
-
import * as
|
|
4
|
+
import { createComponent as r, insert as i, memo as a, mergeProps as o, template as s } from "solid-js/web";
|
|
5
|
+
import { Show as c, createEffect as l, createMemo as u, createSignal as d, createUniqueId as f, onCleanup as p } from "solid-js";
|
|
6
|
+
import * as m from "#sheen-kobalte/popover";
|
|
7
7
|
//#region src/primitives/Popover.tsx
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
|
|
8
|
+
var h = /*#__PURE__*/ s("<div class=sheen-dialog-header>"), g = /*#__PURE__*/ s("<div class=sheen-dialog-body>"), _ = /*#__PURE__*/ s("<div class=sheen-dialog-footer>");
|
|
9
|
+
function v(e) {
|
|
10
|
+
let t = m.usePopoverContext();
|
|
11
|
+
return r(n, o({
|
|
12
|
+
ref(e) {
|
|
13
|
+
var n = t.setTriggerRef;
|
|
14
|
+
typeof n == "function" ? n(e) : t.setTriggerRef = e;
|
|
15
|
+
},
|
|
16
|
+
variant: "outline",
|
|
17
|
+
"data-sheen-popover-trigger": "",
|
|
18
|
+
"aria-haspopup": "dialog",
|
|
19
|
+
get "aria-expanded"() {
|
|
20
|
+
return t.isOpen();
|
|
21
|
+
},
|
|
22
|
+
get "aria-controls"() {
|
|
23
|
+
return a(() => !!t.isOpen())() ? t.contentId() : void 0;
|
|
24
|
+
},
|
|
25
|
+
onPointerDown: (e) => {
|
|
26
|
+
e.pointerType === "mouse" && e.preventDefault();
|
|
27
|
+
},
|
|
28
|
+
onClick: () => t.toggle()
|
|
29
|
+
}, () => t.dataset(), { get children() {
|
|
30
|
+
return e.children;
|
|
31
|
+
} }));
|
|
32
|
+
}
|
|
33
|
+
function y(a) {
|
|
34
|
+
let o = e(), s = f(), [y, b] = d(a.defaultOpen ?? !1), x = () => a.open === void 0 ? y() : a.open, S = (e) => {
|
|
35
|
+
e !== x() && (a.open === void 0 && b(e), a.onOpenChange?.(e));
|
|
12
36
|
};
|
|
13
|
-
|
|
14
|
-
|
|
37
|
+
l(() => {
|
|
38
|
+
x() && p(o.layers.register(s));
|
|
15
39
|
});
|
|
16
|
-
let
|
|
17
|
-
return r(
|
|
40
|
+
let C = u((e) => x() ? o.layers.zIndex(s) : e ?? 100);
|
|
41
|
+
return r(m.Root, {
|
|
18
42
|
get open() {
|
|
19
|
-
return
|
|
43
|
+
return x();
|
|
20
44
|
},
|
|
21
|
-
onOpenChange:
|
|
45
|
+
onOpenChange: S,
|
|
22
46
|
get placement() {
|
|
23
47
|
return a.placement ?? "bottom";
|
|
24
48
|
},
|
|
25
49
|
gutter: 6,
|
|
26
50
|
get children() {
|
|
27
|
-
return [r(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"data-sheen-popover-trigger": "",
|
|
31
|
-
get children() {
|
|
32
|
-
return a.trigger;
|
|
33
|
-
}
|
|
34
|
-
}), r(o, {
|
|
51
|
+
return [r(v, { get children() {
|
|
52
|
+
return a.trigger;
|
|
53
|
+
} }), r(c, {
|
|
35
54
|
get when() {
|
|
36
|
-
return
|
|
55
|
+
return o.portal();
|
|
37
56
|
},
|
|
38
|
-
children: (e) => r(
|
|
57
|
+
children: (e) => r(m.Portal, {
|
|
39
58
|
get mount() {
|
|
40
59
|
return e();
|
|
41
60
|
},
|
|
42
61
|
get children() {
|
|
43
|
-
return r(
|
|
62
|
+
return r(m.Content, {
|
|
44
63
|
"data-kb-top-layer": "true",
|
|
45
64
|
get class() {
|
|
46
65
|
return t("sheen-popover", a.class);
|
|
47
66
|
},
|
|
48
67
|
get "aria-hidden"() {
|
|
49
|
-
return !
|
|
68
|
+
return !x() || void 0;
|
|
50
69
|
},
|
|
51
70
|
get inert() {
|
|
52
|
-
return !
|
|
71
|
+
return !x();
|
|
53
72
|
},
|
|
54
73
|
get style() {
|
|
55
|
-
return { "z-index":
|
|
74
|
+
return { "z-index": C() };
|
|
56
75
|
},
|
|
57
76
|
onEscapeKeyDown: (e) => {
|
|
58
|
-
|
|
77
|
+
o.layers.isTop(s) || e.preventDefault();
|
|
59
78
|
},
|
|
60
79
|
get children() {
|
|
61
80
|
return [
|
|
62
81
|
(() => {
|
|
63
|
-
var e =
|
|
64
|
-
return i(e, r(
|
|
82
|
+
var e = h();
|
|
83
|
+
return i(e, r(m.Title, { get children() {
|
|
65
84
|
return a.title;
|
|
66
|
-
} }), null), i(e, r(
|
|
85
|
+
} }), null), i(e, r(c, {
|
|
67
86
|
get when() {
|
|
68
87
|
return a.description;
|
|
69
88
|
},
|
|
70
89
|
get children() {
|
|
71
|
-
return r(
|
|
90
|
+
return r(m.Description, { get children() {
|
|
72
91
|
return a.description;
|
|
73
92
|
} });
|
|
74
93
|
}
|
|
75
94
|
}), null), e;
|
|
76
95
|
})(),
|
|
77
96
|
(() => {
|
|
78
|
-
var e =
|
|
97
|
+
var e = g();
|
|
79
98
|
return i(e, () => a.children), e;
|
|
80
99
|
})(),
|
|
81
100
|
(() => {
|
|
82
|
-
var e =
|
|
83
|
-
return i(e, r(
|
|
101
|
+
var e = _();
|
|
102
|
+
return i(e, r(m.CloseButton, {
|
|
84
103
|
as: n,
|
|
85
104
|
get "aria-label"() {
|
|
86
|
-
return
|
|
105
|
+
return o.messages().close;
|
|
87
106
|
},
|
|
88
107
|
get children() {
|
|
89
|
-
return
|
|
108
|
+
return o.messages().close;
|
|
90
109
|
}
|
|
91
110
|
})), e;
|
|
92
111
|
})()
|
|
@@ -100,4 +119,4 @@ function g(a) {
|
|
|
100
119
|
});
|
|
101
120
|
}
|
|
102
121
|
//#endregion
|
|
103
|
-
export {
|
|
122
|
+
export { y as Popover };
|
|
@@ -21,10 +21,12 @@ function m(t, n) {
|
|
|
21
21
|
let e = t();
|
|
22
22
|
if (!e) return;
|
|
23
23
|
let r = () => {
|
|
24
|
-
p = !1;
|
|
24
|
+
e.matches(":hover") || (p = !1);
|
|
25
|
+
}, i = () => {
|
|
26
|
+
e.ownerDocument.activeElement !== e && (p = !1);
|
|
25
27
|
};
|
|
26
|
-
e.addEventListener("blur", r), e.addEventListener("pointerleave",
|
|
27
|
-
e.removeEventListener("blur", r), e.removeEventListener("pointerleave",
|
|
28
|
+
e.addEventListener("blur", r), e.addEventListener("pointerleave", i), u(() => {
|
|
29
|
+
e.removeEventListener("blur", r), e.removeEventListener("pointerleave", i);
|
|
28
30
|
}), !n() && (e.ownerDocument.activeElement === e || e.matches(":hover")) && f(!0);
|
|
29
31
|
}), {
|
|
30
32
|
theme: r,
|
|
@@ -2,13 +2,14 @@ import { defaultThemeState as e, readThemeState as t, resolveThemeState as n } f
|
|
|
2
2
|
import { createScopeScript as r } from "./script.js";
|
|
3
3
|
import { createOverlayStack as i } from "./layers.js";
|
|
4
4
|
import { englishMessages as a, resolveMessages as o } from "./messages.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { NumberFormatContext as s, createNumberFormatCache as c } from "./number-format-cache.js";
|
|
6
|
+
import { createComponent as l, effect as u, insert as d, memo as f, mergeProps as p, setAttribute as m, spread as h, template as g, use as _ } from "solid-js/web";
|
|
7
|
+
import { createContext as v, createEffect as y, createMemo as b, createSignal as x, createUniqueId as S, onCleanup as C, onMount as w, useContext as T } from "solid-js";
|
|
8
|
+
import { I18nProvider as E } from "#sheen-kobalte/i18n";
|
|
9
|
+
import { bundledThemeMetadata as D, iconSetForTheme as O } from "@gemologic/sheen-tokens/catalog";
|
|
9
10
|
//#region src/theme/ThemeProvider.tsx
|
|
10
|
-
var
|
|
11
|
-
function
|
|
11
|
+
var k = /*#__PURE__*/ g("<div>"), A = /*#__PURE__*/ g("<section><script>");
|
|
12
|
+
function j(e) {
|
|
12
13
|
return {
|
|
13
14
|
...e,
|
|
14
15
|
portal: () => e.ready() ? e.portal() : void 0,
|
|
@@ -26,25 +27,25 @@ function k(e) {
|
|
|
26
27
|
setRadius: (t) => e.set({ radius: t })
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
|
-
var
|
|
30
|
-
function
|
|
31
|
-
let e =
|
|
30
|
+
var M = v();
|
|
31
|
+
function N() {
|
|
32
|
+
let e = T(M);
|
|
32
33
|
if (!e) throw Error("sheen components require a ThemeProvider");
|
|
33
34
|
return e;
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
+
function P(e, t, n) {
|
|
36
37
|
return Object.fromEntries(Object.entries({
|
|
37
38
|
...e,
|
|
38
39
|
mode: t,
|
|
39
|
-
"icon-set":
|
|
40
|
+
"icon-set": O(e.theme, n)
|
|
40
41
|
}).map(([e, t]) => [`data-sheen-${e}`, t]));
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function F(e) {
|
|
43
44
|
return (() => {
|
|
44
|
-
var t =
|
|
45
|
-
return typeof n == "function" ?
|
|
46
|
-
var r = e.kind, i = e.ready, a = e.state?.theme, o = e.state ? e.mode : void 0, s = e.state ?
|
|
47
|
-
return r !== n.e &&
|
|
45
|
+
var t = k(), n = e.ref;
|
|
46
|
+
return typeof n == "function" ? _(n, t) : e.ref = t, u((n) => {
|
|
47
|
+
var r = e.kind, i = e.ready, a = e.state?.theme, o = e.state ? e.mode : void 0, s = e.state ? O(e.state.theme, e.themes) : void 0, c = e.state?.accent, l = e.state?.density, u = e.state?.radius, d = e.state?.motion, f = e.state?.locale, p = e.state?.direction;
|
|
48
|
+
return r !== n.e && m(t, "data-sheen-portal", n.e = r), i !== n.t && m(t, "data-sheen-ready", n.t = i), a !== n.a && m(t, "data-sheen-theme", n.a = a), o !== n.o && m(t, "data-sheen-mode", n.o = o), s !== n.i && m(t, "data-sheen-icon-set", n.i = s), c !== n.n && m(t, "data-sheen-accent", n.n = c), l !== n.s && m(t, "data-sheen-density", n.s = l), u !== n.h && m(t, "data-sheen-radius", n.h = u), d !== n.r && m(t, "data-sheen-motion", n.r = d), f !== n.d && m(t, "data-sheen-locale", n.d = f), p !== n.l && m(t, "data-sheen-direction", n.l = p), n;
|
|
48
49
|
}, {
|
|
49
50
|
e: void 0,
|
|
50
51
|
t: void 0,
|
|
@@ -60,17 +61,17 @@ function N(e) {
|
|
|
60
61
|
}), t;
|
|
61
62
|
})();
|
|
62
63
|
}
|
|
63
|
-
function
|
|
64
|
-
let [e, t] =
|
|
65
|
-
return
|
|
64
|
+
function I() {
|
|
65
|
+
let [e, t] = x("dark");
|
|
66
|
+
return w(() => {
|
|
66
67
|
let e = matchMedia("(prefers-color-scheme: dark)"), n = () => {
|
|
67
68
|
t(e.matches ? "dark" : "light");
|
|
68
69
|
};
|
|
69
|
-
n(), e.addEventListener("change", n),
|
|
70
|
+
n(), e.addEventListener("change", n), C(() => e.removeEventListener("change", n));
|
|
70
71
|
}), e;
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
-
let r = () => n.themes ??
|
|
73
|
+
function L(n) {
|
|
74
|
+
let r = c(), u = () => n.themes ?? D, d = {
|
|
74
75
|
...e,
|
|
75
76
|
theme: n.defaultTheme ?? e.theme,
|
|
76
77
|
mode: n.defaultMode ?? "dark",
|
|
@@ -80,39 +81,39 @@ function F(n) {
|
|
|
80
81
|
motion: n.defaultMotion ?? "full",
|
|
81
82
|
direction: n.direction ?? "ltr",
|
|
82
83
|
locale: n.locale ?? "en-US"
|
|
83
|
-
}, [
|
|
84
|
-
function
|
|
85
|
-
for (let [e, t] of Object.entries(
|
|
86
|
-
document.documentElement.setAttribute("data-sheen-preference",
|
|
84
|
+
}, [p, m] = x(n.initialState ?? d), h = b(() => p().locale), g = b(() => p().direction), [_, v] = x(!1), [S, C] = x(), T = I(), O = b(() => p().mode === "system" ? T() : p().mode === "light" ? "light" : "dark"), k = 0;
|
|
85
|
+
function A() {
|
|
86
|
+
for (let [e, t] of Object.entries(P(p(), O(), u()))) document.documentElement.setAttribute(e, t);
|
|
87
|
+
document.documentElement.setAttribute("data-sheen-preference", p().mode), document.documentElement.dir = p().direction, document.documentElement.lang = p().locale;
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
+
w(() => {
|
|
89
90
|
if (n.hydration !== "cookie") {
|
|
90
|
-
let e = document.documentElement, n = Object.fromEntries(Object.keys(
|
|
91
|
-
|
|
91
|
+
let e = document.documentElement, n = Object.fromEntries(Object.keys(d).map((t) => [t, e.getAttribute(`data-sheen-${t}`)]));
|
|
92
|
+
m(t({
|
|
92
93
|
...n,
|
|
93
94
|
mode: e.getAttribute("data-sheen-preference") ?? n.mode
|
|
94
|
-
},
|
|
95
|
+
}, d, u().map((e) => e.id)));
|
|
95
96
|
}
|
|
96
|
-
|
|
97
|
-
}),
|
|
98
|
-
|
|
97
|
+
v(!0), A();
|
|
98
|
+
}), y(() => {
|
|
99
|
+
_() && A();
|
|
99
100
|
});
|
|
100
|
-
let
|
|
101
|
-
state:
|
|
102
|
-
defaults:
|
|
103
|
-
resolvedMode:
|
|
104
|
-
ready:
|
|
105
|
-
portal:
|
|
101
|
+
let N = j({
|
|
102
|
+
state: p,
|
|
103
|
+
defaults: d,
|
|
104
|
+
resolvedMode: O,
|
|
105
|
+
ready: _,
|
|
106
|
+
portal: S,
|
|
106
107
|
tokenTarget: () => document.documentElement,
|
|
107
|
-
themes:
|
|
108
|
+
themes: u(),
|
|
108
109
|
nonce: n.nonce,
|
|
109
110
|
layers: i(),
|
|
110
|
-
messages:
|
|
111
|
+
messages: b(() => o(a, n.messages)),
|
|
111
112
|
async set(e) {
|
|
112
113
|
let r = t({
|
|
113
|
-
...
|
|
114
|
+
...p(),
|
|
114
115
|
...e
|
|
115
|
-
},
|
|
116
|
+
}, d, N.themes().map((e) => e.id)), i = ++k;
|
|
116
117
|
if (n.hydration === "cookie") {
|
|
117
118
|
if (!n.persist) throw Error("Cookie hydration requires an app persistence callback");
|
|
118
119
|
try {
|
|
@@ -121,119 +122,129 @@ function F(n) {
|
|
|
121
122
|
throw n.onPersistenceError?.(e), e;
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
|
-
if (i ===
|
|
125
|
+
if (i === k && (m(r), A(), n.hydration !== "cookie")) try {
|
|
125
126
|
localStorage.setItem(n.storageKey ?? "sheen", JSON.stringify(r));
|
|
126
127
|
} catch (e) {
|
|
127
128
|
n.onPersistenceError?.(e);
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
});
|
|
131
|
-
return
|
|
132
|
-
value:
|
|
132
|
+
return l(M.Provider, {
|
|
133
|
+
value: N,
|
|
133
134
|
get children() {
|
|
134
|
-
return s
|
|
135
|
-
|
|
136
|
-
return f();
|
|
137
|
-
},
|
|
138
|
-
get direction() {
|
|
139
|
-
return p();
|
|
140
|
-
},
|
|
135
|
+
return l(s.Provider, {
|
|
136
|
+
value: r,
|
|
141
137
|
get children() {
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return m();
|
|
146
|
-
},
|
|
147
|
-
ref: b,
|
|
148
|
-
get state() {
|
|
149
|
-
return u(() => !!m())() ? l() : void 0;
|
|
138
|
+
return l(E, {
|
|
139
|
+
get locale() {
|
|
140
|
+
return h();
|
|
150
141
|
},
|
|
151
|
-
get
|
|
152
|
-
return
|
|
142
|
+
get direction() {
|
|
143
|
+
return g();
|
|
153
144
|
},
|
|
154
|
-
get
|
|
155
|
-
return
|
|
145
|
+
get children() {
|
|
146
|
+
return [f(() => n.children), l(F, {
|
|
147
|
+
kind: "root",
|
|
148
|
+
get ready() {
|
|
149
|
+
return _();
|
|
150
|
+
},
|
|
151
|
+
ref: C,
|
|
152
|
+
get state() {
|
|
153
|
+
return f(() => !!_())() ? p() : void 0;
|
|
154
|
+
},
|
|
155
|
+
get mode() {
|
|
156
|
+
return O();
|
|
157
|
+
},
|
|
158
|
+
get themes() {
|
|
159
|
+
return u();
|
|
160
|
+
}
|
|
161
|
+
})];
|
|
156
162
|
}
|
|
157
|
-
})
|
|
163
|
+
});
|
|
158
164
|
}
|
|
159
165
|
});
|
|
160
166
|
}
|
|
161
167
|
});
|
|
162
168
|
}
|
|
163
|
-
function
|
|
164
|
-
let t =
|
|
165
|
-
theme: e.theme ?? (e.theme === null ? null :
|
|
166
|
-
mode: e.mode ?? (e.mode === null ? null :
|
|
167
|
-
accent: e.accent ?? (e.accent === null ? null :
|
|
168
|
-
density: e.density ?? (e.density === null ? null :
|
|
169
|
-
radius: e.radius ?? (e.radius === null ? null :
|
|
170
|
-
motion: e.motion ?? (e.motion === null ? null :
|
|
171
|
-
direction: e.direction ?? (e.direction === null ? null :
|
|
172
|
-
locale: e.locale ?? (e.locale === null ? null :
|
|
173
|
-
...
|
|
174
|
-
},
|
|
175
|
-
...
|
|
176
|
-
themes:
|
|
177
|
-
state:
|
|
178
|
-
portal:
|
|
179
|
-
tokenTarget: () =>
|
|
180
|
-
resolvedMode:
|
|
181
|
-
messages:
|
|
169
|
+
function R(e) {
|
|
170
|
+
let t = c(), i = N(), [a, f] = x({}), [g, _] = x(), v = b(() => n(i.state(), {
|
|
171
|
+
theme: e.theme ?? (e.theme === null ? null : i.state().theme),
|
|
172
|
+
mode: e.mode ?? (e.mode === null ? null : i.state().mode),
|
|
173
|
+
accent: e.accent ?? (e.accent === null ? null : i.state().accent),
|
|
174
|
+
density: e.density ?? (e.density === null ? null : i.state().density),
|
|
175
|
+
radius: e.radius ?? (e.radius === null ? null : i.state().radius),
|
|
176
|
+
motion: e.motion ?? (e.motion === null ? null : i.state().motion),
|
|
177
|
+
direction: e.direction ?? (e.direction === null ? null : i.state().direction),
|
|
178
|
+
locale: e.locale ?? (e.locale === null ? null : i.state().locale),
|
|
179
|
+
...a()
|
|
180
|
+
}, i.defaults)), y = b(() => v().locale), C = b(() => v().direction), w = I(), T = b(() => v().mode === "system" ? w() : v().mode === "light" ? "light" : "dark"), D = () => i.themes(), O = j({
|
|
181
|
+
...i,
|
|
182
|
+
themes: i.themes(),
|
|
183
|
+
state: v,
|
|
184
|
+
portal: g,
|
|
185
|
+
tokenTarget: () => g()?.parentElement ?? void 0,
|
|
186
|
+
resolvedMode: T,
|
|
187
|
+
messages: b(() => o(i.messages(), e.messages)),
|
|
182
188
|
async set(t) {
|
|
183
189
|
if (!e.controllable) throw Error("ThemeScope setters require controllable=true");
|
|
184
|
-
|
|
190
|
+
f((e) => ({
|
|
185
191
|
...e,
|
|
186
192
|
...t
|
|
187
193
|
}));
|
|
188
194
|
}
|
|
189
|
-
}),
|
|
195
|
+
}), k = S(), L = () => {
|
|
190
196
|
let t = {};
|
|
191
197
|
return e.theme !== void 0 && (t.theme = e.theme), e.mode !== void 0 && (t.mode = e.mode), e.accent !== void 0 && (t.accent = e.accent), e.density !== void 0 && (t.density = e.density), e.radius !== void 0 && (t.radius = e.radius), e.motion !== void 0 && (t.motion = e.motion), e.direction !== void 0 && (t.direction = e.direction), e.locale !== void 0 && (t.locale = e.locale), t;
|
|
192
198
|
};
|
|
193
|
-
return
|
|
194
|
-
value:
|
|
199
|
+
return l(M.Provider, {
|
|
200
|
+
value: O,
|
|
195
201
|
get children() {
|
|
196
|
-
return s
|
|
197
|
-
|
|
198
|
-
return g();
|
|
199
|
-
},
|
|
200
|
-
get direction() {
|
|
201
|
-
return _();
|
|
202
|
-
},
|
|
202
|
+
return l(s.Provider, {
|
|
203
|
+
value: t,
|
|
203
204
|
get children() {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
} }, () => M(h(), S(), C()), {
|
|
208
|
-
get dir() {
|
|
209
|
-
return h().direction;
|
|
210
|
-
},
|
|
211
|
-
get lang() {
|
|
212
|
-
return h().locale;
|
|
213
|
-
}
|
|
214
|
-
}), !1, !0), l(n, () => e.children, i), l(n, s(N, {
|
|
215
|
-
kind: "scope",
|
|
216
|
-
ref: m,
|
|
217
|
-
get state() {
|
|
218
|
-
return h();
|
|
219
|
-
},
|
|
220
|
-
get mode() {
|
|
221
|
-
return S();
|
|
205
|
+
return l(E, {
|
|
206
|
+
get locale() {
|
|
207
|
+
return y();
|
|
222
208
|
},
|
|
223
|
-
get
|
|
209
|
+
get direction() {
|
|
224
210
|
return C();
|
|
211
|
+
},
|
|
212
|
+
get children() {
|
|
213
|
+
var t = A(), n = t.firstChild;
|
|
214
|
+
return m(t, "id", k), h(t, p({ get class() {
|
|
215
|
+
return e.class;
|
|
216
|
+
} }, () => P(v(), T(), D()), {
|
|
217
|
+
get dir() {
|
|
218
|
+
return v().direction;
|
|
219
|
+
},
|
|
220
|
+
get lang() {
|
|
221
|
+
return v().locale;
|
|
222
|
+
}
|
|
223
|
+
}), !1, !0), d(t, () => e.children, n), d(t, l(F, {
|
|
224
|
+
kind: "scope",
|
|
225
|
+
ref: _,
|
|
226
|
+
get state() {
|
|
227
|
+
return v();
|
|
228
|
+
},
|
|
229
|
+
get mode() {
|
|
230
|
+
return T();
|
|
231
|
+
},
|
|
232
|
+
get themes() {
|
|
233
|
+
return D();
|
|
234
|
+
}
|
|
235
|
+
}), n), u((e) => {
|
|
236
|
+
var t = i.nonce, a = r(L(), i.defaults, D());
|
|
237
|
+
return t !== e.e && m(n, "nonce", e.e = t), a !== e.t && (n.innerHTML = e.t = a), e;
|
|
238
|
+
}, {
|
|
239
|
+
e: void 0,
|
|
240
|
+
t: void 0
|
|
241
|
+
}), t;
|
|
225
242
|
}
|
|
226
|
-
})
|
|
227
|
-
var n = t.nonce, a = r(D(), t.defaults, C());
|
|
228
|
-
return n !== e.e && f(i, "nonce", e.e = n), a !== e.t && (i.innerHTML = e.t = a), e;
|
|
229
|
-
}, {
|
|
230
|
-
e: void 0,
|
|
231
|
-
t: void 0
|
|
232
|
-
}), n;
|
|
243
|
+
});
|
|
233
244
|
}
|
|
234
245
|
});
|
|
235
246
|
}
|
|
236
247
|
});
|
|
237
248
|
}
|
|
238
249
|
//#endregion
|
|
239
|
-
export {
|
|
250
|
+
export { L as ThemeProvider, R as ThemeScope, N as useTheme };
|
package/dist/theme/messages.d.ts
CHANGED
|
@@ -174,6 +174,9 @@ export interface ExtensionMessages {
|
|
|
174
174
|
readonly filterIsEmpty?: string;
|
|
175
175
|
readonly filterIsAnyOf?: string;
|
|
176
176
|
readonly filterSummary?: string;
|
|
177
|
+
readonly constrainedColumns?: string;
|
|
178
|
+
readonly constrainedColumn?: string;
|
|
179
|
+
readonly restoreColumn?: string;
|
|
177
180
|
readonly filterNot?: string;
|
|
178
181
|
readonly filterInheritedNot?: string;
|
|
179
182
|
readonly queryBuilder?: string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
type NumberFormatter = (locale: string, options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
|
|
2
|
+
export declare const NumberFormatContext: import("solid-js").Context<NumberFormatter | undefined>;
|
|
3
|
+
/** Cache plain option records by value; accessors/custom prototypes retain native evaluation. */
|
|
4
|
+
export declare function createNumberFormatCache(): NumberFormatter;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createContext as e } from "solid-js";
|
|
2
|
+
//#region src/theme/number-format-cache.ts
|
|
3
|
+
var t = e();
|
|
4
|
+
function n(e) {
|
|
5
|
+
if (e === void 0) return "[]";
|
|
6
|
+
if (typeof e != "object" || !e) return;
|
|
7
|
+
let t = Object.getPrototypeOf(e);
|
|
8
|
+
if (t !== Object.prototype && t !== null) return;
|
|
9
|
+
let n = [];
|
|
10
|
+
for (let t of Object.getOwnPropertyNames(e).sort()) {
|
|
11
|
+
let r = Object.getOwnPropertyDescriptor(e, t);
|
|
12
|
+
if (!r || !("value" in r)) return;
|
|
13
|
+
let i = r.value;
|
|
14
|
+
if (i !== void 0) {
|
|
15
|
+
if (i !== null && typeof i != "string" && typeof i != "number" && typeof i != "boolean") return;
|
|
16
|
+
n.push([
|
|
17
|
+
t,
|
|
18
|
+
typeof i,
|
|
19
|
+
Object.is(i, -0) ? "-0" : String(i)
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return JSON.stringify(n);
|
|
24
|
+
}
|
|
25
|
+
function r() {
|
|
26
|
+
let e = /* @__PURE__ */ new Map();
|
|
27
|
+
return (t, r) => {
|
|
28
|
+
let i = n(r);
|
|
29
|
+
if (i === void 0) return new Intl.NumberFormat(t, r);
|
|
30
|
+
let a = JSON.stringify([t, i]), o = e.get(a);
|
|
31
|
+
if (o) return o;
|
|
32
|
+
let s = new Intl.NumberFormat(t, r);
|
|
33
|
+
if (e.size >= 32) {
|
|
34
|
+
let t = e.keys().next().value;
|
|
35
|
+
t !== void 0 && e.delete(t);
|
|
36
|
+
}
|
|
37
|
+
return e.set(a, s), s;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { t as NumberFormatContext, r as createNumberFormatCache };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gemologic/sheen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Accessible, themeable SolidJS components for application interfaces.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
},
|
|
141
141
|
"dependencies": {
|
|
142
142
|
"@corvu/resizable": "0.2.5",
|
|
143
|
-
"@gemologic/sheen-tokens": "0.
|
|
143
|
+
"@gemologic/sheen-tokens": "0.2.0",
|
|
144
144
|
"@floating-ui/dom": "^1.5.1",
|
|
145
145
|
"@internationalized/number": "^3.2.1",
|
|
146
146
|
"@solid-primitives/event-listener": "^2.2.14",
|
package/src/index.ts
CHANGED
|
@@ -59,6 +59,8 @@ export { useNumberFormatter, useDateFormatter } from "./theme/intl.ts";
|
|
|
59
59
|
export { Stack, Row, Row as Cluster, Grid, Container, Center, Spacer } from "./layout/Layout.tsx";
|
|
60
60
|
export type { StackProps, RowProps, GridProps, ContainerProps, CenterProps, SpacerProps, Spacing, Alignment, Justification } from "./layout/Layout.tsx";
|
|
61
61
|
export { Text, Heading, Code, Kbd } from "./primitives/Typography.tsx";
|
|
62
|
+
export { NumberText } from "./primitives/NumberText.tsx";
|
|
63
|
+
export type { NumberTextProps } from "./primitives/NumberText.tsx";
|
|
62
64
|
export type { TextProps, HeadingProps, CodeProps, KbdProps } from "./primitives/Typography.tsx";
|
|
63
65
|
export { Badge, Tag } from "./primitives/Status.tsx";
|
|
64
66
|
export type { BadgeProps, TagProps, StatusTone } from "./primitives/Status.tsx";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Index, Show, createMemo, splitProps, useContext } from "solid-js";
|
|
2
|
+
import type { JSX } from "solid-js";
|
|
3
|
+
import { useTheme } from "../theme/ThemeProvider.tsx";
|
|
4
|
+
import { cn } from "../utils/cn.ts";
|
|
5
|
+
import { NumberFormatContext } from "../theme/number-format-cache.ts";
|
|
6
|
+
|
|
7
|
+
export interface NumberTextProps extends Omit<JSX.HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
8
|
+
value: number;
|
|
9
|
+
format?: Intl.NumberFormatOptions;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const quietParts = new Set<Intl.NumberFormatPartTypes>(["decimal", "fraction", "unit", "percentSign", "currency", "compact"]);
|
|
13
|
+
|
|
14
|
+
/** Keep locale ordering and punctuation intact while quieting fractional digits and units. */
|
|
15
|
+
export function NumberText(props: NumberTextProps): JSX.Element {
|
|
16
|
+
const [local, others] = splitProps(props, ["value", "format", "class"]);
|
|
17
|
+
const theme = useTheme();
|
|
18
|
+
const numberFormat = useContext(NumberFormatContext);
|
|
19
|
+
const locale = createMemo(() => theme.state().locale);
|
|
20
|
+
const formatter = createMemo(() => numberFormat ? numberFormat(locale(), local.format) : new Intl.NumberFormat(locale(), local.format));
|
|
21
|
+
const parts = createMemo(() => {
|
|
22
|
+
if (!Number.isFinite(local.value)) throw new Error("NumberText requires a finite value");
|
|
23
|
+
const rendered: Intl.NumberFormatPart[] = [];
|
|
24
|
+
for (const part of formatter().formatToParts(local.value)) {
|
|
25
|
+
const previous = rendered.at(-1);
|
|
26
|
+
if (!quietParts.has(part.type) && previous?.type === "literal") previous.value += part.value;
|
|
27
|
+
else rendered.push(quietParts.has(part.type) ? part : { type: "literal", value: part.value });
|
|
28
|
+
}
|
|
29
|
+
return rendered;
|
|
30
|
+
});
|
|
31
|
+
return <span {...others} class={cn("sheen-number-text", local.class)}><Index each={parts()}>{part =>
|
|
32
|
+
<Show when={quietParts.has(part().type)} fallback={part().value}>
|
|
33
|
+
<span data-number-part={part().type}>{part().value}</span>
|
|
34
|
+
</Show>
|
|
35
|
+
}</Index></span>;
|
|
36
|
+
}
|
|
@@ -16,6 +16,14 @@ export interface PopoverProps extends ParentProps {
|
|
|
16
16
|
class?: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
function PopoverTrigger(props: ParentProps): JSX.Element {
|
|
20
|
+
const context = Primitive.usePopoverContext();
|
|
21
|
+
return <Button ref={context.setTriggerRef} variant="outline" data-sheen-popover-trigger=""
|
|
22
|
+
aria-haspopup="dialog" aria-expanded={context.isOpen()} aria-controls={context.isOpen() ? context.contentId() : undefined}
|
|
23
|
+
onPointerDown={event => { if (event.pointerType === "mouse") event.preventDefault(); }}
|
|
24
|
+
onClick={() => context.toggle()} {...context.dataset()}>{props.children}</Button>;
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
export function Popover(props: PopoverProps): JSX.Element {
|
|
20
28
|
const theme = useTheme();
|
|
21
29
|
const id = createUniqueId();
|
|
@@ -29,7 +37,7 @@ export function Popover(props: PopoverProps): JSX.Element {
|
|
|
29
37
|
createEffect(() => { if (open()) onCleanup(theme.layers.register(id)); });
|
|
30
38
|
const layer = createMemo<number>(previous => open() ? theme.layers.zIndex(id) : previous ?? 100);
|
|
31
39
|
return <Primitive.Root open={open()} onOpenChange={change} placement={props.placement ?? "bottom"} gutter={6}>
|
|
32
|
-
<
|
|
40
|
+
<PopoverTrigger>{props.trigger}</PopoverTrigger>
|
|
33
41
|
<Show when={theme.portal()}>{target => <Primitive.Portal mount={target()}>
|
|
34
42
|
<Primitive.Content data-kb-top-layer="true" class={cn("sheen-popover", props.class)} aria-hidden={!open() || undefined} inert={!open()} style={{ "z-index": layer() }}
|
|
35
43
|
onEscapeKeyDown={event => { if (!theme.layers.isTop(id)) event.preventDefault(); }}>
|
|
@@ -18,12 +18,15 @@ export function createTooltipLayer(trigger: Accessor<HTMLElement | undefined>, d
|
|
|
18
18
|
onMount(() => {
|
|
19
19
|
const element = trigger();
|
|
20
20
|
if (!element) return;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
element.
|
|
21
|
+
// Focus and hover can overlap. Ending just one must not undo Escape
|
|
22
|
+
// while the other still keeps this interaction engaged.
|
|
23
|
+
const releaseFocus = () => { if (!element.matches(":hover")) dismissedWhileEngaged = false; };
|
|
24
|
+
const releasePointer = () => { if (element.ownerDocument.activeElement !== element) dismissedWhileEngaged = false; };
|
|
25
|
+
element.addEventListener("blur", releaseFocus);
|
|
26
|
+
element.addEventListener("pointerleave", releasePointer);
|
|
24
27
|
onCleanup(() => {
|
|
25
|
-
element.removeEventListener("blur",
|
|
26
|
-
element.removeEventListener("pointerleave",
|
|
28
|
+
element.removeEventListener("blur", releaseFocus);
|
|
29
|
+
element.removeEventListener("pointerleave", releasePointer);
|
|
27
30
|
});
|
|
28
31
|
if (!disabled() && (element.ownerDocument.activeElement === element || element.matches(":hover"))) setOpen(true);
|
|
29
32
|
});
|
package/src/styles.css
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
@layer theme, base, components, utilities;
|
|
2
2
|
@layer components {
|
|
3
|
+
.sheen-number-text { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
|
|
4
|
+
.sheen-number-text > :is([data-number-part="decimal"], [data-number-part="fraction"], [data-number-part="unit"], [data-number-part="percentSign"], [data-number-part="currency"], [data-number-part="compact"]) { color: var(--sheen-color-fg-muted); }
|
|
3
5
|
.sheen-editable-text { display: grid; gap: var(--sheen-space-block-xs); min-inline-size: 0; }
|
|
4
6
|
.sheen-editable-text > [role="button"], .sheen-editable-text > input { box-sizing: border-box; min-block-size: var(--sheen-control-h-md); inline-size: 100%; padding-block: var(--sheen-space-block-xs); padding-inline: var(--sheen-control-px-md); border: var(--sheen-control-border-width) solid transparent; border-radius: var(--sheen-control-radius); color: var(--sheen-color-fg); background: transparent; font: inherit; overflow-wrap: anywhere; }
|
|
5
7
|
.sheen-editable-text > [role="button"]:hover { background: var(--sheen-color-bg-hover); }
|
|
@@ -634,11 +636,12 @@
|
|
|
634
636
|
accent-color: var(--sheen-color-accent);
|
|
635
637
|
}
|
|
636
638
|
.sheen-progress::-webkit-progress-bar, .sheen-meter::-webkit-meter-bar { border: 0; border-radius: var(--sheen-radius-pill); background: var(--sheen-color-bg-inset); box-shadow: inset 0 0 0 1px var(--sheen-color-border-subtle); }
|
|
637
|
-
.sheen-progress::-webkit-progress-value
|
|
639
|
+
.sheen-progress::-webkit-progress-value { border-radius: var(--sheen-radius-pill); background: var(--sheen-color-accent); }
|
|
640
|
+
.sheen-progress::-moz-progress-bar { border-radius: var(--sheen-radius-pill); background: var(--sheen-color-accent); }
|
|
638
641
|
.sheen-meter { --sheen-meter-fill: var(--sheen-color-success); }
|
|
639
642
|
.sheen-meter[data-meter-state="suboptimum"] { --sheen-meter-fill: var(--sheen-color-warning); }
|
|
640
643
|
.sheen-meter[data-meter-state="critical"] { --sheen-meter-fill: var(--sheen-color-danger); }
|
|
641
|
-
.sheen-meter::-webkit-meter-optimum-value, .sheen-meter::-webkit-meter-suboptimum-value, .sheen-meter::-webkit-meter-even-less-good-value
|
|
644
|
+
.sheen-meter::-webkit-meter-optimum-value, .sheen-meter::-webkit-meter-suboptimum-value, .sheen-meter::-webkit-meter-even-less-good-value { border: 0; border-radius: var(--sheen-radius-pill); background: var(--sheen-meter-fill); box-shadow: none; }
|
|
642
645
|
.sheen-meter::-moz-meter-bar { border: 0; border-radius: var(--sheen-radius-pill); background: var(--sheen-meter-fill); box-shadow: none; }
|
|
643
646
|
@media (forced-colors: active) { .sheen-progress, .sheen-meter { appearance: auto; -webkit-appearance: auto; box-shadow: none; } }
|
|
644
647
|
.sheen-spinner-label { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
@@ -11,6 +11,7 @@ import { createOverlayStack } from "./layers.ts";
|
|
|
11
11
|
import type { OverlayStack } from "./layers.ts";
|
|
12
12
|
import { englishMessages, resolveMessages } from "./messages.ts";
|
|
13
13
|
import type { Messages } from "./messages.ts";
|
|
14
|
+
import { NumberFormatContext, createNumberFormatCache } from "./number-format-cache.ts";
|
|
14
15
|
|
|
15
16
|
interface ThemeRuntime {
|
|
16
17
|
state: Accessor<ThemeState>;
|
|
@@ -112,6 +113,7 @@ export interface ThemeProviderProps extends ParentProps {
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
export function ThemeProvider(props: ThemeProviderProps): JSX.Element {
|
|
116
|
+
const numberFormat = createNumberFormatCache();
|
|
115
117
|
const themes = () => props.themes ?? bundledThemeMetadata;
|
|
116
118
|
const defaults: ThemeState = {
|
|
117
119
|
...defaultThemeState,
|
|
@@ -162,15 +164,16 @@ export function ThemeProvider(props: ThemeProviderProps): JSX.Element {
|
|
|
162
164
|
}
|
|
163
165
|
},
|
|
164
166
|
});
|
|
165
|
-
return <ThemeContext.Provider value={context}><I18nProvider locale={locale()} direction={direction()}>
|
|
167
|
+
return <ThemeContext.Provider value={context}><NumberFormatContext.Provider value={numberFormat}><I18nProvider locale={locale()} direction={direction()}>
|
|
166
168
|
{props.children}
|
|
167
169
|
<PortalTarget kind="root" ready={ready()} ref={setPortal} state={ready() ? state() : undefined} mode={mode()} themes={themes()} />
|
|
168
|
-
</I18nProvider></ThemeContext.Provider>;
|
|
170
|
+
</I18nProvider></NumberFormatContext.Provider></ThemeContext.Provider>;
|
|
169
171
|
}
|
|
170
172
|
|
|
171
173
|
export interface ThemeScopeProps extends ParentProps, ThemeOverrides { controllable?: boolean; class?: string; messages?: Partial<Messages> }
|
|
172
174
|
|
|
173
175
|
export function ThemeScope(props: ThemeScopeProps): JSX.Element {
|
|
176
|
+
const numberFormat = createNumberFormatCache();
|
|
174
177
|
const parent = useTheme();
|
|
175
178
|
const [local, setLocal] = createSignal<Partial<ThemeState>>({});
|
|
176
179
|
const [portal, setPortal] = createSignal<HTMLElement>();
|
|
@@ -209,11 +212,11 @@ export function ThemeScope(props: ThemeScopeProps): JSX.Element {
|
|
|
209
212
|
if (props.locale !== undefined) result.locale = props.locale;
|
|
210
213
|
return result;
|
|
211
214
|
};
|
|
212
|
-
return <ThemeContext.Provider value={context}><I18nProvider locale={locale()} direction={direction()}>
|
|
215
|
+
return <ThemeContext.Provider value={context}><NumberFormatContext.Provider value={numberFormat}><I18nProvider locale={locale()} direction={direction()}>
|
|
213
216
|
<section id={id} class={props.class} {...attributes(state(), mode(), themes())} dir={state().direction} lang={state().locale}>
|
|
214
217
|
{props.children}
|
|
215
218
|
<PortalTarget kind="scope" ref={setPortal} state={state()} mode={mode()} themes={themes()} />
|
|
216
219
|
<script nonce={parent.nonce} innerHTML={createScopeScript(overrides(), parent.defaults, themes())} />
|
|
217
220
|
</section>
|
|
218
|
-
</I18nProvider></ThemeContext.Provider>;
|
|
221
|
+
</I18nProvider></NumberFormatContext.Provider></ThemeContext.Provider>;
|
|
219
222
|
}
|
package/src/theme/messages.ts
CHANGED
|
@@ -92,6 +92,9 @@ export interface ExtensionMessages {
|
|
|
92
92
|
readonly filterIsEmpty?: string;
|
|
93
93
|
readonly filterIsAnyOf?: string;
|
|
94
94
|
readonly filterSummary?: string;
|
|
95
|
+
readonly constrainedColumns?: string;
|
|
96
|
+
readonly constrainedColumn?: string;
|
|
97
|
+
readonly restoreColumn?: string;
|
|
95
98
|
readonly filterNot?: string;
|
|
96
99
|
readonly filterInheritedNot?: string;
|
|
97
100
|
readonly queryBuilder?: string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createContext } from "solid-js";
|
|
2
|
+
|
|
3
|
+
type NumberFormatter = (locale: string, options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
|
|
4
|
+
|
|
5
|
+
// Context identity is shared; formatter instances belong to each provider/request.
|
|
6
|
+
export const NumberFormatContext = createContext<NumberFormatter>();
|
|
7
|
+
|
|
8
|
+
function optionsKey(options: Intl.NumberFormatOptions | undefined): string | undefined {
|
|
9
|
+
if (options === undefined) return "[]";
|
|
10
|
+
if (options === null || typeof options !== "object") return undefined;
|
|
11
|
+
const prototype: unknown = Object.getPrototypeOf(options);
|
|
12
|
+
if (prototype !== Object.prototype && prototype !== null) return undefined;
|
|
13
|
+
const entries: string[][] = [];
|
|
14
|
+
for (const name of Object.getOwnPropertyNames(options).sort()) {
|
|
15
|
+
const descriptor = Object.getOwnPropertyDescriptor(options, name);
|
|
16
|
+
if (!descriptor || !("value" in descriptor)) return undefined;
|
|
17
|
+
const value: unknown = descriptor.value;
|
|
18
|
+
if (value === undefined) continue;
|
|
19
|
+
if (value !== null && typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return undefined;
|
|
20
|
+
entries.push([name, typeof value, Object.is(value, -0) ? "-0" : String(value)]);
|
|
21
|
+
}
|
|
22
|
+
return JSON.stringify(entries);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Cache plain option records by value; accessors/custom prototypes retain native evaluation. */
|
|
26
|
+
export function createNumberFormatCache(): NumberFormatter {
|
|
27
|
+
const formatters = new Map<string, Intl.NumberFormat>();
|
|
28
|
+
return (locale, options) => {
|
|
29
|
+
const key = optionsKey(options);
|
|
30
|
+
if (key === undefined) return new Intl.NumberFormat(locale, options);
|
|
31
|
+
const identity = JSON.stringify([locale, key]);
|
|
32
|
+
const existing = formatters.get(identity);
|
|
33
|
+
if (existing) return existing;
|
|
34
|
+
const formatter = new Intl.NumberFormat(locale, options);
|
|
35
|
+
if (formatters.size >= 32) {
|
|
36
|
+
const oldest = formatters.keys().next().value;
|
|
37
|
+
if (oldest !== undefined) formatters.delete(oldest);
|
|
38
|
+
}
|
|
39
|
+
formatters.set(identity, formatter);
|
|
40
|
+
return formatter;
|
|
41
|
+
};
|
|
42
|
+
}
|