@momoi-labs/kiso-react 0.8.1 → 0.10.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/README.md +80 -2
- package/dist/app-shell.d.ts +11 -1
- package/dist/app-shell.js +33 -8
- package/dist/chip-input.d.ts +2 -2
- package/dist/chip-input.js +77 -16
- package/dist/command-palette.d.ts +1 -1
- package/dist/command-palette.js +18 -4
- package/dist/empty-state.js +2 -2
- package/dist/filter-expression.d.ts +49 -0
- package/dist/filter-expression.js +264 -0
- package/dist/filter-input.d.ts +14 -0
- package/dist/filter-input.js +251 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.js +10 -0
- package/dist/page-header.d.ts +2 -1
- package/dist/page-header.js +3 -3
- package/dist/sidebar.d.ts +3 -1
- package/dist/sidebar.js +2 -2
- package/dist/split.js +3 -1
- package/dist/status-badge.d.ts +8 -0
- package/dist/status-badge.js +8 -0
- package/dist/styles.css +43 -3
- package/dist/theme-selector.d.ts +2 -1
- package/dist/theme-selector.js +32 -3
- package/package.json +2 -2
package/dist/split.js
CHANGED
|
@@ -18,6 +18,7 @@ function Splitter({ className, defaultSize = 50, min = 25, max = 75, step = 2, o
|
|
|
18
18
|
const ref = React.useRef(null);
|
|
19
19
|
const [size, setSize] = React.useState(defaultSize);
|
|
20
20
|
const [dragging, setDragging] = React.useState(false);
|
|
21
|
+
const dragStart = React.useRef({ x: 0, size: defaultSize });
|
|
21
22
|
useIsomorphicLayoutEffect(() => {
|
|
22
23
|
const pane = ref.current?.previousElementSibling;
|
|
23
24
|
if (pane instanceof HTMLElement)
|
|
@@ -32,6 +33,7 @@ function Splitter({ className, defaultSize = 50, min = 25, max = 75, step = 2, o
|
|
|
32
33
|
}
|
|
33
34
|
return (_jsx("div", { ref: ref, role: "separator", tabIndex: 0, "aria-orientation": "vertical", "aria-label": ariaLabel, "aria-valuenow": Math.round(size), "aria-valuemin": min, "aria-valuemax": max, "data-slot": "splitter", className: cn("splitter", dragging && "dragging", className), ...props, onPointerDown: (event) => {
|
|
34
35
|
onPointerDown?.(event);
|
|
36
|
+
dragStart.current = { x: event.clientX, size };
|
|
35
37
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
36
38
|
setDragging(true);
|
|
37
39
|
}, onPointerMove: (event) => {
|
|
@@ -40,7 +42,7 @@ function Splitter({ className, defaultSize = 50, min = 25, max = 75, step = 2, o
|
|
|
40
42
|
return;
|
|
41
43
|
const box = event.currentTarget.parentElement?.getBoundingClientRect();
|
|
42
44
|
if (box)
|
|
43
|
-
resize(((event.clientX -
|
|
45
|
+
resize(dragStart.current.size + ((event.clientX - dragStart.current.x) / box.width) * 100);
|
|
44
46
|
},
|
|
45
47
|
/* Covers the pointer being released and the drag being cancelled. */
|
|
46
48
|
onLostPointerCapture: (event) => {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Badge } from "./badge.js";
|
|
3
|
+
export type StatusTone = "success" | "danger" | "neutral";
|
|
4
|
+
export type StatusBadgeProps = Omit<React.ComponentProps<typeof Badge>, "variant" | "asChild"> & {
|
|
5
|
+
tone: StatusTone;
|
|
6
|
+
pulse?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function StatusBadge({ tone, pulse, children, ...props }: StatusBadgeProps): React.JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Badge } from "./badge.js";
|
|
3
|
+
import { Dot } from "./dot.js";
|
|
4
|
+
/* The dot pulses while work is going, a run or a build; a thing that is
|
|
5
|
+
merely up holds still. */
|
|
6
|
+
export function StatusBadge({ tone, pulse = false, children, ...props }) {
|
|
7
|
+
return _jsxs(Badge, { ...props, variant: tone, children: [_jsx(Dot, { pulse: pulse }), children] });
|
|
8
|
+
}
|
package/dist/styles.css
CHANGED
|
@@ -16,11 +16,38 @@
|
|
|
16
16
|
border-radius: var(--radius-lg);
|
|
17
17
|
background: var(--color-muted);
|
|
18
18
|
}
|
|
19
|
-
.theme-buttons .btn[aria-
|
|
19
|
+
.theme-buttons .btn[aria-checked="true"] {
|
|
20
20
|
background: var(--color-card);
|
|
21
21
|
color: var(--color-foreground);
|
|
22
22
|
box-shadow: var(--shadow-xs);
|
|
23
23
|
}
|
|
24
|
+
.theme-selector-cards { display: grid; gap: var(--spacing-md); min-width: 0; }
|
|
25
|
+
.theme-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); gap: var(--spacing-md); }
|
|
26
|
+
.theme-cards .theme-card {
|
|
27
|
+
display: grid; align-content: start; justify-content: stretch; gap: var(--spacing-sm);
|
|
28
|
+
height: auto; min-width: 0; padding: var(--spacing-sm);
|
|
29
|
+
border: 1px solid var(--color-border); border-radius: var(--appearance-control-corners, var(--radius-md));
|
|
30
|
+
background: transparent; color: var(--color-foreground);
|
|
31
|
+
text-align: start; white-space: normal; line-height: var(--type-line-height-normal);
|
|
32
|
+
}
|
|
33
|
+
.theme-cards .theme-card:hover { background: var(--color-accent-surface-hover); }
|
|
34
|
+
.theme-cards .theme-card[aria-checked="true"] { border-color: var(--color-focus); background: var(--color-accent-surface); }
|
|
35
|
+
.theme-card-label { display: flex; align-items: center; gap: var(--spacing-sm); }
|
|
36
|
+
.theme-card-description { color: var(--color-muted-foreground); font-weight: var(--type-weight-regular); }
|
|
37
|
+
.theme-card-preview {
|
|
38
|
+
display: flex; height: calc(2 * var(--spacing-3xl)); margin: var(--spacing-sm);
|
|
39
|
+
overflow: hidden; border: 1px solid var(--color-border); border-radius: var(--appearance-corners, var(--radius-surface));
|
|
40
|
+
}
|
|
41
|
+
.theme-card-scene { display: grid; grid-template-columns: var(--spacing-lg) minmax(0, 1fr); flex: 1; min-width: 0; background: var(--color-background); }
|
|
42
|
+
.theme-card-sidebar { display: grid; align-content: start; gap: var(--spacing-xs); padding: var(--spacing-sm) var(--spacing-xs); background: var(--color-sidebar); border-inline-end: 1px solid var(--color-border); }
|
|
43
|
+
.theme-card-scene i { display: block; height: var(--spacing-2xs); background: var(--color-muted-foreground); }
|
|
44
|
+
.theme-card-sidebar i:first-child { height: var(--spacing-sm); margin-bottom: var(--spacing-xs); background: var(--color-link); }
|
|
45
|
+
.theme-card-main { display: grid; grid-template-rows: var(--spacing-lg) minmax(0, 1fr); min-width: 0; }
|
|
46
|
+
.theme-card-header { border-bottom: 1px solid var(--color-border); }
|
|
47
|
+
.theme-card-content { display: grid; align-content: start; gap: var(--spacing-xs); padding: var(--spacing-sm); }
|
|
48
|
+
.theme-card-content i:first-child { height: var(--spacing-xs); width: 80%; background: var(--color-foreground); }
|
|
49
|
+
.theme-card-content i:nth-child(2) { width: 60%; }
|
|
50
|
+
.theme-card-content i:last-child { height: var(--spacing-sm); width: 45%; background: var(--color-primary); }
|
|
24
51
|
/* AccentSelector: a pill row that chooses, and one preview that answers.
|
|
25
52
|
Each pill and the preview carry their own data-accent, so their colours
|
|
26
53
|
resolve under that accent without any inline values. */
|
|
@@ -161,9 +188,17 @@
|
|
|
161
188
|
}
|
|
162
189
|
|
|
163
190
|
@media (pointer: coarse) {
|
|
164
|
-
.
|
|
191
|
+
/* Reserve the extended target in layout so adjacent controls cannot overlap. */
|
|
192
|
+
.kiso-checkbox { margin: calc((var(--size-touch-min) - var(--size-icon-md)) / 2); }
|
|
193
|
+
.kiso-react-switch {
|
|
194
|
+
margin-block: calc((var(--size-touch-min) - 18px) / 2);
|
|
195
|
+
margin-inline: calc((var(--size-touch-min) - 32px) / 2);
|
|
196
|
+
}
|
|
197
|
+
.kiso-checkbox::before, .kiso-react-switch::before {
|
|
165
198
|
content: "";
|
|
166
199
|
position: absolute;
|
|
200
|
+
top: 50%; left: 50%;
|
|
201
|
+
translate: -50% -50%;
|
|
167
202
|
width: var(--size-touch-min);
|
|
168
203
|
height: var(--size-touch-min);
|
|
169
204
|
}
|
|
@@ -217,10 +252,15 @@
|
|
|
217
252
|
cursor: pointer;
|
|
218
253
|
}
|
|
219
254
|
[data-slot="select-trigger"][data-placeholder] {
|
|
220
|
-
color: var(--color-
|
|
255
|
+
color: var(--color-muted-foreground);
|
|
221
256
|
}
|
|
222
257
|
[data-slot="select-trigger"]:disabled { cursor: not-allowed; }
|
|
223
258
|
[data-slot="select-item"] { justify-content: space-between; }
|
|
259
|
+
[data-slot="select-content"] {
|
|
260
|
+
max-height: var(--radix-select-content-available-height);
|
|
261
|
+
overflow: hidden;
|
|
262
|
+
}
|
|
263
|
+
[data-slot="select-viewport"] { min-height: 0; }
|
|
224
264
|
|
|
225
265
|
/* Portalled surfaces: above the page, never wider than it. */
|
|
226
266
|
.kiso-react-floating {
|
package/dist/theme-selector.d.ts
CHANGED
package/dist/theme-selector.js
CHANGED
|
@@ -1,23 +1,52 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useRef } from "react";
|
|
3
4
|
import { Button } from "./button.js";
|
|
4
|
-
|
|
5
|
+
function ThemePreview({ theme }) {
|
|
6
|
+
const schemes = theme === "system" ? ["light", "dark"] : [theme];
|
|
7
|
+
return _jsx("span", { className: "theme-card-preview", "aria-hidden": "true", children: schemes.map(scheme => _jsxs("span", { className: "theme-card-scene", "data-theme": scheme, children: [_jsxs("span", { className: "theme-card-sidebar", children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {})] }), _jsxs("span", { className: "theme-card-main", children: [_jsx("span", { className: "theme-card-header" }), _jsxs("span", { className: "theme-card-content", children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {})] })] })] }, scheme)) });
|
|
8
|
+
}
|
|
9
|
+
export function ThemeSelector({ theme, onChange, variant = "compact", }) {
|
|
10
|
+
const id = useId();
|
|
11
|
+
const cards = variant === "cards";
|
|
12
|
+
const buttons = useRef([]);
|
|
5
13
|
const options = [
|
|
6
14
|
{
|
|
7
15
|
value: "system",
|
|
8
16
|
label: "Follow system",
|
|
17
|
+
name: "System",
|
|
18
|
+
description: "Follow your device",
|
|
9
19
|
path: "M2 2h12v9H2zM8 11v3M5 14h6",
|
|
10
20
|
},
|
|
11
21
|
{
|
|
12
22
|
value: "light",
|
|
13
23
|
label: "Light theme",
|
|
24
|
+
name: "Light",
|
|
25
|
+
description: "Always use light colors",
|
|
14
26
|
path: "M11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM8 0v2m0 12v2M0 8h2m12 0h2M2 2l2 2m8 8 2 2M2 14l2-2M12 4l2-2",
|
|
15
27
|
},
|
|
16
28
|
{
|
|
17
29
|
value: "dark",
|
|
18
30
|
label: "Dark theme",
|
|
31
|
+
name: "Dark",
|
|
32
|
+
description: "Always use dark colors",
|
|
19
33
|
path: "M13.5 10A6 6 0 0 1 6 2.5a6 6 0 1 0 7.5 7.5Z",
|
|
20
34
|
},
|
|
21
35
|
];
|
|
22
|
-
return (_jsxs("div", {
|
|
36
|
+
return (_jsxs("div", { "data-slot": "theme-selector", "data-variant": variant, className: cards ? "theme-selector-cards" : "theme-row", children: [_jsx("span", { className: "t-label", children: "Theme" }), _jsx("div", { className: cards ? "theme-cards" : "theme-buttons", role: "radiogroup", "aria-label": "Theme", children: options.map((option, index) => {
|
|
37
|
+
const icon = _jsx("svg", { className: "icon icon-sm", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.4", "aria-hidden": "true", children: _jsx("path", { d: option.path }) });
|
|
38
|
+
return (_jsx(Button, { ref: (button) => { buttons.current[index] = button; }, variant: "ghost", size: "sm", className: cards ? "theme-card" : "btn-icon", role: "radio", "aria-label": option.label, "aria-describedby": cards ? `${id}-${option.value}-description` : undefined, title: option.label, "aria-checked": theme === option.value, tabIndex: theme === option.value ? 0 : -1, onClick: () => onChange(option.value), onKeyDown: (event) => {
|
|
39
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
40
|
+
return;
|
|
41
|
+
const direction = event.key === "ArrowRight" || event.key === "ArrowDown"
|
|
42
|
+
? 1
|
|
43
|
+
: event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 0;
|
|
44
|
+
if (!direction)
|
|
45
|
+
return;
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
const next = (index + direction + options.length) % options.length;
|
|
48
|
+
buttons.current[next]?.focus();
|
|
49
|
+
onChange(options[next].value);
|
|
50
|
+
}, children: cards ? _jsxs(_Fragment, { children: [_jsx(ThemePreview, { theme: option.value }), _jsxs("span", { className: "theme-card-label", children: [icon, option.name] }), _jsx("span", { id: `${id}-${option.value}-description`, className: "theme-card-description", children: option.description })] }) : icon }, option.value));
|
|
51
|
+
}) })] }));
|
|
23
52
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momoi-labs/kiso-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Kiso React components built with shadcn/ui and Radix",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"prepack": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@momoi-labs/kiso": "^0.
|
|
35
|
+
"@momoi-labs/kiso": "^0.14.0",
|
|
36
36
|
"class-variance-authority": "0.7.1",
|
|
37
37
|
"clsx": "2.1.1",
|
|
38
38
|
"radix-ui": "1.6.7",
|