@northlight/ui 2.31.0 → 2.31.2
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 +23 -10
- package/dist/es/northlight.js +73 -37
- package/dist/es/northlight.js.map +1 -1
- package/dist/umd/northlight.cjs +72 -36
- package/dist/umd/northlight.cjs.map +1 -1
- package/dist/umd/northlight.min.cjs +3 -3
- package/dist/umd/northlight.min.cjs.map +1 -1
- package/package.json +2 -2
package/dist/umd/northlight.cjs
CHANGED
|
@@ -4767,10 +4767,13 @@
|
|
|
4767
4767
|
}),
|
|
4768
4768
|
variants: {
|
|
4769
4769
|
default: ({ theme: { colors: color } }) => ({
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4770
|
+
color: color.text.default,
|
|
4771
|
+
bgColor: color.bg.base,
|
|
4772
|
+
borderWidth: "xs",
|
|
4773
|
+
borderColor: color.border.default,
|
|
4774
|
+
borderStyle: "solid",
|
|
4775
|
+
[$arrowBg.variable]: color.bg.base,
|
|
4776
|
+
[$arrowBorder.variable]: color.border.default
|
|
4774
4777
|
}),
|
|
4775
4778
|
success: ({ theme: { colors: color } }) => ({
|
|
4776
4779
|
color: "text.over.success",
|
|
@@ -7772,7 +7775,7 @@
|
|
|
7772
7775
|
hasArrow = true,
|
|
7773
7776
|
title = "",
|
|
7774
7777
|
description = "",
|
|
7775
|
-
hasIcon =
|
|
7778
|
+
hasIcon = false
|
|
7776
7779
|
} = _b, rest = __objRest$18(_b, [
|
|
7777
7780
|
"variant",
|
|
7778
7781
|
"hasArrow",
|
|
@@ -7787,7 +7790,7 @@
|
|
|
7787
7790
|
{
|
|
7788
7791
|
variant: "14",
|
|
7789
7792
|
sx: {
|
|
7790
|
-
color: !variant || variant === "ai"
|
|
7793
|
+
color: !variant || variant === "ai" ? "text.inverted" : "text.default"
|
|
7791
7794
|
}
|
|
7792
7795
|
},
|
|
7793
7796
|
description
|
|
@@ -13015,12 +13018,13 @@
|
|
|
13015
13018
|
preset = "eu",
|
|
13016
13019
|
isPercentage = false,
|
|
13017
13020
|
onChange = ramda.identity,
|
|
13018
|
-
value,
|
|
13021
|
+
value: valueProp,
|
|
13019
13022
|
numberOfDecimals = 2,
|
|
13020
13023
|
max = Infinity,
|
|
13021
13024
|
min = -Infinity,
|
|
13022
13025
|
inputLeftElement,
|
|
13023
|
-
inputRightElement
|
|
13026
|
+
inputRightElement,
|
|
13027
|
+
onBlur
|
|
13024
13028
|
} = _b, rest = __objRest$g(_b, [
|
|
13025
13029
|
"preset",
|
|
13026
13030
|
"isPercentage",
|
|
@@ -13030,27 +13034,37 @@
|
|
|
13030
13034
|
"max",
|
|
13031
13035
|
"min",
|
|
13032
13036
|
"inputLeftElement",
|
|
13033
|
-
"inputRightElement"
|
|
13037
|
+
"inputRightElement",
|
|
13038
|
+
"onBlur"
|
|
13034
13039
|
]);
|
|
13040
|
+
const [valueState, setValueState] = React.useState(valueProp);
|
|
13041
|
+
const isControlled = typeof valueProp !== "undefined";
|
|
13042
|
+
const value = isControlled ? valueProp : valueState;
|
|
13035
13043
|
const props = presetMap[preset];
|
|
13036
|
-
const
|
|
13044
|
+
const getNumberFormatValues = (number) => ({
|
|
13045
|
+
floatValue: number,
|
|
13046
|
+
formattedValue: reactNumberFormat.numericFormatter(number.toString(), props),
|
|
13047
|
+
value: number.toString()
|
|
13048
|
+
});
|
|
13037
13049
|
const validateRange = () => {
|
|
13038
|
-
if (ramda.isNil(
|
|
13050
|
+
if (ramda.isNil(value))
|
|
13039
13051
|
return;
|
|
13040
|
-
const vNum = typeof
|
|
13052
|
+
const vNum = typeof value === "string" ? parseFloat(value) : value;
|
|
13041
13053
|
const factor = isPercentage ? 100 : 1;
|
|
13042
13054
|
if (vNum * factor > max) {
|
|
13043
13055
|
const newValue = roundToPrecision(max / factor, numberOfDecimals);
|
|
13044
|
-
|
|
13056
|
+
setValueState(newValue);
|
|
13057
|
+
onChange(getNumberFormatValues(newValue));
|
|
13045
13058
|
}
|
|
13046
13059
|
if (vNum * factor < min) {
|
|
13047
13060
|
const newValue = roundToPrecision(min / factor, numberOfDecimals);
|
|
13048
|
-
|
|
13061
|
+
setValueState(newValue);
|
|
13062
|
+
onChange(getNumberFormatValues(newValue));
|
|
13049
13063
|
}
|
|
13050
13064
|
};
|
|
13051
13065
|
const onValueChangeHandler = (values, sourceInfo) => {
|
|
13052
13066
|
const newFloatValue = values.floatValue && isPercentage ? roundToPrecision(values.floatValue / 100, numberOfDecimals) : values.floatValue;
|
|
13053
|
-
|
|
13067
|
+
setValueState(newFloatValue);
|
|
13054
13068
|
onChange(
|
|
13055
13069
|
__spreadProps$3(__spreadValues$k({}, values), {
|
|
13056
13070
|
floatValue: newFloatValue
|
|
@@ -13058,6 +13072,9 @@
|
|
|
13058
13072
|
sourceInfo
|
|
13059
13073
|
);
|
|
13060
13074
|
};
|
|
13075
|
+
React.useEffect(() => {
|
|
13076
|
+
validateRange();
|
|
13077
|
+
}, [value]);
|
|
13061
13078
|
return /* @__PURE__ */ React.createElement(
|
|
13062
13079
|
InputGroupWrapper,
|
|
13063
13080
|
{
|
|
@@ -13069,10 +13086,13 @@
|
|
|
13069
13086
|
__spreadValues$k(__spreadValues$k({
|
|
13070
13087
|
allowLeadingZeros: true,
|
|
13071
13088
|
customInput: react.Input,
|
|
13072
|
-
onBlur:
|
|
13089
|
+
onBlur: (e) => {
|
|
13090
|
+
onBlur == null ? void 0 : onBlur(e);
|
|
13091
|
+
validateRange();
|
|
13092
|
+
},
|
|
13073
13093
|
onValueChange: onValueChangeHandler,
|
|
13074
13094
|
decimalScale: numberOfDecimals,
|
|
13075
|
-
value: isPercentage ? roundToPrecision(parseFloat(`${
|
|
13095
|
+
value: isPercentage ? roundToPrecision(parseFloat(`${value != null ? value : 0}`) * 100, numberOfDecimals) : value,
|
|
13076
13096
|
suffix: isPercentage ? "%" : ""
|
|
13077
13097
|
}, props), rest)
|
|
13078
13098
|
)
|
|
@@ -14236,12 +14256,15 @@
|
|
|
14236
14256
|
onChange,
|
|
14237
14257
|
options,
|
|
14238
14258
|
size,
|
|
14239
|
-
value,
|
|
14259
|
+
value: valueProp,
|
|
14240
14260
|
placeholder,
|
|
14241
14261
|
precision,
|
|
14242
14262
|
formatPreset,
|
|
14243
14263
|
isDisabled,
|
|
14244
|
-
isReadOnly
|
|
14264
|
+
isReadOnly,
|
|
14265
|
+
defaultToZeroIfEmpty = true,
|
|
14266
|
+
max = Infinity,
|
|
14267
|
+
min = -Infinity
|
|
14245
14268
|
} = _b, rest = __objRest$1(_b, [
|
|
14246
14269
|
"onChange",
|
|
14247
14270
|
"options",
|
|
@@ -14251,20 +14274,27 @@
|
|
|
14251
14274
|
"precision",
|
|
14252
14275
|
"formatPreset",
|
|
14253
14276
|
"isDisabled",
|
|
14254
|
-
"isReadOnly"
|
|
14277
|
+
"isReadOnly",
|
|
14278
|
+
"defaultToZeroIfEmpty",
|
|
14279
|
+
"max",
|
|
14280
|
+
"min"
|
|
14255
14281
|
]);
|
|
14282
|
+
var _a2;
|
|
14256
14283
|
const { isOpen, onToggle, onClose } = react.useDisclosure();
|
|
14257
|
-
const [
|
|
14258
|
-
const [
|
|
14284
|
+
const [inputValueState, setInputValueState] = React.useState(valueProp == null ? void 0 : valueProp.input);
|
|
14285
|
+
const [selectOptionState, setselectOptionState] = React.useState((_a2 = valueProp == null ? void 0 : valueProp.option) != null ? _a2 : options[0]);
|
|
14259
14286
|
const [enableSelectInput, setEnableSelectInput] = React.useState(false);
|
|
14287
|
+
const isInputValueControlled = typeof (valueProp == null ? void 0 : valueProp.input) !== "undefined";
|
|
14288
|
+
const inputValue = isInputValueControlled ? valueProp.input : inputValueState;
|
|
14289
|
+
const isOptionControlled = typeof (valueProp == null ? void 0 : valueProp.option) !== "undefined";
|
|
14290
|
+
const selectOption = isOptionControlled ? valueProp.option : selectOptionState;
|
|
14260
14291
|
const buttonRef = React.useRef();
|
|
14261
14292
|
const selectRef = React.useRef();
|
|
14293
|
+
const getNewValue = (option, input) => ramda.is(Number, input) ? { input: Number(input), option } : { option };
|
|
14262
14294
|
const handleInputChange = (newInputvalue) => {
|
|
14263
|
-
|
|
14264
|
-
|
|
14265
|
-
|
|
14266
|
-
option: selectOption
|
|
14267
|
-
});
|
|
14295
|
+
const newValue = getNewValue(selectOption, newInputvalue);
|
|
14296
|
+
setInputValueState(newValue.input);
|
|
14297
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
14268
14298
|
};
|
|
14269
14299
|
const handleSelectClose = () => {
|
|
14270
14300
|
if (buttonRef.current) {
|
|
@@ -14275,12 +14305,11 @@
|
|
|
14275
14305
|
};
|
|
14276
14306
|
const handleSelectChange = (selectedOption) => {
|
|
14277
14307
|
if (selectedOption) {
|
|
14278
|
-
|
|
14279
|
-
onChange == null ? void 0 : onChange(
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
}
|
|
14283
|
-
handleSelectClose();
|
|
14308
|
+
setselectOptionState(selectedOption);
|
|
14309
|
+
onChange == null ? void 0 : onChange(getNewValue(selectedOption, inputValue));
|
|
14310
|
+
if (isOpen) {
|
|
14311
|
+
handleSelectClose();
|
|
14312
|
+
}
|
|
14284
14313
|
}
|
|
14285
14314
|
};
|
|
14286
14315
|
const handleSelectToggle = () => {
|
|
@@ -14294,18 +14323,25 @@
|
|
|
14294
14323
|
selectRef.current.focus();
|
|
14295
14324
|
}
|
|
14296
14325
|
}, [enableSelectInput]);
|
|
14326
|
+
React.useEffect(() => {
|
|
14327
|
+
if (!ramda.is(Number, inputValue) && defaultToZeroIfEmpty) {
|
|
14328
|
+
handleInputChange(clamp(min, max, 0));
|
|
14329
|
+
}
|
|
14330
|
+
}, [valueProp == null ? void 0 : valueProp.input]);
|
|
14297
14331
|
return /* @__PURE__ */ React.createElement(react.InputGroup, null, /* @__PURE__ */ React.createElement(
|
|
14298
14332
|
FormattedNumberInput,
|
|
14299
14333
|
__spreadValues$1({
|
|
14300
14334
|
width: "100%",
|
|
14301
|
-
onChange: handleInputChange,
|
|
14302
|
-
|
|
14335
|
+
onChange: (values) => handleInputChange(values.floatValue),
|
|
14336
|
+
value: inputValue,
|
|
14303
14337
|
placeholder,
|
|
14304
14338
|
size,
|
|
14305
14339
|
numberOfDecimals: precision,
|
|
14306
14340
|
preset: formatPreset,
|
|
14307
14341
|
disabled: isDisabled,
|
|
14308
|
-
readOnly: isReadOnly
|
|
14342
|
+
readOnly: isReadOnly,
|
|
14343
|
+
min,
|
|
14344
|
+
max
|
|
14309
14345
|
}, rest)
|
|
14310
14346
|
), /* @__PURE__ */ React.createElement(
|
|
14311
14347
|
react.InputRightElement,
|