@web-atoms/web-controls 2.3.0 → 2.3.2
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/ModuleFiles.js +1 -55
- package/dist/ModuleFiles.js.map +1 -1
- package/dist/PageNavigator.js +1 -61
- package/dist/PageNavigator.js.map +1 -1
- package/dist/animations/Animations.js +1 -52
- package/dist/animations/Animations.js.map +1 -1
- package/dist/auto-complete/AppComboBoxViewModel.js +1 -19
- package/dist/auto-complete/AppComboBoxViewModel.js.map +1 -1
- package/dist/auto-complete/AutoCompleteBox.js +1 -332
- package/dist/auto-complete/AutoCompleteBox.js.map +1 -1
- package/dist/auto-complete/AutoCompleteBoxStyle.js +1 -86
- package/dist/auto-complete/AutoCompleteBoxStyle.js.map +1 -1
- package/dist/auto-complete/ItemHost.js +1 -42
- package/dist/auto-complete/ItemHost.js.map +1 -1
- package/dist/basic/AtomChips.js +1 -376
- package/dist/basic/AtomChips.js.map +1 -1
- package/dist/basic/AtomRepeater.js +1 -1116
- package/dist/basic/AtomRepeater.js.map +1 -1
- package/dist/basic/AtomSuggestions.js +1 -167
- package/dist/basic/AtomSuggestions.js.map +1 -1
- package/dist/basic/Button.js +1 -65
- package/dist/basic/Button.js.map +1 -1
- package/dist/basic/Calendar.js +1 -251
- package/dist/basic/Calendar.js.map +1 -1
- package/dist/basic/CheckBoxList.js +1 -76
- package/dist/basic/CheckBoxList.js.map +1 -1
- package/dist/basic/Checkbox.js +1 -31
- package/dist/basic/Checkbox.js.map +1 -1
- package/dist/basic/Chip.js +1 -53
- package/dist/basic/Chip.js.map +1 -1
- package/dist/basic/ComboBox.js +1 -87
- package/dist/basic/ComboBox.js.map +1 -1
- package/dist/basic/DataGrid.js +1 -332
- package/dist/basic/DataGrid.js.map +1 -1
- package/dist/basic/DateField.js +1 -94
- package/dist/basic/DateField.js.map +1 -1
- package/dist/basic/DropDown.js +1 -174
- package/dist/basic/DropDown.js.map +1 -1
- package/dist/basic/Editable.js +1 -121
- package/dist/basic/Editable.js.map +1 -1
- package/dist/basic/Expander.js +1 -139
- package/dist/basic/Expander.js.map +1 -1
- package/dist/basic/Form.js +1 -319
- package/dist/basic/Form.js.map +1 -1
- package/dist/basic/FormDialog.js +1 -31
- package/dist/basic/FormDialog.js.map +1 -1
- package/dist/basic/FormField.js +1 -192
- package/dist/basic/FormField.js.map +1 -1
- package/dist/basic/IElement.js +1 -8
- package/dist/basic/InlinePopup.js +1 -327
- package/dist/basic/InlinePopup.js.map +1 -1
- package/dist/basic/InlinePopupControl.js +1 -38
- package/dist/basic/InlinePopupControl.js.map +1 -1
- package/dist/basic/Input.js +1 -29
- package/dist/basic/Input.js.map +1 -1
- package/dist/basic/ListRepeater.js +1 -51
- package/dist/basic/ListRepeater.js.map +1 -1
- package/dist/basic/MaskedInput.js +1 -65
- package/dist/basic/MaskedInput.js.map +1 -1
- package/dist/basic/MaskedInputDiv.js +1 -99
- package/dist/basic/MaskedInputDiv.js.map +1 -1
- package/dist/basic/Mix.js +1 -36
- package/dist/basic/Mix.js.map +1 -1
- package/dist/basic/Panel.js +1 -36
- package/dist/basic/Panel.js.map +1 -1
- package/dist/basic/PasswordBox.js +1 -56
- package/dist/basic/PasswordBox.js.map +1 -1
- package/dist/basic/PinchZoomView.js +1 -270
- package/dist/basic/PinchZoomView.js.map +1 -1
- package/dist/basic/PopupButton.js +1 -73
- package/dist/basic/PopupButton.js.map +1 -1
- package/dist/basic/RadioButtonList.js +1 -66
- package/dist/basic/RadioButtonList.js.map +1 -1
- package/dist/basic/RefreshLock.js +1 -84
- package/dist/basic/RefreshLock.js.map +1 -1
- package/dist/basic/Row.js +1 -42
- package/dist/basic/Row.js.map +1 -1
- package/dist/basic/Swipe.js +1 -120
- package/dist/basic/Swipe.js.map +1 -1
- package/dist/basic/Switch.js +1 -60
- package/dist/basic/Switch.js.map +1 -1
- package/dist/basic/TableRepeater.js +1 -51
- package/dist/basic/TableRepeater.js.map +1 -1
- package/dist/basic/ToggleButtonBar.js +1 -63
- package/dist/basic/ToggleButtonBar.js.map +1 -1
- package/dist/basic/Tooltip.js +1 -101
- package/dist/basic/Tooltip.js.map +1 -1
- package/dist/basic/combineClasses.js +1 -12
- package/dist/basic/combineClasses.js.map +1 -1
- package/dist/basic/in-built/InBuiltStyles.js +1 -48
- package/dist/basic/in-built/InBuiltStyles.js.map +1 -1
- package/dist/button-bar/AtomButtonBar.js +1 -45
- package/dist/button-bar/AtomButtonBar.js.map +1 -1
- package/dist/buttons/AtomPopupButton.js +1 -21
- package/dist/buttons/AtomPopupButton.js.map +1 -1
- package/dist/buttons/AtomPopupButtonStyle.js +1 -31
- package/dist/buttons/AtomPopupButtonStyle.js.map +1 -1
- package/dist/calendar/AtomCalendar.js +1 -98
- package/dist/calendar/AtomCalendar.js.map +1 -1
- package/dist/calendar/AtomCalendarStyle.js +1 -179
- package/dist/calendar/AtomCalendarStyle.js.map +1 -1
- package/dist/calendar/CalendarViewModel.js +1 -133
- package/dist/calendar/CalendarViewModel.js.map +1 -1
- package/dist/calendar/res/SRCalendar.js +1 -89
- package/dist/calendar/res/SRCalendar.js.map +1 -1
- package/dist/calendar/res/en-US/SRCalendar.js +1 -77
- package/dist/calendar/res/en-US/SRCalendar.js.map +1 -1
- package/dist/data-grid/AtomColumn.js +1 -60
- package/dist/data-grid/AtomColumn.js.map +1 -1
- package/dist/data-grid/AtomDataGrid.js +1 -71
- package/dist/data-grid/AtomDataGrid.js.map +1 -1
- package/dist/data-grid/AtomDataGridStyle.js +1 -55
- package/dist/data-grid/AtomDataGridStyle.js.map +1 -1
- package/dist/data-grid/AtomDataGridViewModel.js +1 -78
- package/dist/data-grid/AtomDataGridViewModel.js.map +1 -1
- package/dist/data-grid/GridTemplate.js +1 -65
- package/dist/data-grid/GridTemplate.js.map +1 -1
- package/dist/data-pager/AtomDataPager.js +1 -112
- package/dist/data-pager/AtomDataPager.js.map +1 -1
- package/dist/date-field/AtomDateField.js +1 -60
- package/dist/date-field/AtomDateField.js.map +1 -1
- package/dist/desktop-app/DesktopApp.js +1 -95
- package/dist/desktop-app/DesktopApp.js.map +1 -1
- package/dist/form/AtomField.js +1 -145
- package/dist/form/AtomField.js.map +1 -1
- package/dist/form/AtomForm.js +1 -102
- package/dist/form/AtomForm.js.map +1 -1
- package/dist/form/AtomFormGroup.js +1 -16
- package/dist/form/AtomFormGroup.js.map +1 -1
- package/dist/form/AtomFormStyle.js +1 -72
- package/dist/form/AtomFormStyle.js.map +1 -1
- package/dist/form/HelpPopup.js +1 -26
- package/dist/form/HelpPopup.js.map +1 -1
- package/dist/html-editor/AtomHtmlEditor.js +3 -329
- package/dist/html-editor/AtomHtmlEditor.js.map +1 -1
- package/dist/html-editor/commands/AddImage.js +1 -84
- package/dist/html-editor/commands/AddImage.js.map +1 -1
- package/dist/html-editor/commands/AddLink.js +1 -103
- package/dist/html-editor/commands/AddLink.js.map +1 -1
- package/dist/html-editor/commands/Align.js +1 -40
- package/dist/html-editor/commands/Align.js.map +1 -1
- package/dist/html-editor/commands/AttachFile.js +1 -97
- package/dist/html-editor/commands/AttachFile.js.map +1 -1
- package/dist/html-editor/commands/Bold.js +1 -23
- package/dist/html-editor/commands/Bold.js.map +1 -1
- package/dist/html-editor/commands/ChangeColor.js +1 -56
- package/dist/html-editor/commands/ChangeColor.js.map +1 -1
- package/dist/html-editor/commands/ChangeFont.js +1 -71
- package/dist/html-editor/commands/ChangeFont.js.map +1 -1
- package/dist/html-editor/commands/ChangeFontSize.js +1 -32
- package/dist/html-editor/commands/ChangeFontSize.js.map +1 -1
- package/dist/html-editor/commands/Command.js +1 -56
- package/dist/html-editor/commands/Command.js.map +1 -1
- package/dist/html-editor/commands/CommandButton.js +1 -99
- package/dist/html-editor/commands/CommandButton.js.map +1 -1
- package/dist/html-editor/commands/Headings.js +1 -42
- package/dist/html-editor/commands/Headings.js.map +1 -1
- package/dist/html-editor/commands/HorizontalRule.js +1 -22
- package/dist/html-editor/commands/HorizontalRule.js.map +1 -1
- package/dist/html-editor/commands/HtmlCommands.js +1 -77
- package/dist/html-editor/commands/HtmlCommands.js.map +1 -1
- package/dist/html-editor/commands/IndentLess.js +1 -23
- package/dist/html-editor/commands/IndentLess.js.map +1 -1
- package/dist/html-editor/commands/IndentMore.js +1 -23
- package/dist/html-editor/commands/IndentMore.js.map +1 -1
- package/dist/html-editor/commands/Italic.js +1 -23
- package/dist/html-editor/commands/Italic.js.map +1 -1
- package/dist/html-editor/commands/NumberedList.js +1 -23
- package/dist/html-editor/commands/NumberedList.js.map +1 -1
- package/dist/html-editor/commands/Quote.js +1 -23
- package/dist/html-editor/commands/Quote.js.map +1 -1
- package/dist/html-editor/commands/RemoveFormat.js +1 -23
- package/dist/html-editor/commands/RemoveFormat.js.map +1 -1
- package/dist/html-editor/commands/Separator.js +1 -25
- package/dist/html-editor/commands/Separator.js.map +1 -1
- package/dist/html-editor/commands/Source.js +1 -99
- package/dist/html-editor/commands/Source.js.map +1 -1
- package/dist/html-editor/commands/StrikeThrough.js +1 -23
- package/dist/html-editor/commands/StrikeThrough.js.map +1 -1
- package/dist/html-editor/commands/Underline.js +1 -23
- package/dist/html-editor/commands/Underline.js.map +1 -1
- package/dist/html-editor/commands/Unlink.js +1 -24
- package/dist/html-editor/commands/Unlink.js.map +1 -1
- package/dist/html-editor/commands/UnorderedList.js +1 -23
- package/dist/html-editor/commands/UnorderedList.js.map +1 -1
- package/dist/mobile/pages/AtomPageFrame.js +1 -205
- package/dist/mobile/pages/AtomPageFrame.js.map +1 -1
- package/dist/mobile/pages/AtomPageFrameStyle.js +1 -63
- package/dist/mobile/pages/AtomPageFrameStyle.js.map +1 -1
- package/dist/mobile/pages/AtomPageFrameTemplate.js +1 -53
- package/dist/mobile/pages/AtomPageFrameTemplate.js.map +1 -1
- package/dist/mobile/pages/Page.js +1 -26
- package/dist/mobile/pages/Page.js.map +1 -1
- package/dist/mobile/pages/PageFrameViewModel.js +1 -169
- package/dist/mobile/pages/PageFrameViewModel.js.map +1 -1
- package/dist/mobile/pages/TitleTemplate.js +1 -27
- package/dist/mobile/pages/TitleTemplate.js.map +1 -1
- package/dist/mobile-app/BottomPopup.js +1 -230
- package/dist/mobile-app/BottomPopup.js.map +1 -1
- package/dist/mobile-app/MobileApp.js +1 -604
- package/dist/mobile-app/MobileApp.js.map +1 -1
- package/dist/player/AtomVideoPlayer.js +1 -248
- package/dist/player/AtomVideoPlayer.js.map +1 -1
- package/dist/player/TrackProgress.js +1 -29
- package/dist/player/TrackProgress.js.map +1 -1
- package/dist/setupBridge.js +1 -89
- package/dist/setupBridge.js.map +1 -1
- package/dist/switch/AtomSwitch.js +1 -48
- package/dist/switch/AtomSwitch.js.map +1 -1
- package/dist/switch/AtomSwitchStyle.js +1 -79
- package/dist/switch/AtomSwitchStyle.js.map +1 -1
- package/dist/time-field/AtomTimeField.js +1 -105
- package/dist/time-field/AtomTimeField.js.map +1 -1
- package/dist/time-field/AtomTimeFieldStyle.js +1 -27
- package/dist/time-field/AtomTimeFieldStyle.js.map +1 -1
- package/dist/toggle-view/AtomToggleView.js +1 -101
- package/dist/toggle-view/AtomToggleView.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -1,1117 +1,2 @@
|
|
|
1
|
-
System.register(["@web-atoms/core/dist/core/AtomBinder", "@web-atoms/core/dist/core/Bind", "@web-atoms/core/dist/core/BindableProperty", "@web-atoms/core/dist/core/Colors", "@web-atoms/core/dist/core/StringHelper", "@web-atoms/core/dist/core/WatchProperty", "@web-atoms/core/dist/core/XNode", "@web-atoms/core/dist/style/StyleRule", "@web-atoms/core/dist/web/controls/AtomControl", "@web-atoms/core/dist/web/services/PopupService", "@web-atoms/core/dist/web/styles/CSS", "./InlinePopup"], function (_export, _context) {
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var AtomBinder, Bind, BindableProperty, Colors, StringHelper, WatchProperty, XNode, StyleRule, AtomControl, PopupWindow, CSS, InlinePopup, SelectAllControl, AtomRepeater, __decorate, __metadata, __rest, popupCSS, getParentRepeaterItem, MatchTrue, MatchFalse, ArrowToString, MatchCaseInsensitive, MatchAnyCaseInsensitive, SameObjectValue, maxHeight, getFirstChild, hoverItem, dragOver;
|
|
5
|
-
function askSuggestion(items, itemRenderer, match, options) {
|
|
6
|
-
class Suggestions extends PopupWindow {
|
|
7
|
-
create() {
|
|
8
|
-
var _a;
|
|
9
|
-
this.title = (_a = options === null || options === void 0 ? void 0 : options.title) !== null && _a !== void 0 ? _a : "Select";
|
|
10
|
-
this.render(XNode.create("div", {
|
|
11
|
-
class: popupCSS
|
|
12
|
-
}, XNode.create("input", {
|
|
13
|
-
type: "search",
|
|
14
|
-
value: Bind.twoWaysImmediate(() => this.search),
|
|
15
|
-
autofocus: true
|
|
16
|
-
}), XNode.create("div", {
|
|
17
|
-
class: "items"
|
|
18
|
-
}, XNode.create(AtomRepeater, {
|
|
19
|
-
class: "presenter",
|
|
20
|
-
itemRenderer: itemRenderer,
|
|
21
|
-
visibilityFilter: Bind.oneWay(() => match(this.search)),
|
|
22
|
-
eventItemClick: e => {
|
|
23
|
-
this.close(e.detail);
|
|
24
|
-
},
|
|
25
|
-
items: items
|
|
26
|
-
}))));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
__decorate([BindableProperty, __metadata("design:type", String)], Suggestions.prototype, "search", void 0);
|
|
30
|
-
options !== null && options !== void 0 ? options : options = {};
|
|
31
|
-
if (typeof options.maximize === "undefined") {
|
|
32
|
-
if (typeof options.width === "undefined") {
|
|
33
|
-
options.maxWidth = "90%";
|
|
34
|
-
options.minWidth = "300px";
|
|
35
|
-
}
|
|
36
|
-
if (typeof options.height === "undefined") {
|
|
37
|
-
options.height = "80%";
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return Suggestions.showModal(options);
|
|
41
|
-
}
|
|
42
|
-
function askSuggestionPopup(opener, items, itemRenderer, match, selectedItem) {
|
|
43
|
-
const updateSearch = ("search" in opener);
|
|
44
|
-
const itemsInOpener = ("items" in opener);
|
|
45
|
-
class Suggestions extends InlinePopup {
|
|
46
|
-
get items() {
|
|
47
|
-
return itemsInOpener ? this.opener.items : items;
|
|
48
|
-
}
|
|
49
|
-
onPropertyChanged(name) {
|
|
50
|
-
if (updateSearch && name === "search") {
|
|
51
|
-
opener.search = this.search;
|
|
52
|
-
}
|
|
53
|
-
super.onPropertyChanged(name);
|
|
54
|
-
}
|
|
55
|
-
create() {
|
|
56
|
-
this.anchorItem = selectedItem;
|
|
57
|
-
this.opener = opener;
|
|
58
|
-
if (this.opener.search) {
|
|
59
|
-
this.search = this.opener.search;
|
|
60
|
-
}
|
|
61
|
-
if (selectedItem) {
|
|
62
|
-
this.anchorIndex = items.indexOf(selectedItem);
|
|
63
|
-
}
|
|
64
|
-
const disableSearch = opener.disableSearch;
|
|
65
|
-
if (itemsInOpener) {
|
|
66
|
-
this.render(XNode.create("div", {
|
|
67
|
-
"data-suggestion-popup": "suggestion-popup"
|
|
68
|
-
}, !disableSearch && XNode.create("input", {
|
|
69
|
-
type: "search",
|
|
70
|
-
value: Bind.twoWaysImmediate(() => this.search),
|
|
71
|
-
eventKeydown: e => this.onKey(e),
|
|
72
|
-
autofocus: true
|
|
73
|
-
}), XNode.create("div", {
|
|
74
|
-
class: "items"
|
|
75
|
-
}, XNode.create(AtomRepeater, {
|
|
76
|
-
class: "presenter",
|
|
77
|
-
selectedItem: Bind.oneWay(() => this.anchorItem),
|
|
78
|
-
itemRenderer: itemRenderer,
|
|
79
|
-
visibilityFilter: Bind.oneWay(() => match(this.search)),
|
|
80
|
-
eventItemClick: e => {
|
|
81
|
-
this.anchorItem = e.detail;
|
|
82
|
-
setTimeout(() => this.close(e.detail), 100);
|
|
83
|
-
},
|
|
84
|
-
items: Bind.oneWay(() => this.opener.items)
|
|
85
|
-
}))));
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
this.render(XNode.create("div", {
|
|
89
|
-
"data-suggestion-popup": "suggestion-popup"
|
|
90
|
-
}, !disableSearch && XNode.create("input", {
|
|
91
|
-
type: "search",
|
|
92
|
-
value: Bind.twoWaysImmediate(() => this.search),
|
|
93
|
-
eventKeydown: e => this.onKey(e),
|
|
94
|
-
autofocus: true
|
|
95
|
-
}), XNode.create("div", {
|
|
96
|
-
class: "items"
|
|
97
|
-
}, XNode.create(AtomRepeater, {
|
|
98
|
-
class: "presenter",
|
|
99
|
-
selectedItem: Bind.oneWay(() => this.anchorItem),
|
|
100
|
-
itemRenderer: itemRenderer,
|
|
101
|
-
visibilityFilter: Bind.oneWay(() => match(this.search)),
|
|
102
|
-
scrollToSelection: true,
|
|
103
|
-
eventItemClick: e => {
|
|
104
|
-
this.close(e.detail);
|
|
105
|
-
},
|
|
106
|
-
items: items
|
|
107
|
-
}))));
|
|
108
|
-
}
|
|
109
|
-
onKey(e) {
|
|
110
|
-
var _a;
|
|
111
|
-
const suggested = match ? (_a = this.items) === null || _a === void 0 ? void 0 : _a.filter(match(this.search)) : this.items;
|
|
112
|
-
switch (e.key) {
|
|
113
|
-
case "Enter":
|
|
114
|
-
const anchorItem = this.anchorItem;
|
|
115
|
-
if (!anchorItem) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
this.anchorIndex = 0;
|
|
119
|
-
this.close(anchorItem);
|
|
120
|
-
this.anchorItem = null;
|
|
121
|
-
this.search = "";
|
|
122
|
-
break;
|
|
123
|
-
case "ArrowDown":
|
|
124
|
-
if (suggested) {
|
|
125
|
-
if (!this.anchorItem) {
|
|
126
|
-
this.anchorIndex = 0;
|
|
127
|
-
} else {
|
|
128
|
-
if (this.anchorIndex < suggested.length - 1) {
|
|
129
|
-
this.anchorIndex++;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
this.anchorItem = suggested[this.anchorIndex];
|
|
133
|
-
}
|
|
134
|
-
break;
|
|
135
|
-
case "ArrowUp":
|
|
136
|
-
if (suggested) {
|
|
137
|
-
if (!this.anchorItem) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (this.anchorIndex) {
|
|
141
|
-
this.anchorIndex--;
|
|
142
|
-
}
|
|
143
|
-
this.anchorItem = suggested[this.anchorIndex];
|
|
144
|
-
}
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
__decorate([BindableProperty, __metadata("design:type", String)], Suggestions.prototype, "search", void 0);
|
|
150
|
-
return Suggestions.showControl(opener);
|
|
151
|
-
}
|
|
152
|
-
function SelectorCheckBox(_a, ...nodes) {
|
|
153
|
-
var {
|
|
154
|
-
text,
|
|
155
|
-
icon = "far fa-square",
|
|
156
|
-
iconSelected = "fas fa-check-square"
|
|
157
|
-
} = _a,
|
|
158
|
-
a = __rest(_a, ["text", "icon", "iconSelected"]);
|
|
159
|
-
if (text) {
|
|
160
|
-
return XNode.create("label", null, XNode.create("i", {
|
|
161
|
-
class: icon,
|
|
162
|
-
"data-click-event": "item-select"
|
|
163
|
-
}), XNode.create("i", {
|
|
164
|
-
class: iconSelected,
|
|
165
|
-
"data-click-event": "item-deselect"
|
|
166
|
-
}), XNode.create("span", {
|
|
167
|
-
"data-no-wrap": "true",
|
|
168
|
-
text: text
|
|
169
|
-
}), ...nodes);
|
|
170
|
-
}
|
|
171
|
-
return XNode.create("label", null, XNode.create("i", {
|
|
172
|
-
class: icon,
|
|
173
|
-
"data-click-event": "item-select"
|
|
174
|
-
}), XNode.create("i", {
|
|
175
|
-
class: iconSelected,
|
|
176
|
-
"data-click-event": "item-deselect"
|
|
177
|
-
}), ...nodes);
|
|
178
|
-
}
|
|
179
|
-
function SelectAll(_a, ...nodes) {
|
|
180
|
-
var {
|
|
181
|
-
text = "Select All",
|
|
182
|
-
icon = "far fa-square",
|
|
183
|
-
iconSelected = "fas fa-check-square"
|
|
184
|
-
} = _a,
|
|
185
|
-
a = __rest(_a, ["text", "icon", "iconSelected"]);
|
|
186
|
-
if (text) {
|
|
187
|
-
return XNode.create(SelectAllControl, Object.assign({
|
|
188
|
-
for: "label"
|
|
189
|
-
}, a), XNode.create("i", {
|
|
190
|
-
class: icon,
|
|
191
|
-
"data-ui-type": "item-select"
|
|
192
|
-
}), XNode.create("i", {
|
|
193
|
-
class: iconSelected,
|
|
194
|
-
"data-ui-type": "item-deselect"
|
|
195
|
-
}), XNode.create("span", {
|
|
196
|
-
"data-no-wrap": "true",
|
|
197
|
-
text: text
|
|
198
|
-
}));
|
|
199
|
-
}
|
|
200
|
-
return XNode.create(SelectAllControl, Object.assign({
|
|
201
|
-
for: "label"
|
|
202
|
-
}, a), XNode.create("i", {
|
|
203
|
-
class: icon,
|
|
204
|
-
"data-ui-type": "item-select"
|
|
205
|
-
}), XNode.create("i", {
|
|
206
|
-
class: iconSelected,
|
|
207
|
-
"data-ui-type": "item-deselect"
|
|
208
|
-
}), ...nodes);
|
|
209
|
-
}
|
|
210
|
-
function disposeChildren(owner, e) {
|
|
211
|
-
if (!e) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
let s = e.firstElementChild;
|
|
215
|
-
while (s) {
|
|
216
|
-
const c = s;
|
|
217
|
-
s = s.nextElementSibling;
|
|
218
|
-
const ac = c.atomControl;
|
|
219
|
-
if (ac) {
|
|
220
|
-
ac.dispose();
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
disposeChildren(owner, c);
|
|
224
|
-
owner.unbind(c);
|
|
225
|
-
owner.unbindEvent(c);
|
|
226
|
-
}
|
|
227
|
-
e.innerHTML = "";
|
|
228
|
-
}
|
|
229
|
-
function disposeChild(owner, e) {
|
|
230
|
-
const ac = e.atomControl;
|
|
231
|
-
if (ac) {
|
|
232
|
-
ac.dispose();
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
disposeChildren(owner, e);
|
|
236
|
-
owner.unbind(e);
|
|
237
|
-
owner.unbindEvent(e);
|
|
238
|
-
e.remove();
|
|
239
|
-
}
|
|
240
|
-
function defaultComparer(left, right) {
|
|
241
|
-
if (left && right) {
|
|
242
|
-
if (left instanceof Date) {
|
|
243
|
-
if (right instanceof Date) {
|
|
244
|
-
return left.getTime() === right.getTime();
|
|
245
|
-
}
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return left === right;
|
|
250
|
-
}
|
|
251
|
-
function updateDragDrop(e, force = false) {
|
|
252
|
-
if (!e) {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
if (force) {
|
|
256
|
-
e.draggable = false;
|
|
257
|
-
} else {
|
|
258
|
-
force = e.draggable;
|
|
259
|
-
}
|
|
260
|
-
e = e.firstElementChild;
|
|
261
|
-
while (e) {
|
|
262
|
-
updateDragDrop(e, force);
|
|
263
|
-
e = e.nextElementSibling;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
_export({
|
|
267
|
-
askSuggestion: askSuggestion,
|
|
268
|
-
askSuggestionPopup: askSuggestionPopup,
|
|
269
|
-
SelectorCheckBox: SelectorCheckBox,
|
|
270
|
-
SelectAll: SelectAll,
|
|
271
|
-
disposeChildren: disposeChildren,
|
|
272
|
-
disposeChild: disposeChild,
|
|
273
|
-
defaultComparer: defaultComparer,
|
|
274
|
-
default: void 0
|
|
275
|
-
});
|
|
276
|
-
return {
|
|
277
|
-
setters: [function (_webAtomsCoreDistCoreAtomBinder) {
|
|
278
|
-
AtomBinder = _webAtomsCoreDistCoreAtomBinder.AtomBinder;
|
|
279
|
-
}, function (_webAtomsCoreDistCoreBind) {
|
|
280
|
-
Bind = _webAtomsCoreDistCoreBind.default;
|
|
281
|
-
}, function (_webAtomsCoreDistCoreBindableProperty) {
|
|
282
|
-
BindableProperty = _webAtomsCoreDistCoreBindableProperty.BindableProperty;
|
|
283
|
-
}, function (_webAtomsCoreDistCoreColors) {
|
|
284
|
-
Colors = _webAtomsCoreDistCoreColors.default;
|
|
285
|
-
}, function (_webAtomsCoreDistCoreStringHelper) {
|
|
286
|
-
StringHelper = _webAtomsCoreDistCoreStringHelper.StringHelper;
|
|
287
|
-
}, function (_webAtomsCoreDistCoreWatchProperty) {
|
|
288
|
-
WatchProperty = _webAtomsCoreDistCoreWatchProperty.default;
|
|
289
|
-
}, function (_webAtomsCoreDistCoreXNode) {
|
|
290
|
-
XNode = _webAtomsCoreDistCoreXNode.default;
|
|
291
|
-
}, function (_webAtomsCoreDistStyleStyleRule) {
|
|
292
|
-
StyleRule = _webAtomsCoreDistStyleStyleRule.default;
|
|
293
|
-
}, function (_webAtomsCoreDistWebControlsAtomControl) {
|
|
294
|
-
AtomControl = _webAtomsCoreDistWebControlsAtomControl.AtomControl;
|
|
295
|
-
}, function (_webAtomsCoreDistWebServicesPopupService) {
|
|
296
|
-
PopupWindow = _webAtomsCoreDistWebServicesPopupService.PopupWindow;
|
|
297
|
-
}, function (_webAtomsCoreDistWebStylesCSS) {
|
|
298
|
-
CSS = _webAtomsCoreDistWebStylesCSS.default;
|
|
299
|
-
}, function (_InlinePopup) {
|
|
300
|
-
InlinePopup = _InlinePopup.default;
|
|
301
|
-
}],
|
|
302
|
-
execute: function () {
|
|
303
|
-
__decorate = void 0 && (void 0).__decorate || function (decorators, target, key, desc) {
|
|
304
|
-
var c = arguments.length,
|
|
305
|
-
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
306
|
-
d;
|
|
307
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
308
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
309
|
-
};
|
|
310
|
-
__metadata = void 0 && (void 0).__metadata || function (k, v) {
|
|
311
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
312
|
-
};
|
|
313
|
-
__rest = void 0 && (void 0).__rest || function (s, e) {
|
|
314
|
-
var t = {};
|
|
315
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
316
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
317
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
318
|
-
}
|
|
319
|
-
return t;
|
|
320
|
-
};
|
|
321
|
-
CSS(StyleRule().display("none"), "[data-ui-display=none]");
|
|
322
|
-
popupCSS = CSS(StyleRule().minWidth(200).verticalFlexLayout({
|
|
323
|
-
alignItems: "stretch"
|
|
324
|
-
}).child(StyleRule(".items").flexStretch().overflow("auto").child(StyleRule(".presenter").child(StyleRule("*").padding(5)).child(StyleRule("[data-selected-item=true]").backgroundColor(Colors.lightGreen)))));
|
|
325
|
-
_export("getParentRepeaterItem", getParentRepeaterItem = target => {
|
|
326
|
-
let eventName;
|
|
327
|
-
let repeater;
|
|
328
|
-
let index;
|
|
329
|
-
let root;
|
|
330
|
-
while (target) {
|
|
331
|
-
const a = target.atomControl;
|
|
332
|
-
if (a !== undefined && a instanceof AtomRepeater) {
|
|
333
|
-
repeater = a;
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
if (index === undefined) {
|
|
337
|
-
const itemIndex = target.dataset.itemIndex;
|
|
338
|
-
if (typeof itemIndex !== "undefined") {
|
|
339
|
-
root = target;
|
|
340
|
-
index = ~~itemIndex;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
if (eventName === undefined) {
|
|
344
|
-
const itemClickEvent = target.dataset.clickEvent;
|
|
345
|
-
if (itemClickEvent) {
|
|
346
|
-
eventName = itemClickEvent.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
target = target.parentElement;
|
|
350
|
-
}
|
|
351
|
-
if (index === void 0 || repeater === void 0) {
|
|
352
|
-
return undefined;
|
|
353
|
-
}
|
|
354
|
-
const item = repeater.items[~~index];
|
|
355
|
-
return [eventName, repeater, item, index, root];
|
|
356
|
-
});
|
|
357
|
-
_export("MatchTrue", MatchTrue = (...a) => true);
|
|
358
|
-
_export("MatchFalse", MatchFalse = (...a) => false);
|
|
359
|
-
_export("ArrowToString", ArrowToString = item => {
|
|
360
|
-
var _a, _b;
|
|
361
|
-
return (_b = (_a = item.label) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : item.toString();
|
|
362
|
-
});
|
|
363
|
-
_export("MatchCaseInsensitive", MatchCaseInsensitive = (textField = ArrowToString) => {
|
|
364
|
-
return s => {
|
|
365
|
-
if (!s) {
|
|
366
|
-
return MatchTrue;
|
|
367
|
-
}
|
|
368
|
-
const r = StringHelper.createContainsRegExp(s);
|
|
369
|
-
return item => r.test(textField(item));
|
|
370
|
-
};
|
|
371
|
-
});
|
|
372
|
-
_export("MatchAnyCaseInsensitive", MatchAnyCaseInsensitive = (textField = ArrowToString) => {
|
|
373
|
-
return s => {
|
|
374
|
-
if (!s) {
|
|
375
|
-
return MatchTrue;
|
|
376
|
-
}
|
|
377
|
-
const r = StringHelper.createContainsAnyWordRegExp(s);
|
|
378
|
-
return item => r.test(textField(item));
|
|
379
|
-
};
|
|
380
|
-
});
|
|
381
|
-
_export("SameObjectValue", SameObjectValue = item => item);
|
|
382
|
-
maxHeight = window.screen.availHeight / 2 > 250 ? StyleRule().height("250px") : StyleRule().maxHeight(80);
|
|
383
|
-
CSS(StyleRule().merge(maxHeight).minWidth(80).verticalFlexLayout({
|
|
384
|
-
alignItems: "stretch"
|
|
385
|
-
}).child(StyleRule(".items").flexStretch().overflow("auto").child(StyleRule(".presenter").child(StyleRule("*").padding(5)).child(StyleRule("[data-selected-item=true]").backgroundColor(Colors.lightGreen)))), "*[data-suggestion-popup=suggestion-popup]");
|
|
386
|
-
CSS(StyleRule().nested(StyleRule("i[data-click-event]").padding(5)).nested(StyleRule("[data-no-wrap=true]").whiteSpace("nowrap")), "*[data-selected-item]");
|
|
387
|
-
CSS(StyleRule().nested(StyleRule("i[data-click-event=item-select]").padding(5)).displayNone(" i[data-click-event=item-select]"), "*[data-selected-item=true]");
|
|
388
|
-
CSS(StyleRule().displayNone(" i[data-click-event=item-deselect]"), "*[data-selected-item=false]");
|
|
389
|
-
CSS(StyleRule().flexLayout({
|
|
390
|
-
alignItems: "center",
|
|
391
|
-
justifyContent: "flex-start"
|
|
392
|
-
}).margin(0).nested(StyleRule("i[data-ui-type]").padding(5)).nested(StyleRule("[data-no-wrap=true]").whiteSpace("nowrap")).displayNone("[data-is-selected=true] i[data-ui-type=item-select]").displayNone("[data-is-selected=false] i[data-ui-type=item-deselect]"), "*[data-select-all=select-all]");
|
|
393
|
-
SelectAllControl = class SelectAllControl extends AtomControl {
|
|
394
|
-
preCreate() {
|
|
395
|
-
this.element.dataset.selectAll = "select-all";
|
|
396
|
-
this.items = [];
|
|
397
|
-
this.selectedItems = [];
|
|
398
|
-
this.render(XNode.create(SelectAllControl, {
|
|
399
|
-
"data-is-selected": Bind.oneWay(() => this.items.length > 0 && this.items.length === this.selectedItems.length, false)
|
|
400
|
-
}));
|
|
401
|
-
this.bindEvent(this.element, "click", () => {
|
|
402
|
-
const si = this.selectedItems;
|
|
403
|
-
const items = this.items;
|
|
404
|
-
if (!si) {
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
if (!items) {
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
if (items.length === 0) {
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
if (items.length === si.length) {
|
|
414
|
-
si.clear();
|
|
415
|
-
} else {
|
|
416
|
-
si.length = 0;
|
|
417
|
-
si.push(...items);
|
|
418
|
-
si.refresh();
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
__decorate([BindableProperty, __metadata("design:type", Array)], SelectAllControl.prototype, "items", void 0);
|
|
424
|
-
__decorate([BindableProperty, __metadata("design:type", Array)], SelectAllControl.prototype, "selectedItems", void 0);
|
|
425
|
-
getFirstChild = container => {
|
|
426
|
-
let child = container.firstElementChild;
|
|
427
|
-
while (child && child.dataset.itemIndex === void 0) {
|
|
428
|
-
child = child.nextElementSibling;
|
|
429
|
-
}
|
|
430
|
-
return child;
|
|
431
|
-
};
|
|
432
|
-
_export("default", AtomRepeater = class AtomRepeater extends AtomControl {
|
|
433
|
-
constructor() {
|
|
434
|
-
super(...arguments);
|
|
435
|
-
this.bubbleEvents = true;
|
|
436
|
-
}
|
|
437
|
-
static from(element) {
|
|
438
|
-
while (element) {
|
|
439
|
-
const {
|
|
440
|
-
atomControl
|
|
441
|
-
} = element;
|
|
442
|
-
if (atomControl instanceof AtomRepeater) {
|
|
443
|
-
return atomControl;
|
|
444
|
-
}
|
|
445
|
-
element = element.parentElement;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
set refreshEventScope(v) {
|
|
449
|
-
this.registerDisposable(v.listen(ce => {
|
|
450
|
-
this.refreshItem(ce.detail);
|
|
451
|
-
}));
|
|
452
|
-
}
|
|
453
|
-
get allSelected() {
|
|
454
|
-
const selectedItems = this.selectedItems;
|
|
455
|
-
const items = this.items;
|
|
456
|
-
if (!(items && selectedItems)) {
|
|
457
|
-
return false;
|
|
458
|
-
}
|
|
459
|
-
return items.length && items.length === selectedItems.length;
|
|
460
|
-
}
|
|
461
|
-
get value() {
|
|
462
|
-
var _a;
|
|
463
|
-
if (this.initialValue !== undefined) {
|
|
464
|
-
return this.initialValue;
|
|
465
|
-
}
|
|
466
|
-
const sp = this.selectedItem;
|
|
467
|
-
if (sp === undefined) {
|
|
468
|
-
return sp;
|
|
469
|
-
}
|
|
470
|
-
const vp = (_a = this.valuePath) !== null && _a !== void 0 ? _a : SameObjectValue;
|
|
471
|
-
return vp(sp);
|
|
472
|
-
}
|
|
473
|
-
set value(v) {
|
|
474
|
-
var _a, _b;
|
|
475
|
-
this.initialValue = v;
|
|
476
|
-
if (!this.items || !this.items.length) {
|
|
477
|
-
AtomBinder.refreshValue(this, "value");
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
const vp = (_a = this.valuePath) !== null && _a !== void 0 ? _a : SameObjectValue;
|
|
481
|
-
const c = (_b = this.comparer) !== null && _b !== void 0 ? _b : defaultComparer;
|
|
482
|
-
const selectedItem = this.items.find(item => c(vp(item), v));
|
|
483
|
-
this.selectedItem = selectedItem;
|
|
484
|
-
delete this.initialValue;
|
|
485
|
-
}
|
|
486
|
-
get selectedItem() {
|
|
487
|
-
var _a;
|
|
488
|
-
return (_a = this.selectedItems) === null || _a === void 0 ? void 0 : _a[0];
|
|
489
|
-
}
|
|
490
|
-
set selectedItem(value) {
|
|
491
|
-
var _a;
|
|
492
|
-
const si = (_a = this.selectedItems) !== null && _a !== void 0 ? _a : this.selectedItems = [];
|
|
493
|
-
const first = si[0];
|
|
494
|
-
if (value === first) {
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
si.set(0, value);
|
|
498
|
-
}
|
|
499
|
-
onPropertyChanged(name) {
|
|
500
|
-
var _a, _b;
|
|
501
|
-
switch (name) {
|
|
502
|
-
case "items":
|
|
503
|
-
(_a = this.itemsDisposable) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
504
|
-
const items = this.items;
|
|
505
|
-
const d = items === null || items === void 0 ? void 0 : items.watch((target, type, index, item) => {
|
|
506
|
-
switch (type) {
|
|
507
|
-
case "add":
|
|
508
|
-
case "remove":
|
|
509
|
-
case "set":
|
|
510
|
-
this.updatePartial(type, index, item);
|
|
511
|
-
break;
|
|
512
|
-
default:
|
|
513
|
-
this.updateItems();
|
|
514
|
-
break;
|
|
515
|
-
}
|
|
516
|
-
this.dispatchCustomEvent("items-updated", {
|
|
517
|
-
type,
|
|
518
|
-
items,
|
|
519
|
-
index
|
|
520
|
-
});
|
|
521
|
-
AtomBinder.refreshValue(this, "selectedItem");
|
|
522
|
-
AtomBinder.refreshValue(this, "value");
|
|
523
|
-
});
|
|
524
|
-
if (d) {
|
|
525
|
-
this.itemsDisposable = this.registerDisposable(d);
|
|
526
|
-
}
|
|
527
|
-
const iv = this.initialValue;
|
|
528
|
-
if (iv) {
|
|
529
|
-
this.value = iv;
|
|
530
|
-
}
|
|
531
|
-
this.updateItems();
|
|
532
|
-
this.dispatchCustomEvent("items-updated", {
|
|
533
|
-
type: "reset",
|
|
534
|
-
items,
|
|
535
|
-
index: 0
|
|
536
|
-
});
|
|
537
|
-
if (this.scrollToSelection) {
|
|
538
|
-
this.bringSelectionIntoView();
|
|
539
|
-
}
|
|
540
|
-
break;
|
|
541
|
-
case "selectedItems":
|
|
542
|
-
(_b = this.selectedItemsDisposable) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
543
|
-
const selectedItems = this.selectedItems;
|
|
544
|
-
const sd = selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.watch(() => {
|
|
545
|
-
this.updateClasses();
|
|
546
|
-
if (this.scrollToSelection) {
|
|
547
|
-
this.bringSelectionIntoView();
|
|
548
|
-
}
|
|
549
|
-
if (this.selectedItem) {
|
|
550
|
-
delete this.initialValue;
|
|
551
|
-
}
|
|
552
|
-
AtomBinder.refreshValue(this, "selectedItem");
|
|
553
|
-
AtomBinder.refreshValue(this, "value");
|
|
554
|
-
AtomBinder.refreshValue(this, "allSelected");
|
|
555
|
-
this.dispatchCustomEvent("selection-updated", selectedItems);
|
|
556
|
-
});
|
|
557
|
-
if (sd) {
|
|
558
|
-
this.selectedItemsDisposable = this.registerDisposable(sd);
|
|
559
|
-
}
|
|
560
|
-
this.updateClasses();
|
|
561
|
-
this.dispatchCustomEvent("selection-updated", selectedItems);
|
|
562
|
-
AtomBinder.refreshValue(this, "allSelected");
|
|
563
|
-
break;
|
|
564
|
-
case "itemRenderer":
|
|
565
|
-
case "watch":
|
|
566
|
-
this.updateItems();
|
|
567
|
-
break;
|
|
568
|
-
case "visibilityFilter":
|
|
569
|
-
this.updateVisibility();
|
|
570
|
-
break;
|
|
571
|
-
case "header":
|
|
572
|
-
case "headerRenderer":
|
|
573
|
-
this.updateHeaderFooter("header", this.headerPresenter, this.header, this.headerRenderer, true);
|
|
574
|
-
break;
|
|
575
|
-
case "footer":
|
|
576
|
-
case "footerRenderer":
|
|
577
|
-
this.updateHeaderFooter("footer", this.footerPresenter, this.footer, this.footerRenderer);
|
|
578
|
-
break;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
bringSelectionIntoView(force) {
|
|
582
|
-
if (force) {
|
|
583
|
-
const selection = this.selectedItem;
|
|
584
|
-
if (selection) {
|
|
585
|
-
const element = this.elementForItem(selection);
|
|
586
|
-
element === null || element === void 0 ? void 0 : element.scrollIntoView();
|
|
587
|
-
}
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
if (this.bringIntoViewId) {
|
|
591
|
-
clearTimeout(this.bringIntoViewId);
|
|
592
|
-
}
|
|
593
|
-
this.bringIntoViewId = setTimeout(() => {
|
|
594
|
-
clearTimeout(this.bringIntoViewId);
|
|
595
|
-
this.bringIntoViewId = undefined;
|
|
596
|
-
this.bringSelectionIntoView(true);
|
|
597
|
-
}, 100);
|
|
598
|
-
}
|
|
599
|
-
forEach(action, container) {
|
|
600
|
-
var _a;
|
|
601
|
-
container !== null && container !== void 0 ? container : container = (_a = this.itemsPresenter) !== null && _a !== void 0 ? _a : this.element;
|
|
602
|
-
const items = this.items;
|
|
603
|
-
let start = getFirstChild(container);
|
|
604
|
-
while (start) {
|
|
605
|
-
const index = start.dataset.itemIndex;
|
|
606
|
-
const item = items[~~index];
|
|
607
|
-
action(item, start);
|
|
608
|
-
start = start.nextElementSibling;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
*any(fx, itemSelector, container) {
|
|
612
|
-
var _a;
|
|
613
|
-
container !== null && container !== void 0 ? container : container = (_a = this.itemsPresenter) !== null && _a !== void 0 ? _a : this.element;
|
|
614
|
-
const items = this.items;
|
|
615
|
-
let node = getFirstChild(container);
|
|
616
|
-
while (node) {
|
|
617
|
-
const index = node.dataset.itemIndex;
|
|
618
|
-
const item = items[~~index];
|
|
619
|
-
let element = node;
|
|
620
|
-
if (itemSelector) {
|
|
621
|
-
element = element.querySelector(itemSelector);
|
|
622
|
-
}
|
|
623
|
-
const ie = {
|
|
624
|
-
item,
|
|
625
|
-
element
|
|
626
|
-
};
|
|
627
|
-
if (fx) {
|
|
628
|
-
if (fx(item)) {
|
|
629
|
-
yield ie;
|
|
630
|
-
}
|
|
631
|
-
continue;
|
|
632
|
-
}
|
|
633
|
-
yield ie;
|
|
634
|
-
node = node.nextElementSibling;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
*all(container) {
|
|
638
|
-
var _a;
|
|
639
|
-
container !== null && container !== void 0 ? container : container = (_a = this.itemsPresenter) !== null && _a !== void 0 ? _a : this.element;
|
|
640
|
-
const items = this.items;
|
|
641
|
-
let element = getFirstChild(container);
|
|
642
|
-
while (element) {
|
|
643
|
-
const index = element.dataset.itemIndex;
|
|
644
|
-
const item = items[~~index];
|
|
645
|
-
yield {
|
|
646
|
-
item,
|
|
647
|
-
element
|
|
648
|
-
};
|
|
649
|
-
element = element.nextElementSibling;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
elementForItem(itemToFind, container) {
|
|
653
|
-
var _a;
|
|
654
|
-
container !== null && container !== void 0 ? container : container = (_a = this.itemsPresenter) !== null && _a !== void 0 ? _a : this.element;
|
|
655
|
-
const items = this.items;
|
|
656
|
-
let element = getFirstChild(container);
|
|
657
|
-
while (element) {
|
|
658
|
-
const index = element.dataset.itemIndex;
|
|
659
|
-
const item = items[~~index];
|
|
660
|
-
if (item === itemToFind) {
|
|
661
|
-
return element;
|
|
662
|
-
}
|
|
663
|
-
element = element.nextElementSibling;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
refreshItem(item, fx, index = -1) {
|
|
667
|
-
if (index === -1) {
|
|
668
|
-
index = this.items.indexOf(item);
|
|
669
|
-
}
|
|
670
|
-
if (fx === null || fx === void 0 ? void 0 : fx.then) {
|
|
671
|
-
const finalize = () => {
|
|
672
|
-
this.refreshItem(item, undefined, index);
|
|
673
|
-
};
|
|
674
|
-
fx.then(finalize, finalize);
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
this.updatePartial("set", index, item);
|
|
678
|
-
}
|
|
679
|
-
updatePartial(key, index, item, container) {
|
|
680
|
-
var _a, _b, _c, _d, _e, _f;
|
|
681
|
-
const items = this.items;
|
|
682
|
-
if (!items) {
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
const ir = this.itemRenderer;
|
|
686
|
-
if (!ir) {
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
container !== null && container !== void 0 ? container : container = (_a = this.itemsPresenter) !== null && _a !== void 0 ? _a : this.element;
|
|
690
|
-
let start = getFirstChild(container);
|
|
691
|
-
let ei;
|
|
692
|
-
while (start) {
|
|
693
|
-
ei = ~~start.dataset.itemIndex;
|
|
694
|
-
if (ei === index) {
|
|
695
|
-
break;
|
|
696
|
-
}
|
|
697
|
-
start = start.nextElementSibling;
|
|
698
|
-
}
|
|
699
|
-
if (key !== "add" && !start) {
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
const vp = (_b = this.valuePath) !== null && _b !== void 0 ? _b : it => it;
|
|
703
|
-
const si = ((_c = this.selectedItems) !== null && _c !== void 0 ? _c : []).map(vp);
|
|
704
|
-
const isRemove = key === "remove";
|
|
705
|
-
if (isRemove || key === "set") {
|
|
706
|
-
const current = start;
|
|
707
|
-
start = start.nextElementSibling;
|
|
708
|
-
const ac = current.atomControl;
|
|
709
|
-
if (ac) {
|
|
710
|
-
ac.dispose();
|
|
711
|
-
} else {
|
|
712
|
-
this.unbind(current);
|
|
713
|
-
this.unbindEvent(current);
|
|
714
|
-
}
|
|
715
|
-
current.remove();
|
|
716
|
-
}
|
|
717
|
-
if (!isRemove) {
|
|
718
|
-
const en = ir(item, index, this);
|
|
719
|
-
const ea = (_d = en.attributes) !== null && _d !== void 0 ? _d : en.attributes = {};
|
|
720
|
-
const v = vp(item);
|
|
721
|
-
const e = document.createElement((_f = (_e = ea.for) !== null && _e !== void 0 ? _e : en.name) !== null && _f !== void 0 ? _f : "div");
|
|
722
|
-
e.dataset.itemIndex = (index++).toString();
|
|
723
|
-
e.dataset.selectedItem = si.indexOf(v) !== -1 ? "true" : "false";
|
|
724
|
-
if (this.enableDragDrop) {
|
|
725
|
-
updateDragDrop(e);
|
|
726
|
-
}
|
|
727
|
-
if (start) {
|
|
728
|
-
container.insertBefore(e, start);
|
|
729
|
-
} else {
|
|
730
|
-
container.appendChild(e);
|
|
731
|
-
}
|
|
732
|
-
this.render(en, e, this);
|
|
733
|
-
}
|
|
734
|
-
while (start) {
|
|
735
|
-
const ci = items[index];
|
|
736
|
-
const cv = vp(ci);
|
|
737
|
-
start.dataset.itemIndex = (index++).toString();
|
|
738
|
-
start.dataset.selectedItem = si.indexOf(cv) !== -1 ? "true" : "false";
|
|
739
|
-
start = start.nextElementSibling;
|
|
740
|
-
}
|
|
741
|
-
this.onPropertyChanged("footer");
|
|
742
|
-
}
|
|
743
|
-
updateItems(container, force) {
|
|
744
|
-
var _a, _b, _c, _d, _e, _f;
|
|
745
|
-
if (this.deferUpdates && !force) {
|
|
746
|
-
if (this.deferredUpdateId) {
|
|
747
|
-
return;
|
|
748
|
-
}
|
|
749
|
-
this.deferredUpdateId = setTimeout(() => {
|
|
750
|
-
this.deferredUpdateId = 0;
|
|
751
|
-
this.updateItems(container, true);
|
|
752
|
-
}, 1);
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
container !== null && container !== void 0 ? container : container = (_a = this.itemsPresenter) !== null && _a !== void 0 ? _a : this.element;
|
|
756
|
-
if (!container) {
|
|
757
|
-
return;
|
|
758
|
-
}
|
|
759
|
-
disposeChildren(this, container);
|
|
760
|
-
this.onPropertyChanged("header");
|
|
761
|
-
const ir = this.itemRenderer;
|
|
762
|
-
if (!ir) {
|
|
763
|
-
this.onPropertyChanged("footer");
|
|
764
|
-
return;
|
|
765
|
-
}
|
|
766
|
-
const items = this.items;
|
|
767
|
-
if (!items) {
|
|
768
|
-
this.onPropertyChanged("footer");
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
const vp = (_b = this.valuePath) !== null && _b !== void 0 ? _b : it => it;
|
|
772
|
-
const si = ((_c = this.selectedItems) !== null && _c !== void 0 ? _c : []).map(vp);
|
|
773
|
-
let i = 0;
|
|
774
|
-
for (const iterator of items) {
|
|
775
|
-
const index = i++;
|
|
776
|
-
const e = ir(iterator, index, this);
|
|
777
|
-
const ea = (_d = e.attributes) !== null && _d !== void 0 ? _d : e.attributes = {};
|
|
778
|
-
const v = vp(iterator);
|
|
779
|
-
const element = document.createElement((_f = (_e = ea.for) !== null && _e !== void 0 ? _e : e.name) !== null && _f !== void 0 ? _f : "div");
|
|
780
|
-
element.dataset.itemIndex = index.toString();
|
|
781
|
-
element.dataset.selectedItem = si.indexOf(v) !== -1 ? "true" : "false";
|
|
782
|
-
this.render(e, element, this);
|
|
783
|
-
if (this.enableDragDrop) {
|
|
784
|
-
updateDragDrop(element);
|
|
785
|
-
}
|
|
786
|
-
container.appendChild(element);
|
|
787
|
-
}
|
|
788
|
-
this.onPropertyChanged("footer");
|
|
789
|
-
}
|
|
790
|
-
preCreate() {
|
|
791
|
-
this.element.setAttribute("data-click-event", "item-click");
|
|
792
|
-
}
|
|
793
|
-
dispatchCustomEvent(type, detail) {
|
|
794
|
-
var _a;
|
|
795
|
-
type = StringHelper.fromHyphenToCamel(type);
|
|
796
|
-
(_a = this.element) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new CustomEvent(type, {
|
|
797
|
-
detail,
|
|
798
|
-
bubbles: false,
|
|
799
|
-
cancelable: true
|
|
800
|
-
}));
|
|
801
|
-
}
|
|
802
|
-
updateClasses() {
|
|
803
|
-
var _a, _b, _c;
|
|
804
|
-
const container = (_a = this.itemsPresenter) !== null && _a !== void 0 ? _a : this.element;
|
|
805
|
-
const items = this.items;
|
|
806
|
-
let element = getFirstChild(container);
|
|
807
|
-
const vp = (_b = this.valuePath) !== null && _b !== void 0 ? _b : i => i;
|
|
808
|
-
const si = ((_c = this.selectedItems) !== null && _c !== void 0 ? _c : []).map(vp);
|
|
809
|
-
while (element) {
|
|
810
|
-
const index = ~~element.dataset.itemIndex;
|
|
811
|
-
const item = items[index];
|
|
812
|
-
const v = vp(item);
|
|
813
|
-
element.dataset.selectedItem = si.indexOf(v) !== -1 ? "true" : "false";
|
|
814
|
-
element = element.nextElementSibling;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
updateVisibility() {
|
|
818
|
-
var _a, _b;
|
|
819
|
-
const container = (_a = this.itemsPresenter) !== null && _a !== void 0 ? _a : this.element;
|
|
820
|
-
const items = this.items;
|
|
821
|
-
let element = container.firstElementChild;
|
|
822
|
-
const vf = (_b = this.visibilityFilter) !== null && _b !== void 0 ? _b : MatchTrue;
|
|
823
|
-
while (element) {
|
|
824
|
-
const index = ~~element.dataset.itemIndex;
|
|
825
|
-
const item = items[index];
|
|
826
|
-
if (vf(item)) {
|
|
827
|
-
element.removeAttribute("data-ui-display");
|
|
828
|
-
} else {
|
|
829
|
-
element.dataset.uiDisplay = "none";
|
|
830
|
-
}
|
|
831
|
-
element = element.nextElementSibling;
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
updateHeaderFooter(name, presenter, item, itemRenderer, insert) {
|
|
835
|
-
var _a, _b, _c, _d;
|
|
836
|
-
presenter !== null && presenter !== void 0 ? presenter : presenter = (_a = this.itemsPresenter) !== null && _a !== void 0 ? _a : this.itemsPresenter = this.element;
|
|
837
|
-
if (!presenter) {
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
let current;
|
|
841
|
-
if (insert) {
|
|
842
|
-
current = presenter.firstElementChild;
|
|
843
|
-
while (current && current.dataset[name] !== name) {
|
|
844
|
-
current = current.nextElementSibling;
|
|
845
|
-
}
|
|
846
|
-
} else {
|
|
847
|
-
current = presenter.lastElementChild;
|
|
848
|
-
while (current && current.dataset[name] !== name) {
|
|
849
|
-
current = current.previousElementSibling;
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
if (current) {
|
|
853
|
-
disposeChild(this, current);
|
|
854
|
-
}
|
|
855
|
-
if (!(item && itemRenderer)) {
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
const node = itemRenderer(item);
|
|
859
|
-
const element = document.createElement((_d = (_c = (_b = node.attributes) === null || _b === void 0 ? void 0 : _b.for) !== null && _c !== void 0 ? _c : node.name) !== null && _d !== void 0 ? _d : "div");
|
|
860
|
-
element.dataset[name] = name;
|
|
861
|
-
this.render(node, element, this);
|
|
862
|
-
if (insert) {
|
|
863
|
-
presenter.insertBefore(element, presenter.firstElementChild);
|
|
864
|
-
} else {
|
|
865
|
-
presenter.appendChild(element);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
dispatchHeaderFooterEvent(eventName, type, originalTarget) {
|
|
869
|
-
const detail = this[type];
|
|
870
|
-
const ce = new CustomEvent(eventName !== null && eventName !== void 0 ? eventName : `${type}Click`, {
|
|
871
|
-
detail,
|
|
872
|
-
bubbles: this.bubbleEvents,
|
|
873
|
-
cancelable: true
|
|
874
|
-
});
|
|
875
|
-
originalTarget.dispatchEvent(ce);
|
|
876
|
-
if (!ce.defaultPrevented) {
|
|
877
|
-
this.onPropertyChanged(type);
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
dispatchItemEvent(eventName, item, recreate, originalTarget, nestedItem) {
|
|
881
|
-
const ce = new CustomEvent(eventName !== null && eventName !== void 0 ? eventName : "itemClick", {
|
|
882
|
-
detail: nestedItem !== null && nestedItem !== void 0 ? nestedItem : item,
|
|
883
|
-
bubbles: this.bubbleEvents,
|
|
884
|
-
cancelable: true
|
|
885
|
-
});
|
|
886
|
-
originalTarget.dispatchEvent(ce);
|
|
887
|
-
if (recreate && ce.executed && !ce.defaultPrevented) {
|
|
888
|
-
this.refreshItem(item, ce.promise);
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
dispatchClickEvent(e, data) {
|
|
892
|
-
var _a;
|
|
893
|
-
let {
|
|
894
|
-
clickEvent = "itemClick",
|
|
895
|
-
recreate,
|
|
896
|
-
header,
|
|
897
|
-
footer,
|
|
898
|
-
itemIndex,
|
|
899
|
-
itemPath
|
|
900
|
-
} = data;
|
|
901
|
-
clickEvent = clickEvent.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
902
|
-
if (header) {
|
|
903
|
-
this.dispatchHeaderFooterEvent(clickEvent, header, e.target);
|
|
904
|
-
return;
|
|
905
|
-
}
|
|
906
|
-
if (footer) {
|
|
907
|
-
this.dispatchHeaderFooterEvent(clickEvent, header, e.target);
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
if (itemIndex === void 0 || itemIndex === null) {
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
|
-
let index = ~~itemIndex;
|
|
914
|
-
const item = this.items[index];
|
|
915
|
-
if (clickEvent === "itemSelect" || clickEvent === "itemDeselect") {
|
|
916
|
-
const si = (_a = this.selectedItems) !== null && _a !== void 0 ? _a : this.selectedItems = [];
|
|
917
|
-
if (si) {
|
|
918
|
-
index = si.indexOf(item);
|
|
919
|
-
if (index === -1) {
|
|
920
|
-
if (this.allowMultipleSelection) {
|
|
921
|
-
si.add(item);
|
|
922
|
-
} else {
|
|
923
|
-
si.set(0, item);
|
|
924
|
-
}
|
|
925
|
-
} else {
|
|
926
|
-
si.removeAt(index);
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
if (item) {
|
|
931
|
-
if (itemPath) {
|
|
932
|
-
if (/^[\{\"}]/.test(itemPath)) {
|
|
933
|
-
this.dispatchItemEvent(clickEvent, item, recreate, e.target, JSON.parse(itemPath));
|
|
934
|
-
return;
|
|
935
|
-
}
|
|
936
|
-
let nestedItem = {};
|
|
937
|
-
const all = itemPath.split(",");
|
|
938
|
-
for (const iterator of all) {
|
|
939
|
-
let [name, paths] = iterator.split(/\=|\:/);
|
|
940
|
-
if (paths === void 0) {
|
|
941
|
-
if (all.length > 1) {
|
|
942
|
-
throw new Error("Invalid path, please use name=path format");
|
|
943
|
-
}
|
|
944
|
-
paths = name;
|
|
945
|
-
}
|
|
946
|
-
let start = item;
|
|
947
|
-
for (const path of paths.split(".")) {
|
|
948
|
-
if (path === "$") {
|
|
949
|
-
start = item;
|
|
950
|
-
continue;
|
|
951
|
-
}
|
|
952
|
-
start = start[path];
|
|
953
|
-
}
|
|
954
|
-
if (all.length === 1) {
|
|
955
|
-
nestedItem = start;
|
|
956
|
-
break;
|
|
957
|
-
}
|
|
958
|
-
nestedItem[name] = start;
|
|
959
|
-
}
|
|
960
|
-
this.dispatchItemEvent(clickEvent, item, recreate, e.target, nestedItem);
|
|
961
|
-
return;
|
|
962
|
-
}
|
|
963
|
-
this.dispatchItemEvent(clickEvent, item, recreate, e.target);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
__decorate([BindableProperty, __metadata("design:type", Boolean)], AtomRepeater.prototype, "allowMultipleSelection", void 0);
|
|
968
|
-
__decorate([BindableProperty, __metadata("design:type", Array)], AtomRepeater.prototype, "selectedItems", void 0);
|
|
969
|
-
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "itemsPresenter", void 0);
|
|
970
|
-
__decorate([BindableProperty, __metadata("design:type", Array)], AtomRepeater.prototype, "items", void 0);
|
|
971
|
-
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "watch", void 0);
|
|
972
|
-
__decorate([BindableProperty, __metadata("design:type", Function)], AtomRepeater.prototype, "visibilityFilter", void 0);
|
|
973
|
-
__decorate([BindableProperty, __metadata("design:type", Function)], AtomRepeater.prototype, "enableFunc", void 0);
|
|
974
|
-
__decorate([BindableProperty, __metadata("design:type", Function)], AtomRepeater.prototype, "itemRenderer", void 0);
|
|
975
|
-
__decorate([BindableProperty, __metadata("design:type", Function)], AtomRepeater.prototype, "valuePath", void 0);
|
|
976
|
-
__decorate([BindableProperty, __metadata("design:type", Function)], AtomRepeater.prototype, "comparer", void 0);
|
|
977
|
-
__decorate([BindableProperty, __metadata("design:type", Boolean)], AtomRepeater.prototype, "deferUpdates", void 0);
|
|
978
|
-
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "header", void 0);
|
|
979
|
-
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "headerRenderer", void 0);
|
|
980
|
-
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "footer", void 0);
|
|
981
|
-
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "footerRenderer", void 0);
|
|
982
|
-
__decorate([BindableProperty, __metadata("design:type", Object)], AtomRepeater.prototype, "enableDragDrop", void 0);
|
|
983
|
-
__decorate([WatchProperty, __metadata("design:type", Object), __metadata("design:paramtypes", [])], AtomRepeater.prototype, "allSelected", null);
|
|
984
|
-
hoverItem = {
|
|
985
|
-
repeater: null,
|
|
986
|
-
target: null,
|
|
987
|
-
item: null,
|
|
988
|
-
placeholder: null
|
|
989
|
-
};
|
|
990
|
-
document.body.addEventListener("dragstart", e => {
|
|
991
|
-
const {
|
|
992
|
-
target
|
|
993
|
-
} = e;
|
|
994
|
-
if (target.draggable) {
|
|
995
|
-
const ri = getParentRepeaterItem(target);
|
|
996
|
-
if (!ri) {
|
|
997
|
-
return;
|
|
998
|
-
}
|
|
999
|
-
const [type, repeater, item, index] = ri;
|
|
1000
|
-
if (!repeater || !repeater.enableDragDrop) {
|
|
1001
|
-
return;
|
|
1002
|
-
}
|
|
1003
|
-
const placeholder = document.createElement("div");
|
|
1004
|
-
placeholder.style.width = target.offsetWidth + "px";
|
|
1005
|
-
placeholder.style.height = target.offsetHeight + "px";
|
|
1006
|
-
placeholder.style.backgroundColor = Colors.lightGray.toString();
|
|
1007
|
-
placeholder.style.border = "solid 1px gray";
|
|
1008
|
-
placeholder.style.borderRadius = "10px";
|
|
1009
|
-
hoverItem = {
|
|
1010
|
-
repeater,
|
|
1011
|
-
target,
|
|
1012
|
-
item,
|
|
1013
|
-
placeholder
|
|
1014
|
-
};
|
|
1015
|
-
e.dataTransfer.dropEffect = "move";
|
|
1016
|
-
setTimeout(() => {
|
|
1017
|
-
target.style.display = "none";
|
|
1018
|
-
target.parentElement.insertBefore(placeholder, target);
|
|
1019
|
-
}, 0);
|
|
1020
|
-
}
|
|
1021
|
-
});
|
|
1022
|
-
document.body.addEventListener("dragend", e => {
|
|
1023
|
-
var _a, _b;
|
|
1024
|
-
if (!(hoverItem === null || hoverItem === void 0 ? void 0 : hoverItem.placeholder)) {
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
const {
|
|
1028
|
-
item,
|
|
1029
|
-
placeholder,
|
|
1030
|
-
repeater
|
|
1031
|
-
} = hoverItem;
|
|
1032
|
-
let start = placeholder;
|
|
1033
|
-
let index = -1;
|
|
1034
|
-
while (start) {
|
|
1035
|
-
const itemIndex = (_b = (_a = start.previousElementSibling) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.itemIndex;
|
|
1036
|
-
if (itemIndex !== void 0) {
|
|
1037
|
-
index = ~~itemIndex;
|
|
1038
|
-
}
|
|
1039
|
-
if (start.parentElement.atomControl) {
|
|
1040
|
-
break;
|
|
1041
|
-
}
|
|
1042
|
-
start = start.parentElement;
|
|
1043
|
-
}
|
|
1044
|
-
const targetRepeater = start.parentElement.atomControl;
|
|
1045
|
-
placeholder.remove();
|
|
1046
|
-
hoverItem.placeholder = null;
|
|
1047
|
-
repeater.items.remove(item);
|
|
1048
|
-
index++;
|
|
1049
|
-
const ce = new CustomEvent("itemDropped", {
|
|
1050
|
-
detail: {
|
|
1051
|
-
item,
|
|
1052
|
-
index
|
|
1053
|
-
}
|
|
1054
|
-
});
|
|
1055
|
-
if (ce.defaultPrevented) {
|
|
1056
|
-
return;
|
|
1057
|
-
}
|
|
1058
|
-
const {
|
|
1059
|
-
detail
|
|
1060
|
-
} = ce;
|
|
1061
|
-
targetRepeater.items.insert(detail.index, detail.item);
|
|
1062
|
-
});
|
|
1063
|
-
dragOver = e => {
|
|
1064
|
-
if (hoverItem) {
|
|
1065
|
-
const {
|
|
1066
|
-
placeholder
|
|
1067
|
-
} = hoverItem;
|
|
1068
|
-
if (e.target === placeholder) {
|
|
1069
|
-
return;
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
const ri = getParentRepeaterItem(e.target);
|
|
1073
|
-
if (!ri) {
|
|
1074
|
-
return;
|
|
1075
|
-
}
|
|
1076
|
-
const [type, repeater, item, index, target] = ri;
|
|
1077
|
-
if (!repeater) {
|
|
1078
|
-
return;
|
|
1079
|
-
}
|
|
1080
|
-
if (hoverItem) {
|
|
1081
|
-
const {
|
|
1082
|
-
placeholder
|
|
1083
|
-
} = hoverItem;
|
|
1084
|
-
e.preventDefault();
|
|
1085
|
-
const mp = {
|
|
1086
|
-
x: e.clientX,
|
|
1087
|
-
y: e.clientY
|
|
1088
|
-
};
|
|
1089
|
-
const isBefore = (co, n) => n.x <= co.x + co.width * 0.3 || n.y <= co.y + co.height * 0.3;
|
|
1090
|
-
const isAfter = (co, n) => n.x >= co.x + co.width * 0.7 || n.y >= co.y + co.height * 0.7;
|
|
1091
|
-
const targetBounds = target.getBoundingClientRect();
|
|
1092
|
-
if (isAfter(targetBounds, mp)) {
|
|
1093
|
-
const next = target.nextElementSibling;
|
|
1094
|
-
if (next === placeholder) {
|
|
1095
|
-
return;
|
|
1096
|
-
}
|
|
1097
|
-
placeholder.remove();
|
|
1098
|
-
target.insertAdjacentElement("afterend", placeholder);
|
|
1099
|
-
return;
|
|
1100
|
-
}
|
|
1101
|
-
if (isBefore(targetBounds, mp)) {
|
|
1102
|
-
const previous = target.previousElementSibling;
|
|
1103
|
-
if (previous === placeholder) {
|
|
1104
|
-
return;
|
|
1105
|
-
}
|
|
1106
|
-
placeholder.remove();
|
|
1107
|
-
target.insertAdjacentElement("beforebegin", placeholder);
|
|
1108
|
-
}
|
|
1109
|
-
return;
|
|
1110
|
-
}
|
|
1111
|
-
};
|
|
1112
|
-
document.body.addEventListener("dragover", dragOver);
|
|
1113
|
-
document.body.addEventListener("dragenter", dragOver);
|
|
1114
|
-
}
|
|
1115
|
-
};
|
|
1116
|
-
});
|
|
1
|
+
System.register(["tslib","@web-atoms/core/dist/core/AtomBinder","@web-atoms/core/dist/core/Bind","@web-atoms/core/dist/core/BindableProperty","@web-atoms/core/dist/core/Colors","@web-atoms/core/dist/core/StringHelper","@web-atoms/core/dist/core/WatchProperty","@web-atoms/core/dist/core/XNode","@web-atoms/core/dist/style/StyleRule","@web-atoms/core/dist/web/controls/AtomControl","@web-atoms/core/dist/web/services/PopupService","@web-atoms/core/dist/web/styles/CSS","./InlinePopup"],function(_export,_context){"use strict";var __decorate,__metadata,__rest,AtomBinder,Bind,BindableProperty,Colors,StringHelper,WatchProperty,XNode,StyleRule,AtomControl,PopupWindow,CSS,InlinePopup,SelectAllControl,AtomRepeater,popupCSS,getParentRepeaterItem,MatchTrue,MatchFalse,ArrowToString,MatchCaseInsensitive,MatchAnyCaseInsensitive,SameObjectValue,maxHeight,getFirstChild,hoverItem,dragOver;function askSuggestion(items,itemRenderer,match,options){class Suggestions extends PopupWindow{create(){var _a;this.title=(_a=options===null||options===void 0?void 0:options.title)!==null&&_a!==void 0?_a:"Select";this.render(XNode.create("div",{class:popupCSS},XNode.create("input",{type:"search",value:Bind.twoWaysImmediate(()=>this.search),autofocus:true}),XNode.create("div",{class:"items"},XNode.create(AtomRepeater,{class:"presenter",itemRenderer:itemRenderer,visibilityFilter:Bind.oneWay(()=>match(this.search)),eventItemClick:e=>{this.close(e.detail);},items:items}))));}}__decorate([BindableProperty,__metadata("design:type",String)],Suggestions.prototype,"search",void 0);options!==null&&options!==void 0?options:options={};if(typeof options.maximize==="undefined"){if(typeof options.width==="undefined"){options.maxWidth="90%";options.minWidth="300px";}if(typeof options.height==="undefined"){options.height="80%";}}return Suggestions.showModal(options);}function askSuggestionPopup(opener,items,itemRenderer,match,selectedItem){const updateSearch=("search"in opener);const itemsInOpener=("items"in opener);class Suggestions extends InlinePopup{get items(){return itemsInOpener?this.opener.items:items;}onPropertyChanged(name){if(updateSearch&&name==="search"){opener.search=this.search;}super.onPropertyChanged(name);}create(){this.anchorItem=selectedItem;this.opener=opener;if(this.opener.search){this.search=this.opener.search;}if(selectedItem){this.anchorIndex=items.indexOf(selectedItem);}const disableSearch=opener.disableSearch;if(itemsInOpener){this.render(XNode.create("div",{"data-suggestion-popup":"suggestion-popup"},!disableSearch&&XNode.create("input",{type:"search",value:Bind.twoWaysImmediate(()=>this.search),eventKeydown:e=>this.onKey(e),autofocus:true}),XNode.create("div",{class:"items"},XNode.create(AtomRepeater,{class:"presenter",selectedItem:Bind.oneWay(()=>this.anchorItem),itemRenderer:itemRenderer,visibilityFilter:Bind.oneWay(()=>match(this.search)),eventItemClick:e=>{this.anchorItem=e.detail;setTimeout(()=>this.close(e.detail),100);},items:Bind.oneWay(()=>this.opener.items)}))));return;}this.render(XNode.create("div",{"data-suggestion-popup":"suggestion-popup"},!disableSearch&&XNode.create("input",{type:"search",value:Bind.twoWaysImmediate(()=>this.search),eventKeydown:e=>this.onKey(e),autofocus:true}),XNode.create("div",{class:"items"},XNode.create(AtomRepeater,{class:"presenter",selectedItem:Bind.oneWay(()=>this.anchorItem),itemRenderer:itemRenderer,visibilityFilter:Bind.oneWay(()=>match(this.search)),scrollToSelection:true,eventItemClick:e=>{this.close(e.detail);},items:items}))));}onKey(e){var _a;const suggested=match?(_a=this.items)===null||_a===void 0?void 0:_a.filter(match(this.search)):this.items;switch(e.key){case"Enter":const anchorItem=this.anchorItem;if(!anchorItem){return;}this.anchorIndex=0;this.close(anchorItem);this.anchorItem=null;this.search="";break;case"ArrowDown":if(suggested){if(!this.anchorItem){this.anchorIndex=0;}else{if(this.anchorIndex<suggested.length-1){this.anchorIndex++;}}this.anchorItem=suggested[this.anchorIndex];}break;case"ArrowUp":if(suggested){if(!this.anchorItem){return;}if(this.anchorIndex){this.anchorIndex--;}this.anchorItem=suggested[this.anchorIndex];}break;}}}__decorate([BindableProperty,__metadata("design:type",String)],Suggestions.prototype,"search",void 0);return Suggestions.showControl(opener);}function SelectorCheckBox(_a,...nodes){var{text,icon="far fa-square",iconSelected="fas fa-check-square"}=_a,a=__rest(_a,["text","icon","iconSelected"]);if(text){return XNode.create("label",null,XNode.create("i",{class:icon,"data-click-event":"item-select"}),XNode.create("i",{class:iconSelected,"data-click-event":"item-deselect"}),XNode.create("span",{"data-no-wrap":"true",text:text}),...nodes);}return XNode.create("label",null,XNode.create("i",{class:icon,"data-click-event":"item-select"}),XNode.create("i",{class:iconSelected,"data-click-event":"item-deselect"}),...nodes);}function SelectAll(_a,...nodes){var{text="Select All",icon="far fa-square",iconSelected="fas fa-check-square"}=_a,a=__rest(_a,["text","icon","iconSelected"]);if(text){return XNode.create(SelectAllControl,Object.assign({for:"label"},a),XNode.create("i",{class:icon,"data-ui-type":"item-select"}),XNode.create("i",{class:iconSelected,"data-ui-type":"item-deselect"}),XNode.create("span",{"data-no-wrap":"true",text:text}));}return XNode.create(SelectAllControl,Object.assign({for:"label"},a),XNode.create("i",{class:icon,"data-ui-type":"item-select"}),XNode.create("i",{class:iconSelected,"data-ui-type":"item-deselect"}),...nodes);}function disposeChildren(owner,e){if(!e){return;}let s=e.firstElementChild;while(s){const c=s;s=s.nextElementSibling;const ac=c.atomControl;if(ac){ac.dispose();continue;}disposeChildren(owner,c);owner.unbind(c);owner.unbindEvent(c);}e.innerHTML="";}function disposeChild(owner,e){const ac=e.atomControl;if(ac){ac.dispose();return;}disposeChildren(owner,e);owner.unbind(e);owner.unbindEvent(e);e.remove();}function defaultComparer(left,right){if(left&&right){if(left instanceof Date){if(right instanceof Date){return left.getTime()===right.getTime();}return false;}}return left===right;}function updateDragDrop(e,force=false){if(!e){return;}if(force){e.draggable=false;}else{force=e.draggable;}e=e.firstElementChild;while(e){updateDragDrop(e,force);e=e.nextElementSibling;}}_export({askSuggestion:askSuggestion,askSuggestionPopup:askSuggestionPopup,SelectorCheckBox:SelectorCheckBox,SelectAll:SelectAll,disposeChildren:disposeChildren,disposeChild:disposeChild,defaultComparer:defaultComparer,default:void 0});return{setters:[function(_tslib){__decorate=_tslib.__decorate;__metadata=_tslib.__metadata;__rest=_tslib.__rest;},function(_webAtomsCoreDistCoreAtomBinder){AtomBinder=_webAtomsCoreDistCoreAtomBinder.AtomBinder;},function(_webAtomsCoreDistCoreBind){Bind=_webAtomsCoreDistCoreBind.default;},function(_webAtomsCoreDistCoreBindableProperty){BindableProperty=_webAtomsCoreDistCoreBindableProperty.BindableProperty;},function(_webAtomsCoreDistCoreColors){Colors=_webAtomsCoreDistCoreColors.default;},function(_webAtomsCoreDistCoreStringHelper){StringHelper=_webAtomsCoreDistCoreStringHelper.StringHelper;},function(_webAtomsCoreDistCoreWatchProperty){WatchProperty=_webAtomsCoreDistCoreWatchProperty.default;},function(_webAtomsCoreDistCoreXNode){XNode=_webAtomsCoreDistCoreXNode.default;},function(_webAtomsCoreDistStyleStyleRule){StyleRule=_webAtomsCoreDistStyleStyleRule.default;},function(_webAtomsCoreDistWebControlsAtomControl){AtomControl=_webAtomsCoreDistWebControlsAtomControl.AtomControl;},function(_webAtomsCoreDistWebServicesPopupService){PopupWindow=_webAtomsCoreDistWebServicesPopupService.PopupWindow;},function(_webAtomsCoreDistWebStylesCSS){CSS=_webAtomsCoreDistWebStylesCSS.default;},function(_InlinePopup){InlinePopup=_InlinePopup.default;}],execute:function(){CSS(StyleRule().display("none"),"[data-ui-display=none]");popupCSS=CSS(StyleRule().minWidth(200).verticalFlexLayout({alignItems:"stretch"}).child(StyleRule(".items").flexStretch().overflow("auto").child(StyleRule(".presenter").child(StyleRule("*").padding(5)).child(StyleRule("[data-selected-item=true]").backgroundColor(Colors.lightGreen)))));_export("getParentRepeaterItem",getParentRepeaterItem=target=>{let eventName;let repeater;let index;let root;while(target){const a=target.atomControl;if(a!==undefined&&a instanceof AtomRepeater){repeater=a;break;}if(index===undefined){const itemIndex=target.dataset.itemIndex;if(typeof itemIndex!=="undefined"){root=target;index=~~itemIndex;}}if(eventName===undefined){const itemClickEvent=target.dataset.clickEvent;if(itemClickEvent){eventName=itemClickEvent.replace(/-([a-z])/g,g=>g[1].toUpperCase());}}target=target.parentElement;}if(index===void 0||repeater===void 0){return undefined;}const item=repeater.items[~~index];return[eventName,repeater,item,index,root];});_export("MatchTrue",MatchTrue=(...a)=>true);_export("MatchFalse",MatchFalse=(...a)=>false);_export("ArrowToString",ArrowToString=item=>{var _a,_b;return(_b=(_a=item.label)===null||_a===void 0?void 0:_a.toString())!==null&&_b!==void 0?_b:item.toString();});_export("MatchCaseInsensitive",MatchCaseInsensitive=(textField=ArrowToString)=>{return s=>{if(!s){return MatchTrue;}const r=StringHelper.createContainsRegExp(s);return item=>r.test(textField(item));};});_export("MatchAnyCaseInsensitive",MatchAnyCaseInsensitive=(textField=ArrowToString)=>{return s=>{if(!s){return MatchTrue;}const r=StringHelper.createContainsAnyWordRegExp(s);return item=>r.test(textField(item));};});_export("SameObjectValue",SameObjectValue=item=>item);maxHeight=window.screen.availHeight/2>250?StyleRule().height("250px"):StyleRule().maxHeight(80);CSS(StyleRule().merge(maxHeight).minWidth(80).verticalFlexLayout({alignItems:"stretch"}).child(StyleRule(".items").flexStretch().overflow("auto").child(StyleRule(".presenter").child(StyleRule("*").padding(5)).child(StyleRule("[data-selected-item=true]").backgroundColor(Colors.lightGreen)))),"*[data-suggestion-popup=suggestion-popup]");CSS(StyleRule().nested(StyleRule("i[data-click-event]").padding(5)).nested(StyleRule("[data-no-wrap=true]").whiteSpace("nowrap")),"*[data-selected-item]");CSS(StyleRule().nested(StyleRule("i[data-click-event=item-select]").padding(5)).displayNone(" i[data-click-event=item-select]"),"*[data-selected-item=true]");CSS(StyleRule().displayNone(" i[data-click-event=item-deselect]"),"*[data-selected-item=false]");CSS(StyleRule().flexLayout({alignItems:"center",justifyContent:"flex-start"}).margin(0).nested(StyleRule("i[data-ui-type]").padding(5)).nested(StyleRule("[data-no-wrap=true]").whiteSpace("nowrap")).displayNone("[data-is-selected=true] i[data-ui-type=item-select]").displayNone("[data-is-selected=false] i[data-ui-type=item-deselect]"),"*[data-select-all=select-all]");SelectAllControl=class SelectAllControl extends AtomControl{preCreate(){this.element.dataset.selectAll="select-all";this.items=[];this.selectedItems=[];this.render(XNode.create(SelectAllControl,{"data-is-selected":Bind.oneWay(()=>this.items.length>0&&this.items.length===this.selectedItems.length,false)}));this.bindEvent(this.element,"click",()=>{const si=this.selectedItems;const items=this.items;if(!si){return;}if(!items){return;}if(items.length===0){return;}if(items.length===si.length){si.clear();}else{si.length=0;si.push(...items);si.refresh();}});}};__decorate([BindableProperty,__metadata("design:type",Array)],SelectAllControl.prototype,"items",void 0);__decorate([BindableProperty,__metadata("design:type",Array)],SelectAllControl.prototype,"selectedItems",void 0);getFirstChild=container=>{let child=container.firstElementChild;while(child&&child.dataset.itemIndex===void 0){child=child.nextElementSibling;}return child;};_export("default",AtomRepeater=class AtomRepeater extends AtomControl{constructor(){super(...arguments);this.bubbleEvents=true;}static from(element){while(element){const{atomControl}=element;if(atomControl instanceof AtomRepeater){return atomControl;}element=element.parentElement;}}set refreshEventScope(v){this.registerDisposable(v.listen(ce=>{this.refreshItem(ce.detail);}));}get allSelected(){const selectedItems=this.selectedItems;const items=this.items;if(!(items&&selectedItems)){return false;}return items.length&&items.length===selectedItems.length;}get value(){var _a;if(this.initialValue!==undefined){return this.initialValue;}const sp=this.selectedItem;if(sp===undefined){return sp;}const vp=(_a=this.valuePath)!==null&&_a!==void 0?_a:SameObjectValue;return vp(sp);}set value(v){var _a,_b;this.initialValue=v;if(!this.items||!this.items.length){AtomBinder.refreshValue(this,"value");return;}const vp=(_a=this.valuePath)!==null&&_a!==void 0?_a:SameObjectValue;const c=(_b=this.comparer)!==null&&_b!==void 0?_b:defaultComparer;const selectedItem=this.items.find(item=>c(vp(item),v));this.selectedItem=selectedItem;delete this.initialValue;}get selectedItem(){var _a;return(_a=this.selectedItems)===null||_a===void 0?void 0:_a[0];}set selectedItem(value){var _a;const si=(_a=this.selectedItems)!==null&&_a!==void 0?_a:this.selectedItems=[];const first=si[0];if(value===first){return;}si.set(0,value);}onPropertyChanged(name){var _a,_b;switch(name){case"items":(_a=this.itemsDisposable)===null||_a===void 0?void 0:_a.dispose();const items=this.items;const d=items===null||items===void 0?void 0:items.watch((target,type,index,item)=>{switch(type){case"add":case"remove":case"set":this.updatePartial(type,index,item);break;default:this.updateItems();break;}this.dispatchCustomEvent("items-updated",{type,items,index});AtomBinder.refreshValue(this,"selectedItem");AtomBinder.refreshValue(this,"value");});if(d){this.itemsDisposable=this.registerDisposable(d);}const iv=this.initialValue;if(iv){this.value=iv;}this.updateItems();this.dispatchCustomEvent("items-updated",{type:"reset",items,index:0});if(this.scrollToSelection){this.bringSelectionIntoView();}break;case"selectedItems":(_b=this.selectedItemsDisposable)===null||_b===void 0?void 0:_b.dispose();const selectedItems=this.selectedItems;const sd=selectedItems===null||selectedItems===void 0?void 0:selectedItems.watch(()=>{this.updateClasses();if(this.scrollToSelection){this.bringSelectionIntoView();}if(this.selectedItem){delete this.initialValue;}AtomBinder.refreshValue(this,"selectedItem");AtomBinder.refreshValue(this,"value");AtomBinder.refreshValue(this,"allSelected");this.dispatchCustomEvent("selection-updated",selectedItems);});if(sd){this.selectedItemsDisposable=this.registerDisposable(sd);}this.updateClasses();this.dispatchCustomEvent("selection-updated",selectedItems);AtomBinder.refreshValue(this,"allSelected");break;case"itemRenderer":case"watch":this.updateItems();break;case"visibilityFilter":this.updateVisibility();break;case"header":case"headerRenderer":this.updateHeaderFooter("header",this.headerPresenter,this.header,this.headerRenderer,true);break;case"footer":case"footerRenderer":this.updateHeaderFooter("footer",this.footerPresenter,this.footer,this.footerRenderer);break;}}bringSelectionIntoView(force){if(force){const selection=this.selectedItem;if(selection){const element=this.elementForItem(selection);element===null||element===void 0?void 0:element.scrollIntoView();}return;}if(this.bringIntoViewId){clearTimeout(this.bringIntoViewId);}this.bringIntoViewId=setTimeout(()=>{clearTimeout(this.bringIntoViewId);this.bringIntoViewId=undefined;this.bringSelectionIntoView(true);},100);}forEach(action,container){var _a;container!==null&&container!==void 0?container:container=(_a=this.itemsPresenter)!==null&&_a!==void 0?_a:this.element;const items=this.items;let start=getFirstChild(container);while(start){const index=start.dataset.itemIndex;const item=items[~~index];action(item,start);start=start.nextElementSibling;}}*any(fx,itemSelector,container){var _a;container!==null&&container!==void 0?container:container=(_a=this.itemsPresenter)!==null&&_a!==void 0?_a:this.element;const items=this.items;let node=getFirstChild(container);while(node){const index=node.dataset.itemIndex;const item=items[~~index];let element=node;if(itemSelector){element=element.querySelector(itemSelector);}const ie={item,element};if(fx){if(fx(item)){yield ie;}continue;}yield ie;node=node.nextElementSibling;}}*all(container){var _a;container!==null&&container!==void 0?container:container=(_a=this.itemsPresenter)!==null&&_a!==void 0?_a:this.element;const items=this.items;let element=getFirstChild(container);while(element){const index=element.dataset.itemIndex;const item=items[~~index];yield{item,element};element=element.nextElementSibling;}}elementForItem(itemToFind,container){var _a;container!==null&&container!==void 0?container:container=(_a=this.itemsPresenter)!==null&&_a!==void 0?_a:this.element;const items=this.items;let element=getFirstChild(container);while(element){const index=element.dataset.itemIndex;const item=items[~~index];if(item===itemToFind){return element;}element=element.nextElementSibling;}}refreshItem(item,fx,index=-1){if(index===-1){index=this.items.indexOf(item);}if(fx===null||fx===void 0?void 0:fx.then){const finalize=()=>{this.refreshItem(item,undefined,index);};fx.then(finalize,finalize);return;}this.updatePartial("set",index,item);}updatePartial(key,index,item,container){var _a,_b,_c,_d,_e,_f;const items=this.items;if(!items){return;}const ir=this.itemRenderer;if(!ir){return;}container!==null&&container!==void 0?container:container=(_a=this.itemsPresenter)!==null&&_a!==void 0?_a:this.element;let start=getFirstChild(container);let ei;while(start){ei=~~start.dataset.itemIndex;if(ei===index){break;}start=start.nextElementSibling;}if(key!=="add"&&!start){return;}const vp=(_b=this.valuePath)!==null&&_b!==void 0?_b:it=>it;const si=((_c=this.selectedItems)!==null&&_c!==void 0?_c:[]).map(vp);const isRemove=key==="remove";if(isRemove||key==="set"){const current=start;start=start.nextElementSibling;const ac=current.atomControl;if(ac){ac.dispose();}else{this.unbind(current);this.unbindEvent(current);}current.remove();}if(!isRemove){const en=ir(item,index,this);const ea=(_d=en.attributes)!==null&&_d!==void 0?_d:en.attributes={};const v=vp(item);const e=document.createElement((_f=(_e=ea.for)!==null&&_e!==void 0?_e:en.name)!==null&&_f!==void 0?_f:"div");e.dataset.itemIndex=(index++).toString();e.dataset.selectedItem=si.indexOf(v)!==-1?"true":"false";if(this.enableDragDrop){updateDragDrop(e);}if(start){container.insertBefore(e,start);}else{container.appendChild(e);}this.render(en,e,this);}while(start){const ci=items[index];const cv=vp(ci);start.dataset.itemIndex=(index++).toString();start.dataset.selectedItem=si.indexOf(cv)!==-1?"true":"false";start=start.nextElementSibling;}this.onPropertyChanged("footer");}updateItems(container,force){var _a,_b,_c,_d,_e,_f;if(this.deferUpdates&&!force){if(this.deferredUpdateId){return;}this.deferredUpdateId=setTimeout(()=>{this.deferredUpdateId=0;this.updateItems(container,true);},1);return;}container!==null&&container!==void 0?container:container=(_a=this.itemsPresenter)!==null&&_a!==void 0?_a:this.element;if(!container){return;}disposeChildren(this,container);this.onPropertyChanged("header");const ir=this.itemRenderer;if(!ir){this.onPropertyChanged("footer");return;}const items=this.items;if(!items){this.onPropertyChanged("footer");return;}const vp=(_b=this.valuePath)!==null&&_b!==void 0?_b:it=>it;const si=((_c=this.selectedItems)!==null&&_c!==void 0?_c:[]).map(vp);let i=0;for(const iterator of items){const index=i++;const e=ir(iterator,index,this);const ea=(_d=e.attributes)!==null&&_d!==void 0?_d:e.attributes={};const v=vp(iterator);const element=document.createElement((_f=(_e=ea.for)!==null&&_e!==void 0?_e:e.name)!==null&&_f!==void 0?_f:"div");element.dataset.itemIndex=index.toString();element.dataset.selectedItem=si.indexOf(v)!==-1?"true":"false";this.render(e,element,this);if(this.enableDragDrop){updateDragDrop(element);}container.appendChild(element);}this.onPropertyChanged("footer");}preCreate(){this.element.setAttribute("data-click-event","item-click");}dispatchCustomEvent(type,detail){var _a;type=StringHelper.fromHyphenToCamel(type);(_a=this.element)===null||_a===void 0?void 0:_a.dispatchEvent(new CustomEvent(type,{detail,bubbles:false,cancelable:true}));}updateClasses(){var _a,_b,_c;const container=(_a=this.itemsPresenter)!==null&&_a!==void 0?_a:this.element;const items=this.items;let element=getFirstChild(container);const vp=(_b=this.valuePath)!==null&&_b!==void 0?_b:i=>i;const si=((_c=this.selectedItems)!==null&&_c!==void 0?_c:[]).map(vp);while(element){const index=~~element.dataset.itemIndex;const item=items[index];const v=vp(item);element.dataset.selectedItem=si.indexOf(v)!==-1?"true":"false";element=element.nextElementSibling;}}updateVisibility(){var _a,_b;const container=(_a=this.itemsPresenter)!==null&&_a!==void 0?_a:this.element;const items=this.items;let element=container.firstElementChild;const vf=(_b=this.visibilityFilter)!==null&&_b!==void 0?_b:MatchTrue;while(element){const index=~~element.dataset.itemIndex;const item=items[index];if(vf(item)){element.removeAttribute("data-ui-display");}else{element.dataset.uiDisplay="none";}element=element.nextElementSibling;}}updateHeaderFooter(name,presenter,item,itemRenderer,insert){var _a,_b,_c,_d;presenter!==null&&presenter!==void 0?presenter:presenter=(_a=this.itemsPresenter)!==null&&_a!==void 0?_a:this.itemsPresenter=this.element;if(!presenter){return;}let current;if(insert){current=presenter.firstElementChild;while(current&¤t.dataset[name]!==name){current=current.nextElementSibling;}}else{current=presenter.lastElementChild;while(current&¤t.dataset[name]!==name){current=current.previousElementSibling;}}if(current){disposeChild(this,current);}if(!(item&&itemRenderer)){return;}const node=itemRenderer(item);const element=document.createElement((_d=(_c=(_b=node.attributes)===null||_b===void 0?void 0:_b.for)!==null&&_c!==void 0?_c:node.name)!==null&&_d!==void 0?_d:"div");element.dataset[name]=name;this.render(node,element,this);if(insert){presenter.insertBefore(element,presenter.firstElementChild);}else{presenter.appendChild(element);}}dispatchHeaderFooterEvent(eventName,type,originalTarget){const detail=this[type];const ce=new CustomEvent(eventName!==null&&eventName!==void 0?eventName:`${type}Click`,{detail,bubbles:this.bubbleEvents,cancelable:true});originalTarget.dispatchEvent(ce);if(!ce.defaultPrevented){this.onPropertyChanged(type);}}dispatchItemEvent(eventName,item,recreate,originalTarget,nestedItem){const ce=new CustomEvent(eventName!==null&&eventName!==void 0?eventName:"itemClick",{detail:nestedItem!==null&&nestedItem!==void 0?nestedItem:item,bubbles:this.bubbleEvents,cancelable:true});originalTarget.dispatchEvent(ce);if(recreate&&ce.executed&&!ce.defaultPrevented){this.refreshItem(item,ce.promise);}}dispatchClickEvent(e,data){var _a;let{clickEvent="itemClick",recreate,header,footer,itemIndex,itemPath}=data;clickEvent=clickEvent.replace(/-([a-z])/g,g=>g[1].toUpperCase());if(header){this.dispatchHeaderFooterEvent(clickEvent,header,e.target);return;}if(footer){this.dispatchHeaderFooterEvent(clickEvent,header,e.target);return;}if(itemIndex===void 0||itemIndex===null){return;}let index=~~itemIndex;const item=this.items[index];if(clickEvent==="itemSelect"||clickEvent==="itemDeselect"){const si=(_a=this.selectedItems)!==null&&_a!==void 0?_a:this.selectedItems=[];if(si){index=si.indexOf(item);if(index===-1){if(this.allowMultipleSelection){si.add(item);}else{si.set(0,item);}}else{si.removeAt(index);}}}if(item){if(itemPath){if(/^[\{\"}]/.test(itemPath)){this.dispatchItemEvent(clickEvent,item,recreate,e.target,JSON.parse(itemPath));return;}let nestedItem={};const all=itemPath.split(",");for(const iterator of all){let[name,paths]=iterator.split(/\=|\:/);if(paths===void 0){if(all.length>1){throw new Error("Invalid path, please use name=path format");}paths=name;}let start=item;for(const path of paths.split(".")){if(path==="$"){start=item;continue;}start=start[path];}if(all.length===1){nestedItem=start;break;}nestedItem[name]=start;}this.dispatchItemEvent(clickEvent,item,recreate,e.target,nestedItem);return;}this.dispatchItemEvent(clickEvent,item,recreate,e.target);}}});__decorate([BindableProperty,__metadata("design:type",Boolean)],AtomRepeater.prototype,"allowMultipleSelection",void 0);__decorate([BindableProperty,__metadata("design:type",Array)],AtomRepeater.prototype,"selectedItems",void 0);__decorate([BindableProperty,__metadata("design:type",Object)],AtomRepeater.prototype,"itemsPresenter",void 0);__decorate([BindableProperty,__metadata("design:type",Array)],AtomRepeater.prototype,"items",void 0);__decorate([BindableProperty,__metadata("design:type",Object)],AtomRepeater.prototype,"watch",void 0);__decorate([BindableProperty,__metadata("design:type",Function)],AtomRepeater.prototype,"visibilityFilter",void 0);__decorate([BindableProperty,__metadata("design:type",Function)],AtomRepeater.prototype,"enableFunc",void 0);__decorate([BindableProperty,__metadata("design:type",Function)],AtomRepeater.prototype,"itemRenderer",void 0);__decorate([BindableProperty,__metadata("design:type",Function)],AtomRepeater.prototype,"valuePath",void 0);__decorate([BindableProperty,__metadata("design:type",Function)],AtomRepeater.prototype,"comparer",void 0);__decorate([BindableProperty,__metadata("design:type",Boolean)],AtomRepeater.prototype,"deferUpdates",void 0);__decorate([BindableProperty,__metadata("design:type",Object)],AtomRepeater.prototype,"header",void 0);__decorate([BindableProperty,__metadata("design:type",Object)],AtomRepeater.prototype,"headerRenderer",void 0);__decorate([BindableProperty,__metadata("design:type",Object)],AtomRepeater.prototype,"footer",void 0);__decorate([BindableProperty,__metadata("design:type",Object)],AtomRepeater.prototype,"footerRenderer",void 0);__decorate([BindableProperty,__metadata("design:type",Object)],AtomRepeater.prototype,"enableDragDrop",void 0);__decorate([WatchProperty,__metadata("design:type",Object),__metadata("design:paramtypes",[])],AtomRepeater.prototype,"allSelected",null);hoverItem={repeater:null,target:null,item:null,placeholder:null};document.body.addEventListener("dragstart",e=>{const{target}=e;if(target.draggable){const ri=getParentRepeaterItem(target);if(!ri){return;}const[type,repeater,item,index]=ri;if(!repeater||!repeater.enableDragDrop){return;}const placeholder=document.createElement("div");placeholder.style.width=target.offsetWidth+"px";placeholder.style.height=target.offsetHeight+"px";placeholder.style.backgroundColor=Colors.lightGray.toString();placeholder.style.border="solid 1px gray";placeholder.style.borderRadius="10px";hoverItem={repeater,target,item,placeholder};e.dataTransfer.dropEffect="move";setTimeout(()=>{target.style.display="none";target.parentElement.insertBefore(placeholder,target);},0);}});document.body.addEventListener("dragend",e=>{var _a,_b;if(!(hoverItem===null||hoverItem===void 0?void 0:hoverItem.placeholder)){return;}const{item,placeholder,repeater}=hoverItem;let start=placeholder;let index=-1;while(start){const itemIndex=(_b=(_a=start.previousElementSibling)===null||_a===void 0?void 0:_a.dataset)===null||_b===void 0?void 0:_b.itemIndex;if(itemIndex!==void 0){index=~~itemIndex;}if(start.parentElement.atomControl){break;}start=start.parentElement;}const targetRepeater=start.parentElement.atomControl;placeholder.remove();hoverItem.placeholder=null;repeater.items.remove(item);index++;const ce=new CustomEvent("itemDropped",{detail:{item,index}});if(ce.defaultPrevented){return;}const{detail}=ce;targetRepeater.items.insert(detail.index,detail.item);});dragOver=e=>{if(hoverItem){const{placeholder}=hoverItem;if(e.target===placeholder){return;}}const ri=getParentRepeaterItem(e.target);if(!ri){return;}const[type,repeater,item,index,target]=ri;if(!repeater){return;}if(hoverItem){const{placeholder}=hoverItem;e.preventDefault();const mp={x:e.clientX,y:e.clientY};const isBefore=(co,n)=>n.x<=co.x+co.width*0.3||n.y<=co.y+co.height*0.3;const isAfter=(co,n)=>n.x>=co.x+co.width*0.7||n.y>=co.y+co.height*0.7;const targetBounds=target.getBoundingClientRect();if(isAfter(targetBounds,mp)){const next=target.nextElementSibling;if(next===placeholder){return;}placeholder.remove();target.insertAdjacentElement("afterend",placeholder);return;}if(isBefore(targetBounds,mp)){const previous=target.previousElementSibling;if(previous===placeholder){return;}placeholder.remove();target.insertAdjacentElement("beforebegin",placeholder);}return;}};document.body.addEventListener("dragover",dragOver);document.body.addEventListener("dragenter",dragOver);}};});
|
|
1117
2
|
//# sourceMappingURL=AtomRepeater.js.map
|