tempest-react-sdk 0.27.0 → 0.28.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 +24 -0
- package/bin/lib/css/analyze.mjs +149 -0
- package/bin/lib/css/analyze.test.mjs +136 -0
- package/bin/lib/css/collect.mjs +152 -0
- package/bin/lib/css/findings.mjs +79 -0
- package/bin/lib/css/fix.e2e.test.mjs +99 -0
- package/bin/lib/css/fix.mjs +138 -0
- package/bin/lib/css/fix.test.mjs +108 -0
- package/bin/lib/css/index.mjs +16 -0
- package/bin/lib/css/parse.mjs +398 -0
- package/bin/lib/css/parse.test.mjs +146 -0
- package/bin/lib/css/properties.mjs +399 -0
- package/bin/lib/css/repetition.mjs +213 -0
- package/bin/lib/css/repetition.test.mjs +166 -0
- package/bin/lib/css/semantic.mjs +327 -0
- package/bin/lib/css/semantic.test.mjs +201 -0
- package/bin/lib/css/tokens.mjs +119 -0
- package/bin/lib/doctor/doctor.e2e.test.mjs +45 -0
- package/bin/tempest.mjs +169 -7
- package/dist/charts/scales.cjs +2 -0
- package/dist/charts/scales.cjs.map +1 -0
- package/dist/charts/scales.js +29 -0
- package/dist/charts/scales.js.map +1 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +91 -0
- package/dist/charts.js +9 -8
- package/dist/components/BottomNavigation/BottomNavigation.module.cjs.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.module.js.map +1 -1
- package/dist/components/Carousel/Carousel.module.cjs.map +1 -1
- package/dist/components/Carousel/Carousel.module.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs +3 -0
- package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -0
- package/dist/components/CodeBlock/CodeBlock.js +53 -0
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -0
- package/dist/components/CodeBlock/CodeBlock.module.cjs +2 -0
- package/dist/components/CodeBlock/CodeBlock.module.cjs.map +1 -0
- package/dist/components/CodeBlock/CodeBlock.module.js +29 -0
- package/dist/components/CodeBlock/CodeBlock.module.js.map +1 -0
- package/dist/components/CodeBlock/tokenize.cjs +3 -0
- package/dist/components/CodeBlock/tokenize.cjs.map +1 -0
- package/dist/components/CodeBlock/tokenize.js +267 -0
- package/dist/components/CodeBlock/tokenize.js.map +1 -0
- package/dist/components/Navbar/Navbar.module.cjs.map +1 -1
- package/dist/components/Navbar/Navbar.module.js.map +1 -1
- package/dist/components/QRCode/QRCode.cjs +2 -0
- package/dist/components/QRCode/QRCode.cjs.map +1 -0
- package/dist/components/QRCode/QRCode.js +49 -0
- package/dist/components/QRCode/QRCode.js.map +1 -0
- package/dist/components/QRCode/QRCode.module.cjs +2 -0
- package/dist/components/QRCode/QRCode.module.cjs.map +1 -0
- package/dist/components/QRCode/QRCode.module.js +9 -0
- package/dist/components/QRCode/QRCode.module.js.map +1 -0
- package/dist/components/QRCode/qr-encode.cjs +2 -0
- package/dist/components/QRCode/qr-encode.cjs.map +1 -0
- package/dist/components/QRCode/qr-encode.js +295 -0
- package/dist/components/QRCode/qr-encode.js.map +1 -0
- package/dist/components/QRCode/qr-tables.cjs +2 -0
- package/dist/components/QRCode/qr-tables.cjs.map +1 -0
- package/dist/components/QRCode/qr-tables.js +366 -0
- package/dist/components/QRCode/qr-tables.js.map +1 -0
- package/dist/components/ScrollArea/ScrollArea.cjs +1 -1
- package/dist/components/ScrollArea/ScrollArea.cjs.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +22 -16
- package/dist/components/ScrollArea/ScrollArea.js.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.module.cjs.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.module.js.map +1 -1
- package/dist/components/Sparkline/Sparkline.cjs +2 -0
- package/dist/components/Sparkline/Sparkline.cjs.map +1 -0
- package/dist/components/Sparkline/Sparkline.js +64 -0
- package/dist/components/Sparkline/Sparkline.js.map +1 -0
- package/dist/components/Sparkline/Sparkline.module.cjs +2 -0
- package/dist/components/Sparkline/Sparkline.module.cjs.map +1 -0
- package/dist/components/Sparkline/Sparkline.module.js +10 -0
- package/dist/components/Sparkline/Sparkline.module.js.map +1 -0
- package/dist/components/Sparkline/sparkline-geometry.cjs +2 -0
- package/dist/components/Sparkline/sparkline-geometry.cjs.map +1 -0
- package/dist/components/Sparkline/sparkline-geometry.js +56 -0
- package/dist/components/Sparkline/sparkline-geometry.js.map +1 -0
- package/dist/components/Table/Table.cjs +1 -1
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.js +37 -30
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Table/Table.module.cjs.map +1 -1
- package/dist/components/Table/Table.module.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.cjs +1 -1
- package/dist/components/VirtualList/VirtualList.cjs.map +1 -1
- package/dist/components/VirtualList/VirtualList.js +13 -11
- package/dist/components/VirtualList/VirtualList.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.module.cjs.map +1 -1
- package/dist/components/VirtualList/VirtualList.module.js.map +1 -1
- package/dist/hooks/use-scroll-overflow.cjs +2 -0
- package/dist/hooks/use-scroll-overflow.cjs.map +1 -0
- package/dist/hooks/use-scroll-overflow.js +22 -0
- package/dist/hooks/use-scroll-overflow.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +445 -2
- package/dist/tempest-react-sdk.js +197 -190
- package/dist/theme/create-theme.cjs +3 -3
- package/dist/theme/create-theme.cjs.map +1 -1
- package/dist/theme/create-theme.js +52 -28
- package/dist/theme/create-theme.js.map +1 -1
- package/dist/theme/data-viz-ramps.cjs +2 -0
- package/dist/theme/data-viz-ramps.cjs.map +1 -0
- package/dist/theme/data-viz-ramps.js +58 -0
- package/dist/theme/data-viz-ramps.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
//#region src/components/QRCode/qr-tables.ts
|
|
2
|
+
var e = {
|
|
3
|
+
L: 1,
|
|
4
|
+
M: 0,
|
|
5
|
+
Q: 3,
|
|
6
|
+
H: 2
|
|
7
|
+
}, t = {
|
|
8
|
+
L: [
|
|
9
|
+
7,
|
|
10
|
+
10,
|
|
11
|
+
15,
|
|
12
|
+
20,
|
|
13
|
+
26,
|
|
14
|
+
18,
|
|
15
|
+
20,
|
|
16
|
+
24,
|
|
17
|
+
30,
|
|
18
|
+
18,
|
|
19
|
+
20,
|
|
20
|
+
24,
|
|
21
|
+
26,
|
|
22
|
+
30,
|
|
23
|
+
22,
|
|
24
|
+
24,
|
|
25
|
+
28,
|
|
26
|
+
30,
|
|
27
|
+
28,
|
|
28
|
+
28,
|
|
29
|
+
28,
|
|
30
|
+
28,
|
|
31
|
+
30,
|
|
32
|
+
30,
|
|
33
|
+
26,
|
|
34
|
+
28,
|
|
35
|
+
30,
|
|
36
|
+
30,
|
|
37
|
+
30,
|
|
38
|
+
30,
|
|
39
|
+
30,
|
|
40
|
+
30,
|
|
41
|
+
30,
|
|
42
|
+
30,
|
|
43
|
+
30,
|
|
44
|
+
30,
|
|
45
|
+
30,
|
|
46
|
+
30,
|
|
47
|
+
30,
|
|
48
|
+
30
|
|
49
|
+
],
|
|
50
|
+
M: [
|
|
51
|
+
10,
|
|
52
|
+
16,
|
|
53
|
+
26,
|
|
54
|
+
18,
|
|
55
|
+
24,
|
|
56
|
+
16,
|
|
57
|
+
18,
|
|
58
|
+
22,
|
|
59
|
+
22,
|
|
60
|
+
26,
|
|
61
|
+
30,
|
|
62
|
+
22,
|
|
63
|
+
22,
|
|
64
|
+
24,
|
|
65
|
+
24,
|
|
66
|
+
28,
|
|
67
|
+
28,
|
|
68
|
+
26,
|
|
69
|
+
26,
|
|
70
|
+
26,
|
|
71
|
+
26,
|
|
72
|
+
28,
|
|
73
|
+
28,
|
|
74
|
+
28,
|
|
75
|
+
28,
|
|
76
|
+
28,
|
|
77
|
+
28,
|
|
78
|
+
28,
|
|
79
|
+
28,
|
|
80
|
+
28,
|
|
81
|
+
28,
|
|
82
|
+
28,
|
|
83
|
+
28,
|
|
84
|
+
28,
|
|
85
|
+
28,
|
|
86
|
+
28,
|
|
87
|
+
28,
|
|
88
|
+
28,
|
|
89
|
+
28,
|
|
90
|
+
28
|
|
91
|
+
],
|
|
92
|
+
Q: [
|
|
93
|
+
13,
|
|
94
|
+
22,
|
|
95
|
+
18,
|
|
96
|
+
26,
|
|
97
|
+
18,
|
|
98
|
+
24,
|
|
99
|
+
18,
|
|
100
|
+
22,
|
|
101
|
+
20,
|
|
102
|
+
24,
|
|
103
|
+
28,
|
|
104
|
+
26,
|
|
105
|
+
24,
|
|
106
|
+
20,
|
|
107
|
+
30,
|
|
108
|
+
24,
|
|
109
|
+
28,
|
|
110
|
+
28,
|
|
111
|
+
26,
|
|
112
|
+
30,
|
|
113
|
+
28,
|
|
114
|
+
30,
|
|
115
|
+
30,
|
|
116
|
+
30,
|
|
117
|
+
30,
|
|
118
|
+
28,
|
|
119
|
+
30,
|
|
120
|
+
30,
|
|
121
|
+
30,
|
|
122
|
+
30,
|
|
123
|
+
30,
|
|
124
|
+
30,
|
|
125
|
+
30,
|
|
126
|
+
30,
|
|
127
|
+
30,
|
|
128
|
+
30,
|
|
129
|
+
30,
|
|
130
|
+
30,
|
|
131
|
+
30,
|
|
132
|
+
30
|
|
133
|
+
],
|
|
134
|
+
H: [
|
|
135
|
+
17,
|
|
136
|
+
28,
|
|
137
|
+
22,
|
|
138
|
+
16,
|
|
139
|
+
22,
|
|
140
|
+
28,
|
|
141
|
+
26,
|
|
142
|
+
26,
|
|
143
|
+
24,
|
|
144
|
+
28,
|
|
145
|
+
24,
|
|
146
|
+
28,
|
|
147
|
+
22,
|
|
148
|
+
24,
|
|
149
|
+
24,
|
|
150
|
+
30,
|
|
151
|
+
28,
|
|
152
|
+
28,
|
|
153
|
+
26,
|
|
154
|
+
28,
|
|
155
|
+
30,
|
|
156
|
+
24,
|
|
157
|
+
30,
|
|
158
|
+
30,
|
|
159
|
+
30,
|
|
160
|
+
30,
|
|
161
|
+
30,
|
|
162
|
+
30,
|
|
163
|
+
30,
|
|
164
|
+
30,
|
|
165
|
+
30,
|
|
166
|
+
30,
|
|
167
|
+
30,
|
|
168
|
+
30,
|
|
169
|
+
30,
|
|
170
|
+
30,
|
|
171
|
+
30,
|
|
172
|
+
30,
|
|
173
|
+
30,
|
|
174
|
+
30
|
|
175
|
+
]
|
|
176
|
+
}, n = {
|
|
177
|
+
L: [
|
|
178
|
+
1,
|
|
179
|
+
1,
|
|
180
|
+
1,
|
|
181
|
+
1,
|
|
182
|
+
1,
|
|
183
|
+
2,
|
|
184
|
+
2,
|
|
185
|
+
2,
|
|
186
|
+
2,
|
|
187
|
+
4,
|
|
188
|
+
4,
|
|
189
|
+
4,
|
|
190
|
+
4,
|
|
191
|
+
4,
|
|
192
|
+
6,
|
|
193
|
+
6,
|
|
194
|
+
6,
|
|
195
|
+
6,
|
|
196
|
+
7,
|
|
197
|
+
8,
|
|
198
|
+
8,
|
|
199
|
+
9,
|
|
200
|
+
9,
|
|
201
|
+
10,
|
|
202
|
+
12,
|
|
203
|
+
12,
|
|
204
|
+
12,
|
|
205
|
+
13,
|
|
206
|
+
14,
|
|
207
|
+
15,
|
|
208
|
+
16,
|
|
209
|
+
17,
|
|
210
|
+
18,
|
|
211
|
+
19,
|
|
212
|
+
19,
|
|
213
|
+
20,
|
|
214
|
+
21,
|
|
215
|
+
22,
|
|
216
|
+
24,
|
|
217
|
+
25
|
|
218
|
+
],
|
|
219
|
+
M: [
|
|
220
|
+
1,
|
|
221
|
+
1,
|
|
222
|
+
1,
|
|
223
|
+
2,
|
|
224
|
+
2,
|
|
225
|
+
4,
|
|
226
|
+
4,
|
|
227
|
+
4,
|
|
228
|
+
5,
|
|
229
|
+
5,
|
|
230
|
+
5,
|
|
231
|
+
8,
|
|
232
|
+
9,
|
|
233
|
+
9,
|
|
234
|
+
10,
|
|
235
|
+
10,
|
|
236
|
+
11,
|
|
237
|
+
13,
|
|
238
|
+
14,
|
|
239
|
+
16,
|
|
240
|
+
17,
|
|
241
|
+
17,
|
|
242
|
+
18,
|
|
243
|
+
20,
|
|
244
|
+
21,
|
|
245
|
+
23,
|
|
246
|
+
25,
|
|
247
|
+
26,
|
|
248
|
+
28,
|
|
249
|
+
29,
|
|
250
|
+
31,
|
|
251
|
+
33,
|
|
252
|
+
35,
|
|
253
|
+
37,
|
|
254
|
+
38,
|
|
255
|
+
40,
|
|
256
|
+
43,
|
|
257
|
+
45,
|
|
258
|
+
47,
|
|
259
|
+
49
|
|
260
|
+
],
|
|
261
|
+
Q: [
|
|
262
|
+
1,
|
|
263
|
+
1,
|
|
264
|
+
2,
|
|
265
|
+
2,
|
|
266
|
+
4,
|
|
267
|
+
4,
|
|
268
|
+
6,
|
|
269
|
+
6,
|
|
270
|
+
8,
|
|
271
|
+
8,
|
|
272
|
+
8,
|
|
273
|
+
10,
|
|
274
|
+
12,
|
|
275
|
+
16,
|
|
276
|
+
12,
|
|
277
|
+
17,
|
|
278
|
+
16,
|
|
279
|
+
18,
|
|
280
|
+
21,
|
|
281
|
+
20,
|
|
282
|
+
23,
|
|
283
|
+
23,
|
|
284
|
+
25,
|
|
285
|
+
27,
|
|
286
|
+
29,
|
|
287
|
+
34,
|
|
288
|
+
34,
|
|
289
|
+
35,
|
|
290
|
+
38,
|
|
291
|
+
40,
|
|
292
|
+
43,
|
|
293
|
+
45,
|
|
294
|
+
48,
|
|
295
|
+
51,
|
|
296
|
+
53,
|
|
297
|
+
56,
|
|
298
|
+
59,
|
|
299
|
+
62,
|
|
300
|
+
65,
|
|
301
|
+
68
|
|
302
|
+
],
|
|
303
|
+
H: [
|
|
304
|
+
1,
|
|
305
|
+
1,
|
|
306
|
+
2,
|
|
307
|
+
4,
|
|
308
|
+
4,
|
|
309
|
+
4,
|
|
310
|
+
5,
|
|
311
|
+
6,
|
|
312
|
+
8,
|
|
313
|
+
8,
|
|
314
|
+
11,
|
|
315
|
+
11,
|
|
316
|
+
16,
|
|
317
|
+
16,
|
|
318
|
+
18,
|
|
319
|
+
16,
|
|
320
|
+
19,
|
|
321
|
+
21,
|
|
322
|
+
25,
|
|
323
|
+
25,
|
|
324
|
+
25,
|
|
325
|
+
34,
|
|
326
|
+
30,
|
|
327
|
+
32,
|
|
328
|
+
35,
|
|
329
|
+
37,
|
|
330
|
+
40,
|
|
331
|
+
42,
|
|
332
|
+
45,
|
|
333
|
+
48,
|
|
334
|
+
51,
|
|
335
|
+
54,
|
|
336
|
+
57,
|
|
337
|
+
60,
|
|
338
|
+
63,
|
|
339
|
+
66,
|
|
340
|
+
70,
|
|
341
|
+
74,
|
|
342
|
+
77,
|
|
343
|
+
81
|
|
344
|
+
]
|
|
345
|
+
}, r = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
346
|
+
function i(e) {
|
|
347
|
+
let t = (16 * e + 128) * e + 64;
|
|
348
|
+
if (e >= 2) {
|
|
349
|
+
let n = Math.floor(e / 7) + 2;
|
|
350
|
+
t -= (25 * n - 10) * n - 55, e >= 7 && (t -= 36);
|
|
351
|
+
}
|
|
352
|
+
return t;
|
|
353
|
+
}
|
|
354
|
+
function a(e, r) {
|
|
355
|
+
return Math.floor(i(e) / 8) - t[r][e - 1] * n[r][e - 1];
|
|
356
|
+
}
|
|
357
|
+
function o(e) {
|
|
358
|
+
if (e === 1) return [];
|
|
359
|
+
let t = Math.floor(e / 7) + 2, n = e === 32 ? 26 : Math.ceil((e * 4 + 4) / (t * 2 - 2)) * 2, r = [6];
|
|
360
|
+
for (let i = e * 4 + 10; r.length < t; i -= n) r.splice(1, 0, i);
|
|
361
|
+
return r;
|
|
362
|
+
}
|
|
363
|
+
//#endregion
|
|
364
|
+
export { r as ALPHANUMERIC_CHARS, n as ECC_BLOCK_COUNT, t as ECC_CODEWORDS_PER_BLOCK, e as ECC_FORMAT_BITS, o as alignmentPatternPositions, a as dataCodewords, i as rawDataModules };
|
|
365
|
+
|
|
366
|
+
//# sourceMappingURL=qr-tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-tables.js","names":[],"sources":["../../../src/components/QRCode/qr-tables.ts"],"sourcesContent":["/**\n * The fixed tables of ISO/IEC 18004, transcribed.\n *\n * They are data, not logic: the standard specifies them and there is nothing to\n * derive. They live apart from {@link ./qr-encode} so the algorithm reads as\n * algorithm and a typo in a table stays findable.\n */\n\n/** Error correction level, by how much of the symbol it can lose and survive. */\nexport type QRErrorCorrection = \"L\" | \"M\" | \"Q\" | \"H\";\n\nexport const ECC_LEVELS: readonly QRErrorCorrection[] = [\"L\", \"M\", \"Q\", \"H\"];\n\n/** The 2-bit code each level carries in the format information. */\nexport const ECC_FORMAT_BITS: Record<QRErrorCorrection, number> = { L: 1, M: 0, Q: 3, H: 2 };\n\n/**\n * Error-correction codewords per block, indexed `[level][version - 1]`.\n *\n * Together with {@link ECC_BLOCK_COUNT} this fixes how much of each version is\n * data and how much is redundancy.\n */\nexport const ECC_CODEWORDS_PER_BLOCK: Record<QRErrorCorrection, readonly number[]> = {\n L: [\n 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30,\n 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n M: [\n 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28,\n 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n ],\n Q: [\n 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30,\n 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n H: [\n 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30,\n 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n};\n\n/** Number of error-correction blocks, indexed `[level][version - 1]`. */\nexport const ECC_BLOCK_COUNT: Record<QRErrorCorrection, readonly number[]> = {\n L: [\n 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14,\n 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25,\n ],\n M: [\n 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23,\n 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49,\n ],\n Q: [\n 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34,\n 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68,\n ],\n H: [\n 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35,\n 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81,\n ],\n};\n\n/** The alphanumeric mode's 45-character alphabet, in code order. */\nexport const ALPHANUMERIC_CHARS = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:\";\n\n/** Lowest and highest symbol version. */\nexport const MIN_VERSION = 1;\nexport const MAX_VERSION = 40;\n\n/**\n * Total data modules in a symbol, before subtracting error correction.\n *\n * Closed form rather than a 40-row table: the function patterns a version\n * carries are themselves a function of the version, so counting them beats\n * transcribing the totals and hoping.\n *\n * @param version - Symbol version, 1 to 40.\n * @returns The module count available to data and error correction.\n */\nexport function rawDataModules(version: number): number {\n let result = (16 * version + 128) * version + 64;\n if (version >= 2) {\n const alignCount = Math.floor(version / 7) + 2;\n result -= (25 * alignCount - 10) * alignCount - 55;\n if (version >= 7) result -= 36;\n }\n return result;\n}\n\n/**\n * How many data codewords a version holds at a given level.\n *\n * @param version - Symbol version, 1 to 40.\n * @param level - Error correction level.\n * @returns Codewords left for the message itself.\n */\nexport function dataCodewords(version: number, level: QRErrorCorrection): number {\n return (\n Math.floor(rawDataModules(version) / 8) -\n ECC_CODEWORDS_PER_BLOCK[level][version - 1] * ECC_BLOCK_COUNT[level][version - 1]\n );\n}\n\n/**\n * Row/column centres of the alignment patterns for a version.\n *\n * @param version - Symbol version, 1 to 40.\n * @returns Coordinates, ascending. Empty for version 1, which has none.\n */\nexport function alignmentPatternPositions(version: number): number[] {\n if (version === 1) return [];\n const count = Math.floor(version / 7) + 2;\n // Version 32 is the one case the general spacing rule gets wrong.\n const step = version === 32 ? 26 : Math.ceil((version * 4 + 4) / (count * 2 - 2)) * 2;\n const positions = [6];\n for (let pos = version * 4 + 10; positions.length < count; pos -= step) {\n positions.splice(1, 0, pos);\n }\n return positions;\n}\n"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../utils/cn.cjs"),t=require("./ScrollArea.module.cjs");let
|
|
1
|
+
const e=require("../../utils/cn.cjs"),t=require("../../hooks/use-scroll-overflow.cjs"),n=require("./ScrollArea.module.cjs");let r=require("react"),i=require("react/jsx-runtime");var a=(0,r.forwardRef)(function({maxHeight:a,orientation:o=`vertical`,scrollLabel:s=`Área rolável`,className:c,style:l,children:u,...d},f){let p=(0,r.useRef)(null),m=t.useScrollOverflow(p,o),h=(0,r.useCallback)(e=>{p.current=e,typeof f==`function`?f(e):f&&(f.current=e)},[f]),g={overflowX:o===`vertical`?`hidden`:`auto`,overflowY:o===`horizontal`?`hidden`:`auto`,...a===void 0?{}:{maxHeight:a},...l};return(0,i.jsx)(`div`,{ref:h,className:e.cn(n.default.root,c),style:g,tabIndex:m?0:void 0,role:m?`group`:void 0,"aria-label":m?s:void 0,...d,children:u})});exports.ScrollArea=a;
|
|
2
2
|
//# sourceMappingURL=ScrollArea.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollArea.cjs","names":[],"sources":["../../../src/components/ScrollArea/ScrollArea.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { CSSProperties, HTMLAttributes } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./ScrollArea.module.css\";\n\nexport type ScrollAreaOrientation = \"vertical\" | \"horizontal\" | \"both\";\n\nexport interface ScrollAreaProps extends HTMLAttributes<HTMLDivElement> {\n /** Caps the container height; numbers are treated as pixels. */\n maxHeight?: number | string;\n /** Which axis scrolls. Default `\"vertical\"`. */\n orientation?: ScrollAreaOrientation;\n}\n\n/**\n * A styled scroll container that overflows on the chosen axis and renders a\n * thin custom scrollbar (WebKit) while staying fully functional in browsers\n * without scrollbar styling. Forwards `className`, `style` and the ref to the\n * underlying `<div>`.\n */\nexport const ScrollArea = forwardRef<HTMLDivElement, ScrollAreaProps>(function ScrollArea(\n {
|
|
1
|
+
{"version":3,"file":"ScrollArea.cjs","names":[],"sources":["../../../src/components/ScrollArea/ScrollArea.tsx"],"sourcesContent":["import { forwardRef, useCallback, useRef } from \"react\";\nimport type { CSSProperties, HTMLAttributes } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { useScrollOverflow } from \"@/hooks/use-scroll-overflow\";\nimport styles from \"./ScrollArea.module.css\";\n\nexport type ScrollAreaOrientation = \"vertical\" | \"horizontal\" | \"both\";\n\nexport interface ScrollAreaProps extends HTMLAttributes<HTMLDivElement> {\n /** Caps the container height; numbers are treated as pixels. */\n maxHeight?: number | string;\n /** Which axis scrolls. Default `\"vertical\"`. */\n orientation?: ScrollAreaOrientation;\n /**\n * Accessible name used while the content actually overflows, when the area\n * takes a tab stop of its own. Defaults to a generic one; name it when the\n * page holds several scroll areas.\n */\n scrollLabel?: string;\n}\n\n/**\n * A styled scroll container that overflows on the chosen axis and renders a\n * thin custom scrollbar (WebKit) while staying fully functional in browsers\n * without scrollbar styling. Forwards `className`, `style` and the ref to the\n * underlying `<div>`.\n *\n * While the content overflows, the container becomes a named, focusable group.\n * A scroll area whose children are plain text holds nothing focusable, so\n * without that a keyboard user can see the scrollbar and has no way to move it.\n * The tab stop disappears again once the content fits, so an area that does not\n * scroll never adds one. Callers may still override `tabIndex` or `role`.\n */\nexport const ScrollArea = forwardRef<HTMLDivElement, ScrollAreaProps>(function ScrollArea(\n {\n maxHeight,\n orientation = \"vertical\",\n scrollLabel = \"Área rolável\",\n className,\n style,\n children,\n ...props\n },\n ref,\n) {\n const innerRef = useRef<HTMLDivElement>(null);\n const scrollable = useScrollOverflow(innerRef, orientation);\n\n /**\n * Keep the forwarded ref working while measuring internally: the caller's\n * ref is the public contract, the inner one is what the observer needs.\n */\n const setRefs = useCallback(\n (node: HTMLDivElement | null) => {\n innerRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const mergedStyle: CSSProperties = {\n overflowX: orientation === \"vertical\" ? \"hidden\" : \"auto\",\n overflowY: orientation === \"horizontal\" ? \"hidden\" : \"auto\",\n ...(maxHeight !== undefined ? { maxHeight } : {}),\n ...style,\n };\n\n return (\n <div\n ref={setRefs}\n className={cn(styles.root, className)}\n style={mergedStyle}\n tabIndex={scrollable ? 0 : undefined}\n role={scrollable ? \"group\" : undefined}\n aria-label={scrollable ? scrollLabel : undefined}\n {...props}\n >\n {children}\n </div>\n );\n});\n"],"mappings":"kLAiCA,IAAa,GAAA,EAAA,EAAA,WAAA,CAAyD,SAClE,CACI,YACA,cAAc,WACd,cAAc,eACd,YACA,QACA,WACA,GAAG,GAEP,EACF,CACE,IAAM,GAAA,EAAA,EAAA,OAAA,CAAkC,IAAI,EACtC,EAAa,EAAA,kBAAkB,EAAU,CAAW,EAMpD,GAAA,EAAA,EAAA,YAAA,CACD,GAAgC,CAC7B,EAAS,QAAU,EACf,OAAO,GAAQ,WAAY,EAAI,CAAI,EAC9B,IAAK,EAAI,QAAU,EAChC,EACA,CAAC,CAAG,CACR,EAEM,EAA6B,CAC/B,UAAW,IAAgB,WAAa,SAAW,OACnD,UAAW,IAAgB,aAAe,SAAW,OACrD,GAAI,IAAc,IAAA,GAA4B,CAAC,EAAjB,CAAE,WAAU,EAC1C,GAAG,CACP,EAEA,OACI,EAAA,EAAA,IAAA,CAAC,MAAD,CACI,IAAK,EACL,UAAW,EAAA,GAAG,EAAA,QAAO,KAAM,CAAS,EACpC,MAAO,EACP,SAAU,EAAa,EAAI,IAAA,GAC3B,KAAM,EAAa,QAAU,IAAA,GAC7B,aAAY,EAAa,EAAc,IAAA,GACvC,GAAI,EAEH,UACA,CAAA,CAEb,CAAC"}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import { cn as e } from "../../utils/cn.js";
|
|
2
|
-
import t from "
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import { useScrollOverflow as t } from "../../hooks/use-scroll-overflow.js";
|
|
3
|
+
import n from "./ScrollArea.module.js";
|
|
4
|
+
import { forwardRef as r, useCallback as i, useRef as a } from "react";
|
|
5
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
5
6
|
//#region src/components/ScrollArea/ScrollArea.tsx
|
|
6
|
-
var
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
var s = r(function({ maxHeight: r, orientation: s = "vertical", scrollLabel: c = "Área rolável", className: l, style: u, children: d, ...f }, p) {
|
|
8
|
+
let m = a(null), h = t(m, s), g = i((e) => {
|
|
9
|
+
m.current = e, typeof p == "function" ? p(e) : p && (p.current = e);
|
|
10
|
+
}, [p]), _ = {
|
|
11
|
+
overflowX: s === "vertical" ? "hidden" : "auto",
|
|
12
|
+
overflowY: s === "horizontal" ? "hidden" : "auto",
|
|
13
|
+
...r === void 0 ? {} : { maxHeight: r },
|
|
14
|
+
...u
|
|
12
15
|
};
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
-
ref:
|
|
15
|
-
className: e(
|
|
16
|
-
style:
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
return /* @__PURE__ */ o("div", {
|
|
17
|
+
ref: g,
|
|
18
|
+
className: e(n.root, l),
|
|
19
|
+
style: _,
|
|
20
|
+
tabIndex: h ? 0 : void 0,
|
|
21
|
+
role: h ? "group" : void 0,
|
|
22
|
+
"aria-label": h ? c : void 0,
|
|
23
|
+
...f,
|
|
24
|
+
children: d
|
|
19
25
|
});
|
|
20
26
|
});
|
|
21
27
|
//#endregion
|
|
22
|
-
export {
|
|
28
|
+
export { s as ScrollArea };
|
|
23
29
|
|
|
24
30
|
//# sourceMappingURL=ScrollArea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollArea.js","names":[],"sources":["../../../src/components/ScrollArea/ScrollArea.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { CSSProperties, HTMLAttributes } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./ScrollArea.module.css\";\n\nexport type ScrollAreaOrientation = \"vertical\" | \"horizontal\" | \"both\";\n\nexport interface ScrollAreaProps extends HTMLAttributes<HTMLDivElement> {\n /** Caps the container height; numbers are treated as pixels. */\n maxHeight?: number | string;\n /** Which axis scrolls. Default `\"vertical\"`. */\n orientation?: ScrollAreaOrientation;\n}\n\n/**\n * A styled scroll container that overflows on the chosen axis and renders a\n * thin custom scrollbar (WebKit) while staying fully functional in browsers\n * without scrollbar styling. Forwards `className`, `style` and the ref to the\n * underlying `<div>`.\n */\nexport const ScrollArea = forwardRef<HTMLDivElement, ScrollAreaProps>(function ScrollArea(\n {
|
|
1
|
+
{"version":3,"file":"ScrollArea.js","names":[],"sources":["../../../src/components/ScrollArea/ScrollArea.tsx"],"sourcesContent":["import { forwardRef, useCallback, useRef } from \"react\";\nimport type { CSSProperties, HTMLAttributes } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { useScrollOverflow } from \"@/hooks/use-scroll-overflow\";\nimport styles from \"./ScrollArea.module.css\";\n\nexport type ScrollAreaOrientation = \"vertical\" | \"horizontal\" | \"both\";\n\nexport interface ScrollAreaProps extends HTMLAttributes<HTMLDivElement> {\n /** Caps the container height; numbers are treated as pixels. */\n maxHeight?: number | string;\n /** Which axis scrolls. Default `\"vertical\"`. */\n orientation?: ScrollAreaOrientation;\n /**\n * Accessible name used while the content actually overflows, when the area\n * takes a tab stop of its own. Defaults to a generic one; name it when the\n * page holds several scroll areas.\n */\n scrollLabel?: string;\n}\n\n/**\n * A styled scroll container that overflows on the chosen axis and renders a\n * thin custom scrollbar (WebKit) while staying fully functional in browsers\n * without scrollbar styling. Forwards `className`, `style` and the ref to the\n * underlying `<div>`.\n *\n * While the content overflows, the container becomes a named, focusable group.\n * A scroll area whose children are plain text holds nothing focusable, so\n * without that a keyboard user can see the scrollbar and has no way to move it.\n * The tab stop disappears again once the content fits, so an area that does not\n * scroll never adds one. Callers may still override `tabIndex` or `role`.\n */\nexport const ScrollArea = forwardRef<HTMLDivElement, ScrollAreaProps>(function ScrollArea(\n {\n maxHeight,\n orientation = \"vertical\",\n scrollLabel = \"Área rolável\",\n className,\n style,\n children,\n ...props\n },\n ref,\n) {\n const innerRef = useRef<HTMLDivElement>(null);\n const scrollable = useScrollOverflow(innerRef, orientation);\n\n /**\n * Keep the forwarded ref working while measuring internally: the caller's\n * ref is the public contract, the inner one is what the observer needs.\n */\n const setRefs = useCallback(\n (node: HTMLDivElement | null) => {\n innerRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const mergedStyle: CSSProperties = {\n overflowX: orientation === \"vertical\" ? \"hidden\" : \"auto\",\n overflowY: orientation === \"horizontal\" ? \"hidden\" : \"auto\",\n ...(maxHeight !== undefined ? { maxHeight } : {}),\n ...style,\n };\n\n return (\n <div\n ref={setRefs}\n className={cn(styles.root, className)}\n style={mergedStyle}\n tabIndex={scrollable ? 0 : undefined}\n role={scrollable ? \"group\" : undefined}\n aria-label={scrollable ? scrollLabel : undefined}\n {...props}\n >\n {children}\n </div>\n );\n});\n"],"mappings":";;;;;;AAiCA,IAAa,IAAa,EAA4C,SAClE,EACI,cACA,iBAAc,YACd,iBAAc,gBACd,cACA,UACA,aACA,GAAG,KAEP,GACF;CACE,IAAM,IAAW,EAAuB,IAAI,GACtC,IAAa,EAAkB,GAAU,CAAW,GAMpD,IAAU,GACX,MAAgC;EAE7B,AADA,EAAS,UAAU,GACf,OAAO,KAAQ,aAAY,EAAI,CAAI,IAC9B,MAAK,EAAI,UAAU;CAChC,GACA,CAAC,CAAG,CACR,GAEM,IAA6B;EAC/B,WAAW,MAAgB,aAAa,WAAW;EACnD,WAAW,MAAgB,eAAe,WAAW;EACrD,GAAI,MAAc,KAAA,IAA4B,CAAC,IAAjB,EAAE,aAAU;EAC1C,GAAG;CACP;CAEA,OACI,kBAAC,OAAD;EACI,KAAK;EACL,WAAW,EAAG,EAAO,MAAM,CAAS;EACpC,OAAO;EACP,UAAU,IAAa,IAAI,KAAA;EAC3B,MAAM,IAAa,UAAU,KAAA;EAC7B,cAAY,IAAa,IAAc,KAAA;EACvC,GAAI;EAEH;CACA,CAAA;AAEb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollArea.module.cjs","names":[],"sources":["../../../src/components/ScrollArea/ScrollArea.module.css"],"sourcesContent":[".root {\n /* Overflow is set inline per orientation; this only styles the scrollbar.\n Firefox thin scrollbar; degrades gracefully elsewhere. */\n scrollbar-width: thin;\n scrollbar-color: var(--tempest-border) transparent;\n overscroll-behavior: contain;\n}\n\n.root::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n}\n\n.root::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.root::-webkit-scrollbar-thumb {\n background-color: var(--tempest-border);\n border-radius: var(--tempest-radius-full);\n border: 2px solid transparent;\n background-clip: padding-box;\n}\n\n@media (hover: hover) and (pointer: fine) {\n .root::-webkit-scrollbar-thumb:hover {\n background-color: var(--tempest-text-muted);\n }\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ScrollArea.module.cjs","names":[],"sources":["../../../src/components/ScrollArea/ScrollArea.module.css"],"sourcesContent":[".root {\n /* Overflow is set inline per orientation; this only styles the scrollbar.\n Firefox thin scrollbar; degrades gracefully elsewhere. */\n scrollbar-width: thin;\n scrollbar-color: var(--tempest-border) transparent;\n overscroll-behavior: contain;\n}\n\n.root::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n}\n\n.root::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.root::-webkit-scrollbar-thumb {\n background-color: var(--tempest-border);\n border-radius: var(--tempest-radius-full);\n border: 2px solid transparent;\n background-clip: padding-box;\n}\n\n@media (hover: hover) and (pointer: fine) {\n .root::-webkit-scrollbar-thumb:hover {\n background-color: var(--tempest-text-muted);\n }\n}\n\n.root:focus-visible {\n outline: var(--tempest-focus-ring-width) solid var(--tempest-focus-ring-color);\n outline-offset: 2px;\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollArea.module.js","names":[],"sources":["../../../src/components/ScrollArea/ScrollArea.module.css"],"sourcesContent":[".root {\n /* Overflow is set inline per orientation; this only styles the scrollbar.\n Firefox thin scrollbar; degrades gracefully elsewhere. */\n scrollbar-width: thin;\n scrollbar-color: var(--tempest-border) transparent;\n overscroll-behavior: contain;\n}\n\n.root::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n}\n\n.root::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.root::-webkit-scrollbar-thumb {\n background-color: var(--tempest-border);\n border-radius: var(--tempest-radius-full);\n border: 2px solid transparent;\n background-clip: padding-box;\n}\n\n@media (hover: hover) and (pointer: fine) {\n .root::-webkit-scrollbar-thumb:hover {\n background-color: var(--tempest-text-muted);\n }\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ScrollArea.module.js","names":[],"sources":["../../../src/components/ScrollArea/ScrollArea.module.css"],"sourcesContent":[".root {\n /* Overflow is set inline per orientation; this only styles the scrollbar.\n Firefox thin scrollbar; degrades gracefully elsewhere. */\n scrollbar-width: thin;\n scrollbar-color: var(--tempest-border) transparent;\n overscroll-behavior: contain;\n}\n\n.root::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n}\n\n.root::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.root::-webkit-scrollbar-thumb {\n background-color: var(--tempest-border);\n border-radius: var(--tempest-radius-full);\n border: 2px solid transparent;\n background-clip: padding-box;\n}\n\n@media (hover: hover) and (pointer: fine) {\n .root::-webkit-scrollbar-thumb:hover {\n background-color: var(--tempest-text-muted);\n }\n}\n\n.root:focus-visible {\n outline: var(--tempest-focus-ring-width) solid var(--tempest-focus-ring-color);\n outline-offset: 2px;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../utils/cn.cjs"),t=require("./sparkline-geometry.cjs"),n=require("./Sparkline.module.cjs");let r=require("react/jsx-runtime");function i({data:i,width:a=88,height:o=24,variant:s=`line`,color:c=`var(--tempest-chart-1)`,showEnd:l,min:u,max:d,valueFormatter:f,label:p,className:m,...h}){let g=t.sparkPoints({values:i,width:a,height:o,min:u,max:d}),_=p??t.describeSeries(i,f),v=l??s!==`bar`,y=g[g.length-1],b=o-2;return(0,r.jsx)(`span`,{className:e.cn(n.default.wrapper,m),...h,children:(0,r.jsxs)(`svg`,{className:n.default.svg,width:a,height:o,viewBox:`0 0 ${a} ${o}`,role:`img`,"aria-label":_,children:[g.length>0&&s===`area`&&(0,r.jsx)(`path`,{d:t.areaPath(g,b),fill:c,className:n.default.area}),g.length>0&&s!==`bar`&&(0,r.jsx)(`path`,{d:t.linePath(g),fill:`none`,stroke:c,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`}),s===`bar`&&t.barRects(g,{width:a,baselineY:b}).map(e=>(0,r.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:1,fill:c},e.point.index)),v&&y&&(0,r.jsx)(`circle`,{cx:y.x,cy:y.y,r:3,fill:c,stroke:`var(--tempest-bg)`,strokeWidth:2})]})})}exports.Sparkline=i;
|
|
2
|
+
//# sourceMappingURL=Sparkline.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sparkline.cjs","names":[],"sources":["../../../src/components/Sparkline/Sparkline.tsx"],"sourcesContent":["import type { HTMLAttributes } from \"react\";\n\nimport { cn } from \"@/utils/cn\";\n\nimport { areaPath, barRects, describeSeries, linePath, sparkPoints } from \"./sparkline-geometry\";\nimport styles from \"./Sparkline.module.css\";\n\nexport type SparklineVariant = \"line\" | \"area\" | \"bar\";\n\nexport interface SparklineProps extends Omit<HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** The series, in order. Non-finite entries are skipped. */\n data: readonly number[];\n /** Drawing width in px. Default `88`. */\n width?: number;\n /** Drawing height in px. Default `24`. */\n height?: number;\n /** Which mark to draw. Default `\"line\"`. */\n variant?: SparklineVariant;\n /** Any CSS colour. Defaults to the first chart series token. */\n color?: string;\n /** Draw a dot on the last point. Default `true` for line and area. */\n showEnd?: boolean;\n /** Force the low end of the value axis — use it to compare several sparklines. */\n min?: number;\n /** Force the high end. */\n max?: number;\n /** Render a value; used in the accessible description. */\n valueFormatter?: (value: number) => string;\n /**\n * Accessible name. Defaults to a sentence describing the series.\n *\n * Pass one when the surrounding text already says what is plotted — the default\n * still appends the shape, so a caller never ends up with an unlabelled image.\n */\n label?: string;\n}\n\n/**\n * A tiny inline chart: shape only, no axes, no legend.\n *\n * Sized to sit in a table cell or beside a number, which is why it is plain SVG on\n * the root entry rather than a recharts wrapper — a sparkline in a data table should\n * not oblige an app to install a charting library.\n *\n * It carries `role=\"img\"` and a spoken description of the series (direction, ends,\n * extremes). Without that it is an unlabelled image: a sparkline has no axis or\n * legend to fall back on, so a screen reader would reach it and read nothing. Pair it\n * with the number it annotates — the shape is context, never the only way to read the\n * value.\n *\n * @example\n * <Sparkline data={last30Days} />\n * <Sparkline data={revenue} variant=\"area\" width={120} height={32} />\n *\n * // Same axis across a column, so the rows are comparable\n * <Sparkline data={row.series} min={0} max={columnMax} />\n */\nexport function Sparkline({\n data,\n width = 88,\n height = 24,\n variant = \"line\",\n color = \"var(--tempest-chart-1)\",\n showEnd,\n min,\n max,\n valueFormatter,\n label,\n className,\n ...rest\n}: SparklineProps) {\n const points = sparkPoints({ values: data, width, height, min, max });\n const description = label ?? describeSeries(data, valueFormatter);\n const withEnd = showEnd ?? variant !== \"bar\";\n const last = points[points.length - 1];\n\n /*\n * Bars grow from the bottom of the box; line and area close against it. Both use\n * the same edge so a sparkline swapped between variants keeps its footprint.\n */\n const baselineY = height - 2;\n\n return (\n <span className={cn(styles.wrapper, className)} {...rest}>\n <svg\n className={styles.svg}\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n role=\"img\"\n aria-label={description}\n >\n {points.length > 0 && variant === \"area\" && (\n <path d={areaPath(points, baselineY)} fill={color} className={styles.area} />\n )}\n\n {points.length > 0 && variant !== \"bar\" && (\n <path\n d={linePath(points)}\n fill=\"none\"\n stroke={color}\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n )}\n\n {variant === \"bar\" &&\n barRects(points, { width, baselineY }).map((rect) => (\n <rect\n key={rect.point.index}\n x={rect.x}\n y={rect.y}\n width={rect.width}\n height={rect.height}\n rx={1}\n fill={color}\n />\n ))}\n\n {withEnd && last && (\n /*\n * The ring is drawn in the surface colour rather than as a stroke on\n * the dot: it keeps the marker legible where it sits on top of the\n * line without adding ink that is not data.\n */\n <circle\n cx={last.x}\n cy={last.y}\n r={3}\n fill={color}\n stroke=\"var(--tempest-bg)\"\n strokeWidth={2}\n />\n )}\n </svg>\n </span>\n );\n}\n"],"mappings":"mJAyDA,SAAgB,EAAU,CACtB,OACA,QAAQ,GACR,SAAS,GACT,UAAU,OACV,QAAQ,yBACR,UACA,MACA,MACA,iBACA,QACA,YACA,GAAG,GACY,CACf,IAAM,EAAS,EAAA,YAAY,CAAE,OAAQ,EAAM,QAAO,SAAQ,MAAK,KAAI,CAAC,EAC9D,EAAc,GAAS,EAAA,eAAe,EAAM,CAAc,EAC1D,EAAU,GAAW,IAAY,MACjC,EAAO,EAAO,EAAO,OAAS,GAM9B,EAAY,EAAS,EAE3B,OACI,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,GAAG,EAAA,QAAO,QAAS,CAAS,EAAG,GAAI,YAChD,EAAA,EAAA,KAAA,CAAC,MAAD,CACI,UAAW,EAAA,QAAO,IACX,QACC,SACR,QAAS,OAAO,EAAM,GAAG,IACzB,KAAK,MACL,aAAY,WANhB,CAQK,EAAO,OAAS,GAAK,IAAY,SAC9B,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,EAAG,EAAA,SAAS,EAAQ,CAAS,EAAG,KAAM,EAAO,UAAW,EAAA,QAAO,IAAO,CAAA,EAG/E,EAAO,OAAS,GAAK,IAAY,QAC9B,EAAA,EAAA,IAAA,CAAC,OAAD,CACI,EAAG,EAAA,SAAS,CAAM,EAClB,KAAK,OACL,OAAQ,EACR,YAAa,EACb,cAAc,QACd,eAAe,OAClB,CAAA,EAGJ,IAAY,OACT,EAAA,SAAS,EAAQ,CAAE,QAAO,WAAU,CAAC,CAAC,CAAC,IAAK,IACxC,EAAA,EAAA,IAAA,CAAC,OAAD,CAEI,EAAG,EAAK,EACR,EAAG,EAAK,EACR,MAAO,EAAK,MACZ,OAAQ,EAAK,OACb,GAAI,EACJ,KAAM,CACT,EAPQ,EAAK,MAAM,KAOnB,CACJ,EAEJ,GAAW,IAMR,EAAA,EAAA,IAAA,CAAC,SAAD,CACI,GAAI,EAAK,EACT,GAAI,EAAK,EACT,EAAG,EACH,KAAM,EACN,OAAO,oBACP,YAAa,CAChB,CAAA,CAEJ,GACH,CAAA,CAEd"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { cn as e } from "../../utils/cn.js";
|
|
2
|
+
import { areaPath as t, barRects as n, describeSeries as r, linePath as i, sparkPoints as a } from "./sparkline-geometry.js";
|
|
3
|
+
import o from "./Sparkline.module.js";
|
|
4
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Sparkline/Sparkline.tsx
|
|
6
|
+
function l({ data: l, width: u = 88, height: d = 24, variant: f = "line", color: p = "var(--tempest-chart-1)", showEnd: m, min: h, max: g, valueFormatter: _, label: v, className: y, ...b }) {
|
|
7
|
+
let x = a({
|
|
8
|
+
values: l,
|
|
9
|
+
width: u,
|
|
10
|
+
height: d,
|
|
11
|
+
min: h,
|
|
12
|
+
max: g
|
|
13
|
+
}), S = v ?? r(l, _), C = m ?? f !== "bar", w = x[x.length - 1], T = d - 2;
|
|
14
|
+
return /* @__PURE__ */ s("span", {
|
|
15
|
+
className: e(o.wrapper, y),
|
|
16
|
+
...b,
|
|
17
|
+
children: /* @__PURE__ */ c("svg", {
|
|
18
|
+
className: o.svg,
|
|
19
|
+
width: u,
|
|
20
|
+
height: d,
|
|
21
|
+
viewBox: `0 0 ${u} ${d}`,
|
|
22
|
+
role: "img",
|
|
23
|
+
"aria-label": S,
|
|
24
|
+
children: [
|
|
25
|
+
x.length > 0 && f === "area" && /* @__PURE__ */ s("path", {
|
|
26
|
+
d: t(x, T),
|
|
27
|
+
fill: p,
|
|
28
|
+
className: o.area
|
|
29
|
+
}),
|
|
30
|
+
x.length > 0 && f !== "bar" && /* @__PURE__ */ s("path", {
|
|
31
|
+
d: i(x),
|
|
32
|
+
fill: "none",
|
|
33
|
+
stroke: p,
|
|
34
|
+
strokeWidth: 2,
|
|
35
|
+
strokeLinecap: "round",
|
|
36
|
+
strokeLinejoin: "round"
|
|
37
|
+
}),
|
|
38
|
+
f === "bar" && n(x, {
|
|
39
|
+
width: u,
|
|
40
|
+
baselineY: T
|
|
41
|
+
}).map((e) => /* @__PURE__ */ s("rect", {
|
|
42
|
+
x: e.x,
|
|
43
|
+
y: e.y,
|
|
44
|
+
width: e.width,
|
|
45
|
+
height: e.height,
|
|
46
|
+
rx: 1,
|
|
47
|
+
fill: p
|
|
48
|
+
}, e.point.index)),
|
|
49
|
+
C && w && /* @__PURE__ */ s("circle", {
|
|
50
|
+
cx: w.x,
|
|
51
|
+
cy: w.y,
|
|
52
|
+
r: 3,
|
|
53
|
+
fill: p,
|
|
54
|
+
stroke: "var(--tempest-bg)",
|
|
55
|
+
strokeWidth: 2
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { l as Sparkline };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=Sparkline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sparkline.js","names":[],"sources":["../../../src/components/Sparkline/Sparkline.tsx"],"sourcesContent":["import type { HTMLAttributes } from \"react\";\n\nimport { cn } from \"@/utils/cn\";\n\nimport { areaPath, barRects, describeSeries, linePath, sparkPoints } from \"./sparkline-geometry\";\nimport styles from \"./Sparkline.module.css\";\n\nexport type SparklineVariant = \"line\" | \"area\" | \"bar\";\n\nexport interface SparklineProps extends Omit<HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** The series, in order. Non-finite entries are skipped. */\n data: readonly number[];\n /** Drawing width in px. Default `88`. */\n width?: number;\n /** Drawing height in px. Default `24`. */\n height?: number;\n /** Which mark to draw. Default `\"line\"`. */\n variant?: SparklineVariant;\n /** Any CSS colour. Defaults to the first chart series token. */\n color?: string;\n /** Draw a dot on the last point. Default `true` for line and area. */\n showEnd?: boolean;\n /** Force the low end of the value axis — use it to compare several sparklines. */\n min?: number;\n /** Force the high end. */\n max?: number;\n /** Render a value; used in the accessible description. */\n valueFormatter?: (value: number) => string;\n /**\n * Accessible name. Defaults to a sentence describing the series.\n *\n * Pass one when the surrounding text already says what is plotted — the default\n * still appends the shape, so a caller never ends up with an unlabelled image.\n */\n label?: string;\n}\n\n/**\n * A tiny inline chart: shape only, no axes, no legend.\n *\n * Sized to sit in a table cell or beside a number, which is why it is plain SVG on\n * the root entry rather than a recharts wrapper — a sparkline in a data table should\n * not oblige an app to install a charting library.\n *\n * It carries `role=\"img\"` and a spoken description of the series (direction, ends,\n * extremes). Without that it is an unlabelled image: a sparkline has no axis or\n * legend to fall back on, so a screen reader would reach it and read nothing. Pair it\n * with the number it annotates — the shape is context, never the only way to read the\n * value.\n *\n * @example\n * <Sparkline data={last30Days} />\n * <Sparkline data={revenue} variant=\"area\" width={120} height={32} />\n *\n * // Same axis across a column, so the rows are comparable\n * <Sparkline data={row.series} min={0} max={columnMax} />\n */\nexport function Sparkline({\n data,\n width = 88,\n height = 24,\n variant = \"line\",\n color = \"var(--tempest-chart-1)\",\n showEnd,\n min,\n max,\n valueFormatter,\n label,\n className,\n ...rest\n}: SparklineProps) {\n const points = sparkPoints({ values: data, width, height, min, max });\n const description = label ?? describeSeries(data, valueFormatter);\n const withEnd = showEnd ?? variant !== \"bar\";\n const last = points[points.length - 1];\n\n /*\n * Bars grow from the bottom of the box; line and area close against it. Both use\n * the same edge so a sparkline swapped between variants keeps its footprint.\n */\n const baselineY = height - 2;\n\n return (\n <span className={cn(styles.wrapper, className)} {...rest}>\n <svg\n className={styles.svg}\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n role=\"img\"\n aria-label={description}\n >\n {points.length > 0 && variant === \"area\" && (\n <path d={areaPath(points, baselineY)} fill={color} className={styles.area} />\n )}\n\n {points.length > 0 && variant !== \"bar\" && (\n <path\n d={linePath(points)}\n fill=\"none\"\n stroke={color}\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n )}\n\n {variant === \"bar\" &&\n barRects(points, { width, baselineY }).map((rect) => (\n <rect\n key={rect.point.index}\n x={rect.x}\n y={rect.y}\n width={rect.width}\n height={rect.height}\n rx={1}\n fill={color}\n />\n ))}\n\n {withEnd && last && (\n /*\n * The ring is drawn in the surface colour rather than as a stroke on\n * the dot: it keeps the marker legible where it sits on top of the\n * line without adding ink that is not data.\n */\n <circle\n cx={last.x}\n cy={last.y}\n r={3}\n fill={color}\n stroke=\"var(--tempest-bg)\"\n strokeWidth={2}\n />\n )}\n </svg>\n </span>\n );\n}\n"],"mappings":";;;;;AAyDA,SAAgB,EAAU,EACtB,SACA,WAAQ,IACR,YAAS,IACT,aAAU,QACV,WAAQ,0BACR,YACA,QACA,QACA,mBACA,UACA,cACA,GAAG,KACY;CACf,IAAM,IAAS,EAAY;EAAE,QAAQ;EAAM;EAAO;EAAQ;EAAK;CAAI,CAAC,GAC9D,IAAc,KAAS,EAAe,GAAM,CAAc,GAC1D,IAAU,KAAW,MAAY,OACjC,IAAO,EAAO,EAAO,SAAS,IAM9B,IAAY,IAAS;CAE3B,OACI,kBAAC,QAAD;EAAM,WAAW,EAAG,EAAO,SAAS,CAAS;EAAG,GAAI;YAChD,kBAAC,OAAD;GACI,WAAW,EAAO;GACX;GACC;GACR,SAAS,OAAO,EAAM,GAAG;GACzB,MAAK;GACL,cAAY;aANhB;IAQK,EAAO,SAAS,KAAK,MAAY,UAC9B,kBAAC,QAAD;KAAM,GAAG,EAAS,GAAQ,CAAS;KAAG,MAAM;KAAO,WAAW,EAAO;IAAO,CAAA;IAG/E,EAAO,SAAS,KAAK,MAAY,SAC9B,kBAAC,QAAD;KACI,GAAG,EAAS,CAAM;KAClB,MAAK;KACL,QAAQ;KACR,aAAa;KACb,eAAc;KACd,gBAAe;IAClB,CAAA;IAGJ,MAAY,SACT,EAAS,GAAQ;KAAE;KAAO;IAAU,CAAC,CAAC,CAAC,KAAK,MACxC,kBAAC,QAAD;KAEI,GAAG,EAAK;KACR,GAAG,EAAK;KACR,OAAO,EAAK;KACZ,QAAQ,EAAK;KACb,IAAI;KACJ,MAAM;IACT,GAPQ,EAAK,MAAM,KAOnB,CACJ;IAEJ,KAAW,KAMR,kBAAC,UAAD;KACI,IAAI,EAAK;KACT,IAAI,EAAK;KACT,GAAG;KACH,MAAM;KACN,QAAO;KACP,aAAa;IAChB,CAAA;GAEJ;;CACH,CAAA;AAEd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sparkline.module.cjs","names":[],"sources":["../../../src/components/Sparkline/Sparkline.module.css"],"sourcesContent":[".wrapper {\n display: inline-flex;\n align-items: center;\n /*\n * `middle` rather than the inline default: a sparkline sits beside a number, and\n * a baseline-aligned SVG hangs low enough to look like it fell off the line.\n */\n vertical-align: middle;\n line-height: 0;\n}\n\n.svg {\n display: block;\n overflow: visible;\n}\n\n/*\n * A wash, never a saturated block — the fill is context for the line, and at full\n * strength it competes with the mark that actually carries the data.\n */\n.area {\n opacity: 0.12;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/components/Sparkline/Sparkline.module.css
|
|
2
|
+
var e = "tempest_wrapper_f24dA", t = "tempest_svg_mpG9R", n = "tempest_area_-kPmZ", r = {
|
|
3
|
+
wrapper: e,
|
|
4
|
+
svg: t,
|
|
5
|
+
area: n
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { n as area, r as default, t as svg, e as wrapper };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=Sparkline.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sparkline.module.js","names":[],"sources":["../../../src/components/Sparkline/Sparkline.module.css"],"sourcesContent":[".wrapper {\n display: inline-flex;\n align-items: center;\n /*\n * `middle` rather than the inline default: a sparkline sits beside a number, and\n * a baseline-aligned SVG hangs low enough to look like it fell off the line.\n */\n vertical-align: middle;\n line-height: 0;\n}\n\n.svg {\n display: block;\n overflow: visible;\n}\n\n/*\n * A wash, never a saturated block — the fill is context for the line, and at full\n * strength it competes with the mark that actually carries the data.\n */\n.area {\n opacity: 0.12;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e({values:e,width:t,height:n,padding:r=2,min:i,max:a}){let o=e.map((e,t)=>({value:e,index:t})).filter(e=>Number.isFinite(e.value));if(o.length===0||t<=0||n<=0)return[];let s=o.map(e=>e.value),c=i??Math.min(...s),l=(a??Math.max(...s))-c,u=Math.max(0,t-r*2),d=Math.max(0,n-r*2),f=o.length-1;return o.map((e,t)=>{let n=f===0?.5:t/f,i=l===0?.5:(e.value-c)/l;return{x:r+n*u,y:r+(1-Math.min(1,Math.max(0,i)))*d,value:e.value,index:e.index}})}function t(e){if(e.length===0)return``;if(e.length===1){let[t]=e;return`M ${t.x} ${t.y} L ${t.x} ${t.y}`}return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}function n(e,t){if(e.length===0)return``;let n=e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `),r=e[0];return`${n} L ${e[e.length-1].x} ${t} L ${r.x} ${t} Z`}function r(e,{width:t,baselineY:n,gap:r=2}){if(e.length===0)return[];let i=t/e.length,a=Math.max(1,Math.min(24,i-r));return e.map(e=>{let t=Math.max(1,Math.abs(n-e.y));return{x:e.x-a/2,y:Math.min(e.y,n-t),width:a,height:t,point:e}})}function i(e,t=String){let n=e.filter(e=>Number.isFinite(e));if(n.length===0)return`Sem dados`;if(n.length===1)return`Valor único: ${t(n[0])}`;let r=n[0],i=n[n.length-1],a=i>r?`subindo`:i<r?`descendo`:`estável`;return`${n.length} pontos, ${a}. Início ${t(r)}, fim ${t(i)}. Mínimo ${t(Math.min(...n))}, máximo ${t(Math.max(...n))}.`}exports.areaPath=n,exports.barRects=r,exports.describeSeries=i,exports.linePath=t,exports.sparkPoints=e;
|
|
2
|
+
//# sourceMappingURL=sparkline-geometry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sparkline-geometry.cjs","names":[],"sources":["../../../src/components/Sparkline/sparkline-geometry.ts"],"sourcesContent":["/** A point in the sparkline's own coordinate space. */\nexport interface SparkPoint {\n x: number;\n y: number;\n /** The datum this point came from. */\n value: number;\n /** Its position in the input series. */\n index: number;\n}\n\nexport interface SparkGeometryOptions {\n values: readonly number[];\n width: number;\n height: number;\n /** Room reserved on every side for the end marker's ring, so it is never clipped. */\n padding?: number;\n /** Force the low end of the value axis. Defaults to the series minimum. */\n min?: number;\n /** Force the high end. Defaults to the series maximum. */\n max?: number;\n}\n\n/**\n * Project a series onto the drawing box.\n *\n * `y` is inverted — SVG grows downward and a chart grows upward — and a flat series\n * is centred rather than pinned to an edge, which is the honest reading of \"no\n * variation\" and avoids dividing by a zero-height domain.\n *\n * Non-finite values are dropped rather than drawn: a `NaN` in the middle of a path\n * silently voids the whole `d` attribute and the sparkline disappears with no error.\n *\n * @param options - The series and the box to fit it in.\n * @returns The projected points, in input order.\n */\nexport function sparkPoints({\n values,\n width,\n height,\n padding = 2,\n min,\n max,\n}: SparkGeometryOptions): SparkPoint[] {\n const usable = values\n .map((value, index) => ({ value, index }))\n .filter((item) => Number.isFinite(item.value));\n if (usable.length === 0 || width <= 0 || height <= 0) return [];\n\n const numbers = usable.map((item) => item.value);\n const lo = min ?? Math.min(...numbers);\n const hi = max ?? Math.max(...numbers);\n const span = hi - lo;\n\n const innerW = Math.max(0, width - padding * 2);\n const innerH = Math.max(0, height - padding * 2);\n const lastIndex = usable.length - 1;\n\n return usable.map((item, i) => {\n const t = lastIndex === 0 ? 0.5 : i / lastIndex;\n const v = span === 0 ? 0.5 : (item.value - lo) / span;\n return {\n x: padding + t * innerW,\n y: padding + (1 - Math.min(1, Math.max(0, v))) * innerH,\n value: item.value,\n index: item.index,\n };\n });\n}\n\n/** An SVG `d` for a polyline through the points. */\nexport function linePath(points: readonly SparkPoint[]): string {\n if (points.length === 0) return \"\";\n if (points.length === 1) {\n // A lone point has no line; emit a zero-length segment so the round cap\n // still paints a dot rather than nothing at all.\n const [only] = points;\n return `M ${only.x} ${only.y} L ${only.x} ${only.y}`;\n }\n return points.map((p, i) => `${i === 0 ? \"M\" : \"L\"} ${p.x} ${p.y}`).join(\" \");\n}\n\n/**\n * An SVG `d` for the area under the line, closed along the baseline.\n *\n * @param points - The projected points.\n * @param baselineY - Where the fill closes, in the same space as the points.\n */\nexport function areaPath(points: readonly SparkPoint[], baselineY: number): string {\n if (points.length === 0) return \"\";\n const line = points.map((p, i) => `${i === 0 ? \"M\" : \"L\"} ${p.x} ${p.y}`).join(\" \");\n const first = points[0];\n const last = points[points.length - 1];\n return `${line} L ${last.x} ${baselineY} L ${first.x} ${baselineY} Z`;\n}\n\n/** Bar rectangles growing from the baseline, with the band's leftover left as air. */\nexport function barRects(\n points: readonly SparkPoint[],\n { width, baselineY, gap = 2 }: { width: number; baselineY: number; gap?: number },\n): { x: number; y: number; width: number; height: number; point: SparkPoint }[] {\n if (points.length === 0) return [];\n const band = width / points.length;\n // Never fill the slot: the gap between bars is what separates them, not a stroke.\n const barWidth = Math.max(1, Math.min(24, band - gap));\n return points.map((point) => {\n /*\n * The minimum value sits on the baseline, where the raw height is 0. It still\n * needs a visible sliver — but growing *up* from the baseline, not down: the\n * naive `Math.max(1, …)` on height alone leaves the bar hanging one pixel\n * below the axis it is supposed to stand on.\n */\n const height = Math.max(1, Math.abs(baselineY - point.y));\n return {\n x: point.x - barWidth / 2,\n y: Math.min(point.y, baselineY - height),\n width: barWidth,\n height,\n point,\n };\n });\n}\n\n/**\n * A one-sentence description of the series, for the chart's accessible name.\n *\n * A sparkline has no axes and no legend, so without this it is an unlabelled image:\n * a screen reader reaches it and reads nothing. Direction is stated in words rather\n * than implied by the shape.\n *\n * @param values - The series, in order.\n * @param format - How to render a single value.\n * @returns Text suitable for `aria-label`.\n */\nexport function describeSeries(\n values: readonly number[],\n format: (value: number) => string = String,\n): string {\n const usable = values.filter((v) => Number.isFinite(v));\n if (usable.length === 0) return \"Sem dados\";\n if (usable.length === 1) return `Valor único: ${format(usable[0])}`;\n\n const first = usable[0];\n const last = usable[usable.length - 1];\n const direction = last > first ? \"subindo\" : last < first ? \"descendo\" : \"estável\";\n return (\n `${usable.length} pontos, ${direction}. ` +\n `Início ${format(first)}, fim ${format(last)}. ` +\n `Mínimo ${format(Math.min(...usable))}, máximo ${format(Math.max(...usable))}.`\n );\n}\n"],"mappings":"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"}
|