inviton-powerduck 0.0.145 → 0.0.147
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/common/css/ladda-themeless-zoomin.min.css +89 -89
- package/components/chart-js/thirdparty/flot/jquery.flot.categories.min.js +93 -93
- package/components/chart-js/thirdparty/flot/jquery.flot.crosshair.min.js +83 -83
- package/components/chart-js/thirdparty/flot/jquery.flot.navigate.min.js +270 -270
- package/components/chart-js/thirdparty/flot/jquery.flot.pie.min.js +507 -507
- package/components/chart-js/thirdparty/flot/jquery.flot.resize.min.js +147 -147
- package/components/chart-js/thirdparty/flot/jquery.flot.stack.min.js +104 -104
- package/components/counter/testall.tsx +79 -9
- package/components/dropdown/country-dropdown.tsx +11 -9
- package/components/dropdown/image-dropdown.tsx +45 -33
- package/components/dropdown/index.tsx +60 -39
- package/components/dropdown/language-dropdown.tsx +5 -13
- package/components/dropdown/mobile/legacy_fdd.ts +64 -50
- package/components/image-crop/vendor/jquery.Jcrop.min.css +344 -344
- package/components/import/import-mapper.tsx +231 -231
- package/components/input/plugins/daterangepicker/daterangepicker.min.css +400 -400
- package/components/input/plugins/daterangepicker/jquery.daterangepicker.min.js +1903 -1903
- package/components/modal/css/modal.css +11 -2
- package/components/rating/rating-picker.tsx +57 -63
- package/components/svg/skilift-svg.tsx +6 -6
- package/package.json +1 -1
|
@@ -19,15 +19,17 @@ interface CountryDropdownArgs extends FormItemWrapperArgs {
|
|
|
19
19
|
changed?: (newValue: string | string[]) => void;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function getFlaggedResult(state, originator):
|
|
23
|
-
if (!state) {
|
|
24
|
-
|
|
25
|
-
if (!state.id) {
|
|
22
|
+
function getFlaggedResult(h, state, originator): void {
|
|
23
|
+
if (!state) {
|
|
24
|
+
return null;
|
|
25
|
+
} else if (!state.id) {
|
|
26
|
+
return (<span>{state.text || ''}</span>);
|
|
27
|
+
}
|
|
26
28
|
|
|
27
|
-
if (originator == '
|
|
28
|
-
return state.text;
|
|
29
|
+
if (originator == 'mobile') {
|
|
30
|
+
return (<span>{state.text}</span>);
|
|
29
31
|
} else {
|
|
30
|
-
return
|
|
32
|
+
return (<span><span class={`fi fi-${state.dataRow.twoLetters}`}></span> {state.text}</span>);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -124,8 +126,8 @@ class CountryDropdownComponent extends TsxComponent<CountryDropdownArgs> impleme
|
|
|
124
126
|
<DropdownList
|
|
125
127
|
disabled={this.disabled}
|
|
126
128
|
options={this.getDataSource()}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
customRenderOption={(h, item, o) => { return getFlaggedResult(h, item, o); }}
|
|
130
|
+
customRenderSelectionResult={(h, item, o) => { return getFlaggedResult(h, item, o); }}
|
|
129
131
|
wrap={this.wrap}
|
|
130
132
|
mandatory={this.mandatory}
|
|
131
133
|
multiselect={this.multiselect}
|
|
@@ -57,46 +57,58 @@ class ImageDropdownComponent extends TsxComponent<ImageDropdownArgs> implements
|
|
|
57
57
|
this.changed(e);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
getSelectionTemplate(state, allOpts: ImageDropdownDataItem[]): string | JQuery {
|
|
61
|
-
if (!state) {
|
|
62
|
-
|
|
63
|
-
if (!state.id) {
|
|
60
|
+
getSelectionTemplate(h, state, allOpts: ImageDropdownDataItem[]): string | JQuery {
|
|
61
|
+
if (!state) {
|
|
62
|
+
return null;
|
|
63
|
+
} else if (!state.id) {
|
|
64
|
+
return (<span>{state.text || ''}</span>);
|
|
65
|
+
}
|
|
64
66
|
|
|
65
67
|
const dataItem = allOpts.filter(p => p.id.toString() == state.id)[0];
|
|
66
68
|
if (dataItem == null) {
|
|
67
|
-
return state.text;
|
|
69
|
+
return (<span>{state.text || ''}</span>);
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
return (
|
|
73
|
+
<div class="imgddl-dropdown-wrap">
|
|
74
|
+
<div class="imgddl-image" style={`background-image:url('${dataItem.imageUrl}')`}></div>
|
|
75
|
+
<div class="imgddl-text">{dataItem.text}</div>
|
|
76
|
+
<div class="imgddl-subtitle">{dataItem.subtitle}</div>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
getResultItemTemplate(state, allOpts: ImageDropdownDataItem[]): string | JQuery {
|
|
80
|
-
if (!state) {
|
|
81
|
-
|
|
82
|
-
if (!state.id) {
|
|
81
|
+
getResultItemTemplate(h, state, allOpts: ImageDropdownDataItem[]): string | JQuery {
|
|
82
|
+
if (!state) {
|
|
83
|
+
return null;
|
|
84
|
+
} else if (!state.id) {
|
|
85
|
+
return (<span>{state.text || ''}</span>);
|
|
86
|
+
}
|
|
83
87
|
|
|
84
88
|
const dataItem = allOpts.filter(p => p.id.toString() == state.id)[0];
|
|
85
89
|
if (dataItem == null) {
|
|
86
|
-
return state.text;
|
|
90
|
+
return (<span>{state.text || ''}</span>);
|
|
87
91
|
}
|
|
88
92
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
return (
|
|
94
|
+
<div class="imgddl-dropdown-resultroot">
|
|
95
|
+
<div class="imgddl-dropdown-resultwrap">
|
|
96
|
+
<div class="imgddl-result-image" style={{ backgroundImage: `url('${dataItem.imageUrl}')` }}></div>
|
|
97
|
+
<div class="imgddl-result-text">{dataItem.text}</div>
|
|
98
|
+
|
|
99
|
+
{(this.buttons || []).map((button, i) => (
|
|
100
|
+
<span
|
|
101
|
+
key={i}
|
|
102
|
+
class="imgddl-result-button imgdll-clickable-button"
|
|
103
|
+
data-index={i}
|
|
104
|
+
role="presentation"
|
|
105
|
+
>
|
|
106
|
+
<i class={button.iconCss}></i>
|
|
107
|
+
</span>
|
|
108
|
+
))}
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
100
112
|
}
|
|
101
113
|
|
|
102
114
|
handleAfterBound(elem: JQuery<Element>, select2Instance: any) {
|
|
@@ -205,11 +217,11 @@ class ImageDropdownComponent extends TsxComponent<ImageDropdownArgs> implements
|
|
|
205
217
|
<DropdownList
|
|
206
218
|
ref="ddList"
|
|
207
219
|
options={this.options}
|
|
208
|
-
|
|
209
|
-
return this.getResultItemTemplate(
|
|
220
|
+
customRenderSelectionResult={(h, item, o) => {
|
|
221
|
+
return this.getResultItemTemplate(h, item, this.options);
|
|
210
222
|
}}
|
|
211
|
-
|
|
212
|
-
return this.getSelectionTemplate(
|
|
223
|
+
customRenderOption={(h, item, o) => {
|
|
224
|
+
return this.getSelectionTemplate(h, item, this.options);
|
|
213
225
|
}}
|
|
214
226
|
multiselect={true}
|
|
215
227
|
multiselectMode={MultiselectMode.Tags}
|
|
@@ -217,7 +229,7 @@ class ImageDropdownComponent extends TsxComponent<ImageDropdownArgs> implements
|
|
|
217
229
|
tagsShouldPrependContent={true}
|
|
218
230
|
tagsTemplate={
|
|
219
231
|
this.tagsTemplate
|
|
220
|
-
|| '<li class="imgddl-selected-item"><span class="imgddl-result-remove imgddl-result-button select2-selection__choice__remove" role="presentation"><i class="
|
|
232
|
+
|| '<li class="imgddl-selected-item"><span class="imgddl-result-remove imgddl-result-button select2-selection__choice__remove" role="presentation"><i class="icon icon-trash"></i></span></li>'
|
|
221
233
|
}
|
|
222
234
|
tagsAdded={this.tagsAdded}
|
|
223
235
|
tagsNewPlaceLast={true}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DropdownButtonItemArgs } from '../dropdown-button/dropdown-button-item';
|
|
2
2
|
import type { FormItemWrapperArgs, MarginType } from '../form/form-item-wrapper';
|
|
3
|
+
import { h as _h, h, render, VNodeChild } from 'vue'
|
|
3
4
|
import Sortable from 'sortablejs';
|
|
4
5
|
import { Prop, toNative } from 'vue-facing-decorator';
|
|
5
6
|
import PowerduckState from '../../app/powerduck-state';
|
|
@@ -84,8 +85,8 @@ interface DropdownListArgs extends FormItemWrapperArgs {
|
|
|
84
85
|
changed: (newValue: string | any | Array<string> | Array<any>, exclusivity?: MultiSelectExclusivity) => void;
|
|
85
86
|
afterBound?: (elem: JQuery<Element>, select2Instance: any) => void;
|
|
86
87
|
noResultsFound?: () => void;
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
customRenderOption?: (h, state: DropdownDisplayArgs, originator?: CustomRenderOriginator) => any
|
|
89
|
+
customRenderSelectionResult?: (h, state: DropdownDisplayArgs, originator?: CustomRenderOriginator) => any
|
|
89
90
|
customIdProperty?: string;
|
|
90
91
|
}
|
|
91
92
|
|
|
@@ -115,6 +116,8 @@ class DropdownSelect2Helper {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
type CustomRenderOriginator = 'default' | 'mobile';
|
|
120
|
+
|
|
118
121
|
@Component
|
|
119
122
|
class DropdownListComponent extends TsxComponent<DropdownListArgs> implements DropdownListArgs {
|
|
120
123
|
@Prop() label!: string;
|
|
@@ -159,8 +162,8 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
159
162
|
@Prop() placeholder: string;
|
|
160
163
|
@Prop() noResultsFound: () => void;
|
|
161
164
|
@Prop() marginType?: MarginType;
|
|
162
|
-
@Prop()
|
|
163
|
-
@Prop()
|
|
165
|
+
@Prop() customRenderOption?: (h, state: DropdownDisplayArgs, originator?: CustomRenderOriginator) => any
|
|
166
|
+
@Prop() customRenderSelectionResult?: (h, state: DropdownDisplayArgs, originator?: CustomRenderOriginator) => any
|
|
164
167
|
@Prop() disabled?: boolean;
|
|
165
168
|
@Prop() disableSearch?: boolean;
|
|
166
169
|
@Prop() containerCssClass?: string;
|
|
@@ -411,7 +414,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
411
414
|
}
|
|
412
415
|
|
|
413
416
|
return (
|
|
414
|
-
<span onClick={e => this.showMobilePicker(
|
|
417
|
+
<span onClick={e => this.showMobilePicker(h)} class={`select2 select2-container select2-container--default s2-pseudo maxwidth-input ${this.getRootBaseCssClass()}`} dir="ltr">
|
|
415
418
|
<span class="selection">
|
|
416
419
|
<span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true">
|
|
417
420
|
<span class="select2-selection__rendered mbl-ddl-text" title={selectedText} style="font-size: inherit;">
|
|
@@ -427,15 +430,15 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
427
430
|
);
|
|
428
431
|
}
|
|
429
432
|
|
|
430
|
-
|
|
433
|
+
getCustomFormatOptions(h: any, originator: CustomRenderOriginator) {
|
|
431
434
|
if (this.trailingButton) {
|
|
432
435
|
const self = this;
|
|
433
436
|
return (row) => {
|
|
434
437
|
const retVal = $(`<span class="s2-ri-withtb">${row.text
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
438
|
+
}<button class="s2-trailing-button ${self.trailingButton.cssClass || ''
|
|
439
|
+
} btn-sm">${self.trailingButton.icon != null ? `<i class="${self.trailingButton.icon}"></i> ` : ''
|
|
440
|
+
}${self.trailingButton.text || ''
|
|
441
|
+
}</button></span>`);
|
|
439
442
|
retVal.find('button').click((e) => {
|
|
440
443
|
try {
|
|
441
444
|
clearTimeout(self.preventDefaultTimeout);
|
|
@@ -457,13 +460,27 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
457
460
|
};
|
|
458
461
|
}
|
|
459
462
|
|
|
460
|
-
if (this.
|
|
461
|
-
return this.
|
|
463
|
+
if (this.customRenderOption) {
|
|
464
|
+
return this.handleCustomRenderResult(h, this.customRenderOption, originator);
|
|
462
465
|
}
|
|
463
466
|
|
|
464
467
|
return null;
|
|
465
468
|
}
|
|
466
469
|
|
|
470
|
+
private handleCustomRenderResult(h: any, renderFunc: any, originator: CustomRenderOriginator) {
|
|
471
|
+
return (item: any, container: any) => {
|
|
472
|
+
const result = renderFunc(h, item, originator);
|
|
473
|
+
if (result?.__v_isVNode) {
|
|
474
|
+
const container = document.createElement('span')
|
|
475
|
+
// vue render accepts VNodeChild
|
|
476
|
+
render(result as any, container)
|
|
477
|
+
return (container.firstElementChild ?? container) as HTMLElement
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return result;
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
|
|
467
484
|
isOptionGroupBinding(): boolean {
|
|
468
485
|
if (this.options == null) {
|
|
469
486
|
return false;
|
|
@@ -477,7 +494,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
477
494
|
return false;
|
|
478
495
|
}
|
|
479
496
|
|
|
480
|
-
showMobilePicker(
|
|
497
|
+
showMobilePicker(h: any) {
|
|
481
498
|
const opts = this.getOptions();
|
|
482
499
|
let selectedItems = this.getSelectedItems();
|
|
483
500
|
let dropDown = new FilterableSelect({
|
|
@@ -498,12 +515,12 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
498
515
|
autoInputFocus: !PortalUtils.treatAsMobileDevice(),
|
|
499
516
|
selectedIds: selectedItems.map(p => p.id),
|
|
500
517
|
useListviewBuilder: false,
|
|
501
|
-
formatSelection: this.
|
|
502
|
-
formatResult: this.
|
|
518
|
+
formatSelection: this.customRenderSelectionResult != null ? this.handleCustomRenderResult(h, this.customRenderSelectionResult, 'mobile') : null,
|
|
519
|
+
formatResult: this.getCustomFormatOptions(h, 'mobile'),
|
|
503
520
|
onItemSelected: (items, exclusivity) => {
|
|
504
521
|
this.currentExclusivity = exclusivity;
|
|
505
522
|
this.raiseChangedEvent(items, true);
|
|
506
|
-
this.setMobilePickerInputText(items);
|
|
523
|
+
this.setMobilePickerInputText(h, items);
|
|
507
524
|
},
|
|
508
525
|
});
|
|
509
526
|
|
|
@@ -515,11 +532,11 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
515
532
|
dropDown.open();
|
|
516
533
|
}
|
|
517
534
|
|
|
518
|
-
setMobilePickerInputText(items: DropdownDisplayArgs[]): void {
|
|
535
|
+
setMobilePickerInputText(h: any, items: DropdownDisplayArgs[]): void {
|
|
519
536
|
this.$nextTick(() => {
|
|
520
537
|
let selectedText = this.getMobileSelectionText();
|
|
521
538
|
const textContext = $(this.$el).find('.mbl-ddl-text') as any;
|
|
522
|
-
const isPlaceholder = items.length == 0;
|
|
539
|
+
const isPlaceholder = (items || []).length == 0;
|
|
523
540
|
|
|
524
541
|
if (isNullOrEmpty(selectedText)) {
|
|
525
542
|
selectedText = this.placeholder;
|
|
@@ -529,25 +546,29 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
529
546
|
selectedText = `[${PowerduckState.getResourceValue('all')}]`;
|
|
530
547
|
}
|
|
531
548
|
|
|
532
|
-
if (this.
|
|
549
|
+
if (this.customRenderSelectionResult == null) {
|
|
533
550
|
textContext.attr('title', selectedText);
|
|
534
551
|
textContext.text(selectedText);
|
|
535
552
|
} else {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
553
|
+
const renderFunc = this.handleCustomRenderResult(h, this.customRenderSelectionResult, 'mobile');
|
|
554
|
+
textContext.html('');
|
|
555
|
+
for (const item of items) {
|
|
556
|
+
const response = renderFunc(item, textContext[0]);
|
|
557
|
+
if (response != null) {
|
|
558
|
+
textContext[0].appendChild(response);
|
|
559
|
+
}
|
|
539
560
|
}
|
|
540
561
|
|
|
541
|
-
const result = this.formatResult(item);
|
|
542
|
-
if (isNullOrEmpty(result)) {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
} else if ((result as any).jquery) {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
} else {
|
|
549
|
-
|
|
550
|
-
}
|
|
562
|
+
// const result = this.formatResult(item);
|
|
563
|
+
// if (isNullOrEmpty(result)) {
|
|
564
|
+
// textContext.attr('title', selectedText);
|
|
565
|
+
// textContext.text(selectedText);
|
|
566
|
+
// } else if ((result as any).jquery) {
|
|
567
|
+
// textContext.html('');
|
|
568
|
+
// textContext.append(result);
|
|
569
|
+
// } else {
|
|
570
|
+
// textContext.text(result as any);
|
|
571
|
+
// }
|
|
551
572
|
}
|
|
552
573
|
|
|
553
574
|
if (isPlaceholder) {
|
|
@@ -915,13 +936,13 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
915
936
|
};
|
|
916
937
|
}
|
|
917
938
|
|
|
918
|
-
const
|
|
919
|
-
if (
|
|
920
|
-
s2Args.templateResult =
|
|
939
|
+
const customFormatOptions = this.getCustomFormatOptions(h, 'default');
|
|
940
|
+
if (customFormatOptions != null) {
|
|
941
|
+
s2Args.templateResult = customFormatOptions;
|
|
921
942
|
}
|
|
922
943
|
|
|
923
|
-
if (this.
|
|
924
|
-
s2Args.templateSelection = this.
|
|
944
|
+
if (this.customRenderSelectionResult != null) {
|
|
945
|
+
s2Args.templateSelection = this.handleCustomRenderResult(h, this.customRenderSelectionResult, 'default');
|
|
925
946
|
}
|
|
926
947
|
|
|
927
948
|
const modalContent = $(this.$el).closest('.modal-content');
|
|
@@ -953,7 +974,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
953
974
|
}
|
|
954
975
|
|
|
955
976
|
if (this.tagsButtons != null) {
|
|
956
|
-
if (tagsTemplate == null && this.tagsShouldPrependContent != false && this.
|
|
977
|
+
if (tagsTemplate == null && this.tagsShouldPrependContent != false && this.customRenderSelectionResult == null) {
|
|
957
978
|
validTagsButtons = true;
|
|
958
979
|
tagsTemplate
|
|
959
980
|
= '<li class="select2-selection__choice select2-selection__choice-with-button"><span class="select2-selection__choice__remove" role="presentation"><i class="fas fa-times"></i></span></li>';
|
|
@@ -1216,7 +1237,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
1216
1237
|
mounted() {
|
|
1217
1238
|
this.updateSelect2();
|
|
1218
1239
|
this.$nextTick(() => {
|
|
1219
|
-
this.setMobilePickerInputText(this.getSelectedItems());
|
|
1240
|
+
this.setMobilePickerInputText(h, this.getSelectedItems());
|
|
1220
1241
|
});
|
|
1221
1242
|
}
|
|
1222
1243
|
|
|
@@ -11,16 +11,12 @@ interface LanguageDropdownArgs extends FormItemWrapperArgs {
|
|
|
11
11
|
changed?: (newValue: LanguageUtils.LanguageListItem) => void;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function getFlaggedResult(item):
|
|
14
|
+
function getFlaggedResult(h, item): any {
|
|
15
15
|
if (item.dataRow != null) {
|
|
16
|
-
return
|
|
16
|
+
return (<span><img class="flag" src={LanguageUtils.getLanguageFlagUrl(item.dataRow.flag, false)} /> ${item.dataRow.text}</span>);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
return item.text;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return '';
|
|
19
|
+
return (<span>{item.text || ''}</span>);
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
@Component
|
|
@@ -54,12 +50,8 @@ class LanguageDropdownComponent extends TsxComponent<LanguageDropdownArgs> imple
|
|
|
54
50
|
options={LanguageUtils.getLanguageList()}
|
|
55
51
|
displayMember="text"
|
|
56
52
|
valueMember="id"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}}
|
|
60
|
-
formatSelection={(e) => {
|
|
61
|
-
return getFlaggedResult(e);
|
|
62
|
-
}}
|
|
53
|
+
customRenderOption={(h, item, o) => { return getFlaggedResult(h, item); }}
|
|
54
|
+
customRenderSelectionResult={(h, item, o) => { return getFlaggedResult(h, item); }}
|
|
63
55
|
wrap={this.wrap}
|
|
64
56
|
mandatory={this.mandatory}
|
|
65
57
|
label={this.label}
|
|
@@ -27,8 +27,8 @@ export interface FilterableSelectArgs {
|
|
|
27
27
|
iScroll?: boolean;
|
|
28
28
|
iframeTopMode?: boolean;
|
|
29
29
|
cssClass?: string;
|
|
30
|
-
formatResult?: (state: any, originator?: string) =>
|
|
31
|
-
formatSelection?: (state: any, originator?: string) =>
|
|
30
|
+
formatResult?: (state: any, originator?: string) => HTMLElement;
|
|
31
|
+
formatSelection?: (state: any, originator?: string) => HTMLElement;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface FilterableSelectDataSource {
|
|
@@ -230,33 +230,6 @@ export default function FilterableSelect(this: any, args: FilterableSelectArgs):
|
|
|
230
230
|
return itemLine;
|
|
231
231
|
};
|
|
232
232
|
|
|
233
|
-
if (args.formatResult != null) {
|
|
234
|
-
this._getRowValuePerf = (item) => {
|
|
235
|
-
const formatedResult = args.formatResult(item, 'fdd');
|
|
236
|
-
if ((formatedResult as any).jquery) {
|
|
237
|
-
return (formatedResult[0] as any).outerHTML;
|
|
238
|
-
} else {
|
|
239
|
-
return formatedResult;
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
} else {
|
|
243
|
-
this._getRowValuePerf = item => htmlEscape(item.text);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
this._getRowLineWithSelectedPerf = (item): string => {
|
|
247
|
-
if (hasOptionGroups) {
|
|
248
|
-
if ((item as any).isOptionGroup == true) {
|
|
249
|
-
return `<li class="filterabledd-item filterabledd-optgroup fdd-noselected" data-id="${item.id}"><a href="javascript:" class="fdd-item-link fdd-item-content"><div class="fdd-item-inner fdd-inner"><div class="fdd-item-title fdd-item">${this._getRowValuePerf(item)}</div></div></a></li>`;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
if (this.selectedIds == null || !this.selectedIds.includes(item.id)) {
|
|
254
|
-
return `<li class="filterabledd-item filterabledd-item-perf fdd-noselected" data-id="${item.id}">${this._getRowValuePerf(item)}</li>`;
|
|
255
|
-
} else {
|
|
256
|
-
return `<li class="filterabledd-item filterabledd-item-perf fdd-selected" data-id="${item.id}">${this._getRowValuePerf(item)}</li>`;
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
|
|
260
233
|
this._handleItemClick = (targetElem) => {
|
|
261
234
|
const sender = $(targetElem);
|
|
262
235
|
const liSender = (sender.is('li') ? sender : sender.closest('li'));
|
|
@@ -361,16 +334,71 @@ export default function FilterableSelect(this: any, args: FilterableSelectArgs):
|
|
|
361
334
|
builder._getRowLine = this._getRowLineWithSelected;
|
|
362
335
|
builder.build();
|
|
363
336
|
} else {
|
|
364
|
-
let builder = '';
|
|
365
|
-
for (const item of data) {
|
|
366
|
-
builder += this._getRowLineWithSelectedPerf(item);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
337
|
const listContainer = document.createElement('ul');
|
|
370
338
|
listContainer.onclick = (e) => {
|
|
371
339
|
this._handleItemClick(e.target);
|
|
372
340
|
};
|
|
373
|
-
|
|
341
|
+
|
|
342
|
+
const rebuildData = (filter: string) => {
|
|
343
|
+
const frag = document.createDocumentFragment();
|
|
344
|
+
let opData = data;
|
|
345
|
+
let _setRowValue: (item: any, el: HTMLElement) => void;
|
|
346
|
+
|
|
347
|
+
if (args.formatResult != null) {
|
|
348
|
+
_setRowValue = (item, el) => {
|
|
349
|
+
const formatedResult = args.formatResult(item, 'fdd');
|
|
350
|
+
if ((formatedResult as any).setAttribute) {
|
|
351
|
+
el.appendChild(formatedResult as any);
|
|
352
|
+
} else if ((formatedResult as any).jquery) {
|
|
353
|
+
el.appendChild(formatedResult[0] as any);
|
|
354
|
+
} else {
|
|
355
|
+
return el.innerHTML = (formatedResult as any || '');
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
} else {
|
|
359
|
+
_setRowValue = (item, el) => {
|
|
360
|
+
el.innerHTML = htmlEscape(item.text);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (filter?.length > 0) {
|
|
365
|
+
opData = [];
|
|
366
|
+
for (const item of data) {
|
|
367
|
+
if ((item as any).filterValue.includes(filter)) {
|
|
368
|
+
opData.push(item);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
for (const item of opData) {
|
|
374
|
+
const newEl = document.createElement('li');
|
|
375
|
+
newEl.setAttribute('data-id', item.id);
|
|
376
|
+
|
|
377
|
+
if (hasOptionGroups && (item as any).isOptionGroup == true) {
|
|
378
|
+
newEl.setAttribute('class', 'filterabledd-item filterabledd-optgroup fdd-noselected');
|
|
379
|
+
newEl.innerHTML = `<a href="javascript:" class="fdd-item-link fdd-item-content"><div class="fdd-item-inner fdd-inner"><div class="fdd-item-title fdd-item"></div></div></a>`;
|
|
380
|
+
const targetElem = newEl.querySelector('.fdd-item');
|
|
381
|
+
_setRowValue(item, targetElem as any);
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
} else {
|
|
385
|
+
if (this.selectedIds == null || !this.selectedIds.includes(item.id)) {
|
|
386
|
+
newEl.setAttribute('class', 'filterabledd-item filterabledd-item-perf fdd-noselected');
|
|
387
|
+
} else {
|
|
388
|
+
newEl.setAttribute('class', 'filterabledd-item filterabledd-item-perf fdd-selected');
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
_setRowValue(item, newEl);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
frag.appendChild(newEl);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
listContainer.innerHTML = '';
|
|
398
|
+
listContainer.appendChild(frag);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
rebuildData(null);
|
|
374
402
|
|
|
375
403
|
const targetElem = this._getTargetElement(useIscroll)[0];
|
|
376
404
|
targetElem.innerHTML = `<div class="lvb-filter-container filterableSelectFilter ${cssClass || ''}"><div class="lvb-filter-erase"><span class="far fa-trash-alt"></span></div><input type="text" class="lvb-filter-input" placeholder="Search..."></div>`;
|
|
@@ -394,21 +422,7 @@ export default function FilterableSelect(this: any, args: FilterableSelectArgs):
|
|
|
394
422
|
const currVal = latinize((searchInput.val() || '').toString().toLowerCase());
|
|
395
423
|
if (currVal != this._filterVal) {
|
|
396
424
|
this._filterVal = currVal;
|
|
397
|
-
|
|
398
|
-
let builder = '';
|
|
399
|
-
if (currVal == '') {
|
|
400
|
-
for (const item of data) {
|
|
401
|
-
builder += this._getRowLineWithSelectedPerf(item);
|
|
402
|
-
}
|
|
403
|
-
} else {
|
|
404
|
-
for (const item of data) {
|
|
405
|
-
if ((item as any).filterValue.includes(currVal)) {
|
|
406
|
-
builder += this._getRowLineWithSelectedPerf(item);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
listContainer.innerHTML = builder;
|
|
425
|
+
rebuildData(currVal);
|
|
412
426
|
}
|
|
413
427
|
}, 400);
|
|
414
428
|
});
|