Skip to content

Commit f8e29af

Browse files
authored
Merge branch 'symfony:main' into main
2 parents 29a8a14 + 4f56882 commit f8e29af

File tree

132 files changed

+11027
-67
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+11027
-67
lines changed

.github/build-packages.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
$dir = __DIR__.'/../src/LiveComponent';
4+
$flags = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
5+
6+
$json = ltrim(file_get_contents($dir.'/composer.json'));
7+
if (null === $package = json_decode($json)) {
8+
passthru("composer validate $dir/composer.json");
9+
exit(1);
10+
}
11+
12+
$package->repositories[] = [
13+
'type' => 'path',
14+
'url' => '../TwigComponent',
15+
];
16+
17+
$json = preg_replace('/\n "repositories": \[\n.*?\n \],/s', '', $json);
18+
$json = rtrim(json_encode(['repositories' => $package->repositories], $flags), "\n}").','.substr($json, 1);
19+
$json = preg_replace('/"symfony\/ux-twig-component": "(\^[\d]+\.[\d]+)"/s', '"symfony/ux-twig-component": "@dev"', $json);
20+
file_put_contents($dir.'/composer.json', $json);
21+

.github/workflows/test.yaml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ name: Symfony UX
22

33
on: [push, pull_request]
44

5-
env:
6-
SYMFONY_PHPUNIT_DIR: '/tmp/.phpunit'
7-
SYMFONY_PHPUNIT_VERSION: '8.5'
8-
95
jobs:
106
coding-style-php:
117
runs-on: ubuntu-latest
@@ -55,6 +51,25 @@ jobs:
5551
composer update --prefer-lowest --prefer-dist --no-interaction --no-ansi --no-progress
5652
php vendor/bin/simple-phpunit
5753
54+
tests-php8-low-deps:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@master
58+
- uses: shivammathur/setup-php@v2
59+
with:
60+
php-version: '8.0'
61+
- name: TwigComponent
62+
run: |
63+
cd src/TwigComponent
64+
composer update --prefer-lowest --prefer-dist --no-interaction --no-ansi --no-progress
65+
php vendor/bin/simple-phpunit
66+
- name: LiveComponent
67+
run: |
68+
cd src/LiveComponent
69+
php ../../.github/build-packages.php
70+
composer update --prefer-lowest --prefer-dist --no-interaction --no-ansi --no-progress
71+
php vendor/bin/simple-phpunit
72+
5873
tests-php-high-deps:
5974
runs-on: ubuntu-latest
6075
steps:
@@ -86,6 +101,17 @@ jobs:
86101
composer config platform.php 7.4.99
87102
composer update --prefer-dist --no-interaction --no-ansi --no-progress
88103
php vendor/bin/simple-phpunit
104+
- name: TwigComponent
105+
run: |
106+
cd src/TwigComponent
107+
composer update --prefer-dist --no-interaction --no-ansi --no-progress
108+
php vendor/bin/simple-phpunit
109+
- name: LiveComponent
110+
run: |
111+
cd src/LiveComponent
112+
php ../../.github/build-packages.php
113+
composer update --prefer-dist --no-interaction --no-ansi --no-progress
114+
php vendor/bin/simple-phpunit
89115
90116
tests-js:
91117
runs-on: ubuntu-latest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
node_modules
33
yarn.lock
44
yarn-error.log
5+
/composer.lock
6+
/vendor

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ to build the chart in PHP. The JavaScript is handled for you automatically.
1818

1919
## Components of UX
2020

21-
Symfony UX leverages [Stimulus](https://stimulus.hotwire.dev/) for JavaScript
21+
Symfony UX leverages [Stimulus](https://stimulus.hotwired.dev/) for JavaScript
2222
and the [Stimulus Bridge](https://github.com/symfony/stimulus-bridge) for
2323
integrating it into [Webpack Encore](https://github.com/symfony/webpack-encore).
2424

@@ -34,6 +34,11 @@ integrating it into [Webpack Encore](https://github.com/symfony/webpack-encore).
3434
Improve image loading performances through lazy-loading and data-uri thumbnails
3535
- [UX Swup](https://github.com/symfony/ux-swup):
3636
[Swup](https://swup.js.org/) page transition library integration for Symfony
37+
- [UX Turbo](https://github.com/symfony/ux-turbo): [Hotwire Turbo](https://turbo.hotwired.dev/) library integration for Symfony
38+
- [Twig Component](https://github.com/symfony/ux-twig-component):
39+
A system to build reusable "components" with Twig
40+
- [Live Component](https://github.com/symfony/ux-live-component):
41+
Gives Twig Components a URL and a JavaScript library to automatically re-render via Ajax as your user interacts with it
3742

3843
## Stimulus Tools around the World
3944

@@ -45,7 +50,7 @@ exist beyond the UX packages:
4550
[detecting outside clicks](https://stimulus-use.github.io/stimulus-use/#/use-click-outside)
4651
and many other things. See: https://stimulus-use.github.io/stimulus-use/#/
4752

48-
- [stimulus-components](https://stimulus-components.netlify.app/docs/components/index/): A
53+
- [stimulus-components](https://stimulus-components.netlify.app/): A
4954
large number of pre-made Stimulus controllers, like for
5055
[Copying to clipboard](https://stimulus-components.netlify.app/docs/components/stimulus-clipboard/),
5156
[Sortable](https://stimulus-components.netlify.app/docs/components/stimulus-sortable/),
@@ -63,3 +68,18 @@ do in JavaScript could be done streamlined as a UX package.
6368

6469
We have some ideas and we will release more packages in the coming days. The rest
6570
is on you: let's create an amazing ecosystem together!
71+
72+
## Contributing
73+
74+
If you want to test your code in an existing project that uses Symfony UX packages,
75+
you can use the `link` utility provided in this Git repository (that you have to clone).
76+
This tool scans the `vendor/` directory of your project, finds Symfony UX packages it uses,
77+
and replaces them by symbolic links to the ones in the Git repository.
78+
79+
```shell
80+
# Install required dependencies
81+
$ composer install
82+
83+
# And link Symfony UX packages to your project
84+
$ php link /path/to/your/project
85+
```

composer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "symfony/ux",
3+
"license": "MIT",
4+
"require-dev": {
5+
"symfony/filesystem": "^5.2"
6+
}
7+
}

link

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/*
5+
* This file is part of the Symfony package.
6+
*
7+
* (c) Fabien Potencier <[email protected]>
8+
*
9+
* For the full copyright and license information, please view the LICENSE
10+
* file that was distributed with this source code.
11+
*/
12+
13+
require __DIR__.'/vendor/autoload.php';
14+
15+
use Symfony\Component\Filesystem\Filesystem;
16+
17+
/**
18+
* Links dependencies of a project to a local clone of the main symfony/symfony GitHub repository.
19+
*
20+
* @author Kévin Dunglas <[email protected]>
21+
*/
22+
23+
$copy = false !== $k = array_search('--copy', $argv, true);
24+
$copy && array_splice($argv, $k, 1);
25+
$rollback = false !== $k = array_search('--rollback', $argv, true);
26+
$rollback && array_splice($argv, $k, 1);
27+
$pathToProject = $argv[1] ?? getcwd();
28+
29+
if (!is_dir("$pathToProject/vendor/symfony")) {
30+
echo 'Links dependencies of a project to a local clone of the main symfony/ux GitHub repository.'.PHP_EOL.PHP_EOL;
31+
echo "Usage: $argv[0] /path/to/the/project".PHP_EOL;
32+
echo ' Use `--copy` to copy dependencies instead of symlink'.PHP_EOL.PHP_EOL;
33+
echo ' Use `--rollback` to rollback'.PHP_EOL.PHP_EOL;
34+
echo "The directory \"$pathToProject\" does not exist or the dependencies are not installed, did you forget to run \"composer install\" in your project?".PHP_EOL;
35+
exit(1);
36+
}
37+
38+
$sfPackages = array();
39+
40+
$filesystem = new Filesystem();
41+
$directories = glob(__DIR__.'/src/*', GLOB_ONLYDIR | GLOB_NOSORT);
42+
43+
foreach ($directories as $dir) {
44+
if ($filesystem->exists($composer = "$dir/composer.json")) {
45+
$sfPackages[json_decode(file_get_contents($composer))->name] = $dir;
46+
}
47+
}
48+
49+
foreach (glob("$pathToProject/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
50+
$package = 'symfony/'.basename($dir);
51+
52+
if (!isset($sfPackages[$package])) {
53+
continue;
54+
}
55+
56+
if ($rollback) {
57+
$filesystem->remove($dir);
58+
echo "\"$package\" has been rollback from \"$sfPackages[$package]\".".PHP_EOL;
59+
continue;
60+
}
61+
62+
if (!$copy && is_link($dir)) {
63+
echo "\"$package\" is already a symlink, skipping.".PHP_EOL;
64+
continue;
65+
}
66+
67+
$sfDir = ('\\' === DIRECTORY_SEPARATOR || $copy) ? $sfPackages[$package] : $filesystem->makePathRelative($sfPackages[$package], dirname(realpath($dir)));
68+
69+
$filesystem->remove($dir);
70+
71+
if ($copy) {
72+
$filesystem->mirror($sfDir, $dir);
73+
echo "\"$package\" has been copied from \"$sfPackages[$package]\".".PHP_EOL;
74+
} else {
75+
$filesystem->symlink($sfDir, $dir);
76+
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL;
77+
}
78+
}
79+
80+
foreach (glob("$pathToProject/var/cache/*", GLOB_NOSORT) as $cacheDir) {
81+
$filesystem->remove($cacheDir);
82+
}
83+
84+
if ($rollback) {
85+
echo PHP_EOL."Rollback done, do not forget to run \"composer install\" in your project \"$pathToProject\".".PHP_EOL;
86+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"private": true,
33
"workspaces": [
4-
"src/**/Resources/assets"
4+
"src/**/Resources/assets",
5+
"src/**/assets"
56
],
67
"scripts": {
78
"build": "yarn workspaces run build",

src/Chartjs/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# CHANGELOG
2+
3+
## 1.3
4+
5+
- [DEPENDENCY CHANGE] `chart.js` is no longer included automatically (#93)
6+
but `symfony/flex` will automatically add it to your `package.json` file
7+
when upgrading. Additionally `symfony/flex` 1.13 or higher is now required
8+
if installed.
9+
10+
- Chart.js: add horizontalBar type to chart model #87 - @duboiss

src/Chartjs/Model/Chart.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Chart
2121
{
2222
public const TYPE_LINE = 'line';
2323
public const TYPE_BAR = 'bar';
24+
public const TYPE_BAR_HORIZONTAL = 'horizontalBar';
2425
public const TYPE_RADAR = 'radar';
2526
public const TYPE_PIE = 'pie';
2627
public const TYPE_DOUGHNUT = 'doughnut';
@@ -51,7 +52,7 @@ public function setData(array $data): self
5152
/**
5253
* Sets Chart.js options.
5354
*
54-
* @see https://www.chartjs.org/docs/latest/
55+
* @see https://www.chartjs.org/docs/2.9.4
5556
*
5657
* <code>
5758
* $chart->setOptions([

src/Chartjs/Resources/assets/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
"test": "babel src -d dist && jest",
1919
"lint": "eslint src test"
2020
},
21-
"dependencies": {
22-
"chart.js": "^2.9.4"
23-
},
2421
"peerDependencies": {
22+
"chart.js": "^2.9.4",
2523
"stimulus": "^2.0.0"
2624
},
2725
"devDependencies": {
@@ -30,6 +28,7 @@
3028
"@babel/plugin-proposal-class-properties": "^7.12.1",
3129
"@babel/preset-env": "^7.12.7",
3230
"@symfony/stimulus-testing": "^1.1.0",
31+
"chart.js": "^2.9.4",
3332
"jest-canvas-mock": "^2.3.0",
3433
"stimulus": "^2.0.0"
3534
},

0 commit comments

Comments
 (0)