@oliasoft-open-source/react-ui-library 4.15.1-beta-5 → 4.15.1-beta-7

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
@@ -762,7 +762,7 @@ export declare interface IMenuProps {
762
762
  selected?: boolean;
763
763
  }
764
764
 
765
- declare interface IMenuSection {
765
+ export declare interface IMenuSection {
766
766
  type: TMenuType | string;
767
767
  label?: ReactNode;
768
768
  icon?: string | ReactNode;
@@ -1569,7 +1569,6 @@ export declare interface IUnitInputProps {
1569
1569
  unitkey?: string;
1570
1570
  initUnit?: string;
1571
1571
  noConversion?: boolean;
1572
- doNotConvertValue?: boolean;
1573
1572
  testId?: string;
1574
1573
  warning?: string | boolean | null;
1575
1574
  predefinedOptions?: IPredefinedOption[] | null;
@@ -1579,7 +1578,6 @@ export declare interface IUnitInputProps {
1579
1578
  validationCallback?: (name: string, error: string | null) => any;
1580
1579
  disabledValidation?: boolean;
1581
1580
  allowEmpty?: boolean;
1582
- autoValue?: string;
1583
1581
  onChange?: TOnChangeEventHandler;
1584
1582
  onSwitchUnit?: (unit: string) => void;
1585
1583
  onClick?: MouseEventHandler<HTMLInputElement>;
@@ -1886,7 +1884,7 @@ declare type TUnitTableCellShape = TCellShape | IUnitTableStaticCell | IUnitTabl
1886
1884
 
1887
1885
  declare type UnitContextType = any;
1888
1886
 
1889
- 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;
1887
+ 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, shouldLinkAutomaticly, selectedPredefinedOptionKey, validationCallback, disabledValidation, allowEmpty, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, roundDisplayValue, }: IUnitInputProps) => JSX_2.Element;
1890
1888
 
1891
1889
  export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitTableProps) => JSX_2.Element;
1892
1890
 
package/dist/index.js CHANGED
@@ -20890,6 +20890,11 @@ const Trigger = ({
20890
20890
  }) => {
20891
20891
  var _a2;
20892
20892
  const [inputRef, setInputFocus] = useFocus();
20893
+ useEffect(() => {
20894
+ if (isOpen2 && typeof setInputFocus === "function") {
20895
+ setInputFocus();
20896
+ }
20897
+ }, [isOpen2, setInputFocus]);
20893
20898
  const hasSelection2 = Array.isArray(selectedOptions) ? selectedOptions.length > 0 && ((_a2 = selectedOptions[0]) == null ? void 0 : _a2.value) : selectedOptions == null ? void 0 : selectedOptions.value;
20894
20899
  const canClear = clearable && hasSelection2;
20895
20900
  const order2 = (() => {
@@ -20928,11 +20933,7 @@ const Trigger = ({
20928
20933
  right2 ? styles$m.right : "",
20929
20934
  order2
20930
20935
  ),
20931
- onClick: (evt) => {
20932
- console.log("TRIGGER ONCLICK");
20933
- evt.stopPropagation();
20934
- onClickTrigger(evt);
20935
- },
20936
+ onClick: onClickTrigger,
20936
20937
  onFocus,
20937
20938
  onBlur,
20938
20939
  "data-error": error2 || null,
@@ -70314,7 +70315,6 @@ const UnitInput = ({
70314
70315
  onFocus = noop$3,
70315
70316
  onSwitchUnit = noop$3,
70316
70317
  unitTemplate,
70317
- doNotConvertValue = false,
70318
70318
  testId,
70319
70319
  warning: warning2 = null,
70320
70320
  predefinedOptions,
@@ -70324,7 +70324,6 @@ const UnitInput = ({
70324
70324
  validationCallback = () => ({ name: "", error: null }),
70325
70325
  disabledValidation = false,
70326
70326
  allowEmpty = false,
70327
- autoValue,
70328
70327
  convertBackToStorageUnit = false,
70329
70328
  enableCosmeticRounding = true,
70330
70329
  enableDisplayRounding = false,
@@ -70336,7 +70335,6 @@ const UnitInput = ({
70336
70335
  value = `${value}`;
70337
70336
  }
70338
70337
  const [propValue = "", propUnit = ""] = value !== void 0 ? split$1(value) : [];
70339
- const propAutoUnit = autoValue ? getUnit(autoValue) : "";
70340
70338
  const preferredUnit = useMemo$1(
70341
70339
  () => getPreferredUnit(unitkey, unitTemplate || (context2 == null ? void 0 : context2.unitTemplate)),
70342
70340
  [unitkey, unitTemplate, context2 == null ? void 0 : context2.unitTemplate]
@@ -70349,23 +70347,15 @@ const UnitInput = ({
70349
70347
  toUnit: initDisplayUnit,
70350
70348
  unitkey,
70351
70349
  defaultFromUnit: propUnit,
70352
- doNotConvertValue
70353
- });
70354
- const { value: convertedAutoValue } = safeConvertValue({
70355
- value: autoValue,
70356
- toUnit: initDisplayUnit,
70357
- unitkey,
70358
- defaultFromUnit: propAutoUnit,
70359
- doNotConvertValue
70350
+ doNotConvertValue: noConversion
70360
70351
  });
70361
- const initDisplayLayer = convertedValue !== "" ? { value: convertedValue, unit: initDisplayUnit } : convertedAutoValue !== "" ? { value: convertedAutoValue, unit: initDisplayUnit } : { value: propValue, unit: propUnit };
70352
+ const initDisplayLayer = convertedValue !== "" ? { value: convertedValue, unit: initDisplayUnit } : { value: propValue, unit: propUnit };
70362
70353
  const [displayLayer, setDisplayLayer] = useState(initDisplayLayer);
70363
70354
  const derivedAllowEmpty = allowEmpty || (displayLayer == null ? void 0 : displayLayer.value) === void 0;
70364
70355
  const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(
70365
70356
  initialPredefinedOption ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM
70366
70357
  );
70367
- const isAutoValue = propValue === "" && autoValue;
70368
- const disableInternalErrorValidationMessages = !!(disabledValidation || autoValue || disabled2);
70358
+ const disableInternalErrorValidationMessages = !!(disabledValidation || disabled2);
70369
70359
  const foundPredefinedMenuOption = predefinedOptions && predefinedOptions.find((el2) => {
70370
70360
  if (!(el2 == null ? void 0 : el2.value)) return;
70371
70361
  if (selectedPredefinedOptionKey) {
@@ -70380,7 +70370,7 @@ const UnitInput = ({
70380
70370
  return withUnit(resultValue, predefinedMenuItemUnit) === el2.value;
70381
70371
  });
70382
70372
  const getAlternativeUnits = () => {
70383
- const valueToList = isAutoValue ? autoValue : value ?? "";
70373
+ const valueToList = value ?? "";
70384
70374
  const initToUnit = displayLayer.unit;
70385
70375
  const shouldConvert = checkConversion({
70386
70376
  value: valueToList,
@@ -70439,7 +70429,7 @@ const UnitInput = ({
70439
70429
  toUnit: initDisplayUnit,
70440
70430
  unitkey,
70441
70431
  defaultFromUnit: propUnit,
70442
- doNotConvertValue
70432
+ doNotConvertValue: noConversion
70443
70433
  });
70444
70434
  newValue = resultValue;
70445
70435
  newUnit = initDisplayUnit;
@@ -70449,7 +70439,7 @@ const UnitInput = ({
70449
70439
  toUnit: displayLayer.unit,
70450
70440
  unitkey,
70451
70441
  defaultFromUnit: propUnit,
70452
- doNotConvertValue
70442
+ doNotConvertValue: noConversion
70453
70443
  });
70454
70444
  newValue = resultValue;
70455
70445
  newUnit = displayLayer.unit;
@@ -70522,23 +70512,14 @@ const UnitInput = ({
70522
70512
  sectionsPredefinedMenu = [...sectionsPredefinedMenu, ...dynamicOptions];
70523
70513
  }
70524
70514
  const getPlaceholder = (placeholder22) => {
70525
- if (isAutoValue) {
70526
- const { value: resultValue } = safeConvertValue({
70527
- value: autoValue,
70528
- toUnit: displayLayer.unit,
70529
- unitkey,
70530
- defaultFromUnit: propAutoUnit,
70531
- doNotConvertValue
70532
- });
70533
- return resultValue;
70534
- } else if (isValueWithUnit(placeholder22)) {
70515
+ if (isValueWithUnit(placeholder22)) {
70535
70516
  const placeholderUnit = getUnit(placeholder22);
70536
70517
  const { value: resultValue } = safeConvertValue({
70537
70518
  value: placeholder22,
70538
70519
  toUnit: displayLayer.unit,
70539
70520
  unitkey,
70540
70521
  defaultFromUnit: placeholderUnit,
70541
- doNotConvertValue
70522
+ doNotConvertValue: noConversion
70542
70523
  });
70543
70524
  return resultValue;
70544
70525
  }
@@ -70623,7 +70604,7 @@ const UnitInput = ({
70623
70604
  inline: true,
70624
70605
  onClick: (evt) => {
70625
70606
  evt.stopPropagation();
70626
- onClickUnit(isAutoValue ? "" : value2, altUnit);
70607
+ onClickUnit(value2, altUnit);
70627
70608
  },
70628
70609
  description: displayUnit,
70629
70610
  selected: displayUnit === displayUnitLabel,