@timeax/form-palette 0.1.1 → 0.1.3
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/{variant-BGkGWsSy.d.mts → core-BD0ObjuE.d.mts} +2756 -2749
- package/dist/{variant-B_L0opEi.d.ts → core-q_p0E4W9.d.ts} +2756 -2749
- package/dist/extra.d.mts +2 -2
- package/dist/extra.d.ts +2 -2
- package/dist/extra.js +32 -20
- package/dist/extra.js.map +1 -1
- package/dist/extra.mjs +32 -20
- package/dist/extra.mjs.map +1 -1
- package/dist/index.d.mts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +1649 -1627
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1649 -1627
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/extra.mjs
CHANGED
|
@@ -4451,6 +4451,10 @@ var twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
|
|
|
4451
4451
|
function cn(...inputs) {
|
|
4452
4452
|
return twMerge(clsx(inputs));
|
|
4453
4453
|
}
|
|
4454
|
+
function toArray2(v2) {
|
|
4455
|
+
if (v2 == null) return [];
|
|
4456
|
+
return Array.isArray(v2) ? v2 : [v2];
|
|
4457
|
+
}
|
|
4454
4458
|
function Popover({
|
|
4455
4459
|
...props
|
|
4456
4460
|
}) {
|
|
@@ -19206,10 +19210,6 @@ function pickerBtnSize(size) {
|
|
|
19206
19210
|
return "h-7 w-7";
|
|
19207
19211
|
}
|
|
19208
19212
|
}
|
|
19209
|
-
function toArray2(v2) {
|
|
19210
|
-
if (v2 == null) return [];
|
|
19211
|
-
return Array.isArray(v2) ? v2 : [v2];
|
|
19212
|
-
}
|
|
19213
19213
|
function normaliseFileLike(input) {
|
|
19214
19214
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
19215
19215
|
const asAny = input;
|
|
@@ -19341,6 +19341,7 @@ var FileThumbnail = ({ item }) => {
|
|
|
19341
19341
|
) : /* @__PURE__ */ jsx(File2, { className: "h-4 w-4 text-muted-foreground/50" }) });
|
|
19342
19342
|
};
|
|
19343
19343
|
var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref) {
|
|
19344
|
+
var _a;
|
|
19344
19345
|
const {
|
|
19345
19346
|
value,
|
|
19346
19347
|
onValue,
|
|
@@ -19366,6 +19367,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19366
19367
|
formatFileName,
|
|
19367
19368
|
formatFileSize = formatSizeDefault,
|
|
19368
19369
|
placeholder = "Select file...",
|
|
19370
|
+
asRaw,
|
|
19369
19371
|
className,
|
|
19370
19372
|
custom,
|
|
19371
19373
|
dropAreaClassName,
|
|
@@ -19393,7 +19395,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19393
19395
|
} = props;
|
|
19394
19396
|
const joinControls = mode === "default" ? joinControlsProp != null ? joinControlsProp : true : false;
|
|
19395
19397
|
const extendBoxToControls = mode === "default" ? extendBoxToControlsProp != null ? extendBoxToControlsProp : true : false;
|
|
19396
|
-
const items = value != null ?
|
|
19398
|
+
const items = (_a = toArray2(value)) != null ? _a : [];
|
|
19397
19399
|
const isDisabled = Boolean(disabled || readOnly);
|
|
19398
19400
|
const [dragOver, setDragOver] = React.useState(false);
|
|
19399
19401
|
const [selectedIds, setSelectedIds] = React.useState(
|
|
@@ -19477,12 +19479,16 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19477
19479
|
setSelectedIds(/* @__PURE__ */ new Set());
|
|
19478
19480
|
}, [emitChange, items, selectedIds]);
|
|
19479
19481
|
const openPicker = React.useCallback(async () => {
|
|
19480
|
-
var
|
|
19482
|
+
var _a2;
|
|
19481
19483
|
if (isDisabled) return;
|
|
19482
19484
|
let resolvedLoader = customLoader != null ? customLoader : custom && getPaletteUtil("customLoader");
|
|
19483
19485
|
if (resolvedLoader) {
|
|
19484
19486
|
try {
|
|
19485
|
-
const result = await resolvedLoader({
|
|
19487
|
+
const result = await resolvedLoader({
|
|
19488
|
+
multiple,
|
|
19489
|
+
current: items,
|
|
19490
|
+
allowedTypes: toArray2(accept)
|
|
19491
|
+
});
|
|
19486
19492
|
if (!result) return;
|
|
19487
19493
|
const normalized = toArray2(result).map(normaliseFileLike);
|
|
19488
19494
|
if (mergeMode === "replace" || !multiple) {
|
|
@@ -19498,7 +19504,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19498
19504
|
}
|
|
19499
19505
|
return;
|
|
19500
19506
|
}
|
|
19501
|
-
(
|
|
19507
|
+
(_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
|
|
19502
19508
|
}, [
|
|
19503
19509
|
customLoader,
|
|
19504
19510
|
emitChange,
|
|
@@ -19517,18 +19523,18 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19517
19523
|
);
|
|
19518
19524
|
const onDrop = React.useCallback(
|
|
19519
19525
|
(e4) => {
|
|
19520
|
-
var
|
|
19526
|
+
var _a2;
|
|
19521
19527
|
e4.preventDefault();
|
|
19522
19528
|
setDragOver(false);
|
|
19523
|
-
if (isDisabled || !((
|
|
19529
|
+
if (isDisabled || !((_a2 = e4.dataTransfer.files) == null ? void 0 : _a2.length)) return;
|
|
19524
19530
|
const files = normaliseFromFiles(e4.dataTransfer.files);
|
|
19525
19531
|
handleAddItems(files, "drop");
|
|
19526
19532
|
},
|
|
19527
19533
|
[handleAddItems, isDisabled]
|
|
19528
19534
|
);
|
|
19529
19535
|
const onNativeChange = (e4) => {
|
|
19530
|
-
var
|
|
19531
|
-
if ((
|
|
19536
|
+
var _a2;
|
|
19537
|
+
if ((_a2 = e4.target.files) == null ? void 0 : _a2.length) {
|
|
19532
19538
|
handleAddItems(normaliseFromFiles(e4.target.files), "input");
|
|
19533
19539
|
}
|
|
19534
19540
|
e4.target.value = "";
|
|
@@ -19542,8 +19548,8 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19542
19548
|
const [preview2, setPreview] = React.useState(null);
|
|
19543
19549
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
19544
19550
|
React.useEffect(() => {
|
|
19545
|
-
var
|
|
19546
|
-
const isImage2 = ((
|
|
19551
|
+
var _a2;
|
|
19552
|
+
const isImage2 = ((_a2 = item.type) == null ? void 0 : _a2.startsWith("image/")) || item.name.match(/\.(jpg|jpeg|png|gif|webp)$/i);
|
|
19547
19553
|
if (!isImage2) {
|
|
19548
19554
|
setPreview(null);
|
|
19549
19555
|
return;
|
|
@@ -19929,7 +19935,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19929
19935
|
),
|
|
19930
19936
|
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
19931
19937
|
items.map((item) => {
|
|
19932
|
-
var
|
|
19938
|
+
var _a2;
|
|
19933
19939
|
const selected = selectedIds.has(item.id);
|
|
19934
19940
|
const toggle = () => {
|
|
19935
19941
|
const next = new Set(selectedIds);
|
|
@@ -19956,7 +19962,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19956
19962
|
),
|
|
19957
19963
|
/* @__PURE__ */ jsx(FileThumbnail, { item }),
|
|
19958
19964
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
19959
|
-
/* @__PURE__ */ jsx("div", { className: "truncate font-medium", children: (
|
|
19965
|
+
/* @__PURE__ */ jsx("div", { className: "truncate font-medium", children: (_a2 = formatFileName == null ? void 0 : formatFileName(item)) != null ? _a2 : item.name }),
|
|
19960
19966
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
19961
19967
|
/* @__PURE__ */ jsx("span", { children: formatFileSize(
|
|
19962
19968
|
item.size
|
|
@@ -20074,7 +20080,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
20074
20080
|
] })
|
|
20075
20081
|
] }),
|
|
20076
20082
|
/* @__PURE__ */ jsx(ScrollArea, { className: cn("mt-1 w-full", listClassName), children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: items.map((item, index) => {
|
|
20077
|
-
var
|
|
20083
|
+
var _a2;
|
|
20078
20084
|
const selected = selectedIds.has(item.id);
|
|
20079
20085
|
const toggle = () => {
|
|
20080
20086
|
const next = new Set(selectedIds);
|
|
@@ -20109,7 +20115,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
20109
20115
|
),
|
|
20110
20116
|
/* @__PURE__ */ jsx(FileThumbnail, { item }),
|
|
20111
20117
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
|
|
20112
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-2", children: /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: (
|
|
20118
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-2", children: /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: (_a2 = formatFileName == null ? void 0 : formatFileName(item)) != null ? _a2 : item.name }) }),
|
|
20113
20119
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
20114
20120
|
/* @__PURE__ */ jsx("span", { children: formatFileSize(item.size) }),
|
|
20115
20121
|
item.status === "loading" && /* @__PURE__ */ jsx("span", { className: "flex items-center gap-1 text-primary", children: /* @__PURE__ */ jsx(LoaderCircle, { className: "h-3 w-3 animate-spin" }) }),
|
|
@@ -24653,7 +24659,8 @@ function useField(options) {
|
|
|
24653
24659
|
readOnly: readOnlyProp = false,
|
|
24654
24660
|
validate,
|
|
24655
24661
|
getOriginalValue,
|
|
24656
|
-
onValueChange
|
|
24662
|
+
onValueChange,
|
|
24663
|
+
onSubmit
|
|
24657
24664
|
} = options;
|
|
24658
24665
|
const ref = React.useRef(null);
|
|
24659
24666
|
const stateRef = React.useRef({
|
|
@@ -24740,6 +24747,7 @@ function useField(options) {
|
|
|
24740
24747
|
main,
|
|
24741
24748
|
ignore,
|
|
24742
24749
|
required,
|
|
24750
|
+
onSubmit,
|
|
24743
24751
|
ref,
|
|
24744
24752
|
get defaultValue() {
|
|
24745
24753
|
return stateRef.current.original;
|
|
@@ -24773,7 +24781,8 @@ function useField(options) {
|
|
|
24773
24781
|
if (onValueChange) {
|
|
24774
24782
|
onValueChange(value2, old, variant);
|
|
24775
24783
|
}
|
|
24776
|
-
}
|
|
24784
|
+
},
|
|
24785
|
+
variant: options.variant
|
|
24777
24786
|
// Flags not directly on the Field interface but used via `as any`
|
|
24778
24787
|
// in core-provider (getValue/setValue/reset).
|
|
24779
24788
|
};
|
|
@@ -25138,6 +25147,7 @@ function InputField(props) {
|
|
|
25138
25147
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
25139
25148
|
const {
|
|
25140
25149
|
variant,
|
|
25150
|
+
onSubmit,
|
|
25141
25151
|
// Field identity / wiring
|
|
25142
25152
|
name,
|
|
25143
25153
|
bind,
|
|
@@ -25269,6 +25279,8 @@ function InputField(props) {
|
|
|
25269
25279
|
alias,
|
|
25270
25280
|
main,
|
|
25271
25281
|
ignore,
|
|
25282
|
+
onSubmit,
|
|
25283
|
+
variant,
|
|
25272
25284
|
required,
|
|
25273
25285
|
defaultValue,
|
|
25274
25286
|
validate
|