@fibrae/semi-foundation 0.1.1 → 0.3.0
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/anchor/foundation.d.ts +1 -4
- package/dist/anchor/foundation.js +21 -22
- package/dist/audio-player/foundation.d.ts +10 -13
- package/dist/audio-player/foundation.js +19 -20
- package/dist/auto-complete/foundation.d.ts +12 -14
- package/dist/auto-complete/foundation.js +51 -52
- package/dist/avatar/foundation.d.ts +5 -6
- package/dist/avatar/foundation.js +16 -16
- package/dist/avatar/variables.scss +0 -1
- package/dist/backtop/foundation.d.ts +2 -5
- package/dist/backtop/foundation.js +7 -8
- package/dist/banner/foundation.d.ts +1 -1
- package/dist/banner/foundation.js +4 -4
- package/dist/base/auto-close-foundation.d.ts +8 -9
- package/dist/base/auto-close-foundation.js +15 -15
- package/dist/base/foundation.d.ts +4 -4
- package/dist/base/foundation.js +12 -11
- package/dist/base/list-store.d.ts +0 -1
- package/dist/breadcrumb/foundation.d.ts +5 -5
- package/dist/breadcrumb/foundation.js +9 -10
- package/dist/breadcrumb/item-foundation.d.ts +3 -3
- package/dist/breadcrumb/item-foundation.js +6 -6
- package/dist/calendar/event-util.d.ts +0 -10
- package/dist/calendar/event-util.js +1 -11
- package/dist/calendar/foundation.d.ts +1 -6
- package/dist/calendar/foundation.js +5 -9
- package/dist/calendar/month-foundation.d.ts +2 -3
- package/dist/calendar/month-foundation.js +6 -7
- package/dist/carousel/foundation.d.ts +17 -19
- package/dist/carousel/foundation.js +51 -51
- package/dist/cascader/foundation.d.ts +36 -32
- package/dist/cascader/foundation.js +145 -132
- package/dist/cascader/util.d.ts +1 -8
- package/dist/cascader/util.js +1 -8
- package/dist/checkbox/checkbox-foundation.d.ts +3 -7
- package/dist/checkbox/checkbox-foundation.js +15 -17
- package/dist/checkbox/checkbox-group-foundation.d.ts +2 -3
- package/dist/checkbox/checkbox-group-foundation.js +8 -8
- package/dist/code-highlight/index.d.ts +1 -2
- package/dist/code-highlight/index.js +3 -3
- package/dist/collapse/foundation.d.ts +2 -2
- package/dist/collapse/foundation.js +7 -7
- package/dist/collapsible/foundation.d.ts +3 -3
- package/dist/collapsible/foundation.js +8 -8
- package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
- package/dist/color-picker/alpha-slider-foundation.js +10 -10
- package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
- package/dist/color-picker/color-choose-area-foundation.js +14 -14
- package/dist/color-picker/color-picker.scss +0 -2
- package/dist/color-picker/color-slider-foundation.d.ts +2 -4
- package/dist/color-picker/color-slider-foundation.js +10 -10
- package/dist/color-picker/data-part-foundation.d.ts +5 -5
- package/dist/color-picker/data-part-foundation.js +11 -11
- package/dist/color-picker/foundation.d.ts +4 -4
- package/dist/color-picker/foundation.js +10 -10
- package/dist/color-picker/interface.d.ts +0 -1
- package/dist/config-provider/breakpoint-observer.d.ts +3 -3
- package/dist/config-provider/breakpoint-observer.js +6 -6
- package/dist/config-provider/responsive-types.d.ts +0 -16
- package/dist/cropper/foundation.d.ts +15 -16
- package/dist/cropper/foundation.js +26 -24
- package/dist/date-picker/_utils/get-default-picker-date.d.ts +0 -3
- package/dist/date-picker/_utils/get-default-picker-date.js +0 -3
- package/dist/date-picker/_utils/get-inset-input-format-token.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-format-token.js +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.js +0 -2
- package/dist/date-picker/_utils/parser.d.ts +0 -3
- package/dist/date-picker/_utils/parser.js +0 -7
- package/dist/date-picker/_utils/picker-type.d.ts +1 -3
- package/dist/date-picker/_utils/picker-type.js +0 -2
- package/dist/date-picker/_utils/to-callback-args.d.ts +0 -1
- package/dist/date-picker/_utils/to-callback-args.js +0 -1
- package/dist/date-picker/date-picker.scss +0 -3
- package/dist/date-picker/foundation.d.ts +39 -58
- package/dist/date-picker/foundation.js +126 -153
- package/dist/date-picker/input-foundation.d.ts +10 -16
- package/dist/date-picker/input-foundation.js +28 -30
- package/dist/date-picker/month-foundation.d.ts +0 -3
- package/dist/date-picker/month-foundation.js +0 -2
- package/dist/date-picker/months-grid-foundation.d.ts +17 -26
- package/dist/date-picker/months-grid-foundation.js +65 -75
- package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
- package/dist/date-picker/year-and-month-foundation.js +11 -11
- package/dist/drag-move/foundation.d.ts +2 -3
- package/dist/drag-move/foundation.js +15 -13
- package/dist/dropdown/foundation.d.ts +8 -7
- package/dist/dropdown/foundation.js +32 -28
- package/dist/dropdown/menu-foundation.d.ts +1 -2
- package/dist/dropdown/menu-foundation.js +11 -11
- package/dist/feedback/foundation.d.ts +9 -10
- package/dist/feedback/foundation.js +33 -33
- package/dist/feedback/variables.scss +1 -5
- package/dist/float-button/float-button.css +0 -1
- package/dist/float-button/float-button.scss +0 -2
- package/dist/form/form-api-proxy.d.ts +8 -7
- package/dist/form/form-api-proxy.js +25 -25
- package/dist/form/form.scss +0 -12
- package/dist/form/foundation.d.ts +5 -5
- package/dist/form/foundation.js +60 -76
- package/dist/form/interface.d.ts +2 -15
- package/dist/form/utils.d.ts +0 -8
- package/dist/form/utils.js +0 -7
- package/dist/form/variables.scss +1 -4
- package/dist/grid/variables.scss +0 -10
- package/dist/highlight/foundation.d.ts +0 -2
- package/dist/highlight/foundation.js +1 -3
- package/dist/hot-keys/foundation.d.ts +2 -3
- package/dist/hot-keys/foundation.js +5 -5
- package/dist/image/image-foundation.d.ts +4 -6
- package/dist/image/image-foundation.js +10 -10
- package/dist/image/preview-footer-foundation.d.ts +3 -4
- package/dist/image/preview-footer-foundation.js +10 -10
- package/dist/image/preview-foundation.d.ts +0 -3
- package/dist/image/preview-foundation.js +7 -6
- package/dist/image/preview-image-foundation.d.ts +6 -9
- package/dist/image/preview-image-foundation.js +14 -14
- package/dist/image/preview-inner-foundation.d.ts +9 -10
- package/dist/image/preview-inner-foundation.js +38 -38
- package/dist/input/foundation.d.ts +10 -11
- package/dist/input/foundation.js +47 -49
- package/dist/input/text-entry-foundation.d.ts +3 -5
- package/dist/input/text-entry-foundation.js +14 -15
- package/dist/input/textarea-foundation.d.ts +7 -8
- package/dist/input/textarea-foundation.js +36 -36
- package/dist/input-number/caret.d.ts +0 -1
- package/dist/input-number/caret.js +0 -1
- package/dist/input-number/foundation.d.ts +16 -19
- package/dist/input-number/foundation.js +54 -58
- package/dist/json-viewer/foundation.d.ts +8 -10
- package/dist/json-viewer/foundation.js +23 -24
- package/dist/locale/interface.d.ts +0 -3
- package/dist/lottie/foundation.d.ts +1 -1
- package/dist/lottie/foundation.js +4 -4
- package/dist/markdown-render/foundation.d.ts +2 -7
- package/dist/markdown-render/foundation.js +5 -9
- package/dist/modal/modal-content-foundation.d.ts +7 -7
- package/dist/modal/modal-content-foundation.js +20 -20
- package/dist/modal/modal-foundation.d.ts +6 -6
- package/dist/modal/modal-foundation.js +24 -24
- package/dist/navigation/foundation.d.ts +1 -8
- package/dist/navigation/foundation.js +14 -20
- package/dist/navigation/item-foundation.d.ts +1 -1
- package/dist/navigation/item-foundation.js +8 -8
- package/dist/navigation/sub-nav-foundation.d.ts +3 -4
- package/dist/navigation/sub-nav-foundation.js +17 -17
- package/dist/notification/notification-list-foundation.d.ts +7 -8
- package/dist/notification/notification-list-foundation.js +12 -13
- package/dist/notification/variables.scss +0 -1
- package/dist/overflow-list/foundation.d.ts +4 -6
- package/dist/overflow-list/foundation.js +18 -19
- package/dist/pagination/foundation.d.ts +8 -10
- package/dist/pagination/foundation.js +28 -28
- package/dist/pincode/foundation.d.ts +6 -9
- package/dist/pincode/foundation.js +23 -26
- package/dist/popconfirm/popconfirm-foundation.d.ts +7 -9
- package/dist/popconfirm/popconfirm-foundation.js +26 -26
- package/dist/progress/generates.d.ts +1 -4
- package/dist/progress/generates.js +1 -4
- package/dist/progress/utils.d.ts +1 -1
- package/dist/progress/utils.js +1 -1
- package/dist/radio/radio-foundation.d.ts +5 -9
- package/dist/radio/radio-foundation.js +15 -16
- package/dist/radio/radio-group-foundation.d.ts +2 -3
- package/dist/radio/radio-group-foundation.js +9 -9
- package/dist/rating/foundation.d.ts +10 -15
- package/dist/rating/foundation.js +35 -38
- package/dist/resizable/group/index.d.ts +6 -10
- package/dist/resizable/group/index.js +40 -44
- package/dist/resizable/resizable.scss +0 -1
- package/dist/resizable/single/index.d.ts +3 -7
- package/dist/resizable/single/index.js +10 -13
- package/dist/scroll-list/item-foundation.d.ts +7 -9
- package/dist/scroll-list/item-foundation.js +35 -36
- package/dist/scroll-list/variables.scss +1 -6
- package/dist/select/foundation.d.ts +42 -57
- package/dist/select/foundation.js +214 -279
- package/dist/select/option-foundation.d.ts +23 -28
- package/dist/select/option-foundation.js +10 -19
- package/dist/select/variables.scss +1 -8
- package/dist/side-sheet/side-sheet-foundation.d.ts +7 -12
- package/dist/side-sheet/side-sheet-foundation.js +23 -27
- package/dist/side-sheet/variables.scss +1 -3
- package/dist/slider/foundation.d.ts +17 -28
- package/dist/slider/foundation.js +47 -59
- package/dist/slider/variables.scss +1 -5
- package/dist/sortable/accessibility.d.ts +1 -1
- package/dist/sortable/accessibility.js +2 -2
- package/dist/spin/foundation.d.ts +2 -4
- package/dist/spin/foundation.js +6 -7
- package/dist/spin/variables.scss +1 -3
- package/dist/steps/utils.d.ts +1 -1
- package/dist/switch/foundation.d.ts +2 -3
- package/dist/switch/foundation.js +7 -7
- package/dist/switch/switch.scss +1 -1
- package/dist/switch/variables.scss +1 -5
- package/dist/table/foundation.d.ts +24 -33
- package/dist/table/foundation.js +144 -108
- package/dist/table/table.scss +0 -1
- package/dist/table/utils.d.ts +2 -10
- package/dist/table/utils.js +0 -13
- package/dist/table/variables.scss +1 -5
- package/dist/tabs/foundation.d.ts +5 -14
- package/dist/tabs/foundation.js +17 -21
- package/dist/tabs/tabs.scss +1 -1
- package/dist/tag/focus.js +0 -1
- package/dist/tag-input/foundation.d.ts +11 -13
- package/dist/tag-input/foundation.js +52 -53
- package/dist/tag-input/tag-input.scss +0 -1
- package/dist/tag-input/utils/tag-focus.d.ts +0 -1
- package/dist/tag-input/utils/tag-focus.js +0 -1
- package/dist/time-picker/combox-foundation.d.ts +3 -11
- package/dist/time-picker/combox-foundation.js +3 -10
- package/dist/time-picker/foundation.d.ts +13 -23
- package/dist/time-picker/foundation.js +39 -48
- package/dist/time-picker/input-foundation.d.ts +4 -4
- package/dist/time-picker/input-foundation.js +13 -13
- package/dist/time-picker/utils/index.d.ts +0 -11
- package/dist/time-picker/utils/index.js +0 -11
- package/dist/toast/toast-list-foundation.d.ts +7 -7
- package/dist/toast/toast-list-foundation.js +14 -14
- package/dist/tooltip/adjust-position.d.ts +1 -2
- package/dist/tooltip/constants.d.ts +0 -3
- package/dist/tooltip/constants.js +0 -3
- package/dist/tooltip/foundation.d.ts +9 -12
- package/dist/tooltip/foundation.js +67 -63
- package/dist/tooltip/position.scss +0 -1
- package/dist/transfer/foundation.d.ts +22 -13
- package/dist/transfer/foundation.js +38 -24
- package/dist/tree/foundation.d.ts +14 -16
- package/dist/tree/foundation.js +61 -62
- package/dist/tree/shared.d.ts +2 -4
- package/dist/tree/shared.js +0 -2
- package/dist/tree/tree-util.d.ts +0 -5
- package/dist/tree/tree-util.js +0 -5
- package/dist/tree-select/foundation.d.ts +26 -22
- package/dist/tree-select/foundation.js +91 -86
- package/dist/typography/ellipsis.d.ts +5 -7
- package/dist/typography/ellipsis.js +8 -10
- package/dist/typography/format-numeral.d.ts +1 -1
- package/dist/typography/format-numeral.js +2 -2
- package/dist/typography/typography.scss +0 -1
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +17 -23
- package/dist/upload/foundation.js +93 -103
- package/dist/upload/utils.d.ts +3 -8
- package/dist/upload/utils.js +6 -11
- package/dist/user-guide/foundation.d.ts +3 -5
- package/dist/user-guide/foundation.js +19 -19
- package/dist/utils/a11y.d.ts +2 -6
- package/dist/utils/a11y.js +1 -4
- package/dist/utils/announcer.d.ts +2 -2
- package/dist/utils/announcer.js +4 -4
- package/dist/utils/array.d.ts +0 -6
- package/dist/utils/array.js +0 -6
- package/dist/utils/date-fns-extra.js +1 -5
- package/dist/utils/dom.d.ts +0 -1
- package/dist/utils/dom.js +0 -1
- package/dist/utils/escape-html.js +0 -3
- package/dist/utils/field-sizing.d.ts +0 -2
- package/dist/utils/field-sizing.js +0 -2
- package/dist/utils/focus-handle.d.ts +1 -2
- package/dist/utils/focus-handle.js +1 -3
- package/dist/utils/focus-scope.d.ts +5 -6
- package/dist/utils/focus-scope.js +10 -11
- package/dist/utils/is-promise.d.ts +1 -1
- package/dist/utils/release-holder.d.ts +2 -2
- package/dist/utils/release-holder.js +4 -4
- package/dist/utils/scroll-lock.d.ts +3 -4
- package/dist/utils/scroll-lock.js +3 -4
- package/dist/utils/tween.d.ts +0 -1
- package/dist/utils/tween.js +0 -1
- package/dist/utils/uuid.d.ts +0 -1
- package/dist/utils/uuid.js +0 -1
- package/dist/utils/warning.d.ts +0 -1
- package/dist/utils/warning.js +0 -1
- package/dist/video-player/foundation.d.ts +15 -15
- package/dist/video-player/foundation.js +89 -89
- package/dist/video-player/progress-foundation.d.ts +2 -3
- package/dist/video-player/progress-foundation.js +12 -13
- package/dist/video-player/variables.scss +1 -1
- package/package.json +2 -2
|
@@ -18,7 +18,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
18
18
|
const next = {};
|
|
19
19
|
if (!Array.isArray(fileList)) {
|
|
20
20
|
this.#localUrls = {};
|
|
21
|
-
this.
|
|
21
|
+
this.adapter.updateLocalUrls([]);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
fileList.forEach((item) => {
|
|
@@ -28,7 +28,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
28
28
|
if (uid && typeof url === "string" && url.startsWith("blob:") && fileInstance instanceof File) next[uid] = url;
|
|
29
29
|
});
|
|
30
30
|
this.#localUrls = next;
|
|
31
|
-
this.
|
|
31
|
+
this.adapter.updateLocalUrls(Object.values(this.#localUrls));
|
|
32
32
|
}
|
|
33
33
|
#releaseFileUrl(uid) {
|
|
34
34
|
if (!uid) return;
|
|
@@ -38,7 +38,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
38
38
|
const next = { ...this.#localUrls };
|
|
39
39
|
delete next[uid];
|
|
40
40
|
this.#localUrls = next;
|
|
41
|
-
this.
|
|
41
|
+
this.adapter.updateLocalUrls(Object.values(this.#localUrls));
|
|
42
42
|
}
|
|
43
43
|
#releaseAllFileUrls() {
|
|
44
44
|
const localUrls = this.#localUrls;
|
|
@@ -48,7 +48,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
48
48
|
if (url) this.#releaseBlob(url);
|
|
49
49
|
});
|
|
50
50
|
this.#localUrls = {};
|
|
51
|
-
this.
|
|
51
|
+
this.adapter.updateLocalUrls([]);
|
|
52
52
|
}
|
|
53
53
|
#getFileIndex(file, fileList) {
|
|
54
54
|
return fileList.findIndex((item) => item.uid === file.uid);
|
|
@@ -59,7 +59,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
59
59
|
if (uid && next[uid] && next[uid] !== url) this.#releaseBlob(next[uid]);
|
|
60
60
|
if (uid) next[uid] = url;
|
|
61
61
|
this.#localUrls = next;
|
|
62
|
-
this.
|
|
62
|
+
this.adapter.updateLocalUrls(Object.values(this.#localUrls));
|
|
63
63
|
return url;
|
|
64
64
|
}
|
|
65
65
|
#releaseBlob(url) {
|
|
@@ -67,7 +67,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
67
67
|
}
|
|
68
68
|
#updateFileListInternal(newFileList, callback) {
|
|
69
69
|
this.#latestFileList = newFileList;
|
|
70
|
-
this.
|
|
70
|
+
this.adapter.updateFileList(newFileList, callback);
|
|
71
71
|
}
|
|
72
72
|
#getLatestFileList() {
|
|
73
73
|
return this.#latestFileList || this.getFileList();
|
|
@@ -80,7 +80,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
80
80
|
if (this.checkFileSize(file)) {
|
|
81
81
|
file._sizeInvalid = true;
|
|
82
82
|
file.status = FILE_STATUS_VALID_FAIL;
|
|
83
|
-
this.
|
|
83
|
+
this.adapter.notifySizeError(file, fileList);
|
|
84
84
|
}
|
|
85
85
|
return file;
|
|
86
86
|
}
|
|
@@ -88,7 +88,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
88
88
|
const { uploadTrigger } = this.getProps();
|
|
89
89
|
this.#releaseAllFileUrls();
|
|
90
90
|
const currentFiles = files.map((item) => this.buildFileItem(item, uploadTrigger));
|
|
91
|
-
this.
|
|
91
|
+
this.adapter.notifyChange({
|
|
92
92
|
fileList: currentFiles,
|
|
93
93
|
currentFile: currentFiles[0]
|
|
94
94
|
});
|
|
@@ -109,7 +109,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
109
109
|
lastAdded = file;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
if (lastAdded) this.
|
|
112
|
+
if (lastAdded) this.adapter.notifyChange({
|
|
113
113
|
fileList,
|
|
114
114
|
currentFile: lastAdded
|
|
115
115
|
});
|
|
@@ -130,7 +130,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
130
130
|
}
|
|
131
131
|
if (typeof beforeUpload === "function") {
|
|
132
132
|
const fileList = this.#getLatestFileList();
|
|
133
|
-
const buResult = this.
|
|
133
|
+
const buResult = this.adapter.notifyBeforeUpload({
|
|
134
134
|
file,
|
|
135
135
|
fileList
|
|
136
136
|
});
|
|
@@ -201,7 +201,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
201
201
|
newFileList[index] = currentFile;
|
|
202
202
|
}
|
|
203
203
|
this.#updateFileListInternal(newFileList);
|
|
204
|
-
this.
|
|
204
|
+
this.adapter.notifyChange({
|
|
205
205
|
fileList: newFileList,
|
|
206
206
|
currentFile
|
|
207
207
|
});
|
|
@@ -275,9 +275,9 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
275
275
|
percent,
|
|
276
276
|
status: FILE_STATUS_UPLOADING
|
|
277
277
|
};
|
|
278
|
-
this.
|
|
278
|
+
this.adapter.notifyProgress(percent, fileInstance, newFileList);
|
|
279
279
|
this.#updateFileListInternal(newFileList);
|
|
280
|
-
this.
|
|
280
|
+
this.adapter.notifyChange({
|
|
281
281
|
fileList: newFileList,
|
|
282
282
|
currentFile: newFileList[index]
|
|
283
283
|
});
|
|
@@ -313,9 +313,9 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
313
313
|
};
|
|
314
314
|
if (e) currentFile.event = e;
|
|
315
315
|
newFileList[index] = currentFile;
|
|
316
|
-
this.
|
|
316
|
+
this.adapter.notifyProgress(100, fileInstance, newFileList);
|
|
317
317
|
if (afterUpload && typeof afterUpload === "function") {
|
|
318
|
-
const { autoRemove, status, validateMessage, name, url } = this.
|
|
318
|
+
const { autoRemove, status, validateMessage, name, url } = this.adapter.notifyAfterUpload({
|
|
319
319
|
response: body,
|
|
320
320
|
file: currentFile,
|
|
321
321
|
fileList: newFileList
|
|
@@ -334,8 +334,8 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
334
334
|
newFileList.splice(index, 1);
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
-
this.
|
|
338
|
-
this.
|
|
337
|
+
this.adapter.notifySuccess(body, fileInstance, newFileList);
|
|
338
|
+
this.adapter.notifyChange({
|
|
339
339
|
fileList: newFileList,
|
|
340
340
|
currentFile
|
|
341
341
|
});
|
|
@@ -358,9 +358,9 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
358
358
|
response: error,
|
|
359
359
|
event: e
|
|
360
360
|
};
|
|
361
|
-
this.
|
|
361
|
+
this.adapter.notifyError(error, fileInstance, newFileList, xhr);
|
|
362
362
|
this.#updateFileListInternal(newFileList);
|
|
363
|
-
this.
|
|
363
|
+
this.adapter.notifyChange({
|
|
364
364
|
currentFile: newFileList[index],
|
|
365
365
|
fileList: newFileList
|
|
366
366
|
});
|
|
@@ -370,18 +370,15 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
370
370
|
const items = [].slice.call(e.dataTransfer.items);
|
|
371
371
|
const files = await mapFileTree(items);
|
|
372
372
|
this.#selectFiles(files, false);
|
|
373
|
-
this.
|
|
374
|
-
this.
|
|
373
|
+
this.adapter.updateDragAreaStatus(DRAG_AREA_DEFAULT);
|
|
374
|
+
this.adapter.notifyDrop(e, files, fileList);
|
|
375
375
|
}
|
|
376
|
-
/**
|
|
377
|
-
* Keeps the files accept allows and reports the others. When accept leaves nothing it returns undefined after
|
|
378
|
-
* calling `reset`: a remounted input fires change again when the same file is picked.
|
|
379
|
-
*/
|
|
376
|
+
/** When accept leaves nothing it returns undefined after calling `reset`: a remounted input fires change again when the same file is picked */
|
|
380
377
|
#acceptFiles(files, reset) {
|
|
381
378
|
const { accept } = this.getProps();
|
|
382
379
|
if (typeof accept === "undefined") return files;
|
|
383
380
|
const invalidFiles = files.filter((item) => !this.checkFileFormat(accept, item));
|
|
384
|
-
if (invalidFiles.length !== 0) this.
|
|
381
|
+
if (invalidFiles.length !== 0) this.adapter.notifyAcceptInvalid(invalidFiles);
|
|
385
382
|
const accepted = files.filter((item) => !invalidFiles.includes(item));
|
|
386
383
|
if (accepted.length === 0) {
|
|
387
384
|
reset?.();
|
|
@@ -394,7 +391,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
394
391
|
const used = this.getFileList().length;
|
|
395
392
|
if (typeof limit === "undefined" || used + files.length <= limit) return files;
|
|
396
393
|
if (limit === 1) return files.slice(-1);
|
|
397
|
-
this.
|
|
394
|
+
this.adapter.notifyExceed(files);
|
|
398
395
|
return files.slice(0, Math.max(0, limit - used));
|
|
399
396
|
}
|
|
400
397
|
#dispatchFiles(files, isReplaceOperation) {
|
|
@@ -407,7 +404,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
407
404
|
try {
|
|
408
405
|
return await beforeCrop(file, files) !== false;
|
|
409
406
|
} catch (error) {
|
|
410
|
-
this.
|
|
407
|
+
this.adapter.notifyCropError(error);
|
|
411
408
|
return false;
|
|
412
409
|
}
|
|
413
410
|
}
|
|
@@ -428,9 +425,8 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
428
425
|
isReplaceOperation
|
|
429
426
|
});
|
|
430
427
|
}
|
|
431
|
-
/** Filters by accept, then crops the images (when `crop` is on and allowed) or adds the files to the list */
|
|
432
428
|
#selectFiles(currentFileList, allowCrop) {
|
|
433
|
-
let files = this.#acceptFiles(currentFileList, () => this.
|
|
429
|
+
let files = this.#acceptFiles(currentFileList, () => this.adapter.resetInput());
|
|
434
430
|
if (!files) return;
|
|
435
431
|
if (allowCrop && this.getProps().crop && files.some(isImageFile)) {
|
|
436
432
|
if (this.getStates().cropperVisible) return;
|
|
@@ -442,10 +438,6 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
442
438
|
}
|
|
443
439
|
this.#addSelected(files);
|
|
444
440
|
}
|
|
445
|
-
/**
|
|
446
|
-
* Pipeline for files that passed accept: transform and assign uid, flag invalid sizes, apply limit, add to the
|
|
447
|
-
* list; with uploadTrigger 'auto', each file with a valid size then goes through beforeUpload and the upload.
|
|
448
|
-
*/
|
|
449
441
|
#addSelected(selected) {
|
|
450
442
|
const { limit } = this.getProps();
|
|
451
443
|
const fileList = this.getFileList();
|
|
@@ -455,18 +447,18 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
455
447
|
if (total > limit) {
|
|
456
448
|
if (limit === 1) {
|
|
457
449
|
files = files.slice(-1);
|
|
458
|
-
this.
|
|
459
|
-
this.
|
|
450
|
+
this.adapter.notifyFileSelect(files);
|
|
451
|
+
this.adapter.resetInput();
|
|
460
452
|
this.#replaceFileList(files);
|
|
461
453
|
return;
|
|
462
454
|
}
|
|
463
|
-
this.
|
|
455
|
+
this.adapter.notifyExceed(files);
|
|
464
456
|
const restNum = Math.max(0, limit - fileList.length);
|
|
465
457
|
files = files.slice(0, restNum);
|
|
466
458
|
}
|
|
467
459
|
}
|
|
468
|
-
this.
|
|
469
|
-
this.
|
|
460
|
+
this.adapter.notifyFileSelect(files);
|
|
461
|
+
this.adapter.resetInput();
|
|
470
462
|
this.#addFilesToList(files);
|
|
471
463
|
}
|
|
472
464
|
#replaceFile(file) {
|
|
@@ -475,21 +467,21 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
475
467
|
const fileList = this.getFileList();
|
|
476
468
|
const index = fileList.findIndex((item) => item.uid === replaceUid);
|
|
477
469
|
if (index < 0) {
|
|
478
|
-
this.
|
|
470
|
+
this.adapter.resetReplaceInput();
|
|
479
471
|
return;
|
|
480
472
|
}
|
|
481
473
|
const newFile = this.#prepareFile(file, fileList);
|
|
482
|
-
this.
|
|
474
|
+
this.adapter.notifyFileSelect([newFile]);
|
|
483
475
|
const newFileItem = this.buildFileItem(newFile, uploadTrigger);
|
|
484
476
|
const newFileList = [...fileList];
|
|
485
477
|
this.#releaseFileUrl(replaceUid);
|
|
486
478
|
newFileList.splice(index, 1, newFileItem);
|
|
487
|
-
this.
|
|
479
|
+
this.adapter.notifyChange({
|
|
488
480
|
currentFile: newFileItem,
|
|
489
481
|
fileList: newFileList
|
|
490
482
|
});
|
|
491
483
|
this.#updateFileListInternal(newFileList, () => {
|
|
492
|
-
this.
|
|
484
|
+
this.adapter.resetReplaceInput();
|
|
493
485
|
if (!newFileItem._sizeInvalid) this.#upload(newFileItem);
|
|
494
486
|
});
|
|
495
487
|
}
|
|
@@ -550,7 +542,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
550
542
|
});
|
|
551
543
|
}
|
|
552
544
|
/** Closes the cropper and drops the queue; the files already cropped are discarded */
|
|
553
|
-
cancelCrop() {
|
|
545
|
+
cancelCrop = () => {
|
|
554
546
|
const { cropperSrc } = this.getStates();
|
|
555
547
|
if (cropperSrc) URL.revokeObjectURL(cropperSrc);
|
|
556
548
|
this.setState({
|
|
@@ -562,15 +554,14 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
562
554
|
croppedFiles: [],
|
|
563
555
|
isReplaceOperation: false
|
|
564
556
|
});
|
|
565
|
-
this.
|
|
566
|
-
this.
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
async confirmCrop() {
|
|
557
|
+
this.adapter.resetInput();
|
|
558
|
+
this.adapter.resetReplaceInput();
|
|
559
|
+
};
|
|
560
|
+
confirmCrop = async () => {
|
|
570
561
|
const { cropperFile, cropperSrc, pendingImageFiles, nonImageFiles, croppedFiles, isReplaceOperation } = this.getStates();
|
|
571
562
|
const { crop } = this.getProps();
|
|
572
563
|
try {
|
|
573
|
-
const canvas = this.
|
|
564
|
+
const canvas = this.adapter.getCropperCanvas();
|
|
574
565
|
if (!canvas || !cropperFile) throw new Error("Cropper instance not found");
|
|
575
566
|
const quality = (typeof crop === "object" ? crop.quality : void 0) ?? .92;
|
|
576
567
|
const type = cropperFile.type || "image/png";
|
|
@@ -597,18 +588,17 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
597
588
|
this.cancelCrop();
|
|
598
589
|
this.#dispatchFiles([...nextCropped, ...nonImageFiles], isReplaceOperation);
|
|
599
590
|
} catch (error) {
|
|
600
|
-
this.
|
|
591
|
+
this.adapter.notifyCropError(error);
|
|
601
592
|
}
|
|
602
|
-
}
|
|
593
|
+
};
|
|
603
594
|
/** Keep the synchronous snapshot aligned with an externally controlled fileList. */
|
|
604
|
-
syncLatestFileList(fileList) {
|
|
595
|
+
syncLatestFileList = (fileList) => {
|
|
605
596
|
this.#latestFileList = fileList.slice();
|
|
606
|
-
}
|
|
597
|
+
};
|
|
607
598
|
/** A fileList prop that goes back to undefined clears the list (a form reset) and leaves it uncontrolled */
|
|
608
|
-
handleFileListPropChange(fileList) {
|
|
599
|
+
handleFileListPropChange = (fileList) => {
|
|
609
600
|
if (fileList === void 0) this.#updateFileListInternal([]);
|
|
610
|
-
}
|
|
611
|
-
/** The list on screen: the fileList prop when controlled, otherwise the fileList state. */
|
|
601
|
+
};
|
|
612
602
|
getFileList() {
|
|
613
603
|
const props = this.getProps();
|
|
614
604
|
return props.fileList === void 0 ? this.getState("fileList") : props.fileList || [];
|
|
@@ -618,7 +608,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
618
608
|
this.#syncLocalUrlsFromFileList();
|
|
619
609
|
}
|
|
620
610
|
/** Adds the files of a paste on the page; the host listens only while addOnPasting is on and not disabled */
|
|
621
|
-
handlePasting(e) {
|
|
611
|
+
handlePasting = (e) => {
|
|
622
612
|
if (!e.clipboardData) return;
|
|
623
613
|
const files = [];
|
|
624
614
|
for (const item of e.clipboardData.items) {
|
|
@@ -626,28 +616,28 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
626
616
|
try {
|
|
627
617
|
const file = item.getAsFile();
|
|
628
618
|
if (file) files.push(file);
|
|
629
|
-
else this.
|
|
619
|
+
else this.adapter.notifyPastingError(/* @__PURE__ */ new Error("Failed to read a pasted file from the clipboard"));
|
|
630
620
|
} catch (error) {
|
|
631
|
-
this.
|
|
621
|
+
this.adapter.notifyPastingError(error);
|
|
632
622
|
}
|
|
633
623
|
}
|
|
634
624
|
if (files.length > 0) {
|
|
635
625
|
e.preventDefault();
|
|
636
626
|
this.addFiles(files);
|
|
637
627
|
}
|
|
638
|
-
}
|
|
628
|
+
};
|
|
639
629
|
/** Entry for picked, dropped and pasted files: with crop on, images are cropped before they are added */
|
|
640
|
-
addFiles(currentFileList) {
|
|
630
|
+
addFiles = (currentFileList) => {
|
|
641
631
|
this.#selectFiles(Array.from(currentFileList), true);
|
|
642
|
-
}
|
|
632
|
+
};
|
|
643
633
|
/** Entry for the file picked to replace the item `replaceUid` names; with crop on, an image is cropped first */
|
|
644
|
-
handleReplaceChange(currentFileList) {
|
|
634
|
+
handleReplaceChange = (currentFileList) => {
|
|
645
635
|
const newFile = Array.from(currentFileList).pop();
|
|
646
|
-
if (!newFile || !this.#acceptFiles([newFile], () => this.
|
|
636
|
+
if (!newFile || !this.#acceptFiles([newFile], () => this.adapter.resetReplaceInput())) return;
|
|
647
637
|
if (this.getProps().crop && isImageFile(newFile)) this.#startCrop([newFile], true);
|
|
648
638
|
else this.#replaceFile(newFile);
|
|
649
|
-
}
|
|
650
|
-
insertFileToList(files, index) {
|
|
639
|
+
};
|
|
640
|
+
insertFileToList = (files, index) => {
|
|
651
641
|
const { limit, uploadTrigger } = this.getProps();
|
|
652
642
|
const fileList = this.getFileList();
|
|
653
643
|
const accepted = this.#acceptFiles(Array.from(files));
|
|
@@ -658,12 +648,12 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
658
648
|
if (total > limit) {
|
|
659
649
|
if (limit === 1) {
|
|
660
650
|
currentFileList = currentFileList.slice(-1);
|
|
661
|
-
this.
|
|
662
|
-
this.
|
|
651
|
+
this.adapter.notifyFileSelect(currentFileList);
|
|
652
|
+
this.adapter.resetInput();
|
|
663
653
|
this.#replaceFileList(currentFileList);
|
|
664
654
|
return;
|
|
665
655
|
}
|
|
666
|
-
this.
|
|
656
|
+
this.adapter.notifyExceed(currentFileList);
|
|
667
657
|
const restNum = Math.max(0, limit - fileList.length);
|
|
668
658
|
currentFileList = currentFileList.slice(0, restNum);
|
|
669
659
|
}
|
|
@@ -672,58 +662,58 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
672
662
|
const newFileList = fileList.slice();
|
|
673
663
|
if (typeof index !== "undefined") newFileList.splice(index, 0, ...fileItemList);
|
|
674
664
|
else newFileList.push(...fileItemList);
|
|
675
|
-
this.
|
|
676
|
-
this.
|
|
665
|
+
this.adapter.notifyFileSelect(currentFileList);
|
|
666
|
+
this.adapter.notifyChange({
|
|
677
667
|
fileList: newFileList,
|
|
678
668
|
currentFile: null
|
|
679
669
|
});
|
|
680
670
|
this.#updateFileListInternal(newFileList, () => {
|
|
681
671
|
if (uploadTrigger === TRIGGER_AUTO) this.#startUpload(fileItemList);
|
|
682
672
|
});
|
|
683
|
-
}
|
|
684
|
-
manualUpload() {
|
|
673
|
+
};
|
|
674
|
+
manualUpload = () => {
|
|
685
675
|
const waitToUploadFileList = this.#getLatestFileList().filter((item) => item.status === FILE_STATUS_WAIT_UPLOAD);
|
|
686
676
|
this.#startUpload(waitToUploadFileList);
|
|
687
|
-
}
|
|
688
|
-
handleRemove(file) {
|
|
677
|
+
};
|
|
678
|
+
handleRemove = (file) => {
|
|
689
679
|
const { disabled } = this.getProps();
|
|
690
680
|
if (disabled) return;
|
|
691
681
|
const fileList = this.getFileList();
|
|
692
|
-
Promise.resolve(this.
|
|
682
|
+
Promise.resolve(this.adapter.notifyBeforeRemove(file, fileList)).then((res) => {
|
|
693
683
|
if (res === false) return;
|
|
694
684
|
const newFileList = this.#getLatestFileList().slice();
|
|
695
685
|
const index = this.#getFileIndex(file, newFileList);
|
|
696
686
|
if (index < 0) return;
|
|
697
687
|
newFileList.splice(index, 1);
|
|
698
688
|
this.#releaseFileUrl(file.uid);
|
|
699
|
-
this.
|
|
689
|
+
this.adapter.notifyRemove(file.fileInstance, newFileList, file);
|
|
700
690
|
this.#updateFileListInternal(newFileList);
|
|
701
|
-
this.
|
|
691
|
+
this.adapter.notifyChange({
|
|
702
692
|
fileList: newFileList,
|
|
703
693
|
currentFile: file
|
|
704
694
|
});
|
|
705
695
|
}, () => {});
|
|
706
|
-
}
|
|
707
|
-
handleClear() {
|
|
696
|
+
};
|
|
697
|
+
handleClear = () => {
|
|
708
698
|
const { disabled } = this.getProps();
|
|
709
699
|
const fileList = this.getFileList();
|
|
710
700
|
if (disabled) return;
|
|
711
|
-
Promise.resolve(this.
|
|
701
|
+
Promise.resolve(this.adapter.notifyBeforeClear(fileList)).then((res) => {
|
|
712
702
|
if (res === false) return;
|
|
713
703
|
this.#releaseAllFileUrls();
|
|
714
704
|
this.#updateFileListInternal([]);
|
|
715
|
-
this.
|
|
716
|
-
this.
|
|
705
|
+
this.adapter.notifyClear();
|
|
706
|
+
this.adapter.notifyChange({ fileList: [] });
|
|
717
707
|
}, () => {});
|
|
718
|
-
}
|
|
719
|
-
handleDragEnter(e) {
|
|
708
|
+
};
|
|
709
|
+
handleDragEnter = (e) => {
|
|
720
710
|
e.preventDefault();
|
|
721
711
|
e.stopPropagation();
|
|
722
712
|
this.#dragDepth++;
|
|
723
713
|
const { disabled } = this.getProps();
|
|
724
|
-
if (!disabled) this.
|
|
725
|
-
}
|
|
726
|
-
handleDrop(e) {
|
|
714
|
+
if (!disabled) this.adapter.updateDragAreaStatus(DRAG_AREA_LEGAL);
|
|
715
|
+
};
|
|
716
|
+
handleDrop = (e) => {
|
|
727
717
|
e.preventDefault();
|
|
728
718
|
e.stopPropagation();
|
|
729
719
|
this.#dragDepth = 0;
|
|
@@ -736,27 +726,27 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
736
726
|
}
|
|
737
727
|
const files = Array.from(e.dataTransfer.files);
|
|
738
728
|
this.addFiles(files);
|
|
739
|
-
this.
|
|
740
|
-
this.
|
|
729
|
+
this.adapter.updateDragAreaStatus(DRAG_AREA_DEFAULT);
|
|
730
|
+
this.adapter.notifyDrop(e, files, fileList);
|
|
741
731
|
}
|
|
742
|
-
}
|
|
743
|
-
handleDragOver(e) {
|
|
732
|
+
};
|
|
733
|
+
handleDragOver = (e) => {
|
|
744
734
|
e.preventDefault();
|
|
745
735
|
e.stopPropagation();
|
|
746
|
-
}
|
|
747
|
-
handleDragLeave(e) {
|
|
736
|
+
};
|
|
737
|
+
handleDragLeave = (e) => {
|
|
748
738
|
e.preventDefault();
|
|
749
739
|
e.stopPropagation();
|
|
750
740
|
this.#dragDepth = Math.max(0, this.#dragDepth - 1);
|
|
751
|
-
if (this.#dragDepth === 0) this.
|
|
752
|
-
}
|
|
753
|
-
retry(fileItem) {
|
|
741
|
+
if (this.#dragDepth === 0) this.adapter.updateDragAreaStatus(DRAG_AREA_DEFAULT);
|
|
742
|
+
};
|
|
743
|
+
retry = (fileItem) => {
|
|
754
744
|
if (this.getProps().disabled) return;
|
|
755
|
-
this.
|
|
745
|
+
this.adapter.notifyRetry(fileItem);
|
|
756
746
|
if (fileItem.fileInstance) this.#post(fileItem);
|
|
757
|
-
}
|
|
758
|
-
handlePreviewClick(fileItem) {
|
|
759
|
-
this.
|
|
760
|
-
}
|
|
747
|
+
};
|
|
748
|
+
handlePreviewClick = (fileItem) => {
|
|
749
|
+
this.adapter.notifyPreviewClick(fileItem);
|
|
750
|
+
};
|
|
761
751
|
};
|
|
762
752
|
export { UploadFoundation as default };
|
package/dist/upload/utils.d.ts
CHANGED
|
@@ -3,12 +3,7 @@ export declare const byteMB = 1048576;
|
|
|
3
3
|
export declare const addAreaControlAttributes: string[];
|
|
4
4
|
export declare function containsControl(node: HTMLElement): boolean;
|
|
5
5
|
export declare function containsName(node: HTMLElement): boolean;
|
|
6
|
-
/** The position of the card that holds `target`; -1 when it is outside the cards, like the clear button */
|
|
7
6
|
export declare function indexOfCard(cards: ArrayLike<Element>, target: Node): number;
|
|
8
|
-
/**
|
|
9
|
-
* Where focus goes once the control that held it left the list (a card removed, cleared, retried or replaced): the
|
|
10
|
-
* remove button of the card now at `index`, else of the last card, else the add area.
|
|
11
|
-
*/
|
|
12
7
|
export declare function getFocusHandoverTarget(cards: ArrayLike<Element>, index: number, addArea: HTMLElement | null): HTMLElement | null;
|
|
13
8
|
/**
|
|
14
9
|
* Remembers which control in the file list held focus. Removing, clearing, retrying or replacing a file (or disabling
|
|
@@ -16,9 +11,9 @@ export declare function getFocusHandoverTarget(cards: ArrayLike<Element>, index:
|
|
|
16
11
|
*/
|
|
17
12
|
export declare class ListFocusTracker {
|
|
18
13
|
#private;
|
|
19
|
-
track(node: Node, cards: ArrayLike<Element>)
|
|
20
|
-
untrack(node: Node)
|
|
21
|
-
restore(cards: ArrayLike<Element>, addArea: HTMLElement | null)
|
|
14
|
+
track: (node: Node, cards: ArrayLike<Element>) => void;
|
|
15
|
+
untrack: (node: Node) => void;
|
|
16
|
+
restore: (cards: ArrayLike<Element>, addArea: HTMLElement | null) => void;
|
|
22
17
|
}
|
|
23
18
|
export declare function getFileSize(number: number): string;
|
|
24
19
|
export declare function loopFiles(item: FileSystemDirectoryEntry): Promise<Array<FileSystemEntry>>;
|
package/dist/upload/utils.js
CHANGED
|
@@ -17,14 +17,9 @@ function containsControl(node) {
|
|
|
17
17
|
function containsName(node) {
|
|
18
18
|
return (node.textContent ?? "").trim() !== "" || node.querySelector("[aria-label],[aria-labelledby],[alt]") !== null;
|
|
19
19
|
}
|
|
20
|
-
/** The position of the card that holds `target`; -1 when it is outside the cards, like the clear button */
|
|
21
20
|
function indexOfCard(cards, target) {
|
|
22
21
|
return Array.from(cards).findIndex((card) => card.contains(target));
|
|
23
22
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Where focus goes once the control that held it left the list (a card removed, cleared, retried or replaced): the
|
|
26
|
-
* remove button of the card now at `index`, else of the last card, else the add area.
|
|
27
|
-
*/
|
|
28
23
|
function getFocusHandoverTarget(cards, index, addArea) {
|
|
29
24
|
const card = index >= 0 ? cards[Math.min(index, cards.length - 1)] : void 0;
|
|
30
25
|
const cardTarget = card && (card.querySelector(`.${cssClasses.PREFIX}-file-card-close, .${cssClasses.PREFIX}-picture-file-card-close`) ?? FocusTrapHandle.getFocusableElements(card).find((node) => node instanceof HTMLElement));
|
|
@@ -38,23 +33,23 @@ function getFocusHandoverTarget(cards, index, addArea) {
|
|
|
38
33
|
*/
|
|
39
34
|
var ListFocusTracker = class {
|
|
40
35
|
#focused = null;
|
|
41
|
-
track(node, cards) {
|
|
36
|
+
track = (node, cards) => {
|
|
42
37
|
this.#focused = {
|
|
43
38
|
node,
|
|
44
39
|
index: indexOfCard(cards, node)
|
|
45
40
|
};
|
|
46
|
-
}
|
|
47
|
-
untrack(node) {
|
|
41
|
+
};
|
|
42
|
+
untrack = (node) => {
|
|
48
43
|
queueMicrotask(() => {
|
|
49
44
|
if (this.#focused?.node === node && node.isConnected) this.#focused = null;
|
|
50
45
|
});
|
|
51
|
-
}
|
|
52
|
-
restore(cards, addArea) {
|
|
46
|
+
};
|
|
47
|
+
restore = (cards, addArea) => {
|
|
53
48
|
const lost = this.#focused;
|
|
54
49
|
if (!lost || lost.node.isConnected) return;
|
|
55
50
|
this.#focused = null;
|
|
56
51
|
handoverFocus(lost.node, getFocusHandoverTarget(cards, lost.index, addArea));
|
|
57
|
-
}
|
|
52
|
+
};
|
|
58
53
|
};
|
|
59
54
|
function getFileSize(number) {
|
|
60
55
|
if (number < 1024) return `${(number / byteKB).toFixed(2)}KB`;
|
|
@@ -9,12 +9,10 @@ export interface UserGuideAdapter<P extends UserGuideBaseProps = UserGuideBasePr
|
|
|
9
9
|
disabledBodyScroll: () => void;
|
|
10
10
|
enabledBodyScroll: () => void;
|
|
11
11
|
}
|
|
12
|
-
/** The props the foundation reads */
|
|
13
12
|
export interface UserGuideBaseProps {
|
|
14
13
|
current?: number;
|
|
15
14
|
steps: unknown[];
|
|
16
15
|
}
|
|
17
|
-
/** The state the foundation reads */
|
|
18
16
|
export interface UserGuideBaseState {
|
|
19
17
|
current: number;
|
|
20
18
|
}
|
|
@@ -38,9 +36,9 @@ export default class UserGuideFoundation<P extends UserGuideBaseProps = UserGuid
|
|
|
38
36
|
} | undefined, spotlightPadding: number | undefined, scrollIntoView: boolean): DOMRect | null;
|
|
39
37
|
static isSameRect(a?: DOMRect | null, b?: DOMRect | null): boolean;
|
|
40
38
|
destroy(): void;
|
|
41
|
-
beforeShow()
|
|
42
|
-
releaseScroll()
|
|
43
|
-
afterHide()
|
|
39
|
+
beforeShow: () => void;
|
|
40
|
+
releaseScroll: () => void;
|
|
41
|
+
afterHide: () => void;
|
|
44
42
|
handlePrev: () => void;
|
|
45
43
|
handleNext: () => void;
|
|
46
44
|
handleSkip: () => void;
|
|
@@ -6,7 +6,7 @@ var UserGuideFoundation = class UserGuideFoundation extends BaseFoundation {
|
|
|
6
6
|
return UserGuideFoundation.deriveCurrent(this.getProps(), this.getStates());
|
|
7
7
|
}
|
|
8
8
|
getIsControlledComponent() {
|
|
9
|
-
return this.
|
|
9
|
+
return this.isControlledComponent("current");
|
|
10
10
|
}
|
|
11
11
|
static deriveCurrent(props, state) {
|
|
12
12
|
return props.current === void 0 ? state.current : props.current;
|
|
@@ -37,37 +37,37 @@ var UserGuideFoundation = class UserGuideFoundation extends BaseFoundation {
|
|
|
37
37
|
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
38
38
|
}
|
|
39
39
|
destroy() {
|
|
40
|
-
this.
|
|
40
|
+
this.adapter.enabledBodyScroll();
|
|
41
41
|
}
|
|
42
|
-
beforeShow() {
|
|
43
|
-
this.
|
|
44
|
-
}
|
|
45
|
-
releaseScroll() {
|
|
46
|
-
this.
|
|
47
|
-
}
|
|
48
|
-
afterHide() {
|
|
42
|
+
beforeShow = () => {
|
|
43
|
+
this.adapter.disabledBodyScroll();
|
|
44
|
+
};
|
|
45
|
+
releaseScroll = () => {
|
|
46
|
+
this.adapter.enabledBodyScroll();
|
|
47
|
+
};
|
|
48
|
+
afterHide = () => {
|
|
49
49
|
this.releaseScroll();
|
|
50
|
-
this.
|
|
51
|
-
}
|
|
50
|
+
this.adapter.setCurrent(numbers.DEFAULT_CURRENT);
|
|
51
|
+
};
|
|
52
52
|
handlePrev = () => {
|
|
53
53
|
const newCurrent = this.#getCurrent() - 1;
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
if (!this.getIsControlledComponent()) this.
|
|
54
|
+
this.adapter.notifyChange(newCurrent);
|
|
55
|
+
this.adapter.notifyPrev(newCurrent);
|
|
56
|
+
if (!this.getIsControlledComponent()) this.adapter.setCurrent(newCurrent);
|
|
57
57
|
};
|
|
58
58
|
handleNext = () => {
|
|
59
59
|
const { steps } = this.getProps();
|
|
60
60
|
const current = this.#getCurrent();
|
|
61
|
-
if (current === steps.length - 1) this.
|
|
61
|
+
if (current === steps.length - 1) this.adapter.notifyFinish();
|
|
62
62
|
else {
|
|
63
63
|
const newCurrent = current + 1;
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
66
|
-
if (!this.getIsControlledComponent()) this.
|
|
64
|
+
this.adapter.notifyChange(newCurrent);
|
|
65
|
+
this.adapter.notifyNext(newCurrent);
|
|
66
|
+
if (!this.getIsControlledComponent()) this.adapter.setCurrent(newCurrent);
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
handleSkip = () => {
|
|
70
|
-
this.
|
|
70
|
+
this.adapter.notifySkip();
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
73
|
export { UserGuideFoundation as default };
|
package/dist/utils/a11y.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function handlePrevent(event:
|
|
1
|
+
export declare function handlePrevent(event: Pick<Event, 'stopPropagation' | 'preventDefault'>): void;
|
|
2
2
|
/**
|
|
3
3
|
* Space-separated ids for aria-labelledby and aria-describedby, undefined when there are none; the caller's ids go
|
|
4
4
|
* first, so the Form's ids are added to them instead of replacing them
|
|
@@ -8,7 +8,6 @@ export declare function setFocusToItem(itemNodes: HTMLElement[], targetItem: HTM
|
|
|
8
8
|
export declare function setFocusToFirstItem(itemNodes: HTMLElement[]): void;
|
|
9
9
|
export declare function setFocusToLastItem(itemNodes: HTMLElement[]): void;
|
|
10
10
|
export interface ListNavigationOptions {
|
|
11
|
-
/** Arrows past either end wrap around instead of staying */
|
|
12
11
|
loop?: boolean;
|
|
13
12
|
/** Which arrows step: Up and Down for a vertical list, Left and Right (swapped in RTL) for a horizontal one */
|
|
14
13
|
orientation?: 'vertical' | 'horizontal';
|
|
@@ -87,10 +86,7 @@ export declare class Typeahead {
|
|
|
87
86
|
*/
|
|
88
87
|
match(key: string, labels: string[], current: number): number;
|
|
89
88
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Development-only: warns when a dialog has no accessible name, which screen readers would announce as just
|
|
92
|
-
* "dialog". The name comes from `aria-label` or from the element `aria-labelledby` points at (usually the title).
|
|
93
|
-
*/
|
|
89
|
+
/** Development-only: warns when a dialog has no accessible name, which screen readers would announce as just "dialog" */
|
|
94
90
|
export declare function warnIfDialogUnnamed(dialog: HTMLElement | null, component: string): void;
|
|
95
91
|
/**
|
|
96
92
|
* `root`: the document or shadow root the popup lives in, which also holds its trigger (the popup is portaled into the
|