@panneau/fields 5.0.0-alpha.0 → 5.0.0-alpha.10
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/README.md +103 -20
- package/dist/boolean/BooleanField.d.ts +1 -1
- package/dist/boolean/BooleanField.js +78 -17
- package/dist/boolean/BooleanField.js.map +1 -1
- package/dist/boolean/index.d.ts +1 -1
- package/dist/color/ColorField.css +5 -5
- package/dist/color/ColorField.d.ts +2 -2
- package/dist/color/ColorField.js.map +1 -1
- package/dist/color/ColorField.module.js +3 -3
- package/dist/color/index.d.ts +1 -1
- package/dist/date/DateField.d.ts +1 -1
- package/dist/date/DateField.js.map +1 -1
- package/dist/date/index.d.ts +1 -1
- package/dist/datetime/DateTimeField.d.ts +1 -1
- package/dist/datetime/DateTimeField.js +107 -20
- package/dist/datetime/DateTimeField.js.map +1 -1
- package/dist/datetime/index.d.ts +1 -1
- package/dist/duration/DurationField.css +11 -0
- package/dist/duration/DurationField.d.ts +26 -0
- package/dist/duration/DurationField.d.ts.map +1 -0
- package/dist/duration/DurationField.js +214 -0
- package/dist/duration/DurationField.js.map +1 -0
- package/dist/duration/DurationField.module.js +12 -0
- package/dist/duration/DurationField.module.js.map +1 -0
- package/dist/duration/index.d.ts +2 -0
- package/dist/duration/index.d.ts.map +1 -0
- package/dist/duration/index.js +1 -0
- package/dist/email/EmailField.d.ts +2 -2
- package/dist/email/EmailField.js.map +1 -1
- package/dist/email/index.d.ts +1 -1
- package/dist/embed/EmbedField.css +60 -0
- package/dist/embed/EmbedField.d.ts +20 -0
- package/dist/embed/EmbedField.d.ts.map +1 -0
- package/dist/embed/EmbedField.js +246 -0
- package/dist/embed/EmbedField.js.map +1 -0
- package/dist/embed/EmbedField.module.js +22 -0
- package/dist/embed/EmbedField.module.js.map +1 -0
- package/dist/embed/index.d.ts +3 -0
- package/dist/embed/index.d.ts.map +1 -0
- package/dist/embed/index.js +3 -0
- package/dist/file/FileField.css +54 -0
- package/dist/file/FileField.d.ts +50 -0
- package/dist/file/FileField.d.ts.map +1 -0
- package/dist/file/FileField.js +288 -0
- package/dist/file/FileField.js.map +1 -0
- package/dist/file/FileField.module.js +22 -0
- package/dist/file/FileField.module.js.map +1 -0
- package/dist/file/index.d.ts +3 -0
- package/dist/file/index.d.ts.map +1 -0
- package/dist/file/index.js +1 -0
- package/dist/group/GroupField.css +2 -2
- package/dist/group/GroupField.d.ts +1 -1
- package/dist/group/GroupField.js.map +1 -1
- package/dist/group/GroupField.module.js +1 -1
- package/dist/group/index.d.ts +1 -1
- package/dist/index.d.ts +18 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/json/JsonField.css +7 -0
- package/dist/json/JsonField.d.ts +22 -0
- package/dist/json/JsonField.d.ts.map +1 -0
- package/dist/json/JsonField.js +207 -0
- package/dist/json/JsonField.js.map +1 -0
- package/dist/json/JsonField.module.js +8 -0
- package/dist/json/JsonField.module.js.map +1 -0
- package/dist/json/index.d.ts +2 -0
- package/dist/json/index.d.ts.map +1 -0
- package/dist/json/index.js +1 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/localized/LocalizedField.css +2 -2
- package/dist/localized/LocalizedField.d.ts +1 -1
- package/dist/localized/LocalizedField.d.ts.map +1 -1
- package/dist/localized/LocalizedField.js +1 -0
- package/dist/localized/LocalizedField.js.map +1 -1
- package/dist/localized/LocalizedField.module.js +2 -2
- package/dist/localized/index.d.ts +1 -1
- package/dist/location/LocationField.css +54 -0
- package/dist/location/LocationField.d.ts +31 -0
- package/dist/location/LocationField.d.ts.map +1 -0
- package/dist/location/LocationField.js +563 -0
- package/dist/location/LocationField.js.map +1 -0
- package/dist/location/LocationField.module.js +22 -0
- package/dist/location/LocationField.module.js.map +1 -0
- package/dist/location/LocationMap.d.ts +25 -0
- package/dist/location/LocationMap.d.ts.map +1 -0
- package/dist/location/LocationMap.js +205 -0
- package/dist/location/LocationMap.js.map +1 -0
- package/dist/location/index.d.ts +5 -0
- package/dist/location/index.d.ts.map +1 -0
- package/dist/location/index.js +4 -0
- package/dist/location/leafletCss.d.ts +2 -0
- package/dist/location/leafletCss.d.ts.map +1 -0
- package/dist/location/leafletCss.js +6 -0
- package/dist/location/leafletCss.js.map +1 -0
- package/dist/location/nominatim.d.ts +17 -0
- package/dist/location/nominatim.d.ts.map +1 -0
- package/dist/location/nominatim.js +50 -0
- package/dist/location/nominatim.js.map +1 -0
- package/dist/location/types.d.ts +40 -0
- package/dist/location/types.d.ts.map +1 -0
- package/dist/missing/MissingField.css +4 -3
- package/dist/missing/MissingField.d.ts +4 -3
- package/dist/missing/MissingField.d.ts.map +1 -1
- package/dist/missing/MissingField.js +3 -2
- package/dist/missing/MissingField.js.map +1 -1
- package/dist/missing/MissingField.module.js +3 -3
- package/dist/missing/MissingField.module.js.map +1 -1
- package/dist/number/NumberField.d.ts +1 -1
- package/dist/number/NumberField.js.map +1 -1
- package/dist/number/index.d.ts +1 -1
- package/dist/range/RangeField.d.ts +22 -0
- package/dist/range/RangeField.d.ts.map +1 -0
- package/dist/range/RangeField.js +203 -0
- package/dist/range/RangeField.js.map +1 -0
- package/dist/range/index.d.ts +2 -0
- package/dist/range/index.d.ts.map +1 -0
- package/dist/range/index.js +1 -0
- package/dist/relation/RelationField.css +7 -7
- package/dist/relation/RelationField.d.ts +12 -4
- package/dist/relation/RelationField.d.ts.map +1 -1
- package/dist/relation/RelationField.js +535 -160
- package/dist/relation/RelationField.js.map +1 -1
- package/dist/relation/RelationField.module.js +6 -6
- package/dist/relation/index.d.ts +2 -2
- package/dist/relation/index.d.ts.map +1 -1
- package/dist/relation/index.js +2 -2
- package/dist/repeater/RepeaterField.css +12 -11
- package/dist/repeater/RepeaterField.d.ts +1 -1
- package/dist/repeater/RepeaterField.js +118 -34
- package/dist/repeater/RepeaterField.js.map +1 -1
- package/dist/repeater/RepeaterField.module.js +9 -9
- package/dist/repeater/RepeaterField.module.js.map +1 -1
- package/dist/repeater/index.d.ts +1 -1
- package/dist/select/SelectField.css +1 -1
- package/dist/select/SelectField.d.ts +1 -1
- package/dist/select/SelectField.js.map +1 -1
- package/dist/select/SelectField.module.js +1 -1
- package/dist/select/index.d.ts +1 -1
- package/dist/shared/DefinitionField.d.ts +5 -3
- package/dist/shared/DefinitionField.d.ts.map +1 -1
- package/dist/shared/DefinitionField.js +81 -73
- package/dist/shared/DefinitionField.js.map +1 -1
- package/dist/shared/builtIn.d.ts +5 -3
- package/dist/shared/builtIn.d.ts.map +1 -1
- package/dist/shared/builtIn.js +21 -3
- package/dist/shared/builtIn.js.map +1 -1
- package/dist/shared/check.d.ts +27 -0
- package/dist/shared/check.d.ts.map +1 -0
- package/dist/shared/check.js +18 -0
- package/dist/shared/check.js.map +1 -0
- package/dist/shared/context.d.ts +28 -5
- package/dist/shared/context.d.ts.map +1 -1
- package/dist/shared/context.js +35 -19
- package/dist/shared/context.js.map +1 -1
- package/dist/shared/cx.js.map +1 -1
- package/dist/shared/dates.js.map +1 -1
- package/dist/shared/embed.d.ts +19 -0
- package/dist/shared/embed.d.ts.map +1 -0
- package/dist/shared/embed.js +14 -0
- package/dist/shared/embed.js.map +1 -0
- package/dist/shared/entry.d.ts +11 -2
- package/dist/shared/entry.d.ts.map +1 -1
- package/dist/shared/entry.js +19 -3
- package/dist/shared/entry.js.map +1 -1
- package/dist/shared/relation.d.ts +41 -5
- package/dist/shared/relation.d.ts.map +1 -1
- package/dist/shared/relation.js +119 -12
- package/dist/shared/relation.js.map +1 -1
- package/dist/shared/types.d.ts +2 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/slug/SlugField.css +18 -0
- package/dist/slug/SlugField.d.ts +33 -5
- package/dist/slug/SlugField.d.ts.map +1 -1
- package/dist/slug/SlugField.js +346 -126
- package/dist/slug/SlugField.js.map +1 -1
- package/dist/slug/SlugField.module.js +14 -0
- package/dist/slug/SlugField.module.js.map +1 -0
- package/dist/slug/index.d.ts +1 -1
- package/dist/slug/index.d.ts.map +1 -1
- package/dist/slug/index.js +1 -1
- package/dist/tags/TagsField.d.ts +17 -0
- package/dist/tags/TagsField.d.ts.map +1 -0
- package/dist/tags/TagsField.js +120 -0
- package/dist/tags/TagsField.js.map +1 -0
- package/dist/tags/index.d.ts +2 -0
- package/dist/tags/index.d.ts.map +1 -0
- package/dist/tags/index.js +1 -0
- package/dist/tel/TelField.d.ts +11 -0
- package/dist/tel/TelField.d.ts.map +1 -0
- package/dist/tel/TelField.js +87 -0
- package/dist/tel/TelField.js.map +1 -0
- package/dist/tel/index.d.ts +2 -0
- package/dist/tel/index.d.ts.map +1 -0
- package/dist/tel/index.js +1 -0
- package/dist/text/TextField.d.ts +12 -4
- package/dist/text/TextField.d.ts.map +1 -1
- package/dist/text/TextField.js +104 -60
- package/dist/text/TextField.js.map +1 -1
- package/dist/text/index.d.ts +1 -1
- package/dist/textarea/TextAreaField.d.ts +1 -1
- package/dist/textarea/TextAreaField.js.map +1 -1
- package/dist/textarea/index.d.ts +1 -1
- package/dist/time/TimeField.d.ts +1 -1
- package/dist/time/TimeField.js +64 -10
- package/dist/time/TimeField.js.map +1 -1
- package/dist/time/index.d.ts +1 -1
- package/dist/upload/FilePicker.css +24 -0
- package/dist/upload/FilePicker.d.ts +14 -0
- package/dist/upload/FilePicker.d.ts.map +1 -0
- package/dist/upload/FilePicker.js +130 -0
- package/dist/upload/FilePicker.js.map +1 -0
- package/dist/upload/FilePicker.module.js +12 -0
- package/dist/upload/FilePicker.module.js.map +1 -0
- package/dist/upload/UploadList.css +93 -0
- package/dist/upload/UploadList.d.ts +18 -0
- package/dist/upload/UploadList.d.ts.map +1 -0
- package/dist/upload/UploadList.js +144 -0
- package/dist/upload/UploadList.js.map +1 -0
- package/dist/upload/UploadList.module.js +32 -0
- package/dist/upload/UploadList.module.js.map +1 -0
- package/dist/upload/files.d.ts +5 -0
- package/dist/upload/files.d.ts.map +1 -0
- package/dist/upload/files.js +26 -0
- package/dist/upload/files.js.map +1 -0
- package/dist/upload/types.d.ts +58 -0
- package/dist/upload/types.d.ts.map +1 -0
- package/dist/upload/useRejectionMessage.d.ts +4 -0
- package/dist/upload/useRejectionMessage.d.ts.map +1 -0
- package/dist/upload/useRejectionMessage.js +25 -0
- package/dist/upload/useRejectionMessage.js.map +1 -0
- package/dist/upload/useUploads.d.ts +30 -0
- package/dist/upload/useUploads.d.ts.map +1 -0
- package/dist/upload/useUploads.js +115 -0
- package/dist/upload/useUploads.js.map +1 -0
- package/dist/uppy/index.d.ts +3 -0
- package/dist/uppy/index.d.ts.map +1 -0
- package/dist/uppy/index.js +1 -0
- package/dist/uppy/uploader.d.ts +44 -0
- package/dist/uppy/uploader.d.ts.map +1 -0
- package/dist/uppy/uploader.js +139 -0
- package/dist/uppy/uploader.js.map +1 -0
- package/dist/url/UrlField.css +2 -2
- package/dist/url/UrlField.d.ts +2 -2
- package/dist/url/UrlField.js +69 -14
- package/dist/url/UrlField.js.map +1 -1
- package/dist/url/UrlField.module.js +1 -1
- package/dist/url/index.d.ts +1 -1
- package/package.json +69 -7
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
import { useFieldsContext } from "../shared/context.js";
|
|
2
|
+
import { getFieldProps, getSetting, isNumber, isString } from "../shared/entry.js";
|
|
3
|
+
import { messages } from "../shared/messages.js";
|
|
4
|
+
import LocationField_module_default from "./LocationField.module.js";
|
|
5
|
+
import { LocationMap } from "./LocationMap.js";
|
|
6
|
+
import { c } from "react/compiler-runtime";
|
|
7
|
+
import { ComboBox, Fieldset, IconButton, NumberInput, TextInput, usePanneauIntl } from "@panneau/ui";
|
|
8
|
+
import { useEffect, useRef, useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { X } from "lucide-react";
|
|
11
|
+
//#region src/location/LocationField.tsx
|
|
12
|
+
/** OpenStreetMap's standard tiles: fine for an admin panel, with their credit. */
|
|
13
|
+
var OPEN_STREET_MAP_TILES = {
|
|
14
|
+
url: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
15
|
+
attribution: "© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors",
|
|
16
|
+
maxZoom: 19
|
|
17
|
+
};
|
|
18
|
+
var SEARCH_DELAY = 400;
|
|
19
|
+
var SEARCH_MIN_LENGTH = 3;
|
|
20
|
+
var DEFAULT_CENTER = {
|
|
21
|
+
lat: 20,
|
|
22
|
+
lng: 0
|
|
23
|
+
};
|
|
24
|
+
/** Whether a value is a point. */
|
|
25
|
+
function isLocation(value) {
|
|
26
|
+
return value !== null && typeof value === "object" && isNumber(value.lat) && isNumber(value.lng);
|
|
27
|
+
}
|
|
28
|
+
/** The search of addresses: results of the text typed, after a pause. */
|
|
29
|
+
function useAddressSearch(geocoding, query, locale) {
|
|
30
|
+
const $ = c(9);
|
|
31
|
+
let t0;
|
|
32
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
33
|
+
t0 = {
|
|
34
|
+
query: "",
|
|
35
|
+
results: [],
|
|
36
|
+
loading: false
|
|
37
|
+
};
|
|
38
|
+
$[0] = t0;
|
|
39
|
+
} else t0 = $[0];
|
|
40
|
+
const [state, setState] = useState(t0);
|
|
41
|
+
let t1;
|
|
42
|
+
let t2;
|
|
43
|
+
if ($[1] !== geocoding || $[2] !== locale || $[3] !== query) {
|
|
44
|
+
t1 = () => {
|
|
45
|
+
const text = query.trim();
|
|
46
|
+
if (geocoding === null || text.length < SEARCH_MIN_LENGTH) return;
|
|
47
|
+
const controller = new AbortController();
|
|
48
|
+
const timeout = window.setTimeout(() => {
|
|
49
|
+
setState(_temp);
|
|
50
|
+
geocoding.search(text, {
|
|
51
|
+
signal: controller.signal,
|
|
52
|
+
locale
|
|
53
|
+
}).then((results) => setState({
|
|
54
|
+
query: text,
|
|
55
|
+
results,
|
|
56
|
+
loading: false
|
|
57
|
+
})).catch(() => {
|
|
58
|
+
if (!controller.signal.aborted) setState({
|
|
59
|
+
query: text,
|
|
60
|
+
results: [],
|
|
61
|
+
loading: false
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}, SEARCH_DELAY);
|
|
65
|
+
return () => {
|
|
66
|
+
window.clearTimeout(timeout);
|
|
67
|
+
controller.abort();
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
t2 = [
|
|
71
|
+
geocoding,
|
|
72
|
+
query,
|
|
73
|
+
locale
|
|
74
|
+
];
|
|
75
|
+
$[1] = geocoding;
|
|
76
|
+
$[2] = locale;
|
|
77
|
+
$[3] = query;
|
|
78
|
+
$[4] = t1;
|
|
79
|
+
$[5] = t2;
|
|
80
|
+
} else {
|
|
81
|
+
t1 = $[4];
|
|
82
|
+
t2 = $[5];
|
|
83
|
+
}
|
|
84
|
+
useEffect(t1, t2);
|
|
85
|
+
let t3;
|
|
86
|
+
if ($[6] !== query || $[7] !== state) {
|
|
87
|
+
t3 = query.trim().length >= SEARCH_MIN_LENGTH ? state : {
|
|
88
|
+
...state,
|
|
89
|
+
results: []
|
|
90
|
+
};
|
|
91
|
+
$[6] = query;
|
|
92
|
+
$[7] = state;
|
|
93
|
+
$[8] = t3;
|
|
94
|
+
} else t3 = $[8];
|
|
95
|
+
return t3;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A point on a map, and its address. Clicking the map or dragging the marker places the point,
|
|
99
|
+
* and its latitude and longitude can be typed. With an address search, a place found sets the
|
|
100
|
+
* point and the address; with a reverse search, placing a point fills an empty address.
|
|
101
|
+
*/
|
|
102
|
+
function _temp(current) {
|
|
103
|
+
return {
|
|
104
|
+
...current,
|
|
105
|
+
loading: true
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function LocationField(t0) {
|
|
109
|
+
const $ = c(100);
|
|
110
|
+
const { value, onChange, onBlur, geocoding: geocodingProp, tiles: tilesProp, center: t1, zoom: t2, label, description, errors, disabled, readOnly, required, className } = t0;
|
|
111
|
+
const center = t1 === void 0 ? DEFAULT_CENTER : t1;
|
|
112
|
+
const zoom = t2 === void 0 ? 15 : t2;
|
|
113
|
+
const intl = usePanneauIntl();
|
|
114
|
+
const { maps } = useFieldsContext();
|
|
115
|
+
const geocoding = geocodingProp === void 0 ? maps?.geocoding ?? null : geocodingProp;
|
|
116
|
+
const tiles = tilesProp ?? maps?.tiles ?? OPEN_STREET_MAP_TILES;
|
|
117
|
+
const editable = disabled !== true && readOnly !== true;
|
|
118
|
+
const [query, setQuery] = useState("");
|
|
119
|
+
const [chosen, setChosen] = useState(null);
|
|
120
|
+
const search = useAddressSearch(editable && query !== chosen?.label ? geocoding : null, query, intl.locale);
|
|
121
|
+
let t3;
|
|
122
|
+
if ($[0] !== chosen || $[1] !== query || $[2] !== search) {
|
|
123
|
+
t3 = chosen !== null && query === chosen.label ? [chosen] : search.results;
|
|
124
|
+
$[0] = chosen;
|
|
125
|
+
$[1] = query;
|
|
126
|
+
$[2] = search;
|
|
127
|
+
$[3] = t3;
|
|
128
|
+
} else t3 = $[3];
|
|
129
|
+
const places = t3;
|
|
130
|
+
const addressRef = useRef(null);
|
|
131
|
+
let t4;
|
|
132
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
133
|
+
t4 = () => window.requestAnimationFrame(() => addressRef.current?.querySelector("input")?.focus());
|
|
134
|
+
$[4] = t4;
|
|
135
|
+
} else t4 = $[4];
|
|
136
|
+
const focusAddress = t4;
|
|
137
|
+
const t5 = value?.lat ?? null;
|
|
138
|
+
const t6 = value?.lng ?? null;
|
|
139
|
+
let t7;
|
|
140
|
+
if ($[5] !== t5 || $[6] !== t6 || $[7] !== value) {
|
|
141
|
+
t7 = {
|
|
142
|
+
source: value,
|
|
143
|
+
lat: t5,
|
|
144
|
+
lng: t6
|
|
145
|
+
};
|
|
146
|
+
$[5] = t5;
|
|
147
|
+
$[6] = t6;
|
|
148
|
+
$[7] = value;
|
|
149
|
+
$[8] = t7;
|
|
150
|
+
} else t7 = $[8];
|
|
151
|
+
const [draft, setDraft] = useState(t7);
|
|
152
|
+
if (draft.source !== value) setDraft({
|
|
153
|
+
source: value,
|
|
154
|
+
lat: value?.lat ?? null,
|
|
155
|
+
lng: value?.lng ?? null
|
|
156
|
+
});
|
|
157
|
+
let t8;
|
|
158
|
+
if ($[9] !== geocoding || $[10] !== intl.locale || $[11] !== onChange || $[12] !== value?.address) {
|
|
159
|
+
t8 = (point, newAddress) => {
|
|
160
|
+
const address = newAddress ?? value?.address;
|
|
161
|
+
const next = {
|
|
162
|
+
lat: Number(point.lat.toFixed(6)),
|
|
163
|
+
lng: Number(point.lng.toFixed(6)),
|
|
164
|
+
...address !== void 0 && address !== "" ? { address } : {}
|
|
165
|
+
};
|
|
166
|
+
onChange?.(next);
|
|
167
|
+
if ((address === void 0 || address === "") && geocoding?.reverse !== void 0) {
|
|
168
|
+
const controller = new AbortController();
|
|
169
|
+
geocoding.reverse(point, {
|
|
170
|
+
signal: controller.signal,
|
|
171
|
+
locale: intl.locale
|
|
172
|
+
}).then((place) => {
|
|
173
|
+
if (place !== null) onChange?.({
|
|
174
|
+
...next,
|
|
175
|
+
address: place.label
|
|
176
|
+
});
|
|
177
|
+
}).catch(_temp2);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
$[9] = geocoding;
|
|
181
|
+
$[10] = intl.locale;
|
|
182
|
+
$[11] = onChange;
|
|
183
|
+
$[12] = value?.address;
|
|
184
|
+
$[13] = t8;
|
|
185
|
+
} else t8 = $[13];
|
|
186
|
+
const setPoint = t8;
|
|
187
|
+
let t9;
|
|
188
|
+
if ($[14] !== draft || $[15] !== onChange || $[16] !== setPoint) {
|
|
189
|
+
t9 = (key, number) => {
|
|
190
|
+
const next_0 = {
|
|
191
|
+
...draft,
|
|
192
|
+
[key]: number
|
|
193
|
+
};
|
|
194
|
+
setDraft(next_0);
|
|
195
|
+
if (next_0.lat !== null && next_0.lng !== null) setPoint({
|
|
196
|
+
lat: next_0.lat,
|
|
197
|
+
lng: next_0.lng
|
|
198
|
+
});
|
|
199
|
+
else if (next_0.lat === null && next_0.lng === null) onChange?.(null);
|
|
200
|
+
};
|
|
201
|
+
$[14] = draft;
|
|
202
|
+
$[15] = onChange;
|
|
203
|
+
$[16] = setPoint;
|
|
204
|
+
$[17] = t9;
|
|
205
|
+
} else t9 = $[17];
|
|
206
|
+
const setCoordinate = t9;
|
|
207
|
+
let t10;
|
|
208
|
+
if ($[18] !== value) {
|
|
209
|
+
t10 = isLocation(value) ? {
|
|
210
|
+
lat: value.lat,
|
|
211
|
+
lng: value.lng
|
|
212
|
+
} : null;
|
|
213
|
+
$[18] = value;
|
|
214
|
+
$[19] = t10;
|
|
215
|
+
} else t10 = $[19];
|
|
216
|
+
const point_0 = t10;
|
|
217
|
+
let t11;
|
|
218
|
+
if ($[20] !== chosen || $[21] !== editable || $[22] !== geocoding || $[23] !== intl || $[24] !== places || $[25] !== query || $[26] !== search || $[27] !== setPoint) {
|
|
219
|
+
t11 = editable && geocoding !== null ? /* @__PURE__ */ jsx(ComboBox, {
|
|
220
|
+
"aria-label": intl.formatMessage(messages.searchAddress),
|
|
221
|
+
placeholder: intl.formatMessage(messages.searchAddress),
|
|
222
|
+
onInputChange: setQuery,
|
|
223
|
+
items: places.map(_temp3),
|
|
224
|
+
isLoading: search.loading,
|
|
225
|
+
menuTrigger: "input",
|
|
226
|
+
emptyMessage: query.trim().length < SEARCH_MIN_LENGTH ? intl.formatMessage(messages.searchAddressHint, { count: SEARCH_MIN_LENGTH }) : intl.formatMessage(messages.noPlaces),
|
|
227
|
+
value: chosen !== null && query === chosen.label ? "0" : null,
|
|
228
|
+
onChange: (id) => {
|
|
229
|
+
const result_0 = id !== null ? places[Number(id)] : void 0;
|
|
230
|
+
if (result_0 !== void 0) {
|
|
231
|
+
setChosen(result_0);
|
|
232
|
+
setPoint(result_0, result_0.label);
|
|
233
|
+
focusAddress();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}) : null;
|
|
237
|
+
$[20] = chosen;
|
|
238
|
+
$[21] = editable;
|
|
239
|
+
$[22] = geocoding;
|
|
240
|
+
$[23] = intl;
|
|
241
|
+
$[24] = places;
|
|
242
|
+
$[25] = query;
|
|
243
|
+
$[26] = search;
|
|
244
|
+
$[27] = setPoint;
|
|
245
|
+
$[28] = t11;
|
|
246
|
+
} else t11 = $[28];
|
|
247
|
+
let t12;
|
|
248
|
+
if ($[29] !== setPoint) {
|
|
249
|
+
t12 = (next_1) => setPoint(next_1);
|
|
250
|
+
$[29] = setPoint;
|
|
251
|
+
$[30] = t12;
|
|
252
|
+
} else t12 = $[30];
|
|
253
|
+
const t13 = !editable;
|
|
254
|
+
let t14;
|
|
255
|
+
if ($[31] !== intl || $[32] !== label) {
|
|
256
|
+
t14 = intl.formatMessage(messages.map, { label: typeof label === "string" ? label : "" });
|
|
257
|
+
$[31] = intl;
|
|
258
|
+
$[32] = label;
|
|
259
|
+
$[33] = t14;
|
|
260
|
+
} else t14 = $[33];
|
|
261
|
+
let t15;
|
|
262
|
+
if ($[34] !== center || $[35] !== point_0 || $[36] !== t12 || $[37] !== t13 || $[38] !== t14 || $[39] !== tiles || $[40] !== zoom) {
|
|
263
|
+
t15 = /* @__PURE__ */ jsx(LocationMap, {
|
|
264
|
+
point: point_0,
|
|
265
|
+
onChange: t12,
|
|
266
|
+
tiles,
|
|
267
|
+
center,
|
|
268
|
+
zoom,
|
|
269
|
+
readOnly: t13,
|
|
270
|
+
label: t14
|
|
271
|
+
});
|
|
272
|
+
$[34] = center;
|
|
273
|
+
$[35] = point_0;
|
|
274
|
+
$[36] = t12;
|
|
275
|
+
$[37] = t13;
|
|
276
|
+
$[38] = t14;
|
|
277
|
+
$[39] = tiles;
|
|
278
|
+
$[40] = zoom;
|
|
279
|
+
$[41] = t15;
|
|
280
|
+
} else t15 = $[41];
|
|
281
|
+
let t16;
|
|
282
|
+
if ($[42] !== intl) {
|
|
283
|
+
t16 = intl.formatMessage(messages.latitude);
|
|
284
|
+
$[42] = intl;
|
|
285
|
+
$[43] = t16;
|
|
286
|
+
} else t16 = $[43];
|
|
287
|
+
let t17;
|
|
288
|
+
if ($[44] !== setCoordinate) {
|
|
289
|
+
t17 = (next_2) => setCoordinate("lat", next_2);
|
|
290
|
+
$[44] = setCoordinate;
|
|
291
|
+
$[45] = t17;
|
|
292
|
+
} else t17 = $[45];
|
|
293
|
+
let t18;
|
|
294
|
+
if ($[46] !== onBlur) {
|
|
295
|
+
t18 = () => onBlur?.();
|
|
296
|
+
$[46] = onBlur;
|
|
297
|
+
$[47] = t18;
|
|
298
|
+
} else t18 = $[47];
|
|
299
|
+
let t19;
|
|
300
|
+
if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
|
|
301
|
+
t19 = { maximumFractionDigits: 6 };
|
|
302
|
+
$[48] = t19;
|
|
303
|
+
} else t19 = $[48];
|
|
304
|
+
let t20;
|
|
305
|
+
if ($[49] !== disabled || $[50] !== draft.lat || $[51] !== readOnly || $[52] !== t16 || $[53] !== t17 || $[54] !== t18) {
|
|
306
|
+
t20 = /* @__PURE__ */ jsx(NumberInput, {
|
|
307
|
+
label: t16,
|
|
308
|
+
value: draft.lat,
|
|
309
|
+
onChange: t17,
|
|
310
|
+
onBlur: t18,
|
|
311
|
+
minValue: -90,
|
|
312
|
+
maxValue: 90,
|
|
313
|
+
step: 1e-6,
|
|
314
|
+
formatOptions: t19,
|
|
315
|
+
isDisabled: disabled,
|
|
316
|
+
isReadOnly: readOnly,
|
|
317
|
+
className: LocationField_module_default.coordinate
|
|
318
|
+
});
|
|
319
|
+
$[49] = disabled;
|
|
320
|
+
$[50] = draft.lat;
|
|
321
|
+
$[51] = readOnly;
|
|
322
|
+
$[52] = t16;
|
|
323
|
+
$[53] = t17;
|
|
324
|
+
$[54] = t18;
|
|
325
|
+
$[55] = t20;
|
|
326
|
+
} else t20 = $[55];
|
|
327
|
+
let t21;
|
|
328
|
+
if ($[56] !== intl) {
|
|
329
|
+
t21 = intl.formatMessage(messages.longitude);
|
|
330
|
+
$[56] = intl;
|
|
331
|
+
$[57] = t21;
|
|
332
|
+
} else t21 = $[57];
|
|
333
|
+
let t22;
|
|
334
|
+
if ($[58] !== setCoordinate) {
|
|
335
|
+
t22 = (next_3) => setCoordinate("lng", next_3);
|
|
336
|
+
$[58] = setCoordinate;
|
|
337
|
+
$[59] = t22;
|
|
338
|
+
} else t22 = $[59];
|
|
339
|
+
let t23;
|
|
340
|
+
if ($[60] !== onBlur) {
|
|
341
|
+
t23 = () => onBlur?.();
|
|
342
|
+
$[60] = onBlur;
|
|
343
|
+
$[61] = t23;
|
|
344
|
+
} else t23 = $[61];
|
|
345
|
+
let t24;
|
|
346
|
+
if ($[62] === Symbol.for("react.memo_cache_sentinel")) {
|
|
347
|
+
t24 = { maximumFractionDigits: 6 };
|
|
348
|
+
$[62] = t24;
|
|
349
|
+
} else t24 = $[62];
|
|
350
|
+
let t25;
|
|
351
|
+
if ($[63] !== disabled || $[64] !== draft.lng || $[65] !== readOnly || $[66] !== t21 || $[67] !== t22 || $[68] !== t23) {
|
|
352
|
+
t25 = /* @__PURE__ */ jsx(NumberInput, {
|
|
353
|
+
label: t21,
|
|
354
|
+
value: draft.lng,
|
|
355
|
+
onChange: t22,
|
|
356
|
+
onBlur: t23,
|
|
357
|
+
minValue: -180,
|
|
358
|
+
maxValue: 180,
|
|
359
|
+
step: 1e-6,
|
|
360
|
+
formatOptions: t24,
|
|
361
|
+
isDisabled: disabled,
|
|
362
|
+
isReadOnly: readOnly,
|
|
363
|
+
className: LocationField_module_default.coordinate
|
|
364
|
+
});
|
|
365
|
+
$[63] = disabled;
|
|
366
|
+
$[64] = draft.lng;
|
|
367
|
+
$[65] = readOnly;
|
|
368
|
+
$[66] = t21;
|
|
369
|
+
$[67] = t22;
|
|
370
|
+
$[68] = t23;
|
|
371
|
+
$[69] = t25;
|
|
372
|
+
} else t25 = $[69];
|
|
373
|
+
let t26;
|
|
374
|
+
if ($[70] !== editable || $[71] !== intl || $[72] !== onChange || $[73] !== point_0) {
|
|
375
|
+
t26 = editable && point_0 !== null ? /* @__PURE__ */ jsx(IconButton, {
|
|
376
|
+
icon: X,
|
|
377
|
+
label: intl.formatMessage(messages.removePoint),
|
|
378
|
+
className: LocationField_module_default.remove,
|
|
379
|
+
onPress: () => onChange?.(null)
|
|
380
|
+
}) : null;
|
|
381
|
+
$[70] = editable;
|
|
382
|
+
$[71] = intl;
|
|
383
|
+
$[72] = onChange;
|
|
384
|
+
$[73] = point_0;
|
|
385
|
+
$[74] = t26;
|
|
386
|
+
} else t26 = $[74];
|
|
387
|
+
let t27;
|
|
388
|
+
if ($[75] !== t20 || $[76] !== t25 || $[77] !== t26) {
|
|
389
|
+
t27 = /* @__PURE__ */ jsxs("div", {
|
|
390
|
+
className: LocationField_module_default.coordinates,
|
|
391
|
+
children: [
|
|
392
|
+
t20,
|
|
393
|
+
t25,
|
|
394
|
+
t26
|
|
395
|
+
]
|
|
396
|
+
});
|
|
397
|
+
$[75] = t20;
|
|
398
|
+
$[76] = t25;
|
|
399
|
+
$[77] = t26;
|
|
400
|
+
$[78] = t27;
|
|
401
|
+
} else t27 = $[78];
|
|
402
|
+
let t28;
|
|
403
|
+
if ($[79] !== disabled || $[80] !== intl || $[81] !== onBlur || $[82] !== onChange || $[83] !== point_0 || $[84] !== readOnly || $[85] !== value?.address) {
|
|
404
|
+
t28 = point_0 !== null ? /* @__PURE__ */ jsx("div", {
|
|
405
|
+
ref: addressRef,
|
|
406
|
+
children: /* @__PURE__ */ jsx(TextInput, {
|
|
407
|
+
label: intl.formatMessage(messages.address),
|
|
408
|
+
value: value?.address ?? "",
|
|
409
|
+
onChange: (address_0) => onChange?.({
|
|
410
|
+
lat: point_0.lat,
|
|
411
|
+
lng: point_0.lng,
|
|
412
|
+
...address_0 !== "" ? { address: address_0 } : {}
|
|
413
|
+
}),
|
|
414
|
+
onBlur: () => onBlur?.(),
|
|
415
|
+
isDisabled: disabled,
|
|
416
|
+
isReadOnly: readOnly
|
|
417
|
+
})
|
|
418
|
+
}) : null;
|
|
419
|
+
$[79] = disabled;
|
|
420
|
+
$[80] = intl;
|
|
421
|
+
$[81] = onBlur;
|
|
422
|
+
$[82] = onChange;
|
|
423
|
+
$[83] = point_0;
|
|
424
|
+
$[84] = readOnly;
|
|
425
|
+
$[85] = value?.address;
|
|
426
|
+
$[86] = t28;
|
|
427
|
+
} else t28 = $[86];
|
|
428
|
+
let t29;
|
|
429
|
+
if ($[87] !== t11 || $[88] !== t15 || $[89] !== t27 || $[90] !== t28) {
|
|
430
|
+
t29 = /* @__PURE__ */ jsxs("div", {
|
|
431
|
+
className: LocationField_module_default.location,
|
|
432
|
+
children: [
|
|
433
|
+
t11,
|
|
434
|
+
t15,
|
|
435
|
+
t27,
|
|
436
|
+
t28
|
|
437
|
+
]
|
|
438
|
+
});
|
|
439
|
+
$[87] = t11;
|
|
440
|
+
$[88] = t15;
|
|
441
|
+
$[89] = t27;
|
|
442
|
+
$[90] = t28;
|
|
443
|
+
$[91] = t29;
|
|
444
|
+
} else t29 = $[91];
|
|
445
|
+
let t30;
|
|
446
|
+
if ($[92] !== className || $[93] !== description || $[94] !== disabled || $[95] !== errors || $[96] !== label || $[97] !== required || $[98] !== t29) {
|
|
447
|
+
t30 = /* @__PURE__ */ jsx(Fieldset, {
|
|
448
|
+
legend: label,
|
|
449
|
+
description,
|
|
450
|
+
errors,
|
|
451
|
+
isRequired: required,
|
|
452
|
+
isDisabled: disabled,
|
|
453
|
+
className,
|
|
454
|
+
children: t29
|
|
455
|
+
});
|
|
456
|
+
$[92] = className;
|
|
457
|
+
$[93] = description;
|
|
458
|
+
$[94] = disabled;
|
|
459
|
+
$[95] = errors;
|
|
460
|
+
$[96] = label;
|
|
461
|
+
$[97] = required;
|
|
462
|
+
$[98] = t29;
|
|
463
|
+
$[99] = t30;
|
|
464
|
+
} else t30 = $[99];
|
|
465
|
+
return t30;
|
|
466
|
+
}
|
|
467
|
+
function _temp3(result, index) {
|
|
468
|
+
return {
|
|
469
|
+
id: String(index),
|
|
470
|
+
label: result.label
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function _temp2() {}
|
|
474
|
+
function isPoint(value) {
|
|
475
|
+
return isLocation(value);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* The `location` type: settings `zoom`, `center` (`{ "lat", "lng" }`, where the map opens without
|
|
479
|
+
* a point) and `tiles` (`{ "url", "attribution" }`), over the maps of the `FieldsProvider`.
|
|
480
|
+
*/
|
|
481
|
+
function LocationFieldEntry(props) {
|
|
482
|
+
const $ = c(23);
|
|
483
|
+
const { field } = props;
|
|
484
|
+
let t0;
|
|
485
|
+
if ($[0] !== field) {
|
|
486
|
+
t0 = getSetting(field, "zoom", isNumber);
|
|
487
|
+
$[0] = field;
|
|
488
|
+
$[1] = t0;
|
|
489
|
+
} else t0 = $[1];
|
|
490
|
+
const zoom = t0;
|
|
491
|
+
let t1;
|
|
492
|
+
if ($[2] !== field) {
|
|
493
|
+
t1 = getSetting(field, "center", isPoint);
|
|
494
|
+
$[2] = field;
|
|
495
|
+
$[3] = t1;
|
|
496
|
+
} else t1 = $[3];
|
|
497
|
+
const center = t1;
|
|
498
|
+
let t2;
|
|
499
|
+
if ($[4] !== field) {
|
|
500
|
+
t2 = getSetting(field, "tiles", _temp4);
|
|
501
|
+
$[4] = field;
|
|
502
|
+
$[5] = t2;
|
|
503
|
+
} else t2 = $[5];
|
|
504
|
+
const tiles = t2;
|
|
505
|
+
let t3;
|
|
506
|
+
if ($[6] !== props) {
|
|
507
|
+
t3 = getFieldProps(props);
|
|
508
|
+
$[6] = props;
|
|
509
|
+
$[7] = t3;
|
|
510
|
+
} else t3 = $[7];
|
|
511
|
+
let fieldProps;
|
|
512
|
+
if ($[8] !== t3) {
|
|
513
|
+
const { placeholder: _placeholder, ...t4 } = t3;
|
|
514
|
+
fieldProps = t4;
|
|
515
|
+
$[8] = t3;
|
|
516
|
+
$[9] = fieldProps;
|
|
517
|
+
} else fieldProps = $[9];
|
|
518
|
+
const t4 = isLocation(props.value) ? props.value : null;
|
|
519
|
+
let t5;
|
|
520
|
+
if ($[10] !== zoom) {
|
|
521
|
+
t5 = zoom !== void 0 ? { zoom } : {};
|
|
522
|
+
$[10] = zoom;
|
|
523
|
+
$[11] = t5;
|
|
524
|
+
} else t5 = $[11];
|
|
525
|
+
let t6;
|
|
526
|
+
if ($[12] !== center) {
|
|
527
|
+
t6 = center !== void 0 ? { center } : {};
|
|
528
|
+
$[12] = center;
|
|
529
|
+
$[13] = t6;
|
|
530
|
+
} else t6 = $[13];
|
|
531
|
+
let t7;
|
|
532
|
+
if ($[14] !== tiles) {
|
|
533
|
+
t7 = tiles !== void 0 ? { tiles } : {};
|
|
534
|
+
$[14] = tiles;
|
|
535
|
+
$[15] = t7;
|
|
536
|
+
} else t7 = $[15];
|
|
537
|
+
let t8;
|
|
538
|
+
if ($[16] !== fieldProps || $[17] !== props.onChange || $[18] !== t4 || $[19] !== t5 || $[20] !== t6 || $[21] !== t7) {
|
|
539
|
+
t8 = /* @__PURE__ */ jsx(LocationField, {
|
|
540
|
+
...fieldProps,
|
|
541
|
+
value: t4,
|
|
542
|
+
onChange: props.onChange,
|
|
543
|
+
...t5,
|
|
544
|
+
...t6,
|
|
545
|
+
...t7
|
|
546
|
+
});
|
|
547
|
+
$[16] = fieldProps;
|
|
548
|
+
$[17] = props.onChange;
|
|
549
|
+
$[18] = t4;
|
|
550
|
+
$[19] = t5;
|
|
551
|
+
$[20] = t6;
|
|
552
|
+
$[21] = t7;
|
|
553
|
+
$[22] = t8;
|
|
554
|
+
} else t8 = $[22];
|
|
555
|
+
return t8;
|
|
556
|
+
}
|
|
557
|
+
function _temp4(value) {
|
|
558
|
+
return value !== null && typeof value === "object" && isString(value.url) && isString(value.attribution);
|
|
559
|
+
}
|
|
560
|
+
//#endregion
|
|
561
|
+
export { LocationField, LocationFieldEntry, OPEN_STREET_MAP_TILES, isLocation };
|
|
562
|
+
|
|
563
|
+
//# sourceMappingURL=LocationField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationField.js","names":["X","useEffect","useRef","useState","LocationValue","ComboBox","Fieldset","IconButton","NumberInput","TextInput","usePanneauIntl","useFieldsContext","getFieldProps","getSetting","isNumber","isString","messages","FieldEntryProps","FieldProps","styles","LocationMap","Point","GeocodingResult","GeocodingSource","MapTiles","OPEN_STREET_MAP_TILES","url","attribution","maxZoom","SEARCH_DELAY","SEARCH_MIN_LENGTH","DEFAULT_CENTER","lat","lng","LocationFieldProps","geocoding","tiles","center","zoom","isLocation","value","Record","useAddressSearch","query","locale","$","_c","t0","Symbol","for","results","loading","state","setState","t1","t2","text","trim","length","controller","AbortController","timeout","window","setTimeout","_temp","search","signal","then","catch","aborted","clearTimeout","abort","t3","current","LocationField","onChange","onBlur","geocodingProp","tilesProp","label","description","errors","disabled","readOnly","required","className","undefined","intl","maps","editable","setQuery","chosen","setChosen","places","addressRef","t4","requestAnimationFrame","querySelector","focus","focusAddress","t5","t6","t7","source","draft","setDraft","t8","address","point","newAddress","next","Number","toFixed","reverse","place","_temp2","setPoint","t9","key","number","next_0","setCoordinate","t10","point_0","t11","formatMessage","searchAddress","map","_temp3","searchAddressHint","count","noPlaces","id","result_0","result","t12","next_1","t13","t14","t15","t16","latitude","t17","next_2","t18","t19","maximumFractionDigits","t20","coordinate","t21","longitude","t22","next_3","t23","t24","t25","t26","removePoint","remove","t27","coordinates","t28","address_0","t29","location","t30","index","String","isPoint","LocationFieldEntry","props","field","_temp4","fieldProps","placeholder","_placeholder","_c","styles"],"sources":["../../src/location/LocationField.tsx"],"sourcesContent":["import { X } from 'lucide-react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport type { LocationValue } from '@panneau/protocol';\nimport {\n ComboBox,\n Fieldset,\n IconButton,\n NumberInput,\n TextInput,\n usePanneauIntl,\n} from '@panneau/ui';\n\nimport { useFieldsContext } from '../shared/context';\nimport { getFieldProps, getSetting, isNumber, isString } from '../shared/entry';\nimport { messages } from '../shared/messages';\nimport type { FieldEntryProps, FieldProps } from '../shared/types';\nimport styles from './LocationField.module.css';\nimport { LocationMap, type Point } from './LocationMap';\nimport type { GeocodingResult, GeocodingSource, MapTiles } from './types';\n\nexport type { LocationValue };\n\n/** OpenStreetMap's standard tiles: fine for an admin panel, with their credit. */\nexport const OPEN_STREET_MAP_TILES: MapTiles = {\n url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',\n attribution:\n '© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors',\n maxZoom: 19,\n};\n\nconst SEARCH_DELAY = 400;\nconst SEARCH_MIN_LENGTH = 3;\nconst DEFAULT_CENTER: Point = { lat: 20, lng: 0 };\n\nexport interface LocationFieldProps extends FieldProps<LocationValue> {\n /** The address search. Defaults to that of the `FieldsProvider`; without one, there is none. */\n geocoding?: GeocodingSource | null;\n /** The tiles of the map. Defaults to those of the `FieldsProvider`, or OpenStreetMap's. */\n tiles?: MapTiles;\n /** Where the map opens without a point. Defaults to the whole world. */\n center?: Point;\n /** Zoom of the map on a point. Defaults to 15. */\n zoom?: number;\n}\n\n/** Whether a value is a point. */\nexport function isLocation(value: unknown): value is LocationValue {\n return (\n value !== null &&\n typeof value === 'object' &&\n isNumber((value as Record<string, unknown>).lat) &&\n isNumber((value as Record<string, unknown>).lng)\n );\n}\n\n/** The search of addresses: results of the text typed, after a pause. */\nfunction useAddressSearch(geocoding: GeocodingSource | null, query: string, locale: string) {\n const [state, setState] = useState<{\n query: string;\n results: GeocodingResult[];\n loading: boolean;\n }>({ query: '', results: [], loading: false });\n useEffect(() => {\n const text = query.trim();\n if (geocoding === null || text.length < SEARCH_MIN_LENGTH) {\n return undefined;\n }\n const controller = new AbortController();\n const timeout = window.setTimeout(() => {\n setState((current) => ({ ...current, loading: true }));\n geocoding\n .search(text, { signal: controller.signal, locale })\n .then((results) => setState({ query: text, results, loading: false }))\n .catch(() => {\n if (!controller.signal.aborted) {\n setState({ query: text, results: [], loading: false });\n }\n });\n }, SEARCH_DELAY);\n return () => {\n window.clearTimeout(timeout);\n controller.abort();\n };\n }, [geocoding, query, locale]);\n return query.trim().length >= SEARCH_MIN_LENGTH ? state : { ...state, results: [] };\n}\n\n/**\n * A point on a map, and its address. Clicking the map or dragging the marker places the point,\n * and its latitude and longitude can be typed. With an address search, a place found sets the\n * point and the address; with a reverse search, placing a point fills an empty address.\n */\nexport function LocationField({\n value,\n onChange,\n onBlur,\n geocoding: geocodingProp,\n tiles: tilesProp,\n center = DEFAULT_CENTER,\n zoom = 15,\n label,\n description,\n errors,\n disabled,\n readOnly,\n required,\n className,\n}: LocationFieldProps) {\n const intl = usePanneauIntl();\n const { maps } = useFieldsContext();\n const geocoding = geocodingProp === undefined ? (maps?.geocoding ?? null) : geocodingProp;\n const tiles = tilesProp ?? maps?.tiles ?? OPEN_STREET_MAP_TILES;\n const editable = disabled !== true && readOnly !== true;\n const [query, setQuery] = useState('');\n // The place chosen: the search shows its label until something else is typed\n const [chosen, setChosen] = useState<GeocodingResult | null>(null);\n const search = useAddressSearch(\n editable && query !== chosen?.label ? geocoding : null,\n query,\n intl.locale,\n );\n const places = chosen !== null && query === chosen.label ? [chosen] : search.results;\n // A place chosen moves focus to its address, which closes the results\n const addressRef = useRef<HTMLDivElement>(null);\n const focusAddress = () =>\n window.requestAnimationFrame(() =>\n addressRef.current?.querySelector<HTMLInputElement>('input')?.focus(),\n );\n\n // The coordinates as typed: a value needs both\n const [draft, setDraft] = useState<{ source: unknown; lat: number | null; lng: number | null }>(\n { source: value, lat: value?.lat ?? null, lng: value?.lng ?? null },\n );\n if (draft.source !== value) {\n setDraft({ source: value, lat: value?.lat ?? null, lng: value?.lng ?? null });\n }\n\n const setPoint = (point: Point, newAddress?: string) => {\n const address = newAddress ?? value?.address;\n const next: LocationValue = {\n lat: Number(point.lat.toFixed(6)),\n lng: Number(point.lng.toFixed(6)),\n ...(address !== undefined && address !== '' ? { address } : {}),\n };\n onChange?.(next);\n // Fills an empty address from the point\n if ((address === undefined || address === '') && geocoding?.reverse !== undefined) {\n const controller = new AbortController();\n void geocoding\n .reverse(point, { signal: controller.signal, locale: intl.locale })\n .then((place) => {\n if (place !== null) {\n onChange?.({ ...next, address: place.label });\n }\n })\n .catch(() => undefined);\n }\n };\n\n const setCoordinate = (key: 'lat' | 'lng', number: number | null) => {\n const next = { ...draft, [key]: number };\n setDraft(next);\n if (next.lat !== null && next.lng !== null) {\n setPoint({ lat: next.lat, lng: next.lng });\n } else if (next.lat === null && next.lng === null) {\n onChange?.(null);\n }\n };\n\n const point = isLocation(value) ? { lat: value.lat, lng: value.lng } : null;\n return (\n <Fieldset\n legend={label}\n description={description}\n errors={errors}\n isRequired={required}\n isDisabled={disabled}\n className={className}\n >\n <div className={styles.location}>\n {editable && geocoding !== null ? (\n <ComboBox\n aria-label={intl.formatMessage(messages.searchAddress)}\n placeholder={intl.formatMessage(messages.searchAddress)}\n onInputChange={setQuery}\n items={places.map((result, index) => ({\n id: String(index),\n label: result.label,\n }))}\n isLoading={search.loading}\n menuTrigger=\"input\"\n emptyMessage={\n query.trim().length < SEARCH_MIN_LENGTH\n ? intl.formatMessage(messages.searchAddressHint, {\n count: SEARCH_MIN_LENGTH,\n })\n : intl.formatMessage(messages.noPlaces)\n }\n value={chosen !== null && query === chosen.label ? '0' : null}\n onChange={(id) => {\n const result = id !== null ? places[Number(id)] : undefined;\n if (result !== undefined) {\n setChosen(result);\n setPoint(result, result.label);\n focusAddress();\n }\n }}\n />\n ) : null}\n <LocationMap\n point={point}\n onChange={(next) => setPoint(next)}\n tiles={tiles}\n center={center}\n zoom={zoom}\n readOnly={!editable}\n label={intl.formatMessage(messages.map, {\n label: typeof label === 'string' ? label : '',\n })}\n />\n <div className={styles.coordinates}>\n <NumberInput\n label={intl.formatMessage(messages.latitude)}\n value={draft.lat}\n onChange={(next) => setCoordinate('lat', next)}\n onBlur={() => onBlur?.()}\n minValue={-90}\n maxValue={90}\n step={0.000001}\n formatOptions={{ maximumFractionDigits: 6 }}\n isDisabled={disabled}\n isReadOnly={readOnly}\n className={styles.coordinate}\n />\n <NumberInput\n label={intl.formatMessage(messages.longitude)}\n value={draft.lng}\n onChange={(next) => setCoordinate('lng', next)}\n onBlur={() => onBlur?.()}\n minValue={-180}\n maxValue={180}\n step={0.000001}\n formatOptions={{ maximumFractionDigits: 6 }}\n isDisabled={disabled}\n isReadOnly={readOnly}\n className={styles.coordinate}\n />\n {editable && point !== null ? (\n <IconButton\n icon={X}\n label={intl.formatMessage(messages.removePoint)}\n className={styles.remove}\n onPress={() => onChange?.(null)}\n />\n ) : null}\n </div>\n {point !== null ? (\n <div ref={addressRef}>\n <TextInput\n label={intl.formatMessage(messages.address)}\n value={value?.address ?? ''}\n onChange={(address) =>\n onChange?.({\n lat: point.lat,\n lng: point.lng,\n ...(address !== '' ? { address } : {}),\n })\n }\n onBlur={() => onBlur?.()}\n isDisabled={disabled}\n isReadOnly={readOnly}\n />\n </div>\n ) : null}\n </div>\n </Fieldset>\n );\n}\n\nfunction isPoint(value: unknown): value is Point {\n return isLocation(value);\n}\n\n/**\n * The `location` type: settings `zoom`, `center` (`{ \"lat\", \"lng\" }`, where the map opens without\n * a point) and `tiles` (`{ \"url\", \"attribution\" }`), over the maps of the `FieldsProvider`.\n */\nexport function LocationFieldEntry(props: FieldEntryProps) {\n const { field } = props;\n const zoom = getSetting(field, 'zoom', isNumber);\n const center = getSetting(field, 'center', isPoint);\n const tiles = getSetting(\n field,\n 'tiles',\n (value): value is MapTiles =>\n value !== null &&\n typeof value === 'object' &&\n isString((value as Record<string, unknown>).url) &&\n isString((value as Record<string, unknown>).attribution),\n );\n const { placeholder: _placeholder, ...fieldProps } = getFieldProps(props);\n return (\n <LocationField\n {...fieldProps}\n value={isLocation(props.value) ? props.value : null}\n onChange={props.onChange}\n {...(zoom !== undefined ? { zoom } : {})}\n {...(center !== undefined ? { center } : {})}\n {...(tiles !== undefined ? { tiles } : {})}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;AAwBA,IAAayB,wBAAkC;CAC3CC,KAAK;CACLC,aACI;CACJC,SAAS;AACb;AAEA,IAAMC,eAAe;AACrB,IAAMC,oBAAoB;A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Cd,GAAK,KAC/CX,SAAUyB,MAAgCb,WAAa;AAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "./LocationField.css";
|
|
2
|
+
//#region src/location/LocationField.module.css
|
|
3
|
+
var location = "panneau-location-field-location";
|
|
4
|
+
var map = "panneau-location-field-map";
|
|
5
|
+
var marker = "panneau-location-field-marker";
|
|
6
|
+
var pin = "panneau-location-field-pin";
|
|
7
|
+
var coordinates = "panneau-location-field-coordinates";
|
|
8
|
+
var coordinate = "panneau-location-field-coordinate";
|
|
9
|
+
var remove = "panneau-location-field-remove";
|
|
10
|
+
var LocationField_module_default = {
|
|
11
|
+
location,
|
|
12
|
+
map,
|
|
13
|
+
marker,
|
|
14
|
+
pin,
|
|
15
|
+
coordinates,
|
|
16
|
+
coordinate,
|
|
17
|
+
remove
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { coordinate, coordinates, LocationField_module_default as default, location, map, marker, pin, remove };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=LocationField.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationField.module.js","names":[],"sources":["../../src/location/LocationField.module.css"],"sourcesContent":["/* The search, the map, then the coordinates and the address. */\n.location {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-2);\n}\n\n.map {\n position: relative;\n z-index: 0;\n height: 16rem;\n overflow: hidden;\n background-color: var(--panneau-color-surface-sunken);\n border: var(--panneau-border-width) solid var(--panneau-color-border-control);\n border-radius: var(--panneau-radius-md);\n}\n\n.map:focus-visible {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: 1px;\n}\n\n/* A pin: a round head pointing down at the point. */\n.marker {\n background: none;\n border: 0;\n}\n\n.pin {\n display: block;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n background-color: var(--panneau-color-accent);\n border: 2px solid var(--panneau-color-surface);\n border-radius: 50% 50% 50% 0;\n box-shadow: var(--panneau-shadow-sm);\n rotate: -45deg;\n}\n\n.coordinates {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-end;\n gap: var(--panneau-space-2);\n}\n\n.coordinate {\n flex: 1 1 8rem;\n}\n\n.remove {\n flex: none;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { MapTiles } from './types.js';
|
|
2
|
+
export interface Point {
|
|
3
|
+
lat: number;
|
|
4
|
+
lng: number;
|
|
5
|
+
}
|
|
6
|
+
export interface LocationMapProps {
|
|
7
|
+
point: Point | null;
|
|
8
|
+
/** Called with the point clicked, or where the marker was dropped. */
|
|
9
|
+
onChange?: (point: Point) => void;
|
|
10
|
+
tiles: MapTiles;
|
|
11
|
+
/** Where the map opens without a point. */
|
|
12
|
+
center: Point;
|
|
13
|
+
/** Zoom of the map on a point; the map opens wider without one. */
|
|
14
|
+
zoom: number;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
/** Accessible name of the map. */
|
|
17
|
+
label: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A Leaflet map with a marker on the point. Clicking the map or dragging the marker moves the
|
|
22
|
+
* point. Leaflet and its stylesheet load when the map first shows.
|
|
23
|
+
*/
|
|
24
|
+
export declare function LocationMap({ point, onChange, tiles, center, zoom, readOnly, label, className, }: LocationMapProps): import("react").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=LocationMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationMap.d.ts","sourceRoot":"","sources":["../../src/location/LocationMap.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAwBxC,MAAM,WAAW,KAAK;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC,KAAK,EAAE,QAAQ,CAAC;IAChB,2CAA2C;IAC3C,MAAM,EAAE,KAAK,CAAC;IACd,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,KAAK,EACL,MAAM,EACN,IAAI,EACJ,QAAgB,EAChB,KAAK,EACL,SAAS,GACZ,EAAE,gBAAgB,+BAuGlB"}
|