@timeax/form-palette 0.1.32 → 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.d.mts +1 -1
- package/dist/extra.d.ts +1 -1
- package/dist/extra.js +40 -18
- package/dist/extra.js.map +1 -1
- package/dist/extra.mjs +40 -18
- 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/README.md
CHANGED
|
@@ -1118,16 +1118,28 @@ export function SelectExample() {
|
|
|
1118
1118
|
clearable
|
|
1119
1119
|
/>
|
|
1120
1120
|
|
|
1121
|
-
<InputField
|
|
1122
|
-
name="emails"
|
|
1123
|
-
label="Allowed emails"
|
|
1124
|
-
variant="chips"
|
|
1125
|
-
textareaMode
|
|
1126
|
-
placement="below"
|
|
1127
|
-
addOnEnter
|
|
1128
|
-
addOnBlur
|
|
1129
|
-
/>
|
|
1130
|
-
|
|
1121
|
+
<InputField
|
|
1122
|
+
name="emails"
|
|
1123
|
+
label="Allowed emails"
|
|
1124
|
+
variant="chips"
|
|
1125
|
+
textareaMode
|
|
1126
|
+
placement="below"
|
|
1127
|
+
addOnEnter
|
|
1128
|
+
addOnBlur
|
|
1129
|
+
/>
|
|
1130
|
+
|
|
1131
|
+
// Controlled usage: read/write chips from `e.value` (not e.target.value)
|
|
1132
|
+
const [tags, setTags] = React.useState<string[] | undefined>(["alpha"]);
|
|
1133
|
+
<InputField
|
|
1134
|
+
name="tags_controlled"
|
|
1135
|
+
label="Controlled tags"
|
|
1136
|
+
variant="chips"
|
|
1137
|
+
value={tags}
|
|
1138
|
+
onChange={(e) => {
|
|
1139
|
+
setTags(e.value);
|
|
1140
|
+
}}
|
|
1141
|
+
/>
|
|
1142
|
+
```
|
|
1131
1143
|
|
|
1132
1144
|
## color
|
|
1133
1145
|
|
package/dist/extra.d.mts
CHANGED
|
@@ -257,7 +257,7 @@ type UseDataResult<TItem = any, TFilters = Record<string, any>> = {
|
|
|
257
257
|
clearSelection: () => void;
|
|
258
258
|
isSelected: (id: DataKey) => boolean;
|
|
259
259
|
getSelection: () => TItem | TItem[] | null;
|
|
260
|
-
refresh: () =>
|
|
260
|
+
refresh: () => Promise<TItem[]>;
|
|
261
261
|
override(data: TItem[]): void;
|
|
262
262
|
fetch: (override?: {
|
|
263
263
|
query?: string;
|
package/dist/extra.d.ts
CHANGED
|
@@ -257,7 +257,7 @@ type UseDataResult<TItem = any, TFilters = Record<string, any>> = {
|
|
|
257
257
|
clearSelection: () => void;
|
|
258
258
|
isSelected: (id: DataKey) => boolean;
|
|
259
259
|
getSelection: () => TItem | TItem[] | null;
|
|
260
|
-
refresh: () =>
|
|
260
|
+
refresh: () => Promise<TItem[]>;
|
|
261
261
|
override(data: TItem[]): void;
|
|
262
262
|
fetch: (override?: {
|
|
263
263
|
query?: string;
|
package/dist/extra.js
CHANGED
|
@@ -11271,6 +11271,9 @@ function clampToLimits(n3, min2, max2) {
|
|
|
11271
11271
|
function isFiniteNumber(n3) {
|
|
11272
11272
|
return typeof n3 === "number" && Number.isFinite(n3);
|
|
11273
11273
|
}
|
|
11274
|
+
function sanitizeNumberish(value) {
|
|
11275
|
+
return isFiniteNumber(value) ? value : null;
|
|
11276
|
+
}
|
|
11274
11277
|
function resolveLocale(explicit) {
|
|
11275
11278
|
if (explicit) return explicit;
|
|
11276
11279
|
if (typeof navigator !== "undefined" && navigator.language)
|
|
@@ -11305,6 +11308,7 @@ function parseEditable(editable, locale, decimalSep) {
|
|
|
11305
11308
|
return Number.isFinite(n3) ? n3 : null;
|
|
11306
11309
|
}
|
|
11307
11310
|
function formatDisplayNumber(n3, locale, opts, prefix, suffix) {
|
|
11311
|
+
if (!isFiniteNumber(n3)) return "";
|
|
11308
11312
|
const f2 = new Intl.NumberFormat(locale, opts).format(n3);
|
|
11309
11313
|
return `${prefix != null ? prefix : ""}${f2}${suffix != null ? suffix : ""}`;
|
|
11310
11314
|
}
|
|
@@ -11418,9 +11422,10 @@ var InputNumber = React74__namespace.memo(
|
|
|
11418
11422
|
const emit = React74__namespace.useCallback(
|
|
11419
11423
|
(event, value2) => {
|
|
11420
11424
|
var _a2, _b, _c;
|
|
11425
|
+
const safeValue = sanitizeNumberish(value2);
|
|
11421
11426
|
(_c = props.onValueChange) == null ? void 0 : _c.call(props, {
|
|
11422
11427
|
originalEvent: event,
|
|
11423
|
-
value:
|
|
11428
|
+
value: safeValue,
|
|
11424
11429
|
stopPropagation() {
|
|
11425
11430
|
event == null ? void 0 : event.stopPropagation();
|
|
11426
11431
|
},
|
|
@@ -11430,11 +11435,11 @@ var InputNumber = React74__namespace.memo(
|
|
|
11430
11435
|
target: {
|
|
11431
11436
|
name: (_a2 = props.name) != null ? _a2 : null,
|
|
11432
11437
|
id: (_b = props.id) != null ? _b : null,
|
|
11433
|
-
value:
|
|
11438
|
+
value: safeValue
|
|
11434
11439
|
}
|
|
11435
11440
|
});
|
|
11436
11441
|
if (props.onChange && event) {
|
|
11437
|
-
props.onChange({ originalEvent: event, value:
|
|
11442
|
+
props.onChange({ originalEvent: event, value: safeValue });
|
|
11438
11443
|
}
|
|
11439
11444
|
},
|
|
11440
11445
|
[props]
|
|
@@ -11451,10 +11456,11 @@ var InputNumber = React74__namespace.memo(
|
|
|
11451
11456
|
};
|
|
11452
11457
|
const formatFromModel = React74__namespace.useCallback(
|
|
11453
11458
|
(n3) => {
|
|
11454
|
-
|
|
11455
|
-
if (
|
|
11459
|
+
const safeNumber = sanitizeNumberish(n3);
|
|
11460
|
+
if (safeNumber == null) return "";
|
|
11461
|
+
if (!props.format) return toEditableFromNumber(safeNumber);
|
|
11456
11462
|
const formatted = formatDisplayNumber(
|
|
11457
|
-
|
|
11463
|
+
safeNumber,
|
|
11458
11464
|
locale,
|
|
11459
11465
|
fmtOptions,
|
|
11460
11466
|
props.prefix,
|
|
@@ -11485,11 +11491,12 @@ var InputNumber = React74__namespace.memo(
|
|
|
11485
11491
|
);
|
|
11486
11492
|
const syncFromPropsValue = React74__namespace.useCallback(
|
|
11487
11493
|
(v2) => {
|
|
11488
|
-
|
|
11494
|
+
const safeValue = sanitizeNumberish(v2);
|
|
11495
|
+
if (safeValue == null) {
|
|
11489
11496
|
setDisplay("");
|
|
11490
11497
|
return;
|
|
11491
11498
|
}
|
|
11492
|
-
const clamped = clampModel(
|
|
11499
|
+
const clamped = clampModel(safeValue);
|
|
11493
11500
|
setDisplay(
|
|
11494
11501
|
focused ? toEditableFromNumber(clamped) : formatFromModel(clamped)
|
|
11495
11502
|
);
|
|
@@ -12052,6 +12059,9 @@ var __iconNode37 = [
|
|
|
12052
12059
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
12053
12060
|
];
|
|
12054
12061
|
var X = createLucideIcon("x", __iconNode37);
|
|
12062
|
+
function sanitizeNumberish2(value) {
|
|
12063
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
12064
|
+
}
|
|
12055
12065
|
var ShadcnNumberVariant = React74__namespace.default.forwardRef(function ShadcnNumberVariant2(props, forwardedRef) {
|
|
12056
12066
|
const {
|
|
12057
12067
|
showButtons,
|
|
@@ -12072,11 +12082,12 @@ var ShadcnNumberVariant = React74__namespace.default.forwardRef(function ShadcnN
|
|
|
12072
12082
|
} = rest;
|
|
12073
12083
|
const handleChange = React74__namespace.default.useCallback(
|
|
12074
12084
|
(e4) => {
|
|
12085
|
+
const safeValue = sanitizeNumberish2(e4.value);
|
|
12075
12086
|
if (onValueChange) {
|
|
12076
|
-
onValueChange(
|
|
12087
|
+
onValueChange(safeValue != null ? safeValue : void 0, {
|
|
12077
12088
|
source: "user",
|
|
12078
12089
|
nativeEvent: e4.originalEvent,
|
|
12079
|
-
raw:
|
|
12090
|
+
raw: safeValue
|
|
12080
12091
|
});
|
|
12081
12092
|
}
|
|
12082
12093
|
},
|
|
@@ -12084,21 +12095,21 @@ var ShadcnNumberVariant = React74__namespace.default.forwardRef(function ShadcnN
|
|
|
12084
12095
|
);
|
|
12085
12096
|
const handleStep = React74__namespace.default.useCallback(
|
|
12086
12097
|
(direction, originalEvent) => {
|
|
12087
|
-
var _a;
|
|
12098
|
+
var _a, _b;
|
|
12088
12099
|
if (disabled) return;
|
|
12089
|
-
const current = value != null ?
|
|
12100
|
+
const current = (_a = sanitizeNumberish2(value)) != null ? _a : 0;
|
|
12090
12101
|
let next = current + direction * step;
|
|
12091
12102
|
if (typeof min2 === "number") next = Math.max(next, min2);
|
|
12092
12103
|
if (typeof max2 === "number") next = Math.min(next, max2);
|
|
12093
12104
|
const e4 = {
|
|
12094
12105
|
originalEvent,
|
|
12095
|
-
value: next,
|
|
12106
|
+
value: sanitizeNumberish2(next),
|
|
12096
12107
|
stopPropagation: () => originalEvent.stopPropagation(),
|
|
12097
12108
|
preventDefault: () => originalEvent.preventDefault(),
|
|
12098
12109
|
target: {
|
|
12099
12110
|
name,
|
|
12100
|
-
id: (
|
|
12101
|
-
value: next
|
|
12111
|
+
id: (_b = id != null ? id : inputId) != null ? _b : null,
|
|
12112
|
+
value: sanitizeNumberish2(next)
|
|
12102
12113
|
}
|
|
12103
12114
|
};
|
|
12104
12115
|
handleChange(e4);
|
|
@@ -19134,7 +19145,18 @@ var ShadcnChipsVariant = React74__namespace.forwardRef(function ShadcnChipsVaria
|
|
|
19134
19145
|
// rest of text UI bits (size, density, icons, etc.)
|
|
19135
19146
|
...restTextProps
|
|
19136
19147
|
} = props;
|
|
19137
|
-
const
|
|
19148
|
+
const hasInvalidIncomingValue = value !== void 0 && !Array.isArray(value);
|
|
19149
|
+
React74__namespace.useEffect(() => {
|
|
19150
|
+
if (!hasInvalidIncomingValue) return;
|
|
19151
|
+
console.warn(
|
|
19152
|
+
"[form-palette] ShadcnChipsVariant expected `value` to be `string[] | undefined`; received:",
|
|
19153
|
+
value
|
|
19154
|
+
);
|
|
19155
|
+
}, [hasInvalidIncomingValue, value]);
|
|
19156
|
+
const chips = React74__namespace.useMemo(
|
|
19157
|
+
() => Array.isArray(value) ? value : [],
|
|
19158
|
+
[value]
|
|
19159
|
+
);
|
|
19138
19160
|
const hasChips = chips.length > 0;
|
|
19139
19161
|
const [inputText, setInputText] = React74__namespace.useState("");
|
|
19140
19162
|
const emitChange = React74__namespace.useCallback(
|
|
@@ -34128,8 +34150,8 @@ function useData(opts, deps = []) {
|
|
|
34128
34150
|
getItemKey
|
|
34129
34151
|
]
|
|
34130
34152
|
);
|
|
34131
|
-
const refresh = React74__namespace.useCallback(() => {
|
|
34132
|
-
|
|
34153
|
+
const refresh = React74__namespace.useCallback(async () => {
|
|
34154
|
+
return fetchImpl();
|
|
34133
34155
|
}, [fetchImpl]);
|
|
34134
34156
|
const override = React74__namespace.useCallback((newData) => {
|
|
34135
34157
|
setData(newData);
|