@momoi-labs/kiso-react 0.38.0 → 0.39.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/dist/index.d.ts CHANGED
@@ -84,3 +84,5 @@ export * from "./feature-grid.js";
84
84
  export * from "./feature-list.js";
85
85
  export * from "./window-frame.js";
86
86
  export * from "./perspective-stack.js";
87
+ export * from "./slide.js";
88
+ export * from "./presenter-view.js";
package/dist/index.js CHANGED
@@ -84,3 +84,5 @@ export * from "./feature-grid.js";
84
84
  export * from "./feature-list.js";
85
85
  export * from "./window-frame.js";
86
86
  export * from "./perspective-stack.js";
87
+ export * from "./slide.js";
88
+ export * from "./presenter-view.js";
@@ -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 };
@@ -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;
@@ -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();
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momoi-labs/kiso-react",
3
- "version": "0.38.0",
3
+ "version": "0.39.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.16.0",
35
+ "@momoi-labs/kiso": "^1.17.0",
36
36
  "class-variance-authority": "0.7.1",
37
37
  "clsx": "2.1.1",
38
38
  "radix-ui": "1.6.7",