@timeax/form-palette 0.1.33 → 0.1.35
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 +39 -17
- package/dist/extra.js.map +1 -1
- package/dist/extra.mjs +39 -17
- 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/index.mjs
CHANGED
|
@@ -12310,6 +12310,9 @@ function clampToLimits(n3, min2, max2) {
|
|
|
12310
12310
|
function isFiniteNumber(n3) {
|
|
12311
12311
|
return typeof n3 === "number" && Number.isFinite(n3);
|
|
12312
12312
|
}
|
|
12313
|
+
function sanitizeNumberish(value) {
|
|
12314
|
+
return isFiniteNumber(value) ? value : null;
|
|
12315
|
+
}
|
|
12313
12316
|
function resolveLocale(explicit) {
|
|
12314
12317
|
if (explicit) return explicit;
|
|
12315
12318
|
if (typeof navigator !== "undefined" && navigator.language)
|
|
@@ -12344,6 +12347,7 @@ function parseEditable(editable, locale, decimalSep) {
|
|
|
12344
12347
|
return Number.isFinite(n3) ? n3 : null;
|
|
12345
12348
|
}
|
|
12346
12349
|
function formatDisplayNumber(n3, locale, opts, prefix, suffix) {
|
|
12350
|
+
if (!isFiniteNumber(n3)) return "";
|
|
12347
12351
|
const f2 = new Intl.NumberFormat(locale, opts).format(n3);
|
|
12348
12352
|
return `${prefix != null ? prefix : ""}${f2}${suffix != null ? suffix : ""}`;
|
|
12349
12353
|
}
|
|
@@ -12457,9 +12461,10 @@ var InputNumber = React66.memo(
|
|
|
12457
12461
|
const emit = React66.useCallback(
|
|
12458
12462
|
(event, value2) => {
|
|
12459
12463
|
var _a2, _b, _c;
|
|
12464
|
+
const safeValue = sanitizeNumberish(value2);
|
|
12460
12465
|
(_c = props.onValueChange) == null ? void 0 : _c.call(props, {
|
|
12461
12466
|
originalEvent: event,
|
|
12462
|
-
value:
|
|
12467
|
+
value: safeValue,
|
|
12463
12468
|
stopPropagation() {
|
|
12464
12469
|
event == null ? void 0 : event.stopPropagation();
|
|
12465
12470
|
},
|
|
@@ -12469,11 +12474,11 @@ var InputNumber = React66.memo(
|
|
|
12469
12474
|
target: {
|
|
12470
12475
|
name: (_a2 = props.name) != null ? _a2 : null,
|
|
12471
12476
|
id: (_b = props.id) != null ? _b : null,
|
|
12472
|
-
value:
|
|
12477
|
+
value: safeValue
|
|
12473
12478
|
}
|
|
12474
12479
|
});
|
|
12475
12480
|
if (props.onChange && event) {
|
|
12476
|
-
props.onChange({ originalEvent: event, value:
|
|
12481
|
+
props.onChange({ originalEvent: event, value: safeValue });
|
|
12477
12482
|
}
|
|
12478
12483
|
},
|
|
12479
12484
|
[props]
|
|
@@ -12490,10 +12495,11 @@ var InputNumber = React66.memo(
|
|
|
12490
12495
|
};
|
|
12491
12496
|
const formatFromModel = React66.useCallback(
|
|
12492
12497
|
(n3) => {
|
|
12493
|
-
|
|
12494
|
-
if (
|
|
12498
|
+
const safeNumber = sanitizeNumberish(n3);
|
|
12499
|
+
if (safeNumber == null) return "";
|
|
12500
|
+
if (!props.format) return toEditableFromNumber(safeNumber);
|
|
12495
12501
|
const formatted = formatDisplayNumber(
|
|
12496
|
-
|
|
12502
|
+
safeNumber,
|
|
12497
12503
|
locale,
|
|
12498
12504
|
fmtOptions,
|
|
12499
12505
|
props.prefix,
|
|
@@ -12524,11 +12530,12 @@ var InputNumber = React66.memo(
|
|
|
12524
12530
|
);
|
|
12525
12531
|
const syncFromPropsValue = React66.useCallback(
|
|
12526
12532
|
(v2) => {
|
|
12527
|
-
|
|
12533
|
+
const safeValue = sanitizeNumberish(v2);
|
|
12534
|
+
if (safeValue == null) {
|
|
12528
12535
|
setDisplay("");
|
|
12529
12536
|
return;
|
|
12530
12537
|
}
|
|
12531
|
-
const clamped = clampModel(
|
|
12538
|
+
const clamped = clampModel(safeValue);
|
|
12532
12539
|
setDisplay(
|
|
12533
12540
|
focused ? toEditableFromNumber(clamped) : formatFromModel(clamped)
|
|
12534
12541
|
);
|
|
@@ -12670,6 +12677,9 @@ var InputNumber = React66.memo(
|
|
|
12670
12677
|
})
|
|
12671
12678
|
);
|
|
12672
12679
|
InputNumber.displayName = "InputNumber";
|
|
12680
|
+
function sanitizeNumberish2(value) {
|
|
12681
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
12682
|
+
}
|
|
12673
12683
|
var ShadcnNumberVariant = React66__default.forwardRef(function ShadcnNumberVariant2(props, forwardedRef) {
|
|
12674
12684
|
const {
|
|
12675
12685
|
showButtons,
|
|
@@ -12690,11 +12700,12 @@ var ShadcnNumberVariant = React66__default.forwardRef(function ShadcnNumberVaria
|
|
|
12690
12700
|
} = rest;
|
|
12691
12701
|
const handleChange = React66__default.useCallback(
|
|
12692
12702
|
(e4) => {
|
|
12703
|
+
const safeValue = sanitizeNumberish2(e4.value);
|
|
12693
12704
|
if (onValueChange) {
|
|
12694
|
-
onValueChange(
|
|
12705
|
+
onValueChange(safeValue != null ? safeValue : void 0, {
|
|
12695
12706
|
source: "user",
|
|
12696
12707
|
nativeEvent: e4.originalEvent,
|
|
12697
|
-
raw:
|
|
12708
|
+
raw: safeValue
|
|
12698
12709
|
});
|
|
12699
12710
|
}
|
|
12700
12711
|
},
|
|
@@ -12702,21 +12713,21 @@ var ShadcnNumberVariant = React66__default.forwardRef(function ShadcnNumberVaria
|
|
|
12702
12713
|
);
|
|
12703
12714
|
const handleStep = React66__default.useCallback(
|
|
12704
12715
|
(direction, originalEvent) => {
|
|
12705
|
-
var _a;
|
|
12716
|
+
var _a, _b;
|
|
12706
12717
|
if (disabled) return;
|
|
12707
|
-
const current = value != null ?
|
|
12718
|
+
const current = (_a = sanitizeNumberish2(value)) != null ? _a : 0;
|
|
12708
12719
|
let next = current + direction * step;
|
|
12709
12720
|
if (typeof min2 === "number") next = Math.max(next, min2);
|
|
12710
12721
|
if (typeof max2 === "number") next = Math.min(next, max2);
|
|
12711
12722
|
const e4 = {
|
|
12712
12723
|
originalEvent,
|
|
12713
|
-
value: next,
|
|
12724
|
+
value: sanitizeNumberish2(next),
|
|
12714
12725
|
stopPropagation: () => originalEvent.stopPropagation(),
|
|
12715
12726
|
preventDefault: () => originalEvent.preventDefault(),
|
|
12716
12727
|
target: {
|
|
12717
12728
|
name,
|
|
12718
|
-
id: (
|
|
12719
|
-
value: next
|
|
12729
|
+
id: (_b = id != null ? id : inputId) != null ? _b : null,
|
|
12730
|
+
value: sanitizeNumberish2(next)
|
|
12720
12731
|
}
|
|
12721
12732
|
};
|
|
12722
12733
|
handleChange(e4);
|
|
@@ -19740,7 +19751,18 @@ var ShadcnChipsVariant = React66.forwardRef(function ShadcnChipsVariant2(props,
|
|
|
19740
19751
|
// rest of text UI bits (size, density, icons, etc.)
|
|
19741
19752
|
...restTextProps
|
|
19742
19753
|
} = props;
|
|
19743
|
-
const
|
|
19754
|
+
const hasInvalidIncomingValue = value !== void 0 && !Array.isArray(value);
|
|
19755
|
+
React66.useEffect(() => {
|
|
19756
|
+
if (!hasInvalidIncomingValue) return;
|
|
19757
|
+
console.warn(
|
|
19758
|
+
"[form-palette] ShadcnChipsVariant expected `value` to be `string[] | undefined`; received:",
|
|
19759
|
+
value
|
|
19760
|
+
);
|
|
19761
|
+
}, [hasInvalidIncomingValue, value]);
|
|
19762
|
+
const chips = React66.useMemo(
|
|
19763
|
+
() => Array.isArray(value) ? value : [],
|
|
19764
|
+
[value]
|
|
19765
|
+
);
|
|
19744
19766
|
const hasChips = chips.length > 0;
|
|
19745
19767
|
const [inputText, setInputText] = React66.useState("");
|
|
19746
19768
|
const emitChange = React66.useCallback(
|