@fieldia/map 0.0.0-stage → 0.14.0
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/LICENSE +21 -0
- package/README.md +91 -2
- package/package.json +37 -3
- package/src/index.d.mts +6 -0
- package/src/index.d.ts +6 -0
- package/src/index.js +22 -0
- package/src/index.js.map +1 -0
- package/src/index.mjs +6 -0
- package/src/index.mjs.map +1 -0
- package/src/lib/area.d.mts +3 -0
- package/src/lib/area.d.ts +3 -0
- package/src/lib/area.js +591 -0
- package/src/lib/area.js.map +1 -0
- package/src/lib/area.mjs +588 -0
- package/src/lib/area.mjs.map +1 -0
- package/src/lib/geo.d.mts +72 -0
- package/src/lib/geo.d.ts +72 -0
- package/src/lib/geo.js +149 -0
- package/src/lib/geo.js.map +1 -0
- package/src/lib/geo.mjs +134 -0
- package/src/lib/geo.mjs.map +1 -0
- package/src/lib/kinds.d.mts +35 -0
- package/src/lib/kinds.d.ts +35 -0
- package/src/lib/kinds.js +127 -0
- package/src/lib/kinds.js.map +1 -0
- package/src/lib/kinds.mjs +124 -0
- package/src/lib/kinds.mjs.map +1 -0
- package/src/lib/labels.d.mts +58 -0
- package/src/lib/labels.d.ts +58 -0
- package/src/lib/labels.js +214 -0
- package/src/lib/labels.js.map +1 -0
- package/src/lib/labels.mjs +209 -0
- package/src/lib/labels.mjs.map +1 -0
- package/src/lib/leaflet-css.d.mts +2 -0
- package/src/lib/leaflet-css.d.ts +2 -0
- package/src/lib/leaflet-css.js +34 -0
- package/src/lib/leaflet-css.js.map +1 -0
- package/src/lib/leaflet-css.mjs +31 -0
- package/src/lib/leaflet-css.mjs.map +1 -0
- package/src/lib/leaflet.d.mts +15 -0
- package/src/lib/leaflet.d.ts +15 -0
- package/src/lib/leaflet.js +76 -0
- package/src/lib/leaflet.js.map +1 -0
- package/src/lib/leaflet.mjs +72 -0
- package/src/lib/leaflet.mjs.map +1 -0
- package/src/lib/map-core.d.mts +47 -0
- package/src/lib/map-core.d.ts +47 -0
- package/src/lib/map-core.js +300 -0
- package/src/lib/map-core.js.map +1 -0
- package/src/lib/map-core.mjs +297 -0
- package/src/lib/map-core.mjs.map +1 -0
- package/src/lib/place.d.mts +3 -0
- package/src/lib/place.d.ts +3 -0
- package/src/lib/place.js +323 -0
- package/src/lib/place.js.map +1 -0
- package/src/lib/place.mjs +320 -0
- package/src/lib/place.mjs.map +1 -0
- package/src/lib/providers.d.mts +131 -0
- package/src/lib/providers.d.ts +131 -0
- package/src/lib/providers.js +224 -0
- package/src/lib/providers.js.map +1 -0
- package/src/lib/providers.mjs +217 -0
- package/src/lib/providers.mjs.map +1 -0
- package/src/lib/search-box.d.mts +28 -0
- package/src/lib/search-box.d.ts +28 -0
- package/src/lib/search-box.js +141 -0
- package/src/lib/search-box.js.map +1 -0
- package/src/lib/search-box.mjs +138 -0
- package/src/lib/search-box.mjs.map +1 -0
- package/src/lib/settings.d.mts +19 -0
- package/src/lib/settings.d.ts +19 -0
- package/src/lib/settings.js +3 -0
- package/src/lib/settings.js.map +1 -0
- package/src/lib/settings.mjs +2 -0
- package/src/lib/settings.mjs.map +1 -0
- package/src/lib/styles.d.mts +11 -0
- package/src/lib/styles.d.ts +11 -0
- package/src/lib/styles.js +127 -0
- package/src/lib/styles.js.map +1 -0
- package/src/lib/styles.mjs +122 -0
- package/src/lib/styles.mjs.map +1 -0
- package/src/lib/widgets.d.mts +14 -0
- package/src/lib/widgets.d.ts +14 -0
- package/src/lib/widgets.js +21 -0
- package/src/lib/widgets.js.map +1 -0
- package/src/lib/widgets.mjs +18 -0
- package/src/lib/widgets.mjs.map +1 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.searchBox = searchBox;
|
|
4
|
+
function searchBox(options) {
|
|
5
|
+
const { document: doc, labels } = options;
|
|
6
|
+
const element = doc.createElement('div');
|
|
7
|
+
element.className = 'fd-map-search';
|
|
8
|
+
const input = doc.createElement('input');
|
|
9
|
+
input.className = 'fd-input';
|
|
10
|
+
input.id = options.id;
|
|
11
|
+
input.type = 'text';
|
|
12
|
+
input.placeholder = labels.search;
|
|
13
|
+
input.autocomplete = 'off';
|
|
14
|
+
input.spellcheck = false;
|
|
15
|
+
input.enterKeyHint = 'search';
|
|
16
|
+
const listId = `${options.id}-places`;
|
|
17
|
+
input.setAttribute('role', 'combobox');
|
|
18
|
+
input.setAttribute('aria-autocomplete', 'list');
|
|
19
|
+
input.setAttribute('aria-expanded', 'false');
|
|
20
|
+
input.setAttribute('aria-controls', listId);
|
|
21
|
+
const list = doc.createElement('ul');
|
|
22
|
+
list.className = 'fd-map-results';
|
|
23
|
+
list.id = listId;
|
|
24
|
+
list.setAttribute('role', 'listbox');
|
|
25
|
+
list.setAttribute('aria-label', labels.search);
|
|
26
|
+
list.hidden = true;
|
|
27
|
+
element.append(input, list);
|
|
28
|
+
let places = [];
|
|
29
|
+
let active = -1;
|
|
30
|
+
let asking = null;
|
|
31
|
+
let timer;
|
|
32
|
+
function close() {
|
|
33
|
+
list.hidden = true;
|
|
34
|
+
input.setAttribute('aria-expanded', 'false');
|
|
35
|
+
input.removeAttribute('aria-activedescendant');
|
|
36
|
+
active = -1;
|
|
37
|
+
}
|
|
38
|
+
function mark(index) {
|
|
39
|
+
active = index;
|
|
40
|
+
[...list.children].forEach((option, i) => option.setAttribute('aria-selected', String(i === index)));
|
|
41
|
+
const chosen = list.children[index];
|
|
42
|
+
if (chosen) {
|
|
43
|
+
input.setAttribute('aria-activedescendant', chosen.id);
|
|
44
|
+
chosen.scrollIntoView?.({ block: 'nearest' });
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
input.removeAttribute('aria-activedescendant');
|
|
48
|
+
}
|
|
49
|
+
function choose(place) {
|
|
50
|
+
input.value = place.label;
|
|
51
|
+
close();
|
|
52
|
+
options.say(null);
|
|
53
|
+
options.pick(place);
|
|
54
|
+
}
|
|
55
|
+
function show(found) {
|
|
56
|
+
places = found;
|
|
57
|
+
list.replaceChildren(...found.map((place, i) => {
|
|
58
|
+
const option = doc.createElement('li');
|
|
59
|
+
option.id = `${listId}-${i}`;
|
|
60
|
+
option.setAttribute('role', 'option');
|
|
61
|
+
option.setAttribute('aria-selected', 'false');
|
|
62
|
+
option.textContent = place.label;
|
|
63
|
+
// Picked on the press, the box keeping its focus.
|
|
64
|
+
option.addEventListener('mousedown', (event) => event.preventDefault());
|
|
65
|
+
option.addEventListener('click', () => choose(place));
|
|
66
|
+
return option;
|
|
67
|
+
}));
|
|
68
|
+
const any = found.length > 0;
|
|
69
|
+
list.hidden = !any;
|
|
70
|
+
input.setAttribute('aria-expanded', String(any));
|
|
71
|
+
active = -1;
|
|
72
|
+
options.say(any ? null : labels.noResults);
|
|
73
|
+
}
|
|
74
|
+
function run() {
|
|
75
|
+
clearTimeout(timer);
|
|
76
|
+
const text = input.value.trim();
|
|
77
|
+
asking?.abort();
|
|
78
|
+
if (text.length < (options.asYouType ? 3 : 1)) {
|
|
79
|
+
close();
|
|
80
|
+
options.say(null);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const mine = (asking = new AbortController());
|
|
84
|
+
options.say(labels.searching);
|
|
85
|
+
options
|
|
86
|
+
.search({ text, near: options.near(), locale: options.locale, signal: mine.signal })
|
|
87
|
+
.then((found) => mine === asking && show(found))
|
|
88
|
+
.catch((error) => {
|
|
89
|
+
if (mine !== asking || error.name === 'AbortError')
|
|
90
|
+
return;
|
|
91
|
+
close();
|
|
92
|
+
options.say(labels.searchFailed, 'error');
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
input.addEventListener('input', () => {
|
|
96
|
+
if (!options.asYouType) {
|
|
97
|
+
close();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
clearTimeout(timer);
|
|
101
|
+
timer = setTimeout(run, 350);
|
|
102
|
+
});
|
|
103
|
+
input.addEventListener('keydown', (event) => {
|
|
104
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
105
|
+
if (list.hidden)
|
|
106
|
+
return;
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
const step = event.key === 'ArrowDown' ? 1 : -1;
|
|
109
|
+
mark((active + step + places.length) % places.length);
|
|
110
|
+
}
|
|
111
|
+
else if (event.key === 'Enter') {
|
|
112
|
+
// Never the form's own Enter.
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
if (!list.hidden && active >= 0)
|
|
115
|
+
choose(places[active]);
|
|
116
|
+
else
|
|
117
|
+
run();
|
|
118
|
+
}
|
|
119
|
+
else if (event.key === 'Escape') {
|
|
120
|
+
if (!list.hidden) {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
close();
|
|
123
|
+
}
|
|
124
|
+
else if (input.value) {
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
input.value = '';
|
|
127
|
+
options.say(null);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
input.addEventListener('blur', () => close());
|
|
132
|
+
return {
|
|
133
|
+
element,
|
|
134
|
+
input,
|
|
135
|
+
destroy() {
|
|
136
|
+
clearTimeout(timer);
|
|
137
|
+
asking?.abort();
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=search-box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-box.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/search-box.ts"],"names":[],"mappings":";;AA0BA,8BAyIC;AAzID,SAAgB,SAAS,CAAC,OAAyB;IACjD,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC1C,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC;IACpC,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAA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AChD,IAAI,CAAC,CAAC,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QACxD,CAAC;aAAM,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;YACjC,8BAA8B;YAC9B,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,IAAI,CAAC;gBAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;;gBACnD,GAAG,EAAE,CAAC;QACb,CAAC;aAAM,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACjB,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,KAAK,EAAE,CAAC;YACV,CAAC;iBAAM,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBACvB,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;gBACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;IAE9C,OAAO;QACL,OAAO;QACP,KAAK;QACL,OAAO;YACL,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,EAAE,KAAK,EAAE,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export function searchBox(options) {
|
|
2
|
+
const { document: doc, labels } = options;
|
|
3
|
+
const element = doc.createElement('div');
|
|
4
|
+
element.className = 'fd-map-search';
|
|
5
|
+
const input = doc.createElement('input');
|
|
6
|
+
input.className = 'fd-input';
|
|
7
|
+
input.id = options.id;
|
|
8
|
+
input.type = 'text';
|
|
9
|
+
input.placeholder = labels.search;
|
|
10
|
+
input.autocomplete = 'off';
|
|
11
|
+
input.spellcheck = false;
|
|
12
|
+
input.enterKeyHint = 'search';
|
|
13
|
+
const listId = `${options.id}-places`;
|
|
14
|
+
input.setAttribute('role', 'combobox');
|
|
15
|
+
input.setAttribute('aria-autocomplete', 'list');
|
|
16
|
+
input.setAttribute('aria-expanded', 'false');
|
|
17
|
+
input.setAttribute('aria-controls', listId);
|
|
18
|
+
const list = doc.createElement('ul');
|
|
19
|
+
list.className = 'fd-map-results';
|
|
20
|
+
list.id = listId;
|
|
21
|
+
list.setAttribute('role', 'listbox');
|
|
22
|
+
list.setAttribute('aria-label', labels.search);
|
|
23
|
+
list.hidden = true;
|
|
24
|
+
element.append(input, list);
|
|
25
|
+
let places = [];
|
|
26
|
+
let active = -1;
|
|
27
|
+
let asking = null;
|
|
28
|
+
let timer;
|
|
29
|
+
function close() {
|
|
30
|
+
list.hidden = true;
|
|
31
|
+
input.setAttribute('aria-expanded', 'false');
|
|
32
|
+
input.removeAttribute('aria-activedescendant');
|
|
33
|
+
active = -1;
|
|
34
|
+
}
|
|
35
|
+
function mark(index) {
|
|
36
|
+
active = index;
|
|
37
|
+
[...list.children].forEach((option, i) => option.setAttribute('aria-selected', String(i === index)));
|
|
38
|
+
const chosen = list.children[index];
|
|
39
|
+
if (chosen) {
|
|
40
|
+
input.setAttribute('aria-activedescendant', chosen.id);
|
|
41
|
+
chosen.scrollIntoView?.({ block: 'nearest' });
|
|
42
|
+
}
|
|
43
|
+
else
|
|
44
|
+
input.removeAttribute('aria-activedescendant');
|
|
45
|
+
}
|
|
46
|
+
function choose(place) {
|
|
47
|
+
input.value = place.label;
|
|
48
|
+
close();
|
|
49
|
+
options.say(null);
|
|
50
|
+
options.pick(place);
|
|
51
|
+
}
|
|
52
|
+
function show(found) {
|
|
53
|
+
places = found;
|
|
54
|
+
list.replaceChildren(...found.map((place, i) => {
|
|
55
|
+
const option = doc.createElement('li');
|
|
56
|
+
option.id = `${listId}-${i}`;
|
|
57
|
+
option.setAttribute('role', 'option');
|
|
58
|
+
option.setAttribute('aria-selected', 'false');
|
|
59
|
+
option.textContent = place.label;
|
|
60
|
+
// Picked on the press, the box keeping its focus.
|
|
61
|
+
option.addEventListener('mousedown', (event) => event.preventDefault());
|
|
62
|
+
option.addEventListener('click', () => choose(place));
|
|
63
|
+
return option;
|
|
64
|
+
}));
|
|
65
|
+
const any = found.length > 0;
|
|
66
|
+
list.hidden = !any;
|
|
67
|
+
input.setAttribute('aria-expanded', String(any));
|
|
68
|
+
active = -1;
|
|
69
|
+
options.say(any ? null : labels.noResults);
|
|
70
|
+
}
|
|
71
|
+
function run() {
|
|
72
|
+
clearTimeout(timer);
|
|
73
|
+
const text = input.value.trim();
|
|
74
|
+
asking?.abort();
|
|
75
|
+
if (text.length < (options.asYouType ? 3 : 1)) {
|
|
76
|
+
close();
|
|
77
|
+
options.say(null);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const mine = (asking = new AbortController());
|
|
81
|
+
options.say(labels.searching);
|
|
82
|
+
options
|
|
83
|
+
.search({ text, near: options.near(), locale: options.locale, signal: mine.signal })
|
|
84
|
+
.then((found) => mine === asking && show(found))
|
|
85
|
+
.catch((error) => {
|
|
86
|
+
if (mine !== asking || error.name === 'AbortError')
|
|
87
|
+
return;
|
|
88
|
+
close();
|
|
89
|
+
options.say(labels.searchFailed, 'error');
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
input.addEventListener('input', () => {
|
|
93
|
+
if (!options.asYouType) {
|
|
94
|
+
close();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
clearTimeout(timer);
|
|
98
|
+
timer = setTimeout(run, 350);
|
|
99
|
+
});
|
|
100
|
+
input.addEventListener('keydown', (event) => {
|
|
101
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
102
|
+
if (list.hidden)
|
|
103
|
+
return;
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
const step = event.key === 'ArrowDown' ? 1 : -1;
|
|
106
|
+
mark((active + step + places.length) % places.length);
|
|
107
|
+
}
|
|
108
|
+
else if (event.key === 'Enter') {
|
|
109
|
+
// Never the form's own Enter.
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
if (!list.hidden && active >= 0)
|
|
112
|
+
choose(places[active]);
|
|
113
|
+
else
|
|
114
|
+
run();
|
|
115
|
+
}
|
|
116
|
+
else if (event.key === 'Escape') {
|
|
117
|
+
if (!list.hidden) {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
close();
|
|
120
|
+
}
|
|
121
|
+
else if (input.value) {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
input.value = '';
|
|
124
|
+
options.say(null);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
input.addEventListener('blur', () => close());
|
|
129
|
+
return {
|
|
130
|
+
element,
|
|
131
|
+
input,
|
|
132
|
+
destroy() {
|
|
133
|
+
clearTimeout(timer);
|
|
134
|
+
asking?.abort();
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=search-box.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-box.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/search-box.ts"],"names":[],"mappings":"AA0BA,MAAM,UAAU,SAAS,CAAC,OAAyB;IACjD,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC1C,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC;IACpC,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACzC,KAAK,CAAC,SAAS,GAAG,UAAU,CAAC;IAC7B,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,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,MAAM,CAAC,CAAC;QACxD,CAAC;aAAM,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;YACjC,8BAA8B;YAC9B,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,IAAI,CAAC;gBAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;;gBACnD,GAAG,EAAE,CAAC;QACb,CAAC;aAAM,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACjB,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,KAAK,EAAE,CAAC;YACV,CAAC;iBAAM,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBACvB,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;gBACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;IAE9C,OAAO;QACL,OAAO;QACP,KAAK;QACL,OAAO;YACL,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,EAAE,KAAK,EAAE,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Locale } from '@fieldia/core';
|
|
2
|
+
import type { LatLng } from './geo.mjs';
|
|
3
|
+
import type { MapLabels } from './labels.mjs';
|
|
4
|
+
import type { AddressSearch, MapProvider, ReverseSearch } from './providers.mjs';
|
|
5
|
+
/** What every map of an app shares: given once to `mapWidgets`. */
|
|
6
|
+
export interface MapSettings {
|
|
7
|
+
provider: MapProvider;
|
|
8
|
+
/** The app's own address search, instead of the provider's. */
|
|
9
|
+
search?: AddressSearch;
|
|
10
|
+
/** The app's own naming of a point, instead of the provider's. */
|
|
11
|
+
reverse?: ReverseSearch;
|
|
12
|
+
/** Whether the app's own search may run for each pause in typing (it may unless false). */
|
|
13
|
+
searchAsYouType?: boolean;
|
|
14
|
+
/** Where an empty map opens, and how close. */
|
|
15
|
+
center?: LatLng;
|
|
16
|
+
zoom?: number;
|
|
17
|
+
/** The app's own words over the maps', by language. */
|
|
18
|
+
labels?: Partial<Record<Locale, Partial<MapLabels>>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Locale } from '@fieldia/core';
|
|
2
|
+
import type { LatLng } from './geo';
|
|
3
|
+
import type { MapLabels } from './labels';
|
|
4
|
+
import type { AddressSearch, MapProvider, ReverseSearch } from './providers';
|
|
5
|
+
/** What every map of an app shares: given once to `mapWidgets`. */
|
|
6
|
+
export interface MapSettings {
|
|
7
|
+
provider: MapProvider;
|
|
8
|
+
/** The app's own address search, instead of the provider's. */
|
|
9
|
+
search?: AddressSearch;
|
|
10
|
+
/** The app's own naming of a point, instead of the provider's. */
|
|
11
|
+
reverse?: ReverseSearch;
|
|
12
|
+
/** Whether the app's own search may run for each pause in typing (it may unless false). */
|
|
13
|
+
searchAsYouType?: boolean;
|
|
14
|
+
/** Where an empty map opens, and how close. */
|
|
15
|
+
center?: LatLng;
|
|
16
|
+
zoom?: number;
|
|
17
|
+
/** The app's own words over the maps', by language. */
|
|
18
|
+
labels?: Partial<Record<Locale, Partial<MapLabels>>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/settings.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/settings.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The maps in Fieldia's colours: every colour a token, so a theme, a host's
|
|
3
|
+
* tokens and the dark scheme reach the map's buttons, search, shapes and
|
|
4
|
+
* grips. Fixed on purpose: the veil over the map that asks for two fingers
|
|
5
|
+
* or Ctrl (white words on a dark veil, as an image's caption has them).
|
|
6
|
+
*/
|
|
7
|
+
export declare const MAP_CSS = "\n.fd-map-field { display: grid; gap: 8px; min-width: 0; }\n.fd-map-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }\n.fd-map-tools .fd-button { min-height: 32px; padding-inline: 10px; }\n.fd-map-tools .fd-button[aria-pressed=\"true\"] { background: var(--fd-accent-soft); border-color: var(--fd-accent); color: var(--fd-accent); }\n.fd-map-tools .fd-button svg { width: 16px; height: 16px; flex: none; }\n.fd-map-search { position: relative; flex: 1 1 220px; min-width: 0; }\n.fd-map-results {\n position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 1100; margin: 0; padding: 4px; list-style: none;\n background: var(--fd-surface); color: var(--fd-text); border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius);\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16); max-height: 240px; overflow: auto;\n}\n.fd-map-results [role=\"option\"] { padding: 6px 8px; border-radius: 4px; cursor: pointer; line-height: 1.35; }\n.fd-map-results [role=\"option\"][aria-selected=\"true\"], .fd-map-results [role=\"option\"]:hover { background: var(--fd-accent-soft); }\n.fd-map-results .fd-map-results-note { padding: 6px 8px; color: var(--fd-muted); cursor: default; }\n.fd-map-box {\n position: relative; height: var(--fd-map-height, 280px); min-height: 160px; overflow: hidden; isolation: isolate;\n border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius); background: var(--fd-fill);\n}\n.fd-map-box.leaflet-container:focus { outline: none; }\n.fd-map-box.leaflet-container[data-keys]:focus { outline: 2px solid var(--fd-focus); outline-offset: 1px; }\n.fd-map-box.leaflet-container { font: inherit; background: var(--fd-fill); }\n.fd-map-zoom { position: absolute; top: 8px; z-index: 1000; display: grid; gap: 4px; }\n.fd-map-zoom[data-side=\"right\"] { right: 8px; }\n.fd-map-zoom[data-side=\"left\"] { left: 8px; }\n.fd-map-zoom button {\n width: 32px; height: 32px; display: grid; place-items: center; padding: 0; cursor: pointer; font: 600 18px/1 system-ui, sans-serif;\n background: var(--fd-surface); color: var(--fd-text); border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);\n}\n.fd-map-zoom button:hover { color: var(--fd-accent); border-color: var(--fd-accent); }\n.fd-map-zoom button:focus-visible, .fd-map-hint button:focus-visible { outline: 2px solid var(--fd-focus); outline-offset: 1px; }\n.fd-map-credits {\n position: absolute; right: 0; bottom: 0; z-index: 1000; max-width: 72%; padding: 1px 6px; font-size: 11px; line-height: 1.5;\n background: color-mix(in srgb, var(--fd-surface) 88%, transparent); color: var(--fd-text); border-top-left-radius: 4px;\n}\n.fd-map-credits a { color: inherit; }\n.fd-map-logo { position: absolute; left: 6px; bottom: 4px; z-index: 1000; display: inline-flex; align-items: center; text-decoration: none; }\n.fd-map-logo img { height: 18px; width: auto; display: block; }\n.fd-map-logo span {\n font: 700 12px/1.4 system-ui, sans-serif; padding: 0 5px; border-radius: 3px;\n background: color-mix(in srgb, var(--fd-surface) 88%, transparent); color: var(--fd-text);\n}\n.fd-map-veil {\n position: absolute; inset: 0; z-index: 1001; display: grid; place-items: center; padding: 16px; text-align: center;\n background: rgba(0, 0, 0, 0.5); color: #fff; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s;\n}\n.fd-map-veil[data-show] { opacity: 1; }\n.fd-map-crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; z-index: 900; pointer-events: none; display: none; }\n.fd-map-crosshair::before, .fd-map-crosshair::after { content: \"\"; position: absolute; background: var(--fd-accent); box-shadow: 0 0 0 1px var(--fd-surface); }\n.fd-map-crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }\n.fd-map-crosshair::after { top: 10px; left: 0; height: 2px; width: 22px; }\n.fd-map-box[data-keys]:focus .fd-map-crosshair { display: block; }\n.fd-map-hint {\n position: absolute; top: 8px; left: 8px; right: 52px; z-index: 1000; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;\n padding: 6px 10px; font-size: 13px; line-height: 1.4; background: var(--fd-surface); color: var(--fd-text);\n border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);\n}\n.fd-map-box[data-side=\"left\"] .fd-map-hint { left: 52px; right: 8px; }\n.fd-map-hint p { margin: 0; flex: 1 1 180px; min-width: 0; }\n.fd-map-hint .fd-button { min-height: 28px; padding: 2px 10px; }\n.fd-map-coords { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }\n.fd-map-coords label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fd-muted); }\n.fd-map-coords .fd-input { width: 12ch; font-variant-numeric: tabular-nums; }\n.fd-map-coords .fd-input[aria-invalid=\"true\"] { border-color: var(--fd-error); }\n.fd-map-note { margin: 0; font-size: 12.5px; color: var(--fd-muted); }\n.fd-map-note[data-tone=\"error\"] { color: var(--fd-error); }\n.fd-map-pin { width: 28px; height: 40px; }\n.fd-map-pin svg { display: block; width: 28px; height: 40px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3)); }\n.fd-map-pin .fd-map-pin-body { fill: var(--fd-accent); stroke: var(--fd-surface); stroke-width: 1.5; }\n.fd-map-pin .fd-map-pin-dot { fill: var(--fd-surface); }\n.fd-map-pin:focus-visible { outline: 2px solid var(--fd-focus); outline-offset: 2px; border-radius: 4px; }\npath.fd-map-shape { stroke: var(--fd-accent); fill: var(--fd-accent); stroke-width: 2; fill-opacity: 0.16; }\npath.fd-map-shape.fd-map-movable { cursor: move; }\npath.fd-map-trace { stroke: var(--fd-accent); fill: var(--fd-accent); stroke-width: 2; fill-opacity: 0.08; stroke-dasharray: 6 5; pointer-events: none; }\n.fd-map-grip { width: 24px; height: 24px; display: grid; place-items: center; cursor: grab; }\n.fd-map-grip::after {\n content: \"\"; width: 12px; height: 12px; border-radius: 50%; box-sizing: border-box;\n background: var(--fd-surface); border: 2px solid var(--fd-accent); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\n}\n.fd-map-grip[data-closes]::after { width: 18px; height: 18px; background: var(--fd-accent); border-color: var(--fd-surface); }\n.fd-map-grip:focus-visible { outline: none; }\n.fd-map-grip:focus-visible::after { box-shadow: 0 0 0 3px var(--fd-focus); }\n.fd-map-field select.fd-input { width: auto; max-width: 100%; }\n/* One finger scrolls the page past a map, as on any page; two move it. While a shape is drawn, the map takes every touch. */\n.fd-map-box.leaflet-container, .fd-map-box.leaflet-touch-drag.leaflet-touch-zoom { touch-action: pan-x pan-y; }\n.fd-map-box.leaflet-container[data-drawing] { touch-action: none; }\n.fd-map-box .leaflet-marker-draggable { touch-action: none; }\n.fd-map-grip-add::after { width: 10px; height: 10px; opacity: 0.7; }\n/* Each image overlaps the next by a pixel (leaflet.ts): drawn plainly over it, not added to it as Leaflet's own seam fix adds light. */\n.fd-map-box.leaflet-container img.leaflet-tile { mix-blend-mode: normal; }\n";
|
|
8
|
+
/** The maps' own stylesheet, once per document: the tools, the search and the box are drawn before Leaflet has loaded. */
|
|
9
|
+
export declare function installMapStyles(doc: Document): void;
|
|
10
|
+
/** Leaflet's stylesheet, once per document, before the maps' own (which add to it): it comes with Leaflet. */
|
|
11
|
+
export declare function installLeafletStyles(doc: Document, css: string): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The maps in Fieldia's colours: every colour a token, so a theme, a host's
|
|
3
|
+
* tokens and the dark scheme reach the map's buttons, search, shapes and
|
|
4
|
+
* grips. Fixed on purpose: the veil over the map that asks for two fingers
|
|
5
|
+
* or Ctrl (white words on a dark veil, as an image's caption has them).
|
|
6
|
+
*/
|
|
7
|
+
export declare const MAP_CSS = "\n.fd-map-field { display: grid; gap: 8px; min-width: 0; }\n.fd-map-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }\n.fd-map-tools .fd-button { min-height: 32px; padding-inline: 10px; }\n.fd-map-tools .fd-button[aria-pressed=\"true\"] { background: var(--fd-accent-soft); border-color: var(--fd-accent); color: var(--fd-accent); }\n.fd-map-tools .fd-button svg { width: 16px; height: 16px; flex: none; }\n.fd-map-search { position: relative; flex: 1 1 220px; min-width: 0; }\n.fd-map-results {\n position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 1100; margin: 0; padding: 4px; list-style: none;\n background: var(--fd-surface); color: var(--fd-text); border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius);\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16); max-height: 240px; overflow: auto;\n}\n.fd-map-results [role=\"option\"] { padding: 6px 8px; border-radius: 4px; cursor: pointer; line-height: 1.35; }\n.fd-map-results [role=\"option\"][aria-selected=\"true\"], .fd-map-results [role=\"option\"]:hover { background: var(--fd-accent-soft); }\n.fd-map-results .fd-map-results-note { padding: 6px 8px; color: var(--fd-muted); cursor: default; }\n.fd-map-box {\n position: relative; height: var(--fd-map-height, 280px); min-height: 160px; overflow: hidden; isolation: isolate;\n border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius); background: var(--fd-fill);\n}\n.fd-map-box.leaflet-container:focus { outline: none; }\n.fd-map-box.leaflet-container[data-keys]:focus { outline: 2px solid var(--fd-focus); outline-offset: 1px; }\n.fd-map-box.leaflet-container { font: inherit; background: var(--fd-fill); }\n.fd-map-zoom { position: absolute; top: 8px; z-index: 1000; display: grid; gap: 4px; }\n.fd-map-zoom[data-side=\"right\"] { right: 8px; }\n.fd-map-zoom[data-side=\"left\"] { left: 8px; }\n.fd-map-zoom button {\n width: 32px; height: 32px; display: grid; place-items: center; padding: 0; cursor: pointer; font: 600 18px/1 system-ui, sans-serif;\n background: var(--fd-surface); color: var(--fd-text); border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);\n}\n.fd-map-zoom button:hover { color: var(--fd-accent); border-color: var(--fd-accent); }\n.fd-map-zoom button:focus-visible, .fd-map-hint button:focus-visible { outline: 2px solid var(--fd-focus); outline-offset: 1px; }\n.fd-map-credits {\n position: absolute; right: 0; bottom: 0; z-index: 1000; max-width: 72%; padding: 1px 6px; font-size: 11px; line-height: 1.5;\n background: color-mix(in srgb, var(--fd-surface) 88%, transparent); color: var(--fd-text); border-top-left-radius: 4px;\n}\n.fd-map-credits a { color: inherit; }\n.fd-map-logo { position: absolute; left: 6px; bottom: 4px; z-index: 1000; display: inline-flex; align-items: center; text-decoration: none; }\n.fd-map-logo img { height: 18px; width: auto; display: block; }\n.fd-map-logo span {\n font: 700 12px/1.4 system-ui, sans-serif; padding: 0 5px; border-radius: 3px;\n background: color-mix(in srgb, var(--fd-surface) 88%, transparent); color: var(--fd-text);\n}\n.fd-map-veil {\n position: absolute; inset: 0; z-index: 1001; display: grid; place-items: center; padding: 16px; text-align: center;\n background: rgba(0, 0, 0, 0.5); color: #fff; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s;\n}\n.fd-map-veil[data-show] { opacity: 1; }\n.fd-map-crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; z-index: 900; pointer-events: none; display: none; }\n.fd-map-crosshair::before, .fd-map-crosshair::after { content: \"\"; position: absolute; background: var(--fd-accent); box-shadow: 0 0 0 1px var(--fd-surface); }\n.fd-map-crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }\n.fd-map-crosshair::after { top: 10px; left: 0; height: 2px; width: 22px; }\n.fd-map-box[data-keys]:focus .fd-map-crosshair { display: block; }\n.fd-map-hint {\n position: absolute; top: 8px; left: 8px; right: 52px; z-index: 1000; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;\n padding: 6px 10px; font-size: 13px; line-height: 1.4; background: var(--fd-surface); color: var(--fd-text);\n border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);\n}\n.fd-map-box[data-side=\"left\"] .fd-map-hint { left: 52px; right: 8px; }\n.fd-map-hint p { margin: 0; flex: 1 1 180px; min-width: 0; }\n.fd-map-hint .fd-button { min-height: 28px; padding: 2px 10px; }\n.fd-map-coords { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }\n.fd-map-coords label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fd-muted); }\n.fd-map-coords .fd-input { width: 12ch; font-variant-numeric: tabular-nums; }\n.fd-map-coords .fd-input[aria-invalid=\"true\"] { border-color: var(--fd-error); }\n.fd-map-note { margin: 0; font-size: 12.5px; color: var(--fd-muted); }\n.fd-map-note[data-tone=\"error\"] { color: var(--fd-error); }\n.fd-map-pin { width: 28px; height: 40px; }\n.fd-map-pin svg { display: block; width: 28px; height: 40px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3)); }\n.fd-map-pin .fd-map-pin-body { fill: var(--fd-accent); stroke: var(--fd-surface); stroke-width: 1.5; }\n.fd-map-pin .fd-map-pin-dot { fill: var(--fd-surface); }\n.fd-map-pin:focus-visible { outline: 2px solid var(--fd-focus); outline-offset: 2px; border-radius: 4px; }\npath.fd-map-shape { stroke: var(--fd-accent); fill: var(--fd-accent); stroke-width: 2; fill-opacity: 0.16; }\npath.fd-map-shape.fd-map-movable { cursor: move; }\npath.fd-map-trace { stroke: var(--fd-accent); fill: var(--fd-accent); stroke-width: 2; fill-opacity: 0.08; stroke-dasharray: 6 5; pointer-events: none; }\n.fd-map-grip { width: 24px; height: 24px; display: grid; place-items: center; cursor: grab; }\n.fd-map-grip::after {\n content: \"\"; width: 12px; height: 12px; border-radius: 50%; box-sizing: border-box;\n background: var(--fd-surface); border: 2px solid var(--fd-accent); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\n}\n.fd-map-grip[data-closes]::after { width: 18px; height: 18px; background: var(--fd-accent); border-color: var(--fd-surface); }\n.fd-map-grip:focus-visible { outline: none; }\n.fd-map-grip:focus-visible::after { box-shadow: 0 0 0 3px var(--fd-focus); }\n.fd-map-field select.fd-input { width: auto; max-width: 100%; }\n/* One finger scrolls the page past a map, as on any page; two move it. While a shape is drawn, the map takes every touch. */\n.fd-map-box.leaflet-container, .fd-map-box.leaflet-touch-drag.leaflet-touch-zoom { touch-action: pan-x pan-y; }\n.fd-map-box.leaflet-container[data-drawing] { touch-action: none; }\n.fd-map-box .leaflet-marker-draggable { touch-action: none; }\n.fd-map-grip-add::after { width: 10px; height: 10px; opacity: 0.7; }\n/* Each image overlaps the next by a pixel (leaflet.ts): drawn plainly over it, not added to it as Leaflet's own seam fix adds light. */\n.fd-map-box.leaflet-container img.leaflet-tile { mix-blend-mode: normal; }\n";
|
|
8
|
+
/** The maps' own stylesheet, once per document: the tools, the search and the box are drawn before Leaflet has loaded. */
|
|
9
|
+
export declare function installMapStyles(doc: Document): void;
|
|
10
|
+
/** Leaflet's stylesheet, once per document, before the maps' own (which add to it): it comes with Leaflet. */
|
|
11
|
+
export declare function installLeafletStyles(doc: Document, css: string): void;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAP_CSS = void 0;
|
|
4
|
+
exports.installMapStyles = installMapStyles;
|
|
5
|
+
exports.installLeafletStyles = installLeafletStyles;
|
|
6
|
+
/**
|
|
7
|
+
* The maps in Fieldia's colours: every colour a token, so a theme, a host's
|
|
8
|
+
* tokens and the dark scheme reach the map's buttons, search, shapes and
|
|
9
|
+
* grips. Fixed on purpose: the veil over the map that asks for two fingers
|
|
10
|
+
* or Ctrl (white words on a dark veil, as an image's caption has them).
|
|
11
|
+
*/
|
|
12
|
+
exports.MAP_CSS = `
|
|
13
|
+
.fd-map-field { display: grid; gap: 8px; min-width: 0; }
|
|
14
|
+
.fd-map-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
|
|
15
|
+
.fd-map-tools .fd-button { min-height: 32px; padding-inline: 10px; }
|
|
16
|
+
.fd-map-tools .fd-button[aria-pressed="true"] { background: var(--fd-accent-soft); border-color: var(--fd-accent); color: var(--fd-accent); }
|
|
17
|
+
.fd-map-tools .fd-button svg { width: 16px; height: 16px; flex: none; }
|
|
18
|
+
.fd-map-search { position: relative; flex: 1 1 220px; min-width: 0; }
|
|
19
|
+
.fd-map-results {
|
|
20
|
+
position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 1100; margin: 0; padding: 4px; list-style: none;
|
|
21
|
+
background: var(--fd-surface); color: var(--fd-text); border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius);
|
|
22
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16); max-height: 240px; overflow: auto;
|
|
23
|
+
}
|
|
24
|
+
.fd-map-results [role="option"] { padding: 6px 8px; border-radius: 4px; cursor: pointer; line-height: 1.35; }
|
|
25
|
+
.fd-map-results [role="option"][aria-selected="true"], .fd-map-results [role="option"]:hover { background: var(--fd-accent-soft); }
|
|
26
|
+
.fd-map-results .fd-map-results-note { padding: 6px 8px; color: var(--fd-muted); cursor: default; }
|
|
27
|
+
.fd-map-box {
|
|
28
|
+
position: relative; height: var(--fd-map-height, 280px); min-height: 160px; overflow: hidden; isolation: isolate;
|
|
29
|
+
border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius); background: var(--fd-fill);
|
|
30
|
+
}
|
|
31
|
+
.fd-map-box.leaflet-container:focus { outline: none; }
|
|
32
|
+
.fd-map-box.leaflet-container[data-keys]:focus { outline: 2px solid var(--fd-focus); outline-offset: 1px; }
|
|
33
|
+
.fd-map-box.leaflet-container { font: inherit; background: var(--fd-fill); }
|
|
34
|
+
.fd-map-zoom { position: absolute; top: 8px; z-index: 1000; display: grid; gap: 4px; }
|
|
35
|
+
.fd-map-zoom[data-side="right"] { right: 8px; }
|
|
36
|
+
.fd-map-zoom[data-side="left"] { left: 8px; }
|
|
37
|
+
.fd-map-zoom button {
|
|
38
|
+
width: 32px; height: 32px; display: grid; place-items: center; padding: 0; cursor: pointer; font: 600 18px/1 system-ui, sans-serif;
|
|
39
|
+
background: var(--fd-surface); color: var(--fd-text); border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius);
|
|
40
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
|
|
41
|
+
}
|
|
42
|
+
.fd-map-zoom button:hover { color: var(--fd-accent); border-color: var(--fd-accent); }
|
|
43
|
+
.fd-map-zoom button:focus-visible, .fd-map-hint button:focus-visible { outline: 2px solid var(--fd-focus); outline-offset: 1px; }
|
|
44
|
+
.fd-map-credits {
|
|
45
|
+
position: absolute; right: 0; bottom: 0; z-index: 1000; max-width: 72%; padding: 1px 6px; font-size: 11px; line-height: 1.5;
|
|
46
|
+
background: color-mix(in srgb, var(--fd-surface) 88%, transparent); color: var(--fd-text); border-top-left-radius: 4px;
|
|
47
|
+
}
|
|
48
|
+
.fd-map-credits a { color: inherit; }
|
|
49
|
+
.fd-map-logo { position: absolute; left: 6px; bottom: 4px; z-index: 1000; display: inline-flex; align-items: center; text-decoration: none; }
|
|
50
|
+
.fd-map-logo img { height: 18px; width: auto; display: block; }
|
|
51
|
+
.fd-map-logo span {
|
|
52
|
+
font: 700 12px/1.4 system-ui, sans-serif; padding: 0 5px; border-radius: 3px;
|
|
53
|
+
background: color-mix(in srgb, var(--fd-surface) 88%, transparent); color: var(--fd-text);
|
|
54
|
+
}
|
|
55
|
+
.fd-map-veil {
|
|
56
|
+
position: absolute; inset: 0; z-index: 1001; display: grid; place-items: center; padding: 16px; text-align: center;
|
|
57
|
+
background: rgba(0, 0, 0, 0.5); color: #fff; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s;
|
|
58
|
+
}
|
|
59
|
+
.fd-map-veil[data-show] { opacity: 1; }
|
|
60
|
+
.fd-map-crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; z-index: 900; pointer-events: none; display: none; }
|
|
61
|
+
.fd-map-crosshair::before, .fd-map-crosshair::after { content: ""; position: absolute; background: var(--fd-accent); box-shadow: 0 0 0 1px var(--fd-surface); }
|
|
62
|
+
.fd-map-crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }
|
|
63
|
+
.fd-map-crosshair::after { top: 10px; left: 0; height: 2px; width: 22px; }
|
|
64
|
+
.fd-map-box[data-keys]:focus .fd-map-crosshair { display: block; }
|
|
65
|
+
.fd-map-hint {
|
|
66
|
+
position: absolute; top: 8px; left: 8px; right: 52px; z-index: 1000; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
|
|
67
|
+
padding: 6px 10px; font-size: 13px; line-height: 1.4; background: var(--fd-surface); color: var(--fd-text);
|
|
68
|
+
border: 1px solid var(--fd-border); border-radius: var(--fd-control-radius); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
|
|
69
|
+
}
|
|
70
|
+
.fd-map-box[data-side="left"] .fd-map-hint { left: 52px; right: 8px; }
|
|
71
|
+
.fd-map-hint p { margin: 0; flex: 1 1 180px; min-width: 0; }
|
|
72
|
+
.fd-map-hint .fd-button { min-height: 28px; padding: 2px 10px; }
|
|
73
|
+
.fd-map-coords { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
|
|
74
|
+
.fd-map-coords label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fd-muted); }
|
|
75
|
+
.fd-map-coords .fd-input { width: 12ch; font-variant-numeric: tabular-nums; }
|
|
76
|
+
.fd-map-coords .fd-input[aria-invalid="true"] { border-color: var(--fd-error); }
|
|
77
|
+
.fd-map-note { margin: 0; font-size: 12.5px; color: var(--fd-muted); }
|
|
78
|
+
.fd-map-note[data-tone="error"] { color: var(--fd-error); }
|
|
79
|
+
.fd-map-pin { width: 28px; height: 40px; }
|
|
80
|
+
.fd-map-pin svg { display: block; width: 28px; height: 40px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3)); }
|
|
81
|
+
.fd-map-pin .fd-map-pin-body { fill: var(--fd-accent); stroke: var(--fd-surface); stroke-width: 1.5; }
|
|
82
|
+
.fd-map-pin .fd-map-pin-dot { fill: var(--fd-surface); }
|
|
83
|
+
.fd-map-pin:focus-visible { outline: 2px solid var(--fd-focus); outline-offset: 2px; border-radius: 4px; }
|
|
84
|
+
path.fd-map-shape { stroke: var(--fd-accent); fill: var(--fd-accent); stroke-width: 2; fill-opacity: 0.16; }
|
|
85
|
+
path.fd-map-shape.fd-map-movable { cursor: move; }
|
|
86
|
+
path.fd-map-trace { stroke: var(--fd-accent); fill: var(--fd-accent); stroke-width: 2; fill-opacity: 0.08; stroke-dasharray: 6 5; pointer-events: none; }
|
|
87
|
+
.fd-map-grip { width: 24px; height: 24px; display: grid; place-items: center; cursor: grab; }
|
|
88
|
+
.fd-map-grip::after {
|
|
89
|
+
content: ""; width: 12px; height: 12px; border-radius: 50%; box-sizing: border-box;
|
|
90
|
+
background: var(--fd-surface); border: 2px solid var(--fd-accent); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
|
|
91
|
+
}
|
|
92
|
+
.fd-map-grip[data-closes]::after { width: 18px; height: 18px; background: var(--fd-accent); border-color: var(--fd-surface); }
|
|
93
|
+
.fd-map-grip:focus-visible { outline: none; }
|
|
94
|
+
.fd-map-grip:focus-visible::after { box-shadow: 0 0 0 3px var(--fd-focus); }
|
|
95
|
+
.fd-map-field select.fd-input { width: auto; max-width: 100%; }
|
|
96
|
+
/* One finger scrolls the page past a map, as on any page; two move it. While a shape is drawn, the map takes every touch. */
|
|
97
|
+
.fd-map-box.leaflet-container, .fd-map-box.leaflet-touch-drag.leaflet-touch-zoom { touch-action: pan-x pan-y; }
|
|
98
|
+
.fd-map-box.leaflet-container[data-drawing] { touch-action: none; }
|
|
99
|
+
.fd-map-box .leaflet-marker-draggable { touch-action: none; }
|
|
100
|
+
.fd-map-grip-add::after { width: 10px; height: 10px; opacity: 0.7; }
|
|
101
|
+
/* Each image overlaps the next by a pixel (leaflet.ts): drawn plainly over it, not added to it as Leaflet's own seam fix adds light. */
|
|
102
|
+
.fd-map-box.leaflet-container img.leaflet-tile { mix-blend-mode: normal; }
|
|
103
|
+
`;
|
|
104
|
+
/** The maps' own stylesheet, once per document: the tools, the search and the box are drawn before Leaflet has loaded. */
|
|
105
|
+
function installMapStyles(doc) {
|
|
106
|
+
if (doc.getElementById('fieldia-map-styles'))
|
|
107
|
+
return;
|
|
108
|
+
const own = doc.createElement('style');
|
|
109
|
+
own.id = 'fieldia-map-styles';
|
|
110
|
+
own.textContent = exports.MAP_CSS;
|
|
111
|
+
// Before the page's own styles, so an app's rule for a map wins over these.
|
|
112
|
+
doc.head.prepend(own);
|
|
113
|
+
}
|
|
114
|
+
/** Leaflet's stylesheet, once per document, before the maps' own (which add to it): it comes with Leaflet. */
|
|
115
|
+
function installLeafletStyles(doc, css) {
|
|
116
|
+
if (doc.getElementById('fieldia-leaflet-styles'))
|
|
117
|
+
return;
|
|
118
|
+
const leaflet = doc.createElement('style');
|
|
119
|
+
leaflet.id = 'fieldia-leaflet-styles';
|
|
120
|
+
leaflet.textContent = css;
|
|
121
|
+
const own = doc.getElementById('fieldia-map-styles');
|
|
122
|
+
if (own)
|
|
123
|
+
own.before(leaflet);
|
|
124
|
+
else
|
|
125
|
+
doc.head.prepend(leaflet);
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/styles.ts"],"names":[],"mappings":";;;AAoGA,4CAOC;AAGD,oDAQC;AAtHD;;;;;GAKG;AACU,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2FtB,CAAC;AAEF,0HAA0H;AAC1H,SAAgB,gBAAgB,CAAC,GAAa;IAC5C,IAAI,GAAG,CAAC,cAAc,CAAC,oBAAoB,CAAC;QAAE,OAAO;IACrD,MAAM,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACvC,GAAG,CAAC,EAAE,GAAG,oBAAoB,CAAC;IAC9B,GAAG,CAAC,WAAW,GAAG,eAAO,CAAC;IAC1B,4EAA4E;IAC5E,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,8GAA8G;AAC9G,SAAgB,oBAAoB,CAAC,GAAa,EAAE,GAAW;IAC7D,IAAI,GAAG,CAAC,cAAc,CAAC,wBAAwB,CAAC;QAAE,OAAO;IACzD,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3C,OAAO,CAAC,EAAE,GAAG,wBAAwB,CAAC;IACtC,OAAO,CAAC,WAAW,GAAG,GAAG,CAAC;IAC1B,MAAM,GAAG,GAAG,GAAG,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;IACrD,IAAI,GAAG;QAAE,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;;QACxB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC"}
|