@memori.ai/memori-react 6.1.6 → 6.2.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/CHANGELOG.md +27 -0
- package/dist/components/ChatBubble/ChatBubble.css +7 -2
- package/dist/components/ChatBubble/ChatBubble.js +9 -7
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +58 -5
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/PositionDrawer/PositionDrawer.d.ts +8 -1
- package/dist/components/PositionDrawer/PositionDrawer.js +8 -1
- package/dist/components/PositionDrawer/PositionDrawer.js.map +1 -1
- package/dist/components/VenueWidget/VenueWidget.css +142 -0
- package/dist/components/VenueWidget/VenueWidget.d.ts +33 -0
- package/dist/components/VenueWidget/VenueWidget.js +195 -0
- package/dist/components/VenueWidget/VenueWidget.js.map +1 -0
- package/dist/components/ui/Select.d.ts +2 -1
- package/dist/components/ui/Select.js +2 -2
- package/dist/components/ui/Select.js.map +1 -1
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/helpers/utils.js +25 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/helpers/venue.d.ts +3 -0
- package/dist/helpers/venue.js +23 -0
- package/dist/helpers/venue.js.map +1 -0
- package/dist/locales/en.json +5 -0
- package/dist/locales/it.json +5 -0
- package/dist/styles.css +1 -0
- package/esm/components/ChatBubble/ChatBubble.css +7 -2
- package/esm/components/ChatBubble/ChatBubble.js +9 -7
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +58 -5
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/PositionDrawer/PositionDrawer.d.ts +8 -1
- package/esm/components/PositionDrawer/PositionDrawer.js +7 -1
- package/esm/components/PositionDrawer/PositionDrawer.js.map +1 -1
- package/esm/components/VenueWidget/VenueWidget.css +142 -0
- package/esm/components/VenueWidget/VenueWidget.d.ts +33 -0
- package/esm/components/VenueWidget/VenueWidget.js +192 -0
- package/esm/components/VenueWidget/VenueWidget.js.map +1 -0
- package/esm/components/ui/Select.d.ts +2 -1
- package/esm/components/ui/Select.js +2 -2
- package/esm/components/ui/Select.js.map +1 -1
- package/esm/helpers/utils.d.ts +1 -0
- package/esm/helpers/utils.js +24 -1
- package/esm/helpers/utils.js.map +1 -1
- package/esm/helpers/venue.d.ts +3 -0
- package/esm/helpers/venue.js +19 -0
- package/esm/helpers/venue.js.map +1 -0
- package/esm/locales/en.json +5 -0
- package/esm/locales/it.json +5 -0
- package/esm/styles.css +1 -0
- package/package.json +5 -2
- package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +0 -154
- package/src/components/ChatBubble/ChatBubble.css +7 -2
- package/src/components/ChatBubble/ChatBubble.tsx +3 -1
- package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +41 -100
- package/src/components/MemoriWidget/MemoriWidget.stories.tsx +9 -0
- package/src/components/MemoriWidget/MemoriWidget.tsx +86 -4
- package/src/components/PositionDrawer/PositionDrawer.stories.tsx +46 -0
- package/src/components/PositionDrawer/PositionDrawer.test.tsx +33 -0
- package/src/components/PositionDrawer/PositionDrawer.tsx +24 -5
- package/src/components/PositionDrawer/__snapshots__/PositionDrawer.test.tsx.snap +5 -0
- package/src/components/VenueWidget/VenueWidget.css +142 -0
- package/src/components/VenueWidget/VenueWidget.stories.tsx +66 -0
- package/src/components/VenueWidget/VenueWidget.test.tsx +49 -0
- package/src/components/VenueWidget/VenueWidget.tsx +430 -0
- package/src/components/VenueWidget/__snapshots__/VenueWidget.test.tsx.snap +335 -0
- package/src/components/ui/Select.tsx +3 -1
- package/src/components/ui/__snapshots__/Select.test.tsx.snap +0 -24
- package/src/helpers/utils.ts +36 -1
- package/src/helpers/venue.ts +36 -0
- package/src/locales/en.json +5 -0
- package/src/locales/it.json +5 -0
- package/src/mocks/data.ts +8 -0
- package/src/styles.css +1 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`renders VenueWidget with venue set, exact location 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<fieldset
|
|
6
|
+
class="memori--venue-widget"
|
|
7
|
+
>
|
|
8
|
+
<legend
|
|
9
|
+
class="sr-only"
|
|
10
|
+
>
|
|
11
|
+
Venue
|
|
12
|
+
</legend>
|
|
13
|
+
<div
|
|
14
|
+
class="memori--venue-widget__form-item"
|
|
15
|
+
>
|
|
16
|
+
<div
|
|
17
|
+
class="memori--venue-widget__geosuggest"
|
|
18
|
+
>
|
|
19
|
+
<div
|
|
20
|
+
class="memori--venue-widget-search"
|
|
21
|
+
>
|
|
22
|
+
<input
|
|
23
|
+
aria-expanded="false"
|
|
24
|
+
class="memori--venue-widget-search--input"
|
|
25
|
+
data-headlessui-state=""
|
|
26
|
+
id="headlessui-combobox-input-:r1:"
|
|
27
|
+
placeholder="searchVenue"
|
|
28
|
+
role="combobox"
|
|
29
|
+
type="text"
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
<button
|
|
33
|
+
class="memori-button memori-button--outlined memori-button--rounded memori-button--padded memori--venue-widget__gps-button"
|
|
34
|
+
>
|
|
35
|
+
write_and_speak.useMyPosition
|
|
36
|
+
</button>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<div
|
|
40
|
+
class="memori--venue-widget__form-item"
|
|
41
|
+
>
|
|
42
|
+
<p
|
|
43
|
+
class="memori--venue--widget__place-name"
|
|
44
|
+
>
|
|
45
|
+
<strong>
|
|
46
|
+
venue
|
|
47
|
+
</strong>
|
|
48
|
+
:
|
|
49
|
+
Altedo, Bologna, Italy
|
|
50
|
+
</p>
|
|
51
|
+
<div
|
|
52
|
+
class="memori--venue-widget__map"
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
data-testid="MapContainer"
|
|
56
|
+
>
|
|
57
|
+
<div
|
|
58
|
+
data-testid="TileLayer"
|
|
59
|
+
/>
|
|
60
|
+
<div
|
|
61
|
+
data-testid="Marker"
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
data-testid="Popup"
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</fieldset>
|
|
71
|
+
</div>
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
exports[`renders VenueWidget with venue set, with uncertainty radius 1`] = `
|
|
75
|
+
<div>
|
|
76
|
+
<fieldset
|
|
77
|
+
class="memori--venue-widget"
|
|
78
|
+
>
|
|
79
|
+
<legend
|
|
80
|
+
class="sr-only"
|
|
81
|
+
>
|
|
82
|
+
Venue
|
|
83
|
+
</legend>
|
|
84
|
+
<div
|
|
85
|
+
class="memori--venue-widget__form-item"
|
|
86
|
+
>
|
|
87
|
+
<div
|
|
88
|
+
class="memori--venue-widget__geosuggest"
|
|
89
|
+
>
|
|
90
|
+
<div
|
|
91
|
+
class="memori--venue-widget-search"
|
|
92
|
+
>
|
|
93
|
+
<input
|
|
94
|
+
aria-expanded="false"
|
|
95
|
+
class="memori--venue-widget-search--input"
|
|
96
|
+
data-headlessui-state=""
|
|
97
|
+
id="headlessui-combobox-input-:r2:"
|
|
98
|
+
placeholder="searchVenue"
|
|
99
|
+
role="combobox"
|
|
100
|
+
type="text"
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
<button
|
|
104
|
+
class="memori-button memori-button--outlined memori-button--rounded memori-button--padded memori--venue-widget__gps-button"
|
|
105
|
+
>
|
|
106
|
+
write_and_speak.useMyPosition
|
|
107
|
+
</button>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
<div
|
|
111
|
+
class="memori--venue-widget__form-item"
|
|
112
|
+
>
|
|
113
|
+
<p
|
|
114
|
+
class="memori--venue--widget__place-name"
|
|
115
|
+
>
|
|
116
|
+
<strong>
|
|
117
|
+
venue
|
|
118
|
+
</strong>
|
|
119
|
+
:
|
|
120
|
+
Altedo, Bologna, Italy
|
|
121
|
+
</p>
|
|
122
|
+
<div
|
|
123
|
+
class="memori--venue-widget__map"
|
|
124
|
+
>
|
|
125
|
+
<div
|
|
126
|
+
data-testid="MapContainer"
|
|
127
|
+
>
|
|
128
|
+
<div
|
|
129
|
+
data-testid="TileLayer"
|
|
130
|
+
/>
|
|
131
|
+
<div
|
|
132
|
+
data-testid="Marker"
|
|
133
|
+
>
|
|
134
|
+
<div
|
|
135
|
+
data-testid="Popup"
|
|
136
|
+
/>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
</fieldset>
|
|
142
|
+
</div>
|
|
143
|
+
`;
|
|
144
|
+
|
|
145
|
+
exports[`renders VenueWidget without gps button unchanged 1`] = `
|
|
146
|
+
<div>
|
|
147
|
+
<fieldset
|
|
148
|
+
class="memori--venue-widget"
|
|
149
|
+
>
|
|
150
|
+
<legend
|
|
151
|
+
class="sr-only"
|
|
152
|
+
>
|
|
153
|
+
Venue
|
|
154
|
+
</legend>
|
|
155
|
+
<div
|
|
156
|
+
class="memori--venue-widget__form-item"
|
|
157
|
+
>
|
|
158
|
+
<div
|
|
159
|
+
class="memori--venue-widget__geosuggest"
|
|
160
|
+
>
|
|
161
|
+
<div
|
|
162
|
+
class="memori--venue-widget-search"
|
|
163
|
+
>
|
|
164
|
+
<input
|
|
165
|
+
aria-expanded="false"
|
|
166
|
+
class="memori--venue-widget-search--input"
|
|
167
|
+
data-headlessui-state=""
|
|
168
|
+
id="headlessui-combobox-input-:r4:"
|
|
169
|
+
placeholder="searchVenue"
|
|
170
|
+
role="combobox"
|
|
171
|
+
type="text"
|
|
172
|
+
/>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
<div
|
|
177
|
+
class="memori--venue-widget__form-item"
|
|
178
|
+
>
|
|
179
|
+
<p
|
|
180
|
+
class="memori--venue--widget__place-name"
|
|
181
|
+
>
|
|
182
|
+
<strong>
|
|
183
|
+
venue
|
|
184
|
+
</strong>
|
|
185
|
+
:
|
|
186
|
+
Altedo, Bologna, Italy
|
|
187
|
+
</p>
|
|
188
|
+
<div
|
|
189
|
+
class="memori--venue-widget__map"
|
|
190
|
+
>
|
|
191
|
+
<div
|
|
192
|
+
data-testid="MapContainer"
|
|
193
|
+
>
|
|
194
|
+
<div
|
|
195
|
+
data-testid="TileLayer"
|
|
196
|
+
/>
|
|
197
|
+
<div
|
|
198
|
+
data-testid="Marker"
|
|
199
|
+
>
|
|
200
|
+
<div
|
|
201
|
+
data-testid="Popup"
|
|
202
|
+
/>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
</fieldset>
|
|
208
|
+
</div>
|
|
209
|
+
`;
|
|
210
|
+
|
|
211
|
+
exports[`renders VenueWidget without uncertainty unchanged 1`] = `
|
|
212
|
+
<div>
|
|
213
|
+
<fieldset
|
|
214
|
+
class="memori--venue-widget"
|
|
215
|
+
>
|
|
216
|
+
<legend
|
|
217
|
+
class="sr-only"
|
|
218
|
+
>
|
|
219
|
+
Venue
|
|
220
|
+
</legend>
|
|
221
|
+
<div
|
|
222
|
+
class="memori--venue-widget__form-item"
|
|
223
|
+
>
|
|
224
|
+
<div
|
|
225
|
+
class="memori--venue-widget__geosuggest"
|
|
226
|
+
>
|
|
227
|
+
<div
|
|
228
|
+
class="memori--venue-widget-search"
|
|
229
|
+
>
|
|
230
|
+
<input
|
|
231
|
+
aria-expanded="false"
|
|
232
|
+
class="memori--venue-widget-search--input"
|
|
233
|
+
data-headlessui-state=""
|
|
234
|
+
id="headlessui-combobox-input-:r3:"
|
|
235
|
+
placeholder="searchVenue"
|
|
236
|
+
role="combobox"
|
|
237
|
+
type="text"
|
|
238
|
+
/>
|
|
239
|
+
</div>
|
|
240
|
+
<button
|
|
241
|
+
class="memori-button memori-button--outlined memori-button--rounded memori-button--padded memori--venue-widget__gps-button"
|
|
242
|
+
>
|
|
243
|
+
write_and_speak.useMyPosition
|
|
244
|
+
</button>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
<div
|
|
248
|
+
class="memori--venue-widget__form-item"
|
|
249
|
+
>
|
|
250
|
+
<p
|
|
251
|
+
class="memori--venue--widget__place-name"
|
|
252
|
+
>
|
|
253
|
+
<strong>
|
|
254
|
+
venue
|
|
255
|
+
</strong>
|
|
256
|
+
:
|
|
257
|
+
Altedo, Bologna, Italy
|
|
258
|
+
</p>
|
|
259
|
+
<div
|
|
260
|
+
class="memori--venue-widget__map"
|
|
261
|
+
>
|
|
262
|
+
<div
|
|
263
|
+
data-testid="MapContainer"
|
|
264
|
+
>
|
|
265
|
+
<div
|
|
266
|
+
data-testid="TileLayer"
|
|
267
|
+
/>
|
|
268
|
+
<div
|
|
269
|
+
data-testid="Marker"
|
|
270
|
+
>
|
|
271
|
+
<div
|
|
272
|
+
data-testid="Popup"
|
|
273
|
+
/>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
</fieldset>
|
|
279
|
+
</div>
|
|
280
|
+
`;
|
|
281
|
+
|
|
282
|
+
exports[`renders empty VenueWidget unchanged 1`] = `
|
|
283
|
+
<div>
|
|
284
|
+
<fieldset
|
|
285
|
+
class="memori--venue-widget"
|
|
286
|
+
>
|
|
287
|
+
<legend
|
|
288
|
+
class="sr-only"
|
|
289
|
+
>
|
|
290
|
+
Venue
|
|
291
|
+
</legend>
|
|
292
|
+
<div
|
|
293
|
+
class="memori--venue-widget__form-item"
|
|
294
|
+
>
|
|
295
|
+
<div
|
|
296
|
+
class="memori--venue-widget__geosuggest"
|
|
297
|
+
>
|
|
298
|
+
<div
|
|
299
|
+
class="memori--venue-widget-search"
|
|
300
|
+
>
|
|
301
|
+
<input
|
|
302
|
+
aria-expanded="false"
|
|
303
|
+
class="memori--venue-widget-search--input"
|
|
304
|
+
data-headlessui-state=""
|
|
305
|
+
id="headlessui-combobox-input-:r0:"
|
|
306
|
+
placeholder="searchVenue"
|
|
307
|
+
role="combobox"
|
|
308
|
+
type="text"
|
|
309
|
+
/>
|
|
310
|
+
</div>
|
|
311
|
+
<button
|
|
312
|
+
class="memori-button memori-button--outlined memori-button--rounded memori-button--padded memori--venue-widget__gps-button"
|
|
313
|
+
>
|
|
314
|
+
write_and_speak.useMyPosition
|
|
315
|
+
</button>
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
<div
|
|
319
|
+
class="memori--venue-widget__form-item"
|
|
320
|
+
>
|
|
321
|
+
<div
|
|
322
|
+
class="memori--venue-widget__map"
|
|
323
|
+
>
|
|
324
|
+
<div
|
|
325
|
+
data-testid="MapContainer"
|
|
326
|
+
>
|
|
327
|
+
<div
|
|
328
|
+
data-testid="TileLayer"
|
|
329
|
+
/>
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
</fieldset>
|
|
334
|
+
</div>
|
|
335
|
+
`;
|
|
@@ -6,6 +6,7 @@ import SelectIcon from '../icons/SelectIcon';
|
|
|
6
6
|
export interface Props<T = any> {
|
|
7
7
|
className?: string;
|
|
8
8
|
value?: T;
|
|
9
|
+
name?: string;
|
|
9
10
|
displayValue?: string;
|
|
10
11
|
onChange: (value: T) => void;
|
|
11
12
|
options: { value: T; label: any }[];
|
|
@@ -17,6 +18,7 @@ export interface Props<T = any> {
|
|
|
17
18
|
const Select = ({
|
|
18
19
|
className,
|
|
19
20
|
value,
|
|
21
|
+
name,
|
|
20
22
|
displayValue,
|
|
21
23
|
options,
|
|
22
24
|
onChange,
|
|
@@ -32,7 +34,7 @@ const Select = ({
|
|
|
32
34
|
onChange(value);
|
|
33
35
|
}}
|
|
34
36
|
disabled={disabled}
|
|
35
|
-
name=
|
|
37
|
+
name={name}
|
|
36
38
|
>
|
|
37
39
|
{label && (
|
|
38
40
|
<Listbox.Label className="memori-select--label">
|
|
@@ -5,14 +5,6 @@ exports[`renders Select disabled unchanged 1`] = `
|
|
|
5
5
|
<div
|
|
6
6
|
class="memori-select"
|
|
7
7
|
>
|
|
8
|
-
<input
|
|
9
|
-
hidden=""
|
|
10
|
-
name="day"
|
|
11
|
-
readonly=""
|
|
12
|
-
style="position: fixed; top: 1px; left: 1px; width: 1px; height: 0px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; border-width: 0px; display: none;"
|
|
13
|
-
type="hidden"
|
|
14
|
-
value="2"
|
|
15
|
-
/>
|
|
16
8
|
<label
|
|
17
9
|
class="memori-select--label"
|
|
18
10
|
data-headlessui-state="disabled"
|
|
@@ -113,14 +105,6 @@ exports[`renders Select with custom value display unchanged 1`] = `
|
|
|
113
105
|
<div
|
|
114
106
|
class="memori-select"
|
|
115
107
|
>
|
|
116
|
-
<input
|
|
117
|
-
hidden=""
|
|
118
|
-
name="day"
|
|
119
|
-
readonly=""
|
|
120
|
-
style="position: fixed; top: 1px; left: 1px; width: 1px; height: 0px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; border-width: 0px; display: none;"
|
|
121
|
-
type="hidden"
|
|
122
|
-
value="2"
|
|
123
|
-
/>
|
|
124
108
|
<label
|
|
125
109
|
class="memori-select--label"
|
|
126
110
|
data-headlessui-state=""
|
|
@@ -223,14 +207,6 @@ exports[`renders Select with value unchanged 1`] = `
|
|
|
223
207
|
<div
|
|
224
208
|
class="memori-select"
|
|
225
209
|
>
|
|
226
|
-
<input
|
|
227
|
-
hidden=""
|
|
228
|
-
name="day"
|
|
229
|
-
readonly=""
|
|
230
|
-
style="position: fixed; top: 1px; left: 1px; width: 1px; height: 0px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; border-width: 0px; display: none;"
|
|
231
|
-
type="hidden"
|
|
232
|
-
value="2"
|
|
233
|
-
/>
|
|
234
210
|
<label
|
|
235
211
|
class="memori-select--label"
|
|
236
212
|
data-headlessui-state=""
|
package/src/helpers/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
1
|
+
import { useState, useEffect, useRef, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
export const hasTouchscreen = (): boolean => {
|
|
4
4
|
let hasTouchScreen = false;
|
|
@@ -91,6 +91,41 @@ export function useDebounce<T>(value: T, delay: number): T {
|
|
|
91
91
|
return debouncedValue;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
export function useDebounceFn<T extends (...args: any) => any>(
|
|
95
|
+
fn: T,
|
|
96
|
+
delay: number
|
|
97
|
+
): T {
|
|
98
|
+
const timeoutId = useRef<number | undefined>();
|
|
99
|
+
const originalFn = useRef<T | null>(null);
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
originalFn.current = fn;
|
|
103
|
+
return () => {
|
|
104
|
+
originalFn.current = null;
|
|
105
|
+
};
|
|
106
|
+
}, [fn]);
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
return () => {
|
|
110
|
+
clearTimeout(timeoutId.current);
|
|
111
|
+
};
|
|
112
|
+
}, []);
|
|
113
|
+
|
|
114
|
+
return useMemo<T>(
|
|
115
|
+
() =>
|
|
116
|
+
((...args: unknown[]) => {
|
|
117
|
+
clearTimeout(timeoutId.current);
|
|
118
|
+
|
|
119
|
+
timeoutId.current = window.setTimeout(() => {
|
|
120
|
+
if (originalFn.current) {
|
|
121
|
+
originalFn.current(...args);
|
|
122
|
+
}
|
|
123
|
+
}, delay);
|
|
124
|
+
}) as unknown as T,
|
|
125
|
+
[delay]
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
94
129
|
export const stripDuplicates = (text: string) => {
|
|
95
130
|
if (
|
|
96
131
|
text
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const EARTH_RADIUS_AT_45_DEGRESS = (6357.0 + 6378.0) / 2.0;
|
|
2
|
+
export const DEGREES_TO_RADIANS = Math.PI / 180;
|
|
3
|
+
|
|
4
|
+
export const getUncertaintyByViewport = (
|
|
5
|
+
bouningBox:
|
|
6
|
+
| [number, number, number, number]
|
|
7
|
+
| [string, string, string, string]
|
|
8
|
+
) => {
|
|
9
|
+
// https://nominatim.org/release-docs/develop/api/Output/#boundingbox
|
|
10
|
+
const [minLat, maxLat, minLng, maxLng] =
|
|
11
|
+
typeof bouningBox[0] === 'string'
|
|
12
|
+
? (bouningBox as string[]).map(parseFloat)
|
|
13
|
+
: (bouningBox as number[]);
|
|
14
|
+
|
|
15
|
+
// Convert latitude and longitude to radians
|
|
16
|
+
const phi1 = minLat * DEGREES_TO_RADIANS;
|
|
17
|
+
const lambda1 = minLng * DEGREES_TO_RADIANS;
|
|
18
|
+
|
|
19
|
+
const phi2 = maxLat * DEGREES_TO_RADIANS;
|
|
20
|
+
const lambda2 = maxLng * DEGREES_TO_RADIANS;
|
|
21
|
+
|
|
22
|
+
// Compute distance using the haversine formula
|
|
23
|
+
// https://en.wikipedia.org/wiki/Haversine_formula
|
|
24
|
+
const angle =
|
|
25
|
+
2.0 *
|
|
26
|
+
Math.asin(
|
|
27
|
+
Math.sqrt(
|
|
28
|
+
Math.sin((phi2 - phi1) / 2.0) * Math.sin((phi2 - phi1) / 2.0) +
|
|
29
|
+
Math.cos(phi1) *
|
|
30
|
+
Math.cos(phi2) *
|
|
31
|
+
Math.sin((lambda2 - lambda1) / 2.0) *
|
|
32
|
+
Math.sin((lambda2 - lambda1) / 2.0)
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
return EARTH_RADIUS_AT_45_DEGRESS * angle;
|
|
36
|
+
};
|
package/src/locales/en.json
CHANGED
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
"copyToClipboard": "Copy to clipboard",
|
|
32
32
|
"showOriginalText": "Show original",
|
|
33
33
|
"showTranslatedText": "Show translation",
|
|
34
|
+
"exactPosition": "Exact position",
|
|
35
|
+
"uncertain": "Uncertain",
|
|
36
|
+
"nothingFound": "Nothing found",
|
|
37
|
+
"venue": "Venue",
|
|
38
|
+
"searchVenue": "Search venue...",
|
|
34
39
|
"memoriBlockedTitle": "Blocked",
|
|
35
40
|
"memoriBlockedUntil": "Memori blocked until {{date}}",
|
|
36
41
|
"memoriBlockedAnon": "Currently \"{{name}}\" can't answer, come back here on {{date}}",
|
package/src/locales/it.json
CHANGED
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
"copyToClipboard": "Copia negli appunti",
|
|
32
32
|
"showOriginalText": "Mostra originale",
|
|
33
33
|
"showTranslatedText": "Mostra traduzione",
|
|
34
|
+
"exactPosition": "Posizione esatta",
|
|
35
|
+
"uncertain": "Incertezza",
|
|
36
|
+
"nothingFound": "Nessun risultato",
|
|
37
|
+
"venue": "Luogo",
|
|
38
|
+
"searchVenue": "Cerca luogo...",
|
|
34
39
|
"memoriBlockedTitle": "Bloccato",
|
|
35
40
|
"memoriBlockedUntil": "Memori bloccato fino al {{date}}",
|
|
36
41
|
"memoriBlockedAnon": "Attualmente \"{{name}}\" non può rispondere, torna qui il {{date}}",
|
package/src/mocks/data.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
KnownFact,
|
|
9
9
|
ExpertReference,
|
|
10
10
|
User,
|
|
11
|
+
Venue,
|
|
11
12
|
} from '@memori.ai/memori-api-client/dist/types';
|
|
12
13
|
|
|
13
14
|
export const sessionID = '131165be-9d1a-42fb-a3ce-e8f86d40c88f';
|
|
@@ -326,3 +327,10 @@ export const expertReference: ExpertReference = {
|
|
|
326
327
|
lastChangeTimestamp: '2023-12-01T13:44:04.832072Z',
|
|
327
328
|
lastChangeSessionID: '0ce713c0-c8f1-4aed-a2a6-40f81c06854f',
|
|
328
329
|
};
|
|
330
|
+
|
|
331
|
+
export const venue: Venue = {
|
|
332
|
+
latitude: 44.66579,
|
|
333
|
+
longitude: 11.48823,
|
|
334
|
+
placeName: 'Altedo, Bologna, Italy',
|
|
335
|
+
uncertainty: 2,
|
|
336
|
+
};
|
package/src/styles.css
CHANGED
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
@import url('./components/AgeVerificationModal/AgeVerificationModal.css');
|
|
41
41
|
@import url('./components/KnownFacts/KnownFacts.css');
|
|
42
42
|
@import url('./components/LoginDrawer/LoginDrawer.css');
|
|
43
|
+
@import url('./components/VenueWidget/VenueWidget.css');
|
|
43
44
|
@import url('./components/MemoriWidget/MemoriWidget.css');
|
|
44
45
|
|
|
45
46
|
@import url('https://fonts.bunny.net/css?family=lexend-deca:200,400,700');
|