@momoi-labs/kiso-react 0.11.1 → 0.13.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 CHANGED
@@ -225,6 +225,36 @@ const log = useRef<LogViewHandle>(null);
225
225
  <Button onClick={() => log.current?.scrollToBottom()}>Jump to end</Button>
226
226
  ```
227
227
 
228
+ LogView mounts every line it gets. For a log that grows without bound, hand
229
+ the handle's `getScrollElement()` to a virtualizer and let LogView keep
230
+ following the tail. The
231
+ [LogView contract](../../kiso/docs/components/log-view.md#virtualization) has
232
+ the rules. With TanStack Virtual:
233
+
234
+ ```tsx
235
+ const log = useRef<LogViewHandle>(null);
236
+ const rows = useVirtualizer({
237
+ count: lines.length,
238
+ getScrollElement: () => log.current?.getScrollElement() ?? null,
239
+ estimateSize: () => 20,
240
+ });
241
+
242
+ <LogView ref={log}>
243
+ <div style={{ position: "relative", height: rows.getTotalSize() }}>
244
+ {rows.getVirtualItems().map((row) => (
245
+ <LogViewLine
246
+ key={row.key}
247
+ ref={rows.measureElement}
248
+ data-index={row.index}
249
+ style={{ position: "absolute", top: 0, insetInline: 0, transform: `translateY(${row.start}px)` }}
250
+ >
251
+ {lines[row.index]}
252
+ </LogViewLine>
253
+ ))}
254
+ </div>
255
+ </LogView>
256
+ ```
257
+
228
258
  Compose confirmations with AlertDialogTitle and AlertDialogDescription inside
229
259
  AlertDialogContent, plus AlertDialogCancel and AlertDialogAction. For asynchronous
230
260
  actions, control `open` and prevent the Action's default click behavior until the
@@ -1,4 +1,4 @@
1
- export declare const accents: readonly ["violet", "terracotta", "teal", "cobalt", "nocturne"];
1
+ export declare const accents: readonly ["violet", "terracotta", "teal", "cobalt", "nocturne", "tangerine", "red", "gold", "lime"];
2
2
  export type Accent = (typeof accents)[number];
3
3
  export declare function AccentSelector({ accent, onChange, options, preview, }: {
4
4
  accent: string;
@@ -6,6 +6,10 @@ export const accents = [
6
6
  "teal",
7
7
  "cobalt",
8
8
  "nocturne",
9
+ "tangerine",
10
+ "red",
11
+ "gold",
12
+ "lime",
9
13
  ];
10
14
  const label = (accent) => `${accent[0].toUpperCase()}${accent.slice(1)}`;
11
15
  export function AccentSelector({ accent, onChange, options = accents, preview = true, }) {
@@ -1,5 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Button } from "./button.js";
3
+ import { Header } from "./header.js";
3
4
  declare function AppShell({ className, variant, ...props }: React.ComponentProps<"div"> & {
4
5
  variant?: "default" | "inset";
5
6
  }): React.JSX.Element;
@@ -27,6 +28,7 @@ type ApplicationShellSharedProps = Omit<React.ComponentProps<typeof AppShell>, "
27
28
  brand: React.ReactNode;
28
29
  primaryAction?: React.ReactNode;
29
30
  header?: React.ReactNode;
31
+ headerVariant?: React.ComponentProps<typeof Header>["variant"];
30
32
  panel?: React.ReactNode;
31
33
  children: React.ReactNode;
32
34
  };
package/dist/app-shell.js CHANGED
@@ -32,12 +32,12 @@ function ApplicationShellNavigation({ navigation, navigationLabel, collapsible =
32
32
  }
33
33
  function ApplicationShell(props) {
34
34
  if (props.layout === "topbar") {
35
- const { brand, primaryAction, header, panel, children, layout: _layout, ...shellProps } = props;
36
- return (_jsxs(AppShell, { ...shellProps, "data-layout": "topbar", children: [_jsxs(AppShellMain, { children: [_jsxs(Header, { children: [brand, primaryAction, header] }), children] }), panel] }));
35
+ const { brand, primaryAction, header, headerVariant, panel, children, layout: _layout, ...shellProps } = props;
36
+ return (_jsxs(AppShell, { ...shellProps, "data-layout": "topbar", children: [_jsxs(AppShellMain, { children: [_jsxs(Header, { variant: headerVariant, children: [brand, primaryAction, header] }), children] }), panel] }));
37
37
  }
38
38
  return _jsx(ApplicationShellSidebar, { ...props });
39
39
  }
40
- function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationLabel = "Primary", footer, header, panel, children, layout: _layout, collapsible = false, togglePlacement = "sidebar", collapsed, defaultCollapsed = false, onCollapsedChange, ...shellProps }) {
40
+ function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationLabel = "Primary", footer, header, headerVariant, panel, children, layout: _layout, collapsible = false, togglePlacement = "sidebar", collapsed, defaultCollapsed = false, onCollapsedChange, ...shellProps }) {
41
41
  const [internalCollapsed, setInternalCollapsed] = React.useState(defaultCollapsed);
42
42
  const isCollapsed = collapsible && (collapsed ?? internalCollapsed);
43
43
  const sidebarId = React.useId();
@@ -57,6 +57,6 @@ function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationL
57
57
  onCollapsedChange?.(next);
58
58
  }
59
59
  const toggle = collapsible ? (_jsx(Button, { ref: toggleRef, variant: "ghost", size: "sm", className: "sidebar-toggle btn-icon", "aria-controls": sidebarId, "aria-expanded": !isCollapsed, "aria-label": isCollapsed ? "Expand sidebar" : "Collapse sidebar", title: isCollapsed ? "Expand sidebar" : "Collapse sidebar", onClick: toggleSidebar, children: _jsxs("svg", { className: "icon", viewBox: "0 0 16 16", "aria-hidden": "true", children: [_jsx("rect", { x: "1.5", y: "2", width: "13", height: "12", rx: "1.5" }), _jsx("path", { d: "M5.5 2v12" }), _jsx("path", { d: isCollapsed ? "m8.5 5.5 2.5 2.5-2.5 2.5" : "m11 5.5-2.5 2.5 2.5 2.5" })] }) })) : null;
60
- return (_jsxs(AppShell, { ...shellProps, children: [_jsxs(Sidebar, { ref: sidebarRef, id: sidebarId, collapsed: isCollapsed, children: [_jsx(SidebarHeader, { className: collapsible && togglePlacement === "sidebar" ? "sidebar-header-collapsible" : undefined, children: collapsible ? _jsxs(_Fragment, { children: [_jsxs("div", { className: "sidebar-expanded-content", children: [brand, primaryAction] }), togglePlacement === "sidebar" && toggle] }) : _jsxs(_Fragment, { children: [brand, primaryAction] }) }), _jsx(SidebarBody, { children: _jsx(ApplicationShellNavigation, { navigation: navigation, navigationLabel: navigationLabel, collapsible: collapsible }) }), footer && _jsx(SidebarFooter, { className: collapsible ? "sidebar-expanded-content" : undefined, children: footer })] }), _jsxs(AppShellMain, { children: [(header || (collapsible && togglePlacement === "header")) && _jsxs(Header, { children: [togglePlacement === "header" && toggle, header] }), children] }), panel] }));
60
+ return (_jsxs(AppShell, { ...shellProps, children: [_jsxs(Sidebar, { ref: sidebarRef, id: sidebarId, collapsed: isCollapsed, children: [_jsx(SidebarHeader, { className: collapsible && togglePlacement === "sidebar" ? "sidebar-header-collapsible" : undefined, children: collapsible ? _jsxs(_Fragment, { children: [_jsxs("div", { className: "sidebar-expanded-content", children: [brand, primaryAction] }), togglePlacement === "sidebar" && toggle] }) : _jsxs(_Fragment, { children: [brand, primaryAction] }) }), _jsx(SidebarBody, { children: _jsx(ApplicationShellNavigation, { navigation: navigation, navigationLabel: navigationLabel, collapsible: collapsible }) }), footer && _jsx(SidebarFooter, { className: collapsible ? "sidebar-expanded-content" : undefined, children: footer })] }), _jsxs(AppShellMain, { children: [(header || (collapsible && togglePlacement === "header")) && _jsxs(Header, { variant: headerVariant, children: [togglePlacement === "header" && toggle, header] }), children] }), panel] }));
61
61
  }
62
62
  export { AppShell, AppShellMain, AppShellPanel, AppShellPanelToggle, ApplicationShell };
package/dist/button.d.ts CHANGED
@@ -2,9 +2,12 @@ import * as React from "react";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  declare const buttonVariants: (props?: ({
4
4
  variant?: "default" | "destructive" | "ghost" | "primary" | null | undefined;
5
- size?: "lg" | "md" | "sm" | "xs" | null | undefined;
5
+ size?: "lg" | "md" | "sm" | "xl" | "xs" | null | undefined;
6
+ presentation?: "default" | "tile" | null | undefined;
6
7
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
- declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
8
+ declare function Button({ className, variant, size, asChild, presentation, icon, description, children, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
8
9
  asChild?: boolean;
10
+ icon?: React.ReactNode;
11
+ description?: React.ReactNode;
9
12
  }): React.JSX.Element;
10
13
  export { Button, buttonVariants };
package/dist/button.js CHANGED
@@ -1,4 +1,7 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // Adapted from shadcn/ui new-york-v4. See ../SHADCN-LICENSE.
4
+ import * as React from "react";
2
5
  import { cva } from "class-variance-authority";
3
6
  import { clsx as cn } from "clsx";
4
7
  import { Slot } from "radix-ui";
@@ -10,12 +13,15 @@ const buttonVariants = cva("btn", {
10
13
  destructive: "btn-danger",
11
14
  ghost: "btn-ghost",
12
15
  },
13
- size: { xs: "btn-xs", sm: "btn-sm", md: "", lg: "btn-lg" },
16
+ size: { xs: "btn-xs", sm: "btn-sm", md: "", lg: "btn-lg", xl: "btn-xl" },
17
+ presentation: { default: "", tile: "choice-tile" },
14
18
  },
15
19
  defaultVariants: { variant: "default", size: "md" },
16
20
  });
17
- function Button({ className, variant = "default", size = "md", asChild = false, ...props }) {
21
+ function Button({ className, variant = "default", size = "md", asChild = false, presentation = "default", icon, description, children, ...props }) {
18
22
  const Comp = asChild ? Slot.Root : "button";
19
- return (_jsx(Comp, { ...(!asChild ? { type: "button" } : {}), "data-slot": "button", "data-variant": variant, "data-size": size, className: cn(buttonVariants({ variant, size, className })), ...props }));
23
+ const id = React.useId();
24
+ const tile = presentation === "tile" && !asChild;
25
+ return (_jsx(Comp, { ...(!asChild ? { type: "button" } : {}), "data-slot": "button", "data-variant": variant, "data-size": size, "data-presentation": presentation, "aria-labelledby": tile && !props["aria-label"] ? `${id}-label` : undefined, className: cn(buttonVariants({ variant, size, presentation, className })), ...props, "aria-describedby": [props["aria-describedby"], tile && description != null ? `${id}-description` : undefined].filter(Boolean).join(" ") || undefined, children: tile ? _jsxs(_Fragment, { children: [icon != null && _jsx("span", { className: "choice-icon", "aria-hidden": "true", children: icon }), _jsxs("span", { className: "choice-copy", children: [_jsx("span", { className: "choice-label", id: `${id}-label`, children: children }), description != null && _jsx("span", { className: "choice-description", id: `${id}-description`, children: description })] })] }) : children }));
20
26
  }
21
27
  export { Button, buttonVariants };
@@ -0,0 +1,16 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ export type FileRejection = {
3
+ file: File;
4
+ reason: "type" | "multiple";
5
+ };
6
+ export type FileDropzoneProps = Omit<ComponentProps<"input">, "type" | "children" | "value" | "defaultValue" | "onChange" | "size" | "required" | "name" | "form"> & {
7
+ label: ReactNode;
8
+ description?: ReactNode;
9
+ icon?: ReactNode;
10
+ error?: ReactNode;
11
+ onFilesSelected: (files: File[]) => void;
12
+ onFilesRejected?: (files: FileRejection[]) => void;
13
+ invalidTypeMessage?: string;
14
+ multipleFilesMessage?: string;
15
+ };
16
+ export declare function FileDropzone({ label, description, icon, error, onFilesSelected, onFilesRejected, invalidTypeMessage, multipleFilesMessage, id: providedId, className, disabled, accept, multiple, "aria-describedby": describedBy, "aria-labelledby": labelledBy, ...props }: FileDropzoneProps): import("react").JSX.Element;
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useRef, useState } from "react";
4
+ import { clsx as cn } from "clsx";
5
+ import { ValidationMessage } from "./validation-message.js";
6
+ function accepts(file, accept) {
7
+ const rules = accept?.split(",").map(rule => rule.trim().toLowerCase()).filter(Boolean) ?? [];
8
+ return rules.length === 0 || rules.some(rule => rule.startsWith(".")
9
+ ? file.name.toLowerCase().endsWith(rule)
10
+ : rule.endsWith("/*") ? file.type.toLowerCase().startsWith(rule.slice(0, -1))
11
+ : file.type.toLowerCase() === rule);
12
+ }
13
+ export function FileDropzone({ label, description, icon, error, onFilesSelected, onFilesRejected, invalidTypeMessage = "Choose a file of an accepted type.", multipleFilesMessage = "Choose one file at a time.", id: providedId, className, disabled, accept, multiple = false, "aria-describedby": describedBy, "aria-labelledby": labelledBy, ...props }) {
14
+ const generatedId = useId();
15
+ const id = providedId ?? generatedId;
16
+ const depth = useRef(0);
17
+ const [dragging, setDragging] = useState(false);
18
+ const [rejection, setRejection] = useState();
19
+ const message = error || rejection;
20
+ useEffect(() => { depth.current = 0; setDragging(false); }, [disabled]);
21
+ function select(files) {
22
+ if (disabled || files.length === 0)
23
+ return;
24
+ const rejected = !multiple && files.length > 1
25
+ ? files.map(file => ({ file, reason: "multiple" }))
26
+ : files.filter(file => !accepts(file, accept)).map(file => ({ file, reason: "type" }));
27
+ if (rejected.length) {
28
+ setRejection(rejected[0].reason === "multiple" ? multipleFilesMessage : invalidTypeMessage);
29
+ onFilesRejected?.(rejected);
30
+ return;
31
+ }
32
+ setRejection(undefined);
33
+ onFilesSelected(files);
34
+ }
35
+ return _jsxs("div", { className: cn("file-dropzone-field", className), "data-slot": "file-dropzone", children: [_jsxs("label", { htmlFor: id, className: "file-dropzone", "data-dragging": dragging, "data-disabled": disabled || undefined, "data-invalid": !!message || props["aria-invalid"] === true || props["aria-invalid"] === "true", onDragEnter: event => { if (event.dataTransfer.types.includes("Files")) {
36
+ event.preventDefault();
37
+ if (!disabled) {
38
+ depth.current++;
39
+ setDragging(true);
40
+ }
41
+ } }, onDragOver: event => { if (event.dataTransfer.types.includes("Files")) {
42
+ event.preventDefault();
43
+ event.dataTransfer.dropEffect = disabled ? "none" : "copy";
44
+ } }, onDragLeave: () => { depth.current = Math.max(0, depth.current - 1); if (depth.current === 0)
45
+ setDragging(false); }, onDrop: event => { event.preventDefault(); depth.current = 0; setDragging(false); select(Array.from(event.dataTransfer.files)); }, children: [_jsx("input", { ...props, id: id, type: "file", accept: accept, multiple: multiple, disabled: disabled, className: "file-dropzone-input", "aria-labelledby": labelledBy ?? `${id}-label`, "aria-describedby": [describedBy, description != null ? `${id}-description` : null, message ? `${id}-error` : null].filter(Boolean).join(" ") || undefined, "aria-invalid": message ? true : props["aria-invalid"], onChange: event => { const files = Array.from(event.currentTarget.files ?? []); event.currentTarget.value = ""; select(files); } }), icon != null && _jsx("span", { className: "choice-icon", "aria-hidden": "true", children: icon }), _jsx("span", { className: "choice-label", id: `${id}-label`, children: label }), description != null && _jsx("span", { className: "choice-description", id: `${id}-description`, children: description })] }), message && _jsx(ValidationMessage, { id: `${id}-error`, children: message })] });
46
+ }
package/dist/header.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import * as React from "react";
2
- declare function Header({ className, ...props }: React.ComponentProps<"header">): React.JSX.Element;
2
+ declare function Header({ className, variant, ...props }: React.ComponentProps<"header"> & {
3
+ variant?: "default" | "plain";
4
+ }): React.JSX.Element;
3
5
  export { Header };
package/dist/header.js CHANGED
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { clsx as cn } from "clsx";
3
3
  // Shared product chrome: brand, Navigation, and global status or actions.
4
4
  // Location within the product is Breadcrumb, not Header.
5
- function Header({ className, ...props }) {
6
- return (_jsx("header", { "data-slot": "header", className: cn("topbar", className), ...props }));
5
+ function Header({ className, variant, ...props }) {
6
+ return (_jsx("header", { "data-slot": "header", "data-variant": variant, className: cn("topbar", className), ...props }));
7
7
  }
8
8
  export { Header };
package/dist/index.d.ts CHANGED
@@ -57,3 +57,6 @@ export * from "./dashboard-grid.js";
57
57
  export * from "./step-list.js";
58
58
  export * from "./lifecycle.js";
59
59
  export * from "./status-badge.js";
60
+ export * from "./steps.js";
61
+ export * from "./radio-group.js";
62
+ export * from "./file-dropzone.js";
package/dist/index.js CHANGED
@@ -58,3 +58,6 @@ export * from "./dashboard-grid.js";
58
58
  export * from "./step-list.js";
59
59
  export * from "./lifecycle.js";
60
60
  export * from "./status-badge.js";
61
+ export * from "./steps.js";
62
+ export * from "./radio-group.js";
63
+ export * from "./file-dropzone.js";
package/dist/input.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  type InputProps = React.ComponentProps<"input"> & {
3
- controlSize?: "sm" | "md" | "lg";
3
+ controlSize?: "sm" | "md" | "lg" | "xl";
4
4
  };
5
5
  declare function Input({ className, type, controlSize, ...props }: InputProps): React.JSX.Element;
6
6
  export { Input };
@@ -2,6 +2,7 @@ import * as React from "react";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  type LogViewHandle = {
4
4
  scrollToBottom: (behavior?: ScrollBehavior) => void;
5
+ getScrollElement: () => HTMLDivElement | null;
5
6
  };
6
7
  declare function LogView({ className, children, follow, onFollowChange, ref, ...props }: Omit<React.ComponentProps<"div">, "ref"> & {
7
8
  follow?: boolean;
package/dist/log-view.js CHANGED
@@ -8,6 +8,9 @@ import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
8
8
  /* Within this much of the end counts as "at the bottom". A log that is being
9
9
  written to rarely lands on an exact scroll position. */
10
10
  const BOTTOM_THRESHOLD = 8;
11
+ function isAtBottom(el) {
12
+ return el.scrollHeight - el.scrollTop - el.clientHeight <= BOTTOM_THRESHOLD;
13
+ }
11
14
  /* The frame is `.logview` and the scroller is `.log-scroll` inside it, so the
12
15
  component owns the scroller and with it follow-tail: new lines pin the view
13
16
  to the end until the reader scrolls away, and returning to the end resumes.
@@ -15,6 +18,8 @@ const BOTTOM_THRESHOLD = 8;
15
18
  "Follow" switch — and read `onFollowChange` to keep it in step. */
16
19
  function LogView({ className, children, follow, onFollowChange, ref, ...props }) {
17
20
  const scroller = React.useRef(null);
21
+ /* The scroll height at the last pin, or null while not following. */
22
+ const pinned = React.useRef(null);
18
23
  const [atBottom, setAtBottom] = React.useState(true);
19
24
  const following = follow ?? atBottom;
20
25
  React.useImperativeHandle(ref, () => ({
@@ -23,16 +28,27 @@ function LogView({ className, children, follow, onFollowChange, ref, ...props })
23
28
  if (el)
24
29
  el.scrollTo({ top: el.scrollHeight, behavior });
25
30
  },
31
+ getScrollElement() {
32
+ return scroller.current;
33
+ },
26
34
  }), []);
27
- /* Before paint, so a new line never shows up above the fold first. */
35
+ /* Before paint, so a new line never shows up above the fold first. Skip the
36
+ pin when the height is unchanged and the view is still at the bottom: a
37
+ virtualized body re-renders its rows on every scroll, and pinning then
38
+ pulls back a reader who leaves the end in small steps. */
28
39
  useIsomorphicLayoutEffect(() => {
29
40
  const el = scroller.current;
30
- if (el && following)
31
- el.scrollTop = el.scrollHeight;
41
+ if (!el || !following) {
42
+ pinned.current = null;
43
+ return;
44
+ }
45
+ if (el.scrollHeight === pinned.current && isAtBottom(el))
46
+ return;
47
+ el.scrollTop = el.scrollHeight;
48
+ pinned.current = el.scrollHeight;
32
49
  }, [children, following]);
33
50
  return (_jsx("div", { "data-slot": "log-view", "data-follow": following, className: cn("logview", className), ...props, children: _jsx("div", { ref: scroller, "data-slot": "log-view-scroll", className: "log-scroll", onScroll: (event) => {
34
- const el = event.currentTarget;
35
- const bottom = el.scrollHeight - el.scrollTop - el.clientHeight <= BOTTOM_THRESHOLD;
51
+ const bottom = isAtBottom(event.currentTarget);
36
52
  setAtBottom(bottom);
37
53
  if (bottom !== following)
38
54
  onFollowChange?.(bottom);
@@ -0,0 +1,16 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ import { RadioGroup as RadioPrimitive } from "radix-ui";
3
+ export type RadioGroupProps = ComponentProps<typeof RadioPrimitive.Root> & {
4
+ label: ReactNode;
5
+ description?: ReactNode;
6
+ error?: ReactNode;
7
+ variant?: "default" | "tiles" | "segmented";
8
+ controlSize?: "md" | "xl";
9
+ };
10
+ export declare function RadioGroup({ label, description, error, variant, controlSize, className, "aria-describedby": describedBy, "aria-labelledby": labelledBy, ...props }: RadioGroupProps): import("react").JSX.Element;
11
+ export type RadioGroupItemProps = Omit<ComponentProps<typeof RadioPrimitive.Item>, "children" | "asChild"> & {
12
+ label: ReactNode;
13
+ description?: ReactNode;
14
+ icon?: ReactNode;
15
+ };
16
+ export declare function RadioGroupItem({ label, description, icon, className, "aria-labelledby": labelledBy, "aria-describedby": describedBy, ...props }: RadioGroupItemProps): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId } from "react";
4
+ import { RadioGroup as RadioPrimitive } from "radix-ui";
5
+ import { clsx as cn } from "clsx";
6
+ import { ValidationMessage } from "./validation-message.js";
7
+ export function RadioGroup({ label, description, error, variant = "default", controlSize = "md", className, "aria-describedby": describedBy, "aria-labelledby": labelledBy, ...props }) {
8
+ const id = useId();
9
+ const descriptionIds = [describedBy, description != null ? `${id}-description` : null, error ? `${id}-error` : null].filter(Boolean).join(" ") || undefined;
10
+ return _jsxs("div", { className: "field", "data-slot": "radio-group-field", children: [_jsx("span", { id: `${id}-label`, className: "t-label", children: label }), description != null && _jsx("span", { id: `${id}-description`, className: "field-hint", children: description }), _jsx(RadioPrimitive.Root, { ...props, "data-slot": "radio-group", "data-variant": variant, "data-control-size": controlSize, "aria-labelledby": labelledBy ?? `${id}-label`, "aria-describedby": descriptionIds, "aria-invalid": error ? true : props["aria-invalid"], className: cn("radio-group", className) }), error && _jsx(ValidationMessage, { id: `${id}-error`, children: error })] });
11
+ }
12
+ export function RadioGroupItem({ label, description, icon, className, "aria-labelledby": labelledBy, "aria-describedby": describedBy, ...props }) {
13
+ const id = useId();
14
+ return _jsxs(RadioPrimitive.Item, { ...props, "data-slot": "radio-group-item", className: cn("radio-item", className), "aria-labelledby": labelledBy ?? `${id}-label`, "aria-describedby": [describedBy, description != null ? `${id}-description` : null].filter(Boolean).join(" ") || undefined, children: [_jsx("span", { className: "radio-indicator", "aria-hidden": "true", children: _jsx(RadioPrimitive.Indicator, {}) }), icon != null && _jsx("span", { className: "choice-icon", "aria-hidden": "true", children: icon }), _jsxs("span", { className: "choice-copy", children: [_jsx("span", { className: "choice-label", id: `${id}-label`, children: label }), description != null && _jsx("span", { className: "choice-description", id: `${id}-description`, children: description })] })] });
15
+ }
package/dist/select.d.ts CHANGED
@@ -4,7 +4,7 @@ declare function Select({ ...props }: React.ComponentProps<typeof SelectPrimitiv
4
4
  declare function SelectGroup({ ...props }: React.ComponentProps<typeof SelectPrimitive.Group>): React.JSX.Element;
5
5
  declare function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>): React.JSX.Element;
6
6
  declare function SelectTrigger({ className, controlSize, ...props }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
7
- controlSize?: "sm" | "md" | "lg";
7
+ controlSize?: "sm" | "md" | "lg" | "xl";
8
8
  }): React.JSX.Element;
9
9
  declare function SelectContent({ className, children, position, sideOffset, ...props }: React.ComponentProps<typeof SelectPrimitive.Content>): React.JSX.Element;
10
10
  declare function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Label>): React.JSX.Element;
@@ -0,0 +1,33 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ export type StepsStatus = "upcoming" | "completed" | "error" | "disabled";
3
+ export type StepsItem = {
4
+ id: string;
5
+ label: ReactNode;
6
+ description?: ReactNode;
7
+ status?: StepsStatus;
8
+ navigable?: boolean;
9
+ href?: string;
10
+ };
11
+ declare const defaultLabels: {
12
+ upcoming: string;
13
+ current: string;
14
+ completed: string;
15
+ error: string;
16
+ disabled: string;
17
+ expand: string;
18
+ collapse: string;
19
+ complete: string;
20
+ idle: string;
21
+ position: (position: number, total: number) => string;
22
+ };
23
+ export type StepsProps = Omit<ComponentProps<"nav">, "children"> & {
24
+ label: string;
25
+ items: readonly StepsItem[];
26
+ current?: string | null;
27
+ orientation?: "horizontal" | "vertical";
28
+ responsive?: boolean;
29
+ onStepChange?: (id: string) => void;
30
+ labels?: Partial<typeof defaultLabels>;
31
+ };
32
+ export declare function Steps({ label, items, current, orientation, responsive, onStepChange, labels, className, ...props }: StepsProps): import("react").JSX.Element;
33
+ export {};
package/dist/steps.js ADDED
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useState } from "react";
4
+ import { clsx as cn } from "clsx";
5
+ const defaultLabels = {
6
+ upcoming: "Upcoming", current: "Current", completed: "Completed", error: "Needs attention",
7
+ disabled: "Unavailable", expand: "View steps", collapse: "Hide steps",
8
+ complete: "All steps completed", idle: "No current step",
9
+ position: (position, total) => `Step ${position} of ${total}`,
10
+ };
11
+ export function Steps({ label, items, current, orientation = "horizontal", responsive = true, onStepChange, labels, className, ...props }) {
12
+ const id = useId();
13
+ const [expanded, setExpanded] = useState(false);
14
+ const text = { ...defaultLabels, ...labels };
15
+ const at = items.findIndex(item => item.id === current);
16
+ const complete = items.length > 0 && items.every(item => item.status === "completed");
17
+ return _jsxs("nav", { ...props, "aria-label": label, "data-slot": "steps", "data-orientation": orientation, "data-responsive": responsive, "data-expanded": expanded, className: cn("steps", className), children: [_jsxs("div", { className: "steps-compact", children: [_jsxs("p", { className: "steps-summary", children: [_jsx("span", { children: at >= 0 ? text.position(at + 1, items.length) : complete ? text.complete : text.idle }), at >= 0 && _jsx("strong", { children: items[at].label })] }), _jsx("div", { className: "steps-segments", "aria-hidden": "true", children: items.map(item => _jsx("span", { "data-state": item.status ?? "upcoming", "data-current": item.id === current }, item.id)) }), _jsx("button", { type: "button", className: "steps-toggle", "aria-controls": id, "aria-expanded": expanded, onClick: () => setExpanded(value => !value), children: expanded ? text.collapse : text.expand })] }), _jsx("ol", { id: id, className: "steps-list", children: items.map((item, index) => {
18
+ const status = item.status ?? "upcoming";
19
+ const active = item.id === current;
20
+ const canNavigate = status !== "disabled" && (item.href || (item.navigable && onStepChange));
21
+ const content = _jsxs(_Fragment, { children: [_jsx("span", { className: "steps-marker", "aria-hidden": "true", children: status === "completed" ? _jsx("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "2", children: _jsx("path", { d: "m3 8 3 3 7-7" }) }) : status === "disabled" ? _jsxs("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [_jsx("rect", { x: "3.5", y: "7", width: "9", height: "7", rx: "1" }), _jsx("path", { d: "M5.5 7V4a2.5 2.5 0 0 1 5 0v3" })] }) : status === "error" ? "!" : index + 1 }), _jsxs("span", { className: "steps-copy", children: [_jsx("span", { className: "steps-label", children: item.label }), _jsx("span", { className: "steps-state", children: active ? `${text.current}${status === "error" ? `, ${text.error}` : ""}` : text[status] }), item.description != null && _jsx("span", { className: "steps-description", children: item.description })] })] });
22
+ return _jsx("li", { "data-state": status, "data-current": active, "aria-current": active ? "step" : undefined, children: canNavigate && item.href ? _jsx("a", { className: "steps-item", href: item.href, children: content })
23
+ : canNavigate ? _jsx("button", { type: "button", className: "steps-item", onClick: () => onStepChange?.(item.id), children: content })
24
+ : _jsx("div", { className: "steps-item", children: content }) }, item.id);
25
+ }) })] });
26
+ }
package/dist/styles.css CHANGED
@@ -21,6 +21,26 @@
21
21
  color: var(--color-foreground);
22
22
  box-shadow: var(--shadow-xs);
23
23
  }
24
+ /* The same sliding chip as the Segmented track in ui.css. Its corners follow
25
+ the control corners, which the appearance settings can make asymmetric. */
26
+ @supports (anchor-name: --theme-selected) {
27
+ .theme-buttons:dir(ltr) { position: relative; isolation: isolate; }
28
+ .theme-buttons:dir(ltr) .btn[aria-checked="true"] {
29
+ anchor-name: --theme-selected;
30
+ background: transparent;
31
+ box-shadow: none;
32
+ }
33
+ .theme-buttons:dir(ltr):has(.btn[aria-checked="true"])::before {
34
+ content: ""; position: absolute; z-index: -1;
35
+ position-anchor: --theme-selected;
36
+ inset: anchor(inside);
37
+ border-radius: var(--appearance-control-corners, var(--radius-md));
38
+ background: var(--color-card);
39
+ box-shadow: var(--shadow-xs);
40
+ pointer-events: none;
41
+ transition: inset var(--motion-duration-fast) var(--motion-easing-standard);
42
+ }
43
+ }
24
44
  .theme-selector-cards { display: grid; gap: var(--spacing-md); min-width: 0; }
25
45
  .theme-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); gap: var(--spacing-md); }
26
46
  .theme-cards .theme-card {
@@ -84,6 +104,7 @@
84
104
  color: var(--color-foreground);
85
105
  font-weight: var(--type-weight-medium);
86
106
  }
107
+ .accent-pill:is([data-accent="gold"], [data-accent="lime"])[aria-pressed="true"] { border-color: var(--color-link); }
87
108
  .accent-dot { width: var(--spacing-md); height: var(--spacing-md); border-radius: var(--radius-full); background: var(--color-primary); }
88
109
 
89
110
  .accent-preview {
@@ -1,3 +1,5 @@
1
1
  import * as React from "react";
2
- declare function Textarea({ className, ...props }: React.ComponentProps<"textarea">): React.JSX.Element;
2
+ declare function Textarea({ className, controlSize, ...props }: React.ComponentProps<"textarea"> & {
3
+ controlSize?: "sm" | "md" | "lg" | "xl";
4
+ }): React.JSX.Element;
3
5
  export { Textarea };
package/dist/textarea.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { clsx as cn } from "clsx";
3
- function Textarea({ className, ...props }) {
4
- return (_jsx("textarea", { "data-slot": "textarea", className: cn("textarea", className), ...props }));
3
+ function Textarea({ className, controlSize, ...props }) {
4
+ return (_jsx("textarea", { "data-slot": "textarea", "data-control-size": controlSize, className: cn("textarea", className), ...props }));
5
5
  }
6
6
  export { Textarea };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momoi-labs/kiso-react",
3
- "version": "0.11.1",
3
+ "version": "0.13.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.15.2",
35
+ "@momoi-labs/kiso": "^0.17.0",
36
36
  "class-variance-authority": "0.7.1",
37
37
  "clsx": "2.1.1",
38
38
  "radix-ui": "1.6.7",