@sprawlify/primitives 0.0.23 → 0.0.25
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/{collection-0DmMA3br.mjs → collection-Don0IqzY.mjs} +1 -1
- package/dist/{collection-DIoIDISa.cjs → collection-DrxGD6r-.cjs} +1 -1
- package/dist/collection.cjs +2 -2
- package/dist/collection.mjs +2 -2
- package/dist/{color-utils-D0Lo5X-u.mjs → color-utils-CjwofPil.mjs} +1 -1
- package/dist/{color-utils-LER_6Zwu.cjs → color-utils-grkMlPoh.cjs} +1 -1
- package/dist/color-utils.cjs +2 -2
- package/dist/color-utils.mjs +2 -2
- package/dist/{core-CQFbMdTl.cjs → core-DHn58LRl.cjs} +1 -1
- package/dist/{core-qHH8MshY.mjs → core-DVmt6PX7.mjs} +1 -1
- package/dist/core.cjs +2 -2
- package/dist/core.mjs +2 -2
- package/dist/date-utils.d.mts +1 -1
- package/dist/{dismissable-C-6M-juU.mjs → dismissable-CyZwVu7n.mjs} +2 -2
- package/dist/{dismissable-layer-2TW8ZBcS.d.cts → dismissable-layer-DmvOBneO.d.cts} +1 -1
- package/dist/{dismissable-layer-CllXZ1N9.d.mts → dismissable-layer-xYn_dIUQ.d.mts} +1 -1
- package/dist/{dismissable-CTfKZ4OG.cjs → dismissable-rIq_LmT8.cjs} +2 -2
- package/dist/dismissable.cjs +3 -3
- package/dist/dismissable.d.cts +1 -1
- package/dist/dismissable.d.mts +1 -1
- package/dist/dismissable.mjs +3 -3
- package/dist/dom-query.d.cts +1 -1
- package/dist/dom-query.d.mts +1 -1
- package/dist/{focus-trap-DMoa9bOi.cjs → focus-trap-Brjt3GUU.cjs} +6 -7
- package/dist/{focus-trap-BG22frp5.mjs → focus-trap-C_QmP_9k.mjs} +6 -7
- package/dist/focus-trap.cjs +1 -1
- package/dist/focus-trap.mjs +1 -1
- package/dist/{functions-DFnYr-gp.d.cts → functions-2ix8ad1e.d.cts} +2 -1
- package/dist/{functions-i_nVCRW0.d.mts → functions-qoGE2jOS.d.mts} +2 -1
- package/dist/{index-DLhTkdnW.d.mts → index-DYzqCFaj.d.mts} +5 -5
- package/dist/{interact-outside-BtY3-DVp.mjs → interact-outside-D9gKK1XW.mjs} +1 -1
- package/dist/{interact-outside-C8-oFBpB.cjs → interact-outside-Dp8GERFa.cjs} +1 -1
- package/dist/interact-outside.cjs +2 -2
- package/dist/interact-outside.mjs +2 -2
- package/dist/machines/accordion/index.cjs +2 -2
- package/dist/machines/accordion/index.d.cts +1 -1
- package/dist/machines/accordion/index.d.mts +1 -1
- package/dist/machines/accordion/index.mjs +2 -2
- package/dist/machines/angle-slider/index.cjs +2 -2
- package/dist/machines/angle-slider/index.d.cts +1 -1
- package/dist/machines/angle-slider/index.d.mts +1 -1
- package/dist/machines/angle-slider/index.mjs +2 -2
- package/dist/machines/async-list/index.cjs +2 -2
- package/dist/machines/async-list/index.mjs +2 -2
- package/dist/machines/avatar/index.cjs +2 -2
- package/dist/machines/avatar/index.mjs +2 -2
- package/dist/machines/bottom-sheet/index.cjs +5 -5
- package/dist/machines/bottom-sheet/index.d.cts +2 -2
- package/dist/machines/bottom-sheet/index.d.mts +2 -2
- package/dist/machines/bottom-sheet/index.mjs +5 -5
- package/dist/machines/carousel/index.cjs +2 -2
- package/dist/machines/carousel/index.d.cts +1 -1
- package/dist/machines/carousel/index.d.mts +1 -1
- package/dist/machines/carousel/index.mjs +2 -2
- package/dist/machines/checkbox/index.cjs +2 -2
- package/dist/machines/checkbox/index.mjs +2 -2
- package/dist/machines/clipboard/index.cjs +2 -2
- package/dist/machines/clipboard/index.d.cts +1 -1
- package/dist/machines/clipboard/index.d.mts +1 -1
- package/dist/machines/clipboard/index.mjs +2 -2
- package/dist/machines/collapsible/index.cjs +2 -2
- package/dist/machines/collapsible/index.d.cts +1 -1
- package/dist/machines/collapsible/index.d.mts +1 -1
- package/dist/machines/collapsible/index.mjs +2 -2
- package/dist/machines/color-picker/index.cjs +6 -6
- package/dist/machines/color-picker/index.d.cts +1 -1
- package/dist/machines/color-picker/index.d.mts +1 -1
- package/dist/machines/color-picker/index.mjs +6 -6
- package/dist/machines/combobox/index.cjs +6 -6
- package/dist/machines/combobox/index.d.cts +1 -1
- package/dist/machines/combobox/index.d.mts +1 -1
- package/dist/machines/combobox/index.mjs +6 -6
- package/dist/machines/date-picker/index.cjs +5 -5
- package/dist/machines/date-picker/index.d.cts +1 -1
- package/dist/machines/date-picker/index.d.mts +2 -2
- package/dist/machines/date-picker/index.mjs +5 -5
- package/dist/machines/dialog/index.cjs +5 -5
- package/dist/machines/dialog/index.d.cts +2 -2
- package/dist/machines/dialog/index.d.mts +2 -2
- package/dist/machines/dialog/index.mjs +5 -5
- package/dist/machines/editable/index.cjs +3 -3
- package/dist/machines/editable/index.d.cts +1 -1
- package/dist/machines/editable/index.d.mts +1 -1
- package/dist/machines/editable/index.mjs +3 -3
- package/dist/machines/file-upload/index.cjs +50 -30
- package/dist/machines/file-upload/index.d.cts +6 -1
- package/dist/machines/file-upload/index.d.mts +6 -1
- package/dist/machines/file-upload/index.mjs +50 -30
- package/dist/machines/floating-panel/index.cjs +2 -2
- package/dist/machines/floating-panel/index.d.cts +1 -1
- package/dist/machines/floating-panel/index.d.mts +1 -1
- package/dist/machines/floating-panel/index.mjs +2 -2
- package/dist/machines/hover-card/index.cjs +5 -5
- package/dist/machines/hover-card/index.d.cts +1 -1
- package/dist/machines/hover-card/index.d.mts +1 -1
- package/dist/machines/hover-card/index.mjs +5 -5
- package/dist/machines/image-cropper/index.cjs +2 -2
- package/dist/machines/image-cropper/index.mjs +2 -2
- package/dist/machines/listbox/index.cjs +3 -3
- package/dist/machines/listbox/index.d.cts +1 -1
- package/dist/machines/listbox/index.d.mts +1 -1
- package/dist/machines/listbox/index.mjs +3 -3
- package/dist/machines/marquee/index.cjs +2 -2
- package/dist/machines/marquee/index.d.cts +2 -2
- package/dist/machines/marquee/index.d.mts +2 -2
- package/dist/machines/marquee/index.mjs +2 -2
- package/dist/machines/menu/index.cjs +5 -5
- package/dist/machines/menu/index.d.cts +2 -2
- package/dist/machines/menu/index.d.mts +2 -2
- package/dist/machines/menu/index.mjs +5 -5
- package/dist/machines/navigation-menu/index.cjs +4 -4
- package/dist/machines/navigation-menu/index.d.cts +1 -1
- package/dist/machines/navigation-menu/index.d.mts +1 -1
- package/dist/machines/navigation-menu/index.mjs +4 -4
- package/dist/machines/number-input/index.cjs +2 -2
- package/dist/machines/number-input/index.d.cts +1 -1
- package/dist/machines/number-input/index.d.mts +1 -1
- package/dist/machines/number-input/index.mjs +2 -2
- package/dist/machines/pagination/index.cjs +2 -2
- package/dist/machines/pagination/index.mjs +2 -2
- package/dist/machines/password-input/index.cjs +2 -2
- package/dist/machines/password-input/index.d.cts +1 -1
- package/dist/machines/password-input/index.d.mts +1 -1
- package/dist/machines/password-input/index.mjs +2 -2
- package/dist/machines/pin-input/index.cjs +2 -2
- package/dist/machines/pin-input/index.d.cts +1 -1
- package/dist/machines/pin-input/index.d.mts +1 -1
- package/dist/machines/pin-input/index.mjs +2 -2
- package/dist/machines/popover/index.cjs +6 -6
- package/dist/machines/popover/index.d.cts +2 -2
- package/dist/machines/popover/index.d.mts +2 -2
- package/dist/machines/popover/index.mjs +6 -6
- package/dist/machines/presence/index.cjs +2 -2
- package/dist/machines/presence/index.mjs +2 -2
- package/dist/machines/progress/index.cjs +2 -2
- package/dist/machines/progress/index.d.cts +1 -1
- package/dist/machines/progress/index.d.mts +1 -1
- package/dist/machines/progress/index.mjs +2 -2
- package/dist/machines/qr-code/index.cjs +2 -2
- package/dist/machines/qr-code/index.mjs +2 -2
- package/dist/machines/radio-group/index.cjs +2 -2
- package/dist/machines/radio-group/index.d.cts +1 -1
- package/dist/machines/radio-group/index.d.mts +1 -1
- package/dist/machines/radio-group/index.mjs +2 -2
- package/dist/machines/rating-group/index.cjs +2 -2
- package/dist/machines/rating-group/index.d.cts +1 -1
- package/dist/machines/rating-group/index.d.mts +1 -1
- package/dist/machines/rating-group/index.mjs +2 -2
- package/dist/machines/scroll-area/index.cjs +2 -2
- package/dist/machines/scroll-area/index.mjs +2 -2
- package/dist/machines/select/index.cjs +6 -6
- package/dist/machines/select/index.d.cts +1 -1
- package/dist/machines/select/index.d.mts +1 -1
- package/dist/machines/select/index.mjs +6 -6
- package/dist/machines/signature-pad/index.cjs +2 -2
- package/dist/machines/signature-pad/index.mjs +2 -2
- package/dist/machines/slider/index.cjs +2 -2
- package/dist/machines/slider/index.d.cts +1 -1
- package/dist/machines/slider/index.d.mts +1 -1
- package/dist/machines/slider/index.mjs +2 -2
- package/dist/machines/splitter/index.cjs +2 -2
- package/dist/machines/splitter/index.d.cts +1 -1
- package/dist/machines/splitter/index.d.mts +1 -1
- package/dist/machines/splitter/index.mjs +2 -2
- package/dist/machines/steps/index.cjs +2 -2
- package/dist/machines/steps/index.d.cts +1 -1
- package/dist/machines/steps/index.d.mts +1 -1
- package/dist/machines/steps/index.mjs +2 -2
- package/dist/machines/switch/index.cjs +2 -2
- package/dist/machines/switch/index.mjs +2 -2
- package/dist/machines/tabs/index.cjs +2 -2
- package/dist/machines/tabs/index.d.cts +1 -1
- package/dist/machines/tabs/index.d.mts +1 -1
- package/dist/machines/tabs/index.mjs +2 -2
- package/dist/machines/tags-input/index.cjs +3 -3
- package/dist/machines/tags-input/index.d.cts +1 -1
- package/dist/machines/tags-input/index.d.mts +1 -1
- package/dist/machines/tags-input/index.mjs +3 -3
- package/dist/machines/timer/index.cjs +2 -2
- package/dist/machines/timer/index.d.cts +1 -1
- package/dist/machines/timer/index.d.mts +1 -1
- package/dist/machines/timer/index.mjs +2 -2
- package/dist/machines/toast/index.cjs +4 -4
- package/dist/machines/toast/index.d.cts +1 -1
- package/dist/machines/toast/index.d.mts +1 -1
- package/dist/machines/toast/index.mjs +4 -4
- package/dist/machines/toggle/index.cjs +2 -2
- package/dist/machines/toggle/index.mjs +2 -2
- package/dist/machines/toggle-group/index.cjs +2 -2
- package/dist/machines/toggle-group/index.mjs +2 -2
- package/dist/machines/tooltip/index.cjs +3 -3
- package/dist/machines/tooltip/index.d.cts +1 -1
- package/dist/machines/tooltip/index.d.mts +1 -1
- package/dist/machines/tooltip/index.mjs +3 -3
- package/dist/machines/tour/index.cjs +6 -6
- package/dist/machines/tour/index.d.cts +1 -1
- package/dist/machines/tour/index.d.mts +1 -1
- package/dist/machines/tour/index.mjs +6 -6
- package/dist/machines/tree-view/index.cjs +3 -3
- package/dist/machines/tree-view/index.d.cts +1 -1
- package/dist/machines/tree-view/index.d.mts +1 -1
- package/dist/machines/tree-view/index.mjs +3 -3
- package/dist/{popper-PO8HYerg.mjs → popper-CjBC91Tz.mjs} +1 -1
- package/dist/{popper-Bv3pzKqX.cjs → popper-kp05O3Bm.cjs} +1 -1
- package/dist/popper.cjs +2 -2
- package/dist/popper.mjs +2 -2
- package/dist/{utils-hFKGi-oS.mjs → utils-BIwaJq8z.mjs} +14 -1
- package/dist/{utils-_6frwjgJ.cjs → utils-CtgLe8Vv.cjs} +19 -0
- package/dist/utils.cjs +2 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.mts +2 -2
- package/dist/utils.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_create_anatomy = require('../../create-anatomy-CDsIFUXg.cjs');
|
|
2
2
|
const require_dom_query = require('../../dom-query-CWZdWUGp.cjs');
|
|
3
|
-
const require_utils = require('../../utils-
|
|
4
|
-
const require_core = require('../../core-
|
|
3
|
+
const require_utils = require('../../utils-CtgLe8Vv.cjs');
|
|
4
|
+
const require_core = require('../../core-DHn58LRl.cjs');
|
|
5
5
|
const require_file_utils = require('../../file-utils-G9_tYexo.cjs');
|
|
6
6
|
const require_i18n_utils = require('../../i18n-utils-B8IY1mOh.cjs');
|
|
7
7
|
const require_create_props = require('../../create-props-l5q5b8Wo.cjs');
|
|
@@ -21,6 +21,8 @@ const getItemId = (ctx, id) => ctx.ids?.item?.(id) ?? `file-upload:${ctx.id}:ite
|
|
|
21
21
|
const getItemNameId = (ctx, id) => ctx.ids?.itemName?.(id) ?? `file-upload:${ctx.id}:item-name:${id}`;
|
|
22
22
|
const getItemSizeTextId = (ctx, id) => ctx.ids?.itemSizeText?.(id) ?? `file-upload:${ctx.id}:item-size:${id}`;
|
|
23
23
|
const getItemPreviewId = (ctx, id) => ctx.ids?.itemPreview?.(id) ?? `file-upload:${ctx.id}:item-preview:${id}`;
|
|
24
|
+
const getItemDeleteTriggerId = (ctx, id) => ctx.ids?.itemDeleteTrigger?.(id) ?? `file:${ctx.id}:item-delete:${id}`;
|
|
25
|
+
const getFileId = (file) => require_utils.hash(`${file.name}-${file.size}`);
|
|
24
26
|
const getRootEl = (ctx) => ctx.getById(getRootId(ctx));
|
|
25
27
|
const getHiddenInputEl = (ctx) => ctx.getById(getHiddenInputId(ctx));
|
|
26
28
|
const getDropzoneEl = (ctx) => ctx.getById(getDropzoneId(ctx));
|
|
@@ -103,29 +105,38 @@ function isInteractiveTarget(element, container) {
|
|
|
103
105
|
function connect(service, normalize) {
|
|
104
106
|
const { state, send, prop, computed, scope, context } = service;
|
|
105
107
|
const disabled = !!prop("disabled");
|
|
108
|
+
const readOnly = !!prop("readOnly");
|
|
106
109
|
const required = !!prop("required");
|
|
107
110
|
const allowDrop = prop("allowDrop");
|
|
108
111
|
const translations = prop("translations");
|
|
109
112
|
const dragging = state.matches("dragging");
|
|
113
|
+
const focused = state.matches("focused") && !disabled;
|
|
114
|
+
const acceptedFiles = context.get("acceptedFiles");
|
|
115
|
+
const maxFiles = prop("maxFiles");
|
|
110
116
|
return {
|
|
111
117
|
dragging,
|
|
112
|
-
focused
|
|
113
|
-
disabled
|
|
118
|
+
focused,
|
|
119
|
+
disabled,
|
|
120
|
+
readOnly,
|
|
114
121
|
transforming: context.get("transforming"),
|
|
122
|
+
maxFilesReached: acceptedFiles.length >= maxFiles,
|
|
123
|
+
remainingFiles: Math.max(0, maxFiles - acceptedFiles.length),
|
|
115
124
|
openFilePicker() {
|
|
116
|
-
if (disabled) return;
|
|
125
|
+
if (disabled || readOnly) return;
|
|
117
126
|
send({ type: "OPEN" });
|
|
118
127
|
},
|
|
119
128
|
deleteFile(file, type = DEFAULT_ITEM_TYPE) {
|
|
129
|
+
if (disabled || readOnly) return;
|
|
120
130
|
send({
|
|
121
131
|
type: "FILE.DELETE",
|
|
122
132
|
file,
|
|
123
133
|
itemType: type
|
|
124
134
|
});
|
|
125
135
|
},
|
|
126
|
-
acceptedFiles
|
|
136
|
+
acceptedFiles,
|
|
127
137
|
rejectedFiles: context.get("rejectedFiles"),
|
|
128
138
|
setFiles(files) {
|
|
139
|
+
if (disabled || readOnly) return;
|
|
129
140
|
send({
|
|
130
141
|
type: "FILES.SET",
|
|
131
142
|
files,
|
|
@@ -133,9 +144,11 @@ function connect(service, normalize) {
|
|
|
133
144
|
});
|
|
134
145
|
},
|
|
135
146
|
clearRejectedFiles() {
|
|
147
|
+
if (disabled || readOnly) return;
|
|
136
148
|
send({ type: "REJECTED_FILES.CLEAR" });
|
|
137
149
|
},
|
|
138
150
|
clearFiles() {
|
|
151
|
+
if (disabled || readOnly) return;
|
|
139
152
|
send({ type: "FILES.CLEAR" });
|
|
140
153
|
},
|
|
141
154
|
getFileSize(file) {
|
|
@@ -148,7 +161,7 @@ function connect(service, normalize) {
|
|
|
148
161
|
return () => win.URL.revokeObjectURL(url);
|
|
149
162
|
},
|
|
150
163
|
setClipboardFiles(dt) {
|
|
151
|
-
if (disabled) return false;
|
|
164
|
+
if (disabled || readOnly) return false;
|
|
152
165
|
const files = Array.from(dt?.items ?? []).reduce((acc, item) => {
|
|
153
166
|
if (item.kind !== "file") return acc;
|
|
154
167
|
const file = item.getAsFile();
|
|
@@ -168,6 +181,7 @@ function connect(service, normalize) {
|
|
|
168
181
|
dir: prop("dir"),
|
|
169
182
|
id: getRootId(scope),
|
|
170
183
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
184
|
+
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
171
185
|
"data-dragging": require_dom_query.dataAttr(dragging)
|
|
172
186
|
});
|
|
173
187
|
},
|
|
@@ -176,15 +190,17 @@ function connect(service, normalize) {
|
|
|
176
190
|
...parts.dropzone.attrs,
|
|
177
191
|
dir: prop("dir"),
|
|
178
192
|
id: getDropzoneId(scope),
|
|
179
|
-
tabIndex: disabled || props$1.disableClick ? void 0 : 0,
|
|
193
|
+
tabIndex: disabled || readOnly || props$1.disableClick ? void 0 : 0,
|
|
180
194
|
role: props$1.disableClick ? "application" : "button",
|
|
181
195
|
"aria-label": translations.dropzone,
|
|
182
196
|
"aria-disabled": disabled,
|
|
197
|
+
"aria-readonly": readOnly,
|
|
183
198
|
"data-invalid": require_dom_query.dataAttr(prop("invalid")),
|
|
184
199
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
200
|
+
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
185
201
|
"data-dragging": require_dom_query.dataAttr(dragging),
|
|
186
202
|
onKeyDown(event) {
|
|
187
|
-
if (disabled) return;
|
|
203
|
+
if (disabled || readOnly) return;
|
|
188
204
|
if (event.defaultPrevented) return;
|
|
189
205
|
const target = require_dom_query.getEventTarget(event);
|
|
190
206
|
if (!require_dom_query.contains(event.currentTarget, target)) return;
|
|
@@ -197,7 +213,7 @@ function connect(service, normalize) {
|
|
|
197
213
|
});
|
|
198
214
|
},
|
|
199
215
|
onClick(event) {
|
|
200
|
-
if (disabled) return;
|
|
216
|
+
if (disabled || readOnly) return;
|
|
201
217
|
if (event.defaultPrevented) return;
|
|
202
218
|
if (props$1.disableClick) return;
|
|
203
219
|
const target = require_dom_query.getEventTarget(event);
|
|
@@ -207,7 +223,7 @@ function connect(service, normalize) {
|
|
|
207
223
|
send({ type: "DROPZONE.CLICK" });
|
|
208
224
|
},
|
|
209
225
|
onDragOver(event) {
|
|
210
|
-
if (disabled) return;
|
|
226
|
+
if (disabled || readOnly) return;
|
|
211
227
|
if (!allowDrop) return;
|
|
212
228
|
event.preventDefault();
|
|
213
229
|
event.stopPropagation();
|
|
@@ -222,19 +238,18 @@ function connect(service, normalize) {
|
|
|
222
238
|
});
|
|
223
239
|
},
|
|
224
240
|
onDragLeave(event) {
|
|
225
|
-
if (disabled) return;
|
|
241
|
+
if (disabled || readOnly) return;
|
|
226
242
|
if (!allowDrop) return;
|
|
227
243
|
if (require_dom_query.contains(event.currentTarget, event.relatedTarget)) return;
|
|
228
244
|
send({ type: "DROPZONE.DRAG_LEAVE" });
|
|
229
245
|
},
|
|
230
246
|
onDrop(event) {
|
|
231
|
-
if (disabled) return;
|
|
247
|
+
if (disabled || readOnly) return;
|
|
232
248
|
if (allowDrop) {
|
|
233
249
|
event.preventDefault();
|
|
234
250
|
event.stopPropagation();
|
|
235
251
|
}
|
|
236
|
-
|
|
237
|
-
if (disabled || !hasFiles) return;
|
|
252
|
+
if (!isEventWithFiles(event)) return;
|
|
238
253
|
require_file_utils.getFileEntries(event.dataTransfer.items, prop("directory")).then((files) => {
|
|
239
254
|
send({
|
|
240
255
|
type: "DROPZONE.DROP",
|
|
@@ -243,11 +258,11 @@ function connect(service, normalize) {
|
|
|
243
258
|
});
|
|
244
259
|
},
|
|
245
260
|
onFocus() {
|
|
246
|
-
if (disabled) return;
|
|
261
|
+
if (disabled || readOnly) return;
|
|
247
262
|
send({ type: "DROPZONE.FOCUS" });
|
|
248
263
|
},
|
|
249
264
|
onBlur() {
|
|
250
|
-
if (disabled) return;
|
|
265
|
+
if (disabled || readOnly) return;
|
|
251
266
|
send({ type: "DROPZONE.BLUR" });
|
|
252
267
|
}
|
|
253
268
|
});
|
|
@@ -257,12 +272,13 @@ function connect(service, normalize) {
|
|
|
257
272
|
...parts.trigger.attrs,
|
|
258
273
|
dir: prop("dir"),
|
|
259
274
|
id: getTriggerId(scope),
|
|
260
|
-
disabled,
|
|
275
|
+
disabled: disabled || readOnly,
|
|
261
276
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
277
|
+
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
262
278
|
"data-invalid": require_dom_query.dataAttr(prop("invalid")),
|
|
263
279
|
type: "button",
|
|
264
280
|
onClick(event) {
|
|
265
|
-
if (disabled) return;
|
|
281
|
+
if (disabled || readOnly) return;
|
|
266
282
|
if (require_dom_query.contains(getDropzoneEl(scope), event.currentTarget)) event.stopPropagation();
|
|
267
283
|
send({ type: "OPEN" });
|
|
268
284
|
}
|
|
@@ -272,7 +288,7 @@ function connect(service, normalize) {
|
|
|
272
288
|
return normalize.input({
|
|
273
289
|
id: getHiddenInputId(scope),
|
|
274
290
|
tabIndex: -1,
|
|
275
|
-
disabled,
|
|
291
|
+
disabled: disabled || readOnly,
|
|
276
292
|
type: "file",
|
|
277
293
|
required: prop("required"),
|
|
278
294
|
capture: prop("capture"),
|
|
@@ -285,7 +301,7 @@ function connect(service, normalize) {
|
|
|
285
301
|
event.currentTarget.value = "";
|
|
286
302
|
},
|
|
287
303
|
onInput(event) {
|
|
288
|
-
if (disabled) return;
|
|
304
|
+
if (disabled || readOnly) return;
|
|
289
305
|
const { files } = event.currentTarget;
|
|
290
306
|
send({
|
|
291
307
|
type: "FILE.SELECT",
|
|
@@ -309,7 +325,7 @@ function connect(service, normalize) {
|
|
|
309
325
|
return normalize.element({
|
|
310
326
|
...parts.item.attrs,
|
|
311
327
|
dir: prop("dir"),
|
|
312
|
-
id: getItemId(scope, file
|
|
328
|
+
id: getItemId(scope, getFileId(file)),
|
|
313
329
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
314
330
|
"data-type": type
|
|
315
331
|
});
|
|
@@ -319,7 +335,7 @@ function connect(service, normalize) {
|
|
|
319
335
|
return normalize.element({
|
|
320
336
|
...parts.itemName.attrs,
|
|
321
337
|
dir: prop("dir"),
|
|
322
|
-
id: getItemNameId(scope, file
|
|
338
|
+
id: getItemNameId(scope, getFileId(file)),
|
|
323
339
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
324
340
|
"data-type": type
|
|
325
341
|
});
|
|
@@ -329,7 +345,7 @@ function connect(service, normalize) {
|
|
|
329
345
|
return normalize.element({
|
|
330
346
|
...parts.itemSizeText.attrs,
|
|
331
347
|
dir: prop("dir"),
|
|
332
|
-
id: getItemSizeTextId(scope, file
|
|
348
|
+
id: getItemSizeTextId(scope, getFileId(file)),
|
|
333
349
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
334
350
|
"data-type": type
|
|
335
351
|
});
|
|
@@ -339,7 +355,7 @@ function connect(service, normalize) {
|
|
|
339
355
|
return normalize.element({
|
|
340
356
|
...parts.itemPreview.attrs,
|
|
341
357
|
dir: prop("dir"),
|
|
342
|
-
id: getItemPreviewId(scope, file
|
|
358
|
+
id: getItemPreviewId(scope, getFileId(file)),
|
|
343
359
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
344
360
|
"data-type": type
|
|
345
361
|
});
|
|
@@ -360,13 +376,15 @@ function connect(service, normalize) {
|
|
|
360
376
|
return normalize.button({
|
|
361
377
|
...parts.itemDeleteTrigger.attrs,
|
|
362
378
|
dir: prop("dir"),
|
|
379
|
+
id: getItemDeleteTriggerId(scope, getFileId(file)),
|
|
363
380
|
type: "button",
|
|
364
|
-
disabled,
|
|
381
|
+
disabled: disabled || readOnly,
|
|
365
382
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
383
|
+
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
366
384
|
"data-type": type,
|
|
367
385
|
"aria-label": translations.deleteFile?.(file),
|
|
368
386
|
onClick() {
|
|
369
|
-
if (disabled) return;
|
|
387
|
+
if (disabled || readOnly) return;
|
|
370
388
|
send({
|
|
371
389
|
type: "FILE.DELETE",
|
|
372
390
|
file,
|
|
@@ -390,12 +408,13 @@ function connect(service, normalize) {
|
|
|
390
408
|
...parts.clearTrigger.attrs,
|
|
391
409
|
dir: prop("dir"),
|
|
392
410
|
type: "button",
|
|
393
|
-
disabled,
|
|
394
|
-
hidden:
|
|
411
|
+
disabled: disabled || readOnly,
|
|
412
|
+
hidden: acceptedFiles.length === 0,
|
|
395
413
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
414
|
+
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
396
415
|
onClick(event) {
|
|
397
416
|
if (event.defaultPrevented) return;
|
|
398
|
-
if (disabled) return;
|
|
417
|
+
if (disabled || readOnly) return;
|
|
399
418
|
send({ type: "FILES.CLEAR" });
|
|
400
419
|
}
|
|
401
420
|
});
|
|
@@ -608,6 +627,7 @@ const props = require_create_props.createProps()([
|
|
|
608
627
|
"onFileChange",
|
|
609
628
|
"onFileReject",
|
|
610
629
|
"preventDocumentDrop",
|
|
630
|
+
"readOnly",
|
|
611
631
|
"required",
|
|
612
632
|
"transformFiles",
|
|
613
633
|
"translations",
|
|
@@ -4,7 +4,7 @@ import { b as NormalizeProps, g as RequiredBy, o as LocaleProperties, t as Commo
|
|
|
4
4
|
import { i as FileMimeType, r as FileError } from "../../types-xyuh-a2-.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/machines/file-upload/file-upload.anatomy.d.ts
|
|
7
|
-
declare const anatomy: AnatomyInstance<"root" | "
|
|
7
|
+
declare const anatomy: AnatomyInstance<"root" | "item" | "label" | "trigger" | "clearTrigger" | "itemGroup" | "dropzone" | "itemDeleteTrigger" | "itemName" | "itemPreview" | "itemPreviewImage" | "itemSizeText">;
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/machines/file-upload/file-upload.types.d.ts
|
|
10
10
|
interface FileRejection {
|
|
@@ -35,6 +35,7 @@ type ElementIds = Partial<{
|
|
|
35
35
|
itemName: (id: string) => string;
|
|
36
36
|
itemSizeText: (id: string) => string;
|
|
37
37
|
itemPreview: (id: string) => string;
|
|
38
|
+
itemDeleteTrigger: (id: string) => string;
|
|
38
39
|
}>;
|
|
39
40
|
interface IntlTranslations {
|
|
40
41
|
dropzone?: string | undefined;
|
|
@@ -62,6 +63,7 @@ interface FileUploadProps extends LocaleProperties, CommonProperties {
|
|
|
62
63
|
capture?: "user" | "environment" | undefined;
|
|
63
64
|
directory?: boolean | undefined;
|
|
64
65
|
invalid?: boolean | undefined;
|
|
66
|
+
readOnly?: boolean | undefined;
|
|
65
67
|
transformFiles?: ((files: File[]) => Promise<File[]>) | undefined;
|
|
66
68
|
}
|
|
67
69
|
type PropsWithDefault = "minFileSize" | "maxFileSize" | "maxFiles" | "preventDocumentDrop" | "allowDrop" | "translations";
|
|
@@ -104,7 +106,10 @@ interface FileUploadApi<T extends PropTypes = PropTypes> {
|
|
|
104
106
|
dragging: boolean;
|
|
105
107
|
focused: boolean;
|
|
106
108
|
disabled: boolean;
|
|
109
|
+
readOnly: boolean;
|
|
107
110
|
transforming: boolean;
|
|
111
|
+
maxFilesReached: boolean;
|
|
112
|
+
remainingFiles: number;
|
|
108
113
|
openFilePicker: VoidFunction;
|
|
109
114
|
deleteFile: (file: File, type?: ItemType | undefined) => void;
|
|
110
115
|
acceptedFiles: File[];
|
|
@@ -4,7 +4,7 @@ import { b as NormalizeProps, g as RequiredBy, o as LocaleProperties, t as Commo
|
|
|
4
4
|
import { i as FileMimeType, r as FileError } from "../../types-CsK6JMut.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/machines/file-upload/file-upload.anatomy.d.ts
|
|
7
|
-
declare const anatomy: AnatomyInstance<"root" | "
|
|
7
|
+
declare const anatomy: AnatomyInstance<"root" | "item" | "label" | "trigger" | "clearTrigger" | "itemGroup" | "dropzone" | "itemDeleteTrigger" | "itemName" | "itemPreview" | "itemPreviewImage" | "itemSizeText">;
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/machines/file-upload/file-upload.types.d.ts
|
|
10
10
|
interface FileRejection {
|
|
@@ -35,6 +35,7 @@ type ElementIds = Partial<{
|
|
|
35
35
|
itemName: (id: string) => string;
|
|
36
36
|
itemSizeText: (id: string) => string;
|
|
37
37
|
itemPreview: (id: string) => string;
|
|
38
|
+
itemDeleteTrigger: (id: string) => string;
|
|
38
39
|
}>;
|
|
39
40
|
interface IntlTranslations {
|
|
40
41
|
dropzone?: string | undefined;
|
|
@@ -62,6 +63,7 @@ interface FileUploadProps extends LocaleProperties, CommonProperties {
|
|
|
62
63
|
capture?: "user" | "environment" | undefined;
|
|
63
64
|
directory?: boolean | undefined;
|
|
64
65
|
invalid?: boolean | undefined;
|
|
66
|
+
readOnly?: boolean | undefined;
|
|
65
67
|
transformFiles?: ((files: File[]) => Promise<File[]>) | undefined;
|
|
66
68
|
}
|
|
67
69
|
type PropsWithDefault = "minFileSize" | "maxFileSize" | "maxFiles" | "preventDocumentDrop" | "allowDrop" | "translations";
|
|
@@ -104,7 +106,10 @@ interface FileUploadApi<T extends PropTypes = PropTypes> {
|
|
|
104
106
|
dragging: boolean;
|
|
105
107
|
focused: boolean;
|
|
106
108
|
disabled: boolean;
|
|
109
|
+
readOnly: boolean;
|
|
107
110
|
transforming: boolean;
|
|
111
|
+
maxFilesReached: boolean;
|
|
112
|
+
remainingFiles: number;
|
|
108
113
|
openFilePicker: VoidFunction;
|
|
109
114
|
deleteFile: (file: File, type?: ItemType | undefined) => void;
|
|
110
115
|
acceptedFiles: File[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as createAnatomy } from "../../create-anatomy-CArN8dVu.mjs";
|
|
2
2
|
import { U as raf, Xt as contains, ft as getEventTarget, i as visuallyHiddenStyle, rn as getWindow, st as addDomEvent, vn as dataAttr } from "../../dom-query-Bwyyt0Vp.mjs";
|
|
3
|
-
import { W as callAll, i as warn, u as createSplitProps,
|
|
4
|
-
import { a as createMachine } from "../../core-
|
|
3
|
+
import { W as callAll, i as warn, q as hash, u as createSplitProps, yt as flatArray } from "../../utils-BIwaJq8z.mjs";
|
|
4
|
+
import { a as createMachine } from "../../core-DVmt6PX7.mjs";
|
|
5
5
|
import { i as isFileEqual, r as isValidFileSize, s as getAcceptAttrString, t as isValidFileType, u as getFileEntries } from "../../file-utils-5E6-AtJ9.mjs";
|
|
6
6
|
import { c as formatBytes } from "../../i18n-utils-DCz8B6DF.mjs";
|
|
7
7
|
import { t as createProps } from "../../create-props-SRSjdUTq.mjs";
|
|
@@ -21,6 +21,8 @@ const getItemId = (ctx, id) => ctx.ids?.item?.(id) ?? `file-upload:${ctx.id}:ite
|
|
|
21
21
|
const getItemNameId = (ctx, id) => ctx.ids?.itemName?.(id) ?? `file-upload:${ctx.id}:item-name:${id}`;
|
|
22
22
|
const getItemSizeTextId = (ctx, id) => ctx.ids?.itemSizeText?.(id) ?? `file-upload:${ctx.id}:item-size:${id}`;
|
|
23
23
|
const getItemPreviewId = (ctx, id) => ctx.ids?.itemPreview?.(id) ?? `file-upload:${ctx.id}:item-preview:${id}`;
|
|
24
|
+
const getItemDeleteTriggerId = (ctx, id) => ctx.ids?.itemDeleteTrigger?.(id) ?? `file:${ctx.id}:item-delete:${id}`;
|
|
25
|
+
const getFileId = (file) => hash(`${file.name}-${file.size}`);
|
|
24
26
|
const getRootEl = (ctx) => ctx.getById(getRootId(ctx));
|
|
25
27
|
const getHiddenInputEl = (ctx) => ctx.getById(getHiddenInputId(ctx));
|
|
26
28
|
const getDropzoneEl = (ctx) => ctx.getById(getDropzoneId(ctx));
|
|
@@ -103,29 +105,38 @@ function isInteractiveTarget(element, container) {
|
|
|
103
105
|
function connect(service, normalize) {
|
|
104
106
|
const { state, send, prop, computed, scope, context } = service;
|
|
105
107
|
const disabled = !!prop("disabled");
|
|
108
|
+
const readOnly = !!prop("readOnly");
|
|
106
109
|
const required = !!prop("required");
|
|
107
110
|
const allowDrop = prop("allowDrop");
|
|
108
111
|
const translations = prop("translations");
|
|
109
112
|
const dragging = state.matches("dragging");
|
|
113
|
+
const focused = state.matches("focused") && !disabled;
|
|
114
|
+
const acceptedFiles = context.get("acceptedFiles");
|
|
115
|
+
const maxFiles = prop("maxFiles");
|
|
110
116
|
return {
|
|
111
117
|
dragging,
|
|
112
|
-
focused
|
|
113
|
-
disabled
|
|
118
|
+
focused,
|
|
119
|
+
disabled,
|
|
120
|
+
readOnly,
|
|
114
121
|
transforming: context.get("transforming"),
|
|
122
|
+
maxFilesReached: acceptedFiles.length >= maxFiles,
|
|
123
|
+
remainingFiles: Math.max(0, maxFiles - acceptedFiles.length),
|
|
115
124
|
openFilePicker() {
|
|
116
|
-
if (disabled) return;
|
|
125
|
+
if (disabled || readOnly) return;
|
|
117
126
|
send({ type: "OPEN" });
|
|
118
127
|
},
|
|
119
128
|
deleteFile(file, type = DEFAULT_ITEM_TYPE) {
|
|
129
|
+
if (disabled || readOnly) return;
|
|
120
130
|
send({
|
|
121
131
|
type: "FILE.DELETE",
|
|
122
132
|
file,
|
|
123
133
|
itemType: type
|
|
124
134
|
});
|
|
125
135
|
},
|
|
126
|
-
acceptedFiles
|
|
136
|
+
acceptedFiles,
|
|
127
137
|
rejectedFiles: context.get("rejectedFiles"),
|
|
128
138
|
setFiles(files) {
|
|
139
|
+
if (disabled || readOnly) return;
|
|
129
140
|
send({
|
|
130
141
|
type: "FILES.SET",
|
|
131
142
|
files,
|
|
@@ -133,9 +144,11 @@ function connect(service, normalize) {
|
|
|
133
144
|
});
|
|
134
145
|
},
|
|
135
146
|
clearRejectedFiles() {
|
|
147
|
+
if (disabled || readOnly) return;
|
|
136
148
|
send({ type: "REJECTED_FILES.CLEAR" });
|
|
137
149
|
},
|
|
138
150
|
clearFiles() {
|
|
151
|
+
if (disabled || readOnly) return;
|
|
139
152
|
send({ type: "FILES.CLEAR" });
|
|
140
153
|
},
|
|
141
154
|
getFileSize(file) {
|
|
@@ -148,7 +161,7 @@ function connect(service, normalize) {
|
|
|
148
161
|
return () => win.URL.revokeObjectURL(url);
|
|
149
162
|
},
|
|
150
163
|
setClipboardFiles(dt) {
|
|
151
|
-
if (disabled) return false;
|
|
164
|
+
if (disabled || readOnly) return false;
|
|
152
165
|
const files = Array.from(dt?.items ?? []).reduce((acc, item) => {
|
|
153
166
|
if (item.kind !== "file") return acc;
|
|
154
167
|
const file = item.getAsFile();
|
|
@@ -168,6 +181,7 @@ function connect(service, normalize) {
|
|
|
168
181
|
dir: prop("dir"),
|
|
169
182
|
id: getRootId(scope),
|
|
170
183
|
"data-disabled": dataAttr(disabled),
|
|
184
|
+
"data-readonly": dataAttr(readOnly),
|
|
171
185
|
"data-dragging": dataAttr(dragging)
|
|
172
186
|
});
|
|
173
187
|
},
|
|
@@ -176,15 +190,17 @@ function connect(service, normalize) {
|
|
|
176
190
|
...parts.dropzone.attrs,
|
|
177
191
|
dir: prop("dir"),
|
|
178
192
|
id: getDropzoneId(scope),
|
|
179
|
-
tabIndex: disabled || props$1.disableClick ? void 0 : 0,
|
|
193
|
+
tabIndex: disabled || readOnly || props$1.disableClick ? void 0 : 0,
|
|
180
194
|
role: props$1.disableClick ? "application" : "button",
|
|
181
195
|
"aria-label": translations.dropzone,
|
|
182
196
|
"aria-disabled": disabled,
|
|
197
|
+
"aria-readonly": readOnly,
|
|
183
198
|
"data-invalid": dataAttr(prop("invalid")),
|
|
184
199
|
"data-disabled": dataAttr(disabled),
|
|
200
|
+
"data-readonly": dataAttr(readOnly),
|
|
185
201
|
"data-dragging": dataAttr(dragging),
|
|
186
202
|
onKeyDown(event) {
|
|
187
|
-
if (disabled) return;
|
|
203
|
+
if (disabled || readOnly) return;
|
|
188
204
|
if (event.defaultPrevented) return;
|
|
189
205
|
const target = getEventTarget(event);
|
|
190
206
|
if (!contains(event.currentTarget, target)) return;
|
|
@@ -197,7 +213,7 @@ function connect(service, normalize) {
|
|
|
197
213
|
});
|
|
198
214
|
},
|
|
199
215
|
onClick(event) {
|
|
200
|
-
if (disabled) return;
|
|
216
|
+
if (disabled || readOnly) return;
|
|
201
217
|
if (event.defaultPrevented) return;
|
|
202
218
|
if (props$1.disableClick) return;
|
|
203
219
|
const target = getEventTarget(event);
|
|
@@ -207,7 +223,7 @@ function connect(service, normalize) {
|
|
|
207
223
|
send({ type: "DROPZONE.CLICK" });
|
|
208
224
|
},
|
|
209
225
|
onDragOver(event) {
|
|
210
|
-
if (disabled) return;
|
|
226
|
+
if (disabled || readOnly) return;
|
|
211
227
|
if (!allowDrop) return;
|
|
212
228
|
event.preventDefault();
|
|
213
229
|
event.stopPropagation();
|
|
@@ -222,19 +238,18 @@ function connect(service, normalize) {
|
|
|
222
238
|
});
|
|
223
239
|
},
|
|
224
240
|
onDragLeave(event) {
|
|
225
|
-
if (disabled) return;
|
|
241
|
+
if (disabled || readOnly) return;
|
|
226
242
|
if (!allowDrop) return;
|
|
227
243
|
if (contains(event.currentTarget, event.relatedTarget)) return;
|
|
228
244
|
send({ type: "DROPZONE.DRAG_LEAVE" });
|
|
229
245
|
},
|
|
230
246
|
onDrop(event) {
|
|
231
|
-
if (disabled) return;
|
|
247
|
+
if (disabled || readOnly) return;
|
|
232
248
|
if (allowDrop) {
|
|
233
249
|
event.preventDefault();
|
|
234
250
|
event.stopPropagation();
|
|
235
251
|
}
|
|
236
|
-
|
|
237
|
-
if (disabled || !hasFiles) return;
|
|
252
|
+
if (!isEventWithFiles(event)) return;
|
|
238
253
|
getFileEntries(event.dataTransfer.items, prop("directory")).then((files) => {
|
|
239
254
|
send({
|
|
240
255
|
type: "DROPZONE.DROP",
|
|
@@ -243,11 +258,11 @@ function connect(service, normalize) {
|
|
|
243
258
|
});
|
|
244
259
|
},
|
|
245
260
|
onFocus() {
|
|
246
|
-
if (disabled) return;
|
|
261
|
+
if (disabled || readOnly) return;
|
|
247
262
|
send({ type: "DROPZONE.FOCUS" });
|
|
248
263
|
},
|
|
249
264
|
onBlur() {
|
|
250
|
-
if (disabled) return;
|
|
265
|
+
if (disabled || readOnly) return;
|
|
251
266
|
send({ type: "DROPZONE.BLUR" });
|
|
252
267
|
}
|
|
253
268
|
});
|
|
@@ -257,12 +272,13 @@ function connect(service, normalize) {
|
|
|
257
272
|
...parts.trigger.attrs,
|
|
258
273
|
dir: prop("dir"),
|
|
259
274
|
id: getTriggerId(scope),
|
|
260
|
-
disabled,
|
|
275
|
+
disabled: disabled || readOnly,
|
|
261
276
|
"data-disabled": dataAttr(disabled),
|
|
277
|
+
"data-readonly": dataAttr(readOnly),
|
|
262
278
|
"data-invalid": dataAttr(prop("invalid")),
|
|
263
279
|
type: "button",
|
|
264
280
|
onClick(event) {
|
|
265
|
-
if (disabled) return;
|
|
281
|
+
if (disabled || readOnly) return;
|
|
266
282
|
if (contains(getDropzoneEl(scope), event.currentTarget)) event.stopPropagation();
|
|
267
283
|
send({ type: "OPEN" });
|
|
268
284
|
}
|
|
@@ -272,7 +288,7 @@ function connect(service, normalize) {
|
|
|
272
288
|
return normalize.input({
|
|
273
289
|
id: getHiddenInputId(scope),
|
|
274
290
|
tabIndex: -1,
|
|
275
|
-
disabled,
|
|
291
|
+
disabled: disabled || readOnly,
|
|
276
292
|
type: "file",
|
|
277
293
|
required: prop("required"),
|
|
278
294
|
capture: prop("capture"),
|
|
@@ -285,7 +301,7 @@ function connect(service, normalize) {
|
|
|
285
301
|
event.currentTarget.value = "";
|
|
286
302
|
},
|
|
287
303
|
onInput(event) {
|
|
288
|
-
if (disabled) return;
|
|
304
|
+
if (disabled || readOnly) return;
|
|
289
305
|
const { files } = event.currentTarget;
|
|
290
306
|
send({
|
|
291
307
|
type: "FILE.SELECT",
|
|
@@ -309,7 +325,7 @@ function connect(service, normalize) {
|
|
|
309
325
|
return normalize.element({
|
|
310
326
|
...parts.item.attrs,
|
|
311
327
|
dir: prop("dir"),
|
|
312
|
-
id: getItemId(scope, file
|
|
328
|
+
id: getItemId(scope, getFileId(file)),
|
|
313
329
|
"data-disabled": dataAttr(disabled),
|
|
314
330
|
"data-type": type
|
|
315
331
|
});
|
|
@@ -319,7 +335,7 @@ function connect(service, normalize) {
|
|
|
319
335
|
return normalize.element({
|
|
320
336
|
...parts.itemName.attrs,
|
|
321
337
|
dir: prop("dir"),
|
|
322
|
-
id: getItemNameId(scope, file
|
|
338
|
+
id: getItemNameId(scope, getFileId(file)),
|
|
323
339
|
"data-disabled": dataAttr(disabled),
|
|
324
340
|
"data-type": type
|
|
325
341
|
});
|
|
@@ -329,7 +345,7 @@ function connect(service, normalize) {
|
|
|
329
345
|
return normalize.element({
|
|
330
346
|
...parts.itemSizeText.attrs,
|
|
331
347
|
dir: prop("dir"),
|
|
332
|
-
id: getItemSizeTextId(scope, file
|
|
348
|
+
id: getItemSizeTextId(scope, getFileId(file)),
|
|
333
349
|
"data-disabled": dataAttr(disabled),
|
|
334
350
|
"data-type": type
|
|
335
351
|
});
|
|
@@ -339,7 +355,7 @@ function connect(service, normalize) {
|
|
|
339
355
|
return normalize.element({
|
|
340
356
|
...parts.itemPreview.attrs,
|
|
341
357
|
dir: prop("dir"),
|
|
342
|
-
id: getItemPreviewId(scope, file
|
|
358
|
+
id: getItemPreviewId(scope, getFileId(file)),
|
|
343
359
|
"data-disabled": dataAttr(disabled),
|
|
344
360
|
"data-type": type
|
|
345
361
|
});
|
|
@@ -360,13 +376,15 @@ function connect(service, normalize) {
|
|
|
360
376
|
return normalize.button({
|
|
361
377
|
...parts.itemDeleteTrigger.attrs,
|
|
362
378
|
dir: prop("dir"),
|
|
379
|
+
id: getItemDeleteTriggerId(scope, getFileId(file)),
|
|
363
380
|
type: "button",
|
|
364
|
-
disabled,
|
|
381
|
+
disabled: disabled || readOnly,
|
|
365
382
|
"data-disabled": dataAttr(disabled),
|
|
383
|
+
"data-readonly": dataAttr(readOnly),
|
|
366
384
|
"data-type": type,
|
|
367
385
|
"aria-label": translations.deleteFile?.(file),
|
|
368
386
|
onClick() {
|
|
369
|
-
if (disabled) return;
|
|
387
|
+
if (disabled || readOnly) return;
|
|
370
388
|
send({
|
|
371
389
|
type: "FILE.DELETE",
|
|
372
390
|
file,
|
|
@@ -390,12 +408,13 @@ function connect(service, normalize) {
|
|
|
390
408
|
...parts.clearTrigger.attrs,
|
|
391
409
|
dir: prop("dir"),
|
|
392
410
|
type: "button",
|
|
393
|
-
disabled,
|
|
394
|
-
hidden:
|
|
411
|
+
disabled: disabled || readOnly,
|
|
412
|
+
hidden: acceptedFiles.length === 0,
|
|
395
413
|
"data-disabled": dataAttr(disabled),
|
|
414
|
+
"data-readonly": dataAttr(readOnly),
|
|
396
415
|
onClick(event) {
|
|
397
416
|
if (event.defaultPrevented) return;
|
|
398
|
-
if (disabled) return;
|
|
417
|
+
if (disabled || readOnly) return;
|
|
399
418
|
send({ type: "FILES.CLEAR" });
|
|
400
419
|
}
|
|
401
420
|
});
|
|
@@ -608,6 +627,7 @@ const props = createProps()([
|
|
|
608
627
|
"onFileChange",
|
|
609
628
|
"onFileReject",
|
|
610
629
|
"preventDocumentDrop",
|
|
630
|
+
"readOnly",
|
|
611
631
|
"required",
|
|
612
632
|
"transformFiles",
|
|
613
633
|
"translations",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_create_anatomy = require('../../create-anatomy-CDsIFUXg.cjs');
|
|
2
2
|
const require_dom_query = require('../../dom-query-CWZdWUGp.cjs');
|
|
3
|
-
const require_utils = require('../../utils-
|
|
4
|
-
const require_core = require('../../core-
|
|
3
|
+
const require_utils = require('../../utils-CtgLe8Vv.cjs');
|
|
4
|
+
const require_core = require('../../core-DHn58LRl.cjs');
|
|
5
5
|
const require_rect_utils = require('../../rect-utils-Dp9Wvl7-.cjs');
|
|
6
6
|
const require_store = require('../../store-DDjfrUhd.cjs');
|
|
7
7
|
const require_create_props = require('../../create-props-l5q5b8Wo.cjs');
|
|
@@ -4,7 +4,7 @@ import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as Comm
|
|
|
4
4
|
import { a as Point, o as Rect, y as Size } from "../../types-CaxzY9yP.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/machines/floating-panel/floating-panel.anatomy.d.ts
|
|
7
|
-
declare const anatomy: AnatomyInstance<"
|
|
7
|
+
declare const anatomy: AnatomyInstance<"body" | "header" | "title" | "content" | "control" | "trigger" | "positioner" | "closeTrigger" | "resizeTrigger" | "dragTrigger" | "stageTrigger">;
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/machines/floating-panel/floating-panel.types.d.ts
|
|
10
10
|
interface PositionChangeDetails {
|
|
@@ -4,7 +4,7 @@ import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as Comm
|
|
|
4
4
|
import { a as Point, o as Rect, y as Size } from "../../types-ByFp2QfD.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/machines/floating-panel/floating-panel.anatomy.d.ts
|
|
7
|
-
declare const anatomy: AnatomyInstance<"
|
|
7
|
+
declare const anatomy: AnatomyInstance<"body" | "header" | "title" | "content" | "control" | "trigger" | "positioner" | "closeTrigger" | "resizeTrigger" | "dragTrigger" | "stageTrigger">;
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/machines/floating-panel/floating-panel.types.d.ts
|
|
10
10
|
interface PositionChangeDetails {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as createAnatomy } from "../../create-anatomy-CArN8dVu.mjs";
|
|
2
2
|
import { T as trackPointerMove, U as raf, dt as getEventStep, ft as getEventTarget, ln as isHTMLElement, lt as getEventKey, p as resizeObserverBorderBox, st as addDomEvent, vn as dataAttr, yt as isLeftClick } from "../../dom-query-Bwyyt0Vp.mjs";
|
|
3
|
-
import { H as toPx,
|
|
4
|
-
import { a as createMachine, i as createGuards } from "../../core-
|
|
3
|
+
import { H as toPx, Y as match, g as clampValue, n as ensureProps, p as pick, r as invariant, u as createSplitProps } from "../../utils-BIwaJq8z.mjs";
|
|
4
|
+
import { a as createMachine, i as createGuards } from "../../core-DVmt6PX7.mjs";
|
|
5
5
|
import { G as clampPoint, I as addPoints, K as clampSize, R as createRect, T as constrainRect, W as subtractPoints, d as getWindowRect, t as resizeRect, v as getElementRect, x as isSizeEqual, y as isPointEqual } from "../../rect-utils-j6C9uZk1.mjs";
|
|
6
6
|
import { a as subscribe, n as proxy } from "../../store-CpMJ6RZR.mjs";
|
|
7
7
|
import { t as createProps } from "../../create-props-SRSjdUTq.mjs";
|