@oliasoft-open-source/react-ui-library 4.13.0-beta-17 → 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 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 (!(initialPredefinedOptionObject == null ? void 0 : initialPredefinedOptionObject.linked)) {
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.CUSTOM);
70460
+ const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(PredefinedOptionsMenuState.PREDEFINED);
70459
70461
  if (typeof value === "number") {
70460
70462
  value = `${value}`;
70461
70463
  }
@@ -70590,21 +70592,34 @@ const UnitInput = ({
70590
70592
  predefinedOptions,
70591
70593
  displayLayer,
70592
70594
  onPredefinedOptionSelect: (newValue, optionState) => {
70593
- onChange({
70594
- target: {
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({
70595
70615
  value: newValue,
70596
- name: stringName,
70597
- predefinedSelected: optionState == null ? void 0 : optionState.predefinedSelected,
70598
- predefinedOption: optionState == null ? void 0 : optionState.predefinedOption
70599
- }
70600
- });
70601
- setDisplayLayer({
70602
- value: newValue,
70603
- unit: getUnit(newValue) || displayLayer.unit
70604
- });
70616
+ unit: getUnit(newValue) || displayLayer.unit
70617
+ });
70618
+ }
70605
70619
  },
70606
70620
  disabled: disabled2,
70607
70621
  initialPredefinedOption,
70622
+ predefinedOptionLinked,
70608
70623
  predefinedOptionsMenuState,
70609
70624
  setPredefinedOptionsMenuState
70610
70625
  }