@momoi-labs/kiso-react 0.2.0 → 0.3.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 (69) hide show
  1. package/README.md +87 -13
  2. package/dist/alert.d.ts +10 -0
  3. package/dist/alert.js +27 -0
  4. package/dist/app-shell.d.ts +4 -0
  5. package/dist/app-shell.js +11 -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/header.d.ts +3 -0
  21. package/dist/header.js +8 -0
  22. package/dist/index.d.ts +31 -0
  23. package/dist/index.js +31 -0
  24. package/dist/kv.d.ts +5 -0
  25. package/dist/kv.js +12 -0
  26. package/dist/link.d.ts +10 -0
  27. package/dist/link.js +15 -0
  28. package/dist/log-view.d.ts +17 -0
  29. package/dist/log-view.js +56 -0
  30. package/dist/navigation.d.ts +12 -0
  31. package/dist/navigation.js +23 -0
  32. package/dist/page-header.d.ts +9 -0
  33. package/dist/page-header.js +19 -0
  34. package/dist/pagination.d.ts +10 -0
  35. package/dist/pagination.js +21 -0
  36. package/dist/popover.d.ts +8 -0
  37. package/dist/popover.js +21 -0
  38. package/dist/search.d.ts +5 -0
  39. package/dist/search.js +9 -0
  40. package/dist/select.d.ts +11 -0
  41. package/dist/select.js +30 -0
  42. package/dist/separator.d.ts +4 -0
  43. package/dist/separator.js +9 -0
  44. package/dist/sidebar.d.ts +6 -0
  45. package/dist/sidebar.js +17 -0
  46. package/dist/skeleton.d.ts +7 -0
  47. package/dist/skeleton.js +15 -0
  48. package/dist/spinner.d.ts +9 -0
  49. package/dist/spinner.js +15 -0
  50. package/dist/split.d.ts +11 -0
  51. package/dist/split.js +64 -0
  52. package/dist/stat.d.ts +12 -0
  53. package/dist/stat.js +32 -0
  54. package/dist/styles.css +156 -1
  55. package/dist/switch.d.ts +4 -0
  56. package/dist/switch.js +11 -0
  57. package/dist/tabs.d.ts +7 -0
  58. package/dist/tabs.js +18 -0
  59. package/dist/textarea.d.ts +3 -0
  60. package/dist/textarea.js +6 -0
  61. package/dist/toast.d.ts +15 -0
  62. package/dist/toast.js +43 -0
  63. package/dist/tooltip.d.ts +7 -0
  64. package/dist/tooltip.js +20 -0
  65. package/dist/use-isomorphic-layout-effect.d.ts +2 -0
  66. package/dist/use-isomorphic-layout-effect.js +4 -0
  67. package/dist/validation-message.d.ts +3 -0
  68. package/dist/validation-message.js +8 -0
  69. package/package.json +2 -2
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,15 @@
1
+ import * as React from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ import { Toast as ToastPrimitive } from "radix-ui";
4
+ declare const toastVariants: (props?: ({
5
+ variant?: "error" | "neutral" | "success" | "warning" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ declare function ToastProvider({ ...props }: React.ComponentProps<typeof ToastPrimitive.Provider>): React.JSX.Element;
8
+ declare function ToastViewport({ className, ...props }: React.ComponentProps<typeof ToastPrimitive.Viewport>): React.JSX.Element;
9
+ declare function Toast({ className, variant, type, ...props }: React.ComponentProps<typeof ToastPrimitive.Root> & VariantProps<typeof toastVariants>): React.JSX.Element;
10
+ declare function ToastTitle({ className, ...props }: React.ComponentProps<typeof ToastPrimitive.Title>): React.JSX.Element;
11
+ declare function ToastDescription({ className, ...props }: React.ComponentProps<typeof ToastPrimitive.Description>): React.JSX.Element;
12
+ declare function ToastContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
13
+ declare function ToastAction({ ...props }: React.ComponentProps<typeof ToastPrimitive.Action>): React.JSX.Element;
14
+ declare function ToastClose({ ...props }: React.ComponentProps<typeof ToastPrimitive.Close>): React.JSX.Element;
15
+ export { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastContent, ToastAction, ToastClose, toastVariants, };
package/dist/toast.js ADDED
@@ -0,0 +1,43 @@
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 { cva } from "class-variance-authority";
5
+ import { clsx as cn } from "clsx";
6
+ import { Toast as ToastPrimitive } from "radix-ui";
7
+ const toastVariants = cva("toast", {
8
+ variants: {
9
+ variant: {
10
+ neutral: "",
11
+ success: "toast-success",
12
+ warning: "toast-warning",
13
+ error: "toast-error",
14
+ },
15
+ },
16
+ defaultVariants: { variant: "neutral" },
17
+ });
18
+ function ToastProvider({ ...props }) {
19
+ return _jsx(ToastPrimitive.Provider, { ...props });
20
+ }
21
+ function ToastViewport({ className, ...props }) {
22
+ return (_jsx(ToastPrimitive.Viewport, { "data-slot": "toast-viewport", className: cn("toast-region", className), ...props }));
23
+ }
24
+ // An error interrupts (assertive); everything else waits its turn (polite).
25
+ function Toast({ className, variant = "neutral", type, ...props }) {
26
+ return (_jsx(ToastPrimitive.Root, { "data-slot": "toast", "data-variant": variant, type: type ?? (variant === "error" ? "foreground" : "background"), className: cn(toastVariants({ variant }), className), ...props }));
27
+ }
28
+ function ToastTitle({ className, ...props }) {
29
+ return (_jsx(ToastPrimitive.Title, { "data-slot": "toast-title", className: cn("alert-title", className), ...props }));
30
+ }
31
+ function ToastDescription({ className, ...props }) {
32
+ return (_jsx(ToastPrimitive.Description, { "data-slot": "toast-description", className: cn("alert-body", className), ...props }));
33
+ }
34
+ function ToastContent({ className, ...props }) {
35
+ return (_jsx("div", { "data-slot": "toast-content", className: cn("stack-xs grow", className), ...props }));
36
+ }
37
+ function ToastAction({ ...props }) {
38
+ return _jsx(ToastPrimitive.Action, { "data-slot": "toast-action", ...props });
39
+ }
40
+ function ToastClose({ ...props }) {
41
+ return _jsx(ToastPrimitive.Close, { "data-slot": "toast-close", ...props });
42
+ }
43
+ export { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastContent, ToastAction, ToastClose, 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.3.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.6.0",
36
36
  "class-variance-authority": "0.7.1",
37
37
  "clsx": "2.1.1",
38
38
  "radix-ui": "1.6.7"