@oliasoft-open-source/react-ui-library 4.13.0-beta-19 → 4.13.0

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 CHANGED
@@ -1038,10 +1038,9 @@ export declare interface IPortalProps {
1038
1038
  }
1039
1039
 
1040
1040
  declare interface IPredefinedOption {
1041
- value: string;
1041
+ value?: string;
1042
1042
  label: string;
1043
1043
  valueKey?: string;
1044
- unit?: string;
1045
1044
  }
1046
1045
 
1047
1046
  export declare interface IPrintHeaderProps {
@@ -1561,14 +1560,17 @@ export declare interface IUnitInputProps {
1561
1560
  unitkey?: string;
1562
1561
  initUnit?: string;
1563
1562
  noConversion?: boolean;
1563
+ doNotConvertValue?: boolean;
1564
1564
  testId?: string;
1565
1565
  warning?: string | boolean | null;
1566
1566
  predefinedOptions?: IPredefinedOption[] | null;
1567
- initialPredefinedOption?: string;
1568
- predefinedOptionLinked?: boolean;
1567
+ initialPredefinedOption?: boolean;
1568
+ shouldLinkAutomaticly?: boolean;
1569
+ selectedPredefinedOptionKey?: string;
1569
1570
  validationCallback?: (name: string, error: string | null) => any;
1570
1571
  disabledValidation?: boolean;
1571
1572
  allowEmpty?: boolean;
1573
+ autoValue?: string;
1572
1574
  onChange?: TOnChangeEventHandler;
1573
1575
  onSwitchUnit?: (unit: string) => void;
1574
1576
  onClick?: MouseEventHandler<HTMLInputElement>;
@@ -1871,7 +1873,7 @@ declare type TUnitTableCellShape = TCellShape | IUnitTableStaticCell | IUnitTabl
1871
1873
 
1872
1874
  declare type UnitContextType = any;
1873
1875
 
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;
1876
+ export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, error, left, small, width, value, unitkey, initUnit, noConversion, onChange, onClick, onFocus, onSwitchUnit, unitTemplate, doNotConvertValue, testId, warning, predefinedOptions, initialPredefinedOption, shouldLinkAutomaticly, selectedPredefinedOptionKey, validationCallback, disabledValidation, allowEmpty, autoValue, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, roundDisplayValue, }: IUnitInputProps) => JSX_2.Element;
1875
1877
 
1876
1878
  export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitTableProps) => JSX_2.Element;
1877
1879
 
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, isNil, 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, 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,7 +70233,6 @@ const safeConvertValue = ({
70233
70233
  }) => {
70234
70234
  const rawValue = getValue$1(value);
70235
70235
  const isInvalidInput = isWrongValue(rawValue);
70236
- const availableUnits = ALT_UNITS[unitkey];
70237
70236
  if (isValueWithUnknownUnit(value)) {
70238
70237
  return { value: rawValue };
70239
70238
  }
@@ -70243,9 +70242,6 @@ const safeConvertValue = ({
70243
70242
  if (!isValueWithUnit(value)) {
70244
70243
  return { value };
70245
70244
  }
70246
- if (!(availableUnits == null ? void 0 : availableUnits.includes(getUnit(value)))) {
70247
- return { value: rawValue };
70248
- }
70249
70245
  return convertUnit({
70250
70246
  value,
70251
70247
  unitkey,
@@ -70280,144 +70276,6 @@ const initializeContext = (context2) => {
70280
70276
  UnitContext = context2;
70281
70277
  }
70282
70278
  };
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
- predefinedOptionLinked,
70296
- predefinedOptionsMenuState,
70297
- setPredefinedOptionsMenuState,
70298
- testId
70299
- }) => {
70300
- const extractedValue = extractValue(displayLayer == null ? void 0 : displayLayer.value);
70301
- const [foundPredefinedMenuOption, setFoundPredefinedMenuOption] = useState(void 0);
70302
- const convertPredefinedOptions = ({
70303
- value,
70304
- unit: optionUnitKey
70305
- }) => {
70306
- if (!value || !rootUnitKey) return value;
70307
- if (!isValueWithUnit(value)) return value;
70308
- const selectedUnitKey = optionUnitKey || rootUnitKey;
70309
- const preferredOptionUnit = getPreferredUnit(selectedUnitKey, unitTemplate);
70310
- const { value: resultValue } = safeConvertValue({
70311
- value,
70312
- toUnit: preferredOptionUnit,
70313
- unitkey: selectedUnitKey,
70314
- defaultFromUnit: "",
70315
- doNotConvertValue: false
70316
- });
70317
- return withUnit(resultValue, preferredOptionUnit);
70318
- };
70319
- const createPredefinedOption = (el2) => {
70320
- const convertedValue = convertPredefinedOptions(el2);
70321
- const [inputValue = "", unit2 = ""] = split$1(convertedValue);
70322
- return {
70323
- type: MenuType.OPTION,
70324
- inline: true,
70325
- onClick: () => {
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 (predefinedOptionLinked) {
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, predefinedOptionLinked]);
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
- };
70421
70279
  const predefinedMenuActive = "_predefinedMenuActive_ye9w9_1";
70422
70280
  const inputWrapper = "_inputWrapper_ye9w9_4";
70423
70281
  const styles = {
@@ -70442,14 +70300,17 @@ const UnitInput = ({
70442
70300
  onFocus = noop$3,
70443
70301
  onSwitchUnit = noop$3,
70444
70302
  unitTemplate,
70303
+ doNotConvertValue = false,
70445
70304
  testId,
70446
70305
  warning: warning2 = null,
70447
70306
  predefinedOptions,
70448
- initialPredefinedOption = "",
70449
- predefinedOptionLinked = true,
70307
+ initialPredefinedOption = false,
70308
+ shouldLinkAutomaticly = true,
70309
+ selectedPredefinedOptionKey,
70450
70310
  validationCallback = () => ({ name: "", error: null }),
70451
70311
  disabledValidation = false,
70452
70312
  allowEmpty = false,
70313
+ autoValue,
70453
70314
  convertBackToStorageUnit = false,
70454
70315
  enableCosmeticRounding = true,
70455
70316
  enableDisplayRounding = false,
@@ -70457,11 +70318,11 @@ const UnitInput = ({
70457
70318
  }) => {
70458
70319
  const context2 = useUnitContext();
70459
70320
  const runAfterUpdate = useRunAfterUpdate();
70460
- const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(PredefinedOptionsMenuState.PREDEFINED);
70461
70321
  if (typeof value === "number") {
70462
70322
  value = `${value}`;
70463
70323
  }
70464
70324
  const [propValue = "", propUnit = ""] = value !== void 0 ? split$1(value) : [];
70325
+ const propAutoUnit = autoValue ? getUnit(autoValue) : "";
70465
70326
  const preferredUnit = useMemo$1(
70466
70327
  () => getPreferredUnit(unitkey, unitTemplate || (context2 == null ? void 0 : context2.unitTemplate)),
70467
70328
  [unitkey, unitTemplate, context2 == null ? void 0 : context2.unitTemplate]
@@ -70474,15 +70335,39 @@ const UnitInput = ({
70474
70335
  toUnit: initDisplayUnit,
70475
70336
  unitkey,
70476
70337
  defaultFromUnit: propUnit,
70477
- doNotConvertValue: noConversion
70338
+ doNotConvertValue
70478
70339
  });
70479
- const initDisplayLayer = convertedValue !== "" ? { value: convertedValue, unit: initDisplayUnit } : { value: propValue, unit: propUnit };
70340
+ const { value: convertedAutoValue } = safeConvertValue({
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 };
70480
70348
  const [displayLayer, setDisplayLayer] = useState(initDisplayLayer);
70481
70349
  const derivedAllowEmpty = allowEmpty || (displayLayer == null ? void 0 : displayLayer.value) === void 0;
70482
- const disableInternalErrorValidationMessages = !!disabledValidation || disabled2;
70350
+ const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(
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
+ });
70483
70368
  const getAlternativeUnits = () => {
70484
- const valueToList = value ?? "";
70485
- const initToUnit = displayLayer == null ? void 0 : displayLayer.unit;
70369
+ const valueToList = isAutoValue ? autoValue : value ?? "";
70370
+ const initToUnit = displayLayer.unit;
70486
70371
  const shouldConvert = checkConversion({
70487
70372
  value: valueToList,
70488
70373
  unitkey,
@@ -70540,7 +70425,7 @@ const UnitInput = ({
70540
70425
  toUnit: initDisplayUnit,
70541
70426
  unitkey,
70542
70427
  defaultFromUnit: propUnit,
70543
- doNotConvertValue: noConversion
70428
+ doNotConvertValue
70544
70429
  });
70545
70430
  newValue = resultValue;
70546
70431
  newUnit = initDisplayUnit;
@@ -70550,29 +70435,96 @@ const UnitInput = ({
70550
70435
  toUnit: displayLayer.unit,
70551
70436
  unitkey,
70552
70437
  defaultFromUnit: propUnit,
70553
- doNotConvertValue: noConversion
70438
+ doNotConvertValue
70554
70439
  });
70555
70440
  newValue = resultValue;
70556
70441
  newUnit = displayLayer.unit;
70557
70442
  }
70558
- if (newValue !== void 0 && !initialPredefinedOption) {
70443
+ if (newValue !== void 0) {
70559
70444
  setDisplayLayer({ value: newValue, unit: newUnit });
70560
70445
  }
70446
+ if (predefinedOptions) {
70447
+ if (foundPredefinedMenuOption && shouldLinkAutomaticly) {
70448
+ setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
70449
+ } else {
70450
+ setPredefinedOptionsMenuState(PredefinedOptionsMenuState.CUSTOM);
70451
+ }
70452
+ }
70561
70453
  }
70562
- }, [initDisplayUnit, value, error2]);
70454
+ }, [initDisplayUnit, value, error2, shouldLinkAutomaticly]);
70563
70455
  const alternativeUnits = getAlternativeUnits();
70564
70456
  const displayUnitLabel = label$b(displayLayer.unit) || displayLayer.unit || "";
70565
70457
  const noConvert = noConversion || !alternativeUnits || alternativeUnits && alternativeUnits.length === 1;
70566
70458
  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
+ }
70567
70510
  const getPlaceholder = (placeholder22) => {
70568
- if (isValueWithUnit(placeholder22)) {
70511
+ if (isAutoValue) {
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)) {
70569
70521
  const placeholderUnit = getUnit(placeholder22);
70570
70522
  const { value: resultValue } = safeConvertValue({
70571
70523
  value: placeholder22,
70572
70524
  toUnit: displayLayer.unit,
70573
70525
  unitkey,
70574
70526
  defaultFromUnit: placeholderUnit,
70575
- doNotConvertValue: noConversion
70527
+ doNotConvertValue
70576
70528
  });
70577
70529
  return resultValue;
70578
70530
  }
@@ -70584,44 +70536,32 @@ const UnitInput = ({
70584
70536
  className: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED ? cx$2(styles.predefinedMenuActive) : "",
70585
70537
  children: /* @__PURE__ */ jsxs(InputGroup, { small: small2, width: width2, children: [
70586
70538
  predefinedOptions && /* @__PURE__ */ jsx(
70587
- PredefinedOptionsMenu,
70539
+ Tooltip,
70588
70540
  {
70589
- testId,
70590
- unitTemplate: unitTemplate || (context2 == null ? void 0 : context2.unitTemplate),
70591
- unitkey,
70592
- predefinedOptions,
70593
- displayLayer,
70594
- onPredefinedOptionSelect: (newValue, optionState) => {
70595
- var _a2;
70596
- if (predefinedOptionLinked && ((_a2 = optionState == null ? void 0 : optionState.predefinedOption) == null ? void 0 : _a2.unit)) {
70597
- onChange({
70598
- target: {
70599
- value: withUnit(displayLayer == null ? void 0 : displayLayer.value, displayLayer == null ? void 0 : displayLayer.unit),
70600
- name: stringName,
70601
- predefinedSelected: optionState == null ? void 0 : optionState.predefinedSelected,
70602
- predefinedOption: optionState == null ? void 0 : optionState.predefinedOption
70603
- }
70604
- });
70605
- } else {
70606
- onChange({
70607
- target: {
70608
- value: newValue,
70609
- name: stringName,
70610
- predefinedSelected: optionState == null ? void 0 : optionState.predefinedSelected,
70611
- predefinedOption: optionState == null ? void 0 : optionState.predefinedOption
70612
- }
70613
- });
70614
- setDisplayLayer({
70615
- value: newValue,
70616
- unit: getUnit(newValue) || displayLayer.unit
70617
- });
70541
+ text: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED ? foundPredefinedMenuOption == null ? void 0 : foundPredefinedMenuOption.label : "",
70542
+ children: /* @__PURE__ */ jsx(
70543
+ Menu,
70544
+ {
70545
+ maxHeight: 380,
70546
+ groupOrder: "first",
70547
+ testId: testId && `${testId}-predefined-menu`,
70548
+ disabled: disabled2,
70549
+ menu: {
70550
+ colored: true,
70551
+ trigger: "Component",
70552
+ component: /* @__PURE__ */ jsx(
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
70562
+ }
70618
70563
  }
70619
- },
70620
- disabled: disabled2,
70621
- initialPredefinedOption,
70622
- predefinedOptionLinked,
70623
- predefinedOptionsMenuState,
70624
- setPredefinedOptionsMenuState
70564
+ )
70625
70565
  }
70626
70566
  ),
70627
70567
  /* @__PURE__ */ jsx("div", { className: styles.inputWrapper, children: /* @__PURE__ */ jsx(
@@ -70669,7 +70609,7 @@ const UnitInput = ({
70669
70609
  inline: true,
70670
70610
  onClick: (evt) => {
70671
70611
  evt.stopPropagation();
70672
- onClickUnit(value2, altUnit);
70612
+ onClickUnit(isAutoValue ? "" : value2, altUnit);
70673
70613
  },
70674
70614
  description: displayUnit,
70675
70615
  selected: displayUnit === displayUnitLabel,