@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.js
CHANGED
|
@@ -10809,7 +10809,11 @@ var Input = React74__namespace.forwardRef(
|
|
|
10809
10809
|
children: [
|
|
10810
10810
|
renderBaseInput({
|
|
10811
10811
|
inner: false,
|
|
10812
|
-
className: cx(
|
|
10812
|
+
className: cx(
|
|
10813
|
+
baseBoxClasses,
|
|
10814
|
+
boxPaddingClasses,
|
|
10815
|
+
className
|
|
10816
|
+
),
|
|
10813
10817
|
style: varsStyle
|
|
10814
10818
|
}),
|
|
10815
10819
|
hasLeadingIcons && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -10913,7 +10917,7 @@ var Input = React74__namespace.forwardRef(
|
|
|
10913
10917
|
className: "absolute inset-y-0 left-0 flex items-center cursor-pointer",
|
|
10914
10918
|
style: {
|
|
10915
10919
|
gap: leadingGap,
|
|
10916
|
-
paddingLeft: `${pxDefault}px`
|
|
10920
|
+
paddingLeft: hasLeadingControl ? void 0 : `${pxDefault}px`
|
|
10917
10921
|
},
|
|
10918
10922
|
"data-slot": "leading-icons",
|
|
10919
10923
|
onMouseDown: handleIconMouseDown,
|
|
@@ -10934,7 +10938,7 @@ var Input = React74__namespace.forwardRef(
|
|
|
10934
10938
|
className: "absolute inset-y-0 right-0 flex items-center cursor-pointer",
|
|
10935
10939
|
style: {
|
|
10936
10940
|
gap: trailingGap,
|
|
10937
|
-
paddingRight: `${pxDefault}px`
|
|
10941
|
+
paddingRight: hasTrailingControl ? void 0 : `${pxDefault}px`
|
|
10938
10942
|
},
|
|
10939
10943
|
"data-slot": "trailing-icons",
|
|
10940
10944
|
onMouseDown: handleIconMouseDown,
|
|
@@ -11258,9 +11262,98 @@ var textVariant = {
|
|
|
11258
11262
|
tags: ["text", "input", "string"]
|
|
11259
11263
|
}
|
|
11260
11264
|
};
|
|
11265
|
+
function clampToLimits(n3, min2, max2) {
|
|
11266
|
+
let out = n3;
|
|
11267
|
+
if (min2 != null && out < min2) out = min2;
|
|
11268
|
+
if (max2 != null && out > max2) out = max2;
|
|
11269
|
+
return out;
|
|
11270
|
+
}
|
|
11271
|
+
function isFiniteNumber(n3) {
|
|
11272
|
+
return typeof n3 === "number" && Number.isFinite(n3);
|
|
11273
|
+
}
|
|
11274
|
+
function resolveLocale(explicit) {
|
|
11275
|
+
if (explicit) return explicit;
|
|
11276
|
+
if (typeof navigator !== "undefined" && navigator.language)
|
|
11277
|
+
return navigator.language;
|
|
11278
|
+
return "en-US";
|
|
11279
|
+
}
|
|
11280
|
+
function getDecimalSeparator(locale) {
|
|
11281
|
+
const s3 = new Intl.NumberFormat(locale, { useGrouping: false }).format(1.1);
|
|
11282
|
+
const m2 = s3.match(/1(.?)1/);
|
|
11283
|
+
return (m2 == null ? void 0 : m2[1]) || ".";
|
|
11284
|
+
}
|
|
11285
|
+
function stripAffixes(text, prefix, suffix) {
|
|
11286
|
+
let t4 = text != null ? text : "";
|
|
11287
|
+
if (prefix && t4.startsWith(prefix)) t4 = t4.slice(prefix.length);
|
|
11288
|
+
if (suffix && t4.endsWith(suffix)) t4 = t4.slice(0, -suffix.length);
|
|
11289
|
+
return t4;
|
|
11290
|
+
}
|
|
11291
|
+
function stripGrouping(text, locale) {
|
|
11292
|
+
const group = new Intl.NumberFormat(locale, { useGrouping: true }).format(1e6).replace(/[0-9]/g, "").trim().charAt(0);
|
|
11293
|
+
if (!group) return text;
|
|
11294
|
+
const re3 = new RegExp(`\\${group}`, "g");
|
|
11295
|
+
return text.replace(re3, "");
|
|
11296
|
+
}
|
|
11297
|
+
function parseEditable(editable, locale, decimalSep) {
|
|
11298
|
+
const t4 = editable.trim();
|
|
11299
|
+
if (!t4 || t4 === "-" || t4 === decimalSep) return null;
|
|
11300
|
+
const noGroup = stripGrouping(t4, locale);
|
|
11301
|
+
const normalized = decimalSep === "." ? noGroup : noGroup.replace(decimalSep, ".");
|
|
11302
|
+
const cleaned = normalized.endsWith(".") ? normalized.slice(0, -1) : normalized;
|
|
11303
|
+
if (!cleaned || cleaned === "-") return null;
|
|
11304
|
+
const n3 = Number(cleaned);
|
|
11305
|
+
return Number.isFinite(n3) ? n3 : null;
|
|
11306
|
+
}
|
|
11307
|
+
function formatDisplayNumber(n3, locale, opts, prefix, suffix) {
|
|
11308
|
+
const f2 = new Intl.NumberFormat(locale, opts).format(n3);
|
|
11309
|
+
return `${prefix != null ? prefix : ""}${f2}${suffix != null ? suffix : ""}`;
|
|
11310
|
+
}
|
|
11311
|
+
function applyFractionLimitReplace(next, prev, locale, decimalSep, maxFractionDigits, inputEl) {
|
|
11312
|
+
var _a, _b, _c;
|
|
11313
|
+
if (maxFractionDigits == null)
|
|
11314
|
+
return { text: next, caret: (_a = inputEl.selectionStart) != null ? _a : next.length };
|
|
11315
|
+
const selStart = (_b = inputEl.selectionStart) != null ? _b : 0;
|
|
11316
|
+
const selEnd = (_c = inputEl.selectionEnd) != null ? _c : selStart;
|
|
11317
|
+
const decIndex = next.indexOf(decimalSep);
|
|
11318
|
+
if (decIndex === -1) return { text: next, caret: selStart };
|
|
11319
|
+
const frac = next.slice(decIndex + 1);
|
|
11320
|
+
if (frac.length <= maxFractionDigits)
|
|
11321
|
+
return { text: next, caret: selStart };
|
|
11322
|
+
if (selEnd > selStart) {
|
|
11323
|
+
const trimmed2 = next.slice(0, decIndex + 1 + maxFractionDigits);
|
|
11324
|
+
const caret2 = Math.min(selStart, trimmed2.length);
|
|
11325
|
+
return { text: trimmed2, caret: caret2 };
|
|
11326
|
+
}
|
|
11327
|
+
const caret = selStart;
|
|
11328
|
+
const fracStart = decIndex + 1;
|
|
11329
|
+
const fracEnd = fracStart + maxFractionDigits;
|
|
11330
|
+
const trimmed = next.slice(0, fracEnd);
|
|
11331
|
+
const clampedCaret = Math.min(caret, trimmed.length);
|
|
11332
|
+
return { text: trimmed, caret: clampedCaret };
|
|
11333
|
+
}
|
|
11334
|
+
function normalizeEditable(raw, locale, decimalSep, allowMinus) {
|
|
11335
|
+
let t4 = raw;
|
|
11336
|
+
t4 = stripGrouping(t4, locale);
|
|
11337
|
+
const allowed = new RegExp(`[^0-9\\${decimalSep}\\-]`, "g");
|
|
11338
|
+
t4 = t4.replace(allowed, "");
|
|
11339
|
+
const minusCount = (t4.match(/\-/g) || []).length;
|
|
11340
|
+
if (minusCount) {
|
|
11341
|
+
t4 = t4.replace(/\-/g, "");
|
|
11342
|
+
if (allowMinus) t4 = "-" + t4;
|
|
11343
|
+
}
|
|
11344
|
+
const firstDec = t4.indexOf(decimalSep);
|
|
11345
|
+
if (firstDec !== -1) {
|
|
11346
|
+
const before = t4.slice(0, firstDec + 1);
|
|
11347
|
+
const after = t4.slice(firstDec + 1).replace(new RegExp(`\\${decimalSep}`, "g"), "");
|
|
11348
|
+
t4 = before + after;
|
|
11349
|
+
}
|
|
11350
|
+
if (t4 === "-" + decimalSep) t4 = "-0" + decimalSep;
|
|
11351
|
+
if (t4 === decimalSep) t4 = "0" + decimalSep;
|
|
11352
|
+
return t4;
|
|
11353
|
+
}
|
|
11261
11354
|
var InputNumber = React74__namespace.memo(
|
|
11262
11355
|
React74__namespace.forwardRef((inProps, ref) => {
|
|
11263
|
-
var _a
|
|
11356
|
+
var _a;
|
|
11264
11357
|
const props = {
|
|
11265
11358
|
allowEmpty: true,
|
|
11266
11359
|
autoFocus: false,
|
|
@@ -11274,35 +11367,19 @@ var InputNumber = React74__namespace.memo(
|
|
|
11274
11367
|
type: "text",
|
|
11275
11368
|
...inProps
|
|
11276
11369
|
};
|
|
11277
|
-
const
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
const
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
const
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
const
|
|
11290
|
-
const _decimal = React74__namespace.useRef(null);
|
|
11291
|
-
const _decimalSeparator = React74__namespace.useRef(".");
|
|
11292
|
-
const _suffix = React74__namespace.useRef(null);
|
|
11293
|
-
const _prefix = React74__namespace.useRef(null);
|
|
11294
|
-
const _index = React74__namespace.useRef(() => 0);
|
|
11295
|
-
const isFocusedByClick = React74__namespace.useRef(false);
|
|
11296
|
-
const resolveLocale = React74__namespace.useCallback(() => {
|
|
11297
|
-
if (props.locale) return props.locale;
|
|
11298
|
-
if (typeof navigator !== "undefined" && navigator.language) {
|
|
11299
|
-
return navigator.language;
|
|
11300
|
-
}
|
|
11301
|
-
return "en-US";
|
|
11302
|
-
}, [props.locale]);
|
|
11303
|
-
const _locale = resolveLocale();
|
|
11304
|
-
const inputMode = props.inputMode || (props.mode === "decimal" && !props.minFractionDigits && !props.maxFractionDigits ? "numeric" : "decimal");
|
|
11305
|
-
const getOptions = React74__namespace.useCallback(() => {
|
|
11370
|
+
const locale = React74__namespace.useMemo(
|
|
11371
|
+
() => resolveLocale(props.locale),
|
|
11372
|
+
[props.locale]
|
|
11373
|
+
);
|
|
11374
|
+
const decimalSep = React74__namespace.useMemo(
|
|
11375
|
+
() => getDecimalSeparator(locale),
|
|
11376
|
+
[locale]
|
|
11377
|
+
);
|
|
11378
|
+
const allowMinus = React74__namespace.useMemo(
|
|
11379
|
+
() => props.min == null || props.min < 0,
|
|
11380
|
+
[props.min]
|
|
11381
|
+
);
|
|
11382
|
+
const fmtOptions = React74__namespace.useMemo(() => {
|
|
11306
11383
|
return {
|
|
11307
11384
|
localeMatcher: props.localeMatcher,
|
|
11308
11385
|
style: props.mode,
|
|
@@ -11323,262 +11400,27 @@ var InputNumber = React74__namespace.memo(
|
|
|
11323
11400
|
props.maxFractionDigits,
|
|
11324
11401
|
props.roundingMode
|
|
11325
11402
|
]);
|
|
11326
|
-
const
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
_numeral.current = new RegExp("[" + numerals.join("") + "]", "g");
|
|
11335
|
-
_index.current = (d) => {
|
|
11336
|
-
var _a2;
|
|
11337
|
-
return (_a2 = index.get(d)) != null ? _a2 : 0;
|
|
11338
|
-
};
|
|
11339
|
-
const formatterGroup = new Intl.NumberFormat(loc, { useGrouping: true });
|
|
11340
|
-
groupChar.current = formatterGroup.format(1e6).trim().replace(_numeral.current, "").charAt(0);
|
|
11341
|
-
_group.current = new RegExp("[" + groupChar.current + "]", "g");
|
|
11342
|
-
const formatterMinus = new Intl.NumberFormat(loc, { useGrouping: false });
|
|
11343
|
-
const minusString = formatterMinus.format(-1).trim().replace(_numeral.current, "");
|
|
11344
|
-
_minusSign.current = new RegExp("[" + minusString + "]", "g");
|
|
11345
|
-
if (props.currency) {
|
|
11346
|
-
const formatterCurrency = new Intl.NumberFormat(loc, {
|
|
11347
|
-
style: "currency",
|
|
11348
|
-
currency: props.currency,
|
|
11349
|
-
currencyDisplay: props.currencyDisplay,
|
|
11350
|
-
minimumFractionDigits: 0,
|
|
11351
|
-
maximumFractionDigits: 0,
|
|
11352
|
-
roundingMode: props.roundingMode
|
|
11353
|
-
});
|
|
11354
|
-
_currency.current = new RegExp(
|
|
11355
|
-
"[" + formatterCurrency.format(1).replace(/\s/g, "").replace(_numeral.current, "").replace(_group.current, "") + "]",
|
|
11356
|
-
"g"
|
|
11357
|
-
);
|
|
11358
|
-
} else {
|
|
11359
|
-
_currency.current = new RegExp("[]", "g");
|
|
11360
|
-
}
|
|
11361
|
-
const formatterDecimal = new Intl.NumberFormat(loc, {
|
|
11362
|
-
useGrouping: false
|
|
11363
|
-
});
|
|
11364
|
-
const decSample = formatterDecimal.format(1.1).trim().replace(_numeral.current, "");
|
|
11365
|
-
_decimalSeparator.current = decSample || ".";
|
|
11366
|
-
const formatterDecOptions = new Intl.NumberFormat(loc, {
|
|
11367
|
-
...getOptions(),
|
|
11368
|
-
useGrouping: false
|
|
11369
|
-
});
|
|
11370
|
-
_decimal.current = new RegExp(
|
|
11371
|
-
"[" + formatterDecOptions.format(1.1).replace(_currency.current, "").trim().replace(_numeral.current, "") + "]",
|
|
11372
|
-
"g"
|
|
11373
|
-
);
|
|
11374
|
-
if (props.prefix) {
|
|
11375
|
-
prefixChar.current = props.prefix;
|
|
11376
|
-
} else {
|
|
11377
|
-
const formatterPrefix = new Intl.NumberFormat(loc, {
|
|
11378
|
-
style: props.mode,
|
|
11379
|
-
currency: props.currency,
|
|
11380
|
-
currencyDisplay: props.currencyDisplay
|
|
11381
|
-
});
|
|
11382
|
-
prefixChar.current = formatterPrefix.format(1).split("1")[0];
|
|
11383
|
-
}
|
|
11384
|
-
_prefix.current = new RegExp(escapeRegExp(prefixChar.current || ""), "g");
|
|
11385
|
-
if (props.suffix) {
|
|
11386
|
-
suffixChar.current = props.suffix;
|
|
11387
|
-
} else {
|
|
11388
|
-
const formatterSuffix = new Intl.NumberFormat(loc, {
|
|
11389
|
-
style: props.mode,
|
|
11390
|
-
currency: props.currency,
|
|
11391
|
-
currencyDisplay: props.currencyDisplay,
|
|
11392
|
-
minimumFractionDigits: 0,
|
|
11393
|
-
maximumFractionDigits: 0,
|
|
11394
|
-
roundingMode: props.roundingMode
|
|
11395
|
-
});
|
|
11396
|
-
suffixChar.current = formatterSuffix.format(1).split("1")[1];
|
|
11397
|
-
}
|
|
11398
|
-
_suffix.current = new RegExp(escapeRegExp(suffixChar.current || ""), "g");
|
|
11399
|
-
}, [
|
|
11400
|
-
_locale,
|
|
11401
|
-
getOptions,
|
|
11402
|
-
props.currency,
|
|
11403
|
-
props.currencyDisplay,
|
|
11404
|
-
props.mode,
|
|
11405
|
-
props.prefix,
|
|
11406
|
-
props.roundingMode,
|
|
11407
|
-
props.suffix
|
|
11408
|
-
]);
|
|
11409
|
-
const formatValue = React74__namespace.useCallback(
|
|
11410
|
-
(value2) => {
|
|
11411
|
-
if (value2 == null) return "";
|
|
11412
|
-
if (value2 === "-") return "-";
|
|
11413
|
-
const numeric = typeof value2 === "number" ? value2 : typeof value2 === "string" ? Number(value2) : Number.NaN;
|
|
11414
|
-
if (Number.isNaN(numeric)) return "";
|
|
11415
|
-
if (props.format) {
|
|
11416
|
-
const formatter = numberFormat.current || new Intl.NumberFormat(_locale, getOptions());
|
|
11417
|
-
let formatted = formatter.format(numeric);
|
|
11418
|
-
if (props.prefix) {
|
|
11419
|
-
formatted = props.prefix + formatted;
|
|
11420
|
-
}
|
|
11421
|
-
if (props.suffix) {
|
|
11422
|
-
formatted = formatted + props.suffix;
|
|
11423
|
-
}
|
|
11424
|
-
return formatted;
|
|
11425
|
-
}
|
|
11426
|
-
return numeric.toString();
|
|
11403
|
+
const inputRef = React74__namespace.useRef(null);
|
|
11404
|
+
React74__namespace.useImperativeHandle(ref, () => inputRef.current);
|
|
11405
|
+
const [display, setDisplay] = React74__namespace.useState("");
|
|
11406
|
+
const [focused, setFocused] = React74__namespace.useState(false);
|
|
11407
|
+
const toEditableFromNumber = React74__namespace.useCallback(
|
|
11408
|
+
(n3) => {
|
|
11409
|
+
const s3 = String(n3);
|
|
11410
|
+
return decimalSep === "." ? s3 : s3.replace(".", decimalSep);
|
|
11427
11411
|
},
|
|
11428
|
-
[
|
|
11412
|
+
[decimalSep]
|
|
11429
11413
|
);
|
|
11430
|
-
const
|
|
11431
|
-
(
|
|
11432
|
-
|
|
11433
|
-
let filteredText = text;
|
|
11434
|
-
if (_suffix.current) {
|
|
11435
|
-
filteredText = filteredText.replace(_suffix.current, "");
|
|
11436
|
-
}
|
|
11437
|
-
if (_prefix.current) {
|
|
11438
|
-
filteredText = filteredText.replace(_prefix.current, "");
|
|
11439
|
-
}
|
|
11440
|
-
filteredText = filteredText.trim().replace(/\s/g, "").replace(_currency.current, "").replace(_group.current, "").replace(_minusSign.current, "-").replace(_decimal.current, ".").replace(
|
|
11441
|
-
_numeral.current,
|
|
11442
|
-
(d) => {
|
|
11443
|
-
var _a2;
|
|
11444
|
-
return String((_a2 = _index.current(d)) != null ? _a2 : "");
|
|
11445
|
-
}
|
|
11446
|
-
);
|
|
11447
|
-
if (!filteredText) return null;
|
|
11448
|
-
if (filteredText === "-") {
|
|
11449
|
-
return "-";
|
|
11450
|
-
}
|
|
11451
|
-
const parsedValue = +filteredText;
|
|
11452
|
-
return Number.isNaN(parsedValue) ? null : parsedValue;
|
|
11453
|
-
},
|
|
11454
|
-
[]
|
|
11414
|
+
const clampModel = React74__namespace.useCallback(
|
|
11415
|
+
(n3) => clampToLimits(n3, props.min, props.max),
|
|
11416
|
+
[props.min, props.max]
|
|
11455
11417
|
);
|
|
11456
|
-
const
|
|
11457
|
-
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
timer.current = void 0;
|
|
11461
|
-
}
|
|
11462
|
-
};
|
|
11463
|
-
const allowMinusSign = () => props.min == null || props.min < 0;
|
|
11464
|
-
const isMinusSign = (ch) => {
|
|
11465
|
-
if (_minusSign.current && _minusSign.current.test(ch) || ch === "-") {
|
|
11466
|
-
_minusSign.current && (_minusSign.current.lastIndex = 0);
|
|
11467
|
-
return true;
|
|
11468
|
-
}
|
|
11469
|
-
return false;
|
|
11470
|
-
};
|
|
11471
|
-
const isDecimalMode = () => props.mode === "decimal";
|
|
11472
|
-
const isFloat = (val) => {
|
|
11473
|
-
const formatter = new Intl.NumberFormat(_locale, getOptions());
|
|
11474
|
-
const parsed = parseValue(formatter.format(val));
|
|
11475
|
-
if (parsed === null || typeof parsed !== "number") {
|
|
11476
|
-
return false;
|
|
11477
|
-
}
|
|
11478
|
-
return parsed % 1 !== 0;
|
|
11479
|
-
};
|
|
11480
|
-
const replaceDecimalSeparator = (val) => {
|
|
11481
|
-
if (typeof val === "number" && isFloat(val)) {
|
|
11482
|
-
return val.toString().replace(/\.(?=[^.]*$)/, _decimalSeparator.current);
|
|
11483
|
-
}
|
|
11484
|
-
return val;
|
|
11485
|
-
};
|
|
11486
|
-
const isDecimalSign = (ch) => {
|
|
11487
|
-
if (_decimal.current && (_decimal.current.test(ch) || isFloat(Number(ch)))) {
|
|
11488
|
-
_decimal.current.lastIndex = 0;
|
|
11489
|
-
return true;
|
|
11490
|
-
}
|
|
11491
|
-
return false;
|
|
11492
|
-
};
|
|
11493
|
-
const getDecimalCharIndexes = (val) => {
|
|
11494
|
-
let decimalCharIndex = -1;
|
|
11495
|
-
let decimalCharIndexWithoutPrefix = -1;
|
|
11496
|
-
if (_decimal.current) {
|
|
11497
|
-
decimalCharIndex = val.search(_decimal.current);
|
|
11498
|
-
_decimal.current.lastIndex = 0;
|
|
11499
|
-
let filteredVal = val;
|
|
11500
|
-
if (_prefix.current) {
|
|
11501
|
-
filteredVal = filteredVal.replace(_prefix.current, "");
|
|
11502
|
-
}
|
|
11503
|
-
filteredVal = filteredVal.trim().replace(/\s/g, "").replace(_currency.current, "");
|
|
11504
|
-
decimalCharIndexWithoutPrefix = filteredVal.search(_decimal.current);
|
|
11505
|
-
_decimal.current.lastIndex = 0;
|
|
11506
|
-
}
|
|
11507
|
-
return { decimalCharIndex, decimalCharIndexWithoutPrefix };
|
|
11508
|
-
};
|
|
11509
|
-
const getCharIndexes = (val) => {
|
|
11510
|
-
let decimalCharIndex = -1;
|
|
11511
|
-
let minusCharIndex = -1;
|
|
11512
|
-
let suffixCharIndex = -1;
|
|
11513
|
-
let currencyCharIndex = -1;
|
|
11514
|
-
if (_decimal.current) {
|
|
11515
|
-
decimalCharIndex = val.search(_decimal.current);
|
|
11516
|
-
_decimal.current.lastIndex = 0;
|
|
11517
|
-
}
|
|
11518
|
-
if (_minusSign.current) {
|
|
11519
|
-
minusCharIndex = val.search(_minusSign.current);
|
|
11520
|
-
_minusSign.current.lastIndex = 0;
|
|
11521
|
-
}
|
|
11522
|
-
if (_suffix.current) {
|
|
11523
|
-
suffixCharIndex = val.search(_suffix.current);
|
|
11524
|
-
_suffix.current.lastIndex = 0;
|
|
11525
|
-
}
|
|
11526
|
-
if (_currency.current) {
|
|
11527
|
-
currencyCharIndex = val.search(_currency.current);
|
|
11528
|
-
if (currencyCharIndex === 0 && prefixChar.current && prefixChar.current.length > 1) {
|
|
11529
|
-
currencyCharIndex = prefixChar.current.trim().length;
|
|
11530
|
-
}
|
|
11531
|
-
_currency.current.lastIndex = 0;
|
|
11532
|
-
}
|
|
11533
|
-
return { decimalCharIndex, minusCharIndex, suffixCharIndex, currencyCharIndex };
|
|
11534
|
-
};
|
|
11535
|
-
const resetRegex = () => {
|
|
11536
|
-
if (_numeral.current) _numeral.current.lastIndex = 0;
|
|
11537
|
-
if (_decimal.current) _decimal.current.lastIndex = 0;
|
|
11538
|
-
if (_group.current) _group.current.lastIndex = 0;
|
|
11539
|
-
if (_minusSign.current) _minusSign.current.lastIndex = 0;
|
|
11540
|
-
};
|
|
11541
|
-
const isNumeralChar = (ch) => {
|
|
11542
|
-
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))) {
|
|
11543
|
-
resetRegex();
|
|
11544
|
-
return true;
|
|
11545
|
-
}
|
|
11546
|
-
return false;
|
|
11547
|
-
};
|
|
11548
|
-
const evaluateEmpty = (newValue) => {
|
|
11549
|
-
var _a2;
|
|
11550
|
-
if ((newValue == null || newValue === "") && !props.allowEmpty) {
|
|
11551
|
-
return (_a2 = props.min) != null ? _a2 : 0;
|
|
11552
|
-
}
|
|
11553
|
-
return newValue;
|
|
11554
|
-
};
|
|
11555
|
-
const validateValueByLimit = (value2) => {
|
|
11556
|
-
if (value2 === "-" || value2 === null || value2 === "") {
|
|
11557
|
-
return null;
|
|
11558
|
-
}
|
|
11559
|
-
let num = typeof value2 === "number" ? value2 : Number(value2);
|
|
11560
|
-
if (Number.isNaN(num)) {
|
|
11561
|
-
return null;
|
|
11562
|
-
}
|
|
11563
|
-
if (props.min != null && num < props.min) num = props.min;
|
|
11564
|
-
if (props.max != null && num > props.max) num = props.max;
|
|
11565
|
-
return num;
|
|
11566
|
-
};
|
|
11567
|
-
const validateValue = (value2) => {
|
|
11568
|
-
if (value2 === "-") return null;
|
|
11569
|
-
return validateValueByLimit(value2);
|
|
11570
|
-
};
|
|
11571
|
-
const formattedValue = (val) => {
|
|
11572
|
-
const newVal = evaluateEmpty(val);
|
|
11573
|
-
return formatValue(newVal);
|
|
11574
|
-
};
|
|
11575
|
-
const updateModel = (event, value2) => {
|
|
11576
|
-
var _a2, _b2;
|
|
11577
|
-
const finalValue = value2;
|
|
11578
|
-
if (props.onValueChange) {
|
|
11579
|
-
props.onValueChange({
|
|
11418
|
+
const emit = React74__namespace.useCallback(
|
|
11419
|
+
(event, value2) => {
|
|
11420
|
+
var _a2, _b, _c;
|
|
11421
|
+
(_c = props.onValueChange) == null ? void 0 : _c.call(props, {
|
|
11580
11422
|
originalEvent: event,
|
|
11581
|
-
value:
|
|
11423
|
+
value: value2,
|
|
11582
11424
|
stopPropagation() {
|
|
11583
11425
|
event == null ? void 0 : event.stopPropagation();
|
|
11584
11426
|
},
|
|
@@ -11587,600 +11429,160 @@ var InputNumber = React74__namespace.memo(
|
|
|
11587
11429
|
},
|
|
11588
11430
|
target: {
|
|
11589
11431
|
name: (_a2 = props.name) != null ? _a2 : null,
|
|
11590
|
-
id: (
|
|
11591
|
-
value:
|
|
11432
|
+
id: (_b = props.id) != null ? _b : null,
|
|
11433
|
+
value: value2
|
|
11592
11434
|
}
|
|
11593
11435
|
});
|
|
11594
|
-
|
|
11595
|
-
|
|
11596
|
-
props.onChange({ originalEvent: event, value: finalValue });
|
|
11597
|
-
}
|
|
11598
|
-
};
|
|
11599
|
-
const handleOnChange = (event, currentValue, newValue) => {
|
|
11600
|
-
if (!props.onChange) return;
|
|
11601
|
-
const parsedCurrent = typeof currentValue === "string" ? parseValue(currentValue) : null;
|
|
11602
|
-
const changed = newValue !== parsedCurrent;
|
|
11603
|
-
if (changed) {
|
|
11604
|
-
props.onChange({ originalEvent: event, value: newValue });
|
|
11605
|
-
}
|
|
11606
|
-
};
|
|
11607
|
-
const concatValues = (val1, val2) => {
|
|
11608
|
-
if (val1 && val2) {
|
|
11609
|
-
const decimalCharIndex = val2.search(_decimal.current);
|
|
11610
|
-
_decimal.current.lastIndex = 0;
|
|
11611
|
-
const newVal1 = replaceDecimalSeparator(val1);
|
|
11612
|
-
const base = newVal1.split(_decimal.current)[0].replace(_suffix.current, "").trim();
|
|
11613
|
-
return decimalCharIndex !== -1 ? base + val2.slice(decimalCharIndex) : val1;
|
|
11614
|
-
}
|
|
11615
|
-
return val1;
|
|
11616
|
-
};
|
|
11617
|
-
const getDecimalLength = (value2) => {
|
|
11618
|
-
if (value2) {
|
|
11619
|
-
const valueSplit = value2.split(_decimal.current);
|
|
11620
|
-
if (valueSplit.length === 2) {
|
|
11621
|
-
return valueSplit[1].replace(_suffix.current, "").length;
|
|
11622
|
-
}
|
|
11623
|
-
}
|
|
11624
|
-
return 0;
|
|
11625
|
-
};
|
|
11626
|
-
const deleteRange = (value2, start, end) => {
|
|
11627
|
-
if (end - start === value2.length) {
|
|
11628
|
-
return "";
|
|
11629
|
-
} else if (start === 0) {
|
|
11630
|
-
return value2.slice(end);
|
|
11631
|
-
} else if (end === value2.length) {
|
|
11632
|
-
return value2.slice(0, start);
|
|
11633
|
-
}
|
|
11634
|
-
return value2.slice(0, start) + value2.slice(end);
|
|
11635
|
-
};
|
|
11636
|
-
const replaceSuffix = (value2) => value2 ? value2.replace(_suffix.current, "").trim().replace(/\s/g, "").replace(_currency.current, "") : value2;
|
|
11637
|
-
const insertText = (value2, text, start, end) => {
|
|
11638
|
-
const textSplit = isDecimalSign(text) ? text : text.split(_decimal.current);
|
|
11639
|
-
if (textSplit.length === 2) {
|
|
11640
|
-
const local = value2.slice(start, end);
|
|
11641
|
-
const decimalCharIndex = local.search(_decimal.current);
|
|
11642
|
-
_decimal.current.lastIndex = 0;
|
|
11643
|
-
return decimalCharIndex > 0 ? value2.slice(0, start) + formatValue(text) + replaceSuffix(value2).slice(end) : value2 || formatValue(text);
|
|
11644
|
-
}
|
|
11645
|
-
if (isDecimalSign(text) && value2.length === 0) {
|
|
11646
|
-
return formatValue("0.");
|
|
11647
|
-
}
|
|
11648
|
-
if (end - start === value2.length) {
|
|
11649
|
-
return formatValue(text);
|
|
11650
|
-
}
|
|
11651
|
-
if (start === 0) {
|
|
11652
|
-
const suffix = /[A-Za-z]$/.test(value2[end]) ? end - 1 : end;
|
|
11653
|
-
return text + value2.slice(suffix);
|
|
11654
|
-
}
|
|
11655
|
-
if (end === value2.length) {
|
|
11656
|
-
return value2.slice(0, start) + text;
|
|
11657
|
-
}
|
|
11658
|
-
const selectionValue = value2.slice(start, end);
|
|
11659
|
-
const space = /\s$/.test(selectionValue) ? " " : "";
|
|
11660
|
-
return value2.slice(0, start) + text + space + value2.slice(end);
|
|
11661
|
-
};
|
|
11662
|
-
const evaluateEmptyForUpdate = (newValue) => evaluateEmpty(newValue);
|
|
11663
|
-
const updateInput = (value2, insertedValueStr, operation, valueStr) => {
|
|
11664
|
-
var _a2, _b2;
|
|
11665
|
-
insertedValueStr = insertedValueStr || "";
|
|
11666
|
-
const inputEl = inputRef.current;
|
|
11667
|
-
if (!inputEl) return;
|
|
11668
|
-
const inputValue = inputEl.value;
|
|
11669
|
-
let newValue = formatValue(value2);
|
|
11670
|
-
const currentLength = inputValue.length;
|
|
11671
|
-
if (newValue !== valueStr && valueStr != null) {
|
|
11672
|
-
newValue = concatValues(newValue, valueStr);
|
|
11673
|
-
}
|
|
11674
|
-
if (currentLength === 0) {
|
|
11675
|
-
inputEl.value = newValue;
|
|
11676
|
-
inputEl.setSelectionRange(0, 0);
|
|
11677
|
-
const index = initCursor();
|
|
11678
|
-
const selectionEnd = index + insertedValueStr.length + (isDecimalSign(insertedValueStr) ? 1 : 0);
|
|
11679
|
-
inputEl.setSelectionRange(selectionEnd, selectionEnd);
|
|
11680
|
-
} else {
|
|
11681
|
-
let selectionStart = (_a2 = inputEl.selectionStart) != null ? _a2 : 0;
|
|
11682
|
-
let selectionEnd = (_b2 = inputEl.selectionEnd) != null ? _b2 : 0;
|
|
11683
|
-
if (props.maxLength && props.maxLength < newValue.length) {
|
|
11684
|
-
return;
|
|
11685
|
-
}
|
|
11686
|
-
inputEl.value = newValue;
|
|
11687
|
-
const newLength = newValue.length;
|
|
11688
|
-
if (operation === "range-insert") {
|
|
11689
|
-
const startValue = parseValue((inputValue || "").slice(0, selectionStart));
|
|
11690
|
-
const startValueStr = startValue != null ? String(startValue) : "";
|
|
11691
|
-
const startExpr = startValueStr.split("").join("(" + groupChar.current + ")?");
|
|
11692
|
-
const sRegex = new RegExp(startExpr, "g");
|
|
11693
|
-
sRegex.test(newValue);
|
|
11694
|
-
const tExpr = insertedValueStr.split("").join("(" + groupChar.current + ")?");
|
|
11695
|
-
const tRegex = new RegExp(tExpr, "g");
|
|
11696
|
-
tRegex.test(newValue.slice(sRegex.lastIndex));
|
|
11697
|
-
selectionEnd = sRegex.lastIndex + tRegex.lastIndex;
|
|
11698
|
-
inputEl.setSelectionRange(selectionEnd, selectionEnd);
|
|
11699
|
-
} else if (newLength === currentLength) {
|
|
11700
|
-
if (operation === "insert" || operation === "delete-back-single") {
|
|
11701
|
-
let newSelectionEnd = selectionEnd;
|
|
11702
|
-
if (insertedValueStr === "0") {
|
|
11703
|
-
newSelectionEnd = selectionEnd + 1;
|
|
11704
|
-
} else {
|
|
11705
|
-
newSelectionEnd = newSelectionEnd + Number(isDecimalSign(value2) || isDecimalSign(insertedValueStr));
|
|
11706
|
-
}
|
|
11707
|
-
inputEl.setSelectionRange(newSelectionEnd, newSelectionEnd);
|
|
11708
|
-
} else if (operation === "delete-single") {
|
|
11709
|
-
inputEl.setSelectionRange(selectionEnd - 1, selectionEnd - 1);
|
|
11710
|
-
} else if (operation === "delete-range" || operation === "spin") {
|
|
11711
|
-
inputEl.setSelectionRange(selectionEnd, selectionEnd);
|
|
11712
|
-
}
|
|
11713
|
-
} else if (operation === "delete-back-single") {
|
|
11714
|
-
const prevChar = inputValue.charAt(selectionEnd - 1);
|
|
11715
|
-
const nextChar = inputValue.charAt(selectionEnd);
|
|
11716
|
-
const diff = currentLength - newLength;
|
|
11717
|
-
const isGroupChar = _group.current.test(nextChar);
|
|
11718
|
-
if (isGroupChar && diff === 1) {
|
|
11719
|
-
selectionEnd = selectionEnd + 1;
|
|
11720
|
-
} else if (!isGroupChar && isNumeralChar(prevChar)) {
|
|
11721
|
-
selectionEnd = selectionEnd + (-1 * diff + 1);
|
|
11722
|
-
}
|
|
11723
|
-
_group.current.lastIndex = 0;
|
|
11724
|
-
inputEl.setSelectionRange(selectionEnd, selectionEnd);
|
|
11725
|
-
} else if (inputValue === "-" && operation === "insert") {
|
|
11726
|
-
inputEl.setSelectionRange(0, 0);
|
|
11727
|
-
const idx = initCursor();
|
|
11728
|
-
const end = idx + insertedValueStr.length + 1;
|
|
11729
|
-
inputEl.setSelectionRange(end, end);
|
|
11730
|
-
} else {
|
|
11731
|
-
selectionEnd = selectionEnd + (newLength - currentLength);
|
|
11732
|
-
inputEl.setSelectionRange(selectionEnd, selectionEnd);
|
|
11436
|
+
if (props.onChange && event) {
|
|
11437
|
+
props.onChange({ originalEvent: event, value: value2 });
|
|
11733
11438
|
}
|
|
11734
|
-
}
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
const
|
|
11738
|
-
const
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
inputEl.value = formatted;
|
|
11745
|
-
inputEl.setAttribute("aria-valuenow", evaluated == null ? "" : String(evaluated));
|
|
11746
|
-
}
|
|
11747
|
-
};
|
|
11748
|
-
const isValueChanged = (currentValue, newValue) => {
|
|
11749
|
-
if (newValue == null && currentValue != null) return true;
|
|
11750
|
-
if (newValue != null) {
|
|
11751
|
-
const parsedCurrent = typeof currentValue === "string" ? parseValue(currentValue) : null;
|
|
11752
|
-
return newValue !== parsedCurrent;
|
|
11753
|
-
}
|
|
11754
|
-
return false;
|
|
11755
|
-
};
|
|
11756
|
-
const updateValue = (event, valueStr, insertedValueStr, operation) => {
|
|
11757
|
-
const inputEl = inputRef.current;
|
|
11758
|
-
if (!inputEl) return;
|
|
11759
|
-
const currentValue = inputEl.value;
|
|
11760
|
-
if (valueStr != null) {
|
|
11761
|
-
const parsed = parseValue(valueStr);
|
|
11762
|
-
evaluateEmpty(parsed);
|
|
11763
|
-
const limited = validateValueByLimit(parsed);
|
|
11764
|
-
updateInput(limited, insertedValueStr, operation, valueStr);
|
|
11765
|
-
if (event && typeof currentValue === "string" && typeof limited === "number" && isValueChanged(currentValue, limited)) {
|
|
11766
|
-
handleOnChange(event, currentValue, limited);
|
|
11439
|
+
},
|
|
11440
|
+
[props]
|
|
11441
|
+
);
|
|
11442
|
+
const setCaret = (pos) => {
|
|
11443
|
+
const el = inputRef.current;
|
|
11444
|
+
if (!el) return;
|
|
11445
|
+
queueMicrotask(() => {
|
|
11446
|
+
try {
|
|
11447
|
+
el.setSelectionRange(pos, pos);
|
|
11448
|
+
} catch {
|
|
11767
11449
|
}
|
|
11768
|
-
|
|
11769
|
-
}
|
|
11770
|
-
};
|
|
11771
|
-
const spin = (event, dir) => {
|
|
11772
|
-
var _a2, _b2;
|
|
11773
|
-
const inputEl = inputRef.current;
|
|
11774
|
-
if (!inputEl) return;
|
|
11775
|
-
const step = ((_a2 = props.step) != null ? _a2 : 1) * dir;
|
|
11776
|
-
const currentValue = (_b2 = parseValue(inputEl.value)) != null ? _b2 : 0;
|
|
11777
|
-
const newValue = validateValue(addWithPrecision(currentValue, step));
|
|
11778
|
-
if (newValue == null) return;
|
|
11779
|
-
if (props.maxLength && props.maxLength < formatValue(newValue).length) {
|
|
11780
|
-
return;
|
|
11781
|
-
}
|
|
11782
|
-
handleOnChange(event, inputEl.value, newValue);
|
|
11783
|
-
updateInput(newValue, null, "spin");
|
|
11784
|
-
updateModel(event, newValue);
|
|
11450
|
+
});
|
|
11785
11451
|
};
|
|
11786
|
-
const
|
|
11787
|
-
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
11791
|
-
|
|
11792
|
-
|
|
11793
|
-
|
|
11794
|
-
|
|
11795
|
-
|
|
11796
|
-
|
|
11797
|
-
|
|
11798
|
-
|
|
11799
|
-
|
|
11800
|
-
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
|
|
11807
|
-
|
|
11808
|
-
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
|
|
11813
|
-
|
|
11814
|
-
|
|
11815
|
-
|
|
11816
|
-
|
|
11817
|
-
|
|
11818
|
-
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
|
|
11822
|
-
|
|
11823
|
-
|
|
11824
|
-
|
|
11825
|
-
}
|
|
11826
|
-
}
|
|
11827
|
-
} else {
|
|
11828
|
-
const operation = selectionStart !== selectionEnd ? "range-insert" : "insert";
|
|
11829
|
-
if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
|
|
11830
|
-
if (selectionStart + text.length - (decimalCharIndex + 1) <= maxFractionDigits) {
|
|
11831
|
-
const charIndex = currencyCharIndex >= selectionStart ? currencyCharIndex - 1 : suffixCharIndex >= selectionStart ? suffixCharIndex : inputValue.length;
|
|
11832
|
-
newValueStr = inputValue.slice(0, selectionStart) + text + inputValue.slice(selectionStart + text.length, charIndex) + inputValue.slice(charIndex);
|
|
11833
|
-
updateValue(event, newValueStr, text, operation);
|
|
11834
|
-
}
|
|
11835
|
-
} else {
|
|
11836
|
-
newValueStr = insertText(inputValue, text, selectionStart, selectionEnd);
|
|
11837
|
-
updateValue(event, newValueStr, text, operation);
|
|
11452
|
+
const formatFromModel = React74__namespace.useCallback(
|
|
11453
|
+
(n3) => {
|
|
11454
|
+
if (n3 == null) return "";
|
|
11455
|
+
if (!props.format) return toEditableFromNumber(n3);
|
|
11456
|
+
const formatted = formatDisplayNumber(
|
|
11457
|
+
n3,
|
|
11458
|
+
locale,
|
|
11459
|
+
fmtOptions,
|
|
11460
|
+
props.prefix,
|
|
11461
|
+
props.suffix
|
|
11462
|
+
);
|
|
11463
|
+
return formatted;
|
|
11464
|
+
},
|
|
11465
|
+
[
|
|
11466
|
+
props.format,
|
|
11467
|
+
props.prefix,
|
|
11468
|
+
props.suffix,
|
|
11469
|
+
locale,
|
|
11470
|
+
fmtOptions,
|
|
11471
|
+
toEditableFromNumber
|
|
11472
|
+
]
|
|
11473
|
+
);
|
|
11474
|
+
const getModelFromDisplay = React74__namespace.useCallback(
|
|
11475
|
+
(text) => {
|
|
11476
|
+
const stripped = stripAffixes(text, props.prefix, props.suffix);
|
|
11477
|
+
const withoutGroup = stripGrouping(stripped, locale);
|
|
11478
|
+
const candidate = decimalSep !== "." ? withoutGroup.replace(".", decimalSep) : withoutGroup;
|
|
11479
|
+
const n3 = parseEditable(candidate, locale, decimalSep);
|
|
11480
|
+
if (n3 == null) return null;
|
|
11481
|
+
const clamped = clampModel(n3);
|
|
11482
|
+
return clamped;
|
|
11483
|
+
},
|
|
11484
|
+
[props.prefix, props.suffix, locale, decimalSep, clampModel]
|
|
11485
|
+
);
|
|
11486
|
+
const syncFromPropsValue = React74__namespace.useCallback(
|
|
11487
|
+
(v2) => {
|
|
11488
|
+
if (v2 == null) {
|
|
11489
|
+
setDisplay("");
|
|
11490
|
+
return;
|
|
11838
11491
|
}
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11492
|
+
const clamped = clampModel(v2);
|
|
11493
|
+
setDisplay(
|
|
11494
|
+
focused ? toEditableFromNumber(clamped) : formatFromModel(clamped)
|
|
11495
|
+
);
|
|
11496
|
+
},
|
|
11497
|
+
[clampModel, focused, toEditableFromNumber, formatFromModel]
|
|
11498
|
+
);
|
|
11499
|
+
React74__namespace.useEffect(() => {
|
|
11842
11500
|
var _a2;
|
|
11843
|
-
|
|
11844
|
-
|
|
11845
|
-
|
|
11846
|
-
let inputValue = inputEl.value;
|
|
11847
|
-
const valueLength = inputValue.length;
|
|
11848
|
-
let index = null;
|
|
11849
|
-
const prefixLength = (prefixChar.current || "").length;
|
|
11850
|
-
inputValue = inputValue.replace(_prefix.current, "");
|
|
11851
|
-
selectionStart = selectionStart - prefixLength;
|
|
11852
|
-
let ch = inputValue.charAt(selectionStart);
|
|
11853
|
-
if (isNumeralChar(ch)) {
|
|
11854
|
-
return selectionStart + prefixLength;
|
|
11855
|
-
}
|
|
11856
|
-
let i3 = selectionStart - 1;
|
|
11857
|
-
while (i3 >= 0) {
|
|
11858
|
-
ch = inputValue.charAt(i3);
|
|
11859
|
-
if (isNumeralChar(ch)) {
|
|
11860
|
-
index = i3 + prefixLength;
|
|
11861
|
-
break;
|
|
11862
|
-
}
|
|
11863
|
-
i3--;
|
|
11864
|
-
}
|
|
11865
|
-
if (index != null) {
|
|
11866
|
-
inputEl.setSelectionRange(index + 1, index + 1);
|
|
11867
|
-
} else {
|
|
11868
|
-
i3 = selectionStart;
|
|
11869
|
-
while (i3 < valueLength) {
|
|
11870
|
-
ch = inputValue.charAt(i3);
|
|
11871
|
-
if (isNumeralChar(ch)) {
|
|
11872
|
-
index = i3 + prefixLength;
|
|
11873
|
-
break;
|
|
11874
|
-
}
|
|
11875
|
-
i3++;
|
|
11876
|
-
}
|
|
11877
|
-
if (index != null) {
|
|
11878
|
-
inputEl.setSelectionRange(index, index);
|
|
11879
|
-
}
|
|
11880
|
-
}
|
|
11881
|
-
return index != null ? index : 0;
|
|
11882
|
-
};
|
|
11883
|
-
const onInputPointerDown = () => {
|
|
11884
|
-
isFocusedByClick.current = true;
|
|
11885
|
-
};
|
|
11886
|
-
const onInputClick = () => {
|
|
11887
|
-
initCursor();
|
|
11888
|
-
};
|
|
11889
|
-
const onInput = (event) => {
|
|
11890
|
-
if (props.disabled || props.readOnly) return;
|
|
11891
|
-
if (utilsIsSpecialChar.current) {
|
|
11892
|
-
event.currentTarget.value = lastValue.current;
|
|
11893
|
-
utilsIsSpecialChar.current = false;
|
|
11894
|
-
}
|
|
11895
|
-
};
|
|
11896
|
-
const utilsIsSpecialChar = React74__namespace.useRef(false);
|
|
11897
|
-
const onInputAndroidKey = (event) => {
|
|
11501
|
+
syncFromPropsValue((_a2 = props.value) != null ? _a2 : null);
|
|
11502
|
+
}, []);
|
|
11503
|
+
React74__namespace.useEffect(() => {
|
|
11898
11504
|
var _a2;
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
const code = event.which || event.keyCode;
|
|
11904
|
-
if (code !== 13) {
|
|
11905
|
-
event.preventDefault();
|
|
11906
|
-
}
|
|
11907
|
-
const ch = String.fromCharCode(code);
|
|
11908
|
-
const decimal = isDecimalSign(ch);
|
|
11909
|
-
const minus = isMinusSign(ch);
|
|
11910
|
-
if (code >= 48 && code <= 57 || minus || decimal) {
|
|
11911
|
-
insert(event, ch, { isDecimalSign: decimal, isMinusSign: minus });
|
|
11912
|
-
} else {
|
|
11913
|
-
const inputVal = event.target.value;
|
|
11914
|
-
updateValue(event, inputVal, null, "delete-single");
|
|
11915
|
-
}
|
|
11916
|
-
};
|
|
11917
|
-
const onInputKeyDown = (event) => {
|
|
11918
|
-
var _a2, _b2, _c;
|
|
11919
|
-
if (props.disabled || props.readOnly) return;
|
|
11920
|
-
if (event.altKey || event.ctrlKey || event.metaKey) {
|
|
11921
|
-
if (event.key.toLowerCase() === "x" && (event.ctrlKey || event.metaKey)) {
|
|
11922
|
-
utilsIsSpecialChar.current = false;
|
|
11923
|
-
} else {
|
|
11924
|
-
utilsIsSpecialChar.current = true;
|
|
11925
|
-
}
|
|
11926
|
-
return;
|
|
11927
|
-
}
|
|
11928
|
-
(_a2 = props.onKeyDown) == null ? void 0 : _a2.call(props, event);
|
|
11929
|
-
if (event.defaultPrevented) return;
|
|
11930
|
-
const inputEl = event.currentTarget;
|
|
11931
|
-
lastValue.current = inputEl.value;
|
|
11932
|
-
const isAndroid2 = /Android/i.test(navigator.userAgent);
|
|
11933
|
-
if (isAndroid2) return;
|
|
11934
|
-
let selectionStart = (_b2 = inputEl.selectionStart) != null ? _b2 : 0;
|
|
11935
|
-
let selectionEnd = (_c = inputEl.selectionEnd) != null ? _c : 0;
|
|
11936
|
-
const inputValue = inputEl.value;
|
|
11937
|
-
let newValueStr = null;
|
|
11938
|
-
switch (event.code) {
|
|
11939
|
-
case "ArrowUp":
|
|
11940
|
-
spin(event, 1);
|
|
11941
|
-
event.preventDefault();
|
|
11942
|
-
break;
|
|
11943
|
-
case "ArrowDown":
|
|
11944
|
-
spin(event, -1);
|
|
11945
|
-
event.preventDefault();
|
|
11946
|
-
break;
|
|
11947
|
-
case "ArrowLeft": {
|
|
11948
|
-
const charPrev = inputValue.charAt(selectionStart - 1);
|
|
11949
|
-
if (!isNumeralChar(charPrev)) {
|
|
11950
|
-
event.preventDefault();
|
|
11951
|
-
}
|
|
11952
|
-
break;
|
|
11953
|
-
}
|
|
11954
|
-
case "ArrowRight": {
|
|
11955
|
-
const charNext = inputValue.charAt(selectionStart);
|
|
11956
|
-
if (!isNumeralChar(charNext)) {
|
|
11957
|
-
event.preventDefault();
|
|
11958
|
-
}
|
|
11959
|
-
break;
|
|
11960
|
-
}
|
|
11961
|
-
case "Tab":
|
|
11962
|
-
case "Enter":
|
|
11963
|
-
case "NumpadEnter": {
|
|
11964
|
-
const parsedVal = validateValue(parseValue(inputValue));
|
|
11965
|
-
inputRef.current.value = formatValue(parsedVal);
|
|
11966
|
-
inputRef.current.setAttribute("aria-valuenow", parsedVal == null ? "" : String(parsedVal));
|
|
11967
|
-
updateModel(event, parsedVal);
|
|
11968
|
-
break;
|
|
11969
|
-
}
|
|
11970
|
-
case "Backspace": {
|
|
11971
|
-
event.preventDefault();
|
|
11972
|
-
if (selectionStart === selectionEnd) {
|
|
11973
|
-
const deleteChar = inputValue.charAt(selectionStart - 1);
|
|
11974
|
-
if (isNumeralChar(deleteChar)) {
|
|
11975
|
-
const {
|
|
11976
|
-
decimalCharIndex,
|
|
11977
|
-
decimalCharIndexWithoutPrefix
|
|
11978
|
-
} = getDecimalCharIndexes(inputValue);
|
|
11979
|
-
const decimalLength = getDecimalLength(inputValue);
|
|
11980
|
-
if (_group.current.test(deleteChar)) {
|
|
11981
|
-
_group.current.lastIndex = 0;
|
|
11982
|
-
newValueStr = inputValue.slice(0, selectionStart - 2) + inputValue.slice(selectionStart - 1);
|
|
11983
|
-
} else if (_decimal.current.test(deleteChar)) {
|
|
11984
|
-
_decimal.current.lastIndex = 0;
|
|
11985
|
-
if (decimalLength) {
|
|
11986
|
-
inputRef.current.setSelectionRange(selectionStart - 1, selectionStart - 1);
|
|
11987
|
-
} else {
|
|
11988
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + inputValue.slice(selectionStart);
|
|
11989
|
-
}
|
|
11990
|
-
} else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
|
|
11991
|
-
const insertedText = isDecimalMode() && (props.minFractionDigits || 0) < decimalLength ? "" : "0";
|
|
11992
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + insertedText + inputValue.slice(selectionStart);
|
|
11993
|
-
} else if (decimalCharIndexWithoutPrefix === 1) {
|
|
11994
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + "0" + inputValue.slice(selectionStart);
|
|
11995
|
-
newValueStr = parseValue(newValueStr) > 0 ? newValueStr : "";
|
|
11996
|
-
} else {
|
|
11997
|
-
newValueStr = inputValue.slice(0, selectionStart - 1) + inputValue.slice(selectionStart);
|
|
11998
|
-
}
|
|
11999
|
-
} else if (_currency.current.test(deleteChar)) {
|
|
12000
|
-
const {
|
|
12001
|
-
minusCharIndex,
|
|
12002
|
-
currencyCharIndex
|
|
12003
|
-
} = getCharIndexes(inputValue);
|
|
12004
|
-
if (minusCharIndex === currencyCharIndex - 1) {
|
|
12005
|
-
newValueStr = inputValue.slice(0, minusCharIndex) + inputValue.slice(selectionStart);
|
|
12006
|
-
}
|
|
12007
|
-
}
|
|
12008
|
-
updateValue(event, newValueStr, null, "delete-single");
|
|
12009
|
-
} else {
|
|
12010
|
-
newValueStr = deleteRange(inputValue, selectionStart, selectionEnd);
|
|
12011
|
-
updateValue(event, newValueStr, null, "delete-range");
|
|
12012
|
-
}
|
|
12013
|
-
break;
|
|
12014
|
-
}
|
|
12015
|
-
case "Delete": {
|
|
12016
|
-
event.preventDefault();
|
|
12017
|
-
if (selectionStart === selectionEnd) {
|
|
12018
|
-
const deleteChar = inputValue.charAt(selectionStart);
|
|
12019
|
-
const {
|
|
12020
|
-
decimalCharIndex,
|
|
12021
|
-
decimalCharIndexWithoutPrefix
|
|
12022
|
-
} = getDecimalCharIndexes(inputValue);
|
|
12023
|
-
if (isNumeralChar(deleteChar)) {
|
|
12024
|
-
const decimalLength = getDecimalLength(inputValue);
|
|
12025
|
-
if (_group.current.test(deleteChar)) {
|
|
12026
|
-
_group.current.lastIndex = 0;
|
|
12027
|
-
newValueStr = inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 2);
|
|
12028
|
-
} else if (_decimal.current.test(deleteChar)) {
|
|
12029
|
-
_decimal.current.lastIndex = 0;
|
|
12030
|
-
if (decimalLength) {
|
|
12031
|
-
inputRef.current.setSelectionRange(selectionStart + 1, selectionStart + 1);
|
|
12032
|
-
} else {
|
|
12033
|
-
newValueStr = inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 1);
|
|
12034
|
-
}
|
|
12035
|
-
} else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
|
|
12036
|
-
const insertedText = isDecimalMode() && (props.minFractionDigits || 0) < decimalLength ? "" : "0";
|
|
12037
|
-
newValueStr = inputValue.slice(0, selectionStart) + insertedText + inputValue.slice(selectionStart + 1);
|
|
12038
|
-
} else if (decimalCharIndexWithoutPrefix === 1) {
|
|
12039
|
-
newValueStr = inputValue.slice(0, selectionStart) + "0" + inputValue.slice(selectionStart + 1);
|
|
12040
|
-
newValueStr = parseValue(newValueStr) > 0 ? newValueStr : "";
|
|
12041
|
-
} else {
|
|
12042
|
-
newValueStr = inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 1);
|
|
12043
|
-
}
|
|
12044
|
-
}
|
|
12045
|
-
updateValue(event, newValueStr, null, "delete-back-single");
|
|
12046
|
-
} else {
|
|
12047
|
-
newValueStr = deleteRange(inputValue, selectionStart, selectionEnd);
|
|
12048
|
-
updateValue(event, newValueStr, null, "delete-range");
|
|
12049
|
-
}
|
|
12050
|
-
break;
|
|
12051
|
-
}
|
|
12052
|
-
case "End":
|
|
12053
|
-
event.preventDefault();
|
|
12054
|
-
if (props.max != null) {
|
|
12055
|
-
updateModel(event, props.max);
|
|
12056
|
-
updateInputValue(props.max);
|
|
12057
|
-
}
|
|
12058
|
-
break;
|
|
12059
|
-
case "Home":
|
|
12060
|
-
event.preventDefault();
|
|
12061
|
-
if (props.min != null) {
|
|
12062
|
-
updateModel(event, props.min);
|
|
12063
|
-
updateInputValue(props.min);
|
|
12064
|
-
}
|
|
12065
|
-
break;
|
|
12066
|
-
default: {
|
|
12067
|
-
event.preventDefault();
|
|
12068
|
-
let ch = event.key;
|
|
12069
|
-
if (!ch) break;
|
|
12070
|
-
if (ch === ".") {
|
|
12071
|
-
ch = _decimalSeparator.current;
|
|
12072
|
-
}
|
|
12073
|
-
const decimal = isDecimalSign(ch);
|
|
12074
|
-
const minus = isMinusSign(ch);
|
|
12075
|
-
if (ch >= "0" && ch <= "9" || minus || decimal) {
|
|
12076
|
-
insert(event, ch, { isDecimalSign: decimal, isMinusSign: minus });
|
|
12077
|
-
}
|
|
12078
|
-
break;
|
|
12079
|
-
}
|
|
12080
|
-
}
|
|
12081
|
-
};
|
|
12082
|
-
const onPaste = (event) => {
|
|
12083
|
-
event.preventDefault();
|
|
12084
|
-
if (props.disabled || props.readOnly) return;
|
|
12085
|
-
const data = (event.clipboardData || window.clipboardData).getData("Text");
|
|
12086
|
-
if (!data) return;
|
|
12087
|
-
const filteredData = parseValue(data);
|
|
12088
|
-
if (filteredData != null) {
|
|
12089
|
-
if (typeof filteredData === "number" && isFloat(filteredData)) {
|
|
12090
|
-
const formatted = formatValue(filteredData);
|
|
12091
|
-
if (inputRef.current) {
|
|
12092
|
-
inputRef.current.value = formatted;
|
|
12093
|
-
}
|
|
12094
|
-
updateModel(event, filteredData);
|
|
12095
|
-
} else {
|
|
12096
|
-
insert(event, String(filteredData));
|
|
12097
|
-
}
|
|
12098
|
-
}
|
|
12099
|
-
};
|
|
12100
|
-
const onInputFocus = (event) => {
|
|
11505
|
+
if (focused) return;
|
|
11506
|
+
syncFromPropsValue((_a2 = props.value) != null ? _a2 : null);
|
|
11507
|
+
}, [props.value, focused, syncFromPropsValue]);
|
|
11508
|
+
const onFocus = (e4) => {
|
|
12101
11509
|
var _a2;
|
|
12102
|
-
|
|
12103
|
-
(_a2 = props.onFocus) == null ? void 0 : _a2.call(props,
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12108
|
-
|
|
12109
|
-
|
|
12110
|
-
|
|
11510
|
+
setFocused(true);
|
|
11511
|
+
(_a2 = props.onFocus) == null ? void 0 : _a2.call(props, e4);
|
|
11512
|
+
const model = isFiniteNumber(props.value) ? clampModel(props.value) : getModelFromDisplay(display);
|
|
11513
|
+
const editable = model == null ? stripAffixes(display, props.prefix, props.suffix) : toEditableFromNumber(model);
|
|
11514
|
+
const normalized = normalizeEditable(
|
|
11515
|
+
editable,
|
|
11516
|
+
locale,
|
|
11517
|
+
decimalSep,
|
|
11518
|
+
allowMinus
|
|
11519
|
+
);
|
|
11520
|
+
setDisplay(normalized);
|
|
11521
|
+
queueMicrotask(() => {
|
|
11522
|
+
var _a3, _b;
|
|
11523
|
+
setCaret(((_b = (_a3 = inputRef.current) == null ? void 0 : _a3.value) != null ? _b : "").length);
|
|
11524
|
+
});
|
|
12111
11525
|
};
|
|
12112
|
-
const
|
|
12113
|
-
var _a2,
|
|
12114
|
-
|
|
12115
|
-
|
|
12116
|
-
|
|
12117
|
-
|
|
12118
|
-
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
11526
|
+
const onBlur = (e4) => {
|
|
11527
|
+
var _a2, _b;
|
|
11528
|
+
setFocused(false);
|
|
11529
|
+
const el = e4.currentTarget;
|
|
11530
|
+
const raw = stripAffixes(el.value, props.prefix, props.suffix);
|
|
11531
|
+
const normalized = normalizeEditable(
|
|
11532
|
+
raw,
|
|
11533
|
+
locale,
|
|
11534
|
+
decimalSep,
|
|
11535
|
+
allowMinus
|
|
11536
|
+
);
|
|
11537
|
+
const parsed = parseEditable(normalized, locale, decimalSep);
|
|
11538
|
+
let model = parsed == null ? null : clampModel(parsed);
|
|
11539
|
+
if (model == null && props.allowEmpty === false) {
|
|
11540
|
+
const fallback = (_a2 = props.min) != null ? _a2 : 0;
|
|
11541
|
+
model = clampModel(fallback);
|
|
11542
|
+
}
|
|
11543
|
+
setDisplay(formatFromModel(model));
|
|
11544
|
+
emit(e4, model);
|
|
11545
|
+
(_b = props.onBlur) == null ? void 0 : _b.call(props, e4);
|
|
12125
11546
|
};
|
|
12126
|
-
const
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
const
|
|
12130
|
-
|
|
12131
|
-
|
|
11547
|
+
const onChangeText = (e4) => {
|
|
11548
|
+
var _a2, _b;
|
|
11549
|
+
if (props.disabled || props.readOnly) return;
|
|
11550
|
+
const el = e4.currentTarget;
|
|
11551
|
+
const caretBefore = (_a2 = el.selectionStart) != null ? _a2 : el.value.length;
|
|
11552
|
+
const stripped = stripAffixes(el.value, props.prefix, props.suffix);
|
|
11553
|
+
let next = normalizeEditable(
|
|
11554
|
+
stripped,
|
|
11555
|
+
locale,
|
|
11556
|
+
decimalSep,
|
|
11557
|
+
allowMinus
|
|
11558
|
+
);
|
|
11559
|
+
const fracLimit = props.maxFractionDigits;
|
|
11560
|
+
if (fracLimit != null) {
|
|
11561
|
+
const applied = applyFractionLimitReplace(
|
|
11562
|
+
next,
|
|
11563
|
+
display,
|
|
11564
|
+
locale,
|
|
11565
|
+
decimalSep,
|
|
11566
|
+
fracLimit,
|
|
11567
|
+
el
|
|
11568
|
+
);
|
|
11569
|
+
next = applied.text;
|
|
11570
|
+
setDisplay(next);
|
|
11571
|
+
setCaret(applied.caret);
|
|
11572
|
+
} else {
|
|
11573
|
+
setDisplay(next);
|
|
11574
|
+
setCaret(caretBefore);
|
|
12132
11575
|
}
|
|
11576
|
+
const parsed = parseEditable(next, locale, decimalSep);
|
|
11577
|
+
const model = parsed == null ? null : clampModel(parsed);
|
|
11578
|
+
const finalModel = model == null && props.allowEmpty === false ? clampModel((_b = props.min) != null ? _b : 0) : model;
|
|
11579
|
+
emit(e4, finalModel);
|
|
12133
11580
|
};
|
|
12134
|
-
|
|
12135
|
-
React74__namespace.useEffect(() => {
|
|
12136
|
-
if (props.inputRef) {
|
|
12137
|
-
if (typeof props.inputRef === "function") {
|
|
12138
|
-
props.inputRef(inputRef.current);
|
|
12139
|
-
} else {
|
|
12140
|
-
props.inputRef.current = inputRef.current;
|
|
12141
|
-
}
|
|
12142
|
-
}
|
|
12143
|
-
}, [props.inputRef]);
|
|
12144
|
-
React74__namespace.useEffect(
|
|
12145
|
-
() => () => {
|
|
12146
|
-
clearTimer();
|
|
12147
|
-
},
|
|
12148
|
-
[]
|
|
12149
|
-
);
|
|
12150
|
-
React74__namespace.useEffect(() => {
|
|
12151
|
-
constructParser();
|
|
12152
|
-
const newValue = validateValue(props.value);
|
|
12153
|
-
if (props.value != null && props.value !== newValue) {
|
|
12154
|
-
updateModel(null, newValue);
|
|
12155
|
-
}
|
|
12156
|
-
}, []);
|
|
12157
|
-
React74__namespace.useEffect(() => {
|
|
12158
|
-
constructParser();
|
|
12159
|
-
changeValue();
|
|
12160
|
-
}, [
|
|
12161
|
-
_locale,
|
|
12162
|
-
props.locale,
|
|
12163
|
-
props.localeMatcher,
|
|
12164
|
-
props.mode,
|
|
12165
|
-
props.currency,
|
|
12166
|
-
props.currencyDisplay,
|
|
12167
|
-
props.useGrouping,
|
|
12168
|
-
props.minFractionDigits,
|
|
12169
|
-
props.maxFractionDigits,
|
|
12170
|
-
props.suffix,
|
|
12171
|
-
props.prefix
|
|
12172
|
-
]);
|
|
12173
|
-
React74__namespace.useEffect(() => {
|
|
12174
|
-
changeValue();
|
|
12175
|
-
}, [props.value]);
|
|
12176
|
-
React74__namespace.useEffect(() => {
|
|
12177
|
-
if (props.disabled) clearTimer();
|
|
12178
|
-
}, [props.disabled]);
|
|
11581
|
+
const inputMode = props.inputMode || (props.mode === "decimal" && props.maxFractionDigits == null && props.minFractionDigits == null ? "numeric" : "decimal");
|
|
12179
11582
|
const inputClassName = [
|
|
12180
11583
|
props.inputClassName,
|
|
12181
11584
|
props.invalid ? "p-invalid" : void 0
|
|
12182
11585
|
].filter(Boolean).join(" ");
|
|
12183
|
-
const valueToRender = formattedValue((_a = props.value) != null ? _a : null);
|
|
12184
11586
|
const {
|
|
12185
11587
|
inputId,
|
|
12186
11588
|
inputStyle,
|
|
@@ -12191,34 +11593,32 @@ var InputNumber = React74__namespace.memo(
|
|
|
12191
11593
|
value,
|
|
12192
11594
|
icon,
|
|
12193
11595
|
iconGap,
|
|
12194
|
-
// anything you *don’t* want to pass down can be pulled out here too
|
|
12195
|
-
// e.g. internal-only props
|
|
12196
11596
|
...passThroughProps
|
|
12197
|
-
// everything else goes straight to ShadcnTextVariant
|
|
12198
11597
|
} = props;
|
|
12199
11598
|
return (
|
|
12200
11599
|
//@ts-ignore
|
|
12201
11600
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12202
11601
|
Input,
|
|
12203
11602
|
{
|
|
12204
|
-
|
|
12205
|
-
|
|
11603
|
+
ref: (node) => {
|
|
11604
|
+
inputRef.current = node;
|
|
11605
|
+
if (typeof props.inputRef === "function")
|
|
11606
|
+
props.inputRef(node);
|
|
11607
|
+
else if (props.inputRef && typeof props.inputRef === "object") {
|
|
11608
|
+
props.inputRef.current = node;
|
|
11609
|
+
}
|
|
11610
|
+
},
|
|
12206
11611
|
...passThroughProps,
|
|
12207
11612
|
id: inputId != null ? inputId : props.id,
|
|
12208
11613
|
style: inputStyle != null ? inputStyle : props.style,
|
|
12209
11614
|
role: "spinbutton",
|
|
12210
11615
|
className: inputClassName || props.className,
|
|
12211
|
-
|
|
12212
|
-
type: (_b = props.type) != null ? _b : "text",
|
|
11616
|
+
type: (_a = props.type) != null ? _a : "text",
|
|
12213
11617
|
inputMode,
|
|
12214
|
-
|
|
12215
|
-
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
onPointerDown: onInputPointerDown,
|
|
12219
|
-
onBlur: onInputBlur,
|
|
12220
|
-
onFocus: onInputFocus,
|
|
12221
|
-
onPaste,
|
|
11618
|
+
value: display,
|
|
11619
|
+
onFocus,
|
|
11620
|
+
onBlur,
|
|
11621
|
+
onChange: onChangeText,
|
|
12222
11622
|
leadingControl,
|
|
12223
11623
|
trailingControl,
|
|
12224
11624
|
leadingControlClassName,
|
|
@@ -20619,17 +20019,21 @@ function normalizeItems(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
20619
20019
|
label: mappers.getLabel(item, index),
|
|
20620
20020
|
description: mappers.getDescription ? mappers.getDescription(item, index) : void 0,
|
|
20621
20021
|
disabled: mappers.isDisabled ? mappers.isDisabled(item, index) : false,
|
|
20622
|
-
key: mappers.getKey ? mappers.getKey(item, index) : index
|
|
20022
|
+
key: mappers.getKey ? mappers.getKey(item, index) : index,
|
|
20023
|
+
raw: item
|
|
20623
20024
|
}));
|
|
20624
20025
|
}
|
|
20625
20026
|
if (optionValueKey || optionLabelKey) {
|
|
20626
20027
|
return items.map((item, index) => {
|
|
20627
|
-
return
|
|
20628
|
-
|
|
20629
|
-
|
|
20630
|
-
|
|
20631
|
-
|
|
20632
|
-
|
|
20028
|
+
return {
|
|
20029
|
+
...globalNormalizeCheckBasedOptions(
|
|
20030
|
+
item,
|
|
20031
|
+
index,
|
|
20032
|
+
optionLabelKey,
|
|
20033
|
+
optionValueKey
|
|
20034
|
+
),
|
|
20035
|
+
raw: item
|
|
20036
|
+
};
|
|
20633
20037
|
});
|
|
20634
20038
|
}
|
|
20635
20039
|
return items.map((item, index) => {
|
|
@@ -20640,7 +20044,8 @@ function normalizeItems(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
20640
20044
|
label: String(item),
|
|
20641
20045
|
description: void 0,
|
|
20642
20046
|
disabled: false,
|
|
20643
|
-
key: index
|
|
20047
|
+
key: index,
|
|
20048
|
+
raw: item
|
|
20644
20049
|
};
|
|
20645
20050
|
}
|
|
20646
20051
|
return item;
|
|
@@ -20703,11 +20108,12 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
20703
20108
|
return found ? String(found.value) : void 0;
|
|
20704
20109
|
}, [normalized, value]);
|
|
20705
20110
|
const handleSelect = React74__namespace.useCallback(
|
|
20706
|
-
(next) => {
|
|
20111
|
+
(next, selectedRaw) => {
|
|
20707
20112
|
if (!onValue || disabled) return;
|
|
20708
20113
|
const detail = {
|
|
20709
20114
|
source: "variant",
|
|
20710
|
-
raw: next,
|
|
20115
|
+
raw: selectedRaw != null ? selectedRaw : next,
|
|
20116
|
+
selectedOptions: [selectedRaw != null ? selectedRaw : next],
|
|
20711
20117
|
nativeEvent: void 0,
|
|
20712
20118
|
meta: void 0
|
|
20713
20119
|
};
|
|
@@ -20717,9 +20123,10 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
20717
20123
|
);
|
|
20718
20124
|
const handleRadioChange = React74__namespace.useCallback(
|
|
20719
20125
|
(raw) => {
|
|
20126
|
+
var _a;
|
|
20720
20127
|
const found = normalized.find((item) => String(item.value) === raw);
|
|
20721
20128
|
if (!found) return;
|
|
20722
|
-
handleSelect(found.value);
|
|
20129
|
+
handleSelect(found.value, (_a = found.raw) != null ? _a : found.value);
|
|
20723
20130
|
},
|
|
20724
20131
|
[normalized, handleSelect]
|
|
20725
20132
|
);
|
|
@@ -20965,7 +20372,8 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
20965
20372
|
description: mappers.getDescription ? mappers.getDescription(item, index) : void 0,
|
|
20966
20373
|
disabled: mappers.isDisabled ? mappers.isDisabled(item, index) : false,
|
|
20967
20374
|
key: mappers.getKey ? mappers.getKey(item, index) : index,
|
|
20968
|
-
tristate: mappers.getTristate ? mappers.getTristate(item, index) : void 0
|
|
20375
|
+
tristate: mappers.getTristate ? mappers.getTristate(item, index) : void 0,
|
|
20376
|
+
raw: item
|
|
20969
20377
|
}));
|
|
20970
20378
|
}
|
|
20971
20379
|
if (optionValueKey || optionLabelKey) {
|
|
@@ -20980,7 +20388,8 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
20980
20388
|
const tristate = anyItem.tristate;
|
|
20981
20389
|
return {
|
|
20982
20390
|
...normalised,
|
|
20983
|
-
tristate
|
|
20391
|
+
tristate,
|
|
20392
|
+
raw: item
|
|
20984
20393
|
};
|
|
20985
20394
|
});
|
|
20986
20395
|
}
|
|
@@ -20993,7 +20402,8 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
20993
20402
|
description: void 0,
|
|
20994
20403
|
disabled: false,
|
|
20995
20404
|
key: index,
|
|
20996
|
-
tristate: void 0
|
|
20405
|
+
tristate: void 0,
|
|
20406
|
+
raw: item
|
|
20997
20407
|
};
|
|
20998
20408
|
}
|
|
20999
20409
|
return item;
|
|
@@ -21004,7 +20414,17 @@ function isEqualValue2(a3, b2) {
|
|
|
21004
20414
|
}
|
|
21005
20415
|
function asGroupValue(value) {
|
|
21006
20416
|
if (!value) return void 0;
|
|
21007
|
-
if (Array.isArray(value))
|
|
20417
|
+
if (Array.isArray(value)) {
|
|
20418
|
+
if (value.length === 0) return void 0;
|
|
20419
|
+
const first = value[0];
|
|
20420
|
+
if (first && typeof first === "object" && "value" in first && "state" in first) {
|
|
20421
|
+
return value;
|
|
20422
|
+
}
|
|
20423
|
+
return value.map((item) => ({
|
|
20424
|
+
value: item,
|
|
20425
|
+
state: true
|
|
20426
|
+
}));
|
|
20427
|
+
}
|
|
21008
20428
|
if (typeof value == "object")
|
|
21009
20429
|
return Object.keys(value).map(
|
|
21010
20430
|
(key) => ({
|
|
@@ -21060,11 +20480,21 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21060
20480
|
} = props;
|
|
21061
20481
|
const hasError = !!error;
|
|
21062
20482
|
const isSingle = !!single;
|
|
20483
|
+
const normalized = React74__namespace.useMemo(
|
|
20484
|
+
() => normalizeItems2(
|
|
20485
|
+
items != null ? items : options,
|
|
20486
|
+
mappers,
|
|
20487
|
+
optionValue,
|
|
20488
|
+
optionLabel
|
|
20489
|
+
),
|
|
20490
|
+
[items, options, mappers, optionValue, optionLabel]
|
|
20491
|
+
);
|
|
21063
20492
|
if (isSingle) {
|
|
21064
20493
|
const singleVal = asSingleValue(value);
|
|
21065
20494
|
const effectiveTristate = !!tristateDefault;
|
|
21066
20495
|
const internalState = effectiveTristate ? singleVal != null ? singleVal : "none" : !!singleVal;
|
|
21067
20496
|
const handleSingleChange = (next) => {
|
|
20497
|
+
var _a;
|
|
21068
20498
|
if (!onValue || disabled) return;
|
|
21069
20499
|
let nextPublic;
|
|
21070
20500
|
if (effectiveTristate) {
|
|
@@ -21075,6 +20505,7 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21075
20505
|
const detail = {
|
|
21076
20506
|
source: "variant",
|
|
21077
20507
|
raw: nextPublic,
|
|
20508
|
+
selectedOptions: nextPublic === true ? normalized[0] ? [(_a = normalized[0].raw) != null ? _a : normalized[0].value] : [] : [],
|
|
21078
20509
|
nativeEvent: void 0,
|
|
21079
20510
|
meta: void 0
|
|
21080
20511
|
};
|
|
@@ -21133,15 +20564,6 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21133
20564
|
);
|
|
21134
20565
|
}
|
|
21135
20566
|
const groupValue = asGroupValue(value);
|
|
21136
|
-
const normalized = React74__namespace.useMemo(
|
|
21137
|
-
() => normalizeItems2(
|
|
21138
|
-
items != null ? items : options,
|
|
21139
|
-
mappers,
|
|
21140
|
-
optionValue,
|
|
21141
|
-
optionLabel
|
|
21142
|
-
),
|
|
21143
|
-
[items, options, mappers, optionValue, optionLabel]
|
|
21144
|
-
);
|
|
21145
20567
|
const {
|
|
21146
20568
|
groupStyle,
|
|
21147
20569
|
groupClasses,
|
|
@@ -21161,6 +20583,13 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21161
20583
|
labelTextSizeClass: labelTextSize2(size),
|
|
21162
20584
|
descriptionTextSizeClass: descriptionTextSize2(size)
|
|
21163
20585
|
});
|
|
20586
|
+
const hasAnyTristate = React74__namespace.useMemo(
|
|
20587
|
+
() => normalized.some((item) => {
|
|
20588
|
+
var _a, _b;
|
|
20589
|
+
return (_b = (_a = item.tristate) != null ? _a : tristateDefault) != null ? _b : false;
|
|
20590
|
+
}),
|
|
20591
|
+
[normalized, tristateDefault]
|
|
20592
|
+
);
|
|
21164
20593
|
const findEntryIndex = React74__namespace.useCallback(
|
|
21165
20594
|
(val) => {
|
|
21166
20595
|
if (!groupValue) return -1;
|
|
@@ -21233,14 +20662,28 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
21233
20662
|
const detail = {
|
|
21234
20663
|
source: "variant",
|
|
21235
20664
|
raw: nextList,
|
|
20665
|
+
selectedOptions: nextList.map(
|
|
20666
|
+
(entry) => {
|
|
20667
|
+
var _a, _b;
|
|
20668
|
+
return (_b = (_a = normalized.find(
|
|
20669
|
+
(item) => isEqualValue2(item.value, entry.value)
|
|
20670
|
+
)) == null ? void 0 : _a.raw) != null ? _b : entry.value;
|
|
20671
|
+
}
|
|
20672
|
+
),
|
|
21236
20673
|
nativeEvent: void 0,
|
|
21237
20674
|
meta: void 0
|
|
21238
20675
|
};
|
|
21239
|
-
|
|
21240
|
-
|
|
21241
|
-
|
|
20676
|
+
if (hasAnyTristate) {
|
|
20677
|
+
const value2 = {};
|
|
20678
|
+
nextList.forEach(
|
|
20679
|
+
(item) => value2[item.value] = item.state
|
|
20680
|
+
);
|
|
20681
|
+
onValue(value2, detail);
|
|
20682
|
+
return;
|
|
20683
|
+
}
|
|
20684
|
+
onValue(nextList.map((item) => item.value), detail);
|
|
21242
20685
|
},
|
|
21243
|
-
[onValue, disabled, groupValue]
|
|
20686
|
+
[onValue, disabled, groupValue, normalized, hasAnyTristate]
|
|
21244
20687
|
);
|
|
21245
20688
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21246
20689
|
"div",
|
|
@@ -21516,13 +20959,14 @@ var ShadcnSelectVariant = React74__namespace.forwardRef(function ShadcnSelectVar
|
|
|
21516
20959
|
);
|
|
21517
20960
|
const handleChange = React74__namespace.useCallback(
|
|
21518
20961
|
(rawKey) => {
|
|
21519
|
-
var _a2, _b2, _c;
|
|
20962
|
+
var _a2, _b2, _c, _d;
|
|
21520
20963
|
if (!onValue || rawKey === "") return;
|
|
21521
20964
|
const primitive = (_a2 = valueMap.get(rawKey)) != null ? _a2 : rawKey;
|
|
21522
20965
|
const item = (_b2 = items.find((it) => String(it.value) === String(primitive))) != null ? _b2 : null;
|
|
21523
20966
|
const detail = {
|
|
21524
20967
|
source: "variant",
|
|
21525
20968
|
raw: (_c = item == null ? void 0 : item.raw) != null ? _c : primitive,
|
|
20969
|
+
selectedOptions: [(_d = item == null ? void 0 : item.raw) != null ? _d : primitive],
|
|
21526
20970
|
nativeEvent: void 0,
|
|
21527
20971
|
meta: void 0
|
|
21528
20972
|
};
|
|
@@ -21624,6 +21068,7 @@ var ShadcnSelectVariant = React74__namespace.forwardRef(function ShadcnSelectVar
|
|
|
21624
21068
|
const detail = {
|
|
21625
21069
|
source: "variant",
|
|
21626
21070
|
raw: void 0,
|
|
21071
|
+
selectedOptions: [],
|
|
21627
21072
|
nativeEvent: void 0,
|
|
21628
21073
|
meta: { action: "clear" }
|
|
21629
21074
|
};
|
|
@@ -22258,7 +21703,12 @@ var ShadcnMultiSelectVariant = React74__namespace.forwardRef(function ShadcnMult
|
|
|
22258
21703
|
next = [...current, primitive];
|
|
22259
21704
|
}
|
|
22260
21705
|
const final = next.length ? next : void 0;
|
|
22261
|
-
const values = next == null ? void 0 : next.map(
|
|
21706
|
+
const values = next == null ? void 0 : next.map(
|
|
21707
|
+
(item) => {
|
|
21708
|
+
var _a2, _b;
|
|
21709
|
+
return (_b = (_a2 = keyedItems[item]) == null ? void 0 : _a2.raw) != null ? _b : item;
|
|
21710
|
+
}
|
|
21711
|
+
);
|
|
22262
21712
|
const detail = {
|
|
22263
21713
|
source: "variant",
|
|
22264
21714
|
raw: {
|
|
@@ -22267,12 +21717,13 @@ var ShadcnMultiSelectVariant = React74__namespace.forwardRef(function ShadcnMult
|
|
|
22267
21717
|
next: final,
|
|
22268
21718
|
values
|
|
22269
21719
|
},
|
|
21720
|
+
selectedOptions: values != null ? values : [],
|
|
22270
21721
|
nativeEvent: void 0,
|
|
22271
21722
|
meta: void 0
|
|
22272
21723
|
};
|
|
22273
21724
|
onValue(final, detail);
|
|
22274
21725
|
},
|
|
22275
|
-
[onValue, value, disabled, readOnly]
|
|
21726
|
+
[onValue, value, disabled, readOnly, keyedItems]
|
|
22276
21727
|
);
|
|
22277
21728
|
const handleSelectAll = React74__namespace.useCallback(() => {
|
|
22278
21729
|
if (!onValue || disabled || readOnly) return;
|
|
@@ -22288,7 +21739,10 @@ var ShadcnMultiSelectVariant = React74__namespace.forwardRef(function ShadcnMult
|
|
|
22288
21739
|
next = Array.from(merged);
|
|
22289
21740
|
}
|
|
22290
21741
|
const final = next.length ? next : void 0;
|
|
22291
|
-
const values = next.map((item) =>
|
|
21742
|
+
const values = next.map((item) => {
|
|
21743
|
+
var _a2, _b;
|
|
21744
|
+
return (_b = (_a2 = keyedItems[item]) == null ? void 0 : _a2.raw) != null ? _b : item;
|
|
21745
|
+
});
|
|
22292
21746
|
const detail = {
|
|
22293
21747
|
source: "variant",
|
|
22294
21748
|
raw: {
|
|
@@ -22296,6 +21750,7 @@ var ShadcnMultiSelectVariant = React74__namespace.forwardRef(function ShadcnMult
|
|
|
22296
21750
|
next: final,
|
|
22297
21751
|
values
|
|
22298
21752
|
},
|
|
21753
|
+
selectedOptions: values,
|
|
22299
21754
|
nativeEvent: void 0,
|
|
22300
21755
|
meta: {
|
|
22301
21756
|
allSelected: !currentlyAllSelected
|
|
@@ -22308,7 +21763,8 @@ var ShadcnMultiSelectVariant = React74__namespace.forwardRef(function ShadcnMult
|
|
|
22308
21763
|
disabled,
|
|
22309
21764
|
readOnly,
|
|
22310
21765
|
allSelectableValues,
|
|
22311
|
-
selectedValues
|
|
21766
|
+
selectedValues,
|
|
21767
|
+
keyedItems
|
|
22312
21768
|
]);
|
|
22313
21769
|
const handleClearAll = React74__namespace.useCallback(() => {
|
|
22314
21770
|
if (!onValue || disabled || readOnly) return;
|
|
@@ -22317,6 +21773,7 @@ var ShadcnMultiSelectVariant = React74__namespace.forwardRef(function ShadcnMult
|
|
|
22317
21773
|
raw: {
|
|
22318
21774
|
type: "clear"
|
|
22319
21775
|
},
|
|
21776
|
+
selectedOptions: [],
|
|
22320
21777
|
nativeEvent: void 0,
|
|
22321
21778
|
meta: void 0
|
|
22322
21779
|
};
|
|
@@ -22332,9 +21789,14 @@ var ShadcnMultiSelectVariant = React74__namespace.forwardRef(function ShadcnMult
|
|
|
22332
21789
|
selectedValues,
|
|
22333
21790
|
item.value
|
|
22334
21791
|
);
|
|
21792
|
+
const selectedOptions = (updated != null ? updated : []).map((value2) => {
|
|
21793
|
+
var _a2, _b;
|
|
21794
|
+
return (_b = (_a2 = keyedItems[value2]) == null ? void 0 : _a2.raw) != null ? _b : value2;
|
|
21795
|
+
});
|
|
22335
21796
|
const detail = {
|
|
22336
21797
|
source: "variant",
|
|
22337
21798
|
raw: item,
|
|
21799
|
+
selectedOptions,
|
|
22338
21800
|
nativeEvent: void 0,
|
|
22339
21801
|
meta: { action: "remove", removed: value }
|
|
22340
21802
|
};
|
|
@@ -24259,9 +23721,16 @@ var ShadcnTreeSelectVariant = React74__namespace.forwardRef(function ShadcnTreeS
|
|
|
24259
23721
|
setOpen(false);
|
|
24260
23722
|
}
|
|
24261
23723
|
const nextSelectedValues = Array.isArray(nextValue) ? nextValue : nextValue !== void 0 && nextValue !== null ? [nextValue] : [];
|
|
23724
|
+
const nextSelectedOptions = nextSelectedValues.map(
|
|
23725
|
+
(val) => {
|
|
23726
|
+
var _a, _b;
|
|
23727
|
+
return (_b = (_a = allNodesFlat.find((node) => node.value === val)) == null ? void 0 : _a.raw) != null ? _b : val;
|
|
23728
|
+
}
|
|
23729
|
+
);
|
|
24262
23730
|
const detail = {
|
|
24263
23731
|
source: "variant",
|
|
24264
23732
|
raw: item.raw,
|
|
23733
|
+
selectedOptions: nextSelectedOptions,
|
|
24265
23734
|
nativeEvent: void 0,
|
|
24266
23735
|
meta: {
|
|
24267
23736
|
toggled: item.value,
|
|
@@ -24276,7 +23745,8 @@ var ShadcnTreeSelectVariant = React74__namespace.forwardRef(function ShadcnTreeS
|
|
|
24276
23745
|
multiple,
|
|
24277
23746
|
selectedValues,
|
|
24278
23747
|
onValue,
|
|
24279
|
-
toggleExpanded
|
|
23748
|
+
toggleExpanded,
|
|
23749
|
+
allNodesFlat
|
|
24280
23750
|
]
|
|
24281
23751
|
);
|
|
24282
23752
|
const handleClear = React74__namespace.useCallback(() => {
|
|
@@ -24284,6 +23754,7 @@ var ShadcnTreeSelectVariant = React74__namespace.forwardRef(function ShadcnTreeS
|
|
|
24284
23754
|
const detail = {
|
|
24285
23755
|
source: "variant",
|
|
24286
23756
|
raw: void 0,
|
|
23757
|
+
selectedOptions: [],
|
|
24287
23758
|
nativeEvent: void 0,
|
|
24288
23759
|
meta: { action: "clear" }
|
|
24289
23760
|
};
|
|
@@ -26057,6 +25528,7 @@ var ShadcnToggleVariant3 = React74__namespace.forwardRef(function ShadcnToggleVa
|
|
|
26057
25528
|
source: "variant",
|
|
26058
25529
|
raw: rawSelection,
|
|
26059
25530
|
// original item(s)
|
|
25531
|
+
selectedOptions: Array.isArray(rawSelection) ? rawSelection : rawSelection === void 0 ? [] : [rawSelection],
|
|
26060
25532
|
nativeEvent: void 0,
|
|
26061
25533
|
meta: { action: "toggle" }
|
|
26062
25534
|
};
|
|
@@ -30836,7 +30308,7 @@ var ShadcnIconVariant = React74__namespace.forwardRef(function ShadcnIconVariant
|
|
|
30836
30308
|
PopoverContent,
|
|
30837
30309
|
{
|
|
30838
30310
|
className: cn(
|
|
30839
|
-
"w-(--radix-popover-trigger-width) p-0",
|
|
30311
|
+
"w-(--radix-popover-trigger-width) p-0 max-h-(--radix-popper-available-height)",
|
|
30840
30312
|
popoverClassName
|
|
30841
30313
|
),
|
|
30842
30314
|
align: "start",
|
|
@@ -31686,7 +31158,7 @@ var ShadcnImageIconVariant = React74__namespace.forwardRef(function ShadcnImageI
|
|
|
31686
31158
|
PopoverContent,
|
|
31687
31159
|
{
|
|
31688
31160
|
className: cn(
|
|
31689
|
-
"w-(--radix-popover-trigger-width) p-0",
|
|
31161
|
+
"w-(--radix-popover-trigger-width) p-0 max-h-(--radix-popper-available-height)",
|
|
31690
31162
|
popoverClassName
|
|
31691
31163
|
),
|
|
31692
31164
|
align: "start",
|