@alulore/kumiko 0.0.0-stage → 0.14.1
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/badge/badge.css +287 -0
- package/dist/badge/badge.d.ts +40 -0
- package/dist/badge/badge.js +51 -0
- package/dist/badge/index.d.ts +1 -0
- package/dist/badge/index.js +1 -0
- package/dist/board/board-api.d.ts +147 -0
- package/dist/board/board-api.js +139 -0
- package/dist/board/board-card-menu.d.ts +17 -0
- package/dist/board/board-card-menu.js +53 -0
- package/dist/board/board-drag-events.d.ts +12 -0
- package/dist/board/board-drag-events.js +86 -0
- package/dist/board/board-fold.d.ts +10 -0
- package/dist/board/board-fold.js +30 -0
- package/dist/board/board-group.d.ts +10 -0
- package/dist/board/board-group.js +28 -0
- package/dist/board/board-keys.d.ts +16 -0
- package/dist/board/board-keys.js +65 -0
- package/dist/board/board-locked-rows.d.ts +23 -0
- package/dist/board/board-locked-rows.js +77 -0
- package/dist/board/board-motion.d.ts +7 -0
- package/dist/board/board-motion.js +102 -0
- package/dist/board/board-primitive.d.ts +53 -0
- package/dist/board/board-primitive.js +66 -0
- package/dist/board/board-pull.d.ts +6 -0
- package/dist/board/board-pull.js +94 -0
- package/dist/board/board-selection.d.ts +42 -0
- package/dist/board/board-selection.js +130 -0
- package/dist/board/board-slots.d.ts +1003 -0
- package/dist/board/board-slots.js +250 -0
- package/dist/board/board-types.d.ts +99 -0
- package/dist/board/board-types.js +1 -0
- package/dist/board/board.css +343 -0
- package/dist/board/board.d.ts +290 -0
- package/dist/board/board.js +23 -0
- package/dist/board/card-menu.d.ts +21 -0
- package/dist/board/card-menu.js +79 -0
- package/dist/board/cell-key.d.ts +6 -0
- package/dist/board/cell-key.js +16 -0
- package/dist/board/index.d.ts +6 -0
- package/dist/board/index.js +5 -0
- package/dist/board/interactive.d.ts +18 -0
- package/dist/board/interactive.js +51 -0
- package/dist/board/keep-capture.d.ts +16 -0
- package/dist/board/keep-capture.js +57 -0
- package/dist/board/landing.d.ts +5 -0
- package/dist/board/landing.js +10 -0
- package/dist/board/press-to-drop.d.ts +9 -0
- package/dist/board/press-to-drop.js +28 -0
- package/dist/board/refused-home.d.ts +16 -0
- package/dist/board/refused-home.js +50 -0
- package/dist/board/repeat-gate.d.ts +4 -0
- package/dist/board/repeat-gate.js +12 -0
- package/dist/board/scrollbar-gutter.d.ts +1 -0
- package/dist/board/scrollbar-gutter.js +27 -0
- package/dist/board/touch-hold.d.ts +19 -0
- package/dist/board/touch-hold.js +103 -0
- package/dist/button/button.css +576 -0
- package/dist/button/button.d.ts +50 -0
- package/dist/button/button.js +70 -0
- package/dist/button/index.d.ts +2 -0
- package/dist/button/index.js +1 -0
- package/dist/checkbox/checkbox-mark.d.ts +8 -0
- package/dist/checkbox/checkbox-mark.js +17 -0
- package/dist/checkbox/checkbox-marks.d.ts +33 -0
- package/dist/checkbox/checkbox-marks.js +30 -0
- package/dist/checkbox/checkbox.css +201 -0
- package/dist/checkbox/checkbox.d.ts +26 -0
- package/dist/checkbox/checkbox.js +11 -0
- package/dist/checkbox/index.d.ts +3 -0
- package/dist/checkbox/index.js +3 -0
- package/dist/chip/chip.css +251 -0
- package/dist/chip/chip.d.ts +39 -0
- package/dist/chip/chip.js +25 -0
- package/dist/chip/index.d.ts +1 -0
- package/dist/chip/index.js +1 -0
- package/dist/dialog/dialog.css +247 -0
- package/dist/dialog/index.d.ts +3 -0
- package/dist/dialog/index.js +3 -0
- package/dist/hover-card/hover-card.css +149 -0
- package/dist/hover-card/hover-card.d.ts +3 -0
- package/dist/hover-card/hover-card.js +8 -0
- package/dist/hover-card/index.d.ts +2 -0
- package/dist/hover-card/index.js +2 -0
- package/dist/input/index.d.ts +5 -0
- package/dist/input/index.js +5 -0
- package/dist/input/input-attributes.d.ts +12 -0
- package/dist/input/input-attributes.js +9 -0
- package/dist/input/input.css +752 -0
- package/dist/input/input.d.ts +28 -0
- package/dist/input/input.js +9 -0
- package/dist/input/search-input.d.ts +41 -0
- package/dist/input/search-input.js +47 -0
- package/dist/kbd/index.d.ts +1 -0
- package/dist/kbd/index.js +1 -0
- package/dist/kbd/kbd.css +77 -0
- package/dist/kbd/kbd.d.ts +21 -0
- package/dist/kbd/kbd.js +37 -0
- package/dist/label/index.d.ts +1 -0
- package/dist/label/index.js +1 -0
- package/dist/label/label.css +37 -0
- package/dist/label/label.d.ts +13 -0
- package/dist/label/label.js +10 -0
- package/dist/menu/index.d.ts +3 -0
- package/dist/menu/index.js +3 -0
- package/dist/menu/menu.css +349 -0
- package/dist/menu/menu.d.ts +11 -0
- package/dist/menu/menu.js +86 -0
- package/dist/menu/point-menu.d.ts +26 -0
- package/dist/menu/point-menu.js +51 -0
- package/dist/motion/flip-math.d.ts +19 -0
- package/dist/motion/flip-math.js +33 -0
- package/dist/motion/flip.d.ts +40 -0
- package/dist/motion/flip.js +203 -0
- package/dist/motion/index.d.ts +2 -0
- package/dist/motion/index.js +2 -0
- package/dist/motion/motion.css +169 -0
- package/dist/popover/index.d.ts +1 -0
- package/dist/popover/index.js +1 -0
- package/dist/popover/popover.css +208 -0
- package/dist/progress/index.d.ts +2 -0
- package/dist/progress/index.js +2 -0
- package/dist/progress/progress.css +390 -0
- package/dist/progress/progress.d.ts +36 -0
- package/dist/progress/progress.js +107 -0
- package/dist/select/index.d.ts +3 -0
- package/dist/select/index.js +2 -0
- package/dist/select/select-labels.d.ts +6 -0
- package/dist/select/select-labels.js +64 -0
- package/dist/select/select-search.d.ts +18 -0
- package/dist/select/select-search.js +10 -0
- package/dist/select/select.css +470 -0
- package/dist/select/select.d.ts +44 -0
- package/dist/select/select.js +92 -0
- package/dist/separator/index.d.ts +2 -0
- package/dist/separator/index.js +1 -0
- package/dist/separator/separator.css +32 -0
- package/dist/separator/separator.d.ts +17 -0
- package/dist/separator/separator.js +10 -0
- package/dist/slider/index.d.ts +2 -0
- package/dist/slider/index.js +2 -0
- package/dist/slider/slider-bubble.css +203 -0
- package/dist/slider/slider-feel.d.ts +33 -0
- package/dist/slider/slider-feel.js +153 -0
- package/dist/slider/slider-format.d.ts +13 -0
- package/dist/slider/slider-format.js +15 -0
- package/dist/slider/slider-marks.d.ts +16 -0
- package/dist/slider/slider-marks.js +32 -0
- package/dist/slider/slider.css +335 -0
- package/dist/slider/slider.d.ts +34 -0
- package/dist/slider/slider.js +94 -0
- package/dist/smooth-caret/caret-box.d.ts +7 -0
- package/dist/smooth-caret/caret-box.js +8 -0
- package/dist/smooth-caret/caret-controller.d.ts +7 -0
- package/dist/smooth-caret/caret-controller.js +222 -0
- package/dist/smooth-caret/caret-geometry.d.ts +11 -0
- package/dist/smooth-caret/caret-geometry.js +230 -0
- package/dist/smooth-caret/caret-glide.d.ts +13 -0
- package/dist/smooth-caret/caret-glide.js +76 -0
- package/dist/smooth-caret/caret-host.d.ts +5 -0
- package/dist/smooth-caret/caret-host.js +40 -0
- package/dist/smooth-caret/index.d.ts +7 -0
- package/dist/smooth-caret/index.js +7 -0
- package/dist/smooth-caret/remote-carets.d.ts +40 -0
- package/dist/smooth-caret/remote-carets.js +130 -0
- package/dist/smooth-caret/smooth-caret.css +157 -0
- package/dist/smooth-caret/smooth-caret.d.ts +5 -0
- package/dist/smooth-caret/smooth-caret.js +9 -0
- package/dist/smooth-caret/use-smooth-caret.d.ts +5 -0
- package/dist/smooth-caret/use-smooth-caret.js +9 -0
- package/dist/switch/index.d.ts +2 -0
- package/dist/switch/index.js +2 -0
- package/dist/switch/switch-drag.d.ts +21 -0
- package/dist/switch/switch-drag.js +23 -0
- package/dist/switch/switch-gesture.d.ts +28 -0
- package/dist/switch/switch-gesture.js +131 -0
- package/dist/switch/switch.css +189 -0
- package/dist/switch/switch.d.ts +15 -0
- package/dist/switch/switch.js +24 -0
- package/dist/textarea/index.d.ts +2 -0
- package/dist/textarea/index.js +2 -0
- package/dist/textarea/textarea.css +37 -0
- package/dist/textarea/textarea.d.ts +35 -0
- package/dist/textarea/textarea.js +11 -0
- package/dist/toast/index.d.ts +2 -0
- package/dist/toast/index.js +2 -0
- package/dist/toast/toast.css +293 -0
- package/dist/tooltip/index.d.ts +2 -0
- package/dist/tooltip/index.js +2 -0
- package/dist/tooltip/tooltip.css +143 -0
- package/dist/tooltip/tooltip.d.ts +14 -0
- package/dist/tooltip/tooltip.js +13 -0
- package/package.json +246 -5
- package/README.md +0 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Input as SdkInput } from "@ui-sdk/react/input";
|
|
2
|
+
import { type InputLook, type InputSize } from "./input-attributes";
|
|
3
|
+
type SdkInputProps = Parameters<typeof SdkInput>[0];
|
|
4
|
+
export type InputProps = Omit<SdkInputProps, "size"> & {
|
|
5
|
+
/**
|
|
6
|
+
* The height and text size: `title` is large display text, `touch` is tall with 16px text.
|
|
7
|
+
* @defaultValue "default"
|
|
8
|
+
*/
|
|
9
|
+
size?: InputSize;
|
|
10
|
+
/**
|
|
11
|
+
* The look of this field. Without it the field takes the look of its container's `look-*` word, and `cozy`
|
|
12
|
+
* outside any.
|
|
13
|
+
*/
|
|
14
|
+
look?: InputLook;
|
|
15
|
+
/**
|
|
16
|
+
* `bare` has no border or background, for text edited in place.
|
|
17
|
+
* @defaultValue "field"
|
|
18
|
+
*/
|
|
19
|
+
variant?: "field" | "bare";
|
|
20
|
+
/**
|
|
21
|
+
* Whether the gliding caret follows this field. Off keeps the browser's caret.
|
|
22
|
+
* @defaultValue true
|
|
23
|
+
*/
|
|
24
|
+
smoothCaret?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/** The ui-sdk input with Kumiko's field look. The look keys on `data-slot` and `data-size`, not on the tag. */
|
|
27
|
+
export declare function Input({ size, look, variant, smoothCaret, ...props }: InputProps): React.JSX.Element;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Input as SdkInput } from "@ui-sdk/react/input";
|
|
3
|
+
import { useSmoothCaret } from "../smooth-caret/use-smooth-caret";
|
|
4
|
+
import { inputAttributes } from "./input-attributes";
|
|
5
|
+
/** The ui-sdk input with Kumiko's field look. The look keys on `data-slot` and `data-size`, not on the tag. */
|
|
6
|
+
export function Input({ size = "default", look, variant = "field", smoothCaret = true, ...props }) {
|
|
7
|
+
useSmoothCaret(smoothCaret);
|
|
8
|
+
return (_jsx(SdkInput, { ...props, ...inputAttributes(size, look), "data-variant": variant === "bare" ? "bare" : undefined, "data-native-caret": smoothCaret ? undefined : "" }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Input as SdkInput } from "@ui-sdk/react/input";
|
|
2
|
+
import { type InputLook, type InputSize } from "./input-attributes";
|
|
3
|
+
type SdkInputProps = Parameters<typeof SdkInput>[0];
|
|
4
|
+
/**
|
|
5
|
+
* What Escape does: `clear-then-blur` clears, then a second press on the empty field blurs it; `clear-and-blur`
|
|
6
|
+
* does both at once; `none` leaves Escape alone.
|
|
7
|
+
*/
|
|
8
|
+
export type SearchEscape = "clear-then-blur" | "clear-and-blur" | "none";
|
|
9
|
+
export type SearchInputProps = Omit<SdkInputProps, "size" | "controller" | "type"> & {
|
|
10
|
+
/** @defaultValue "default" */
|
|
11
|
+
size?: InputSize;
|
|
12
|
+
/** The look of this field, as on `Input`. */
|
|
13
|
+
look?: InputLook;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the gliding caret follows this field. Off keeps the browser's caret.
|
|
16
|
+
* @defaultValue true
|
|
17
|
+
*/
|
|
18
|
+
smoothCaret?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* No border or background.
|
|
21
|
+
* @defaultValue false
|
|
22
|
+
*/
|
|
23
|
+
bare?: boolean;
|
|
24
|
+
/** Shown at the end, such as a `<kbd>/</kbd>`, while the clear button is not. */
|
|
25
|
+
hint?: React.ReactNode;
|
|
26
|
+
/** Called when the field is cleared by the × or by Escape. */
|
|
27
|
+
onClear?: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* What Escape does.
|
|
30
|
+
* @defaultValue "clear-then-blur"
|
|
31
|
+
*/
|
|
32
|
+
escape?: SearchEscape;
|
|
33
|
+
/**
|
|
34
|
+
* The accessible name of the ×.
|
|
35
|
+
* @defaultValue "Clear search"
|
|
36
|
+
*/
|
|
37
|
+
clearLabel?: string;
|
|
38
|
+
};
|
|
39
|
+
/** A search field: a magnifier, the input, a clear × and an optional hint, in one group. */
|
|
40
|
+
export declare function SearchInput({ size, look, smoothCaret, bare, hint, onClear, escape, clearLabel, onValueChange, onKeyDown, ...props }: SearchInputProps): React.JSX.Element;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createInputController, InputClear, InputGroup, Input as SdkInput } from "@ui-sdk/react/input";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useSmoothCaret } from "../smooth-caret/use-smooth-caret";
|
|
5
|
+
import { inputAttributes } from "./input-attributes";
|
|
6
|
+
function Magnifier() {
|
|
7
|
+
return (_jsxs("svg", { "data-slot": "search-icon", "aria-hidden": "true", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", children: [_jsx("circle", { cx: "7", cy: "7", r: "4.5" }), _jsx("path", { d: "M10.5 10.5L14 14" })] }));
|
|
8
|
+
}
|
|
9
|
+
function Cross() {
|
|
10
|
+
return (_jsx("svg", { "aria-hidden": "true", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", children: _jsx("path", { d: "M4 4l8 8M12 4l-8 8" }) }));
|
|
11
|
+
}
|
|
12
|
+
/* The × reports through `onClear`. */
|
|
13
|
+
function callOnClear(reason, onClear) {
|
|
14
|
+
if (reason === "clear-press") {
|
|
15
|
+
onClear?.();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/* Escape clears a filled field, and blurs it as the chosen mode says. */
|
|
19
|
+
function pressEscape(event, escape, controller, onClear) {
|
|
20
|
+
if (event.key !== "Escape" || escape === "none" || event.nativeEvent.isComposing) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const field = event.currentTarget;
|
|
24
|
+
if (field.value === "") {
|
|
25
|
+
if (escape === "clear-then-blur") {
|
|
26
|
+
field.blur();
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
controller.clear();
|
|
31
|
+
onClear?.();
|
|
32
|
+
if (escape === "clear-and-blur") {
|
|
33
|
+
field.blur();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** A search field: a magnifier, the input, a clear × and an optional hint, in one group. */
|
|
37
|
+
export function SearchInput({ size = "default", look, smoothCaret = true, bare = false, hint, onClear, escape = "clear-then-blur", clearLabel = "Clear search", onValueChange, onKeyDown, ...props }) {
|
|
38
|
+
const [controller] = useState(createInputController);
|
|
39
|
+
useSmoothCaret(smoothCaret);
|
|
40
|
+
return (_jsxs(InputGroup, { role: "search", "data-size": size, "data-look": look, "data-variant": bare ? "bare" : undefined, "data-escape": escape, children: [_jsx(Magnifier, {}), _jsx(SdkInput, { inputMode: "search", enterKeyHint: "search", autoComplete: "off", ...props, controller: controller, ...inputAttributes(size, look), "data-variant": "bare", "data-native-caret": smoothCaret ? undefined : "", onValueChange: (value, details) => {
|
|
41
|
+
onValueChange?.(value, details);
|
|
42
|
+
callOnClear(details.reason, onClear);
|
|
43
|
+
}, onKeyDown: (event) => {
|
|
44
|
+
onKeyDown?.(event);
|
|
45
|
+
pressEscape(event, escape, controller, onClear);
|
|
46
|
+
} }), _jsx(InputClear, { "aria-label": clearLabel, children: _jsx(Cross, {}) }), hint === undefined ? null : _jsx("span", { "data-slot": "search-hint", children: hint })] }));
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Kbd, type KbdLook, type KbdProps } from "./kbd";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Kbd } from "./kbd";
|
package/dist/kbd/kbd.css
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
@import "../motion/motion.css";
|
|
2
|
+
|
|
3
|
+
@layer kumiko {
|
|
4
|
+
:where(:root) {
|
|
5
|
+
--kumiko-kbd-font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
6
|
+
--kumiko-kbd-font-size: 0.75rem;
|
|
7
|
+
--kumiko-kbd-min-size: 1.5rem;
|
|
8
|
+
--kumiko-kbd-padding: 0.4em;
|
|
9
|
+
--kumiko-kbd-radius: 0.3rem;
|
|
10
|
+
--kumiko-kbd-bg: Canvas;
|
|
11
|
+
--kumiko-kbd-fg: CanvasText;
|
|
12
|
+
--kumiko-kbd-border: color-mix(in oklab, CanvasText 30%, transparent);
|
|
13
|
+
--kumiko-kbd-depth: 2px;
|
|
14
|
+
--kumiko-kbd-edge: color-mix(in oklab, CanvasText 30%, transparent);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[data-slot="kbd"] {
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
min-inline-size: var(--kumiko-kbd-min-size);
|
|
23
|
+
padding: 0.15em var(--kumiko-kbd-padding);
|
|
24
|
+
border: 1px solid var(--kumiko-kbd-border);
|
|
25
|
+
border-radius: var(--kumiko-kbd-radius);
|
|
26
|
+
background: var(--kumiko-kbd-bg);
|
|
27
|
+
color: var(--kumiko-kbd-fg);
|
|
28
|
+
font-family: var(--kumiko-kbd-font-family);
|
|
29
|
+
font-size: var(--kumiko-kbd-font-size);
|
|
30
|
+
line-height: 1.3;
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
direction: ltr;
|
|
33
|
+
cursor: default;
|
|
34
|
+
user-select: none;
|
|
35
|
+
transition:
|
|
36
|
+
translate var(--kumiko-press-duration) var(--kumiko-press-ease),
|
|
37
|
+
box-shadow var(--kumiko-press-duration) var(--kumiko-press-ease),
|
|
38
|
+
background-color var(--kumiko-fade-duration) var(--kumiko-fade-ease);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* A raised keycap: a small shadow under its bottom edge. */
|
|
42
|
+
[data-slot="kbd"] {
|
|
43
|
+
--_depth: var(--kumiko-kbd-depth);
|
|
44
|
+
|
|
45
|
+
box-shadow: 0 var(--_depth) 0 var(--kumiko-kbd-edge);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Flat: the outline alone. A prop on the key wins; without one, a word on the key or any container picks. */
|
|
49
|
+
[data-slot="kbd"]:is(
|
|
50
|
+
[data-look="flat"],
|
|
51
|
+
:not([data-look]):is([data-kumiko-kbd~="flat"], [data-kumiko-kbd~="flat"] *)
|
|
52
|
+
) {
|
|
53
|
+
--_depth: 0px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* While its shortcut is held, the key presses down onto its shadow. */
|
|
57
|
+
[data-slot="kbd"][data-pressed] {
|
|
58
|
+
translate: 0 var(--_depth);
|
|
59
|
+
box-shadow: 0 0 0 var(--kumiko-kbd-edge);
|
|
60
|
+
background: color-mix(in oklab, CanvasText 10%, var(--kumiko-kbd-bg));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Forced colours keep the edge on the system palette. */
|
|
64
|
+
@media (forced-colors: active) {
|
|
65
|
+
[data-slot="kbd"] {
|
|
66
|
+
border-color: ButtonText;
|
|
67
|
+
background: Canvas;
|
|
68
|
+
color: CanvasText;
|
|
69
|
+
box-shadow: 0 var(--kumiko-kbd-depth) 0 ButtonText;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
[data-slot="kbd"][data-pressed] {
|
|
73
|
+
background: Highlight;
|
|
74
|
+
color: HighlightText;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** How a key looks. */
|
|
2
|
+
export type KbdLook = "keycap" | "flat";
|
|
3
|
+
export type KbdProps = Omit<React.ComponentPropsWithoutRef<"kbd">, "children"> & {
|
|
4
|
+
/** The text to show, as it is. Used when `keys` is not set. */
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
/** A shortcut such as `"mod+k"`, shown the way this platform writes it: ⌘K on a Mac, Ctrl+K elsewhere. */
|
|
7
|
+
keys?: string;
|
|
8
|
+
/**
|
|
9
|
+
* How the key looks: a raised keycap, or a flat outline.
|
|
10
|
+
* Without it, `data-kumiko-kbd="flat"` or `"keycap"` on any container picks, and the default is a keycap.
|
|
11
|
+
* @defaultValue "keycap"
|
|
12
|
+
*/
|
|
13
|
+
look?: KbdLook;
|
|
14
|
+
/** Makes the key press down while its `keys` are held on the keyboard. Off when there are no `keys`. @defaultValue true */
|
|
15
|
+
listen?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A key on the keyboard, as a native `<kbd>`. Give it children, shown as they are, or `keys` to format a shortcut for
|
|
19
|
+
* the platform. With `keys` it presses down while the shortcut is held, which `listen={false}` turns off.
|
|
20
|
+
*/
|
|
21
|
+
export declare function Kbd({ children, keys, look, listen, ...props }: KbdProps): React.JSX.Element;
|
package/dist/kbd/kbd.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { matchesShortcut } from "@ui-sdk/core";
|
|
3
|
+
import { formatShortcut } from "@ui-sdk/react/shortcuts";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
/** Holds `true` while the shortcut is down, and lets go when any key comes up or the window loses focus. */
|
|
6
|
+
function useShortcutDown(keys, listen) {
|
|
7
|
+
const [down, setDown] = useState(false);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!listen || !keys) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const press = (event) => {
|
|
13
|
+
if (matchesShortcut(event, keys)) {
|
|
14
|
+
setDown(true);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const release = () => setDown(false);
|
|
18
|
+
window.addEventListener("keydown", press);
|
|
19
|
+
window.addEventListener("keyup", release);
|
|
20
|
+
window.addEventListener("blur", release);
|
|
21
|
+
return () => {
|
|
22
|
+
window.removeEventListener("keydown", press);
|
|
23
|
+
window.removeEventListener("keyup", release);
|
|
24
|
+
window.removeEventListener("blur", release);
|
|
25
|
+
setDown(false);
|
|
26
|
+
};
|
|
27
|
+
}, [keys, listen]);
|
|
28
|
+
return down;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A key on the keyboard, as a native `<kbd>`. Give it children, shown as they are, or `keys` to format a shortcut for
|
|
32
|
+
* the platform. With `keys` it presses down while the shortcut is held, which `listen={false}` turns off.
|
|
33
|
+
*/
|
|
34
|
+
export function Kbd({ children, keys, look, listen = true, ...props }) {
|
|
35
|
+
const down = useShortcutDown(keys, listen);
|
|
36
|
+
return (_jsx("kbd", { "data-slot": "kbd", "data-look": look, "data-pressed": down ? "" : undefined, ...props, children: keys ? formatShortcut(keys) : children }));
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Label, type LabelProps } from "./label";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Label } from "./label";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@layer kumiko {
|
|
2
|
+
:where(:root) {
|
|
3
|
+
--kumiko-label-font-size: 0.875rem;
|
|
4
|
+
--kumiko-label-font-weight: 500;
|
|
5
|
+
--kumiko-label-color: CanvasText;
|
|
6
|
+
--kumiko-label-gap: 0.5rem;
|
|
7
|
+
--kumiko-label-disabled-opacity: 0.5;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
[data-slot="label"] {
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
gap: var(--kumiko-label-gap);
|
|
13
|
+
align-items: center;
|
|
14
|
+
color: var(--kumiko-label-color);
|
|
15
|
+
font-size: var(--kumiko-label-font-size);
|
|
16
|
+
font-weight: var(--kumiko-label-font-weight);
|
|
17
|
+
line-height: 1.4;
|
|
18
|
+
cursor: var(--kumiko-press-cursor, pointer);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* A label that wraps a disabled control dims with it, with no prop needed. */
|
|
22
|
+
[data-slot="label"]:is([data-disabled], :has(:is(:disabled, [data-disabled]))) {
|
|
23
|
+
opacity: var(--kumiko-label-disabled-opacity);
|
|
24
|
+
cursor: not-allowed;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@media (forced-colors: active) {
|
|
28
|
+
[data-slot="label"] {
|
|
29
|
+
color: CanvasText;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[data-slot="label"]:is([data-disabled], :has(:is(:disabled, [data-disabled]))) {
|
|
33
|
+
color: GrayText;
|
|
34
|
+
opacity: 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Label as SdkLabel } from "@ui-sdk/react/label";
|
|
2
|
+
type SdkLabelProps = Parameters<typeof SdkLabel>[0];
|
|
3
|
+
export type LabelProps = SdkLabelProps & {
|
|
4
|
+
/** Dims the label, for a control that is disabled. ui-sdk does not tell the label, so the caller does. */
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The ui-sdk label with Kumiko's look.
|
|
9
|
+
* It names any control, by `htmlFor` or by wrapping it, and a press on it reaches the control.
|
|
10
|
+
* A label that wraps a control sits in a row with it, with a gap.
|
|
11
|
+
*/
|
|
12
|
+
export declare function Label({ disabled, ...props }: LabelProps): React.JSX.Element | null;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Label as SdkLabel } from "@ui-sdk/react/label";
|
|
3
|
+
/**
|
|
4
|
+
* The ui-sdk label with Kumiko's look.
|
|
5
|
+
* It names any control, by `htmlFor` or by wrapping it, and a press on it reaches the control.
|
|
6
|
+
* A label that wraps a control sits in a row with it, with a gap.
|
|
7
|
+
*/
|
|
8
|
+
export function Label({ disabled = false, ...props }) {
|
|
9
|
+
return _jsx(SdkLabel, { "data-disabled": disabled ? "" : undefined, ...props });
|
|
10
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createMenuController, MenuCheckboxItem, MenuContextTrigger, MenuGroup, MenuGroupLabel, MenuItem, MenuItemIcon, MenuItemIndicator, MenuItems, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuShortcut, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, type MenuProps, type MenuSubProps } from "@ui-sdk/react/menu";
|
|
2
|
+
export { Menu, MenuContent } from "./menu";
|
|
3
|
+
export { createPointMenu, usePointMenu, type Point, type PointMenu, type PointMenuOptions } from "./point-menu";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createMenuController, MenuCheckboxItem, MenuContextTrigger, MenuGroup, MenuGroupLabel, MenuItem, MenuItemIcon, MenuItemIndicator, MenuItems, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuShortcut, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger } from "@ui-sdk/react/menu";
|
|
2
|
+
export { Menu, MenuContent } from "./menu";
|
|
3
|
+
export { createPointMenu, usePointMenu } from "./point-menu";
|