@momoi-labs/kiso-react 0.38.0 → 0.40.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 +7 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/presenter-view.d.ts +23 -0
- package/dist/presenter-view.js +35 -0
- package/dist/radio-group.d.ts +2 -1
- package/dist/radio-group.js +2 -2
- package/dist/slide.d.ts +16 -0
- package/dist/slide.js +8 -0
- package/dist/styles.css +1 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -32,11 +32,13 @@ field uses another input, and add `error` for wired validation feedback:
|
|
|
32
32
|
</FormField>
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
`@momoi-labs/kiso` is a regular dependency. The stylesheet imports
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
`@momoi-labs/kiso` is a regular dependency. The stylesheet imports Kiso tokens
|
|
36
|
+
and the component layer; consumers do not need to import those again. React and
|
|
37
|
+
React DOM are peer dependencies supplied by the application. No Tailwind setup
|
|
38
|
+
is required. The stylesheet includes global styles. It does not load fonts, so
|
|
39
|
+
a blocking `@import` never delays first paint: load Inter, DM Sans, and
|
|
40
|
+
JetBrains Mono from the app with a `<link>` in the page head, `next/font`, or
|
|
41
|
+
similar.
|
|
40
42
|
|
|
41
43
|
## Appearance
|
|
42
44
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare const defaultLabels: {
|
|
3
|
+
elapsed: string;
|
|
4
|
+
remaining: string;
|
|
5
|
+
next: string;
|
|
6
|
+
end: string;
|
|
7
|
+
notes: string;
|
|
8
|
+
previous: string;
|
|
9
|
+
advance: string;
|
|
10
|
+
};
|
|
11
|
+
export type PresenterViewProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
12
|
+
current: React.ReactNode;
|
|
13
|
+
next?: React.ReactNode;
|
|
14
|
+
notes?: React.ReactNode;
|
|
15
|
+
position?: React.ReactNode;
|
|
16
|
+
startedAt?: Date | number;
|
|
17
|
+
endsAt?: Date | number;
|
|
18
|
+
onPrevious?: () => void;
|
|
19
|
+
onNext?: () => void;
|
|
20
|
+
labels?: Partial<typeof defaultLabels>;
|
|
21
|
+
};
|
|
22
|
+
declare function PresenterView({ className, current, next, notes, position, startedAt, endsAt, onPrevious, onNext, labels, ...props }: PresenterViewProps): React.JSX.Element;
|
|
23
|
+
export { PresenterView };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { clsx as cn } from "clsx";
|
|
5
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
const defaultLabels = {
|
|
8
|
+
elapsed: "Elapsed", remaining: "Remaining", next: "Next slide", end: "End of deck",
|
|
9
|
+
notes: "Notes", previous: "Previous", advance: "Next",
|
|
10
|
+
};
|
|
11
|
+
function formatClock(ms) {
|
|
12
|
+
const total = Math.floor(Math.abs(ms) / 1000);
|
|
13
|
+
const [h, m, s] = [Math.floor(total / 3600), Math.floor(total / 60) % 60, total % 60];
|
|
14
|
+
const text = (h > 0 ? [h, m, s] : [m, s]).map(part => String(part).padStart(2, "0")).join(":");
|
|
15
|
+
return ms < 0 ? `-${text}` : text;
|
|
16
|
+
}
|
|
17
|
+
function duration(ms) {
|
|
18
|
+
const total = Math.floor(Math.abs(ms) / 1000);
|
|
19
|
+
return `PT${Math.floor(total / 3600)}H${Math.floor(total / 60) % 60}M${total % 60}S`;
|
|
20
|
+
}
|
|
21
|
+
function PresenterView({ className, current, next, notes, position, startedAt, endsAt, onPrevious, onNext, labels, ...props }) {
|
|
22
|
+
const text = { ...defaultLabels, ...labels };
|
|
23
|
+
const [clock, setClock] = React.useState(null);
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
const start = Date.now();
|
|
26
|
+
const tick = () => setClock({ start, now: Date.now() });
|
|
27
|
+
tick();
|
|
28
|
+
const id = setInterval(tick, 1000);
|
|
29
|
+
return () => clearInterval(id);
|
|
30
|
+
}, []);
|
|
31
|
+
const elapsed = clock ? Math.max(0, clock.now - (startedAt != null ? +startedAt : clock.start)) : 0;
|
|
32
|
+
const remaining = clock && endsAt != null ? +endsAt - clock.now : null;
|
|
33
|
+
return (_jsxs("div", { "data-slot": "presenter-view", className: cn("presenter-view", className), ...props, children: [_jsxs("div", { className: "presenter-view-bar", children: [_jsxs("div", { className: "presenter-view-timers", children: [_jsxs("p", { className: "presenter-view-timer", children: [_jsx("span", { className: "presenter-view-label", children: text.elapsed }), _jsx("time", { className: "presenter-view-clock", role: "timer", dateTime: duration(elapsed), children: formatClock(elapsed) })] }), endsAt != null && (_jsxs("p", { className: "presenter-view-timer", children: [_jsx("span", { className: "presenter-view-label", children: text.remaining }), _jsx("time", { className: "presenter-view-clock", role: "timer", dateTime: remaining != null ? duration(remaining) : undefined, "data-overrun": remaining != null && remaining < 0 ? "" : undefined, children: remaining != null ? formatClock(remaining) : "--:--" })] }))] }), _jsxs("div", { className: "presenter-view-controls", children: [_jsxs(Button, { onClick: onPrevious, disabled: !onPrevious, children: [_jsx(ChevronLeft, { "aria-hidden": "true" }), text.previous] }), position != null && _jsx("span", { className: "presenter-view-position", children: position }), _jsxs(Button, { variant: "primary", onClick: onNext, disabled: !onNext, children: [text.advance, _jsx(ChevronRight, { "aria-hidden": "true" })] })] })] }), _jsx("div", { className: "presenter-view-current", children: current }), _jsxs("div", { className: "presenter-view-next", children: [_jsx("p", { className: "presenter-view-label", children: text.next }), next ?? _jsx("div", { className: "presenter-view-end", children: text.end })] }), notes != null && (_jsxs("section", { className: "presenter-view-notes", "aria-label": text.notes, children: [_jsx("p", { className: "presenter-view-label", "aria-hidden": "true", children: text.notes }), typeof notes === "string" ? _jsx("p", { children: notes }) : notes] }))] }));
|
|
34
|
+
}
|
|
35
|
+
export { PresenterView };
|
package/dist/radio-group.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ export type RadioGroupProps = ComponentProps<typeof RadioPrimitive.Root> & {
|
|
|
6
6
|
error?: ReactNode;
|
|
7
7
|
variant?: "default" | "tiles" | "segmented";
|
|
8
8
|
controlSize?: "md" | "xl";
|
|
9
|
+
thumb?: "inset" | "flush";
|
|
9
10
|
};
|
|
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 declare function RadioGroup({ label, description, error, variant, controlSize, thumb, className, "aria-describedby": describedBy, "aria-labelledby": labelledBy, ...props }: RadioGroupProps): import("react").JSX.Element;
|
|
11
12
|
export type RadioGroupItemProps = Omit<ComponentProps<typeof RadioPrimitive.Item>, "children" | "asChild"> & {
|
|
12
13
|
label: ReactNode;
|
|
13
14
|
description?: ReactNode;
|
package/dist/radio-group.js
CHANGED
|
@@ -4,10 +4,10 @@ import { useId } from "react";
|
|
|
4
4
|
import { RadioGroup as RadioPrimitive } from "radix-ui";
|
|
5
5
|
import { clsx as cn } from "clsx";
|
|
6
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 }) {
|
|
7
|
+
export function RadioGroup({ label, description, error, variant = "default", controlSize = "md", thumb = "inset", className, "aria-describedby": describedBy, "aria-labelledby": labelledBy, ...props }) {
|
|
8
8
|
const id = useId();
|
|
9
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 })] });
|
|
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, "data-thumb": variant === "segmented" ? thumb : undefined, "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
11
|
}
|
|
12
12
|
export function RadioGroupItem({ label, description, icon, className, "aria-labelledby": labelledBy, "aria-describedby": describedBy, ...props }) {
|
|
13
13
|
const id = useId();
|
package/dist/slide.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type SlideLayout = "title" | "section" | "statement" | "bullets" | "code" | "terminal" | "split" | "cards" | "steps" | "stats" | "lab" | "recap" | "image" | "media" | "gallery";
|
|
3
|
+
export type SlideProps = Omit<React.ComponentProps<"section">, "title"> & {
|
|
4
|
+
layout?: SlideLayout;
|
|
5
|
+
step?: number | "all";
|
|
6
|
+
fit?: "width" | "fill";
|
|
7
|
+
eyebrow?: React.ReactNode;
|
|
8
|
+
title?: React.ReactNode;
|
|
9
|
+
subline?: React.ReactNode;
|
|
10
|
+
titleAs?: "h1" | "h2" | "h3";
|
|
11
|
+
deck?: React.ReactNode;
|
|
12
|
+
number?: number;
|
|
13
|
+
total?: number;
|
|
14
|
+
};
|
|
15
|
+
declare function Slide({ className, layout, step, fit, eyebrow, title, subline, titleAs: Title, deck, number, total, children, ...props }: SlideProps): React.JSX.Element;
|
|
16
|
+
export { Slide };
|
package/dist/slide.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { clsx as cn } from "clsx";
|
|
3
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
4
|
+
function Slide({ className, layout, step, fit = "width", eyebrow, title, subline, titleAs: Title = "h2", deck, number, total, children, ...props }) {
|
|
5
|
+
const count = number != null ? (total != null ? `${pad(number)} / ${pad(total)}` : pad(number)) : null;
|
|
6
|
+
return (_jsx("section", { "data-slot": "slide", "aria-roledescription": "slide", "data-layout": layout, "data-step-current": step, "data-fit": fit === "fill" ? "fill" : undefined, className: cn("slide", className), ...props, children: _jsxs("div", { className: "slide-canvas", children: [(eyebrow != null || title != null || subline != null) && (_jsxs("div", { className: "site-heading", children: [eyebrow != null && _jsx("p", { className: "site-heading-eyebrow", children: eyebrow }), title != null && _jsx(Title, { className: "site-heading-title", children: title }), subline != null && _jsx("p", { className: "site-heading-description", children: subline })] })), children != null && _jsx("div", { className: "slide-body", children: children }), (deck != null || count != null) && (_jsxs("footer", { className: "slide-footer", children: [_jsx("span", { children: deck }), count != null && _jsx("span", { children: count })] }))] }) }));
|
|
7
|
+
}
|
|
8
|
+
export { Slide };
|
package/dist/styles.css
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600&family=JetBrains+Mono:wght@400;500&display=swap");
|
|
2
1
|
@import "@momoi-labs/kiso/tokens.css";
|
|
3
2
|
@import "@momoi-labs/kiso/ui.css";
|
|
4
3
|
|
|
@@ -23,7 +22,7 @@
|
|
|
23
22
|
color: var(--color-foreground);
|
|
24
23
|
box-shadow: var(--shadow-xs);
|
|
25
24
|
}
|
|
26
|
-
/* The same
|
|
25
|
+
/* The same chip as the Segmented track in ui.css. Its corners follow
|
|
27
26
|
the control corners, which the appearance settings can make asymmetric. */
|
|
28
27
|
@supports (anchor-name: --theme-selected) {
|
|
29
28
|
.theme-buttons:dir(ltr) { position: relative; isolation: isolate; }
|
|
@@ -40,7 +39,6 @@
|
|
|
40
39
|
background: var(--color-card);
|
|
41
40
|
box-shadow: var(--shadow-xs);
|
|
42
41
|
pointer-events: none;
|
|
43
|
-
transition: inset var(--motion-duration-fast) var(--motion-easing-standard);
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
.theme-selector-cards { display: grid; gap: var(--spacing-md); min-width: 0; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momoi-labs/kiso-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.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": "^1.
|
|
35
|
+
"@momoi-labs/kiso": "^1.18.0",
|
|
36
36
|
"class-variance-authority": "0.7.1",
|
|
37
37
|
"clsx": "2.1.1",
|
|
38
38
|
"radix-ui": "1.6.7",
|