jsl-ui 9.28.2 → 9.28.3

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 (170) hide show
  1. package/lib/components/IntervalComponent.d.ts +17 -17
  2. package/lib/components/IntervalComponent.js +65 -68
  3. package/lib/components/auto-suggest/AutoSuggestComponent.d.ts +22 -22
  4. package/lib/components/auto-suggest/AutoSuggestComponent.js +47 -49
  5. package/lib/components/button/ButtonComponent.d.ts +18 -18
  6. package/lib/components/button/ButtonComponent.js +29 -46
  7. package/lib/components/checkbox/CheckBoxComponent.d.ts +28 -28
  8. package/lib/components/checkbox/CheckBoxComponent.js +81 -98
  9. package/lib/components/date/DateComponent.d.ts +32 -32
  10. package/lib/components/date/DateComponent.js +89 -106
  11. package/lib/components/date-range/DateRangeComponent.d.ts +35 -35
  12. package/lib/components/date-range/DateRangeComponent.js +123 -136
  13. package/lib/components/date-time/DateTimeComponent.d.ts +15 -15
  14. package/lib/components/date-time/DateTimeComponent.js +39 -53
  15. package/lib/components/dialog/DialogComponent.d.ts +67 -67
  16. package/lib/components/dialog/DialogComponent.js +198 -251
  17. package/lib/components/drop-down/DropDownComponent.d.ts +27 -27
  18. package/lib/components/drop-down/DropDownComponent.js +60 -74
  19. package/lib/components/expander/ExpanderComponent.d.ts +27 -27
  20. package/lib/components/expander/ExpanderComponent.js +89 -90
  21. package/lib/components/form-field/FormComponent.d.ts +12 -12
  22. package/lib/components/form-field/FormComponent.js +23 -26
  23. package/lib/components/form-field/FormFieldComponent.d.ts +39 -39
  24. package/lib/components/form-field/FormFieldComponent.js +138 -140
  25. package/lib/components/grid/GridComponent.d.ts +26 -26
  26. package/lib/components/grid/GridComponent.js +110 -116
  27. package/lib/components/input/InputComponent.d.ts +33 -33
  28. package/lib/components/input/InputComponent.js +126 -147
  29. package/lib/components/loading/LoadingComponent.d.ts +8 -8
  30. package/lib/components/loading/LoadingComponent.js +20 -22
  31. package/lib/components/navigation/NavigationComponent.d.ts +34 -34
  32. package/lib/components/navigation/NavigationComponent.js +45 -70
  33. package/lib/components/notification/Notification.d.ts +19 -19
  34. package/lib/components/notification/Notification.js +65 -69
  35. package/lib/components/number/NumberComponent.d.ts +26 -26
  36. package/lib/components/number/NumberComponent.js +80 -98
  37. package/lib/components/overlay/OverlayComponent.d.ts +27 -27
  38. package/lib/components/overlay/OverlayComponent.js +137 -149
  39. package/lib/components/progress/ProgressComponent.d.ts +18 -18
  40. package/lib/components/progress/ProgressComponent.js +40 -42
  41. package/lib/components/ribbon-menu/RibbonMenuComponent.d.ts +12 -12
  42. package/lib/components/ribbon-menu/RibbonMenuComponent.js +23 -34
  43. package/lib/components/select/SelectComponent.d.ts +79 -79
  44. package/lib/components/select/SelectComponent.js +356 -369
  45. package/lib/components/select/SelectDDAreaComponent.d.ts +32 -32
  46. package/lib/components/select/SelectDDAreaComponent.js +303 -317
  47. package/lib/components/slider/nouislider.d.ts +44 -44
  48. package/lib/components/slider/nouislider.js +2158 -2158
  49. package/lib/components/stack-panel/SplitterComponent.d.ts +21 -21
  50. package/lib/components/stack-panel/SplitterComponent.js +124 -126
  51. package/lib/components/stack-panel/StackPanelComponent.d.ts +20 -20
  52. package/lib/components/stack-panel/StackPanelComponent.js +50 -64
  53. package/lib/components/tabs/TabsComponent.d.ts +40 -40
  54. package/lib/components/tabs/TabsComponent.js +200 -204
  55. package/lib/components/time/TimeComponent.d.ts +29 -29
  56. package/lib/components/time/TimeComponent.js +104 -113
  57. package/lib/components/tree-view/TreeViewComponent.d.ts +23 -23
  58. package/lib/components/tree-view/TreeViewComponent.js +43 -45
  59. package/lib/components/virtual-render/VirtualRenderComponent.d.ts +30 -30
  60. package/lib/components/virtual-render/VirtualRenderComponent.js +92 -104
  61. package/lib/core/culture.d.ts +5 -5
  62. package/lib/core/culture.js +385 -385
  63. package/lib/core/date.d.ts +14 -14
  64. package/lib/core/date.js +346 -350
  65. package/lib/core/helper.d.ts +13 -13
  66. package/lib/core/helper.js +100 -104
  67. package/lib/core/jq.d.ts +37 -37
  68. package/lib/core/jq.js +362 -371
  69. package/lib/core/lang.d.ts +24 -24
  70. package/lib/core/lang.js +24 -28
  71. package/lib/core/numeric.d.ts +7 -7
  72. package/lib/core/numeric.js +139 -143
  73. package/lib/core/polyfills.js +22 -22
  74. package/lib/core.d.ts +6 -6
  75. package/lib/core.js +6 -6
  76. package/lib/grid/filterDialogs/dateRangeFilter.d.ts +7 -7
  77. package/lib/grid/filterDialogs/dateRangeFilter.js +106 -156
  78. package/lib/grid/filterDialogs/excelFilter.d.ts +9 -9
  79. package/lib/grid/filterDialogs/excelFilter.js +250 -316
  80. package/lib/grid/plugins/ext.overlay.d.ts +2 -2
  81. package/lib/grid/plugins/ext.overlay.js +295 -295
  82. package/lib/grid/plugins/slick.cellrangedecorator.d.ts +12 -12
  83. package/lib/grid/plugins/slick.cellrangedecorator.js +68 -68
  84. package/lib/grid/plugins/slick.cellrangeselector.d.ts +1 -1
  85. package/lib/grid/plugins/slick.cellrangeselector.js +144 -144
  86. package/lib/grid/plugins/slick.cellselectionmodel.d.ts +1 -1
  87. package/lib/grid/plugins/slick.cellselectionmodel.js +194 -194
  88. package/lib/grid/plugins/slick.headerbuttons.d.ts +55 -55
  89. package/lib/grid/plugins/slick.headerbuttons.js +156 -156
  90. package/lib/grid/plugins/slick.headermenu.d.ts +74 -74
  91. package/lib/grid/plugins/slick.headermenu.js +260 -260
  92. package/lib/grid/plugins/slick.rowmovemanager.d.ts +18 -18
  93. package/lib/grid/plugins/slick.rowmovemanager.js +249 -249
  94. package/lib/grid/plugins/slick.rowselectionmodel.d.ts +1 -1
  95. package/lib/grid/plugins/slick.rowselectionmodel.js +167 -167
  96. package/lib/grid/slick.core.d.ts +91 -91
  97. package/lib/grid/slick.core.js +574 -574
  98. package/lib/grid/slick.creator.d.ts +81 -81
  99. package/lib/grid/slick.creator.js +726 -726
  100. package/lib/grid/slick.dataview.d.ts +71 -71
  101. package/lib/grid/slick.dataview.js +1069 -1080
  102. package/lib/grid/slick.editors.core.d.ts +4 -4
  103. package/lib/grid/slick.editors.core.js +235 -235
  104. package/lib/grid/slick.editors.date.d.ts +2 -2
  105. package/lib/grid/slick.editors.date.js +125 -125
  106. package/lib/grid/slick.editors.lookup.d.ts +14 -14
  107. package/lib/grid/slick.editors.lookup.js +352 -353
  108. package/lib/grid/slick.editors.nav.d.ts +6 -6
  109. package/lib/grid/slick.editors.nav.js +22 -22
  110. package/lib/grid/slick.formatters.d.ts +17 -17
  111. package/lib/grid/slick.formatters.js +144 -144
  112. package/lib/grid/slick.grid.d.ts +285 -285
  113. package/lib/grid/slick.grid.js +5409 -5412
  114. package/lib/grid/slick.groupitemmetadataprovider.d.ts +39 -39
  115. package/lib/grid/slick.groupitemmetadataprovider.js +165 -165
  116. package/lib/grid/slick.tree.d.ts +33 -33
  117. package/lib/grid/slick.tree.js +208 -220
  118. package/lib/grid.css +1 -705
  119. package/lib/grid.d.ts +13 -13
  120. package/lib/grid.js +13 -13
  121. package/lib/index.css +8 -2195
  122. package/lib/index.css.map +1 -1
  123. package/lib/index.d.ts +56 -55
  124. package/lib/index.js +61 -61
  125. package/lib/index.js.map +1 -1
  126. package/lib/interaction/dataconverter.d.ts +4 -4
  127. package/lib/interaction/dataconverter.js +0 -1
  128. package/lib/interaction/eventhandler.d.ts +13 -13
  129. package/lib/interaction/eventhandler.js +39 -42
  130. package/lib/interaction/moveable.d.ts +39 -39
  131. package/lib/interaction/moveable.js +160 -174
  132. package/lib/interaction/resizable.d.ts +37 -37
  133. package/lib/interaction/resizable.js +109 -123
  134. package/lib/ui/auto.suggest.d.ts +18 -18
  135. package/lib/ui/auto.suggest.js +244 -259
  136. package/lib/ui/date.picker/date-picker-options.d.ts +11 -11
  137. package/lib/ui/date.picker/date-picker-options.js +76 -76
  138. package/lib/ui/date.picker/lib/date-manip.d.ts +74 -74
  139. package/lib/ui/date.picker/lib/date-manip.js +120 -120
  140. package/lib/ui/date.picker/lib/dom.d.ts +23 -23
  141. package/lib/ui/date.picker/lib/dom.js +28 -28
  142. package/lib/ui/date.picker/lib/emitter.d.ts +13 -13
  143. package/lib/ui/date.picker/lib/emitter.js +49 -49
  144. package/lib/ui/date.picker/lib/fns.d.ts +23 -23
  145. package/lib/ui/date.picker/lib/fns.js +39 -43
  146. package/lib/ui/date.picker/mode/base-mode.d.ts +26 -26
  147. package/lib/ui/date.picker/mode/base-mode.js +248 -248
  148. package/lib/ui/date.picker/mode/dropdown-mode.d.ts +28 -28
  149. package/lib/ui/date.picker/mode/dropdown-mode.js +50 -50
  150. package/lib/ui/date.picker/mode/index.d.ts +28 -28
  151. package/lib/ui/date.picker/mode/index.js +18 -18
  152. package/lib/ui/date.picker/mode/modal-mode.d.ts +25 -25
  153. package/lib/ui/date.picker/mode/modal-mode.js +17 -17
  154. package/lib/ui/date.picker/mode/permanent-mode.d.ts +29 -29
  155. package/lib/ui/date.picker/mode/permanent-mode.js +19 -19
  156. package/lib/ui/date.picker/views/day-picker.d.ts +40 -40
  157. package/lib/ui/date.picker/views/day-picker.js +155 -155
  158. package/lib/ui/date.picker/views/month-picker.d.ts +26 -26
  159. package/lib/ui/date.picker/views/month-picker.js +65 -65
  160. package/lib/ui/date.picker/views/year-picker.d.ts +20 -20
  161. package/lib/ui/date.picker/views/year-picker.js +66 -66
  162. package/lib/ui/date.picker.d.ts +66 -66
  163. package/lib/ui/date.picker.js +32 -32
  164. package/lib/ui/dialog.d.ts +22 -22
  165. package/lib/ui/dialog.js +98 -113
  166. package/lib/ui/drop.down.d.ts +52 -52
  167. package/lib/ui/drop.down.js +2112 -2112
  168. package/lib/ui/number.input.d.ts +13 -13
  169. package/lib/ui/number.input.js +56 -67
  170. package/package.json +1 -1
@@ -1,317 +1,303 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
- import { VirtualRenderComponent } from "../virtual-render/VirtualRenderComponent";
11
- import { EventHandler } from "../../interaction/eventhandler";
12
- function isInternetExplorer() {
13
- return window.navigator.userAgent.indexOf("MSIE ") > 0 || !!window.navigator.userAgent.match(/Trident.*rv\:11\./);
14
- }
15
- var SelectDDAreaComponent = /** @class */ (function () {
16
- function SelectDDAreaComponent(options, component, args) {
17
- this.options = options;
18
- this.component = component;
19
- this.args = args;
20
- this.onRender = new EventHandler();
21
- this.isScrolling = false;
22
- if (args.searchTxt) {
23
- this.search(args.searchTxt);
24
- }
25
- this.focusFirst();
26
- }
27
- SelectDDAreaComponent.prototype.onCreate = function (node) {
28
- var _this = this;
29
- var _a, _b;
30
- this.dom = node.dom;
31
- this.scrollContainer = this.dom.querySelector(".sel-dd-items");
32
- var item = this.component.getSelected();
33
- if (item != null) {
34
- if (Array.isArray(item)) {
35
- item = item[0];
36
- }
37
- if (item != null) {
38
- var d = (_b = (_a = this.renderedData) !== null && _a !== void 0 ? _a : this.filteredData) !== null && _b !== void 0 ? _b : this.options.data;
39
- var idx = d.indexOf(item);
40
- this.scrollContainer.scrollTop = this.options.rowHeight * idx;
41
- }
42
- }
43
- //bugfix for IE -> blur event of search box is called when user clicks scroll bar
44
- if (isInternetExplorer()) {
45
- this.scrollContainer.addEventListener("scroll", function (e) {
46
- _this.isScrolling = true;
47
- setTimeout(function () {
48
- _this.isScrolling = false;
49
- _this.dom.querySelector(".sel-search input").focus();
50
- }, 20);
51
- });
52
- this.scrollContainer.addEventListener("mousedown", function (e) {
53
- if (e.offsetX > _this.scrollContainer.clientWidth || e.offsetY > _this.scrollContainer.clientHeight) {
54
- _this.isScrolling = true;
55
- setTimeout(function () {
56
- _this.isScrolling = false;
57
- _this.dom.querySelector(".sel-search input").focus();
58
- }, 20);
59
- }
60
- });
61
- }
62
- };
63
- SelectDDAreaComponent.prototype.render = function () {
64
- var _this = this;
65
- var _a;
66
- var data = (_a = this.filteredData) !== null && _a !== void 0 ? _a : this.options.data;
67
- if (this.options.groupProperty != null) {
68
- var sortedData = __spreadArray([], data, true);
69
- sortedData.sort(function (a, b) {
70
- return a[_this.options.groupProperty] < b[_this.options.groupProperty] ? -1
71
- : a[_this.options.groupProperty] > b[_this.options.groupProperty] ? 1 : (data.indexOf(a) - data.indexOf(b) // preserve order if it is for same group
72
- );
73
- });
74
- data = [];
75
- var prevGroupVal = NaN;
76
- for (var _i = 0, sortedData_1 = sortedData; _i < sortedData_1.length; _i++) {
77
- var x = sortedData_1[_i];
78
- if (x[this.options.groupProperty] !== prevGroupVal) {
79
- // create group entry
80
- data.push({ __isGroup: true, __groupValue: x[this.options.groupProperty] });
81
- prevGroupVal = x[this.options.groupProperty];
82
- }
83
- data.push(x);
84
- }
85
- }
86
- this.onRender.notify(data);
87
- this.renderedData = data;
88
- var ddNode = {
89
- tag: "div", animation: this.options.enableAnimation ? { attr: "opacity", from: "0", to: "1", duration: 400 } : undefined, children: [
90
- {
91
- tag: "div", attr: { class: "sel-search", style: this.options.enableSearch ? undefined : "height:0;padding:0;margin:0;border:none;" },
92
- children: [
93
- {
94
- tag: "input", attr: {
95
- type: "text", value: this.args.searchTxt, placeholder: "Search", blur: function (e) {
96
- e.preventDefault();
97
- if (isInternetExplorer()) {
98
- requestAnimationFrame(function () {
99
- if (!_this.isScrolling) {
100
- _this.component.close();
101
- }
102
- });
103
- }
104
- else {
105
- _this.component.close();
106
- }
107
- return false;
108
- }, input: function (e, node) {
109
- if (!_this.options.enableSearch) {
110
- return false;
111
- }
112
- var term = node.dom.value;
113
- if (!term) {
114
- _this.clearSearch();
115
- }
116
- else {
117
- _this.search(term);
118
- }
119
- }, keydown: function (e, node) {
120
- var _a;
121
- if (!_this.options.enableKeyboard) {
122
- return;
123
- }
124
- if (e.which === SelectDDAreaComponent.ESCAPE_KEY) {
125
- node.dom.blur();
126
- }
127
- else if (e.which === SelectDDAreaComponent.DOWN_KEY) {
128
- _this.navigateDown();
129
- }
130
- else if (e.which === SelectDDAreaComponent.UP_KEY) {
131
- _this.navigateUp();
132
- }
133
- else if (e.which === SelectDDAreaComponent.ENTER_KEY) { // TODO: multiselect
134
- var focus_1 = _this.component.getFocus();
135
- if (focus_1 == null) {
136
- // if only 1 result is left then auto select this entry
137
- var d = (_a = _this.filteredData) !== null && _a !== void 0 ? _a : _this.options.data;
138
- if (d.length === 1) {
139
- focus_1 = d[0];
140
- }
141
- }
142
- if (_this.options.multiple) {
143
- if (focus_1 != null) {
144
- var currentSelection = _this.component.getSelected();
145
- if (currentSelection.indexOf(focus_1) >= 0) {
146
- currentSelection.splice(currentSelection.indexOf(focus_1), 1);
147
- }
148
- else {
149
- currentSelection.push(focus_1);
150
- }
151
- _this.component.setSelected(currentSelection);
152
- }
153
- }
154
- else {
155
- if (focus_1 != null) {
156
- _this.component.setSelected(focus_1);
157
- }
158
- node.dom.blur();
159
- }
160
- }
161
- else if (e.which === SelectDDAreaComponent.TAB_KEY) {
162
- e.preventDefault();
163
- node.dom.blur();
164
- }
165
- }
166
- }
167
- }
168
- ]
169
- },
170
- new VirtualRenderComponent({
171
- class: "sel-dd-items" + (this.options.multiple ? " multiple" : ""),
172
- data: data,
173
- style: this.options.enableSearch ? "height:calc(100% - 1.8rem)" : "height:100%",
174
- viewportSizeInPX: this.args.renderHeight + 20,
175
- bufferSizeInPx: 20,
176
- renderRow: function (args) {
177
- var result = { tag: "div", attr: { class: "sel-dd-item" } };
178
- if (_this.options.groupProperty && args.rowData.__isGroup) {
179
- result.attr.class += " sel-dd-group";
180
- var groupValue = args.rowData.__groupValue;
181
- var groupArgs = {
182
- groupValue: groupValue,
183
- node: result
184
- };
185
- var resGroup = _this.options.onRenderGroup(groupArgs);
186
- if (resGroup != null) {
187
- result.children = [resGroup];
188
- }
189
- result.attr.mousedown = function (evt) {
190
- evt.preventDefault();
191
- evt.stopPropagation();
192
- evt.stopImmediatePropagation();
193
- };
194
- return result;
195
- }
196
- var renderArg = {
197
- data: args.rowData,
198
- node: result,
199
- isFocused: _this.component.getFocus() === args.rowData,
200
- isSelected: _this.options.multiple ?
201
- _this.component.getSelected().indexOf(args.rowData) >= 0 :
202
- _this.component.getSelected() === args.rowData,
203
- isCurrent: false
204
- };
205
- if (renderArg.isFocused) {
206
- result.attr.class += " focused";
207
- }
208
- if (renderArg.isSelected) {
209
- result.attr.class += " selected";
210
- }
211
- result.attr.mousedown = function (evt) {
212
- if (_this.options.multiple) {
213
- evt.preventDefault();
214
- evt.stopPropagation();
215
- evt.stopImmediatePropagation();
216
- var currentSelection = _this.component.getSelected();
217
- if (currentSelection.indexOf(args.rowData) >= 0) {
218
- currentSelection.splice(currentSelection.indexOf(args.rowData), 1);
219
- _this.component.setSelected(currentSelection);
220
- }
221
- else {
222
- _this.component.setSelected(args.rowData);
223
- }
224
- }
225
- else {
226
- _this.component.setSelected(args.rowData);
227
- }
228
- };
229
- var res = _this.options.onRender(renderArg);
230
- if (res != null) {
231
- result.children = [res];
232
- }
233
- return result;
234
- },
235
- rowHeight: this.options.rowHeight
236
- })
237
- ]
238
- };
239
- return ddNode;
240
- };
241
- SelectDDAreaComponent.prototype.navigateDown = function () {
242
- var _a, _b, _c;
243
- var d = (_b = (_a = this.renderedData) !== null && _a !== void 0 ? _a : this.filteredData) !== null && _b !== void 0 ? _b : this.options.data;
244
- var selItem = (_c = this.component.getFocus()) !== null && _c !== void 0 ? _c : this.component.getSelected();
245
- if (selItem == null) {
246
- this.component.setFocus(d.filter(function (x) { return !x.__isGroup; })[0]);
247
- return;
248
- }
249
- if (Array.isArray(selItem)) {
250
- selItem = selItem[0];
251
- }
252
- var idx = d.indexOf(selItem);
253
- if (idx < 0) {
254
- this.component.setFocus(d.filter(function (x) { return !x.__isGroup; })[0]);
255
- }
256
- else {
257
- while (idx < d.length - 1) {
258
- idx++;
259
- if (!d[idx].__isGroup) {
260
- this.component.setFocus(d[idx]);
261
- this.scrollContainer.scrollTop = this.options.rowHeight * idx;
262
- break;
263
- }
264
- }
265
- }
266
- };
267
- SelectDDAreaComponent.prototype.navigateUp = function () {
268
- var _a, _b, _c;
269
- var d = (_b = (_a = this.renderedData) !== null && _a !== void 0 ? _a : this.filteredData) !== null && _b !== void 0 ? _b : this.options.data;
270
- var selItem = (_c = this.component.getFocus()) !== null && _c !== void 0 ? _c : this.component.getSelected();
271
- if (selItem == null) {
272
- this.component.setFocus(d.filter(function (x) { return !x.__isGroup; })[0]);
273
- return;
274
- }
275
- if (Array.isArray(selItem)) {
276
- selItem = selItem[0];
277
- }
278
- var idx = d.indexOf(selItem);
279
- while (idx > 0) {
280
- idx--;
281
- if (!d[idx].__isGroup) {
282
- this.component.setFocus(d[idx]);
283
- this.scrollContainer.scrollTop = this.options.rowHeight * idx;
284
- return;
285
- }
286
- }
287
- this.component.setFocus(d.filter(function (x) { return !x.__isGroup; })[0]);
288
- };
289
- SelectDDAreaComponent.prototype.search = function (term) {
290
- var _this = this;
291
- var _a, _b, _c, _d;
292
- var oldLen = (_b = (_a = this.filteredData) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
293
- this.filteredData = this.options.data.filter(function (d) { return _this.options.matchSearch(d, term); });
294
- var newLen = (_d = (_c = this.filteredData) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
295
- if (oldLen !== newLen && this.scrollContainer != null) {
296
- this.scrollContainer.scrollTop = 0;
297
- }
298
- this.focusFirst();
299
- };
300
- SelectDDAreaComponent.prototype.clearSearch = function () {
301
- this.filteredData = null;
302
- this.focusFirst();
303
- };
304
- SelectDDAreaComponent.prototype.focusFirst = function () {
305
- var _a;
306
- if (this.options.focusFirstItem && (this.component.getSelected() == null || this.component.getSelected().length === 0)) /* TODO multiselect */ {
307
- this.component.setFocus(((_a = this.filteredData) !== null && _a !== void 0 ? _a : this.options.data)[0]);
308
- }
309
- };
310
- SelectDDAreaComponent.ESCAPE_KEY = 27;
311
- SelectDDAreaComponent.DOWN_KEY = 40;
312
- SelectDDAreaComponent.UP_KEY = 38;
313
- SelectDDAreaComponent.ENTER_KEY = 13;
314
- SelectDDAreaComponent.TAB_KEY = 9;
315
- return SelectDDAreaComponent;
316
- }());
317
- export { SelectDDAreaComponent };
1
+ import { VirtualRenderComponent } from "../virtual-render/VirtualRenderComponent";
2
+ import { EventHandler } from "../../interaction/eventhandler";
3
+ function isInternetExplorer() {
4
+ return window.navigator.userAgent.indexOf("MSIE ") > 0 || !!window.navigator.userAgent.match(/Trident.*rv\:11\./);
5
+ }
6
+ export class SelectDDAreaComponent {
7
+ constructor(options, component, args) {
8
+ this.options = options;
9
+ this.component = component;
10
+ this.args = args;
11
+ this.onRender = new EventHandler();
12
+ this.isScrolling = false;
13
+ if (args.searchTxt) {
14
+ this.search(args.searchTxt);
15
+ }
16
+ this.focusFirst();
17
+ }
18
+ onCreate(node) {
19
+ var _a, _b;
20
+ this.dom = node.dom;
21
+ this.scrollContainer = this.dom.querySelector(".sel-dd-items");
22
+ let item = this.component.getSelected();
23
+ if (item != null) {
24
+ if (Array.isArray(item)) {
25
+ item = item[0];
26
+ }
27
+ if (item != null) {
28
+ const d = (_b = (_a = this.renderedData) !== null && _a !== void 0 ? _a : this.filteredData) !== null && _b !== void 0 ? _b : this.options.data;
29
+ const idx = d.indexOf(item);
30
+ this.scrollContainer.scrollTop = this.options.rowHeight * idx;
31
+ }
32
+ }
33
+ //bugfix for IE -> blur event of search box is called when user clicks scroll bar
34
+ if (isInternetExplorer()) {
35
+ this.scrollContainer.addEventListener("scroll", (e) => {
36
+ this.isScrolling = true;
37
+ setTimeout(() => {
38
+ this.isScrolling = false;
39
+ this.dom.querySelector(".sel-search input").focus();
40
+ }, 20);
41
+ });
42
+ this.scrollContainer.addEventListener("mousedown", (e) => {
43
+ if (e.offsetX > this.scrollContainer.clientWidth || e.offsetY > this.scrollContainer.clientHeight) {
44
+ this.isScrolling = true;
45
+ setTimeout(() => {
46
+ this.isScrolling = false;
47
+ this.dom.querySelector(".sel-search input").focus();
48
+ }, 20);
49
+ }
50
+ });
51
+ }
52
+ }
53
+ render() {
54
+ var _a;
55
+ let data = (_a = this.filteredData) !== null && _a !== void 0 ? _a : this.options.data;
56
+ if (this.options.groupProperty != null) {
57
+ const sortedData = [...data];
58
+ sortedData.sort((a, b) => {
59
+ return a[this.options.groupProperty] < b[this.options.groupProperty] ? -1
60
+ : a[this.options.groupProperty] > b[this.options.groupProperty] ? 1 : (data.indexOf(a) - data.indexOf(b) // preserve order if it is for same group
61
+ );
62
+ });
63
+ data = [];
64
+ let prevGroupVal = NaN;
65
+ for (const x of sortedData) {
66
+ if (x[this.options.groupProperty] !== prevGroupVal) {
67
+ // create group entry
68
+ data.push({ __isGroup: true, __groupValue: x[this.options.groupProperty] });
69
+ prevGroupVal = x[this.options.groupProperty];
70
+ }
71
+ data.push(x);
72
+ }
73
+ }
74
+ this.onRender.notify(data);
75
+ this.renderedData = data;
76
+ const ddNode = {
77
+ tag: "div", animation: this.options.enableAnimation ? { attr: "opacity", from: "0", to: "1", duration: 400 } : undefined,
78
+ children: [
79
+ {
80
+ tag: "div", attr: { class: "sel-search", style: this.options.enableSearch ? undefined : "height:0;padding:0;margin:0;border:none;" },
81
+ children: [
82
+ {
83
+ tag: "input",
84
+ attr: {
85
+ type: "text", value: this.args.searchTxt, placeholder: "Search", blur: (e) => {
86
+ e.preventDefault();
87
+ if (isInternetExplorer()) {
88
+ requestAnimationFrame(() => {
89
+ if (!this.isScrolling) {
90
+ this.component.close();
91
+ }
92
+ });
93
+ }
94
+ else {
95
+ this.component.close();
96
+ }
97
+ return false;
98
+ },
99
+ input: (e, node) => {
100
+ if (!this.options.enableSearch) {
101
+ return false;
102
+ }
103
+ const term = node.dom.value;
104
+ if (!term) {
105
+ this.clearSearch();
106
+ }
107
+ else {
108
+ this.search(term);
109
+ }
110
+ }, keydown: (e, node) => {
111
+ var _a;
112
+ if (!this.options.enableKeyboard) {
113
+ return;
114
+ }
115
+ if (e.which === SelectDDAreaComponent.ESCAPE_KEY) {
116
+ node.dom.blur();
117
+ }
118
+ else if (e.which === SelectDDAreaComponent.DOWN_KEY) {
119
+ this.navigateDown();
120
+ }
121
+ else if (e.which === SelectDDAreaComponent.UP_KEY) {
122
+ this.navigateUp();
123
+ }
124
+ else if (e.which === SelectDDAreaComponent.ENTER_KEY) { // TODO: multiselect
125
+ let focus = this.component.getFocus();
126
+ if (focus == null) {
127
+ // if only 1 result is left then auto select this entry
128
+ const d = (_a = this.filteredData) !== null && _a !== void 0 ? _a : this.options.data;
129
+ if (d.length === 1) {
130
+ focus = d[0];
131
+ }
132
+ }
133
+ if (this.options.multiple) {
134
+ if (focus != null) {
135
+ const currentSelection = this.component.getSelected();
136
+ if (currentSelection.indexOf(focus) >= 0) {
137
+ currentSelection.splice(currentSelection.indexOf(focus), 1);
138
+ }
139
+ else {
140
+ currentSelection.push(focus);
141
+ }
142
+ this.component.setSelected(currentSelection);
143
+ }
144
+ }
145
+ else {
146
+ if (focus != null) {
147
+ this.component.setSelected(focus);
148
+ }
149
+ node.dom.blur();
150
+ }
151
+ }
152
+ else if (e.which === SelectDDAreaComponent.TAB_KEY) {
153
+ e.preventDefault();
154
+ node.dom.blur();
155
+ }
156
+ }
157
+ }
158
+ }
159
+ ]
160
+ },
161
+ new VirtualRenderComponent({
162
+ class: "sel-dd-items" + (this.options.multiple ? " multiple" : ""), data,
163
+ style: this.options.enableSearch ? "height:calc(100% - 1.8rem)" : "height:100%",
164
+ viewportSizeInPX: this.args.renderHeight + 20,
165
+ bufferSizeInPx: 20,
166
+ renderRow: (args) => {
167
+ const result = { tag: "div", attr: { class: "sel-dd-item" } };
168
+ if (this.options.groupProperty && args.rowData.__isGroup) {
169
+ result.attr.class += " sel-dd-group";
170
+ const groupValue = args.rowData.__groupValue;
171
+ const groupArgs = {
172
+ groupValue, node: result
173
+ };
174
+ const resGroup = this.options.onRenderGroup(groupArgs);
175
+ if (resGroup != null) {
176
+ result.children = [resGroup];
177
+ }
178
+ result.attr.mousedown = (evt) => {
179
+ evt.preventDefault();
180
+ evt.stopPropagation();
181
+ evt.stopImmediatePropagation();
182
+ };
183
+ return result;
184
+ }
185
+ const renderArg = {
186
+ data: args.rowData,
187
+ node: result,
188
+ isFocused: this.component.getFocus() === args.rowData,
189
+ isSelected: this.options.multiple ?
190
+ this.component.getSelected().indexOf(args.rowData) >= 0 :
191
+ this.component.getSelected() === args.rowData,
192
+ isCurrent: false
193
+ };
194
+ if (renderArg.isFocused) {
195
+ result.attr.class += " focused";
196
+ }
197
+ if (renderArg.isSelected) {
198
+ result.attr.class += " selected";
199
+ }
200
+ result.attr.mousedown = (evt) => {
201
+ if (this.options.multiple) {
202
+ evt.preventDefault();
203
+ evt.stopPropagation();
204
+ evt.stopImmediatePropagation();
205
+ const currentSelection = this.component.getSelected();
206
+ if (currentSelection.indexOf(args.rowData) >= 0) {
207
+ currentSelection.splice(currentSelection.indexOf(args.rowData), 1);
208
+ this.component.setSelected(currentSelection);
209
+ }
210
+ else {
211
+ this.component.setSelected(args.rowData);
212
+ }
213
+ }
214
+ else {
215
+ this.component.setSelected(args.rowData);
216
+ }
217
+ };
218
+ const res = this.options.onRender(renderArg);
219
+ if (res != null) {
220
+ result.children = [res];
221
+ }
222
+ return result;
223
+ },
224
+ rowHeight: this.options.rowHeight
225
+ })
226
+ ]
227
+ };
228
+ return ddNode;
229
+ }
230
+ navigateDown() {
231
+ var _a, _b, _c;
232
+ const d = (_b = (_a = this.renderedData) !== null && _a !== void 0 ? _a : this.filteredData) !== null && _b !== void 0 ? _b : this.options.data;
233
+ let selItem = (_c = this.component.getFocus()) !== null && _c !== void 0 ? _c : this.component.getSelected();
234
+ if (selItem == null) {
235
+ this.component.setFocus(d.filter((x) => !x.__isGroup)[0]);
236
+ return;
237
+ }
238
+ if (Array.isArray(selItem)) {
239
+ selItem = selItem[0];
240
+ }
241
+ let idx = d.indexOf(selItem);
242
+ if (idx < 0) {
243
+ this.component.setFocus(d.filter((x) => !x.__isGroup)[0]);
244
+ }
245
+ else {
246
+ while (idx < d.length - 1) {
247
+ idx++;
248
+ if (!d[idx].__isGroup) {
249
+ this.component.setFocus(d[idx]);
250
+ this.scrollContainer.scrollTop = this.options.rowHeight * idx;
251
+ break;
252
+ }
253
+ }
254
+ }
255
+ }
256
+ navigateUp() {
257
+ var _a, _b, _c;
258
+ const d = (_b = (_a = this.renderedData) !== null && _a !== void 0 ? _a : this.filteredData) !== null && _b !== void 0 ? _b : this.options.data;
259
+ let selItem = (_c = this.component.getFocus()) !== null && _c !== void 0 ? _c : this.component.getSelected();
260
+ if (selItem == null) {
261
+ this.component.setFocus(d.filter((x) => !x.__isGroup)[0]);
262
+ return;
263
+ }
264
+ if (Array.isArray(selItem)) {
265
+ selItem = selItem[0];
266
+ }
267
+ let idx = d.indexOf(selItem);
268
+ while (idx > 0) {
269
+ idx--;
270
+ if (!d[idx].__isGroup) {
271
+ this.component.setFocus(d[idx]);
272
+ this.scrollContainer.scrollTop = this.options.rowHeight * idx;
273
+ return;
274
+ }
275
+ }
276
+ this.component.setFocus(d.filter((x) => !x.__isGroup)[0]);
277
+ }
278
+ search(term) {
279
+ var _a, _b, _c, _d;
280
+ const oldLen = (_b = (_a = this.filteredData) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
281
+ this.filteredData = this.options.data.filter((d) => this.options.matchSearch(d, term));
282
+ const newLen = (_d = (_c = this.filteredData) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
283
+ if (oldLen !== newLen && this.scrollContainer != null) {
284
+ this.scrollContainer.scrollTop = 0;
285
+ }
286
+ this.focusFirst();
287
+ }
288
+ clearSearch() {
289
+ this.filteredData = null;
290
+ this.focusFirst();
291
+ }
292
+ focusFirst() {
293
+ var _a;
294
+ if (this.options.focusFirstItem && (this.component.getSelected() == null || this.component.getSelected().length === 0)) /* TODO multiselect */ {
295
+ this.component.setFocus(((_a = this.filteredData) !== null && _a !== void 0 ? _a : this.options.data)[0]);
296
+ }
297
+ }
298
+ }
299
+ SelectDDAreaComponent.ESCAPE_KEY = 27;
300
+ SelectDDAreaComponent.DOWN_KEY = 40;
301
+ SelectDDAreaComponent.UP_KEY = 38;
302
+ SelectDDAreaComponent.ENTER_KEY = 13;
303
+ SelectDDAreaComponent.TAB_KEY = 9;