@rockshin/tao-ui 0.0.48 → 0.0.51

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.
Files changed (147) hide show
  1. package/dist/components/affix/affix.js +20 -16
  2. package/dist/components/alert/alert.js +114 -99
  3. package/dist/components/app/app-modals.js +134 -96
  4. package/dist/components/app/app-notices.js +39 -23
  5. package/dist/components/auto-complete/auto-complete.js +21 -7
  6. package/dist/components/avatar/avatar.js +31 -11
  7. package/dist/components/badge/badge.css +1 -1
  8. package/dist/components/badge/badge.js +72 -257
  9. package/dist/components/border-beam/border-beam.js +21 -17
  10. package/dist/components/breadcrumb/breadcrumb.js +178 -159
  11. package/dist/components/button/button.css +9 -1
  12. package/dist/components/button/button.js +61 -53
  13. package/dist/components/calendar/calendar.js +6 -4
  14. package/dist/components/card/card.js +24 -8
  15. package/dist/components/carousel/carousel.d.ts +1 -1
  16. package/dist/components/carousel/carousel.js +105 -68
  17. package/dist/components/cascader/cascader.js +54 -19
  18. package/dist/components/checkbox/checkbox.css +13 -2
  19. package/dist/components/checkbox/checkbox.d.ts +2 -0
  20. package/dist/components/checkbox/checkbox.js +320 -229
  21. package/dist/components/collapse/collapse-panels.d.ts +1 -1
  22. package/dist/components/collapse/collapse-panels.js +122 -113
  23. package/dist/components/collapse/collapse.js +98 -63
  24. package/dist/components/color-picker/color-picker.js +539 -441
  25. package/dist/components/color-picker/color.js +1 -1
  26. package/dist/components/context-menu/context-menu.d.ts +1 -1
  27. package/dist/components/context-menu/context-menu.js +108 -68
  28. package/dist/components/date-picker/calendar/calendar-grid.js +42 -39
  29. package/dist/components/date-picker/calendar/month-grid.d.ts +8 -1
  30. package/dist/components/date-picker/calendar/month-grid.js +79 -37
  31. package/dist/components/date-picker/calendar/time-panel.d.ts +2 -1
  32. package/dist/components/date-picker/calendar/time-panel.js +94 -89
  33. package/dist/components/date-picker/calendar/year-grid.d.ts +8 -1
  34. package/dist/components/date-picker/calendar/year-grid.js +66 -35
  35. package/dist/components/date-picker/date-picker.css +24 -1
  36. package/dist/components/date-picker/date-picker.js +99 -53
  37. package/dist/components/date-picker/presets.d.ts +2 -1
  38. package/dist/components/date-picker/presets.js +27 -24
  39. package/dist/components/date-picker/range-picker.js +308 -153
  40. package/dist/components/descriptions/descriptions.js +7 -3
  41. package/dist/components/divider/divider.css +1 -1
  42. package/dist/components/divider/divider.js +1 -1
  43. package/dist/components/drawer/drawer.js +201 -369
  44. package/dist/components/dropdown/dropdown.d.ts +1 -1
  45. package/dist/components/dropdown/dropdown.js +183 -279
  46. package/dist/components/empty/empty.js +57 -78
  47. package/dist/components/float-button/float-button.d.ts +1 -0
  48. package/dist/components/float-button/float-button.js +47 -30
  49. package/dist/components/form/field-control.d.ts +4 -2
  50. package/dist/components/form/field-control.js +17 -9
  51. package/dist/components/form/form-context.d.ts +8 -2
  52. package/dist/components/form/form-context.js +2 -1
  53. package/dist/components/form/form-item.js +85 -63
  54. package/dist/components/form/use-form.d.ts +2 -1
  55. package/dist/components/form/use-form.js +2 -1
  56. package/dist/components/form-field/form-field-view.d.ts +3 -1
  57. package/dist/components/form-field/form-field-view.js +194 -141
  58. package/dist/components/form-section/form-section.d.ts +1 -1
  59. package/dist/components/form-section/form-section.js +52 -45
  60. package/dist/components/image/image.js +585 -477
  61. package/dist/components/input/base-input.js +8 -9
  62. package/dist/components/input/input-shared.d.ts +5 -2
  63. package/dist/components/input/input-shared.js +42 -18
  64. package/dist/components/input/input.css +1 -0
  65. package/dist/components/input/otp.js +236 -217
  66. package/dist/components/input/password.js +2 -1
  67. package/dist/components/input/search.js +8 -7
  68. package/dist/components/list/list-pagination.js +41 -36
  69. package/dist/components/list/list.js +141 -125
  70. package/dist/components/listy/listy.js +175 -106
  71. package/dist/components/masonry/masonry.js +108 -85
  72. package/dist/components/mentions/mentions.js +12 -3
  73. package/dist/components/menu/menu-render.d.ts +9 -3
  74. package/dist/components/menu/menu-render.js +99 -36
  75. package/dist/components/modal/confirm-dialog.js +10 -4
  76. package/dist/components/modal/confirm.js +3 -7
  77. package/dist/components/modal/index.js +9 -3
  78. package/dist/components/modal/modal.js +390 -365
  79. package/dist/components/pagination/pagination.js +105 -96
  80. package/dist/components/popconfirm/popconfirm.d.ts +1 -1
  81. package/dist/components/popconfirm/popconfirm.js +219 -168
  82. package/dist/components/popover/popover.js +330 -243
  83. package/dist/components/progress/progress.css +2 -2
  84. package/dist/components/progress/progress.js +232 -458
  85. package/dist/components/qr-code/qr-code.js +72 -66
  86. package/dist/components/radio/radio.css +15 -4
  87. package/dist/components/radio/radio.d.ts +2 -1
  88. package/dist/components/radio/radio.js +260 -198
  89. package/dist/components/rate/rate.js +173 -113
  90. package/dist/components/scroll-area/scroll-area.js +241 -211
  91. package/dist/components/segmented/segmented.js +73 -41
  92. package/dist/components/select/mobile-select.d.ts +2 -1
  93. package/dist/components/select/mobile-select.js +24 -13
  94. package/dist/components/select/select-searchable-list.d.ts +2 -1
  95. package/dist/components/select/select-searchable-list.js +2 -3
  96. package/dist/components/select/select.css +3 -2
  97. package/dist/components/select/select.js +49 -25
  98. package/dist/components/select/use-select-selection.d.ts +1 -1
  99. package/dist/components/select/use-select-selection.js +7 -4
  100. package/dist/components/skeleton/skeleton.js +56 -48
  101. package/dist/components/slider/slider.js +87 -212
  102. package/dist/components/sonner/sonner.js +109 -93
  103. package/dist/components/spinner/spinner.js +147 -138
  104. package/dist/components/splitter/splitter.js +222 -159
  105. package/dist/components/statistic/statistic.js +7 -6
  106. package/dist/components/steps/steps.js +88 -81
  107. package/dist/components/steps/use-display-steps.js +1 -1
  108. package/dist/components/switch/switch.js +89 -89
  109. package/dist/components/table/table-filter.js +66 -56
  110. package/dist/components/table/table-icons.d.ts +2 -1
  111. package/dist/components/table/table-icons.js +11 -9
  112. package/dist/components/table/table-model.js +1 -1
  113. package/dist/components/table/table.js +107 -83
  114. package/dist/components/table/use-table-data.d.ts +6 -3
  115. package/dist/components/table/use-table-data.js +166 -130
  116. package/dist/components/tabs/tabs.css +1 -1
  117. package/dist/components/tabs/tabs.js +236 -179
  118. package/dist/components/tag/tag.d.ts +2 -2
  119. package/dist/components/tag/tag.js +111 -108
  120. package/dist/components/textarea/textarea.js +22 -17
  121. package/dist/components/time-picker/time-picker.js +5 -3
  122. package/dist/components/timeline/timeline.css +6 -1
  123. package/dist/components/timeline/timeline.js +21 -11
  124. package/dist/components/tooltip/tooltip.d.ts +2 -2
  125. package/dist/components/tooltip/tooltip.js +123 -233
  126. package/dist/components/tour/tour.css +4 -0
  127. package/dist/components/tour/tour.js +400 -331
  128. package/dist/components/transfer/transfer-list.js +31 -12
  129. package/dist/components/transfer/transfer-parts.js +1 -1
  130. package/dist/components/transfer/transfer-types.d.ts +1 -0
  131. package/dist/components/transfer/transfer.css +5 -0
  132. package/dist/components/transfer/transfer.js +29 -14
  133. package/dist/components/tree/tree-keyboard.d.ts +1 -1
  134. package/dist/components/tree/tree-keyboard.js +5 -3
  135. package/dist/components/tree/tree.js +74 -59
  136. package/dist/components/tree-select/select-engine.d.ts +3 -2
  137. package/dist/components/tree-select/select-engine.js +18 -16
  138. package/dist/components/tree-select/tree-select.js +21 -5
  139. package/dist/components/upload/upload.css +8 -0
  140. package/dist/components/upload/upload.js +160 -72
  141. package/dist/components/watermark/watermark.js +36 -29
  142. package/dist/number-input/use-number-input.js +129 -90
  143. package/dist/number-input/validate.js +32 -5
  144. package/dist/provider/merge-locale.js +12 -9
  145. package/dist/provider/tao-provider.d.ts +3 -1
  146. package/dist/provider/tao-provider.js +123 -86
  147. package/package.json +4 -3
@@ -135,6 +135,14 @@
135
135
  height: 100%;
136
136
  }
137
137
 
138
+ [data-tao-upload-preview] img {
139
+ object-fit: contain;
140
+ max-width: 100%;
141
+ max-height: 70dvh;
142
+ margin-inline: auto;
143
+ display: block;
144
+ }
145
+
138
146
  [data-tao-upload][data-list-type="picture"] [data-tao-upload-item] {
139
147
  padding: var(--tao-padding-xs);
140
148
  border: 1px solid var(--tao-color-border-secondary);
@@ -6,11 +6,15 @@ import { flushSync } from "react-dom";
6
6
  import { useTaoConfig } from "../../provider/tao-provider.js";
7
7
  import { cx } from "../../utils/semantic.js";
8
8
  import { Button } from "../button/button.js";
9
+ import { Modal } from "../modal/modal.js";
9
10
  import { Progress } from "../progress/progress.js";
10
11
  import "./upload.css";
11
12
  import { interopDefault } from "../../utils/interop-default.js";
12
13
  const RcUploaderComponent = /*#__PURE__*/ interopDefault(upload);
13
14
  const LIST_IGNORE = '__TAO_UPLOAD_LIST_IGNORE__';
15
+ function asError(reason) {
16
+ return reason instanceof Error ? reason : new Error(String(reason));
17
+ }
14
18
  function toFile(file) {
15
19
  return {
16
20
  uid: file.uid,
@@ -31,6 +35,11 @@ function readPreview(file, failureMessage) {
31
35
  reader.readAsDataURL(file);
32
36
  });
33
37
  }
38
+ function sameUploadFile(file, candidate) {
39
+ if (!candidate) return false;
40
+ if (file.originFileObj || candidate.originFileObj) return file.originFileObj === candidate.originFileObj;
41
+ return file.name === candidate.name && file.url === candidate.url;
42
+ }
34
43
  function FilePreview(t0) {
35
44
  const $ = c(13);
36
45
  const { file, previewFile } = t0;
@@ -41,9 +50,12 @@ function FilePreview(t0) {
41
50
  let t2;
42
51
  if ($[0] !== file.originFileObj || $[1] !== file.thumbUrl || $[2] !== file.url || $[3] !== locale.messages.previewUnavailable || $[4] !== locale.messages.readFileError || $[5] !== previewFile) {
43
52
  t1 = ()=>{
53
+ setPreview(void 0);
54
+ setError(void 0);
44
55
  if (file.thumbUrl || file.url || !file.originFileObj) return;
45
56
  let active = true;
46
- Promise.resolve(previewFile ? previewFile(file.originFileObj) : readPreview(file.originFileObj, locale.messages.readFileError)).then((value)=>{
57
+ const load = async (source)=>previewFile ? previewFile(source) : readPreview(source, locale.messages.readFileError);
58
+ load(file.originFileObj).then((value)=>{
47
59
  if (active) setPreview(value);
48
60
  }, (reason)=>{
49
61
  if (active) setError(reason instanceof Error ? reason.message : locale.messages.previewUnavailable);
@@ -123,15 +135,21 @@ function FileIcon(t0) {
123
135
  const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
124
136
  const config = useTaoConfig();
125
137
  const [localFiles, setFiles] = useState(props.defaultFileList ?? []);
126
- const files = props.fileList ?? localFiles;
138
+ const files = 'fileList' in props ? props.fileList ?? [] : localFiles;
127
139
  const filesRef = useRef(files);
128
140
  filesRef.current = files;
129
141
  const propsRef = useRef(props);
130
142
  propsRef.current = props;
131
143
  const root = useRef(null), uploader = useRef(null);
132
144
  const ignored = useRef(new Set());
145
+ const preparations = useRef(new WeakMap());
146
+ const requestOrigins = useRef(new WeakMap());
147
+ const settledRequests = useRef(new WeakSet());
148
+ const pendingRemovals = useRef(new Map());
133
149
  const [dragging, setDragging] = useState(false), [removeError, setRemoveError] = useState();
150
+ const [previewFile, setPreviewFile] = useState();
134
151
  const disabled = props.disabled ?? config.disabled;
152
+ if (disabled && dragging) setDragging(false);
135
153
  const listType = props.listType ?? 'text', type = props.type ?? 'select';
136
154
  const names = 'function' == typeof props.classNames ? props.classNames({
137
155
  props: {
@@ -156,18 +174,21 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
156
174
  uploadError: config.locale.messages.uploadError,
157
175
  ...props.locale
158
176
  };
159
- const current = ()=>propsRef.current.fileList ?? filesRef.current;
177
+ const current = ()=>'fileList' in propsRef.current ? propsRef.current.fileList ?? [] : filesRef.current;
160
178
  const emit = (file, next, event)=>{
179
+ if (!root.current) return;
161
180
  const max = propsRef.current.maxCount;
162
181
  const limited = 1 === max ? next.slice(-1) : max ? next.slice(0, max) : next;
163
182
  flushSync(()=>{
164
- if (void 0 === propsRef.current.fileList) {
183
+ if (!('fileList' in propsRef.current)) {
165
184
  filesRef.current = limited;
166
185
  setFiles(limited);
167
186
  }
168
187
  if ('removed' === file.status || limited.some((item)=>item.uid === file.uid)) propsRef.current.onChange?.({
169
188
  file,
170
- fileList: limited,
189
+ fileList: [
190
+ ...limited
191
+ ],
171
192
  ...event ? {
172
193
  event
173
194
  } : {}
@@ -175,8 +196,12 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
175
196
  });
176
197
  };
177
198
  const update = (file_0, patch, event_0)=>{
199
+ if (settledRequests.current.has(file_0)) return;
178
200
  const items = current(), found = items.find((item_0)=>item_0.uid === file_0.uid);
179
201
  if (!found) return;
202
+ const origin = requestOrigins.current.get(file_0);
203
+ if (origin && found.originFileObj && found.originFileObj !== origin) return;
204
+ if ('done' === patch.status || 'error' === patch.status) settledRequests.current.add(file_0);
180
205
  const changed = {
181
206
  ...found,
182
207
  ...patch
@@ -198,17 +223,36 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
198
223
  error,
199
224
  response: response_0
200
225
  });
226
+ const customRequest = props.customRequest;
227
+ const request = customRequest ? (options, info)=>{
228
+ try {
229
+ return customRequest(options, info);
230
+ } catch (reason) {
231
+ if ('object' == typeof options.file && settledRequests.current.has(options.file)) throw reason;
232
+ options.onError?.(asError(reason));
233
+ }
234
+ } : void 0;
201
235
  const onBatchStart = (batch)=>{
202
236
  const allowed = batch.filter(({ file: file_4 })=>!ignored.current.delete(file_4.uid));
237
+ for (const { file: file_5, parsedFile } of allowed)if (parsedFile && 'object' == typeof parsedFile) {
238
+ requestOrigins.current.set(parsedFile, file_5);
239
+ settledRequests.current.delete(parsedFile);
240
+ }
203
241
  let next_0 = [
204
242
  ...current()
205
243
  ];
206
- const additions = allowed.map(({ file: file_5, parsedFile })=>({
207
- ...toFile(file_5),
208
- ...parsedFile ? {
244
+ const additions = allowed.map(({ file: file_6, parsedFile: parsedFile_0 })=>{
245
+ const error_0 = preparations.current.get(file_6)?.error;
246
+ return {
247
+ ...toFile(file_6),
248
+ ...error_0 ? {
249
+ status: 'error',
250
+ error: error_0
251
+ } : parsedFile_0 ? {
209
252
  status: 'uploading'
210
253
  } : {}
211
- }));
254
+ };
255
+ });
212
256
  for (const item_2 of additions)next_0 = [
213
257
  ...next_0.filter((old)=>old.uid !== item_2.uid),
214
258
  item_2
@@ -224,28 +268,37 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
224
268
  upload: uploader.current,
225
269
  nativeElement: root.current
226
270
  }));
227
- const remove = async (file_6)=>{
271
+ const remove = async (file_7)=>{
272
+ if (disabled) return;
273
+ const pending = pendingRemovals.current;
274
+ if (sameUploadFile(file_7, pending.get(file_7.uid))) return;
275
+ pending.set(file_7.uid, file_7);
276
+ const isCurrent = (candidate)=>root.current && pending.get(file_7.uid) === file_7 && sameUploadFile(file_7, candidate);
228
277
  try {
229
- if (await propsRef.current.onRemove?.(file_6) === false) return;
278
+ if (await propsRef.current.onRemove?.(file_7) === false) return;
230
279
  const items_0 = current();
231
- if (!items_0.some((item_4)=>item_4.uid === file_6.uid)) return;
232
- uploader.current?.abort(file_6);
280
+ const latest = items_0.find((item_5)=>item_5.uid === file_7.uid);
281
+ if (!latest || !isCurrent(latest)) return;
282
+ uploader.current?.abort(file_7);
233
283
  emit({
234
- ...file_6,
284
+ ...latest,
235
285
  status: 'removed'
236
- }, items_0.filter((item_5)=>item_5.uid !== file_6.uid));
286
+ }, items_0.filter((item_6)=>item_6.uid !== file_7.uid));
237
287
  setRemoveError(void 0);
238
- } catch (error_0) {
239
- setRemoveError(error_0 instanceof Error ? error_0.message : config.locale.messages.removeFileError);
288
+ } catch (error_1) {
289
+ if (!isCurrent(current().find((item_4)=>item_4.uid === file_7.uid))) return;
290
+ setRemoveError(error_1 instanceof Error ? error_1.message : config.locale.messages.removeFileError);
291
+ } finally{
292
+ if (pending.get(file_7.uid) === file_7) pending.delete(file_7.uid);
240
293
  }
241
294
  };
242
- const download = (file_7)=>{
243
- if (props.onDownload) props.onDownload(file_7);
244
- else if (file_7.url) window.open(file_7.url, '_blank', 'noopener,noreferrer');
295
+ const download = (file_8)=>{
296
+ if (props.onDownload) props.onDownload(file_8);
297
+ else if (file_8.url) window.open(file_8.url, '_blank', 'noopener,noreferrer');
245
298
  };
246
299
  const listConfig = 'object' == typeof props.showUploadList ? props.showUploadList : {};
247
- const visible = (option, file_8, fallback)=>'function' == typeof option ? option(file_8) : option ?? fallback;
248
- const renderOption = (option_0, file_9)=>'function' == typeof option_0 ? option_0(file_9) : option_0;
300
+ const visible = (option, file_9, fallback)=>'function' == typeof option ? option(file_9) : option ?? fallback;
301
+ const renderOption = (option_0, file_10)=>'function' == typeof option_0 ? option_0(file_10) : option_0;
249
302
  const triggerStyle = {
250
303
  ...styles?.trigger
251
304
  };
@@ -266,47 +319,61 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
266
319
  "data-tao-upload-trigger": "",
267
320
  className: names?.trigger,
268
321
  style: triggerStyle,
322
+ onDragOver: disabled ? void 0 : ()=>setDragging(true),
323
+ onDragLeave: disabled ? void 0 : ()=>setDragging(false),
324
+ onDrop: disabled ? void 0 : (event_2)=>{
325
+ setDragging(false);
326
+ props.onDrop?.(event_2);
327
+ },
269
328
  children: /*#__PURE__*/ jsx(RcUploaderComponent, {
270
329
  onFocus: props.onFocus,
271
330
  ref: uploader,
272
331
  prefixCls: props.prefixCls ?? 'tao-upload-input',
273
332
  component: "span",
274
- action: props.action ?? '',
333
+ action: (file_11)=>preparations.current.get(file_11)?.action ?? '',
275
334
  name: props.name,
276
335
  method: props.method,
277
336
  headers: props.headers,
278
- data: 'function' == typeof props.data ? (file_10)=>props.data(toFile(file_10)) : props.data,
279
- customRequest: props.customRequest,
337
+ data: (file_12)=>preparations.current.get(file_12)?.data ?? {},
338
+ customRequest: request,
280
339
  withCredentials: props.withCredentials,
281
340
  disabled: disabled,
282
341
  multiple: props.multiple,
283
342
  accept: props.accept,
284
343
  directory: props.directory,
285
344
  capture: props.capture,
286
- pastable: props.pastable,
345
+ pastable: props.pastable && !disabled,
287
346
  id: props.id,
288
347
  openFileDialogOnClick: props.openFileDialogOnClick,
289
348
  hasControlInside: props.hasControlInside ?? !!props.children,
290
- beforeUpload: async (file_11, list)=>{
291
- const result = await props.beforeUpload?.(file_11, list);
349
+ beforeUpload: async (file_13, list)=>{
350
+ preparations.current.delete(file_13);
351
+ const result = await props.beforeUpload?.(file_13, list);
292
352
  if (result === LIST_IGNORE) {
293
- ignored.current.add(file_11.uid);
353
+ ignored.current.add(file_13.uid);
354
+ return false;
355
+ }
356
+ if (false === result) return false;
357
+ const { action, data } = propsRef.current;
358
+ try {
359
+ preparations.current.set(file_13, {
360
+ action: 'function' == typeof action ? await action(file_13) : action,
361
+ data: 'function' == typeof data ? await data(toFile(file_13)) : data
362
+ });
363
+ } catch (reason_0) {
364
+ preparations.current.set(file_13, {
365
+ error: asError(reason_0)
366
+ });
294
367
  return false;
295
368
  }
296
369
  return result;
297
370
  },
298
371
  onBatchStart: onBatchStart,
299
- onProgress: (event_2, file_12)=>onProgress({
300
- percent: event_2.percent ?? 0
301
- }, file_12),
372
+ onProgress: (event_3, file_14)=>onProgress({
373
+ percent: event_3.percent ?? 0
374
+ }, file_14),
302
375
  onSuccess: onSuccess,
303
376
  onError: onError,
304
- onDragOver: ()=>setDragging(true),
305
- onDragLeave: ()=>setDragging(false),
306
- onDrop: (event_3)=>{
307
- setDragging(false);
308
- props.onDrop?.(event_3);
309
- },
310
377
  children: props.children ?? ('drag' === type ? config.locale.messages.uploadDrop : config.locale.messages.uploadFile)
311
378
  })
312
379
  }),
@@ -314,91 +381,99 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
314
381
  "data-tao-upload-list": "",
315
382
  className: names?.list,
316
383
  style: styles?.list,
317
- children: files.map((file_13)=>{
318
- const image = props.isImageUrl ? props.isImageUrl(file_13) : !!(file_13.type?.startsWith('image/') || /\.(png|jpe?g|gif|webp|svg|avif)(\?|$)/i.test(file_13.url ?? file_13.name));
384
+ children: files.map((file_15)=>{
385
+ const image = props.isImageUrl ? props.isImageUrl(file_15) : !!(file_15.type?.startsWith('image/') || /\.(png|jpe?g|gif|webp|svg|avif)(\?|$)/i.test(file_15.url ?? file_15.name));
386
+ const localPreview = image && !!file_15.originFileObj;
387
+ const previewUrl = file_15.url ?? file_15.thumbUrl;
319
388
  const actions = {
320
- preview: ()=>props.onPreview?.(file_13),
321
- download: ()=>download(file_13),
389
+ preview: ()=>{
390
+ if (props.onPreview) props.onPreview(file_15);
391
+ else if (previewUrl) window.open(previewUrl, '_blank', 'noopener,noreferrer');
392
+ else if (localPreview) setPreviewFile(file_15);
393
+ },
394
+ download: ()=>download(file_15),
322
395
  remove: ()=>{
323
- remove(file_13);
396
+ remove(file_15);
324
397
  }
325
398
  };
326
399
  const node = /*#__PURE__*/ jsxs("span", {
327
400
  "data-tao-upload-item": "",
328
- "data-status": file_13.status,
401
+ "data-status": file_15.status,
329
402
  className: names?.item,
330
403
  style: styles?.item,
331
404
  children: [
332
405
  'text' !== listType && image ? /*#__PURE__*/ jsx("span", {
333
406
  "data-tao-upload-thumbnail": "",
334
407
  children: /*#__PURE__*/ jsx(FilePreview, {
335
- file: file_13,
408
+ file: file_15,
336
409
  previewFile: props.previewFile
337
410
  })
338
- }) : props.iconRender?.(file_13, listType) ?? /*#__PURE__*/ jsx(FileIcon, {}),
411
+ }) : props.iconRender?.(file_15, listType) ?? /*#__PURE__*/ jsx(FileIcon, {}),
339
412
  /*#__PURE__*/ jsxs("span", {
340
413
  "data-tao-upload-details": "",
341
414
  children: [
342
- file_13.url ? /*#__PURE__*/ jsx("a", {
343
- ...file_13.linkProps,
344
- href: file_13.url,
415
+ file_15.url ? /*#__PURE__*/ jsx("a", {
416
+ ...file_15.linkProps,
417
+ href: file_15.url,
345
418
  target: "_blank",
346
419
  rel: "noopener noreferrer",
347
420
  onClick: (event_4)=>{
348
- if (props.onPreview) {
421
+ const linkClick = file_15.linkProps?.onClick;
422
+ if ('function' == typeof linkClick) linkClick(event_4);
423
+ if (!event_4.defaultPrevented && props.onPreview) {
349
424
  event_4.preventDefault();
350
425
  actions.preview();
351
426
  }
352
427
  },
353
- children: file_13.name
428
+ children: file_15.name
354
429
  }) : /*#__PURE__*/ jsx("span", {
355
- children: file_13.name
430
+ children: file_15.name
356
431
  }),
357
- 'error' === file_13.status && /*#__PURE__*/ jsx("span", {
432
+ 'error' === file_15.status && /*#__PURE__*/ jsx("span", {
358
433
  "data-tao-upload-error": "",
359
434
  role: "status",
360
- children: file_13.error?.message ?? locale.uploadError
435
+ children: file_15.error?.message ?? locale.uploadError
361
436
  }),
362
- 'uploading' === file_13.status && /*#__PURE__*/ jsx(Progress, {
437
+ 'uploading' === file_15.status && /*#__PURE__*/ jsx(Progress, {
363
438
  size: "small",
364
439
  showInfo: false,
365
440
  ...props.progress,
366
- percent: file_13.percent ?? 0,
367
- "aria-label": file_13['aria-label'] ?? file_13.name,
368
- "aria-labelledby": file_13['aria-labelledby']
441
+ percent: file_15.percent ?? 0,
442
+ "aria-label": file_15['aria-label'] ?? file_15.name,
443
+ "aria-labelledby": file_15['aria-labelledby']
369
444
  }),
370
- renderOption(listConfig.extra, file_13)
445
+ renderOption(listConfig.extra, file_15)
371
446
  ]
372
447
  }),
373
448
  /*#__PURE__*/ jsxs("span", {
374
449
  "data-tao-upload-actions": "",
375
450
  children: [
376
- visible(listConfig.showPreviewIcon, file_13, 'picture-card' === listType || 'picture-circle' === listType) && /*#__PURE__*/ jsx(Button, {
451
+ visible(listConfig.showPreviewIcon, file_15, 'picture-card' === listType || 'picture-circle' === listType) && /*#__PURE__*/ jsx(Button, {
377
452
  variant: "ghost",
378
453
  size: "small",
379
- disabled: false,
454
+ disabled: !props.onPreview && !previewUrl && !localPreview,
380
455
  type: "button",
381
- "aria-label": `${locale.previewFile} ${file_13.name}`,
456
+ "aria-label": `${locale.previewFile} ${file_15.name}`,
382
457
  onClick: actions.preview,
383
- children: renderOption(listConfig.previewIcon, file_13) ?? '↗'
458
+ children: renderOption(listConfig.previewIcon, file_15) ?? '↗'
384
459
  }),
385
- visible(listConfig.showDownloadIcon, file_13, false) && /*#__PURE__*/ jsx(Button, {
460
+ visible(listConfig.showDownloadIcon, file_15, false) && /*#__PURE__*/ jsx(Button, {
386
461
  variant: "ghost",
387
462
  size: "small",
388
- disabled: false,
463
+ disabled: !props.onDownload && !file_15.url,
389
464
  type: "button",
390
- "aria-label": `${locale.downloadFile} ${file_13.name}`,
465
+ "aria-label": `${locale.downloadFile} ${file_15.name}`,
391
466
  onClick: actions.download,
392
- children: renderOption(listConfig.downloadIcon, file_13) ?? '↓'
467
+ children: renderOption(listConfig.downloadIcon, file_15) ?? '↓'
393
468
  }),
394
- visible(listConfig.showRemoveIcon, file_13, true) && !disabled && /*#__PURE__*/ jsx(Button, {
469
+ visible(listConfig.showRemoveIcon, file_15, true) && !disabled && /*#__PURE__*/ jsx(Button, {
395
470
  variant: "ghost",
396
471
  size: "small",
397
472
  disabled: false,
398
473
  type: "button",
399
- "aria-label": `${locale.removeFile} ${file_13.name}`,
474
+ "aria-label": `${locale.removeFile} ${file_15.name}`,
400
475
  onClick: actions.remove,
401
- children: renderOption(listConfig.removeIcon, file_13) ?? /*#__PURE__*/ jsx(FileIcon, {
476
+ children: renderOption(listConfig.removeIcon, file_15) ?? /*#__PURE__*/ jsx(FileIcon, {
402
477
  remove: true
403
478
  })
404
479
  })
@@ -408,8 +483,21 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
408
483
  });
409
484
  return /*#__PURE__*/ jsx("span", {
410
485
  "data-tao-upload-row": "",
411
- children: props.itemRender ? props.itemRender(node, file_13, files, actions) : node
412
- }, file_13.uid);
486
+ children: props.itemRender ? props.itemRender(node, file_15, files, actions) : node
487
+ }, file_15.uid);
488
+ })
489
+ }),
490
+ previewFile && /*#__PURE__*/ jsx(Modal, {
491
+ open: true,
492
+ title: previewFile.name,
493
+ footer: null,
494
+ onClose: ()=>setPreviewFile(void 0),
495
+ children: /*#__PURE__*/ jsx("div", {
496
+ "data-tao-upload-preview": "",
497
+ children: /*#__PURE__*/ jsx(FilePreview, {
498
+ file: previewFile,
499
+ previewFile: props.previewFile
500
+ })
413
501
  })
414
502
  }),
415
503
  removeError && /*#__PURE__*/ jsx("span", {
@@ -169,15 +169,17 @@ const Watermark = /*#__PURE__*/ forwardRef((props, ref)=>{
169
169
  height: (size.fontBoundingBoxAscent ?? size.actualBoundingBoxAscent ?? 12) + (size.fontBoundingBoxDescent ?? size.actualBoundingBoxDescent ?? 4)
170
170
  };
171
171
  });
172
- const markWidth = width ?? (image ? 120 : Math.ceil(Math.max(0, ...metrics.map(_temp2))));
173
- const markHeight = height ?? (image ? 64 : metrics.reduce(_temp3, 0) + 3 * Math.max(0, lines.length - 1));
172
+ const textWidth = Math.ceil(Math.max(0, ...metrics.map(_temp2)));
173
+ const textHeight = metrics.reduce(_temp3, 0) + 3 * Math.max(0, lines.length - 1);
174
174
  const radians = rotate * Math.PI / 180;
175
- const rotatedWidth = Math.abs(markWidth * Math.cos(radians)) + Math.abs(markHeight * Math.sin(radians));
176
- const rotatedHeight = Math.abs(markWidth * Math.sin(radians)) + Math.abs(markHeight * Math.cos(radians));
177
- const tileWidth = Math.max(1, Math.ceil(rotatedWidth + gapX));
178
- const tileHeight = Math.max(1, Math.ceil(rotatedHeight + gapY));
179
175
  const draw = (picture)=>{
180
176
  if (cancelled) return;
177
+ const markWidth = width ?? Math.max(image ? 120 : 0, picture ? 0 : textWidth);
178
+ const markHeight = height ?? Math.max(image ? 64 : 0, picture ? 0 : textHeight);
179
+ const rotatedWidth = Math.abs(markWidth * Math.cos(radians)) + Math.abs(markHeight * Math.sin(radians));
180
+ const rotatedHeight = Math.abs(markWidth * Math.sin(radians)) + Math.abs(markHeight * Math.cos(radians));
181
+ const tileWidth = Math.max(1, Math.ceil(rotatedWidth + gapX));
182
+ const tileHeight = Math.max(1, Math.ceil(rotatedHeight + gapY));
181
183
  const ratio = window.devicePixelRatio || 1;
182
184
  canvas.width = Math.ceil(tileWidth * ratio);
183
185
  canvas.height = Math.ceil(tileHeight * ratio);
@@ -281,7 +283,12 @@ const Watermark = /*#__PURE__*/ forwardRef((props, ref)=>{
281
283
  backgroundPosition: `${Math.min(0, offsetX)}px ${Math.min(0, offsetY)}px`,
282
284
  ...styles?.mark
283
285
  };
284
- Object.assign(mark.style, Object.fromEntries(Object.entries(markStyle).map(_temp4)));
286
+ for (const [key_0, value_0] of Object.entries(markStyle)){
287
+ if (null == value_0) continue;
288
+ const property = key_0.startsWith("--") ? key_0 : key_0.replace(/[A-Z]/g, _temp4);
289
+ mark.style.setProperty(property, String(value_0));
290
+ if ("number" == typeof value_0 && !mark.style.getPropertyValue(property)) mark.style.setProperty(property, `${value_0}px`);
291
+ }
285
292
  mark.style.setProperty("visibility", "visible", "important");
286
293
  const expectedStyle = mark.style.cssText;
287
294
  const expectedClass = classNames?.mark ?? "";
@@ -299,7 +306,10 @@ const Watermark = /*#__PURE__*/ forwardRef((props, ref)=>{
299
306
  }
300
307
  mark.style.cssText = expectedStyle;
301
308
  mark.className = expectedClass;
309
+ mark.setAttribute("data-tao-watermark-mark", "");
310
+ mark.setAttribute("aria-hidden", "true");
302
311
  mark.removeAttribute("hidden");
312
+ mark.replaceChildren();
303
313
  if (rootChanged) {
304
314
  holder.style.position = rootPosition;
305
315
  holder.style.overflow = rootOverflow;
@@ -385,33 +395,34 @@ const Watermark = /*#__PURE__*/ forwardRef((props, ref)=>{
385
395
  $[63] = t17;
386
396
  $[64] = t18;
387
397
  } else t18 = $[64];
388
- let t19;
389
- if ($[65] !== children || $[66] !== inherit) {
390
- t19 = inherit ? /*#__PURE__*/ jsx(WatermarkContext.Provider, {
391
- value: context,
398
+ const t19 = inherit ? context : null;
399
+ let t20;
400
+ if ($[65] !== children || $[66] !== t19) {
401
+ t20 = /*#__PURE__*/ jsx(WatermarkContext.Provider, {
402
+ value: t19,
392
403
  children: children
393
- }) : children;
404
+ });
394
405
  $[65] = children;
395
- $[66] = inherit;
396
- $[67] = t19;
397
- } else t19 = $[67];
398
- let t20;
399
- if ($[68] !== rest || $[69] !== t16 || $[70] !== t18 || $[71] !== t19) {
400
- t20 = /*#__PURE__*/ jsx("div", {
406
+ $[66] = t19;
407
+ $[67] = t20;
408
+ } else t20 = $[67];
409
+ let t21;
410
+ if ($[68] !== rest || $[69] !== t16 || $[70] !== t18 || $[71] !== t20) {
411
+ t21 = /*#__PURE__*/ jsx("div", {
401
412
  ...rest,
402
413
  ref: root,
403
414
  "data-tao-watermark": "",
404
415
  className: t16,
405
416
  style: t18,
406
- children: t19
417
+ children: t20
407
418
  });
408
419
  $[68] = rest;
409
420
  $[69] = t16;
410
421
  $[70] = t18;
411
- $[71] = t19;
412
- $[72] = t20;
413
- } else t20 = $[72];
414
- return t20;
422
+ $[71] = t20;
423
+ $[72] = t21;
424
+ } else t21 = $[72];
425
+ return t21;
415
426
  });
416
427
  Watermark.displayName = 'Watermark';
417
428
  function _temp() {
@@ -423,12 +434,8 @@ function _temp2(metric) {
423
434
  function _temp3(sum, metric_0) {
424
435
  return sum + metric_0.height;
425
436
  }
426
- function _temp4(t0) {
427
- const [key_0, value_0] = t0;
428
- return [
429
- key_0,
430
- "number" == typeof value_0 && "zIndex" !== key_0 && "opacity" !== key_0 ? `${value_0}px` : value_0
431
- ];
437
+ function _temp4(letter) {
438
+ return `-${letter.toLowerCase()}`;
432
439
  }
433
440
  function _temp5(cleanup) {
434
441
  cleanup();