@oliasoft-open-source/react-ui-library 4.2.0-beta-1 → 4.2.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 (63) hide show
  1. package/dist/assets/{index-9914ac27.js → index-26f804a8.js} +1 -0
  2. package/dist/index.d.ts +3 -3
  3. package/dist/index.html +1 -1
  4. package/dist/index.js +47 -25
  5. package/dist/index.js.map +1 -1
  6. package/dist/storybook/assets/{Color-6VNJS4EI-626cced0.js → Color-6VNJS4EI-4c266928.js} +1 -1
  7. package/dist/storybook/assets/{DocsRenderer-NNNQARDV-576d9da9.js → DocsRenderer-NNNQARDV-4522c04a.js} +1 -1
  8. package/dist/storybook/assets/{WithTooltip-4HIR6TLV-bee8e125.js → WithTooltip-4HIR6TLV-3f797c81.js} +1 -1
  9. package/dist/storybook/assets/{accordion.stories-54aa7085.js → accordion.stories-0f8af16e.js} +1 -1
  10. package/dist/storybook/assets/{button.stories-531033a8.js → button.stories-9b954335.js} +1 -1
  11. package/dist/storybook/assets/{buttons-and-links-5c2f81ed.js → buttons-and-links-3ca65a4b.js} +1 -1
  12. package/dist/storybook/assets/{casing-loads.stories-d235dd15.js → casing-loads.stories-cfbab702.js} +1 -1
  13. package/dist/storybook/assets/{cell.stories-6d7c1887.js → cell.stories-524a7418.js} +1 -1
  14. package/dist/storybook/assets/{chunk-HLWAVYOI-7cf52e0e.js → chunk-HLWAVYOI-6bd5aff8.js} +1 -1
  15. package/dist/storybook/assets/{color-373aeff7.js → color-6f498d70.js} +1 -1
  16. package/dist/storybook/assets/{drawer.stories-2512fef1.js → drawer.stories-39625e91.js} +1 -1
  17. package/dist/storybook/assets/{file-input.stories-0e546123.js → file-input.stories-1c6ce0ea.js} +1 -1
  18. package/dist/storybook/assets/{flex-47732c42.js → flex-1d14d86c.js} +1 -1
  19. package/dist/storybook/assets/{flex.stories-9d4c08a1.js → flex.stories-09e9c602.js} +1 -1
  20. package/dist/storybook/assets/{footer.stories-9337b9e2.js → footer.stories-57f07ea2.js} +1 -1
  21. package/dist/storybook/assets/{form.stories-40e17b4c.js → form.stories-45c0cd59.js} +1 -1
  22. package/dist/storybook/assets/{formation.stories-fc57d144.js → formation.stories-5eeaa826.js} +1 -1
  23. package/dist/storybook/assets/{formatter-SWP5E3XI-46182822.js → formatter-SWP5E3XI-cf89c041.js} +1 -1
  24. package/dist/storybook/assets/{heading.stories-869d41ea.js → heading.stories-9689bddc.js} +1 -1
  25. package/dist/storybook/assets/{icon.stories-fca93dba.js → icon.stories-8dae69e1.js} +1 -1
  26. package/dist/storybook/assets/iframe-4241ee87.js +1 -0
  27. package/dist/storybook/assets/{index-fba8c0d7.js → index-24b2d8c6.js} +4 -4
  28. package/dist/storybook/assets/{index-0bfda4aa.js → index-57d7693e.js} +1 -1
  29. package/dist/storybook/assets/{input-validation-3b7b7cda.js → input-validation-ca50f656.js} +1 -1
  30. package/dist/storybook/assets/{inputs-c02f8012.js → inputs-48a26c2d.js} +1 -1
  31. package/dist/storybook/assets/{layout-forms-bdf4b47b.js → layout-forms-ee9889f6.js} +1 -1
  32. package/dist/storybook/assets/{layout-general-2c5e127e.js → layout-general-2d6bd6c2.js} +1 -1
  33. package/dist/storybook/assets/{list.stories-0f30d0b5.js → list.stories-5715452e.js} +1 -1
  34. package/dist/storybook/assets/{list.stories-data-390b28e1.js → list.stories-data-94f7c623.js} +1 -1
  35. package/dist/storybook/assets/{menu.stories-7a422ddf.js → menu.stories-927adf3d.js} +1 -1
  36. package/dist/storybook/assets/{menu.stories-data-38257c11.js → menu.stories-data-28e27478.js} +1 -1
  37. package/dist/storybook/assets/{number-input-66bb0350.js → number-input-7d49b0b3.js} +1 -1
  38. package/dist/storybook/assets/{number-input.stories-ef65b216.js → number-input.stories-02528124.js} +1 -1
  39. package/dist/storybook/assets/{padding-and-spacing-5cfec3f6.js → padding-and-spacing-c11842e2.js} +1 -1
  40. package/dist/storybook/assets/{popover.stories-4c074762.js → popover.stories-f651a81c.js} +1 -1
  41. package/dist/storybook/assets/preview-ea6061e8.js +1 -0
  42. package/dist/storybook/assets/{preview-8a38ceb3.js → preview-f4241840.js} +1 -1
  43. package/dist/storybook/assets/{row.stories-4c5f0247.js → row.stories-d5b6b4a6.js} +1 -1
  44. package/dist/storybook/assets/{side-bar.stories-0887207d.js → side-bar.stories-2c06f8a6.js} +1 -1
  45. package/dist/storybook/assets/{spacer.stories-97086558.js → spacer.stories-38071af8.js} +1 -1
  46. package/dist/storybook/assets/{syntaxhighlighter-NMPM6SWI-758c17ef.js → syntaxhighlighter-NMPM6SWI-2e6bd966.js} +1 -1
  47. package/dist/storybook/assets/{table-646201c1.js → table-da6f6045.js} +1 -1
  48. package/dist/storybook/assets/{table.stories-ca3ed877.js → table.stories-67a3023a.js} +1 -1
  49. package/dist/storybook/assets/{table.stories-data-aefdf55f.js → table.stories-data-8a836b92.js} +1 -1
  50. package/dist/storybook/assets/{textarea-54dd1c9a.js → textarea-d48efea2.js} +1 -1
  51. package/dist/storybook/assets/{textarea.stories-4b85aa60.js → textarea.stories-89c8afd7.js} +1 -1
  52. package/dist/storybook/assets/{title.stories-7ad1232e.js → title.stories-5b4a226c.js} +1 -1
  53. package/dist/storybook/assets/{toaster.stories-bed0d43f.js → toaster.stories-5e4d95b1.js} +1 -1
  54. package/dist/storybook/assets/{tooltip.test-case.stories-ef78bd26.js → tooltip.test-case.stories-9817078b.js} +1 -1
  55. package/dist/storybook/assets/unit-input.stories-ca28e74b.js +257 -0
  56. package/dist/storybook/iframe.html +1 -1
  57. package/dist/storybook/index.json +1 -1
  58. package/dist/storybook/project.json +1 -1
  59. package/dist/storybook/stories.json +1 -1
  60. package/package.json +1 -1
  61. package/dist/storybook/assets/iframe-c1f0de6b.js +0 -1
  62. package/dist/storybook/assets/preview-f8076f66.js +0 -1
  63. package/dist/storybook/assets/unit-input.stories-c70beb80.js +0 -1
@@ -77535,6 +77535,7 @@ const styles$3 = {
77535
77535
  placeholderContainer,
77536
77536
  placeholder
77537
77537
  };
77538
+ requireUnits();
77538
77539
  const predefinedMenuActive = "_predefinedMenuActive_1yvt4_1";
77539
77540
  const styles$2 = {
77540
77541
  predefinedMenuActive
package/dist/index.d.ts CHANGED
@@ -1017,7 +1017,7 @@ export declare interface IPortalProps {
1017
1017
  declare interface IPredefinedOption {
1018
1018
  value: string;
1019
1019
  label: string;
1020
- valueKey: string;
1020
+ valueKey?: string;
1021
1021
  }
1022
1022
 
1023
1023
  export declare interface IPrintHeaderProps {
@@ -1492,7 +1492,7 @@ export declare interface IUnitInputProps {
1492
1492
  placeholder?: string;
1493
1493
  disabled?: boolean;
1494
1494
  disabledUnit?: boolean;
1495
- error?: string | null;
1495
+ error?: string | null | boolean;
1496
1496
  left?: boolean;
1497
1497
  small?: boolean;
1498
1498
  width?: string | number;
@@ -1518,7 +1518,7 @@ export declare interface IUnitInputProps {
1518
1518
  onSwitchUnit?: (unit: string) => void;
1519
1519
  onClick?: MouseEventHandler<HTMLInputElement>;
1520
1520
  onFocus?: FocusEventHandler<HTMLInputElement>;
1521
- unitTemplate: Record<string, any>;
1521
+ unitTemplate?: Record<string, any>;
1522
1522
  }
1523
1523
 
1524
1524
  export declare const Label: ({ label, width, helpText, helpTextMaxWidth, onClickHelp, lock, info, libraryIcon, labelLeft, }: ILabelProps) => JSX_2.Element;
package/dist/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><head><title>React UI Library</title><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1" user-scalable="no"><meta name="apple-mobile-web-app-capable" content="yes"><script type="module" crossorigin src="/react-ui-library/assets/index-9914ac27.js"></script><link rel="stylesheet" href="/react-ui-library/assets/index-0d78a198.css"></head><body><div id="content"></div></body>
1
+ <!doctype html><head><title>React UI Library</title><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1" user-scalable="no"><meta name="apple-mobile-web-app-capable" content="yes"><script type="module" crossorigin src="/react-ui-library/assets/index-26f804a8.js"></script><link rel="stylesheet" href="/react-ui-library/assets/index-0d78a198.css"></head><body><div id="content"></div></body>
package/dist/index.js CHANGED
@@ -11,7 +11,8 @@ import * as PropTypes from "prop-types";
11
11
  import PropTypes__default from "prop-types";
12
12
  import ReactDOM, { createPortal, unstable_batchedUpdates, render } from "react-dom";
13
13
  import _$1, { 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, isObjectLike, has as has$1 } from "lodash";
14
- import { validateNumber, cleanNumStr, unitFromQuantity, isValueWithUnit, convertSamePrecision, withUnit, getValue as getValue$1, split as split$1, getUnit, checkAndCleanDecimalComma, label as label$b, altUnitsList, isNumeric, isValidNum } from "@oliasoft-open-source/units";
14
+ import { validateNumber, cleanNumStr, unitFromQuantity, isValueWithUnit, convertSamePrecision, withUnit, getValue as getValue$1, split as split$1, getUnit, checkAndCleanDecimalComma, label as label$b, altUnitsList } from "@oliasoft-open-source/units";
15
+ import { isValueWithUnit as isValueWithUnit$1 } from "@oliasoft-open-source/units/dist/units";
15
16
  const global$2 = "";
16
17
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
17
18
  function getDefaultExportFromCjs(x2) {
@@ -70168,6 +70169,35 @@ const getErrorMessage = (error2) => {
70168
70169
  return null;
70169
70170
  }
70170
70171
  };
70172
+ const hasLeadingZeroes = (value) => {
70173
+ return value.search(RegExp(/(^0{2}\.)|(^0+[1-9])/g)) === 0;
70174
+ };
70175
+ const validate = (value, options) => {
70176
+ var _a;
70177
+ const {
70178
+ allowEmpty = false,
70179
+ autoValue,
70180
+ placeholder: placeholder3,
70181
+ disabledValidation = false
70182
+ } = options || {};
70183
+ const stringValue = String(value);
70184
+ if (disabledValidation || autoValue || placeholder3) {
70185
+ return null;
70186
+ }
70187
+ const cleanValue = isValueWithUnit$1(stringValue) ? getValue$1(stringValue) : stringValue;
70188
+ if (allowEmpty && cleanValue === "") {
70189
+ return null;
70190
+ }
70191
+ if (hasLeadingZeroes(cleanValue)) {
70192
+ return "Invalid number format due to leading zeroes";
70193
+ }
70194
+ const validationErrors = validateNumber(cleanValue);
70195
+ if (!validationErrors.valid) {
70196
+ const firstError = ((_a = validationErrors == null ? void 0 : validationErrors.errors) == null ? void 0 : _a[0]) ?? null;
70197
+ return getErrorMessage(firstError);
70198
+ }
70199
+ return null;
70200
+ };
70171
70201
  const predefinedMenuActive = "_predefinedMenuActive_1yvt4_1";
70172
70202
  const styles = {
70173
70203
  predefinedMenuActive
@@ -70259,7 +70289,6 @@ const UnitInput = ({
70259
70289
  }
70260
70290
  };
70261
70291
  const onSetValue = (evt) => {
70262
- var _a;
70263
70292
  const stringName2 = getStringName(name2);
70264
70293
  const input2 = evt.target;
70265
70294
  const { value: inputValue, selectionStart: currentCursorPosition } = input2;
@@ -70268,16 +70297,13 @@ const UnitInput = ({
70268
70297
  );
70269
70298
  const newValue = withUnit(cleanInputValue, (displayLayer == null ? void 0 : displayLayer.unit) || "");
70270
70299
  const rawValue = getValue$1(newValue);
70271
- let validation = validateNumber(rawValue);
70272
- const isLeadingZeroes = rawValue.search(RegExp(/(^0{2}\.)|(^0+[1-9])/g)) === 0;
70273
- if (!(allowEmpty && rawValue === "" || autoValue) && !isNumeric(rawValue) || !isValidNum(rawValue) || isLeadingZeroes) {
70274
- validation = {
70275
- ...validation,
70276
- valid: false,
70277
- errors: ["Invalid number format"]
70278
- };
70279
- }
70280
- if (validation.valid || rawValue === "" && autoValue || allowEmpty && rawValue === "") {
70300
+ const validationResult = validate(rawValue, {
70301
+ allowEmpty,
70302
+ autoValue,
70303
+ placeholder: placeholder3,
70304
+ disabledValidation
70305
+ });
70306
+ if (validationResult === null) {
70281
70307
  onChange({
70282
70308
  target: {
70283
70309
  value: newValue,
@@ -70289,11 +70315,9 @@ const UnitInput = ({
70289
70315
  setValidationError(null);
70290
70316
  validationCallback(stringName2, null);
70291
70317
  } else {
70292
- const firstError = ((_a = validation == null ? void 0 : validation.errors) == null ? void 0 : _a[0]) ?? null;
70293
- const errorMessage = getErrorMessage(firstError);
70294
70318
  setDisplayLayer({ value: cleanInputValue, unit: displayLayer.unit });
70295
- setValidationError(errorMessage);
70296
- validationCallback(getStringName(name2), errorMessage);
70319
+ setValidationError(validationResult);
70320
+ validationCallback(stringName2, validationResult);
70297
70321
  }
70298
70322
  runAfterUpdate(() => {
70299
70323
  input2.selectionStart = currentCursorPosition;
@@ -70310,7 +70334,6 @@ const UnitInput = ({
70310
70334
  }
70311
70335
  };
70312
70336
  useEffect(() => {
70313
- var _a;
70314
70337
  if (initDisplayUnit) {
70315
70338
  let newValue, newUnit = "";
70316
70339
  if (previousInitUnit !== initDisplayUnit) {
@@ -70345,14 +70368,13 @@ const UnitInput = ({
70345
70368
  checkAndCleanDecimalComma(propValue),
70346
70369
  (displayLayer == null ? void 0 : displayLayer.unit) || ""
70347
70370
  );
70348
- const validation = validateNumber(getValue$1(cleanValue));
70349
- if (!validation.valid && !disabledValidation) {
70350
- const firstError = ((_a = validation == null ? void 0 : validation.errors) == null ? void 0 : _a[0]) ?? null;
70351
- const errorMessage = getErrorMessage(firstError);
70352
- setValidationError(errorMessage);
70353
- } else {
70354
- setValidationError(null);
70355
- }
70371
+ const errorMessage = validate(cleanValue, {
70372
+ allowEmpty,
70373
+ autoValue,
70374
+ placeholder: placeholder3,
70375
+ disabledValidation
70376
+ });
70377
+ setValidationError(errorMessage);
70356
70378
  }, [initDisplayUnit, value, error2, shouldLinkAutomaticly]);
70357
70379
  const alternativeUnits = getAlternativeUnits();
70358
70380
  const displayUnitLabel = label$b(displayLayer.unit) || displayLayer.unit || "";