@alulore/kumiko 0.20.1 → 0.21.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/avatar/avatar.js +1 -1
- package/dist/badge/badge.css +41 -3
- package/dist/badge/badge.js +11 -4
- package/dist/board/board-slots.js +2 -1
- package/dist/board/scrollbar-gutter.js +26 -2
- package/dist/button/button.css +21 -7
- package/dist/card/card.css +3 -2
- package/dist/card/item-card.d.ts +1 -1
- package/dist/card/item-card.js +3 -2
- package/dist/chip/chip.css +6 -10
- package/dist/chip/chip.js +1 -1
- package/dist/form/error-line.js +4 -3
- package/dist/input/input.css +99 -114
- package/dist/list-row/list-row-motion.js +29 -10
- package/dist/media-viewer/gesture-press.d.ts +1 -0
- package/dist/media-viewer/gesture-press.js +12 -0
- package/dist/media-viewer/media-slide.d.ts +3 -1
- package/dist/media-viewer/media-slide.js +3 -2
- package/dist/media-viewer/media-viewer.css +5 -1
- package/dist/media-viewer/media-viewer.js +41 -23
- package/dist/media-viewer/stage-rect.d.ts +16 -0
- package/dist/media-viewer/stage-rect.js +56 -0
- package/dist/media-viewer/view-gesture.d.ts +1 -2
- package/dist/media-viewer/view-gesture.js +39 -44
- package/dist/media-viewer/viewer-chrome.d.ts +2 -1
- package/dist/media-viewer/viewer-chrome.js +3 -1
- package/dist/media-viewer/viewer-motion.d.ts +1 -0
- package/dist/media-viewer/viewer-motion.js +20 -7
- package/dist/media-viewer/zoom-pan.d.ts +1 -0
- package/dist/media-viewer/zoom-pan.js +3 -0
- package/dist/media-viewer/zoom-store.d.ts +8 -0
- package/dist/media-viewer/zoom-store.js +30 -0
- package/dist/menu/menu.js +6 -3
- package/dist/menu/point-menu.js +32 -12
- package/dist/motion/flip.js +33 -20
- package/dist/page/page-actions.js +2 -1
- package/dist/page/page-breadcrumbs.js +2 -1
- package/dist/page/use-measured-fit.d.ts +5 -0
- package/dist/page/use-measured-fit.js +47 -5
- package/dist/page/use-stuck.js +12 -2
- package/dist/pagination/pagination-fit.d.ts +3 -1
- package/dist/pagination/pagination-fit.js +4 -3
- package/dist/pagination/pagination-motion.js +18 -11
- package/dist/pagination/pagination.css +50 -6
- package/dist/pagination/pagination.js +20 -3
- package/dist/progress/progress.css +3 -2
- package/dist/progress/progress.js +15 -3
- package/dist/select/select-labels.d.ts +2 -0
- package/dist/select/select-labels.js +5 -1
- package/dist/select/select.css +7 -11
- package/dist/select/select.d.ts +1 -1
- package/dist/select/select.js +12 -6
- package/dist/shortcuts/hints.js +10 -4
- package/dist/shortcuts/provider.d.ts +4 -2
- package/dist/shortcuts/provider.js +14 -17
- package/dist/skeleton/skeleton.css +22 -9
- package/dist/slider/slider-feel.js +18 -6
- package/dist/slider/slider.css +9 -10
- package/dist/slider/slider.js +13 -10
- package/dist/smooth-caret/caret-controller.js +18 -6
- package/dist/smooth-caret/caret-geometry.js +18 -7
- package/dist/smooth-caret/caret-glide.js +3 -2
- package/dist/smooth-caret/remote-carets.js +20 -3
- package/dist/smooth-caret/smooth-caret.css +1 -1
- package/dist/switch/switch-gesture.d.ts +4 -4
- package/dist/switch/switch-gesture.js +52 -14
- package/dist/switch/switch.css +12 -13
- package/dist/switch/switch.d.ts +2 -1
- package/dist/switch/switch.js +4 -6
- package/dist/table/data-table.js +32 -12
- package/dist/table/table-cells.d.ts +20 -8
- package/dist/table/table-cells.js +18 -20
- package/dist/table/table-model.d.ts +0 -2
- package/dist/table/table-model.js +15 -9
- package/dist/table/table-search.d.ts +12 -0
- package/dist/table/table-search.js +34 -0
- package/dist/table/table-sections.d.ts +3 -2
- package/dist/table/table-sections.js +16 -13
- package/dist/table/table.css +2 -14
- package/dist/table/use-latest.d.ts +6 -0
- package/dist/table/use-latest.js +22 -0
- package/dist/table/use-table-view.js +36 -24
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createPaginationController, Pagination as SdkPagination, PaginationEllipsis, PaginationFirst, PaginationItem, PaginationLast, PaginationLink, PaginationList, PaginationNext, PaginationPrevious } from "@ui-sdk/react/pagination";
|
|
3
|
-
import { useMemo, useState } from "react";
|
|
3
|
+
import { useLayoutEffect, useMemo, useState } from "react";
|
|
4
4
|
import { PaginationJump, PaginationPageSize, PaginationRange } from "./pagination-extras";
|
|
5
5
|
import { usePaginationFit } from "./pagination-fit";
|
|
6
6
|
import { FirstIcon, LastIcon, NextIcon, PreviousIcon } from "./pagination-icons";
|
|
@@ -44,10 +44,26 @@ function Trailing({ state, options, controller, perPage, changeSize, words, form
|
|
|
44
44
|
const { pageSizes, disabled = false } = options;
|
|
45
45
|
return (_jsxs("div", { "data-slot": "pagination-trailing", children: [pageSizes && (_jsx(PaginationPageSize, { sizes: pageSizes, value: perPage, onChange: changeSize, words: words, format: format, disabled: disabled })), options.jump && (_jsx(PaginationJump, { controller: controller, pageCount: state.pageCount, words: words, disabled: disabled }))] }));
|
|
46
46
|
}
|
|
47
|
+
/** Everything the pages and what sits beside them show, which decides how wide the list is. */
|
|
48
|
+
function widthKey({ state, options, perPage, appearance }) {
|
|
49
|
+
return [
|
|
50
|
+
appearance,
|
|
51
|
+
state.page,
|
|
52
|
+
state.pageCount,
|
|
53
|
+
state.items.join(","),
|
|
54
|
+
perPage,
|
|
55
|
+
options.total,
|
|
56
|
+
options.pageSizes?.join(","),
|
|
57
|
+
options.firstLast,
|
|
58
|
+
options.range,
|
|
59
|
+
options.jump
|
|
60
|
+
].join("|");
|
|
61
|
+
}
|
|
47
62
|
function Body(props) {
|
|
48
63
|
const { state, options, perPage, words, format } = props;
|
|
49
64
|
const { renderLink, getHref, total } = options;
|
|
50
65
|
const [list, setList] = useState(null);
|
|
66
|
+
useLayoutEffect(props.measure, [props.measure, widthKey(props)]);
|
|
51
67
|
usePaginationMotion(list, state.page, state.items.join(","));
|
|
52
68
|
const trailing = Boolean(options.range || options.pageSizes || options.jump);
|
|
53
69
|
const link = renderLink && getHref
|
|
@@ -72,6 +88,7 @@ export function Pagination(props) {
|
|
|
72
88
|
const [own] = useState(createPaginationController);
|
|
73
89
|
const controller = given ?? own;
|
|
74
90
|
const { perPage, changeSize } = usePageSize(props, controller);
|
|
75
|
-
const { fit, rootRef } = usePaginationFit(fitting);
|
|
76
|
-
|
|
91
|
+
const { fit, rootRef, measure } = usePaginationFit(fitting);
|
|
92
|
+
const appearance = [fit, size, layout, look, siblings, locale, ...Object.values(words)].join("|");
|
|
93
|
+
return (_jsx(SdkPagination, { "aria-label": words.navigation, ...rest, ref: rootRef, pageSize: rest.total === undefined ? undefined : perPage, siblings: fit >= 1 ? 0 : siblings, controller: controller, "data-layout": layout, "data-look": look, "data-size": size, "data-fit": fitWords[fit] || undefined, children: (state) => (_jsx(Body, { state: state, options: props, controller: controller, perPage: perPage, changeSize: changeSize, words: words, format: format, measure: measure, appearance: appearance })) }));
|
|
77
94
|
}
|
|
@@ -181,7 +181,8 @@
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
/* A soft glow at the leading end of the fill, which is its inline end. It moves with the fill. */
|
|
184
|
-
[data-slot="progress-
|
|
184
|
+
[data-slot="progress-indicator"]::before {
|
|
185
|
+
content: "";
|
|
185
186
|
position: absolute;
|
|
186
187
|
inset-block: 0;
|
|
187
188
|
inset-inline-end: 0;
|
|
@@ -224,7 +225,7 @@
|
|
|
224
225
|
animation: kumiko-progress-sheen var(--kumiko-progress-sheen-duration) ease-in-out infinite;
|
|
225
226
|
}
|
|
226
227
|
|
|
227
|
-
[data-slot="progress-indicator"][data-indeterminate]
|
|
228
|
+
[data-slot="progress-indicator"][data-indeterminate]::before,
|
|
228
229
|
[data-slot="progress-indicator"][data-indeterminate] > [data-slot="progress-sheen"],
|
|
229
230
|
[data-slot="progress-indicator"][data-complete] > [data-slot="progress-sheen"] {
|
|
230
231
|
display: none;
|
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Progress as SdkProgress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue } from "@ui-sdk/react/progress";
|
|
3
3
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
const formatters = new Map();
|
|
5
|
+
/** One formatter per locale and options, so counting up does not build a new one every frame. */
|
|
6
|
+
function formatterFor(locale, options) {
|
|
7
|
+
const key = `${locale ?? ""}|${JSON.stringify(options)}`;
|
|
8
|
+
const known = formatters.get(key);
|
|
9
|
+
if (known) {
|
|
10
|
+
return known;
|
|
11
|
+
}
|
|
12
|
+
const made = new Intl.NumberFormat(locale, options);
|
|
13
|
+
formatters.set(key, made);
|
|
14
|
+
return made;
|
|
15
|
+
}
|
|
4
16
|
/** The text ui-sdk would show for a value, for the numbers in between while counting. */
|
|
5
17
|
function formatAt(value, { min = 0, max = 100, format, locale }) {
|
|
6
18
|
if (typeof format === "function") {
|
|
7
19
|
return format(value);
|
|
8
20
|
}
|
|
9
21
|
if (format && format.style !== "percent") {
|
|
10
|
-
return
|
|
22
|
+
return formatterFor(locale, format).format(value);
|
|
11
23
|
}
|
|
12
24
|
const span = max - min;
|
|
13
25
|
const share = span === 0 ? 0 : (Math.min(max, Math.max(min, value)) - min) / span;
|
|
14
|
-
return
|
|
26
|
+
return formatterFor(locale, format ?? { style: "percent" }).format(share);
|
|
15
27
|
}
|
|
16
28
|
/** The move duration, in milliseconds, that the tokens give an element. */
|
|
17
29
|
function moveDuration(element) {
|
|
@@ -103,5 +115,5 @@ export function Progress({ size = "md", label, showValue = false, indeterminate
|
|
|
103
115
|
};
|
|
104
116
|
return (_jsxs(SdkProgress, { "data-size": size, "data-indeterminate-style": indeterminate, "data-kumiko-progress": looks({ recessed, floating, sheen, completeGlow, lit }), "data-finished": finished ? "" : undefined, ...props, children: [named ? _jsx(ProgressLabel, { children: label }) : null, showValue ? (_jsx(ProgressValue, { children: countUp
|
|
105
117
|
? (state) => (_jsx(CountedValue, { state: state, settings: settings }))
|
|
106
|
-
: undefined })) : null, _jsx(ProgressTrack, { children: _jsx("div", { "data-slot": "progress-clip", children:
|
|
118
|
+
: undefined })) : null, _jsx(ProgressTrack, { children: _jsx("div", { "data-slot": "progress-clip", children: _jsx(ProgressIndicator, { children: _jsx("span", { "data-slot": "progress-sheen", "aria-hidden": "true" }) }) }) })] }));
|
|
107
119
|
}
|
|
@@ -4,3 +4,5 @@ import { type ReactNode } from "react";
|
|
|
4
4
|
export declare const LabelsContext: import("react").Context<readonly string[]>;
|
|
5
5
|
/** Every option label that a select's `items` and children give, and its placeholder. */
|
|
6
6
|
export declare function labelsOf(items: ListData<unknown> | undefined, children: ReactNode, placeholder: string | undefined): string[];
|
|
7
|
+
/** Whether two label lists hold the same labels in the same order. */
|
|
8
|
+
export declare function sameLabels(left: readonly string[], right: readonly string[]): boolean;
|
|
@@ -60,5 +60,9 @@ export function labelsOf(items, children, placeholder) {
|
|
|
60
60
|
if (found.length > 0 && placeholder) {
|
|
61
61
|
found.push(placeholder);
|
|
62
62
|
}
|
|
63
|
-
return [...new Set(found)];
|
|
63
|
+
return [...new Set(found.map((label) => label.replaceAll(/\s+/gu, " ").trim()))];
|
|
64
|
+
}
|
|
65
|
+
/** Whether two label lists hold the same labels in the same order. */
|
|
66
|
+
export function sameLabels(left, right) {
|
|
67
|
+
return left.length === right.length && left.every((label, at) => label === right[at]);
|
|
64
68
|
}
|
package/dist/select/select.css
CHANGED
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/* Without a sizer, the trigger fits its value, up to the cap. */
|
|
82
|
-
:where([data-slot="select-trigger"]:not(
|
|
82
|
+
:where([data-slot="select-trigger"]:not([data-sized])) {
|
|
83
83
|
max-inline-size: min(var(--kumiko-select-trigger-max-width), 100%);
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -93,25 +93,21 @@
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/*
|
|
96
|
-
* The sizer is an invisible copy of every option label,
|
|
97
|
-
* one sets the trigger's own width and choosing never resizes it.
|
|
98
|
-
* the page gives the trigger is honoured, and the value fills it.
|
|
96
|
+
* The sizer is an invisible copy of every option label, one per line and no taller than nothing, in
|
|
97
|
+
* the value's cell, so the widest one sets the trigger's own width and choosing never resizes it.
|
|
98
|
+
* Its cap is the only cap: a width the page gives the trigger is honoured, and the value fills it.
|
|
99
99
|
*/
|
|
100
100
|
:where([data-slot="select-sizer"]) {
|
|
101
|
-
|
|
101
|
+
block-size: 1lh;
|
|
102
102
|
grid-area: 1 / 2;
|
|
103
103
|
max-inline-size: var(--kumiko-select-trigger-max-width);
|
|
104
104
|
overflow: hidden;
|
|
105
105
|
pointer-events: none;
|
|
106
106
|
visibility: hidden;
|
|
107
|
-
white-space:
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
:where([data-slot="select-sizer"] > *) {
|
|
111
|
-
grid-area: 1 / 1;
|
|
107
|
+
white-space: pre;
|
|
112
108
|
}
|
|
113
109
|
|
|
114
|
-
:where([data-slot="select-trigger"]
|
|
110
|
+
:where([data-slot="select-trigger"][data-sized]) {
|
|
115
111
|
--_select-value-contain: inline-size;
|
|
116
112
|
}
|
|
117
113
|
|
package/dist/select/select.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type SelectTriggerProps = SdkTriggerProps & {
|
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* The ui-sdk select trigger, with a chevron after its children unless `chevron` is `false`. It is as wide as its
|
|
21
|
-
* longest option, which an invisible copy of every label (a sizer) gives it, so choosing never resizes it.
|
|
21
|
+
* longest option, which an invisible copy of every label, one per line (a sizer) gives it, so choosing never resizes it.
|
|
22
22
|
*/
|
|
23
23
|
export declare function SelectTrigger({ chevron, tooltip, children, ref: callerRef, ...props }: SelectTriggerProps): React.JSX.Element;
|
|
24
24
|
type SdkContentProps = Parameters<typeof SdkSelectContent>[0];
|
package/dist/select/select.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Select as SdkSelect, SelectItemText, SelectContent as SdkSelectContent, SelectItem as SdkSelectItem, SelectItemIndicator, SelectTrigger as SdkSelectTrigger } from "@ui-sdk/react/select";
|
|
3
|
-
import { useCallback, useContext, useRef, useState } from "react";
|
|
3
|
+
import { useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip";
|
|
5
|
-
import { labelsOf, LabelsContext } from "./select-labels";
|
|
5
|
+
import { labelsOf, LabelsContext, sameLabels } from "./select-labels";
|
|
6
6
|
import { SearchContext, SearchedList } from "./select-search";
|
|
7
7
|
/** The ui-sdk select, which opens as a bottom sheet on small touch screens instead of always as a popover. Any `presentation` still overrides it. */
|
|
8
8
|
export function Select(props) {
|
|
9
|
-
const
|
|
9
|
+
const found = useMemo(() => labelsOf(props.items, props.children, props.placeholder), [props.items, props.children, props.placeholder]);
|
|
10
|
+
const kept = useRef(found);
|
|
11
|
+
if (!sameLabels(kept.current, found)) {
|
|
12
|
+
kept.current = found;
|
|
13
|
+
}
|
|
14
|
+
const labels = kept.current;
|
|
10
15
|
return (_jsx(LabelsContext.Provider, { value: labels, children: _jsx(SdkSelect, { ...props, presentation: props.presentation ?? "auto" }) }));
|
|
11
16
|
}
|
|
12
17
|
/** Children with something added after them, whether they are nodes or a function of the part's state. */
|
|
@@ -53,7 +58,7 @@ function CutOffTip({ trigger, triggerRef }) {
|
|
|
53
58
|
}
|
|
54
59
|
/**
|
|
55
60
|
* The ui-sdk select trigger, with a chevron after its children unless `chevron` is `false`. It is as wide as its
|
|
56
|
-
* longest option, which an invisible copy of every label (a sizer) gives it, so choosing never resizes it.
|
|
61
|
+
* longest option, which an invisible copy of every label, one per line (a sizer) gives it, so choosing never resizes it.
|
|
57
62
|
*/
|
|
58
63
|
export function SelectTrigger({ chevron = true, tooltip = true, children, ref: callerRef, ...props }) {
|
|
59
64
|
const ref = useRef(null);
|
|
@@ -75,8 +80,9 @@ export function SelectTrigger({ chevron = true, tooltip = true, children, ref: c
|
|
|
75
80
|
return undefined;
|
|
76
81
|
}, [callerRef]);
|
|
77
82
|
const labels = useContext(LabelsContext);
|
|
78
|
-
const
|
|
79
|
-
const
|
|
83
|
+
const sized = labels.length > 0;
|
|
84
|
+
const extra = (_jsxs(_Fragment, { children: [sized ? (_jsx("span", { "data-slot": "select-sizer", "aria-hidden": "true", children: labels.join("\n") })) : null, chevron ? _jsx("span", { "data-slot": "select-chevron", "aria-hidden": "true" }) : null] }));
|
|
85
|
+
const trigger = (_jsx(SdkSelectTrigger, { ...props, "data-sized": sized ? "" : undefined, ref: both, children: followedBy(children, extra) }));
|
|
80
86
|
return tooltip ? _jsx(CutOffTip, { trigger: trigger, triggerRef: ref }) : trigger;
|
|
81
87
|
}
|
|
82
88
|
/** The ui-sdk select content, which opens below its trigger, aligned to its start, with a small gap. */
|
package/dist/shortcuts/hints.js
CHANGED
|
@@ -3,13 +3,18 @@ import { ariaKeyshortcuts } from "@ui-sdk/react/shortcuts";
|
|
|
3
3
|
import { cloneElement } from "react";
|
|
4
4
|
import { Kbd } from "../kbd";
|
|
5
5
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip";
|
|
6
|
-
import { useShortcuts } from "./provider";
|
|
6
|
+
import { useModHeldValue, useShortcuts } from "./provider";
|
|
7
|
+
/** The badge of a hint, the one part of it that follows the mod key. */
|
|
8
|
+
function HintBadge({ keys }) {
|
|
9
|
+
const [modHeld] = useModHeldValue();
|
|
10
|
+
return (_jsx(Kbd, { keys: keys, listen: false, className: "kumiko-shortcuts-badge", "data-shown": modHeld ? "" : undefined, "aria-hidden": "true" }));
|
|
11
|
+
}
|
|
7
12
|
/**
|
|
8
13
|
* Shows an action's current keys on the control that runs it, the way the provider's `hints` says:
|
|
9
14
|
* a tooltip, a badge while the mod key is held, or nothing.
|
|
10
15
|
*/
|
|
11
16
|
export function ShortcutHint({ action, label, children }) {
|
|
12
|
-
const { keysFor, options
|
|
17
|
+
const { keysFor, options } = useShortcuts();
|
|
13
18
|
const keys = keysFor(action);
|
|
14
19
|
const first = keys[0];
|
|
15
20
|
const control = cloneElement(children, {
|
|
@@ -19,13 +24,14 @@ export function ShortcutHint({ action, label, children }) {
|
|
|
19
24
|
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: control }), _jsxs(TooltipContent, { children: [label, first ? (_jsxs(_Fragment, { children: [" ", _jsx(Kbd, { keys: first, listen: false, look: "flat" })] })) : null] })] }));
|
|
20
25
|
}
|
|
21
26
|
if (options.hints === "badges") {
|
|
22
|
-
return (_jsxs("span", { className: "kumiko-shortcuts-target", children: [control, first ?
|
|
27
|
+
return (_jsxs("span", { className: "kumiko-shortcuts-target", children: [control, first ? _jsx(HintBadge, { keys: first }) : null] }));
|
|
23
28
|
}
|
|
24
29
|
return control;
|
|
25
30
|
}
|
|
26
31
|
/** A button that shows the key badges on a touch screen, where there is no mod key to hold. Renders only when `hints` is "badges". */
|
|
27
32
|
export function ShortcutBadgesButton({ className, children = "Show key badges" }) {
|
|
28
|
-
const { options
|
|
33
|
+
const { options } = useShortcuts();
|
|
34
|
+
const [modHeld, setModHeld] = useModHeldValue();
|
|
29
35
|
if (options.hints !== "badges") {
|
|
30
36
|
return null;
|
|
31
37
|
}
|
|
@@ -85,14 +85,15 @@ export interface ShortcutsContextValue {
|
|
|
85
85
|
available: ReadonlySet<string>;
|
|
86
86
|
/** Whether the last attempt to save the changed keys failed. */
|
|
87
87
|
saveFailed: boolean;
|
|
88
|
-
modHeld: boolean;
|
|
89
|
-
setModHeld: (held: boolean) => void;
|
|
90
88
|
/**
|
|
91
89
|
* Binds code to a declared action. The binding last mounted for an id wins, and the one before it takes
|
|
92
90
|
* over again when that one goes. Returns the way to remove it.
|
|
93
91
|
*/
|
|
94
92
|
bind: (id: string, binding: React.RefObject<BoundShortcutAction>) => () => void;
|
|
95
93
|
}
|
|
94
|
+
type ModHeldValue = readonly [held: boolean, setHeld: (held: boolean) => void];
|
|
95
|
+
/** Whether the mod key is held, and a way to set it. Only the parts that show the badges read it, so a key press renders no one else. */
|
|
96
|
+
export declare function useModHeldValue(): ModHeldValue;
|
|
96
97
|
export declare function useShortcuts(): ShortcutsContextValue;
|
|
97
98
|
/** The shortcuts of the nearest provider, or nothing when there is none. */
|
|
98
99
|
export declare function useOptionalShortcuts(): ShortcutsContextValue | null;
|
|
@@ -103,3 +104,4 @@ export type ShortcutsProviderProps = ShortcutsOptions & {
|
|
|
103
104
|
};
|
|
104
105
|
/** Wraps the part of the app that has shortcuts: registers every action and holds what the help sheet and hints need. */
|
|
105
106
|
export declare function ShortcutsProvider(props: ShortcutsProviderProps): React.JSX.Element;
|
|
107
|
+
export {};
|
|
@@ -5,6 +5,17 @@ import { isOverrides, keysOf, sanitizeOverrides, withoutActions } from "./bindin
|
|
|
5
5
|
import { defaultReservedKeys } from "./keys";
|
|
6
6
|
import { listAvailable, useModHeld, useRegistration } from "./registration";
|
|
7
7
|
const ShortcutsContext = createContext(null);
|
|
8
|
+
const ModHeldContext = createContext([false, () => { }]);
|
|
9
|
+
/** Whether the mod key is held, and a way to set it. Only the parts that show the badges read it, so a key press renders no one else. */
|
|
10
|
+
export function useModHeldValue() {
|
|
11
|
+
return use(ModHeldContext);
|
|
12
|
+
}
|
|
13
|
+
/** Holds the mod key state apart from the shortcuts' own context, so holding the key renders only its readers. */
|
|
14
|
+
function ModHeldScope({ enabled, children }) {
|
|
15
|
+
const [held, setHeld] = useModHeld(enabled);
|
|
16
|
+
const value = useMemo(() => [held, setHeld], [held, setHeld]);
|
|
17
|
+
return _jsx(ModHeldContext, { value: value, children: children });
|
|
18
|
+
}
|
|
8
19
|
export function useShortcuts() {
|
|
9
20
|
const value = use(ShortcutsContext);
|
|
10
21
|
if (!value) {
|
|
@@ -116,7 +127,6 @@ export function ShortcutsProvider(props) {
|
|
|
116
127
|
const { bind, binding } = useBindings();
|
|
117
128
|
const live = useRef({ ...options, actions, overrides, toggleHelp: () => { }, binding });
|
|
118
129
|
const help = useHelpState(live);
|
|
119
|
-
const [modHeld, setModHeld] = useModHeld(options.hints === "badges");
|
|
120
130
|
useRegistered(live, { options, actions, overrides, binding, help });
|
|
121
131
|
const value = useMemo(() => ({
|
|
122
132
|
...help,
|
|
@@ -133,20 +143,7 @@ export function ShortcutsProvider(props) {
|
|
|
133
143
|
setOverrides,
|
|
134
144
|
resetAll: () => setOverrides(withoutActions(overrides, actions)),
|
|
135
145
|
bind,
|
|
136
|
-
saveFailed
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}), [
|
|
140
|
-
help,
|
|
141
|
-
actions,
|
|
142
|
-
notes,
|
|
143
|
-
overrides,
|
|
144
|
-
options,
|
|
145
|
-
setOverrides,
|
|
146
|
-
saveFailed,
|
|
147
|
-
modHeld,
|
|
148
|
-
setModHeld,
|
|
149
|
-
bind
|
|
150
|
-
]);
|
|
151
|
-
return _jsx(ShortcutsContext, { value: value, children: children });
|
|
146
|
+
saveFailed
|
|
147
|
+
}), [help, actions, notes, overrides, options, setOverrides, saveFailed, bind]);
|
|
148
|
+
return (_jsx(ShortcutsContext, { value: value, children: _jsx(ModHeldScope, { enabled: options.hints === "badges", children: children }) }));
|
|
152
149
|
}
|
|
@@ -26,29 +26,41 @@
|
|
|
26
26
|
block-size: var(--kumiko-skeleton-size);
|
|
27
27
|
border-radius: var(--kumiko-skeleton-radius);
|
|
28
28
|
background-color: var(--kumiko-skeleton-bg);
|
|
29
|
+
position: relative;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* The band lives on its own layer, three times as wide as the block, that slides by translate so no frame repaints. */
|
|
34
|
+
:where([data-slot="skeleton"])::after {
|
|
35
|
+
content: "";
|
|
36
|
+
display: var(--_skeleton-shine-display, block);
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: 0;
|
|
39
|
+
left: 0;
|
|
40
|
+
width: 300%;
|
|
41
|
+
height: 100%;
|
|
29
42
|
background-image: linear-gradient(
|
|
30
43
|
90deg,
|
|
31
44
|
transparent calc(50% - var(--kumiko-skeleton-band) / 2),
|
|
32
45
|
var(--kumiko-skeleton-shine) 50%,
|
|
33
46
|
transparent calc(50% + var(--kumiko-skeleton-band) / 2)
|
|
34
47
|
);
|
|
35
|
-
|
|
36
|
-
background-size: 300% 100%;
|
|
48
|
+
pointer-events: none;
|
|
37
49
|
animation: kumiko-skeleton-sweep var(--_skeleton-sweep) ease-in-out infinite;
|
|
38
50
|
}
|
|
39
51
|
|
|
40
52
|
@keyframes kumiko-skeleton-sweep {
|
|
41
53
|
from {
|
|
42
|
-
|
|
54
|
+
translate: -66.667% 0;
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
to {
|
|
46
|
-
|
|
58
|
+
translate: 0 0;
|
|
47
59
|
}
|
|
48
60
|
}
|
|
49
61
|
|
|
50
62
|
/* In right-to-left text the band sweeps the other way, from the start of the line. */
|
|
51
|
-
:where([data-slot="skeleton"]:dir(rtl)) {
|
|
63
|
+
:where([data-slot="skeleton"]:dir(rtl))::after {
|
|
52
64
|
animation-direction: reverse;
|
|
53
65
|
}
|
|
54
66
|
|
|
@@ -79,7 +91,7 @@
|
|
|
79
91
|
:not([data-animation]):is([data-kumiko-skeleton~="pulse"] *)
|
|
80
92
|
)
|
|
81
93
|
) {
|
|
82
|
-
|
|
94
|
+
--_skeleton-shine-display: none;
|
|
83
95
|
animation: kumiko-skeleton-pulse var(--_skeleton-pulse) ease-in-out infinite;
|
|
84
96
|
}
|
|
85
97
|
|
|
@@ -95,7 +107,7 @@
|
|
|
95
107
|
:not([data-animation]):is([data-kumiko-skeleton~="still"] *)
|
|
96
108
|
)
|
|
97
109
|
) {
|
|
98
|
-
|
|
110
|
+
--_skeleton-shine-display: none;
|
|
99
111
|
animation: none;
|
|
100
112
|
}
|
|
101
113
|
|
|
@@ -106,7 +118,7 @@
|
|
|
106
118
|
:not([data-animation]):is([data-kumiko-skeleton~="still"] *)
|
|
107
119
|
)
|
|
108
120
|
) {
|
|
109
|
-
|
|
121
|
+
--_skeleton-shine-display: none;
|
|
110
122
|
animation: kumiko-skeleton-pulse calc(var(--_skeleton-pulse) * 1.5) ease-in-out infinite;
|
|
111
123
|
}
|
|
112
124
|
}
|
|
@@ -117,7 +129,7 @@
|
|
|
117
129
|
:not([data-animation]):is([data-kumiko-skeleton~="still"] *)
|
|
118
130
|
)
|
|
119
131
|
) {
|
|
120
|
-
|
|
132
|
+
--_skeleton-shine-display: none;
|
|
121
133
|
animation: kumiko-skeleton-pulse calc(var(--_skeleton-pulse) * 1.5) ease-in-out infinite;
|
|
122
134
|
}
|
|
123
135
|
|
|
@@ -136,6 +148,7 @@
|
|
|
136
148
|
|
|
137
149
|
@media (forced-colors: active) {
|
|
138
150
|
:where([data-slot="skeleton"]) {
|
|
151
|
+
--_skeleton-shine-display: none;
|
|
139
152
|
background: GrayText;
|
|
140
153
|
forced-color-adjust: none;
|
|
141
154
|
}
|
|
@@ -66,10 +66,12 @@ function useBubbleHold() {
|
|
|
66
66
|
};
|
|
67
67
|
return { shown, delay, hold, holdAgain };
|
|
68
68
|
}
|
|
69
|
-
/** Reads the bubble delay, and gives the thumb an event happened in unless the slider is locked. */
|
|
70
|
-
function thumbFor(event, delay) {
|
|
69
|
+
/** Reads the bubble delay once for each press or held key (`reads` is false while a key is already held), and gives the thumb an event happened in unless the slider is locked. */
|
|
70
|
+
function thumbFor(event, delay, reads = true) {
|
|
71
71
|
const index = thumbIn(event.target);
|
|
72
|
-
|
|
72
|
+
if (reads) {
|
|
73
|
+
delay.current = bubbleDelay(event.currentTarget);
|
|
74
|
+
}
|
|
73
75
|
return index !== null && !isLocked(event.currentTarget) ? index : null;
|
|
74
76
|
}
|
|
75
77
|
/** Whether the last thing done to the slider was a pointer press, and whether that press was a finger. */
|
|
@@ -77,6 +79,7 @@ function usePressKind() {
|
|
|
77
79
|
const [pointer, setPointer] = useState(false);
|
|
78
80
|
const [touch, setTouch] = useState(false);
|
|
79
81
|
const pressing = useRef(false);
|
|
82
|
+
const held = useRef(false);
|
|
80
83
|
return {
|
|
81
84
|
pointer,
|
|
82
85
|
touch,
|
|
@@ -88,7 +91,15 @@ function usePressKind() {
|
|
|
88
91
|
up: () => {
|
|
89
92
|
pressing.current = false;
|
|
90
93
|
},
|
|
91
|
-
key: () =>
|
|
94
|
+
key: () => {
|
|
95
|
+
setPointer(false);
|
|
96
|
+
const again = held.current;
|
|
97
|
+
held.current = true;
|
|
98
|
+
return again;
|
|
99
|
+
},
|
|
100
|
+
keyEnd: () => {
|
|
101
|
+
held.current = false;
|
|
102
|
+
},
|
|
92
103
|
left: (event) => {
|
|
93
104
|
if (!pressing.current && !event.currentTarget.contains(event.relatedTarget)) {
|
|
94
105
|
setPointer(false);
|
|
@@ -108,6 +119,7 @@ export function useSliderFeel() {
|
|
|
108
119
|
const kind = usePressKind();
|
|
109
120
|
const { shown, delay, hold, holdAgain } = useBubbleHold();
|
|
110
121
|
const keyUp = () => {
|
|
122
|
+
kind.keyEnd();
|
|
111
123
|
setKeyed(null);
|
|
112
124
|
setFollow(false);
|
|
113
125
|
holdAgain();
|
|
@@ -137,8 +149,8 @@ export function useSliderFeel() {
|
|
|
137
149
|
holdAgain();
|
|
138
150
|
},
|
|
139
151
|
keyDown: (event) => {
|
|
140
|
-
kind.key();
|
|
141
|
-
const index = thumbFor(event, delay);
|
|
152
|
+
const again = kind.key();
|
|
153
|
+
const index = thumbFor(event, delay, !again);
|
|
142
154
|
if (adjusting.has(event.key) && index !== null) {
|
|
143
155
|
setKeyed(index);
|
|
144
156
|
hold(index);
|
package/dist/slider/slider.css
CHANGED
|
@@ -171,11 +171,11 @@
|
|
|
171
171
|
transition: none;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
[data-slot="slider-thumb
|
|
175
|
-
|
|
174
|
+
[data-slot="slider-thumb"]::before {
|
|
175
|
+
content: "";
|
|
176
|
+
position: absolute;
|
|
177
|
+
inset: 0;
|
|
176
178
|
box-sizing: border-box;
|
|
177
|
-
inline-size: 100%;
|
|
178
|
-
block-size: 100%;
|
|
179
179
|
border: var(--kumiko-slider-thumb-border-width) solid var(--kumiko-slider-thumb-border);
|
|
180
180
|
border-radius: 999px;
|
|
181
181
|
background: var(--kumiko-slider-thumb-bg);
|
|
@@ -195,14 +195,13 @@
|
|
|
195
195
|
--_slider-ring: 2px solid var(--kumiko-slider-focus-ring);
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
[data-slot="slider-thumb"][data-dragging]
|
|
198
|
+
[data-slot="slider-thumb"][data-dragging]::before {
|
|
199
199
|
scale: var(--kumiko-squash-x) var(--kumiko-squash-y);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
@media (hover: hover) and (pointer: fine) {
|
|
203
203
|
[data-slot="slider"]:not([data-disabled], [data-readonly])
|
|
204
|
-
[data-slot="slider-thumb"]:hover:not([data-dragging])
|
|
205
|
-
[data-slot="slider-thumb-face"] {
|
|
204
|
+
[data-slot="slider-thumb"]:hover:not([data-dragging])::before {
|
|
206
205
|
scale: var(--kumiko-hover-scale);
|
|
207
206
|
}
|
|
208
207
|
}
|
|
@@ -237,7 +236,7 @@
|
|
|
237
236
|
cursor: not-allowed;
|
|
238
237
|
}
|
|
239
238
|
|
|
240
|
-
[data-slot="slider"][data-readonly] [data-slot="slider-thumb
|
|
239
|
+
[data-slot="slider"][data-readonly] [data-slot="slider-thumb"]::before {
|
|
241
240
|
border-color: var(--kumiko-slider-readonly-thumb-bg);
|
|
242
241
|
background: var(--kumiko-slider-readonly-thumb-bg);
|
|
243
242
|
}
|
|
@@ -313,12 +312,12 @@
|
|
|
313
312
|
box-shadow: none;
|
|
314
313
|
}
|
|
315
314
|
|
|
316
|
-
[data-slot="slider-thumb
|
|
315
|
+
[data-slot="slider-thumb"]::before {
|
|
317
316
|
border-color: ButtonText;
|
|
318
317
|
background: Canvas;
|
|
319
318
|
}
|
|
320
319
|
|
|
321
|
-
[data-slot="slider"][data-readonly] [data-slot="slider-thumb
|
|
320
|
+
[data-slot="slider"][data-readonly] [data-slot="slider-thumb"]::before {
|
|
322
321
|
border-color: GrayText;
|
|
323
322
|
background: GrayText;
|
|
324
323
|
}
|
package/dist/slider/slider.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { pageLocale } from "@ui-sdk/core";
|
|
3
3
|
import { Slider as SdkSlider, SliderControl, SliderIndicator, SliderThumb, SliderTrack, SliderValue } from "@ui-sdk/react/slider";
|
|
4
|
-
import { useState } from "react";
|
|
4
|
+
import { useCallback, useMemo, useState } from "react";
|
|
5
5
|
import { alongside, useSliderFeel } from "./slider-feel";
|
|
6
6
|
import { formatThumb } from "./slider-format";
|
|
7
7
|
import { isPassed, marksFor } from "./slider-marks";
|
|
@@ -13,26 +13,29 @@ function looks(on) {
|
|
|
13
13
|
/** The value bubble, which reads the page's locale once it is mounted, the way ui-sdk does for the thumb's own text. */
|
|
14
14
|
function Bubble({ value, formatting }) {
|
|
15
15
|
const [page, setPage] = useState(undefined);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const read = useCallback((element) => {
|
|
17
|
+
if (element) {
|
|
18
|
+
setPage(pageLocale(element));
|
|
19
|
+
}
|
|
20
|
+
}, []);
|
|
21
|
+
return (_jsx("span", { "data-slot": "slider-bubble", "aria-hidden": "true", ref: read, children: formatThumb(value, { ...formatting, pageLocale: page }) }));
|
|
22
22
|
}
|
|
23
23
|
function Thumbs({ count, labels, bubble, keyed, shown, formatting }) {
|
|
24
|
-
return (_jsx(_Fragment, { children: Array.from({ length: count }, (_, index) => (_jsx(SliderThumb, { index: index, "aria-label": Array.isArray(labels) ? labels[index] : labels, "data-adjusting": keyed === index ? "" : undefined, "data-revealed": shown === index ? "" : undefined, children: (state) =>
|
|
24
|
+
return (_jsx(_Fragment, { children: Array.from({ length: count }, (_, index) => (_jsx(SliderThumb, { index: index, "aria-label": Array.isArray(labels) ? labels[index] : labels, "data-adjusting": keyed === index ? "" : undefined, "data-revealed": shown === index ? "" : undefined, children: (state) => bubble ? _jsx(Bubble, { value: state.thumbValue, formatting: formatting }) : null }, index))) }));
|
|
25
25
|
}
|
|
26
26
|
function markStyle(percent) {
|
|
27
27
|
return { "--kumiko-slider-mark-at": `${percent}%` };
|
|
28
28
|
}
|
|
29
29
|
/** A mark at each step, each told whether the fill has passed it. Nothing above 20 steps. */
|
|
30
30
|
function Marks({ min, max, step, values }) {
|
|
31
|
-
const marks = marksFor(min, max, step)
|
|
31
|
+
const marks = useMemo(() => marksFor(min, max, step).map((mark) => ({
|
|
32
|
+
...mark,
|
|
33
|
+
style: markStyle(mark.percent)
|
|
34
|
+
})), [min, max, step]);
|
|
32
35
|
if (marks.length === 0) {
|
|
33
36
|
return null;
|
|
34
37
|
}
|
|
35
|
-
return (_jsx("span", { "data-slot": "slider-marks", "aria-hidden": "true", children: marks.map((mark) => (_jsx("span", { "data-slot": "slider-mark", "data-passed": isPassed(mark.value, values) ? "" : undefined, style:
|
|
38
|
+
return (_jsx("span", { "data-slot": "slider-marks", "aria-hidden": "true", children: marks.map((mark) => (_jsx("span", { "data-slot": "slider-mark", "data-passed": isPassed(mark.value, values) ? "" : undefined, style: mark.style }, mark.value))) }));
|
|
36
39
|
}
|
|
37
40
|
/** The control with the track, its fill, the marks and the thumbs. */
|
|
38
41
|
function Rail({ marks, thumbs }) {
|
|
@@ -52,6 +52,8 @@ class CaretController {
|
|
|
52
52
|
watchFrame = 0;
|
|
53
53
|
watchTimer = 0;
|
|
54
54
|
stillFrames = 0;
|
|
55
|
+
writtenHeight = "";
|
|
56
|
+
writtenColour = "";
|
|
55
57
|
fieldBox = "";
|
|
56
58
|
raisedField = null;
|
|
57
59
|
raisedLayer = null;
|
|
@@ -64,7 +66,11 @@ class CaretController {
|
|
|
64
66
|
this.bar = bar;
|
|
65
67
|
this.glider = createGlider((x, y, height) => {
|
|
66
68
|
caret.style.transform = `translate3d(${x}px, ${y}px, 0)`;
|
|
67
|
-
|
|
69
|
+
const written = `${height}px`;
|
|
70
|
+
if (written !== this.writtenHeight) {
|
|
71
|
+
this.writtenHeight = written;
|
|
72
|
+
caret.style.height = written;
|
|
73
|
+
}
|
|
68
74
|
});
|
|
69
75
|
}
|
|
70
76
|
start() {
|
|
@@ -149,8 +155,8 @@ class CaretController {
|
|
|
149
155
|
if (this.watchTimer) {
|
|
150
156
|
window.clearTimeout(this.watchTimer);
|
|
151
157
|
this.watchTimer = 0;
|
|
152
|
-
this.watchField();
|
|
153
158
|
}
|
|
159
|
+
this.watchField();
|
|
154
160
|
}
|
|
155
161
|
followField() {
|
|
156
162
|
const { tracked } = this;
|
|
@@ -186,16 +192,22 @@ class CaretController {
|
|
|
186
192
|
!this.visible ||
|
|
187
193
|
!this.last ||
|
|
188
194
|
Math.hypot(rect.x - this.last.x, rect.y - this.last.y) > GLIDE_LIMIT;
|
|
189
|
-
const reduced = prefersReducedMotion(field);
|
|
190
195
|
this.raise(field);
|
|
191
|
-
|
|
196
|
+
const reduced = prefersReducedMotion(field);
|
|
197
|
+
const colour = colourOf(field);
|
|
198
|
+
const flourishing = this.flourish && !reduced;
|
|
199
|
+
const flourishDuration = flourishing ? flourishMs(this.bar) : 0;
|
|
200
|
+
if (colour !== this.writtenColour) {
|
|
201
|
+
this.writtenColour = colour;
|
|
202
|
+
this.caret.style.setProperty("--_caret-color", colour);
|
|
203
|
+
}
|
|
192
204
|
this.glider.to(rect.x, rect.y, rect.height, snap || reduced);
|
|
193
205
|
this.caret.dataset.visible = "true";
|
|
194
206
|
this.visible = true;
|
|
195
207
|
this.last = rect;
|
|
196
|
-
if (
|
|
208
|
+
if (flourishing) {
|
|
197
209
|
this.bar.animate(FLOURISH_KEYFRAMES, {
|
|
198
|
-
duration:
|
|
210
|
+
duration: flourishDuration,
|
|
199
211
|
easing: "ease-out"
|
|
200
212
|
});
|
|
201
213
|
}
|