panelui-native 0.22.6 → 0.25.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.
Files changed (135) hide show
  1. package/README.md +1 -0
  2. package/lib/module/components/area-chart/index.js +826 -0
  3. package/lib/module/components/area-chart/index.js.map +1 -0
  4. package/lib/module/components/avatar/index.js +1 -1
  5. package/lib/module/components/avatar/index.js.map +1 -1
  6. package/lib/module/components/bar-chart/index.js +853 -0
  7. package/lib/module/components/bar-chart/index.js.map +1 -0
  8. package/lib/module/components/bottom-sheet/index.js +207 -23
  9. package/lib/module/components/bottom-sheet/index.js.map +1 -1
  10. package/lib/module/components/breadcrumb/index.js +275 -0
  11. package/lib/module/components/breadcrumb/index.js.map +1 -0
  12. package/lib/module/components/chip/index.js +2 -2
  13. package/lib/module/components/direction/index.js +13 -19
  14. package/lib/module/components/direction/index.js.map +1 -1
  15. package/lib/module/components/frame/index.js +17 -0
  16. package/lib/module/components/frame/index.js.map +1 -1
  17. package/lib/module/components/heatmap-chart/index.js +28 -8
  18. package/lib/module/components/heatmap-chart/index.js.map +1 -1
  19. package/lib/module/components/input-group/index.js +2 -2
  20. package/lib/module/components/input-group/index.js.map +1 -1
  21. package/lib/module/components/line-chart/index.js +4 -146
  22. package/lib/module/components/line-chart/index.js.map +1 -1
  23. package/lib/module/components/loader/index.js +758 -0
  24. package/lib/module/components/loader/index.js.map +1 -0
  25. package/lib/module/components/map/basemap.js +265 -0
  26. package/lib/module/components/map/basemap.js.map +1 -0
  27. package/lib/module/components/map/index.js +850 -0
  28. package/lib/module/components/map/index.js.map +1 -0
  29. package/lib/module/components/map/maplibre.js +87 -0
  30. package/lib/module/components/map/maplibre.js.map +1 -0
  31. package/lib/module/components/message/index.js +8 -7
  32. package/lib/module/components/message/index.js.map +1 -1
  33. package/lib/module/components/otp-input/index.js +2 -2
  34. package/lib/module/components/progress/index.js +8 -2
  35. package/lib/module/components/progress/index.js.map +1 -1
  36. package/lib/module/components/ring-chart/index.js +423 -0
  37. package/lib/module/components/ring-chart/index.js.map +1 -0
  38. package/lib/module/components/section-rail/index.js +2 -2
  39. package/lib/module/components/separator/index.js +76 -22
  40. package/lib/module/components/separator/index.js.map +1 -1
  41. package/lib/module/components/shimmer/index.js +10 -1
  42. package/lib/module/components/shimmer/index.js.map +1 -1
  43. package/lib/module/components/slider/index.js +19 -5
  44. package/lib/module/components/slider/index.js.map +1 -1
  45. package/lib/module/components/steps/index.js +1 -1
  46. package/lib/module/components/switch/index.js +6 -1
  47. package/lib/module/components/switch/index.js.map +1 -1
  48. package/lib/module/components/typography/index.js +5 -0
  49. package/lib/module/components/typography/index.js.map +1 -1
  50. package/lib/module/hooks/use-direction.js +43 -0
  51. package/lib/module/hooks/use-direction.js.map +1 -0
  52. package/lib/module/icons/index.js +117 -2
  53. package/lib/module/icons/index.js.map +1 -1
  54. package/lib/module/index.js +8 -2
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/primitives/text.js +30 -10
  57. package/lib/module/primitives/text.js.map +1 -1
  58. package/lib/module/utils/chart.js +279 -0
  59. package/lib/module/utils/chart.js.map +1 -0
  60. package/lib/typescript/src/components/area-chart/index.d.ts +197 -0
  61. package/lib/typescript/src/components/area-chart/index.d.ts.map +1 -0
  62. package/lib/typescript/src/components/bar-chart/index.d.ts +228 -0
  63. package/lib/typescript/src/components/bar-chart/index.d.ts.map +1 -0
  64. package/lib/typescript/src/components/bottom-sheet/index.d.ts +75 -4
  65. package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
  66. package/lib/typescript/src/components/breadcrumb/index.d.ts +100 -0
  67. package/lib/typescript/src/components/breadcrumb/index.d.ts.map +1 -0
  68. package/lib/typescript/src/components/direction/index.d.ts +11 -10
  69. package/lib/typescript/src/components/direction/index.d.ts.map +1 -1
  70. package/lib/typescript/src/components/frame/index.d.ts +17 -0
  71. package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
  72. package/lib/typescript/src/components/heatmap-chart/index.d.ts +22 -3
  73. package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
  74. package/lib/typescript/src/components/line-chart/index.d.ts +1 -0
  75. package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
  76. package/lib/typescript/src/components/loader/index.d.ts +38 -0
  77. package/lib/typescript/src/components/loader/index.d.ts.map +1 -0
  78. package/lib/typescript/src/components/map/basemap.d.ts +76 -0
  79. package/lib/typescript/src/components/map/basemap.d.ts.map +1 -0
  80. package/lib/typescript/src/components/map/index.d.ts +367 -0
  81. package/lib/typescript/src/components/map/index.d.ts.map +1 -0
  82. package/lib/typescript/src/components/map/maplibre.d.ts +193 -0
  83. package/lib/typescript/src/components/map/maplibre.d.ts.map +1 -0
  84. package/lib/typescript/src/components/message/index.d.ts.map +1 -1
  85. package/lib/typescript/src/components/progress/index.d.ts.map +1 -1
  86. package/lib/typescript/src/components/ring-chart/index.d.ts +156 -0
  87. package/lib/typescript/src/components/ring-chart/index.d.ts.map +1 -0
  88. package/lib/typescript/src/components/separator/index.d.ts +36 -1
  89. package/lib/typescript/src/components/separator/index.d.ts.map +1 -1
  90. package/lib/typescript/src/components/shimmer/index.d.ts.map +1 -1
  91. package/lib/typescript/src/components/slider/index.d.ts.map +1 -1
  92. package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
  93. package/lib/typescript/src/components/typography/index.d.ts +6 -0
  94. package/lib/typescript/src/components/typography/index.d.ts.map +1 -1
  95. package/lib/typescript/src/hooks/use-direction.d.ts +20 -0
  96. package/lib/typescript/src/hooks/use-direction.d.ts.map +1 -0
  97. package/lib/typescript/src/icons/index.d.ts +5 -0
  98. package/lib/typescript/src/icons/index.d.ts.map +1 -1
  99. package/lib/typescript/src/index.d.ts +9 -3
  100. package/lib/typescript/src/index.d.ts.map +1 -1
  101. package/lib/typescript/src/primitives/text.d.ts.map +1 -1
  102. package/lib/typescript/src/utils/chart.d.ts +96 -0
  103. package/lib/typescript/src/utils/chart.d.ts.map +1 -0
  104. package/package.json +9 -1
  105. package/src/components/area-chart/index.tsx +994 -0
  106. package/src/components/avatar/index.tsx +1 -1
  107. package/src/components/bar-chart/index.tsx +1048 -0
  108. package/src/components/bottom-sheet/index.tsx +280 -20
  109. package/src/components/breadcrumb/index.tsx +365 -0
  110. package/src/components/chip/index.tsx +2 -2
  111. package/src/components/direction/index.tsx +20 -21
  112. package/src/components/frame/index.tsx +17 -0
  113. package/src/components/heatmap-chart/index.tsx +58 -11
  114. package/src/components/input-group/index.tsx +2 -2
  115. package/src/components/line-chart/index.tsx +13 -181
  116. package/src/components/loader/index.tsx +812 -0
  117. package/src/components/map/basemap.ts +304 -0
  118. package/src/components/map/index.tsx +1118 -0
  119. package/src/components/map/maplibre.ts +201 -0
  120. package/src/components/message/index.tsx +8 -7
  121. package/src/components/otp-input/index.tsx +2 -2
  122. package/src/components/progress/index.tsx +10 -2
  123. package/src/components/ring-chart/index.tsx +543 -0
  124. package/src/components/section-rail/index.tsx +2 -2
  125. package/src/components/separator/index.tsx +77 -19
  126. package/src/components/shimmer/index.tsx +10 -1
  127. package/src/components/slider/index.tsx +20 -5
  128. package/src/components/steps/index.tsx +1 -1
  129. package/src/components/switch/index.tsx +6 -1
  130. package/src/components/typography/index.tsx +5 -0
  131. package/src/hooks/use-direction.ts +45 -0
  132. package/src/icons/index.tsx +66 -0
  133. package/src/index.ts +84 -0
  134. package/src/primitives/text.tsx +25 -7
  135. package/src/utils/chart.ts +355 -0
@@ -0,0 +1,304 @@
1
+ /**
2
+ * The basemap, drawn from theme tokens.
3
+ *
4
+ * A hosted map style ships its colours baked in, which gives you exactly two
5
+ * maps: a light one and a dark one. PanelUI has six themes, and a map that
6
+ * stays grey while the rest of the screen turns green is the one element on
7
+ * the page that visibly does not belong to it.
8
+ *
9
+ * So the style is assembled here instead. Tiles still come from the vector
10
+ * source — that is the part worth paying someone for — but every colour in
11
+ * the style is a token the caller's theme already resolved, which means a new
12
+ * theme gets a matching basemap without anyone drawing one.
13
+ *
14
+ * The layer list is deliberately short. A full street style runs to ninety-odd
15
+ * layers separating tunnel casings from bridge casings at eleven zoom stops;
16
+ * almost none of that survives being recoloured down to five greys, and every
17
+ * layer is another thing to keep in step with the tokens. What is here is the
18
+ * set that still reads as a map at any zoom: ground, water, green space,
19
+ * buildings, roads, boundaries, and the labels that make them findable.
20
+ */
21
+ import type { StyleSpecification } from './maplibre';
22
+
23
+ /** Resolved theme colours the style is built from. */
24
+ export interface BasemapTokens {
25
+ /** Ground — everything that is not something else. */
26
+ background: string;
27
+ /** Water bodies and rivers. */
28
+ water: string;
29
+ /** Parks, forest, and other green space. */
30
+ land: string;
31
+ /** Building footprints. */
32
+ building: string;
33
+ /** Roads, boundaries and other lines. */
34
+ line: string;
35
+ /** Label text. */
36
+ label: string;
37
+ /** Halo behind label text, so it stays legible over any fill. */
38
+ labelHalo: string;
39
+ }
40
+
41
+ /**
42
+ * Vector tiles and the glyphs to label them with.
43
+ *
44
+ * Swappable because the tiles are the one part of the style that is somebody
45
+ * else's to license. The defaults follow the OpenMapTiles schema, so any
46
+ * source using it can be dropped in without touching the layers below.
47
+ */
48
+ export interface BasemapSource {
49
+ /** TileJSON URL for the vector source. */
50
+ url: string;
51
+ /** Glyph endpoint, `{fontstack}` and `{range}` templated. */
52
+ glyphs: string;
53
+ /** Font stack for labels. Needs to exist at the glyph endpoint. */
54
+ fonts: string[];
55
+ /** Shown in the attribution control. Check your provider's terms. */
56
+ attribution?: string;
57
+ }
58
+
59
+ /**
60
+ * CARTO's street tiles.
61
+ *
62
+ * Free for non-commercial use; commercial use needs a licence from them. Pass
63
+ * your own `BasemapSource` to use a different provider — the layers below only
64
+ * assume the OpenMapTiles schema, which most vector providers serve.
65
+ */
66
+ export const CARTO_SOURCE: BasemapSource = {
67
+ url: 'https://tiles.basemaps.cartocdn.com/vector/carto.streets/v1/tiles.json',
68
+ glyphs: 'https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf',
69
+ fonts: ['Montserrat Regular', 'Open Sans Regular', 'Noto Sans Regular'],
70
+ attribution: '© OpenStreetMap contributors, © CARTO',
71
+ };
72
+
73
+ const SOURCE_ID = 'basemap';
74
+
75
+ /**
76
+ * Widths that hold up across the whole zoom range.
77
+ *
78
+ * A road drawn at a fixed width is a hairline at zoom 5 and a runway at zoom
79
+ * 18, so each class interpolates between the zoom it appears at and the zoom
80
+ * it stops growing. Exponential rather than linear because zoom itself is
81
+ * exponential — a linear ramp makes every road look identical for the first
82
+ * half of the range and then explodes.
83
+ */
84
+ function width(stops: [number, number][]) {
85
+ return [
86
+ 'interpolate',
87
+ ['exponential', 1.5],
88
+ ['zoom'],
89
+ ...stops.flat(),
90
+ ] as unknown as number;
91
+ }
92
+
93
+ /**
94
+ * Builds a complete MapLibre style from resolved theme colours.
95
+ *
96
+ * `blank` drops the tile source and every layer that reads from it, leaving
97
+ * just the ground colour — a canvas for data that supplies its own geography,
98
+ * such as a choropleth or an arc diagram, where street detail underneath is
99
+ * noise rather than context.
100
+ */
101
+ export function buildBasemapStyle(
102
+ tokens: BasemapTokens,
103
+ options: { blank?: boolean; source?: BasemapSource } = {}
104
+ ): StyleSpecification {
105
+ const { blank = false, source = CARTO_SOURCE } = options;
106
+
107
+ const ground = {
108
+ id: 'ground',
109
+ type: 'background',
110
+ paint: { 'background-color': tokens.background },
111
+ };
112
+
113
+ if (blank) {
114
+ return {
115
+ version: 8,
116
+ name: 'PanelUI blank',
117
+ sources: {},
118
+ layers: [ground],
119
+ } as unknown as StyleSpecification;
120
+ }
121
+
122
+ const label = {
123
+ 'text-font': source.fonts,
124
+ 'text-max-width': 8,
125
+ };
126
+
127
+ const labelPaint = {
128
+ 'text-color': tokens.label,
129
+ 'text-halo-color': tokens.labelHalo,
130
+ 'text-halo-width': 1.2,
131
+ };
132
+
133
+ return {
134
+ version: 8,
135
+ name: 'PanelUI',
136
+ glyphs: source.glyphs,
137
+ sources: {
138
+ [SOURCE_ID]: {
139
+ type: 'vector',
140
+ url: source.url,
141
+ ...(source.attribution ? { attribution: source.attribution } : {}),
142
+ },
143
+ },
144
+ layers: [
145
+ ground,
146
+ // Green space sits directly on the ground and everything else on top of
147
+ // it, so a park never punches a hole through a road crossing it.
148
+ {
149
+ id: 'landcover',
150
+ type: 'fill',
151
+ source: SOURCE_ID,
152
+ 'source-layer': 'landcover',
153
+ paint: { 'fill-color': tokens.land, 'fill-opacity': 0.7 },
154
+ },
155
+ {
156
+ id: 'park',
157
+ type: 'fill',
158
+ source: SOURCE_ID,
159
+ 'source-layer': 'park',
160
+ paint: { 'fill-color': tokens.land, 'fill-opacity': 0.7 },
161
+ },
162
+ {
163
+ id: 'water',
164
+ type: 'fill',
165
+ source: SOURCE_ID,
166
+ 'source-layer': 'water',
167
+ paint: { 'fill-color': tokens.water },
168
+ },
169
+ {
170
+ id: 'waterway',
171
+ type: 'line',
172
+ source: SOURCE_ID,
173
+ 'source-layer': 'waterway',
174
+ paint: {
175
+ 'line-color': tokens.water,
176
+ 'line-width': width([
177
+ [8, 0.5],
178
+ [16, 3],
179
+ ]),
180
+ },
181
+ },
182
+ // Buildings only from the zoom where they stop being a grey smear.
183
+ {
184
+ id: 'building',
185
+ type: 'fill',
186
+ source: SOURCE_ID,
187
+ 'source-layer': 'building',
188
+ minzoom: 14,
189
+ paint: { 'fill-color': tokens.building, 'fill-opacity': 0.8 },
190
+ },
191
+ // Roads as one line per class rather than a fill over a casing. At these
192
+ // contrasts a casing is a second grey against the first and reads as a
193
+ // blur, not as an edge.
194
+ {
195
+ id: 'road-minor',
196
+ type: 'line',
197
+ source: SOURCE_ID,
198
+ 'source-layer': 'transportation',
199
+ minzoom: 12,
200
+ filter: ['match', ['get', 'class'], ['minor', 'service', 'track'], true, false],
201
+ paint: {
202
+ 'line-color': tokens.line,
203
+ 'line-width': width([
204
+ [12, 0.4],
205
+ [18, 6],
206
+ ]),
207
+ },
208
+ layout: { 'line-cap': 'round', 'line-join': 'round' },
209
+ },
210
+ {
211
+ id: 'road-secondary',
212
+ type: 'line',
213
+ source: SOURCE_ID,
214
+ 'source-layer': 'transportation',
215
+ minzoom: 8,
216
+ filter: ['match', ['get', 'class'], ['secondary', 'tertiary'], true, false],
217
+ paint: {
218
+ 'line-color': tokens.line,
219
+ 'line-width': width([
220
+ [8, 0.5],
221
+ [18, 10],
222
+ ]),
223
+ },
224
+ layout: { 'line-cap': 'round', 'line-join': 'round' },
225
+ },
226
+ {
227
+ id: 'road-major',
228
+ type: 'line',
229
+ source: SOURCE_ID,
230
+ 'source-layer': 'transportation',
231
+ filter: ['match', ['get', 'class'], ['motorway', 'trunk', 'primary'], true, false],
232
+ paint: {
233
+ 'line-color': tokens.line,
234
+ 'line-width': width([
235
+ [5, 0.5],
236
+ [18, 14],
237
+ ]),
238
+ },
239
+ layout: { 'line-cap': 'round', 'line-join': 'round' },
240
+ },
241
+ // Dashed, because a border is a claim rather than a thing on the ground.
242
+ {
243
+ id: 'boundary',
244
+ type: 'line',
245
+ source: SOURCE_ID,
246
+ 'source-layer': 'boundary',
247
+ filter: ['<=', ['get', 'admin_level'], 4],
248
+ paint: {
249
+ 'line-color': tokens.line,
250
+ 'line-dasharray': [2, 2],
251
+ 'line-width': width([
252
+ [3, 0.6],
253
+ [12, 1.8],
254
+ ]),
255
+ },
256
+ },
257
+ {
258
+ id: 'water-label',
259
+ type: 'symbol',
260
+ source: SOURCE_ID,
261
+ 'source-layer': 'water_name',
262
+ layout: { ...label, 'text-field': ['get', 'name'], 'text-size': 11 },
263
+ paint: labelPaint,
264
+ },
265
+ {
266
+ id: 'road-label',
267
+ type: 'symbol',
268
+ source: SOURCE_ID,
269
+ 'source-layer': 'transportation_name',
270
+ minzoom: 14,
271
+ layout: {
272
+ ...label,
273
+ 'text-field': ['get', 'name'],
274
+ 'text-size': 10,
275
+ 'symbol-placement': 'line',
276
+ },
277
+ paint: labelPaint,
278
+ },
279
+ // Places last, so a city name is never hidden under a street name.
280
+ {
281
+ id: 'place-label',
282
+ type: 'symbol',
283
+ source: SOURCE_ID,
284
+ 'source-layer': 'place',
285
+ layout: {
286
+ ...label,
287
+ 'text-field': ['get', 'name'],
288
+ // Cities carry more weight than villages, and the type is the only
289
+ // thing distinguishing them once every label is the same colour.
290
+ 'text-size': [
291
+ 'match',
292
+ ['get', 'class'],
293
+ 'city',
294
+ 14,
295
+ 'town',
296
+ 12,
297
+ 10,
298
+ ],
299
+ },
300
+ paint: labelPaint,
301
+ },
302
+ ],
303
+ } as unknown as StyleSpecification;
304
+ }