@brijbyte/agentic-ui 0.0.3 → 0.0.5
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 +280 -53
- package/dist/accordion/accordion.d.ts +14 -0
- package/dist/accordion/accordion.d.ts.map +1 -1
- package/dist/accordion/accordion.js +5 -0
- package/dist/accordion/accordion.js.map +1 -1
- package/dist/accordion/index.d.ts +2 -2
- package/dist/accordion/index.js +2 -2
- package/dist/accordion/parts.d.ts +6 -14
- package/dist/accordion/parts.d.ts.map +1 -1
- package/dist/accordion/parts.js +7 -6
- package/dist/accordion/parts.js.map +1 -1
- package/dist/alert-dialog/alert-dialog.d.ts +11 -0
- package/dist/alert-dialog/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog/alert-dialog.js +5 -0
- package/dist/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/alert-dialog/parts.d.ts +4 -12
- package/dist/alert-dialog/parts.d.ts.map +1 -1
- package/dist/alert-dialog/parts.js +17 -19
- package/dist/alert-dialog/parts.js.map +1 -1
- package/dist/badge/badge.d.ts +6 -0
- package/dist/badge/badge.d.ts.map +1 -1
- package/dist/badge/badge.js +4 -0
- package/dist/badge/badge.js.map +1 -1
- package/dist/button/button.d.ts +12 -1
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.js +5 -0
- package/dist/button/button.js.map +1 -1
- package/dist/card/card.d.ts +10 -0
- package/dist/card/card.d.ts.map +1 -1
- package/dist/card/card.js +7 -0
- package/dist/card/card.js.map +1 -1
- package/dist/checkbox/checkbox.d.ts +13 -0
- package/dist/checkbox/checkbox.d.ts.map +1 -1
- package/dist/checkbox/checkbox.js +4 -0
- package/dist/checkbox/checkbox.js.map +1 -1
- package/dist/checkbox/parts.d.ts +2 -5
- package/dist/checkbox/parts.d.ts.map +1 -1
- package/dist/checkbox/parts.js +3 -2
- package/dist/checkbox/parts.js.map +1 -1
- package/dist/collapsible/collapsible.d.ts +11 -0
- package/dist/collapsible/collapsible.d.ts.map +1 -1
- package/dist/collapsible/collapsible.js +5 -0
- package/dist/collapsible/collapsible.js.map +1 -1
- package/dist/collapsible/parts.d.ts +3 -9
- package/dist/collapsible/parts.d.ts.map +1 -1
- package/dist/collapsible/parts.js +7 -6
- package/dist/collapsible/parts.js.map +1 -1
- package/dist/context-menu/context-menu.d.ts +5 -0
- package/dist/context-menu/context-menu.d.ts.map +1 -1
- package/dist/context-menu/context-menu.js +4 -0
- package/dist/context-menu/context-menu.js.map +1 -1
- package/dist/context-menu/parts.d.ts +6 -18
- package/dist/context-menu/parts.d.ts.map +1 -1
- package/dist/context-menu/parts.js +16 -16
- package/dist/context-menu/parts.js.map +1 -1
- package/dist/dialog/dialog.d.ts +13 -1
- package/dist/dialog/dialog.d.ts.map +1 -1
- package/dist/dialog/dialog.js +6 -0
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/dialog/parts.d.ts +6 -18
- package/dist/dialog/parts.d.ts.map +1 -1
- package/dist/dialog/parts.js +8 -9
- package/dist/dialog/parts.js.map +1 -1
- package/dist/drawer/drawer.d.ts +11 -0
- package/dist/drawer/drawer.d.ts.map +1 -1
- package/dist/drawer/drawer.js +5 -0
- package/dist/drawer/drawer.js.map +1 -1
- package/dist/drawer/parts.d.ts +7 -19
- package/dist/drawer/parts.d.ts.map +1 -1
- package/dist/drawer/parts.js +14 -13
- package/dist/drawer/parts.js.map +1 -1
- package/dist/index.css +1580 -1150
- package/dist/index.d.ts +20 -11
- package/dist/index.js +15 -2
- package/dist/input/input.d.ts +8 -0
- package/dist/input/input.d.ts.map +1 -1
- package/dist/input/input.js +5 -0
- package/dist/input/input.js.map +1 -1
- package/dist/menu/menu.css +3 -8
- package/dist/menu/menu.d.ts +11 -4
- package/dist/menu/menu.d.ts.map +1 -1
- package/dist/menu/menu.js +10 -24
- package/dist/menu/menu.js.map +1 -1
- package/dist/menu/menu.module.js +1 -1
- package/dist/menu/menu.module.js.map +1 -1
- package/dist/menu/parts.d.ts +6 -18
- package/dist/menu/parts.d.ts.map +1 -1
- package/dist/menu/parts.js +7 -6
- package/dist/menu/parts.js.map +1 -1
- package/dist/meter/circular-meter.d.ts +48 -0
- package/dist/meter/circular-meter.d.ts.map +1 -0
- package/dist/meter/circular-meter.js +86 -0
- package/dist/meter/circular-meter.js.map +1 -0
- package/dist/meter/index.d.ts +4 -0
- package/dist/meter/index.js +5 -0
- package/dist/meter/meter.css +152 -0
- package/dist/meter/meter.d.ts +58 -0
- package/dist/meter/meter.d.ts.map +1 -0
- package/dist/meter/meter.js +50 -0
- package/dist/meter/meter.js.map +1 -0
- package/dist/meter/meter.module.css.d.ts +2 -0
- package/dist/meter/meter.module.js +27 -0
- package/dist/meter/meter.module.js.map +1 -0
- package/dist/meter/meterState.js +18 -0
- package/dist/meter/meterState.js.map +1 -0
- package/dist/meter/parts.d.ts +25 -0
- package/dist/meter/parts.d.ts.map +1 -0
- package/dist/meter/parts.js +57 -0
- package/dist/meter/parts.js.map +1 -0
- package/dist/number-field/number-field.d.ts +16 -0
- package/dist/number-field/number-field.d.ts.map +1 -1
- package/dist/number-field/number-field.js +4 -0
- package/dist/number-field/number-field.js.map +1 -1
- package/dist/number-field/parts.d.ts +6 -18
- package/dist/number-field/parts.d.ts.map +1 -1
- package/dist/number-field/parts.js +7 -6
- package/dist/number-field/parts.js.map +1 -1
- package/dist/popover/index.d.ts +3 -0
- package/dist/popover/index.js +4 -0
- package/dist/popover/parts.d.ts +29 -0
- package/dist/popover/parts.d.ts.map +1 -0
- package/dist/popover/parts.js +93 -0
- package/dist/popover/parts.js.map +1 -0
- package/dist/popover/popover.css +173 -0
- package/dist/popover/popover.d.ts +49 -0
- package/dist/popover/popover.d.ts.map +1 -0
- package/dist/popover/popover.js +68 -0
- package/dist/popover/popover.js.map +1 -0
- package/dist/popover/popover.module.css.d.ts +2 -0
- package/dist/popover/popover.module.js +16 -0
- package/dist/popover/popover.module.js.map +1 -0
- package/dist/progress/parts.d.ts +2 -4
- package/dist/progress/parts.d.ts.map +1 -1
- package/dist/progress/parts.js +3 -6
- package/dist/progress/parts.js.map +1 -1
- package/dist/progress/progress.d.ts +11 -0
- package/dist/progress/progress.d.ts.map +1 -1
- package/dist/progress/progress.js +5 -0
- package/dist/progress/progress.js.map +1 -1
- package/dist/radio/index.d.ts +3 -0
- package/dist/radio/index.js +4 -0
- package/dist/radio/parts.d.ts +14 -0
- package/dist/radio/parts.d.ts.map +1 -0
- package/dist/radio/parts.js +43 -0
- package/dist/radio/parts.js.map +1 -0
- package/dist/radio/radio.css +84 -0
- package/dist/radio/radio.d.ts +31 -0
- package/dist/radio/radio.d.ts.map +1 -0
- package/dist/radio/radio.js +33 -0
- package/dist/radio/radio.js.map +1 -0
- package/dist/radio/radio.module.css.d.ts +2 -0
- package/dist/radio/radio.module.js +11 -0
- package/dist/radio/radio.module.js.map +1 -0
- package/dist/radio-group/index.d.ts +3 -0
- package/dist/radio-group/index.js +4 -0
- package/dist/radio-group/parts.d.ts +11 -0
- package/dist/radio-group/parts.d.ts.map +1 -0
- package/dist/radio-group/parts.js +32 -0
- package/dist/radio-group/parts.js.map +1 -0
- package/dist/radio-group/radio-group.css +17 -0
- package/dist/radio-group/radio-group.d.ts +37 -0
- package/dist/radio-group/radio-group.d.ts.map +1 -0
- package/dist/radio-group/radio-group.js +28 -0
- package/dist/radio-group/radio-group.js.map +1 -0
- package/dist/radio-group/radio-group.module.css.d.ts +2 -0
- package/dist/radio-group/radio-group.module.js +9 -0
- package/dist/radio-group/radio-group.module.js.map +1 -0
- package/dist/reset-scoped.css +112 -0
- package/dist/select/parts.d.ts +11 -32
- package/dist/select/parts.d.ts.map +1 -1
- package/dist/select/parts.js +10 -9
- package/dist/select/parts.js.map +1 -1
- package/dist/select/select.d.ts +14 -1
- package/dist/select/select.d.ts.map +1 -1
- package/dist/select/select.js +4 -0
- package/dist/select/select.js.map +1 -1
- package/dist/separator/separator.d.ts +4 -0
- package/dist/separator/separator.d.ts.map +1 -1
- package/dist/separator/separator.js +4 -0
- package/dist/separator/separator.js.map +1 -1
- package/dist/shared/PopupArrow.js +22 -0
- package/dist/shared/PopupArrow.js.map +1 -0
- package/dist/slider/parts.d.ts +6 -18
- package/dist/slider/parts.d.ts.map +1 -1
- package/dist/slider/parts.js +7 -6
- package/dist/slider/parts.js.map +1 -1
- package/dist/slider/slider.d.ts +18 -0
- package/dist/slider/slider.d.ts.map +1 -1
- package/dist/slider/slider.js +6 -0
- package/dist/slider/slider.js.map +1 -1
- package/dist/switch/parts.d.ts +2 -6
- package/dist/switch/parts.d.ts.map +1 -1
- package/dist/switch/parts.js +3 -2
- package/dist/switch/parts.js.map +1 -1
- package/dist/switch/switch.css +11 -2
- package/dist/switch/switch.d.ts +12 -0
- package/dist/switch/switch.d.ts.map +1 -1
- package/dist/switch/switch.js +4 -0
- package/dist/switch/switch.js.map +1 -1
- package/dist/switch/switch.module.js.map +1 -1
- package/dist/tabs/parts.d.ts +3 -9
- package/dist/tabs/parts.d.ts.map +1 -1
- package/dist/tabs/parts.js +4 -3
- package/dist/tabs/parts.js.map +1 -1
- package/dist/tabs/tabs.d.ts +8 -1
- package/dist/tabs/tabs.d.ts.map +1 -1
- package/dist/tabs/tabs.js +4 -0
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/toast/parts.d.ts +5 -15
- package/dist/toast/parts.d.ts.map +1 -1
- package/dist/toast/parts.js +6 -5
- package/dist/toast/parts.js.map +1 -1
- package/dist/toast/toast.d.ts +11 -0
- package/dist/toast/toast.d.ts.map +1 -1
- package/dist/toast/toast.js +8 -0
- package/dist/toast/toast.js.map +1 -1
- package/dist/tooltip/parts.d.ts +3 -9
- package/dist/tooltip/parts.d.ts.map +1 -1
- package/dist/tooltip/parts.js +4 -3
- package/dist/tooltip/parts.js.map +1 -1
- package/dist/tooltip/tooltip.d.ts +9 -0
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +4 -0
- package/dist/tooltip/tooltip.js.map +1 -1
- package/dist/utils/resolveClassName.js +25 -0
- package/dist/utils/resolveClassName.js.map +1 -0
- package/package.json +25 -4
- package/src/accordion/accordion.tsx +14 -0
- package/src/accordion/index.ts +1 -1
- package/src/accordion/parts.tsx +10 -17
- package/src/alert-dialog/alert-dialog.tsx +11 -0
- package/src/alert-dialog/parts.tsx +23 -31
- package/src/badge/badge.tsx +6 -0
- package/src/button/button.tsx +12 -1
- package/src/card/card.tsx +10 -0
- package/src/checkbox/checkbox.tsx +13 -0
- package/src/checkbox/parts.tsx +5 -7
- package/src/collapsible/collapsible.tsx +11 -0
- package/src/collapsible/parts.tsx +10 -15
- package/src/context-menu/context-menu.tsx +5 -0
- package/src/context-menu/parts.tsx +34 -34
- package/src/dialog/dialog.tsx +13 -1
- package/src/dialog/parts.tsx +14 -27
- package/src/drawer/drawer.tsx +11 -0
- package/src/drawer/parts.tsx +30 -38
- package/src/index.ts +4 -0
- package/src/input/input.tsx +8 -0
- package/src/menu/menu.module.css +3 -10
- package/src/menu/menu.tsx +13 -26
- package/src/menu/parts.tsx +13 -24
- package/src/meter/circular-meter.tsx +114 -0
- package/src/meter/index.ts +9 -0
- package/src/meter/meter.module.css +162 -0
- package/src/meter/meter.tsx +86 -0
- package/src/meter/meterState.ts +29 -0
- package/src/meter/parts.tsx +73 -0
- package/src/number-field/number-field.tsx +16 -0
- package/src/number-field/parts.tsx +33 -24
- package/src/popover/index.ts +14 -0
- package/src/popover/parts.tsx +105 -0
- package/src/popover/popover.module.css +189 -0
- package/src/popover/popover.tsx +80 -0
- package/src/progress/parts.tsx +13 -6
- package/src/progress/progress.tsx +11 -0
- package/src/radio/index.ts +6 -0
- package/src/radio/parts.tsx +42 -0
- package/src/radio/radio.module.css +96 -0
- package/src/radio/radio.tsx +37 -0
- package/src/radio-group/index.ts +5 -0
- package/src/radio-group/parts.tsx +31 -0
- package/src/radio-group/radio-group.module.css +17 -0
- package/src/radio-group/radio-group.tsx +63 -0
- package/src/select/parts.tsx +34 -41
- package/src/select/select.tsx +14 -1
- package/src/separator/separator.tsx +4 -0
- package/src/shared/PopupArrow.tsx +41 -0
- package/src/slider/parts.tsx +13 -24
- package/src/slider/slider.tsx +18 -0
- package/src/styles/reset-scoped.css +112 -0
- package/src/switch/parts.tsx +5 -8
- package/src/switch/switch.module.css +11 -2
- package/src/switch/switch.tsx +12 -0
- package/src/tabs/parts.tsx +7 -12
- package/src/tabs/tabs.tsx +8 -1
- package/src/toast/parts.tsx +11 -20
- package/src/toast/toast.tsx +11 -0
- package/src/tooltip/parts.tsx +7 -12
- package/src/tooltip/tooltip.tsx +9 -0
- package/src/utils/resolveClassName.ts +24 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @brijbyte/agentic-ui — Scoped reset
|
|
3
|
+
*
|
|
4
|
+
* A class-anchored mirror of reset.css for use in sandboxed environments
|
|
5
|
+
* (e.g. documentation demo canvases) where you want the same baseline as
|
|
6
|
+
* a real app that imports reset.css — without touching html/body globally.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* @import "@brijbyte/agentic-ui/reset-scoped";
|
|
10
|
+
*
|
|
11
|
+
* <div class="agentic-reset">
|
|
12
|
+
* <!-- your component demo here -->
|
|
13
|
+
* </div>
|
|
14
|
+
*
|
|
15
|
+
* Rules are kept in exact 1-to-1 correspondence with reset.css.
|
|
16
|
+
* html → .agentic-reset
|
|
17
|
+
* body → .agentic-reset
|
|
18
|
+
* Keep both files in sync when either changes.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
@layer base {
|
|
22
|
+
.agentic-reset,
|
|
23
|
+
.agentic-reset *,
|
|
24
|
+
.agentic-reset *::before,
|
|
25
|
+
.agentic-reset *::after {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.agentic-reset * {
|
|
30
|
+
margin: 0;
|
|
31
|
+
padding: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* html rules → applied to the root of the scoped subtree */
|
|
35
|
+
.agentic-reset {
|
|
36
|
+
-webkit-font-smoothing: antialiased;
|
|
37
|
+
-moz-osx-font-smoothing: grayscale;
|
|
38
|
+
text-rendering: optimizeLegibility;
|
|
39
|
+
tab-size: 2;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* body rules → same root */
|
|
43
|
+
.agentic-reset {
|
|
44
|
+
font-family: var(--font-mono);
|
|
45
|
+
font-size: var(--font-size-md);
|
|
46
|
+
line-height: var(--line-height-normal);
|
|
47
|
+
color: var(--color-primary);
|
|
48
|
+
background-color: var(--color-canvas);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.agentic-reset img,
|
|
52
|
+
.agentic-reset picture,
|
|
53
|
+
.agentic-reset video,
|
|
54
|
+
.agentic-reset canvas,
|
|
55
|
+
.agentic-reset svg {
|
|
56
|
+
display: block;
|
|
57
|
+
max-width: 100%;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.agentic-reset input,
|
|
61
|
+
.agentic-reset button,
|
|
62
|
+
.agentic-reset textarea,
|
|
63
|
+
.agentic-reset select {
|
|
64
|
+
font: inherit;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.agentic-reset * {
|
|
68
|
+
-webkit-tap-highlight-color: transparent;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.agentic-reset p,
|
|
72
|
+
.agentic-reset h1,
|
|
73
|
+
.agentic-reset h2,
|
|
74
|
+
.agentic-reset h3,
|
|
75
|
+
.agentic-reset h4,
|
|
76
|
+
.agentic-reset h5,
|
|
77
|
+
.agentic-reset h6 {
|
|
78
|
+
overflow-wrap: break-word;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.agentic-reset h1,
|
|
82
|
+
.agentic-reset h2,
|
|
83
|
+
.agentic-reset h3,
|
|
84
|
+
.agentic-reset h4,
|
|
85
|
+
.agentic-reset h5,
|
|
86
|
+
.agentic-reset h6 {
|
|
87
|
+
font-family: var(--font-display);
|
|
88
|
+
font-weight: var(--font-weight-semibold);
|
|
89
|
+
line-height: var(--line-height-tight);
|
|
90
|
+
letter-spacing: var(--letter-spacing-tight);
|
|
91
|
+
color: var(--color-primary);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.agentic-reset * {
|
|
95
|
+
scrollbar-width: thin;
|
|
96
|
+
scrollbar-color: var(--color-thumb) var(--color-track);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.agentic-reset *::-webkit-scrollbar {
|
|
100
|
+
width: 6px;
|
|
101
|
+
height: 6px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.agentic-reset *::-webkit-scrollbar-thumb {
|
|
105
|
+
background: var(--color-thumb);
|
|
106
|
+
border-radius: var(--radius-full);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.agentic-reset *::-webkit-scrollbar-track {
|
|
110
|
+
background: var(--color-track);
|
|
111
|
+
}
|
|
112
|
+
}
|
package/src/switch/parts.tsx
CHANGED
|
@@ -18,27 +18,24 @@ import { forwardRef } from "react";
|
|
|
18
18
|
import type { ComponentRef, ComponentPropsWithoutRef } from "react";
|
|
19
19
|
import { Switch as BaseSwitch } from "@base-ui/react/switch";
|
|
20
20
|
import styles from "./switch.module.css";
|
|
21
|
+
import { resolveClassName, cx } from "../utils/resolveClassName";
|
|
21
22
|
|
|
22
23
|
type BaseRootProps = ComponentPropsWithoutRef<typeof BaseSwitch.Root>;
|
|
23
24
|
type BaseThumbProps = ComponentPropsWithoutRef<typeof BaseSwitch.Thumb>;
|
|
24
25
|
|
|
25
|
-
export interface SwitchRootProps extends
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
export interface SwitchThumbProps extends Omit<BaseThumbProps, "className"> {
|
|
29
|
-
className?: string;
|
|
30
|
-
}
|
|
26
|
+
export interface SwitchRootProps extends BaseRootProps {}
|
|
27
|
+
export interface SwitchThumbProps extends BaseThumbProps {}
|
|
31
28
|
|
|
32
29
|
export const SwitchRoot = forwardRef<ComponentRef<typeof BaseSwitch.Root>, SwitchRootProps>(function SwitchRoot(
|
|
33
30
|
{ className, ...props },
|
|
34
31
|
ref,
|
|
35
32
|
) {
|
|
36
|
-
return <BaseSwitch.Root ref={ref} className={
|
|
33
|
+
return <BaseSwitch.Root ref={ref} className={(state) => cx(styles["thumb-track"], resolveClassName(className, state))} {...props} />;
|
|
37
34
|
});
|
|
38
35
|
|
|
39
36
|
export const SwitchThumb = forwardRef<ComponentRef<typeof BaseSwitch.Thumb>, SwitchThumbProps>(function SwitchThumb(
|
|
40
37
|
{ className, ...props },
|
|
41
38
|
ref,
|
|
42
39
|
) {
|
|
43
|
-
return <BaseSwitch.Thumb ref={ref} className={
|
|
40
|
+
return <BaseSwitch.Thumb ref={ref} className={(state) => cx(styles.thumb, resolveClassName(className, state))} {...props} />;
|
|
44
41
|
});
|
|
@@ -6,10 +6,14 @@
|
|
|
6
6
|
cursor: pointer;
|
|
7
7
|
user-select: none;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/* data-disabled lives on the inner button, not the label wrapper.
|
|
10
|
+
Use :has() to dim the label text, and target the track directly. */
|
|
11
|
+
.root:has([data-disabled]) {
|
|
11
12
|
cursor: not-allowed;
|
|
12
13
|
}
|
|
14
|
+
.root:has([data-disabled]) .label {
|
|
15
|
+
opacity: 0.44;
|
|
16
|
+
}
|
|
13
17
|
.thumb-track {
|
|
14
18
|
position: relative;
|
|
15
19
|
width: 36px;
|
|
@@ -24,6 +28,11 @@
|
|
|
24
28
|
outline: none;
|
|
25
29
|
flex-shrink: 0;
|
|
26
30
|
}
|
|
31
|
+
.thumb-track[data-disabled] {
|
|
32
|
+
opacity: 0.44;
|
|
33
|
+
cursor: not-allowed;
|
|
34
|
+
pointer-events: none;
|
|
35
|
+
}
|
|
27
36
|
.thumb-track:focus-visible {
|
|
28
37
|
box-shadow: var(--shadow-focus);
|
|
29
38
|
}
|
package/src/switch/switch.tsx
CHANGED
|
@@ -4,19 +4,31 @@ import { Switch as BaseSwitch } from "@base-ui/react/switch";
|
|
|
4
4
|
import styles from "./switch.module.css";
|
|
5
5
|
|
|
6
6
|
export interface SwitchProps {
|
|
7
|
+
/** Controlled checked state. */
|
|
7
8
|
checked?: boolean;
|
|
9
|
+
/** Initial checked state (uncontrolled). */
|
|
8
10
|
defaultChecked?: boolean;
|
|
11
|
+
/** Prevent interaction. */
|
|
9
12
|
disabled?: boolean;
|
|
13
|
+
/** Mark the field as required for form validation. */
|
|
10
14
|
required?: boolean;
|
|
15
|
+
/** HTML name attribute for form submission. */
|
|
11
16
|
name?: string;
|
|
17
|
+
/** HTML value attribute for form submission. */
|
|
12
18
|
value?: string;
|
|
13
19
|
/** Called when checked state changes. `eventDetails` is the base-ui event details object. */
|
|
14
20
|
onCheckedChange?: (checked: boolean, eventDetails: unknown) => void;
|
|
21
|
+
/** Label content rendered next to the switch. */
|
|
15
22
|
children?: ReactNode;
|
|
23
|
+
/** Override the auto-generated element id. */
|
|
16
24
|
id?: string;
|
|
17
25
|
className?: string;
|
|
18
26
|
}
|
|
19
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Toggle for boolean settings. Renders a track with a sliding thumb and
|
|
30
|
+
* an optional label. Wraps `@base-ui/react` Switch.
|
|
31
|
+
*/
|
|
20
32
|
export function Switch({ children, id, className, onCheckedChange, ...props }: SwitchProps) {
|
|
21
33
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
22
34
|
const switchId = id ?? useId();
|
package/src/tabs/parts.tsx
CHANGED
|
@@ -20,29 +20,24 @@ import { forwardRef } from "react";
|
|
|
20
20
|
import type { ComponentRef, ComponentPropsWithoutRef } from "react";
|
|
21
21
|
import { Tabs as BaseTabs } from "@base-ui/react/tabs";
|
|
22
22
|
import styles from "./tabs.module.css";
|
|
23
|
+
import { resolveClassName, cx } from "../utils/resolveClassName";
|
|
23
24
|
|
|
24
25
|
type BaseListProps = ComponentPropsWithoutRef<typeof BaseTabs.List>;
|
|
25
26
|
type BaseTabProps = ComponentPropsWithoutRef<typeof BaseTabs.Tab>;
|
|
26
27
|
type BasePanelProps = ComponentPropsWithoutRef<typeof BaseTabs.Panel>;
|
|
27
28
|
|
|
28
|
-
export interface TabsListProps extends
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
export interface TabsTabProps extends Omit<BaseTabProps, "className"> {
|
|
32
|
-
className?: string;
|
|
33
|
-
}
|
|
34
|
-
export interface TabsPanelProps extends Omit<BasePanelProps, "className"> {
|
|
35
|
-
className?: string;
|
|
36
|
-
}
|
|
29
|
+
export interface TabsListProps extends BaseListProps {}
|
|
30
|
+
export interface TabsTabProps extends BaseTabProps {}
|
|
31
|
+
export interface TabsPanelProps extends BasePanelProps {}
|
|
37
32
|
|
|
38
33
|
export const TabsList = forwardRef<ComponentRef<typeof BaseTabs.List>, TabsListProps>(function TabsList({ className, ...props }, ref) {
|
|
39
|
-
return <BaseTabs.List ref={ref} className={
|
|
34
|
+
return <BaseTabs.List ref={ref} className={(state) => cx(styles.list, resolveClassName(className, state))} {...props} />;
|
|
40
35
|
});
|
|
41
36
|
|
|
42
37
|
export const TabsTab = forwardRef<ComponentRef<typeof BaseTabs.Tab>, TabsTabProps>(function TabsTab({ className, ...props }, ref) {
|
|
43
|
-
return <BaseTabs.Tab ref={ref} className={
|
|
38
|
+
return <BaseTabs.Tab ref={ref} className={(state) => cx(styles.tab, resolveClassName(className, state))} {...props} />;
|
|
44
39
|
});
|
|
45
40
|
|
|
46
41
|
export const TabsPanel = forwardRef<ComponentRef<typeof BaseTabs.Panel>, TabsPanelProps>(function TabsPanel({ className, ...props }, ref) {
|
|
47
|
-
return <BaseTabs.Panel ref={ref} className={
|
|
42
|
+
return <BaseTabs.Panel ref={ref} className={(state) => cx(styles.panel, resolveClassName(className, state))} {...props} />;
|
|
48
43
|
});
|
package/src/tabs/tabs.tsx
CHANGED
|
@@ -11,14 +11,21 @@ export interface TabItem {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export interface TabsProps {
|
|
14
|
+
/** Array of tab definitions to render. */
|
|
14
15
|
items: TabItem[];
|
|
16
|
+
/** Currently active tab value (controlled). */
|
|
15
17
|
value?: string;
|
|
18
|
+
/** Initially active tab value (uncontrolled). Defaults to the first item. */
|
|
16
19
|
defaultValue?: string;
|
|
17
|
-
/** `eventDetails` is the base-ui event details object. */
|
|
20
|
+
/** Called when the active tab changes. `eventDetails` is the base-ui event details object. */
|
|
18
21
|
onValueChange?: (value: unknown, eventDetails: unknown) => void;
|
|
19
22
|
className?: string;
|
|
20
23
|
}
|
|
21
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Tab navigation for switching between content panels. Each tab can have
|
|
27
|
+
* an optional icon and can be individually disabled.
|
|
28
|
+
*/
|
|
22
29
|
export function Tabs({ items, className, ...props }: TabsProps) {
|
|
23
30
|
const defaultVal = props.defaultValue ?? items[0]?.value;
|
|
24
31
|
|
package/src/toast/parts.tsx
CHANGED
|
@@ -20,6 +20,7 @@ import { forwardRef } from "react";
|
|
|
20
20
|
import type { ComponentRef, ComponentPropsWithoutRef } from "react";
|
|
21
21
|
import { Toast as BaseToast } from "@base-ui/react/toast";
|
|
22
22
|
import styles from "./toast.module.css";
|
|
23
|
+
import { resolveClassName, cx } from "../utils/resolveClassName";
|
|
23
24
|
|
|
24
25
|
type BaseRootProps = ComponentPropsWithoutRef<typeof BaseToast.Root>;
|
|
25
26
|
type BaseTitleProps = ComponentPropsWithoutRef<typeof BaseToast.Title>;
|
|
@@ -27,50 +28,40 @@ type BaseDescriptionProps = ComponentPropsWithoutRef<typeof BaseToast.Descriptio
|
|
|
27
28
|
type BaseCloseProps = ComponentPropsWithoutRef<typeof BaseToast.Close>;
|
|
28
29
|
type BaseViewportProps = ComponentPropsWithoutRef<typeof BaseToast.Viewport>;
|
|
29
30
|
|
|
30
|
-
export interface ToastRootProps extends
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
export interface
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
export interface ToastDescriptionProps extends Omit<BaseDescriptionProps, "className"> {
|
|
37
|
-
className?: string;
|
|
38
|
-
}
|
|
39
|
-
export interface ToastCloseProps extends Omit<BaseCloseProps, "className"> {
|
|
40
|
-
className?: string;
|
|
41
|
-
}
|
|
42
|
-
export interface ToastViewportPartProps extends Omit<BaseViewportProps, "className"> {
|
|
43
|
-
className?: string;
|
|
44
|
-
}
|
|
31
|
+
export interface ToastRootProps extends BaseRootProps {}
|
|
32
|
+
export interface ToastTitleProps extends BaseTitleProps {}
|
|
33
|
+
export interface ToastDescriptionProps extends BaseDescriptionProps {}
|
|
34
|
+
export interface ToastCloseProps extends BaseCloseProps {}
|
|
35
|
+
export interface ToastViewportPartProps extends BaseViewportProps {}
|
|
45
36
|
|
|
46
37
|
export const ToastRoot = forwardRef<ComponentRef<typeof BaseToast.Root>, ToastRootProps>(function ToastRoot({ className, ...props }, ref) {
|
|
47
|
-
return <BaseToast.Root ref={ref} className={
|
|
38
|
+
return <BaseToast.Root ref={ref} className={(state) => cx(styles.toast, resolveClassName(className, state))} {...props} />;
|
|
48
39
|
});
|
|
49
40
|
|
|
50
41
|
export const ToastTitle = forwardRef<ComponentRef<typeof BaseToast.Title>, ToastTitleProps>(function ToastTitle(
|
|
51
42
|
{ className, ...props },
|
|
52
43
|
ref,
|
|
53
44
|
) {
|
|
54
|
-
return <BaseToast.Title ref={ref} className={
|
|
45
|
+
return <BaseToast.Title ref={ref} className={(state) => cx(styles.title, resolveClassName(className, state))} {...props} />;
|
|
55
46
|
});
|
|
56
47
|
|
|
57
48
|
export const ToastDescription = forwardRef<ComponentRef<typeof BaseToast.Description>, ToastDescriptionProps>(function ToastDescription(
|
|
58
49
|
{ className, ...props },
|
|
59
50
|
ref,
|
|
60
51
|
) {
|
|
61
|
-
return <BaseToast.Description ref={ref} className={
|
|
52
|
+
return <BaseToast.Description ref={ref} className={(state) => cx(styles.description, resolveClassName(className, state))} {...props} />;
|
|
62
53
|
});
|
|
63
54
|
|
|
64
55
|
export const ToastClose = forwardRef<ComponentRef<typeof BaseToast.Close>, ToastCloseProps>(function ToastClose(
|
|
65
56
|
{ className, ...props },
|
|
66
57
|
ref,
|
|
67
58
|
) {
|
|
68
|
-
return <BaseToast.Close ref={ref} className={
|
|
59
|
+
return <BaseToast.Close ref={ref} className={(state) => cx(styles.close, resolveClassName(className, state))} {...props} />;
|
|
69
60
|
});
|
|
70
61
|
|
|
71
62
|
export const ToastViewportPart = forwardRef<ComponentRef<typeof BaseToast.Viewport>, ToastViewportPartProps>(function ToastViewportPart(
|
|
72
63
|
{ className, ...props },
|
|
73
64
|
ref,
|
|
74
65
|
) {
|
|
75
|
-
return <BaseToast.Viewport ref={ref} className={
|
|
66
|
+
return <BaseToast.Viewport ref={ref} className={(state) => cx(styles.viewport, resolveClassName(className, state))} {...props} />;
|
|
76
67
|
});
|
package/src/toast/toast.tsx
CHANGED
|
@@ -77,8 +77,11 @@ const DEFAULT_LIMIT: Record<NonNullable<ToastViewportProps["variant"]>, number>
|
|
|
77
77
|
|
|
78
78
|
export interface ToastProviderProps {
|
|
79
79
|
children: ReactNode;
|
|
80
|
+
/** Layout style for the viewport. @default "list" */
|
|
80
81
|
variant?: ToastViewportProps["variant"];
|
|
82
|
+
/** Maximum number of toasts shown at once. */
|
|
81
83
|
limit?: number;
|
|
84
|
+
/** Auto-dismiss delay in milliseconds. */
|
|
82
85
|
timeout?: number;
|
|
83
86
|
}
|
|
84
87
|
|
|
@@ -91,6 +94,10 @@ const MAX_LIMIT: Record<NonNullable<ToastViewportProps["variant"]>, number> = {
|
|
|
91
94
|
list: 5,
|
|
92
95
|
};
|
|
93
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Drop-in provider that wires limit defaults to the chosen viewport variant.
|
|
99
|
+
* Use this instead of base-ui's `Toast.Provider` when using `ToastViewport`.
|
|
100
|
+
*/
|
|
94
101
|
export function ToastProvider({ children, variant = "list", limit, timeout }: ToastProviderProps) {
|
|
95
102
|
const resolvedLimit = Math.min(limit ?? DEFAULT_LIMIT[variant], MAX_LIMIT[variant]);
|
|
96
103
|
return (
|
|
@@ -100,6 +107,10 @@ export function ToastProvider({ children, variant = "list", limit, timeout }: To
|
|
|
100
107
|
);
|
|
101
108
|
}
|
|
102
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Renders and manages toast notifications. Supports `"stacked"` (Sonner-style
|
|
112
|
+
* fanned cards) and `"list"` (vertically stacked, each fully visible) layouts.
|
|
113
|
+
*/
|
|
103
114
|
export function ToastViewport({ variant = "list", limit: _limit }: ToastViewportProps) {
|
|
104
115
|
const manager = useToastManager();
|
|
105
116
|
const isStacked = variant === "stacked";
|
package/src/tooltip/parts.tsx
CHANGED
|
@@ -25,38 +25,33 @@ import { forwardRef } from "react";
|
|
|
25
25
|
import type { ComponentRef, ComponentPropsWithoutRef } from "react";
|
|
26
26
|
import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
|
|
27
27
|
import styles from "./tooltip.module.css";
|
|
28
|
+
import { resolveClassName, cx } from "../utils/resolveClassName";
|
|
28
29
|
|
|
29
30
|
type BasePositionerProps = ComponentPropsWithoutRef<typeof BaseTooltip.Positioner>;
|
|
30
31
|
type BasePopupProps = ComponentPropsWithoutRef<typeof BaseTooltip.Popup>;
|
|
31
32
|
type BaseArrowProps = ComponentPropsWithoutRef<typeof BaseTooltip.Arrow>;
|
|
32
33
|
|
|
33
|
-
export interface TooltipPositionerProps extends
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
export interface TooltipPopupProps extends Omit<BasePopupProps, "className"> {
|
|
37
|
-
className?: string;
|
|
38
|
-
}
|
|
39
|
-
export interface TooltipArrowProps extends Omit<BaseArrowProps, "className"> {
|
|
40
|
-
className?: string;
|
|
41
|
-
}
|
|
34
|
+
export interface TooltipPositionerProps extends BasePositionerProps {}
|
|
35
|
+
export interface TooltipPopupProps extends BasePopupProps {}
|
|
36
|
+
export interface TooltipArrowProps extends BaseArrowProps {}
|
|
42
37
|
|
|
43
38
|
export const TooltipPositioner = forwardRef<ComponentRef<typeof BaseTooltip.Positioner>, TooltipPositionerProps>(function TooltipPositioner(
|
|
44
39
|
{ className, ...props },
|
|
45
40
|
ref,
|
|
46
41
|
) {
|
|
47
|
-
return <BaseTooltip.Positioner ref={ref} className={
|
|
42
|
+
return <BaseTooltip.Positioner ref={ref} className={(state) => cx(styles.positioner, resolveClassName(className, state))} {...props} />;
|
|
48
43
|
});
|
|
49
44
|
|
|
50
45
|
export const TooltipPopup = forwardRef<ComponentRef<typeof BaseTooltip.Popup>, TooltipPopupProps>(function TooltipPopup(
|
|
51
46
|
{ className, ...props },
|
|
52
47
|
ref,
|
|
53
48
|
) {
|
|
54
|
-
return <BaseTooltip.Popup ref={ref} className={
|
|
49
|
+
return <BaseTooltip.Popup ref={ref} className={(state) => cx(styles.popup, resolveClassName(className, state))} {...props} />;
|
|
55
50
|
});
|
|
56
51
|
|
|
57
52
|
export const TooltipArrow = forwardRef<ComponentRef<typeof BaseTooltip.Arrow>, TooltipArrowProps>(function TooltipArrow(
|
|
58
53
|
{ className, ...props },
|
|
59
54
|
ref,
|
|
60
55
|
) {
|
|
61
|
-
return <BaseTooltip.Arrow ref={ref} className={
|
|
56
|
+
return <BaseTooltip.Arrow ref={ref} className={(state) => cx(styles.arrow, resolveClassName(className, state))} {...props} />;
|
|
62
57
|
});
|
package/src/tooltip/tooltip.tsx
CHANGED
|
@@ -3,13 +3,22 @@ import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
|
|
|
3
3
|
import styles from "./tooltip.module.css";
|
|
4
4
|
|
|
5
5
|
export interface TooltipProps {
|
|
6
|
+
/** Text or rich content shown inside the tooltip popup. */
|
|
6
7
|
content: ReactNode;
|
|
8
|
+
/** The element that triggers the tooltip on hover/focus. */
|
|
7
9
|
children: ReactElement;
|
|
10
|
+
/** Hover delay in milliseconds before the tooltip appears. @default 400 */
|
|
8
11
|
delay?: number;
|
|
12
|
+
/** Which side of the trigger the tooltip appears on. @default "top" */
|
|
9
13
|
side?: "top" | "bottom" | "left" | "right";
|
|
14
|
+
/** Alignment along the side axis. @default "center" */
|
|
10
15
|
align?: "start" | "center" | "end";
|
|
11
16
|
}
|
|
12
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Accessible popup shown on hover or focus. Automatically positions itself
|
|
20
|
+
* with an arrow and supports configurable delay, side, and alignment.
|
|
21
|
+
*/
|
|
13
22
|
export function Tooltip({ content, children, delay = 400, side = "top", align = "center" }: TooltipProps) {
|
|
14
23
|
return (
|
|
15
24
|
<BaseTooltip.Provider delay={delay}>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a base-ui className prop (string | function | undefined) into a string.
|
|
3
|
+
* When the className is a function, it is called with the component state.
|
|
4
|
+
* Used by styled parts to merge our fixed style class with the consumer's className.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* // In a styled part, prepend our class while preserving function className support:
|
|
9
|
+
* className={(state) => cx(styles.root, resolveClassName(className, state))}
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export function resolveClassName<State>(
|
|
13
|
+
className: string | ((state: State) => string | undefined) | undefined,
|
|
14
|
+
state: State,
|
|
15
|
+
): string | undefined {
|
|
16
|
+
return typeof className === "function" ? className(state) : className;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Joins class name strings, filtering out falsy values.
|
|
21
|
+
*/
|
|
22
|
+
export function cx(...classes: (string | undefined | null | false)[]): string {
|
|
23
|
+
return classes.filter(Boolean).join(" ");
|
|
24
|
+
}
|