Skip to content

Commit 94bc665

Browse files
ChqThomasweaverryan
authored andcommitted
[Svelte] Introduce Svelte UX component
1 parent 8eb4e08 commit 94bc665

30 files changed

+1065
-0
lines changed

.github/workflows/test.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ jobs:
120120
run: php vendor/bin/simple-phpunit
121121
working-directory: src/React
122122

123+
- name: Svelte Dependencies
124+
uses: ramsey/composer-install@v2
125+
with:
126+
working-directory: src/Svelte
127+
dependency-versions: lowest
128+
- name: Svelte Tests
129+
run: php vendor/bin/simple-phpunit
130+
working-directory: src/Svelte
131+
123132
tests-php8-low-deps:
124133
runs-on: ubuntu-latest
125134
steps:
@@ -228,6 +237,14 @@ jobs:
228237
working-directory: src/Autocomplete
229238
run: php vendor/bin/simple-phpunit
230239

240+
- name: Svelte Dependencies
241+
uses: ramsey/composer-install@v2
242+
with:
243+
working-directory: src/Svelte
244+
- name: Svelte Tests
245+
working-directory: src/Svelte
246+
run: php vendor/bin/simple-phpunit
247+
231248
tests-php81-high-deps:
232249
runs-on: ubuntu-latest
233250
steps:

src/Svelte/.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore
3+
/.symfony.bundle.yaml export-ignore
4+
/assets/.gitignore export-ignore
5+
/assets/jest.config.js export-ignore
6+
/assets/test export-ignore
7+
/tests export-ignore
8+
/assets/src/*.ts export-ignore

src/Svelte/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/composer.lock
2+
/phpunit.xml
3+
/vendor/
4+
/.phpunit.result.cache

src/Svelte/.symfony.bundle.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
branches: ["2.x"]
2+
maintained_branches: ["2.x"]
3+
doc_dir: "doc"

src/Svelte/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Fabien Potencier
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is furnished
10+
to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

src/Svelte/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Symfony UX Svelte
2+
3+
Symfony UX Svelte integrates [Svelte](https://svelte.dev/) into Symfony applications.
4+
It provides tools to render Svelte 3 components from Twig.
5+
6+
**This repository is a READ-ONLY sub-tree split**. See
7+
https://github.com/symfony/ux to create issues or submit pull requests.
8+
9+
## Resources
10+
11+
- [Documentation](https://symfony.com/bundles/ux-svelte/current/index.html)
12+
- [Report issues](https://github.com/symfony/ux/issues) and
13+
[send Pull Requests](https://github.com/symfony/ux/pulls)
14+
in the [main Symfony UX repository](https://github.com/symfony/ux)

src/Svelte/assets/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference types="webpack-env" />
2+
import type { SvelteComponent } from 'svelte';
3+
declare global {
4+
function resolveSvelteComponent(name: string): typeof SvelteComponent;
5+
interface Window {
6+
resolveSvelteComponent(name: string): typeof SvelteComponent;
7+
}
8+
}
9+
export declare function registerSvelteControllerComponents(context: __WebpackModuleApi.RequireContext): void;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function registerSvelteControllerComponents(context) {
2+
const svelteControllers = {};
3+
const importAllSvelteComponents = (r) => {
4+
r.keys().forEach((key) => (svelteControllers[key] = r(key).default));
5+
};
6+
importAllSvelteComponents(context);
7+
window.resolveSvelteComponent = (name) => {
8+
const component = svelteControllers[`./${name}.svelte`];
9+
if (typeof component === 'undefined') {
10+
throw new Error(`Svelte controller "${name}" does not exist`);
11+
}
12+
return component;
13+
};
14+
}
15+
16+
export { registerSvelteControllerComponents };
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Controller } from '@hotwired/stimulus';
2+
import { SvelteComponent } from 'svelte';
3+
export default class extends Controller<Element & {
4+
root?: SvelteComponent;
5+
}> {
6+
private app;
7+
readonly componentValue: string;
8+
private props;
9+
private intro;
10+
readonly propsValue: Record<string, unknown> | null | undefined;
11+
readonly introValue: boolean | undefined;
12+
static values: {
13+
component: StringConstructor;
14+
props: ObjectConstructor;
15+
intro: BooleanConstructor;
16+
};
17+
connect(): void;
18+
disconnect(): void;
19+
_destroyIfExists(): void;
20+
private dispatchEvent;
21+
}

0 commit comments

Comments
 (0)