@web-atoms/web-controls 2.6.5 → 2.6.6
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/tsconfig.tsbuildinfo +1 -1
- package/dist-esm/ArrayLike.js +14 -12
- package/dist-esm/DataAttributes.js +18 -19
- package/dist-esm/Focusable.js +10 -11
- package/dist-esm/ModuleFiles.js +43 -42
- package/dist-esm/NumberFormats.js +60 -56
- package/dist-esm/PageNavigator.js +28 -30
- package/dist-esm/animations/Animations.js +36 -33
- package/dist-esm/basic/AtomChips.js +312 -305
- package/dist-esm/basic/AtomRepeater.js +1070 -1035
- package/dist-esm/basic/AtomSuggestions.js +97 -107
- package/dist-esm/basic/AttachedPopup.js +0 -1
- package/dist-esm/basic/Button.js +45 -19
- package/dist-esm/basic/ButtonBar.js +84 -64
- package/dist-esm/basic/Calendar.js +211 -203
- package/dist-esm/basic/CheckBoxList.js +90 -70
- package/dist-esm/basic/Checkbox.js +16 -8
- package/dist-esm/basic/Chip.js +36 -12
- package/dist-esm/basic/ComboBox.js +47 -51
- package/dist-esm/basic/DataGrid.js +258 -252
- package/dist-esm/basic/DateField.js +149 -127
- package/dist-esm/basic/DropDown.js +91 -103
- package/dist-esm/basic/DropDownInput.js +78 -106
- package/dist-esm/basic/Editable.js +82 -77
- package/dist-esm/basic/Expander.js +104 -86
- package/dist-esm/basic/FilesDragDrop.js +84 -80
- package/dist-esm/basic/Form.js +80 -52
- package/dist-esm/basic/FormField.js +164 -106
- package/dist-esm/basic/IElement.js +1 -2
- package/dist-esm/basic/InlinePopup.js +263 -234
- package/dist-esm/basic/InlinePopupButton.js +99 -88
- package/dist-esm/basic/InlinePopupControl.js +24 -23
- package/dist-esm/basic/ItemPath.js +59 -60
- package/dist-esm/basic/LimitedText.js +49 -38
- package/dist-esm/basic/ListRepeater.js +13 -14
- package/dist-esm/basic/MaskedInput.js +37 -29
- package/dist-esm/basic/MaskedInputDiv.js +55 -48
- package/dist-esm/basic/MergeNode.js +64 -35
- package/dist-esm/basic/PasswordBox.js +32 -17
- package/dist-esm/basic/PinchZoomView.js +221 -199
- package/dist-esm/basic/PopupButton.js +39 -16
- package/dist-esm/basic/PopupMenu.js +3 -4
- package/dist-esm/basic/RadioButtonList.js +35 -25
- package/dist-esm/basic/RefreshLock.js +41 -42
- package/dist-esm/basic/Resizable.js +43 -33
- package/dist-esm/basic/Select.js +72 -65
- package/dist-esm/basic/SortByButton.js +41 -31
- package/dist-esm/basic/Swipe.js +91 -84
- package/dist-esm/basic/Switch.js +22 -8
- package/dist-esm/basic/TableRepeater.js +29 -33
- package/dist-esm/basic/TimeEditor.js +97 -52
- package/dist-esm/basic/TitleEditor.js +115 -95
- package/dist-esm/basic/ToggleButtonBar.js +21 -22
- package/dist-esm/basic/Tooltip.js +49 -47
- package/dist-esm/basic/TypeWriter.js +45 -42
- package/dist-esm/basic/UploadEvent.js +211 -178
- package/dist-esm/basic/ZoomView.js +229 -198
- package/dist-esm/basic/combineClasses.js +2 -3
- package/dist-esm/basic/elements/AtomPopover.js +270 -253
- package/dist-esm/basic/elements/getContainingBlock.js +34 -35
- package/dist-esm/basic/elements/relativeRect.js +40 -21
- package/dist-esm/desktop-app/DesktopApp.js +65 -80
- package/dist-esm/desktop-app/MobileDesktopApp.js +20 -23
- package/dist-esm/html-editor/AtomHtmlEditor.js +243 -268
- package/dist-esm/html-editor/HtmlEditorCommands.js +6 -4
- package/dist-esm/html-editor/InlineHtmlEditor.js +174 -166
- package/dist-esm/html-editor/RangeEditor.js +49 -51
- package/dist-esm/html-editor/commands/AddImage.js +40 -35
- package/dist-esm/html-editor/commands/AddLink.js +56 -54
- package/dist-esm/html-editor/commands/Align.js +24 -7
- package/dist-esm/html-editor/commands/AttachFile.js +23 -13
- package/dist-esm/html-editor/commands/AttachImage.js +35 -25
- package/dist-esm/html-editor/commands/Bold.js +10 -11
- package/dist-esm/html-editor/commands/ChangeColor.js +31 -107
- package/dist-esm/html-editor/commands/ChangeFont.js +42 -42
- package/dist-esm/html-editor/commands/ChangeFontSize.js +15 -5
- package/dist-esm/html-editor/commands/Command.js +34 -16
- package/dist-esm/html-editor/commands/CommandButton.js +51 -32
- package/dist-esm/html-editor/commands/Headings.js +25 -9
- package/dist-esm/html-editor/commands/HorizontalRule.js +9 -10
- package/dist-esm/html-editor/commands/HtmlCommands.js +160 -65
- package/dist-esm/html-editor/commands/IndentLess.js +10 -11
- package/dist-esm/html-editor/commands/IndentMore.js +10 -11
- package/dist-esm/html-editor/commands/Italic.js +10 -11
- package/dist-esm/html-editor/commands/NumberedList.js +10 -11
- package/dist-esm/html-editor/commands/Quote.js +10 -11
- package/dist-esm/html-editor/commands/RemoveFormat.js +10 -11
- package/dist-esm/html-editor/commands/Separator.js +5 -4
- package/dist-esm/html-editor/commands/Source.js +29 -25
- package/dist-esm/html-editor/commands/StrikeThrough.js +10 -11
- package/dist-esm/html-editor/commands/Toolbar.js +6 -4
- package/dist-esm/html-editor/commands/Underline.js +10 -11
- package/dist-esm/html-editor/commands/Unlink.js +10 -9
- package/dist-esm/html-editor/commands/UnorderedList.js +10 -11
- package/dist-esm/mobile-app/BottomPopup.js +137 -148
- package/dist-esm/mobile-app/MasterDetailPage.js +153 -152
- package/dist-esm/mobile-app/MobileApp.js +577 -569
- package/dist-esm/player/AtomVideoPlayer.js +316 -270
- package/dist-esm/player/TrackProgress.js +11 -7
- package/dist-esm/player/input-range-style.js +97 -98
- package/dist-esm/tests/app-test/AppTestApp.js +12 -15
- package/dist-esm/tests/app-test/AppTestApp.pack.js +54 -0
- package/dist-esm/tests/app-test/commands/AppCommands.js +14 -11
- package/dist-esm/tests/app-test/drawer/AppDrawer.js +4 -6
- package/dist-esm/tests/app-test/model/model.js +1 -2
- package/dist-esm/tests/app-test/pages/detail/DetailPage.js +21 -15
- package/dist-esm/tests/app-test/pages/home/HomePage.js +7 -8
- package/dist-esm/tests/app-test/pages/list/ListPage.js +79 -62
- package/dist-esm/tests/basic/PopupTest.js +9 -7
- package/dist-esm/tests/basic/TimeEditorTest.js +5 -9
- package/dist-esm/tests/basic/TimeEditorTest.pack.js +39 -0
- package/dist-esm/tests/basic/TimerTest.js +27 -37
- package/dist-esm/tests/basic/TimerTest.pack.js +40 -0
- package/dist-esm/tests/basic/basic-form/BasicForm.js +47 -27
- package/dist-esm/tests/basic/basic-form/BasicForm.pack.js +44 -0
- package/dist-esm/tests/basic/calendar/BasicCalendarTest.js +5 -9
- package/dist-esm/tests/basic/calendar/BasicCalendarTest.pack.js +53 -0
- package/dist-esm/tests/basic/chips/ChipsTest.js +25 -15
- package/dist-esm/tests/basic/chips/ChipsTest.pack.js +56 -0
- package/dist-esm/tests/basic/data-grid/DataGridTest.js +55 -60
- package/dist-esm/tests/basic/data-grid/DataGridTest.pack.js +58 -0
- package/dist-esm/tests/basic/date/DateFieldTest.js +21 -96
- package/dist-esm/tests/basic/date/DateFieldTest.pack.js +57 -0
- package/dist-esm/tests/basic/drop-down/DropDownTest.js +25 -19
- package/dist-esm/tests/basic/drop-down/DropDownTest.pack.js +52 -0
- package/dist-esm/tests/basic/drop-down-input/DropDownTest.js +32 -32
- package/dist-esm/tests/basic/drop-down-input/DropDownTest.pack.js +54 -0
- package/dist-esm/tests/basic/expander/ExpanderMenuTest.js +20 -14
- package/dist-esm/tests/basic/expander/ExpanderMenuTest.pack.js +38 -0
- package/dist-esm/tests/basic/expander/ExpanderTest.js +11 -12
- package/dist-esm/tests/basic/expander/ExpanderTest.pack.js +38 -0
- package/dist-esm/tests/basic/form2/Form2Test.js +26 -24
- package/dist-esm/tests/basic/form2/Form2Test.pack.js +46 -0
- package/dist-esm/tests/basic/limited-text/LimitedTextTest.js +14 -11
- package/dist-esm/tests/basic/limited-text/LimitedTextTest.pack.js +38 -0
- package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.js +14 -14
- package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.pack.js +38 -0
- package/dist-esm/tests/basic/repeater/DragDropRepater.js +30 -12
- package/dist-esm/tests/basic/repeater/DragDropRepater.pack.js +51 -0
- package/dist-esm/tests/basic/repeater/RepeaterTest.js +45 -35
- package/dist-esm/tests/basic/repeater/RepeaterTest.pack.js +52 -0
- package/dist-esm/tests/basic/swipe/SwipeTest.js +13 -13
- package/dist-esm/tests/basic/swipe/SwipeTest.pack.js +52 -0
- package/dist-esm/tests/basic/switch-test/SwitchTest.js +8 -10
- package/dist-esm/tests/basic/switch-test/SwitchTest.pack.js +38 -0
- package/dist-esm/tests/basic/title-editor/TitleEditorTest.js +8 -9
- package/dist-esm/tests/basic/title-editor/TitleEditorTest.pack.js +38 -0
- package/dist-esm/tests/basic/tooltip/TooltipTest.js +30 -24
- package/dist-esm/tests/basic/tooltip/TooltipTest.pack.js +52 -0
- package/dist-esm/tests/basic/typewriter/TypeWriter.js +10 -9
- package/dist-esm/tests/basic/typewriter/TypeWriter.pack.js +39 -0
- package/dist-esm/tests/basic/video/AtomVideoTest.js +13 -10
- package/dist-esm/tests/basic/video/AtomVideoTest.pack.js +38 -0
- package/dist-esm/tests/basic/zoom/ZoomViewTest.js +13 -13
- package/dist-esm/tests/basic/zoom/ZoomViewTest.pack.js +38 -0
- package/dist-esm/tests/check-box-list/CheckBoxListSample.js +13 -12
- package/dist-esm/tests/check-box-list/CheckBoxListSample.pack.js +52 -0
- package/dist-esm/tests/data-grid/GridTestViewModel.js +203 -227
- package/dist-esm/tests/form/CustomHelp.js +6 -9
- package/dist-esm/tests/form/FormViewModel.js +21 -28
- package/dist-esm/tests/html-editor/HtmlEditorTest.js +7 -37
- package/dist-esm/tests/html-editor/HtmlEditorTest.pack.js +83 -0
- package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.js +9 -38
- package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.pack.js +85 -0
- package/dist-esm/tests/mask/MaskedInputTest.js +11 -12
- package/dist-esm/tests/mask/MaskedInputTest.pack.js +38 -0
- package/dist-esm/tests/mobile-app/DesktopAppTest.js +8 -9
- package/dist-esm/tests/mobile-app/DesktopAppTest.pack.js +60 -0
- package/dist-esm/tests/mobile-app/MobileAppTest.js +64 -53
- package/dist-esm/tests/mobile-app/MobileAppTest.pack.js +55 -0
- package/dist-esm/tests/pop-over/PopOverTest.js +37 -77
- package/dist-esm/tests/switch/SwitchTest.js +9 -8
- package/dist-esm/tests/toggle-view/ToggleViewTest.js +15 -22
- package/dist-esm/tests/toggle-view/ToggleViewTest.pack.js +45 -0
- package/dist-esm/toggle-view/AtomToggleView.js +77 -73
- package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -6,194 +6,227 @@ import { AtomControl } from "@web-atoms/core/dist/web/controls/AtomControl.js";
|
|
|
6
6
|
import PopupService from "@web-atoms/core/dist/web/services/PopupService.js";
|
|
7
7
|
import { toFileSize } from "../NumberFormats.js";
|
|
8
8
|
const acceptCache = {};
|
|
9
|
-
export const isFileType =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
const types = accept.split(/\,/g).map((x) => {
|
|
15
|
-
x = x.trim();
|
|
16
|
-
if (x.startsWith(".")) {
|
|
17
|
-
return (file) => file.name.endsWith(x);
|
|
18
|
-
}
|
|
19
|
-
if (x.endsWith("/*")) {
|
|
20
|
-
const prefix = x.substring(0, x.length - 1);
|
|
21
|
-
return (file) => file.type.startsWith(prefix);
|
|
22
|
-
}
|
|
23
|
-
return (file) => file.type === x;
|
|
24
|
-
});
|
|
25
|
-
return (file) => {
|
|
26
|
-
for (const iterator of types) {
|
|
27
|
-
if (iterator(file)) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
};
|
|
9
|
+
export const isFileType = acceptType => {
|
|
10
|
+
function isFileTypeFactory(accept) {
|
|
11
|
+
if (!accept || accept === "*/*") {
|
|
12
|
+
return () => true;
|
|
33
13
|
}
|
|
34
|
-
|
|
14
|
+
const types = accept.split(/\,/g).map(x => {
|
|
15
|
+
x = x.trim();
|
|
16
|
+
if (x.startsWith(".")) {
|
|
17
|
+
return file => file.name.endsWith(x);
|
|
18
|
+
}
|
|
19
|
+
if (x.endsWith("/*")) {
|
|
20
|
+
const prefix = x.substring(0, x.length - 1);
|
|
21
|
+
return file => file.type.startsWith(prefix);
|
|
22
|
+
}
|
|
23
|
+
return file => file.type === x;
|
|
24
|
+
});
|
|
25
|
+
return file => {
|
|
26
|
+
for (const iterator of types) {
|
|
27
|
+
if (iterator(file)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return acceptCache[acceptType] ??= isFileTypeFactory(acceptType);
|
|
35
35
|
};
|
|
36
36
|
let previousFile;
|
|
37
37
|
const uploadCommand = Command.create({
|
|
38
|
-
|
|
38
|
+
name: "upload-command"
|
|
39
39
|
});
|
|
40
|
-
const requestUpload = ({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const requestUpload = ({
|
|
41
|
+
element,
|
|
42
|
+
multiple,
|
|
43
|
+
authorize,
|
|
44
|
+
extra,
|
|
45
|
+
convert,
|
|
46
|
+
upload,
|
|
47
|
+
folder,
|
|
48
|
+
stream,
|
|
49
|
+
maxStreamSize,
|
|
50
|
+
uploadEvent
|
|
51
|
+
}) => {
|
|
52
|
+
if (authorize) {
|
|
53
|
+
if (!App.authorize()) {
|
|
54
|
+
return;
|
|
45
55
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
}
|
|
57
|
+
const chain = [];
|
|
58
|
+
let start = element;
|
|
59
|
+
while (start) {
|
|
60
|
+
chain.push(start);
|
|
61
|
+
start = start.parentElement;
|
|
62
|
+
}
|
|
63
|
+
previousFile?.remove();
|
|
64
|
+
const file = document.createElement("input");
|
|
65
|
+
file.type = "file";
|
|
66
|
+
file.multiple = multiple;
|
|
67
|
+
if (folder) {
|
|
68
|
+
file.webkitdirectory = folder;
|
|
69
|
+
}
|
|
70
|
+
const accept = element.getAttribute("data-accept") || "*/*";
|
|
71
|
+
file.accept = accept;
|
|
72
|
+
const capture = element.getAttribute("data-capture");
|
|
73
|
+
if (capture) {
|
|
74
|
+
file.capture = capture;
|
|
75
|
+
}
|
|
76
|
+
file.style.position = "absolute";
|
|
77
|
+
file.style.left = "-1000px";
|
|
78
|
+
file.style.top = "-1000px";
|
|
79
|
+
document.body.append(file);
|
|
80
|
+
previousFile = file;
|
|
81
|
+
const maxSize = parseInt(element.getAttribute("data-max-size") || "0", 10);
|
|
82
|
+
stream ||= element.getAttribute("data-stream") === "true";
|
|
83
|
+
maxStreamSize ??= parseInt(element.getAttribute("data-max-stream-size") || "0", 10);
|
|
84
|
+
const forceType = element.getAttribute("data-force-type") === "true";
|
|
85
|
+
file.addEventListener("change", () => {
|
|
86
|
+
let files = Array.from(file.files);
|
|
87
|
+
let msgItems = [];
|
|
88
|
+
if (forceType || maxSize) {
|
|
89
|
+
const validated = [];
|
|
90
|
+
const checkFileType = isFileType(accept);
|
|
91
|
+
for (const iterator of files) {
|
|
92
|
+
if (forceType) {
|
|
93
|
+
if (!checkFileType(iterator)) {
|
|
94
|
+
msgItems.push(`${iterator.name} is invalid file.`, XNode.create("br", null));
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (stream) {
|
|
99
|
+
if (iterator.size > maxStreamSize) {
|
|
100
|
+
msgItems.push(`Size of ${iterator.name} is more than ${toFileSize(maxStreamSize)}.`, XNode.create("br", null));
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
validated.push(iterator);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (!convert && maxSize && iterator.size > maxSize) {
|
|
107
|
+
msgItems.push(`Size of ${iterator.name} is more than ${toFileSize(maxSize)}.`, XNode.create("br", null));
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
validated.push(iterator);
|
|
111
|
+
}
|
|
112
|
+
files = validated;
|
|
64
113
|
}
|
|
65
|
-
file.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
for (const iterator of files) {
|
|
81
|
-
if (forceType) {
|
|
82
|
-
if (!checkFileType(iterator)) {
|
|
83
|
-
msgItems.push(`${iterator.name} is invalid file.`, XNode.create("br", null));
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (stream) {
|
|
88
|
-
if (iterator.size > maxStreamSize) {
|
|
89
|
-
msgItems.push(`Size of ${iterator.name} is more than ${toFileSize(maxStreamSize)}.`, XNode.create("br", null));
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
validated.push(iterator);
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
if (!convert && maxSize && iterator.size > maxSize) {
|
|
96
|
-
msgItems.push(`Size of ${iterator.name} is more than ${toFileSize(maxSize)}.`, XNode.create("br", null));
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
validated.push(iterator);
|
|
100
|
-
}
|
|
101
|
-
files = validated;
|
|
114
|
+
file.remove();
|
|
115
|
+
previousFile = null;
|
|
116
|
+
chain.reverse();
|
|
117
|
+
while (chain.length) {
|
|
118
|
+
const root = chain.pop();
|
|
119
|
+
if (root.isConnected) {
|
|
120
|
+
const control = AtomControl.from(root);
|
|
121
|
+
if (msgItems.length) {
|
|
122
|
+
const msg = XNode.create("p", null, ...msgItems);
|
|
123
|
+
control.app.runAsync(() => PopupService.alert({
|
|
124
|
+
message: msg
|
|
125
|
+
}));
|
|
126
|
+
if (files.length === 0) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
102
129
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
extra,
|
|
122
|
-
convert,
|
|
123
|
-
stream,
|
|
124
|
-
maxStreamSize,
|
|
125
|
-
maxSize,
|
|
126
|
-
uploadEvent
|
|
127
|
-
},
|
|
128
|
-
bubbles: true,
|
|
129
|
-
cancelable: true
|
|
130
|
-
});
|
|
131
|
-
root.dispatchEvent(doUploadEvent);
|
|
132
|
-
if (doUploadEvent.defaultPrevented) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
root.dispatchEvent(new CustomEvent(uploadEvent, { detail: {
|
|
137
|
-
files,
|
|
138
|
-
extra
|
|
139
|
-
}, bubbles: true }));
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
130
|
+
if (upload) {
|
|
131
|
+
const doUploadEvent = new CustomEvent("uploadRequested", {
|
|
132
|
+
detail: {
|
|
133
|
+
files,
|
|
134
|
+
extra,
|
|
135
|
+
convert,
|
|
136
|
+
stream,
|
|
137
|
+
maxStreamSize,
|
|
138
|
+
maxSize,
|
|
139
|
+
uploadEvent
|
|
140
|
+
},
|
|
141
|
+
bubbles: true,
|
|
142
|
+
cancelable: true
|
|
143
|
+
});
|
|
144
|
+
root.dispatchEvent(doUploadEvent);
|
|
145
|
+
if (doUploadEvent.defaultPrevented) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
142
148
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
root.dispatchEvent(new CustomEvent(uploadEvent, {
|
|
150
|
+
detail: {
|
|
151
|
+
files,
|
|
152
|
+
extra
|
|
153
|
+
},
|
|
154
|
+
bubbles: true
|
|
155
|
+
}));
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
151
158
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
159
|
+
});
|
|
160
|
+
setTimeout(() => {
|
|
161
|
+
file.dispatchEvent(new MouseEvent("click"));
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
window.addEventListener(uploadCommand.eventName, ce => {
|
|
165
|
+
if (ce.defaultPrevented) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const element = ce.target;
|
|
169
|
+
const authorize = element.getAttribute("data-authorize") === "true";
|
|
170
|
+
const multiple = element.getAttribute("data-multiple") === "true";
|
|
171
|
+
const extra = element.extra ?? element.getAttribute("data-extra");
|
|
172
|
+
const upload = element.getAttribute("data-upload") === "true";
|
|
173
|
+
const folder = element.hasAttribute("data-folder");
|
|
174
|
+
const convert = element.getAttribute("data-convert") === "true";
|
|
175
|
+
const stream = element.getAttribute("data-stream") === "true";
|
|
176
|
+
const maxStreamSize = parseInt(element.getAttribute("data-max-stream-size") ?? "0", 10);
|
|
177
|
+
const uploadEvent = StringHelper.fromHyphenToCamel(element.getAttribute("data-upload-event"));
|
|
178
|
+
requestUpload({
|
|
179
|
+
element,
|
|
180
|
+
authorize,
|
|
181
|
+
multiple,
|
|
182
|
+
extra,
|
|
183
|
+
convert,
|
|
184
|
+
upload,
|
|
185
|
+
folder,
|
|
186
|
+
stream,
|
|
187
|
+
maxStreamSize,
|
|
188
|
+
uploadEvent
|
|
189
|
+
});
|
|
174
190
|
});
|
|
175
191
|
let id = 1;
|
|
176
192
|
export default class UploadEvent {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
193
|
+
static {
|
|
194
|
+
this.requestUpload = requestUpload;
|
|
195
|
+
}
|
|
196
|
+
static AttachUploadAction({
|
|
197
|
+
uploadEvent = "filesAvailable",
|
|
198
|
+
accept = "*/*",
|
|
199
|
+
capture,
|
|
200
|
+
multiple = false,
|
|
201
|
+
forceType = true,
|
|
202
|
+
maxSize = 524288000,
|
|
203
|
+
maxStreamSize = 100 * 1024 * 1024,
|
|
204
|
+
stream = false,
|
|
205
|
+
extra,
|
|
206
|
+
convert = false,
|
|
207
|
+
upload = true,
|
|
208
|
+
authorize = true,
|
|
209
|
+
ariaLabel = "Upload",
|
|
210
|
+
folder = false,
|
|
211
|
+
...others
|
|
212
|
+
}) {
|
|
213
|
+
return {
|
|
214
|
+
...others,
|
|
215
|
+
"data-folder": folder ? "true" : void 0,
|
|
216
|
+
"data-click-command": uploadCommand.name,
|
|
217
|
+
"data-upload-event": uploadEvent,
|
|
218
|
+
"data-accept": accept,
|
|
219
|
+
"data-multiple": multiple ? "true" : "false",
|
|
220
|
+
"data-capture": capture,
|
|
221
|
+
"data-convert": convert,
|
|
222
|
+
"data-stream": stream ? "true" : "false",
|
|
223
|
+
"data-max-stream-size": maxStreamSize ? maxStreamSize.toString() : undefined,
|
|
224
|
+
"data-upload": upload ? "true" : "false",
|
|
225
|
+
"data-force-type": forceType ? "true" : "false",
|
|
226
|
+
"data-max-size": maxSize ? maxSize.toString() : undefined,
|
|
227
|
+
"data-authorize": authorize.toString(),
|
|
228
|
+
"aria-label": ariaLabel,
|
|
229
|
+
extra
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|