@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,208 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { DialSchema, DialGroupConfig, LabelPositionT } from "./DialProvider";
|
|
4
|
+
import {
|
|
5
|
+
DialBooleanInput,
|
|
6
|
+
DialEulerDegInput,
|
|
7
|
+
DialIntInput,
|
|
8
|
+
DialNumberInput,
|
|
9
|
+
DialSelectInput,
|
|
10
|
+
DialSliderInput,
|
|
11
|
+
DialVec3Input,
|
|
12
|
+
DialVectorInput,
|
|
13
|
+
} from "./wrapped-inputs";
|
|
14
|
+
|
|
15
|
+
interface DialSchemaRendererProps {
|
|
16
|
+
schemas: DialSchema[];
|
|
17
|
+
groups?: DialGroupConfig[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const DialPanel: React.FC<DialSchemaRendererProps> = ({ schemas, groups: groupConfigs }) => {
|
|
21
|
+
// Create a map of group configurations for easy lookup
|
|
22
|
+
const groupConfigMap: Record<string, DialGroupConfig> = {};
|
|
23
|
+
|
|
24
|
+
// First, populate from explicit groups prop if provided
|
|
25
|
+
if (groupConfigs) {
|
|
26
|
+
groupConfigs.forEach((config) => {
|
|
27
|
+
groupConfigMap[config.name] = config;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Then, analyze schemas to build group configs from tags if not already defined
|
|
32
|
+
schemas.forEach((schema) => {
|
|
33
|
+
const grouping = schema.tags?.grouping;
|
|
34
|
+
if (grouping && !groupConfigMap[grouping]) {
|
|
35
|
+
// Initialize group config if it doesn't exist
|
|
36
|
+
groupConfigMap[grouping] = { name: grouping };
|
|
37
|
+
}
|
|
38
|
+
// Check if this schema has noWrap tag and apply it to the group
|
|
39
|
+
if (grouping && schema.tags?.noWrap && groupConfigMap[grouping]) {
|
|
40
|
+
groupConfigMap[grouping].noWrap = true;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Group schemas by their grouping tag
|
|
45
|
+
const groupedSchemas: Record<string, DialSchema[]> = {};
|
|
46
|
+
const ungrouped: DialSchema[] = [];
|
|
47
|
+
|
|
48
|
+
schemas.forEach((schema) => {
|
|
49
|
+
const grouping = schema.tags?.grouping;
|
|
50
|
+
if (grouping) {
|
|
51
|
+
if (!groupedSchemas[grouping]) {
|
|
52
|
+
groupedSchemas[grouping] = [];
|
|
53
|
+
}
|
|
54
|
+
groupedSchemas[grouping].push(schema);
|
|
55
|
+
} else {
|
|
56
|
+
ungrouped.push(schema);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Render a single schema item as an input component
|
|
61
|
+
const renderSchemaInput = (schema: DialSchema) => {
|
|
62
|
+
const { name, dtype, min, max, step, options, tags } = schema;
|
|
63
|
+
const labelPosition = tags?.labelPosition as LabelPositionT;
|
|
64
|
+
const label = name.charAt(0).toUpperCase() + name.slice(1);
|
|
65
|
+
|
|
66
|
+
// Choose the right input component based on dtype
|
|
67
|
+
switch (dtype) {
|
|
68
|
+
case "vector3":
|
|
69
|
+
return (
|
|
70
|
+
<DialVec3Input
|
|
71
|
+
key={name}
|
|
72
|
+
name={name}
|
|
73
|
+
label={label}
|
|
74
|
+
step={step}
|
|
75
|
+
labelPosition={labelPosition}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
case "euler":
|
|
80
|
+
return (
|
|
81
|
+
<DialEulerDegInput
|
|
82
|
+
key={name}
|
|
83
|
+
name={name}
|
|
84
|
+
label={label}
|
|
85
|
+
step={step}
|
|
86
|
+
labelPosition={labelPosition}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
case "vector":
|
|
91
|
+
case "vector-6":
|
|
92
|
+
case "number-group":
|
|
93
|
+
// For generic vector or number-group, use VectorN input
|
|
94
|
+
return <DialVectorInput key={name} name={name} label={label} />;
|
|
95
|
+
|
|
96
|
+
case "boolean":
|
|
97
|
+
return (
|
|
98
|
+
<DialBooleanInput key={name} name={name} label={label} labelPosition={labelPosition} />
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
case "number-int":
|
|
102
|
+
// Integer input
|
|
103
|
+
return (
|
|
104
|
+
<DialIntInput
|
|
105
|
+
key={name}
|
|
106
|
+
name={name}
|
|
107
|
+
label={label}
|
|
108
|
+
step={step || 1}
|
|
109
|
+
labelPosition={labelPosition}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
case "number":
|
|
114
|
+
// Use slider if min and max are defined, otherwise use number input
|
|
115
|
+
if (min !== undefined && max !== undefined && !options) {
|
|
116
|
+
return (
|
|
117
|
+
<DialSliderInput
|
|
118
|
+
key={name}
|
|
119
|
+
name={name}
|
|
120
|
+
label={label}
|
|
121
|
+
min={min}
|
|
122
|
+
max={max}
|
|
123
|
+
step={step}
|
|
124
|
+
labelPosition={labelPosition}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Use select if options are provided
|
|
130
|
+
if (options && options.length > 0) {
|
|
131
|
+
return (
|
|
132
|
+
<DialSelectInput
|
|
133
|
+
key={name}
|
|
134
|
+
name={name}
|
|
135
|
+
label={label}
|
|
136
|
+
options={options}
|
|
137
|
+
labelPosition={labelPosition}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Default to number input
|
|
143
|
+
return (
|
|
144
|
+
<DialNumberInput
|
|
145
|
+
key={name}
|
|
146
|
+
name={name}
|
|
147
|
+
label={label}
|
|
148
|
+
min={min}
|
|
149
|
+
max={max}
|
|
150
|
+
step={step}
|
|
151
|
+
labelPosition={labelPosition}
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
case "string":
|
|
156
|
+
// If options are provided, use select
|
|
157
|
+
if (options && options.length > 0) {
|
|
158
|
+
return (
|
|
159
|
+
<DialSelectInput
|
|
160
|
+
key={name}
|
|
161
|
+
name={name}
|
|
162
|
+
label={label}
|
|
163
|
+
options={options}
|
|
164
|
+
labelPosition={labelPosition}
|
|
165
|
+
/>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
// For now, skip pure string inputs (could add text input later)
|
|
169
|
+
return null;
|
|
170
|
+
|
|
171
|
+
default:
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<div className="dial-schema-renderer space-y-4">
|
|
178
|
+
{/* Render grouped schemas */}
|
|
179
|
+
{Object.entries(groupedSchemas).map(([name, schemaList]) => {
|
|
180
|
+
// Use group configuration
|
|
181
|
+
const groupConfig = groupConfigMap[name];
|
|
182
|
+
const hasNoWrap = groupConfig?.noWrap;
|
|
183
|
+
const wrapClass = hasNoWrap ? "" : "flex-wrap";
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<div key={name} className="dial-group">
|
|
187
|
+
<div className="text-text-primary mb-2 font-medium">{name}</div>
|
|
188
|
+
<div className={`dial-row flex flex-row ${wrapClass} gap-4`}>
|
|
189
|
+
{schemaList.map(renderSchemaInput)}
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
);
|
|
193
|
+
})}
|
|
194
|
+
|
|
195
|
+
{/* Render ungrouped schemas - always wrap */}
|
|
196
|
+
{ungrouped.length > 0 && (
|
|
197
|
+
<div className="dial-group">
|
|
198
|
+
{/*<h3 className="text-sm font-semibold text-text-primary mb-2">*/}
|
|
199
|
+
{/* General*/}
|
|
200
|
+
{/*</h3>*/}
|
|
201
|
+
<div className="dial-row flex flex-row flex-wrap gap-4">
|
|
202
|
+
{ungrouped.map(renderSchemaInput)}
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
)}
|
|
206
|
+
</div>
|
|
207
|
+
);
|
|
208
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { DialProvider, DialSchema, DialValue } from "./DialProvider";
|
|
3
|
+
|
|
4
|
+
// Example 1: Uncontrolled Component (manages its own state)
|
|
5
|
+
export const UncontrolledExample = () => {
|
|
6
|
+
const schemas: DialSchema[] = [
|
|
7
|
+
{ name: "volume", dtype: "number", value: 50, min: 0, max: 100 },
|
|
8
|
+
{ name: "enabled", dtype: "boolean", value: true },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<DialProvider
|
|
13
|
+
schemas={schemas}
|
|
14
|
+
onValueChange={(name, value) => {
|
|
15
|
+
console.log(`${name} changed to:`, value);
|
|
16
|
+
}}
|
|
17
|
+
>
|
|
18
|
+
<div>{/* Your dial components here */}</div>
|
|
19
|
+
</DialProvider>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Example 2: Controlled Component (parent manages state)
|
|
24
|
+
export const ControlledExample = () => {
|
|
25
|
+
const [dialValues, setDialValues] = useState<Record<string, DialValue>>({
|
|
26
|
+
volume: 50,
|
|
27
|
+
enabled: true,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const schemas: DialSchema[] = [
|
|
31
|
+
{ name: "volume", dtype: "number", min: 0, max: 100 },
|
|
32
|
+
{ name: "enabled", dtype: "boolean" },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const handleValueChange = (name: string, value: DialValue) => {
|
|
36
|
+
setDialValues((prev) => ({
|
|
37
|
+
...prev,
|
|
38
|
+
[name]: value,
|
|
39
|
+
}));
|
|
40
|
+
console.log(`${name} changed to:`, value);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div>
|
|
45
|
+
<DialProvider
|
|
46
|
+
schemas={schemas}
|
|
47
|
+
values={dialValues} // Pass controlled values
|
|
48
|
+
onValueChange={handleValueChange}
|
|
49
|
+
>
|
|
50
|
+
<div>{/* Your dial components here */}</div>
|
|
51
|
+
</DialProvider>
|
|
52
|
+
|
|
53
|
+
{/* Parent can also control values externally */}
|
|
54
|
+
<button onClick={() => setDialValues({ volume: 0, enabled: false })}>
|
|
55
|
+
Reset All Values
|
|
56
|
+
</button>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Example 3: Semi-controlled (initial values + onChange)
|
|
62
|
+
export const SemiControlledExample = () => {
|
|
63
|
+
const schemas: DialSchema[] = [
|
|
64
|
+
{ name: "volume", dtype: "number", min: 0, max: 100 },
|
|
65
|
+
{ name: "enabled", dtype: "boolean" },
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<DialProvider
|
|
70
|
+
schemas={schemas}
|
|
71
|
+
initialValues={{ volume: 75, enabled: false }} // Set initial values
|
|
72
|
+
onValueChange={(name, value) => {
|
|
73
|
+
// React to changes but don't control the values
|
|
74
|
+
console.log(`${name} changed to:`, value);
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
<div>{/* Your dial components here */}</div>
|
|
78
|
+
</DialProvider>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React, { createContext, ReactNode, useCallback, useContext, useMemo, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export type LabelPositionT = "left" | "top" | "inline" | undefined;
|
|
4
|
+
|
|
5
|
+
// Define specific value types for dial values
|
|
6
|
+
export type DialValue = string | number | boolean | number[] | string[] | null | undefined;
|
|
7
|
+
|
|
8
|
+
// Types for the dial schema
|
|
9
|
+
export interface DialSchema {
|
|
10
|
+
name: string;
|
|
11
|
+
dtype: string;
|
|
12
|
+
value?: DialValue;
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
step?: number;
|
|
16
|
+
options?: Array<string | number | { label: string; value: string | number }>;
|
|
17
|
+
dimensions?: number;
|
|
18
|
+
placeholders?: string[];
|
|
19
|
+
tooltips?: string[];
|
|
20
|
+
dtypes?: string[];
|
|
21
|
+
mins?: number[];
|
|
22
|
+
maxs?: number[];
|
|
23
|
+
steps?: number[];
|
|
24
|
+
helpText?: string;
|
|
25
|
+
icon?: string;
|
|
26
|
+
tags?: {
|
|
27
|
+
grouping?: string;
|
|
28
|
+
col?: boolean | number;
|
|
29
|
+
row?: number;
|
|
30
|
+
layout?: string;
|
|
31
|
+
labelPosition?: LabelPositionT;
|
|
32
|
+
noWrap?: boolean;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Group configuration interface
|
|
37
|
+
export interface DialGroupConfig {
|
|
38
|
+
name: string;
|
|
39
|
+
noWrap?: boolean;
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface DialSchemaGroup {
|
|
44
|
+
component: string;
|
|
45
|
+
schemas: DialSchema[];
|
|
46
|
+
groups?: DialGroupConfig[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Context type
|
|
50
|
+
interface DialContextValue {
|
|
51
|
+
values: Record<string, DialValue>;
|
|
52
|
+
schemas: DialSchema[];
|
|
53
|
+
getValue: (name: string) => DialValue;
|
|
54
|
+
setValue: (name: string, value: DialValue) => void;
|
|
55
|
+
onValueChange?: (name: string, value: DialValue) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Create the context
|
|
59
|
+
const DialSchemaContext = createContext<DialContextValue | undefined>(undefined);
|
|
60
|
+
|
|
61
|
+
// Hook to use the dial context
|
|
62
|
+
export const useDialSchema = () => {
|
|
63
|
+
const context = useContext(DialSchemaContext);
|
|
64
|
+
if (!context) {
|
|
65
|
+
throw new Error("useDialSchema must be used within a DialSchemaProvider");
|
|
66
|
+
}
|
|
67
|
+
return context;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
interface DialSchemaProviderProps {
|
|
71
|
+
children: ReactNode;
|
|
72
|
+
schemas: DialSchema[];
|
|
73
|
+
initialValues?: Record<string, DialValue>;
|
|
74
|
+
values?: Record<string, DialValue>; // For controlled mode
|
|
75
|
+
onValueChange?: (name: string, value: DialValue) => void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Provider component
|
|
79
|
+
export const DialProvider: React.FC<DialSchemaProviderProps> = ({
|
|
80
|
+
children,
|
|
81
|
+
schemas,
|
|
82
|
+
initialValues = {},
|
|
83
|
+
values: controlledValues,
|
|
84
|
+
onValueChange,
|
|
85
|
+
}) => {
|
|
86
|
+
// Determine if component is controlled
|
|
87
|
+
const isControlled = controlledValues !== undefined;
|
|
88
|
+
|
|
89
|
+
// Initialize state with default values from schemas or provided initial values
|
|
90
|
+
const [internalValues, setInternalValues] = useState<Record<string, DialValue>>(() => {
|
|
91
|
+
const defaultValues: Record<string, DialValue> = {};
|
|
92
|
+
schemas.forEach((schema) => {
|
|
93
|
+
defaultValues[schema.name] = initialValues[schema.name] ?? schema.value;
|
|
94
|
+
});
|
|
95
|
+
return defaultValues;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Use controlled values if provided, otherwise use internal state
|
|
99
|
+
const values = isControlled ? controlledValues : internalValues;
|
|
100
|
+
|
|
101
|
+
const getValue = useCallback(
|
|
102
|
+
(name: string) => {
|
|
103
|
+
return values[name];
|
|
104
|
+
},
|
|
105
|
+
[values],
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const setValue = useCallback(
|
|
109
|
+
(name: string, value: DialValue) => {
|
|
110
|
+
if (isControlled) {
|
|
111
|
+
// In controlled mode, only call the change handler
|
|
112
|
+
onValueChange?.(name, value);
|
|
113
|
+
} else {
|
|
114
|
+
// In uncontrolled mode, update internal state
|
|
115
|
+
setInternalValues((prev) => ({
|
|
116
|
+
...prev,
|
|
117
|
+
[name]: value,
|
|
118
|
+
}));
|
|
119
|
+
// Also call external change handler if provided
|
|
120
|
+
onValueChange?.(name, value);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
[isControlled, onValueChange],
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const contextValue = useMemo(
|
|
127
|
+
() => ({
|
|
128
|
+
values,
|
|
129
|
+
schemas,
|
|
130
|
+
getValue,
|
|
131
|
+
setValue,
|
|
132
|
+
onValueChange,
|
|
133
|
+
}),
|
|
134
|
+
[values, schemas, getValue, setValue, onValueChange],
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
return <DialSchemaContext.Provider value={contextValue}>{children}</DialSchemaContext.Provider>;
|
|
138
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Core dial components
|
|
2
|
+
export { DialProvider, useDialSchema } from './DialProvider';
|
|
3
|
+
export type { DialSchema, DialSchemaGroup, DialGroupConfig, DialValue, LabelPositionT } from './DialProvider';
|
|
4
|
+
export { DialPanel } from './DialPanel';
|
|
5
|
+
|
|
6
|
+
// All wrapped input components
|
|
7
|
+
export {
|
|
8
|
+
// Basic controlled inputs
|
|
9
|
+
DialBooleanInput,
|
|
10
|
+
DialNumberInput,
|
|
11
|
+
DialSelectInput,
|
|
12
|
+
DialSliderInput,
|
|
13
|
+
DialVectorInput,
|
|
14
|
+
// UIKit wrapped inputs
|
|
15
|
+
DialVec3Input,
|
|
16
|
+
DialEulerInput,
|
|
17
|
+
DialEulerDegInput,
|
|
18
|
+
DialQuaternionInput,
|
|
19
|
+
DialVectorWrappedInput,
|
|
20
|
+
DialIntInput,
|
|
21
|
+
DialDegInput,
|
|
22
|
+
DialRadInput,
|
|
23
|
+
DialCmInput,
|
|
24
|
+
DialInchInput,
|
|
25
|
+
DialTimeInput,
|
|
26
|
+
} from './wrapped-inputs';
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { LabelPositionT, useDialSchema } from "../DialProvider";
|
|
3
|
+
import {
|
|
4
|
+
FormLayout,
|
|
5
|
+
Input,
|
|
6
|
+
InputSlot,
|
|
7
|
+
Label,
|
|
8
|
+
Select,
|
|
9
|
+
SelectContent,
|
|
10
|
+
SelectItem,
|
|
11
|
+
SelectTrigger,
|
|
12
|
+
SelectValue,
|
|
13
|
+
Slider,
|
|
14
|
+
Switch,
|
|
15
|
+
} from "../../index"; // Base input component that connects to the dial store
|
|
16
|
+
|
|
17
|
+
// Base input component that connects to the dial store
|
|
18
|
+
interface DialInputProps {
|
|
19
|
+
name: string;
|
|
20
|
+
type?: string;
|
|
21
|
+
min?: number;
|
|
22
|
+
max?: number;
|
|
23
|
+
step?: number;
|
|
24
|
+
options?: any[];
|
|
25
|
+
label?: string;
|
|
26
|
+
labelPosition?: LabelPositionT;
|
|
27
|
+
size?: "sm" | "md" | "lg";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Helper component for wrapping inputs with labels
|
|
31
|
+
const DialInputWrapper: React.FC<{
|
|
32
|
+
label?: string;
|
|
33
|
+
children: React.ReactElement;
|
|
34
|
+
}> = ({ label, children }) => {
|
|
35
|
+
if (!label) {
|
|
36
|
+
return <>{children}</>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<FormLayout orientation="label-top">
|
|
41
|
+
<Label size="sm">{label}</Label>
|
|
42
|
+
{children}
|
|
43
|
+
</FormLayout>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const DialNumberInput: React.FC<DialInputProps> = ({
|
|
48
|
+
name,
|
|
49
|
+
min,
|
|
50
|
+
max,
|
|
51
|
+
step = 1,
|
|
52
|
+
label,
|
|
53
|
+
labelPosition,
|
|
54
|
+
size = "sm",
|
|
55
|
+
}) => {
|
|
56
|
+
const { getValue, setValue } = useDialSchema();
|
|
57
|
+
const value = (getValue(name) ?? 0) as number;
|
|
58
|
+
|
|
59
|
+
const inputProps = {
|
|
60
|
+
type: "number" as const,
|
|
61
|
+
value,
|
|
62
|
+
min,
|
|
63
|
+
max,
|
|
64
|
+
step,
|
|
65
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>) =>
|
|
66
|
+
setValue(name, parseFloat(e.target.value)),
|
|
67
|
+
size,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
if (labelPosition === "inline") {
|
|
71
|
+
return (
|
|
72
|
+
<Input {...inputProps}>{label ? <InputSlot side="left">{label}</InputSlot> : null}</Input>
|
|
73
|
+
);
|
|
74
|
+
} else {
|
|
75
|
+
return (
|
|
76
|
+
<DialInputWrapper label={label}>
|
|
77
|
+
<Input {...inputProps} />
|
|
78
|
+
</DialInputWrapper>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const DialBooleanInput: React.FC<DialInputProps> = ({ name, label, labelPosition }) => {
|
|
84
|
+
const { getValue, setValue } = useDialSchema();
|
|
85
|
+
const value = (getValue(name) ?? false) as boolean;
|
|
86
|
+
|
|
87
|
+
const switchProps = {
|
|
88
|
+
checked: value,
|
|
89
|
+
onCheckedChange: (checked: boolean) => setValue(name, checked),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
if (!label) {
|
|
93
|
+
return <Switch {...switchProps} />;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div className="flex flex-row items-center gap-2">
|
|
98
|
+
<Label size="sm">{label}</Label>
|
|
99
|
+
<Switch {...switchProps} />
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const DialSelectInput: React.FC<DialInputProps> = ({
|
|
105
|
+
name,
|
|
106
|
+
options = [],
|
|
107
|
+
label,
|
|
108
|
+
labelPosition,
|
|
109
|
+
size = "sm",
|
|
110
|
+
}) => {
|
|
111
|
+
const { getValue, setValue } = useDialSchema();
|
|
112
|
+
const value = getValue(name);
|
|
113
|
+
|
|
114
|
+
const selectComponent = (
|
|
115
|
+
<Select
|
|
116
|
+
value={String(value)}
|
|
117
|
+
onValueChange={(val) => {
|
|
118
|
+
// Try to parse as number if possible
|
|
119
|
+
const parsed = !isNaN(Number(val)) ? Number(val) : val;
|
|
120
|
+
setValue(name, parsed);
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<SelectTrigger size={size}>
|
|
124
|
+
<SelectValue placeholder="Select an option" />
|
|
125
|
+
</SelectTrigger>
|
|
126
|
+
<SelectContent>
|
|
127
|
+
{options.map((opt, i) => (
|
|
128
|
+
<SelectItem key={i} value={String(opt)}>
|
|
129
|
+
{String(opt)}
|
|
130
|
+
</SelectItem>
|
|
131
|
+
))}
|
|
132
|
+
</SelectContent>
|
|
133
|
+
</Select>
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
if (!label) {
|
|
137
|
+
return selectComponent;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return <DialInputWrapper label={label}>{selectComponent}</DialInputWrapper>;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const DialSliderInput: React.FC<DialInputProps> = ({
|
|
144
|
+
name,
|
|
145
|
+
min = 0,
|
|
146
|
+
max = 100,
|
|
147
|
+
step = 1,
|
|
148
|
+
label,
|
|
149
|
+
labelPosition,
|
|
150
|
+
size = "sm",
|
|
151
|
+
}) => {
|
|
152
|
+
const { getValue, setValue } = useDialSchema();
|
|
153
|
+
const value = (getValue(name) ?? min) as number;
|
|
154
|
+
|
|
155
|
+
const sliderProps = {
|
|
156
|
+
value: [value],
|
|
157
|
+
onValueChange: ([val]: number[]) => setValue(name, val),
|
|
158
|
+
min,
|
|
159
|
+
max,
|
|
160
|
+
step,
|
|
161
|
+
className: "flex-1",
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const sliderComponent = (
|
|
165
|
+
<div className="flex flex-1 items-center gap-2">
|
|
166
|
+
<Slider {...sliderProps} />
|
|
167
|
+
<span className="text-text-secondary w-12 text-right text-sm">{value}</span>
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
if (!label) {
|
|
172
|
+
return sliderComponent;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return <DialInputWrapper label={label}>{sliderComponent}</DialInputWrapper>;
|
|
176
|
+
};
|