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,259 +1,244 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import "./auto.suggest.css";
13
- var autoComplete = (function () {
14
- function autoComplete(options) {
15
- // helpers
16
- function hasClass(el, className) { return el.classList.contains(className); }
17
- function addEvent(el, type, handler) {
18
- el.addEventListener(type, handler);
19
- }
20
- function removeEvent(el, type, handler) {
21
- // if (el.removeEventListener) not working in IE11
22
- el.removeEventListener(type, handler);
23
- }
24
- function live(elClass, event, cb, context) {
25
- addEvent(context || document, event, function (e) {
26
- var found;
27
- var el = e.target || e.srcElement;
28
- while (el && !(found = hasClass(el, elClass))) {
29
- el = el.parentElement;
30
- }
31
- if (found) {
32
- cb.call(el, e);
33
- }
34
- });
35
- }
36
- var o = {
37
- selector: "",
38
- source: function (val, s) { return []; },
39
- minChars: 0,
40
- delay: 150,
41
- offsetLeft: 0,
42
- offsetTop: 1,
43
- cache: false,
44
- menuClass: '',
45
- renderItem: function (item, search) {
46
- // escape special characters
47
- search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
48
- var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi");
49
- return '<div class="autocomplete-suggestion" data-val="' + item + '">' + item.replace(re, "<b>$1</b>") + '</div>';
50
- },
51
- onSelect: function (e, term, item) { }
52
- };
53
- for (var k in options) {
54
- if (options.hasOwnProperty(k)) {
55
- o[k] = options[k];
56
- }
57
- }
58
- // init
59
- var elems = typeof o.selector === 'object' ? [o.selector] : document.querySelectorAll(o.selector);
60
- var _loop_1 = function (i) {
61
- var that = elems[i];
62
- // create suggestions container "sc"
63
- that.sc = document.createElement('div');
64
- that.sc.className = 'autocomplete-suggestions ' + o.menuClass;
65
- that.autocompleteAttr = that.getAttribute('autocomplete');
66
- that.setAttribute('autocomplete', 'off');
67
- that.cache = {};
68
- that.last_val = '';
69
- that.updateSC = function (resize, next) {
70
- var rect = that.getBoundingClientRect();
71
- that.sc.style.left = Math.round(rect.left + (window.pageXOffset || document.documentElement.scrollLeft) + o.offsetLeft) + 'px';
72
- that.sc.style.top = Math.round(rect.bottom + (window.pageYOffset || document.documentElement.scrollTop) + o.offsetTop) + 'px';
73
- that.sc.style.width = Math.round(rect.right - rect.left) + 'px'; // outerWidth
74
- if (!resize) {
75
- that.sc.style.display = 'block';
76
- if (!that.sc.maxHeight) {
77
- that.sc.maxHeight = parseInt((window.getComputedStyle ? getComputedStyle(that.sc, null) : that.sc.currentStyle).maxHeight, 10);
78
- }
79
- if (!that.sc.suggestionHeight) {
80
- that.sc.suggestionHeight = that.sc.querySelector('.autocomplete-suggestion').offsetHeight;
81
- }
82
- if (that.sc.suggestionHeight) {
83
- if (!next) {
84
- that.sc.scrollTop = 0;
85
- }
86
- else {
87
- var scrTop = that.sc.scrollTop, selTop = next.getBoundingClientRect().top - that.sc.getBoundingClientRect().top;
88
- if (selTop + that.sc.suggestionHeight - that.sc.maxHeight > 0) {
89
- that.sc.scrollTop = selTop + that.sc.suggestionHeight + scrTop - that.sc.maxHeight;
90
- }
91
- else if (selTop < 0) {
92
- that.sc.scrollTop = selTop + scrTop;
93
- }
94
- }
95
- }
96
- }
97
- };
98
- addEvent(window, 'resize', that.updateSC);
99
- document.body.appendChild(that.sc);
100
- live('autocomplete-suggestion', 'mouseleave', function (e) {
101
- var sel = that.sc.querySelector('.autocomplete-suggestion.selected');
102
- if (sel) {
103
- setTimeout(function () { sel.className = sel.className.replace('selected', ''); }, 20);
104
- }
105
- }, that.sc);
106
- live('autocomplete-suggestion', 'mouseover', function (e) {
107
- var sel = that.sc.querySelector('.autocomplete-suggestion.selected');
108
- if (sel) {
109
- sel.className = sel.className.replace('selected', '');
110
- }
111
- this.className += ' selected';
112
- }, that.sc);
113
- live('autocomplete-suggestion', 'mousedown', function (e) {
114
- // window.setTimeout(() => {
115
- if (hasClass(this, 'autocomplete-suggestion')) { // else outside click
116
- var v = this.getAttribute('data-val');
117
- that.value = v;
118
- o.onSelect(e, v, this);
119
- that.sc.style.display = 'none';
120
- }
121
- // }, 1000);
122
- }, that.sc);
123
- that.blurHandler = function () {
124
- //var over_sb;
125
- //try { over_sb = document.querySelector('.autocomplete-suggestions:hover'); } catch (e) { over_sb = 0; }
126
- //if (!over_sb) {
127
- that.last_val = that.value;
128
- that.sc.style.display = 'none';
129
- //setTimeout(function() { that.sc.style.display = 'none'; }, 350); // hide suggestions on fast input
130
- //} else if (that !== document.activeElement) { setTimeout(function() { that.focus(); }, 200); }
131
- };
132
- addEvent(that, 'blur', that.blurHandler);
133
- that.inputHandler = function () {
134
- options.onChange(that.value);
135
- };
136
- addEvent(that, 'input', that.inputHandler);
137
- suggest = function (data) {
138
- var val = that.value;
139
- that.cache[val] = data;
140
- if (data.length && val.length >= o.minChars) {
141
- var s = '';
142
- for (var i = 0; i < data.length; i++) {
143
- s += o.renderItem(data[i], val);
144
- }
145
- that.sc.innerHTML = s;
146
- that.updateSC(0);
147
- }
148
- else {
149
- that.sc.style.display = 'none';
150
- }
151
- };
152
- that.keydownHandler = function (e) {
153
- var key = window.event ? e.keyCode : e.which;
154
- // down (40), up (38)
155
- if ((key === 40 || key === 38) && that.sc.innerHTML) {
156
- var next, sel = that.sc.querySelector('.autocomplete-suggestion.selected');
157
- if (!sel) {
158
- next = (key == 40) ? that.sc.querySelector('.autocomplete-suggestion') : that.sc.childNodes[that.sc.childNodes.length - 1]; // first : last
159
- next.className += ' selected';
160
- that.value = next.getAttribute('data-val');
161
- }
162
- else {
163
- next = (key == 40) ? sel.nextSibling : sel.previousSibling;
164
- if (next) {
165
- sel.className = sel.className.replace('selected', '');
166
- next.className += ' selected';
167
- that.value = next.getAttribute('data-val');
168
- }
169
- else {
170
- sel.className = sel.className.replace('selected', '');
171
- that.value = that.last_val;
172
- next = 0;
173
- }
174
- }
175
- that.updateSC(0, next);
176
- return false;
177
- }
178
- else if (key == 27) {
179
- that.value = that.last_val;
180
- that.sc.style.display = 'none';
181
- }
182
- else if (key == 13 || key == 9) {
183
- var sel = that.sc.querySelector('.autocomplete-suggestion.selected');
184
- if (sel && that.sc.style.display != 'none') {
185
- o.onSelect(e, sel.getAttribute('data-val'), sel);
186
- setTimeout(function () { that.sc.style.display = 'none'; }, 20);
187
- }
188
- }
189
- };
190
- addEvent(that, 'keydown', that.keydownHandler);
191
- that.keyupHandler = function (e) {
192
- var key = window.event ? e.keyCode : e.which;
193
- if (!key || (key < 35 || key > 40) && key != 13 && key != 27) {
194
- var val = that.value;
195
- if (val.length >= o.minChars) {
196
- if (val != that.last_val) {
197
- that.last_val = val;
198
- clearTimeout(that.timer);
199
- if (o.cache) {
200
- if (val in that.cache) {
201
- suggest(that.cache[val]);
202
- return;
203
- }
204
- // no requests if previous suggestions were empty
205
- for (var i = 1; i < val.length - o.minChars; i++) {
206
- var part = val.slice(0, val.length - i);
207
- if (part in that.cache && !that.cache[part].length) {
208
- suggest([]);
209
- return;
210
- }
211
- }
212
- }
213
- that.timer = setTimeout(function () { o.source(val, suggest); }, o.delay);
214
- }
215
- }
216
- else {
217
- that.last_val = val;
218
- that.sc.style.display = 'none';
219
- }
220
- }
221
- };
222
- addEvent(that, 'keyup', that.keyupHandler);
223
- that.focusHandler = function (e) {
224
- that.last_val = '\n';
225
- that.keyupHandler(e);
226
- };
227
- if (!o.minChars) {
228
- addEvent(that, 'focus', that.focusHandler);
229
- }
230
- };
231
- var suggest;
232
- for (var i = 0; i < elems.length; i++) {
233
- _loop_1(i);
234
- }
235
- // public destroy method
236
- this.destroy = function () {
237
- for (var i = 0; i < elems.length; i++) {
238
- var that = elems[i];
239
- removeEvent(window, 'resize', that.updateSC);
240
- removeEvent(that, 'blur', that.blurHandler);
241
- removeEvent(that, 'focus', that.focusHandler);
242
- removeEvent(that, 'keydown', that.keydownHandler);
243
- removeEvent(that, 'keyup', that.keyupHandler);
244
- if (that.autocompleteAttr) {
245
- that.setAttribute('autocomplete', that.autocompleteAttr);
246
- }
247
- else {
248
- that.removeAttribute('autocomplete');
249
- }
250
- document.body.removeChild(that.sc);
251
- that = null;
252
- }
253
- };
254
- }
255
- return autoComplete;
256
- })();
257
- export function AutoSuggest(input, opts) {
258
- return new autoComplete(__assign({ selector: input }, opts));
259
- }
1
+ import "./auto.suggest.css";
2
+ let autoComplete = (function () {
3
+ function autoComplete(options) {
4
+ // helpers
5
+ function hasClass(el, className) { return el.classList.contains(className); }
6
+ function addEvent(el, type, handler) {
7
+ el.addEventListener(type, handler);
8
+ }
9
+ function removeEvent(el, type, handler) {
10
+ // if (el.removeEventListener) not working in IE11
11
+ el.removeEventListener(type, handler);
12
+ }
13
+ function live(elClass, event, cb, context) {
14
+ addEvent(context || document, event, function (e) {
15
+ let found;
16
+ let el = e.target || e.srcElement;
17
+ while (el && !(found = hasClass(el, elClass))) {
18
+ el = el.parentElement;
19
+ }
20
+ if (found) {
21
+ cb.call(el, e);
22
+ }
23
+ });
24
+ }
25
+ const o = {
26
+ selector: "",
27
+ source: function (val, s) { return []; },
28
+ minChars: 0,
29
+ delay: 150,
30
+ offsetLeft: 0,
31
+ offsetTop: 1,
32
+ cache: false,
33
+ menuClass: '',
34
+ renderItem: function (item, search) {
35
+ // escape special characters
36
+ search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
37
+ var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi");
38
+ return '<div class="autocomplete-suggestion" data-val="' + item + '">' + item.replace(re, "<b>$1</b>") + '</div>';
39
+ },
40
+ onSelect: function (e, term, item) { }
41
+ };
42
+ for (const k in options) {
43
+ if (options.hasOwnProperty(k)) {
44
+ o[k] = options[k];
45
+ }
46
+ }
47
+ // init
48
+ let elems = typeof o.selector === 'object' ? [o.selector] : document.querySelectorAll(o.selector);
49
+ for (let i = 0; i < elems.length; i++) {
50
+ let that = elems[i];
51
+ // create suggestions container "sc"
52
+ that.sc = document.createElement('div');
53
+ that.sc.className = 'autocomplete-suggestions ' + o.menuClass;
54
+ that.autocompleteAttr = that.getAttribute('autocomplete');
55
+ that.setAttribute('autocomplete', 'off');
56
+ that.cache = {};
57
+ that.last_val = '';
58
+ that.updateSC = function (resize, next) {
59
+ var rect = that.getBoundingClientRect();
60
+ that.sc.style.left = Math.round(rect.left + (window.pageXOffset || document.documentElement.scrollLeft) + o.offsetLeft) + 'px';
61
+ that.sc.style.top = Math.round(rect.bottom + (window.pageYOffset || document.documentElement.scrollTop) + o.offsetTop) + 'px';
62
+ that.sc.style.width = Math.round(rect.right - rect.left) + 'px'; // outerWidth
63
+ if (!resize) {
64
+ that.sc.style.display = 'block';
65
+ if (!that.sc.maxHeight) {
66
+ that.sc.maxHeight = parseInt((window.getComputedStyle ? getComputedStyle(that.sc, null) : that.sc.currentStyle).maxHeight, 10);
67
+ }
68
+ if (!that.sc.suggestionHeight) {
69
+ that.sc.suggestionHeight = that.sc.querySelector('.autocomplete-suggestion').offsetHeight;
70
+ }
71
+ if (that.sc.suggestionHeight) {
72
+ if (!next) {
73
+ that.sc.scrollTop = 0;
74
+ }
75
+ else {
76
+ var scrTop = that.sc.scrollTop, selTop = next.getBoundingClientRect().top - that.sc.getBoundingClientRect().top;
77
+ if (selTop + that.sc.suggestionHeight - that.sc.maxHeight > 0) {
78
+ that.sc.scrollTop = selTop + that.sc.suggestionHeight + scrTop - that.sc.maxHeight;
79
+ }
80
+ else if (selTop < 0) {
81
+ that.sc.scrollTop = selTop + scrTop;
82
+ }
83
+ }
84
+ }
85
+ }
86
+ };
87
+ addEvent(window, 'resize', that.updateSC);
88
+ document.body.appendChild(that.sc);
89
+ live('autocomplete-suggestion', 'mouseleave', function (e) {
90
+ const sel = that.sc.querySelector('.autocomplete-suggestion.selected');
91
+ if (sel) {
92
+ setTimeout(function () { sel.className = sel.className.replace('selected', ''); }, 20);
93
+ }
94
+ }, that.sc);
95
+ live('autocomplete-suggestion', 'mouseover', function (e) {
96
+ const sel = that.sc.querySelector('.autocomplete-suggestion.selected');
97
+ if (sel) {
98
+ sel.className = sel.className.replace('selected', '');
99
+ }
100
+ this.className += ' selected';
101
+ }, that.sc);
102
+ live('autocomplete-suggestion', 'mousedown', function (e) {
103
+ // window.setTimeout(() => {
104
+ if (hasClass(this, 'autocomplete-suggestion')) { // else outside click
105
+ const v = this.getAttribute('data-val');
106
+ that.value = v;
107
+ o.onSelect(e, v, this);
108
+ that.sc.style.display = 'none';
109
+ }
110
+ // }, 1000);
111
+ }, that.sc);
112
+ that.blurHandler = function () {
113
+ //var over_sb;
114
+ //try { over_sb = document.querySelector('.autocomplete-suggestions:hover'); } catch (e) { over_sb = 0; }
115
+ //if (!over_sb) {
116
+ that.last_val = that.value;
117
+ that.sc.style.display = 'none';
118
+ //setTimeout(function() { that.sc.style.display = 'none'; }, 350); // hide suggestions on fast input
119
+ //} else if (that !== document.activeElement) { setTimeout(function() { that.focus(); }, 200); }
120
+ };
121
+ addEvent(that, 'blur', that.blurHandler);
122
+ that.inputHandler = function () {
123
+ options.onChange(that.value);
124
+ };
125
+ addEvent(that, 'input', that.inputHandler);
126
+ var suggest = function (data) {
127
+ var val = that.value;
128
+ that.cache[val] = data;
129
+ if (data.length && val.length >= o.minChars) {
130
+ var s = '';
131
+ for (var i = 0; i < data.length; i++) {
132
+ s += o.renderItem(data[i], val);
133
+ }
134
+ that.sc.innerHTML = s;
135
+ that.updateSC(0);
136
+ }
137
+ else {
138
+ that.sc.style.display = 'none';
139
+ }
140
+ };
141
+ that.keydownHandler = function (e) {
142
+ var key = window.event ? e.keyCode : e.which;
143
+ // down (40), up (38)
144
+ if ((key === 40 || key === 38) && that.sc.innerHTML) {
145
+ var next, sel = that.sc.querySelector('.autocomplete-suggestion.selected');
146
+ if (!sel) {
147
+ next = (key == 40) ? that.sc.querySelector('.autocomplete-suggestion') : that.sc.childNodes[that.sc.childNodes.length - 1]; // first : last
148
+ next.className += ' selected';
149
+ that.value = next.getAttribute('data-val');
150
+ }
151
+ else {
152
+ next = (key == 40) ? sel.nextSibling : sel.previousSibling;
153
+ if (next) {
154
+ sel.className = sel.className.replace('selected', '');
155
+ next.className += ' selected';
156
+ that.value = next.getAttribute('data-val');
157
+ }
158
+ else {
159
+ sel.className = sel.className.replace('selected', '');
160
+ that.value = that.last_val;
161
+ next = 0;
162
+ }
163
+ }
164
+ that.updateSC(0, next);
165
+ return false;
166
+ }
167
+ else if (key == 27) {
168
+ that.value = that.last_val;
169
+ that.sc.style.display = 'none';
170
+ }
171
+ else if (key == 13 || key == 9) {
172
+ var sel = that.sc.querySelector('.autocomplete-suggestion.selected');
173
+ if (sel && that.sc.style.display != 'none') {
174
+ o.onSelect(e, sel.getAttribute('data-val'), sel);
175
+ setTimeout(function () { that.sc.style.display = 'none'; }, 20);
176
+ }
177
+ }
178
+ };
179
+ addEvent(that, 'keydown', that.keydownHandler);
180
+ that.keyupHandler = function (e) {
181
+ var key = window.event ? e.keyCode : e.which;
182
+ if (!key || (key < 35 || key > 40) && key != 13 && key != 27) {
183
+ var val = that.value;
184
+ if (val.length >= o.minChars) {
185
+ if (val != that.last_val) {
186
+ that.last_val = val;
187
+ clearTimeout(that.timer);
188
+ if (o.cache) {
189
+ if (val in that.cache) {
190
+ suggest(that.cache[val]);
191
+ return;
192
+ }
193
+ // no requests if previous suggestions were empty
194
+ for (var i = 1; i < val.length - o.minChars; i++) {
195
+ var part = val.slice(0, val.length - i);
196
+ if (part in that.cache && !that.cache[part].length) {
197
+ suggest([]);
198
+ return;
199
+ }
200
+ }
201
+ }
202
+ that.timer = setTimeout(function () { o.source(val, suggest); }, o.delay);
203
+ }
204
+ }
205
+ else {
206
+ that.last_val = val;
207
+ that.sc.style.display = 'none';
208
+ }
209
+ }
210
+ };
211
+ addEvent(that, 'keyup', that.keyupHandler);
212
+ that.focusHandler = function (e) {
213
+ that.last_val = '\n';
214
+ that.keyupHandler(e);
215
+ };
216
+ if (!o.minChars) {
217
+ addEvent(that, 'focus', that.focusHandler);
218
+ }
219
+ }
220
+ // public destroy method
221
+ this.destroy = function () {
222
+ for (var i = 0; i < elems.length; i++) {
223
+ var that = elems[i];
224
+ removeEvent(window, 'resize', that.updateSC);
225
+ removeEvent(that, 'blur', that.blurHandler);
226
+ removeEvent(that, 'focus', that.focusHandler);
227
+ removeEvent(that, 'keydown', that.keydownHandler);
228
+ removeEvent(that, 'keyup', that.keyupHandler);
229
+ if (that.autocompleteAttr) {
230
+ that.setAttribute('autocomplete', that.autocompleteAttr);
231
+ }
232
+ else {
233
+ that.removeAttribute('autocomplete');
234
+ }
235
+ document.body.removeChild(that.sc);
236
+ that = null;
237
+ }
238
+ };
239
+ }
240
+ return autoComplete;
241
+ })();
242
+ export function AutoSuggest(input, opts) {
243
+ return new autoComplete({ selector: input, ...opts });
244
+ }
@@ -1,11 +1,11 @@
1
- /**
2
- * @file Responsible for sanitizing and creating date picker options.
3
- */
4
- /**
5
- * DatePickerOptions constructs a new date picker options object, overriding
6
- * default values with any values specified in opts.
7
- *
8
- * @param {DatePickerOptions} opts
9
- * @returns {DatePickerOptions}
10
- */
11
- export default function DatePickerOptions(opts: any): any;
1
+ /**
2
+ * @file Responsible for sanitizing and creating date picker options.
3
+ */
4
+ /**
5
+ * DatePickerOptions constructs a new date picker options object, overriding
6
+ * default values with any values specified in opts.
7
+ *
8
+ * @param {DatePickerOptions} opts
9
+ * @returns {DatePickerOptions}
10
+ */
11
+ export default function DatePickerOptions(opts: any): any;