@timeax/form-palette 0.1.27 → 0.1.29
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/{core-BxK4PLut.d.mts → core-74nd0n1e.d.mts} +17 -13
- package/dist/{core-DDFFngF0.d.ts → core-B8Htm7S-.d.ts} +17 -13
- package/dist/extra.d.mts +2 -2
- package/dist/extra.d.ts +2 -2
- package/dist/extra.js +385 -913
- package/dist/extra.js.map +1 -1
- package/dist/extra.mjs +385 -913
- package/dist/extra.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +965 -1492
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +889 -1416
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/extra.mjs
CHANGED
|
@@ -10771,7 +10771,11 @@ var Input = React74.forwardRef(
|
|
|
10771
10771
|
children: [
|
|
10772
10772
|
renderBaseInput({
|
|
10773
10773
|
inner: false,
|
|
10774
|
-
className: cx(
|
|
10774
|
+
className: cx(
|
|
10775
|
+
baseBoxClasses,
|
|
10776
|
+
boxPaddingClasses,
|
|
10777
|
+
className
|
|
10778
|
+
),
|
|
10775
10779
|
style: varsStyle
|
|
10776
10780
|
}),
|
|
10777
10781
|
hasLeadingIcons && /* @__PURE__ */ jsx(
|
|
@@ -10875,7 +10879,7 @@ var Input = React74.forwardRef(
|
|
|
10875
10879
|
className: "absolute inset-y-0 left-0 flex items-center cursor-pointer",
|
|
10876
10880
|
style: {
|
|
10877
10881
|
gap: leadingGap,
|
|
10878
|
-
paddingLeft: `${pxDefault}px`
|
|
10882
|
+
paddingLeft: hasLeadingControl ? void 0 : `${pxDefault}px`
|
|
10879
10883
|
},
|
|
10880
10884
|
"data-slot": "leading-icons",
|
|
10881
10885
|
onMouseDown: handleIconMouseDown,
|
|
@@ -10896,7 +10900,7 @@ var Input = React74.forwardRef(
|
|
|
10896
10900
|
className: "absolute inset-y-0 right-0 flex items-center cursor-pointer",
|
|
10897
10901
|
style: {
|
|
10898
10902
|
gap: trailingGap,
|
|
10899
|
-
paddingRight: `${pxDefault}px`
|
|
10903
|
+
paddingRight: hasTrailingControl ? void 0 : `${pxDefault}px`
|
|
10900
10904
|
},
|
|
10901
10905
|
"data-slot": "trailing-icons",
|
|
10902
10906
|
onMouseDown: handleIconMouseDown,
|
|
@@ -11220,9 +11224,98 @@ var textVariant = {
|
|
|
11220
11224
|
tags: ["text", "input", "string"]
|
|
11221
11225
|
}
|
|
11222
11226
|
};
|
|
11227
|
+
function clampToLimits(n3, min2, max2) {
|
|
11228
|
+
let out = n3;
|
|
11229
|
+
if (min2 != null && out < min2) out = min2;
|
|
11230
|
+
if (max2 != null && out > max2) out = max2;
|
|
11231
|
+
return out;
|
|
11232
|
+
}
|
|
11233
|
+
function isFiniteNumber(n3) {
|
|
11234
|
+
return typeof n3 === "number" && Number.isFinite(n3);
|
|
11235
|
+
}
|
|
11236
|
+
function resolveLocale(explicit) {
|
|
11237
|
+
if (explicit) return explicit;
|
|
11238
|
+
if (typeof navigator !== "undefined" && navigator.language)
|
|
11239
|
+
return navigator.language;
|
|
11240
|
+
return "en-US";
|
|
11241
|
+
}
|
|
11242
|
+
function getDecimalSeparator(locale) {
|
|
11243
|
+
const s3 = new Intl.NumberFormat(locale, { useGrouping: false }).format(1.1);
|
|
11244
|
+
const m2 = s3.match(/1(.?)1/);
|
|
11245
|
+
return (m2 == null ? void 0 : m2[1]) || ".";
|
|
11246
|
+
}
|
|
11247
|
+
function stripAffixes(text, prefix, suffix) {
|
|
11248
|
+
let t4 = text != null ? text : "";
|
|
11249
|
+
if (prefix && t4.startsWith(prefix)) t4 = t4.slice(prefix.length);
|
|
11250
|
+
if (suffix && t4.endsWith(suffix)) t4 = t4.slice(0, -suffix.length);
|
|
11251
|
+
return t4;
|
|
11252
|
+
}
|
|
11253
|
+
function stripGrouping(text, locale) {
|
|
11254
|
+
const group = new Intl.NumberFormat(locale, { useGrouping: true }).format(1e6).replace(/[0-9]/g, "").trim().charAt(0);
|
|
11255
|
+
if (!group) return text;
|
|
11256
|
+
const re3 = new RegExp(`\\${group}`, "g");
|
|
11257
|
+
return text.replace(re3, "");
|
|
11258
|
+
}
|
|
11259
|
+
function parseEditable(editable, locale, decimalSep) {
|
|
11260
|
+
const t4 = editable.trim();
|
|
11261
|
+
if (!t4 || t4 === "-" || t4 === decimalSep) return null;
|
|
11262
|
+
const noGroup = stripGrouping(t4, locale);
|
|
11263
|
+
const normalized = decimalSep === "." ? noGroup : noGroup.replace(decimalSep, ".");
|
|
11264
|
+
const cleaned = normalized.endsWith(".") ? normalized.slice(0, -1) : normalized;
|
|
11265
|
+
if (!cleaned || cleaned === "-") return null;
|
|
11266
|
+
const n3 = Number(cleaned);
|
|
11267
|
+
return Number.isFinite(n3) ? n3 : null;
|
|
11268
|
+
}
|
|
11269
|
+
function formatDisplayNumber(n3, locale, opts, prefix, suffix) {
|
|
11270
|
+
const f2 = new Intl.NumberFormat(locale, opts).format(n3);
|
|
11271
|
+
return `${prefix != null ? prefix : ""}${f2}${suffix != null ? suffix : ""}`;
|
|
11272
|
+
}
|
|
11273
|
+
function applyFractionLimitReplace(next, prev, locale, decimalSep, maxFractionDigits, inputEl) {
|
|
11274
|
+
var _a, _b, _c;
|
|
11275
|
+
if (maxFractionDigits == null)
|
|
11276
|
+
return { text: next, caret: (_a = inputEl.selectionStart) != null ? _a : next.length };
|
|
11277
|
+
const selStart = (_b = inputEl.selectionStart) != null ? _b : 0;
|
|
11278
|
+
const selEnd = (_c = inputEl.selectionEnd) != null ? _c : selStart;
|
|
11279
|
+
const decIndex = next.indexOf(decimalSep);
|
|
11280
|
+
if (decIndex === -1) return { text: next, caret: selStart };
|
|
11281
|
+
const frac = next.slice(decIndex + 1);
|
|
11282
|
+
if (frac.length <= maxFractionDigits)
|
|
11283
|
+
return { text: next, caret: selStart };
|
|
11284
|
+
if (selEnd > selStart) {
|
|
11285
|
+
const trimmed2 = next.slice(0, decIndex + 1 + maxFractionDigits);
|
|
11286
|
+
const caret2 = Math.min(selStart, trimmed2.length);
|
|
11287
|
+
return { text: trimmed2, caret: caret2 };
|
|
11288
|
+
}
|
|
11289
|
+
const caret = selStart;
|
|
11290
|
+
const fracStart = decIndex + 1;
|
|
11291
|
+
const fracEnd = fracStart + maxFractionDigits;
|
|
11292
|
+
const trimmed = next.slice(0, fracEnd);
|
|
11293
|
+
const clampedCaret = Math.min(caret, trimmed.length);
|
|
11294
|
+
return { text: trimmed, caret: clampedCaret };
|
|
11295
|
+
}
|
|
11296
|
+
function normalizeEditable(raw, locale, decimalSep, allowMinus) {
|
|
11297
|
+
let t4 = raw;
|
|
11298
|
+
t4 = stripGrouping(t4, locale);
|
|
11299
|
+
const allowed = new RegExp(`[^0-9\\${decimalSep}\\-]`, "g");
|
|
11300
|
+
t4 = t4.replace(allowed, "");
|
|
11301
|
+
const minusCount = (t4.match(/\-/g) || []).length;
|
|
11302
|
+
if (minusCount) {
|
|
11303
|
+
t4 = t4.replace(/\-/g, "");
|
|
11304
|
+
if (allowMinus) t4 = "-" + t4;
|
|
11305
|
+
}
|
|
11306
|
+
const firstDec = t4.indexOf(decimalSep);
|
|
11307
|
+
if (firstDec !== -1) {
|
|
11308
|
+
const before = t4.slice(0, firstDec + 1);
|
|
11309
|
+
const after = t4.slice(firstDec + 1).replace(new RegExp(`\\${decimalSep}`, "g"), "");
|
|
11310
|
+
t4 = before + after;
|
|
11311
|
+
}
|
|
11312
|
+
if (t4 === "-" + decimalSep) t4 = "-0" + decimalSep;
|
|
11313
|
+
if (t4 === decimalSep) t4 = "0" + decimalSep;
|
|
11314
|
+
return t4;
|
|
11315
|
+
}
|
|
11223
11316
|
var InputNumber = React74.memo(
|
|
11224
11317
|
React74.forwardRef((inProps, ref) => {
|
|
11225
|
-
var _a
|
|
11318
|
+
var _a;
|
|
11226
11319
|
const props = {
|
|
11227
11320
|
allowEmpty: true,
|
|
11228
11321
|
autoFocus: false,
|
|
@@ -11236,35 +11329,19 @@ var InputNumber = React74.memo(
|
|
|
11236
11329
|
type: "text",
|
|
11237
11330
|
...inProps
|
|
11238
11331
|
};
|
|
11239
|
-
const
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
const
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
|
|
11247
|
-
const
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
const
|
|
11252
|
-
const _decimal = React74.useRef(null);
|
|
11253
|
-
const _decimalSeparator = React74.useRef(".");
|
|
11254
|
-
const _suffix = React74.useRef(null);
|
|
11255
|
-
const _prefix = React74.useRef(null);
|
|
11256
|
-
const _index = React74.useRef(() => 0);
|
|
11257
|
-
const isFocusedByClick = React74.useRef(false);
|
|
11258
|
-
const resolveLocale = React74.useCallback(() => {
|
|
11259
|
-
if (props.locale) return props.locale;
|
|
11260
|
-
if (typeof navigator !== "undefined" && navigator.language) {
|
|
11261
|
-
return navigator.language;
|
|
11262
|
-
}
|
|
11263
|
-
return "en-US";
|
|
11264
|
-
}, [props.locale]);
|
|
11265
|
-
const _locale = resolveLocale();
|
|
11266
|
-
const inputMode = props.inputMode || (props.mode === "decimal" && !props.minFractionDigits && !props.maxFractionDigits ? "numeric" : "decimal");
|
|
11267
|
-
const getOptions = React74.useCallback(() => {
|
|
11332
|
+
const locale = React74.useMemo(
|
|
11333
|
+
() => resolveLocale(props.locale),
|
|
11334
|
+
[props.locale]
|
|
11335
|
+
);
|
|
11336
|
+
const decimalSep = React74.useMemo(
|
|
11337
|
+
() => getDecimalSeparator(locale),
|
|
11338
|
+
[locale]
|
|
11339
|
+
);
|
|
11340
|
+
const allowMinus = React74.useMemo(
|
|
11341
|
+
() => props.min == null || props.min < 0,
|
|
11342
|
+
[props.min]
|
|
11343
|
+
);
|
|
11344
|
+
const fmtOptions = React74.useMemo(() => {
|
|
11268
11345
|
return {
|
|
11269
11346
|
localeMatcher: props.localeMatcher,
|
|
11270
11347
|
style: props.mode,
|
|
@@ -11285,262 +11362,27 @@ var InputNumber = React74.memo(
|
|
|
11285
11362
|
props.maxFractionDigits,
|
|
11286
11363
|
props.roundingMode
|
|
11287
11364
|
]);
|
|
11288
|
-
const
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
_numeral.current = new RegExp("[" + numerals.join("") + "]", "g");
|
|
11297
|
-
_index.current = (d) => {
|
|
11298
|
-
var _a2;
|
|
11299
|
-
return (_a2 = index.get(d)) != null ? _a2 : 0;
|
|
11300
|
-
};
|
|
11301
|
-
const formatterGroup = new Intl.NumberFormat(loc, { useGrouping: true });
|
|
11302
|
-
groupChar.current = formatterGroup.format(1e6).trim().replace(_numeral.current, "").charAt(0);
|
|
11303
|
-
_group.current = new RegExp("[" + groupChar.current + "]", "g");
|
|
11304
|
-
const formatterMinus = new Intl.NumberFormat(loc, { useGrouping: false });
|
|
11305
|
-
const minusString = formatterMinus.format(-1).trim().replace(_numeral.current, "");
|
|
11306
|
-
_minusSign.current = new RegExp("[" + minusString + "]", "g");
|
|
11307
|
-
if (props.currency) {
|
|
11308
|
-
const formatterCurrency = new Intl.NumberFormat(loc, {
|
|
11309
|
-
style: "currency",
|
|
11310
|
-
currency: props.currency,
|
|
11311
|
-
currencyDisplay: props.currencyDisplay,
|
|
11312
|
-
minimumFractionDigits: 0,
|
|
11313
|
-
maximumFractionDigits: 0,
|
|
11314
|
-
roundingMode: props.roundingMode
|
|
11315
|
-
});
|
|
11316
|
-
_currency.current = new RegExp(
|
|
11317
|
-
"[" + formatterCurrency.format(1).replace(/\s/g, "").replace(_numeral.current, "").replace(_group.current, "") + "]",
|
|
11318
|
-
"g"
|
|
11319
|
-
);
|
|
11320
|
-
} else {
|
|
11321
|
-
_currency.current = new RegExp("[]", "g");
|
|
11322
|
-
}
|
|
11323
|
-
const formatterDecimal = new Intl.NumberFormat(loc, {
|
|
11324
|
-
useGrouping: false
|
|
11325
|
-
});
|
|
11326
|
-
const decSample = formatterDecimal.format(1.1).trim().replace(_numeral.current, "");
|
|
11327
|
-
_decimalSeparator.current = decSample || ".";
|
|
11328
|
-
const formatterDecOptions = new Intl.NumberFormat(loc, {
|
|
11329
|
-
...getOptions(),
|
|
11330
|
-
useGrouping: false
|
|
11331
|
-
});
|
|
11332
|
-
_decimal.current = new RegExp(
|
|
11333
|
-
"[" + formatterDecOptions.format(1.1).replace(_currency.current, "").trim().replace(_numeral.current, "") + "]",
|
|
11334
|
-
"g"
|
|
11335
|
-
);
|
|
11336
|
-
if (props.prefix) {
|
|
11337
|
-
prefixChar.current = props.prefix;
|
|
11338
|
-
} else {
|
|
11339
|
-
const formatterPrefix = new Intl.NumberFormat(loc, {
|
|
11340
|
-
style: props.mode,
|
|
11341
|
-
currency: props.currency,
|
|
11342
|
-
currencyDisplay: props.currencyDisplay
|
|
11343
|
-
});
|
|
11344
|
-
prefixChar.current = formatterPrefix.format(1).split("1")[0];
|
|
11345
|
-
}
|
|
11346
|
-
_prefix.current = new RegExp(escapeRegExp(prefixChar.current || ""), "g");
|
|
11347
|
-
if (props.suffix) {
|
|
11348
|
-
suffixChar.current = props.suffix;
|
|
11349
|
-
} else {
|
|
11350
|
-
const formatterSuffix = new Intl.NumberFormat(loc, {
|
|
11351
|
-
style: props.mode,
|
|
11352
|
-
currency: props.currency,
|
|
11353
|
-
currencyDisplay: props.currencyDisplay,
|
|
11354
|
-
minimumFractionDigits: 0,
|
|
11355
|
-
maximumFractionDigits: 0,
|
|
11356
|
-
roundingMode: props.roundingMode
|
|
11357
|
-
});
|
|
11358
|
-
suffixChar.current = formatterSuffix.format(1).split("1")[1];
|
|
11359
|
-
}
|
|
11360
|
-
_suffix.current = new RegExp(escapeRegExp(suffixChar.current || ""), "g");
|
|
11361
|
-
}, [
|
|
11362
|
-
_locale,
|
|
11363
|
-
getOptions,
|
|
11364
|
-
props.currency,
|
|
11365
|
-
props.currencyDisplay,
|
|
11366
|
-
props.mode,
|
|
11367
|
-
props.prefix,
|
|
11368
|
-
props.roundingMode,
|
|
11369
|
-
props.suffix
|
|
11370
|
-
]);
|
|
11371
|
-
const formatValue = React74.useCallback(
|
|
11372
|
-
(value2) => {
|
|
11373
|
-
if (value2 == null) return "";
|
|
11374
|
-
if (value2 === "-") return "-";
|
|
11375
|
-
const numeric = typeof value2 === "number" ? value2 : typeof value2 === "string" ? Number(value2) : Number.NaN;
|
|
11376
|
-
if (Number.isNaN(numeric)) return "";
|
|
11377
|
-
if (props.format) {
|
|
11378
|
-
const formatter = numberFormat.current || new Intl.NumberFormat(_locale, getOptions());
|
|
11379
|
-
let formatted = formatter.format(numeric);
|
|
11380
|
-
if (props.prefix) {
|
|
11381
|
-
formatted = props.prefix + formatted;
|
|
11382
|
-
}
|
|
11383
|
-
if (props.suffix) {
|
|
11384
|
-
formatted = formatted + props.suffix;
|
|
11385
|
-
}
|
|
11386
|
-
return formatted;
|
|
11387
|
-
}
|
|
11388
|
-
return numeric.toString();
|
|
11365
|
+
const inputRef = React74.useRef(null);
|
|
11366
|
+
React74.useImperativeHandle(ref, () => inputRef.current);
|
|
11367
|
+
const [display, setDisplay] = React74.useState("");
|
|
11368
|
+
const [focused, setFocused] = React74.useState(false);
|
|
11369
|
+
const toEditableFromNumber = React74.useCallback(
|
|
11370
|
+
(n3) => {
|
|
11371
|
+
const s3 = String(n3);
|
|
11372
|
+
return decimalSep === "." ? s3 : s3.replace(".", decimalSep);
|
|
11389
11373
|
},
|
|
11390
|
-
[
|
|
11374
|
+
[decimalSep]
|
|
11391
11375
|
);
|
|
11392
|
-
const
|
|
11393
|
-
(
|
|
11394
|
-
|
|
11395
|
-
let filteredText = text;
|
|
11396
|
-
if (_suffix.current) {
|
|
11397
|
-
filteredText = filteredText.replace(_suffix.current, "");
|
|
11398
|
-
}
|
|
11399
|
-
if (_prefix.current) {
|
|
11400
|
-
filteredText = filteredText.replace(_prefix.current, "");
|
|
11401
|
-
}
|
|
11402
|
-
filteredText = filteredText.trim().replace(/\s/g, "").replace(_currency.current, "").replace(_group.current, "").replace(_minusSign.current, "-").replace(_decimal.current, ".").replace(
|
|
11403
|
-
_numeral.current,
|
|
11404
|
-
(d) => {
|
|
11405
|
-
var _a2;
|
|
11406
|
-
return String((_a2 = _index.current(d)) != null ? _a2 : "");
|
|
11407
|
-
}
|
|
11408
|
-
);
|
|
11409
|
-
if (!filteredText) return null;
|
|
11410
|
-
if (filteredText === "-") {
|
|
11411
|
-
return "-";
|
|
11412
|
-
}
|
|
11413
|
-
const parsedValue = +filteredText;
|
|
11414
|
-
return Number.isNaN(parsedValue) ? null : parsedValue;
|
|
11415
|
-
},
|
|
11416
|
-
[]
|
|
11376
|
+
const clampModel = React74.useCallback(
|
|
11377
|
+
(n3) => clampToLimits(n3, props.min, props.max),
|
|
11378
|
+
[props.min, props.max]
|
|
11417
11379
|
);
|
|
11418
|
-
const
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
timer.current = void 0;
|
|
11423
|
-
}
|
|
11424
|
-
};
|
|
11425
|
-
const allowMinusSign = () => props.min == null || props.min < 0;
|
|
11426
|
-
const isMinusSign = (ch) => {
|
|
11427
|
-
if (_minusSign.current && _minusSign.current.test(ch) || ch === "-") {
|
|
11428
|
-
_minusSign.current && (_minusSign.current.lastIndex = 0);
|
|
11429
|
-
return true;
|
|
11430
|
-
}
|
|
11431
|
-
return false;
|
|
11432
|
-
};
|
|
11433
|
-
const isDecimalMode = () => props.mode === "decimal";
|
|
11434
|
-
const isFloat = (val) => {
|
|
11435
|
-
const formatter = new Intl.NumberFormat(_locale, getOptions());
|
|
11436
|
-
const parsed = parseValue(formatter.format(val));
|
|
11437
|
-
if (parsed === null || typeof parsed !== "number") {
|
|
11438
|
-
return false;
|
|
11439
|
-
}
|
|
11440
|
-
return parsed % 1 !== 0;
|
|
11441
|
-
};
|
|
11442
|
-
const replaceDecimalSeparator = (val) => {
|
|
11443
|
-
if (typeof val === "number" && isFloat(val)) {
|
|
11444
|
-
return val.toString().replace(/\.(?=[^.]*$)/, _decimalSeparator.current);
|
|
11445
|
-
}
|
|
11446
|
-
return val;
|
|
11447
|
-
};
|
|
11448
|
-
const isDecimalSign = (ch) => {
|
|
11449
|
-
if (_decimal.current && (_decimal.current.test(ch) || isFloat(Number(ch)))) {
|
|
11450
|
-
_decimal.current.lastIndex = 0;
|
|
11451
|
-
return true;
|
|
11452
|
-
}
|
|
11453
|
-
return false;
|
|
11454
|
-
};
|
|
11455
|
-
const getDecimalCharIndexes = (val) => {
|
|
11456
|
-
let decimalCharIndex = -1;
|
|
11457
|
-
let decimalCharIndexWithoutPrefix = -1;
|
|
11458
|
-
if (_decimal.current) {
|
|
11459
|
-
decimalCharIndex = val.search(_decimal.current);
|
|
11460
|
-
_decimal.current.lastIndex = 0;
|
|
11461
|
-
let filteredVal = val;
|
|
11462
|
-
if (_prefix.current) {
|
|
11463
|
-
filteredVal = filteredVal.replace(_prefix.current, "");
|
|
11464
|
-
}
|
|
11465
|
-
filteredVal = filteredVal.trim().replace(/\s/g, "").replace(_currency.current, "");
|
|
11466
|
-
decimalCharIndexWithoutPrefix = filteredVal.search(_decimal.current);
|
|
11467
|
-
_decimal.current.lastIndex = 0;
|
|
11468
|
-
}
|
|
11469
|
-
return { decimalCharIndex, decimalCharIndexWithoutPrefix };
|
|
11470
|
-
};
|
|
11471
|
-
const getCharIndexes = (val) => {
|
|
11472
|
-
let decimalCharIndex = -1;
|
|
11473
|
-
let minusCharIndex = -1;
|
|
11474
|
-
let suffixCharIndex = -1;
|
|
11475
|
-
let currencyCharIndex = -1;
|
|
11476
|
-
if (_decimal.current) {
|
|
11477
|
-
decimalCharIndex = val.search(_decimal.current);
|
|
11478
|
-
_decimal.current.lastIndex = 0;
|
|
11479
|
-
}
|
|
11480
|
-
if (_minusSign.current) {
|
|
11481
|
-
minusCharIndex = val.search(_minusSign.current);
|
|
11482
|
-
_minusSign.current.lastIndex = 0;
|
|
11483
|
-
}
|
|
11484
|
-
if (_suffix.current) {
|
|
11485
|
-
suffixCharIndex = val.search(_suffix.current);
|
|
11486
|
-
_suffix.current.lastIndex = 0;
|
|
11487
|
-
}
|
|
11488
|
-
if (_currency.current) {
|
|
11489
|
-
currencyCharIndex = val.search(_currency.current);
|
|
11490
|
-
if (currencyCharIndex === 0 && prefixChar.current && prefixChar.current.length > 1) {
|
|
11491
|
-
currencyCharIndex = prefixChar.current.trim().length;
|
|
11492
|
-
}
|
|
11493
|
-
_currency.current.lastIndex = 0;
|
|
11494
|
-
}
|
|
11495
|
-
return { decimalCharIndex, minusCharIndex, suffixCharIndex, currencyCharIndex };
|
|
11496
|
-
};
|
|
11497
|
-
const resetRegex = () => {
|
|
11498
|
-
if (_numeral.current) _numeral.current.lastIndex = 0;
|
|
11499
|
-
if (_decimal.current) _decimal.current.lastIndex = 0;
|
|
11500
|
-
if (_group.current) _group.current.lastIndex = 0;
|
|
11501
|
-
if (_minusSign.current) _minusSign.current.lastIndex = 0;
|
|
11502
|
-
};
|
|
11503
|
-
const isNumeralChar = (ch) => {
|
|
11504
|
-
if (ch.length === 1 && (_numeral.current && _numeral.current.test(ch) || _decimal.current && _decimal.current.test(ch) || _group.current && _group.current.test(ch) || _minusSign.current && _minusSign.current.test(ch))) {
|
|
11505
|
-
resetRegex();
|
|
11506
|
-
return true;
|
|
11507
|
-
}
|
|
11508
|
-
return false;
|
|
11509
|
-
};
|
|
11510
|
-
const evaluateEmpty = (newValue) => {
|
|
11511
|
-
var _a2;
|
|
11512
|
-
if ((newValue == null || newValue === "") && !props.allowEmpty) {
|
|
11513
|
-
return (_a2 = props.min) != null ? _a2 : 0;
|
|
11514
|
-
}
|
|
11515
|
-
return newValue;
|
|
11516
|
-
};
|
|
11517
|
-
const validateValueByLimit = (value2) => {
|
|
11518
|
-
if (value2 === "-" || value2 === null || value2 === "") {
|
|
11519
|
-
return null;
|
|
11520
|
-
}
|
|
11521
|
-
let num = typeof value2 === "number" ? value2 : Number(value2);
|
|
11522
|
-
if (Number.isNaN(num)) {
|
|
11523
|
-
return null;
|
|
11524
|
-
}
|
|
11525
|
-
if (props.min != null && num < props.min) num = props.min;
|
|
11526
|
-
if (props.max != null && num > props.max) num = props.max;
|
|
11527
|
-
return num;
|
|
11528
|
-
};
|
|
11529
|
-
const validateValue = (value2) => {
|
|
11530
|
-
if (value2 === "-") return null;
|
|
11531
|
-
return validateValueByLimit(value2);
|
|
11532
|
-
};
|
|
11533
|
-
const formattedValue = (val) => {
|
|
11534
|
-
const newVal = evaluateEmpty(val);
|
|
11535
|
-
return formatValue(newVal);
|
|
11536
|
-
};
|
|
11537
|
-
const updateModel = (event, value2) => {
|
|
11538
|
-
var _a2, _b2;
|
|
11539
|
-
const finalValue = value2;
|
|
11540
|
-
if (props.onValueChange) {
|
|
11541
|
-
props.onValueChange({
|
|
11380
|
+
const emit = React74.useCallback(
|
|
11381
|
+
(event, value2) => {
|
|
11382
|
+
var _a2, _b, _c;
|
|
11383
|
+
(_c = props.onValueChange) == null ? void 0 : _c.call(props, {
|
|
11542
11384
|
originalEvent: event,
|
|
11543
|
-
value:
|
|
11385
|
+
value: value2,
|
|
11544
11386
|
stopPropagation() {
|
|
11545
11387
|
event == null ? void 0 : event.stopPropagation();
|
|
11546
11388
|
},
|
|
@@ -11549,600 +11391,160 @@ var InputNumber = React74.memo(
|
|
|
11549
11391
|
},
|
|
11550
11392
|
target: {
|
|
11551
11393
|
name: (_a2 = props.name) != null ? _a2 : null,
|
|
11552
|
-
id: (
|
|
11553
|
-
value:
|
|
11394
|
+
id: (_b = props.id) != null ? _b : null,
|
|
11395
|
+
value: value2
|
|
11554
11396
|
}
|
|
11555
11397
|
});
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
props.onChange({ originalEvent: event, value: finalValue });
|
|
11559
|
-
}
|
|
11560
|
-
};
|
|
11561
|
-
const handleOnChange = (event, currentValue, newValue) => {
|
|
11562
|
-
if (!props.onChange) return;
|
|
11563
|
-
const parsedCurrent = typeof currentValue === "string" ? parseValue(currentValue) : null;
|
|
11564
|
-
const changed = newValue !== parsedCurrent;
|
|
11565
|
-
if (changed) {
|
|
11566
|
-
props.onChange({ originalEvent: event, value: newValue });
|
|
11567
|
-
}
|
|
11568
|
-
};
|
|
11569
|
-
const concatValues = (val1, val2) => {
|
|
11570
|
-
if (val1 && val2) {
|
|
11571
|
-
const decimalCharIndex = val2.search(_decimal.current);
|
|
11572
|
-
_decimal.current.lastIndex = 0;
|
|
11573
|
-
const newVal1 = replaceDecimalSeparator(val1);
|
|
11574
|
-
const base = newVal1.split(_decimal.current)[0].replace(_suffix.current, "").trim();
|
|
11575
|
-
return decimalCharIndex !== -1 ? base + val2.slice(decimalCharIndex) : val1;
|
|
11576
|
-
}
|
|
11577
|
-
return val1;
|
|
11578
|
-
};
|
|
11579
|
-
const getDecimalLength = (value2) => {
|
|
11580
|
-
if (value2) {
|
|
11581
|
-
const valueSplit = value2.split(_decimal.current);
|
|
11582
|
-
if (valueSplit.length === 2) {
|
|
11583
|
-
return valueSplit[1].replace(_suffix.current, "").length;
|
|
11584
|
-
}
|
|
11585
|
-
}
|
|
11586
|
-
return 0;
|
|
11587
|
-
};
|
|
11588
|
-
const deleteRange = (value2, start, end) => {
|
|
11589
|
-
if (end - start === value2.length) {
|
|
11590
|
-
return "";
|
|
11591
|
-
} else if (start === 0) {
|
|
11592
|
-
return value2.slice(end);
|
|
11593
|
-
} else if (end === value2.length) {
|
|
11594
|
-
return value2.slice(0, start);
|
|
11595
|
-
}
|
|
11596
|
-
return value2.slice(0, start) + value2.slice(end);
|
|
11597
|
-
};
|
|
11598
|
-
const replaceSuffix = (value2) => value2 ? value2.replace(_suffix.current, "").trim().replace(/\s/g, "").replace(_currency.current, "") : value2;
|
|
11599
|
-
const insertText = (value2, text, start, end) => {
|
|
11600
|
-
const textSplit = isDecimalSign(text) ? text : text.split(_decimal.current);
|
|
11601
|
-
if (textSplit.length === 2) {
|
|
11602
|
-
const local = value2.slice(start, end);
|
|
11603
|
-
const decimalCharIndex = local.search(_decimal.current);
|
|
11604
|
-
_decimal.current.lastIndex = 0;
|
|
11605
|
-
return decimalCharIndex > 0 ? value2.slice(0, start) + formatValue(text) + replaceSuffix(value2).slice(end) : value2 || formatValue(text);
|
|
11606
|
-
}
|
|
11607
|
-
if (isDecimalSign(text) && value2.length === 0) {
|
|
11608
|
-
return formatValue("0.");
|
|
11609
|
-
}
|
|
11610
|
-
if (end - start === value2.length) {
|
|
11611
|
-
return formatValue(text);
|
|
11612
|
-
}
|
|
11613
|
-
if (start === 0) {
|
|
11614
|
-
const suffix = /[A-Za-z]$/.test(value2[end]) ? end - 1 : end;
|
|
11615
|
-
return text + value2.slice(suffix);
|
|
11616
|
-
}
|
|
11617
|
-
if (end === value2.length) {
|
|
11618
|
-
return value2.slice(0, start) + text;
|
|
11619
|
-
}
|
|
11620
|
-
const selectionValue = value2.slice(start, end);
|
|
11621
|
-
const space = /\s$/.test(selectionValue) ? " " : "";
|
|
11622
|
-
return value2.slice(0, start) + text + space + value2.slice(end);
|
|
11623
|
-
};
|
|
11624
|
-
const evaluateEmptyForUpdate = (newValue) => evaluateEmpty(newValue);
|
|
11625
|
-
const updateInput = (value2, insertedValueStr, operation, valueStr) => {
|
|
11626
|
-
var _a2, _b2;
|
|
11627
|
-
insertedValueStr = insertedValueStr || "";
|
|
11628
|
-
const inputEl = inputRef.current;
|
|
11629
|
-
if (!inputEl) return;
|
|
11630
|
-
const inputValue = inputEl.value;
|
|
11631
|
-
let newValue = formatValue(value2);
|
|
11632
|
-
const currentLength = inputValue.length;
|
|
11633
|
-
if (newValue !== valueStr && valueStr != null) {
|
|
11634
|
-
newValue = concatValues(newValue, valueStr);
|
|
11635
|
-
}
|
|
11636
|
-
if (currentLength === 0) {
|
|
11637
|
-
inputEl.value = newValue;
|
|
11638
|
-
inputEl.setSelectionRange(0, 0);
|
|
11639
|
-
const index = initCursor();
|
|
11640
|
-
const selectionEnd = index + insertedValueStr.length + (isDecimalSign(insertedValueStr) ? 1 : 0);
|
|
11641
|
-
inputEl.setSelectionRange(selectionEnd, selectionEnd);
|
|
11642
|
-
} else {
|
|
11643
|
-
let selectionStart = (_a2 = inputEl.selectionStart) != null ? _a2 : 0;
|
|
11644
|
-
let selectionEnd = (_b2 = inputEl.selectionEnd) != null ? _b2 : 0;
|
|
11645
|
-
if (props.maxLength && props.maxLength < newValue.length) {
|
|
11646
|
-
return;
|
|
11647
|
-
}
|
|
11648
|
-
inputEl.value = newValue;
|
|
11649
|
-
const newLength = newValue.length;
|
|
11650
|
-
if (operation === "range-insert") {
|
|
11651
|
-
const startValue = parseValue((inputValue || "").slice(0, selectionStart));
|
|
11652
|
-
const startValueStr = startValue != null ? String(startValue) : "";
|
|
11653
|
-
const startExpr = startValueStr.split("").join("(" + groupChar.current + ")?");
|
|
11654
|
-
const sRegex = new RegExp(startExpr, "g");
|
|
11655
|
-
sRegex.test(newValue);
|
|
11656
|
-
const tExpr = insertedValueStr.split("").join("(" + groupChar.current + ")?");
|
|
11657
|
-
const tRegex = new RegExp(tExpr, "g");
|
|
11658
|
-
tRegex.test(newValue.slice(sRegex.lastIndex));
|
|
11659
|
-
selectionEnd = sRegex.lastIndex + tRegex.lastIndex;
|
|
11660
|
-
inputEl.setSelectionRange(selectionEnd, selectionEnd);
|
|
11661
|
-
} else if (newLength === currentLength) {
|
|
11662
|
-
if (operation === "insert" || operation === "delete-back-single") {
|
|
11663
|
-
let newSelectionEnd = selectionEnd;
|
|
11664
|
-
if (insertedValueStr === "0") {
|
|
11665
|
-
newSelectionEnd = selectionEnd + 1;
|
|
11666
|
-
} else {
|
|
11667
|
-
newSelectionEnd = newSelectionEnd + Number(isDecimalSign(value2) || isDecimalSign(insertedValueStr));
|
|
11668
|
-
}
|
|
11669
|
-
inputEl.setSelectionRange(newSelectionEnd, newSelectionEnd);
|
|
11670
|
-
} else if (operation === "delete-single") {
|
|
11671
|
-
inputEl.setSelectionRange(selectionEnd - 1, selectionEnd - 1);
|
|
11672
|
-
} else if (operation === "delete-range" || operation === "spin") {
|
|
11673
|
-
inputEl.setSelectionRange(selectionEnd, selectionEnd);
|
|
11674
|
-
}
|
|
11675
|
-
} else if (operation === "delete-back-single") {
|
|
11676
|
-
const prevChar = inputValue.charAt(selectionEnd - 1);
|
|
11677
|
-
const nextChar = inputValue.charAt(selectionEnd);
|
|
11678
|
-
const diff = currentLength - newLength;
|
|
11679
|
-
const isGroupChar = _group.current.test(nextChar);
|
|
11680
|
-
if (isGroupChar && diff === 1) {
|
|
11681
|
-
selectionEnd = selectionEnd + 1;
|
|
11682
|
-
} else if (!isGroupChar && isNumeralChar(prevChar)) {
|
|
11683
|
-
selectionEnd = selectionEnd + (-1 * diff + 1);
|
|
11684
|
-
}
|
|
11685
|
-
_group.current.lastIndex = 0;
|
|
11686
|
-
inputEl.setSelectionRange(selectionEnd, selectionEnd);
|
|
11687
|
-
} else if (inputValue === "-" && operation === "insert") {
|
|
11688
|
-
inputEl.setSelectionRange(0, 0);
|
|
11689
|
-
const idx = initCursor();
|
|
11690
|
-
const end = idx + insertedValueStr.length + 1;
|
|
11691
|
-
inputEl.setSelectionRange(end, end);
|
|
11692
|
-
} else {
|
|
11693
|
-
selectionEnd = selectionEnd + (newLength - currentLength);
|
|
11694
|
-
inputEl.setSelectionRange(selectionEnd, selectionEnd);
|
|
11398
|
+
if (props.onChange && event) {
|
|
11399
|
+
props.onChange({ originalEvent: event, value: value2 });
|
|
11695
11400
|
}
|
|
11696
|
-
}
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
const
|
|
11700
|
-
const
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
inputEl.value = formatted;
|
|
11707
|
-
inputEl.setAttribute("aria-valuenow", evaluated == null ? "" : String(evaluated));
|
|
11708
|
-
}
|
|
11709
|
-
};
|
|
11710
|
-
const isValueChanged = (currentValue, newValue) => {
|
|
11711
|
-
if (newValue == null && currentValue != null) return true;
|
|
11712
|
-
if (newValue != null) {
|
|
11713
|
-
const parsedCurrent = typeof currentValue === "string" ? parseValue(currentValue) : null;
|
|
11714
|
-
return newValue !== parsedCurrent;
|
|
11715
|
-
}
|
|
11716
|
-
return false;
|
|
11717
|
-
};
|
|
11718
|
-
const updateValue = (event, valueStr, insertedValueStr, operation) => {
|
|
11719
|
-
const inputEl = inputRef.current;
|
|
11720
|
-
if (!inputEl) return;
|
|
11721
|
-
const currentValue = inputEl.value;
|
|
11722
|
-
if (valueStr != null) {
|
|
11723
|
-
const parsed = parseValue(valueStr);
|
|
11724
|
-
evaluateEmpty(parsed);
|
|
11725
|
-
const limited = validateValueByLimit(parsed);
|
|
11726
|
-
updateInput(limited, insertedValueStr, operation, valueStr);
|
|
11727
|
-
if (event && typeof currentValue === "string" && typeof limited === "number" && isValueChanged(currentValue, limited)) {
|
|
11728
|
-
handleOnChange(event, currentValue, limited);
|
|
11401
|
+
},
|
|
11402
|
+
[props]
|
|
11403
|
+
);
|
|
11404
|
+
const setCaret = (pos) => {
|
|
11405
|
+
const el = inputRef.current;
|
|
11406
|
+
if (!el) return;
|
|
11407
|
+
queueMicrotask(() => {
|
|
11408
|
+
try {
|
|
11409
|
+
el.setSelectionRange(pos, pos);
|
|
11410
|
+
} catch {
|
|
11729
11411
|
}
|
|
11730
|
-
|
|
11731
|
-
}
|
|
11732
|
-
};
|
|
11733
|
-
const spin = (event, dir) => {
|
|
11734
|
-
var _a2, _b2;
|
|
11735
|
-
const inputEl = inputRef.current;
|
|
11736
|
-
if (!inputEl) return;
|
|
11737
|
-
const step = ((_a2 = props.step) != null ? _a2 : 1) * dir;
|
|
11738
|
-
const currentValue = (_b2 = parseValue(inputEl.value)) != null ? _b2 : 0;
|
|
11739
|
-
const newValue = validateValue(addWithPrecision(currentValue, step));
|
|
11740
|
-
if (newValue == null) return;
|
|
11741
|
-
if (props.maxLength && props.maxLength < formatValue(newValue).length) {
|
|
11742
|
-
return;
|
|
11743
|
-
}
|
|
11744
|
-
handleOnChange(event, inputEl.value, newValue);
|
|
11745
|
-
updateInput(newValue, null, "spin");
|
|
11746
|
-
updateModel(event, newValue);
|
|
11412
|
+
});
|
|
11747
11413
|
};
|
|
11748
|
-
const
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11765
|
-
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
|
|
11786
|
-
|
|
11787
|
-
}
|
|
11788
|
-
}
|
|
11789
|
-
} else {
|
|
11790
|
-
const operation = selectionStart !== selectionEnd ? "range-insert" : "insert";
|
|
11791
|
-
if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
|
|
11792
|
-
if (selectionStart + text.length - (decimalCharIndex + 1) <= maxFractionDigits) {
|
|
11793
|
-
const charIndex = currencyCharIndex >= selectionStart ? currencyCharIndex - 1 : suffixCharIndex >= selectionStart ? suffixCharIndex : inputValue.length;
|
|
11794
|
-
newValueStr = inputValue.slice(0, selectionStart) + text + inputValue.slice(selectionStart + text.length, charIndex) + inputValue.slice(charIndex);
|
|
11795
|
-
updateValue(event, newValueStr, text, operation);
|
|
11796
|
-
}
|
|
11797
|
-
} else {
|
|
11798
|
-
newValueStr = insertText(inputValue, text, selectionStart, selectionEnd);
|
|
11799
|
-
updateValue(event, newValueStr, text, operation);
|
|
11414
|
+
const formatFromModel = React74.useCallback(
|
|
11415
|
+
(n3) => {
|
|
11416
|
+
if (n3 == null) return "";
|
|
11417
|
+
if (!props.format) return toEditableFromNumber(n3);
|
|
11418
|
+
const formatted = formatDisplayNumber(
|
|
11419
|
+
n3,
|
|
11420
|
+
locale,
|
|
11421
|
+
fmtOptions,
|
|
11422
|
+
props.prefix,
|
|
11423
|
+
props.suffix
|
|
11424
|
+
);
|
|
11425
|
+
return formatted;
|
|
11426
|
+
},
|
|
11427
|
+
[
|
|
11428
|
+
props.format,
|
|
11429
|
+
props.prefix,
|
|
11430
|
+
props.suffix,
|
|
11431
|
+
locale,
|
|
11432
|
+
fmtOptions,
|
|
11433
|
+
toEditableFromNumber
|
|
11434
|
+
]
|
|
11435
|
+
);
|
|
11436
|
+
const getModelFromDisplay = React74.useCallback(
|
|
11437
|
+
(text) => {
|
|
11438
|
+
const stripped = stripAffixes(text, props.prefix, props.suffix);
|
|
11439
|
+
const withoutGroup = stripGrouping(stripped, locale);
|
|
11440
|
+
const candidate = decimalSep !== "." ? withoutGroup.replace(".", decimalSep) : withoutGroup;
|
|
11441
|
+
const n3 = parseEditable(candidate, locale, decimalSep);
|
|
11442
|
+
if (n3 == null) return null;
|
|
11443
|
+
const clamped = clampModel(n3);
|
|
11444
|
+
return clamped;
|
|
11445
|
+
},
|
|
11446
|
+
[props.prefix, props.suffix, locale, decimalSep, clampModel]
|
|
11447
|
+
);
|
|
11448
|
+
const syncFromPropsValue = React74.useCallback(
|
|
11449
|
+
(v2) => {
|
|
11450
|
+
if (v2 == null) {
|
|
11451
|
+
setDisplay("");
|
|
11452
|
+
return;
|
|
11800
11453
|
}
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11454
|
+
const clamped = clampModel(v2);
|
|
11455
|
+
setDisplay(
|
|
11456
|
+
focused ? toEditableFromNumber(clamped) : formatFromModel(clamped)
|
|
11457
|
+
);
|
|
11458
|
+
},
|
|
11459
|
+
[clampModel, focused, toEditableFromNumber, formatFromModel]
|
|
11460
|
+
);
|
|
11461
|
+
React74.useEffect(() => {
|
|
11804
11462
|
var _a2;
|
|
11805
|
-
|
|
11806
|
-
|
|
11807
|
-
|
|
11808
|
-
let inputValue = inputEl.value;
|
|
11809
|
-
const valueLength = inputValue.length;
|
|
11810
|
-
let index = null;
|
|
11811
|
-
const prefixLength = (prefixChar.current || "").length;
|
|
11812
|
-
inputValue = inputValue.replace(_prefix.current, "");
|
|
11813
|
-
selectionStart = selectionStart - prefixLength;
|
|
11814
|
-
let ch = inputValue.charAt(selectionStart);
|
|
11815
|
-
if (isNumeralChar(ch)) {
|
|
11816
|
-
return selectionStart + prefixLength;
|
|
11817
|
-
}
|
|
11818
|
-
let i3 = selectionStart - 1;
|
|
11819
|
-
while (i3 >= 0) {
|
|
11820
|
-
ch = inputValue.charAt(i3);
|
|
11821
|
-
if (isNumeralChar(ch)) {
|
|
11822
|
-
index = i3 + prefixLength;
|
|
11823
|
-
break;
|
|
11824
|
-
}
|
|
11825
|
-
i3--;
|
|
11826
|
-
}
|
|
11827
|
-
if (index != null) {
|
|
11828
|
-
inputEl.setSelectionRange(index + 1, index + 1);
|
|
11829
|
-
} else {
|
|
11830
|
-
i3 = selectionStart;
|
|
11831
|
-
while (i3 < valueLength) {
|
|
11832
|
-
ch = inputValue.charAt(i3);
|
|
11833
|
-
if (isNumeralChar(ch)) {
|
|
11834
|
-
index = i3 + prefixLength;
|
|
11835
|
-
break;
|
|
11836
|
-
}
|
|
11837
|
-
i3++;
|
|
11838
|
-
}
|
|
11839
|
-
if (index != null) {
|
|
11840
|
-
inputEl.setSelectionRange(index, index);
|
|
11841
|
-
}
|
|
11842
|
-
}
|
|
11843
|
-
return index != null ? index : 0;
|
|
11844
|
-
};
|
|
11845
|
-
const onInputPointerDown = () => {
|
|
11846
|
-
isFocusedByClick.current = true;
|
|
11847
|
-
};
|
|
11848
|
-
const onInputClick = () => {
|
|
11849
|
-
initCursor();
|
|
11850
|
-
};
|
|
11851
|
-
const onInput = (event) => {
|
|
11852
|
-
if (props.disabled || props.readOnly) return;
|
|
11853
|
-
if (utilsIsSpecialChar.current) {
|
|
11854
|
-
event.currentTarget.value = lastValue.current;
|
|
11855
|
-
utilsIsSpecialChar.current = false;
|
|
11856
|
-
}
|
|
11857
|
-
};
|
|
11858
|
-
const utilsIsSpecialChar = React74.useRef(false);
|
|
11859
|
-
const onInputAndroidKey = (event) => {
|
|
11463
|
+
syncFromPropsValue((_a2 = props.value) != null ? _a2 : null);
|
|
11464
|
+
}, []);
|
|
11465
|
+
React74.useEffect(() => {
|
|
11860
11466
|
var _a2;
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
const code = event.which || event.keyCode;
|
|
11866
|
-
if (code !== 13) {
|
|
11867
|
-
event.preventDefault();
|
|
11868
|
-
}
|
|
11869
|
-
const ch = String.fromCharCode(code);
|
|
11870
|
-
const decimal = isDecimalSign(ch);
|
|
11871
|
-
const minus = isMinusSign(ch);
|
|
11872
|
-
if (code >= 48 && code <= 57 || minus || decimal) {
|
|
11873
|
-
insert(event, ch, { isDecimalSign: decimal, isMinusSign: minus });
|
|
11874
|
-
} else {
|
|
11875
|
-
const inputVal = event.target.value;
|
|
11876
|
-
updateValue(event, inputVal, null, "delete-single");
|
|
11877
|
-
}
|
|
11878
|
-
};
|
|
11879
|
-
const onInputKeyDown = (event) => {
|
|
11880
|
-
var _a2, _b2, _c;
|
|
11881
|
-
if (props.disabled || props.readOnly) return;
|
|
11882
|
-
if (event.altKey || event.ctrlKey || event.metaKey) {
|
|
11883
|
-
if (event.key.toLowerCase() === "x" && (event.ctrlKey || event.metaKey)) {
|
|
11884
|
-
utilsIsSpecialChar.current = false;
|
|
11885
|
-
} else {
|
|
11886
|
-
utilsIsSpecialChar.current = true;
|
|
11887
|
-
}
|
|
11888
|
-
return;
|
|
11889
|
-
}
|
|
11890
|
-
(_a2 = props.onKeyDown) == null ? void 0 : _a2.call(props, event);
|
|
11891
|
-
if (event.defaultPrevented) return;
|
|
11892
|
-
const inputEl = event.currentTarget;
|
|
11893
|
-
lastValue.current = inputEl.value;
|
|
11894
|
-
const isAndroid2 = /Android/i.test(navigator.userAgent);
|
|
11895
|
-
if (isAndroid2) return;
|
|
11896
|
-
let selectionStart = (_b2 = inputEl.selectionStart) != null ? _b2 : 0;
|
|
11897
|
-
let selectionEnd = (_c = inputEl.selectionEnd) != null ? _c : 0;
|
|
11898
|
-
const inputValue = inputEl.value;
|
|
11899
|
-
let newValueStr = null;
|
|
11900
|
-
switch (event.code) {
|
|
11901
|
-
case "ArrowUp":
|
|
11902
|
-
spin(event, 1);
|
|
11903
|
-
event.preventDefault();
|
|
11904
|
-
break;
|
|
11905
|
-
case "ArrowDown":
|
|
11906
|
-
spin(event, -1);
|
|
11907
|
-
event.preventDefault();
|
|
11908
|
-
break;
|
|
11909
|
-
case "ArrowLeft": {
|
|
11910
|
-
const charPrev = inputValue.charAt(selectionStart - 1);
|
|
11911
|
-
if (!isNumeralChar(charPrev)) {
|
|
11912
|
-
event.preventDefault();
|
|
11913
|
-
}
|
|
11914
|
-
break;
|
|
11915
|
-
}
|
|
11916
|
-
case "ArrowRight": {
|
|
11917
|
-
const charNext = inputValue.charAt(selectionStart);
|
|
11918
|
-
if (!isNumeralChar(charNext)) {
|
|
11919
|
-
event.preventDefault();
|
|
11920
|
-
}
|
|
11921
|
-
break;
|
|
11922
|
-
}
|
|
11923
|
-
case "Tab":
|
|
11924
|
-
case "Enter":
|
|
11925
|
-
case "NumpadEnter": {
|
|
11926
|
-
const parsedVal = validateValue(parseValue(inputValue));
|
|
11927
|
-
inputRef.current.value = formatValue(parsedVal);
|
|
11928
|
-
inputRef.current.setAttribute("aria-valuenow", parsedVal == null ? "" : String(parsedVal));
|
|
11929
|
-
updateModel(event, parsedVal);
|
|
11930
|
-
break;
|
|
11931
|
-
}
|
|
11932
|
-
case "Backspace": {
|
|
11933
|
-
event.preventDefault();
|
|
11934
|
-
if (selectionStart === selectionEnd) {
|
|
11935
|
-
const deleteChar = inputValue.charAt(selectionStart - 1);
|
|
11936
|
-
if (isNumeralChar(deleteChar)) {
|
|
11937
|
-
const {
|
|
11938
|
-
decimalCharIndex,
|
|
11939
|
-
decimalCharIndexWithoutPrefix
|
|
11940
|
-
} = getDecimalCharIndexes(inputValue);
|
|
11941
|
-
const decimalLength = getDecimalLength(inputValue);
|
|
11942
|
-
if (_group.current.test(deleteChar)) {
|
|
11943
|
-
_group.current.lastIndex = 0;
|
|
11944
|
-
newValueStr = inputValue.slice(0, selectionStart - 2) + inputValue.slice(selectionStart - 1);
|
|
11945
|
-
} else if (_decimal.current.test(deleteChar)) {
|
|
11946
|
-
_decimal.current.lastIndex = 0;
|
|
11947
|
-
if (decimalLength) {
|
|
11948
|
-
inputRef.current.setSelectionRange(selectionStart - 1, selectionStart - 1);
|
|
11949
|
-
} else {
|
|
11950
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + inputValue.slice(selectionStart);
|
|
11951
|
-
}
|
|
11952
|
-
} else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
|
|
11953
|
-
const insertedText = isDecimalMode() && (props.minFractionDigits || 0) < decimalLength ? "" : "0";
|
|
11954
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + insertedText + inputValue.slice(selectionStart);
|
|
11955
|
-
} else if (decimalCharIndexWithoutPrefix === 1) {
|
|
11956
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + "0" + inputValue.slice(selectionStart);
|
|
11957
|
-
newValueStr = parseValue(newValueStr) > 0 ? newValueStr : "";
|
|
11958
|
-
} else {
|
|
11959
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + inputValue.slice(selectionStart);
|
|
11960
|
-
}
|
|
11961
|
-
} else if (_currency.current.test(deleteChar)) {
|
|
11962
|
-
const {
|
|
11963
|
-
minusCharIndex,
|
|
11964
|
-
currencyCharIndex
|
|
11965
|
-
} = getCharIndexes(inputValue);
|
|
11966
|
-
if (minusCharIndex === currencyCharIndex - 1) {
|
|
11967
|
-
newValueStr = inputValue.slice(0, minusCharIndex) + inputValue.slice(selectionStart);
|
|
11968
|
-
}
|
|
11969
|
-
}
|
|
11970
|
-
updateValue(event, newValueStr, null, "delete-single");
|
|
11971
|
-
} else {
|
|
11972
|
-
newValueStr = deleteRange(inputValue, selectionStart, selectionEnd);
|
|
11973
|
-
updateValue(event, newValueStr, null, "delete-range");
|
|
11974
|
-
}
|
|
11975
|
-
break;
|
|
11976
|
-
}
|
|
11977
|
-
case "Delete": {
|
|
11978
|
-
event.preventDefault();
|
|
11979
|
-
if (selectionStart === selectionEnd) {
|
|
11980
|
-
const deleteChar = inputValue.charAt(selectionStart);
|
|
11981
|
-
const {
|
|
11982
|
-
decimalCharIndex,
|
|
11983
|
-
decimalCharIndexWithoutPrefix
|
|
11984
|
-
} = getDecimalCharIndexes(inputValue);
|
|
11985
|
-
if (isNumeralChar(deleteChar)) {
|
|
11986
|
-
const decimalLength = getDecimalLength(inputValue);
|
|
11987
|
-
if (_group.current.test(deleteChar)) {
|
|
11988
|
-
_group.current.lastIndex = 0;
|
|
11989
|
-
newValueStr = inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 2);
|
|
11990
|
-
} else if (_decimal.current.test(deleteChar)) {
|
|
11991
|
-
_decimal.current.lastIndex = 0;
|
|
11992
|
-
if (decimalLength) {
|
|
11993
|
-
inputRef.current.setSelectionRange(selectionStart + 1, selectionStart + 1);
|
|
11994
|
-
} else {
|
|
11995
|
-
newValueStr = inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 1);
|
|
11996
|
-
}
|
|
11997
|
-
} else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
|
|
11998
|
-
const insertedText = isDecimalMode() && (props.minFractionDigits || 0) < decimalLength ? "" : "0";
|
|
11999
|
-
newValueStr = inputValue.slice(0, selectionStart) + insertedText + inputValue.slice(selectionStart + 1);
|
|
12000
|
-
} else if (decimalCharIndexWithoutPrefix === 1) {
|
|
12001
|
-
newValueStr = inputValue.slice(0, selectionStart) + "0" + inputValue.slice(selectionStart + 1);
|
|
12002
|
-
newValueStr = parseValue(newValueStr) > 0 ? newValueStr : "";
|
|
12003
|
-
} else {
|
|
12004
|
-
newValueStr = inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 1);
|
|
12005
|
-
}
|
|
12006
|
-
}
|
|
12007
|
-
updateValue(event, newValueStr, null, "delete-back-single");
|
|
12008
|
-
} else {
|
|
12009
|
-
newValueStr = deleteRange(inputValue, selectionStart, selectionEnd);
|
|
12010
|
-
updateValue(event, newValueStr, null, "delete-range");
|
|
12011
|
-
}
|
|
12012
|
-
break;
|
|
12013
|
-
}
|
|
12014
|
-
case "End":
|
|
12015
|
-
event.preventDefault();
|
|
12016
|
-
if (props.max != null) {
|
|
12017
|
-
updateModel(event, props.max);
|
|
12018
|
-
updateInputValue(props.max);
|
|
12019
|
-
}
|
|
12020
|
-
break;
|
|
12021
|
-
case "Home":
|
|
12022
|
-
event.preventDefault();
|
|
12023
|
-
if (props.min != null) {
|
|
12024
|
-
updateModel(event, props.min);
|
|
12025
|
-
updateInputValue(props.min);
|
|
12026
|
-
}
|
|
12027
|
-
break;
|
|
12028
|
-
default: {
|
|
12029
|
-
event.preventDefault();
|
|
12030
|
-
let ch = event.key;
|
|
12031
|
-
if (!ch) break;
|
|
12032
|
-
if (ch === ".") {
|
|
12033
|
-
ch = _decimalSeparator.current;
|
|
12034
|
-
}
|
|
12035
|
-
const decimal = isDecimalSign(ch);
|
|
12036
|
-
const minus = isMinusSign(ch);
|
|
12037
|
-
if (ch >= "0" && ch <= "9" || minus || decimal) {
|
|
12038
|
-
insert(event, ch, { isDecimalSign: decimal, isMinusSign: minus });
|
|
12039
|
-
}
|
|
12040
|
-
break;
|
|
12041
|
-
}
|
|
12042
|
-
}
|
|
12043
|
-
};
|
|
12044
|
-
const onPaste = (event) => {
|
|
12045
|
-
event.preventDefault();
|
|
12046
|
-
if (props.disabled || props.readOnly) return;
|
|
12047
|
-
const data = (event.clipboardData || window.clipboardData).getData("Text");
|
|
12048
|
-
if (!data) return;
|
|
12049
|
-
const filteredData = parseValue(data);
|
|
12050
|
-
if (filteredData != null) {
|
|
12051
|
-
if (typeof filteredData === "number" && isFloat(filteredData)) {
|
|
12052
|
-
const formatted = formatValue(filteredData);
|
|
12053
|
-
if (inputRef.current) {
|
|
12054
|
-
inputRef.current.value = formatted;
|
|
12055
|
-
}
|
|
12056
|
-
updateModel(event, filteredData);
|
|
12057
|
-
} else {
|
|
12058
|
-
insert(event, String(filteredData));
|
|
12059
|
-
}
|
|
12060
|
-
}
|
|
12061
|
-
};
|
|
12062
|
-
const onInputFocus = (event) => {
|
|
11467
|
+
if (focused) return;
|
|
11468
|
+
syncFromPropsValue((_a2 = props.value) != null ? _a2 : null);
|
|
11469
|
+
}, [props.value, focused, syncFromPropsValue]);
|
|
11470
|
+
const onFocus = (e4) => {
|
|
12063
11471
|
var _a2;
|
|
12064
|
-
|
|
12065
|
-
(_a2 = props.onFocus) == null ? void 0 : _a2.call(props,
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
11472
|
+
setFocused(true);
|
|
11473
|
+
(_a2 = props.onFocus) == null ? void 0 : _a2.call(props, e4);
|
|
11474
|
+
const model = isFiniteNumber(props.value) ? clampModel(props.value) : getModelFromDisplay(display);
|
|
11475
|
+
const editable = model == null ? stripAffixes(display, props.prefix, props.suffix) : toEditableFromNumber(model);
|
|
11476
|
+
const normalized = normalizeEditable(
|
|
11477
|
+
editable,
|
|
11478
|
+
locale,
|
|
11479
|
+
decimalSep,
|
|
11480
|
+
allowMinus
|
|
11481
|
+
);
|
|
11482
|
+
setDisplay(normalized);
|
|
11483
|
+
queueMicrotask(() => {
|
|
11484
|
+
var _a3, _b;
|
|
11485
|
+
setCaret(((_b = (_a3 = inputRef.current) == null ? void 0 : _a3.value) != null ? _b : "").length);
|
|
11486
|
+
});
|
|
12073
11487
|
};
|
|
12074
|
-
const
|
|
12075
|
-
var _a2,
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
|
|
11488
|
+
const onBlur = (e4) => {
|
|
11489
|
+
var _a2, _b;
|
|
11490
|
+
setFocused(false);
|
|
11491
|
+
const el = e4.currentTarget;
|
|
11492
|
+
const raw = stripAffixes(el.value, props.prefix, props.suffix);
|
|
11493
|
+
const normalized = normalizeEditable(
|
|
11494
|
+
raw,
|
|
11495
|
+
locale,
|
|
11496
|
+
decimalSep,
|
|
11497
|
+
allowMinus
|
|
11498
|
+
);
|
|
11499
|
+
const parsed = parseEditable(normalized, locale, decimalSep);
|
|
11500
|
+
let model = parsed == null ? null : clampModel(parsed);
|
|
11501
|
+
if (model == null && props.allowEmpty === false) {
|
|
11502
|
+
const fallback = (_a2 = props.min) != null ? _a2 : 0;
|
|
11503
|
+
model = clampModel(fallback);
|
|
11504
|
+
}
|
|
11505
|
+
setDisplay(formatFromModel(model));
|
|
11506
|
+
emit(e4, model);
|
|
11507
|
+
(_b = props.onBlur) == null ? void 0 : _b.call(props, e4);
|
|
12087
11508
|
};
|
|
12088
|
-
const
|
|
12089
|
-
|
|
12090
|
-
|
|
12091
|
-
const
|
|
12092
|
-
|
|
12093
|
-
|
|
11509
|
+
const onChangeText = (e4) => {
|
|
11510
|
+
var _a2, _b;
|
|
11511
|
+
if (props.disabled || props.readOnly) return;
|
|
11512
|
+
const el = e4.currentTarget;
|
|
11513
|
+
const caretBefore = (_a2 = el.selectionStart) != null ? _a2 : el.value.length;
|
|
11514
|
+
const stripped = stripAffixes(el.value, props.prefix, props.suffix);
|
|
11515
|
+
let next = normalizeEditable(
|
|
11516
|
+
stripped,
|
|
11517
|
+
locale,
|
|
11518
|
+
decimalSep,
|
|
11519
|
+
allowMinus
|
|
11520
|
+
);
|
|
11521
|
+
const fracLimit = props.maxFractionDigits;
|
|
11522
|
+
if (fracLimit != null) {
|
|
11523
|
+
const applied = applyFractionLimitReplace(
|
|
11524
|
+
next,
|
|
11525
|
+
display,
|
|
11526
|
+
locale,
|
|
11527
|
+
decimalSep,
|
|
11528
|
+
fracLimit,
|
|
11529
|
+
el
|
|
11530
|
+
);
|
|
11531
|
+
next = applied.text;
|
|
11532
|
+
setDisplay(next);
|
|
11533
|
+
setCaret(applied.caret);
|
|
11534
|
+
} else {
|
|
11535
|
+
setDisplay(next);
|
|
11536
|
+
setCaret(caretBefore);
|
|
12094
11537
|
}
|
|
11538
|
+
const parsed = parseEditable(next, locale, decimalSep);
|
|
11539
|
+
const model = parsed == null ? null : clampModel(parsed);
|
|
11540
|
+
const finalModel = model == null && props.allowEmpty === false ? clampModel((_b = props.min) != null ? _b : 0) : model;
|
|
11541
|
+
emit(e4, finalModel);
|
|
12095
11542
|
};
|
|
12096
|
-
|
|
12097
|
-
React74.useEffect(() => {
|
|
12098
|
-
if (props.inputRef) {
|
|
12099
|
-
if (typeof props.inputRef === "function") {
|
|
12100
|
-
props.inputRef(inputRef.current);
|
|
12101
|
-
} else {
|
|
12102
|
-
props.inputRef.current = inputRef.current;
|
|
12103
|
-
}
|
|
12104
|
-
}
|
|
12105
|
-
}, [props.inputRef]);
|
|
12106
|
-
React74.useEffect(
|
|
12107
|
-
() => () => {
|
|
12108
|
-
clearTimer();
|
|
12109
|
-
},
|
|
12110
|
-
[]
|
|
12111
|
-
);
|
|
12112
|
-
React74.useEffect(() => {
|
|
12113
|
-
constructParser();
|
|
12114
|
-
const newValue = validateValue(props.value);
|
|
12115
|
-
if (props.value != null && props.value !== newValue) {
|
|
12116
|
-
updateModel(null, newValue);
|
|
12117
|
-
}
|
|
12118
|
-
}, []);
|
|
12119
|
-
React74.useEffect(() => {
|
|
12120
|
-
constructParser();
|
|
12121
|
-
changeValue();
|
|
12122
|
-
}, [
|
|
12123
|
-
_locale,
|
|
12124
|
-
props.locale,
|
|
12125
|
-
props.localeMatcher,
|
|
12126
|
-
props.mode,
|
|
12127
|
-
props.currency,
|
|
12128
|
-
props.currencyDisplay,
|
|
12129
|
-
props.useGrouping,
|
|
12130
|
-
props.minFractionDigits,
|
|
12131
|
-
props.maxFractionDigits,
|
|
12132
|
-
props.suffix,
|
|
12133
|
-
props.prefix
|
|
12134
|
-
]);
|
|
12135
|
-
React74.useEffect(() => {
|
|
12136
|
-
changeValue();
|
|
12137
|
-
}, [props.value]);
|
|
12138
|
-
React74.useEffect(() => {
|
|
12139
|
-
if (props.disabled) clearTimer();
|
|
12140
|
-
}, [props.disabled]);
|
|
11543
|
+
const inputMode = props.inputMode || (props.mode === "decimal" && props.maxFractionDigits == null && props.minFractionDigits == null ? "numeric" : "decimal");
|
|
12141
11544
|
const inputClassName = [
|
|
12142
11545
|
props.inputClassName,
|
|
12143
11546
|
props.invalid ? "p-invalid" : void 0
|
|
12144
11547
|
].filter(Boolean).join(" ");
|
|
12145
|
-
const valueToRender = formattedValue((_a = props.value) != null ? _a : null);
|
|
12146
11548
|
const {
|
|
12147
11549
|
inputId,
|
|
12148
11550
|
inputStyle,
|
|
@@ -12153,34 +11555,32 @@ var InputNumber = React74.memo(
|
|
|
12153
11555
|
value,
|
|
12154
11556
|
icon,
|
|
12155
11557
|
iconGap,
|
|
12156
|
-
// anything you *don’t* want to pass down can be pulled out here too
|
|
12157
|
-
// e.g. internal-only props
|
|
12158
11558
|
...passThroughProps
|
|
12159
|
-
// everything else goes straight to ShadcnTextVariant
|
|
12160
11559
|
} = props;
|
|
12161
11560
|
return (
|
|
12162
11561
|
//@ts-ignore
|
|
12163
11562
|
/* @__PURE__ */ jsx(
|
|
12164
11563
|
Input,
|
|
12165
11564
|
{
|
|
12166
|
-
|
|
12167
|
-
|
|
11565
|
+
ref: (node) => {
|
|
11566
|
+
inputRef.current = node;
|
|
11567
|
+
if (typeof props.inputRef === "function")
|
|
11568
|
+
props.inputRef(node);
|
|
11569
|
+
else if (props.inputRef && typeof props.inputRef === "object") {
|
|
11570
|
+
props.inputRef.current = node;
|
|
11571
|
+
}
|
|
11572
|
+
},
|
|
12168
11573
|
...passThroughProps,
|
|
12169
11574
|
id: inputId != null ? inputId : props.id,
|
|
12170
11575
|
style: inputStyle != null ? inputStyle : props.style,
|
|
12171
11576
|
role: "spinbutton",
|
|
12172
11577
|
className: inputClassName || props.className,
|
|
12173
|
-
|
|
12174
|
-
type: (_b = props.type) != null ? _b : "text",
|
|
11578
|
+
type: (_a = props.type) != null ? _a : "text",
|
|
12175
11579
|
inputMode,
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
onPointerDown: onInputPointerDown,
|
|
12181
|
-
onBlur: onInputBlur,
|
|
12182
|
-
onFocus: onInputFocus,
|
|
12183
|
-
onPaste,
|
|
11580
|
+
value: display,
|
|
11581
|
+
onFocus,
|
|
11582
|
+
onBlur,
|
|
11583
|
+
onChange: onChangeText,
|
|
12184
11584
|
leadingControl,
|
|
12185
11585
|
trailingControl,
|
|
12186
11586
|
leadingControlClassName,
|
|
@@ -20581,17 +19981,21 @@ function normalizeItems(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
20581
19981
|
label: mappers.getLabel(item, index),
|
|
20582
19982
|
description: mappers.getDescription ? mappers.getDescription(item, index) : void 0,
|
|
20583
19983
|
disabled: mappers.isDisabled ? mappers.isDisabled(item, index) : false,
|
|
20584
|
-
key: mappers.getKey ? mappers.getKey(item, index) : index
|
|
19984
|
+
key: mappers.getKey ? mappers.getKey(item, index) : index,
|
|
19985
|
+
raw: item
|
|
20585
19986
|
}));
|
|
20586
19987
|
}
|
|
20587
19988
|
if (optionValueKey || optionLabelKey) {
|
|
20588
19989
|
return items.map((item, index) => {
|
|
20589
|
-
return
|
|
20590
|
-
|
|
20591
|
-
|
|
20592
|
-
|
|
20593
|
-
|
|
20594
|
-
|
|
19990
|
+
return {
|
|
19991
|
+
...globalNormalizeCheckBasedOptions(
|
|
19992
|
+
item,
|
|
19993
|
+
index,
|
|
19994
|
+
optionLabelKey,
|
|
19995
|
+
optionValueKey
|
|
19996
|
+
),
|
|
19997
|
+
raw: item
|
|
19998
|
+
};
|
|
20595
19999
|
});
|
|
20596
20000
|
}
|
|
20597
20001
|
return items.map((item, index) => {
|
|
@@ -20602,7 +20006,8 @@ function normalizeItems(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
20602
20006
|
label: String(item),
|
|
20603
20007
|
description: void 0,
|
|
20604
20008
|
disabled: false,
|
|
20605
|
-
key: index
|
|
20009
|
+
key: index,
|
|
20010
|
+
raw: item
|
|
20606
20011
|
};
|
|
20607
20012
|
}
|
|
20608
20013
|
return item;
|
|
@@ -20665,11 +20070,12 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
20665
20070
|
return found ? String(found.value) : void 0;
|
|
20666
20071
|
}, [normalized, value]);
|
|
20667
20072
|
const handleSelect = React74.useCallback(
|
|
20668
|
-
(next) => {
|
|
20073
|
+
(next, selectedRaw) => {
|
|
20669
20074
|
if (!onValue || disabled) return;
|
|
20670
20075
|
const detail = {
|
|
20671
20076
|
source: "variant",
|
|
20672
|
-
raw: next,
|
|
20077
|
+
raw: selectedRaw != null ? selectedRaw : next,
|
|
20078
|
+
selectedOptions: [selectedRaw != null ? selectedRaw : next],
|
|
20673
20079
|
nativeEvent: void 0,
|
|
20674
20080
|
meta: void 0
|
|
20675
20081
|
};
|
|
@@ -20679,9 +20085,10 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
20679
20085
|
);
|
|
20680
20086
|
const handleRadioChange = React74.useCallback(
|
|
20681
20087
|
(raw) => {
|
|
20088
|
+
var _a;
|
|
20682
20089
|
const found = normalized.find((item) => String(item.value) === raw);
|
|
20683
20090
|
if (!found) return;
|
|
20684
|
-
handleSelect(found.value);
|
|
20091
|
+
handleSelect(found.value, (_a = found.raw) != null ? _a : found.value);
|
|
20685
20092
|
},
|
|
20686
20093
|
[normalized, handleSelect]
|
|
20687
20094
|
);
|
|
@@ -20927,7 +20334,8 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
20927
20334
|
description: mappers.getDescription ? mappers.getDescription(item, index) : void 0,
|
|
20928
20335
|
disabled: mappers.isDisabled ? mappers.isDisabled(item, index) : false,
|
|
20929
20336
|
key: mappers.getKey ? mappers.getKey(item, index) : index,
|
|
20930
|
-
tristate: mappers.getTristate ? mappers.getTristate(item, index) : void 0
|
|
20337
|
+
tristate: mappers.getTristate ? mappers.getTristate(item, index) : void 0,
|
|
20338
|
+
raw: item
|
|
20931
20339
|
}));
|
|
20932
20340
|
}
|
|
20933
20341
|
if (optionValueKey || optionLabelKey) {
|
|
@@ -20942,7 +20350,8 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
20942
20350
|
const tristate = anyItem.tristate;
|
|
20943
20351
|
return {
|
|
20944
20352
|
...normalised,
|
|
20945
|
-
tristate
|
|
20353
|
+
tristate,
|
|
20354
|
+
raw: item
|
|
20946
20355
|
};
|
|
20947
20356
|
});
|
|
20948
20357
|
}
|
|
@@ -20955,7 +20364,8 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
20955
20364
|
description: void 0,
|
|
20956
20365
|
disabled: false,
|
|
20957
20366
|
key: index,
|
|
20958
|
-
tristate: void 0
|
|
20367
|
+
tristate: void 0,
|
|
20368
|
+
raw: item
|
|
20959
20369
|
};
|
|
20960
20370
|
}
|
|
20961
20371
|
return item;
|
|
@@ -20966,7 +20376,17 @@ function isEqualValue2(a3, b2) {
|
|
|
20966
20376
|
}
|
|
20967
20377
|
function asGroupValue(value) {
|
|
20968
20378
|
if (!value) return void 0;
|
|
20969
|
-
if (Array.isArray(value))
|
|
20379
|
+
if (Array.isArray(value)) {
|
|
20380
|
+
if (value.length === 0) return void 0;
|
|
20381
|
+
const first = value[0];
|
|
20382
|
+
if (first && typeof first === "object" && "value" in first && "state" in first) {
|
|
20383
|
+
return value;
|
|
20384
|
+
}
|
|
20385
|
+
return value.map((item) => ({
|
|
20386
|
+
value: item,
|
|
20387
|
+
state: true
|
|
20388
|
+
}));
|
|
20389
|
+
}
|
|
20970
20390
|
if (typeof value == "object")
|
|
20971
20391
|
return Object.keys(value).map(
|
|
20972
20392
|
(key) => ({
|
|
@@ -21022,11 +20442,21 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21022
20442
|
} = props;
|
|
21023
20443
|
const hasError = !!error;
|
|
21024
20444
|
const isSingle = !!single;
|
|
20445
|
+
const normalized = React74.useMemo(
|
|
20446
|
+
() => normalizeItems2(
|
|
20447
|
+
items != null ? items : options,
|
|
20448
|
+
mappers,
|
|
20449
|
+
optionValue,
|
|
20450
|
+
optionLabel
|
|
20451
|
+
),
|
|
20452
|
+
[items, options, mappers, optionValue, optionLabel]
|
|
20453
|
+
);
|
|
21025
20454
|
if (isSingle) {
|
|
21026
20455
|
const singleVal = asSingleValue(value);
|
|
21027
20456
|
const effectiveTristate = !!tristateDefault;
|
|
21028
20457
|
const internalState = effectiveTristate ? singleVal != null ? singleVal : "none" : !!singleVal;
|
|
21029
20458
|
const handleSingleChange = (next) => {
|
|
20459
|
+
var _a;
|
|
21030
20460
|
if (!onValue || disabled) return;
|
|
21031
20461
|
let nextPublic;
|
|
21032
20462
|
if (effectiveTristate) {
|
|
@@ -21037,6 +20467,7 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21037
20467
|
const detail = {
|
|
21038
20468
|
source: "variant",
|
|
21039
20469
|
raw: nextPublic,
|
|
20470
|
+
selectedOptions: nextPublic === true ? normalized[0] ? [(_a = normalized[0].raw) != null ? _a : normalized[0].value] : [] : [],
|
|
21040
20471
|
nativeEvent: void 0,
|
|
21041
20472
|
meta: void 0
|
|
21042
20473
|
};
|
|
@@ -21095,15 +20526,6 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21095
20526
|
);
|
|
21096
20527
|
}
|
|
21097
20528
|
const groupValue = asGroupValue(value);
|
|
21098
|
-
const normalized = React74.useMemo(
|
|
21099
|
-
() => normalizeItems2(
|
|
21100
|
-
items != null ? items : options,
|
|
21101
|
-
mappers,
|
|
21102
|
-
optionValue,
|
|
21103
|
-
optionLabel
|
|
21104
|
-
),
|
|
21105
|
-
[items, options, mappers, optionValue, optionLabel]
|
|
21106
|
-
);
|
|
21107
20529
|
const {
|
|
21108
20530
|
groupStyle,
|
|
21109
20531
|
groupClasses,
|
|
@@ -21123,6 +20545,13 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21123
20545
|
labelTextSizeClass: labelTextSize2(size),
|
|
21124
20546
|
descriptionTextSizeClass: descriptionTextSize2(size)
|
|
21125
20547
|
});
|
|
20548
|
+
const hasAnyTristate = React74.useMemo(
|
|
20549
|
+
() => normalized.some((item) => {
|
|
20550
|
+
var _a, _b;
|
|
20551
|
+
return (_b = (_a = item.tristate) != null ? _a : tristateDefault) != null ? _b : false;
|
|
20552
|
+
}),
|
|
20553
|
+
[normalized, tristateDefault]
|
|
20554
|
+
);
|
|
21126
20555
|
const findEntryIndex = React74.useCallback(
|
|
21127
20556
|
(val) => {
|
|
21128
20557
|
if (!groupValue) return -1;
|
|
@@ -21195,14 +20624,28 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21195
20624
|
const detail = {
|
|
21196
20625
|
source: "variant",
|
|
21197
20626
|
raw: nextList,
|
|
20627
|
+
selectedOptions: nextList.map(
|
|
20628
|
+
(entry) => {
|
|
20629
|
+
var _a, _b;
|
|
20630
|
+
return (_b = (_a = normalized.find(
|
|
20631
|
+
(item) => isEqualValue2(item.value, entry.value)
|
|
20632
|
+
)) == null ? void 0 : _a.raw) != null ? _b : entry.value;
|
|
20633
|
+
}
|
|
20634
|
+
),
|
|
21198
20635
|
nativeEvent: void 0,
|
|
21199
20636
|
meta: void 0
|
|
21200
20637
|
};
|
|
21201
|
-
|
|
21202
|
-
|
|
21203
|
-
|
|
20638
|
+
if (hasAnyTristate) {
|
|
20639
|
+
const value2 = {};
|
|
20640
|
+
nextList.forEach(
|
|
20641
|
+
(item) => value2[item.value] = item.state
|
|
20642
|
+
);
|
|
20643
|
+
onValue(value2, detail);
|
|
20644
|
+
return;
|
|
20645
|
+
}
|
|
20646
|
+
onValue(nextList.map((item) => item.value), detail);
|
|
21204
20647
|
},
|
|
21205
|
-
[onValue, disabled, groupValue]
|
|
20648
|
+
[onValue, disabled, groupValue, normalized, hasAnyTristate]
|
|
21206
20649
|
);
|
|
21207
20650
|
return /* @__PURE__ */ jsx(
|
|
21208
20651
|
"div",
|
|
@@ -21478,13 +20921,14 @@ var ShadcnSelectVariant = React74.forwardRef(function ShadcnSelectVariant2(props
|
|
|
21478
20921
|
);
|
|
21479
20922
|
const handleChange = React74.useCallback(
|
|
21480
20923
|
(rawKey) => {
|
|
21481
|
-
var _a2, _b2, _c;
|
|
20924
|
+
var _a2, _b2, _c, _d;
|
|
21482
20925
|
if (!onValue || rawKey === "") return;
|
|
21483
20926
|
const primitive = (_a2 = valueMap.get(rawKey)) != null ? _a2 : rawKey;
|
|
21484
20927
|
const item = (_b2 = items.find((it) => String(it.value) === String(primitive))) != null ? _b2 : null;
|
|
21485
20928
|
const detail = {
|
|
21486
20929
|
source: "variant",
|
|
21487
20930
|
raw: (_c = item == null ? void 0 : item.raw) != null ? _c : primitive,
|
|
20931
|
+
selectedOptions: [(_d = item == null ? void 0 : item.raw) != null ? _d : primitive],
|
|
21488
20932
|
nativeEvent: void 0,
|
|
21489
20933
|
meta: void 0
|
|
21490
20934
|
};
|
|
@@ -21586,6 +21030,7 @@ var ShadcnSelectVariant = React74.forwardRef(function ShadcnSelectVariant2(props
|
|
|
21586
21030
|
const detail = {
|
|
21587
21031
|
source: "variant",
|
|
21588
21032
|
raw: void 0,
|
|
21033
|
+
selectedOptions: [],
|
|
21589
21034
|
nativeEvent: void 0,
|
|
21590
21035
|
meta: { action: "clear" }
|
|
21591
21036
|
};
|
|
@@ -22220,7 +21665,12 @@ var ShadcnMultiSelectVariant = React74.forwardRef(function ShadcnMultiSelectVari
|
|
|
22220
21665
|
next = [...current, primitive];
|
|
22221
21666
|
}
|
|
22222
21667
|
const final = next.length ? next : void 0;
|
|
22223
|
-
const values = next == null ? void 0 : next.map(
|
|
21668
|
+
const values = next == null ? void 0 : next.map(
|
|
21669
|
+
(item) => {
|
|
21670
|
+
var _a2, _b;
|
|
21671
|
+
return (_b = (_a2 = keyedItems[item]) == null ? void 0 : _a2.raw) != null ? _b : item;
|
|
21672
|
+
}
|
|
21673
|
+
);
|
|
22224
21674
|
const detail = {
|
|
22225
21675
|
source: "variant",
|
|
22226
21676
|
raw: {
|
|
@@ -22229,12 +21679,13 @@ var ShadcnMultiSelectVariant = React74.forwardRef(function ShadcnMultiSelectVari
|
|
|
22229
21679
|
next: final,
|
|
22230
21680
|
values
|
|
22231
21681
|
},
|
|
21682
|
+
selectedOptions: values != null ? values : [],
|
|
22232
21683
|
nativeEvent: void 0,
|
|
22233
21684
|
meta: void 0
|
|
22234
21685
|
};
|
|
22235
21686
|
onValue(final, detail);
|
|
22236
21687
|
},
|
|
22237
|
-
[onValue, value, disabled, readOnly]
|
|
21688
|
+
[onValue, value, disabled, readOnly, keyedItems]
|
|
22238
21689
|
);
|
|
22239
21690
|
const handleSelectAll = React74.useCallback(() => {
|
|
22240
21691
|
if (!onValue || disabled || readOnly) return;
|
|
@@ -22250,7 +21701,10 @@ var ShadcnMultiSelectVariant = React74.forwardRef(function ShadcnMultiSelectVari
|
|
|
22250
21701
|
next = Array.from(merged);
|
|
22251
21702
|
}
|
|
22252
21703
|
const final = next.length ? next : void 0;
|
|
22253
|
-
const values = next.map((item) =>
|
|
21704
|
+
const values = next.map((item) => {
|
|
21705
|
+
var _a2, _b;
|
|
21706
|
+
return (_b = (_a2 = keyedItems[item]) == null ? void 0 : _a2.raw) != null ? _b : item;
|
|
21707
|
+
});
|
|
22254
21708
|
const detail = {
|
|
22255
21709
|
source: "variant",
|
|
22256
21710
|
raw: {
|
|
@@ -22258,6 +21712,7 @@ var ShadcnMultiSelectVariant = React74.forwardRef(function ShadcnMultiSelectVari
|
|
|
22258
21712
|
next: final,
|
|
22259
21713
|
values
|
|
22260
21714
|
},
|
|
21715
|
+
selectedOptions: values,
|
|
22261
21716
|
nativeEvent: void 0,
|
|
22262
21717
|
meta: {
|
|
22263
21718
|
allSelected: !currentlyAllSelected
|
|
@@ -22270,7 +21725,8 @@ var ShadcnMultiSelectVariant = React74.forwardRef(function ShadcnMultiSelectVari
|
|
|
22270
21725
|
disabled,
|
|
22271
21726
|
readOnly,
|
|
22272
21727
|
allSelectableValues,
|
|
22273
|
-
selectedValues
|
|
21728
|
+
selectedValues,
|
|
21729
|
+
keyedItems
|
|
22274
21730
|
]);
|
|
22275
21731
|
const handleClearAll = React74.useCallback(() => {
|
|
22276
21732
|
if (!onValue || disabled || readOnly) return;
|
|
@@ -22279,6 +21735,7 @@ var ShadcnMultiSelectVariant = React74.forwardRef(function ShadcnMultiSelectVari
|
|
|
22279
21735
|
raw: {
|
|
22280
21736
|
type: "clear"
|
|
22281
21737
|
},
|
|
21738
|
+
selectedOptions: [],
|
|
22282
21739
|
nativeEvent: void 0,
|
|
22283
21740
|
meta: void 0
|
|
22284
21741
|
};
|
|
@@ -22294,9 +21751,14 @@ var ShadcnMultiSelectVariant = React74.forwardRef(function ShadcnMultiSelectVari
|
|
|
22294
21751
|
selectedValues,
|
|
22295
21752
|
item.value
|
|
22296
21753
|
);
|
|
21754
|
+
const selectedOptions = (updated != null ? updated : []).map((value2) => {
|
|
21755
|
+
var _a2, _b;
|
|
21756
|
+
return (_b = (_a2 = keyedItems[value2]) == null ? void 0 : _a2.raw) != null ? _b : value2;
|
|
21757
|
+
});
|
|
22297
21758
|
const detail = {
|
|
22298
21759
|
source: "variant",
|
|
22299
21760
|
raw: item,
|
|
21761
|
+
selectedOptions,
|
|
22300
21762
|
nativeEvent: void 0,
|
|
22301
21763
|
meta: { action: "remove", removed: value }
|
|
22302
21764
|
};
|
|
@@ -24221,9 +23683,16 @@ var ShadcnTreeSelectVariant = React74.forwardRef(function ShadcnTreeSelectVarian
|
|
|
24221
23683
|
setOpen(false);
|
|
24222
23684
|
}
|
|
24223
23685
|
const nextSelectedValues = Array.isArray(nextValue) ? nextValue : nextValue !== void 0 && nextValue !== null ? [nextValue] : [];
|
|
23686
|
+
const nextSelectedOptions = nextSelectedValues.map(
|
|
23687
|
+
(val) => {
|
|
23688
|
+
var _a, _b;
|
|
23689
|
+
return (_b = (_a = allNodesFlat.find((node) => node.value === val)) == null ? void 0 : _a.raw) != null ? _b : val;
|
|
23690
|
+
}
|
|
23691
|
+
);
|
|
24224
23692
|
const detail = {
|
|
24225
23693
|
source: "variant",
|
|
24226
23694
|
raw: item.raw,
|
|
23695
|
+
selectedOptions: nextSelectedOptions,
|
|
24227
23696
|
nativeEvent: void 0,
|
|
24228
23697
|
meta: {
|
|
24229
23698
|
toggled: item.value,
|
|
@@ -24238,7 +23707,8 @@ var ShadcnTreeSelectVariant = React74.forwardRef(function ShadcnTreeSelectVarian
|
|
|
24238
23707
|
multiple,
|
|
24239
23708
|
selectedValues,
|
|
24240
23709
|
onValue,
|
|
24241
|
-
toggleExpanded
|
|
23710
|
+
toggleExpanded,
|
|
23711
|
+
allNodesFlat
|
|
24242
23712
|
]
|
|
24243
23713
|
);
|
|
24244
23714
|
const handleClear = React74.useCallback(() => {
|
|
@@ -24246,6 +23716,7 @@ var ShadcnTreeSelectVariant = React74.forwardRef(function ShadcnTreeSelectVarian
|
|
|
24246
23716
|
const detail = {
|
|
24247
23717
|
source: "variant",
|
|
24248
23718
|
raw: void 0,
|
|
23719
|
+
selectedOptions: [],
|
|
24249
23720
|
nativeEvent: void 0,
|
|
24250
23721
|
meta: { action: "clear" }
|
|
24251
23722
|
};
|
|
@@ -26019,6 +25490,7 @@ var ShadcnToggleVariant3 = React74.forwardRef(function ShadcnToggleVariant4(prop
|
|
|
26019
25490
|
source: "variant",
|
|
26020
25491
|
raw: rawSelection,
|
|
26021
25492
|
// original item(s)
|
|
25493
|
+
selectedOptions: Array.isArray(rawSelection) ? rawSelection : rawSelection === void 0 ? [] : [rawSelection],
|
|
26022
25494
|
nativeEvent: void 0,
|
|
26023
25495
|
meta: { action: "toggle" }
|
|
26024
25496
|
};
|
|
@@ -30798,7 +30270,7 @@ var ShadcnIconVariant = React74.forwardRef(function ShadcnIconVariant2(props, re
|
|
|
30798
30270
|
PopoverContent,
|
|
30799
30271
|
{
|
|
30800
30272
|
className: cn(
|
|
30801
|
-
"w-(--radix-popover-trigger-width) p-0",
|
|
30273
|
+
"w-(--radix-popover-trigger-width) p-0 max-h-(--radix-popper-available-height)",
|
|
30802
30274
|
popoverClassName
|
|
30803
30275
|
),
|
|
30804
30276
|
align: "start",
|
|
@@ -31648,7 +31120,7 @@ var ShadcnImageIconVariant = React74.forwardRef(function ShadcnImageIconVariant2
|
|
|
31648
31120
|
PopoverContent,
|
|
31649
31121
|
{
|
|
31650
31122
|
className: cn(
|
|
31651
|
-
"w-(--radix-popover-trigger-width) p-0",
|
|
31123
|
+
"w-(--radix-popover-trigger-width) p-0 max-h-(--radix-popper-available-height)",
|
|
31652
31124
|
popoverClassName
|
|
31653
31125
|
),
|
|
31654
31126
|
align: "start",
|