@momoi-labs/kiso-react 0.2.0 → 0.4.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.
Files changed (71) hide show
  1. package/README.md +115 -14
  2. package/dist/alert.d.ts +10 -0
  3. package/dist/alert.js +27 -0
  4. package/dist/app-shell.d.ts +28 -0
  5. package/dist/app-shell.js +22 -0
  6. package/dist/breadcrumb.d.ts +10 -0
  7. package/dist/breadcrumb.js +23 -0
  8. package/dist/command-palette.d.ts +17 -0
  9. package/dist/command-palette.js +78 -0
  10. package/dist/dialog.d.ts +14 -0
  11. package/dist/dialog.js +39 -0
  12. package/dist/dot.d.ts +9 -0
  13. package/dist/dot.js +21 -0
  14. package/dist/drawer.d.ts +9 -0
  15. package/dist/drawer.js +17 -0
  16. package/dist/dropdown-menu.d.ts +13 -0
  17. package/dist/dropdown-menu.js +32 -0
  18. package/dist/empty-state.d.ts +14 -0
  19. package/dist/empty-state.js +30 -0
  20. package/dist/form-field.d.ts +15 -5
  21. package/dist/form-field.js +19 -6
  22. package/dist/header.d.ts +3 -0
  23. package/dist/header.js +8 -0
  24. package/dist/index.d.ts +31 -0
  25. package/dist/index.js +31 -0
  26. package/dist/kv.d.ts +5 -0
  27. package/dist/kv.js +12 -0
  28. package/dist/link.d.ts +10 -0
  29. package/dist/link.js +15 -0
  30. package/dist/log-view.d.ts +17 -0
  31. package/dist/log-view.js +56 -0
  32. package/dist/navigation.d.ts +12 -0
  33. package/dist/navigation.js +23 -0
  34. package/dist/page-header.d.ts +9 -0
  35. package/dist/page-header.js +19 -0
  36. package/dist/pagination.d.ts +10 -0
  37. package/dist/pagination.js +21 -0
  38. package/dist/popover.d.ts +8 -0
  39. package/dist/popover.js +21 -0
  40. package/dist/search.d.ts +5 -0
  41. package/dist/search.js +9 -0
  42. package/dist/select.d.ts +11 -0
  43. package/dist/select.js +30 -0
  44. package/dist/separator.d.ts +4 -0
  45. package/dist/separator.js +9 -0
  46. package/dist/sidebar.d.ts +6 -0
  47. package/dist/sidebar.js +17 -0
  48. package/dist/skeleton.d.ts +7 -0
  49. package/dist/skeleton.js +15 -0
  50. package/dist/spinner.d.ts +9 -0
  51. package/dist/spinner.js +15 -0
  52. package/dist/split.d.ts +11 -0
  53. package/dist/split.js +64 -0
  54. package/dist/stat.d.ts +12 -0
  55. package/dist/stat.js +32 -0
  56. package/dist/styles.css +156 -1
  57. package/dist/switch.d.ts +4 -0
  58. package/dist/switch.js +11 -0
  59. package/dist/tabs.d.ts +7 -0
  60. package/dist/tabs.js +18 -0
  61. package/dist/textarea.d.ts +3 -0
  62. package/dist/textarea.js +6 -0
  63. package/dist/toast.d.ts +23 -0
  64. package/dist/toast.js +69 -0
  65. package/dist/tooltip.d.ts +7 -0
  66. package/dist/tooltip.js +20 -0
  67. package/dist/use-isomorphic-layout-effect.d.ts +2 -0
  68. package/dist/use-isomorphic-layout-effect.js +4 -0
  69. package/dist/validation-message.d.ts +3 -0
  70. package/dist/validation-message.js +8 -0
  71. package/package.json +2 -2
package/dist/split.js ADDED
@@ -0,0 +1,64 @@
1
+ // Adapted from shadcn/ui new-york-v4. See ../SHADCN-LICENSE.
2
+ "use client";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import * as React from "react";
5
+ import { clsx as cn } from "clsx";
6
+ import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
7
+ function Split({ className, ...props }) {
8
+ return (_jsx("div", { "data-slot": "split", className: cn("split", className), ...props }));
9
+ }
10
+ function Pane({ className, ...props }) {
11
+ return (_jsx("div", { "data-slot": "pane", className: cn("pane", className), ...props }));
12
+ }
13
+ /* The divider owns the size so that dropping one between two panes is the
14
+ whole setup — no state to lift for a drag. Where it puts that size is what
15
+ `.split > .pane` already expects: `flex-basis` on the pane before it.
16
+ `onSizeChange` reports the percentage for anyone who wants to persist it. */
17
+ function Splitter({ className, defaultSize = 50, min = 25, max = 75, step = 2, onSizeChange, onPointerDown, onPointerMove, onLostPointerCapture, onKeyDown, "aria-label": ariaLabel = "Resize panes", ...props }) {
18
+ const ref = React.useRef(null);
19
+ const [size, setSize] = React.useState(defaultSize);
20
+ const [dragging, setDragging] = React.useState(false);
21
+ useIsomorphicLayoutEffect(() => {
22
+ const pane = ref.current?.previousElementSibling;
23
+ if (pane instanceof HTMLElement)
24
+ pane.style.flexBasis = `${size}%`;
25
+ }, [size]);
26
+ function resize(next) {
27
+ const value = Math.min(max, Math.max(min, next));
28
+ if (value === size)
29
+ return;
30
+ setSize(value);
31
+ onSizeChange?.(value);
32
+ }
33
+ return (_jsx("div", { ref: ref, role: "separator", tabIndex: 0, "aria-orientation": "vertical", "aria-label": ariaLabel, "aria-valuenow": Math.round(size), "aria-valuemin": min, "aria-valuemax": max, "data-slot": "splitter", className: cn("splitter", dragging && "dragging", className), ...props, onPointerDown: (event) => {
34
+ onPointerDown?.(event);
35
+ event.currentTarget.setPointerCapture(event.pointerId);
36
+ setDragging(true);
37
+ }, onPointerMove: (event) => {
38
+ onPointerMove?.(event);
39
+ if (!dragging)
40
+ return;
41
+ const box = event.currentTarget.parentElement?.getBoundingClientRect();
42
+ if (box)
43
+ resize(((event.clientX - box.left) / box.width) * 100);
44
+ },
45
+ /* Covers the pointer being released and the drag being cancelled. */
46
+ onLostPointerCapture: (event) => {
47
+ onLostPointerCapture?.(event);
48
+ setDragging(false);
49
+ }, onKeyDown: (event) => {
50
+ onKeyDown?.(event);
51
+ if (event.key === "ArrowLeft")
52
+ resize(size - step);
53
+ else if (event.key === "ArrowRight")
54
+ resize(size + step);
55
+ else if (event.key === "Home")
56
+ resize(min);
57
+ else if (event.key === "End")
58
+ resize(max);
59
+ else
60
+ return;
61
+ event.preventDefault();
62
+ } }));
63
+ }
64
+ export { Split, Pane, Splitter };
package/dist/stat.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ declare function Stat({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
4
+ declare function StatHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
5
+ declare function StatLabel({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
6
+ declare function StatValue({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
7
+ declare function StatFoot({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
8
+ declare const statDeltaVariants: (props?: ({
9
+ variant?: "danger" | "info" | "neutral" | "success" | "warning" | null | undefined;
10
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
11
+ declare function StatDelta({ className, variant, ...props }: React.ComponentProps<"span"> & VariantProps<typeof statDeltaVariants>): React.JSX.Element;
12
+ export { Stat, StatHeader, StatLabel, StatValue, StatFoot, StatDelta, statDeltaVariants, };
package/dist/stat.js ADDED
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cva } from "class-variance-authority";
3
+ import { clsx as cn } from "clsx";
4
+ function Stat({ className, ...props }) {
5
+ return (_jsx("div", { "data-slot": "stat", className: cn("stat", className), ...props }));
6
+ }
7
+ /* The tile puts its label and its delta on one line. */
8
+ function StatHeader({ className, ...props }) {
9
+ return (_jsx("div", { "data-slot": "stat-header", className: cn("between", className), ...props }));
10
+ }
11
+ function StatLabel({ className, ...props }) {
12
+ return (_jsx("span", { "data-slot": "stat-label", className: cn("stat-label", className), ...props }));
13
+ }
14
+ function StatValue({ className, ...props }) {
15
+ return (_jsx("span", { "data-slot": "stat-value", className: cn("stat-value", className), ...props }));
16
+ }
17
+ function StatFoot({ className, ...props }) {
18
+ return (_jsx("span", { "data-slot": "stat-foot", className: cn("stat-foot", className), ...props }));
19
+ }
20
+ const statDeltaVariants = cva("badge badge-outline stat-delta", {
21
+ variants: { variant: {
22
+ neutral: "", info: "info", success: "success",
23
+ warning: "warning", danger: "danger",
24
+ } },
25
+ defaultVariants: { variant: "neutral" },
26
+ });
27
+ /* A slot rather than a prop: the direction arrow, the number and its unit are
28
+ content, and only their colour is the component's business. */
29
+ function StatDelta({ className, variant = "neutral", ...props }) {
30
+ return (_jsx("span", { "data-slot": "stat-delta", "data-variant": variant, className: cn(statDeltaVariants({ variant }), className), ...props }));
31
+ }
32
+ export { Stat, StatHeader, StatLabel, StatValue, StatFoot, StatDelta, statDeltaVariants, };
package/dist/styles.css CHANGED
@@ -108,4 +108,159 @@
108
108
  .kiso-checkbox .checkbox-mixed,
109
109
  .kiso-checkbox[data-state="indeterminate"] .checkbox-check { display: none; }
110
110
  .kiso-checkbox[data-state="indeterminate"] .checkbox-mixed { display: block; }
111
- .kiso-react-dialog { max-height: calc(100dvh - 2 * var(--spacing-lg)); overflow-y: auto; }
111
+ /* Corner marks are drawn outside the surface, so the surface itself must not
112
+ scroll: it would scroll to reveal them and show two scrollbars on a dialog
113
+ that fits. The content region scrolls instead. */
114
+ .kiso-react-dialog {
115
+ display: flex;
116
+ flex-direction: column;
117
+ max-height: calc(100dvh - 2 * var(--spacing-lg));
118
+ }
119
+ .kiso-react-dialog > *,
120
+ .kiso-react-drawer > * {
121
+ min-width: 0;
122
+ min-height: 0;
123
+ }
124
+
125
+ /* Shapes the CSS layer names in prose but not in a class. */
126
+ .spinner-sm { width: var(--size-icon-sm); height: var(--size-icon-sm); }
127
+ .skeleton-text { height: 1lh; border-radius: var(--radius-sm); }
128
+ .skeleton-circle { aspect-ratio: 1; border-radius: var(--radius-full); }
129
+ .empty-sm { padding: var(--spacing-lg) var(--spacing-md); }
130
+
131
+ /* Lists carry the semantics; the CSS layer styles their containers. */
132
+ [data-slot="navigation-list"],
133
+ [data-slot="breadcrumb-list"],
134
+ [data-slot="toast-viewport"] {
135
+ list-style: none;
136
+ margin: 0;
137
+ padding: 0;
138
+ }
139
+ /* A column by default. `.nav-row` is the shared layer's row treatment, so
140
+ yield to it rather than override it from here. */
141
+ [data-slot="navigation-list"]:not(.nav-row) {
142
+ display: grid;
143
+ gap: var(--spacing-2xs);
144
+ }
145
+
146
+ /* Radix renders the Select trigger as a button, so the native select's
147
+ text alignment has to be restated. */
148
+ [data-slot="select-trigger"] {
149
+ display: flex;
150
+ align-items: center;
151
+ gap: var(--spacing-sm);
152
+ text-align: start;
153
+ cursor: pointer;
154
+ }
155
+ [data-slot="select-trigger"][data-placeholder] {
156
+ color: var(--color-subtle-foreground);
157
+ }
158
+ [data-slot="select-trigger"]:disabled { cursor: not-allowed; }
159
+ [data-slot="select-item"] { justify-content: space-between; }
160
+
161
+ /* Portalled surfaces: above the page, never wider than it. */
162
+ .kiso-react-floating {
163
+ z-index: 70;
164
+ max-width: calc(100vw - 2 * var(--spacing-lg));
165
+ }
166
+ .kiso-react-floating .menu-item[data-highlighted] {
167
+ background: var(--color-selected);
168
+ color: var(--color-selected-foreground);
169
+ outline: none;
170
+ }
171
+ .kiso-react-floating .menu-item.is-danger[data-highlighted] {
172
+ background: var(--color-danger-surface);
173
+ color: var(--color-danger);
174
+ }
175
+ .kiso-react-floating .menu-item[data-disabled] {
176
+ color: var(--color-disabled);
177
+ cursor: not-allowed;
178
+ }
179
+ .kiso-react-popover {
180
+ display: grid;
181
+ gap: var(--spacing-md);
182
+ padding: var(--spacing-lg);
183
+ border: 1px solid var(--color-border);
184
+ border-radius: var(--radius-lg);
185
+ background: var(--color-popover);
186
+ color: var(--color-popover-foreground);
187
+ box-shadow: var(--shadow-md);
188
+ max-width: min(24rem, calc(100vw - 2 * var(--spacing-lg)));
189
+ }
190
+ [data-slot="tooltip-content"] { max-width: 28ch; }
191
+
192
+ .kiso-react-switch {
193
+ position: relative;
194
+ width: 32px;
195
+ height: 18px;
196
+ flex: none;
197
+ padding: 0;
198
+ border: 0;
199
+ border-radius: var(--radius-full);
200
+ background: var(--color-border-strong);
201
+ cursor: pointer;
202
+ transition: background var(--motion-duration-fast) var(--motion-easing-standard);
203
+ }
204
+ .kiso-react-switch[data-state="checked"] { background: var(--color-primary); }
205
+ .kiso-react-switch:disabled { opacity: .5; cursor: not-allowed; }
206
+ .kiso-react-switch-thumb {
207
+ display: block;
208
+ width: 14px;
209
+ height: 14px;
210
+ margin-inline-start: 2px;
211
+ border-radius: var(--radius-full);
212
+ background: var(--color-white);
213
+ box-shadow: var(--shadow-xs);
214
+ transition: translate var(--motion-duration-fast) var(--motion-easing-standard);
215
+ }
216
+ .kiso-react-switch[data-state="checked"] .kiso-react-switch-thumb {
217
+ translate: 14px 0;
218
+ background: var(--color-primary-foreground);
219
+ }
220
+
221
+ [data-slot="tabs-content"] { padding-block-start: var(--spacing-lg); }
222
+
223
+ [data-slot="toast-viewport"] { max-width: calc(100vw - 2 * var(--spacing-lg)); }
224
+ [data-slot="toast"] { max-width: 100%; }
225
+ [data-slot="toast"][data-variant="success"] { border-color: var(--color-success-border); }
226
+ [data-slot="toast"][data-variant="warning"] { border-color: var(--color-warning-border); }
227
+ [data-slot="toast"][data-variant="error"] { border-color: var(--color-danger-border); }
228
+
229
+ /* A Drawer is the dialog surface moved to an edge. */
230
+ .kiso-react-drawer {
231
+ position: fixed;
232
+ z-index: 51;
233
+ display: flex;
234
+ flex-direction: column;
235
+ background: var(--color-elevated-surface);
236
+ border: 1px solid var(--color-border);
237
+ box-shadow: var(--shadow-md);
238
+ }
239
+ .kiso-react-drawer[data-placement="side"] {
240
+ inset-block: 0;
241
+ inset-inline-end: 0;
242
+ width: min(28rem, calc(100vw - var(--spacing-xl)));
243
+ border-start-start-radius: var(--radius-surface);
244
+ border-end-start-radius: var(--radius-surface);
245
+ }
246
+ .kiso-react-drawer[data-placement="bottom"] {
247
+ inset-inline: 0;
248
+ inset-block-end: 0;
249
+ max-height: 85dvh;
250
+ border-start-start-radius: var(--radius-surface);
251
+ border-start-end-radius: var(--radius-surface);
252
+ }
253
+ /* Header and footer stay put; the body takes the leftover height. */
254
+ .kiso-react-drawer [data-slot="dialog-body"] {
255
+ flex: 1 1 auto;
256
+ overflow-y: auto;
257
+ }
258
+
259
+ .kiso-react-palette {
260
+ position: fixed;
261
+ z-index: 51;
262
+ inset-block-start: 12vh;
263
+ inset-inline-start: 50%;
264
+ translate: -50% 0;
265
+ width: min(560px, calc(100vw - 2 * var(--spacing-lg)));
266
+ }
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import { Switch as SwitchPrimitive } from "radix-ui";
3
+ declare function Switch({ className, ...props }: React.ComponentProps<typeof SwitchPrimitive.Root>): React.JSX.Element;
4
+ export { Switch };
package/dist/switch.js ADDED
@@ -0,0 +1,11 @@
1
+ // Adapted from shadcn/ui new-york-v4. See ../SHADCN-LICENSE.
2
+ "use client";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { clsx as cn } from "clsx";
5
+ import { Switch as SwitchPrimitive } from "radix-ui";
6
+ // One immediate boolean setting. A form choice is Checkbox; one value out of
7
+ // many is Select.
8
+ function Switch({ className, ...props }) {
9
+ return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", className: cn("kiso-react-switch", className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: "kiso-react-switch-thumb" }) }));
10
+ }
11
+ export { Switch };
package/dist/tabs.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import { Tabs as TabsPrimitive } from "radix-ui";
3
+ declare function Tabs({ ...props }: React.ComponentProps<typeof TabsPrimitive.Root>): React.JSX.Element;
4
+ declare function TabsList({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.List>): React.JSX.Element;
5
+ declare function TabsTrigger({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Trigger>): React.JSX.Element;
6
+ declare function TabsContent({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Content>): React.JSX.Element;
7
+ export { Tabs, TabsList, TabsTrigger, TabsContent };
package/dist/tabs.js ADDED
@@ -0,0 +1,18 @@
1
+ // Adapted from shadcn/ui new-york-v4. See ../SHADCN-LICENSE.
2
+ "use client";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { clsx as cn } from "clsx";
5
+ import { Tabs as TabsPrimitive } from "radix-ui";
6
+ function Tabs({ ...props }) {
7
+ return _jsx(TabsPrimitive.Root, { "data-slot": "tabs", ...props });
8
+ }
9
+ function TabsList({ className, ...props }) {
10
+ return (_jsx(TabsPrimitive.List, { "data-slot": "tabs-list", className: cn("tabs", className), ...props }));
11
+ }
12
+ function TabsTrigger({ className, ...props }) {
13
+ return (_jsx(TabsPrimitive.Trigger, { "data-slot": "tabs-trigger", className: cn("", className), ...props }));
14
+ }
15
+ function TabsContent({ className, ...props }) {
16
+ return (_jsx(TabsPrimitive.Content, { "data-slot": "tabs-content", className: cn("", className), ...props }));
17
+ }
18
+ export { Tabs, TabsList, TabsTrigger, TabsContent };
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare function Textarea({ className, ...props }: React.ComponentProps<"textarea">): React.JSX.Element;
3
+ export { Textarea };
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { clsx as cn } from "clsx";
3
+ function Textarea({ className, ...props }) {
4
+ return (_jsx("textarea", { "data-slot": "textarea", className: cn("textarea", className), ...props }));
5
+ }
6
+ export { Textarea };
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ import { Toast as ToastPrimitive } from "radix-ui";
4
+ type ToastVariant = "neutral" | "success" | "warning" | "error";
5
+ type ToastNotify = (variant: ToastVariant, title: React.ReactNode, body?: React.ReactNode) => void;
6
+ declare const toastVariants: (props?: ({
7
+ variant?: "error" | "neutral" | "success" | "warning" | null | undefined;
8
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
9
+ declare function ToastProvider({ ...props }: React.ComponentProps<typeof ToastPrimitive.Provider>): React.JSX.Element;
10
+ declare function ToastViewport({ className, ...props }: React.ComponentProps<typeof ToastPrimitive.Viewport>): React.JSX.Element;
11
+ declare function Toast({ className, variant, type, ...props }: React.ComponentProps<typeof ToastPrimitive.Root> & VariantProps<typeof toastVariants>): React.JSX.Element;
12
+ declare function ToastTitle({ className, ...props }: React.ComponentProps<typeof ToastPrimitive.Title>): React.JSX.Element;
13
+ declare function ToastDescription({ className, ...props }: React.ComponentProps<typeof ToastPrimitive.Description>): React.JSX.Element;
14
+ declare function ToastContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
15
+ declare function ToastAction({ ...props }: React.ComponentProps<typeof ToastPrimitive.Action>): React.JSX.Element;
16
+ declare function ToastClose({ ...props }: React.ComponentProps<typeof ToastPrimitive.Close>): React.JSX.Element;
17
+ declare function useToast(): ToastNotify;
18
+ declare function Toasts({ children, duration, }: {
19
+ children: React.ReactNode;
20
+ duration?: number;
21
+ }): React.JSX.Element;
22
+ export { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastContent, ToastAction, ToastClose, Toasts, useToast, toastVariants, };
23
+ export type { ToastNotify, ToastVariant };
package/dist/toast.js ADDED
@@ -0,0 +1,69 @@
1
+ // Adapted from shadcn/ui new-york-v4. See ../SHADCN-LICENSE.
2
+ "use client";
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ import * as React from "react";
5
+ import { cva } from "class-variance-authority";
6
+ import { clsx as cn } from "clsx";
7
+ import { Toast as ToastPrimitive } from "radix-ui";
8
+ import { Button } from "./button.js";
9
+ const ToastContext = React.createContext(null);
10
+ const toastVariants = cva("toast", {
11
+ variants: {
12
+ variant: {
13
+ neutral: "",
14
+ success: "toast-success",
15
+ warning: "toast-warning",
16
+ error: "toast-error",
17
+ },
18
+ },
19
+ defaultVariants: { variant: "neutral" },
20
+ });
21
+ function ToastProvider({ ...props }) {
22
+ return _jsx(ToastPrimitive.Provider, { ...props });
23
+ }
24
+ function ToastViewport({ className, ...props }) {
25
+ return (_jsx(ToastPrimitive.Viewport, { "data-slot": "toast-viewport", className: cn("toast-region", className), ...props }));
26
+ }
27
+ // An error interrupts (assertive); everything else waits its turn (polite).
28
+ function Toast({ className, variant = "neutral", type, ...props }) {
29
+ return (_jsx(ToastPrimitive.Root, { "data-slot": "toast", "data-variant": variant, type: type ?? (variant === "error" ? "foreground" : "background"), className: cn(toastVariants({ variant }), className), ...props }));
30
+ }
31
+ function ToastTitle({ className, ...props }) {
32
+ return (_jsx(ToastPrimitive.Title, { "data-slot": "toast-title", className: cn("alert-title", className), ...props }));
33
+ }
34
+ function ToastDescription({ className, ...props }) {
35
+ return (_jsx(ToastPrimitive.Description, { "data-slot": "toast-description", className: cn("alert-body", className), ...props }));
36
+ }
37
+ function ToastContent({ className, ...props }) {
38
+ return (_jsx("div", { "data-slot": "toast-content", className: cn("stack-xs grow", className), ...props }));
39
+ }
40
+ function ToastAction({ ...props }) {
41
+ return _jsx(ToastPrimitive.Action, { "data-slot": "toast-action", ...props });
42
+ }
43
+ function ToastClose({ ...props }) {
44
+ return _jsx(ToastPrimitive.Close, { "data-slot": "toast-close", ...props });
45
+ }
46
+ function useToast() {
47
+ const notify = React.useContext(ToastContext);
48
+ if (!notify)
49
+ throw new Error("useToast must be used within Toasts");
50
+ return notify;
51
+ }
52
+ function Toasts({ children, duration = 6000, }) {
53
+ const [notices, setNotices] = React.useState([]);
54
+ const nextId = React.useRef(0);
55
+ const notify = React.useCallback((variant, title, body) => {
56
+ const id = nextId.current++;
57
+ setNotices((current) => [...current, { id, variant, title, body }]);
58
+ }, []);
59
+ const dismiss = React.useCallback((id) => {
60
+ setNotices((current) => current.filter((notice) => notice.id !== id));
61
+ }, []);
62
+ return (_jsx(ToastContext.Provider, { value: notify, children: _jsxs(ToastProvider, { duration: duration, children: [children, notices.map((notice) => (_jsxs(Toast, { variant: notice.variant, onOpenChange: (open) => {
63
+ if (!open)
64
+ dismiss(notice.id);
65
+ }, children: [_jsxs(ToastContent, { children: [_jsx(ToastTitle, { children: notice.title }), typeof notice.body === "string" || typeof notice.body === "number"
66
+ ? _jsx(ToastDescription, { children: notice.body })
67
+ : notice.body] }), _jsx(ToastClose, { asChild: true, children: _jsx(Button, { size: "xs", variant: "ghost", children: "Dismiss" }) })] }, notice.id))), _jsx(ToastViewport, {})] }) }));
68
+ }
69
+ export { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastContent, ToastAction, ToastClose, Toasts, useToast, toastVariants, };
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import { Tooltip as TooltipPrimitive } from "radix-ui";
3
+ declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>): React.JSX.Element;
4
+ declare function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): React.JSX.Element;
5
+ declare function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>): React.JSX.Element;
6
+ declare function TooltipContent({ className, sideOffset, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content>): React.JSX.Element;
7
+ export { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent };
@@ -0,0 +1,20 @@
1
+ // Adapted from shadcn/ui new-york-v4. See ../SHADCN-LICENSE.
2
+ "use client";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { clsx as cn } from "clsx";
5
+ import { Tooltip as TooltipPrimitive } from "radix-ui";
6
+ // Never essential: whatever a Tooltip says must also be reachable without
7
+ // hover or focus.
8
+ function TooltipProvider({ delayDuration = 150, ...props }) {
9
+ return (_jsx(TooltipPrimitive.Provider, { "data-slot": "tooltip-provider", delayDuration: delayDuration, ...props }));
10
+ }
11
+ function Tooltip({ ...props }) {
12
+ return _jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props });
13
+ }
14
+ function TooltipTrigger({ ...props }) {
15
+ return _jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
16
+ }
17
+ function TooltipContent({ className, sideOffset = 4, ...props }) {
18
+ return (_jsx(TooltipPrimitive.Portal, { children: _jsx(TooltipPrimitive.Content, { "data-slot": "tooltip-content", sideOffset: sideOffset, className: cn("tooltip kiso-react-floating", className), ...props }) }));
19
+ }
20
+ export { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent };
@@ -0,0 +1,2 @@
1
+ import * as React from "react";
2
+ export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ /* `useLayoutEffect` warns when it runs on the server, where there is no DOM to
3
+ measure. Internal: not exported from the package. */
4
+ export const useIsomorphicLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare function ValidationMessage({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
3
+ export { ValidationMessage };
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { clsx as cn } from "clsx";
3
+ // Associate it with the control through aria-describedby, and mark the control
4
+ // aria-invalid. Give it an id the control can point at.
5
+ function ValidationMessage({ className, ...props }) {
6
+ return (_jsx("p", { "data-slot": "validation-message", className: cn("field-error", className), ...props }));
7
+ }
8
+ export { ValidationMessage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momoi-labs/kiso-react",
3
- "version": "0.2.0",
3
+ "version": "0.4.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.5.0",
35
+ "@momoi-labs/kiso": "^0.7.0",
36
36
  "class-variance-authority": "0.7.1",
37
37
  "clsx": "2.1.1",
38
38
  "radix-ui": "1.6.7"