@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.js
CHANGED
|
@@ -12348,6 +12348,9 @@ function clampToLimits(n3, min2, max2) {
|
|
|
12348
12348
|
function isFiniteNumber(n3) {
|
|
12349
12349
|
return typeof n3 === "number" && Number.isFinite(n3);
|
|
12350
12350
|
}
|
|
12351
|
+
function sanitizeNumberish(value) {
|
|
12352
|
+
return isFiniteNumber(value) ? value : null;
|
|
12353
|
+
}
|
|
12351
12354
|
function resolveLocale(explicit) {
|
|
12352
12355
|
if (explicit) return explicit;
|
|
12353
12356
|
if (typeof navigator !== "undefined" && navigator.language)
|
|
@@ -12382,6 +12385,7 @@ function parseEditable(editable, locale, decimalSep) {
|
|
|
12382
12385
|
return Number.isFinite(n3) ? n3 : null;
|
|
12383
12386
|
}
|
|
12384
12387
|
function formatDisplayNumber(n3, locale, opts, prefix, suffix) {
|
|
12388
|
+
if (!isFiniteNumber(n3)) return "";
|
|
12385
12389
|
const f2 = new Intl.NumberFormat(locale, opts).format(n3);
|
|
12386
12390
|
return `${prefix != null ? prefix : ""}${f2}${suffix != null ? suffix : ""}`;
|
|
12387
12391
|
}
|
|
@@ -12495,9 +12499,10 @@ var InputNumber = React66__namespace.memo(
|
|
|
12495
12499
|
const emit = React66__namespace.useCallback(
|
|
12496
12500
|
(event, value2) => {
|
|
12497
12501
|
var _a2, _b, _c;
|
|
12502
|
+
const safeValue = sanitizeNumberish(value2);
|
|
12498
12503
|
(_c = props.onValueChange) == null ? void 0 : _c.call(props, {
|
|
12499
12504
|
originalEvent: event,
|
|
12500
|
-
value:
|
|
12505
|
+
value: safeValue,
|
|
12501
12506
|
stopPropagation() {
|
|
12502
12507
|
event == null ? void 0 : event.stopPropagation();
|
|
12503
12508
|
},
|
|
@@ -12507,11 +12512,11 @@ var InputNumber = React66__namespace.memo(
|
|
|
12507
12512
|
target: {
|
|
12508
12513
|
name: (_a2 = props.name) != null ? _a2 : null,
|
|
12509
12514
|
id: (_b = props.id) != null ? _b : null,
|
|
12510
|
-
value:
|
|
12515
|
+
value: safeValue
|
|
12511
12516
|
}
|
|
12512
12517
|
});
|
|
12513
12518
|
if (props.onChange && event) {
|
|
12514
|
-
props.onChange({ originalEvent: event, value:
|
|
12519
|
+
props.onChange({ originalEvent: event, value: safeValue });
|
|
12515
12520
|
}
|
|
12516
12521
|
},
|
|
12517
12522
|
[props]
|
|
@@ -12528,10 +12533,11 @@ var InputNumber = React66__namespace.memo(
|
|
|
12528
12533
|
};
|
|
12529
12534
|
const formatFromModel = React66__namespace.useCallback(
|
|
12530
12535
|
(n3) => {
|
|
12531
|
-
|
|
12532
|
-
if (
|
|
12536
|
+
const safeNumber = sanitizeNumberish(n3);
|
|
12537
|
+
if (safeNumber == null) return "";
|
|
12538
|
+
if (!props.format) return toEditableFromNumber(safeNumber);
|
|
12533
12539
|
const formatted = formatDisplayNumber(
|
|
12534
|
-
|
|
12540
|
+
safeNumber,
|
|
12535
12541
|
locale,
|
|
12536
12542
|
fmtOptions,
|
|
12537
12543
|
props.prefix,
|
|
@@ -12562,11 +12568,12 @@ var InputNumber = React66__namespace.memo(
|
|
|
12562
12568
|
);
|
|
12563
12569
|
const syncFromPropsValue = React66__namespace.useCallback(
|
|
12564
12570
|
(v2) => {
|
|
12565
|
-
|
|
12571
|
+
const safeValue = sanitizeNumberish(v2);
|
|
12572
|
+
if (safeValue == null) {
|
|
12566
12573
|
setDisplay("");
|
|
12567
12574
|
return;
|
|
12568
12575
|
}
|
|
12569
|
-
const clamped = clampModel(
|
|
12576
|
+
const clamped = clampModel(safeValue);
|
|
12570
12577
|
setDisplay(
|
|
12571
12578
|
focused ? toEditableFromNumber(clamped) : formatFromModel(clamped)
|
|
12572
12579
|
);
|
|
@@ -12708,6 +12715,9 @@ var InputNumber = React66__namespace.memo(
|
|
|
12708
12715
|
})
|
|
12709
12716
|
);
|
|
12710
12717
|
InputNumber.displayName = "InputNumber";
|
|
12718
|
+
function sanitizeNumberish2(value) {
|
|
12719
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
12720
|
+
}
|
|
12711
12721
|
var ShadcnNumberVariant = React66__namespace.default.forwardRef(function ShadcnNumberVariant2(props, forwardedRef) {
|
|
12712
12722
|
const {
|
|
12713
12723
|
showButtons,
|
|
@@ -12728,11 +12738,12 @@ var ShadcnNumberVariant = React66__namespace.default.forwardRef(function ShadcnN
|
|
|
12728
12738
|
} = rest;
|
|
12729
12739
|
const handleChange = React66__namespace.default.useCallback(
|
|
12730
12740
|
(e4) => {
|
|
12741
|
+
const safeValue = sanitizeNumberish2(e4.value);
|
|
12731
12742
|
if (onValueChange) {
|
|
12732
|
-
onValueChange(
|
|
12743
|
+
onValueChange(safeValue != null ? safeValue : void 0, {
|
|
12733
12744
|
source: "user",
|
|
12734
12745
|
nativeEvent: e4.originalEvent,
|
|
12735
|
-
raw:
|
|
12746
|
+
raw: safeValue
|
|
12736
12747
|
});
|
|
12737
12748
|
}
|
|
12738
12749
|
},
|
|
@@ -12740,21 +12751,21 @@ var ShadcnNumberVariant = React66__namespace.default.forwardRef(function ShadcnN
|
|
|
12740
12751
|
);
|
|
12741
12752
|
const handleStep = React66__namespace.default.useCallback(
|
|
12742
12753
|
(direction, originalEvent) => {
|
|
12743
|
-
var _a;
|
|
12754
|
+
var _a, _b;
|
|
12744
12755
|
if (disabled) return;
|
|
12745
|
-
const current = value != null ?
|
|
12756
|
+
const current = (_a = sanitizeNumberish2(value)) != null ? _a : 0;
|
|
12746
12757
|
let next = current + direction * step;
|
|
12747
12758
|
if (typeof min2 === "number") next = Math.max(next, min2);
|
|
12748
12759
|
if (typeof max2 === "number") next = Math.min(next, max2);
|
|
12749
12760
|
const e4 = {
|
|
12750
12761
|
originalEvent,
|
|
12751
|
-
value: next,
|
|
12762
|
+
value: sanitizeNumberish2(next),
|
|
12752
12763
|
stopPropagation: () => originalEvent.stopPropagation(),
|
|
12753
12764
|
preventDefault: () => originalEvent.preventDefault(),
|
|
12754
12765
|
target: {
|
|
12755
12766
|
name,
|
|
12756
|
-
id: (
|
|
12757
|
-
value: next
|
|
12767
|
+
id: (_b = id != null ? id : inputId) != null ? _b : null,
|
|
12768
|
+
value: sanitizeNumberish2(next)
|
|
12758
12769
|
}
|
|
12759
12770
|
};
|
|
12760
12771
|
handleChange(e4);
|
|
@@ -19778,7 +19789,18 @@ var ShadcnChipsVariant = React66__namespace.forwardRef(function ShadcnChipsVaria
|
|
|
19778
19789
|
// rest of text UI bits (size, density, icons, etc.)
|
|
19779
19790
|
...restTextProps
|
|
19780
19791
|
} = props;
|
|
19781
|
-
const
|
|
19792
|
+
const hasInvalidIncomingValue = value !== void 0 && !Array.isArray(value);
|
|
19793
|
+
React66__namespace.useEffect(() => {
|
|
19794
|
+
if (!hasInvalidIncomingValue) return;
|
|
19795
|
+
console.warn(
|
|
19796
|
+
"[form-palette] ShadcnChipsVariant expected `value` to be `string[] | undefined`; received:",
|
|
19797
|
+
value
|
|
19798
|
+
);
|
|
19799
|
+
}, [hasInvalidIncomingValue, value]);
|
|
19800
|
+
const chips = React66__namespace.useMemo(
|
|
19801
|
+
() => Array.isArray(value) ? value : [],
|
|
19802
|
+
[value]
|
|
19803
|
+
);
|
|
19782
19804
|
const hasChips = chips.length > 0;
|
|
19783
19805
|
const [inputText, setInputText] = React66__namespace.useState("");
|
|
19784
19806
|
const emitChange = React66__namespace.useCallback(
|