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