@timeax/form-palette 0.1.33 → 0.1.34
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/README.md +22 -10
- package/dist/extra.js +38 -16
- package/dist/extra.js.map +1 -1
- package/dist/extra.mjs +38 -16
- package/dist/extra.mjs.map +1 -1
- package/dist/index.js +38 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/extra.mjs
CHANGED
|
@@ -11233,6 +11233,9 @@ function clampToLimits(n3, min2, max2) {
|
|
|
11233
11233
|
function isFiniteNumber(n3) {
|
|
11234
11234
|
return typeof n3 === "number" && Number.isFinite(n3);
|
|
11235
11235
|
}
|
|
11236
|
+
function sanitizeNumberish(value) {
|
|
11237
|
+
return isFiniteNumber(value) ? value : null;
|
|
11238
|
+
}
|
|
11236
11239
|
function resolveLocale(explicit) {
|
|
11237
11240
|
if (explicit) return explicit;
|
|
11238
11241
|
if (typeof navigator !== "undefined" && navigator.language)
|
|
@@ -11267,6 +11270,7 @@ function parseEditable(editable, locale, decimalSep) {
|
|
|
11267
11270
|
return Number.isFinite(n3) ? n3 : null;
|
|
11268
11271
|
}
|
|
11269
11272
|
function formatDisplayNumber(n3, locale, opts, prefix, suffix) {
|
|
11273
|
+
if (!isFiniteNumber(n3)) return "";
|
|
11270
11274
|
const f2 = new Intl.NumberFormat(locale, opts).format(n3);
|
|
11271
11275
|
return `${prefix != null ? prefix : ""}${f2}${suffix != null ? suffix : ""}`;
|
|
11272
11276
|
}
|
|
@@ -11380,9 +11384,10 @@ var InputNumber = React74.memo(
|
|
|
11380
11384
|
const emit = React74.useCallback(
|
|
11381
11385
|
(event, value2) => {
|
|
11382
11386
|
var _a2, _b, _c;
|
|
11387
|
+
const safeValue = sanitizeNumberish(value2);
|
|
11383
11388
|
(_c = props.onValueChange) == null ? void 0 : _c.call(props, {
|
|
11384
11389
|
originalEvent: event,
|
|
11385
|
-
value:
|
|
11390
|
+
value: safeValue,
|
|
11386
11391
|
stopPropagation() {
|
|
11387
11392
|
event == null ? void 0 : event.stopPropagation();
|
|
11388
11393
|
},
|
|
@@ -11392,11 +11397,11 @@ var InputNumber = React74.memo(
|
|
|
11392
11397
|
target: {
|
|
11393
11398
|
name: (_a2 = props.name) != null ? _a2 : null,
|
|
11394
11399
|
id: (_b = props.id) != null ? _b : null,
|
|
11395
|
-
value:
|
|
11400
|
+
value: safeValue
|
|
11396
11401
|
}
|
|
11397
11402
|
});
|
|
11398
11403
|
if (props.onChange && event) {
|
|
11399
|
-
props.onChange({ originalEvent: event, value:
|
|
11404
|
+
props.onChange({ originalEvent: event, value: safeValue });
|
|
11400
11405
|
}
|
|
11401
11406
|
},
|
|
11402
11407
|
[props]
|
|
@@ -11413,10 +11418,11 @@ var InputNumber = React74.memo(
|
|
|
11413
11418
|
};
|
|
11414
11419
|
const formatFromModel = React74.useCallback(
|
|
11415
11420
|
(n3) => {
|
|
11416
|
-
|
|
11417
|
-
if (
|
|
11421
|
+
const safeNumber = sanitizeNumberish(n3);
|
|
11422
|
+
if (safeNumber == null) return "";
|
|
11423
|
+
if (!props.format) return toEditableFromNumber(safeNumber);
|
|
11418
11424
|
const formatted = formatDisplayNumber(
|
|
11419
|
-
|
|
11425
|
+
safeNumber,
|
|
11420
11426
|
locale,
|
|
11421
11427
|
fmtOptions,
|
|
11422
11428
|
props.prefix,
|
|
@@ -11447,11 +11453,12 @@ var InputNumber = React74.memo(
|
|
|
11447
11453
|
);
|
|
11448
11454
|
const syncFromPropsValue = React74.useCallback(
|
|
11449
11455
|
(v2) => {
|
|
11450
|
-
|
|
11456
|
+
const safeValue = sanitizeNumberish(v2);
|
|
11457
|
+
if (safeValue == null) {
|
|
11451
11458
|
setDisplay("");
|
|
11452
11459
|
return;
|
|
11453
11460
|
}
|
|
11454
|
-
const clamped = clampModel(
|
|
11461
|
+
const clamped = clampModel(safeValue);
|
|
11455
11462
|
setDisplay(
|
|
11456
11463
|
focused ? toEditableFromNumber(clamped) : formatFromModel(clamped)
|
|
11457
11464
|
);
|
|
@@ -12014,6 +12021,9 @@ var __iconNode37 = [
|
|
|
12014
12021
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
12015
12022
|
];
|
|
12016
12023
|
var X = createLucideIcon("x", __iconNode37);
|
|
12024
|
+
function sanitizeNumberish2(value) {
|
|
12025
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
12026
|
+
}
|
|
12017
12027
|
var ShadcnNumberVariant = React74__default.forwardRef(function ShadcnNumberVariant2(props, forwardedRef) {
|
|
12018
12028
|
const {
|
|
12019
12029
|
showButtons,
|
|
@@ -12034,11 +12044,12 @@ var ShadcnNumberVariant = React74__default.forwardRef(function ShadcnNumberVaria
|
|
|
12034
12044
|
} = rest;
|
|
12035
12045
|
const handleChange = React74__default.useCallback(
|
|
12036
12046
|
(e4) => {
|
|
12047
|
+
const safeValue = sanitizeNumberish2(e4.value);
|
|
12037
12048
|
if (onValueChange) {
|
|
12038
|
-
onValueChange(
|
|
12049
|
+
onValueChange(safeValue != null ? safeValue : void 0, {
|
|
12039
12050
|
source: "user",
|
|
12040
12051
|
nativeEvent: e4.originalEvent,
|
|
12041
|
-
raw:
|
|
12052
|
+
raw: safeValue
|
|
12042
12053
|
});
|
|
12043
12054
|
}
|
|
12044
12055
|
},
|
|
@@ -12046,21 +12057,21 @@ var ShadcnNumberVariant = React74__default.forwardRef(function ShadcnNumberVaria
|
|
|
12046
12057
|
);
|
|
12047
12058
|
const handleStep = React74__default.useCallback(
|
|
12048
12059
|
(direction, originalEvent) => {
|
|
12049
|
-
var _a;
|
|
12060
|
+
var _a, _b;
|
|
12050
12061
|
if (disabled) return;
|
|
12051
|
-
const current = value != null ?
|
|
12062
|
+
const current = (_a = sanitizeNumberish2(value)) != null ? _a : 0;
|
|
12052
12063
|
let next = current + direction * step;
|
|
12053
12064
|
if (typeof min2 === "number") next = Math.max(next, min2);
|
|
12054
12065
|
if (typeof max2 === "number") next = Math.min(next, max2);
|
|
12055
12066
|
const e4 = {
|
|
12056
12067
|
originalEvent,
|
|
12057
|
-
value: next,
|
|
12068
|
+
value: sanitizeNumberish2(next),
|
|
12058
12069
|
stopPropagation: () => originalEvent.stopPropagation(),
|
|
12059
12070
|
preventDefault: () => originalEvent.preventDefault(),
|
|
12060
12071
|
target: {
|
|
12061
12072
|
name,
|
|
12062
|
-
id: (
|
|
12063
|
-
value: next
|
|
12073
|
+
id: (_b = id != null ? id : inputId) != null ? _b : null,
|
|
12074
|
+
value: sanitizeNumberish2(next)
|
|
12064
12075
|
}
|
|
12065
12076
|
};
|
|
12066
12077
|
handleChange(e4);
|
|
@@ -19096,7 +19107,18 @@ var ShadcnChipsVariant = React74.forwardRef(function ShadcnChipsVariant2(props,
|
|
|
19096
19107
|
// rest of text UI bits (size, density, icons, etc.)
|
|
19097
19108
|
...restTextProps
|
|
19098
19109
|
} = props;
|
|
19099
|
-
const
|
|
19110
|
+
const hasInvalidIncomingValue = value !== void 0 && !Array.isArray(value);
|
|
19111
|
+
React74.useEffect(() => {
|
|
19112
|
+
if (!hasInvalidIncomingValue) return;
|
|
19113
|
+
console.warn(
|
|
19114
|
+
"[form-palette] ShadcnChipsVariant expected `value` to be `string[] | undefined`; received:",
|
|
19115
|
+
value
|
|
19116
|
+
);
|
|
19117
|
+
}, [hasInvalidIncomingValue, value]);
|
|
19118
|
+
const chips = React74.useMemo(
|
|
19119
|
+
() => Array.isArray(value) ? value : [],
|
|
19120
|
+
[value]
|
|
19121
|
+
);
|
|
19100
19122
|
const hasChips = chips.length > 0;
|
|
19101
19123
|
const [inputText, setInputText] = React74.useState("");
|
|
19102
19124
|
const emitChange = React74.useCallback(
|