panelui-native 0.44.0 → 0.46.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 +2 -1
- package/lib/module/components/combobox/index.js +7 -1
- package/lib/module/components/combobox/index.js.map +1 -1
- package/lib/module/components/date-time-picker/index.js +254 -0
- package/lib/module/components/date-time-picker/index.js.map +1 -0
- package/lib/module/components/grid-item/index.js +486 -0
- package/lib/module/components/grid-item/index.js.map +1 -0
- package/lib/module/components/{kpi-chart → kpi}/index.js +62 -62
- package/lib/module/components/kpi/index.js.map +1 -0
- package/lib/module/components/line-chart/index.js +92 -10
- package/lib/module/components/line-chart/index.js.map +1 -1
- package/lib/module/components/pie-chart/index.js +625 -0
- package/lib/module/components/pie-chart/index.js.map +1 -0
- package/lib/module/components/scatter-chart/index.js +1173 -0
- package/lib/module/components/scatter-chart/index.js.map +1 -0
- package/lib/module/components/tabs/index.js +275 -33
- package/lib/module/components/tabs/index.js.map +1 -1
- package/lib/module/index.js +5 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/chart.js +81 -0
- package/lib/module/utils/chart.js.map +1 -1
- package/lib/typescript/src/components/combobox/index.d.ts.map +1 -1
- package/lib/typescript/src/components/date-time-picker/index.d.ts +121 -0
- package/lib/typescript/src/components/date-time-picker/index.d.ts.map +1 -0
- package/lib/typescript/src/components/grid-item/index.d.ts +292 -0
- package/lib/typescript/src/components/grid-item/index.d.ts.map +1 -0
- package/lib/typescript/src/components/{kpi-chart → kpi}/index.d.ts +65 -65
- package/lib/typescript/src/components/kpi/index.d.ts.map +1 -0
- package/lib/typescript/src/components/line-chart/index.d.ts +25 -1
- package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/pie-chart/index.d.ts +245 -0
- package/lib/typescript/src/components/pie-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/scatter-chart/index.d.ts +309 -0
- package/lib/typescript/src/components/scatter-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/tabs/index.d.ts +20 -2
- package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/chart.d.ts +34 -0
- package/lib/typescript/src/utils/chart.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/combobox/index.tsx +7 -1
- package/src/components/date-time-picker/index.tsx +375 -0
- package/src/components/grid-item/index.tsx +515 -0
- package/src/components/{kpi-chart → kpi}/index.tsx +85 -85
- package/src/components/line-chart/index.tsx +98 -8
- package/src/components/pie-chart/index.tsx +863 -0
- package/src/components/scatter-chart/index.tsx +1401 -0
- package/src/components/tabs/index.tsx +305 -35
- package/src/index.ts +65 -17
- package/src/utils/chart.ts +110 -0
- package/lib/module/components/kpi-chart/index.js.map +0 -1
- package/lib/typescript/src/components/kpi-chart/index.d.ts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Kpi — one number, and what it is doing.
|
|
3
3
|
*
|
|
4
4
|
* A metric card is not a chart with a caption. The number is the message and
|
|
5
5
|
* the chart is the footnote, so the parts here are sized and ordered around
|
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
* because nobody is reading values off it.
|
|
9
9
|
*
|
|
10
10
|
* ```tsx
|
|
11
|
-
* <
|
|
12
|
-
* <
|
|
13
|
-
* <
|
|
14
|
-
* </
|
|
15
|
-
* <
|
|
16
|
-
* <
|
|
17
|
-
* <
|
|
18
|
-
* </
|
|
19
|
-
* <
|
|
20
|
-
* </
|
|
11
|
+
* <Kpi>
|
|
12
|
+
* <Kpi.Header>
|
|
13
|
+
* <Kpi.Title>Active users</Kpi.Title>
|
|
14
|
+
* </Kpi.Header>
|
|
15
|
+
* <Kpi.Content>
|
|
16
|
+
* <Kpi.Value>12,480</Kpi.Value>
|
|
17
|
+
* <Kpi.Trend value={12.4} />
|
|
18
|
+
* </Kpi.Content>
|
|
19
|
+
* <Kpi.Chart data={week} dataKey="v" />
|
|
20
|
+
* </Kpi>
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
23
|
* The trend is given a number rather than a written string, so the component
|
|
@@ -244,7 +244,7 @@ type KpiVariantProps = VariantProps<typeof kpiVariants>;
|
|
|
244
244
|
export type KpiTone = NonNullable<KpiVariantProps['tone']>;
|
|
245
245
|
/** Which direction of movement is the good news for this metric. */
|
|
246
246
|
export type KpiGoodDirection = 'up' | 'down' | 'none';
|
|
247
|
-
export interface
|
|
247
|
+
export interface KpiProps extends Omit<ViewProps, 'children'> {
|
|
248
248
|
className?: string;
|
|
249
249
|
/**
|
|
250
250
|
* Which `--color-chart-*` token the sparkline and the icon take. Set on the
|
|
@@ -262,16 +262,16 @@ export interface KpiChartProps extends Omit<ViewProps, 'children'> {
|
|
|
262
262
|
surface?: boolean;
|
|
263
263
|
children: ReactNode;
|
|
264
264
|
}
|
|
265
|
-
export interface
|
|
265
|
+
export interface KpiHeaderProps extends ViewProps {
|
|
266
266
|
className?: string;
|
|
267
267
|
children: ReactNode;
|
|
268
268
|
}
|
|
269
269
|
/** The top row: an icon, the metric's name, and anything acting on it. */
|
|
270
|
-
declare function
|
|
271
|
-
declare namespace
|
|
270
|
+
declare function KpiHeader({ className, children, ...props }: KpiHeaderProps): import("react").JSX.Element;
|
|
271
|
+
declare namespace KpiHeader {
|
|
272
272
|
var displayName: string;
|
|
273
273
|
}
|
|
274
|
-
export interface
|
|
274
|
+
export interface KpiIconProps extends ViewProps {
|
|
275
275
|
className?: string;
|
|
276
276
|
/** Overrides the tint the card's `colorIndex` would give it. */
|
|
277
277
|
tone?: KpiTone;
|
|
@@ -284,20 +284,20 @@ export interface KpiChartIconProps extends ViewProps {
|
|
|
284
284
|
* from whatever set the app already uses — and an icon from outside this
|
|
285
285
|
* library will not read an ambient colour, so pass it one.
|
|
286
286
|
*/
|
|
287
|
-
declare function
|
|
288
|
-
declare namespace
|
|
287
|
+
declare function KpiIcon({ className, tone, children, ...props }: KpiIconProps): import("react").JSX.Element;
|
|
288
|
+
declare namespace KpiIcon {
|
|
289
289
|
var displayName: string;
|
|
290
290
|
}
|
|
291
|
-
export interface
|
|
291
|
+
export interface KpiTitleProps {
|
|
292
292
|
className?: string;
|
|
293
293
|
children: ReactNode;
|
|
294
294
|
}
|
|
295
295
|
/** The metric's name. Quiet on purpose — the value is the thing being read. */
|
|
296
|
-
declare function
|
|
297
|
-
declare namespace
|
|
296
|
+
declare function KpiTitle({ className, children }: KpiTitleProps): import("react").JSX.Element;
|
|
297
|
+
declare namespace KpiTitle {
|
|
298
298
|
var displayName: string;
|
|
299
299
|
}
|
|
300
|
-
export interface
|
|
300
|
+
export interface KpiStatProps extends ViewProps {
|
|
301
301
|
className?: string;
|
|
302
302
|
children: ReactNode;
|
|
303
303
|
}
|
|
@@ -310,31 +310,31 @@ export interface KpiChartStatProps extends ViewProps {
|
|
|
310
310
|
* between facts. It also takes the width in an `inline` row, leaving the chart
|
|
311
311
|
* its column on the end.
|
|
312
312
|
*/
|
|
313
|
-
declare function
|
|
314
|
-
declare namespace
|
|
313
|
+
declare function KpiStat({ className, children, ...props }: KpiStatProps): import("react").JSX.Element;
|
|
314
|
+
declare namespace KpiStat {
|
|
315
315
|
var displayName: string;
|
|
316
316
|
}
|
|
317
|
-
export interface
|
|
317
|
+
export interface KpiActionsProps extends ViewProps {
|
|
318
318
|
className?: string;
|
|
319
319
|
children: ReactNode;
|
|
320
320
|
}
|
|
321
321
|
/** The trailing end of the header — a menu trigger, a filter, a link. */
|
|
322
|
-
declare function
|
|
323
|
-
declare namespace
|
|
322
|
+
declare function KpiActions({ className, children, ...props }: KpiActionsProps): import("react").JSX.Element;
|
|
323
|
+
declare namespace KpiActions {
|
|
324
324
|
var displayName: string;
|
|
325
325
|
}
|
|
326
|
-
export interface
|
|
326
|
+
export interface KpiContentProps extends ViewProps {
|
|
327
327
|
className?: string;
|
|
328
328
|
/** `inline` puts the chart beside the value instead of under everything. */
|
|
329
329
|
layout?: NonNullable<KpiVariantProps['layout']>;
|
|
330
330
|
children: ReactNode;
|
|
331
331
|
}
|
|
332
332
|
/** The row the value and the trend share. */
|
|
333
|
-
declare function
|
|
334
|
-
declare namespace
|
|
333
|
+
declare function KpiContent({ className, layout, children, ...props }: KpiContentProps): import("react").JSX.Element;
|
|
334
|
+
declare namespace KpiContent {
|
|
335
335
|
var displayName: string;
|
|
336
336
|
}
|
|
337
|
-
export interface
|
|
337
|
+
export interface KpiValueProps {
|
|
338
338
|
className?: string;
|
|
339
339
|
children: ReactNode;
|
|
340
340
|
}
|
|
@@ -345,11 +345,11 @@ export interface KpiChartValueProps {
|
|
|
345
345
|
* and units are locale decisions, and a component that guessed them would be
|
|
346
346
|
* wrong in a way that is hard to notice and impossible to override.
|
|
347
347
|
*/
|
|
348
|
-
declare function
|
|
349
|
-
declare namespace
|
|
348
|
+
declare function KpiValue({ className, children }: KpiValueProps): import("react").JSX.Element;
|
|
349
|
+
declare namespace KpiValue {
|
|
350
350
|
var displayName: string;
|
|
351
351
|
}
|
|
352
|
-
export interface
|
|
352
|
+
export interface KpiTrendProps extends Omit<ViewProps, 'children'> {
|
|
353
353
|
className?: string;
|
|
354
354
|
/**
|
|
355
355
|
* How much it moved, as a percentage. The sign carries the direction, so
|
|
@@ -386,11 +386,11 @@ export interface KpiChartTrendProps extends Omit<ViewProps, 'children'> {
|
|
|
386
386
|
* label has to remember to change the colour when the metric changes, and
|
|
387
387
|
* nobody does.
|
|
388
388
|
*/
|
|
389
|
-
declare function
|
|
390
|
-
declare namespace
|
|
389
|
+
declare function KpiTrend({ className, value, format, goodDirection, variant, caption, threshold, children, ...props }: KpiTrendProps): import("react").JSX.Element;
|
|
390
|
+
declare namespace KpiTrend {
|
|
391
391
|
var displayName: string;
|
|
392
392
|
}
|
|
393
|
-
export interface
|
|
393
|
+
export interface KpiSparklineProps {
|
|
394
394
|
className?: string;
|
|
395
395
|
/** The rows. One point each, in order. */
|
|
396
396
|
data: LineChartDatum[];
|
|
@@ -421,11 +421,11 @@ export interface KpiChartSparklineProps {
|
|
|
421
421
|
* every point of padding is a point the shape is not using. Nobody reads a
|
|
422
422
|
* value off one of these; they read whether it is going up.
|
|
423
423
|
*/
|
|
424
|
-
declare function
|
|
425
|
-
declare namespace
|
|
424
|
+
declare function KpiSparkline({ className, data, dataKey, colorIndex, filled, height, inline, strokeWidth, }: KpiSparklineProps): import("react").JSX.Element;
|
|
425
|
+
declare namespace KpiSparkline {
|
|
426
426
|
var displayName: string;
|
|
427
427
|
}
|
|
428
|
-
export interface
|
|
428
|
+
export interface KpiProgressProps {
|
|
429
429
|
className?: string;
|
|
430
430
|
/** Where it has got to. */
|
|
431
431
|
value: number;
|
|
@@ -437,32 +437,32 @@ export interface KpiChartProgressProps {
|
|
|
437
437
|
showValueLabel?: boolean;
|
|
438
438
|
}
|
|
439
439
|
/** Progress towards a target, for a metric that has one. */
|
|
440
|
-
declare function
|
|
441
|
-
declare namespace
|
|
440
|
+
declare function KpiProgressBar({ className, value, maxValue, label, showValueLabel, }: KpiProgressProps): import("react").JSX.Element;
|
|
441
|
+
declare namespace KpiProgressBar {
|
|
442
442
|
var displayName: string;
|
|
443
443
|
}
|
|
444
|
-
export interface
|
|
444
|
+
export interface KpiFooterProps extends ViewProps {
|
|
445
445
|
className?: string;
|
|
446
446
|
children: ReactNode;
|
|
447
447
|
}
|
|
448
448
|
/** The bottom strip — a comparison period, a caveat, a link. */
|
|
449
|
-
declare function
|
|
450
|
-
declare namespace
|
|
449
|
+
declare function KpiFooter({ className, children, ...props }: KpiFooterProps): import("react").JSX.Element;
|
|
450
|
+
declare namespace KpiFooter {
|
|
451
451
|
var displayName: string;
|
|
452
452
|
}
|
|
453
|
-
export interface
|
|
453
|
+
export interface KpiSeparatorProps extends ViewProps {
|
|
454
454
|
className?: string;
|
|
455
455
|
}
|
|
456
456
|
/** A hairline across the card. */
|
|
457
|
-
declare function
|
|
458
|
-
declare namespace
|
|
457
|
+
declare function KpiSeparator({ className, ...props }: KpiSeparatorProps): import("react").JSX.Element;
|
|
458
|
+
declare namespace KpiSeparator {
|
|
459
459
|
var displayName: string;
|
|
460
460
|
}
|
|
461
|
-
export type
|
|
462
|
-
export interface
|
|
461
|
+
export type KpiGroupOrientation = 'horizontal' | 'vertical';
|
|
462
|
+
export interface KpiGroupProps extends ViewProps {
|
|
463
463
|
className?: string;
|
|
464
464
|
/** `horizontal` splits the row between the cards; `vertical` stacks them. */
|
|
465
|
-
orientation?:
|
|
465
|
+
orientation?: KpiGroupOrientation;
|
|
466
466
|
/**
|
|
467
467
|
* Draw a hairline between the cards rather than spacing them apart. Several
|
|
468
468
|
* metrics separated by a rule read as one panel; several spaced apart read
|
|
@@ -471,20 +471,20 @@ export interface KpiChartGroupProps extends ViewProps {
|
|
|
471
471
|
separated?: boolean;
|
|
472
472
|
children: ReactNode;
|
|
473
473
|
}
|
|
474
|
-
export declare const
|
|
475
|
-
Header: typeof
|
|
476
|
-
Icon: typeof
|
|
477
|
-
Title: typeof
|
|
478
|
-
Stat: typeof
|
|
479
|
-
Actions: typeof
|
|
480
|
-
Content: typeof
|
|
481
|
-
Value: typeof
|
|
482
|
-
Trend: typeof
|
|
483
|
-
Chart: typeof
|
|
484
|
-
Progress: typeof
|
|
485
|
-
Footer: typeof
|
|
486
|
-
Separator: typeof
|
|
487
|
-
Group: import("react").ForwardRefExoticComponent<
|
|
474
|
+
export declare const Kpi: import("react").ForwardRefExoticComponent<KpiProps & import("react").RefAttributes<View>> & {
|
|
475
|
+
Header: typeof KpiHeader;
|
|
476
|
+
Icon: typeof KpiIcon;
|
|
477
|
+
Title: typeof KpiTitle;
|
|
478
|
+
Stat: typeof KpiStat;
|
|
479
|
+
Actions: typeof KpiActions;
|
|
480
|
+
Content: typeof KpiContent;
|
|
481
|
+
Value: typeof KpiValue;
|
|
482
|
+
Trend: typeof KpiTrend;
|
|
483
|
+
Chart: typeof KpiSparkline;
|
|
484
|
+
Progress: typeof KpiProgressBar;
|
|
485
|
+
Footer: typeof KpiFooter;
|
|
486
|
+
Separator: typeof KpiSeparator;
|
|
487
|
+
Group: import("react").ForwardRefExoticComponent<KpiGroupProps & import("react").RefAttributes<View>>;
|
|
488
488
|
};
|
|
489
489
|
export {};
|
|
490
490
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/kpi/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAkD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACvF,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI1D,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,sBAAmB,CAAC;AAC1D,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,wBAAe,CAAC;AAwB/D,QAAA,MAAM,WAAW;IAkBb;;;OAGG;;;;;;;;;;;;;;;;;;;IAOH;;;;;;OAMG;;;;;;;;;;;IAKH,mDAAmD;;QAEjD,6DAA6D;;QAE7D;;;;;WAKG;;;;;;;;;;;;IAxCL,8EAA8E;;;;;;;;;IAU9E;;;OAGG;;;;;;;;;;;;;;;;;;;IAOH;;;;;;OAMG;;;;;;;;;;;IAKH,mDAAmD;;QAEjD,6DAA6D;;QAE7D;;;;;WAKG;;;;;;;;;;;;IAxCL,8EAA8E;;;;;;;;;IAU9E;;;OAGG;;;;;;;;;;;;;;;;;;;IAOH;;;;;;OAMG;;;;;;;;;;;IAKH,mDAAmD;;QAEjD,6DAA6D;;QAE7D;;;;;WAKG;;;;;;;;;;;;IAxCL,8EAA8E;;;;;;;;2CAuDhF,CAAC;AAEH,KAAK,eAAe,GAAG,YAAY,CAAC,OAAO,WAAW,CAAC,CAAC;AAExD,2EAA2E;AAC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E,MAAM,CAAC;IAClB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,4DAA4D;AAC5D,iBAAS,cAAc,CAAC,EACtB,SAAS,EACT,KAAK,EACL,QAAc,EACd,KAAK,EACL,cAAc,GACf,EAAE,gBAAgB,+BAWlB;kBAjBQ,cAAc;;;AAuBvB,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,gEAAgE;AAChE,iBAAS,SAAS,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,+BAOnE;kBAPQ,SAAS;;;AASlB,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,kCAAkC;AAClC,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,+BAG/D;kBAHQ,YAAY;;;AASrB,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE5D,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAmFD,eAAO,MAAM,GAAG;;;;;;;;;;;;;;CAcd,CAAC"}
|
|
@@ -191,6 +191,30 @@ declare namespace LineChartXAxis {
|
|
|
191
191
|
var displayName: string;
|
|
192
192
|
var layer: Layer;
|
|
193
193
|
}
|
|
194
|
+
export interface LineChartYAxisProps {
|
|
195
|
+
/** How many intervals to divide the axis into. Yields `ticks + 1` labels. */
|
|
196
|
+
ticks?: number;
|
|
197
|
+
/** Turn a value into its label. Defaults to a compact number. */
|
|
198
|
+
format?: (value: number) => string;
|
|
199
|
+
className?: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Value labels down the side, one per grid line.
|
|
203
|
+
*
|
|
204
|
+
* Give it the same `ticks` as the grid, or the numbers name lines that are not
|
|
205
|
+
* there. Four is the default on both for that reason.
|
|
206
|
+
*
|
|
207
|
+
* The labels are the domain the data settles at, not the tweening one — a
|
|
208
|
+
* number that counts up through every intermediate value while the axis
|
|
209
|
+
* animates is noise, and the axis is the part of the chart that is supposed to
|
|
210
|
+
* hold still enough to read.
|
|
211
|
+
*/
|
|
212
|
+
declare function LineChartYAxis({ ticks, format, className }: LineChartYAxisProps): import("react").JSX.Element;
|
|
213
|
+
declare namespace LineChartYAxis {
|
|
214
|
+
var displayName: string;
|
|
215
|
+
var layer: Layer;
|
|
216
|
+
var axis: "y";
|
|
217
|
+
}
|
|
194
218
|
export interface LineChartTooltipProps {
|
|
195
219
|
color?: string;
|
|
196
220
|
/**
|
|
@@ -272,7 +296,6 @@ declare namespace LineChartHeader {
|
|
|
272
296
|
var displayName: string;
|
|
273
297
|
var layer: Layer;
|
|
274
298
|
}
|
|
275
|
-
/** Only reached if the theme CSS was never imported. */
|
|
276
299
|
export declare const LineChart: import("react").ForwardRefExoticComponent<LineChartProps & import("react").RefAttributes<LineChartHandle>> & {
|
|
277
300
|
Header: typeof LineChartHeader;
|
|
278
301
|
Grid: typeof LineChartGrid;
|
|
@@ -280,6 +303,7 @@ export declare const LineChart: import("react").ForwardRefExoticComponent<LineCh
|
|
|
280
303
|
Line: typeof LineChartLine;
|
|
281
304
|
Skeleton: typeof LineChartSkeleton;
|
|
282
305
|
XAxis: typeof LineChartXAxis;
|
|
306
|
+
YAxis: typeof LineChartYAxis;
|
|
283
307
|
Tooltip: typeof LineChartTooltip;
|
|
284
308
|
Legend: typeof LineChartLegend;
|
|
285
309
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/line-chart/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,OAAO,EAWL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/line-chart/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,OAAO,EAWL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAqDxF;;;;GAIG;AACH,KAAK,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE1C,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,CAAC;AAClD,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,QAAQ,CAAC;AACnD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAsChF;;;;;;;GAOG;AACH,wBAAgB,YAAY;;;;EAO3B;AAED,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,cAAc,CAAC,EAAE,MA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AO,CAAC;IACjB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,iBAAS,eAAe,CAAC,EACvB,SAAS,EACT,KAAK,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,MAAc,EACd,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,oBAAoB,+BAwCtB;kBAjDQ,eAAe;;;;AAqDxB,eAAO,MAAM,SAAS;;;;;;;;;;CAUpB,CAAC"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PieChart — one whole, divided between its parts.
|
|
3
|
+
*
|
|
4
|
+
* ```tsx
|
|
5
|
+
* <PieChart data={spend} innerRadius={0.58}>
|
|
6
|
+
* <PieChart.Header title="This month" value="$18,420" legend />
|
|
7
|
+
* <PieChart.Slices />
|
|
8
|
+
* <PieChart.Center />
|
|
9
|
+
* </PieChart>
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* ## What it is, against the ring beside it
|
|
13
|
+
*
|
|
14
|
+
* A ring chart draws a value against *its own* target, so three rings can all
|
|
15
|
+
* sit at ninety percent of three unrelated numbers and nothing has to add up.
|
|
16
|
+
* A pie is the opposite claim: every slice is a share of one total, the angles
|
|
17
|
+
* must come to a full turn, and a slice only means anything next to the others.
|
|
18
|
+
* That is why nothing here takes a `maxValue` and why every value is normalised
|
|
19
|
+
* against the sum — the sum *is* the subject.
|
|
20
|
+
*
|
|
21
|
+
* It follows that a pie is the wrong shape for a great many things. Two numbers
|
|
22
|
+
* that do not belong to one whole, a series over time, anything a reader has to
|
|
23
|
+
* compare precisely: all of those are a bar chart, because an angle is the
|
|
24
|
+
* hardest quantity to read off a page and the fifth-largest slice of eleven is
|
|
25
|
+
* not a fact anybody is going to extract. Use it for a handful of parts of one
|
|
26
|
+
* obvious total, and put the number in the middle.
|
|
27
|
+
*
|
|
28
|
+
* ## Drawing
|
|
29
|
+
*
|
|
30
|
+
* Each slice is a filled path rather than a stroked arc, because a slice is a
|
|
31
|
+
* *region* — two arcs and two radial edges — and a stroke is a band of even
|
|
32
|
+
* thickness with no ends of its own. `wedgePath` builds it, and rebuilds it on
|
|
33
|
+
* the UI thread on every frame of the reveal.
|
|
34
|
+
*
|
|
35
|
+
* That is what makes the reveal an unroll rather than a fade: one angle sweeps
|
|
36
|
+
* clockwise from the start and each slice is drawn only as far as it has got
|
|
37
|
+
* to. The pie fills the way it would be drawn by hand, and the slices arrive in
|
|
38
|
+
* the order they are listed rather than all at once.
|
|
39
|
+
*
|
|
40
|
+
* Touch, not hover: a slice is selected by pressing it, and pressing the same
|
|
41
|
+
* one again clears the selection. There is no equivalent of a pointer resting
|
|
42
|
+
* somewhere without committing, so a chart that only revealed its numbers on
|
|
43
|
+
* hover would never reveal them at all.
|
|
44
|
+
*/
|
|
45
|
+
import { type ReactNode } from 'react';
|
|
46
|
+
import { type ViewProps } from 'react-native';
|
|
47
|
+
/** Whether the chart is showing data or waiting for it. */
|
|
48
|
+
export type PieChartStatus = 'loading' | 'ready';
|
|
49
|
+
/** One slice. Its share is worked out from the others, so there is no maximum. */
|
|
50
|
+
export interface PieDatum {
|
|
51
|
+
/** Name for the legend, the centre readout and the accessibility label. */
|
|
52
|
+
label: string;
|
|
53
|
+
/** How much of the whole this slice is. Negatives are treated as zero. */
|
|
54
|
+
value: number;
|
|
55
|
+
/** Explicit colour, overriding the `--color-chart-*` token. */
|
|
56
|
+
color?: string;
|
|
57
|
+
}
|
|
58
|
+
/** The selected slice and its share, for something rendered inside the chart. */
|
|
59
|
+
export declare function usePieChart(): {
|
|
60
|
+
activeIndex: number;
|
|
61
|
+
activeSlice: PieDatum | null;
|
|
62
|
+
/** The selected slice's share of the whole, 0 to 1. */
|
|
63
|
+
activeFraction: number;
|
|
64
|
+
};
|
|
65
|
+
export interface PieChartProps extends ViewProps {
|
|
66
|
+
className?: string;
|
|
67
|
+
/** One entry per slice, in the order they are drawn clockwise. */
|
|
68
|
+
data: PieDatum[];
|
|
69
|
+
/** Fixed diameter in points. Measured from the container when omitted. */
|
|
70
|
+
size?: number;
|
|
71
|
+
/**
|
|
72
|
+
* The hole, as a share of the radius. `0` is a pie; anything above it is a
|
|
73
|
+
* donut, and `0.55`–`0.65` is the range that leaves room for a readout in the
|
|
74
|
+
* middle without the band getting thin enough to be hard to hit.
|
|
75
|
+
*
|
|
76
|
+
* Given as a share rather than in points so a chart keeps its proportions at
|
|
77
|
+
* whatever size it is measured at.
|
|
78
|
+
*/
|
|
79
|
+
innerRadius?: number;
|
|
80
|
+
/** Where the first slice begins, in degrees clockwise from twelve o'clock. */
|
|
81
|
+
startAngle?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Where the last one ends, on the same clock. Leaving a turn's worth between
|
|
84
|
+
* the two gives a closed pie; anything less leaves a gap and reads as a dial.
|
|
85
|
+
*/
|
|
86
|
+
endAngle?: number;
|
|
87
|
+
/** Gap between one slice and the next, in degrees. */
|
|
88
|
+
padAngle?: number;
|
|
89
|
+
/**
|
|
90
|
+
* The smallest angle any non-zero slice is drawn at, in degrees.
|
|
91
|
+
*
|
|
92
|
+
* A slice worth a fifth of a percent is a hairline nobody can see and nobody
|
|
93
|
+
* can press, so it reads as missing rather than as small — and "missing" is a
|
|
94
|
+
* different claim from "nearly none". The angle it borrows comes off the
|
|
95
|
+
* others in proportion, so the turn still closes.
|
|
96
|
+
*/
|
|
97
|
+
minAngle?: number;
|
|
98
|
+
/** Milliseconds for the pie to unroll. */
|
|
99
|
+
animationDuration?: number;
|
|
100
|
+
/** `loading` draws a plain muted ring until the data arrives. */
|
|
101
|
+
status?: PieChartStatus;
|
|
102
|
+
/** Selected slice. Leave unset to let the chart track it. */
|
|
103
|
+
activeIndex?: number;
|
|
104
|
+
/** Fires with the selected slice, or `-1` when the selection is cleared. */
|
|
105
|
+
onActiveIndexChange?: (index: number) => void;
|
|
106
|
+
children?: ReactNode;
|
|
107
|
+
}
|
|
108
|
+
/** Imperative handle: re-run the unroll, for a "replay" control. */
|
|
109
|
+
export interface PieChartHandle {
|
|
110
|
+
replay: () => void;
|
|
111
|
+
}
|
|
112
|
+
export interface PieChartSlicesProps {
|
|
113
|
+
/** Rounds the four turns of each slice, in points. */
|
|
114
|
+
cornerRadius?: number;
|
|
115
|
+
/** How far a selected slice lifts out of the pie, in points. */
|
|
116
|
+
popOut?: number;
|
|
117
|
+
/** Opacity of the slices that are not selected, once one is. */
|
|
118
|
+
dimOpacity?: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Every slice, drawn in the order the data lists them.
|
|
122
|
+
*
|
|
123
|
+
* One part rather than one per datum, unlike the rings next door. A ring is
|
|
124
|
+
* configured on its own — its own thickness, its own cap, its own segment count
|
|
125
|
+
* — because it is its own measurement. Slices of a pie are not: they share a
|
|
126
|
+
* radius, a hole and a dial by definition, and a chart where one of them could
|
|
127
|
+
* be given a different radius would be a chart drawing a lie.
|
|
128
|
+
*/
|
|
129
|
+
declare function PieChartSlices({ cornerRadius, popOut, dimOpacity, }: PieChartSlicesProps): import("react").JSX.Element | null;
|
|
130
|
+
declare namespace PieChartSlices {
|
|
131
|
+
var displayName: string;
|
|
132
|
+
var slot: "svg";
|
|
133
|
+
}
|
|
134
|
+
export interface PieChartSkeletonProps {
|
|
135
|
+
color?: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The loading state: the dial as one plain band, with nothing divided up yet.
|
|
139
|
+
*
|
|
140
|
+
* Deliberately undivided. Placeholder slices would be a made-up split, and a
|
|
141
|
+
* reader has no way to tell an invented one from a real one until it changes
|
|
142
|
+
* under them — which is worse than showing nothing, because it is showing
|
|
143
|
+
* something wrong.
|
|
144
|
+
*/
|
|
145
|
+
declare function PieChartSkeleton({ color }: PieChartSkeletonProps): import("react").JSX.Element | null;
|
|
146
|
+
declare namespace PieChartSkeleton {
|
|
147
|
+
var displayName: string;
|
|
148
|
+
var slot: "svg";
|
|
149
|
+
}
|
|
150
|
+
export interface PieChartCenterProps {
|
|
151
|
+
/** Heading shown when no slice is selected. */
|
|
152
|
+
defaultLabel?: string;
|
|
153
|
+
/** Format the number under the label. Defaults to a compact number. */
|
|
154
|
+
formatValue?: (value: number, slice: PieDatum | null) => string;
|
|
155
|
+
/**
|
|
156
|
+
* Draw the middle yourself. Given the selected slice, or `null` when nothing
|
|
157
|
+
* is selected.
|
|
158
|
+
*/
|
|
159
|
+
children?: (slice: PieDatum | null) => ReactNode;
|
|
160
|
+
className?: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The hole's readout: the total, and the selected slice's own figures once one
|
|
164
|
+
* is picked.
|
|
165
|
+
*
|
|
166
|
+
* Unlike the ring chart's centre, the default here *is* an aggregate, and it is
|
|
167
|
+
* the honest one — the whole point of a pie is that its parts belong to a total,
|
|
168
|
+
* so the total is the number the chart is about. Selecting a slice swaps it for
|
|
169
|
+
* that slice's value and its share.
|
|
170
|
+
*/
|
|
171
|
+
declare function PieChartCenter({ defaultLabel, formatValue, children, className, }: PieChartCenterProps): import("react").JSX.Element | null;
|
|
172
|
+
declare namespace PieChartCenter {
|
|
173
|
+
var displayName: string;
|
|
174
|
+
var slot: "overlay";
|
|
175
|
+
}
|
|
176
|
+
export interface PieChartLegendProps extends ViewProps {
|
|
177
|
+
className?: string;
|
|
178
|
+
/** Show each slice's share of the whole beside its name. */
|
|
179
|
+
showValue?: boolean;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* A swatch, a name and a share per slice, under the chart and across the width
|
|
183
|
+
* of it. Pressable in the same way the slices are — the legend is usually the
|
|
184
|
+
* easier target of the two, and a slice worth a couple of percent is not a
|
|
185
|
+
* target at all.
|
|
186
|
+
*
|
|
187
|
+
* It wraps rather than stacking, so five or six entries take two lines instead
|
|
188
|
+
* of six. A key is a lookup table, and a lookup table read down a column of one
|
|
189
|
+
* word each is a column the eye has to walk.
|
|
190
|
+
*/
|
|
191
|
+
declare function PieChartLegend({ className, showValue, ...props }: PieChartLegendProps): import("react").JSX.Element | null;
|
|
192
|
+
declare namespace PieChartLegend {
|
|
193
|
+
var displayName: string;
|
|
194
|
+
var slot: "footer";
|
|
195
|
+
}
|
|
196
|
+
export interface PieChartHeaderProps extends ViewProps {
|
|
197
|
+
className?: string;
|
|
198
|
+
/** Small line above the value — what the chart is of. */
|
|
199
|
+
title?: string;
|
|
200
|
+
/** The readout. The largest thing on the card, and the first thing read. */
|
|
201
|
+
value?: string;
|
|
202
|
+
/** One muted line under the value — a period, a comparison, a caveat. */
|
|
203
|
+
caption?: string;
|
|
204
|
+
/** Prettier names for the slices, keyed by their `label`. */
|
|
205
|
+
labels?: Record<string, string>;
|
|
206
|
+
/**
|
|
207
|
+
* Draw a swatch and a name per slice along the trailing edge.
|
|
208
|
+
*
|
|
209
|
+
* For two or three short names. Past that use `PieChart.Legend`, which runs
|
|
210
|
+
* under the chart across the full width: a key of five long names crammed
|
|
211
|
+
* into the trailing corner of a header wraps to a column and leaves the title
|
|
212
|
+
* beside it a few points wide.
|
|
213
|
+
*/
|
|
214
|
+
legend?: boolean;
|
|
215
|
+
/** Trailing slot — a control, a badge, a range picker. Wins over `legend`. */
|
|
216
|
+
children?: ReactNode;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The strip above the pie: what the chart is of, what it reads, and what the
|
|
220
|
+
* colours mean.
|
|
221
|
+
*
|
|
222
|
+
* It belongs to the chart rather than to the card around it because it is about
|
|
223
|
+
* the *slices* — the number changes as one is selected, and the legend is the
|
|
224
|
+
* list the chart itself is holding. The card's header is a caption on the tray
|
|
225
|
+
* the chart sits in; this is the chart introducing itself.
|
|
226
|
+
*
|
|
227
|
+
* The value is not derived here even though there is a total to derive it from,
|
|
228
|
+
* because the formatting is not the chart's to guess: a total of 18420 is a
|
|
229
|
+
* count, a currency or a percentage depending on what was counted, and only the
|
|
230
|
+
* caller knows which.
|
|
231
|
+
*/
|
|
232
|
+
declare function PieChartHeader({ className, title, value, caption, labels, legend, children, ...props }: PieChartHeaderProps): import("react").JSX.Element;
|
|
233
|
+
declare namespace PieChartHeader {
|
|
234
|
+
var displayName: string;
|
|
235
|
+
var slot: "header";
|
|
236
|
+
}
|
|
237
|
+
export declare const PieChart: import("react").ForwardRefExoticComponent<PieChartProps & import("react").RefAttributes<PieChartHandle>> & {
|
|
238
|
+
Header: typeof PieChartHeader;
|
|
239
|
+
Slices: typeof PieChartSlices;
|
|
240
|
+
Center: typeof PieChartCenter;
|
|
241
|
+
Legend: typeof PieChartLegend;
|
|
242
|
+
Skeleton: typeof PieChartSkeleton;
|
|
243
|
+
};
|
|
244
|
+
export {};
|
|
245
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/pie-chart/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,EAWL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAA2C,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAwBvF,2DAA2D;AAC3D,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC;AAEjD,kFAAkF;AAClF,MAAM,WAAW,QAAQ;IACvB,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA2CD,iFAAiF;AACjF,wBAAgB,WAAW;;;IAKvB,uDAAuD;;EAG1D;AAED,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,M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