@oliasoft-open-source/react-ui-library 4.13.0-beta-15 → 4.13.0-beta-16
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 +5 -7
- package/dist/index.js +180 -134
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1038,9 +1038,11 @@ export declare interface IPortalProps {
|
|
|
1038
1038
|
}
|
|
1039
1039
|
|
|
1040
1040
|
declare interface IPredefinedOption {
|
|
1041
|
-
value
|
|
1041
|
+
value: string;
|
|
1042
1042
|
label: string;
|
|
1043
1043
|
valueKey?: string;
|
|
1044
|
+
unit?: string;
|
|
1045
|
+
linked?: boolean;
|
|
1044
1046
|
}
|
|
1045
1047
|
|
|
1046
1048
|
export declare interface IPrintHeaderProps {
|
|
@@ -1560,17 +1562,13 @@ export declare interface IUnitInputProps {
|
|
|
1560
1562
|
unitkey?: string;
|
|
1561
1563
|
initUnit?: string;
|
|
1562
1564
|
noConversion?: boolean;
|
|
1563
|
-
doNotConvertValue?: boolean;
|
|
1564
1565
|
testId?: string;
|
|
1565
1566
|
warning?: string | boolean | null;
|
|
1566
1567
|
predefinedOptions?: IPredefinedOption[] | null;
|
|
1567
|
-
initialPredefinedOption?:
|
|
1568
|
-
shouldLinkAutomaticly?: boolean;
|
|
1569
|
-
selectedPredefinedOptionKey?: string;
|
|
1568
|
+
initialPredefinedOption?: string;
|
|
1570
1569
|
validationCallback?: (name: string, error: string | null) => any;
|
|
1571
1570
|
disabledValidation?: boolean;
|
|
1572
1571
|
allowEmpty?: boolean;
|
|
1573
|
-
autoValue?: string;
|
|
1574
1572
|
onChange?: TOnChangeEventHandler;
|
|
1575
1573
|
onSwitchUnit?: (unit: string) => void;
|
|
1576
1574
|
onClick?: MouseEventHandler<HTMLInputElement>;
|
|
@@ -1873,7 +1871,7 @@ declare type TUnitTableCellShape = TCellShape | IUnitTableStaticCell | IUnitTabl
|
|
|
1873
1871
|
|
|
1874
1872
|
declare type UnitContextType = any;
|
|
1875
1873
|
|
|
1876
|
-
export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, error, left, small, width, value, unitkey, initUnit, noConversion, onChange, onClick, onFocus, onSwitchUnit, unitTemplate,
|
|
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;
|
|
1877
1875
|
|
|
1878
1876
|
export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitTableProps) => JSX_2.Element;
|
|
1879
1877
|
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import React__default, { useContext, isValidElement, useState, useRef, useEffect
|
|
|
15
15
|
import * as PropTypes from "prop-types";
|
|
16
16
|
import PropTypes__default from "prop-types";
|
|
17
17
|
import ReactDOM, { createPortal, unstable_batchedUpdates, render } from "react-dom";
|
|
18
|
-
import { noop as noop$3, set, get as get$2, isString as isString$3, isNumber as isNumber$1, isBoolean as isBoolean$2, isFunction as isFunction$3, isEmpty, isArray as isArray$1, toNumber, debounce as debounce$2, isObject as isObject$5, isEqual as isEqual$4 } from "lodash";
|
|
18
|
+
import { noop as noop$3, set, get as get$2, isString as isString$3, isNumber as isNumber$1, isBoolean as isBoolean$2, isFunction as isFunction$3, isEmpty, isArray as isArray$1, toNumber, debounce as debounce$2, isObject as isObject$5, isNil, isEqual as isEqual$4 } from "lodash";
|
|
19
19
|
import { toString as toString$1, isScientificStringNum, roundToPrecision, toNum, validateNumber, cleanNumStr, stripLeadingZeros, roundToFixed, roundByMagnitude, unitFromQuantity, getUnit, KNOWN_UNITS, ALT_UNITS, isValueWithUnit, getValue as getValue$1, withUnit, convertSamePrecision, convertAndGetValue, split as split$1, label as label$b, isValidNum, getAltUnitsListByQuantity, altUnitsList, getUnitsForQuantity, roundByMagnitudeToFixed } from "@oliasoft-open-source/units";
|
|
20
20
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
21
21
|
function getDefaultExportFromCjs(x2) {
|
|
@@ -70233,6 +70233,7 @@ const safeConvertValue = ({
|
|
|
70233
70233
|
}) => {
|
|
70234
70234
|
const rawValue = getValue$1(value);
|
|
70235
70235
|
const isInvalidInput = isWrongValue(rawValue);
|
|
70236
|
+
const availableUnits = ALT_UNITS[unitkey];
|
|
70236
70237
|
if (isValueWithUnknownUnit(value)) {
|
|
70237
70238
|
return { value: rawValue };
|
|
70238
70239
|
}
|
|
@@ -70242,6 +70243,9 @@ const safeConvertValue = ({
|
|
|
70242
70243
|
if (!isValueWithUnit(value)) {
|
|
70243
70244
|
return { value };
|
|
70244
70245
|
}
|
|
70246
|
+
if (!(availableUnits == null ? void 0 : availableUnits.includes(getUnit(value)))) {
|
|
70247
|
+
return { value: rawValue };
|
|
70248
|
+
}
|
|
70245
70249
|
return convertUnit({
|
|
70246
70250
|
value,
|
|
70247
70251
|
unitkey,
|
|
@@ -70276,6 +70280,144 @@ const initializeContext = (context2) => {
|
|
|
70276
70280
|
UnitContext = context2;
|
|
70277
70281
|
}
|
|
70278
70282
|
};
|
|
70283
|
+
const extractValue = (value) => {
|
|
70284
|
+
if (isNil(value)) return value;
|
|
70285
|
+
return isValueWithUnit(value) ? getValue$1(value) : value;
|
|
70286
|
+
};
|
|
70287
|
+
const PredefinedOptionsMenu = ({
|
|
70288
|
+
predefinedOptions,
|
|
70289
|
+
displayLayer,
|
|
70290
|
+
unitkey: rootUnitKey,
|
|
70291
|
+
unitTemplate,
|
|
70292
|
+
onPredefinedOptionSelect,
|
|
70293
|
+
disabled: disabled2,
|
|
70294
|
+
initialPredefinedOption,
|
|
70295
|
+
predefinedOptionsMenuState,
|
|
70296
|
+
setPredefinedOptionsMenuState,
|
|
70297
|
+
testId
|
|
70298
|
+
}) => {
|
|
70299
|
+
const extractedValue = extractValue(displayLayer == null ? void 0 : displayLayer.value);
|
|
70300
|
+
const [foundPredefinedMenuOption, setFoundPredefinedMenuOption] = useState(void 0);
|
|
70301
|
+
const convertPredefinedOptions = ({
|
|
70302
|
+
value,
|
|
70303
|
+
unit: optionUnitKey
|
|
70304
|
+
}) => {
|
|
70305
|
+
if (!value || !rootUnitKey) return value;
|
|
70306
|
+
if (!isValueWithUnit(value)) return value;
|
|
70307
|
+
const selectedUnitKey = optionUnitKey || rootUnitKey;
|
|
70308
|
+
const preferredOptionUnit = getPreferredUnit(selectedUnitKey, unitTemplate);
|
|
70309
|
+
const { value: resultValue } = safeConvertValue({
|
|
70310
|
+
value,
|
|
70311
|
+
toUnit: preferredOptionUnit,
|
|
70312
|
+
unitkey: selectedUnitKey,
|
|
70313
|
+
defaultFromUnit: "",
|
|
70314
|
+
doNotConvertValue: false
|
|
70315
|
+
});
|
|
70316
|
+
return withUnit(resultValue, preferredOptionUnit);
|
|
70317
|
+
};
|
|
70318
|
+
const createPredefinedOption = (el2) => {
|
|
70319
|
+
const convertedValue = convertPredefinedOptions(el2);
|
|
70320
|
+
const [inputValue = "", unit2 = ""] = split$1(convertedValue);
|
|
70321
|
+
return {
|
|
70322
|
+
type: MenuType.OPTION,
|
|
70323
|
+
inline: true,
|
|
70324
|
+
onClick: () => {
|
|
70325
|
+
if (isEqual$4(foundPredefinedMenuOption, el2)) return;
|
|
70326
|
+
const validation = validateNumber(inputValue);
|
|
70327
|
+
const optionState = {
|
|
70328
|
+
predefinedSelected: true,
|
|
70329
|
+
predefinedOption: el2
|
|
70330
|
+
};
|
|
70331
|
+
if (validation.valid && !disabled2) {
|
|
70332
|
+
setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
|
|
70333
|
+
onPredefinedOptionSelect(convertedValue, optionState);
|
|
70334
|
+
setFoundPredefinedMenuOption(el2);
|
|
70335
|
+
}
|
|
70336
|
+
},
|
|
70337
|
+
label: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
70338
|
+
/* @__PURE__ */ jsx(Text, { children: el2.label }),
|
|
70339
|
+
/* @__PURE__ */ jsx(Spacer, { width: "20px", height: "0" })
|
|
70340
|
+
] }),
|
|
70341
|
+
description: `${inputValue} ${unit2}`,
|
|
70342
|
+
selected: isEqual$4(foundPredefinedMenuOption, el2) && predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED
|
|
70343
|
+
};
|
|
70344
|
+
};
|
|
70345
|
+
const initialPredefinedOptionObject = useMemo$1(() => {
|
|
70346
|
+
return predefinedOptions.find(
|
|
70347
|
+
(option2) => [option2.value, option2.label, option2.valueKey].includes(
|
|
70348
|
+
initialPredefinedOption
|
|
70349
|
+
)
|
|
70350
|
+
);
|
|
70351
|
+
}, [initialPredefinedOption]);
|
|
70352
|
+
useEffect(() => {
|
|
70353
|
+
if (initialPredefinedOptionObject) {
|
|
70354
|
+
setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
|
|
70355
|
+
setFoundPredefinedMenuOption(initialPredefinedOptionObject);
|
|
70356
|
+
if (!(initialPredefinedOptionObject == null ? void 0 : initialPredefinedOptionObject.linked)) {
|
|
70357
|
+
onPredefinedOptionSelect(initialPredefinedOptionObject.value, {
|
|
70358
|
+
predefinedSelected: true,
|
|
70359
|
+
predefinedOption: initialPredefinedOptionObject
|
|
70360
|
+
});
|
|
70361
|
+
}
|
|
70362
|
+
}
|
|
70363
|
+
}, [
|
|
70364
|
+
initialPredefinedOptionObject == null ? void 0 : initialPredefinedOptionObject.value,
|
|
70365
|
+
initialPredefinedOptionObject == null ? void 0 : initialPredefinedOptionObject.label
|
|
70366
|
+
]);
|
|
70367
|
+
useEffect(() => {
|
|
70368
|
+
const foundOption = predefinedOptions.find((option2) => {
|
|
70369
|
+
const convertedValue = convertPredefinedOptions(option2);
|
|
70370
|
+
return convertedValue === withUnit(displayLayer == null ? void 0 : displayLayer.value, (displayLayer == null ? void 0 : displayLayer.unit) ?? "");
|
|
70371
|
+
});
|
|
70372
|
+
if (foundOption || initialPredefinedOptionObject) {
|
|
70373
|
+
setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
|
|
70374
|
+
setFoundPredefinedMenuOption(
|
|
70375
|
+
foundOption || initialPredefinedOptionObject
|
|
70376
|
+
);
|
|
70377
|
+
} else {
|
|
70378
|
+
setPredefinedOptionsMenuState(PredefinedOptionsMenuState.CUSTOM);
|
|
70379
|
+
setFoundPredefinedMenuOption(void 0);
|
|
70380
|
+
}
|
|
70381
|
+
}, [extractedValue]);
|
|
70382
|
+
const sectionsPredefinedMenu = [
|
|
70383
|
+
{
|
|
70384
|
+
type: MenuType.OPTION,
|
|
70385
|
+
inline: true,
|
|
70386
|
+
onClick: () => {
|
|
70387
|
+
if (!disabled2) {
|
|
70388
|
+
setPredefinedOptionsMenuState(PredefinedOptionsMenuState.CUSTOM);
|
|
70389
|
+
}
|
|
70390
|
+
},
|
|
70391
|
+
label: "Custom",
|
|
70392
|
+
selected: predefinedOptionsMenuState === PredefinedOptionsMenuState.CUSTOM
|
|
70393
|
+
},
|
|
70394
|
+
...predefinedOptions.map(createPredefinedOption)
|
|
70395
|
+
];
|
|
70396
|
+
return /* @__PURE__ */ jsx(
|
|
70397
|
+
Menu,
|
|
70398
|
+
{
|
|
70399
|
+
testId: testId && `${testId}-predefined-menu`,
|
|
70400
|
+
maxHeight: 380,
|
|
70401
|
+
groupOrder: "first",
|
|
70402
|
+
disabled: disabled2,
|
|
70403
|
+
menu: {
|
|
70404
|
+
colored: true,
|
|
70405
|
+
trigger: "Component",
|
|
70406
|
+
component: /* @__PURE__ */ jsx(
|
|
70407
|
+
Button$1,
|
|
70408
|
+
{
|
|
70409
|
+
groupOrder: "first",
|
|
70410
|
+
active: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED,
|
|
70411
|
+
icon: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED ? "link" : "unlink"
|
|
70412
|
+
}
|
|
70413
|
+
),
|
|
70414
|
+
small: true,
|
|
70415
|
+
sections: sectionsPredefinedMenu
|
|
70416
|
+
},
|
|
70417
|
+
tooltip: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED ? foundPredefinedMenuOption == null ? void 0 : foundPredefinedMenuOption.label : ""
|
|
70418
|
+
}
|
|
70419
|
+
);
|
|
70420
|
+
};
|
|
70279
70421
|
const predefinedMenuActive = "_predefinedMenuActive_ye9w9_1";
|
|
70280
70422
|
const inputWrapper = "_inputWrapper_ye9w9_4";
|
|
70281
70423
|
const styles = {
|
|
@@ -70300,17 +70442,13 @@ const UnitInput = ({
|
|
|
70300
70442
|
onFocus = noop$3,
|
|
70301
70443
|
onSwitchUnit = noop$3,
|
|
70302
70444
|
unitTemplate,
|
|
70303
|
-
doNotConvertValue = false,
|
|
70304
70445
|
testId,
|
|
70305
70446
|
warning: warning2 = null,
|
|
70306
70447
|
predefinedOptions,
|
|
70307
|
-
initialPredefinedOption =
|
|
70308
|
-
shouldLinkAutomaticly = true,
|
|
70309
|
-
selectedPredefinedOptionKey,
|
|
70448
|
+
initialPredefinedOption = "",
|
|
70310
70449
|
validationCallback = () => ({ name: "", error: null }),
|
|
70311
70450
|
disabledValidation = false,
|
|
70312
70451
|
allowEmpty = false,
|
|
70313
|
-
autoValue,
|
|
70314
70452
|
convertBackToStorageUnit = false,
|
|
70315
70453
|
enableCosmeticRounding = true,
|
|
70316
70454
|
enableDisplayRounding = false,
|
|
@@ -70318,11 +70456,11 @@ const UnitInput = ({
|
|
|
70318
70456
|
}) => {
|
|
70319
70457
|
const context2 = useUnitContext();
|
|
70320
70458
|
const runAfterUpdate = useRunAfterUpdate();
|
|
70459
|
+
const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(PredefinedOptionsMenuState.CUSTOM);
|
|
70321
70460
|
if (typeof value === "number") {
|
|
70322
70461
|
value = `${value}`;
|
|
70323
70462
|
}
|
|
70324
70463
|
const [propValue = "", propUnit = ""] = value !== void 0 ? split$1(value) : [];
|
|
70325
|
-
const propAutoUnit = autoValue ? getUnit(autoValue) : "";
|
|
70326
70464
|
const preferredUnit = useMemo$1(
|
|
70327
70465
|
() => getPreferredUnit(unitkey, unitTemplate || (context2 == null ? void 0 : context2.unitTemplate)),
|
|
70328
70466
|
[unitkey, unitTemplate, context2 == null ? void 0 : context2.unitTemplate]
|
|
@@ -70335,39 +70473,15 @@ const UnitInput = ({
|
|
|
70335
70473
|
toUnit: initDisplayUnit,
|
|
70336
70474
|
unitkey,
|
|
70337
70475
|
defaultFromUnit: propUnit,
|
|
70338
|
-
doNotConvertValue
|
|
70476
|
+
doNotConvertValue: noConversion
|
|
70339
70477
|
});
|
|
70340
|
-
const { value:
|
|
70341
|
-
value: autoValue,
|
|
70342
|
-
toUnit: initDisplayUnit,
|
|
70343
|
-
unitkey,
|
|
70344
|
-
defaultFromUnit: propAutoUnit,
|
|
70345
|
-
doNotConvertValue
|
|
70346
|
-
});
|
|
70347
|
-
const initDisplayLayer = convertedValue !== "" ? { value: convertedValue, unit: initDisplayUnit } : convertedAutoValue !== "" ? { value: convertedAutoValue, unit: initDisplayUnit } : { value: propValue, unit: propUnit };
|
|
70478
|
+
const initDisplayLayer = convertedValue !== "" ? { value: convertedValue, unit: initDisplayUnit } : { value: propValue, unit: propUnit };
|
|
70348
70479
|
const [displayLayer, setDisplayLayer] = useState(initDisplayLayer);
|
|
70349
70480
|
const derivedAllowEmpty = allowEmpty || (displayLayer == null ? void 0 : displayLayer.value) === void 0;
|
|
70350
|
-
const
|
|
70351
|
-
initialPredefinedOption ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM
|
|
70352
|
-
);
|
|
70353
|
-
const isAutoValue = propValue === "" && autoValue;
|
|
70354
|
-
const disableInternalErrorValidationMessages = !!(disabledValidation || autoValue || disabled2);
|
|
70355
|
-
const foundPredefinedMenuOption = predefinedOptions && predefinedOptions.find((el2) => {
|
|
70356
|
-
if (!(el2 == null ? void 0 : el2.value)) return;
|
|
70357
|
-
if (selectedPredefinedOptionKey) {
|
|
70358
|
-
return selectedPredefinedOptionKey === el2.valueKey;
|
|
70359
|
-
}
|
|
70360
|
-
const predefinedMenuItemUnit = isValueWithUnit(el2.value) ? getUnit(el2.value) : "";
|
|
70361
|
-
const { value: resultValue = value } = convertUnit({
|
|
70362
|
-
value: String(value),
|
|
70363
|
-
unitkey,
|
|
70364
|
-
toUnit: predefinedMenuItemUnit
|
|
70365
|
-
});
|
|
70366
|
-
return withUnit(resultValue, predefinedMenuItemUnit) === el2.value;
|
|
70367
|
-
});
|
|
70481
|
+
const disableInternalErrorValidationMessages = !!disabledValidation || disabled2;
|
|
70368
70482
|
const getAlternativeUnits = () => {
|
|
70369
|
-
const valueToList =
|
|
70370
|
-
const initToUnit = displayLayer.unit;
|
|
70483
|
+
const valueToList = value ?? "";
|
|
70484
|
+
const initToUnit = displayLayer == null ? void 0 : displayLayer.unit;
|
|
70371
70485
|
const shouldConvert = checkConversion({
|
|
70372
70486
|
value: valueToList,
|
|
70373
70487
|
unitkey,
|
|
@@ -70425,7 +70539,7 @@ const UnitInput = ({
|
|
|
70425
70539
|
toUnit: initDisplayUnit,
|
|
70426
70540
|
unitkey,
|
|
70427
70541
|
defaultFromUnit: propUnit,
|
|
70428
|
-
doNotConvertValue
|
|
70542
|
+
doNotConvertValue: noConversion
|
|
70429
70543
|
});
|
|
70430
70544
|
newValue = resultValue;
|
|
70431
70545
|
newUnit = initDisplayUnit;
|
|
@@ -70435,96 +70549,29 @@ const UnitInput = ({
|
|
|
70435
70549
|
toUnit: displayLayer.unit,
|
|
70436
70550
|
unitkey,
|
|
70437
70551
|
defaultFromUnit: propUnit,
|
|
70438
|
-
doNotConvertValue
|
|
70552
|
+
doNotConvertValue: noConversion
|
|
70439
70553
|
});
|
|
70440
70554
|
newValue = resultValue;
|
|
70441
70555
|
newUnit = displayLayer.unit;
|
|
70442
70556
|
}
|
|
70443
|
-
if (newValue !== void 0) {
|
|
70557
|
+
if (newValue !== void 0 && !initialPredefinedOption) {
|
|
70444
70558
|
setDisplayLayer({ value: newValue, unit: newUnit });
|
|
70445
70559
|
}
|
|
70446
|
-
if (predefinedOptions) {
|
|
70447
|
-
if (foundPredefinedMenuOption && shouldLinkAutomaticly) {
|
|
70448
|
-
setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
|
|
70449
|
-
} else {
|
|
70450
|
-
setPredefinedOptionsMenuState(PredefinedOptionsMenuState.CUSTOM);
|
|
70451
|
-
}
|
|
70452
|
-
}
|
|
70453
70560
|
}
|
|
70454
|
-
}, [initDisplayUnit, value, error2
|
|
70561
|
+
}, [initDisplayUnit, value, error2]);
|
|
70455
70562
|
const alternativeUnits = getAlternativeUnits();
|
|
70456
70563
|
const displayUnitLabel = label$b(displayLayer.unit) || displayLayer.unit || "";
|
|
70457
70564
|
const noConvert = noConversion || !alternativeUnits || alternativeUnits && alternativeUnits.length === 1;
|
|
70458
70565
|
const stringName = getStringName(name2);
|
|
70459
|
-
let sectionsPredefinedMenu;
|
|
70460
|
-
const createPredefinedOption = (el2) => {
|
|
70461
|
-
const elementValue = (el2 == null ? void 0 : el2.value) ? el2.value : "";
|
|
70462
|
-
const [value2 = "", unit2 = ""] = isValueWithUnit(elementValue) ? split$1(elementValue) : [elementValue];
|
|
70463
|
-
return {
|
|
70464
|
-
type: MenuType.OPTION,
|
|
70465
|
-
inline: true,
|
|
70466
|
-
onClick: () => {
|
|
70467
|
-
const validation = validateNumber(value2);
|
|
70468
|
-
if (validation.valid && !disabled2) {
|
|
70469
|
-
setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
|
|
70470
|
-
onChange({
|
|
70471
|
-
target: {
|
|
70472
|
-
value: elementValue,
|
|
70473
|
-
name: typeof name2 === "string" ? name2 : (name2 == null ? void 0 : name2.fieldName) || "",
|
|
70474
|
-
predefinedSelected: true,
|
|
70475
|
-
predefinedOption: el2
|
|
70476
|
-
}
|
|
70477
|
-
});
|
|
70478
|
-
}
|
|
70479
|
-
},
|
|
70480
|
-
label: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
70481
|
-
/* @__PURE__ */ jsx(Text, { children: el2.label }),
|
|
70482
|
-
/* @__PURE__ */ jsx(Spacer, { width: "20px", height: "0" })
|
|
70483
|
-
] }),
|
|
70484
|
-
description: isValueWithUnit(elementValue) ? `${value2} ${unit2}` : elementValue,
|
|
70485
|
-
selected: foundPredefinedMenuOption === el2 && predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED
|
|
70486
|
-
};
|
|
70487
|
-
};
|
|
70488
|
-
sectionsPredefinedMenu = [
|
|
70489
|
-
{
|
|
70490
|
-
type: MenuType.OPTION,
|
|
70491
|
-
inline: true,
|
|
70492
|
-
onClick: () => {
|
|
70493
|
-
if (predefinedOptionsMenuState !== PredefinedOptionsMenuState.CUSTOM && !disabled2) {
|
|
70494
|
-
onChange({
|
|
70495
|
-
target: {
|
|
70496
|
-
value: withUnit(displayLayer.value, displayLayer.unit),
|
|
70497
|
-
name: typeof name2 === "string" ? name2 : (name2 == null ? void 0 : name2.fieldName) || ""
|
|
70498
|
-
}
|
|
70499
|
-
});
|
|
70500
|
-
}
|
|
70501
|
-
},
|
|
70502
|
-
label: "Custom",
|
|
70503
|
-
selected: predefinedOptionsMenuState === PredefinedOptionsMenuState.CUSTOM
|
|
70504
|
-
}
|
|
70505
|
-
];
|
|
70506
|
-
if (predefinedOptions == null ? void 0 : predefinedOptions.length) {
|
|
70507
|
-
const dynamicOptions = predefinedOptions.map(createPredefinedOption);
|
|
70508
|
-
sectionsPredefinedMenu = [...sectionsPredefinedMenu, ...dynamicOptions];
|
|
70509
|
-
}
|
|
70510
70566
|
const getPlaceholder = (placeholder22) => {
|
|
70511
|
-
if (
|
|
70512
|
-
const { value: resultValue } = safeConvertValue({
|
|
70513
|
-
value: autoValue,
|
|
70514
|
-
toUnit: displayLayer.unit,
|
|
70515
|
-
unitkey,
|
|
70516
|
-
defaultFromUnit: propAutoUnit,
|
|
70517
|
-
doNotConvertValue
|
|
70518
|
-
});
|
|
70519
|
-
return resultValue;
|
|
70520
|
-
} else if (isValueWithUnit(placeholder22)) {
|
|
70567
|
+
if (isValueWithUnit(placeholder22)) {
|
|
70521
70568
|
const placeholderUnit = getUnit(placeholder22);
|
|
70522
70569
|
const { value: resultValue } = safeConvertValue({
|
|
70523
70570
|
value: placeholder22,
|
|
70524
70571
|
toUnit: displayLayer.unit,
|
|
70525
70572
|
unitkey,
|
|
70526
70573
|
defaultFromUnit: placeholderUnit,
|
|
70527
|
-
doNotConvertValue
|
|
70574
|
+
doNotConvertValue: noConversion
|
|
70528
70575
|
});
|
|
70529
70576
|
return resultValue;
|
|
70530
70577
|
}
|
|
@@ -70536,32 +70583,31 @@ const UnitInput = ({
|
|
|
70536
70583
|
className: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED ? cx$2(styles.predefinedMenuActive) : "",
|
|
70537
70584
|
children: /* @__PURE__ */ jsxs(InputGroup, { small: small2, width: width2, children: [
|
|
70538
70585
|
predefinedOptions && /* @__PURE__ */ jsx(
|
|
70539
|
-
|
|
70586
|
+
PredefinedOptionsMenu,
|
|
70540
70587
|
{
|
|
70541
|
-
|
|
70542
|
-
|
|
70543
|
-
|
|
70544
|
-
|
|
70545
|
-
|
|
70546
|
-
|
|
70547
|
-
|
|
70548
|
-
|
|
70549
|
-
|
|
70550
|
-
|
|
70551
|
-
|
|
70552
|
-
|
|
70553
|
-
Button$1,
|
|
70554
|
-
{
|
|
70555
|
-
groupOrder: "first",
|
|
70556
|
-
active: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED,
|
|
70557
|
-
icon: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED ? "link" : "unlink"
|
|
70558
|
-
}
|
|
70559
|
-
),
|
|
70560
|
-
small: small2,
|
|
70561
|
-
sections: sectionsPredefinedMenu
|
|
70588
|
+
testId,
|
|
70589
|
+
unitTemplate: unitTemplate || (context2 == null ? void 0 : context2.unitTemplate),
|
|
70590
|
+
unitkey,
|
|
70591
|
+
predefinedOptions,
|
|
70592
|
+
displayLayer,
|
|
70593
|
+
onPredefinedOptionSelect: (newValue, optionState) => {
|
|
70594
|
+
onChange({
|
|
70595
|
+
target: {
|
|
70596
|
+
value: newValue,
|
|
70597
|
+
name: stringName,
|
|
70598
|
+
predefinedSelected: optionState == null ? void 0 : optionState.predefinedSelected,
|
|
70599
|
+
predefinedOption: optionState == null ? void 0 : optionState.predefinedOption
|
|
70562
70600
|
}
|
|
70563
|
-
}
|
|
70564
|
-
|
|
70601
|
+
});
|
|
70602
|
+
setDisplayLayer({
|
|
70603
|
+
value: newValue,
|
|
70604
|
+
unit: getUnit(newValue) || displayLayer.unit
|
|
70605
|
+
});
|
|
70606
|
+
},
|
|
70607
|
+
disabled: disabled2,
|
|
70608
|
+
initialPredefinedOption,
|
|
70609
|
+
predefinedOptionsMenuState,
|
|
70610
|
+
setPredefinedOptionsMenuState
|
|
70565
70611
|
}
|
|
70566
70612
|
),
|
|
70567
70613
|
/* @__PURE__ */ jsx("div", { className: styles.inputWrapper, children: /* @__PURE__ */ jsx(
|
|
@@ -70609,7 +70655,7 @@ const UnitInput = ({
|
|
|
70609
70655
|
inline: true,
|
|
70610
70656
|
onClick: (evt) => {
|
|
70611
70657
|
evt.stopPropagation();
|
|
70612
|
-
onClickUnit(
|
|
70658
|
+
onClickUnit(value2, altUnit);
|
|
70613
70659
|
},
|
|
70614
70660
|
description: displayUnit,
|
|
70615
70661
|
selected: displayUnit === displayUnitLabel,
|