@momoi-labs/kiso-react 0.37.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/alert.d.ts +2 -1
- package/dist/alert.js +2 -2
- package/dist/app-shell.js +1 -1
- 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/package.json +2 -2
package/dist/alert.d.ts
CHANGED
|
@@ -11,11 +11,12 @@ type AlertLabels = {
|
|
|
11
11
|
hide?: string;
|
|
12
12
|
dismiss?: string;
|
|
13
13
|
};
|
|
14
|
-
declare function Alert({ className, variant, appearance, tape, animated, pulse, placement, onDismiss, labels, role, ref, children, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants> & {
|
|
14
|
+
declare function Alert({ className, variant, appearance, tape, animated, pulse, placement, side, onDismiss, labels, role, ref, children, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants> & {
|
|
15
15
|
tape?: AlertTape;
|
|
16
16
|
animated?: boolean;
|
|
17
17
|
pulse?: boolean;
|
|
18
18
|
placement?: "inline" | "overlay";
|
|
19
|
+
side?: "top" | "middle" | "bottom";
|
|
19
20
|
onDismiss?: () => void;
|
|
20
21
|
labels?: AlertLabels;
|
|
21
22
|
}): React.JSX.Element;
|
package/dist/alert.js
CHANGED
|
@@ -47,7 +47,7 @@ function useOverlaySlot(overlay, id) {
|
|
|
47
47
|
return { hidden: overlay && index !== -1 && !top, more: overlay && top ? stack.length - 1 : 0 };
|
|
48
48
|
}
|
|
49
49
|
const AlertDetailsContext = React.createContext(null);
|
|
50
|
-
function Alert({ className, variant = "info", appearance = "tinted", tape, animated = false, pulse = false, placement = "inline", onDismiss, labels, role, ref, children, ...props }) {
|
|
50
|
+
function Alert({ className, variant = "info", appearance = "tinted", tape, animated = false, pulse = false, placement = "inline", side = "top", onDismiss, labels, role, ref, children, ...props }) {
|
|
51
51
|
const severity = variant ?? "info";
|
|
52
52
|
const loud = appearance === "loud";
|
|
53
53
|
const id = React.useId();
|
|
@@ -84,7 +84,7 @@ function Alert({ className, variant = "info", appearance = "tinted", tape, anima
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
const resolvedTape = tape ?? (severity === "error" || severity === "warning" ? "top" : "none");
|
|
87
|
-
const alert = (_jsxs("div", { ref: setRef, "data-slot": "alert", "data-variant": variant, "data-appearance": appearance, "data-placement": placement, "data-tape": loud ? resolvedTape : undefined, "data-animated": loud && animated ? "true" : undefined, "data-pulse": loud && pulse ? "true" : undefined, role: role ?? (severity === "error" ? "alert" : "status"), hidden: hidden || undefined, className: cn(alertVariants({ variant, appearance }), placement === "overlay" && "alert-overlay", className), ...props, children: [loud && _jsx(LoudMark, { variant: severity }), _jsx(AlertDetailsContext.Provider, { value: { id: detailsId, open }, children: children }), (hasDetails || onDismiss || more > 0) && (_jsxs("div", { "data-slot": "alert-actions", className: "alert-actions", children: [more > 0 && (_jsxs("span", { className: "alert-count", "aria-label": `${more} more ${more === 1 ? "alert" : "alerts"}`, children: ["+", more] })), hasDetails && (_jsxs(Button, { size: "xs", className: "alert-details-toggle", "aria-expanded": open, "aria-controls": detailsId, onClick: () => setOpen((value) => !value), children: [_jsx(ChevronDown, { className: "icon icon-sm", "aria-hidden": "true" }), open ? (labels?.hide ?? "Hide details") : (labels?.show ?? "Details")] })), onDismiss && (_jsx(Button, { className: "btn-icon", size: "sm", variant: "ghost", "aria-label": labels?.dismiss ?? "Dismiss", onClick: dismiss, children: _jsx(X, { className: "icon icon-sm", "aria-hidden": "true" }) }))] }))] }));
|
|
87
|
+
const alert = (_jsxs("div", { ref: setRef, "data-slot": "alert", "data-variant": variant, "data-appearance": appearance, "data-placement": placement, "data-side": placement === "overlay" ? side : undefined, "data-tape": loud ? resolvedTape : undefined, "data-animated": loud && animated ? "true" : undefined, "data-pulse": loud && pulse ? "true" : undefined, role: role ?? (severity === "error" ? "alert" : "status"), hidden: hidden || undefined, className: cn(alertVariants({ variant, appearance }), placement === "overlay" && "alert-overlay", className), ...props, children: [loud && _jsx(LoudMark, { variant: severity }), _jsx(AlertDetailsContext.Provider, { value: { id: detailsId, open }, children: children }), (hasDetails || onDismiss || more > 0) && (_jsxs("div", { "data-slot": "alert-actions", className: "alert-actions", children: [more > 0 && (_jsxs("span", { className: "alert-count", "aria-label": `${more} more ${more === 1 ? "alert" : "alerts"}`, children: ["+", more] })), hasDetails && (_jsxs(Button, { size: "xs", className: "alert-details-toggle", "aria-expanded": open, "aria-controls": detailsId, onClick: () => setOpen((value) => !value), children: [_jsx(ChevronDown, { className: "icon icon-sm", "aria-hidden": "true" }), open ? (labels?.hide ?? "Hide details") : (labels?.show ?? "Details")] })), onDismiss && (_jsx(Button, { className: "btn-icon", size: "sm", variant: "ghost", "aria-label": labels?.dismiss ?? "Dismiss", onClick: dismiss, children: _jsx(X, { className: "icon icon-sm", "aria-hidden": "true" }) }))] }))] }));
|
|
88
88
|
return placement === "overlay" ? _jsx(PortalPrimitive.Root, { asChild: true, children: alert }) : alert;
|
|
89
89
|
}
|
|
90
90
|
function AlertContent({ className, ...props }) {
|
package/dist/app-shell.js
CHANGED
|
@@ -64,7 +64,7 @@ function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationL
|
|
|
64
64
|
useIsomorphicLayoutEffect(() => {
|
|
65
65
|
const sidebar = sidebarRef.current;
|
|
66
66
|
const focused = sidebar?.ownerDocument.activeElement;
|
|
67
|
-
if (isCollapsed && focused && sidebar?.contains(focused) && !focused.getClientRects().length) {
|
|
67
|
+
if (isCollapsed && focused && sidebar?.contains(focused) && (!focused.getClientRects().length || sidebar.ownerDocument.defaultView?.getComputedStyle(focused).visibility === "hidden")) {
|
|
68
68
|
toggleRef.current?.focus();
|
|
69
69
|
}
|
|
70
70
|
}, [isCollapsed]);
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momoi-labs/kiso-react",
|
|
3
|
-
"version": "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.
|
|
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",
|