panelui-native 0.22.5 → 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.
- package/README.md +8 -3
- package/lib/module/components/area-chart/index.js +826 -0
- package/lib/module/components/area-chart/index.js.map +1 -0
- package/lib/module/components/avatar/index.js +1 -1
- package/lib/module/components/avatar/index.js.map +1 -1
- package/lib/module/components/bar-chart/index.js +853 -0
- package/lib/module/components/bar-chart/index.js.map +1 -0
- package/lib/module/components/bottom-sheet/index.js +207 -23
- package/lib/module/components/bottom-sheet/index.js.map +1 -1
- package/lib/module/components/breadcrumb/index.js +275 -0
- package/lib/module/components/breadcrumb/index.js.map +1 -0
- package/lib/module/components/chip/index.js +2 -2
- package/lib/module/components/direction/index.js +13 -19
- package/lib/module/components/direction/index.js.map +1 -1
- package/lib/module/components/frame/index.js +17 -0
- package/lib/module/components/frame/index.js.map +1 -1
- package/lib/module/components/heatmap-chart/index.js +28 -8
- package/lib/module/components/heatmap-chart/index.js.map +1 -1
- package/lib/module/components/input-group/index.js +2 -2
- package/lib/module/components/input-group/index.js.map +1 -1
- package/lib/module/components/line-chart/index.js +4 -146
- package/lib/module/components/line-chart/index.js.map +1 -1
- package/lib/module/components/loader/index.js +758 -0
- package/lib/module/components/loader/index.js.map +1 -0
- package/lib/module/components/map/basemap.js +265 -0
- package/lib/module/components/map/basemap.js.map +1 -0
- package/lib/module/components/map/index.js +850 -0
- package/lib/module/components/map/index.js.map +1 -0
- package/lib/module/components/map/maplibre.js +87 -0
- package/lib/module/components/map/maplibre.js.map +1 -0
- package/lib/module/components/message/index.js +8 -7
- package/lib/module/components/message/index.js.map +1 -1
- package/lib/module/components/otp-input/index.js +2 -2
- package/lib/module/components/progress/index.js +8 -2
- package/lib/module/components/progress/index.js.map +1 -1
- package/lib/module/components/ring-chart/index.js +423 -0
- package/lib/module/components/ring-chart/index.js.map +1 -0
- package/lib/module/components/section-rail/index.js +2 -2
- package/lib/module/components/separator/index.js +76 -22
- package/lib/module/components/separator/index.js.map +1 -1
- package/lib/module/components/shimmer/index.js +10 -1
- package/lib/module/components/shimmer/index.js.map +1 -1
- package/lib/module/components/slider/index.js +19 -5
- package/lib/module/components/slider/index.js.map +1 -1
- package/lib/module/components/steps/index.js +1 -1
- package/lib/module/components/switch/index.js +6 -1
- package/lib/module/components/switch/index.js.map +1 -1
- package/lib/module/components/typography/index.js +5 -0
- package/lib/module/components/typography/index.js.map +1 -1
- package/lib/module/hooks/use-direction.js +43 -0
- package/lib/module/hooks/use-direction.js.map +1 -0
- package/lib/module/icons/index.js +117 -2
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/index.js +8 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/primitives/text.js +30 -10
- package/lib/module/primitives/text.js.map +1 -1
- package/lib/module/utils/chart.js +279 -0
- package/lib/module/utils/chart.js.map +1 -0
- package/lib/typescript/src/components/area-chart/index.d.ts +197 -0
- package/lib/typescript/src/components/area-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/bar-chart/index.d.ts +228 -0
- package/lib/typescript/src/components/bar-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/bottom-sheet/index.d.ts +75 -4
- package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
- package/lib/typescript/src/components/breadcrumb/index.d.ts +100 -0
- package/lib/typescript/src/components/breadcrumb/index.d.ts.map +1 -0
- package/lib/typescript/src/components/direction/index.d.ts +11 -10
- package/lib/typescript/src/components/direction/index.d.ts.map +1 -1
- package/lib/typescript/src/components/frame/index.d.ts +17 -0
- package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
- package/lib/typescript/src/components/heatmap-chart/index.d.ts +22 -3
- package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/line-chart/index.d.ts +1 -0
- package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/loader/index.d.ts +38 -0
- package/lib/typescript/src/components/loader/index.d.ts.map +1 -0
- package/lib/typescript/src/components/map/basemap.d.ts +76 -0
- package/lib/typescript/src/components/map/basemap.d.ts.map +1 -0
- package/lib/typescript/src/components/map/index.d.ts +367 -0
- package/lib/typescript/src/components/map/index.d.ts.map +1 -0
- package/lib/typescript/src/components/map/maplibre.d.ts +193 -0
- package/lib/typescript/src/components/map/maplibre.d.ts.map +1 -0
- package/lib/typescript/src/components/message/index.d.ts.map +1 -1
- package/lib/typescript/src/components/progress/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ring-chart/index.d.ts +156 -0
- package/lib/typescript/src/components/ring-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/separator/index.d.ts +36 -1
- package/lib/typescript/src/components/separator/index.d.ts.map +1 -1
- package/lib/typescript/src/components/shimmer/index.d.ts.map +1 -1
- package/lib/typescript/src/components/slider/index.d.ts.map +1 -1
- package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
- package/lib/typescript/src/components/typography/index.d.ts +6 -0
- package/lib/typescript/src/components/typography/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/use-direction.d.ts +20 -0
- package/lib/typescript/src/hooks/use-direction.d.ts.map +1 -0
- package/lib/typescript/src/icons/index.d.ts +5 -0
- package/lib/typescript/src/icons/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +9 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/primitives/text.d.ts.map +1 -1
- package/lib/typescript/src/utils/chart.d.ts +96 -0
- package/lib/typescript/src/utils/chart.d.ts.map +1 -0
- package/package.json +9 -1
- package/src/components/area-chart/index.tsx +994 -0
- package/src/components/avatar/index.tsx +1 -1
- package/src/components/bar-chart/index.tsx +1048 -0
- package/src/components/bottom-sheet/index.tsx +280 -20
- package/src/components/breadcrumb/index.tsx +365 -0
- package/src/components/chip/index.tsx +2 -2
- package/src/components/direction/index.tsx +20 -21
- package/src/components/frame/index.tsx +17 -0
- package/src/components/heatmap-chart/index.tsx +58 -11
- package/src/components/input-group/index.tsx +2 -2
- package/src/components/line-chart/index.tsx +13 -181
- package/src/components/loader/index.tsx +812 -0
- package/src/components/map/basemap.ts +304 -0
- package/src/components/map/index.tsx +1118 -0
- package/src/components/map/maplibre.ts +201 -0
- package/src/components/message/index.tsx +8 -7
- package/src/components/otp-input/index.tsx +2 -2
- package/src/components/progress/index.tsx +10 -2
- package/src/components/ring-chart/index.tsx +543 -0
- package/src/components/section-rail/index.tsx +2 -2
- package/src/components/separator/index.tsx +77 -19
- package/src/components/shimmer/index.tsx +10 -1
- package/src/components/slider/index.tsx +20 -5
- package/src/components/steps/index.tsx +1 -1
- package/src/components/switch/index.tsx +6 -1
- package/src/components/typography/index.tsx +5 -0
- package/src/hooks/use-direction.ts +45 -0
- package/src/icons/index.tsx +66 -0
- package/src/index.ts +84 -0
- package/src/primitives/text.tsx +25 -7
- 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
|
+
}
|