uiconfig-blueprint 0.1.0-dev.1 → 0.1.0-dev.11
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 +27 -1
- package/dist/ConfigObject.d.ts +2 -1
- package/dist/UiConfigRendererBlueprint.d.ts +6 -4
- package/dist/allPaths-Dhco1c7a.js +23 -0
- package/dist/{allPaths-EYaH0Usv.js.map → allPaths-Dhco1c7a.js.map} +1 -1
- package/dist/{allPathsLoader-UVZ15qNf.js → allPathsLoader-BNvrKJa2.js} +5 -5
- package/dist/{allPathsLoader-UVZ15qNf.js.map → allPathsLoader-BNvrKJa2.js.map} +1 -1
- package/dist/bpComponents/BPButtonComponent.d.ts +1 -0
- package/dist/bpComponents/BPColorInputComponent.d.ts +1 -0
- package/dist/bpComponents/BPComponent.d.ts +3 -1
- package/dist/bpComponents/BPContainerComponent.d.ts +1 -1
- package/dist/bpComponents/BPFileComponent.d.ts +8 -5
- package/dist/bpComponents/BPFolderComponent.d.ts +9 -1
- package/dist/bpComponents/BPInputComponent.d.ts +2 -1
- package/dist/bpComponents/BPNumberInputComponent.d.ts +3 -1
- package/dist/bpComponents/BPSliderInputComponent.d.ts +1 -0
- package/dist/bpComponents/BPTreeComponent.d.ts +20 -10
- package/dist/bpComponents/BPValueComponent.d.ts +4 -1
- package/dist/bpComponents/BPVectorInputComponent.d.ts +1 -0
- package/dist/bpComponents/GetNumberTransformFunctions.d.ts +4 -0
- package/dist/bpComponents/NumberUnits.d.ts +7 -0
- package/dist/components/DialogContext.d.ts +18 -10
- package/dist/components/DraggableIcon.d.ts +1 -0
- package/dist/components/ExtendedNumericInput.d.ts +13 -3
- package/dist/components/FileComponent.d.ts +3 -1
- package/dist/components/InspectorStackComponent.d.ts +2 -1
- package/dist/components/NumericInput.d.ts +79 -0
- package/dist/components/Tree2.d.ts +52 -0
- package/dist/components/TreeNode2.d.ts +43 -0
- package/dist/components/axesIcons.d.ts +7 -0
- package/dist/components/bpIconWrapper.d.ts +2 -2
- package/dist/components/iconMapping.d.ts +198 -0
- package/dist/components/loadingState.d.ts +4 -0
- package/dist/components/shapesIcons.d.ts +100 -0
- package/dist/components/treeTypes.d.ts +18 -0
- package/dist/index-B1k4Miq7.js +671 -0
- package/dist/index-B1k4Miq7.js.map +1 -0
- package/dist/index-BvGAMcRo.js +671 -0
- package/dist/index-BvGAMcRo.js.map +1 -0
- package/dist/index-GANXo7JZ.js +13560 -0
- package/dist/index-GANXo7JZ.js.map +1 -0
- package/dist/index.js +71 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/lib.d.ts +4 -1
- package/dist/{splitPathsBySizeLoader-GhF5umHk.js → splitPathsBySizeLoader-DGIXBgyZ.js} +6 -6
- package/dist/{splitPathsBySizeLoader-GhF5umHk.js.map → splitPathsBySizeLoader-DGIXBgyZ.js.map} +1 -1
- package/docs/assets/highlight.css +45 -17
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/UI.html +10 -5
- package/docs/classes/UiConfigRendererBlueprint.html +10 -5
- package/docs/index.html +16 -5
- package/lib/css/renderer.css +189 -23
- package/lib/css/renderer.css.map +1 -1
- package/lib/esm/ConfigObject.d.ts +2 -1
- package/lib/esm/ConfigObject.js +15 -9
- package/lib/esm/ConfigObject.js.map +1 -1
- package/lib/esm/UiConfigRendererBlueprint.d.ts +6 -4
- package/lib/esm/UiConfigRendererBlueprint.js +30 -17
- package/lib/esm/UiConfigRendererBlueprint.js.map +1 -1
- package/lib/esm/bpComponents/BPButtonComponent.d.ts +1 -0
- package/lib/esm/bpComponents/BPButtonComponent.js +4 -2
- package/lib/esm/bpComponents/BPButtonComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPColorInputComponent.d.ts +1 -0
- package/lib/esm/bpComponents/BPColorInputComponent.js +4 -2
- package/lib/esm/bpComponents/BPColorInputComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPComponent.d.ts +3 -1
- package/lib/esm/bpComponents/BPComponent.js +15 -2
- package/lib/esm/bpComponents/BPComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPContainerComponent.d.ts +1 -1
- package/lib/esm/bpComponents/BPContainerComponent.js +12 -2
- package/lib/esm/bpComponents/BPContainerComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPDropdownInputComponent.js +7 -3
- package/lib/esm/bpComponents/BPDropdownInputComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPFileComponent.d.ts +8 -5
- package/lib/esm/bpComponents/BPFileComponent.js +18 -24
- package/lib/esm/bpComponents/BPFileComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPFolderComponent.d.ts +9 -1
- package/lib/esm/bpComponents/BPFolderComponent.js +55 -12
- package/lib/esm/bpComponents/BPFolderComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPInputComponent.d.ts +2 -1
- package/lib/esm/bpComponents/BPInputComponent.js +2 -1
- package/lib/esm/bpComponents/BPInputComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPNumberInputComponent.d.ts +3 -1
- package/lib/esm/bpComponents/BPNumberInputComponent.js +6 -1
- package/lib/esm/bpComponents/BPNumberInputComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPPanelComponent.js +1 -1
- package/lib/esm/bpComponents/BPPanelComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPSliderInputComponent.d.ts +1 -0
- package/lib/esm/bpComponents/BPSliderInputComponent.js +18 -6
- package/lib/esm/bpComponents/BPSliderInputComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPTextInputComponent.js +1 -1
- package/lib/esm/bpComponents/BPTextInputComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPToggleInputComponent.js +3 -2
- package/lib/esm/bpComponents/BPToggleInputComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPTreeComponent.d.ts +20 -10
- package/lib/esm/bpComponents/BPTreeComponent.js +120 -26
- package/lib/esm/bpComponents/BPTreeComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPTreeFolderComponent.js +4 -3
- package/lib/esm/bpComponents/BPTreeFolderComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPValueComponent.d.ts +4 -1
- package/lib/esm/bpComponents/BPValueComponent.js +19 -3
- package/lib/esm/bpComponents/BPValueComponent.js.map +1 -1
- package/lib/esm/bpComponents/BPVectorInputComponent.d.ts +1 -0
- package/lib/esm/bpComponents/BPVectorInputComponent.js +14 -8
- package/lib/esm/bpComponents/BPVectorInputComponent.js.map +1 -1
- package/lib/esm/bpComponents/GetNumberTransformFunctions.d.ts +4 -0
- package/lib/esm/bpComponents/GetNumberTransformFunctions.js +14 -0
- package/lib/esm/bpComponents/GetNumberTransformFunctions.js.map +1 -0
- package/lib/esm/bpComponents/NumberUnits.d.ts +7 -0
- package/lib/esm/bpComponents/NumberUnits.js +101 -0
- package/lib/esm/bpComponents/NumberUnits.js.map +1 -0
- package/lib/esm/components/AppToaster.js.map +1 -1
- package/lib/esm/components/ConfigurationPanelComponent.js +6 -1
- package/lib/esm/components/ConfigurationPanelComponent.js.map +1 -1
- package/lib/esm/components/DialogContext.d.ts +18 -10
- package/lib/esm/components/DialogContext.js +52 -33
- package/lib/esm/components/DialogContext.js.map +1 -1
- package/lib/esm/components/DraggableIcon.d.ts +1 -0
- package/lib/esm/components/DraggableIcon.js +7 -4
- package/lib/esm/components/DraggableIcon.js.map +1 -1
- package/lib/esm/components/ExtendedNumericInput.d.ts +13 -3
- package/lib/esm/components/ExtendedNumericInput.js +62 -17
- package/lib/esm/components/ExtendedNumericInput.js.map +1 -1
- package/lib/esm/components/FileComponent.d.ts +3 -1
- package/lib/esm/components/FileComponent.js +19 -19
- package/lib/esm/components/FileComponent.js.map +1 -1
- package/lib/esm/components/InspectorStackComponent.d.ts +2 -1
- package/lib/esm/components/InspectorStackComponent.js +2 -2
- package/lib/esm/components/InspectorStackComponent.js.map +1 -1
- package/lib/esm/components/NumericInput.d.ts +79 -0
- package/lib/esm/components/NumericInput.js +311 -0
- package/lib/esm/components/NumericInput.js.map +1 -0
- package/lib/esm/components/Tree2.d.ts +52 -0
- package/lib/esm/components/Tree2.js +177 -0
- package/lib/esm/components/Tree2.js.map +1 -0
- package/lib/esm/components/TreeNode2.d.ts +43 -0
- package/lib/esm/components/TreeNode2.js +111 -0
- package/lib/esm/components/TreeNode2.js.map +1 -0
- package/lib/esm/components/VisualStyleContext.js +9 -3
- package/lib/esm/components/VisualStyleContext.js.map +1 -1
- package/lib/esm/components/axesIcons.d.ts +7 -0
- package/lib/esm/components/axesIcons.js +10 -0
- package/lib/esm/components/axesIcons.js.map +1 -0
- package/lib/esm/components/bpIconWrapper.d.ts +2 -2
- package/lib/esm/components/bpIconWrapper.js +2 -2
- package/lib/esm/components/bpIconWrapper.js.map +1 -1
- package/lib/esm/components/iconMapping.d.ts +198 -0
- package/lib/esm/components/iconMapping.js +202 -0
- package/lib/esm/components/iconMapping.js.map +1 -0
- package/lib/esm/components/loadingState.d.ts +4 -0
- package/lib/esm/components/loadingState.js +10 -0
- package/lib/esm/components/loadingState.js.map +1 -1
- package/lib/esm/components/shapesIcons.d.ts +100 -0
- package/lib/esm/components/shapesIcons.js +102 -0
- package/lib/esm/components/shapesIcons.js.map +1 -0
- package/lib/esm/components/treeTypes.d.ts +18 -0
- package/lib/esm/components/treeTypes.js +2 -0
- package/lib/esm/components/treeTypes.js.map +1 -0
- package/lib/esm/lib.d.ts +4 -1
- package/lib/esm/lib.js +4 -1
- package/lib/esm/lib.js.map +1 -1
- package/lib/esm/renderer.css.js +1 -0
- package/package.json +62 -13
- package/src/ConfigObject.tsx +25 -11
- package/src/UiConfigRendererBlueprint.tsx +31 -20
- package/src/bpComponents/BPButtonComponent.scss +5 -1
- package/src/bpComponents/BPButtonComponent.tsx +9 -2
- package/src/bpComponents/BPColorInputComponent.tsx +8 -2
- package/src/bpComponents/BPComponent.tsx +17 -4
- package/src/bpComponents/BPContainerComponent.tsx +13 -1
- package/src/bpComponents/BPDropdownInputComponent.tsx +8 -2
- package/src/bpComponents/BPFileComponent.tsx +55 -27
- package/src/bpComponents/BPFolderComponent.scss +20 -6
- package/src/bpComponents/BPFolderComponent.tsx +105 -16
- package/src/bpComponents/BPInputComponent.tsx +6 -2
- package/src/bpComponents/BPNumberInputComponent.tsx +14 -2
- package/src/bpComponents/BPPanelComponent.tsx +1 -1
- package/src/bpComponents/BPSliderInputComponent.tsx +40 -20
- package/src/bpComponents/BPTextInputComponent.tsx +1 -0
- package/src/bpComponents/BPToggleInputComponent.tsx +6 -3
- package/src/bpComponents/BPTreeComponent.tsx +125 -25
- package/src/bpComponents/BPTreeFolderComponent.tsx +3 -3
- package/src/bpComponents/BPValueComponent.tsx +31 -4
- package/src/bpComponents/BPVectorInputComponent.tsx +23 -20
- package/src/bpComponents/GetNumberTransformFunctions.tsx +14 -0
- package/src/bpComponents/NumberUnits.tsx +123 -0
- package/src/components/AppToaster.tsx +20 -0
- package/src/components/ConfigurationPanelComponent.tsx +14 -3
- package/src/components/DialogContext.tsx +125 -65
- package/src/components/DraggableIcon.tsx +6 -5
- package/src/components/ExtendedNumericInput.tsx +70 -18
- package/src/components/FileComponent.tsx +48 -25
- package/src/components/InspectorStackComponent.tsx +2 -2
- package/src/components/NumericInput.tsx +679 -0
- package/src/components/Tree2.tsx +344 -0
- package/src/components/TreeNode2.tsx +192 -0
- package/src/components/VisualStyleContext.tsx +10 -2
- package/src/components/axesIcons.tsx +116 -0
- package/src/components/bpIconWrapper.tsx +5 -4
- package/src/components/common.scss +17 -0
- package/src/components/iconMapping.ts +354 -0
- package/src/components/loadingState.tsx +9 -0
- package/src/components/shapesIcons.tsx +980 -0
- package/src/components/tree2.scss +69 -0
- package/src/components/treeTypes.ts +97 -0
- package/src/lib.ts +4 -1
- package/src/renderer.scss +79 -11
- package/tsconfig.json +1 -0
- package/dist/allPaths-EYaH0Usv.js +0 -23
- package/dist/index-0vU2D25U.js +0 -604
- package/dist/index-0vU2D25U.js.map +0 -1
- package/dist/index-JBvBPdy9.js +0 -604
- package/dist/index-JBvBPdy9.js.map +0 -1
- package/dist/index-OyL-zObJ.js +0 -12765
- package/dist/index-OyL-zObJ.js.map +0 -1
- package/lib/cjs/ConfigObject.d.ts +0 -18
- package/lib/cjs/ConfigObject.js +0 -82
- package/lib/cjs/ConfigObject.js.map +0 -1
- package/lib/cjs/UiConfigRendererBlueprint.d.ts +0 -13
- package/lib/cjs/UiConfigRendererBlueprint.js +0 -56
- package/lib/cjs/UiConfigRendererBlueprint.js.map +0 -1
- package/lib/cjs/bpComponents/BPButtonComponent.d.ts +0 -8
- package/lib/cjs/bpComponents/BPButtonComponent.js +0 -19
- package/lib/cjs/bpComponents/BPButtonComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPColorInputComponent.d.ts +0 -24
- package/lib/cjs/bpComponents/BPColorInputComponent.js +0 -127
- package/lib/cjs/bpComponents/BPColorInputComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPComponent.d.ts +0 -29
- package/lib/cjs/bpComponents/BPComponent.js +0 -59
- package/lib/cjs/bpComponents/BPComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPContainerComponent.d.ts +0 -21
- package/lib/cjs/bpComponents/BPContainerComponent.js +0 -54
- package/lib/cjs/bpComponents/BPContainerComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPDropdownInputComponent.d.ts +0 -15
- package/lib/cjs/bpComponents/BPDropdownInputComponent.js +0 -43
- package/lib/cjs/bpComponents/BPDropdownInputComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPFileComponent.d.ts +0 -25
- package/lib/cjs/bpComponents/BPFileComponent.js +0 -69
- package/lib/cjs/bpComponents/BPFileComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPFolderComponent.d.ts +0 -16
- package/lib/cjs/bpComponents/BPFolderComponent.js +0 -39
- package/lib/cjs/bpComponents/BPFolderComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPInputComponent.d.ts +0 -11
- package/lib/cjs/bpComponents/BPInputComponent.js +0 -34
- package/lib/cjs/bpComponents/BPInputComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPLabelledComponent.d.ts +0 -8
- package/lib/cjs/bpComponents/BPLabelledComponent.js +0 -14
- package/lib/cjs/bpComponents/BPLabelledComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPNumberInputComponent.d.ts +0 -10
- package/lib/cjs/bpComponents/BPNumberInputComponent.js +0 -40
- package/lib/cjs/bpComponents/BPNumberInputComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPPanelComponent.d.ts +0 -16
- package/lib/cjs/bpComponents/BPPanelComponent.js +0 -35
- package/lib/cjs/bpComponents/BPPanelComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPSliderInputComponent.d.ts +0 -14
- package/lib/cjs/bpComponents/BPSliderInputComponent.js +0 -41
- package/lib/cjs/bpComponents/BPSliderInputComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPTextInputComponent.d.ts +0 -7
- package/lib/cjs/bpComponents/BPTextInputComponent.js +0 -19
- package/lib/cjs/bpComponents/BPTextInputComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPToggleInputComponent.d.ts +0 -8
- package/lib/cjs/bpComponents/BPToggleInputComponent.js +0 -22
- package/lib/cjs/bpComponents/BPToggleInputComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPTreeComponent.d.ts +0 -36
- package/lib/cjs/bpComponents/BPTreeComponent.js +0 -131
- package/lib/cjs/bpComponents/BPTreeComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPTreeFolderComponent.d.ts +0 -10
- package/lib/cjs/bpComponents/BPTreeFolderComponent.js +0 -40
- package/lib/cjs/bpComponents/BPTreeFolderComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPValueComponent.d.ts +0 -16
- package/lib/cjs/bpComponents/BPValueComponent.js +0 -46
- package/lib/cjs/bpComponents/BPValueComponent.js.map +0 -1
- package/lib/cjs/bpComponents/BPVectorInputComponent.d.ts +0 -19
- package/lib/cjs/bpComponents/BPVectorInputComponent.js +0 -110
- package/lib/cjs/bpComponents/BPVectorInputComponent.js.map +0 -1
- package/lib/cjs/components/ConfigurationPanelComponent.d.ts +0 -4
- package/lib/cjs/components/ConfigurationPanelComponent.js +0 -30
- package/lib/cjs/components/ConfigurationPanelComponent.js.map +0 -1
- package/lib/cjs/components/DialogContext.d.ts +0 -48
- package/lib/cjs/components/DialogContext.js +0 -79
- package/lib/cjs/components/DialogContext.js.map +0 -1
- package/lib/cjs/components/DraggableIcon.d.ts +0 -19
- package/lib/cjs/components/DraggableIcon.js +0 -70
- package/lib/cjs/components/DraggableIcon.js.map +0 -1
- package/lib/cjs/components/ExtendedNumericInput.d.ts +0 -25
- package/lib/cjs/components/ExtendedNumericInput.js +0 -174
- package/lib/cjs/components/ExtendedNumericInput.js.map +0 -1
- package/lib/cjs/components/FileComponent.d.ts +0 -7
- package/lib/cjs/components/FileComponent.js +0 -49
- package/lib/cjs/components/FileComponent.js.map +0 -1
- package/lib/cjs/components/FormGroupComponent.d.ts +0 -6
- package/lib/cjs/components/FormGroupComponent.js +0 -16
- package/lib/cjs/components/FormGroupComponent.js.map +0 -1
- package/lib/cjs/components/InspectorStackComponent.d.ts +0 -4
- package/lib/cjs/components/InspectorStackComponent.js +0 -27
- package/lib/cjs/components/InspectorStackComponent.js.map +0 -1
- package/lib/cjs/components/VisualStyleContext.d.ts +0 -119
- package/lib/cjs/components/VisualStyleContext.js +0 -60
- package/lib/cjs/components/VisualStyleContext.js.map +0 -1
- package/lib/cjs/components/bpIconWrapper.d.ts +0 -2
- package/lib/cjs/components/bpIconWrapper.js +0 -9
- package/lib/cjs/components/bpIconWrapper.js.map +0 -1
- package/lib/cjs/components/loadingState.d.ts +0 -4
- package/lib/cjs/components/loadingState.js +0 -16
- package/lib/cjs/components/loadingState.js.map +0 -1
- package/lib/cjs/components/variableIcons.d.ts +0 -40
- package/lib/cjs/components/variableIcons.js +0 -46
- package/lib/cjs/components/variableIcons.js.map +0 -1
- package/lib/cjs/contexts.d.ts +0 -1
- package/lib/cjs/contexts.js +0 -3
- package/lib/cjs/contexts.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -4
- package/lib/cjs/index.js +0 -9
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/lib.d.ts +0 -32
- package/lib/cjs/lib.js +0 -49
- package/lib/cjs/lib.js.map +0 -1
- package/lib/cjs/threejs.d.ts +0 -2
- package/lib/cjs/threejs.js +0 -3
- package/lib/cjs/threejs.js.map +0 -1
- package/lib/esnext/ConfigObject.d.ts +0 -18
- package/lib/esnext/ConfigObject.js +0 -75
- package/lib/esnext/ConfigObject.js.map +0 -1
- package/lib/esnext/UiConfigRendererBlueprint.d.ts +0 -13
- package/lib/esnext/UiConfigRendererBlueprint.js +0 -52
- package/lib/esnext/UiConfigRendererBlueprint.js.map +0 -1
- package/lib/esnext/bpComponents/BPButtonComponent.d.ts +0 -8
- package/lib/esnext/bpComponents/BPButtonComponent.js +0 -15
- package/lib/esnext/bpComponents/BPButtonComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPColorInputComponent.d.ts +0 -24
- package/lib/esnext/bpComponents/BPColorInputComponent.js +0 -110
- package/lib/esnext/bpComponents/BPColorInputComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPComponent.d.ts +0 -29
- package/lib/esnext/bpComponents/BPComponent.js +0 -46
- package/lib/esnext/bpComponents/BPComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPContainerComponent.d.ts +0 -21
- package/lib/esnext/bpComponents/BPContainerComponent.js +0 -51
- package/lib/esnext/bpComponents/BPContainerComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPDropdownInputComponent.d.ts +0 -15
- package/lib/esnext/bpComponents/BPDropdownInputComponent.js +0 -40
- package/lib/esnext/bpComponents/BPDropdownInputComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPFileComponent.d.ts +0 -25
- package/lib/esnext/bpComponents/BPFileComponent.js +0 -52
- package/lib/esnext/bpComponents/BPFileComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPFolderComponent.d.ts +0 -16
- package/lib/esnext/bpComponents/BPFolderComponent.js +0 -30
- package/lib/esnext/bpComponents/BPFolderComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPInputComponent.d.ts +0 -11
- package/lib/esnext/bpComponents/BPInputComponent.js +0 -19
- package/lib/esnext/bpComponents/BPInputComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPLabelledComponent.d.ts +0 -8
- package/lib/esnext/bpComponents/BPLabelledComponent.js +0 -13
- package/lib/esnext/bpComponents/BPLabelledComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPNumberInputComponent.d.ts +0 -10
- package/lib/esnext/bpComponents/BPNumberInputComponent.js +0 -21
- package/lib/esnext/bpComponents/BPNumberInputComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPPanelComponent.d.ts +0 -16
- package/lib/esnext/bpComponents/BPPanelComponent.js +0 -31
- package/lib/esnext/bpComponents/BPPanelComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPSliderInputComponent.d.ts +0 -14
- package/lib/esnext/bpComponents/BPSliderInputComponent.js +0 -39
- package/lib/esnext/bpComponents/BPSliderInputComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPTextInputComponent.d.ts +0 -7
- package/lib/esnext/bpComponents/BPTextInputComponent.js +0 -15
- package/lib/esnext/bpComponents/BPTextInputComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPToggleInputComponent.d.ts +0 -8
- package/lib/esnext/bpComponents/BPToggleInputComponent.js +0 -18
- package/lib/esnext/bpComponents/BPToggleInputComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPTreeComponent.d.ts +0 -36
- package/lib/esnext/bpComponents/BPTreeComponent.js +0 -111
- package/lib/esnext/bpComponents/BPTreeComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPTreeFolderComponent.d.ts +0 -10
- package/lib/esnext/bpComponents/BPTreeFolderComponent.js +0 -23
- package/lib/esnext/bpComponents/BPTreeFolderComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPValueComponent.d.ts +0 -16
- package/lib/esnext/bpComponents/BPValueComponent.js +0 -29
- package/lib/esnext/bpComponents/BPValueComponent.js.map +0 -1
- package/lib/esnext/bpComponents/BPVectorInputComponent.d.ts +0 -19
- package/lib/esnext/bpComponents/BPVectorInputComponent.js +0 -93
- package/lib/esnext/bpComponents/BPVectorInputComponent.js.map +0 -1
- package/lib/esnext/components/ConfigurationPanelComponent.d.ts +0 -4
- package/lib/esnext/components/ConfigurationPanelComponent.js +0 -26
- package/lib/esnext/components/ConfigurationPanelComponent.js.map +0 -1
- package/lib/esnext/components/DialogContext.d.ts +0 -48
- package/lib/esnext/components/DialogContext.js +0 -55
- package/lib/esnext/components/DialogContext.js.map +0 -1
- package/lib/esnext/components/DraggableIcon.d.ts +0 -19
- package/lib/esnext/components/DraggableIcon.js +0 -62
- package/lib/esnext/components/DraggableIcon.js.map +0 -1
- package/lib/esnext/components/ExtendedNumericInput.d.ts +0 -25
- package/lib/esnext/components/ExtendedNumericInput.js +0 -151
- package/lib/esnext/components/ExtendedNumericInput.js.map +0 -1
- package/lib/esnext/components/FileComponent.d.ts +0 -7
- package/lib/esnext/components/FileComponent.js +0 -42
- package/lib/esnext/components/FileComponent.js.map +0 -1
- package/lib/esnext/components/FormGroupComponent.d.ts +0 -6
- package/lib/esnext/components/FormGroupComponent.js +0 -11
- package/lib/esnext/components/FormGroupComponent.js.map +0 -1
- package/lib/esnext/components/InspectorStackComponent.d.ts +0 -4
- package/lib/esnext/components/InspectorStackComponent.js +0 -23
- package/lib/esnext/components/InspectorStackComponent.js.map +0 -1
- package/lib/esnext/components/VisualStyleContext.d.ts +0 -119
- package/lib/esnext/components/VisualStyleContext.js +0 -53
- package/lib/esnext/components/VisualStyleContext.js.map +0 -1
- package/lib/esnext/components/bpIconWrapper.d.ts +0 -2
- package/lib/esnext/components/bpIconWrapper.js +0 -5
- package/lib/esnext/components/bpIconWrapper.js.map +0 -1
- package/lib/esnext/components/loadingState.d.ts +0 -4
- package/lib/esnext/components/loadingState.js +0 -12
- package/lib/esnext/components/loadingState.js.map +0 -1
- package/lib/esnext/components/variableIcons.d.ts +0 -40
- package/lib/esnext/components/variableIcons.js +0 -43
- package/lib/esnext/components/variableIcons.js.map +0 -1
- package/lib/esnext/contexts.d.ts +0 -1
- package/lib/esnext/contexts.js +0 -2
- package/lib/esnext/contexts.js.map +0 -1
- package/lib/esnext/index.d.ts +0 -4
- package/lib/esnext/index.js +0 -5
- package/lib/esnext/index.js.map +0 -1
- package/lib/esnext/lib.d.ts +0 -32
- package/lib/esnext/lib.js +0 -33
- package/lib/esnext/lib.js.map +0 -1
- package/lib/esnext/threejs.d.ts +0 -2
- package/lib/esnext/threejs.js +0 -2
- package/lib/esnext/threejs.js.map +0 -1
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import classNames from "classnames";
|
|
18
|
+
import * as React from "react";
|
|
19
|
+
|
|
20
|
+
import {ChevronDown, ChevronUp} from "@blueprintjs/icons";
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
AbstractPureComponent,
|
|
24
|
+
Button,
|
|
25
|
+
ButtonGroup,
|
|
26
|
+
Classes,
|
|
27
|
+
ControlGroup,
|
|
28
|
+
DISPLAYNAME_PREFIX,
|
|
29
|
+
type HTMLInputProps,
|
|
30
|
+
InputGroup,
|
|
31
|
+
Intent,
|
|
32
|
+
Position,
|
|
33
|
+
refHandler,
|
|
34
|
+
removeNonHTMLProps,
|
|
35
|
+
setRef,
|
|
36
|
+
Utils,
|
|
37
|
+
} from "@blueprintjs/core";
|
|
38
|
+
import * as Errors from "@blueprintjs/core/src/common/errors";
|
|
39
|
+
import type {InputSharedProps} from "@blueprintjs/core/src/components/forms/inputSharedProps";
|
|
40
|
+
import {
|
|
41
|
+
clampValue,
|
|
42
|
+
getValueOrEmptyValue,
|
|
43
|
+
isValidNumericKeyboardEvent,
|
|
44
|
+
isValueNumeric,
|
|
45
|
+
parseStringToStringNumber,
|
|
46
|
+
sanitizeNumericInput,
|
|
47
|
+
toLocaleString,
|
|
48
|
+
toMaxPrecision,
|
|
49
|
+
} from "@blueprintjs/core/src/components/forms/numericInputUtils";
|
|
50
|
+
|
|
51
|
+
export interface NumericInputProps extends InputSharedProps {
|
|
52
|
+
/**
|
|
53
|
+
* Whether to allow only floating-point number characters in the field,
|
|
54
|
+
* mimicking the native `input[type="number"]`.
|
|
55
|
+
*
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
allowNumericCharactersOnly?: boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Set this to `true` if you will be controlling the `value` of this input with asynchronous updates.
|
|
62
|
+
* These may occur if you do not immediately call setState in a parent component with the value from
|
|
63
|
+
* the `onChange` handler.
|
|
64
|
+
*/
|
|
65
|
+
asyncControl?: boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The position of the buttons with respect to the input field.
|
|
69
|
+
*
|
|
70
|
+
* @default Position.RIGHT
|
|
71
|
+
*/
|
|
72
|
+
buttonPosition?: typeof Position.LEFT | typeof Position.RIGHT | "none";
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Whether the value should be clamped to `[min, max]` on blur.
|
|
76
|
+
* The value will be clamped to each bound only if the bound is defined.
|
|
77
|
+
* Note that native `input[type="number"]` controls do *NOT* clamp on blur.
|
|
78
|
+
*
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
81
|
+
clampValueOnBlur?: boolean;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* In uncontrolled mode, this sets the default value of the input.
|
|
85
|
+
* Note that this value is only used upon component instantiation and changes to this prop
|
|
86
|
+
* during the component lifecycle will be ignored.
|
|
87
|
+
*
|
|
88
|
+
* @default ""
|
|
89
|
+
*/
|
|
90
|
+
defaultValue?: number | string;
|
|
91
|
+
/**
|
|
92
|
+
* If set to `true`, the input will display with larger styling.
|
|
93
|
+
* This is equivalent to setting `Classes.LARGE` via className on the
|
|
94
|
+
* parent control group and on the child input group.
|
|
95
|
+
*
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
large?: boolean;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The locale name, which is passed to the component to format the number and allowing to type the number in the specific locale.
|
|
102
|
+
* [See MDN documentation for more info about browser locale identification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
|
|
103
|
+
*
|
|
104
|
+
* @default ""
|
|
105
|
+
*/
|
|
106
|
+
locale?: string;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The increment between successive values when <kbd>shift</kbd> is held.
|
|
110
|
+
* Pass explicit `null` value to disable this interaction.
|
|
111
|
+
*
|
|
112
|
+
* @default 10
|
|
113
|
+
*/
|
|
114
|
+
majorStepSize?: number | null;
|
|
115
|
+
|
|
116
|
+
/** The maximum value of the input. */
|
|
117
|
+
max?: number;
|
|
118
|
+
|
|
119
|
+
/** The minimum value of the input. */
|
|
120
|
+
min?: number;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The increment between successive values when <kbd>alt</kbd> is held.
|
|
124
|
+
* Pass explicit `null` value to disable this interaction.
|
|
125
|
+
*
|
|
126
|
+
* @default 0.1
|
|
127
|
+
*/
|
|
128
|
+
minorStepSize?: number | null;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Whether the entire text field should be selected on focus.
|
|
132
|
+
*
|
|
133
|
+
* @default false
|
|
134
|
+
*/
|
|
135
|
+
selectAllOnFocus?: boolean;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Whether the entire text field should be selected on increment.
|
|
139
|
+
*
|
|
140
|
+
* @default false
|
|
141
|
+
*/
|
|
142
|
+
selectAllOnIncrement?: boolean;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* If set to `true`, the input will display with smaller styling.
|
|
146
|
+
* This is equivalent to setting `Classes.SMALL` via className on the
|
|
147
|
+
* parent control group and on the child input group.
|
|
148
|
+
*
|
|
149
|
+
* @default false
|
|
150
|
+
*/
|
|
151
|
+
small?: boolean;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The increment between successive values when no modifier keys are held.
|
|
155
|
+
*
|
|
156
|
+
* @default 1
|
|
157
|
+
*/
|
|
158
|
+
stepSize?: number;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The value to display in the input field.
|
|
162
|
+
*/
|
|
163
|
+
value?: number | string;
|
|
164
|
+
|
|
165
|
+
/** The callback invoked when the value changes due to a button click. */
|
|
166
|
+
onButtonClick?(valueAsNumber: number, valueAsString: string): void;
|
|
167
|
+
|
|
168
|
+
/** The callback invoked when the value changes due to typing, arrow keys, or button clicks. */
|
|
169
|
+
onValueChange?(valueAsNumber: number, valueAsString: string, inputElement: HTMLInputElement | null): void;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface NumericInputState {
|
|
173
|
+
currentImeInputInvalid: boolean;
|
|
174
|
+
prevMinProp?: number;
|
|
175
|
+
prevMaxProp?: number;
|
|
176
|
+
shouldSelectAfterUpdate: boolean;
|
|
177
|
+
stepMaxPrecision: number;
|
|
178
|
+
value: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
enum IncrementDirection {
|
|
182
|
+
DOWN = -1,
|
|
183
|
+
UP = +1,
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const NON_HTML_PROPS: Array<keyof NumericInputProps> = [
|
|
187
|
+
"allowNumericCharactersOnly",
|
|
188
|
+
"buttonPosition",
|
|
189
|
+
"clampValueOnBlur",
|
|
190
|
+
"className",
|
|
191
|
+
"defaultValue",
|
|
192
|
+
"majorStepSize",
|
|
193
|
+
"minorStepSize",
|
|
194
|
+
"onButtonClick",
|
|
195
|
+
"onValueChange",
|
|
196
|
+
"selectAllOnFocus",
|
|
197
|
+
"selectAllOnIncrement",
|
|
198
|
+
"stepSize",
|
|
199
|
+
];
|
|
200
|
+
|
|
201
|
+
type ButtonEventHandlers = Required<Pick<React.HTMLAttributes<HTMLElement>, "onKeyDown" | "onMouseDown">>;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Numeric input component.
|
|
205
|
+
*
|
|
206
|
+
* @see https://blueprintjs.com/docs/#core/components/numeric-input
|
|
207
|
+
*/
|
|
208
|
+
export class NumericInput extends AbstractPureComponent<HTMLInputProps & NumericInputProps, NumericInputState> {
|
|
209
|
+
public static displayName = `${DISPLAYNAME_PREFIX}.NumericInput`;
|
|
210
|
+
|
|
211
|
+
public static VALUE_EMPTY = "";
|
|
212
|
+
|
|
213
|
+
public static VALUE_ZERO = "0";
|
|
214
|
+
|
|
215
|
+
private numericInputId = Utils.uniqueId("numericInput");
|
|
216
|
+
|
|
217
|
+
public static defaultProps: NumericInputProps = {
|
|
218
|
+
allowNumericCharactersOnly: true,
|
|
219
|
+
buttonPosition: Position.RIGHT,
|
|
220
|
+
clampValueOnBlur: false,
|
|
221
|
+
defaultValue: NumericInput.VALUE_EMPTY,
|
|
222
|
+
large: false,
|
|
223
|
+
majorStepSize: 10,
|
|
224
|
+
minorStepSize: 0.1,
|
|
225
|
+
selectAllOnFocus: false,
|
|
226
|
+
selectAllOnIncrement: false,
|
|
227
|
+
small: false,
|
|
228
|
+
stepSize: 1,
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
public static getDerivedStateFromProps(props: NumericInputProps, state: NumericInputState) {
|
|
232
|
+
const nextState = {
|
|
233
|
+
prevMaxProp: props.max,
|
|
234
|
+
prevMinProp: props.min,
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const didMinChange = props.min !== state.prevMinProp;
|
|
238
|
+
const didMaxChange = props.max !== state.prevMaxProp;
|
|
239
|
+
const didBoundsChange = didMinChange || didMaxChange;
|
|
240
|
+
|
|
241
|
+
// in controlled mode, use props.value
|
|
242
|
+
// in uncontrolled mode, if state.value has not been assigned yet (upon initial mount), use props.defaultValue
|
|
243
|
+
const value = props.value?.toString() ?? state.value;
|
|
244
|
+
const stepMaxPrecision = NumericInput.getStepMaxPrecision(props);
|
|
245
|
+
|
|
246
|
+
const sanitizedValue =
|
|
247
|
+
value !== NumericInput.VALUE_EMPTY
|
|
248
|
+
? NumericInput.roundAndClampValue(value, stepMaxPrecision, props.min, props.max, 0, props.locale)
|
|
249
|
+
: NumericInput.VALUE_EMPTY;
|
|
250
|
+
|
|
251
|
+
// if a new min and max were provided that cause the existing value to fall
|
|
252
|
+
// outside of the new bounds, then clamp the value to the new valid range.
|
|
253
|
+
if (didBoundsChange && sanitizedValue !== state.value) {
|
|
254
|
+
return { ...nextState, stepMaxPrecision, value: sanitizedValue };
|
|
255
|
+
}
|
|
256
|
+
return { ...nextState, stepMaxPrecision, value };
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
private static CONTINUOUS_CHANGE_DELAY = 300;
|
|
260
|
+
|
|
261
|
+
private static CONTINUOUS_CHANGE_INTERVAL = 100;
|
|
262
|
+
|
|
263
|
+
// Value Helpers
|
|
264
|
+
// =============
|
|
265
|
+
private static getStepMaxPrecision(props: HTMLInputProps & NumericInputProps) {
|
|
266
|
+
if (props.minorStepSize != null) {
|
|
267
|
+
return Utils.countDecimalPlaces(props.minorStepSize);
|
|
268
|
+
} else {
|
|
269
|
+
return Utils.countDecimalPlaces(props.stepSize!);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private static roundAndClampValue(
|
|
274
|
+
value: string,
|
|
275
|
+
stepMaxPrecision: number,
|
|
276
|
+
min: number | undefined,
|
|
277
|
+
max: number | undefined,
|
|
278
|
+
delta = 0,
|
|
279
|
+
locale: string | undefined,
|
|
280
|
+
) {
|
|
281
|
+
if (!isValueNumeric(value, locale)) {
|
|
282
|
+
return NumericInput.VALUE_EMPTY;
|
|
283
|
+
}
|
|
284
|
+
const currentValue = parseStringToStringNumber(value, locale);
|
|
285
|
+
const nextValue = toMaxPrecision(Number(currentValue) + delta, stepMaxPrecision);
|
|
286
|
+
const clampedValue = clampValue(nextValue, min, max);
|
|
287
|
+
return toLocaleString(clampedValue, locale);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
public state: NumericInputState = {
|
|
291
|
+
currentImeInputInvalid: false,
|
|
292
|
+
shouldSelectAfterUpdate: false,
|
|
293
|
+
stepMaxPrecision: NumericInput.getStepMaxPrecision(this.props),
|
|
294
|
+
value: getValueOrEmptyValue(this.props.value ?? this.props.defaultValue),
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// updating these flags need not trigger re-renders, so don't include them in this.state.
|
|
298
|
+
private didPasteEventJustOccur = false;
|
|
299
|
+
|
|
300
|
+
private delta = 0;
|
|
301
|
+
|
|
302
|
+
public inputElement: HTMLInputElement | null = null;
|
|
303
|
+
|
|
304
|
+
private inputRef: React.Ref<HTMLInputElement> = refHandler(this, "inputElement", this.props.inputRef);
|
|
305
|
+
|
|
306
|
+
private intervalId?: number;
|
|
307
|
+
|
|
308
|
+
private incrementButtonHandlers = this.getButtonEventHandlers(IncrementDirection.UP);
|
|
309
|
+
|
|
310
|
+
private decrementButtonHandlers = this.getButtonEventHandlers(IncrementDirection.DOWN);
|
|
311
|
+
|
|
312
|
+
private getCurrentValueAsNumber = () => Number(parseStringToStringNumber(this.state.value, this.props.locale));
|
|
313
|
+
|
|
314
|
+
public render() {
|
|
315
|
+
const { buttonPosition, className, fill, large, small } = this.props;
|
|
316
|
+
const containerClasses = classNames(
|
|
317
|
+
Classes.NUMERIC_INPUT,
|
|
318
|
+
{ [Classes.LARGE]: large, [Classes.SMALL]: small },
|
|
319
|
+
className,
|
|
320
|
+
);
|
|
321
|
+
const buttons = this.renderButtons();
|
|
322
|
+
return (
|
|
323
|
+
<ControlGroup className={containerClasses} fill={fill}>
|
|
324
|
+
{buttonPosition === Position.LEFT && buttons}
|
|
325
|
+
{this.renderInput()}
|
|
326
|
+
{buttonPosition === Position.RIGHT && buttons}
|
|
327
|
+
</ControlGroup>
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
public componentDidUpdate(prevProps: NumericInputProps, prevState: NumericInputState) {
|
|
332
|
+
super.componentDidUpdate(prevProps, prevState);
|
|
333
|
+
|
|
334
|
+
if (prevProps.inputRef !== this.props.inputRef) {
|
|
335
|
+
setRef(prevProps.inputRef, null);
|
|
336
|
+
this.inputRef = refHandler(this, "inputElement", this.props.inputRef);
|
|
337
|
+
setRef(this.props.inputRef, this.inputElement);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (this.state.shouldSelectAfterUpdate) {
|
|
341
|
+
this.inputElement?.setSelectionRange(0, this.state.value.length);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const didMinChange = this.props.min !== prevProps.min;
|
|
345
|
+
const didMaxChange = this.props.max !== prevProps.max;
|
|
346
|
+
const didBoundsChange = didMinChange || didMaxChange;
|
|
347
|
+
const didLocaleChange = this.props.locale !== prevProps.locale;
|
|
348
|
+
const didValueChange = this.state.value !== prevState.value;
|
|
349
|
+
|
|
350
|
+
if ((didBoundsChange && didValueChange) || (didLocaleChange && prevState.value !== NumericInput.VALUE_EMPTY)) {
|
|
351
|
+
// we clamped the value due to a bounds change, so we should fire the change callback
|
|
352
|
+
const valueToParse = didLocaleChange ? prevState.value : this.state.value;
|
|
353
|
+
const valueAsString = parseStringToStringNumber(valueToParse, prevProps.locale);
|
|
354
|
+
const localizedValue = toLocaleString(+valueAsString, this.props.locale);
|
|
355
|
+
|
|
356
|
+
this.props.onValueChange?.(+valueAsString, localizedValue, this.inputElement);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
protected validateProps(nextProps: HTMLInputProps & NumericInputProps) {
|
|
361
|
+
const { majorStepSize, max, min, minorStepSize, stepSize/*, value*/ } = nextProps;
|
|
362
|
+
if (min != null && max != null && min > max) {
|
|
363
|
+
console.error(Errors.NUMERIC_INPUT_MIN_MAX);
|
|
364
|
+
}
|
|
365
|
+
if (stepSize! <= 0) {
|
|
366
|
+
console.error(Errors.NUMERIC_INPUT_STEP_SIZE_NON_POSITIVE);
|
|
367
|
+
}
|
|
368
|
+
if (minorStepSize && minorStepSize <= 0) {
|
|
369
|
+
console.error(Errors.NUMERIC_INPUT_MINOR_STEP_SIZE_NON_POSITIVE);
|
|
370
|
+
}
|
|
371
|
+
if (majorStepSize && majorStepSize <= 0) {
|
|
372
|
+
console.error(Errors.NUMERIC_INPUT_MAJOR_STEP_SIZE_NON_POSITIVE);
|
|
373
|
+
}
|
|
374
|
+
if (minorStepSize && minorStepSize > stepSize!) {
|
|
375
|
+
console.error(Errors.NUMERIC_INPUT_MINOR_STEP_SIZE_BOUND);
|
|
376
|
+
}
|
|
377
|
+
if (majorStepSize && majorStepSize < stepSize!) {
|
|
378
|
+
console.error(Errors.NUMERIC_INPUT_MAJOR_STEP_SIZE_BOUND);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// controlled mode
|
|
382
|
+
// if (value != null) {
|
|
383
|
+
// const stepMaxPrecision = NumericInput.getStepMaxPrecision(nextProps);
|
|
384
|
+
// const sanitizedValue = NumericInput.roundAndClampValue(
|
|
385
|
+
// value.toString(),
|
|
386
|
+
// stepMaxPrecision,
|
|
387
|
+
// min,
|
|
388
|
+
// max,
|
|
389
|
+
// 0,
|
|
390
|
+
// this.props.locale,
|
|
391
|
+
// );
|
|
392
|
+
// const valueDoesNotMatch = sanitizedValue !== value.toString();
|
|
393
|
+
// const localizedValue = toLocaleString(
|
|
394
|
+
// Number(parseStringToStringNumber(value, this.props.locale)),
|
|
395
|
+
// this.props.locale,
|
|
396
|
+
// );
|
|
397
|
+
// const isNotLocalized = sanitizedValue !== localizedValue;
|
|
398
|
+
//
|
|
399
|
+
// if (valueDoesNotMatch && isNotLocalized) {
|
|
400
|
+
// console.warn(Errors.NUMERIC_INPUT_CONTROLLED_VALUE_INVALID);
|
|
401
|
+
// }
|
|
402
|
+
// }
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Render Helpers
|
|
406
|
+
// ==============
|
|
407
|
+
|
|
408
|
+
private renderButtons() {
|
|
409
|
+
const { intent, max, min, locale } = this.props;
|
|
410
|
+
const value = parseStringToStringNumber(this.state.value, locale);
|
|
411
|
+
const disabled = this.props.disabled || this.props.readOnly;
|
|
412
|
+
const isIncrementDisabled = max !== undefined && value !== "" && +value >= max;
|
|
413
|
+
const isDecrementDisabled = min !== undefined && value !== "" && +value <= min;
|
|
414
|
+
|
|
415
|
+
return (
|
|
416
|
+
<ButtonGroup className={Classes.FIXED} key="button-group" vertical={true}>
|
|
417
|
+
<Button
|
|
418
|
+
aria-label="increment"
|
|
419
|
+
aria-controls={this.numericInputId}
|
|
420
|
+
disabled={disabled || isIncrementDisabled}
|
|
421
|
+
icon={<ChevronUp />}
|
|
422
|
+
intent={intent}
|
|
423
|
+
{...this.incrementButtonHandlers}
|
|
424
|
+
/>
|
|
425
|
+
<Button
|
|
426
|
+
aria-label="decrement"
|
|
427
|
+
aria-controls={this.numericInputId}
|
|
428
|
+
disabled={disabled || isDecrementDisabled}
|
|
429
|
+
icon={<ChevronDown />}
|
|
430
|
+
intent={intent}
|
|
431
|
+
{...this.decrementButtonHandlers}
|
|
432
|
+
/>
|
|
433
|
+
</ButtonGroup>
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
private renderInput() {
|
|
438
|
+
const inputGroupHtmlProps = removeNonHTMLProps(this.props, NON_HTML_PROPS, true);
|
|
439
|
+
const valueAsNumber = this.getCurrentValueAsNumber();
|
|
440
|
+
|
|
441
|
+
return (
|
|
442
|
+
<InputGroup
|
|
443
|
+
asyncControl={this.props.asyncControl}
|
|
444
|
+
autoComplete="off"
|
|
445
|
+
id={this.numericInputId}
|
|
446
|
+
role={this.props.allowNumericCharactersOnly ? "spinbutton" : undefined}
|
|
447
|
+
{...inputGroupHtmlProps}
|
|
448
|
+
aria-valuemax={this.props.max}
|
|
449
|
+
aria-valuemin={this.props.min}
|
|
450
|
+
aria-valuenow={valueAsNumber}
|
|
451
|
+
intent={this.state.currentImeInputInvalid ? Intent.DANGER : this.props.intent}
|
|
452
|
+
inputClassName={this.props.inputClassName}
|
|
453
|
+
inputRef={this.inputRef}
|
|
454
|
+
large={this.props.large}
|
|
455
|
+
leftElement={this.props.leftElement}
|
|
456
|
+
leftIcon={this.props.leftIcon}
|
|
457
|
+
onFocus={this.handleInputFocus}
|
|
458
|
+
onBlur={this.handleInputBlur}
|
|
459
|
+
onCompositionEnd={this.handleCompositionEnd}
|
|
460
|
+
onCompositionUpdate={this.handleCompositionUpdate}
|
|
461
|
+
onKeyDown={this.handleInputKeyDown}
|
|
462
|
+
onKeyPress={this.handleInputKeyPress}
|
|
463
|
+
onPaste={this.handleInputPaste}
|
|
464
|
+
onValueChange={this.handleInputChange}
|
|
465
|
+
rightElement={this.props.rightElement}
|
|
466
|
+
small={this.props.small}
|
|
467
|
+
value={this.state.value}
|
|
468
|
+
/>
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// Callbacks - Buttons
|
|
473
|
+
// ===================
|
|
474
|
+
|
|
475
|
+
private getButtonEventHandlers(direction: IncrementDirection): ButtonEventHandlers {
|
|
476
|
+
return {
|
|
477
|
+
// keydown is fired repeatedly when held so it's implicitly continuous
|
|
478
|
+
onKeyDown: evt => {
|
|
479
|
+
if (!this.props.disabled && Utils.isKeyboardClick(evt)) {
|
|
480
|
+
this.handleButtonClick(evt, direction);
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
onMouseDown: evt => {
|
|
484
|
+
if (!this.props.disabled) {
|
|
485
|
+
this.handleButtonClick(evt, direction);
|
|
486
|
+
this.startContinuousChange();
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
private handleButtonClick = (e: React.MouseEvent | React.KeyboardEvent, direction: IncrementDirection) => {
|
|
493
|
+
const delta = this.updateDelta(direction, e);
|
|
494
|
+
const nextValue = this.incrementValue(delta);
|
|
495
|
+
this.props.onButtonClick?.(Number(parseStringToStringNumber(nextValue, this.props.locale)), nextValue);
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
private startContinuousChange() {
|
|
499
|
+
// The button's onMouseUp event handler doesn't fire if the user
|
|
500
|
+
// releases outside of the button, so we need to watch all the way
|
|
501
|
+
// from the top.
|
|
502
|
+
document.addEventListener("mouseup", this.stopContinuousChange);
|
|
503
|
+
|
|
504
|
+
// Initial delay is slightly longer to prevent the user from
|
|
505
|
+
// accidentally triggering the continuous increment/decrement.
|
|
506
|
+
this.setTimeout(() => {
|
|
507
|
+
this.intervalId = window.setInterval(this.handleContinuousChange, NumericInput.CONTINUOUS_CHANGE_INTERVAL);
|
|
508
|
+
}, NumericInput.CONTINUOUS_CHANGE_DELAY);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
private stopContinuousChange = () => {
|
|
512
|
+
this.delta = 0;
|
|
513
|
+
this.clearTimeouts();
|
|
514
|
+
clearInterval(this.intervalId);
|
|
515
|
+
document.removeEventListener("mouseup", this.stopContinuousChange);
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
private handleContinuousChange = () => {
|
|
519
|
+
// If either min or max prop is set, when reaching the limit
|
|
520
|
+
// the button will be disabled and stopContinuousChange will be never fired,
|
|
521
|
+
// hence the need to check on each iteration to properly clear the timeout
|
|
522
|
+
if (this.props.min !== undefined || this.props.max !== undefined) {
|
|
523
|
+
const min = this.props.min ?? -Infinity;
|
|
524
|
+
const max = this.props.max ?? Infinity;
|
|
525
|
+
const valueAsNumber = this.getCurrentValueAsNumber();
|
|
526
|
+
if (valueAsNumber <= min || valueAsNumber >= max) {
|
|
527
|
+
this.stopContinuousChange();
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
const nextValue = this.incrementValue(this.delta);
|
|
532
|
+
this.props.onButtonClick?.(Number(parseStringToStringNumber(nextValue, this.props.locale)), nextValue);
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
// Callbacks - Input
|
|
536
|
+
// =================
|
|
537
|
+
|
|
538
|
+
private handleInputFocus = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
539
|
+
// update this state flag to trigger update for input selection (see componentDidUpdate)
|
|
540
|
+
this.setState({ shouldSelectAfterUpdate: this.props.selectAllOnFocus! });
|
|
541
|
+
this.props.onFocus?.(e);
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
private handleInputBlur = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
545
|
+
// always disable this flag on blur so it's ready for next time.
|
|
546
|
+
this.setState({ shouldSelectAfterUpdate: false });
|
|
547
|
+
|
|
548
|
+
if (this.props.clampValueOnBlur) {
|
|
549
|
+
const { value } = e.target as HTMLInputElement;
|
|
550
|
+
this.handleNextValue(this.roundAndClampValue(value));
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
this.props.onBlur?.(e);
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
private handleInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
557
|
+
if (this.props.disabled || this.props.readOnly) {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const direction = Utils.getArrowKeyDirection(e, ["ArrowDown"], ["ArrowUp"]);
|
|
562
|
+
if (direction !== undefined) {
|
|
563
|
+
// when the input field has focus, some key combinations will modify
|
|
564
|
+
// the field's selection range. we'll actually want to select all
|
|
565
|
+
// text in the field after we modify the value on the following
|
|
566
|
+
// lines. preventing the default selection behavior lets us do that
|
|
567
|
+
// without interference.
|
|
568
|
+
e.preventDefault();
|
|
569
|
+
|
|
570
|
+
const delta = this.updateDelta(direction, e);
|
|
571
|
+
this.incrementValue(delta);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
this.props.onKeyDown?.(e);
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
private handleCompositionEnd = (e: React.CompositionEvent<HTMLInputElement>) => {
|
|
578
|
+
if (this.props.allowNumericCharactersOnly) {
|
|
579
|
+
this.handleNextValue(sanitizeNumericInput(e.data, this.props.locale));
|
|
580
|
+
this.setState({ currentImeInputInvalid: false });
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
private handleCompositionUpdate = (e: React.CompositionEvent<HTMLInputElement>) => {
|
|
585
|
+
if (this.props.allowNumericCharactersOnly) {
|
|
586
|
+
const { data } = e;
|
|
587
|
+
const sanitizedValue = sanitizeNumericInput(data, this.props.locale);
|
|
588
|
+
if (sanitizedValue.length === 0 && data.length > 0) {
|
|
589
|
+
this.setState({ currentImeInputInvalid: true });
|
|
590
|
+
} else {
|
|
591
|
+
this.setState({ currentImeInputInvalid: false });
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
private handleInputKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
597
|
+
// we prohibit keystrokes in onKeyPress instead of onKeyDown, because
|
|
598
|
+
// e.key is not trustworthy in onKeyDown in all browsers.
|
|
599
|
+
if (this.props.allowNumericCharactersOnly && !isValidNumericKeyboardEvent(e, this.props.locale)) {
|
|
600
|
+
e.preventDefault();
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
604
|
+
this.props.onKeyPress?.(e);
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
private handleInputPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {
|
|
608
|
+
this.didPasteEventJustOccur = true;
|
|
609
|
+
this.props.onPaste?.(e);
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
private handleInputChange = (value: string) => {
|
|
613
|
+
let nextValue = value;
|
|
614
|
+
if (this.props.allowNumericCharactersOnly && this.didPasteEventJustOccur) {
|
|
615
|
+
this.didPasteEventJustOccur = false;
|
|
616
|
+
nextValue = sanitizeNumericInput(value, this.props.locale);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
this.handleNextValue(nextValue);
|
|
620
|
+
this.setState({ shouldSelectAfterUpdate: false });
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
// Data logic
|
|
624
|
+
// ==========
|
|
625
|
+
|
|
626
|
+
private handleNextValue(valueAsString: string) {
|
|
627
|
+
if (this.props.value == null) {
|
|
628
|
+
this.setState({ value: valueAsString });
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
this.props.onValueChange?.(
|
|
632
|
+
Number(parseStringToStringNumber(valueAsString, this.props.locale)),
|
|
633
|
+
valueAsString,
|
|
634
|
+
this.inputElement,
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
private incrementValue(delta: number) {
|
|
639
|
+
// pretend we're incrementing from 0 if currValue is empty
|
|
640
|
+
const currValue = this.state.value === NumericInput.VALUE_EMPTY ? NumericInput.VALUE_ZERO : this.state.value;
|
|
641
|
+
const nextValue = this.roundAndClampValue(currValue, delta);
|
|
642
|
+
|
|
643
|
+
if (nextValue !== this.state.value) {
|
|
644
|
+
this.handleNextValue(nextValue);
|
|
645
|
+
this.setState({ shouldSelectAfterUpdate: this.props.selectAllOnIncrement! });
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// return value used in continuous change updates
|
|
649
|
+
return nextValue;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
private getIncrementDelta(direction: IncrementDirection, isShiftKeyPressed: boolean, isAltKeyPressed: boolean) {
|
|
653
|
+
const { majorStepSize, minorStepSize, stepSize } = this.props;
|
|
654
|
+
|
|
655
|
+
if (isShiftKeyPressed && majorStepSize != null) {
|
|
656
|
+
return direction * majorStepSize;
|
|
657
|
+
} else if (isAltKeyPressed && minorStepSize != null) {
|
|
658
|
+
return direction * minorStepSize;
|
|
659
|
+
} else {
|
|
660
|
+
return direction * stepSize!;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
private roundAndClampValue(value: string, delta = 0) {
|
|
665
|
+
return NumericInput.roundAndClampValue(
|
|
666
|
+
value,
|
|
667
|
+
this.state.stepMaxPrecision,
|
|
668
|
+
this.props.min,
|
|
669
|
+
this.props.max,
|
|
670
|
+
delta,
|
|
671
|
+
this.props.locale,
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
private updateDelta(direction: IncrementDirection, e: React.MouseEvent | React.KeyboardEvent) {
|
|
676
|
+
this.delta = this.getIncrementDelta(direction, e.shiftKey, e.altKey);
|
|
677
|
+
return this.delta;
|
|
678
|
+
}
|
|
679
|
+
}
|