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.
- package/lib/components/IntervalComponent.d.ts +17 -17
- package/lib/components/IntervalComponent.js +65 -68
- package/lib/components/auto-suggest/AutoSuggestComponent.d.ts +22 -22
- package/lib/components/auto-suggest/AutoSuggestComponent.js +47 -49
- package/lib/components/button/ButtonComponent.d.ts +18 -18
- package/lib/components/button/ButtonComponent.js +29 -46
- package/lib/components/checkbox/CheckBoxComponent.d.ts +28 -28
- package/lib/components/checkbox/CheckBoxComponent.js +81 -98
- package/lib/components/date/DateComponent.d.ts +32 -32
- package/lib/components/date/DateComponent.js +89 -106
- package/lib/components/date-range/DateRangeComponent.d.ts +35 -35
- package/lib/components/date-range/DateRangeComponent.js +123 -136
- package/lib/components/date-time/DateTimeComponent.d.ts +15 -15
- package/lib/components/date-time/DateTimeComponent.js +39 -53
- package/lib/components/dialog/DialogComponent.d.ts +67 -67
- package/lib/components/dialog/DialogComponent.js +198 -251
- package/lib/components/drop-down/DropDownComponent.d.ts +27 -27
- package/lib/components/drop-down/DropDownComponent.js +60 -74
- package/lib/components/expander/ExpanderComponent.d.ts +27 -27
- package/lib/components/expander/ExpanderComponent.js +89 -90
- package/lib/components/form-field/FormComponent.d.ts +12 -12
- package/lib/components/form-field/FormComponent.js +23 -26
- package/lib/components/form-field/FormFieldComponent.d.ts +39 -39
- package/lib/components/form-field/FormFieldComponent.js +138 -140
- package/lib/components/grid/GridComponent.d.ts +26 -26
- package/lib/components/grid/GridComponent.js +110 -116
- package/lib/components/input/InputComponent.d.ts +33 -33
- package/lib/components/input/InputComponent.js +126 -147
- package/lib/components/loading/LoadingComponent.d.ts +8 -8
- package/lib/components/loading/LoadingComponent.js +20 -22
- package/lib/components/navigation/NavigationComponent.d.ts +34 -34
- package/lib/components/navigation/NavigationComponent.js +45 -70
- package/lib/components/notification/Notification.d.ts +19 -19
- package/lib/components/notification/Notification.js +65 -69
- package/lib/components/number/NumberComponent.d.ts +26 -26
- package/lib/components/number/NumberComponent.js +80 -98
- package/lib/components/overlay/OverlayComponent.d.ts +27 -27
- package/lib/components/overlay/OverlayComponent.js +137 -149
- package/lib/components/progress/ProgressComponent.d.ts +18 -18
- package/lib/components/progress/ProgressComponent.js +40 -42
- package/lib/components/ribbon-menu/RibbonMenuComponent.d.ts +12 -12
- package/lib/components/ribbon-menu/RibbonMenuComponent.js +23 -34
- package/lib/components/select/SelectComponent.d.ts +79 -79
- package/lib/components/select/SelectComponent.js +356 -369
- package/lib/components/select/SelectDDAreaComponent.d.ts +32 -32
- package/lib/components/select/SelectDDAreaComponent.js +303 -317
- package/lib/components/slider/nouislider.d.ts +44 -44
- package/lib/components/slider/nouislider.js +2158 -2158
- package/lib/components/stack-panel/SplitterComponent.d.ts +21 -21
- package/lib/components/stack-panel/SplitterComponent.js +124 -126
- package/lib/components/stack-panel/StackPanelComponent.d.ts +20 -20
- package/lib/components/stack-panel/StackPanelComponent.js +50 -64
- package/lib/components/tabs/TabsComponent.d.ts +40 -40
- package/lib/components/tabs/TabsComponent.js +200 -204
- package/lib/components/time/TimeComponent.d.ts +29 -29
- package/lib/components/time/TimeComponent.js +104 -113
- package/lib/components/tree-view/TreeViewComponent.d.ts +23 -23
- package/lib/components/tree-view/TreeViewComponent.js +43 -45
- package/lib/components/virtual-render/VirtualRenderComponent.d.ts +30 -30
- package/lib/components/virtual-render/VirtualRenderComponent.js +92 -104
- package/lib/core/culture.d.ts +5 -5
- package/lib/core/culture.js +385 -385
- package/lib/core/date.d.ts +14 -14
- package/lib/core/date.js +346 -350
- package/lib/core/helper.d.ts +13 -13
- package/lib/core/helper.js +100 -104
- package/lib/core/jq.d.ts +37 -37
- package/lib/core/jq.js +362 -371
- package/lib/core/lang.d.ts +24 -24
- package/lib/core/lang.js +24 -28
- package/lib/core/numeric.d.ts +7 -7
- package/lib/core/numeric.js +139 -143
- package/lib/core/polyfills.js +22 -22
- package/lib/core.d.ts +6 -6
- package/lib/core.js +6 -6
- package/lib/grid/filterDialogs/dateRangeFilter.d.ts +7 -7
- package/lib/grid/filterDialogs/dateRangeFilter.js +106 -156
- package/lib/grid/filterDialogs/excelFilter.d.ts +9 -9
- package/lib/grid/filterDialogs/excelFilter.js +250 -316
- package/lib/grid/plugins/ext.overlay.d.ts +2 -2
- package/lib/grid/plugins/ext.overlay.js +295 -295
- package/lib/grid/plugins/slick.cellrangedecorator.d.ts +12 -12
- package/lib/grid/plugins/slick.cellrangedecorator.js +68 -68
- package/lib/grid/plugins/slick.cellrangeselector.d.ts +1 -1
- package/lib/grid/plugins/slick.cellrangeselector.js +144 -144
- package/lib/grid/plugins/slick.cellselectionmodel.d.ts +1 -1
- package/lib/grid/plugins/slick.cellselectionmodel.js +194 -194
- package/lib/grid/plugins/slick.headerbuttons.d.ts +55 -55
- package/lib/grid/plugins/slick.headerbuttons.js +156 -156
- package/lib/grid/plugins/slick.headermenu.d.ts +74 -74
- package/lib/grid/plugins/slick.headermenu.js +260 -260
- package/lib/grid/plugins/slick.rowmovemanager.d.ts +18 -18
- package/lib/grid/plugins/slick.rowmovemanager.js +249 -249
- package/lib/grid/plugins/slick.rowselectionmodel.d.ts +1 -1
- package/lib/grid/plugins/slick.rowselectionmodel.js +167 -167
- package/lib/grid/slick.core.d.ts +91 -91
- package/lib/grid/slick.core.js +574 -574
- package/lib/grid/slick.creator.d.ts +81 -81
- package/lib/grid/slick.creator.js +726 -726
- package/lib/grid/slick.dataview.d.ts +71 -71
- package/lib/grid/slick.dataview.js +1069 -1080
- package/lib/grid/slick.editors.core.d.ts +4 -4
- package/lib/grid/slick.editors.core.js +235 -235
- package/lib/grid/slick.editors.date.d.ts +2 -2
- package/lib/grid/slick.editors.date.js +125 -125
- package/lib/grid/slick.editors.lookup.d.ts +14 -14
- package/lib/grid/slick.editors.lookup.js +352 -353
- package/lib/grid/slick.editors.nav.d.ts +6 -6
- package/lib/grid/slick.editors.nav.js +22 -22
- package/lib/grid/slick.formatters.d.ts +17 -17
- package/lib/grid/slick.formatters.js +144 -144
- package/lib/grid/slick.grid.d.ts +285 -285
- package/lib/grid/slick.grid.js +5409 -5412
- package/lib/grid/slick.groupitemmetadataprovider.d.ts +39 -39
- package/lib/grid/slick.groupitemmetadataprovider.js +165 -165
- package/lib/grid/slick.tree.d.ts +33 -33
- package/lib/grid/slick.tree.js +208 -220
- package/lib/grid.css +1 -705
- package/lib/grid.d.ts +13 -13
- package/lib/grid.js +13 -13
- package/lib/index.css +8 -2195
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +56 -55
- package/lib/index.js +61 -61
- package/lib/index.js.map +1 -1
- package/lib/interaction/dataconverter.d.ts +4 -4
- package/lib/interaction/dataconverter.js +0 -1
- package/lib/interaction/eventhandler.d.ts +13 -13
- package/lib/interaction/eventhandler.js +39 -42
- package/lib/interaction/moveable.d.ts +39 -39
- package/lib/interaction/moveable.js +160 -174
- package/lib/interaction/resizable.d.ts +37 -37
- package/lib/interaction/resizable.js +109 -123
- package/lib/ui/auto.suggest.d.ts +18 -18
- package/lib/ui/auto.suggest.js +244 -259
- package/lib/ui/date.picker/date-picker-options.d.ts +11 -11
- package/lib/ui/date.picker/date-picker-options.js +76 -76
- package/lib/ui/date.picker/lib/date-manip.d.ts +74 -74
- package/lib/ui/date.picker/lib/date-manip.js +120 -120
- package/lib/ui/date.picker/lib/dom.d.ts +23 -23
- package/lib/ui/date.picker/lib/dom.js +28 -28
- package/lib/ui/date.picker/lib/emitter.d.ts +13 -13
- package/lib/ui/date.picker/lib/emitter.js +49 -49
- package/lib/ui/date.picker/lib/fns.d.ts +23 -23
- package/lib/ui/date.picker/lib/fns.js +39 -43
- package/lib/ui/date.picker/mode/base-mode.d.ts +26 -26
- package/lib/ui/date.picker/mode/base-mode.js +248 -248
- package/lib/ui/date.picker/mode/dropdown-mode.d.ts +28 -28
- package/lib/ui/date.picker/mode/dropdown-mode.js +50 -50
- package/lib/ui/date.picker/mode/index.d.ts +28 -28
- package/lib/ui/date.picker/mode/index.js +18 -18
- package/lib/ui/date.picker/mode/modal-mode.d.ts +25 -25
- package/lib/ui/date.picker/mode/modal-mode.js +17 -17
- package/lib/ui/date.picker/mode/permanent-mode.d.ts +29 -29
- package/lib/ui/date.picker/mode/permanent-mode.js +19 -19
- package/lib/ui/date.picker/views/day-picker.d.ts +40 -40
- package/lib/ui/date.picker/views/day-picker.js +155 -155
- package/lib/ui/date.picker/views/month-picker.d.ts +26 -26
- package/lib/ui/date.picker/views/month-picker.js +65 -65
- package/lib/ui/date.picker/views/year-picker.d.ts +20 -20
- package/lib/ui/date.picker/views/year-picker.js +66 -66
- package/lib/ui/date.picker.d.ts +66 -66
- package/lib/ui/date.picker.js +32 -32
- package/lib/ui/dialog.d.ts +22 -22
- package/lib/ui/dialog.js +98 -113
- package/lib/ui/drop.down.d.ts +52 -52
- package/lib/ui/drop.down.js +2112 -2112
- package/lib/ui/number.input.d.ts +13 -13
- package/lib/ui/number.input.js +56 -67
- package/package.json +1 -1
|
@@ -1,369 +1,356 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
this.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
var
|
|
296
|
-
if (this.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
return {
|
|
362
|
-
tag: "div", attr: { class: "sel-result" }, content: node != null ? undefined : this.options.placehoder,
|
|
363
|
-
children: node == null ? undefined : [node, clearbtn]
|
|
364
|
-
};
|
|
365
|
-
};
|
|
366
|
-
SelectComponent.ENTER_KEY = 13;
|
|
367
|
-
return SelectComponent;
|
|
368
|
-
}());
|
|
369
|
-
export { SelectComponent };
|
|
1
|
+
import "./SelectStyle.scss";
|
|
2
|
+
import { JSLRender } from "jsl-render";
|
|
3
|
+
import { SelectDDAreaComponent } from "./SelectDDAreaComponent";
|
|
4
|
+
import { EventHandler } from "../../interaction/eventhandler";
|
|
5
|
+
export class SelectComponent {
|
|
6
|
+
constructor(o) {
|
|
7
|
+
var _a;
|
|
8
|
+
this.expanded = false;
|
|
9
|
+
this.doNotFocus = false;
|
|
10
|
+
const defaultOptions = {
|
|
11
|
+
data: undefined,
|
|
12
|
+
keyColumn: "value",
|
|
13
|
+
textColumn: "text",
|
|
14
|
+
dropdownHeight: "10rem",
|
|
15
|
+
dropDirection: "auto",
|
|
16
|
+
enableSearch: true,
|
|
17
|
+
enableAnimation: true,
|
|
18
|
+
enableKeyboard: true,
|
|
19
|
+
rowHeight: 28,
|
|
20
|
+
allowEmpty: true,
|
|
21
|
+
enabled: true,
|
|
22
|
+
openOnEnter: true,
|
|
23
|
+
focusFirstItem: true,
|
|
24
|
+
autoShrink: true,
|
|
25
|
+
bindMode: "toModel",
|
|
26
|
+
onAppend: (dom) => {
|
|
27
|
+
document.body.appendChild(dom);
|
|
28
|
+
},
|
|
29
|
+
onRenderGroup: (args) => {
|
|
30
|
+
args.node.content = args.groupValue;
|
|
31
|
+
},
|
|
32
|
+
onRender: o.multiple ? (args) => {
|
|
33
|
+
if (args.isCurrent) {
|
|
34
|
+
args.node.content = args.data.map((d) => d[this.options.textColumn]).join(", ");
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
args.node.content = args.data[this.options.textColumn];
|
|
38
|
+
}
|
|
39
|
+
} : (args) => {
|
|
40
|
+
args.node.content = args.data[this.options.textColumn];
|
|
41
|
+
},
|
|
42
|
+
matchSearch: (data, term) => { var _a; return (((_a = data[this.options.textColumn]) !== null && _a !== void 0 ? _a : "").toString().toLowerCase().indexOf(term.toLowerCase()) >= 0); }
|
|
43
|
+
};
|
|
44
|
+
this.options = { ...defaultOptions, ...o };
|
|
45
|
+
this.options.onChange = EventHandler.Create(o.onChange);
|
|
46
|
+
if (this.options.bindTo != null && this.options.property != null && this.options.value == null) {
|
|
47
|
+
this.options.value = (((_a = this.options.converter) === null || _a === void 0 ? void 0 : _a.toUI) ?
|
|
48
|
+
this.options.converter.toUI(this.options.bindTo[this.options.property]) :
|
|
49
|
+
this.options.bindTo[this.options.property]);
|
|
50
|
+
}
|
|
51
|
+
this.setValue(this.options.value);
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
if (this.options.bindMode !== "toModel" && this.options.bindTo != null && this.options.property != null) {
|
|
56
|
+
const value = ((_a = this.options.converter) === null || _a === void 0 ? void 0 : _a.toUI) ?
|
|
57
|
+
this.options.converter.toUI(this.options.bindTo[this.options.property]) :
|
|
58
|
+
this.options.bindTo[this.options.property];
|
|
59
|
+
if (value != null) {
|
|
60
|
+
if (this.options.multiple) {
|
|
61
|
+
this.selected = this.options.data.filter((x) => value.indexOf(x[this.options.keyColumn]) >= 0);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.selected = this.options.data.filter((x) => x[this.options.keyColumn] === value)[0];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.selected = this.options.multiple ? [] : null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
tag: "div",
|
|
73
|
+
attr: {
|
|
74
|
+
style: this.options.style,
|
|
75
|
+
class: "select-comp " + (this.expanded ? "expanded " : "") + (!this.options.enabled ? "disabled " : "") + ((_b = this.options.class) !== null && _b !== void 0 ? _b : ""),
|
|
76
|
+
mousedown: (e) => { if (this.expanded || e.which === 3) {
|
|
77
|
+
return;
|
|
78
|
+
} {
|
|
79
|
+
this.doNotFocus = true;
|
|
80
|
+
this.show();
|
|
81
|
+
} }
|
|
82
|
+
},
|
|
83
|
+
children: [this.renderSelection(), {
|
|
84
|
+
tag: "button",
|
|
85
|
+
attr: {
|
|
86
|
+
disabled: this.options.enabled ? undefined : "disabled",
|
|
87
|
+
class: "sel-expander",
|
|
88
|
+
keydown: (e) => {
|
|
89
|
+
if (this.options.openOnEnter && this.options.enabled) {
|
|
90
|
+
if (e.which === SelectComponent.ENTER_KEY) {
|
|
91
|
+
this.toggle();
|
|
92
|
+
}
|
|
93
|
+
else if (!this.expanded) {
|
|
94
|
+
if (e.key && e.key.length === 1) {
|
|
95
|
+
this.show(e.key);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
focus: (e) => {
|
|
101
|
+
if (!this.doNotFocus && this.options.openOnFocus && this.options.enabled) {
|
|
102
|
+
this.toggle();
|
|
103
|
+
}
|
|
104
|
+
if (this.doNotFocus) {
|
|
105
|
+
this.doNotFocus = false;
|
|
106
|
+
}
|
|
107
|
+
}, click: (e) => {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
content: this.expanded ? "▲" : "▼"
|
|
112
|
+
}]
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
onCreate(node) {
|
|
116
|
+
this.dom = node.dom;
|
|
117
|
+
}
|
|
118
|
+
onUpdate(node) {
|
|
119
|
+
this.dom = node.dom;
|
|
120
|
+
}
|
|
121
|
+
onInit(renderer) {
|
|
122
|
+
this.renderer = renderer;
|
|
123
|
+
}
|
|
124
|
+
toggle() {
|
|
125
|
+
this.expanded = !this.expanded;
|
|
126
|
+
if (this.expanded) {
|
|
127
|
+
this.show();
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.close();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
isExpanded() {
|
|
134
|
+
return this.expanded;
|
|
135
|
+
}
|
|
136
|
+
show(searchTxt) {
|
|
137
|
+
var _a;
|
|
138
|
+
if (!this.options.enabled) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this.expanded = true;
|
|
142
|
+
const dimension = this.dom.getBoundingClientRect();
|
|
143
|
+
const left = Math.round(dimension.left + window.pageXOffset);
|
|
144
|
+
const top = Math.round(dimension.top + window.pageYOffset);
|
|
145
|
+
this.dropdownArea = document.createElement("div");
|
|
146
|
+
this.dropdownArea.className = "sel-comp-dd " + ((_a = this.options.dropdownClass) !== null && _a !== void 0 ? _a : "");
|
|
147
|
+
this.dropdownArea.style.width = this.options.dropdownWidth || (Math.round(dimension.width) + "px");
|
|
148
|
+
this.dropdownArea.style.height = this.options.dropdownHeight;
|
|
149
|
+
this.dropdownArea.style.left = left + "px";
|
|
150
|
+
if (this.options.dropDirection === "up") {
|
|
151
|
+
this.dropdownArea.style.top = "calc(" + top + "px - " + this.options.dropdownHeight + ")";
|
|
152
|
+
this.dropdownArea.classList.add("sel-comp-dd-up");
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this.dropdownArea.style.top = Math.round(top + dimension.height) + "px";
|
|
156
|
+
this.dropdownArea.classList.add("sel-comp-dd-down");
|
|
157
|
+
}
|
|
158
|
+
this.options.onAppend(this.dropdownArea);
|
|
159
|
+
const ddDimension = this.dropdownArea.getBoundingClientRect();
|
|
160
|
+
if (this.options.dropDirection === "auto") {
|
|
161
|
+
// check if there is enought room for dropdown at bottom
|
|
162
|
+
if (ddDimension.bottom > window.innerHeight) {
|
|
163
|
+
// position "up"
|
|
164
|
+
this.dropdownArea.style.top = "calc(" + Math.round(top) + "px - " + this.options.dropdownHeight + ")";
|
|
165
|
+
this.dropdownArea.classList.add("sel-comp-dd-up");
|
|
166
|
+
this.dropdownArea.classList.remove("sel-comp-dd-down");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const ddAreaComp = new SelectDDAreaComponent(this.options, this, {
|
|
170
|
+
renderHeight: ddDimension.height - 2,
|
|
171
|
+
searchTxt
|
|
172
|
+
});
|
|
173
|
+
if (this.options.autoShrink) {
|
|
174
|
+
ddAreaComp.onRender.subscribe((data) => {
|
|
175
|
+
let ddHeight;
|
|
176
|
+
if (this.options.enableSearch) {
|
|
177
|
+
ddHeight = Math.min((data.length * this.options.rowHeight + 4), ddDimension.height - 2) + "px + 1.8rem";
|
|
178
|
+
this.dropdownArea.style.height = "calc(" + ddHeight + ")";
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
ddHeight = Math.min((data.length * this.options.rowHeight + 4), ddDimension.height - 2) + "px";
|
|
182
|
+
this.dropdownArea.style.height = ddHeight;
|
|
183
|
+
}
|
|
184
|
+
if (this.dropdownArea.classList.contains("sel-comp-dd-up")) {
|
|
185
|
+
this.dropdownArea.style.top = "calc(" + Math.round(top) + "px - (" + ddHeight + "))";
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
new JSLRender(this.dropdownArea, false).render(ddAreaComp);
|
|
190
|
+
requestAnimationFrame(() => {
|
|
191
|
+
const s = this.dropdownArea.querySelector(".sel-search input");
|
|
192
|
+
s.focus();
|
|
193
|
+
s.selectionStart = s.selectionEnd = s.value.length;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
destroy() {
|
|
197
|
+
const x = document.querySelector(".sel-comp-dd");
|
|
198
|
+
if (x != null && x.parentElement != null) {
|
|
199
|
+
try {
|
|
200
|
+
x.parentElement.removeChild(x);
|
|
201
|
+
}
|
|
202
|
+
catch (ex) {
|
|
203
|
+
// under certain conditions the child may not be in the parentElements child collection anymore, although the child node still has that element as its parent (e.g. blur event handler) - weird JavaScript stuff eh
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
this.expanded = false;
|
|
207
|
+
}
|
|
208
|
+
close() {
|
|
209
|
+
var _a;
|
|
210
|
+
this.expanded = false;
|
|
211
|
+
this.focused = null;
|
|
212
|
+
this.doNotFocus = true;
|
|
213
|
+
try {
|
|
214
|
+
if (((_a = this.dropdownArea) === null || _a === void 0 ? void 0 : _a.parentElement) != null) {
|
|
215
|
+
this.dropdownArea.parentElement.removeChild(this.dropdownArea);
|
|
216
|
+
}
|
|
217
|
+
if (this.renderer != null) {
|
|
218
|
+
this.renderer.refresh();
|
|
219
|
+
}
|
|
220
|
+
this.dom.querySelector(".sel-expander").focus();
|
|
221
|
+
}
|
|
222
|
+
catch (e) {
|
|
223
|
+
// https://stackoverflow.com/questions/21926083/failed-to-execute-removechild-on-node
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
setFocus(item) {
|
|
227
|
+
this.focused = item;
|
|
228
|
+
}
|
|
229
|
+
getFocus() {
|
|
230
|
+
return this.focused;
|
|
231
|
+
}
|
|
232
|
+
getValue() {
|
|
233
|
+
if (this.selected == null) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
if (this.options.multiple) {
|
|
237
|
+
return this.selected.map((itm) => itm[this.options.keyColumn]);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
return this.selected[this.options.keyColumn];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
setValue(value) {
|
|
244
|
+
var _a;
|
|
245
|
+
if (value != null) {
|
|
246
|
+
if (this.options.multiple) {
|
|
247
|
+
this.selected = this.options.data.filter((x) => value.indexOf(x[this.options.keyColumn]) >= 0);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this.selected = this.options.data.filter((x) => x[this.options.keyColumn] === value)[0];
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
this.selected = this.options.multiple ? [] : null;
|
|
255
|
+
}
|
|
256
|
+
if (this.options.bindTo && this.options.bindMode !== "fromModel" && this.options.property) {
|
|
257
|
+
this.options.bindTo[this.options.property] = ((_a = this.options.converter) === null || _a === void 0 ? void 0 : _a.toData) ? this.options.converter.toData(value) : value;
|
|
258
|
+
}
|
|
259
|
+
if (this.renderer != null) {
|
|
260
|
+
this.renderer.refresh();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
getSelected() {
|
|
264
|
+
return this.selected;
|
|
265
|
+
}
|
|
266
|
+
setSelected(item) {
|
|
267
|
+
var _a;
|
|
268
|
+
if (this.options.multiple) {
|
|
269
|
+
if (item == null) {
|
|
270
|
+
this.selected = [];
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
if (Array.isArray(item)) {
|
|
274
|
+
this.selected = item;
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
this.selected.push(item);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
this.selected = item;
|
|
283
|
+
}
|
|
284
|
+
const value = this.getValue();
|
|
285
|
+
if (this.options.bindMode !== "fromModel" && this.options.bindTo != null && this.options.property != null) {
|
|
286
|
+
this.options.bindTo[this.options.property] =
|
|
287
|
+
((_a = this.options.converter) === null || _a === void 0 ? void 0 : _a.toData) ? this.options.converter.toData(value) : value;
|
|
288
|
+
}
|
|
289
|
+
if (this.options.onChange != null) {
|
|
290
|
+
this.options.onChange.notify(value, this.selected);
|
|
291
|
+
}
|
|
292
|
+
this.renderer.refresh();
|
|
293
|
+
}
|
|
294
|
+
focus() {
|
|
295
|
+
var _a;
|
|
296
|
+
if (this.dom == null) {
|
|
297
|
+
requestAnimationFrame(() => {
|
|
298
|
+
var _a;
|
|
299
|
+
if (this.dom != null) {
|
|
300
|
+
(_a = this.dom.querySelector(".sel-expander")) === null || _a === void 0 ? void 0 : _a.focus();
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
(_a = this.dom.querySelector(".sel-expander")) === null || _a === void 0 ? void 0 : _a.focus();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
hasSelection() {
|
|
309
|
+
if (this.options.multiple) {
|
|
310
|
+
return this.selected.length > 0;
|
|
311
|
+
}
|
|
312
|
+
return this.selected != null;
|
|
313
|
+
}
|
|
314
|
+
renderSelection() {
|
|
315
|
+
let node;
|
|
316
|
+
if (this.hasSelection()) {
|
|
317
|
+
node = { tag: "div", attr: { class: "sel-dd-item" } };
|
|
318
|
+
const res = this.options.onRender({
|
|
319
|
+
isSelected: true,
|
|
320
|
+
isCurrent: true,
|
|
321
|
+
isFocused: false,
|
|
322
|
+
data: this.selected,
|
|
323
|
+
node
|
|
324
|
+
});
|
|
325
|
+
if (res != null) {
|
|
326
|
+
node.children = [res];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
let clearbtn;
|
|
330
|
+
if (this.options.allowEmpty) {
|
|
331
|
+
clearbtn = {
|
|
332
|
+
tag: "button", content: "✗",
|
|
333
|
+
attr: {
|
|
334
|
+
disabled: this.options.enabled ? undefined : "disabled",
|
|
335
|
+
title: "clear", class: "clear-btn",
|
|
336
|
+
mousedown: (e) => {
|
|
337
|
+
if (!this.options.enabled) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
e.stopImmediatePropagation();
|
|
341
|
+
this.setSelected(null);
|
|
342
|
+
},
|
|
343
|
+
click: (e) => {
|
|
344
|
+
e.preventDefault();
|
|
345
|
+
this.setSelected(null);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
tag: "div", attr: { class: "sel-result" }, content: node != null ? undefined : this.options.placehoder,
|
|
352
|
+
children: node == null ? undefined : [node, clearbtn]
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
SelectComponent.ENTER_KEY = 13;
|