@oliasoft-open-source/react-ui-library 4.10.7-beta-1 → 4.11.0-beta-1

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.
Files changed (39) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +27 -31
  3. package/dist/index.js.map +1 -1
  4. package/dist/storybook/assets/{Color-KGDBMAHA-BUFB6l_A.js → Color-KGDBMAHA-DNHJyTIW.js} +1 -1
  5. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-BFirtfR2.js → DocsRenderer-PKQXORMH-C9rr-9Kf.js} +1 -1
  6. package/dist/storybook/assets/{accordion.stories-BTxV-ybU.js → accordion.stories-BLEGXECa.js} +1 -1
  7. package/dist/storybook/assets/{buttons-and-links-DUCa3trE.js → buttons-and-links-BR6gQ0FR.js} +1 -1
  8. package/dist/storybook/assets/{casing-loads.stories-CJpnsmsZ.js → casing-loads.stories-BCXgA6_-.js} +1 -1
  9. package/dist/storybook/assets/{cell.stories-Bpl0Squh.js → cell.stories-CrIM0y6t.js} +1 -1
  10. package/dist/storybook/assets/{chunk-HLWAVYOI-zzWMdYo-.js → chunk-HLWAVYOI-xZeJ0r5F.js} +1 -1
  11. package/dist/storybook/assets/{color-BsQt-pUp.js → color-CL4Yvq6B.js} +1 -1
  12. package/dist/storybook/assets/{footer.stories-DgjDE_JR.js → footer.stories-BU-TGwM2.js} +1 -1
  13. package/dist/storybook/assets/{formation.stories-BT8VrcqV.js → formation.stories-DxVe8Zyc.js} +1 -1
  14. package/dist/storybook/assets/{iframe-CEXx5q1g.js → iframe-DtGyYU7Y.js} +2 -2
  15. package/dist/storybook/assets/{index-DV8wElrm.js → index-BLlJkNz-.js} +4 -4
  16. package/dist/storybook/assets/{index-D6cl8fdc.js → index-DOnfURi4.js} +1 -1
  17. package/dist/storybook/assets/initialize-context-ScheoYVG.js +1 -0
  18. package/dist/storybook/assets/{input-validation-DQ5xtETO.js → input-validation-e-lIRBH9.js} +1 -1
  19. package/dist/storybook/assets/{inputs-BBS7v9vl.js → inputs-i9oqcOde.js} +1 -1
  20. package/dist/storybook/assets/{layout-forms-Dxh8TDk3.js → layout-forms-CSDOaD98.js} +1 -1
  21. package/dist/storybook/assets/{layout-general-6L1ONGo2.js → layout-general-Ch_fXD34.js} +1 -1
  22. package/dist/storybook/assets/{number-input-Bpg4Yqmo.js → number-input-B5ReSBSL.js} +2 -2
  23. package/dist/storybook/assets/{number-input.stories-DhCjZ37u.js → number-input.stories-DMAU21wG.js} +1 -1
  24. package/dist/storybook/assets/{padding-and-spacing-6E_xR1m4.js → padding-and-spacing-CGADpYHw.js} +1 -1
  25. package/dist/storybook/assets/{preview-CVFg0NpW.js → preview-BMsQEfL5.js} +1 -1
  26. package/dist/storybook/assets/{preview-CG8M72p-.js → preview-DFAYoqIF.js} +2 -2
  27. package/dist/storybook/assets/{row.stories-msEoNdGI.js → row.stories-C8rG1yoB.js} +1 -1
  28. package/dist/storybook/assets/{table-5Y5KPNSk.js → table-DdpQxqOc.js} +1 -1
  29. package/dist/storybook/assets/{table.stories-Clltxls0.js → table.stories-D4zMbjkS.js} +1 -1
  30. package/dist/storybook/assets/{title.stories-CsrYTGde.js → title.stories-hThIUrWl.js} +1 -1
  31. package/dist/storybook/assets/unit-input.stories-D-520BU0.js +421 -0
  32. package/dist/storybook/assets/unit-table.stories-DT8GuYu8.js +152 -0
  33. package/dist/storybook/iframe.html +1 -1
  34. package/dist/storybook/index.json +1 -1
  35. package/dist/storybook/project.json +1 -1
  36. package/package.json +1 -1
  37. package/dist/storybook/assets/unit-input.stories-DoCaLohq.js +0 -426
  38. package/dist/storybook/assets/unit-table.stories-uy3ukIal.js +0 -152
  39. package/dist/storybook/assets/use-previous-D775JrO6.js +0 -1
package/dist/index.d.ts CHANGED
@@ -1551,7 +1551,7 @@ declare interface IUnitConfigItem {
1551
1551
  }) => void;
1552
1552
  unitKey: string;
1553
1553
  storageUnit: string;
1554
- preferredUnit: string;
1554
+ preferredUnit?: string;
1555
1555
  }
1556
1556
 
1557
1557
  export declare interface IUnitInputProps {
package/dist/index.js CHANGED
@@ -55688,10 +55688,6 @@ const NumberInput = ({
55688
55688
  }) => {
55689
55689
  const validateInputValue = (value2) => {
55690
55690
  const validation = validateNumber(value2);
55691
- const isPlaceholder = placeholder3 && isEmptyNullOrUndefined(value2);
55692
- if (isPlaceholder) {
55693
- return { valid: true, errors: [] };
55694
- }
55695
55691
  if (allowEmpty && value2 === "" || validation.valid) {
55696
55692
  return { ...validation, valid: true, errors: void 0 };
55697
55693
  } else {
@@ -55737,7 +55733,7 @@ const NumberInput = ({
55737
55733
  value2.replaceAll(" ", "").replaceAll("|", "")
55738
55734
  );
55739
55735
  setDisplayValue(inputValue);
55740
- if (((_b = validateInputValue(inputValue)) == null ? void 0 : _b.valid) || placeholder3 && isEmptyNullOrUndefined(value2)) {
55736
+ if ((_b = validateInputValue(inputValue)) == null ? void 0 : _b.valid) {
55741
55737
  const event = {
55742
55738
  ...evt,
55743
55739
  target: {
@@ -70342,7 +70338,7 @@ const UnitInput = ({
70342
70338
  initialPredefinedOption ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM
70343
70339
  );
70344
70340
  const isAutoValue = propValue === "" && autoValue;
70345
- const disableInternalErrorValidationMessages = !!(disabledValidation || autoValue);
70341
+ const disableInternalErrorValidationMessages = !!(disabledValidation || autoValue || placeholder3 && isEmptyNullOrUndefined(value));
70346
70342
  const foundPredefinedMenuOption = predefinedOptions && predefinedOptions.find((el2) => {
70347
70343
  if (!(el2 == null ? void 0 : el2.value)) return;
70348
70344
  if (selectedPredefinedOptionKey) {
@@ -70494,27 +70490,6 @@ const UnitInput = ({
70494
70490
  const dynamicOptions = predefinedOptions.map(createPredefinedOption);
70495
70491
  sectionsPredefinedMenu = [...sectionsPredefinedMenu, ...dynamicOptions];
70496
70492
  }
70497
- const getPlaceholder = (placeholder22) => {
70498
- if (isAutoValue) {
70499
- return safeConvertValue({
70500
- value: autoValue,
70501
- toUnit: displayLayer.unit,
70502
- unitkey,
70503
- defaultFromUnit: propAutoUnit,
70504
- doNotConvertValue
70505
- });
70506
- } else if (isValueWithUnit(placeholder22)) {
70507
- const placeholderUnit = getUnit(placeholder22);
70508
- return safeConvertValue({
70509
- value: placeholder22,
70510
- toUnit: displayLayer.unit,
70511
- unitkey,
70512
- defaultFromUnit: placeholderUnit,
70513
- doNotConvertValue
70514
- });
70515
- }
70516
- return placeholder22;
70517
- };
70518
70493
  return /* @__PURE__ */ jsx(
70519
70494
  "div",
70520
70495
  {
@@ -70555,7 +70530,13 @@ const UnitInput = ({
70555
70530
  name: stringName,
70556
70531
  testId,
70557
70532
  disabled: disabled2,
70558
- placeholder: getPlaceholder(placeholder3),
70533
+ placeholder: isAutoValue ? safeConvertValue({
70534
+ value: autoValue,
70535
+ toUnit: displayLayer.unit,
70536
+ unitkey,
70537
+ defaultFromUnit: propAutoUnit,
70538
+ doNotConvertValue
70539
+ }) : placeholder3,
70559
70540
  value: displayLayer.value,
70560
70541
  onChange: onSetValue,
70561
70542
  onFocus,
@@ -70609,12 +70590,27 @@ const UnitInput = ({
70609
70590
  };
70610
70591
  const normalizeUnits = (unitConfig) => unitConfig.reduce(
70611
70592
  ({ preferredUnits, storageUnits }, { unitKey, preferredUnit, storageUnit }) => {
70612
- preferredUnits[unitKey] = preferredUnit;
70593
+ const { unitTemplate = null } = useUnitContext() ?? {};
70594
+ preferredUnits[unitKey] = preferredUnit ?? (unitTemplate == null ? void 0 : unitTemplate[unitKey]);
70613
70595
  storageUnits[unitKey] = storageUnit;
70614
70596
  return { preferredUnits, storageUnits };
70615
70597
  },
70616
70598
  { preferredUnits: {}, storageUnits: {} }
70617
70599
  );
70600
+ const tryConvertValue = (value, unitKey, selectedUnit, storageUnit) => {
70601
+ if (checkConversion({
70602
+ value,
70603
+ unitkey: unitKey,
70604
+ toUnit: selectedUnit
70605
+ })) {
70606
+ try {
70607
+ return convertAndGetValue(value, selectedUnit, storageUnit);
70608
+ } catch {
70609
+ return value;
70610
+ }
70611
+ }
70612
+ return value;
70613
+ };
70618
70614
  const convertVisibleRows = ({
70619
70615
  headers,
70620
70616
  rows,
@@ -70656,7 +70652,7 @@ const convertVisibleRows = ({
70656
70652
  const selectedUnit = selectedUnits[unitKey];
70657
70653
  const storageUnit = storageUnits[unitKey];
70658
70654
  const unitChanged = selectedUnit !== storageUnit;
70659
- const convertedValue = unitChanged ? convertAndGetValue(value, selectedUnit, storageUnit) : cell2.value;
70655
+ const convertedValue = unitChanged ? tryConvertValue(value, unitKey, selectedUnit, storageUnit) : cell2.value;
70660
70656
  const formattedDisplayValue = formatDisplayValue ? formatDisplayValue(convertedValue) : convertedValue;
70661
70657
  return {
70662
70658
  ...cell2,
@@ -70671,7 +70667,7 @@ const convertVisibleRows = ({
70671
70667
  const selectedUnit2 = selectedUnits[unitKey];
70672
70668
  const unitChanged2 = selectedUnit2 !== storageUnit2;
70673
70669
  const nextUnit = convertBackToStorageUnit ? storageUnit2 : selectedUnit2;
70674
- const nextValueConverted = unitChanged2 ? convertAndGetValue(value2, nextUnit, selectedUnit2) : value2;
70670
+ const nextValueConverted = unitChanged2 ? tryConvertValue(value2, unitKey, nextUnit, selectedUnit2) : value2;
70675
70671
  if ("onChange" in cell2) {
70676
70672
  const { onChange } = cell2;
70677
70673
  const event = {