@oliasoft-open-source/react-ui-library 4.2.0 → 4.2.1-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.
- package/dist/assets/{index-9e4179c3.css → index-0d78a198.css} +3 -0
- package/dist/assets/{index-cfa07a3f.js → index-26f804a8.js} +180 -175
- package/dist/index.d.ts +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +35 -17
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-6VNJS4EI-b934ab6b.js → Color-6VNJS4EI-38f93e87.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-NNNQARDV-ddf564a7.js → DocsRenderer-NNNQARDV-850c5573.js} +1 -1
- package/dist/storybook/assets/{WithTooltip-4HIR6TLV-8e7953d1.js → WithTooltip-4HIR6TLV-c574e731.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-d52a4724.js → accordion.stories-41aed20e.js} +2 -2
- package/dist/storybook/assets/{afe.stories-dbb9e71e.js → afe.stories-a4fbd6ce.js} +1 -1
- package/dist/storybook/assets/{blowout.stories-af7f9432.js → blowout.stories-3d16e5ec.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-bea8e431.js → buttons-and-links-dab2a936.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-97ec4b66.js → casing-loads.stories-d5882170.js} +2 -2
- package/dist/storybook/assets/{cell.stories-4a847cd0.js → cell.stories-0ae4bf08.js} +2 -2
- package/dist/storybook/assets/{chunk-HLWAVYOI-15cd9aaa.js → chunk-HLWAVYOI-48e544a6.js} +1 -1
- package/dist/storybook/assets/{color-d7525af7.js → color-c848f869.js} +1 -1
- package/dist/storybook/assets/{file-input.stories-a7e96582.js → file-input.stories-6878a9b8.js} +1 -1
- package/dist/storybook/assets/{footer.stories-da256be2.js → footer.stories-50a2e3db.js} +2 -2
- package/dist/storybook/assets/{form.stories-7c1518fa.js → form.stories-fb337772.js} +1 -1
- package/dist/storybook/assets/{formation.stories-a033bc86.js → formation.stories-3c9cd637.js} +2 -2
- package/dist/storybook/assets/{formatter-SWP5E3XI-bc797410.js → formatter-SWP5E3XI-3022f287.js} +1 -1
- package/dist/storybook/assets/iframe-c049b5de.js +1 -0
- package/dist/storybook/assets/{number-input-7cb3ea4d.js → index-57d7693e.js} +9 -9
- package/dist/storybook/assets/{index-ded8dd51.js → index-facfe879.js} +4 -4
- package/dist/storybook/assets/{input-validation-98dcb1cc.js → input-validation-36225c65.js} +1 -1
- package/dist/storybook/assets/{inputs-95a86db4.js → inputs-76e61ee6.js} +2 -2
- package/dist/storybook/assets/{layout-forms-2d1a89fa.js → layout-forms-e5b070bb.js} +1 -1
- package/dist/storybook/assets/{layout-general-d43e1deb.js → layout-general-86c12240.js} +1 -1
- package/dist/storybook/assets/number-input-cfbd9eb7.js +1 -0
- package/dist/storybook/assets/{number-input.stories-a78d1390.js → number-input.stories-8137782e.js} +2 -2
- package/dist/storybook/assets/{padding-and-spacing-175c928c.js → padding-and-spacing-27184e3b.js} +1 -1
- package/dist/storybook/assets/{page.stories-b69a6953.js → page.stories-8d0476d7.js} +1 -1
- package/dist/storybook/assets/preview-2ce67243.js +1 -0
- package/dist/storybook/assets/{preview-5b4b7caf.js → preview-b8e17d34.js} +1 -1
- package/dist/storybook/assets/{projects.stories-104a0c19.js → projects.stories-47d63f05.js} +1 -1
- package/dist/storybook/assets/{reservoirs.stories-0306bd1a.js → reservoirs.stories-537002ca.js} +1 -1
- package/dist/storybook/assets/{row.stories-d565ec28.js → row.stories-c12a3e52.js} +2 -2
- package/dist/storybook/assets/{site.stories-ae79a20c.js → site.stories-9486039d.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-NMPM6SWI-696a62ca.js → syntaxhighlighter-NMPM6SWI-abcfc30f.js} +1 -1
- package/dist/storybook/assets/{table-a19b5c53.js → table-134da40b.js} +1 -1
- package/dist/storybook/assets/{table.stories-4b24d81a.js → table.stories-8dd2a568.js} +2 -2
- package/dist/storybook/assets/{textarea-598f9fff.js → textarea-5ebdd171.js} +1 -1
- package/dist/storybook/assets/{textarea.stories-3902f4aa.js → textarea.stories-02879684.js} +1 -1
- package/dist/storybook/assets/{title.stories-00dc9f42.js → title.stories-2ba6aa87.js} +2 -2
- package/dist/storybook/assets/{top-bar-38689fe2.js → top-bar-2c70083e.js} +1 -1
- package/dist/storybook/assets/{top-bar.stories-3d9a6da1.js → top-bar.stories-bbfb7220.js} +1 -1
- package/dist/storybook/assets/{top-bar.testcase.stories-dc051455.js → top-bar.testcase.stories-1d4c6e3a.js} +1 -1
- package/dist/storybook/assets/unit-input.stories-035fa696.js +265 -0
- package/dist/storybook/assets/unit-input.stories-c251e2c8.css +1 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/stories.json +1 -1
- package/package.json +1 -1
- package/dist/404.html +0 -1
- package/dist/storybook/assets/iframe-615023be.js +0 -1
- package/dist/storybook/assets/preview-e85ca407.js +0 -1
package/dist/index.d.ts
CHANGED
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-
|
|
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,7 @@ 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,
|
|
14
|
+
import { validateNumber, cleanNumStr, unitFromQuantity, isValueWithUnit, withUnit, convertSamePrecision, getValue as getValue$1, getUnit, KNOWN_UNITS, split as split$1, checkAndCleanDecimalComma, label as label$b, altUnitsList } from "@oliasoft-open-source/units";
|
|
15
15
|
import { isValueWithUnit as isValueWithUnit$1 } from "@oliasoft-open-source/units/dist/units";
|
|
16
16
|
const global$2 = "";
|
|
17
17
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
@@ -70138,20 +70138,29 @@ const isWrongValue = (val) => {
|
|
|
70138
70138
|
return val === "undefined" || val === void 0 || val === "" || val === "null" || val === null || val === "NaN" || isNaN(val);
|
|
70139
70139
|
};
|
|
70140
70140
|
const convertUnit = (stringValue = "", toUnit, defaultFromUnit = "", doNotConvertValue = false) => {
|
|
70141
|
-
if (
|
|
70141
|
+
if (doNotConvertValue)
|
|
70142
|
+
return stringValue;
|
|
70143
|
+
if (toUnit && !isWrongValue(stringValue)) {
|
|
70142
70144
|
try {
|
|
70143
|
-
const
|
|
70145
|
+
const valueWithUnit = isValueWithUnit(stringValue) ? stringValue : withUnit(stringValue, defaultFromUnit);
|
|
70146
|
+
const result = convertSamePrecision(valueWithUnit, toUnit);
|
|
70144
70147
|
return getValue$1(result);
|
|
70145
70148
|
} catch (e2) {
|
|
70146
70149
|
}
|
|
70147
70150
|
}
|
|
70148
|
-
return
|
|
70151
|
+
return stringValue;
|
|
70149
70152
|
};
|
|
70150
70153
|
const safeConvertValue = (value = "", toUnit, defaultFromUnit, doNotConvertValue) => {
|
|
70154
|
+
if (doNotConvertValue)
|
|
70155
|
+
return value;
|
|
70151
70156
|
const isWithUnit = isValueWithUnit(value);
|
|
70152
|
-
const
|
|
70153
|
-
const
|
|
70154
|
-
|
|
70157
|
+
const rawValue = getValue$1(value);
|
|
70158
|
+
const isInvalidInput = isWrongValue(rawValue);
|
|
70159
|
+
if (isInvalidInput)
|
|
70160
|
+
return rawValue;
|
|
70161
|
+
if (!isWithUnit)
|
|
70162
|
+
return value;
|
|
70163
|
+
return convertUnit(rawValue, toUnit, defaultFromUnit, doNotConvertValue);
|
|
70155
70164
|
};
|
|
70156
70165
|
const getStringName = (name2) => {
|
|
70157
70166
|
if (isObject$5(name2) && !isArray$1(name2) && !isFunction$3(name2)) {
|
|
@@ -70198,6 +70207,14 @@ const validate = (value, options) => {
|
|
|
70198
70207
|
}
|
|
70199
70208
|
return null;
|
|
70200
70209
|
};
|
|
70210
|
+
const isUnitKnown = (unit2 = "") => {
|
|
70211
|
+
var _a;
|
|
70212
|
+
return (_a = KNOWN_UNITS) == null ? void 0 : _a.includes(unit2);
|
|
70213
|
+
};
|
|
70214
|
+
const isKnownUnit = (valueWithUnit, defaultUnit) => {
|
|
70215
|
+
const unitFromValue = getUnit(valueWithUnit || "");
|
|
70216
|
+
return isUnitKnown(defaultUnit) && isUnitKnown(unitFromValue);
|
|
70217
|
+
};
|
|
70201
70218
|
const predefinedMenuActive = "_predefinedMenuActive_1yvt4_1";
|
|
70202
70219
|
const styles = {
|
|
70203
70220
|
predefinedMenuActive
|
|
@@ -70246,6 +70263,7 @@ const UnitInput = ({
|
|
|
70246
70263
|
() => getPreferredUnit(unitkey, unitTemplate),
|
|
70247
70264
|
[unitkey, unitTemplate]
|
|
70248
70265
|
);
|
|
70266
|
+
const knownUnit = isKnownUnit(value, defaultUnit);
|
|
70249
70267
|
const initDisplayUnit = initUnit || defaultUnit || propUnit;
|
|
70250
70268
|
const previousInitUnit = usePrevious(initDisplayUnit);
|
|
70251
70269
|
const convertedValue = safeConvertValue(
|
|
@@ -70273,14 +70291,14 @@ const UnitInput = ({
|
|
|
70273
70291
|
}
|
|
70274
70292
|
const predefinedMenuItemUnit = isValueWithUnit(el2.value) ? getUnit(el2.value) : "";
|
|
70275
70293
|
return withUnit(
|
|
70276
|
-
convertUnit(
|
|
70294
|
+
convertUnit(value, predefinedMenuItemUnit),
|
|
70277
70295
|
predefinedMenuItemUnit
|
|
70278
70296
|
) === el2.value;
|
|
70279
70297
|
});
|
|
70280
70298
|
const getAlternativeUnits = () => {
|
|
70281
70299
|
if (unitkey) {
|
|
70282
70300
|
try {
|
|
70283
|
-
const valueToList =
|
|
70301
|
+
const valueToList = isAutoValue ? autoValue : value ?? "";
|
|
70284
70302
|
let alternativeUnits2 = altUnitsList(valueToList, unitkey);
|
|
70285
70303
|
if (getValue$1(valueToList) === "") {
|
|
70286
70304
|
return alternativeUnits2.map((unitRow) => ["", unitRow[1]]);
|
|
@@ -70339,22 +70357,25 @@ const UnitInput = ({
|
|
|
70339
70357
|
useEffect(() => {
|
|
70340
70358
|
if (initDisplayUnit) {
|
|
70341
70359
|
let newValue, newUnit = "";
|
|
70342
|
-
if (previousInitUnit !== initDisplayUnit) {
|
|
70360
|
+
if (previousInitUnit !== initDisplayUnit && knownUnit) {
|
|
70343
70361
|
newValue = safeConvertValue(
|
|
70344
|
-
|
|
70362
|
+
value,
|
|
70345
70363
|
initDisplayUnit,
|
|
70346
70364
|
propUnit,
|
|
70347
70365
|
doNotConvertValue
|
|
70348
70366
|
);
|
|
70349
70367
|
newUnit = initDisplayUnit;
|
|
70350
|
-
} else if (withUnit(displayLayer.value, displayLayer.unit) !== value) {
|
|
70368
|
+
} else if (withUnit(displayLayer.value, displayLayer.unit) !== value && knownUnit) {
|
|
70351
70369
|
newValue = safeConvertValue(
|
|
70352
|
-
|
|
70370
|
+
value,
|
|
70353
70371
|
displayLayer.unit,
|
|
70354
70372
|
propUnit,
|
|
70355
70373
|
doNotConvertValue
|
|
70356
70374
|
);
|
|
70357
70375
|
newUnit = displayLayer.unit;
|
|
70376
|
+
} else if (!knownUnit) {
|
|
70377
|
+
newValue = getValue$1(value ?? "");
|
|
70378
|
+
newUnit = initDisplayUnit;
|
|
70358
70379
|
}
|
|
70359
70380
|
if (newValue !== void 0) {
|
|
70360
70381
|
setDisplayLayer({ value: newValue, unit: newUnit });
|
|
@@ -70367,10 +70388,7 @@ const UnitInput = ({
|
|
|
70367
70388
|
}
|
|
70368
70389
|
}
|
|
70369
70390
|
}
|
|
70370
|
-
const cleanValue =
|
|
70371
|
-
checkAndCleanDecimalComma(propValue),
|
|
70372
|
-
(displayLayer == null ? void 0 : displayLayer.unit) || ""
|
|
70373
|
-
);
|
|
70391
|
+
const cleanValue = checkAndCleanDecimalComma(propValue);
|
|
70374
70392
|
const errorMessage = validate(cleanValue, {
|
|
70375
70393
|
allowEmpty,
|
|
70376
70394
|
autoValue,
|