Skip to content

Commit a767b6a

Browse files
committed
Document about alternative JS assets installation with npm packages
1 parent 821f2ae commit a767b6a

File tree

20 files changed

+145
-35
lines changed

20 files changed

+145
-35
lines changed

src/Autocomplete/doc/index.rst

+12-7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ needed if you're using AssetMapper):
3030
$ npm install --force
3131
$ npm run watch
3232
33+
.. note::
34+
35+
Alternatively, the `@symfony/ux-autocomplete package`_ can be used to install the JavaScript assets without requiring PHP.
36+
3337
Usage in a Form (without Ajax)
3438
------------------------------
3539

@@ -288,7 +292,7 @@ Passing Extra Options to the Ajax-powered Autocomplete
288292

289293
Autocomplete field options are **not preserved** when the field is rendered
290294
on an Ajax call. So, features like exclude some options based on the current
291-
form data are not possible by default.
295+
form data are not possible by default.
292296

293297
To partially avoid this limitation, the ``extra_options`` option was added.
294298

@@ -299,7 +303,7 @@ To partially avoid this limitation, the ``extra_options`` option was added.
299303
can be passed as extra options.
300304

301305
Considering the following example, when the form type is rendered for the first
302-
time, it will use the ``query_builder`` defined while adding a ``food`` field
306+
time, it will use the ``query_builder`` defined while adding a ``food`` field
303307
to the ``FoodForm``. However, when the Ajax is used to fetch the results, on
304308
the consequent renders, the default ``query_builder`` will be used::
305309

@@ -324,8 +328,8 @@ the consequent renders, the default ``query_builder`` will be used::
324328
}
325329
}
326330

327-
If some food can be consisted of other foods, we might want to exclude the
328-
"root" food from the list of available foods. To achieve this, we can remove
331+
If some food can be consisted of other foods, we might want to exclude the
332+
"root" food from the list of available foods. To achieve this, we can remove
329333
the ``query_builder`` option from the above example and pass the ``excluded_foods``
330334
extra option to the ``FoodAutocompleteField``::
331335

@@ -600,13 +604,13 @@ Passing Extra Options to the Autocompleter
600604

601605
The ability to pass extra options was added in Autocomplete 2.14.
602606

603-
If you need to pass extra options to the autocompleter, you can do so by
604-
implementing the ``\Symfony\UX\Autocomplete\OptionsAwareEntityAutocompleterInterface``
607+
If you need to pass extra options to the autocompleter, you can do so by
608+
implementing the ``\Symfony\UX\Autocomplete\OptionsAwareEntityAutocompleterInterface``
605609
interface.
606610

607611
.. tip::
608612

609-
If you want to know **why** you might need to use the ``extra_options``
613+
If you want to know **why** you might need to use the ``extra_options``
610614
feature, see :ref:`passing-extra-options-to-the-ajax-powered-autocomplete`.
611615

612616
.. code-block:: diff
@@ -757,3 +761,4 @@ the Symfony framework: https://symfony.com/doc/current/contributing/code/bc.html
757761
.. _`Tom Select Render Templates`: https://tom-select.js.org/docs/#render-templates
758762
.. _`Tom Select Option Group`: https://tom-select.js.org/examples/optgroups/
759763
.. _`Symfony Form`: https://symfony.com/doc/current/forms.html
764+
.. _`@symfony/ux-autocomplete package`: https://www.npmjs.com/package/@symfony/ux-autocomplete

src/Chartjs/doc/index.rst

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ needed if you're using AssetMapper):
2222
$ npm install --force
2323
$ npm run watch
2424
25+
.. note::
26+
27+
Alternatively, the `@symfony/ux-chartjs package`_ can be used to install the JavaScript assets without requiring PHP.
28+
2529
Usage
2630
-----
2731

@@ -253,3 +257,4 @@ the Symfony framework: https://symfony.com/doc/current/contributing/code/bc.html
253257
.. _`zoom plugin documentation`: https://www.chartjs.org/chartjs-plugin-zoom/latest/guide/integration.html
254258
.. _`register Chart.js plugins globally`: https://www.chartjs.org/docs/latest/developers/plugins.html
255259
.. _`Tooltip positioner`: https://www.chartjs.org/docs/latest/samples/tooltip/position.html
260+
.. _`@symfony/ux-chartjs package`: https://www.npmjs.com/package/@symfony/ux-chartjs

src/Cropperjs/doc/index.rst

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ needed if you're using AssetMapper):
2626
$ npm install --force
2727
$ npm run watch
2828
29+
.. note::
30+
31+
Alternatively, the `@symfony/ux-cropperjs package`_ can be used to install the JavaScript assets without requiring PHP.
32+
2933
Usage
3034
-----
3135

@@ -149,3 +153,4 @@ https://symfony.com/doc/current/contributing/code/bc.html
149153
.. _`the Symfony UX initiative`: https://ux.symfony.com/
150154
.. _`the Cropper.js options`: https://github.com/fengyuanchen/cropperjs/blob/main/README.md#options
151155
.. _StimulusBundle configured in your app: https://symfony.com/bundles/StimulusBundle/current/index.html
156+
.. _`@symfony/ux-cropperjs package`: https://www.npmjs.com/package/@symfony/ux-cropperjs

src/Dropzone/doc/index.rst

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ needed if you're using AssetMapper):
2828
$ npm install --force
2929
$ npm run watch
3030
31+
.. note::
32+
33+
Alternatively, the `@symfony/ux-dropzone package`_ can be used to install the JavaScript assets without requiring PHP.
34+
3135
Usage
3236
-----
3337

@@ -155,3 +159,4 @@ https://symfony.com/doc/current/contributing/code/bc.html
155159

156160
.. _`the Symfony UX initiative`: https://ux.symfony.com/
157161
.. _StimulusBundle configured in your app: https://symfony.com/bundles/StimulusBundle/current/index.html
162+
.. _`@symfony/ux-dropzone package`: https://www.npmjs.com/package/@symfony/ux-dropzone

src/LazyImage/doc/index.rst

+7-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ needed if you're using AssetMapper):
3636
$ npm install --force
3737
$ npm run watch
3838
39+
.. note::
40+
41+
Alternatively, the `@symfony/ux-lazy-image package`_ can be used to install the JavaScript assets without requiring PHP.
42+
3943
Usage
4044
-----
4145

@@ -216,7 +220,7 @@ on the page and should be less than 2.5 seconds. It's part of the `Core Web Vita
216220
and is used by Google to evaluate the user experience of a website, impacting
217221
the Search ranking.
218222

219-
Using the Symfony UX LazyImage for your LCP image can be a good idea at first,
223+
Using the Symfony UX LazyImage for your LCP image can be a good idea at first,
220224
but in reality, it will lower the LCP score because:
221225

222226
- `The progressive loading (through blurhash) is not taken into account in the LCP calculation`_;
@@ -239,7 +243,7 @@ A solution is to not use the Stimulus controller for the LCP image but to use
239243
width="200"
240244
height="150"
241245
/>
242-
246+
243247
This way, the browser will display the BlurHash image as soon as possible, and
244248
will load the high-definition image at the same time, without waiting for the
245249
Stimulus controller to be loaded.
@@ -262,3 +266,4 @@ https://symfony.com/doc/current/contributing/code/bc.html
262266
.. _`Core Web Vitals`: https://web.dev/vitals/
263267
.. _`The progressive loading (through blurhash) is not taken into account in the LCP calculation`: https://github.com/w3c/largest-contentful-paint/issues/71_
264268
.. _`didn't preload the image`: https://symfony.com/doc/current/web_link.html
269+
.. _`@symfony/ux-lazy-image package`: https://www.npmjs.com/package/@symfony/ux-lazy-image

src/LiveComponent/doc/index.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ needed if you're using AssetMapper):
8383
$ npm install --force
8484
$ npm run watch
8585
86+
.. note::
87+
88+
Alternatively, the `@symfony/ux-live-component package`_ can be used to install the JavaScript assets without requiring PHP.
89+
8690
If your project is localized in different languages (either via the `locale route parameter`_
8791
or by `setting the locale in the request`_) add the ``{_locale}`` attribute to
8892
the UX Live Components route definition to keep the locale between re-renders:
@@ -3790,7 +3794,7 @@ uses Symfony's test client to render and make requests to your components::
37903794
// authenticate a user ($user is instance of UserInterface)
37913795
$testComponent->actingAs($user);
37923796

3793-
// set the '_locale' route parameter (if the component route is localized)
3797+
// set the '_locale' route parameter (if the component route is localized)
37943798
$testComponent->setRouteLocale('fr');
37953799

37963800
// customize the test client
@@ -3892,3 +3896,4 @@ promise. However, any internal implementation in the JavaScript files
38923896
.. _`locale route parameter`: https://symfony.com/doc/current/translation.html#the-locale-and-the-url
38933897
.. _`setting the locale in the request`: https://symfony.com/doc/current/translation.html#translation-locale
38943898
.. _`Stimulus action parameter`: https://stimulus.hotwired.dev/reference/actions#action-parameters
3899+
.. _`@symfony/ux-live-component package`: https://www.npmjs.com/package/@symfony/ux-live-component

src/Map/doc/index.rst

+5-13
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ Install the bundle using Composer and Symfony Flex:
1616
1717
$ composer require symfony/ux-map
1818
19-
If you're using WebpackEncore, install your assets and restart Encore (not
20-
needed if you're using AssetMapper):
21-
22-
.. code-block:: terminal
23-
24-
$ npm install --force
25-
$ npm run watch
26-
2719
Configuration
2820
-------------
2921

@@ -140,25 +132,25 @@ Remove elements from Map
140132
~~~~~~~~~~~~~~~~~~~~~~~~
141133

142134
It is possible to remove elements like ``Marker``, ``Polygon`` and ``Polyline`` instances by using ``Map::remove*()`` methods::
143-
135+
144136
// Add elements
145137
$map->addMarker($marker = new Marker(/* ... */));
146138
$map->addPolygon($polygon = new Polygon(/* ... */));
147139
$map->addPolyline($polyline = new Polyline(/* ... */));
148-
140+
149141
// And later, remove those elements
150142
$map->removeMarker($marker);
151143
$map->removePolygon($polygon);
152144
$map->removePolyline($polyline);
153-
145+
154146
If unfortunately you were unable to store an element instance, you can still remove them by passing the identifier string::
155-
147+
156148
$map = new Map(/* ... */);
157149
// Add elements
158150
$map->addMarker(new Marker(id: 'my-marker', /* ... */));
159151
$map->addPolygon(new Polygon(id: 'my-polygon', /* ... */));
160152
$map->addPolyline(new Polyline(id: 'my-marker', /* ... */));
161-
153+
162154
// And later, remove those elements
163155
$map->removeMarker('my-marker');
164156
$map->removePolygon('my-polygon');

src/Map/src/Bridge/Google/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
[Google Maps](https://developers.google.com/maps/documentation/javascript/overview) integration for Symfony UX Map.
44

5+
## Installation
6+
7+
Install the bundle using Composer and Symfony Flex:
8+
9+
```shell
10+
composer require symfony/ux-google-map
11+
```
12+
13+
If you're using WebpackEncore, install your assets and restart Encore (not
14+
needed if you're using AssetMapper):
15+
16+
```shell
17+
npm install --force
18+
npm run watch
19+
```
20+
21+
> [!NOTE]
22+
> Alternatively, [@symfony/ux-google-map package](https://www.npmjs.com/package/@symfony/ux-google-map) can be used to install the JavaScript assets without requiring PHP.
23+
524
## DSN example
625

726
```dotenv

src/Map/src/Bridge/Leaflet/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
[Leaflet](https://leafletjs.com/) integration for Symfony UX Map.
44

5+
## Installation
6+
7+
Install the bundle using Composer and Symfony Flex:
8+
9+
```shell
10+
composer require symfony/ux-leaflet-map
11+
```
12+
13+
If you're using WebpackEncore, install your assets and restart Encore (not
14+
needed if you're using AssetMapper):
15+
16+
```shell
17+
npm install --force
18+
npm run watch
19+
```
20+
21+
> [!NOTE]
22+
> Alternatively, [@symfony/ux-leaflet-map package](https://www.npmjs.com/package/@symfony/ux-leaflet-map) can be used to install the JavaScript assets without requiring PHP.
23+
524
## DSN example
625

726
```dotenv

src/Notify/doc/index.rst

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ needed if you're using AssetMapper):
2525
$ npm install --force
2626
$ npm run watch
2727
28+
.. note::
29+
30+
Alternatively, the `@symfony/ux-notify package`_ can be used to install the JavaScript assets without requiring PHP.
31+
2832
Usage
2933
-----
3034

@@ -154,3 +158,4 @@ https://symfony.com/doc/current/contributing/code/bc.html
154158
.. _`Mercure`: https://mercure.rocks
155159
.. _`running Mercure server`: https://symfony.com/doc/current/mercure.html#running-a-mercure-hub
156160
.. _`native notifications`: https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API
161+
.. _`@symfony/ux-notify package`: https://www.npmjs.com/package/@symfony/ux-notify

src/React/doc/index.rst

+9-4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Next, install a package to help React:
3737
$ npm install -D @babel/preset-react --force
3838
$ npm run watch
3939
40+
.. note::
41+
42+
Alternatively, the `@symfony/ux-react package`_ can be used to install the JavaScript assets without requiring PHP.
43+
4044
That's it! Any files inside ``assets/react/controllers/`` can now be rendered as
4145
React components.
4246

@@ -99,21 +103,21 @@ Permanent components
99103
The ability to mark a component ``permanent`` was added in UX React 2.21.
100104

101105
The controller responsible to render the React components can be configured
102-
to keep the React component mounted when the root element is removed from
106+
to keep the React component mounted when the root element is removed from
103107
the DOM, using the ``permanent`` option.
104108

105109
This is particularly useful when the root element of a component is moved around
106-
in the DOM or is removed and immediately re-added to the DOM (e.g. when using
110+
in the DOM or is removed and immediately re-added to the DOM (e.g. when using
107111
`Turbo`_ and its `data-turbo-permanent` attribute).
108112

109113
.. code-block:: html+twig
110114

111115
{# templates/home.html.twig #}
112116
{% extends 'base.html.twig' %}
113-
117+
114118
{# The React component will stay mounted if the div is moved in the DOM #}
115119
<div {{ react_component('Hello', {fullName: 'Fabien'}, {permanent: true}) }}>
116-
Loading...
120+
Loading...
117121
</div>
118122

119123
.. _using-with-asset-mapper:
@@ -156,3 +160,4 @@ https://symfony.com/doc/current/contributing/code/bc.html
156160
.. _`Symfony UX initiative`: https://ux.symfony.com/
157161
.. _`Symfony UX React demo`: https://ux.symfony.com/react
158162
.. _`Turbo`: https://turbo.hotwire.dev/
163+
.. _`@symfony/ux-react package`: https://www.npmjs.com/package/@symfony/ux-react

src/StimulusBundle/doc/index.rst

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ necessary files. If not, or you're curious, see :ref:`Manual Setup <manual-insta
3939
If you're using Encore, be sure to install your assets (e.g. ``npm install``)
4040
and restart Encore.
4141

42+
.. note::
43+
44+
Alternatively, the `@symfony/stimulus-bundle package`_ can be used to install the JavaScript assets without requiring PHP.
45+
4246
Usage
4347
-----
4448

@@ -533,3 +537,4 @@ it will normalize it:
533537
.. _`sensiolabs/typescript-bundle`: https://github.com/sensiolabs/AssetMapperTypeScriptBundle
534538
.. _`Stimulus plugin`: https://plugins.jetbrains.com/plugin/24562-stimulus
535539
.. _`official UX packages`: https://ux.symfony.com/packages
540+
.. _`@symfony/stimulus-bundle package`: https://www.npmjs.com/package/@symfony/stimulus-bundle

src/Svelte/doc/index.rst

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Install the bundle using Composer and Symfony Flex:
2727
$ npm install --force
2828
$ npm run watch
2929
30+
.. note::
31+
32+
Alternatively, the `@symfony/ux-svelte package`_ can be used to install the JavaScript assets without requiring PHP.
33+
3034
The Flex recipe will automatically set things up for you, like adding
3135
``.enableSvelte()`` to your ``webpack.config.js`` file and adding code
3236
to load your Svelte components inside ``assets/app.js``.
@@ -150,3 +154,4 @@ https://symfony.com/doc/current/contributing/code/bc.html
150154
.. _`Svelte`: https://svelte.dev/
151155
.. _`the Symfony UX initiative`: https://ux.symfony.com/
152156
.. _the Svelte 4 migration guide: https://svelte.dev/docs/v4-migration-guide#browser-conditions-for-bundlers
157+
.. _`@symfony/ux-svelte package`: https://www.npmjs.com/package/@symfony/ux-svelte

src/Swup/doc/index.rst

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ needed if you're using AssetMapper):
3030
$ npm install --force
3131
$ npm run watch
3232
33+
.. note::
34+
35+
Alternatively, the `@symfony/ux-swup package`_ can be used to install the JavaScript assets without requiring PHP.
36+
3337
Usage
3438
-----
3539

@@ -202,3 +206,4 @@ https://symfony.com/doc/current/contributing/code/bc.html
202206
.. _`StimulusBundle`: https://symfony.com/bundles/StimulusBundle/current/index.html
203207
.. _`Swup Options`: https://swup.js.org/options
204208
.. _StimulusBundle configured in your app: https://symfony.com/bundles/StimulusBundle/current/index.html
209+
.. _`@symfony/ux-swup package`: https://www.npmjs.com/package/@symfony/ux-swup

src/TogglePassword/doc/index.rst

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ needed if you're using AssetMapper):
3232
$ npm install --force
3333
$ npm run watch
3434
35+
.. note::
36+
37+
Alternatively, the `@symfony/ux-toggle-password package`_ can be used to install the JavaScript assets without requiring PHP.
38+
3539
Usage with Symfony Forms
3640
------------------------
3741

@@ -301,3 +305,4 @@ https://symfony.com/doc/current/contributing/code/bc.html
301305
.. _`the Symfony UX initiative`: https://ux.symfony.com/
302306
.. _StimulusBundle configured in your app: https://symfony.com/bundles/StimulusBundle/current/index.html
303307
.. _Heroicons: https://heroicons.com/
308+
.. _`@symfony/ux-toggle-password package`: https://www.npmjs.com/package/@symfony/ux-toggle-password

0 commit comments

Comments
 (0)