@longline/aqua-ui 1.0.338 → 1.0.340

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.
Files changed (258) hide show
  1. package/containers/Anchor/Anchor.d.ts +5 -0
  2. package/containers/Anchor/Anchor.js +20 -8
  3. package/containers/Dock/Dock.d.ts +5 -0
  4. package/containers/Dock/Dock.js +1 -1
  5. package/containers/Dock/Dockable.d.ts +5 -0
  6. package/containers/Dock/Dockable.js +20 -12
  7. package/containers/DragBar/DragBar.d.ts +5 -0
  8. package/containers/DragBar/DragBar.js +16 -5
  9. package/containers/Form/Field.d.ts +0 -3
  10. package/containers/Form/Field.js +3 -6
  11. package/containers/Form/Form.js +5 -36
  12. package/containers/Form/Validation.d.ts +1 -1
  13. package/containers/Form/Validation.js +6 -6
  14. package/containers/Form/context/FormContext.d.ts +1 -2
  15. package/containers/Form/context/useForm.d.ts +1 -1
  16. package/containers/Form/elements/BoxWrapper.js +2 -0
  17. package/containers/GlassPane/GlassPane.d.ts +7 -2
  18. package/containers/GlassPane/GlassPane.js +3 -3
  19. package/containers/InfoBox/InfoBox.d.ts +5 -0
  20. package/containers/InfoBox/InfoBox.js +1 -1
  21. package/containers/List/List.d.ts +5 -0
  22. package/containers/List/List.js +1 -1
  23. package/containers/List/ListCell.d.ts +5 -0
  24. package/containers/List/ListCell.js +1 -1
  25. package/containers/List/ListRow.d.ts +7 -2
  26. package/containers/List/ListRow.js +1 -1
  27. package/containers/Message/Error.d.ts +2 -0
  28. package/containers/Message/Error.js +1 -1
  29. package/containers/Message/Message.d.ts +5 -0
  30. package/containers/Message/Message.js +1 -1
  31. package/containers/Message/NoData.d.ts +2 -0
  32. package/containers/Message/NoData.js +1 -1
  33. package/containers/Message/NoFilteredData.d.ts +2 -0
  34. package/containers/Message/NoFilteredData.js +1 -1
  35. package/containers/Openable/Openable.d.ts +5 -0
  36. package/containers/Openable/Openable.js +8 -8
  37. package/containers/PublicRoute/PublicRoute.d.ts +9 -1
  38. package/containers/PublicRoute/PublicRoute.js +3 -7
  39. package/containers/Tabs/Pane.d.ts +5 -0
  40. package/containers/Tabs/Pane.js +3 -3
  41. package/containers/Tabs/Tabs.d.ts +5 -0
  42. package/containers/Tabs/Tabs.js +3 -3
  43. package/controls/Chip/Chip.d.ts +15 -3
  44. package/controls/Chip/Chip.js +7 -6
  45. package/controls/CircularProgress/CircularProgress.d.ts +11 -0
  46. package/controls/CircularProgress/CircularProgress.js +19 -11
  47. package/controls/Dropzone/Dropzone.d.ts +11 -1
  48. package/controls/Dropzone/Dropzone.js +18 -7
  49. package/controls/Fab/Fab.d.ts +14 -6
  50. package/controls/Fab/Fab.js +7 -20
  51. package/controls/Ghost/Ghost.js +3 -3
  52. package/controls/Gradient/Gradient.d.ts +5 -0
  53. package/controls/Gradient/Gradient.js +7 -4
  54. package/controls/Histogram/Histogram.d.ts +8 -2
  55. package/controls/Histogram/Histogram.js +9 -9
  56. package/controls/Histogram/HistogramBar.d.ts +2 -2
  57. package/controls/Icon/Icon.d.ts +10 -4
  58. package/controls/Icon/Icon.js +23 -6
  59. package/controls/Key/Key.d.ts +5 -0
  60. package/controls/Key/Key.js +2 -5
  61. package/controls/LinearChart/LinearChart.d.ts +9 -0
  62. package/controls/LinearChart/LinearChart.js +11 -6
  63. package/controls/ListButton/ListButton.d.ts +46 -3
  64. package/controls/ListButton/ListButton.js +70 -9
  65. package/controls/ListView/ColumnsManager/ColumnDraggable.js +11 -5
  66. package/controls/ListView/ColumnsManager/SourceColumns.js +1 -1
  67. package/controls/ListView/IListViewProps.d.ts +9 -2
  68. package/controls/ListView/ListView.js +13 -12
  69. package/controls/ListView/defaults.d.ts +3 -0
  70. package/controls/ListView/defaults.js +6 -0
  71. package/controls/ListView/elements/Body.d.ts +1 -1
  72. package/controls/ListView/elements/Body.js +23 -12
  73. package/controls/ListView/elements/Ghost.js +3 -2
  74. package/controls/ListView/elements/Header.js +3 -2
  75. package/controls/ListView/elements/HeaderCell.js +3 -3
  76. package/controls/ListView/elements/Table.js +16 -10
  77. package/controls/Mouse/Mouse.d.ts +6 -4
  78. package/controls/Mouse/Mouse.js +15 -8
  79. package/controls/PrimaryButton/PrimaryButton.d.ts +9 -3
  80. package/controls/PrimaryButton/PrimaryButton.js +5 -5
  81. package/controls/Progress/Progress.d.ts +9 -0
  82. package/controls/Progress/Progress.js +12 -8
  83. package/controls/SecondaryButton/SecondaryButton.d.ts +8 -3
  84. package/controls/SecondaryButton/SecondaryButton.js +1 -1
  85. package/controls/SpeechRecognizer/EditorRegistry.js +1 -2
  86. package/controls/SpeechRecognizer/SpeechRecognizer.d.ts +9 -1
  87. package/controls/SpeechRecognizer/SpeechRecognizer.js +16 -9
  88. package/controls/TabBar/TabBar.d.ts +5 -0
  89. package/controls/TabBar/TabBar.js +14 -6
  90. package/controls/TabBar/Underliner.js +1 -1
  91. package/controls/TertiaryButton/TertiaryButton.d.ts +9 -3
  92. package/controls/TertiaryButton/TertiaryButton.js +5 -3
  93. package/controls/ToggleButton/ToggleButton.d.ts +8 -2
  94. package/controls/ToggleButton/ToggleButton.js +1 -1
  95. package/controls/View/View.d.ts +5 -0
  96. package/controls/View/View.js +1 -1
  97. package/formatters/CountryFormatter/CountryFormatter.d.ts +3 -2
  98. package/formatters/CountryFormatter/CountryUtil.d.ts +3 -3
  99. package/formatters/DateTimeFormatter/DateTimeFormatter.d.ts +11 -10
  100. package/formatters/DateTimeFormatter/elements/Custom.d.ts +1 -1
  101. package/formatters/DateTimeFormatter/elements/DistanceDate.d.ts +1 -1
  102. package/formatters/DateTimeFormatter/elements/LongDate.d.ts +1 -1
  103. package/formatters/DateTimeFormatter/elements/LongDateTime.d.ts +1 -1
  104. package/formatters/DateTimeFormatter/elements/LongTime.d.ts +1 -1
  105. package/formatters/DateTimeFormatter/elements/Month.d.ts +1 -1
  106. package/formatters/DateTimeFormatter/elements/ShortDate.d.ts +1 -1
  107. package/formatters/DateTimeFormatter/elements/ShortDateTime.d.ts +1 -1
  108. package/formatters/DateTimeFormatter/elements/ShortTime.d.ts +1 -1
  109. package/formatters/DivisionFormatter/DivisionFormatter.d.ts +2 -2
  110. package/formatters/DivisionFormatter/DivisionFormatter.js +1 -1
  111. package/formatters/DivisionFormatter/DivisionUtil.d.ts +1 -1
  112. package/formatters/DivisionFormatter/DivisionUtil.js +5 -3
  113. package/formatters/FilesizeFormatter/FilesizeFormatter.d.ts +3 -3
  114. package/formatters/GIS/CoordinateFormatter.d.ts +2 -2
  115. package/formatters/GIS/LatitudeFormatter.d.ts +2 -2
  116. package/formatters/GIS/LongitudeFormatter.d.ts +2 -2
  117. package/formatters/HumanFormatter/HumanFormatter.d.ts +3 -3
  118. package/formatters/NumberFormatter/NumberFormatter.d.ts +3 -3
  119. package/formatters/PhoneFormatter/PhoneFormatter.d.ts +25 -0
  120. package/formatters/PhoneFormatter/PhoneFormatter.js +34 -0
  121. package/formatters/PhoneFormatter/index.d.ts +1 -0
  122. package/formatters/PhoneFormatter/index.js +1 -0
  123. package/formatters/StringFormatter/StringFormatter.d.ts +3 -3
  124. package/formatters/StringFormatter/StringFormatter.js +1 -4
  125. package/helper/DMS.d.ts +1 -1
  126. package/helper/DMS.js +2 -2
  127. package/helper/phoneNumber.d.ts +31 -0
  128. package/helper/phoneNumber.js +142 -0
  129. package/hooks/useOutsideClose/useOutsideClose.js +20 -11
  130. package/hooks/useSpeechAIRecorder/useSpeechAIRecorder.js +10 -7
  131. package/index.js +1 -0
  132. package/inputs/DateInput/Body.d.ts +2 -2
  133. package/inputs/DateInput/Body.js +11 -7
  134. package/inputs/DateInput/Calendar.d.ts +1 -1
  135. package/inputs/DateInput/Calendar.js +3 -5
  136. package/inputs/DateInput/DateInput.d.ts +11 -3
  137. package/inputs/DateInput/DateInput.js +11 -3
  138. package/inputs/DateInput/Day.d.ts +1 -1
  139. package/inputs/DateInput/InfiniteList.js +6 -3
  140. package/inputs/DateInput/Navbar.js +3 -2
  141. package/inputs/DateInput/NumericInput.js +3 -0
  142. package/inputs/DateInput/Selector.d.ts +1 -1
  143. package/inputs/DateInput/Selector.js +9 -6
  144. package/inputs/Dropdown/Body.d.ts +2 -2
  145. package/inputs/Dropdown/Column.d.ts +1 -1
  146. package/inputs/Dropdown/Dropdown.d.ts +5 -0
  147. package/inputs/Dropdown/Dropdown.js +36 -63
  148. package/inputs/Dropdown/Pill.js +1 -1
  149. package/inputs/Dropdown/Selection.js +1 -1
  150. package/inputs/Editor/Editor.d.ts +5 -0
  151. package/inputs/Editor/Editor.js +16 -6
  152. package/inputs/Editor/buttons/SpeechAIButton.js +2 -0
  153. package/inputs/Editor/buttons/TextAIButton.d.ts +0 -13
  154. package/inputs/Editor/buttons/TextAIButton.js +30 -14
  155. package/inputs/Editor/buttons/TextAIMenu.js +1 -1
  156. package/inputs/Editor/menu/MenuBar.d.ts +1 -1
  157. package/inputs/Editor/menu/MenuBar.js +1 -1
  158. package/inputs/Editor/menu/MenuButton.js +1 -1
  159. package/inputs/Input/Clear.js +1 -1
  160. package/inputs/Input/Input.d.ts +5 -0
  161. package/inputs/Input/Input.js +8 -6
  162. package/inputs/Input/InputWrapper.d.ts +2 -0
  163. package/inputs/Input/InputWrapper.js +1 -1
  164. package/inputs/Input/Reveal.js +1 -1
  165. package/inputs/MonthRange/Body.d.ts +1 -1
  166. package/inputs/MonthRange/Calendar.d.ts +2 -2
  167. package/inputs/MonthRange/Calendar.js +6 -9
  168. package/inputs/MonthRange/MonthRange.d.ts +7 -1
  169. package/inputs/MonthRange/MonthRange.js +14 -6
  170. package/inputs/MonthRange/Selector.d.ts +1 -1
  171. package/inputs/MonthRange/Selector.js +12 -11
  172. package/inputs/PhoneInput/PhoneInput.d.ts +97 -0
  173. package/inputs/PhoneInput/PhoneInput.js +113 -0
  174. package/inputs/PhoneInput/index.d.ts +2 -0
  175. package/inputs/PhoneInput/index.js +1 -0
  176. package/inputs/Selector/Selector.d.ts +5 -0
  177. package/inputs/Selector/Selector.js +4 -1
  178. package/inputs/Slider/Slider.d.ts +75 -22
  179. package/inputs/Slider/Slider.js +104 -22
  180. package/inputs/Textarea/Textarea.d.ts +5 -5
  181. package/inputs/Textarea/Textarea.js +3 -2
  182. package/map/Map/Map.d.ts +2 -2
  183. package/map/Map/Map.js +20 -14
  184. package/map/PositionsManager/PositionBox.js +7 -3
  185. package/map/PositionsManager/PositionsManager.js +33 -13
  186. package/map/controls/CompassButton/CompassButton.js +1 -1
  187. package/map/controls/FullscreenButton/FullscreenButton.js +1 -1
  188. package/map/controls/Geocoder/Geocoder.js +28 -14
  189. package/map/controls/Geocoder/GeocoderApi.js +2 -0
  190. package/map/controls/Geocoder/GeocoderSelector.js +1 -1
  191. package/map/controls/Graticule/Graticule.js +1 -5
  192. package/map/controls/MapLoader/MapLoader.js +1 -1
  193. package/map/controls/ScaleControl/ScaleControl.js +1 -1
  194. package/map/controls/ZoomInButton/ZoomInButton.js +1 -1
  195. package/map/controls/ZoomOutButton/ZoomOutButton.d.ts +1 -1
  196. package/map/controls/ZoomOutButton/ZoomOutButton.js +2 -2
  197. package/map/controls/base/MapButton/MapButton.d.ts +8 -2
  198. package/map/controls/base/MapButton/MapButton.js +11 -2
  199. package/map/controls/base/MapControl/MapControl.d.ts +5 -0
  200. package/map/controls/base/MapControl/MapControl.js +10 -7
  201. package/map/layers/ClusterLayer/ClusterLayer.d.ts +1 -1
  202. package/map/layers/ClusterLayer/ClusterLayer.js +7 -3
  203. package/map/layers/HtmlMarkerLayer/HtmlMarkerLayer.js +8 -4
  204. package/map/layers/IdwBlendLayer/IdwBlendLayer.js +9 -4
  205. package/map/layers/IdwLayer/IdwLayer.d.ts +2 -1
  206. package/map/layers/IdwLayer/IdwLayer.js +271 -215
  207. package/map/layers/InterpolationLayer/ContoursFragmentShader.d.ts +1 -1
  208. package/map/layers/InterpolationLayer/ContoursFragmentShader.js +1 -1
  209. package/map/layers/InterpolationLayer/InterpolationLayer.d.ts +4 -3
  210. package/map/layers/InterpolationLayer/InterpolationLayer.js +362 -275
  211. package/map/layers/ParticlesLayer/ParticlesLayer.d.ts +8 -7
  212. package/map/layers/ParticlesLayer/ParticlesLayer.js +528 -404
  213. package/map/markers/ClusterMarker/ClusterMarker.d.ts +6 -1
  214. package/map/markers/ClusterMarker/ClusterMarker.js +15 -6
  215. package/map/markers/RiskMarker/RiskMarker.d.ts +5 -1
  216. package/map/markers/RiskMarker/RiskMarker.js +4 -4
  217. package/modules/CountryDropdown/CountryDropdown.js +10 -1
  218. package/modules/Filter/Filter.d.ts +5 -0
  219. package/modules/Filter/Filter.js +10 -6
  220. package/modules/Globe/Globe.d.ts +5 -0
  221. package/modules/Globe/Globe.js +4 -4
  222. package/modules/MainMenu/Item.d.ts +9 -2
  223. package/modules/MainMenu/Item.js +8 -5
  224. package/modules/MainMenu/MainMenu.d.ts +5 -0
  225. package/modules/MainMenu/MainMenu.js +1 -1
  226. package/modules/ParticleGlobe/GL.d.ts +1 -1
  227. package/modules/ParticleGlobe/ParticleGlobe.d.ts +5 -0
  228. package/modules/ParticleGlobe/ParticleGlobe.js +69 -40
  229. package/modules/Public/Public.d.ts +5 -0
  230. package/modules/Public/Public.js +3 -3
  231. package/package.json +1 -1
  232. package/services/Auth/Auth.js +13 -7
  233. package/services/Auth/AuthContext.js +9 -1
  234. package/services/Dialog/Dialog.d.ts +7 -2
  235. package/services/Dialog/Dialog.js +7 -6
  236. package/services/Dialog/DialogWindow.d.ts +3 -1
  237. package/services/Dialog/DialogWindow.js +1 -1
  238. package/services/Dialog/XhrDialog.d.ts +1 -1
  239. package/services/Toast/Toast.js +5 -3
  240. package/services/Toast/ToastContainer.js +3 -1
  241. package/services/Toast/ToastContext.d.ts +1 -1
  242. package/services/Toast/ToastProvider.js +2 -0
  243. package/map/layers/HtmlMarkerLayer/HtmlMarkerLayer copy.d.ts +0 -35
  244. package/map/layers/HtmlMarkerLayer/HtmlMarkerLayer copy.js +0 -176
  245. package/modules/Root/Content.d.ts +0 -16
  246. package/modules/Root/Content.js +0 -25
  247. package/modules/Root/Overlay.d.ts +0 -23
  248. package/modules/Root/Overlay.js +0 -33
  249. package/modules/Root/Root.d.ts +0 -10
  250. package/modules/Root/Root.js +0 -46
  251. package/modules/Root/Shader.d.ts +0 -15
  252. package/modules/Root/Shader.js +0 -24
  253. package/modules/Root/Sidebar.d.ts +0 -13
  254. package/modules/Root/Sidebar.js +0 -24
  255. package/modules/Root/index.d.ts +0 -1
  256. package/modules/Root/index.js +0 -1
  257. package/modules/Root/stories/SampleContent.d.ts +0 -7
  258. package/modules/Root/stories/SampleContent.js +0 -44
@@ -4,80 +4,133 @@ interface ISliderProps extends ITestable {
4
4
  /** @ignore */
5
5
  className?: string;
6
6
  /**
7
- * Current value.
7
+ * Current (controlled) value. Values outside `min`..`max` are clamped, and
8
+ * snapped to the nearest tick when `snapToTicks` is set. Changing this prop
9
+ * repositions the knob.
10
+ * @default min
8
11
  */
9
12
  value?: number;
10
13
  /**
11
- * If set, `Slider` will fill all horizontal space available to it.
14
+ * If set, `Slider` fills all horizontal space available to it. Otherwise the
15
+ * control has a fixed minimum width of 200px.
12
16
  * @default false
13
17
  */
14
18
  fluid?: boolean;
15
19
  /**
16
- * Minimum value.
20
+ * Minimum value, mapped to the left end of the track.
17
21
  * @default 0
18
22
  */
19
23
  min?: number;
20
24
  /**
21
- * Maximum value.
25
+ * Maximum value, mapped to the right end of the track.
22
26
  * @default 100
23
27
  */
24
28
  max?: number;
25
29
  /**
26
- * If set, `onChange` is called continuously while the slide is being moved.
27
- * If not, `onChange` is called only when the slider is released.
30
+ * If set, `onChange` fires continuously while the knob is being dragged.
31
+ * If not, `onChange` fires only once, when the knob is released.
32
+ * Keyboard changes always notify regardless of this setting.
28
33
  * @default false
29
34
  */
30
35
  immediate?: boolean;
31
36
  /**
32
- * Sets the value change when an arrow key is pressed. If omitted,
33
- * `delta` will be 10% of the value range.
37
+ * Amount the value changes for a single arrow-key press. `PageUp`/`PageDown`
38
+ * move by three times this amount. If omitted, `delta` defaults to 10% of
39
+ * the value range (`max - min`). Ignored when `snapToTicks` is set, in which
40
+ * case each key press moves one tick.
34
41
  */
35
42
  delta?: number;
36
43
  /**
37
- * Should ticks be displayed? If so, how many?
44
+ * Number of evenly spaced ticks to render along the track. Ticks are also
45
+ * used as snap points when `snapToTicks` is set. `0` or `1` disables ticks.
38
46
  * @default 0
39
47
  */
40
48
  ticks?: number;
41
49
  /**
42
- * If set, ticks are hidden.
50
+ * If set, ticks are not rendered even when `ticks` is greater than zero.
51
+ * Snapping (`snapToTicks`) still uses the tick positions.
52
+ * @default false
43
53
  */
44
54
  hideTicks?: boolean;
45
55
  /**
46
- * Should the control snap to ticks (if present)?
56
+ * If set, the value snaps to the nearest tick while dragging and on keyboard
57
+ * input. Has no effect unless `ticks` is greater than 1.
47
58
  * @default false
48
59
  */
49
60
  snapToTicks?: boolean;
50
61
  /**
51
- * A disabled `Slider` cannot be interacted with.
62
+ * A disabled `Slider` is greyed out and cannot be interacted with.
63
+ * @default false
52
64
  */
53
65
  disabled?: boolean;
54
66
  /**
55
- * Adds left and right padding.
67
+ * Adds horizontal (left and right) padding so the knob and value tooltip are
68
+ * not clipped at the extremes of the track.
69
+ * @default false
56
70
  */
57
71
  padded?: boolean;
58
72
  /**
59
- * A `Slider` can be in an `error` state.
73
+ * Shows the `Slider` in an error state (track, fill and knob turn red).
74
+ * @default false
60
75
  */
61
76
  error?: boolean;
62
77
  /**
63
- * Custom text color
78
+ * Custom color for the value label shown in the knob's teardrop. Defaults to
79
+ * the theme's primary color.
64
80
  */
65
81
  color?: string;
66
82
  /**
67
- * An optional formatter that takes the current slider value (a number)
68
- * and returns a string. This can be used to divide values by 100,
69
- * for example.
83
+ * Optional formatter that takes the current value (a number) and returns the
84
+ * string shown in the knob's teardrop tooltip and exposed as the ARIA value
85
+ * text. Useful to add units or rescale — e.g. dividing by 100 to show a
86
+ * fraction, or appending `"%"` or `"px"`.
70
87
  */
71
88
  formatter?: (value: number) => string;
72
89
  /**
73
- * Event is triggered when slider's value changes.
90
+ * Called with the new value when it changes. Fires on release by default, or
91
+ * continuously during a drag when `immediate` is set; keyboard changes always
92
+ * notify.
74
93
  */
75
94
  onChange?: (value: number) => void;
95
+ /**
96
+ * Optional inline styles applied to the outer element, for one-off overrides
97
+ * of the default styling.
98
+ */
99
+ style?: React.CSSProperties;
76
100
  }
77
101
  /**
78
- * Sliders allow users to view and select a value (or range) along a track.
79
- * They're ideal for adjusting settings such as volume and brightness, or for
80
- * applying image filters.
102
+ * A `Slider` lets users view and pick a single numeric value along a horizontal
103
+ * track by dragging the knob or using the keyboard. It's ideal for adjusting
104
+ * settings such as volume or brightness, or for applying image filters.
105
+ *
106
+ * The value is bounded by `min`/`max` (default `0`..`100`) and can optionally
107
+ * snap to evenly spaced `ticks`. A `formatter` controls how the value is
108
+ * rendered in the knob's tooltip. By default `onChange` fires once, on release;
109
+ * set `immediate` to be notified continuously while dragging.
110
+ *
111
+ * The control is keyboard-accessible: arrow keys move by `delta`,
112
+ * `PageUp`/`PageDown` move by three times `delta`, and `Home`/`End` jump to the
113
+ * minimum/maximum. It exposes the `role="slider"` ARIA contract, keeping
114
+ * `aria-valuenow`/`aria-valuetext` in sync as the value changes.
115
+ *
116
+ * ## Usage
117
+ *
118
+ * ```tsx
119
+ * // Basic, controlled
120
+ * <Slider value={volume} onChange={setVolume}/>
121
+ *
122
+ * // Custom range, notified while dragging
123
+ * <Slider min={0} max={10} value={rating} immediate onChange={setRating}/>
124
+ *
125
+ * // Ticks with snapping and a formatted tooltip
126
+ * <Slider
127
+ * ticks={5}
128
+ * snapToTicks
129
+ * value={amount}
130
+ * formatter={v => `${v}%`}
131
+ * onChange={setAmount}
132
+ * />
133
+ * ```
81
134
  */
82
135
  declare const Slider: {
83
136
  ({ min, max, fluid, ...props }: ISliderProps): React.JSX.Element;
@@ -26,11 +26,20 @@ var __rest = (this && this.__rest) || function (s, e) {
26
26
  };
27
27
  import * as React from 'react';
28
28
  import styled, { css, keyframes } from 'styled-components';
29
+ // Default value range, shared by the base and the export wrapper.
30
+ var DEFAULT_MIN = 0;
31
+ var DEFAULT_MAX = 100;
29
32
  var SliderBase = function (props) {
33
+ var _a, _b, _c, _d;
34
+ // Defaults supplied by the export wrapper below.
35
+ var min = (_a = props.min) !== null && _a !== void 0 ? _a : DEFAULT_MIN;
36
+ var max = (_b = props.max) !== null && _b !== void 0 ? _b : DEFAULT_MAX;
30
37
  // Current value. This is not the same as props.value: it is the value
31
38
  // while the knob is being dragged. Upon release, this value is called back
32
39
  // with onChange. Or continuously, if `immediate` is set.
33
- var value = React.useRef(props.value);
40
+ var value = React.useRef((_c = props.value) !== null && _c !== void 0 ? _c : min);
41
+ // Reference: outer (focusable) element, used to keep ARIA value in sync.
42
+ var wrapperRef = React.useRef(null);
34
43
  // Reference: track body
35
44
  var trackRef = React.useRef(null);
36
45
  // Reference: track fill.
@@ -54,20 +63,29 @@ var SliderBase = function (props) {
54
63
  if (!props.ticks || props.ticks <= 1)
55
64
  return value;
56
65
  // If ticks are present, then clamp x-position to ticks:
57
- var section = (props.max - props.min) / (props.ticks - 1);
58
- return Math.round((value - props.min) / section) * section + props.min;
66
+ var section = (max - min) / (props.ticks - 1);
67
+ return Math.round((value - min) / section) * section + min;
59
68
  };
60
69
  //
61
70
  // Change current value. If notify is set, also call onChange.
62
71
  //
63
72
  var setValue = function (v, notify) {
64
- value.current = Math.round(snapToTicks(clamp(v, props.min, props.max)));
73
+ value.current = Math.round(snapToTicks(clamp(v, min, max)));
65
74
  // Calculate position in 0..1 range:
66
- var pos = (value.current - props.min) / (props.max - props.min);
75
+ var pos = (value.current - min) / (max - min);
67
76
  // Set knob position as a percentage:
68
- knobRef.current.style.left = "".concat(pos * 100, "%");
69
- trackFillRef.current.style.width = "".concat(pos * 100, "%");
70
- tearValueRef.current.textContent = props.formatter ? props.formatter(value.current) : value.current.toString();
77
+ if (knobRef.current)
78
+ knobRef.current.style.left = "".concat(pos * 100, "%");
79
+ if (trackFillRef.current)
80
+ trackFillRef.current.style.width = "".concat(pos * 100, "%");
81
+ if (tearValueRef.current)
82
+ tearValueRef.current.textContent = props.formatter ? props.formatter(value.current) : value.current.toString();
83
+ // Keep the ARIA value in sync (the control updates imperatively while dragging).
84
+ if (wrapperRef.current) {
85
+ wrapperRef.current.setAttribute('aria-valuenow', String(value.current));
86
+ if (props.formatter)
87
+ wrapperRef.current.setAttribute('aria-valuetext', props.formatter(value.current));
88
+ }
71
89
  if (notify && props.onChange)
72
90
  props.onChange(value.current);
73
91
  };
@@ -75,17 +93,18 @@ var SliderBase = function (props) {
75
93
  var getDelta = function () {
76
94
  // If ticks are present and snapToTicks is on, then snap to ticks:
77
95
  if (props.snapToTicks && props.ticks && props.ticks > 1) {
78
- return (props.max - props.min) / (props.ticks - 1);
96
+ return (max - min) / (props.ticks - 1);
79
97
  }
80
98
  // If a custom delta was specified, use it:
81
99
  if (props.delta)
82
100
  return props.delta;
83
101
  // If no custom delta was specified, then use 10% of value range:
84
- return (props.max - props.min) / 10;
102
+ return (max - min) / 10;
85
103
  };
86
104
  // When the value or the range changes, reposition the knob.
87
105
  React.useEffect(function () {
88
- setValue(props.value);
106
+ var _a;
107
+ setValue((_a = props.value) !== null && _a !== void 0 ? _a : min);
89
108
  }, [props.value, props.min, props.max, props.ticks, props.snapToTicks]);
90
109
  // Mouseup and mousemove and document-wide events. They are only relevant
91
110
  // when dragging is on.
@@ -98,11 +117,13 @@ var SliderBase = function (props) {
98
117
  };
99
118
  });
100
119
  var handleMouseEvent = function (clientX) {
120
+ if (!trackRef.current)
121
+ return;
101
122
  var rect = trackRef.current.getBoundingClientRect();
102
123
  // Calculate x-position in range 0..1:
103
124
  var x = clamp((clientX - rect.left) / trackRef.current.offsetWidth, 0, 1);
104
125
  // Derive value from x-position:
105
- var v = Math.round((props.max - props.min) * x + props.min);
126
+ var v = Math.round((max - min) * x + min);
106
127
  // Set new value. If props.immediate, then call onChange immediately.
107
128
  setValue(v, props.immediate);
108
129
  };
@@ -126,6 +147,9 @@ var SliderBase = function (props) {
126
147
  }
127
148
  };
128
149
  var handleKeyDown = function (e) {
150
+ // Prevent the page from scrolling on keys the slider consumes.
151
+ if (['ArrowLeft', 'ArrowRight', 'Home', 'End', 'PageUp', 'PageDown'].includes(e.key))
152
+ e.preventDefault();
129
153
  switch (e.key) {
130
154
  case 'ArrowLeft':
131
155
  setValue(value.current - getDelta(), true);
@@ -135,11 +159,11 @@ var SliderBase = function (props) {
135
159
  break;
136
160
  // Home moves to minimum:
137
161
  case "Home":
138
- setValue(props.min, true);
162
+ setValue(min, true);
139
163
  break;
140
164
  // End moves to maximum.
141
165
  case "End":
142
- setValue(props.max, true);
166
+ setValue(max, true);
143
167
  break;
144
168
  // PageUp/PageDown take 3x size steps:
145
169
  case "PageUp":
@@ -154,7 +178,7 @@ var SliderBase = function (props) {
154
178
  // Create a number of ticks and return them.
155
179
  return Array(props.ticks).fill(0).map(function (t, idx) { return React.createElement(Tick, { key: idx }); });
156
180
  };
157
- return (React.createElement("div", { "data-testid": props['data-testid'] || "Slider", className: props.className, onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, tabIndex: 0 },
181
+ return (React.createElement("div", { "data-testid": props['data-testid'] || "Slider", className: props.className, style: props.style, onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, tabIndex: 0, ref: wrapperRef, role: "slider", "aria-orientation": "horizontal", "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": (_d = props.value) !== null && _d !== void 0 ? _d : min, "aria-disabled": props.disabled },
158
182
  React.createElement(Track, { ref: trackRef },
159
183
  React.createElement(TrackFill, { "$disabled": props.disabled, "$error": props.error, ref: trackFillRef }),
160
184
  props.ticks && props.hideTicks != true && renderTicks(),
@@ -179,18 +203,76 @@ var TrackFill = styled.div(templateObject_16 || (templateObject_16 = __makeTempl
179
203
  var Track = styled.div(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n position: relative;\n height: 4px;\n border-radius: 2px;\n box-sizing: border-box;\n background-color: ", ";\n\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n padding-top: 1px;\n padding-left: 2px;\n padding-right: 2px;\n"], ["\n position: relative;\n height: 4px;\n border-radius: 2px;\n box-sizing: border-box;\n background-color: ", ";\n\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n padding-top: 1px;\n padding-left: 2px;\n padding-right: 2px;\n"])), function (p) { return p.theme.colors.primary[5]; });
180
204
  var SliderStyled = styled(SliderBase)(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n position: relative;\n min-width: ", ";\n box-sizing: border-box;\n // Padding above and below to capture mouse-down\n padding-top: 52px;\n padding-bottom: 14px;\n ", "\n cursor: ", ";\n user-select: none;\n outline: none;\n ", "\n\n ", "\n"], ["\n position: relative;\n min-width: ", ";\n box-sizing: border-box;\n // Padding above and below to capture mouse-down\n padding-top: 52px;\n padding-bottom: 14px;\n ", "\n cursor: ", ";\n user-select: none;\n outline: none;\n ", "\n\n ", "\n"
181
205
  /**
182
- * Sliders allow users to view and select a value (or range) along a track.
183
- * They're ideal for adjusting settings such as volume and brightness, or for
184
- * applying image filters.
206
+ * A `Slider` lets users view and pick a single numeric value along a horizontal
207
+ * track by dragging the knob or using the keyboard. It's ideal for adjusting
208
+ * settings such as volume or brightness, or for applying image filters.
209
+ *
210
+ * The value is bounded by `min`/`max` (default `0`..`100`) and can optionally
211
+ * snap to evenly spaced `ticks`. A `formatter` controls how the value is
212
+ * rendered in the knob's tooltip. By default `onChange` fires once, on release;
213
+ * set `immediate` to be notified continuously while dragging.
214
+ *
215
+ * The control is keyboard-accessible: arrow keys move by `delta`,
216
+ * `PageUp`/`PageDown` move by three times `delta`, and `Home`/`End` jump to the
217
+ * minimum/maximum. It exposes the `role="slider"` ARIA contract, keeping
218
+ * `aria-valuenow`/`aria-valuetext` in sync as the value changes.
219
+ *
220
+ * ## Usage
221
+ *
222
+ * ```tsx
223
+ * // Basic, controlled
224
+ * <Slider value={volume} onChange={setVolume}/>
225
+ *
226
+ * // Custom range, notified while dragging
227
+ * <Slider min={0} max={10} value={rating} immediate onChange={setRating}/>
228
+ *
229
+ * // Ticks with snapping and a formatted tooltip
230
+ * <Slider
231
+ * ticks={5}
232
+ * snapToTicks
233
+ * value={amount}
234
+ * formatter={v => `${v}%`}
235
+ * onChange={setAmount}
236
+ * />
237
+ * ```
185
238
  */
186
239
  ])), function (p) { return p.fluid == true ? '100%' : '200px'; }, function (p) { return p.padded && css(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n padding-left: 20px;\n padding-right: 20px;\n "], ["\n padding-left: 20px;\n padding-right: 20px;\n "]))); }, function (p) { return p.disabled ? 'auto' : 'pointer'; }, function (p) { return p.disabled && css(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n pointer-events: none;\n "], ["\n pointer-events: none;\n "]))); }, function (p) { return !p.disabled && css(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n // Focus ring:\n &:focus ", ":before {\n animation: ", " 2s linear infinite;\n }\n\n &:hover ", ":before {\n animation: none;\n opacity: 0.7;\n } \n\n // Active focus ring:\n &:active ", ":before {\n animation: none;\n opacity: 1;\n }\n "], ["\n // Focus ring:\n &:focus ", ":before {\n animation: ", " 2s linear infinite;\n }\n\n &:hover ", ":before {\n animation: none;\n opacity: 0.7;\n } \n\n // Active focus ring:\n &:active ", ":before {\n animation: none;\n opacity: 1;\n }\n "])), Knob, Pulse, Knob, Knob); });
187
240
  /**
188
- * Sliders allow users to view and select a value (or range) along a track.
189
- * They're ideal for adjusting settings such as volume and brightness, or for
190
- * applying image filters.
241
+ * A `Slider` lets users view and pick a single numeric value along a horizontal
242
+ * track by dragging the knob or using the keyboard. It's ideal for adjusting
243
+ * settings such as volume or brightness, or for applying image filters.
244
+ *
245
+ * The value is bounded by `min`/`max` (default `0`..`100`) and can optionally
246
+ * snap to evenly spaced `ticks`. A `formatter` controls how the value is
247
+ * rendered in the knob's tooltip. By default `onChange` fires once, on release;
248
+ * set `immediate` to be notified continuously while dragging.
249
+ *
250
+ * The control is keyboard-accessible: arrow keys move by `delta`,
251
+ * `PageUp`/`PageDown` move by three times `delta`, and `Home`/`End` jump to the
252
+ * minimum/maximum. It exposes the `role="slider"` ARIA contract, keeping
253
+ * `aria-valuenow`/`aria-valuetext` in sync as the value changes.
254
+ *
255
+ * ## Usage
256
+ *
257
+ * ```tsx
258
+ * // Basic, controlled
259
+ * <Slider value={volume} onChange={setVolume}/>
260
+ *
261
+ * // Custom range, notified while dragging
262
+ * <Slider min={0} max={10} value={rating} immediate onChange={setRating}/>
263
+ *
264
+ * // Ticks with snapping and a formatted tooltip
265
+ * <Slider
266
+ * ticks={5}
267
+ * snapToTicks
268
+ * value={amount}
269
+ * formatter={v => `${v}%`}
270
+ * onChange={setAmount}
271
+ * />
272
+ * ```
191
273
  */
192
274
  var Slider = function (_a) {
193
- var _b = _a.min, min = _b === void 0 ? 0 : _b, _c = _a.max, max = _c === void 0 ? 100 : _c, _d = _a.fluid, fluid = _d === void 0 ? false : _d, props = __rest(_a, ["min", "max", "fluid"]);
275
+ var _b = _a.min, min = _b === void 0 ? DEFAULT_MIN : _b, _c = _a.max, max = _c === void 0 ? DEFAULT_MAX : _c, _d = _a.fluid, fluid = _d === void 0 ? false : _d, props = __rest(_a, ["min", "max", "fluid"]);
194
276
  return React.createElement(SliderStyled, __assign({ min: min, max: max, fluid: fluid }, props));
195
277
  };
196
278
  Slider.displayName = 'Slider';
@@ -1,10 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { ITestable } from '../../Types';
3
- /**
4
- * Textarea validates itself using the HTML validation API whenever its
5
- * content changes. Listeners can use onValidate to obtain the resulting
6
- * ValidityState.
7
- */
8
3
  interface ITextareaProps extends ITestable {
9
4
  /** @ignore */
10
5
  className?: string;
@@ -70,6 +65,11 @@ interface ITextareaProps extends ITestable {
70
65
  * Listeners are notified whenever the user interacts with the Textarea.
71
66
  */
72
67
  onChange?: (value: any) => void;
68
+ /**
69
+ * Optional inline styles applied to the outer element, for one-off overrides
70
+ * of the default styling.
71
+ */
72
+ style?: React.CSSProperties;
73
73
  }
74
74
  /**
75
75
  * `Textarea` encapsulated and styles the `<textarea>` element. Like `Input`,
@@ -34,14 +34,15 @@ var TextareaBase = function (props) {
34
34
  }
35
35
  };
36
36
  var toggleFullscreen = function () {
37
+ var _a;
37
38
  if (document.fullscreenElement) {
38
39
  document.exitFullscreen();
39
40
  }
40
41
  else {
41
- textareaRef.current.requestFullscreen();
42
+ (_a = textareaRef.current) === null || _a === void 0 ? void 0 : _a.requestFullscreen();
42
43
  }
43
44
  };
44
- return (React.createElement(InputWrapper, { fluid: props.fluid, ghost: props.ghost, error: props.error, disabled: props.disabled, transparent: props.transparent, flex: props.flex },
45
+ return (React.createElement(InputWrapper, { fluid: props.fluid, ghost: props.ghost, error: props.error, disabled: props.disabled, transparent: props.transparent, flex: props.flex, style: props.style },
45
46
  React.createElement("textarea", { "data-testid": props['data-testid'] || "Textarea", className: props.className, ref: textareaRef, name: props.name, value: value == null ? '' : value, placeholder: props.placeholder, disabled: props.disabled, tabIndex: 0, onChange: handleChange }),
46
47
  props.fullscreen &&
47
48
  React.createElement(FullscreenToggle, { onClick: toggleFullscreen },
package/map/Map/Map.d.ts CHANGED
@@ -128,8 +128,8 @@ interface IMapProps extends ITestable {
128
128
  */
129
129
  onMouseLeave?: (e: MapMouseEvent) => void;
130
130
  }
131
- declare const ViewStateContext: React.Context<ViewState>;
132
- declare const useViewState: () => ViewState;
131
+ declare const ViewStateContext: React.Context<ViewState | null>;
132
+ declare const useViewState: () => ViewState | null;
133
133
  declare const Map: {
134
134
  ({ longitude, latitude, zoom, pitch, bearing, logoPosition, interactiveLayerIds, noRotate, preserveDrawingBuffer, minZoom, maxZoom, fadeDuration, doubleClickZoom, ...props }: IMapProps): React.JSX.Element;
135
135
  displayName: string;
package/map/Map/Map.js CHANGED
@@ -74,21 +74,24 @@ var useViewState = function () {
74
74
  * The map's current ViewState is tracked in local state, and fed into a context provider.
75
75
  * The ViewState can be retrieved by child components using `useViewState()`.
76
76
  */
77
+ // Default view-state prop values, referenced both by the MapBase fallbacks and
78
+ // the Map wrapper below.
79
+ var DEFAULT_LONGITUDE = -64.6;
80
+ var DEFAULT_LATITUDE = 44.02;
81
+ var DEFAULT_ZOOM = 11;
82
+ var DEFAULT_PITCH = 0;
83
+ var DEFAULT_BEARING = 0;
77
84
  var MapBase = function (props) {
85
+ var _a, _b, _c, _d, _e;
78
86
  var theme = useTheme();
79
- var _a = React.useState({
80
- longitude: props.longitude,
81
- latitude: props.latitude,
82
- zoom: props.zoom,
83
- pitch: props.pitch,
84
- bearing: props.bearing,
87
+ var _f = React.useState({
88
+ longitude: (_a = props.longitude) !== null && _a !== void 0 ? _a : DEFAULT_LONGITUDE,
89
+ latitude: (_b = props.latitude) !== null && _b !== void 0 ? _b : DEFAULT_LATITUDE,
90
+ zoom: (_c = props.zoom) !== null && _c !== void 0 ? _c : DEFAULT_ZOOM,
91
+ pitch: (_d = props.pitch) !== null && _d !== void 0 ? _d : DEFAULT_PITCH,
92
+ bearing: (_e = props.bearing) !== null && _e !== void 0 ? _e : DEFAULT_BEARING,
85
93
  padding: props.padding || { top: 0, bottom: 0, left: 0, right: 0 }
86
- }), viewState = _a[0], setViewState = _a[1];
87
- // TODO: REMOVE THIS!
88
- // React.useEffect(() => {
89
- // // Clears entire Mapbox tile cache for testing of clipping strategy.
90
- // MapboxGL.clearStorage();
91
- // }, []);
94
+ }), viewState = _f[0], setViewState = _f[1];
92
95
  var loadImage = function (url) {
93
96
  return new Promise(function (res, rej) {
94
97
  var img = new Image();
@@ -169,7 +172,7 @@ var MapBase = function (props) {
169
172
  };
170
173
  React.useEffect(function () {
171
174
  if (!props.clipped)
172
- return;
175
+ return undefined;
173
176
  var originalFetch = window.fetch;
174
177
  window.fetch = function () {
175
178
  var args = [];
@@ -201,6 +204,9 @@ var MapBase = function (props) {
201
204
  });
202
205
  });
203
206
  };
207
+ // Restore the original fetch when the clipped map unmounts, so the global
208
+ // override doesn't leak into the rest of the app.
209
+ return function () { window.fetch = originalFetch; };
204
210
  }, []);
205
211
  var handleLoad = function (e) {
206
212
  var map = e.target;
@@ -229,7 +235,7 @@ var MapBase = function (props) {
229
235
  };
230
236
  var Controls = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n & > * {\n pointer-events: all;\n }\n\n ", ";\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n & > * {\n pointer-events: all;\n }\n\n ", ";\n"])), function (p) { return p.theme.font.bodyMedium; });
231
237
  var Map = function (_a) {
232
- var _b = _a.longitude, longitude = _b === void 0 ? -64.6 : _b, _c = _a.latitude, latitude = _c === void 0 ? 44.02 : _c, _d = _a.zoom, zoom = _d === void 0 ? 11 : _d, _e = _a.pitch, pitch = _e === void 0 ? 0 : _e, _f = _a.bearing, bearing = _f === void 0 ? 0 : _f, _g = _a.logoPosition, logoPosition = _g === void 0 ? 'top-right' : _g, _h = _a.interactiveLayerIds, interactiveLayerIds = _h === void 0 ? [] : _h, _j = _a.noRotate, noRotate = _j === void 0 ? false : _j, _k = _a.preserveDrawingBuffer, preserveDrawingBuffer = _k === void 0 ? false : _k, _l = _a.minZoom, minZoom = _l === void 0 ? 1 : _l, _m = _a.maxZoom, maxZoom = _m === void 0 ? 20 : _m, _o = _a.fadeDuration, fadeDuration = _o === void 0 ? 300 : _o, _p = _a.doubleClickZoom, doubleClickZoom = _p === void 0 ? true : _p, props = __rest(_a, ["longitude", "latitude", "zoom", "pitch", "bearing", "logoPosition", "interactiveLayerIds", "noRotate", "preserveDrawingBuffer", "minZoom", "maxZoom", "fadeDuration", "doubleClickZoom"]);
238
+ var _b = _a.longitude, longitude = _b === void 0 ? DEFAULT_LONGITUDE : _b, _c = _a.latitude, latitude = _c === void 0 ? DEFAULT_LATITUDE : _c, _d = _a.zoom, zoom = _d === void 0 ? DEFAULT_ZOOM : _d, _e = _a.pitch, pitch = _e === void 0 ? DEFAULT_PITCH : _e, _f = _a.bearing, bearing = _f === void 0 ? DEFAULT_BEARING : _f, _g = _a.logoPosition, logoPosition = _g === void 0 ? 'top-right' : _g, _h = _a.interactiveLayerIds, interactiveLayerIds = _h === void 0 ? [] : _h, _j = _a.noRotate, noRotate = _j === void 0 ? false : _j, _k = _a.preserveDrawingBuffer, preserveDrawingBuffer = _k === void 0 ? false : _k, _l = _a.minZoom, minZoom = _l === void 0 ? 1 : _l, _m = _a.maxZoom, maxZoom = _m === void 0 ? 20 : _m, _o = _a.fadeDuration, fadeDuration = _o === void 0 ? 300 : _o, _p = _a.doubleClickZoom, doubleClickZoom = _p === void 0 ? true : _p, props = __rest(_a, ["longitude", "latitude", "zoom", "pitch", "bearing", "logoPosition", "interactiveLayerIds", "noRotate", "preserveDrawingBuffer", "minZoom", "maxZoom", "fadeDuration", "doubleClickZoom"]);
233
239
  return React.createElement(MapBase, __assign({ longitude: longitude, latitude: latitude, zoom: zoom, pitch: pitch, bearing: bearing, logoPosition: logoPosition, interactiveLayerIds: interactiveLayerIds, noRotate: noRotate, preserveDrawingBuffer: preserveDrawingBuffer, minZoom: minZoom, maxZoom: maxZoom, fadeDuration: fadeDuration, doubleClickZoom: doubleClickZoom }, props));
234
240
  };
235
241
  Map.displayName = 'Map';
@@ -24,15 +24,19 @@ var PositionBox = function (props) {
24
24
  };
25
25
  });
26
26
  var handleMouseMove = function (ev) {
27
- if (dragging)
27
+ if (dragging && dragOffset.current)
28
28
  props.onMove(ev.clientX - dragOffset.current[0], ev.clientY - dragOffset.current[1]);
29
29
  };
30
30
  var handleMouseUp = function () {
31
31
  setDragging(false);
32
32
  };
33
33
  var handleStartDrag = function (ev) {
34
- var x = wrapperRef.current.parentElement.offsetLeft;
35
- var y = wrapperRef.current.parentElement.offsetTop;
34
+ var _a;
35
+ var parent = (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.parentElement;
36
+ if (!parent)
37
+ return;
38
+ var x = parent.offsetLeft;
39
+ var y = parent.offsetTop;
36
40
  dragOffset.current = [ev.clientX - x - 9, ev.clientY - y - 38];
37
41
  setDragging(true);
38
42
  };
@@ -40,10 +40,16 @@ var PositionsManager = function (_a) {
40
40
  var store = storage == 'session' ? sessionStorage : localStorage;
41
41
  // Retrieve positions from storage. Returns [] if no data in store.
42
42
  var loadPositionsFromStorage = function () {
43
- var json = store.getItem(STORAGE_KEY);
44
- if (json == null)
43
+ try {
44
+ var json = store.getItem(STORAGE_KEY);
45
+ if (json == null)
46
+ return [];
47
+ return JSON.parse(json);
48
+ }
49
+ catch (_a) {
50
+ // Ignore corrupt/unavailable storage.
45
51
  return [];
46
- return JSON.parse(json);
52
+ }
47
53
  };
48
54
  // Save positions to store.
49
55
  var savePositionsToStorage = function (positions) {
@@ -55,13 +61,16 @@ var PositionsManager = function (_a) {
55
61
  // Ctrl key must be held down.
56
62
  if (!ev.originalEvent.ctrlKey)
57
63
  return;
64
+ var m = map.current;
65
+ if (!m)
66
+ return;
58
67
  // Add click coordinates to positions list.
59
68
  setPositions(function (positions) {
60
69
  // Allow no more than 3 saved positions.
61
70
  if (positions.length >= maxPositions)
62
71
  return positions;
63
72
  // Add new position to positions list.
64
- var position = { lng: ev.lngLat.lng, lat: ev.lngLat.lat, zoom: map.current.getZoom() };
73
+ var position = { lng: ev.lngLat.lng, lat: ev.lngLat.lat, zoom: m.getZoom() };
65
74
  var newPositions = __spreadArray([position], positions, true);
66
75
  // Store new positions list in store.
67
76
  savePositionsToStorage(newPositions);
@@ -71,31 +80,42 @@ var PositionsManager = function (_a) {
71
80
  // Add a CTRL+click handler to the map, and removes
72
81
  // it on unmount.
73
82
  React.useEffect(function () {
74
- map.current.on('click', handleRegisterCoordinate);
75
- return function () { map.current.off('contextmenu', handleRegisterCoordinate); };
83
+ var m = map.current;
84
+ if (!m)
85
+ return undefined;
86
+ m.on('click', handleRegisterCoordinate);
87
+ return function () { m.off('click', handleRegisterCoordinate); };
76
88
  }, []);
77
89
  var handleMovePosition = function (idx, x, y) {
78
- var _a = map.current.unproject([x, y]), lng = _a.lng, lat = _a.lat;
79
- var position = { lng: lng, lat: lat, zoom: map.current.getZoom() };
90
+ var m = map.current;
91
+ if (!m)
92
+ return;
93
+ var _a = m.unproject([x, y]), lng = _a.lng, lat = _a.lat;
94
+ var position = { lng: lng, lat: lat, zoom: m.getZoom() };
80
95
  var head = positions.slice(0, idx);
81
96
  var tail = positions.slice(idx + 1);
82
97
  var newPositions = __spreadArray(__spreadArray(__spreadArray([], head, true), [position], false), tail, true);
83
98
  setPositions(newPositions);
84
- savePositionsToStorage(positions);
99
+ savePositionsToStorage(newPositions);
85
100
  };
86
101
  var handleDeletePosition = function (idx) {
87
- positions.splice(idx, 1);
88
- setPositions(__spreadArray([], positions, true));
89
- savePositionsToStorage(positions);
102
+ var newPositions = positions.filter(function (_, i) { return i !== idx; });
103
+ setPositions(newPositions);
104
+ savePositionsToStorage(newPositions);
90
105
  };
91
106
  var handleFocus = function (idx) {
92
107
  var position = positions[idx];
108
+ if (!map.current)
109
+ return;
93
110
  map.current.easeTo({
94
111
  center: [position.lng, position.lat],
95
112
  zoom: position.zoom
96
113
  });
97
114
  };
98
- return (React.createElement(React.Fragment, null, positions.reverse().map(function (position, idx) {
115
+ return (React.createElement(React.Fragment, null, positions.slice().reverse().map(function (position, revIdx) {
116
+ // Map the display (reversed) index back to the canonical index so the
117
+ // move/delete/focus handlers target the correct entry.
118
+ var idx = positions.length - 1 - revIdx;
99
119
  return React.createElement(PositionBox, { key: idx, coord: position, onMove: function (x, y) { return handleMovePosition(idx, x, y); }, onDelete: function () { return handleDeletePosition(idx); }, onFocus: function () { return handleFocus(idx); } });
100
120
  })));
101
121
  };
@@ -34,7 +34,7 @@ import { Key } from '../../../controls/Key';
34
34
  var CompassButtonBase = function (props) {
35
35
  var viewState = useViewState();
36
36
  var map = useMap().current;
37
- return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "CompassButton", onClick: function () { map.rotateTo(0); map.resetNorthPitch(); } }, props),
37
+ return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "CompassButton", ariaLabel: "Reset bearing and pitch", onClick: function () { map.rotateTo(0); map.resetNorthPitch(); } }, props),
38
38
  React.createElement("div", { style: { transform: "rotateX(".concat(props.visualizePitch ? viewState.pitch : 0, "deg)") } },
39
39
  React.createElement("svg", { style: { transform: "rotateZ(".concat(-viewState.bearing, "deg)") }, xmlns: "http://www.w3.org/2000/svg", x: "0px", y: "0px", viewBox: "0 0 1000 1000" },
40
40
  React.createElement("polygon", { className: "tip", points: "100,1000 500,0 900,1000 500,700 " }),
@@ -59,7 +59,7 @@ var FullscreenButton = function (_a) {
59
59
  window.document.exitFullscreen();
60
60
  }
61
61
  };
62
- return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "FullscreenButton", disabled: !checkFullscreenSupport(), onClick: toggle, hint: hint }, props),
62
+ return (React.createElement(MapButton, __assign({ "data-testid": props['data-testid'] || "FullscreenButton", ariaLabel: "Toggle fullscreen", disabled: !checkFullscreenSupport(), onClick: toggle, hint: hint }, props),
63
63
  React.createElement("svg", { width: "100", height: "100", viewBox: "0 0 448 512", xmlns: "http://www.w3.org/2000/svg" },
64
64
  React.createElement("path", { d: "M32 32C14.3 32 0 46.3 0 64v96c0 17.7 14.3 32 32 32s32-14.3 32-32V96h64c17.7 0 32-14.3 32-32s-14.3-32-32-32H32zM64 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7 14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H64V352zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32h64v64c0 17.7 14.3 32 32 32s32-14.3 32-32V64c0-17.7-14.3-32-32-32H320zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v64H320c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32V352z" }))));
65
65
  };