Skip to content

Commit 3f86ba4

Browse files
committed
Updating CHANGELOG, tom-select 2.2.2 & building
1 parent aae7bc0 commit 3f86ba4

File tree

10 files changed

+82
-75
lines changed

10 files changed

+82
-75
lines changed

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const wildcardExternalsPlugin = (peerDependencies) => ({
3838
}
3939
});
4040

41-
const files = glob.sync("src/React/assets/src/*controller.ts");
41+
const files = glob.sync('src/*/assets/src/*controller.ts');
4242
const packages = files.map((file) => {
4343
const absolutePath = path.join(__dirname, file);
4444
const packageData = require(pkgUp.sync({ cwd: absolutePath }));

src/Autocomplete/CHANGELOG.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# CHANGELOG
22

3-
## Unreleased
4-
5-
- Add support for recent versions of Tom Select
6-
73
## 2.6.0
84

95
- [BC BREAK]: The path to `routes.php` changed and you should update your
@@ -17,8 +13,12 @@ ux_autocomplete:
1713
prefix: '/autocomplete'
1814
```
1915

20-
- Fix issue where `max_results` was not passed as a Stimulus value (#538)
21-
- Add all possible stylesheets for tom-select to the autoimport to choose from
16+
- Add support for `tom-select` version `2.2.2` and made this the minimum-supported
17+
version.
18+
- Added support for the `preload` TomSelect option.
19+
- Fix don't add WHERE IN criteria without params (#561).
20+
- Fix issue where `max_results` was not passed as a Stimulus value (#538).
21+
- Add all possible stylesheets for tom-select to the autoimport to choose from.
2222

2323
## 2.5.0
2424

src/Autocomplete/assets/dist/controller.js

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ function __classPrivateFieldGet(receiver, state, kind, f) {
2222
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2323
}
2424

25-
var _default_1_instances, _default_1_getCommonConfig, _default_1_createAutocomplete, _default_1_createAutocompleteWithHtmlContents, _default_1_createAutocompleteWithRemoteData, _default_1_stripTags, _default_1_mergeObjects, _default_1_createTomSelect, _default_1_dispatchEvent;
25+
var _instances, _getCommonConfig, _createAutocomplete, _createAutocompleteWithHtmlContents, _createAutocompleteWithRemoteData, _stripTags, _mergeObjects, _createTomSelect, _dispatchEvent;
2626
class default_1 extends Controller {
2727
constructor() {
2828
super(...arguments);
29-
_default_1_instances.add(this);
29+
_instances.add(this);
3030
}
3131
initialize() {
3232
this.element.setAttribute('data-live-ignore', '');
@@ -39,14 +39,14 @@ class default_1 extends Controller {
3939
}
4040
connect() {
4141
if (this.urlValue) {
42-
this.tomSelect = __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_createAutocompleteWithRemoteData).call(this, this.urlValue, this.minCharactersValue);
42+
this.tomSelect = __classPrivateFieldGet(this, _instances, "m", _createAutocompleteWithRemoteData).call(this, this.urlValue, this.minCharactersValue);
4343
return;
4444
}
4545
if (this.optionsAsHtmlValue) {
46-
this.tomSelect = __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_createAutocompleteWithHtmlContents).call(this);
46+
this.tomSelect = __classPrivateFieldGet(this, _instances, "m", _createAutocompleteWithHtmlContents).call(this);
4747
return;
4848
}
49-
this.tomSelect = __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_createAutocomplete).call(this);
49+
this.tomSelect = __classPrivateFieldGet(this, _instances, "m", _createAutocomplete).call(this);
5050
}
5151
disconnect() {
5252
this.tomSelect.revertSettings.innerHTML = this.element.innerHTML;
@@ -65,14 +65,19 @@ class default_1 extends Controller {
6565
return this.element;
6666
}
6767
get preload() {
68-
if (this.preloadValue == 'false')
68+
if (!this.hasPreloadValue) {
69+
return 'focus';
70+
}
71+
if (this.preloadValue == 'false') {
6972
return false;
70-
if (this.preloadValue == 'true')
73+
}
74+
if (this.preloadValue == 'true') {
7175
return true;
76+
}
7277
return this.preloadValue;
7378
}
7479
}
75-
_default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _default_1_getCommonConfig() {
80+
_instances = new WeakSet(), _getCommonConfig = function _getCommonConfig() {
7681
const plugins = {};
7782
const isMultiple = !this.selectElement || this.selectElement.multiple;
7883
if (!this.formElement.disabled && !isMultiple) {
@@ -87,7 +92,7 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
8792
const render = {
8893
no_results: () => {
8994
return `<div class="no-results">${this.noResultsFoundTextValue}</div>`;
90-
}
95+
},
9196
};
9297
const config = {
9398
render: render,
@@ -104,19 +109,19 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
104109
if (!this.selectElement && !this.urlValue) {
105110
config.shouldLoad = () => false;
106111
}
107-
return __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_mergeObjects).call(this, config, this.tomSelectOptionsValue);
108-
}, _default_1_createAutocomplete = function _default_1_createAutocomplete() {
109-
const config = __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_mergeObjects).call(this, __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_getCommonConfig).call(this), {
112+
return __classPrivateFieldGet(this, _instances, "m", _mergeObjects).call(this, config, this.tomSelectOptionsValue);
113+
}, _createAutocomplete = function _createAutocomplete() {
114+
const config = __classPrivateFieldGet(this, _instances, "m", _mergeObjects).call(this, __classPrivateFieldGet(this, _instances, "m", _getCommonConfig).call(this), {
110115
maxOptions: this.selectElement ? this.selectElement.options.length : 50,
111116
});
112-
return __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_createTomSelect).call(this, config);
113-
}, _default_1_createAutocompleteWithHtmlContents = function _default_1_createAutocompleteWithHtmlContents() {
114-
const config = __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_mergeObjects).call(this, __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_getCommonConfig).call(this), {
117+
return __classPrivateFieldGet(this, _instances, "m", _createTomSelect).call(this, config);
118+
}, _createAutocompleteWithHtmlContents = function _createAutocompleteWithHtmlContents() {
119+
const config = __classPrivateFieldGet(this, _instances, "m", _mergeObjects).call(this, __classPrivateFieldGet(this, _instances, "m", _getCommonConfig).call(this), {
115120
maxOptions: this.selectElement ? this.selectElement.options.length : 50,
116121
score: (search) => {
117122
const scoringFunction = this.tomSelect.getScoreFunction(search);
118123
return (item) => {
119-
return scoringFunction(Object.assign(Object.assign({}, item), { text: __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_stripTags).call(this, item.text) }));
124+
return scoringFunction(Object.assign(Object.assign({}, item), { text: __classPrivateFieldGet(this, _instances, "m", _stripTags).call(this, item.text) }));
120125
};
121126
},
122127
render: {
@@ -125,21 +130,24 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
125130
},
126131
option: function (item) {
127132
return `<div>${item.text}</div>`;
128-
}
133+
},
129134
},
130135
});
131-
return __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_createTomSelect).call(this, config);
132-
}, _default_1_createAutocompleteWithRemoteData = function _default_1_createAutocompleteWithRemoteData(autocompleteEndpointUrl, minCharacterLength) {
133-
const config = __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_mergeObjects).call(this, __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_getCommonConfig).call(this), {
136+
return __classPrivateFieldGet(this, _instances, "m", _createTomSelect).call(this, config);
137+
}, _createAutocompleteWithRemoteData = function _createAutocompleteWithRemoteData(autocompleteEndpointUrl, minCharacterLength) {
138+
const config = __classPrivateFieldGet(this, _instances, "m", _mergeObjects).call(this, __classPrivateFieldGet(this, _instances, "m", _getCommonConfig).call(this), {
134139
firstUrl: (query) => {
135140
const separator = autocompleteEndpointUrl.includes('?') ? '&' : '?';
136141
return `${autocompleteEndpointUrl}${separator}query=${encodeURIComponent(query)}`;
137142
},
138143
load: function (query, callback) {
139144
const url = this.getUrl(query);
140145
fetch(url)
141-
.then(response => response.json())
142-
.then(json => { this.setNextUrl(query, json.next_page); callback(json.results); })
146+
.then((response) => response.json())
147+
.then((json) => {
148+
this.setNextUrl(query, json.next_page);
149+
callback(json.results);
150+
})
143151
.catch(() => callback());
144152
},
145153
shouldLoad: function (query) {
@@ -167,17 +175,17 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
167175
},
168176
preload: this.preload,
169177
});
170-
return __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_createTomSelect).call(this, config);
171-
}, _default_1_stripTags = function _default_1_stripTags(string) {
178+
return __classPrivateFieldGet(this, _instances, "m", _createTomSelect).call(this, config);
179+
}, _stripTags = function _stripTags(string) {
172180
return string.replace(/(<([^>]+)>)/gi, '');
173-
}, _default_1_mergeObjects = function _default_1_mergeObjects(object1, object2) {
181+
}, _mergeObjects = function _mergeObjects(object1, object2) {
174182
return Object.assign(Object.assign({}, object1), object2);
175-
}, _default_1_createTomSelect = function _default_1_createTomSelect(options) {
176-
__classPrivateFieldGet(this, _default_1_instances, "m", _default_1_dispatchEvent).call(this, 'autocomplete:pre-connect', { options });
183+
}, _createTomSelect = function _createTomSelect(options) {
184+
__classPrivateFieldGet(this, _instances, "m", _dispatchEvent).call(this, 'autocomplete:pre-connect', { options });
177185
const tomSelect = new TomSelect(this.formElement, options);
178-
__classPrivateFieldGet(this, _default_1_instances, "m", _default_1_dispatchEvent).call(this, 'autocomplete:connect', { tomSelect, options });
186+
__classPrivateFieldGet(this, _instances, "m", _dispatchEvent).call(this, 'autocomplete:connect', { tomSelect, options });
179187
return tomSelect;
180-
}, _default_1_dispatchEvent = function _default_1_dispatchEvent(name, payload) {
188+
}, _dispatchEvent = function _dispatchEvent(name, payload) {
181189
this.element.dispatchEvent(new CustomEvent(name, { detail: payload, bubbles: true }));
182190
};
183191
default_1.values = {

src/Autocomplete/assets/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
"enabled": true,
1515
"autoimport": {
1616
"tom-select/dist/css/tom-select.default.css": true,
17-
"tom-select/dist/css/tom-select.bootstrap4.css": false,
1817
"tom-select/dist/css/tom-select.bootstrap5.css": false
1918
}
2019
}
2120
}
2221
},
2322
"peerDependencies": {
2423
"@hotwired/stimulus": "^3.0.0",
25-
"tom-select": "^2.0.1"
24+
"tom-select": "^2.2.2"
2625
},
2726
"devDependencies": {
2827
"@hotwired/stimulus": "^3.0.0",

src/Autocomplete/assets/src/controller.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default class extends Controller {
1919
readonly noResultsFoundTextValue: string;
2020
readonly minCharactersValue: number;
2121
readonly tomSelectOptionsValue: object;
22+
readonly hasPreloadValue: boolean;
2223
readonly preloadValue: string;
2324
tomSelect: TomSelect;
2425

@@ -225,6 +226,10 @@ export default class extends Controller {
225226
}
226227

227228
get preload() {
229+
if (!this.hasPreloadValue) {
230+
return 'focus';
231+
}
232+
228233
if (this.preloadValue == 'false') {
229234
return false;
230235
}

src/Autocomplete/doc/index.rst

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -167,28 +167,16 @@ Styling Tom Select
167167
In your ``assets/controllers.json`` file, you should see a line that automatically
168168
includes a CSS file for Tom Select which will give you basic styles.
169169

170-
.. code-block:: text
171-
172-
"autoimport": {
173-
"tom-select/dist/css/tom-select.default.css": true
174-
}
175-
176-
If you're using Bootstrap, you can get Bootstrap-ready styling by
177-
changing this line to ``false``:
170+
If you're using Bootstrap, set ``tom-select.default.css`` to false
171+
and ``tom-select.bootstrap5.css`` to true:
178172

179173
.. code-block:: text
180174
181175
"autoimport": {
182-
"tom-select/dist/css/tom-select.default.css": false
176+
"tom-select/dist/css/tom-select.default.css": false,
177+
"tom-select/dist/css/tom-select.bootstrap5.css": true
183178
}
184179
185-
And then importing the Bootstrap CSS file:
186-
187-
.. code-block:: css
188-
189-
/* assets/styles/app.css */
190-
@import 'tom-select/dist/css/tom-select.bootstrap5.css';
191-
192180
To further customize things, you can override the classes with your own custom
193181
CSS and even control how individual parts of Tom Select render. See `Tom Select Render Templates`_.
194182

@@ -382,7 +370,7 @@ This only works for Doctrine entities: see `Manually using the Stimulus Controll
382370
if you're autocompleting something other than an entity.
383371

384372
To expose the endpoint, create a class that implements ``Symfony\UX\Autocomplete\EntityAutocompleterInterface``
385-
and tag this service with ``ux.entity_autocompleter`` and include an ``alias``::
373+
and tag this service with ``ux.entity_autocompleter``, including an ``alias`` option::
386374

387375
namespace App\Autocompleter;
388376

src/LiveComponent/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ live_component:
1414
+ prefix: /_components
1515
```
1616

17+
- Removed `Content-Type` header when returning the empty response redirect.
18+
- Fixed bug when re-rendering SVG's (.#557)
19+
1720
## 2.5.0
1821

1922
- [BEHAVIOR CHANGE] Previously, Ajax calls could happen in parallel (if

0 commit comments

Comments
 (0)