@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,337 +6,344 @@ import { CancelToken } from "@web-atoms/core/dist/core/types.js";
|
|
|
6
6
|
import XNode from "@web-atoms/core/dist/core/XNode.js";
|
|
7
7
|
import AtomRepeater, { MatchTrue } from "./AtomRepeater.js";
|
|
8
8
|
export { default as Chip } from "./Chip.js";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
ESMPack.installStyleSheet(import.meta.resolve("./styles/chips.global.css"));
|
|
10
|
+
ESMPack.installStyleSheet(import.meta.resolve("./styles/item-suggestion.global.css"));
|
|
11
11
|
import AtomPopover from "./elements/AtomPopover.js";
|
|
12
12
|
function getChips(target) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
start = start.parentElement;
|
|
13
|
+
let start = target;
|
|
14
|
+
while (start) {
|
|
15
|
+
const chips = start.atomControl;
|
|
16
|
+
if (chips && chips instanceof AtomChips) {
|
|
17
|
+
return chips;
|
|
20
18
|
}
|
|
19
|
+
start = start.parentElement;
|
|
20
|
+
}
|
|
21
21
|
}
|
|
22
|
-
document.body.addEventListener("focusin",
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
document.body.addEventListener("focusin", e => {
|
|
23
|
+
const chips = getChips(e.target);
|
|
24
|
+
chips?.setFocus(true);
|
|
25
25
|
});
|
|
26
|
-
document.body.addEventListener("focusout",
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
document.body.addEventListener("focusout", e => {
|
|
27
|
+
const chips = getChips(e.target);
|
|
28
|
+
chips?.setFocus(false);
|
|
29
29
|
});
|
|
30
|
-
document.body.addEventListener("keydown",
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
document.body.addEventListener("keydown", e => {
|
|
31
|
+
const chips = getChips(e.target);
|
|
32
|
+
chips?.onKey(e);
|
|
33
33
|
});
|
|
34
34
|
function askSuggestionPopup(host, opener, itemRenderer, suggestionFilter, cancelToken) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
class Suggestions extends AtomPopover {
|
|
36
|
+
init() {
|
|
37
|
+
this.opener = opener;
|
|
38
|
+
this.renderer = XNode.create("div", {
|
|
39
|
+
"data-suggestion-popup": "suggestion-popup"
|
|
40
|
+
}, XNode.create("div", {
|
|
41
|
+
class: "items"
|
|
42
|
+
}, XNode.create(AtomRepeater, {
|
|
43
|
+
class: "presenter",
|
|
44
|
+
selectedItem: Bind.source(opener, x => x.source.anchorItem),
|
|
45
|
+
itemRenderer: itemRenderer,
|
|
46
|
+
eventDeleteSuggestion: e => opener.element.dispatchEvent(e),
|
|
47
|
+
visibilityFilter: suggestionFilter ?? MatchTrue,
|
|
48
|
+
"event-item-click": e => {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
e.stopImmediatePropagation();
|
|
51
|
+
e.stopPropagation();
|
|
52
|
+
this.close(e.detail);
|
|
53
|
+
},
|
|
54
|
+
items: Bind.source(opener, x => x.source.suggestions)
|
|
55
|
+
})));
|
|
47
56
|
}
|
|
48
|
-
|
|
57
|
+
}
|
|
58
|
+
return Suggestions.show(host, {
|
|
59
|
+
"anchor-top": "parent-bottom",
|
|
60
|
+
"anchor-left": "parent-left",
|
|
61
|
+
cancelToken
|
|
62
|
+
});
|
|
49
63
|
}
|
|
50
|
-
export function Suggestion({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
export function Suggestion({
|
|
65
|
+
icon,
|
|
66
|
+
label,
|
|
67
|
+
header,
|
|
68
|
+
deleteIcon,
|
|
69
|
+
...a
|
|
70
|
+
}, ...nodes) {
|
|
71
|
+
return XNode.create("div", {
|
|
72
|
+
"data-item-suggestion": "suggestion",
|
|
73
|
+
...a
|
|
74
|
+
}, icon && XNode.create("i", {
|
|
75
|
+
class: "icon " + icon
|
|
76
|
+
}), header && XNode.create("label", {
|
|
77
|
+
class: "header",
|
|
78
|
+
text: header,
|
|
79
|
+
title: header
|
|
80
|
+
}), label && XNode.create("label", {
|
|
81
|
+
class: "label",
|
|
82
|
+
text: label,
|
|
83
|
+
title: label
|
|
84
|
+
}), ...nodes, deleteIcon && XNode.create("i", {
|
|
85
|
+
class: "delete " + deleteIcon,
|
|
86
|
+
"data-click-event": "remove-suggestion"
|
|
87
|
+
}));
|
|
57
88
|
}
|
|
58
89
|
export default class AtomChips extends AtomRepeater {
|
|
59
|
-
|
|
60
|
-
|
|
90
|
+
get searchType() {
|
|
91
|
+
return this.searchInput.type;
|
|
92
|
+
}
|
|
93
|
+
set searchType(v) {
|
|
94
|
+
this.searchInput.type = v;
|
|
95
|
+
}
|
|
96
|
+
get enterKeyHint() {
|
|
97
|
+
return this.searchInput.enterKeyHint;
|
|
98
|
+
}
|
|
99
|
+
set enterKeyHint(v) {
|
|
100
|
+
this.searchInput.enterKeyHint = v;
|
|
101
|
+
}
|
|
102
|
+
onPropertyChanged(name) {
|
|
103
|
+
super.onPropertyChanged(name);
|
|
104
|
+
switch (name) {
|
|
105
|
+
case "labelPath":
|
|
106
|
+
this.itemRenderer = item => XNode.create("div", {
|
|
107
|
+
text: this.labelPath(item)
|
|
108
|
+
});
|
|
109
|
+
break;
|
|
110
|
+
case "prompt":
|
|
111
|
+
this.updateClasses();
|
|
112
|
+
break;
|
|
113
|
+
case "focused":
|
|
114
|
+
this.updatePopup();
|
|
115
|
+
break;
|
|
116
|
+
case "suggestions":
|
|
117
|
+
this.suggestionsWatcher?.dispose();
|
|
118
|
+
this.suggestionsWatcher = undefined;
|
|
119
|
+
const suggestions = this.suggestions;
|
|
120
|
+
if (suggestions) {
|
|
121
|
+
this.suggestionsWatcher = this.registerDisposable(suggestions.watch(() => {
|
|
122
|
+
this.updatePopup();
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
this.updatePopup();
|
|
126
|
+
break;
|
|
61
127
|
}
|
|
62
|
-
|
|
63
|
-
|
|
128
|
+
}
|
|
129
|
+
preCreate() {
|
|
130
|
+
super.preCreate();
|
|
131
|
+
this.preventDuplicates = true;
|
|
132
|
+
this.softDeleteProperty = null;
|
|
133
|
+
this.prompt = "Search";
|
|
134
|
+
this.element.setAttribute("data-atom-chips", "atom-chips");
|
|
135
|
+
this.element.setAttribute("data-mode", "search");
|
|
136
|
+
this.suggestionFilter = MatchTrue;
|
|
137
|
+
this.valuePath = item => item?.value ?? item;
|
|
138
|
+
this.labelPath = item => item?.label ?? item;
|
|
139
|
+
this.itemRenderer = item => XNode.create("div", {
|
|
140
|
+
text: this.labelPath(item)
|
|
141
|
+
});
|
|
142
|
+
this.element.dataset.dropDown = "drop-down";
|
|
143
|
+
this.render(XNode.create("div", null, XNode.create("div", {
|
|
144
|
+
class: "presenter"
|
|
145
|
+
}), XNode.create("input", {
|
|
146
|
+
class: "search",
|
|
147
|
+
placeholder: Bind.oneWay(() => this.prompt),
|
|
148
|
+
value: Bind.twoWaysImmediate(() => this.search),
|
|
149
|
+
autofocus: Bind.oneWay(() => this.autofocus),
|
|
150
|
+
type: "search"
|
|
151
|
+
}), XNode.create("div", {
|
|
152
|
+
class: "footer"
|
|
153
|
+
})));
|
|
154
|
+
this.itemsPresenter = this.element.children[0];
|
|
155
|
+
this.searchInput = this.element.children[1];
|
|
156
|
+
this.footerPresenter = this.element.children[2];
|
|
157
|
+
this.bindEvent(this.element, "removeChip", e => e.defaultPrevented || this.removeItem(e.detail));
|
|
158
|
+
this.bindEvent(this.element, "undoRemoveChip", e => e.defaultPrevented || this.undoRemoveItem(e.detail));
|
|
159
|
+
this.bindEvent(this.searchInput, "blur", () => {
|
|
160
|
+
if (!this.onBlurItemToChip) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
const search = this.search;
|
|
165
|
+
if (search) {
|
|
166
|
+
const item = this.onBlurItemToChip(search);
|
|
167
|
+
if (item) {
|
|
168
|
+
this.items.add(item);
|
|
169
|
+
this.searchInput.value = "";
|
|
170
|
+
this.search = "";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}, 200);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
setFocus(hasFocus) {
|
|
177
|
+
if (hasFocus) {
|
|
178
|
+
if (this.focusTimeout) {
|
|
179
|
+
clearTimeout(this.focusTimeout);
|
|
180
|
+
this.focusTimeout = void 0;
|
|
181
|
+
}
|
|
182
|
+
this.focused = true;
|
|
183
|
+
return;
|
|
64
184
|
}
|
|
65
|
-
|
|
66
|
-
|
|
185
|
+
this.focusTimeout = setTimeout(() => {
|
|
186
|
+
this.focusTimeout = void 0;
|
|
187
|
+
this.focused = false;
|
|
188
|
+
}, 1500);
|
|
189
|
+
}
|
|
190
|
+
async updatePopup() {
|
|
191
|
+
const suggestions = this.suggestions;
|
|
192
|
+
if (!this.focused) {
|
|
193
|
+
this.popupCancelToken?.cancel();
|
|
194
|
+
this.popupCancelToken = null;
|
|
195
|
+
return;
|
|
67
196
|
}
|
|
68
|
-
|
|
69
|
-
|
|
197
|
+
const detail = this.suggestions;
|
|
198
|
+
const ce = new CustomEvent("suggestions-requested", {
|
|
199
|
+
detail
|
|
200
|
+
});
|
|
201
|
+
this.element.dispatchEvent(ce);
|
|
202
|
+
if (ce.defaultPrevented) {
|
|
203
|
+
return;
|
|
70
204
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
break;
|
|
77
|
-
case "prompt":
|
|
78
|
-
this.updateClasses();
|
|
79
|
-
break;
|
|
80
|
-
case "focused":
|
|
81
|
-
this.updatePopup();
|
|
82
|
-
break;
|
|
83
|
-
case "suggestions":
|
|
84
|
-
this.suggestionsWatcher?.dispose();
|
|
85
|
-
this.suggestionsWatcher = undefined;
|
|
86
|
-
const suggestions = this.suggestions;
|
|
87
|
-
if (suggestions) {
|
|
88
|
-
this.suggestionsWatcher = this.registerDisposable(suggestions.watch(() => {
|
|
89
|
-
this.updatePopup();
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
92
|
-
this.updatePopup();
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
205
|
+
const {
|
|
206
|
+
promise
|
|
207
|
+
} = ce;
|
|
208
|
+
if (promise) {
|
|
209
|
+
await promise;
|
|
95
210
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.preventDuplicates = true;
|
|
99
|
-
this.softDeleteProperty = null;
|
|
100
|
-
this.prompt = "Search";
|
|
101
|
-
this.element.setAttribute("data-atom-chips", "atom-chips");
|
|
102
|
-
this.element.setAttribute("data-mode", "search");
|
|
103
|
-
this.suggestionFilter = MatchTrue;
|
|
104
|
-
this.valuePath = (item) => item?.value ?? item;
|
|
105
|
-
this.labelPath = (item) => item?.label ?? item;
|
|
106
|
-
this.itemRenderer = (item) => XNode.create("div", { text: this.labelPath(item) });
|
|
107
|
-
this.element.dataset.dropDown = "drop-down";
|
|
108
|
-
this.render(XNode.create("div", null,
|
|
109
|
-
XNode.create("div", { class: "presenter" }),
|
|
110
|
-
XNode.create("input", { class: "search", placeholder: Bind.oneWay(() => this.prompt), value: Bind.twoWaysImmediate(() => this.search), autofocus: Bind.oneWay(() => this.autofocus), type: "search" }),
|
|
111
|
-
XNode.create("div", { class: "footer" })));
|
|
112
|
-
this.itemsPresenter = this.element.children[0];
|
|
113
|
-
this.searchInput = this.element.children[1];
|
|
114
|
-
this.footerPresenter = this.element.children[2];
|
|
115
|
-
this.bindEvent(this.element, "removeChip", (e) => e.defaultPrevented || this.removeItem(e.detail));
|
|
116
|
-
this.bindEvent(this.element, "undoRemoveChip", (e) => e.defaultPrevented || this.undoRemoveItem(e.detail));
|
|
117
|
-
this.bindEvent(this.searchInput, "blur", () => {
|
|
118
|
-
if (!this.onBlurItemToChip) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
setTimeout(() => {
|
|
122
|
-
const search = this.search;
|
|
123
|
-
if (search) {
|
|
124
|
-
const item = this.onBlurItemToChip(search);
|
|
125
|
-
if (item) {
|
|
126
|
-
this.items.add(item);
|
|
127
|
-
this.searchInput.value = "";
|
|
128
|
-
this.search = "";
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}, 200);
|
|
132
|
-
});
|
|
211
|
+
if (ce.detail !== this.suggestions) {
|
|
212
|
+
this.suggestions = ce.detail;
|
|
133
213
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.focusTimeout = void 0;
|
|
139
|
-
}
|
|
140
|
-
this.focused = true;
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
this.focusTimeout = setTimeout(() => {
|
|
144
|
-
this.focusTimeout = void 0;
|
|
145
|
-
this.focused = false;
|
|
146
|
-
}, 1500);
|
|
214
|
+
if (!suggestions?.length) {
|
|
215
|
+
this.popupCancelToken?.cancel();
|
|
216
|
+
this.popupCancelToken = null;
|
|
217
|
+
return;
|
|
147
218
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (!this.focused) {
|
|
151
|
-
this.popupCancelToken?.cancel();
|
|
152
|
-
this.popupCancelToken = null;
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const detail = this.suggestions;
|
|
156
|
-
const ce = new CustomEvent("suggestions-requested", { detail });
|
|
157
|
-
this.element.dispatchEvent(ce);
|
|
158
|
-
if (ce.defaultPrevented) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const { promise } = ce;
|
|
162
|
-
if (promise) {
|
|
163
|
-
await promise;
|
|
164
|
-
}
|
|
165
|
-
if (ce.detail !== this.suggestions) {
|
|
166
|
-
this.suggestions = ce.detail;
|
|
167
|
-
}
|
|
168
|
-
if (!(suggestions?.length)) {
|
|
169
|
-
this.popupCancelToken?.cancel();
|
|
170
|
-
this.popupCancelToken = null;
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
if (this.popupCancelToken) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const cancelToken = this.popupCancelToken = new CancelToken();
|
|
177
|
-
try {
|
|
178
|
-
let selectedItem = await askSuggestionPopup(this.element, this, this.suggestionRenderer ?? this.itemRenderer, this.suggestionFilter, cancelToken);
|
|
179
|
-
const itemToChip = this.itemToChip;
|
|
180
|
-
if (itemToChip) {
|
|
181
|
-
selectedItem = itemToChip(selectedItem, this.search);
|
|
182
|
-
}
|
|
183
|
-
this.addItem(selectedItem);
|
|
184
|
-
this.search = "";
|
|
185
|
-
this.popupCancelToken = null;
|
|
186
|
-
}
|
|
187
|
-
catch (e) {
|
|
188
|
-
this.popupCancelToken = null;
|
|
189
|
-
if (CancelToken.isCancelled(e)) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
console.warn(e);
|
|
193
|
-
}
|
|
219
|
+
if (this.popupCancelToken) {
|
|
220
|
+
return;
|
|
194
221
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
222
|
+
const cancelToken = this.popupCancelToken = new CancelToken();
|
|
223
|
+
try {
|
|
224
|
+
let selectedItem = await askSuggestionPopup(this.element, this, this.suggestionRenderer ?? this.itemRenderer, this.suggestionFilter, cancelToken);
|
|
225
|
+
const itemToChip = this.itemToChip;
|
|
226
|
+
if (itemToChip) {
|
|
227
|
+
selectedItem = itemToChip(selectedItem, this.search);
|
|
228
|
+
}
|
|
229
|
+
this.addItem(selectedItem);
|
|
230
|
+
this.search = "";
|
|
231
|
+
this.popupCancelToken = null;
|
|
232
|
+
} catch (e) {
|
|
233
|
+
this.popupCancelToken = null;
|
|
234
|
+
if (CancelToken.isCancelled(e)) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
console.warn(e);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
addItem(selectedItem) {
|
|
241
|
+
const ce = new CustomEvent("suggestionChosen", {
|
|
242
|
+
detail: selectedItem,
|
|
243
|
+
cancelable: true,
|
|
244
|
+
bubbles: true
|
|
245
|
+
});
|
|
246
|
+
this.element.dispatchEvent(ce);
|
|
247
|
+
if (!ce.defaultPrevented) {
|
|
248
|
+
const item = ce.detail;
|
|
249
|
+
const vp = this.valuePath ?? (x => x);
|
|
250
|
+
const v = vp(item);
|
|
251
|
+
for (const iterator of this.items) {
|
|
252
|
+
if (v === vp(iterator)) {
|
|
253
|
+
return;
|
|
212
254
|
}
|
|
255
|
+
}
|
|
256
|
+
this.items.add(ce.detail);
|
|
213
257
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
258
|
+
}
|
|
259
|
+
undoRemoveItem(item) {
|
|
260
|
+
let {
|
|
261
|
+
softDeleteProperty
|
|
262
|
+
} = this;
|
|
263
|
+
softDeleteProperty = typeof softDeleteProperty !== "string" ? "$deleted" : softDeleteProperty;
|
|
264
|
+
item[softDeleteProperty] = false;
|
|
265
|
+
AtomBinder.refreshValue(this.items, "length");
|
|
266
|
+
this.refreshItem(item);
|
|
267
|
+
}
|
|
268
|
+
removeItem(item) {
|
|
269
|
+
let {
|
|
270
|
+
softDeleteProperty
|
|
271
|
+
} = this;
|
|
272
|
+
if (softDeleteProperty) {
|
|
273
|
+
softDeleteProperty = typeof softDeleteProperty !== "string" ? "$deleted" : softDeleteProperty;
|
|
274
|
+
item[softDeleteProperty] = true;
|
|
275
|
+
AtomBinder.refreshValue(this.items, "length");
|
|
276
|
+
this.refreshItem(item);
|
|
277
|
+
} else {
|
|
278
|
+
this.items.remove(item);
|
|
220
279
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
280
|
+
}
|
|
281
|
+
onKey(e) {
|
|
282
|
+
const suggested = this.suggestions;
|
|
283
|
+
const onKeyPressedItemToChip = this.onKeyPressedItemToChip;
|
|
284
|
+
if (onKeyPressedItemToChip && this.search) {
|
|
285
|
+
const item = onKeyPressedItemToChip(e.key, this.search);
|
|
286
|
+
if (item) {
|
|
287
|
+
this.addItem(item);
|
|
288
|
+
this.searchInput.value = "";
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
232
291
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
292
|
+
switch (e.key) {
|
|
293
|
+
case "Enter":
|
|
294
|
+
e.preventDefault?.();
|
|
295
|
+
e.stopImmediatePropagation?.();
|
|
296
|
+
setTimeout(() => {
|
|
297
|
+
let anchorItem = this.anchorItem;
|
|
298
|
+
const itemToChip = this.itemToChip;
|
|
299
|
+
if (itemToChip) {
|
|
300
|
+
anchorItem = itemToChip(anchorItem, this.search);
|
|
301
|
+
}
|
|
302
|
+
if (!anchorItem) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
this.addItem(anchorItem);
|
|
306
|
+
this.anchorIndex = 0;
|
|
307
|
+
this.anchorItem = null;
|
|
308
|
+
this.search = "";
|
|
309
|
+
}, 1);
|
|
310
|
+
break;
|
|
311
|
+
case "ArrowDown":
|
|
312
|
+
if (suggested) {
|
|
313
|
+
if (!this.anchorItem) {
|
|
314
|
+
this.anchorIndex = 0;
|
|
315
|
+
} else {
|
|
316
|
+
if (this.anchorIndex < suggested.length - 1) {
|
|
317
|
+
this.anchorIndex++;
|
|
242
318
|
}
|
|
319
|
+
}
|
|
320
|
+
this.anchorItem = suggested[this.anchorIndex];
|
|
243
321
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (!anchorItem) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
this.addItem(anchorItem);
|
|
258
|
-
this.anchorIndex = 0;
|
|
259
|
-
this.anchorItem = null;
|
|
260
|
-
this.search = "";
|
|
261
|
-
}, 1);
|
|
262
|
-
break;
|
|
263
|
-
case "ArrowDown":
|
|
264
|
-
if (suggested) {
|
|
265
|
-
if (!this.anchorItem) {
|
|
266
|
-
this.anchorIndex = 0;
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
if (this.anchorIndex < suggested.length - 1) {
|
|
270
|
-
this.anchorIndex++;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
this.anchorItem = suggested[this.anchorIndex];
|
|
274
|
-
}
|
|
275
|
-
break;
|
|
276
|
-
case "ArrowUp":
|
|
277
|
-
if (suggested) {
|
|
278
|
-
if (!this.anchorItem) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
if (this.anchorIndex) {
|
|
282
|
-
this.anchorIndex--;
|
|
283
|
-
}
|
|
284
|
-
this.anchorItem = suggested[this.anchorIndex];
|
|
285
|
-
}
|
|
286
|
-
break;
|
|
322
|
+
break;
|
|
323
|
+
case "ArrowUp":
|
|
324
|
+
if (suggested) {
|
|
325
|
+
if (!this.anchorItem) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (this.anchorIndex) {
|
|
329
|
+
this.anchorIndex--;
|
|
330
|
+
}
|
|
331
|
+
this.anchorItem = suggested[this.anchorIndex];
|
|
287
332
|
}
|
|
333
|
+
break;
|
|
288
334
|
}
|
|
335
|
+
}
|
|
289
336
|
}
|
|
290
|
-
__decorate([
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
], AtomChips.prototype, "
|
|
294
|
-
__decorate([
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
], AtomChips.prototype, "
|
|
298
|
-
__decorate([
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
], AtomChips.prototype, "
|
|
302
|
-
__decorate([
|
|
303
|
-
BindableProperty,
|
|
304
|
-
__metadata("design:type", String)
|
|
305
|
-
], AtomChips.prototype, "suggestionPrompt", void 0);
|
|
306
|
-
__decorate([
|
|
307
|
-
BindableProperty,
|
|
308
|
-
__metadata("design:type", Object)
|
|
309
|
-
], AtomChips.prototype, "autofocus", void 0);
|
|
310
|
-
__decorate([
|
|
311
|
-
BindableProperty,
|
|
312
|
-
__metadata("design:type", String)
|
|
313
|
-
], AtomChips.prototype, "softDeleteProperty", void 0);
|
|
314
|
-
__decorate([
|
|
315
|
-
BindableProperty,
|
|
316
|
-
__metadata("design:type", Function)
|
|
317
|
-
], AtomChips.prototype, "labelPath", void 0);
|
|
318
|
-
__decorate([
|
|
319
|
-
BindableProperty,
|
|
320
|
-
__metadata("design:type", Function)
|
|
321
|
-
], AtomChips.prototype, "match", void 0);
|
|
322
|
-
__decorate([
|
|
323
|
-
BindableProperty,
|
|
324
|
-
__metadata("design:type", Function)
|
|
325
|
-
], AtomChips.prototype, "suggestionRenderer", void 0);
|
|
326
|
-
__decorate([
|
|
327
|
-
BindableProperty,
|
|
328
|
-
__metadata("design:type", Function)
|
|
329
|
-
], AtomChips.prototype, "suggestionFilter", void 0);
|
|
330
|
-
__decorate([
|
|
331
|
-
BindableProperty,
|
|
332
|
-
__metadata("design:type", Boolean)
|
|
333
|
-
], AtomChips.prototype, "focused", void 0);
|
|
334
|
-
__decorate([
|
|
335
|
-
BindableProperty,
|
|
336
|
-
__metadata("design:type", Function)
|
|
337
|
-
], AtomChips.prototype, "onKeyPressedItemToChip", void 0);
|
|
338
|
-
__decorate([
|
|
339
|
-
BindableProperty,
|
|
340
|
-
__metadata("design:type", Function)
|
|
341
|
-
], AtomChips.prototype, "onBlurItemToChip", void 0);
|
|
342
|
-
//# sourceMappingURL=AtomChips.js.map
|
|
337
|
+
__decorate([BindableProperty, __metadata("design:type", Array)], AtomChips.prototype, "suggestions", void 0);
|
|
338
|
+
__decorate([BindableProperty, __metadata("design:type", String)], AtomChips.prototype, "search", void 0);
|
|
339
|
+
__decorate([BindableProperty, __metadata("design:type", String)], AtomChips.prototype, "prompt", void 0);
|
|
340
|
+
__decorate([BindableProperty, __metadata("design:type", String)], AtomChips.prototype, "suggestionPrompt", void 0);
|
|
341
|
+
__decorate([BindableProperty, __metadata("design:type", Object)], AtomChips.prototype, "autofocus", void 0);
|
|
342
|
+
__decorate([BindableProperty, __metadata("design:type", String)], AtomChips.prototype, "softDeleteProperty", void 0);
|
|
343
|
+
__decorate([BindableProperty, __metadata("design:type", Function)], AtomChips.prototype, "labelPath", void 0);
|
|
344
|
+
__decorate([BindableProperty, __metadata("design:type", Function)], AtomChips.prototype, "match", void 0);
|
|
345
|
+
__decorate([BindableProperty, __metadata("design:type", Function)], AtomChips.prototype, "suggestionRenderer", void 0);
|
|
346
|
+
__decorate([BindableProperty, __metadata("design:type", Function)], AtomChips.prototype, "suggestionFilter", void 0);
|
|
347
|
+
__decorate([BindableProperty, __metadata("design:type", Boolean)], AtomChips.prototype, "focused", void 0);
|
|
348
|
+
__decorate([BindableProperty, __metadata("design:type", Function)], AtomChips.prototype, "onKeyPressedItemToChip", void 0);
|
|
349
|
+
__decorate([BindableProperty, __metadata("design:type", Function)], AtomChips.prototype, "onBlurItemToChip", void 0);
|