@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,155 @@
|
|
|
1
|
+
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { type ComponentProps, forwardRef, useRef } from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../hooks";
|
|
6
|
+
|
|
7
|
+
const inputRootVariants = cva(
|
|
8
|
+
["flex", "gap-md", "items-center", "rounded-uk-sm", "overflow-hidden", "bg-bg-secondary"],
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
state: {
|
|
12
|
+
default: [
|
|
13
|
+
"hover:bg-bg-secondary/80",
|
|
14
|
+
"has-[input:focus]:bg-bg-secondary",
|
|
15
|
+
],
|
|
16
|
+
disabled: ["disabled:cursor-not-allowed", "bg-bg-secondary", "text-text-secondary"],
|
|
17
|
+
error: ["hover:bg-danger-primary/10", "bg-danger-primary/20"],
|
|
18
|
+
},
|
|
19
|
+
size: {
|
|
20
|
+
sm: ["h-6", "text-uk-sm", "[&_.input-slot>svg:not([class*='size-'])]:size-3", "px-sm"],
|
|
21
|
+
md: ["h-8", "text-uk-md", "[&_.input-slot>svg:not([class*='size-'])]:size-4", "px-md"],
|
|
22
|
+
lg: ["h-9", "text-uk-lg", "[&_.input-slot>svg:not([class*='size-'])]:size-5", "px-lg"],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
state: "default",
|
|
27
|
+
size: "md",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export interface InputRootProps
|
|
33
|
+
extends Omit<ComponentProps<"input">, "size">,
|
|
34
|
+
VariantProps<typeof inputRootVariants> {
|
|
35
|
+
state?: "default" | "error";
|
|
36
|
+
side?: "left" | "right" | "center";
|
|
37
|
+
asChild?: boolean;
|
|
38
|
+
inputClassName?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Stylized input root that provides consistent container and input styling.
|
|
43
|
+
* Includes clickable slots on left/right to control caret position.
|
|
44
|
+
*
|
|
45
|
+
* @param state - Visual state ("default" | "error")
|
|
46
|
+
* @param size - Control size ("sm" | "base" | "lg")
|
|
47
|
+
* @param side - Align text for inputs ("left" | "right" | "center")
|
|
48
|
+
* @param inputClassName - Additional classes applied to the internal input element
|
|
49
|
+
*/
|
|
50
|
+
export const InputRoot = forwardRef<HTMLInputElement, InputRootProps>(function InputRoot(
|
|
51
|
+
{ style, className, side, children, disabled, state, size, type, inputClassName, ...props },
|
|
52
|
+
ref,
|
|
53
|
+
) {
|
|
54
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
style={style}
|
|
59
|
+
data-input
|
|
60
|
+
className={cn(inputRootVariants({ size, state: disabled ? "disabled" : state }), className)}
|
|
61
|
+
onClick={(event) => {
|
|
62
|
+
const target = event.target as HTMLElement;
|
|
63
|
+
if (target.closest("input, button, a")) return;
|
|
64
|
+
|
|
65
|
+
const input = inputRef.current;
|
|
66
|
+
if (!input) return;
|
|
67
|
+
|
|
68
|
+
// Same selector as in the CSS to find the right slot
|
|
69
|
+
const isRightSlot = target.closest(`
|
|
70
|
+
.input-slot[data-side='right'],
|
|
71
|
+
.input-slot:not([data-side='right']) ~ .input-slot:not([data-side='left'])
|
|
72
|
+
`);
|
|
73
|
+
|
|
74
|
+
const cursorPosition = isRightSlot ? input.value.length : 0;
|
|
75
|
+
|
|
76
|
+
requestAnimationFrame(() => {
|
|
77
|
+
// Only some input types support this, browsers will throw an error if not supported
|
|
78
|
+
// See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange#:~:text=Note%20that%20according,not%20support%20selection%22.
|
|
79
|
+
try {
|
|
80
|
+
input.setSelectionRange(cursorPosition, cursorPosition);
|
|
81
|
+
} catch {
|
|
82
|
+
/* empty */
|
|
83
|
+
}
|
|
84
|
+
input.focus();
|
|
85
|
+
});
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<input
|
|
89
|
+
spellCheck="false"
|
|
90
|
+
{...props}
|
|
91
|
+
type={type}
|
|
92
|
+
data-side={side}
|
|
93
|
+
disabled={disabled}
|
|
94
|
+
name={type ?? "text"}
|
|
95
|
+
ref={composeRefs(inputRef, ref)}
|
|
96
|
+
className={cn(
|
|
97
|
+
[
|
|
98
|
+
"w-full",
|
|
99
|
+
"h-full",
|
|
100
|
+
"outline-none",
|
|
101
|
+
"data-[side=right]:text-right",
|
|
102
|
+
"data-[side=center]:text-center",
|
|
103
|
+
"[input[type=number]]:font-number-input",
|
|
104
|
+
"[&::-webkit-inner-spin-button]:appearance-none",
|
|
105
|
+
"[&::-webkit-outer-spin-button]:appearance-none",
|
|
106
|
+
],
|
|
107
|
+
inputClassName,
|
|
108
|
+
)}
|
|
109
|
+
/>
|
|
110
|
+
{children}
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export interface InputSlotProps extends ComponentProps<"div"> {
|
|
116
|
+
side?: "left" | "right";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Decorative/interactive slot that can be placed on either side of the input.
|
|
121
|
+
* Useful for icons, prefixes, or suffixes.
|
|
122
|
+
*
|
|
123
|
+
* @param side - Which side this slot is on ("left" | "right")
|
|
124
|
+
*/
|
|
125
|
+
export const InputSlot = forwardRef<HTMLDivElement, InputSlotProps>(function (
|
|
126
|
+
{ className, children, side = "left", ...props },
|
|
127
|
+
ref,
|
|
128
|
+
) {
|
|
129
|
+
return (
|
|
130
|
+
<div
|
|
131
|
+
data-side={side}
|
|
132
|
+
{...props}
|
|
133
|
+
ref={ref}
|
|
134
|
+
className={cn(
|
|
135
|
+
[
|
|
136
|
+
"input-slot",
|
|
137
|
+
"cursor-text",
|
|
138
|
+
"shrink-0",
|
|
139
|
+
"order-[0]",
|
|
140
|
+
"text-text-tertiary",
|
|
141
|
+
"data-[side=left]:-order-1",
|
|
142
|
+
],
|
|
143
|
+
className,
|
|
144
|
+
)}
|
|
145
|
+
>
|
|
146
|
+
{children}
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
note-ge: add this since a bunch of tools defaults to import Input.
|
|
153
|
+
If you want to change this, look up the usage references first.
|
|
154
|
+
*/
|
|
155
|
+
export { InputRoot as Input };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { InputNumbers, InputNumbersProps } from "../input-numbers";
|
|
4
|
+
|
|
5
|
+
interface CmInputProps extends Omit<InputNumbersProps, "value" | "onValuesChange" | "onChange"> {
|
|
6
|
+
value?: number;
|
|
7
|
+
onChange?: (value: number) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const CmInput = forwardRef<HTMLDivElement, CmInputProps>(function CmInput(
|
|
11
|
+
{ value = 0, onChange, ...props },
|
|
12
|
+
ref,
|
|
13
|
+
) {
|
|
14
|
+
return (
|
|
15
|
+
<InputNumbers
|
|
16
|
+
ref={ref}
|
|
17
|
+
value={[value]}
|
|
18
|
+
onValuesChange={(values) => onChange?.(values[0])}
|
|
19
|
+
suffix={["cm"]}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { CmInput };
|
|
26
|
+
export type { CmInputProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { InputNumbers, InputNumbersProps } from "../input-numbers";
|
|
4
|
+
|
|
5
|
+
interface DegInputProps extends Omit<InputNumbersProps, "value" | "onValuesChange" | "onChange"> {
|
|
6
|
+
value?: number;
|
|
7
|
+
onChange?: (value: number) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const DegInput = forwardRef<HTMLDivElement, DegInputProps>(function DegInput(
|
|
11
|
+
{ value = 0, onChange, ...props },
|
|
12
|
+
ref,
|
|
13
|
+
) {
|
|
14
|
+
return (
|
|
15
|
+
<InputNumbers
|
|
16
|
+
ref={ref}
|
|
17
|
+
value={[value]}
|
|
18
|
+
onValuesChange={(values) => onChange?.(values[0])}
|
|
19
|
+
suffix={["°"]}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { DegInput };
|
|
26
|
+
export type { DegInputProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { EulerInput, EulerInputProps } from "./EulerInput";
|
|
4
|
+
|
|
5
|
+
type EulerDegInputProps = Omit<EulerInputProps, "unit">;
|
|
6
|
+
|
|
7
|
+
const EulerDegInput = forwardRef<HTMLDivElement, EulerDegInputProps>(
|
|
8
|
+
function EulerDegInput(props, ref) {
|
|
9
|
+
return <EulerInput ref={ref} unit="deg" {...props} />;
|
|
10
|
+
},
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export { EulerDegInput };
|
|
14
|
+
export type { EulerDegInputProps };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { VectorInput, VectorInputProps } from "./VectorInput";
|
|
4
|
+
|
|
5
|
+
interface EulerInputProps extends Omit<VectorInputProps, "value" | "labels" | "onValuesChange"> {
|
|
6
|
+
value: [number, number, number];
|
|
7
|
+
onValuesChange?: (value: [number, number, number]) => void;
|
|
8
|
+
unit?: "deg" | "rad";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const EulerInput = forwardRef<HTMLDivElement, EulerInputProps>(function EulerInput(
|
|
12
|
+
{ value, onValuesChange, unit = "deg", ...props },
|
|
13
|
+
ref,
|
|
14
|
+
) {
|
|
15
|
+
const unitSymbol = unit === "deg" ? "°" : "rad";
|
|
16
|
+
const labels = [`x${unitSymbol}`, `y${unitSymbol}`, `z${unitSymbol}`];
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<VectorInput
|
|
20
|
+
ref={ref}
|
|
21
|
+
value={value}
|
|
22
|
+
onValuesChange={onValuesChange as (value: number[]) => void}
|
|
23
|
+
labels={labels}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export { EulerInput };
|
|
30
|
+
export type { EulerInputProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { EulerInput, EulerInputProps } from "./EulerInput";
|
|
4
|
+
|
|
5
|
+
type EulerRadInputProps = Omit<EulerInputProps, "unit">;
|
|
6
|
+
|
|
7
|
+
const EulerRadInput = forwardRef<HTMLDivElement, EulerRadInputProps>(
|
|
8
|
+
function EulerRadInput(props, ref) {
|
|
9
|
+
return <EulerInput ref={ref} unit="rad" {...props} />;
|
|
10
|
+
},
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export { EulerRadInput };
|
|
14
|
+
export type { EulerRadInputProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { InputNumbers, InputNumbersProps } from "../input-numbers";
|
|
4
|
+
|
|
5
|
+
interface InchInputProps extends Omit<InputNumbersProps, "value" | "onValuesChange" | "onChange"> {
|
|
6
|
+
value?: number;
|
|
7
|
+
onChange?: (value: number) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const InchInput = forwardRef<HTMLDivElement, InchInputProps>(function InchInput(
|
|
11
|
+
{ value = 0, onChange, ...props },
|
|
12
|
+
ref,
|
|
13
|
+
) {
|
|
14
|
+
return (
|
|
15
|
+
<InputNumbers
|
|
16
|
+
ref={ref}
|
|
17
|
+
value={[value]}
|
|
18
|
+
onValuesChange={(values) => onChange?.(values[0])}
|
|
19
|
+
suffix={["in"]}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { InchInput };
|
|
26
|
+
export type { InchInputProps };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { forwardRef, useCallback } from "react";
|
|
2
|
+
|
|
3
|
+
import { InputNumbers, InputNumbersProps } from "../input-numbers";
|
|
4
|
+
|
|
5
|
+
interface IntInputProps extends Omit<InputNumbersProps, "value" | "onValuesChange" | "onChange"> {
|
|
6
|
+
value?: number;
|
|
7
|
+
onChange?: (value: number) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const IntInput = forwardRef<HTMLDivElement, IntInputProps>(function IntInput(
|
|
11
|
+
{ value = 0, onChange, ...props },
|
|
12
|
+
ref,
|
|
13
|
+
) {
|
|
14
|
+
const handleValuesChange = useCallback(
|
|
15
|
+
(values: number[]) => {
|
|
16
|
+
const newValue = values[0];
|
|
17
|
+
|
|
18
|
+
if (newValue === ("" as unknown as number)) {
|
|
19
|
+
onChange?.(newValue as unknown as number);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (isNaN(newValue) || newValue === undefined || newValue === null) {
|
|
24
|
+
onChange?.(0);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const intValue = Math.round(newValue);
|
|
29
|
+
onChange?.(intValue);
|
|
30
|
+
},
|
|
31
|
+
[onChange],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<InputNumbers
|
|
36
|
+
ref={ref}
|
|
37
|
+
value={[value]}
|
|
38
|
+
onValuesChange={handleValuesChange}
|
|
39
|
+
step={1}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export { IntInput };
|
|
46
|
+
export type { IntInputProps };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { VectorInput, VectorInputProps } from "./VectorInput";
|
|
4
|
+
|
|
5
|
+
interface KVectorInputProps extends Omit<VectorInputProps, "labels"> {
|
|
6
|
+
dimensions?: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const KVectorInput = forwardRef<HTMLDivElement, KVectorInputProps>(function KVectorInput(
|
|
10
|
+
{ value, dimensions, ...props },
|
|
11
|
+
ref,
|
|
12
|
+
) {
|
|
13
|
+
const k = dimensions || value.length;
|
|
14
|
+
const labels = Array.from({ length: k }, (_, i) => `${i}`);
|
|
15
|
+
|
|
16
|
+
return <VectorInput ref={ref} value={value} labels={labels} {...props} />;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { KVectorInput };
|
|
20
|
+
export type { KVectorInputProps };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { VectorInput, VectorInputProps } from "./VectorInput";
|
|
4
|
+
|
|
5
|
+
interface QuaternionInputProps
|
|
6
|
+
extends Omit<VectorInputProps, "value" | "labels" | "onValuesChange"> {
|
|
7
|
+
value: [number, number, number, number];
|
|
8
|
+
onValuesChange?: (value: [number, number, number, number]) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const QuaternionInput = forwardRef<HTMLDivElement, QuaternionInputProps>(function QuaternionInput(
|
|
12
|
+
{ value, onValuesChange, ...props },
|
|
13
|
+
ref,
|
|
14
|
+
) {
|
|
15
|
+
return (
|
|
16
|
+
<VectorInput
|
|
17
|
+
ref={ref}
|
|
18
|
+
value={value}
|
|
19
|
+
onValuesChange={onValuesChange as (value: number[]) => void}
|
|
20
|
+
labels={["w", "x", "y", "z"]}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export { QuaternionInput };
|
|
27
|
+
export type { QuaternionInputProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { InputNumbers, InputNumbersProps } from "../input-numbers";
|
|
4
|
+
|
|
5
|
+
interface RadInputProps extends Omit<InputNumbersProps, "value" | "onValuesChange" | "onChange"> {
|
|
6
|
+
value?: number;
|
|
7
|
+
onChange?: (value: number) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const RadInput = forwardRef<HTMLDivElement, RadInputProps>(function RadInput(
|
|
11
|
+
{ value = 0, onChange, ...props },
|
|
12
|
+
ref,
|
|
13
|
+
) {
|
|
14
|
+
return (
|
|
15
|
+
<InputNumbers
|
|
16
|
+
ref={ref}
|
|
17
|
+
value={[value]}
|
|
18
|
+
onValuesChange={(values) => onChange?.(values[0])}
|
|
19
|
+
suffix={["rad"]}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { RadInput };
|
|
26
|
+
export type { RadInputProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { InputNumbers, InputNumbersProps } from "../input-numbers";
|
|
4
|
+
|
|
5
|
+
interface TimeInputProps extends Omit<InputNumbersProps, "value" | "onValuesChange" | "onChange"> {
|
|
6
|
+
value?: number;
|
|
7
|
+
onChange?: (value: number) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const TimeInput = forwardRef<HTMLDivElement, TimeInputProps>(function TimeInput(
|
|
11
|
+
{ value = 0, onChange, ...props },
|
|
12
|
+
ref,
|
|
13
|
+
) {
|
|
14
|
+
return (
|
|
15
|
+
<InputNumbers
|
|
16
|
+
ref={ref}
|
|
17
|
+
value={[value]}
|
|
18
|
+
onValuesChange={(values) => onChange?.(values[0])}
|
|
19
|
+
suffix={["s"]}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { TimeInput };
|
|
26
|
+
export type { TimeInputProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { VectorInput, VectorInputProps } from "./VectorInput";
|
|
4
|
+
|
|
5
|
+
interface Vec3InputProps extends Omit<VectorInputProps, "value" | "labels" | "onValuesChange"> {
|
|
6
|
+
value: [number, number, number];
|
|
7
|
+
onValuesChange?: (value: [number, number, number]) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const Vec3Input = forwardRef<HTMLDivElement, Vec3InputProps>(function Vec3Input(
|
|
11
|
+
{ value, onValuesChange, ...props },
|
|
12
|
+
ref,
|
|
13
|
+
) {
|
|
14
|
+
return (
|
|
15
|
+
<VectorInput
|
|
16
|
+
ref={ref}
|
|
17
|
+
value={value}
|
|
18
|
+
onValuesChange={onValuesChange as (value: number[]) => void}
|
|
19
|
+
labels={["x", "y", "z"]}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { Vec3Input };
|
|
26
|
+
export type { Vec3InputProps };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { forwardRef, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { InputNumbers, InputNumbersProps } from "../input-numbers";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
interface VectorInputProps
|
|
7
|
+
extends Omit<InputNumbersProps, "value" | "onValuesChange" | "onChange"> {
|
|
8
|
+
value: number[];
|
|
9
|
+
onValuesChange?: (value: number[]) => void;
|
|
10
|
+
labels?: ReactNode[];
|
|
11
|
+
step?: number | number[];
|
|
12
|
+
gridAutoFlow?: "column" | "row";
|
|
13
|
+
columns?: number;
|
|
14
|
+
rows?: number;
|
|
15
|
+
// Legacy props (deprecated)
|
|
16
|
+
layout?: "column" | "row";
|
|
17
|
+
columnMajor?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const VectorInput = forwardRef<HTMLDivElement, VectorInputProps>(function VectorInput(
|
|
21
|
+
{ labels, prefix, gridAutoFlow, columns, rows, layout, columnMajor, ...props },
|
|
22
|
+
ref,
|
|
23
|
+
) {
|
|
24
|
+
return (
|
|
25
|
+
<InputNumbers
|
|
26
|
+
ref={ref}
|
|
27
|
+
prefix={labels || prefix}
|
|
28
|
+
gridAutoFlow={gridAutoFlow || layout}
|
|
29
|
+
columns={columns}
|
|
30
|
+
rows={rows}
|
|
31
|
+
columnMajor={columnMajor}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export { VectorInput };
|
|
38
|
+
export type { VectorInputProps };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export { IntInput } from "./IntInput";
|
|
2
|
+
export type { IntInputProps } from "./IntInput";
|
|
3
|
+
|
|
4
|
+
export { DegInput } from "./DegInput";
|
|
5
|
+
export type { DegInputProps } from "./DegInput";
|
|
6
|
+
|
|
7
|
+
export { RadInput } from "./RadInput";
|
|
8
|
+
export type { RadInputProps } from "./RadInput";
|
|
9
|
+
|
|
10
|
+
export { InchInput } from "./InchInput";
|
|
11
|
+
export type { InchInputProps } from "./InchInput";
|
|
12
|
+
|
|
13
|
+
export { CmInput } from "./CmInput";
|
|
14
|
+
export type { CmInputProps } from "./CmInput";
|
|
15
|
+
|
|
16
|
+
export { TimeInput } from "./TimeInput";
|
|
17
|
+
export type { TimeInputProps } from "./TimeInput";
|
|
18
|
+
|
|
19
|
+
export { VectorInput } from "./VectorInput";
|
|
20
|
+
export type { VectorInputProps } from "./VectorInput";
|
|
21
|
+
|
|
22
|
+
export { Vec3Input } from "./Vec3Input";
|
|
23
|
+
export type { Vec3InputProps } from "./Vec3Input";
|
|
24
|
+
|
|
25
|
+
export { EulerInput } from "./EulerInput";
|
|
26
|
+
export type { EulerInputProps } from "./EulerInput";
|
|
27
|
+
|
|
28
|
+
export { EulerDegInput } from "./EulerDegInput";
|
|
29
|
+
export type { EulerDegInputProps } from "./EulerDegInput";
|
|
30
|
+
|
|
31
|
+
export { EulerRadInput } from "./EulerRadInput";
|
|
32
|
+
export type { EulerRadInputProps } from "./EulerRadInput";
|
|
33
|
+
|
|
34
|
+
export { QuaternionInput } from "./QuaternionInput";
|
|
35
|
+
export type { QuaternionInputProps } from "./QuaternionInput";
|
|
36
|
+
|
|
37
|
+
export { KVectorInput } from "./KVectorInput";
|
|
38
|
+
export type { KVectorInputProps } from "./KVectorInput";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { forwardRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { Button } from "../button";
|
|
4
|
+
import { InputNumbers, InputNumbersProps } from "./input-numbers";
|
|
5
|
+
import { cn } from "../../hooks";
|
|
6
|
+
|
|
7
|
+
interface PresetsInputProps
|
|
8
|
+
extends Omit<InputNumbersProps, "presets" | "value" | "onChange" | "onValuesChange"> {
|
|
9
|
+
presets: [number, number, number];
|
|
10
|
+
value?: number;
|
|
11
|
+
onChange?: (value: number) => void;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const PresetsInput = forwardRef<HTMLDivElement, PresetsInputProps>(function PresetsInput(
|
|
16
|
+
{ presets, value = 0, onChange, size, className, ...props },
|
|
17
|
+
ref,
|
|
18
|
+
) {
|
|
19
|
+
const [preset, setPreset] = useState(value);
|
|
20
|
+
|
|
21
|
+
const handleValueChange = (values: number[]) => {
|
|
22
|
+
const newValue = values[0];
|
|
23
|
+
setPreset(newValue);
|
|
24
|
+
onChange?.(newValue);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const handlePresetClick = (presetValue: number) => {
|
|
28
|
+
setPreset(presetValue);
|
|
29
|
+
onChange?.(presetValue);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className={cn("gap-xs grid grid-cols-5", className)}>
|
|
34
|
+
<div className="col-span-full">
|
|
35
|
+
<InputNumbers
|
|
36
|
+
{...props}
|
|
37
|
+
ref={ref}
|
|
38
|
+
size={size}
|
|
39
|
+
value={[preset]}
|
|
40
|
+
onValuesChange={handleValueChange}
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
{presets.map((p: number, i: number) => {
|
|
45
|
+
return (
|
|
46
|
+
<Button
|
|
47
|
+
key={i}
|
|
48
|
+
size={size}
|
|
49
|
+
variant="secondary"
|
|
50
|
+
className="h-6"
|
|
51
|
+
onClick={() => handlePresetClick(p)}
|
|
52
|
+
>
|
|
53
|
+
{p}
|
|
54
|
+
</Button>
|
|
55
|
+
);
|
|
56
|
+
})}
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
});
|
package/src/ui/label.tsx
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../hooks";
|
|
6
|
+
|
|
7
|
+
const labelVariants = cva(
|
|
8
|
+
["font-normal", "leading-none", "peer-disabled:cursor-not-allowed", "peer-disabled:opacity-70"],
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
size: {
|
|
12
|
+
xs: "text-xxs",
|
|
13
|
+
sm: "text-xs",
|
|
14
|
+
lg: "text-md",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
size: "sm",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
type LabelProps = React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
24
|
+
VariantProps<typeof labelVariants> & {
|
|
25
|
+
size?: "xs" | "sm" | "lg";
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const Label = React.forwardRef<React.ComponentRef<typeof LabelPrimitive.Root>, LabelProps>(
|
|
29
|
+
({ className, size, ...props }, ref) => (
|
|
30
|
+
<LabelPrimitive.Root ref={ref} className={cn(labelVariants({ size }), className)} {...props} />
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
34
|
+
|
|
35
|
+
export { Label };
|