@symfony/ux-autocomplete 2.30.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/README.md +1 -1
- package/dist/controller.d.ts +1 -1
- package/dist/controller.js +15 -4
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ composer require symfony/ux-autocomplete:2.23.0
|
|
|
14
14
|
npm add @symfony/ux-autocomplete@2.23.0
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
**Tip:** Your `package.json` file will be automatically modified by [Flex](https://github.com/symfony/flex) when installing or upgrading a PHP package. To prevent this behavior, ensure to **use at least Flex 1.22.0 or 2.5.0**, and run `composer config extra.symfony
|
|
17
|
+
**Tip:** Your `package.json` file will be automatically modified by [Flex](https://github.com/symfony/flex) when installing or upgrading a PHP package. To prevent this behavior, ensure to **use at least Flex 1.22.0 or 2.5.0**, and run `composer config --json "extra.symfony/flex.synchronize_package_json" false`.
|
|
18
18
|
|
|
19
19
|
## Resources
|
|
20
20
|
|
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,12 +310,13 @@ 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: {
|
|
319
|
+
...commonConfig.render,
|
|
309
320
|
item: (item) => `<div>${item[labelField]}</div>`,
|
|
310
321
|
option: (item) => `<div>${item[labelField]}</div>`
|
|
311
322
|
}
|
|
@@ -344,7 +355,7 @@ createAutocompleteWithRemoteData_fn = function(autocompleteEndpointUrl, minChara
|
|
|
344
355
|
},
|
|
345
356
|
optgroupField: "group_by",
|
|
346
357
|
// avoid extra filtering after results are returned
|
|
347
|
-
score: (
|
|
358
|
+
score: (_search) => (_item) => 1,
|
|
348
359
|
render: {
|
|
349
360
|
option: (item) => `<div>${item[labelField]}</div>`,
|
|
350
361
|
item: (item) => `<div>${item[labelField]}</div>`,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symfony/ux-autocomplete",
|
|
3
3
|
"description": "JavaScript Autocomplete functionality for Symfony",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.32.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"symfony-ux"
|
|
8
8
|
],
|
|
@@ -57,8 +57,9 @@
|
|
|
57
57
|
"build": "tsx ../../../bin/build_package.ts .",
|
|
58
58
|
"watch": "tsx ../../../bin/build_package.ts . --watch",
|
|
59
59
|
"test": "pnpm run test:unit && pnpm run test:browser",
|
|
60
|
-
"test:unit": "../../../bin/
|
|
61
|
-
"test:browser": "
|
|
60
|
+
"test:unit": "../../../bin/unit_test_package.sh .",
|
|
61
|
+
"test:browser": "playwright test",
|
|
62
|
+
"test:browser:ui": "playwright test --ui",
|
|
62
63
|
"check": "biome check",
|
|
63
64
|
"ci": "biome ci"
|
|
64
65
|
}
|