Skip to content

Commit e1ee777

Browse files
committed
WIP
1 parent 0b49a5c commit e1ee777

File tree

125 files changed

+2190
-2282
lines changed

Some content is hidden

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

125 files changed

+2190
-2282
lines changed

.github/workflows/test.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ jobs:
7171

7272
- id: components
7373
run: |
74-
components=$(tree src -J -d -L 1 | jq -c '.[0].contents | map(.name)')
74+
components=()
75+
while IFS= read -r line; do
76+
components+=("$line")
77+
done <<< $(find src -type f -name composer.json \( -path 'src/*/composer.json' -o -path 'src/*/src/Bridge/*/composer.json' \) ! -path '*/vendor/*' | sed -e 's/^src\///' -e 's/\/composer.json$//' | sort)
7578
echo "$components"
7679
echo "components=$components" >> $GITHUB_OUTPUT
7780
@@ -91,6 +94,10 @@ jobs:
9194
exclude:
9295
- component: Map # does not support PHP 8.1
9396
php-version: '8.1'
97+
- component: Map/src/Bridge/Google # does not support PHP 8.1
98+
php-version: '8.1'
99+
- component: Map/src/Bridge/Leaflet # does not support PHP 8.1
100+
php-version: '8.1'
94101
- component: Swup # has no tests
95102
- component: Turbo # has its own workflow (test-turbo.yml)
96103
- component: Typed # has no tests

bin/build_javascript.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const files = [
2121
// custom handling for StimulusBundle
2222
'src/StimulusBundle/assets/src/loader.ts',
2323
'src/StimulusBundle/assets/src/controllers.ts',
24+
// custom handling for Map
25+
...glob.sync('src/Map/src/Bridge/*/assets/src/*controller.ts'),
2426
...glob.sync('src/*/assets/src/*controller.ts'),
2527
];
2628

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"private": true,
33
"workspaces": [
4-
"src/*/assets"
4+
"src/*/assets",
5+
"src/Map/src/Bridge/*/assets"
56
],
67
"scripts": {
78
"build": "node bin/build_javascript.js && node bin/build_styles.js",
89
"test": "bin/run-vitest-all.sh",
910
"lint": "yarn workspaces run eslint src test",
10-
"format": "prettier src/*/assets/src/*.ts src/*/assets/test/*.js {,src/*/}*.{json,md} --write",
11+
"format": "prettier src/*/assets/src/*.ts src/*/assets/test/*.js src/*/src/Bridge/*/assets/src/*.ts src/*/src/Bridge/*/assets/test/*.ts {,src/*/}*.{json,md} --write",
1112
"check-lint": "yarn lint --no-fix",
1213
"check-format": "yarn format --no-write --check"
1314
},

rollup.config.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@ const wildcardExternalsPlugin = (peerDependencies) => ({
4646
const moveTypescriptDeclarationsPlugin = (packagePath) => ({
4747
name: 'move-ts-declarations',
4848
writeBundle: async () => {
49-
const files = glob.sync(path.join(packagePath, 'dist', '*', 'assets', 'src', '**/*.d.ts'));
49+
const isBridge = packagePath.includes('src/Bridge');
50+
const globPattern = isBridge
51+
? path.join(packagePath, 'dist', packagePath.replace(/^src\//, ''), '**/*.d.ts')
52+
: path.join(packagePath, 'dist', '*', 'assets', 'src', '**/*.d.ts')
53+
const files = glob.sync(globPattern);
5054
files.forEach((file) => {
51-
// a bit odd, but remove first 7 directories, which will leave
55+
// a bit odd, but remove first 7 or 13 directories, which will leave
5256
// only the relative path to the file
53-
const relativePath = file.split('/').slice(7).join('/');
57+
const relativePath = file.split('/').slice(isBridge ? 13 : 7).join('/');
5458

5559
const targetFile = path.join(packagePath, 'dist', relativePath);
5660
if (!fs.existsSync(path.dirname(targetFile))) {

src/Map/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor
22
composer.lock
33
.phpunit.result.cache
4+
assets/node_modules
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { Controller } from '@hotwired/stimulus';
2+
export type LatLng = {
3+
lat: number;
4+
lng: number;
5+
};
6+
export type MapView<Options, MarkerOptions, InfoWindowOptions> = {
7+
center: LatLng;
8+
zoom: number;
9+
fitBoundsToMarkers: boolean;
10+
markers: Array<MarkerDefinition<MarkerOptions, InfoWindowOptions>>;
11+
options: Options;
12+
};
13+
export type MarkerDefinition<MarkerOptions, InfoWindowOptions> = {
14+
position: LatLng;
15+
title: string | null;
16+
infoWindow?: Omit<InfoWindowDefinition<InfoWindowOptions>, 'position'>;
17+
rawOptions?: MarkerOptions;
18+
};
19+
export type InfoWindowDefinition<InfoWindowOptions> = {
20+
headerContent: string | null;
21+
content: string | null;
22+
position: LatLng;
23+
opened: boolean;
24+
autoClose: boolean;
25+
rawOptions?: InfoWindowOptions;
26+
};
27+
export default abstract class<MapOptions, Map, MarkerOptions, Marker, InfoWindowOptions, InfoWindow> extends Controller<HTMLElement> {
28+
static values: {
29+
providerOptions: ObjectConstructor;
30+
view: ObjectConstructor;
31+
};
32+
viewValue: MapView<MapOptions, MarkerOptions, InfoWindowOptions>;
33+
protected map: Map;
34+
protected markers: Array<Marker>;
35+
protected infoWindows: Array<InfoWindow>;
36+
initialize(): void;
37+
connect(): void;
38+
protected abstract doCreateMap({ center, zoom, options, }: {
39+
center: LatLng;
40+
zoom: number;
41+
options: MapOptions;
42+
}): Map;
43+
createMarker(definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>): Marker;
44+
protected abstract doCreateMarker(definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>): Marker;
45+
protected createInfoWindow({ definition, marker, }: {
46+
definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>['infoWindow'];
47+
marker: Marker;
48+
}): InfoWindow;
49+
protected abstract doCreateInfoWindow({ definition, marker, }: {
50+
definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>['infoWindow'];
51+
marker: Marker;
52+
}): InfoWindow;
53+
protected abstract doFitBoundsToMarkers(): void;
54+
private dispatchEvent;
55+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { Controller } from '@hotwired/stimulus';
2+
3+
class default_1 extends Controller {
4+
constructor() {
5+
super(...arguments);
6+
this.markers = [];
7+
this.infoWindows = [];
8+
}
9+
initialize() { }
10+
connect() {
11+
this.dispatchEvent('pre-connect', {});
12+
const { center, zoom, options, markers, fitBoundsToMarkers } = this.viewValue;
13+
this.map = this.doCreateMap({ center, zoom, options });
14+
markers.forEach((marker) => this.createMarker(marker));
15+
if (fitBoundsToMarkers) {
16+
this.doFitBoundsToMarkers();
17+
}
18+
this.dispatchEvent('connect');
19+
}
20+
createMarker(definition) {
21+
this.dispatchEvent('marker:before-create', { definition });
22+
const marker = this.doCreateMarker(definition);
23+
this.dispatchEvent('marker:after-create', { marker });
24+
this.markers.push(marker);
25+
return marker;
26+
}
27+
createInfoWindow({ definition, marker, }) {
28+
this.dispatchEvent('info-window:before-create', { definition, marker });
29+
const infoWindow = this.doCreateInfoWindow({ definition, marker });
30+
this.dispatchEvent('info-window:after-create', { infoWindow, marker });
31+
this.infoWindows.push(infoWindow);
32+
return infoWindow;
33+
}
34+
dispatchEvent(name, payload = {}) {
35+
this.dispatch(name, { prefix: 'ux:map', detail: payload });
36+
}
37+
}
38+
default_1.values = {
39+
providerOptions: Object,
40+
view: Object,
41+
};
42+
43+
export { default_1 as default };

src/Map/assets/dist/google_maps_controller.d.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/Map/assets/dist/google_maps_controller.js

Lines changed: 0 additions & 122 deletions
This file was deleted.

src/Map/assets/dist/leaflet_controller.d.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)