@northlight/ui 2.30.0 → 2.31.1
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/dist/es/northlight.d.ts +48 -6
- package/dist/es/northlight.js +24 -19
- package/dist/es/northlight.js.map +1 -1
- package/dist/umd/northlight.cjs +24 -19
- package/dist/umd/northlight.cjs.map +1 -1
- package/dist/umd/northlight.min.cjs +2 -2
- package/dist/umd/northlight.min.cjs.map +1 -1
- package/package.json +2 -2
package/dist/umd/northlight.cjs
CHANGED
|
@@ -14238,27 +14238,33 @@
|
|
|
14238
14238
|
size,
|
|
14239
14239
|
value,
|
|
14240
14240
|
placeholder,
|
|
14241
|
-
|
|
14241
|
+
precision,
|
|
14242
|
+
formatPreset,
|
|
14243
|
+
isDisabled,
|
|
14244
|
+
isReadOnly
|
|
14242
14245
|
} = _b, rest = __objRest$1(_b, [
|
|
14243
14246
|
"onChange",
|
|
14244
14247
|
"options",
|
|
14245
14248
|
"size",
|
|
14246
14249
|
"value",
|
|
14247
14250
|
"placeholder",
|
|
14248
|
-
"
|
|
14251
|
+
"precision",
|
|
14252
|
+
"formatPreset",
|
|
14253
|
+
"isDisabled",
|
|
14254
|
+
"isReadOnly"
|
|
14249
14255
|
]);
|
|
14256
|
+
var _a2;
|
|
14250
14257
|
const { isOpen, onToggle, onClose } = react.useDisclosure();
|
|
14251
|
-
const [inputValue, setInputValue] = React.useState(value ? value.input
|
|
14252
|
-
const [selectOption, setSelectOption] = React.useState(value ? value.option : options[0]);
|
|
14258
|
+
const [inputValue, setInputValue] = React.useState(value == null ? void 0 : value.input);
|
|
14259
|
+
const [selectOption, setSelectOption] = React.useState((_a2 = value == null ? void 0 : value.option) != null ? _a2 : options[0]);
|
|
14253
14260
|
const [enableSelectInput, setEnableSelectInput] = React.useState(false);
|
|
14254
14261
|
const buttonRef = React.useRef();
|
|
14255
14262
|
const selectRef = React.useRef();
|
|
14263
|
+
const getNewValue = (option, input) => input ? { input: Number(input), option } : { option };
|
|
14256
14264
|
const handleInputChange = (newInputvalue) => {
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
|
|
14260
|
-
option: selectOption
|
|
14261
|
-
});
|
|
14265
|
+
const newValue = getNewValue(selectOption, newInputvalue.floatValue);
|
|
14266
|
+
setInputValue(newValue.input);
|
|
14267
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
14262
14268
|
};
|
|
14263
14269
|
const handleSelectClose = () => {
|
|
14264
14270
|
if (buttonRef.current) {
|
|
@@ -14270,10 +14276,7 @@
|
|
|
14270
14276
|
const handleSelectChange = (selectedOption) => {
|
|
14271
14277
|
if (selectedOption) {
|
|
14272
14278
|
setSelectOption(selectedOption);
|
|
14273
|
-
onChange == null ? void 0 : onChange(
|
|
14274
|
-
input: inputValue,
|
|
14275
|
-
option: selectedOption
|
|
14276
|
-
});
|
|
14279
|
+
onChange == null ? void 0 : onChange(getNewValue(selectedOption, inputValue));
|
|
14277
14280
|
handleSelectClose();
|
|
14278
14281
|
}
|
|
14279
14282
|
};
|
|
@@ -14288,17 +14291,19 @@
|
|
|
14288
14291
|
selectRef.current.focus();
|
|
14289
14292
|
}
|
|
14290
14293
|
}, [enableSelectInput]);
|
|
14291
|
-
return /* @__PURE__ */ React.createElement(react.InputGroup,
|
|
14292
|
-
|
|
14294
|
+
return /* @__PURE__ */ React.createElement(react.InputGroup, null, /* @__PURE__ */ React.createElement(
|
|
14295
|
+
FormattedNumberInput,
|
|
14293
14296
|
__spreadValues$1({
|
|
14294
14297
|
width: "100%",
|
|
14295
|
-
overflow: "hidden",
|
|
14296
14298
|
onChange: handleInputChange,
|
|
14297
14299
|
defaultValue: inputValue,
|
|
14298
14300
|
placeholder,
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14301
|
+
size,
|
|
14302
|
+
numberOfDecimals: precision,
|
|
14303
|
+
preset: formatPreset,
|
|
14304
|
+
disabled: isDisabled,
|
|
14305
|
+
readOnly: isReadOnly
|
|
14306
|
+
}, rest)
|
|
14302
14307
|
), /* @__PURE__ */ React.createElement(
|
|
14303
14308
|
react.InputRightElement,
|
|
14304
14309
|
{
|