@oliasoft-open-source/react-ui-library 4.13.0-beta-18 → 4.13.0-beta-19
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/index.d.ts +2 -2
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1042,7 +1042,6 @@ declare interface IPredefinedOption {
|
|
|
1042
1042
|
label: string;
|
|
1043
1043
|
valueKey?: string;
|
|
1044
1044
|
unit?: string;
|
|
1045
|
-
linked?: boolean;
|
|
1046
1045
|
}
|
|
1047
1046
|
|
|
1048
1047
|
export declare interface IPrintHeaderProps {
|
|
@@ -1566,6 +1565,7 @@ export declare interface IUnitInputProps {
|
|
|
1566
1565
|
warning?: string | boolean | null;
|
|
1567
1566
|
predefinedOptions?: IPredefinedOption[] | null;
|
|
1568
1567
|
initialPredefinedOption?: string;
|
|
1568
|
+
predefinedOptionLinked?: boolean;
|
|
1569
1569
|
validationCallback?: (name: string, error: string | null) => any;
|
|
1570
1570
|
disabledValidation?: boolean;
|
|
1571
1571
|
allowEmpty?: boolean;
|
|
@@ -1871,7 +1871,7 @@ declare type TUnitTableCellShape = TCellShape | IUnitTableStaticCell | IUnitTabl
|
|
|
1871
1871
|
|
|
1872
1872
|
declare type UnitContextType = any;
|
|
1873
1873
|
|
|
1874
|
-
export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, error, left, small, width, value, unitkey, initUnit, noConversion, onChange, onClick, onFocus, onSwitchUnit, unitTemplate, testId, warning, predefinedOptions, initialPredefinedOption, validationCallback, disabledValidation, allowEmpty, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, roundDisplayValue, }: IUnitInputProps) => JSX_2.Element;
|
|
1874
|
+
export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, error, left, small, width, value, unitkey, initUnit, noConversion, onChange, onClick, onFocus, onSwitchUnit, unitTemplate, testId, warning, predefinedOptions, initialPredefinedOption, predefinedOptionLinked, validationCallback, disabledValidation, allowEmpty, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, roundDisplayValue, }: IUnitInputProps) => JSX_2.Element;
|
|
1875
1875
|
|
|
1876
1876
|
export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitTableProps) => JSX_2.Element;
|
|
1877
1877
|
|
package/dist/index.js
CHANGED
|
@@ -70292,6 +70292,7 @@ const PredefinedOptionsMenu = ({
|
|
|
70292
70292
|
onPredefinedOptionSelect,
|
|
70293
70293
|
disabled: disabled2,
|
|
70294
70294
|
initialPredefinedOption,
|
|
70295
|
+
predefinedOptionLinked,
|
|
70295
70296
|
predefinedOptionsMenuState,
|
|
70296
70297
|
setPredefinedOptionsMenuState,
|
|
70297
70298
|
testId
|
|
@@ -70352,7 +70353,7 @@ const PredefinedOptionsMenu = ({
|
|
|
70352
70353
|
if (initialPredefinedOptionObject) {
|
|
70353
70354
|
setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
|
|
70354
70355
|
setFoundPredefinedMenuOption(initialPredefinedOptionObject);
|
|
70355
|
-
if (
|
|
70356
|
+
if (predefinedOptionLinked) {
|
|
70356
70357
|
onPredefinedOptionSelect(initialPredefinedOptionObject.value, {
|
|
70357
70358
|
predefinedSelected: true,
|
|
70358
70359
|
predefinedOption: initialPredefinedOptionObject
|
|
@@ -70377,7 +70378,7 @@ const PredefinedOptionsMenu = ({
|
|
|
70377
70378
|
setPredefinedOptionsMenuState(PredefinedOptionsMenuState.CUSTOM);
|
|
70378
70379
|
setFoundPredefinedMenuOption(void 0);
|
|
70379
70380
|
}
|
|
70380
|
-
}, [extractedValue]);
|
|
70381
|
+
}, [extractedValue, predefinedOptionLinked]);
|
|
70381
70382
|
const sectionsPredefinedMenu = [
|
|
70382
70383
|
{
|
|
70383
70384
|
type: MenuType.OPTION,
|
|
@@ -70445,6 +70446,7 @@ const UnitInput = ({
|
|
|
70445
70446
|
warning: warning2 = null,
|
|
70446
70447
|
predefinedOptions,
|
|
70447
70448
|
initialPredefinedOption = "",
|
|
70449
|
+
predefinedOptionLinked = true,
|
|
70448
70450
|
validationCallback = () => ({ name: "", error: null }),
|
|
70449
70451
|
disabledValidation = false,
|
|
70450
70452
|
allowEmpty = false,
|
|
@@ -70455,7 +70457,7 @@ const UnitInput = ({
|
|
|
70455
70457
|
}) => {
|
|
70456
70458
|
const context2 = useUnitContext();
|
|
70457
70459
|
const runAfterUpdate = useRunAfterUpdate();
|
|
70458
|
-
const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(PredefinedOptionsMenuState.
|
|
70460
|
+
const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(PredefinedOptionsMenuState.PREDEFINED);
|
|
70459
70461
|
if (typeof value === "number") {
|
|
70460
70462
|
value = `${value}`;
|
|
70461
70463
|
}
|
|
@@ -70531,23 +70533,30 @@ const UnitInput = ({
|
|
|
70531
70533
|
};
|
|
70532
70534
|
useEffect(() => {
|
|
70533
70535
|
if (initDisplayUnit) {
|
|
70536
|
+
let newValue, newUnit = "";
|
|
70534
70537
|
if (previousInitUnit !== initDisplayUnit) {
|
|
70535
|
-
safeConvertValue({
|
|
70538
|
+
const { value: resultValue } = safeConvertValue({
|
|
70536
70539
|
value,
|
|
70537
70540
|
toUnit: initDisplayUnit,
|
|
70538
70541
|
unitkey,
|
|
70539
70542
|
defaultFromUnit: propUnit,
|
|
70540
70543
|
doNotConvertValue: noConversion
|
|
70541
70544
|
});
|
|
70545
|
+
newValue = resultValue;
|
|
70546
|
+
newUnit = initDisplayUnit;
|
|
70542
70547
|
} else if (withUnit(displayLayer.value, displayLayer.unit) !== value) {
|
|
70543
|
-
safeConvertValue({
|
|
70548
|
+
const { value: resultValue } = safeConvertValue({
|
|
70544
70549
|
value,
|
|
70545
70550
|
toUnit: displayLayer.unit,
|
|
70546
70551
|
unitkey,
|
|
70547
70552
|
defaultFromUnit: propUnit,
|
|
70548
70553
|
doNotConvertValue: noConversion
|
|
70549
70554
|
});
|
|
70550
|
-
|
|
70555
|
+
newValue = resultValue;
|
|
70556
|
+
newUnit = displayLayer.unit;
|
|
70557
|
+
}
|
|
70558
|
+
if (newValue !== void 0 && !initialPredefinedOption) {
|
|
70559
|
+
setDisplayLayer({ value: newValue, unit: newUnit });
|
|
70551
70560
|
}
|
|
70552
70561
|
}
|
|
70553
70562
|
}, [initDisplayUnit, value, error2]);
|
|
@@ -70584,7 +70593,7 @@ const UnitInput = ({
|
|
|
70584
70593
|
displayLayer,
|
|
70585
70594
|
onPredefinedOptionSelect: (newValue, optionState) => {
|
|
70586
70595
|
var _a2;
|
|
70587
|
-
if ((_a2 = optionState == null ? void 0 : optionState.predefinedOption) == null ? void 0 : _a2.
|
|
70596
|
+
if (predefinedOptionLinked && ((_a2 = optionState == null ? void 0 : optionState.predefinedOption) == null ? void 0 : _a2.unit)) {
|
|
70588
70597
|
onChange({
|
|
70589
70598
|
target: {
|
|
70590
70599
|
value: withUnit(displayLayer == null ? void 0 : displayLayer.value, displayLayer == null ? void 0 : displayLayer.unit),
|
|
@@ -70610,6 +70619,7 @@ const UnitInput = ({
|
|
|
70610
70619
|
},
|
|
70611
70620
|
disabled: disabled2,
|
|
70612
70621
|
initialPredefinedOption,
|
|
70622
|
+
predefinedOptionLinked,
|
|
70613
70623
|
predefinedOptionsMenuState,
|
|
70614
70624
|
setPredefinedOptionsMenuState
|
|
70615
70625
|
}
|