@momoi-labs/kiso-react 0.9.0 → 0.11.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
@@ -103,7 +103,8 @@ Navigation
103
103
  - Tabs, TabsList, TabsTrigger, TabsContent.
104
104
  - ThemeSelector, a controlled selector. The application owns theme persistence
105
105
  and applies `data-theme="light"` or `data-theme="dark"` to the document root.
106
- Remove the attribute for system mode.
106
+ Remove the attribute for system mode. The default `variant="compact"` uses
107
+ icons. Set `variant="cards"` for labeled options with light and dark previews.
107
108
  - AccentSelector, a controlled selector, plus the `accents` list and `Accent`
108
109
  type. The application owns accent persistence and applies
109
110
  `data-accent="<name>"` to the document root, or to any container that should
@@ -152,6 +153,45 @@ the package owns the repeated Sidebar, Navigation, Header, and main
152
153
  arrangement. With `layout="topbar"`, omit navigation and footer: brand and
153
154
  primary action move into Header beside the existing header slot.
154
155
 
156
+ Add `collapsible` to let the user reduce the sidebar to compact navigation.
157
+ Use destination `leading` slots for icons. The toggle preserves accessible
158
+ names, the active destination, and keyboard focus. `defaultCollapsed` sets the
159
+ initial state; `collapsed` with `onCollapsedChange` lets the product control or
160
+ persist the preference. On narrow screens the navigation keeps its labels and
161
+ returns to the chosen state when the viewport widens. Existing appearance
162
+ settings apply to both states.
163
+
164
+ PageHeader accepts `variant="editorial"` for a larger responsive title and
165
+ more space around the heading.
166
+ AppShell and ApplicationShell accept `variant="inset"` to put the main content
167
+ inside a frame with space around it. These options work independently and
168
+ preserve the current Appearance settings.
169
+
170
+ Set `data-visual-style="editorial"` on `html` to share the editorial hierarchy
171
+ across headings, cards, metrics, and page layouts. Buttons, fields, and tables
172
+ keep their existing density. A region with `data-visual-style="default"` keeps
173
+ the compact composition. The earlier `data-page-header` attribute still works
174
+ for heading-only styling.
175
+
176
+ `data-app-shell="inset"` chooses the application frame independently.
177
+ PageHeader and AppShell follow these preferences when `variant` is omitted;
178
+ an explicit `variant` overrides the corresponding treatment. Without
179
+ preferences, the existing heading sizes, spacing, and frame remain the default.
180
+
181
+ ```tsx
182
+ <ApplicationShell variant="inset" collapsible brand={brand} navigation={groups}>
183
+ <div className="page">
184
+ <PageHeader variant="editorial" actions={<Button>Deploy application</Button>}>
185
+ <PageHeaderTitle>Your homelab</PageHeaderTitle>
186
+ <PageHeaderDescription>
187
+ Applications, machines, and images in one place.
188
+ </PageHeaderDescription>
189
+ </PageHeader>
190
+ {content}
191
+ </div>
192
+ </ApplicationShell>
193
+ ```
194
+
155
195
  Navigation, Sidebar, and Link know nothing about routing. Mark the current
156
196
  destination with `active`, and pass `asChild` to render a router's own link
157
197
  component. CommandPalette is controlled: it owns the overlay, focus, and its
package/dist/alert.d.ts CHANGED
@@ -2,8 +2,9 @@ import * as React from "react";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  declare const alertVariants: (props?: ({
4
4
  variant?: "error" | "info" | "success" | "warning" | null | undefined;
5
+ appearance?: "rail" | "tinted" | null | undefined;
5
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
- declare function Alert({ className, variant, role, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>): React.JSX.Element;
7
+ declare function Alert({ className, variant, appearance, role, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>): React.JSX.Element;
7
8
  declare function AlertContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
8
9
  declare function AlertTitle({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
9
10
  declare function AlertDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
package/dist/alert.js CHANGED
@@ -9,14 +9,15 @@ const alertVariants = cva("alert", {
9
9
  warning: "alert-warning",
10
10
  error: "alert-danger",
11
11
  },
12
+ appearance: { tinted: "", rail: "alert-rail" },
12
13
  },
13
- defaultVariants: { variant: "info" },
14
+ defaultVariants: { variant: "info", appearance: "tinted" },
14
15
  });
15
- function Alert({ className, variant = "info", role, ...props }) {
16
- return (_jsx("div", { "data-slot": "alert", "data-variant": variant, role: role ?? (variant === "error" ? "alert" : "status"), className: cn(alertVariants({ variant }), className), ...props }));
16
+ function Alert({ className, variant = "info", appearance = "tinted", role, ...props }) {
17
+ return (_jsx("div", { "data-slot": "alert", "data-variant": variant, "data-appearance": appearance, role: role ?? (variant === "error" ? "alert" : "status"), className: cn(alertVariants({ variant, appearance }), className), ...props }));
17
18
  }
18
19
  function AlertContent({ className, ...props }) {
19
- return (_jsx("div", { "data-slot": "alert-content", className: cn("stack-xs grow", className), ...props }));
20
+ return (_jsx("div", { "data-slot": "alert-content", className: cn("alert-content stack-xs grow", className), ...props }));
20
21
  }
21
22
  function AlertTitle({ className, ...props }) {
22
23
  return (_jsx("p", { "data-slot": "alert-title", className: cn("alert-title", className), ...props }));
@@ -1,6 +1,15 @@
1
1
  import * as React from "react";
2
- declare function AppShell({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
2
+ import { Button } from "./button.js";
3
+ declare function AppShell({ className, variant, ...props }: React.ComponentProps<"div"> & {
4
+ variant?: "default" | "inset";
5
+ }): React.JSX.Element;
3
6
  declare function AppShellMain({ className, ...props }: React.ComponentProps<"main">): React.JSX.Element;
7
+ declare function AppShellPanel({ className, ...props }: React.ComponentProps<"aside">): React.JSX.Element;
8
+ declare function AppShellPanelToggle({ className, placement, children, "aria-label": label, ...props }: React.ComponentProps<typeof Button> & {
9
+ placement?: "header" | "floating";
10
+ "aria-controls": string;
11
+ "aria-expanded": boolean;
12
+ }): React.JSX.Element;
4
13
  type ApplicationShellDestination = {
5
14
  href: string;
6
15
  active?: boolean;
@@ -18,6 +27,7 @@ type ApplicationShellSharedProps = Omit<React.ComponentProps<typeof AppShell>, "
18
27
  brand: React.ReactNode;
19
28
  primaryAction?: React.ReactNode;
20
29
  header?: React.ReactNode;
30
+ panel?: React.ReactNode;
21
31
  children: React.ReactNode;
22
32
  };
23
33
  type ApplicationShellSidebarProps = ApplicationShellSharedProps & {
@@ -25,14 +35,24 @@ type ApplicationShellSidebarProps = ApplicationShellSharedProps & {
25
35
  navigation: readonly ApplicationShellGroup[];
26
36
  navigationLabel?: string;
27
37
  footer?: React.ReactNode;
38
+ collapsible?: boolean;
39
+ togglePlacement?: "sidebar" | "header";
40
+ collapsed?: boolean;
41
+ defaultCollapsed?: boolean;
42
+ onCollapsedChange?: (collapsed: boolean) => void;
28
43
  };
29
44
  type ApplicationShellTopbarProps = ApplicationShellSharedProps & {
30
45
  layout: "topbar";
31
46
  navigation?: never;
32
47
  navigationLabel?: never;
33
48
  footer?: never;
49
+ collapsible?: never;
50
+ togglePlacement?: never;
51
+ collapsed?: never;
52
+ defaultCollapsed?: never;
53
+ onCollapsedChange?: never;
34
54
  };
35
55
  type ApplicationShellProps = ApplicationShellSidebarProps | ApplicationShellTopbarProps;
36
56
  declare function ApplicationShell(props: ApplicationShellProps): React.JSX.Element;
37
- export { AppShell, AppShellMain, ApplicationShell };
57
+ export { AppShell, AppShellMain, AppShellPanel, AppShellPanelToggle, ApplicationShell };
38
58
  export type { ApplicationShellDestination, ApplicationShellGroup, ApplicationShellProps, };
package/dist/app-shell.js CHANGED
@@ -1,30 +1,62 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ // Adapted from shadcn/ui new-york-v4. See ../SHADCN-LICENSE.
2
+ "use client";
3
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ import * as React from "react";
2
5
  import { clsx as cn } from "clsx";
6
+ import { Button } from "./button.js";
3
7
  import { Header } from "./header.js";
8
+ import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
4
9
  import { Navigation, NavigationGroup, NavigationItem, NavigationLink, NavigationList, } from "./navigation.js";
5
10
  import { Sidebar, SidebarBody, SidebarFooter, SidebarHeader } from "./sidebar.js";
6
- function AppShell({ className, ...props }) {
7
- return (_jsx("div", { "data-slot": "app-shell", className: cn("app-shell", className), ...props }));
11
+ function AppShell({ className, variant, ...props }) {
12
+ return (_jsx("div", { "data-slot": "app-shell", "data-variant": variant, className: cn("app-shell", className), ...props }));
8
13
  }
9
14
  /* `grow` carries the `min-width: 0` the main column needs so a wide table or
10
15
  log line cannot push the sidebar off the screen. */
11
16
  function AppShellMain({ className, ...props }) {
12
17
  return (_jsx("main", { "data-slot": "app-shell-main", className: cn("grow", className), ...props }));
13
18
  }
14
- function ApplicationShellNavigation({ navigation, navigationLabel, }) {
15
- return (_jsx(Navigation, { "aria-label": navigationLabel, children: navigation.map((group, groupIndex) => (_jsx(NavigationGroup, { label: group.label, children: group.destinations.length > 0 ? (_jsx(NavigationList, { children: group.destinations.map((destination, destinationIndex) => (_jsx(NavigationItem, { children: _jsxs(NavigationLink, { href: destination.href, active: destination.active, onClick: (event) => {
19
+ function AppShellPanel({ className, ...props }) {
20
+ return _jsx("aside", { "data-slot": "app-shell-panel", className: cn("app-shell-panel", className), ...props });
21
+ }
22
+ function AppShellPanelToggle({ className, placement = "header", children, "aria-label": label, ...props }) {
23
+ return _jsx(Button, { variant: "ghost", size: "sm", "data-slot": "app-shell-panel-toggle", "data-placement": placement, className: cn("app-shell-panel-toggle", className), "aria-label": label ?? (props["aria-expanded"] ? "Close panel" : "Open panel"), title: label ?? (props["aria-expanded"] ? "Close panel" : "Open panel"), ...props, children: 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: "M10.5 2v12" })] }) });
24
+ }
25
+ function ApplicationShellNavigation({ navigation, navigationLabel, collapsible = false, }) {
26
+ return (_jsx(Navigation, { "aria-label": navigationLabel, children: navigation.map((group, groupIndex) => (_jsx(NavigationGroup, { label: group.label, children: group.destinations.length > 0 ? (_jsx(NavigationList, { children: group.destinations.map((destination, destinationIndex) => (_jsx(NavigationItem, { children: _jsx(NavigationLink, { href: destination.href, active: destination.active, className: collapsible && destination.leading ? "sidebar-link-with-icon" : undefined, title: collapsible && typeof destination.label === "string" ? destination.label : undefined, onClick: (event) => {
16
27
  if (!destination.onClick)
17
28
  return;
18
29
  event.preventDefault();
19
30
  destination.onClick();
20
- }, children: [destination.leading, _jsx("span", { className: "grow truncate", children: destination.label }), destination.trailing] }) }, `${destination.href}-${destinationIndex}`))) })) : (group.empty) }, group.label ?? groupIndex))) }));
31
+ }, children: collapsible ? _jsxs(_Fragment, { children: [destination.leading && _jsx("span", { className: "sidebar-link-icon", "aria-hidden": "true", children: destination.leading }), _jsx("span", { className: "sidebar-link-label grow truncate", children: destination.label }), destination.trailing && _jsx("span", { className: "sidebar-link-trailing", children: destination.trailing })] }) : _jsxs(_Fragment, { children: [destination.leading, _jsx("span", { className: "grow truncate", children: destination.label }), destination.trailing] }) }) }, `${destination.href}-${destinationIndex}`))) })) : (group.empty) }, group.label ?? groupIndex))) }));
21
32
  }
22
33
  function ApplicationShell(props) {
23
34
  if (props.layout === "topbar") {
24
- const { brand, primaryAction, header, children, layout: _layout, ...shellProps } = props;
25
- return (_jsx(AppShell, { ...shellProps, "data-layout": "topbar", children: _jsxs(AppShellMain, { children: [_jsxs(Header, { children: [brand, primaryAction, header] }), children] }) }));
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] }));
37
+ }
38
+ return _jsx(ApplicationShellSidebar, { ...props });
39
+ }
40
+ function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationLabel = "Primary", footer, header, panel, children, layout: _layout, collapsible = false, togglePlacement = "sidebar", collapsed, defaultCollapsed = false, onCollapsedChange, ...shellProps }) {
41
+ const [internalCollapsed, setInternalCollapsed] = React.useState(defaultCollapsed);
42
+ const isCollapsed = collapsible && (collapsed ?? internalCollapsed);
43
+ const sidebarId = React.useId();
44
+ const sidebarRef = React.useRef(null);
45
+ const toggleRef = React.useRef(null);
46
+ useIsomorphicLayoutEffect(() => {
47
+ const sidebar = sidebarRef.current;
48
+ const focused = sidebar?.ownerDocument.activeElement;
49
+ if (isCollapsed && focused && sidebar?.contains(focused) && !focused.getClientRects().length) {
50
+ toggleRef.current?.focus();
51
+ }
52
+ }, [isCollapsed]);
53
+ function toggleSidebar() {
54
+ const next = !isCollapsed;
55
+ if (collapsed === undefined)
56
+ setInternalCollapsed(next);
57
+ onCollapsedChange?.(next);
26
58
  }
27
- const { brand, primaryAction, navigation, navigationLabel = "Primary", footer, header, children, layout: _layout, ...shellProps } = props;
28
- return (_jsxs(AppShell, { ...shellProps, children: [_jsxs(Sidebar, { children: [_jsxs(SidebarHeader, { children: [brand, primaryAction] }), _jsx(SidebarBody, { children: _jsx(ApplicationShellNavigation, { navigation: navigation, navigationLabel: navigationLabel }) }), footer && _jsx(SidebarFooter, { children: footer })] }), _jsxs(AppShellMain, { children: [header && _jsx(Header, { children: header }), children] })] }));
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] }));
29
61
  }
30
- export { AppShell, AppShellMain, ApplicationShell };
62
+ export { AppShell, AppShellMain, AppShellPanel, AppShellPanelToggle, ApplicationShell };
@@ -2,6 +2,8 @@ import { type ComponentProps, type ReactElement, type ReactNode } from "react";
2
2
  import { Input } from "./input.js";
3
3
  type FormControlProps = {
4
4
  id?: string;
5
+ controlSize?: ComponentProps<typeof Input>["controlSize"];
6
+ "data-control-size"?: ComponentProps<typeof Input>["controlSize"];
5
7
  "aria-describedby"?: string;
6
8
  "aria-invalid"?: ComponentProps<"input">["aria-invalid"];
7
9
  };
@@ -11,6 +13,9 @@ type FormFieldProps = Omit<ComponentProps<typeof Input>, "children"> & {
11
13
  error?: ReactNode;
12
14
  children?: ReactElement<FormControlProps>;
13
15
  fieldClassName?: string;
16
+ layout?: "stacked" | "inline";
17
+ leading?: ReactNode;
18
+ suffix?: ReactNode;
14
19
  };
15
- export declare function FormField({ label, hint, error, children, fieldClassName, id: providedId, "aria-describedby": describedBy, "aria-invalid": invalid, ...props }: FormFieldProps): import("react").JSX.Element;
20
+ export declare function FormField({ label, hint, error, children, fieldClassName, layout, leading, suffix, controlSize, id: providedId, "aria-describedby": describedBy, "aria-invalid": invalid, ...props }: FormFieldProps): import("react").JSX.Element;
16
21
  export type { FormFieldProps };
@@ -8,18 +8,24 @@ function mergeDescriptions(...descriptions) {
8
8
  const ids = descriptions.flatMap((description) => description?.split(/\s+/).filter(Boolean) ?? []);
9
9
  return ids.length > 0 ? [...new Set(ids)].join(" ") : undefined;
10
10
  }
11
- export function FormField({ label, hint, error, children, fieldClassName, id: providedId, "aria-describedby": describedBy, "aria-invalid": invalid, ...props }) {
11
+ export function FormField({ label, hint, error, children, fieldClassName, layout = "stacked", leading, suffix, controlSize, id: providedId, "aria-describedby": describedBy, "aria-invalid": invalid, ...props }) {
12
12
  const generatedId = useId();
13
13
  const id = providedId ?? children?.props.id ?? generatedId;
14
14
  const hintId = hint ? `${id}-help` : undefined;
15
15
  const errorId = error ? `${id}-error` : undefined;
16
- const description = mergeDescriptions(describedBy, children?.props["aria-describedby"], hintId, errorId);
16
+ const suffixId = suffix ? `${id}-suffix` : undefined;
17
+ const size = controlSize ?? children?.props.controlSize ?? children?.props["data-control-size"];
18
+ const description = mergeDescriptions(describedBy, children?.props["aria-describedby"], hintId, errorId, suffixId);
17
19
  const controlProps = {
18
20
  id,
19
21
  "aria-describedby": description,
20
22
  "aria-invalid": error ? true : children?.props["aria-invalid"] ?? invalid,
23
+ ...(size ? { "data-control-size": size } : {}),
21
24
  };
22
- return (_jsxs("div", { className: fieldClassName ? `field ${fieldClassName}` : "field", children: [_jsx(Label, { htmlFor: id, children: label }), children
23
- ? cloneElement(children, controlProps)
24
- : _jsx(Input, { ...props, ...controlProps }), hint && (_jsx("small", { className: "field-hint", id: hintId, children: hint })), error && _jsx(ValidationMessage, { id: errorId, children: error })] }));
25
+ const control = children
26
+ ? cloneElement(children, controlProps)
27
+ : _jsx(Input, { ...props, ...controlProps });
28
+ const fieldLabel = _jsx(Label, { htmlFor: id, children: label });
29
+ const grouped = layout === "inline" || leading || suffix;
30
+ return (_jsxs("div", { className: fieldClassName ? `field ${fieldClassName}` : "field", "data-layout": layout, "data-control-size": size, children: [layout !== "inline" && fieldLabel, grouped ? _jsxs("div", { className: "field-control", children: [leading && _jsx("span", { className: "field-leading", "aria-hidden": "true", children: leading }), layout === "inline" && fieldLabel, control, suffix && _jsx("span", { className: "field-suffix", id: suffixId, children: suffix })] }) : control, hint && (_jsx("small", { className: "field-hint", id: hintId, children: hint })), error && _jsx(ValidationMessage, { id: errorId, children: error })] }));
25
31
  }
package/dist/input.d.ts CHANGED
@@ -1,3 +1,7 @@
1
1
  import * as React from "react";
2
- declare function Input({ className, type, ...props }: React.ComponentProps<"input">): React.JSX.Element;
2
+ type InputProps = React.ComponentProps<"input"> & {
3
+ controlSize?: "sm" | "md" | "lg";
4
+ };
5
+ declare function Input({ className, type, controlSize, ...props }: InputProps): React.JSX.Element;
3
6
  export { Input };
7
+ export type { InputProps };
package/dist/input.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 Input({ className, type, ...props }) {
4
- return (_jsx("input", { type: type, "data-slot": "input", className: cn("input", className), ...props }));
3
+ function Input({ className, type, controlSize, ...props }) {
4
+ return (_jsx("input", { type: type, "data-slot": "input", "data-control-size": controlSize, className: cn("input", className), ...props }));
5
5
  }
6
6
  export { Input };
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
- declare function PageHeader({ className, actions, children, ...props }: React.ComponentProps<"div"> & {
2
+ declare function PageHeader({ className, actions, children, variant, ...props }: React.ComponentProps<"div"> & {
3
3
  actions?: React.ReactNode;
4
+ variant?: "default" | "editorial";
4
5
  }): React.JSX.Element;
5
6
  declare function PageHeaderTitle({ className, asChild, ...props }: React.ComponentProps<"h1"> & {
6
7
  asChild?: boolean;
@@ -3,11 +3,11 @@ import { clsx as cn } from "clsx";
3
3
  import { Slot } from "radix-ui";
4
4
  // Actions sit beside the title, so they are a prop rather than a child: the
5
5
  // title block keeps its own grid either way.
6
- function PageHeader({ className, actions, children, ...props }) {
7
- const heading = (_jsx("div", { "data-slot": "page-header", className: cn("page-header", className), ...props, children: children }));
6
+ function PageHeader({ className, actions, children, variant, ...props }) {
7
+ const heading = (_jsx("div", { "data-slot": "page-header", "data-variant": variant, className: cn("page-header", className), ...props, children: children }));
8
8
  if (!actions)
9
9
  return heading;
10
- return (_jsxs("div", { "data-slot": "page-header-row", className: "between", children: [heading, _jsx("div", { "data-slot": "page-header-actions", className: "row-wrap", children: actions })] }));
10
+ return (_jsxs("div", { "data-slot": "page-header-row", "data-variant": variant, className: "between", children: [heading, _jsx("div", { "data-slot": "page-header-actions", className: "row-wrap", children: actions })] }));
11
11
  }
12
12
  function PageHeaderTitle({ className, asChild = false, ...props }) {
13
13
  const Comp = asChild ? Slot.Root : "h1";
package/dist/select.d.ts CHANGED
@@ -3,7 +3,9 @@ import { Select as SelectPrimitive } from "radix-ui";
3
3
  declare function Select({ ...props }: React.ComponentProps<typeof SelectPrimitive.Root>): React.JSX.Element;
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
- declare function SelectTrigger({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Trigger>): React.JSX.Element;
6
+ declare function SelectTrigger({ className, controlSize, ...props }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
7
+ controlSize?: "sm" | "md" | "lg";
8
+ }): React.JSX.Element;
7
9
  declare function SelectContent({ className, children, position, sideOffset, ...props }: React.ComponentProps<typeof SelectPrimitive.Content>): React.JSX.Element;
8
10
  declare function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Label>): React.JSX.Element;
9
11
  declare function SelectItem({ className, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Item>): React.JSX.Element;
package/dist/select.js CHANGED
@@ -12,8 +12,8 @@ function SelectGroup({ ...props }) {
12
12
  function SelectValue({ ...props }) {
13
13
  return _jsx(SelectPrimitive.Value, { "data-slot": "select-value", ...props });
14
14
  }
15
- function SelectTrigger({ className, ...props }) {
16
- return (_jsx(SelectPrimitive.Trigger, { "data-slot": "select-trigger", className: cn("select", className), ...props }));
15
+ function SelectTrigger({ className, controlSize, ...props }) {
16
+ return (_jsx(SelectPrimitive.Trigger, { "data-slot": "select-trigger", "data-control-size": controlSize, className: cn("select", className), ...props }));
17
17
  }
18
18
  function SelectContent({ className, children, position = "popper", sideOffset = 4, ...props }) {
19
19
  return (_jsx(SelectPrimitive.Portal, { children: _jsx(SelectPrimitive.Content, { "data-slot": "select-content", position: position, sideOffset: sideOffset, className: cn("menu kiso-react-floating", className), ...props, children: _jsx(SelectPrimitive.Viewport, { "data-slot": "select-viewport", children: children }) }) }));
package/dist/sidebar.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as React from "react";
2
- declare function Sidebar({ className, ...props }: React.ComponentProps<"aside">): React.JSX.Element;
2
+ declare function Sidebar({ className, collapsed, ...props }: React.ComponentProps<"aside"> & {
3
+ collapsed?: boolean;
4
+ }): React.JSX.Element;
3
5
  declare function SidebarHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
4
6
  declare function SidebarBody({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
5
7
  declare function SidebarFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
package/dist/sidebar.js CHANGED
@@ -2,8 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { clsx as cn } from "clsx";
3
3
  // Sidebar is layout. Its destinations are Navigation children, so it holds no
4
4
  // route, no active item, and no disclosure state of its own.
5
- function Sidebar({ className, ...props }) {
6
- return (_jsx("aside", { "data-slot": "sidebar", className: cn("sidebar", className), ...props }));
5
+ function Sidebar({ className, collapsed = false, ...props }) {
6
+ return (_jsx("aside", { "data-slot": "sidebar", "data-collapsed": collapsed || undefined, className: cn("sidebar", className), ...props }));
7
7
  }
8
8
  function SidebarHeader({ className, ...props }) {
9
9
  return (_jsx("div", { "data-slot": "sidebar-header", className: cn("sidebar-header", className), ...props }));
package/dist/styles.css CHANGED
@@ -21,6 +21,33 @@
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. */
@@ -128,10 +155,11 @@
128
155
  z-index: 51;
129
156
  transform: translate(-50%, -50%);
130
157
  width: min(32rem, calc(100vw - 2 * var(--spacing-lg)));
131
- background: var(--color-elevated-surface);
132
- border: 1px solid var(--color-border);
133
- border-radius: var(--radius-surface);
134
- box-shadow: var(--shadow-md);
158
+ --frame-fill: var(--color-elevated-surface);
159
+ background: color-mix(in srgb, var(--frame-fill) calc((1 - var(--appearance-expressive, 0)) * 100%), transparent);
160
+ border: 1px var(--appearance-panel-border, solid) var(--color-border);
161
+ border-radius: var(--appearance-corners, var(--radius-surface));
162
+ box-shadow: var(--appearance-frame-shadow, var(--shadow-md));
135
163
  }
136
164
  .dialog-scroll {
137
165
  max-height: calc(100dvh - 2 * var(--spacing-xl));
@@ -227,6 +255,12 @@
227
255
  [data-slot="select-trigger"][data-placeholder] {
228
256
  color: var(--color-muted-foreground);
229
257
  }
258
+ .field-control > .select > [data-slot="select-value"] {
259
+ min-width: 0;
260
+ overflow: hidden;
261
+ text-overflow: ellipsis;
262
+ white-space: nowrap;
263
+ }
230
264
  [data-slot="select-trigger"]:disabled { cursor: not-allowed; }
231
265
  [data-slot="select-item"] { justify-content: space-between; }
232
266
  [data-slot="select-content"] {
@@ -309,9 +343,10 @@
309
343
  z-index: 51;
310
344
  display: flex;
311
345
  flex-direction: column;
312
- background: var(--color-elevated-surface);
313
- border: 1px solid var(--color-border);
314
- box-shadow: var(--shadow-md);
346
+ --frame-fill: var(--color-elevated-surface);
347
+ background: color-mix(in srgb, var(--frame-fill) calc((1 - var(--appearance-expressive, 0)) * 100%), transparent);
348
+ border: 1px var(--appearance-panel-border, solid) var(--color-border);
349
+ box-shadow: var(--appearance-frame-shadow, var(--shadow-md));
315
350
  }
316
351
  .kiso-react-drawer[data-placement="side"] {
317
352
  inset-block: 0;
package/dist/table.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import * as React from "react";
2
- declare function Table({ className, ...props }: React.ComponentProps<"table">): React.JSX.Element;
2
+ type TableProps = React.ComponentProps<"table"> & {
3
+ density?: "compact" | "comfortable" | "spacious";
4
+ header?: "tinted" | "plain";
5
+ };
6
+ declare function TableFrame({ className, frame, ...props }: React.ComponentProps<"div"> & {
7
+ frame?: "default" | "none";
8
+ }): React.JSX.Element;
9
+ declare function Table({ className, density, header, ...props }: TableProps): React.JSX.Element;
3
10
  declare function TableHeader({ className, ...props }: React.ComponentProps<"thead">): React.JSX.Element;
4
11
  declare function TableBody({ className, ...props }: React.ComponentProps<"tbody">): React.JSX.Element;
5
12
  declare function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">): React.JSX.Element;
@@ -7,4 +14,5 @@ declare function TableRow({ className, ...props }: React.ComponentProps<"tr">):
7
14
  declare function TableHead({ className, ...props }: React.ComponentProps<"th">): React.JSX.Element;
8
15
  declare function TableCell({ className, ...props }: React.ComponentProps<"td">): React.JSX.Element;
9
16
  declare function TableCaption({ className, ...props }: React.ComponentProps<"caption">): React.JSX.Element;
10
- export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
17
+ export { Table, TableFrame, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
18
+ export type { TableProps };
package/dist/table.js CHANGED
@@ -2,8 +2,11 @@
2
2
  "use client";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
4
  import { clsx as cn } from "clsx";
5
- function Table({ className, ...props }) {
6
- return (_jsx("div", { "data-slot": "table-container", className: "table-scroll", children: _jsx("table", { "data-slot": "table", className: cn("table", className), ...props }) }));
5
+ function TableFrame({ className, frame = "default", ...props }) {
6
+ return _jsx("div", { "data-slot": "table-frame", "data-frame": frame, className: cn("table-wrap", className), ...props });
7
+ }
8
+ function Table({ className, density, header, ...props }) {
9
+ return (_jsx("div", { "data-slot": "table-container", className: "table-scroll", children: _jsx("table", { "data-slot": "table", "data-density": density, "data-header": header, className: cn("table", className), ...props }) }));
7
10
  }
8
11
  function TableHeader({ className, ...props }) {
9
12
  return (_jsx("thead", { "data-slot": "table-header", className: cn("", className), ...props }));
@@ -26,4 +29,4 @@ function TableCell({ className, ...props }) {
26
29
  function TableCaption({ className, ...props }) {
27
30
  return (_jsx("caption", { "data-slot": "table-caption", className: cn("muted", className), ...props }));
28
31
  }
29
- export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
32
+ export { Table, TableFrame, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
@@ -1,4 +1,5 @@
1
- export declare function ThemeSelector({ theme, onChange, }: {
1
+ export declare function ThemeSelector({ theme, onChange, variant, }: {
2
2
  theme: string;
3
3
  onChange: (theme: string) => void;
4
+ variant?: "compact" | "cards";
4
5
  }): import("react").JSX.Element;
@@ -1,37 +1,52 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useRef } from "react";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useRef } from "react";
4
4
  import { Button } from "./button.js";
5
- export function ThemeSelector({ theme, onChange, }) {
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";
6
12
  const buttons = useRef([]);
7
13
  const options = [
8
14
  {
9
15
  value: "system",
10
16
  label: "Follow system",
17
+ name: "System",
18
+ description: "Follow your device",
11
19
  path: "M2 2h12v9H2zM8 11v3M5 14h6",
12
20
  },
13
21
  {
14
22
  value: "light",
15
23
  label: "Light theme",
24
+ name: "Light",
25
+ description: "Always use light colors",
16
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",
17
27
  },
18
28
  {
19
29
  value: "dark",
20
30
  label: "Dark theme",
31
+ name: "Dark",
32
+ description: "Always use dark colors",
21
33
  path: "M13.5 10A6 6 0 0 1 6 2.5a6 6 0 1 0 7.5 7.5Z",
22
34
  },
23
35
  ];
24
- return (_jsxs("div", { className: "theme-row", children: [_jsx("span", { className: "t-label", children: "Theme" }), _jsx("div", { className: "theme-buttons", role: "radiogroup", "aria-label": "Theme", children: options.map((option, index) => (_jsx(Button, { ref: (button) => { buttons.current[index] = button; }, variant: "ghost", size: "sm", className: "btn-icon", role: "radio", "aria-label": option.label, title: option.label, "aria-checked": theme === option.value, tabIndex: theme === option.value ? 0 : -1, onClick: () => onChange(option.value), onKeyDown: (event) => {
25
- if (event.altKey || event.ctrlKey || event.metaKey)
26
- return;
27
- const direction = event.key === "ArrowRight" || event.key === "ArrowDown"
28
- ? 1
29
- : event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 0;
30
- if (!direction)
31
- return;
32
- event.preventDefault();
33
- const next = (index + direction + options.length) % options.length;
34
- buttons.current[next]?.focus();
35
- onChange(options[next].value);
36
- }, children: _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 }) }) }, option.value))) })] }));
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
+ }) })] }));
37
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momoi-labs/kiso-react",
3
- "version": "0.9.0",
3
+ "version": "0.11.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.13.0",
35
+ "@momoi-labs/kiso": "^0.15.0",
36
36
  "class-variance-authority": "0.7.1",
37
37
  "clsx": "2.1.1",
38
38
  "radix-ui": "1.6.7",