@northlight/ui 2.36.8 → 2.36.10
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.js
CHANGED
|
@@ -3,7 +3,7 @@ export { AbsoluteCenter, AccordionIcon, AlertDescription, AlertDialog, AlertDial
|
|
|
3
3
|
import React, { useState, useEffect, useRef, isValidElement, cloneElement, Children, createContext, useContext, forwardRef as forwardRef$1, useImperativeHandle, memo, useMemo, useCallback } from 'react';
|
|
4
4
|
import { CreatableSelect, chakraComponents, AsyncSelect, Select as Select$3 } from 'chakra-react-select';
|
|
5
5
|
export { AsyncCreatableSelect, AsyncSelect, Select as ChakraReactSelect, CreatableSelect, chakraComponents as selectChakraComponents } from 'chakra-react-select';
|
|
6
|
-
import { isNil, last, map, prop, difference, replace, split, path, T, keys, omit,
|
|
6
|
+
import { isNil, last, map, prop, difference, replace, split, path, T, keys, omit, merge, isEmpty, identity, any, ifElse, gt, always, defaultTo, take, inc, dec, forEach, is, trim, values, equals, mergeAll, toLower, find, times, has, not, all, filter, test, indexOf, remove, insert, intersection, findIndex, concat, head, match, length, propEq } from 'ramda';
|
|
7
7
|
import { useFocusManager, FocusScope, useFocusRing } from '@react-aria/focus';
|
|
8
8
|
import { useForm, FormProvider, useFormContext, Controller } from 'react-hook-form';
|
|
9
9
|
export { useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from 'react-hook-form';
|
|
@@ -1614,7 +1614,10 @@ const themeMap = {
|
|
|
1614
1614
|
const processColorSchemeBasedOnTheme = ({
|
|
1615
1615
|
currentTheme,
|
|
1616
1616
|
colorScheme
|
|
1617
|
-
}) =>
|
|
1617
|
+
}) => {
|
|
1618
|
+
var _a;
|
|
1619
|
+
return (_a = path([currentTheme, colorScheme], themeMap)) != null ? _a : colorScheme;
|
|
1620
|
+
};
|
|
1618
1621
|
|
|
1619
1622
|
const Tag$1 = {
|
|
1620
1623
|
parts: ["container"],
|
|
@@ -13482,10 +13485,8 @@ const FormattedNumberInput = (_a) => {
|
|
|
13482
13485
|
"inputRightElement",
|
|
13483
13486
|
"onBlur"
|
|
13484
13487
|
]);
|
|
13485
|
-
const [valueState, setValueState] = useState(valueProp);
|
|
13486
|
-
const isControlled = typeof valueProp !== "undefined";
|
|
13487
|
-
const value = isControlled ? valueProp : valueState;
|
|
13488
13488
|
const props = presetMap[preset];
|
|
13489
|
+
const value = valueProp != null ? valueProp : "";
|
|
13489
13490
|
const getNumberFormatValues = (number) => ({
|
|
13490
13491
|
floatValue: number,
|
|
13491
13492
|
formattedValue: numericFormatter(number.toString(), props),
|
|
@@ -13498,18 +13499,15 @@ const FormattedNumberInput = (_a) => {
|
|
|
13498
13499
|
const factor = isPercentage ? 100 : 1;
|
|
13499
13500
|
if (vNum * factor > max) {
|
|
13500
13501
|
const newValue = roundToPrecision(max / factor, numberOfDecimals);
|
|
13501
|
-
setValueState(newValue);
|
|
13502
13502
|
onChange(getNumberFormatValues(newValue));
|
|
13503
13503
|
}
|
|
13504
13504
|
if (vNum * factor < min) {
|
|
13505
13505
|
const newValue = roundToPrecision(min / factor, numberOfDecimals);
|
|
13506
|
-
setValueState(newValue);
|
|
13507
13506
|
onChange(getNumberFormatValues(newValue));
|
|
13508
13507
|
}
|
|
13509
13508
|
};
|
|
13510
13509
|
const onValueChangeHandler = (values, sourceInfo) => {
|
|
13511
13510
|
const newFloatValue = values.floatValue && isPercentage ? roundToPrecision(values.floatValue / 100, numberOfDecimals) : values.floatValue;
|
|
13512
|
-
setValueState(newFloatValue);
|
|
13513
13511
|
onChange(
|
|
13514
13512
|
__spreadProps$3(__spreadValues$k({}, values), {
|
|
13515
13513
|
floatValue: newFloatValue
|
|
@@ -14745,13 +14743,9 @@ const ComboPicker = (_a) => {
|
|
|
14745
14743
|
]);
|
|
14746
14744
|
var _a2, _b2, _c;
|
|
14747
14745
|
const { isOpen, onToggle, onClose } = useDisclosure();
|
|
14748
|
-
const [
|
|
14749
|
-
const [
|
|
14746
|
+
const [inputValue, setInputValue] = useState(valueProp == null ? void 0 : valueProp.input);
|
|
14747
|
+
const [selectOption, setSelectOption] = useState(valueProp == null ? void 0 : valueProp.option);
|
|
14750
14748
|
const [enableSelectInput, setEnableSelectInput] = useState(false);
|
|
14751
|
-
const isInputValueControlled = typeof (valueProp == null ? void 0 : valueProp.input) !== "undefined";
|
|
14752
|
-
const inputValue = isInputValueControlled ? valueProp.input : inputValueState;
|
|
14753
|
-
const isOptionControlled = typeof (valueProp == null ? void 0 : valueProp.option) !== "undefined";
|
|
14754
|
-
const selectOption = isOptionControlled ? valueProp.option : selectOptionState;
|
|
14755
14749
|
const buttonRef = useRef();
|
|
14756
14750
|
const selectRef = useRef();
|
|
14757
14751
|
const getNewValue = (option, input) => {
|
|
@@ -14759,8 +14753,7 @@ const ComboPicker = (_a) => {
|
|
|
14759
14753
|
return is(Number, input) ? { input: Number(input), option: newValueOption } : { option: newValueOption };
|
|
14760
14754
|
};
|
|
14761
14755
|
const handleInputChange = (newInputvalue) => {
|
|
14762
|
-
const newValue = getNewValue(
|
|
14763
|
-
setInputValueState(newValue.input);
|
|
14756
|
+
const newValue = getNewValue(valueProp == null ? void 0 : valueProp.option, newInputvalue);
|
|
14764
14757
|
onChange == null ? void 0 : onChange(newValue);
|
|
14765
14758
|
};
|
|
14766
14759
|
const handleSelectClose = () => {
|
|
@@ -14772,8 +14765,7 @@ const ComboPicker = (_a) => {
|
|
|
14772
14765
|
};
|
|
14773
14766
|
const handleSelectChange = (selectedOption) => {
|
|
14774
14767
|
if (selectedOption) {
|
|
14775
|
-
|
|
14776
|
-
onChange == null ? void 0 : onChange(getNewValue(selectedOption, inputValue));
|
|
14768
|
+
onChange == null ? void 0 : onChange(getNewValue(selectedOption, valueProp == null ? void 0 : valueProp.input));
|
|
14777
14769
|
if (isOpen) {
|
|
14778
14770
|
handleSelectClose();
|
|
14779
14771
|
}
|
|
@@ -14791,20 +14783,13 @@ const ComboPicker = (_a) => {
|
|
|
14791
14783
|
}
|
|
14792
14784
|
}, [enableSelectInput]);
|
|
14793
14785
|
useEffect(() => {
|
|
14794
|
-
|
|
14795
|
-
const
|
|
14796
|
-
const
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
if (needsToCorrectInput) {
|
|
14802
|
-
setInputValueState(input);
|
|
14803
|
-
}
|
|
14804
|
-
if (needsToCorrectOption || needsToCorrectInput) {
|
|
14805
|
-
onChange == null ? void 0 : onChange(getNewValue(option, input));
|
|
14806
|
-
}
|
|
14807
|
-
}, [inputValue, defaultToZeroIfEmpty]);
|
|
14786
|
+
var _a3, _b3;
|
|
14787
|
+
const option = (_a3 = valueProp == null ? void 0 : valueProp.option) != null ? _a3 : options[0];
|
|
14788
|
+
const input = defaultToZeroIfEmpty ? (_b3 = valueProp == null ? void 0 : valueProp.input) != null ? _b3 : 0 : valueProp == null ? void 0 : valueProp.input;
|
|
14789
|
+
setSelectOption(option);
|
|
14790
|
+
setInputValue(input);
|
|
14791
|
+
onChange == null ? void 0 : onChange(getNewValue(option, input));
|
|
14792
|
+
}, [valueProp == null ? void 0 : valueProp.input, valueProp == null ? void 0 : valueProp.option, defaultToZeroIfEmpty, options]);
|
|
14808
14793
|
const buttonWidth = (_b2 = (_a2 = buttonRef.current) == null ? void 0 : _a2.offsetWidth) != null ? _b2 : 0;
|
|
14809
14794
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
14810
14795
|
FormattedNumberInput,
|