@vaadin/map 23.0.0-beta1 → 23.0.0-beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/map",
3
- "version": "23.0.0-beta1",
3
+ "version": "23.0.0-beta2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@polymer/polymer": "^3.0.0",
38
- "@vaadin/component-base": "23.0.0-beta1",
38
+ "@vaadin/component-base": "23.0.0-beta2",
39
39
  "@vaadin/vaadin-license-checker": "^2.1.0",
40
40
  "ol": "6.11.0"
41
41
  },
@@ -44,5 +44,5 @@
44
44
  "@vaadin/testing-helpers": "^0.3.2",
45
45
  "sinon": "^9.2.4"
46
46
  },
47
- "gitHead": "467244b76021176c109df675799b07029b293e58"
47
+ "gitHead": "a276f7a0fd00e5459b87267468e0dd0d4fb6f7f3"
48
48
  }
@@ -4,7 +4,7 @@
4
4
  * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
5
5
  */
6
6
  import OpenLayersMap from 'ol/Map.js';
7
- import { ElementMixin } from '@vaadin/component-base';
7
+ import { ElementMixin, FocusMixin, ResizeMixin } from '@vaadin/component-base';
8
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
9
9
 
10
10
  /**
@@ -44,15 +44,17 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
44
44
  * @extends HTMLElement
45
45
  * @mixes ThemableMixin
46
46
  * @mixes ElementMixin
47
+ * @mixes FocusMixin
48
+ * @mixes ResizeMixin
47
49
  */
48
- declare class Map extends ThemableMixin(ElementMixin(HTMLElement)) {
50
+ declare class Map extends ResizeMixin(FocusMixin(ThemableMixin(ElementMixin(HTMLElement)))) {
49
51
  /**
50
52
  * The internal OpenLayers map instance used to configure the map.
51
53
  * See the OpenLayers [API](https://openlayers.org/en/latest/apidoc/) and
52
54
  * [examples](https://openlayers.org/en/latest/examples/) for further information.
53
55
  * @returns {*}
54
56
  */
55
- get configuration(): OpenLayersMap | undefined;
57
+ get configuration(): OpenLayersMap;
56
58
  }
57
59
 
58
60
  declare global {
package/src/vaadin-map.js CHANGED
@@ -4,8 +4,12 @@
4
4
  * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
5
5
  */
6
6
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
7
+ import { defaults as defaultControls } from 'ol/control';
8
+ import { defaults as defaultInteractions } from 'ol/interaction';
7
9
  import OpenLayersMap from 'ol/Map.js';
8
10
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
11
+ import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
12
+ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
9
13
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
14
 
11
15
  function isEnabled() {
@@ -49,8 +53,10 @@ function isEnabled() {
49
53
  * @extends HTMLElement
50
54
  * @mixes ThemableMixin
51
55
  * @mixes ElementMixin
56
+ * @mixes FocusMixin
57
+ * @mixes ResizeMixin
52
58
  */
53
- class Map extends ElementMixin(ThemableMixin(PolymerElement)) {
59
+ class Map extends ResizeMixin(FocusMixin(ElementMixin(ThemableMixin(PolymerElement)))) {
54
60
  static get template() {
55
61
  return html`
56
62
  <style>
@@ -60,16 +66,306 @@ class Map extends ElementMixin(ThemableMixin(PolymerElement)) {
60
66
  overflow: hidden;
61
67
  }
62
68
 
69
+ :host([hidden]) {
70
+ display: none !important;
71
+ }
72
+
63
73
  #map {
64
74
  width: 100%;
65
75
  height: 100%;
76
+ outline: none;
66
77
  }
67
78
 
68
- :host([hidden]) {
69
- display: none !important;
79
+ #map,
80
+ .ol-viewport,
81
+ .ol-layers {
82
+ border-radius: inherit;
83
+ overflow: hidden;
84
+ }
85
+
86
+ #map:fullscreen {
87
+ border-radius: 0;
88
+ }
89
+
90
+ #map:-webkit-full-screen {
91
+ border-radius: 0;
92
+ }
93
+
94
+ /* Functional styles, copied from 'ol/ol.css' */
95
+
96
+ .ol-box {
97
+ box-sizing: border-box;
98
+ border-radius: 2px;
99
+ border: 1px solid rgba(0, 0, 0, 0.5);
100
+ background-color: rgba(255, 255, 255, 0.2);
101
+ box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
102
+ }
103
+
104
+ .ol-unsupported {
105
+ display: none;
106
+ }
107
+
108
+ .ol-viewport,
109
+ .ol-unselectable {
110
+ -webkit-touch-callout: none;
111
+ -webkit-user-select: none;
112
+ -moz-user-select: none;
113
+ -ms-user-select: none;
114
+ user-select: none;
115
+ -webkit-tap-highlight-color: transparent;
116
+ }
117
+
118
+ .ol-viewport canvas {
119
+ all: unset;
120
+ }
121
+
122
+ .ol-selectable {
123
+ -webkit-touch-callout: default;
124
+ -webkit-user-select: text;
125
+ -moz-user-select: text;
126
+ -ms-user-select: text;
127
+ user-select: text;
128
+ }
129
+
130
+ .ol-grabbing {
131
+ cursor: -webkit-grabbing;
132
+ cursor: -moz-grabbing;
133
+ cursor: grabbing;
134
+ }
135
+
136
+ .ol-grab {
137
+ cursor: move;
138
+ cursor: -webkit-grab;
139
+ cursor: -moz-grab;
140
+ cursor: grab;
141
+ }
142
+
143
+ /* Control positioning and styling */
144
+
145
+ .ol-overlaycontainer-stopevent {
146
+ display: grid;
147
+ grid-template-columns: min-content 1fr min-content;
148
+ grid-template-rows: min-content 1fr min-content min-content min-content min-content;
149
+ padding: var(--vaadin-map-controls-inset, 0.25em);
150
+ box-sizing: border-box;
151
+ grid-template-areas:
152
+ 'scale mouse-position fullscreen'
153
+ 'overview-map . zoom-extent'
154
+ 'overview-map . compass'
155
+ 'overview-map . zoom-slider'
156
+ 'overview-map . zoom'
157
+ 'overview-map attribution attribution';
158
+ }
159
+
160
+ .ol-mouse-position {
161
+ grid-area: mouse-position;
162
+ align-self: start;
163
+ text-align: center;
164
+ font-size: 0.625em;
165
+ color: #000;
166
+ filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
167
+ }
168
+
169
+ .ol-scale-line,
170
+ .ol-scale-bar {
171
+ grid-area: scale;
172
+ position: relative;
173
+ pointer-events: none !important;
174
+ color: #000;
175
+ }
176
+
177
+ .ol-scale-line-inner {
178
+ border: 1px solid rgba(0, 0, 0, 0.5);
179
+ border-top: none;
180
+ font-size: 0.625em;
181
+ text-align: center;
182
+ will-change: contents, width, filter;
183
+ transition: all 0.25s;
184
+ filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
185
+ }
186
+
187
+ .ol-scale-bar-inner {
188
+ border: 1px solid rgba(0, 0, 0, 0.5);
189
+ box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
190
+ overflow: hidden;
191
+ }
192
+
193
+ .ol-scale-step-marker {
194
+ display: none;
195
+ }
196
+
197
+ .ol-scale-step-text {
198
+ position: absolute;
199
+ top: 0.75em;
200
+ font-size: 0.625em;
201
+ color: #000;
202
+ filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
203
+ white-space: nowrap;
204
+ overflow: hidden;
205
+ }
206
+
207
+ .ol-scale-text {
208
+ position: absolute;
209
+ font-size: 0.625em;
210
+ top: 2em;
211
+ color: #000;
212
+ white-space: nowrap;
213
+ filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
214
+ }
215
+
216
+ .ol-scale-singlebar {
217
+ height: 0.25em;
218
+ opacity: 0.5;
219
+ }
220
+
221
+ .ol-control {
222
+ margin: 0.25em;
223
+ }
224
+
225
+ .ol-control button {
226
+ -webkit-appearance: none;
227
+ border: 0;
228
+ margin: 0;
229
+ padding: 0;
230
+ background: #fff;
231
+ font: inherit;
232
+ color: inherit;
233
+ width: 1.5em;
234
+ height: 1.5em;
235
+ }
236
+
237
+ .ol-control button::-moz-focus-inner {
238
+ border: none;
239
+ padding: 0;
240
+ }
241
+
242
+ .ol-compass {
243
+ grid-area: compass;
244
+ display: block;
245
+ will-change: transform;
246
+ }
247
+
248
+ .ol-zoom {
249
+ grid-area: zoom;
250
+ display: flex;
251
+ flex-direction: column;
252
+ }
253
+
254
+ .ol-zoom-in:empty::before {
255
+ content: var(--vaadin-map-icon-zoom-in, '+');
256
+ }
257
+
258
+ .ol-zoom-out:empty::before {
259
+ content: var(--vaadin-map-icon-zoom-out, '–');
260
+ }
261
+
262
+ .ol-attribution {
263
+ grid-area: attribution;
264
+ margin-inline-start: auto !important;
265
+ display: flex;
266
+ flex-flow: row-reverse;
267
+ }
268
+
269
+ .ol-attribution.ol-uncollapsible {
270
+ margin-inline-end: calc(var(--vaadin-map-controls-inset, 0.25em) * -1);
271
+ margin-block-end: calc(var(--vaadin-map-controls-inset, 0.25em) * -1);
272
+ }
273
+
274
+ .ol-attribution button span:empty::before {
275
+ content: var(--vaadin-map-icon-attribution-collapse, '▸');
276
+ }
277
+
278
+ .ol-attribution.ol-collapsed button span:empty::before {
279
+ content: var(--vaadin-map-icon-attribution-expand, 'ℹ');
280
+ }
281
+
282
+ .ol-attribution ul {
283
+ display: flex;
284
+ align-items: center;
285
+ gap: 1em;
286
+ list-style: none;
287
+ margin: 0;
288
+ padding: 0.25em 0.5em;
289
+ font-size: 0.8em;
290
+ }
291
+
292
+ .ol-attribution.ol-collapsed ul {
293
+ display: none;
294
+ }
295
+
296
+ .ol-attribution.ol-uncollapsible button {
297
+ display: none;
298
+ }
299
+
300
+ .ol-rotate {
301
+ grid-area: compass;
302
+ }
303
+
304
+ .ol-compass:empty::before {
305
+ content: var(--vaadin-map-icon-compass, '↑');
306
+ }
307
+
308
+ .ol-full-screen {
309
+ grid-area: fullscreen;
310
+ }
311
+
312
+ .ol-full-screen button:empty::before {
313
+ content: var(--vaadin-map-icon-fullscreen, '⤢');
314
+ }
315
+
316
+ .ol-full-screen .ol-full-screen-true:empty::before {
317
+ content: var(--vaadin-map-icon-close, '×');
318
+ }
319
+
320
+ .ol-overviewmap {
321
+ grid-area: overview-map;
322
+ align-self: end;
323
+ width: max-content;
324
+ }
325
+
326
+ .ol-overviewmap button span:empty::before {
327
+ content: var(--vaadin-map-icon-overview-map-collapse, '▾');
328
+ }
329
+
330
+ .ol-overviewmap.ol-collapsed button span:empty::before {
331
+ content: var(--vaadin-map-icon-overview-map-expand, '▴');
332
+ }
333
+
334
+ .ol-overviewmap-map {
335
+ height: 10em;
336
+ width: 10em;
337
+ border: 1px solid rgba(0, 0, 0, 0.5);
338
+ }
339
+
340
+ .ol-overviewmap.ol-collapsed .ol-overviewmap-map,
341
+ .ol-overviewmap.ol-uncollapsible button {
342
+ display: none;
343
+ }
344
+
345
+ .ol-overviewmap-box {
346
+ border: 1px dashed rgba(0, 0, 0, 0.5);
347
+ filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
348
+ will-change: filter;
349
+ cursor: move;
350
+ }
351
+
352
+ .ol-zoomslider {
353
+ grid-area: zoom-slider;
354
+ height: 8em;
355
+ }
356
+
357
+ .ol-zoomslider button {
358
+ position: relative;
359
+ height: 0.5em;
360
+ display: block;
361
+ border-radius: inherit;
362
+ }
363
+
364
+ .ol-zoom-extent {
365
+ grid-area: zoom-extent;
366
+ align-self: end;
70
367
  }
71
368
  </style>
72
- <div id="map"></div>
73
369
  `;
74
370
  }
75
371
 
@@ -87,18 +383,74 @@ class Map extends ElementMixin(ThemableMixin(PolymerElement)) {
87
383
  return this._configuration;
88
384
  }
89
385
 
386
+ constructor() {
387
+ super();
388
+ // Create map container element and initialize OL map instance
389
+ this._mapTarget = document.createElement('div');
390
+ this._mapTarget.id = 'map';
391
+ // Ensure accessible keyboard controls are enabled
392
+ this._mapTarget.setAttribute('tabindex', '0');
393
+ const options = {
394
+ // Override default controls to remove default labels, which is required to
395
+ // correctly display icons through pseudo-element
396
+ controls: defaultControls({
397
+ rotate: false,
398
+ zoomOptions: { zoomInLabel: '', zoomOutLabel: '' }
399
+ }),
400
+ // Override default interactions to allow mouse-wheel zoom + drag-pan when not focused
401
+ interactions: defaultInteractions({ onFocusOnly: false }),
402
+ target: this._mapTarget
403
+ };
404
+ this._configuration = new OpenLayersMap(options);
405
+ }
406
+
90
407
  /** @protected */
91
408
  ready() {
92
409
  super.ready();
410
+ // Add map container to shadow root, trigger OL resize calculation
411
+ this.shadowRoot.appendChild(this._mapTarget);
412
+ this.__addMapFocusListeners();
413
+ }
93
414
 
94
- this.__initMap();
415
+ /**
416
+ * Implements resize callback from ResizeMixin to update size of OL map instance
417
+ * @override
418
+ * @protected
419
+ */
420
+ _onResize(_contentRect) {
421
+ this._configuration.updateSize();
95
422
  }
96
423
 
97
- /** @private */
98
- __initMap() {
99
- this._configuration = new OpenLayersMap({
100
- target: this.$.map
424
+ /**
425
+ * Registers focus listeners on the map container to manually manage focus in
426
+ * FocusMixin. FocusMixin currently assumes that the focusable element will
427
+ * be in the light DOM and is available as event target.
428
+ * The map container however is in the shadow DOM and thus focus events will
429
+ * always have the host element as target.
430
+ * @private
431
+ */
432
+ __addMapFocusListeners() {
433
+ this._mapTarget.addEventListener('focusin', (e) => {
434
+ if (e.target === this._mapTarget) {
435
+ this._setFocused(true);
436
+ }
101
437
  });
438
+ this._mapTarget.addEventListener('focusout', () => {
439
+ this._setFocused(false);
440
+ });
441
+ }
442
+
443
+ /**
444
+ * Overrides method from `FocusMixin` to disable automatic focus management.
445
+ * See custom logic in __addMapFocusListeners
446
+ *
447
+ * @param {FocusEvent} _event
448
+ * @return {boolean}
449
+ * @override
450
+ * @protected
451
+ */
452
+ _shouldSetFocus(_event) {
453
+ return false;
102
454
  }
103
455
  }
104
456
 
@@ -0,0 +1,186 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2022 - 2022 Vaadin Ltd.
4
+ * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
5
+ */
6
+ import '@vaadin/vaadin-lumo-styles/color.js';
7
+ import '@vaadin/vaadin-lumo-styles/typography.js';
8
+ import '@vaadin/vaadin-lumo-styles/sizing.js';
9
+ import '@vaadin/vaadin-lumo-styles/spacing.js';
10
+ import '@vaadin/vaadin-lumo-styles/style.js';
11
+ import '@vaadin/vaadin-lumo-styles/font-icons.js';
12
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
+
14
+ registerStyles(
15
+ 'vaadin-map',
16
+ css`
17
+ :host {
18
+ font-family: var(--lumo-font-family);
19
+ font-size: var(--lumo-font-size-m);
20
+ --vaadin-map-controls-inset: var(--lumo-space-xs);
21
+ --vaadin-map-icon-zoom-in: var(--lumo-icons-plus);
22
+ --vaadin-map-icon-zoom-out: var(--lumo-icons-minus);
23
+ --vaadin-map-icon-compass: var(--lumo-icons-arrow-up);
24
+ --vaadin-map-icon-overview-map-collapse: var(--lumo-icons-angle-down);
25
+ --vaadin-map-icon-overview-map-expand: var(--lumo-icons-angle-up);
26
+ --vaadin-map-icon-close: var(--lumo-icons-cross);
27
+ --vaadin-map-icon-attribution-collapse: var(--lumo-icons-angle-right);
28
+ }
29
+
30
+ :host(:not([theme~='borderless'])) {
31
+ border-radius: var(--lumo-border-radius-l);
32
+ position: relative;
33
+ }
34
+
35
+ :host(:not([theme~='borderless']))::before {
36
+ content: '';
37
+ position: absolute;
38
+ inset: 0;
39
+ border: 1px solid var(--lumo-contrast-10pct);
40
+ border-radius: inherit;
41
+ z-index: 1;
42
+ pointer-events: none;
43
+ }
44
+
45
+ :host([focus-ring]) {
46
+ box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
47
+ }
48
+
49
+ .ol-control,
50
+ .ol-scale-bar,
51
+ .ol-scale-line {
52
+ margin: var(--lumo-space-xs);
53
+ }
54
+
55
+ .ol-control {
56
+ border-radius: var(--lumo-border-radius-m);
57
+ transition: 0.15s box-shadow, 0.15s background-color;
58
+ -webkit-backdrop-filter: blur(8px);
59
+ }
60
+
61
+ .ol-control:hover {
62
+ background-color: var(--lumo-base-color);
63
+ }
64
+
65
+ .ol-control:not(.ol-uncollapsible):hover {
66
+ box-shadow: var(--lumo-box-shadow-s);
67
+ background-color: var(--lumo-shade-20pct);
68
+ }
69
+
70
+ .ol-control button {
71
+ width: var(--lumo-size-s);
72
+ height: var(--lumo-size-s);
73
+ border-radius: inherit;
74
+ font-family: 'lumo-icons';
75
+ font-size: var(--lumo-icon-size-s);
76
+ font-weight: 400;
77
+ }
78
+
79
+ .ol-control button,
80
+ .ol-attribution:not(.ol-uncollapsible) ul {
81
+ transition: 0.15s opacity;
82
+ background-color: var(--lumo-base-color);
83
+ color: var(--lumo-body-text-color);
84
+ opacity: 0.65;
85
+ }
86
+
87
+ .ol-control:hover button,
88
+ .ol-control button:focus,
89
+ .ol-attribution:hover ul {
90
+ opacity: 1;
91
+ }
92
+
93
+ .ol-control button:hover {
94
+ color: var(--lumo-primary-text-color);
95
+ }
96
+
97
+ .ol-control button:active {
98
+ background: var(--lumo-base-color) linear-gradient(var(--lumo-contrast-5pct), var(--lumo-contrast-5pct));
99
+ }
100
+
101
+ @supports not selector(:focus-visible) {
102
+ .ol-control button:focus {
103
+ outline: none;
104
+ box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
105
+ }
106
+ }
107
+
108
+ .ol-control button:focus-visible {
109
+ outline: none;
110
+ box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
111
+ }
112
+
113
+ .ol-zoom {
114
+ gap: 2px;
115
+ }
116
+
117
+ button.ol-zoom-in {
118
+ border-bottom-left-radius: 0;
119
+ border-bottom-right-radius: 0;
120
+ }
121
+
122
+ button.ol-zoom-out {
123
+ border-top-left-radius: 0;
124
+ border-top-right-radius: 0;
125
+ }
126
+
127
+ .ol-attribution.ol-uncollapsible {
128
+ border-radius: var(--lumo-border-radius-m) 0 0 0;
129
+ }
130
+
131
+ .ol-attribution ul {
132
+ font-size: var(--lumo-font-size-xxs);
133
+ color: var(--lumo-secondary-text-color);
134
+ padding: var(--lumo-space-xs) var(--lumo-space-s);
135
+ cursor: default;
136
+ }
137
+
138
+ .ol-attribution:not(.ol-uncollapsible) ul {
139
+ background-color: var(--lumo-base-color);
140
+ }
141
+
142
+ .ol-attribution a {
143
+ color: inherit;
144
+ cursor: pointer;
145
+ }
146
+
147
+ .ol-scale-bar-inner {
148
+ border-radius: var(--lumo-border-radius-s);
149
+ }
150
+
151
+ .ol-full-screen {
152
+ height: var(--lumo-size-s);
153
+ }
154
+
155
+ .ol-overviewmap:not(.ol-collapsed),
156
+ .ol-overviewmap:not(.ol-collapsed):hover {
157
+ background-color: var(--lumo-base-color);
158
+ box-shadow: var(--lumo-box-shadow-s);
159
+ transition: 0.15s box-shadow;
160
+ }
161
+
162
+ .ol-overviewmap-map {
163
+ margin: var(--lumo-space-xs);
164
+ border: 0;
165
+ border-radius: var(--lumo-border-radius-s);
166
+ }
167
+
168
+ .ol-overviewmap:not(.ol-uncollapsible) .ol-overviewmap-map {
169
+ margin-bottom: 0;
170
+ }
171
+
172
+ .ol-zoomslider:not(.ol-uncollapsible):hover {
173
+ box-shadow: none;
174
+ overflow: visible;
175
+ }
176
+
177
+ .ol-zoomslider button {
178
+ height: var(--lumo-space-m);
179
+ }
180
+
181
+ .ol-zoomslider:hover button {
182
+ box-shadow: var(--lumo-box-shadow-s);
183
+ }
184
+ `,
185
+ { moduleId: 'lumo-map' }
186
+ );
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2022 - 2022 Vaadin Ltd.
4
+ * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
5
+ */
6
+ import './vaadin-map-styles.js';
7
+ import '../../src/vaadin-map.js';
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2022 - 2022 Vaadin Ltd.
4
+ * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
5
+ */
6
+ import '@vaadin/vaadin-material-styles/color.js';
7
+ import '@vaadin/vaadin-material-styles/shadow.js';
8
+ import '@vaadin/vaadin-material-styles/typography.js';
9
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
+
11
+ registerStyles(
12
+ 'vaadin-map',
13
+ css`
14
+ :host {
15
+ font-family: var(--material-font-family);
16
+ font-size: var(--material-body-font-size);
17
+ }
18
+
19
+ :host(:not([theme~='borderless'])) {
20
+ border-radius: 4px;
21
+ border: 1px solid var(--material-divider-color);
22
+ }
23
+
24
+ :host([focus-ring]) {
25
+ box-shadow: 0 0 0 2px var(--material-primary-color);
26
+ }
27
+
28
+ .ol-control {
29
+ border-radius: 4px;
30
+ transition: 0.1s box-shadow;
31
+ box-shadow: var(--material-shadow-elevation-2dp);
32
+ }
33
+
34
+ .ol-control:hover {
35
+ background-color: var(--material-background-color);
36
+ }
37
+
38
+ .ol-control:not(.ol-uncollapsible):hover {
39
+ box-shadow: var(--material-shadow-elevation-4dp);
40
+ background-color: rgba(0, 0, 0, 0.2);
41
+ }
42
+
43
+ .ol-control button {
44
+ width: 2em;
45
+ height: 2em;
46
+ background-color: var(--material-background-color);
47
+ border-radius: inherit;
48
+ }
49
+
50
+ .ol-control button,
51
+ .ol-attribution:not(.ol-uncollapsible) ul {
52
+ color: var(--material-secondary-text-color);
53
+ }
54
+
55
+ .ol-control:hover button,
56
+ .ol-attribution:hover ul {
57
+ color: var(--material-body-text-color);
58
+ }
59
+
60
+ .ol-control button:hover {
61
+ color: var(--material-primary-text-color);
62
+ }
63
+
64
+ .ol-control button:active {
65
+ background-color: var(--material-secondary-background-color);
66
+ }
67
+
68
+ @supports not selector(:focus-visible) {
69
+ .ol-control button:focus {
70
+ outline: none;
71
+ box-shadow: 0 0 0 2px var(--material-primary-color);
72
+ }
73
+ }
74
+
75
+ .ol-control button:focus-visible {
76
+ outline: none;
77
+ box-shadow: 0 0 0 2px var(--material-primary-color);
78
+ }
79
+
80
+ .ol-zoom {
81
+ gap: 1px;
82
+ }
83
+
84
+ button.ol-zoom-in {
85
+ border-bottom-left-radius: 0;
86
+ border-bottom-right-radius: 0;
87
+ }
88
+
89
+ button.ol-zoom-out {
90
+ border-top-left-radius: 0;
91
+ border-top-right-radius: 0;
92
+ }
93
+
94
+ .ol-attribution.ol-uncollapsible {
95
+ border-radius: 4px 0 0;
96
+ }
97
+
98
+ .ol-attribution ul {
99
+ font-size: var(--material-caption-font-size);
100
+ cursor: default;
101
+ }
102
+
103
+ .ol-attribution:not(.ol-uncollapsible) ul {
104
+ background-color: var(--material-background-color);
105
+ }
106
+
107
+ .ol-attribution a {
108
+ color: inherit;
109
+ cursor: pointer;
110
+ }
111
+
112
+ .ol-scale-bar-inner {
113
+ border-radius: 4px;
114
+ }
115
+
116
+ .ol-full-screen {
117
+ height: 2em;
118
+ }
119
+
120
+ .ol-overviewmap:not(.ol-collapsed),
121
+ .ol-overviewmap:not(.ol-collapsed):hover {
122
+ background-color: var(--material-background-color);
123
+ }
124
+
125
+ .ol-overviewmap-map {
126
+ margin: 2px;
127
+ border: 0;
128
+ border-radius: 2px;
129
+ }
130
+
131
+ .ol-zoomslider,
132
+ .ol-zoomslider:not(.ol-uncollapsible):hover {
133
+ box-shadow: none;
134
+ overflow: visible;
135
+ }
136
+
137
+ .ol-zoomslider button {
138
+ height: 16px;
139
+ box-shadow: var(--material-shadow-elevation-2dp);
140
+ }
141
+
142
+ .ol-zoomslider:hover button {
143
+ box-shadow: var(--material-shadow-elevation-4dp);
144
+ }
145
+ `,
146
+ { moduleId: 'material-map' }
147
+ );
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2022 - 2022 Vaadin Ltd.
4
+ * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
5
+ */
6
+ import './vaadin-map-styles.js';
7
+ import '../../src/vaadin-map.js';
package/vaadin-map.js CHANGED
@@ -1,2 +1,2 @@
1
- import './theme/vaadin-map-base-theme.js';
1
+ import './theme/lumo/vaadin-map.js';
2
2
  export * from './src/vaadin-map.js';
@@ -1,305 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2022 - 2022 Vaadin Ltd.
4
- * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
5
- */
6
-
7
- /**
8
- * @licence OpenLayers
9
- *
10
- * BSD 2-Clause License, https://github.com/openlayers/openlayers/blob/main/LICENSE.md
11
- */
12
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
-
14
- // Adopted from `ol/ol.css`
15
- const mapBaseTheme = css`
16
- .ol-box {
17
- box-sizing: border-box;
18
- border-radius: 2px;
19
- border: 1.5px solid rgb(179, 197, 219);
20
- background-color: rgba(255, 255, 255, 0.4);
21
- }
22
-
23
- .ol-mouse-position {
24
- top: 8px;
25
- right: 8px;
26
- position: absolute;
27
- }
28
-
29
- .ol-scale-line {
30
- background: rgba(0, 60, 136, 0.3);
31
- border-radius: 4px;
32
- bottom: 8px;
33
- left: 8px;
34
- padding: 2px;
35
- position: absolute;
36
- }
37
- .ol-scale-line-inner {
38
- border: 1px solid #eee;
39
- border-top: none;
40
- color: #eee;
41
- font-size: 10px;
42
- text-align: center;
43
- margin: 1px;
44
- will-change: contents, width;
45
- transition: all 0.25s;
46
- }
47
- .ol-scale-bar {
48
- position: absolute;
49
- bottom: 8px;
50
- left: 8px;
51
- }
52
- .ol-scale-step-marker {
53
- width: 1px;
54
- height: 15px;
55
- background-color: #000000;
56
- float: right;
57
- z-index: 10;
58
- }
59
- .ol-scale-step-text {
60
- position: absolute;
61
- bottom: -5px;
62
- font-size: 12px;
63
- z-index: 11;
64
- color: #000000;
65
- text-shadow: -2px 0 #ffffff, 0 2px #ffffff, 2px 0 #ffffff, 0 -2px #ffffff;
66
- }
67
- .ol-scale-text {
68
- position: absolute;
69
- font-size: 14px;
70
- text-align: center;
71
- bottom: 25px;
72
- color: #000000;
73
- text-shadow: -2px 0 #ffffff, 0 2px #ffffff, 2px 0 #ffffff, 0 -2px #ffffff;
74
- }
75
- .ol-scale-singlebar {
76
- position: relative;
77
- height: 10px;
78
- z-index: 9;
79
- box-sizing: border-box;
80
- border: 1px solid black;
81
- }
82
-
83
- .ol-unsupported {
84
- display: none;
85
- }
86
- .ol-viewport,
87
- .ol-unselectable {
88
- -webkit-touch-callout: none;
89
- -webkit-user-select: none;
90
- -moz-user-select: none;
91
- -ms-user-select: none;
92
- user-select: none;
93
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
94
- }
95
- .ol-viewport canvas {
96
- all: unset;
97
- }
98
- .ol-selectable {
99
- -webkit-touch-callout: default;
100
- -webkit-user-select: text;
101
- -moz-user-select: text;
102
- -ms-user-select: text;
103
- user-select: text;
104
- }
105
- .ol-grabbing {
106
- cursor: -webkit-grabbing;
107
- cursor: -moz-grabbing;
108
- cursor: grabbing;
109
- }
110
- .ol-grab {
111
- cursor: move;
112
- cursor: -webkit-grab;
113
- cursor: -moz-grab;
114
- cursor: grab;
115
- }
116
- .ol-control {
117
- position: absolute;
118
- background-color: rgba(255, 255, 255, 0.4);
119
- border-radius: 4px;
120
- padding: 2px;
121
- }
122
- .ol-control:hover {
123
- background-color: rgba(255, 255, 255, 0.6);
124
- }
125
- .ol-zoom {
126
- top: 0.5em;
127
- left: 0.5em;
128
- }
129
- .ol-rotate {
130
- top: 0.5em;
131
- right: 0.5em;
132
- transition: opacity 0.25s linear, visibility 0s linear;
133
- }
134
- .ol-rotate.ol-hidden {
135
- opacity: 0;
136
- visibility: hidden;
137
- transition: opacity 0.25s linear, visibility 0s linear 0.25s;
138
- }
139
- .ol-zoom-extent {
140
- top: 4.643em;
141
- left: 0.5em;
142
- }
143
- .ol-full-screen {
144
- right: 0.5em;
145
- top: 0.5em;
146
- }
147
-
148
- .ol-control button {
149
- display: block;
150
- margin: 1px;
151
- padding: 0;
152
- color: white;
153
- font-weight: bold;
154
- text-decoration: none;
155
- font-size: inherit;
156
- text-align: center;
157
- height: 1.375em;
158
- width: 1.375em;
159
- line-height: 0.4em;
160
- background-color: rgba(0, 60, 136, 0.5);
161
- border: none;
162
- border-radius: 2px;
163
- }
164
- .ol-control button::-moz-focus-inner {
165
- border: none;
166
- padding: 0;
167
- }
168
- .ol-zoom-extent button {
169
- line-height: 1.4em;
170
- }
171
- .ol-compass {
172
- display: block;
173
- font-weight: normal;
174
- font-size: 1.2em;
175
- will-change: transform;
176
- }
177
- .ol-touch .ol-control button {
178
- font-size: 1.5em;
179
- }
180
- .ol-touch .ol-zoom-extent {
181
- top: 5.5em;
182
- }
183
- .ol-control button:hover,
184
- .ol-control button:focus {
185
- text-decoration: none;
186
- background-color: rgba(0, 60, 136, 0.7);
187
- }
188
- .ol-zoom .ol-zoom-in {
189
- border-radius: 2px 2px 0 0;
190
- }
191
- .ol-zoom .ol-zoom-out {
192
- border-radius: 0 0 2px 2px;
193
- }
194
-
195
- .ol-attribution {
196
- text-align: right;
197
- bottom: 0.5em;
198
- right: 0.5em;
199
- max-width: calc(100% - 1.3em);
200
- display: flex;
201
- flex-flow: row-reverse;
202
- align-items: center;
203
- }
204
- .ol-attribution a {
205
- color: rgba(0, 60, 136, 0.7);
206
- text-decoration: none;
207
- }
208
- .ol-attribution ul {
209
- margin: 0;
210
- padding: 1px 0.5em;
211
- color: #000;
212
- text-shadow: 0 0 2px #fff;
213
- font-size: 12px;
214
- }
215
- .ol-attribution li {
216
- display: inline;
217
- list-style: none;
218
- }
219
- .ol-attribution li:not(:last-child):after {
220
- content: ' ';
221
- }
222
- .ol-attribution img {
223
- max-height: 2em;
224
- max-width: inherit;
225
- vertical-align: middle;
226
- }
227
- .ol-attribution button {
228
- flex-shrink: 0;
229
- }
230
- .ol-attribution.ol-collapsed ul {
231
- display: none;
232
- }
233
- .ol-attribution:not(.ol-collapsed) {
234
- background: rgba(255, 255, 255, 0.8);
235
- }
236
- .ol-attribution.ol-uncollapsible {
237
- bottom: 0;
238
- right: 0;
239
- border-radius: 4px 0 0;
240
- }
241
- .ol-attribution.ol-uncollapsible img {
242
- margin-top: -0.2em;
243
- max-height: 1.6em;
244
- }
245
- .ol-attribution.ol-uncollapsible button {
246
- display: none;
247
- }
248
-
249
- .ol-zoomslider {
250
- top: 4.5em;
251
- left: 0.5em;
252
- height: 200px;
253
- }
254
- .ol-zoomslider button {
255
- position: relative;
256
- height: 10px;
257
- }
258
-
259
- .ol-touch .ol-zoomslider {
260
- top: 5.5em;
261
- }
262
-
263
- .ol-overviewmap {
264
- left: 0.5em;
265
- bottom: 0.5em;
266
- }
267
- .ol-overviewmap.ol-uncollapsible {
268
- bottom: 0;
269
- left: 0;
270
- border-radius: 0 4px 0 0;
271
- }
272
- .ol-overviewmap .ol-overviewmap-map,
273
- .ol-overviewmap button {
274
- display: block;
275
- }
276
- .ol-overviewmap .ol-overviewmap-map {
277
- border: 1px solid #7b98bc;
278
- height: 150px;
279
- margin: 2px;
280
- width: 150px;
281
- }
282
- .ol-overviewmap:not(.ol-collapsed) button {
283
- bottom: 2px;
284
- left: 2px;
285
- position: absolute;
286
- }
287
- .ol-overviewmap.ol-collapsed .ol-overviewmap-map,
288
- .ol-overviewmap.ol-uncollapsible button {
289
- display: none;
290
- }
291
- .ol-overviewmap:not(.ol-collapsed) {
292
- background: rgba(255, 255, 255, 0.8);
293
- }
294
- .ol-overviewmap-box {
295
- border: 2px dotted rgba(0, 60, 136, 0.7);
296
- }
297
-
298
- .ol-overviewmap .ol-overviewmap-box:hover {
299
- cursor: move;
300
- }
301
- `;
302
-
303
- registerStyles('vaadin-map', mapBaseTheme, { moduleId: 'vaadin-map-base-theme' });
304
-
305
- export { mapBaseTheme };