@vuer-ai/vuer-uikit 0.0.96 → 0.0.98
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 +106 -7
- package/cli/dial-cli.js +49 -7
- package/dist/SyncScroll/SyncScroll.cjs +10 -10
- package/dist/SyncScroll/SyncScroll.mjs +3 -3
- package/dist/SyncScroll/index.cjs +10 -10
- package/dist/SyncScroll/index.mjs +3 -3
- package/dist/chunk-3HEZVWRW.mjs +62 -0
- package/dist/chunk-4KWGGESI.cjs +494 -0
- package/dist/{chunk-CCMKL2OA.cjs → chunk-7GWDO25E.cjs} +2 -2
- package/dist/chunk-A5LCX2UQ.cjs +208 -0
- package/dist/chunk-BEJIZ56L.mjs +300 -0
- package/dist/chunk-C7VGRU3O.mjs +283 -0
- package/dist/{chunk-LONOMMFA.cjs → chunk-LJMNHTTG.cjs} +21 -21
- package/dist/chunk-O66RESRR.cjs +285 -0
- package/dist/{chunk-RINTUFYQ.cjs → chunk-RMK6W774.cjs} +24 -19
- package/dist/{chunk-BFQ2WL5U.mjs → chunk-TTYSYGVE.mjs} +2 -2
- package/dist/chunk-VA3PEYFM.mjs +489 -0
- package/dist/chunk-VBBJSIY7.cjs +308 -0
- package/dist/{chunk-AIINOWEH.mjs → chunk-W4JCKCW7.mjs} +5 -5
- package/dist/chunk-WWGF6TBZ.mjs +206 -0
- package/dist/chunk-ZGN4UEJR.cjs +679 -0
- package/dist/chunk-ZQLRMOUW.mjs +661 -0
- package/dist/dial/DialPanel.cjs +24 -24
- package/dist/dial/DialPanel.mjs +23 -23
- package/dist/dial/DialProvider.cjs +3 -3
- package/dist/dial/DialProvider.d.cts +1 -0
- package/dist/dial/DialProvider.d.ts +1 -0
- package/dist/dial/DialProvider.example.cjs +72 -0
- package/dist/dial/DialProvider.example.d.cts +7 -0
- package/dist/dial/DialProvider.example.d.ts +7 -0
- package/dist/dial/DialProvider.example.mjs +68 -0
- package/dist/dial/DialProvider.mjs +1 -1
- package/dist/dial/index.cjs +42 -42
- package/dist/dial/index.mjs +23 -23
- package/dist/dial/wrapped-inputs/ControlledInputs.cjs +27 -27
- package/dist/dial/wrapped-inputs/ControlledInputs.mjs +23 -23
- package/dist/dial/wrapped-inputs/DialInputs.cjs +34 -34
- package/dist/dial/wrapped-inputs/DialInputs.mjs +23 -23
- package/dist/dial/wrapped-inputs/DialVectorInput.cjs +24 -24
- package/dist/dial/wrapped-inputs/DialVectorInput.mjs +23 -23
- package/dist/dial/wrapped-inputs/index.cjs +39 -39
- package/dist/dial/wrapped-inputs/index.mjs +23 -23
- package/dist/highlight-cursor/cursor-provider.cjs +3 -3
- package/dist/highlight-cursor/cursor-provider.mjs +2 -2
- package/dist/highlight-cursor/enhanced-components.cjs +10 -10
- package/dist/highlight-cursor/enhanced-components.mjs +5 -5
- package/dist/highlight-cursor/index.cjs +16 -16
- package/dist/highlight-cursor/index.mjs +6 -6
- package/dist/hooks/index.cjs +5 -5
- package/dist/hooks/index.mjs +1 -1
- package/dist/index.cjs +190 -190
- package/dist/index.mjs +23 -23
- package/dist/ui/UIKitBadge.cjs +6 -6
- package/dist/ui/UIKitBadge.mjs +2 -2
- package/dist/ui/avatar.cjs +1 -1
- package/dist/ui/avatar.mjs +1 -1
- package/dist/ui/badge.cjs +1 -1
- package/dist/ui/badge.d.cts +1 -1
- package/dist/ui/badge.d.ts +1 -1
- package/dist/ui/badge.mjs +1 -1
- package/dist/ui/button.cjs +1 -1
- package/dist/ui/button.mjs +1 -1
- package/dist/ui/card.cjs +1 -1
- package/dist/ui/card.mjs +1 -1
- package/dist/ui/checkbox.cjs +1 -1
- package/dist/ui/checkbox.mjs +1 -1
- package/dist/ui/collapsible.cjs +1 -1
- package/dist/ui/collapsible.mjs +1 -1
- package/dist/ui/drawer.cjs +1 -1
- package/dist/ui/drawer.mjs +1 -1
- package/dist/ui/dropdown.cjs +1 -1
- package/dist/ui/dropdown.mjs +1 -1
- package/dist/ui/index.cjs +107 -107
- package/dist/ui/index.mjs +17 -17
- package/dist/ui/inputs/color-input.cjs +1 -1
- package/dist/ui/inputs/color-input.mjs +1 -1
- package/dist/ui/inputs/index.cjs +11 -11
- package/dist/ui/inputs/index.mjs +3 -3
- package/dist/ui/inputs/input-numbers.cjs +1 -1
- package/dist/ui/inputs/input-numbers.mjs +1 -1
- package/dist/ui/inputs/input.cjs +1 -1
- package/dist/ui/inputs/input.d.cts +1 -1
- package/dist/ui/inputs/input.d.ts +1 -1
- package/dist/ui/inputs/input.mjs +1 -1
- package/dist/ui/inputs/number-inputs/CmInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/CmInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/DegInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/DegInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerDegInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerDegInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerRadInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerRadInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/InchInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/InchInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/IntInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/IntInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/KVectorInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/KVectorInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/QuaternionInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/QuaternionInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/RadInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/RadInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/TimeInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/TimeInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/Vec3Input.cjs +1 -1
- package/dist/ui/inputs/number-inputs/Vec3Input.mjs +1 -1
- package/dist/ui/inputs/number-inputs/VectorInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/VectorInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/index.cjs +11 -11
- package/dist/ui/inputs/number-inputs/index.mjs +3 -3
- package/dist/ui/inputs/presets-input.cjs +1 -1
- package/dist/ui/inputs/presets-input.mjs +1 -1
- package/dist/ui/label.cjs +1 -1
- package/dist/ui/label.mjs +1 -1
- package/dist/ui/layout.cjs +1 -1
- package/dist/ui/layout.mjs +1 -1
- package/dist/ui/layouts/dock-layout/DockLayoutView.cjs +1 -1
- package/dist/ui/layouts/dock-layout/DockLayoutView.mjs +1 -1
- package/dist/ui/layouts/dock-layout/LayoutSlots.cjs +1 -1
- package/dist/ui/layouts/dock-layout/LayoutSlots.mjs +1 -1
- package/dist/ui/layouts/dock-layout/index.cjs +1 -1
- package/dist/ui/layouts/dock-layout/index.mjs +1 -1
- package/dist/ui/layouts/index.cjs +2 -2
- package/dist/ui/layouts/index.mjs +2 -2
- package/dist/ui/layouts/liquid-layout/LayoutSlots.cjs +1 -1
- package/dist/ui/layouts/liquid-layout/LayoutSlots.mjs +1 -1
- package/dist/ui/layouts/liquid-layout/LiquidLayoutView.cjs +1 -1
- package/dist/ui/layouts/liquid-layout/LiquidLayoutView.mjs +1 -1
- package/dist/ui/layouts/liquid-layout/index.cjs +1 -1
- package/dist/ui/layouts/liquid-layout/index.mjs +1 -1
- package/dist/ui/modal.cjs +1 -1
- package/dist/ui/modal.mjs +1 -1
- package/dist/ui/navigation.cjs +1 -1
- package/dist/ui/navigation.mjs +1 -1
- package/dist/ui/pagination.cjs +1 -1
- package/dist/ui/pagination.mjs +1 -1
- package/dist/ui/panel.cjs +1 -1
- package/dist/ui/panel.mjs +1 -1
- package/dist/ui/popover.cjs +1 -1
- package/dist/ui/popover.mjs +1 -1
- package/dist/ui/radio-group.cjs +1 -1
- package/dist/ui/radio-group.mjs +1 -1
- package/dist/ui/resizable.cjs +1 -1
- package/dist/ui/resizable.mjs +1 -1
- package/dist/ui/select.cjs +1 -1
- package/dist/ui/select.d.cts +1 -1
- package/dist/ui/select.d.ts +1 -1
- package/dist/ui/select.mjs +1 -1
- package/dist/ui/separator.cjs +1 -1
- package/dist/ui/separator.mjs +1 -1
- package/dist/ui/sheet.cjs +1 -1
- package/dist/ui/sheet.mjs +1 -1
- package/dist/ui/sidebar.cjs +26 -26
- package/dist/ui/sidebar.mjs +2 -2
- package/dist/ui/simple-tree-view.cjs +1 -1
- package/dist/ui/simple-tree-view.mjs +1 -1
- package/dist/ui/skeleton.cjs +1 -1
- package/dist/ui/skeleton.mjs +1 -1
- package/dist/ui/slider.cjs +1 -1
- package/dist/ui/slider.mjs +1 -1
- package/dist/ui/switch.cjs +1 -1
- package/dist/ui/switch.mjs +1 -1
- package/dist/ui/table.cjs +1 -1
- package/dist/ui/table.mjs +1 -1
- package/dist/ui/tabs.cjs +1 -1
- package/dist/ui/tabs.mjs +1 -1
- package/dist/ui/textarea.cjs +1 -1
- package/dist/ui/textarea.d.cts +1 -1
- package/dist/ui/textarea.d.ts +1 -1
- package/dist/ui/textarea.mjs +1 -1
- package/dist/ui/theme/ThemeToggles.cjs +1 -1
- package/dist/ui/theme/ThemeToggles.mjs +1 -1
- package/dist/ui/theme/index.cjs +1 -1
- package/dist/ui/theme/index.mjs +1 -1
- package/dist/ui/toggle-buttons.cjs +1 -1
- package/dist/ui/toggle-buttons.mjs +1 -1
- package/dist/ui/toggle-group.cjs +1 -1
- package/dist/ui/toggle-group.mjs +1 -1
- package/dist/ui/toggle.cjs +1 -1
- package/dist/ui/toggle.mjs +1 -1
- package/dist/ui/toolbar.cjs +1 -1
- package/dist/ui/toolbar.mjs +1 -1
- package/dist/ui/tooltip.cjs +1 -1
- package/dist/ui/tooltip.mjs +1 -1
- package/dist/ui/tree-view/TreeSearchBar.cjs +1 -1
- package/dist/ui/tree-view/TreeSearchBar.mjs +1 -1
- package/dist/ui/tree-view/TreeView.cjs +1 -1
- package/dist/ui/tree-view/TreeView.mjs +1 -1
- package/dist/ui/tree-view/index.cjs +6 -6
- package/dist/ui/tree-view/index.mjs +2 -2
- package/dist/ui/tree-view-legacy.cjs +9 -9
- package/dist/ui/tree-view-legacy.mjs +5 -5
- package/dist/ui/waterfall/CursorOverlay.cjs +1 -1
- package/dist/ui/waterfall/CursorOverlay.mjs +1 -1
- package/dist/ui/waterfall/TimelineEvent.cjs +1 -1
- package/dist/ui/waterfall/TimelineEvent.mjs +1 -1
- package/dist/ui/waterfall/TimelineProcessBar.cjs +1 -1
- package/dist/ui/waterfall/TimelineProcessBar.mjs +1 -1
- package/dist/ui/waterfall/Wedges.cjs +1 -1
- package/dist/ui/waterfall/Wedges.mjs +1 -1
- package/dist/ui/waterfall/index.cjs +8 -8
- package/dist/ui/waterfall/index.mjs +7 -7
- package/package.json +28 -2
- package/src/SyncScroll/README.md +283 -0
- package/src/SyncScroll/SyncScroll.tsx +361 -0
- package/src/SyncScroll/index.ts +22 -0
- package/src/SyncScroll/useSyncScroll.tsx +226 -0
- package/src/cli/dial-cli.ts +1133 -0
- package/src/dial/DialPanel.tsx +208 -0
- package/src/dial/DialProvider.example.tsx +80 -0
- package/src/dial/DialProvider.tsx +138 -0
- package/src/dial/index.ts +26 -0
- package/src/dial/wrapped-inputs/ControlledInputs.tsx +176 -0
- package/src/dial/wrapped-inputs/DialInputs.tsx +401 -0
- package/src/dial/wrapped-inputs/DialVectorInput.tsx +125 -0
- package/src/dial/wrapped-inputs/index.ts +25 -0
- package/src/highlight-cursor/cursor-context.tsx +23 -0
- package/src/highlight-cursor/cursor-provider.tsx +264 -0
- package/src/highlight-cursor/enhanced-components.tsx +16 -0
- package/src/highlight-cursor/index.ts +21 -0
- package/src/highlight-cursor/tabs-cursor-context.tsx +121 -0
- package/src/highlight-cursor/types.ts +40 -0
- package/src/highlight-cursor/with-cursor.tsx +144 -0
- package/src/hooks/clientOnly.tsx +54 -0
- package/src/hooks/cn.ts +33 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/useDocument.tsx +18 -0
- package/src/hooks/useDragSelect.ts +116 -0
- package/src/hooks/useIsMobile.ts +35 -0
- package/src/hooks/useLocalStorage.ts +122 -0
- package/src/hooks/useLocation.tsx +95 -0
- package/src/hooks/useQueryParams.tsx +31 -0
- package/src/hooks/useWindow.tsx +18 -0
- package/src/index.css +5 -0
- package/src/index.ts +5 -0
- package/src/styles/.editorconfig +0 -0
- package/src/styles/theme.css +152 -0
- package/src/styles/toast.css +67 -0
- package/src/styles/variables.css +229 -0
- package/src/ui/UIKitBadge.tsx +171 -0
- package/src/ui/avatar.tsx +221 -0
- package/src/ui/badge.tsx +74 -0
- package/src/ui/button.tsx +143 -0
- package/src/ui/card.tsx +146 -0
- package/src/ui/checkbox.tsx +78 -0
- package/src/ui/collapsible.tsx +43 -0
- package/src/ui/drag-selectable/DragSelectProvider.tsx +178 -0
- package/src/ui/drag-selectable/createSelectable.tsx +43 -0
- package/src/ui/drag-selectable/index.ts +2 -0
- package/src/ui/drawer.tsx +137 -0
- package/src/ui/dropdown.tsx +707 -0
- package/src/ui/icons/MouseCursorIcons.tsx +39 -0
- package/src/ui/icons/cursor.tsx +38 -0
- package/src/ui/icons/index.ts +2 -0
- package/src/ui/index.ts +45 -0
- package/src/ui/inputs/color-input.tsx +61 -0
- package/src/ui/inputs/index.tsx +5 -0
- package/src/ui/inputs/input-numbers.tsx +394 -0
- package/src/ui/inputs/input.tsx +155 -0
- package/src/ui/inputs/number-inputs/CmInput.tsx +26 -0
- package/src/ui/inputs/number-inputs/DegInput.tsx +26 -0
- package/src/ui/inputs/number-inputs/EulerDegInput.tsx +14 -0
- package/src/ui/inputs/number-inputs/EulerInput.tsx +30 -0
- package/src/ui/inputs/number-inputs/EulerRadInput.tsx +14 -0
- package/src/ui/inputs/number-inputs/InchInput.tsx +26 -0
- package/src/ui/inputs/number-inputs/IntInput.tsx +46 -0
- package/src/ui/inputs/number-inputs/KVectorInput.tsx +20 -0
- package/src/ui/inputs/number-inputs/QuaternionInput.tsx +27 -0
- package/src/ui/inputs/number-inputs/RadInput.tsx +26 -0
- package/src/ui/inputs/number-inputs/TimeInput.tsx +26 -0
- package/src/ui/inputs/number-inputs/Vec3Input.tsx +26 -0
- package/src/ui/inputs/number-inputs/VectorInput.tsx +38 -0
- package/src/ui/inputs/number-inputs/index.ts +38 -0
- package/src/ui/inputs/presets-input.tsx +59 -0
- package/src/ui/label.tsx +35 -0
- package/src/ui/layout.tsx +43 -0
- package/src/ui/layouts/dock-layout/DockLayoutView.tsx +128 -0
- package/src/ui/layouts/dock-layout/LayoutSlots.tsx +85 -0
- package/src/ui/layouts/dock-layout/index.tsx +2 -0
- package/src/ui/layouts/index.ts +2 -0
- package/src/ui/layouts/liquid-layout/LayoutSlots.tsx +82 -0
- package/src/ui/layouts/liquid-layout/LiquidLayoutView.tsx +76 -0
- package/src/ui/layouts/liquid-layout/index.ts +1 -0
- package/src/ui/modal.tsx +211 -0
- package/src/ui/navigation.tsx +86 -0
- package/src/ui/pagination.tsx +129 -0
- package/src/ui/panel.tsx +146 -0
- package/src/ui/popover.tsx +112 -0
- package/src/ui/radio-group.tsx +63 -0
- package/src/ui/resizable.tsx +52 -0
- package/src/ui/select.tsx +365 -0
- package/src/ui/separator.tsx +26 -0
- package/src/ui/sheet.tsx +257 -0
- package/src/ui/sidebar.tsx +695 -0
- package/src/ui/simple-tree-view.tsx +604 -0
- package/src/ui/skeleton.tsx +15 -0
- package/src/ui/slider.tsx +204 -0
- package/src/ui/switch.tsx +45 -0
- package/src/ui/table.tsx +99 -0
- package/src/ui/tabs.tsx +192 -0
- package/src/ui/textarea.tsx +55 -0
- package/src/ui/theme/ThemeProvider.tsx +319 -0
- package/src/ui/theme/ThemeToggles.tsx +84 -0
- package/src/ui/theme/index.ts +21 -0
- package/src/ui/theme/themeScript.tsx +179 -0
- package/src/ui/theme/types.ts +61 -0
- package/src/ui/toast.tsx +30 -0
- package/src/ui/toggle-buttons.tsx +290 -0
- package/src/ui/toggle-group.tsx +236 -0
- package/src/ui/toggle.tsx +94 -0
- package/src/ui/toolbar.tsx +54 -0
- package/src/ui/tooltip.tsx +171 -0
- package/src/ui/tree-view/TreeSearchBar.tsx +88 -0
- package/src/ui/tree-view/TreeView.tsx +232 -0
- package/src/ui/tree-view/hooks.tsx +289 -0
- package/src/ui/tree-view/index.ts +4 -0
- package/src/ui/tree-view/types.ts +23 -0
- package/src/ui/tree-view-legacy.tsx +644 -0
- package/src/ui/version-badge.tsx +0 -0
- package/src/ui/waterfall/CursorOverlay.tsx +96 -0
- package/src/ui/waterfall/NavigationControls.tsx +42 -0
- package/src/ui/waterfall/Tick.tsx +51 -0
- package/src/ui/waterfall/TimeRuleEventDot.tsx +19 -0
- package/src/ui/waterfall/TimelineEvent.tsx +60 -0
- package/src/ui/waterfall/TimelineProcessBar.tsx +207 -0
- package/src/ui/waterfall/Wedges.tsx +67 -0
- package/src/ui/waterfall/WheelZoomContext.tsx +128 -0
- package/src/ui/waterfall/hooks/useTimelineState.tsx +134 -0
- package/src/ui/waterfall/hooks/useViewport.tsx +293 -0
- package/src/ui/waterfall/index.tsx +326 -0
- package/src/ui/waterfall/types.ts +20 -0
- package/src/ui/waterfall/utils.ts +91 -0
- package/dist/chunk-W2YAQV5N.mjs +0 -57
- package/dist/{chunk-QLCEHV4Q.mjs → chunk-2OZK5DY5.mjs} +2 -2
- package/dist/{chunk-Z35DNFRZ.cjs → chunk-7IS37C3P.cjs} +2 -2
- package/dist/{chunk-4AOAH77D.mjs → chunk-A2PCEL5S.mjs} +2 -2
- package/dist/{chunk-K4VD5PPY.mjs → chunk-BIUDC66P.mjs} +1 -1
- package/dist/{chunk-RKJR6RZU.cjs → chunk-OYNLQTHW.cjs} +1 -1
- package/dist/{chunk-VE3XLQLO.cjs → chunk-QUFZWF4E.cjs} +2 -2
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../hooks";
|
|
6
|
+
|
|
7
|
+
export const toggleButtonsVariants = cva(
|
|
8
|
+
["rounded-uk-md", "relative", "inline-flex", "items-center"],
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
primary: "bg-bg-secondary",
|
|
13
|
+
secondary: "bg-bg-secondary",
|
|
14
|
+
ghost: "bg-transparent",
|
|
15
|
+
},
|
|
16
|
+
padding: {
|
|
17
|
+
true: "p-xs",
|
|
18
|
+
false: "p-0",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
variant: "primary",
|
|
23
|
+
padding: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const toggleButtonHighlightVariants = cva(
|
|
29
|
+
["pointer-events-none", "absolute", "transition-all", "duration-200", "ease-out"],
|
|
30
|
+
{
|
|
31
|
+
variants: {
|
|
32
|
+
variant: {
|
|
33
|
+
primary: ["bg-brand-primary", "shadow-sm", "rounded-uk-sm"],
|
|
34
|
+
secondary: ["bg-bg-primary", "shadow-sm", "rounded-uk-sm"],
|
|
35
|
+
ghost: ["bg-bg-secondary", "shadow-sm", "rounded-uk-md"],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
defaultVariants: {
|
|
39
|
+
variant: "primary",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export const toggleButtonVariants = cva(
|
|
45
|
+
[
|
|
46
|
+
"focus-visible:ring-ring",
|
|
47
|
+
"relative",
|
|
48
|
+
"z-10",
|
|
49
|
+
"inline-flex",
|
|
50
|
+
"items-center",
|
|
51
|
+
"justify-center",
|
|
52
|
+
"font-normal",
|
|
53
|
+
"whitespace-nowrap",
|
|
54
|
+
"transition-colors",
|
|
55
|
+
"focus-visible:ring-2",
|
|
56
|
+
"focus-visible:outline-none",
|
|
57
|
+
"disabled:pointer-events-none",
|
|
58
|
+
"disabled:opacity-50",
|
|
59
|
+
"cursor-pointer",
|
|
60
|
+
],
|
|
61
|
+
{
|
|
62
|
+
variants: {
|
|
63
|
+
variant: {
|
|
64
|
+
primary: [
|
|
65
|
+
"text-text-primary",
|
|
66
|
+
"hover:text-text-primary",
|
|
67
|
+
"active:text-brand-primary",
|
|
68
|
+
"data-[selected=true]:text-text-withbg",
|
|
69
|
+
],
|
|
70
|
+
secondary: [
|
|
71
|
+
"text-text-primary",
|
|
72
|
+
"hover:text-text-secondary",
|
|
73
|
+
"active:text-brand-primary",
|
|
74
|
+
"data-[selected=true]:text-text-highlight",
|
|
75
|
+
"data-[selected=true]:bg-bg-primary",
|
|
76
|
+
],
|
|
77
|
+
ghost: [
|
|
78
|
+
"text-text-tertiary",
|
|
79
|
+
"hover:text-text-secondary",
|
|
80
|
+
"active:text-brand-primary",
|
|
81
|
+
"data-[selected=true]:text-text-highlight",
|
|
82
|
+
"data-[selected=true]:bg-bg-secondary",
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
size: {
|
|
86
|
+
sm: "text-uk-sm gap-xxs",
|
|
87
|
+
md: "text-uk-md gap-xs",
|
|
88
|
+
lg: "text-uk-lg gap-xs",
|
|
89
|
+
},
|
|
90
|
+
icon: {
|
|
91
|
+
false: "",
|
|
92
|
+
true: "shrink-0 [&_svg]:shrink-0 [&_svg]:pointer-events-none",
|
|
93
|
+
},
|
|
94
|
+
corner: {
|
|
95
|
+
sm: "rounded-uk-sm",
|
|
96
|
+
md: "rounded-uk-md",
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
compoundVariants: [
|
|
100
|
+
// Icon button sizes
|
|
101
|
+
{ size: "sm", icon: false, class: "h-6 px-md" },
|
|
102
|
+
{ size: "md", icon: false, class: "h-7 px-lg" },
|
|
103
|
+
{ size: "lg", icon: false, class: "h-8 px-xl" },
|
|
104
|
+
{ size: "sm", icon: true, class: "size-6 p-xs" },
|
|
105
|
+
{ size: "md", icon: true, class: "size-8 p-sm" },
|
|
106
|
+
{ size: "lg", icon: true, class: "size-9 p-md" },
|
|
107
|
+
],
|
|
108
|
+
defaultVariants: {
|
|
109
|
+
variant: "primary",
|
|
110
|
+
size: "md",
|
|
111
|
+
icon: false,
|
|
112
|
+
corner: "sm",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
interface ToggleButtonsContextValue
|
|
118
|
+
extends Pick<VariantProps<typeof toggleButtonVariants>, "variant" | "size"> {
|
|
119
|
+
value: string;
|
|
120
|
+
onValueChange: (value: string) => void;
|
|
121
|
+
registerItem: (value: string, element: HTMLElement) => void;
|
|
122
|
+
unregisterItem: (value: string) => void;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const ToggleButtonsContext = React.createContext<ToggleButtonsContextValue | null>(null);
|
|
126
|
+
|
|
127
|
+
interface ToggleButtonsProps
|
|
128
|
+
extends React.ComponentProps<"div">,
|
|
129
|
+
VariantProps<typeof toggleButtonsVariants> {
|
|
130
|
+
value: string;
|
|
131
|
+
onValueChange: (value: string) => void;
|
|
132
|
+
children: React.ReactNode;
|
|
133
|
+
size?: "sm" | "md" | "lg";
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const ToggleButtons = React.forwardRef<HTMLDivElement, ToggleButtonsProps>(
|
|
137
|
+
(
|
|
138
|
+
{
|
|
139
|
+
value,
|
|
140
|
+
onValueChange,
|
|
141
|
+
children,
|
|
142
|
+
className,
|
|
143
|
+
size = "md",
|
|
144
|
+
padding = true,
|
|
145
|
+
variant = "primary",
|
|
146
|
+
...props
|
|
147
|
+
},
|
|
148
|
+
ref,
|
|
149
|
+
) => {
|
|
150
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
151
|
+
const [items, setItems] = React.useState<Map<string, HTMLElement>>(new Map());
|
|
152
|
+
const [highlightStyle, setHighlightStyle] = React.useState<React.CSSProperties>({
|
|
153
|
+
opacity: 0,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const registerItem = React.useCallback((itemValue: string, element: HTMLElement) => {
|
|
157
|
+
setItems((prev) => new Map(prev).set(itemValue, element));
|
|
158
|
+
}, []);
|
|
159
|
+
|
|
160
|
+
const unregisterItem = React.useCallback((itemValue: string) => {
|
|
161
|
+
setItems((prev) => {
|
|
162
|
+
const newMap = new Map(prev);
|
|
163
|
+
newMap.delete(itemValue);
|
|
164
|
+
return newMap;
|
|
165
|
+
});
|
|
166
|
+
}, []);
|
|
167
|
+
|
|
168
|
+
React.useEffect(() => {
|
|
169
|
+
const selectedElement = items.get(value);
|
|
170
|
+
const container = containerRef.current;
|
|
171
|
+
|
|
172
|
+
if (selectedElement && container) {
|
|
173
|
+
// Use requestAnimationFrame to ensure DOM has settled after state changes
|
|
174
|
+
const rafId = requestAnimationFrame(() => {
|
|
175
|
+
const containerRect = container.getBoundingClientRect();
|
|
176
|
+
const selectedRect = selectedElement.getBoundingClientRect();
|
|
177
|
+
|
|
178
|
+
// Calculate position relative to container
|
|
179
|
+
const paddingOffset = padding ? 4 : 0;
|
|
180
|
+
const left = selectedRect.left - containerRect.left - paddingOffset;
|
|
181
|
+
const top = selectedRect.top - containerRect.top - paddingOffset;
|
|
182
|
+
|
|
183
|
+
setHighlightStyle({
|
|
184
|
+
width: selectedRect.width,
|
|
185
|
+
height: selectedRect.height,
|
|
186
|
+
transform: `translate(${left}px, ${top}px)`,
|
|
187
|
+
opacity: 1,
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
return () => cancelAnimationFrame(rafId);
|
|
192
|
+
} else {
|
|
193
|
+
setHighlightStyle((prev) => ({ ...prev, opacity: 0 }));
|
|
194
|
+
}
|
|
195
|
+
}, [value, items, padding]);
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<ToggleButtonsContext.Provider
|
|
199
|
+
value={{ value, onValueChange, size, variant, registerItem, unregisterItem }}
|
|
200
|
+
>
|
|
201
|
+
<div
|
|
202
|
+
ref={(node) => {
|
|
203
|
+
containerRef.current = node;
|
|
204
|
+
if (typeof ref === "function") ref(node);
|
|
205
|
+
else if (ref) ref.current = node;
|
|
206
|
+
}}
|
|
207
|
+
className={cn(toggleButtonsVariants({ variant, padding }), className)}
|
|
208
|
+
{...props}
|
|
209
|
+
>
|
|
210
|
+
<div className={cn(toggleButtonHighlightVariants({ variant }))} style={highlightStyle} />
|
|
211
|
+
{children}
|
|
212
|
+
</div>
|
|
213
|
+
</ToggleButtonsContext.Provider>
|
|
214
|
+
);
|
|
215
|
+
},
|
|
216
|
+
);
|
|
217
|
+
ToggleButtons.displayName = "ToggleButtons";
|
|
218
|
+
|
|
219
|
+
interface ToggleButtonProps
|
|
220
|
+
extends React.ComponentProps<"button">,
|
|
221
|
+
VariantProps<typeof toggleButtonVariants> {
|
|
222
|
+
value: string;
|
|
223
|
+
children: React.ReactNode;
|
|
224
|
+
asChild?: boolean;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const ToggleButton = React.forwardRef<HTMLButtonElement, ToggleButtonProps>(
|
|
228
|
+
(
|
|
229
|
+
{ value, children, className, asChild = false, icon = false, size, variant, corner, ...props },
|
|
230
|
+
ref,
|
|
231
|
+
) => {
|
|
232
|
+
const context = React.useContext(ToggleButtonsContext);
|
|
233
|
+
const itemRef = React.useRef<HTMLElement>(null);
|
|
234
|
+
|
|
235
|
+
if (!context) {
|
|
236
|
+
throw new Error("ToggleButton must be used within ToggleButtons");
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const {
|
|
240
|
+
value: selectedValue,
|
|
241
|
+
onValueChange,
|
|
242
|
+
size: contextSize,
|
|
243
|
+
variant: contextVariant,
|
|
244
|
+
registerItem,
|
|
245
|
+
unregisterItem,
|
|
246
|
+
} = context;
|
|
247
|
+
const isSelected = selectedValue === value;
|
|
248
|
+
const finalSize = size ?? contextSize;
|
|
249
|
+
const finalVariant = variant ?? contextVariant;
|
|
250
|
+
const finalCorner = corner ?? (finalVariant === "ghost" ? "md" : "sm");
|
|
251
|
+
|
|
252
|
+
const Comp = asChild ? Slot : "button";
|
|
253
|
+
|
|
254
|
+
React.useEffect(() => {
|
|
255
|
+
const element = itemRef.current;
|
|
256
|
+
if (element) {
|
|
257
|
+
registerItem(value, element);
|
|
258
|
+
return () => unregisterItem(value);
|
|
259
|
+
}
|
|
260
|
+
}, [value, registerItem, unregisterItem]);
|
|
261
|
+
|
|
262
|
+
return (
|
|
263
|
+
<Comp
|
|
264
|
+
ref={(node) => {
|
|
265
|
+
itemRef.current = node;
|
|
266
|
+
if (typeof ref === "function") ref(node);
|
|
267
|
+
else if (ref) ref.current = node;
|
|
268
|
+
}}
|
|
269
|
+
{...props}
|
|
270
|
+
data-selected={isSelected}
|
|
271
|
+
className={cn(
|
|
272
|
+
toggleButtonVariants({
|
|
273
|
+
variant: finalVariant,
|
|
274
|
+
size: finalSize,
|
|
275
|
+
icon,
|
|
276
|
+
corner: finalCorner,
|
|
277
|
+
}),
|
|
278
|
+
className,
|
|
279
|
+
)}
|
|
280
|
+
onClick={() => onValueChange(value)}
|
|
281
|
+
type={asChild ? undefined : "button"}
|
|
282
|
+
>
|
|
283
|
+
{children}
|
|
284
|
+
</Comp>
|
|
285
|
+
);
|
|
286
|
+
},
|
|
287
|
+
);
|
|
288
|
+
ToggleButton.displayName = "ToggleButton";
|
|
289
|
+
|
|
290
|
+
export { ToggleButtons, ToggleButton };
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { ComponentProps, createContext, useContext } from "react";
|
|
4
|
+
|
|
5
|
+
import { cn, createClientOnlyComponent } from "../hooks";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Toggle Group item variants using design system CSS variables.
|
|
9
|
+
*/
|
|
10
|
+
const toggleGroupVariants = cva(
|
|
11
|
+
[
|
|
12
|
+
// Base button styling
|
|
13
|
+
"inline-flex",
|
|
14
|
+
"cursor-pointer",
|
|
15
|
+
"items-center",
|
|
16
|
+
"justify-center",
|
|
17
|
+
"shrink-0",
|
|
18
|
+
"whitespace-nowrap",
|
|
19
|
+
"font-normal",
|
|
20
|
+
"transition-all",
|
|
21
|
+
"[&_svg]:shrink-0",
|
|
22
|
+
"[&_svg]:pointer-events-none",
|
|
23
|
+
"outline-none",
|
|
24
|
+
"focus-visible:border-ring",
|
|
25
|
+
"focus-visible:ring-ring/50",
|
|
26
|
+
"focus-visible:ring-[3px]",
|
|
27
|
+
"focus-visible:bg-accent",
|
|
28
|
+
"aria-invalid:ring-destructive/20",
|
|
29
|
+
"aria-invalid:border-destructive",
|
|
30
|
+
|
|
31
|
+
// Toggle group specific styling
|
|
32
|
+
"min-w-0",
|
|
33
|
+
"flex-1",
|
|
34
|
+
"rounded-none",
|
|
35
|
+
"first:rounded-l-uk-sm",
|
|
36
|
+
"first:rounded-r-none",
|
|
37
|
+
"last:rounded-r-uk-sm",
|
|
38
|
+
"last:rounded-l-none",
|
|
39
|
+
"[&:not(:first-child):not(:last-child)]:rounded-none",
|
|
40
|
+
"focus:z-10",
|
|
41
|
+
"focus-visible:z-10",
|
|
42
|
+
|
|
43
|
+
// Disabled state
|
|
44
|
+
"disabled:pointer-events-none",
|
|
45
|
+
"disabled:text-text-secondary/30",
|
|
46
|
+
],
|
|
47
|
+
{
|
|
48
|
+
variants: {
|
|
49
|
+
variant: {
|
|
50
|
+
primary: [
|
|
51
|
+
"text-text-secondary",
|
|
52
|
+
"bg-bg-tertiary",
|
|
53
|
+
"hover:bg-secondary",
|
|
54
|
+
"data-[state=on]:text-text-withbg",
|
|
55
|
+
"data-[state=on]:bg-brand-primary",
|
|
56
|
+
"data-[state=on]:shadow-[inset_0.5px_0_0_var(--secondary),inset_-0.5px_0_0_var(--secondary)]",
|
|
57
|
+
"data-[state=on]:first:shadow-[inset_-0.5px_0_0_var(--secondary)]",
|
|
58
|
+
"data-[state=on]:last:shadow-[inset_0.5px_0_0_var(--secondary)]",
|
|
59
|
+
],
|
|
60
|
+
secondary: [
|
|
61
|
+
"text-text-secondary",
|
|
62
|
+
"bg-bg-secondary",
|
|
63
|
+
"hover:bg-group-hover",
|
|
64
|
+
"border-solid border border-transparent -mr-[1px]",
|
|
65
|
+
"data-[state=on]:text-secondary-foreground",
|
|
66
|
+
"data-[state=on]:bg-group-primary",
|
|
67
|
+
"data-[state=on]:border-line-secondary",
|
|
68
|
+
"data-[state=on]:shadow-[inset_0.5px_0_0_var(--muted),inset_-0.5px_0_0_var(--muted)]",
|
|
69
|
+
],
|
|
70
|
+
ghost: [
|
|
71
|
+
"hover:bg-tertiary",
|
|
72
|
+
"text-icon-secondary",
|
|
73
|
+
"data-[state=on]:text-icon-highlight",
|
|
74
|
+
"data-[state=on]:bg-bg-secondary",
|
|
75
|
+
"data-[state=on]:shadow-[inset_0.5px_0_0_var(--muted),inset_-0.5px_0_0_var(--muted)]",
|
|
76
|
+
"data-[state=on]:first:shadow-[inset_-0.5px_0_0_var(--muted)]",
|
|
77
|
+
"data-[state=on]:last:shadow-[inset_0.5px_0_0_var(--muted)]",
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
size: {
|
|
81
|
+
sm: ["text-uk-sm", "h-6", "gap-xxs", "px-md", "[&_svg:not([class*='size-'])]:size-3"],
|
|
82
|
+
base: ["text-uk-md", "h-8", "gap-xs", "px-lg", "[&_svg:not([class*='size-'])]:size-4"],
|
|
83
|
+
lg: ["text-uk-lg", "h-9", "gap-xs", "px-xl", "[&_svg:not([class*='size-'])]:size-5"],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
defaultVariants: {
|
|
87
|
+
variant: "primary",
|
|
88
|
+
size: "base",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Context to propagate toggle size/variant to group items.
|
|
95
|
+
*/
|
|
96
|
+
const ToggleGroupContext = createContext<
|
|
97
|
+
Pick<VariantProps<typeof toggleGroupVariants>, "variant" | "size">
|
|
98
|
+
>({
|
|
99
|
+
size: "base",
|
|
100
|
+
variant: "primary",
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Group container for multiple toggles.
|
|
105
|
+
*/
|
|
106
|
+
function ToggleGroupRoot({
|
|
107
|
+
className,
|
|
108
|
+
variant,
|
|
109
|
+
size,
|
|
110
|
+
children,
|
|
111
|
+
...props
|
|
112
|
+
}: ComponentProps<typeof ToggleGroupPrimitive.Root> &
|
|
113
|
+
Pick<VariantProps<typeof toggleGroupVariants>, "variant" | "size">) {
|
|
114
|
+
return (
|
|
115
|
+
<ToggleGroupPrimitive.Root
|
|
116
|
+
data-slot="toggle-group"
|
|
117
|
+
data-variant={variant}
|
|
118
|
+
data-size={size}
|
|
119
|
+
className={cn(
|
|
120
|
+
"group/toggle-group",
|
|
121
|
+
"flex",
|
|
122
|
+
"w-fit",
|
|
123
|
+
"items-center",
|
|
124
|
+
"rounded-uk-md",
|
|
125
|
+
className,
|
|
126
|
+
)}
|
|
127
|
+
{...props}
|
|
128
|
+
>
|
|
129
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>
|
|
130
|
+
{children}
|
|
131
|
+
</ToggleGroupContext.Provider>
|
|
132
|
+
</ToggleGroupPrimitive.Root>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* SSR fallback for toggle group.
|
|
138
|
+
*/
|
|
139
|
+
function ToggleGroupFallback({
|
|
140
|
+
className,
|
|
141
|
+
variant,
|
|
142
|
+
size,
|
|
143
|
+
children,
|
|
144
|
+
...props
|
|
145
|
+
}: ComponentProps<"div"> & Pick<VariantProps<typeof toggleGroupVariants>, "variant" | "size">) {
|
|
146
|
+
return (
|
|
147
|
+
<div
|
|
148
|
+
data-slot="toggle-group"
|
|
149
|
+
data-variant={variant}
|
|
150
|
+
data-size={size}
|
|
151
|
+
className={cn(
|
|
152
|
+
"group/toggle-group",
|
|
153
|
+
"flex",
|
|
154
|
+
"w-fit",
|
|
155
|
+
"items-center",
|
|
156
|
+
"rounded-uk-md",
|
|
157
|
+
className,
|
|
158
|
+
)}
|
|
159
|
+
{...props}
|
|
160
|
+
>
|
|
161
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>
|
|
162
|
+
{children}
|
|
163
|
+
</ToggleGroupContext.Provider>
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const ToggleGroup = createClientOnlyComponent(ToggleGroupRoot, ToggleGroupFallback);
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Toggle item that reads size/variant from group context.
|
|
172
|
+
*/
|
|
173
|
+
function ToggleGroupItemRoot({
|
|
174
|
+
className,
|
|
175
|
+
children,
|
|
176
|
+
variant,
|
|
177
|
+
size,
|
|
178
|
+
...props
|
|
179
|
+
}: ComponentProps<typeof ToggleGroupPrimitive.Item> &
|
|
180
|
+
Pick<VariantProps<typeof toggleGroupVariants>, "variant" | "size">) {
|
|
181
|
+
const context = useContext(ToggleGroupContext);
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<ToggleGroupPrimitive.Item
|
|
185
|
+
data-slot="toggle-group-item"
|
|
186
|
+
data-variant={context.variant || variant}
|
|
187
|
+
data-size={context.size || size}
|
|
188
|
+
className={cn(
|
|
189
|
+
toggleGroupVariants({
|
|
190
|
+
variant: context.variant || variant,
|
|
191
|
+
size: context.size || size,
|
|
192
|
+
}),
|
|
193
|
+
className,
|
|
194
|
+
)}
|
|
195
|
+
{...props}
|
|
196
|
+
>
|
|
197
|
+
{children}
|
|
198
|
+
</ToggleGroupPrimitive.Item>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* SSR fallback for toggle group item.
|
|
204
|
+
*/
|
|
205
|
+
function ToggleGroupItemFallback({
|
|
206
|
+
className,
|
|
207
|
+
children,
|
|
208
|
+
variant,
|
|
209
|
+
size,
|
|
210
|
+
...props
|
|
211
|
+
}: ComponentProps<"button"> & Pick<VariantProps<typeof toggleGroupVariants>, "variant" | "size">) {
|
|
212
|
+
const context = useContext(ToggleGroupContext);
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<button
|
|
216
|
+
data-slot="toggle-group-item"
|
|
217
|
+
data-variant={context.variant || variant}
|
|
218
|
+
data-size={context.size || size}
|
|
219
|
+
className={cn(
|
|
220
|
+
toggleGroupVariants({
|
|
221
|
+
variant: context.variant || variant,
|
|
222
|
+
size: context.size || size,
|
|
223
|
+
}),
|
|
224
|
+
className,
|
|
225
|
+
)}
|
|
226
|
+
{...props}
|
|
227
|
+
>
|
|
228
|
+
{children}
|
|
229
|
+
</button>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const ToggleGroupItem = createClientOnlyComponent(ToggleGroupItemRoot, ToggleGroupItemFallback);
|
|
234
|
+
|
|
235
|
+
export { ToggleGroup, ToggleGroupItem, toggleGroupVariants };
|
|
236
|
+
export type { VariantProps };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../hooks";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Variants for the toggle component.
|
|
9
|
+
*/
|
|
10
|
+
const toggleVariants = cva(
|
|
11
|
+
[
|
|
12
|
+
"inline-flex",
|
|
13
|
+
"items-center",
|
|
14
|
+
"justify-center",
|
|
15
|
+
"shrink-0",
|
|
16
|
+
"whitespace-nowrap",
|
|
17
|
+
"font-normal",
|
|
18
|
+
"transition-all",
|
|
19
|
+
"[&_svg]:shrink-0 ",
|
|
20
|
+
"[&_svg]:pointer-events-none",
|
|
21
|
+
"outline-none",
|
|
22
|
+
"disabled:bg-transparent",
|
|
23
|
+
"disabled:text-bg-tertiary",
|
|
24
|
+
"disabled:cursor-not-allowed",
|
|
25
|
+
],
|
|
26
|
+
{
|
|
27
|
+
variants: {
|
|
28
|
+
variant: {
|
|
29
|
+
primary: [
|
|
30
|
+
"text-text-primary",
|
|
31
|
+
"data-[state=on]:text-text-withbg",
|
|
32
|
+
"data-[state=on]:bg-brand-primary",
|
|
33
|
+
"hover:bg-bg-secondary",
|
|
34
|
+
],
|
|
35
|
+
secondary: [
|
|
36
|
+
"text-text-secondary",
|
|
37
|
+
"data-[state=on]:text-text-highlight",
|
|
38
|
+
"data-[state=on]:bg-bg-secondary",
|
|
39
|
+
"hover:bg-bg-secondary ",
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
size: {
|
|
43
|
+
sm: [
|
|
44
|
+
"text-uk-sm",
|
|
45
|
+
"leading-uk-sm",
|
|
46
|
+
"gap-xxs",
|
|
47
|
+
"p-xs",
|
|
48
|
+
"[&_svg:not([class*='size-'])]:size-3",
|
|
49
|
+
"rounded-uk-xs",
|
|
50
|
+
],
|
|
51
|
+
base: [
|
|
52
|
+
"text-uk-md",
|
|
53
|
+
"leading-uk-md",
|
|
54
|
+
"gap-xs",
|
|
55
|
+
"p-sm",
|
|
56
|
+
"[&_svg:not([class*='size-'])]:size-4",
|
|
57
|
+
"rounded-uk-sm",
|
|
58
|
+
],
|
|
59
|
+
lg: [
|
|
60
|
+
"text-uk-lg",
|
|
61
|
+
"leading-uk-lg",
|
|
62
|
+
"gap-xs",
|
|
63
|
+
"p-md",
|
|
64
|
+
"[&_svg:not([class*='size-'])]:size-5",
|
|
65
|
+
"rounded-uk-md",
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
variant: "primary",
|
|
71
|
+
size: "base",
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Toggle button component.
|
|
78
|
+
*/
|
|
79
|
+
function Toggle({
|
|
80
|
+
className,
|
|
81
|
+
variant,
|
|
82
|
+
size,
|
|
83
|
+
...props
|
|
84
|
+
}: ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>) {
|
|
85
|
+
return (
|
|
86
|
+
<TogglePrimitive.Root
|
|
87
|
+
data-slot="toggle"
|
|
88
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
89
|
+
{...props}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../hooks";
|
|
4
|
+
|
|
5
|
+
export interface ToolbarProps {
|
|
6
|
+
className?: string;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
variant?: "default" | "floating" | "liquid" | "liquid-dark";
|
|
9
|
+
size?: "sm" | "md" | "lg";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ToolbarGroupProps {
|
|
13
|
+
className?: string;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ToolbarButtonProps {
|
|
18
|
+
variant?: "primary" | "secondary" | "destructive" | "ghost" | "link";
|
|
19
|
+
size?: "sm" | "md" | "lg";
|
|
20
|
+
icon?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
onClick?: () => void;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
tooltip?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function Toolbar({ className, children, variant = "default", size = "md" }: ToolbarProps) {
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
className={cn(
|
|
32
|
+
"bg-bg-primary flex items-center gap-2 shadow-sm",
|
|
33
|
+
"liquid:liquid-bg",
|
|
34
|
+
size === "sm" && "rounded-uk-md p-1.5",
|
|
35
|
+
size === "md" && "rounded-uk-lg p-1.5",
|
|
36
|
+
size === "lg" && "rounded-uk-xl p-1.5",
|
|
37
|
+
variant === "floating" &&
|
|
38
|
+
"rounded-[var(--radius-uk-md)] bg-white shadow-lg dark:bg-gray-900" &&
|
|
39
|
+
(size === "sm" ? "px-1 py-1" : size === "md" ? "px-2 py-2" : "px-3 py-3"),
|
|
40
|
+
className,
|
|
41
|
+
)}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function ToolbarGroup({ className, children }: ToolbarGroupProps) {
|
|
49
|
+
return <div className={cn("flex items-center gap-1", className)}>{children}</div>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function ToolbarSeparator({ className }: { className?: string }) {
|
|
53
|
+
return <div className={cn("bg-line-primary mx-2 h-3.5 w-0.75 rounded-full", className)} />;
|
|
54
|
+
}
|