@lumiastream/ui 0.2.2 → 0.2.3
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 +2 -2
- package/dist/index.js +16 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -55,9 +55,9 @@ declare const LSInput: React.ForwardRefExoticComponent<Omit<LSInputProps$1, "ref
|
|
|
55
55
|
|
|
56
56
|
interface LSInputPropsChild {
|
|
57
57
|
name?: string;
|
|
58
|
-
value?: number;
|
|
58
|
+
value?: number | string | null;
|
|
59
59
|
autoFocus?: boolean;
|
|
60
|
-
defaultValue?: number;
|
|
60
|
+
defaultValue?: number | string | null;
|
|
61
61
|
label?: React.ReactNode;
|
|
62
62
|
inline?: boolean;
|
|
63
63
|
hasInfo?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -185,6 +185,20 @@ import Slider from "@mui/material/Slider";
|
|
|
185
185
|
import classNames2 from "classnames";
|
|
186
186
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
187
187
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
188
|
+
var normalizeSliderValue = (rawValue) => {
|
|
189
|
+
if (typeof rawValue === "number") {
|
|
190
|
+
return Number.isFinite(rawValue) ? rawValue : 0;
|
|
191
|
+
}
|
|
192
|
+
if (typeof rawValue === "string") {
|
|
193
|
+
const trimmedValue = rawValue.trim();
|
|
194
|
+
if (!trimmedValue) {
|
|
195
|
+
return 0;
|
|
196
|
+
}
|
|
197
|
+
const numericValue = Number(trimmedValue);
|
|
198
|
+
return Number.isFinite(numericValue) ? numericValue : 0;
|
|
199
|
+
}
|
|
200
|
+
return 0;
|
|
201
|
+
};
|
|
188
202
|
var LSSliderInput = ({
|
|
189
203
|
name,
|
|
190
204
|
value,
|
|
@@ -214,13 +228,7 @@ var LSSliderInput = ({
|
|
|
214
228
|
const isValueFloat = Boolean(isFloat || isFloatMiliseconds || isMiliseconds);
|
|
215
229
|
const actualToDisplay = useCallback(
|
|
216
230
|
(input) => {
|
|
217
|
-
|
|
218
|
-
return input;
|
|
219
|
-
}
|
|
220
|
-
const numericValue = Number(input);
|
|
221
|
-
if (Number.isNaN(numericValue)) {
|
|
222
|
-
return 0;
|
|
223
|
-
}
|
|
231
|
+
const numericValue = normalizeSliderValue(input);
|
|
224
232
|
if (!isValueFloat) {
|
|
225
233
|
return numericValue;
|
|
226
234
|
}
|
|
@@ -241,7 +249,7 @@ var LSSliderInput = ({
|
|
|
241
249
|
return decimalIndex === -1 ? 0 : stepString.length - decimalIndex - 1;
|
|
242
250
|
}, [displayStep]);
|
|
243
251
|
useEffect(() => {
|
|
244
|
-
if (
|
|
252
|
+
if (value !== void 0) {
|
|
245
253
|
setDisplayValue(actualToDisplay(value));
|
|
246
254
|
}
|
|
247
255
|
}, [actualToDisplay, value]);
|