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

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 (27) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +30 -31
  3. package/dist/index.js.map +1 -1
  4. package/dist/storybook/assets/{Color-KGDBMAHA-D26yaCjU.js → Color-KGDBMAHA-D_NCUJPU.js} +1 -1
  5. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-vElC6boV.js → DocsRenderer-PKQXORMH-BCC2y5si.js} +1 -1
  6. package/dist/storybook/assets/{buttons-and-links-Bzw6sQEl.js → buttons-and-links-ArQ5RWpo.js} +1 -1
  7. package/dist/storybook/assets/{chunk-HLWAVYOI-Dub2zPy2.js → chunk-HLWAVYOI-BzRd0mjz.js} +1 -1
  8. package/dist/storybook/assets/{color-sXpR2rDi.js → color-B3CrjofM.js} +1 -1
  9. package/dist/storybook/assets/{iframe-DfbvzuKW.js → iframe-4h-2QvBF.js} +2 -2
  10. package/dist/storybook/assets/{index-Cj40cYYp.js → index-Cjy_0_1e.js} +1 -1
  11. package/dist/storybook/assets/{index-CI3hSkVq.js → index-nyFwcT46.js} +88 -88
  12. package/dist/storybook/assets/initialize-context-ScheoYVG.js +1 -0
  13. package/dist/storybook/assets/{input-validation-5WW8MSTd.js → input-validation-CFLVl6eG.js} +1 -1
  14. package/dist/storybook/assets/{inputs-C6ZKc-en.js → inputs-BaoK3U4o.js} +1 -1
  15. package/dist/storybook/assets/{layout-forms-Davxfa-B.js → layout-forms-_Vn_gCYs.js} +1 -1
  16. package/dist/storybook/assets/{layout-general-C4k_FsG1.js → layout-general-C_WmY3IA.js} +1 -1
  17. package/dist/storybook/assets/{padding-and-spacing-ChZ-7T_N.js → padding-and-spacing-DaIt9nD2.js} +1 -1
  18. package/dist/storybook/assets/{preview-Dn1IHTmv.js → preview-Bhr6RB-I.js} +1 -1
  19. package/dist/storybook/assets/{preview-Blwe7Q4Y.js → preview-DxrUSTYT.js} +2 -2
  20. package/dist/storybook/assets/{unit-input.stories-9b23SnFs.js → unit-input.stories-D-520BU0.js} +5 -5
  21. package/dist/storybook/assets/unit-table.stories-CI1eqBM4.js +152 -0
  22. package/dist/storybook/iframe.html +1 -1
  23. package/dist/storybook/project.json +1 -1
  24. package/package.json +1 -1
  25. package/dist/404.html +0 -1
  26. package/dist/storybook/assets/unit-table.stories-CEqyw4pW.js +0 -152
  27. 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,30 @@ 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
+ console.log("unitTemplate", unitTemplate);
70595
+ console.log("unitTemplate?.[unitKey]", unitTemplate == null ? void 0 : unitTemplate[unitKey]);
70596
+ preferredUnits[unitKey] = preferredUnit ?? (unitTemplate == null ? void 0 : unitTemplate[unitKey]);
70613
70597
  storageUnits[unitKey] = storageUnit;
70598
+ console.log("preferredUnits", preferredUnits);
70614
70599
  return { preferredUnits, storageUnits };
70615
70600
  },
70616
70601
  { preferredUnits: {}, storageUnits: {} }
70617
70602
  );
70603
+ const tryConvertValue = (value, unitKey, selectedUnit, storageUnit) => {
70604
+ if (checkConversion({
70605
+ value,
70606
+ unitkey: unitKey,
70607
+ toUnit: selectedUnit
70608
+ })) {
70609
+ try {
70610
+ return convertAndGetValue(value, selectedUnit, storageUnit);
70611
+ } catch {
70612
+ return value;
70613
+ }
70614
+ }
70615
+ return value;
70616
+ };
70618
70617
  const convertVisibleRows = ({
70619
70618
  headers,
70620
70619
  rows,
@@ -70656,7 +70655,7 @@ const convertVisibleRows = ({
70656
70655
  const selectedUnit = selectedUnits[unitKey];
70657
70656
  const storageUnit = storageUnits[unitKey];
70658
70657
  const unitChanged = selectedUnit !== storageUnit;
70659
- const convertedValue = unitChanged ? convertAndGetValue(value, selectedUnit, storageUnit) : cell2.value;
70658
+ const convertedValue = unitChanged ? tryConvertValue(value, unitKey, selectedUnit, storageUnit) : cell2.value;
70660
70659
  const formattedDisplayValue = formatDisplayValue ? formatDisplayValue(convertedValue) : convertedValue;
70661
70660
  return {
70662
70661
  ...cell2,
@@ -70671,7 +70670,7 @@ const convertVisibleRows = ({
70671
70670
  const selectedUnit2 = selectedUnits[unitKey];
70672
70671
  const unitChanged2 = selectedUnit2 !== storageUnit2;
70673
70672
  const nextUnit = convertBackToStorageUnit ? storageUnit2 : selectedUnit2;
70674
- const nextValueConverted = unitChanged2 ? convertAndGetValue(value2, nextUnit, selectedUnit2) : value2;
70673
+ const nextValueConverted = unitChanged2 ? tryConvertValue(value2, unitKey, nextUnit, selectedUnit2) : value2;
70675
70674
  if ("onChange" in cell2) {
70676
70675
  const { onChange } = cell2;
70677
70676
  const event = {