@momoi-labs/kiso-react 0.9.0 → 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 +41 -1
- package/dist/app-shell.d.ts +11 -1
- package/dist/app-shell.js +33 -8
- 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/styles.css +27 -0
- package/dist/theme-selector.d.ts +2 -1
- package/dist/theme-selector.js +31 -16
- package/package.json +2 -2
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/app-shell.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare function AppShell({ className, ...props }: React.ComponentProps<"div">
|
|
2
|
+
declare function AppShell({ className, variant, ...props }: React.ComponentProps<"div"> & {
|
|
3
|
+
variant?: "default" | "inset";
|
|
4
|
+
}): React.JSX.Element;
|
|
3
5
|
declare function AppShellMain({ className, ...props }: React.ComponentProps<"main">): React.JSX.Element;
|
|
4
6
|
type ApplicationShellDestination = {
|
|
5
7
|
href: string;
|
|
@@ -25,12 +27,20 @@ type ApplicationShellSidebarProps = ApplicationShellSharedProps & {
|
|
|
25
27
|
navigation: readonly ApplicationShellGroup[];
|
|
26
28
|
navigationLabel?: string;
|
|
27
29
|
footer?: React.ReactNode;
|
|
30
|
+
collapsible?: boolean;
|
|
31
|
+
collapsed?: boolean;
|
|
32
|
+
defaultCollapsed?: boolean;
|
|
33
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
28
34
|
};
|
|
29
35
|
type ApplicationShellTopbarProps = ApplicationShellSharedProps & {
|
|
30
36
|
layout: "topbar";
|
|
31
37
|
navigation?: never;
|
|
32
38
|
navigationLabel?: never;
|
|
33
39
|
footer?: never;
|
|
40
|
+
collapsible?: never;
|
|
41
|
+
collapsed?: never;
|
|
42
|
+
defaultCollapsed?: never;
|
|
43
|
+
onCollapsedChange?: never;
|
|
34
44
|
};
|
|
35
45
|
type ApplicationShellProps = ApplicationShellSidebarProps | ApplicationShellTopbarProps;
|
|
36
46
|
declare function ApplicationShell(props: ApplicationShellProps): React.JSX.Element;
|
package/dist/app-shell.js
CHANGED
|
@@ -1,30 +1,55 @@
|
|
|
1
|
-
|
|
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:
|
|
19
|
+
function ApplicationShellNavigation({ navigation, navigationLabel, collapsible = false, }) {
|
|
20
|
+
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
21
|
if (!destination.onClick)
|
|
17
22
|
return;
|
|
18
23
|
event.preventDefault();
|
|
19
24
|
destination.onClick();
|
|
20
|
-
}, children: [destination.leading, _jsx("span", { className: "grow truncate", children: destination.label }), destination.trailing] }) }, `${destination.href}-${destinationIndex}`))) })) : (group.empty) }, group.label ?? groupIndex))) }));
|
|
25
|
+
}, 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
26
|
}
|
|
22
27
|
function ApplicationShell(props) {
|
|
23
28
|
if (props.layout === "topbar") {
|
|
24
29
|
const { brand, primaryAction, header, children, layout: _layout, ...shellProps } = props;
|
|
25
30
|
return (_jsx(AppShell, { ...shellProps, "data-layout": "topbar", children: _jsxs(AppShellMain, { children: [_jsxs(Header, { children: [brand, primaryAction, header] }), children] }) }));
|
|
26
31
|
}
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
return _jsx(ApplicationShellSidebar, { ...props });
|
|
33
|
+
}
|
|
34
|
+
function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationLabel = "Primary", footer, header, children, layout: _layout, collapsible = false, collapsed, defaultCollapsed = false, onCollapsedChange, ...shellProps }) {
|
|
35
|
+
const [internalCollapsed, setInternalCollapsed] = React.useState(defaultCollapsed);
|
|
36
|
+
const isCollapsed = collapsible && (collapsed ?? internalCollapsed);
|
|
37
|
+
const sidebarId = React.useId();
|
|
38
|
+
const sidebarRef = React.useRef(null);
|
|
39
|
+
const toggleRef = React.useRef(null);
|
|
40
|
+
useIsomorphicLayoutEffect(() => {
|
|
41
|
+
const sidebar = sidebarRef.current;
|
|
42
|
+
const focused = sidebar?.ownerDocument.activeElement;
|
|
43
|
+
if (isCollapsed && focused && sidebar?.contains(focused) && !focused.getClientRects().length) {
|
|
44
|
+
toggleRef.current?.focus();
|
|
45
|
+
}
|
|
46
|
+
}, [isCollapsed]);
|
|
47
|
+
function toggleSidebar() {
|
|
48
|
+
const next = !isCollapsed;
|
|
49
|
+
if (collapsed === undefined)
|
|
50
|
+
setInternalCollapsed(next);
|
|
51
|
+
onCollapsedChange?.(next);
|
|
52
|
+
}
|
|
53
|
+
return (_jsxs(AppShell, { ...shellProps, children: [_jsxs(Sidebar, { ref: sidebarRef, id: sidebarId, collapsed: isCollapsed, children: [_jsx(SidebarHeader, { className: collapsible ? "sidebar-header-collapsible" : undefined, children: collapsible ? _jsxs(_Fragment, { children: [_jsxs("div", { className: "sidebar-expanded-content", children: [brand, primaryAction] }), _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" })] }) })] }) : _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 && _jsx(Header, { children: header }), children] })] }));
|
|
29
54
|
}
|
|
30
55
|
export { AppShell, AppShellMain, ApplicationShell };
|
package/dist/page-header.d.ts
CHANGED
|
@@ -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;
|
package/dist/page-header.js
CHANGED
|
@@ -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/sidebar.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare function Sidebar({ className, ...props }: React.ComponentProps<"aside">
|
|
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. */
|
package/dist/theme-selector.d.ts
CHANGED
package/dist/theme-selector.js
CHANGED
|
@@ -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
|
-
|
|
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) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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.
|
|
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",
|