@jfrader/ui 0.5.0 → 0.5.1
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/accordion-DLul6vIl.js +205 -0
- package/dist/accordion.js +1 -1
- package/dist/{announcement-bar-B58xempt.js → announcement-bar-Dlbq5-9D.js} +1 -1
- package/dist/announcement-bar.js +1 -1
- package/dist/avatar-CaGJHy1N.js +145 -0
- package/dist/{avatar-group-DOQQuV51.js → avatar-group-M1opAQEG.js} +1 -1
- package/dist/avatar-group.js +1 -1
- package/dist/avatar.js +1 -1
- package/dist/badge-CjM5Agqk.js +119 -0
- package/dist/badge.js +1 -1
- package/dist/{bottom-sheet-DPJBFkie.js → bottom-sheet-DjZOPq4k.js} +10 -9
- package/dist/bottom-sheet.js +1 -1
- package/dist/{breadcrumbs-Cfw_hgt2.js → breadcrumbs-BDK_LiwH.js} +10 -3
- package/dist/breadcrumbs.js +1 -1
- package/dist/{button-C92uYFJW.js → button-NLY0h6EJ.js} +7 -7
- package/dist/button.js +1 -1
- package/dist/{calendar-B3Svu0X2.js → calendar-BzJdv_SZ.js} +3 -1
- package/dist/calendar.js +1 -1
- package/dist/card-Ca4KQKYQ.js +154 -0
- package/dist/card.js +1 -1
- package/dist/carousel-B7OrvD6J.js +474 -0
- package/dist/carousel.js +1 -1
- package/dist/{checkbox-cFquiSdy.js → checkbox-DKSzExj2.js} +16 -15
- package/dist/checkbox.js +1 -1
- package/dist/{chip-group-DTQd_M-G.js → chip-group-DjQ0_6Y9.js} +2 -1
- package/dist/chip-group.js +1 -1
- package/dist/{code-block-ahnRi-g8.js → code-block-B5we2lZa.js} +75 -74
- package/dist/code-block.js +1 -1
- package/dist/{combobox-Bhzvu9ma.js → combobox-DFFqOBCi.js} +114 -109
- package/dist/combobox.js +1 -1
- package/dist/command-palette-BmQu2w4H.js +391 -0
- package/dist/command-palette.js +1 -1
- package/dist/comment-thread-ASaXDcGo.js +1410 -0
- package/dist/comment-thread.js +2 -0
- package/dist/context-menu-__1c2Dk9.js +370 -0
- package/dist/context-menu.js +2 -0
- package/dist/{copy-button-ByiA6D3R.js → copy-button-DCSLcYS-.js} +1 -1
- package/dist/copy-button.js +1 -1
- package/dist/{date-picker-5zKSSuFF.js → date-picker-BiPN7yeK.js} +4 -4
- package/dist/date-picker.js +1 -1
- package/dist/date-range-picker-DQpUeKqV.js +570 -0
- package/dist/date-range-picker.js +1 -1
- package/dist/{dialog-ciiv9H2b.js → dialog-BX1zYMs-.js} +2 -1
- package/dist/dialog.js +1 -1
- package/dist/{divider-DYoJf0I_.js → divider-Cp7aNbhM.js} +21 -20
- package/dist/divider.js +1 -1
- package/dist/elastic-slider-BG6K019r.js +395 -0
- package/dist/elastic-slider.js +2 -0
- package/dist/{expandable-card-C-qJcZ14.js → expandable-card-rUATve0o.js} +8 -1
- package/dist/expandable-card.js +1 -1
- package/dist/expanding-search-BxOwtdwt.js +238 -0
- package/dist/expanding-search.js +2 -0
- package/dist/file-dropzone-BuXm3Tea.js +457 -0
- package/dist/file-dropzone.js +1 -1
- package/dist/{filter-toolbar-D5KEKTSe.js → filter-toolbar-Cy5Hqur-.js} +4 -2
- package/dist/filter-toolbar.js +1 -1
- package/dist/{hover-card-B-nrCIy2.js → hover-card-CoMJKg1g.js} +7 -7
- package/dist/hover-card.js +1 -1
- package/dist/{image-compare-ciuhPtQZ.js → image-compare-BxY8Ykzt.js} +1 -1
- package/dist/image-compare.js +1 -1
- package/dist/index.js +81 -76
- package/dist/{json-viewer-BcySQfjZ.js → json-viewer-DgWqyU75.js} +7 -3
- package/dist/json-viewer.js +1 -1
- package/dist/mention-input-sq61si9L.js +600 -0
- package/dist/mention-input.js +1 -1
- package/dist/menu-DDKgmK2F.js +295 -0
- package/dist/menu.js +1 -1
- package/dist/{metric-card-Bh9K4fZs.js → metric-card--lVTz5Wn.js} +2 -2
- package/dist/metric-card.js +1 -1
- package/dist/{multi-select-Pce_IYnz.js → multi-select-DG1BCFX7.js} +14 -6
- package/dist/multi-select.js +1 -1
- package/dist/{navigation-sP5fiuQS.js → navigation-CC26JDr-.js} +20 -14
- package/dist/navigation.js +1 -1
- package/dist/{overlay-layer-SeUyyEPD.js → overlay-layer-qEbpEtb8.js} +16 -2
- package/dist/{pagination-DmXZ8E85.js → pagination-BfkeWbmP.js} +23 -22
- package/dist/pagination.js +1 -1
- package/dist/pill-BaS-uIbn.js +58 -0
- package/dist/pill.js +1 -1
- package/dist/popover-CErIw2q3.js +125 -0
- package/dist/popover.js +1 -1
- package/dist/{progress-CbOWBUdA.js → progress-DAQkfhPd.js} +1 -1
- package/dist/progress.js +1 -1
- package/dist/{radio-cards-D2QZENI_.js → radio-cards-Cu9cBssN.js} +35 -34
- package/dist/radio-cards.js +1 -1
- package/dist/{radio-group-E6mMRgo7.js → radio-group-TIK0-iPX.js} +18 -15
- package/dist/radio-group.js +1 -1
- package/dist/{resizable-panels-BhjUVXZZ.js → resizable-panels-DUpQEpwG.js} +3 -2
- package/dist/resizable-panels.js +1 -1
- package/dist/{search-field-IxF0IJXm.js → search-field-DMvho0KQ.js} +2 -2
- package/dist/search-field.js +1 -1
- package/dist/{segmented-control-yO1K1nbi.js → segmented-control-8ZUGnsZm.js} +2 -1
- package/dist/segmented-control.js +1 -1
- package/dist/{select-n_H52W1Z.js → select-D5rhJ8gi.js} +3 -2
- package/dist/select.js +1 -1
- package/dist/{signature-pad-q2SAsrdD.js → signature-pad-_bTeguN9.js} +256 -251
- package/dist/signature-pad.js +1 -1
- package/dist/slider-DVG6-Awh.js +308 -0
- package/dist/slider.js +1 -1
- package/dist/{sortable-data-table-tirqlLY2.js → sortable-data-table-CYKT_Ng7.js} +2 -2
- package/dist/sortable-data-table.js +1 -1
- package/dist/{split-button-Cb3EHs64.js → split-button-BCw4zZom.js} +75 -81
- package/dist/split-button.js +1 -1
- package/dist/{swipe-actions-DiZC57-3.js → swipe-actions-CBuJREU1.js} +4 -2
- package/dist/swipe-actions.js +1 -1
- package/dist/switch-C1WrKrf-.js +145 -0
- package/dist/switch.js +1 -1
- package/dist/tabs-XluwRjgg.js +210 -0
- package/dist/tabs.js +1 -1
- package/dist/{text-field-C8TWG-tY.js → text-field-hU72iSVS.js} +15 -13
- package/dist/text-field.js +1 -1
- package/dist/{textarea-BrW0XcG_.js → textarea-3k4Y0QQ3.js} +18 -16
- package/dist/textarea.js +1 -1
- package/dist/theme-root.js +1 -1
- package/dist/theme-switch-C505TtU8.js +166 -0
- package/dist/theme-switch.js +2 -0
- package/dist/{time-picker-Db8D49cP.js → time-picker-CPlhW0tr.js} +26 -20
- package/dist/time-picker.js +1 -1
- package/dist/{timeline-k3nURuCP.js → timeline-B0uAAVfT.js} +8 -2
- package/dist/timeline.js +1 -1
- package/dist/{toast-BHxI32ZA.js → toast-B7wo3sX1.js} +98 -79
- package/dist/{toast-stack-DqrAzdg5.js → toast-stack-B40VpS4M.js} +18 -4
- package/dist/toast-stack.js +1 -1
- package/dist/toast.js +1 -1
- package/dist/{toggle-group-fcjzpifI.js → toggle-group-B2fpFZwV.js} +1 -1
- package/dist/toggle-group.js +1 -1
- package/dist/tooltip-BvgVTCTN.js +120 -0
- package/dist/tooltip.js +1 -1
- package/dist/{tree-view-C2liIxqy.js → tree-view-j8qLqkb_.js} +5 -1
- package/dist/tree-view.js +1 -1
- package/dist/types/components/checkbox/checkbox.d.ts +1 -1
- package/dist/types/components/command-palette/command-palette.d.ts +1 -1
- package/dist/types/components/comment-thread/comment-thread.d.ts +118 -0
- package/dist/types/components/comment-thread/index.d.ts +1 -0
- package/dist/types/components/comment-thread/thread-core.d.ts +96 -0
- package/dist/types/components/comment-thread/thread-parts.d.ts +114 -0
- package/dist/types/components/context-menu/context-menu.d.ts +55 -0
- package/dist/types/components/context-menu/index.d.ts +2 -0
- package/dist/types/components/date-range-picker/date-range-picker.d.ts +1 -1
- package/dist/types/components/elastic-slider/elastic-slider.d.ts +53 -0
- package/dist/types/components/elastic-slider/index.d.ts +1 -0
- package/dist/types/components/expanding-search/expanding-search.d.ts +22 -0
- package/dist/types/components/expanding-search/index.d.ts +1 -0
- package/dist/types/components/menu/menu.d.ts +50 -7
- package/dist/types/components/pagination/pagination.d.ts +1 -1
- package/dist/types/components/radio-cards/radio-cards.d.ts +1 -1
- package/dist/types/components/radio-group/radio-group.d.ts +1 -1
- package/dist/types/components/slider/slider-style.d.ts +14 -0
- package/dist/types/components/slider/slider.d.ts +2 -10
- package/dist/types/components/slider/use-slider-interaction.d.ts +79 -0
- package/dist/types/components/split-button/split-button.d.ts +2 -2
- package/dist/types/components/tabs/tabs.d.ts +1 -1
- package/dist/types/components/text-field/text-field.d.ts +1 -1
- package/dist/types/components/textarea/textarea.d.ts +1 -1
- package/dist/types/components/theme-switch/index.d.ts +1 -0
- package/dist/types/components/theme-switch/theme-switch.d.ts +33 -0
- package/dist/types/components/tooltip/tooltip.d.ts +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/overlay/overlay-layer.d.ts +20 -0
- package/dist/types/overlay/use-overlay-floating.d.ts +9 -2
- package/dist/{use-overlay-floating-DvJifLpF.js → use-overlay-floating-Bx2jBKAA.js} +8 -6
- package/dist/use-slider-interaction-ChL-208h.js +234 -0
- package/package.json +22 -2
- package/dist/accordion-xCI_u0BV.js +0 -198
- package/dist/avatar-BahDVO9t.js +0 -132
- package/dist/badge-B_sLygxU.js +0 -108
- package/dist/card-D-aI2QHx.js +0 -158
- package/dist/carousel-IvPqN-oM.js +0 -472
- package/dist/command-palette-BQ5LleGb.js +0 -384
- package/dist/date-range-picker-B5uFWsm-.js +0 -562
- package/dist/file-dropzone-pR4v7owg.js +0 -457
- package/dist/mention-input-BcQKX2EJ.js +0 -599
- package/dist/menu-xwOOUtWP.js +0 -275
- package/dist/pill-DO2gHzMb.js +0 -56
- package/dist/popover-QHcEvf9c.js +0 -119
- package/dist/slider-t0B5cecO.js +0 -477
- package/dist/switch-qwv8jQnR.js +0 -142
- package/dist/tabs-CAVJndX1.js +0 -203
- package/dist/tooltip-CkeiW9C1.js +0 -113
- package/dist/{theme-root-BbTBuLMQ.js → theme-root-Bs1U3uPA.js} +2 -2
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { r as e, t } from "./sx-Dx9JUKp5.js";
|
|
3
|
-
import { n } from "./focus-ring-BK5W5_NY.js";
|
|
4
|
-
import { n as r, r as i } from "./media-8yrN85VT.js";
|
|
5
|
-
import { t as a } from "./use-latest-callback-cj1OOQL6.js";
|
|
6
|
-
import { t as ee } from "./use-controlled-state-DpeVQZNR.js";
|
|
7
|
-
import { t as te } from "./visually-hidden-BJdvqqvn.js";
|
|
8
|
-
import { t as o } from "./renderable-DzcIj1Lo.js";
|
|
9
|
-
import { t as ne } from "./button-C92uYFJW.js";
|
|
10
|
-
import { t as re } from "./progress-CbOWBUdA.js";
|
|
11
|
-
import { useEffect as s, useId as ie, useRef as c, useState as l } from "react";
|
|
12
|
-
import { vars as u } from "@jfrader/tokens/vars";
|
|
13
|
-
import { createElement as ae } from "@emotion/react";
|
|
14
|
-
import { jsx as d, jsxs as f } from "@emotion/react/jsx-runtime";
|
|
15
|
-
import { useMergeRefs as oe } from "@floating-ui/react";
|
|
16
|
-
//#region src/components/file-dropzone/file-dropzone.tsx
|
|
17
|
-
var se = e({
|
|
18
|
-
label: "file-dropzone",
|
|
19
|
-
display: "grid",
|
|
20
|
-
gap: u.space[3],
|
|
21
|
-
minInlineSize: 0,
|
|
22
|
-
color: u.color.text,
|
|
23
|
-
fontFamily: u.font.sans,
|
|
24
|
-
fontSize: u.textSize.sm,
|
|
25
|
-
lineHeight: u.lineHeight.base
|
|
26
|
-
}), ce = e({
|
|
27
|
-
position: "relative",
|
|
28
|
-
display: "grid",
|
|
29
|
-
border: `1px dashed ${u.color.borderControl}`,
|
|
30
|
-
borderRadius: u.radius.lg,
|
|
31
|
-
backgroundColor: u.color.surface,
|
|
32
|
-
cursor: "pointer",
|
|
33
|
-
transitionProperty: "background-color, border-color",
|
|
34
|
-
transitionDuration: u.motion.duration.fast,
|
|
35
|
-
transitionTimingFunction: u.motion.easeStandard,
|
|
36
|
-
"&:has(input:focus-visible)": n,
|
|
37
|
-
"&[data-dragging=\"true\"]": {
|
|
38
|
-
borderStyle: "solid",
|
|
39
|
-
backgroundColor: u.color.surfaceHover
|
|
40
|
-
},
|
|
41
|
-
[i]: { transitionDuration: "0s" },
|
|
42
|
-
[r]: { borderColor: "ButtonText" }
|
|
43
|
-
}), le = e({
|
|
44
|
-
display: "grid",
|
|
45
|
-
justifyItems: "center",
|
|
46
|
-
gap: u.space[3],
|
|
47
|
-
textAlign: "center"
|
|
48
|
-
}), ue = e({ cursor: "not-allowed" }), de = {
|
|
49
|
-
sm: e({ padding: u.space[4] }),
|
|
50
|
-
md: e({ padding: u.space[6] }),
|
|
51
|
-
lg: e({ padding: u.space[8] })
|
|
52
|
-
}, fe = {
|
|
53
|
-
sm: e({
|
|
54
|
-
paddingInline: u.space[4],
|
|
55
|
-
paddingBlockEnd: u.space[4]
|
|
56
|
-
}),
|
|
57
|
-
md: e({
|
|
58
|
-
paddingInline: u.space[6],
|
|
59
|
-
paddingBlockEnd: u.space[6]
|
|
60
|
-
}),
|
|
61
|
-
lg: e({
|
|
62
|
-
paddingInline: u.space[8],
|
|
63
|
-
paddingBlockEnd: u.space[8]
|
|
64
|
-
})
|
|
65
|
-
}, pe = e({
|
|
66
|
-
display: "inline-flex",
|
|
67
|
-
alignItems: "center",
|
|
68
|
-
minBlockSize: u.space[8],
|
|
69
|
-
paddingInline: u.space[3],
|
|
70
|
-
border: `1px solid ${u.color.borderControl}`,
|
|
71
|
-
borderRadius: u.radius.md,
|
|
72
|
-
fontWeight: u.fontWeight.medium,
|
|
73
|
-
overflowWrap: "anywhere"
|
|
74
|
-
}), me = e({
|
|
75
|
-
position: "absolute",
|
|
76
|
-
opacity: 0,
|
|
77
|
-
inlineSize: "1px",
|
|
78
|
-
blockSize: "1px"
|
|
79
|
-
}), p = e({ color: u.color.textMuted }), he = e({
|
|
80
|
-
display: "grid",
|
|
81
|
-
gap: u.space[2],
|
|
82
|
-
margin: 0,
|
|
83
|
-
padding: 0,
|
|
84
|
-
listStyle: "none",
|
|
85
|
-
inlineSize: "100%",
|
|
86
|
-
textAlign: "start"
|
|
87
|
-
}), ge = e({
|
|
88
|
-
display: "flex",
|
|
89
|
-
flexWrap: "wrap",
|
|
90
|
-
alignItems: "center",
|
|
91
|
-
gap: u.space[3],
|
|
92
|
-
padding: u.space[3],
|
|
93
|
-
border: `1px solid ${u.color.borderControl}`,
|
|
94
|
-
borderRadius: u.radius.md,
|
|
95
|
-
backgroundColor: u.color.surfaceRaised,
|
|
96
|
-
cursor: "default"
|
|
97
|
-
}), _e = e({
|
|
98
|
-
flex: "1 1 10rem",
|
|
99
|
-
minInlineSize: 0,
|
|
100
|
-
display: "grid",
|
|
101
|
-
gap: u.space[2],
|
|
102
|
-
overflowWrap: "anywhere"
|
|
103
|
-
}), ve = e({
|
|
104
|
-
inlineSize: u.space[12],
|
|
105
|
-
blockSize: u.space[12],
|
|
106
|
-
objectFit: "cover",
|
|
107
|
-
borderRadius: u.radius.sm
|
|
108
|
-
}), ye = e({
|
|
109
|
-
display: "flex",
|
|
110
|
-
flexWrap: "wrap",
|
|
111
|
-
gap: u.space[2]
|
|
112
|
-
}), be = e({
|
|
113
|
-
whiteSpace: "normal",
|
|
114
|
-
overflowWrap: "anywhere",
|
|
115
|
-
minBlockSize: u.space[8],
|
|
116
|
-
blockSize: "auto",
|
|
117
|
-
paddingBlock: u.space[2],
|
|
118
|
-
maxInlineSize: "100%"
|
|
119
|
-
}), xe = e({
|
|
120
|
-
color: u.color.dangerText,
|
|
121
|
-
overflowWrap: "anywhere"
|
|
122
|
-
}), Se = e({ "& > [data-ui=\"progress-indicator\"]": { transitionDuration: "0s" } }), Ce = "label, [data-file-row], a, button, input, select, textarea, [role=\"button\"]", we = [], Te = 5, Ee = 100, m = 1e3, h = [
|
|
123
|
-
"byte",
|
|
124
|
-
"kilobyte",
|
|
125
|
-
"megabyte",
|
|
126
|
-
"gigabyte"
|
|
127
|
-
], De = (e, t) => e.length === t.length && e.every((e, n) => e.id === t[n]?.id && e.file === t[n]?.file), g = (e) => Array.from(e.types).includes("Files"), Oe = (e, t) => e.name === t.name && e.size === t.size && e.lastModified === t.lastModified;
|
|
128
|
-
function ke(e, t) {
|
|
129
|
-
let n = t?.split(",").map((e) => e.trim().toLowerCase()).filter(Boolean) ?? [];
|
|
130
|
-
return !n.length || n.some((t) => t.startsWith(".") ? e.name.toLowerCase().endsWith(t) : !!e.type && (t.endsWith("/*") ? e.type.toLowerCase().startsWith(t.slice(0, -1)) : e.type.toLowerCase() === t));
|
|
131
|
-
}
|
|
132
|
-
function Ae(e, t) {
|
|
133
|
-
let n = e > 0 ? Math.min(Math.floor(Math.log(e) / Math.log(m)), h.length - 1) : 0;
|
|
134
|
-
return new Intl.NumberFormat(t, {
|
|
135
|
-
style: "unit",
|
|
136
|
-
unit: h[Math.max(0, n)],
|
|
137
|
-
unitDisplay: "short",
|
|
138
|
-
maximumFractionDigits: 1
|
|
139
|
-
}).format(e / m ** Math.max(0, n));
|
|
140
|
-
}
|
|
141
|
-
function _({ ref: e, value: n, defaultValue: r = we, onValueChange: i, onReject: u, accept: m, multiple: h = !0, maxFiles: _ = Te, maxSize: v, validate: je, onUpload: y, listPlacement: b = "below", compactAt: x, label: S, description: C, note: w, dropLabel: Me, error: T, messages: E, locale: Ne, disabled: D = !1, readOnly: O = !1, required: Pe = !1, size: Fe = "md", paste: Ie = !0, renderFileIcon: Le, name: Re, inputRef: ze, slotProps: k, className: Be, sx: Ve, onDragEnter: He, onDragOver: Ue, onDragLeave: We, onDrop: Ge, onPaste: Ke, ...qe }) {
|
|
142
|
-
let A = ie(), Je = c(r), [j = we, Ye, Xe] = ee(n, Je.current, i), M = c(null), N = c(null), Ze = oe([N, e]), Qe = oe([M, ze]), P = c(/* @__PURE__ */ new Map()), F = c(/* @__PURE__ */ new Map()), I = c(/* @__PURE__ */ new Map()), L = c(null), [, $e] = l(0), R = () => $e((e) => e + 1), [z, B] = l(!1), V = c(0), [H, et] = l([]), [tt, U] = l(""), [nt, rt] = l(/* @__PURE__ */ new Set()), W = D || O, G = o(S) && S !== "", it = o(C), K = o(w), q = o(T) || H.length > 0, J = k?.input, at = J?.id ?? `${A}-input`, ot = [
|
|
143
|
-
J?.["aria-describedby"],
|
|
144
|
-
it && `${A}-description`,
|
|
145
|
-
K && `${A}-note`,
|
|
146
|
-
q && `${A}-error`
|
|
147
|
-
].filter(Boolean).join(" ") || void 0, st = [J?.["aria-labelledby"], G && `${A}-label`].filter(Boolean).join(" ") || void 0, ct = q ? !0 : J?.["aria-invalid"], Y = (e) => {
|
|
148
|
-
De(j, e) || Ye(e);
|
|
149
|
-
}, lt = Number.isInteger(_) && _ > 0 ? _ : Te, X = a((e) => {
|
|
150
|
-
if (!e.file || !y) return;
|
|
151
|
-
P.current.get(e.id)?.controller.abort();
|
|
152
|
-
let t = {
|
|
153
|
-
file: e.file,
|
|
154
|
-
controller: new AbortController(),
|
|
155
|
-
status: "uploading"
|
|
156
|
-
};
|
|
157
|
-
P.current.set(e.id, t), R();
|
|
158
|
-
let n = () => !t.controller.signal.aborted && P.current.get(e.id) === t, r = (e) => {
|
|
159
|
-
n() && t.status === "uploading" && Number.isFinite(e) && (t.progress = Math.max(t.progress ?? 0, Math.min(Ee, Math.max(0, e))), R());
|
|
160
|
-
};
|
|
161
|
-
Promise.resolve().then(() => {
|
|
162
|
-
if (n()) return y(e, {
|
|
163
|
-
signal: t.controller.signal,
|
|
164
|
-
onProgress: r
|
|
165
|
-
});
|
|
166
|
-
}).then(() => {
|
|
167
|
-
n() && (t.status = "uploaded", U(E.status("uploaded", e.name)), R());
|
|
168
|
-
}, (r) => {
|
|
169
|
-
n() && (r instanceof Error && r.name === "AbortError" ? (t.status = "idle", R()) : (t.status = "failed", t.error = r instanceof Error && r.message.trim() ? r.message : E.uploadError, U(E.status("failed", e.name)), R()));
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
s(() => {
|
|
173
|
-
let e = !1, t = 0;
|
|
174
|
-
for (let [t, n] of P.current) j.some((e) => e.id === t && e.file === n.file) || (n.controller.abort(), P.current.delete(t), e = !0);
|
|
175
|
-
for (let [t, n] of I.current) j.some((e) => e.id === t && e.file === n.file && e.preview === void 0) || (URL.revokeObjectURL(n.url), I.current.delete(t), e = !0);
|
|
176
|
-
for (let n of j) {
|
|
177
|
-
let r = F.current.get(n.id);
|
|
178
|
-
r && r.file === n.file && (F.current.delete(n.id), n.file?.type.startsWith("image/") && n.preview === void 0 && !I.current.has(n.id) && (I.current.set(n.id, {
|
|
179
|
-
file: n.file,
|
|
180
|
-
url: URL.createObjectURL(n.file)
|
|
181
|
-
}), e = !0), t++, X(n));
|
|
182
|
-
}
|
|
183
|
-
t && U(E.added(t));
|
|
184
|
-
let n = L.current;
|
|
185
|
-
n && !j.some((e) => e.id === n.item.id && e.file === n.item.file) && (L.current = null, U(E.removed(n.item.name)), n.active && (N.current?.ownerDocument.activeElement === n.active || N.current?.ownerDocument.activeElement === N.current?.ownerDocument.body) && ((N.current?.querySelectorAll("[data-file-row]")?.[Math.min(n.index, j.length - 1)])?.querySelector("[data-action=\"remove\"]") ?? M.current)?.focus()), e && R();
|
|
186
|
-
}, [
|
|
187
|
-
j,
|
|
188
|
-
E,
|
|
189
|
-
X
|
|
190
|
-
]), s(() => () => {
|
|
191
|
-
for (let e of P.current.values()) e.controller.abort();
|
|
192
|
-
P.current.clear();
|
|
193
|
-
for (let e of I.current.values()) URL.revokeObjectURL(e.url);
|
|
194
|
-
I.current.clear(), F.current.clear();
|
|
195
|
-
}, []);
|
|
196
|
-
let ut = a(() => {
|
|
197
|
-
F.current.clear(), et([]), U(""), n === void 0 ? Xe() : Y(Je.current);
|
|
198
|
-
});
|
|
199
|
-
s(() => {
|
|
200
|
-
let e = M.current?.form, t = (e) => {
|
|
201
|
-
queueMicrotask(() => {
|
|
202
|
-
e.defaultPrevented || ut();
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
|
-
return e?.addEventListener("reset", t), () => e?.removeEventListener("reset", t);
|
|
206
|
-
}, [ut]);
|
|
207
|
-
function Z(e) {
|
|
208
|
-
if (W) return;
|
|
209
|
-
let t = [], n = [], r = h ? j : j.filter((e) => !e.file);
|
|
210
|
-
for (let i of e) {
|
|
211
|
-
let e, a = null;
|
|
212
|
-
ke(i, m) ? v !== void 0 && Number.isFinite(v) && v >= 0 && i.size > v ? e = "size" : (a = je?.(i) ?? null, a !== null && (e = "custom")) : e = "type", (e || !j.some((e) => e.file && Oe(e.file, i)) && !n.some((e) => Oe(e, i))) && (!e && (r.length + n.length >= lt || !h && n.length >= 1) && (e = "count"), e ? t.push({
|
|
213
|
-
file: i,
|
|
214
|
-
code: e,
|
|
215
|
-
message: e === "custom" ? a : E.rejection(e, i)
|
|
216
|
-
}) : n.push(i));
|
|
217
|
-
}
|
|
218
|
-
if (et(t), t.length && u?.(t), !n.length) return;
|
|
219
|
-
let i = n.map((e) => ({
|
|
220
|
-
id: crypto.randomUUID(),
|
|
221
|
-
file: e,
|
|
222
|
-
name: e.name,
|
|
223
|
-
size: e.size
|
|
224
|
-
}));
|
|
225
|
-
F.current.clear();
|
|
226
|
-
for (let e of i) F.current.set(e.id, e);
|
|
227
|
-
Y([...r, ...i]);
|
|
228
|
-
}
|
|
229
|
-
function dt(e, t) {
|
|
230
|
-
if (W) return;
|
|
231
|
-
let n = N.current?.querySelectorAll("[data-file-row]")[t], r = N.current?.ownerDocument.activeElement ?? null;
|
|
232
|
-
L.current = {
|
|
233
|
-
item: e,
|
|
234
|
-
index: t,
|
|
235
|
-
active: n?.contains(r) ? r : null
|
|
236
|
-
}, Y(j.filter((t) => t.id !== e.id));
|
|
237
|
-
}
|
|
238
|
-
function ft(e, t, n) {
|
|
239
|
-
if (!W && e.target instanceof HTMLButtonElement && ((e.key === "Delete" || e.key === "Backspace") && (e.preventDefault(), dt(t, n)), e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
240
|
-
e.preventDefault();
|
|
241
|
-
let t = n + (e.key === "ArrowUp" ? -1 : 1), r = N.current?.querySelectorAll("[data-file-row]")[t], i = e.target.dataset.action;
|
|
242
|
-
(r?.querySelector(`[data-action="${i}"]`) ?? r?.querySelector("[data-action=\"remove\"]"))?.focus();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
let Q = j.length > 0 && /* @__PURE__ */ d("ul", {
|
|
246
|
-
...k?.list,
|
|
247
|
-
"aria-label": k?.list?.["aria-label"] ?? E.files,
|
|
248
|
-
css: [
|
|
249
|
-
he,
|
|
250
|
-
b === "inside" && fe[Fe],
|
|
251
|
-
k?.list?.css
|
|
252
|
-
],
|
|
253
|
-
children: j.map((e, t) => {
|
|
254
|
-
let n = P.current.get(e.id), r = n?.status ?? (e.uploaded ? "uploaded" : "idle"), i = e.preview ?? I.current.get(e.id)?.url, a = Le?.(e);
|
|
255
|
-
return /* @__PURE__ */ ae("li", {
|
|
256
|
-
...k?.item,
|
|
257
|
-
key: e.id,
|
|
258
|
-
"data-file-row": !0,
|
|
259
|
-
"data-state": r,
|
|
260
|
-
onKeyDown: (n) => {
|
|
261
|
-
k?.item?.onKeyDown?.(n), n.defaultPrevented || ft(n, e, t);
|
|
262
|
-
},
|
|
263
|
-
css: [ge, k?.item?.css]
|
|
264
|
-
}, i && !nt.has(i) ? /* @__PURE__ */ d("img", {
|
|
265
|
-
...k?.preview,
|
|
266
|
-
src: i,
|
|
267
|
-
alt: "",
|
|
268
|
-
css: [ve, k?.preview?.css],
|
|
269
|
-
onError: (e) => {
|
|
270
|
-
k?.preview?.onError?.(e), rt((e) => /* @__PURE__ */ new Set([...e, i]));
|
|
271
|
-
}
|
|
272
|
-
}) : o(a) && /* @__PURE__ */ d("span", {
|
|
273
|
-
"aria-hidden": !0,
|
|
274
|
-
children: a
|
|
275
|
-
}), /* @__PURE__ */ f("div", {
|
|
276
|
-
css: _e,
|
|
277
|
-
children: [
|
|
278
|
-
/* @__PURE__ */ d("bdi", { children: e.name }),
|
|
279
|
-
/* @__PURE__ */ d("span", {
|
|
280
|
-
css: p,
|
|
281
|
-
children: Ae(e.size, Ne)
|
|
282
|
-
}),
|
|
283
|
-
/* @__PURE__ */ d("span", { children: E.status(r, e.name) }),
|
|
284
|
-
r === "uploading" && /* @__PURE__ */ d(re, {
|
|
285
|
-
...k?.progress,
|
|
286
|
-
value: n?.progress,
|
|
287
|
-
"aria-label": k?.progress?.["aria-label"] ?? e.name,
|
|
288
|
-
getValueLabel: (e) => new Intl.NumberFormat(Ne, { style: "percent" }).format(e / Ee),
|
|
289
|
-
css: [Se, k?.progress?.css]
|
|
290
|
-
}),
|
|
291
|
-
n?.error && /* @__PURE__ */ d("span", {
|
|
292
|
-
css: xe,
|
|
293
|
-
children: n.error
|
|
294
|
-
})
|
|
295
|
-
]
|
|
296
|
-
}), /* @__PURE__ */ f("div", {
|
|
297
|
-
css: ye,
|
|
298
|
-
children: [r === "failed" && e.file && y && /* @__PURE__ */ d(ne, {
|
|
299
|
-
...k?.action,
|
|
300
|
-
css: [be, k?.action?.css],
|
|
301
|
-
variant: "outline",
|
|
302
|
-
size: "sm",
|
|
303
|
-
disabled: D,
|
|
304
|
-
"aria-disabled": O || k?.action?.["aria-disabled"],
|
|
305
|
-
"data-action": "retry",
|
|
306
|
-
"aria-label": k?.action?.["aria-label"] ?? E.retry(e.name),
|
|
307
|
-
onClick: (t) => {
|
|
308
|
-
k?.action?.onClick?.(t), !t.defaultPrevented && !W && (X(e), t.currentTarget.parentElement?.querySelector("[data-action=\"remove\"]")?.focus());
|
|
309
|
-
},
|
|
310
|
-
children: E.retry(e.name)
|
|
311
|
-
}), /* @__PURE__ */ d(ne, {
|
|
312
|
-
...k?.action,
|
|
313
|
-
css: [be, k?.action?.css],
|
|
314
|
-
variant: "outline",
|
|
315
|
-
size: "sm",
|
|
316
|
-
disabled: D,
|
|
317
|
-
"aria-disabled": O || k?.action?.["aria-disabled"],
|
|
318
|
-
"data-action": "remove",
|
|
319
|
-
"aria-label": k?.action?.["aria-label"] ?? E.remove(e.name),
|
|
320
|
-
onClick: (n) => {
|
|
321
|
-
k?.action?.onClick?.(n), n.defaultPrevented || dt(e, t);
|
|
322
|
-
},
|
|
323
|
-
children: E.remove(e.name)
|
|
324
|
-
})]
|
|
325
|
-
}));
|
|
326
|
-
})
|
|
327
|
-
}), $ = x !== void 0 && x > 0 && j.length >= x && !z;
|
|
328
|
-
return /* @__PURE__ */ d(t, {
|
|
329
|
-
className: [k?.root?.className, Be].filter(Boolean).join(" "),
|
|
330
|
-
styles: [se, k?.root?.css],
|
|
331
|
-
sx: Ve,
|
|
332
|
-
children: (e) => /* @__PURE__ */ f("div", {
|
|
333
|
-
...k?.root,
|
|
334
|
-
...qe,
|
|
335
|
-
ref: Ze,
|
|
336
|
-
className: e,
|
|
337
|
-
"data-ui": "file-dropzone",
|
|
338
|
-
"data-state": z ? "dragging" : j.length ? "selected" : "empty",
|
|
339
|
-
"aria-disabled": W || qe["aria-disabled"] || k?.root?.["aria-disabled"],
|
|
340
|
-
onDragEnter: (e) => {
|
|
341
|
-
k?.root?.onDragEnter?.(e), He?.(e), !e.defaultPrevented && !W && g(e.dataTransfer) && (e.preventDefault(), V.current++, B(!0));
|
|
342
|
-
},
|
|
343
|
-
onDragOver: (e) => {
|
|
344
|
-
k?.root?.onDragOver?.(e), Ue?.(e), !e.defaultPrevented && !W && g(e.dataTransfer) && (e.preventDefault(), e.dataTransfer.dropEffect = "copy");
|
|
345
|
-
},
|
|
346
|
-
onDragLeave: (e) => {
|
|
347
|
-
k?.root?.onDragLeave?.(e), We?.(e), !e.defaultPrevented && g(e.dataTransfer) && (V.current = Math.max(0, V.current - 1), V.current || B(!1));
|
|
348
|
-
},
|
|
349
|
-
onDrop: (e) => {
|
|
350
|
-
k?.root?.onDrop?.(e), Ge?.(e), V.current = 0, B(!1), !e.defaultPrevented && g(e.dataTransfer) && (e.preventDefault(), Z(Array.from(e.dataTransfer.files)));
|
|
351
|
-
},
|
|
352
|
-
onPaste: (e) => {
|
|
353
|
-
k?.root?.onPaste?.(e), Ke?.(e);
|
|
354
|
-
let t = e.target;
|
|
355
|
-
!e.defaultPrevented && Ie && !W && N.current?.contains(N.current.ownerDocument.activeElement) && !t.closest("input, textarea, [contenteditable]:not([contenteditable=\"false\"])") && e.clipboardData.files.length && (e.preventDefault(), Z(Array.from(e.clipboardData.files)));
|
|
356
|
-
},
|
|
357
|
-
children: [
|
|
358
|
-
/* @__PURE__ */ f("div", {
|
|
359
|
-
...k?.target,
|
|
360
|
-
"data-dragging": z,
|
|
361
|
-
"data-compact": $,
|
|
362
|
-
css: [
|
|
363
|
-
ce,
|
|
364
|
-
W && ue,
|
|
365
|
-
k?.target?.css
|
|
366
|
-
],
|
|
367
|
-
onClick: (e) => {
|
|
368
|
-
k?.target?.onClick?.(e);
|
|
369
|
-
let t = e.target.closest(Ce);
|
|
370
|
-
!e.defaultPrevented && !W && !e.currentTarget.contains(t) && M.current?.click();
|
|
371
|
-
},
|
|
372
|
-
children: [/* @__PURE__ */ f("label", {
|
|
373
|
-
...k?.label,
|
|
374
|
-
htmlFor: at,
|
|
375
|
-
css: [
|
|
376
|
-
le,
|
|
377
|
-
de[Fe],
|
|
378
|
-
k?.label?.css
|
|
379
|
-
],
|
|
380
|
-
children: [
|
|
381
|
-
/* @__PURE__ */ d("input", {
|
|
382
|
-
...J,
|
|
383
|
-
ref: Qe,
|
|
384
|
-
id: at,
|
|
385
|
-
type: "file",
|
|
386
|
-
name: Re,
|
|
387
|
-
accept: m,
|
|
388
|
-
multiple: h,
|
|
389
|
-
required: Pe,
|
|
390
|
-
disabled: D,
|
|
391
|
-
"aria-disabled": O || J?.["aria-disabled"],
|
|
392
|
-
"aria-labelledby": st,
|
|
393
|
-
"aria-label": J?.["aria-label"] ?? (!G && !J?.["aria-labelledby"] ? E.browse : void 0),
|
|
394
|
-
"aria-describedby": ot,
|
|
395
|
-
"aria-invalid": ct,
|
|
396
|
-
css: [me, J?.css],
|
|
397
|
-
onClick: (e) => {
|
|
398
|
-
J?.onClick?.(e), W && e.preventDefault();
|
|
399
|
-
},
|
|
400
|
-
onChange: (e) => {
|
|
401
|
-
J?.onChange?.(e), e.defaultPrevented || Z(Array.from(e.currentTarget.files ?? [])), e.currentTarget.value = "";
|
|
402
|
-
}
|
|
403
|
-
}),
|
|
404
|
-
G && /* @__PURE__ */ d("span", {
|
|
405
|
-
id: `${A}-label`,
|
|
406
|
-
children: S
|
|
407
|
-
}),
|
|
408
|
-
it && /* @__PURE__ */ d("div", {
|
|
409
|
-
...k?.description,
|
|
410
|
-
id: `${A}-description`,
|
|
411
|
-
css: [$ ? te : p, k?.description?.css],
|
|
412
|
-
children: C
|
|
413
|
-
}),
|
|
414
|
-
z && o(Me) && /* @__PURE__ */ d("div", { children: Me }),
|
|
415
|
-
$ && /* @__PURE__ */ d("span", { children: E.count(j.length) }),
|
|
416
|
-
/* @__PURE__ */ d("span", {
|
|
417
|
-
...k?.browse,
|
|
418
|
-
"aria-hidden": !0,
|
|
419
|
-
css: [pe, k?.browse?.css],
|
|
420
|
-
children: E.browse
|
|
421
|
-
}),
|
|
422
|
-
K && /* @__PURE__ */ d("div", {
|
|
423
|
-
...k?.note,
|
|
424
|
-
id: `${A}-note`,
|
|
425
|
-
css: [p, k?.note?.css],
|
|
426
|
-
children: w
|
|
427
|
-
})
|
|
428
|
-
]
|
|
429
|
-
}), b === "inside" && Q]
|
|
430
|
-
}),
|
|
431
|
-
q && /* @__PURE__ */ f("div", {
|
|
432
|
-
...k?.error,
|
|
433
|
-
id: `${A}-error`,
|
|
434
|
-
role: "alert",
|
|
435
|
-
css: [xe, k?.error?.css],
|
|
436
|
-
children: [o(T) && T, H.length > 0 && /* @__PURE__ */ d("ul", { children: H.map((e, t) => /* @__PURE__ */ f("li", { children: [
|
|
437
|
-
/* @__PURE__ */ d("bdi", { children: e.file.name }),
|
|
438
|
-
": ",
|
|
439
|
-
e.message
|
|
440
|
-
] }, t)) })]
|
|
441
|
-
}),
|
|
442
|
-
b === "below" && Q,
|
|
443
|
-
/* @__PURE__ */ d("div", {
|
|
444
|
-
...k?.status,
|
|
445
|
-
role: "status",
|
|
446
|
-
"aria-live": "polite",
|
|
447
|
-
"aria-atomic": "true",
|
|
448
|
-
css: [te, k?.status?.css],
|
|
449
|
-
children: tt
|
|
450
|
-
})
|
|
451
|
-
]
|
|
452
|
-
})
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
_.displayName = "FileDropzone";
|
|
456
|
-
//#endregion
|
|
457
|
-
export { _ as t };
|