@symfony/ux-autocomplete 2.31.0 → 2.32.0
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/dist/controller.d.ts +1 -1
- package/dist/controller.js +14 -4
- package/package.json +1 -1
package/dist/controller.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ declare class export_default extends Controller {
|
|
|
32
32
|
readonly tomSelectOptionsValue: object;
|
|
33
33
|
readonly hasPreloadValue: boolean;
|
|
34
34
|
readonly preloadValue: string;
|
|
35
|
-
tomSelect: TomSelect;
|
|
35
|
+
tomSelect: TomSelect | undefined;
|
|
36
36
|
private mutationObserver;
|
|
37
37
|
private isObserving;
|
|
38
38
|
private hasLoadedChoicesPreviously;
|
package/dist/controller.js
CHANGED
|
@@ -65,6 +65,9 @@ var controller_default = class extends Controller {
|
|
|
65
65
|
}
|
|
66
66
|
disconnect() {
|
|
67
67
|
this.stopMutationObserver();
|
|
68
|
+
if (!this.tomSelect) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
68
71
|
let currentSelectedValues = [];
|
|
69
72
|
if (this.selectElement) {
|
|
70
73
|
if (this.selectElement.multiple) {
|
|
@@ -74,6 +77,7 @@ var controller_default = class extends Controller {
|
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
this.tomSelect.destroy();
|
|
80
|
+
this.tomSelect = void 0;
|
|
77
81
|
if (this.selectElement) {
|
|
78
82
|
if (this.selectElement.multiple) {
|
|
79
83
|
Array.from(this.selectElement.options).forEach((option) => {
|
|
@@ -136,6 +140,9 @@ var controller_default = class extends Controller {
|
|
|
136
140
|
}
|
|
137
141
|
}
|
|
138
142
|
changeTomSelectDisabledState(isDisabled) {
|
|
143
|
+
if (!this.tomSelect) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
139
146
|
this.stopMutationObserver();
|
|
140
147
|
if (isDisabled) {
|
|
141
148
|
this.tomSelect.disable();
|
|
@@ -244,11 +251,14 @@ getCommonConfig_fn = function() {
|
|
|
244
251
|
plugins,
|
|
245
252
|
// clear the text input after selecting a value
|
|
246
253
|
onItemAdd: () => {
|
|
247
|
-
this.tomSelect
|
|
254
|
+
this.tomSelect?.setTextboxValue("");
|
|
248
255
|
},
|
|
249
256
|
closeAfterSelect: true,
|
|
250
257
|
// fix positioning (in the dropdown) of options added through addOption()
|
|
251
258
|
onOptionAdd: (value, data) => {
|
|
259
|
+
if (!this.tomSelect) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
252
262
|
let parentElement = this.tomSelect.input;
|
|
253
263
|
let optgroupData = null;
|
|
254
264
|
const optgroup = data[this.tomSelect.settings.optgroupField];
|
|
@@ -300,9 +310,9 @@ createAutocompleteWithHtmlContents_fn = function() {
|
|
|
300
310
|
const config = __privateMethod(this, _instances, mergeConfigs_fn).call(this, commonConfig, {
|
|
301
311
|
maxOptions: this.getMaxOptions(),
|
|
302
312
|
score: (search) => {
|
|
303
|
-
const scoringFunction = this.tomSelect
|
|
313
|
+
const scoringFunction = this.tomSelect?.getScoreFunction(search);
|
|
304
314
|
return (item) => {
|
|
305
|
-
return scoringFunction({ ...item, text: __privateMethod(this, _instances, stripTags_fn).call(this, item[labelField]) });
|
|
315
|
+
return scoringFunction?.({ ...item, text: __privateMethod(this, _instances, stripTags_fn).call(this, item[labelField]) });
|
|
306
316
|
};
|
|
307
317
|
},
|
|
308
318
|
render: {
|
|
@@ -345,7 +355,7 @@ createAutocompleteWithRemoteData_fn = function(autocompleteEndpointUrl, minChara
|
|
|
345
355
|
},
|
|
346
356
|
optgroupField: "group_by",
|
|
347
357
|
// avoid extra filtering after results are returned
|
|
348
|
-
score: (
|
|
358
|
+
score: (_search) => (_item) => 1,
|
|
349
359
|
render: {
|
|
350
360
|
option: (item) => `<div>${item[labelField]}</div>`,
|
|
351
361
|
item: (item) => `<div>${item[labelField]}</div>`,
|