panelui-native 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +3 -1
  2. package/lib/module/components/area-chart/index.js +15 -3
  3. package/lib/module/components/area-chart/index.js.map +1 -1
  4. package/lib/module/components/bar-chart/index.js +15 -3
  5. package/lib/module/components/bar-chart/index.js.map +1 -1
  6. package/lib/module/components/bottom-sheet/index.js +34 -2
  7. package/lib/module/components/bottom-sheet/index.js.map +1 -1
  8. package/lib/module/components/bubble-chart/index.js +13 -3
  9. package/lib/module/components/bubble-chart/index.js.map +1 -1
  10. package/lib/module/components/bump-chart/index.js +15 -3
  11. package/lib/module/components/bump-chart/index.js.map +1 -1
  12. package/lib/module/components/candlestick-chart/index.js +15 -3
  13. package/lib/module/components/candlestick-chart/index.js.map +1 -1
  14. package/lib/module/components/line-chart/index.js +15 -3
  15. package/lib/module/components/line-chart/index.js.map +1 -1
  16. package/lib/module/components/live-line-chart/index.js +15 -3
  17. package/lib/module/components/live-line-chart/index.js.map +1 -1
  18. package/lib/module/components/mirror-area-chart/index.js +15 -3
  19. package/lib/module/components/mirror-area-chart/index.js.map +1 -1
  20. package/lib/module/components/plot/index.js +15 -3
  21. package/lib/module/components/plot/index.js.map +1 -1
  22. package/lib/module/components/pyramid-chart/index.js +15 -3
  23. package/lib/module/components/pyramid-chart/index.js.map +1 -1
  24. package/lib/module/components/scatter-chart/index.js +13 -3
  25. package/lib/module/components/scatter-chart/index.js.map +1 -1
  26. package/lib/module/components/waterfall-chart/index.js +15 -3
  27. package/lib/module/components/waterfall-chart/index.js.map +1 -1
  28. package/lib/module/index.js.map +1 -1
  29. package/lib/typescript/src/components/area-chart/index.d.ts +11 -1
  30. package/lib/typescript/src/components/area-chart/index.d.ts.map +1 -1
  31. package/lib/typescript/src/components/bar-chart/index.d.ts +11 -1
  32. package/lib/typescript/src/components/bar-chart/index.d.ts.map +1 -1
  33. package/lib/typescript/src/components/bottom-sheet/index.d.ts +12 -6
  34. package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
  35. package/lib/typescript/src/components/bubble-chart/index.d.ts +11 -1
  36. package/lib/typescript/src/components/bubble-chart/index.d.ts.map +1 -1
  37. package/lib/typescript/src/components/bump-chart/index.d.ts +11 -1
  38. package/lib/typescript/src/components/bump-chart/index.d.ts.map +1 -1
  39. package/lib/typescript/src/components/candlestick-chart/index.d.ts +11 -1
  40. package/lib/typescript/src/components/candlestick-chart/index.d.ts.map +1 -1
  41. package/lib/typescript/src/components/line-chart/index.d.ts +11 -1
  42. package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
  43. package/lib/typescript/src/components/live-line-chart/index.d.ts +11 -1
  44. package/lib/typescript/src/components/live-line-chart/index.d.ts.map +1 -1
  45. package/lib/typescript/src/components/mirror-area-chart/index.d.ts +11 -1
  46. package/lib/typescript/src/components/mirror-area-chart/index.d.ts.map +1 -1
  47. package/lib/typescript/src/components/plot/index.d.ts +11 -1
  48. package/lib/typescript/src/components/plot/index.d.ts.map +1 -1
  49. package/lib/typescript/src/components/pyramid-chart/index.d.ts +11 -1
  50. package/lib/typescript/src/components/pyramid-chart/index.d.ts.map +1 -1
  51. package/lib/typescript/src/components/scatter-chart/index.d.ts +11 -1
  52. package/lib/typescript/src/components/scatter-chart/index.d.ts.map +1 -1
  53. package/lib/typescript/src/components/waterfall-chart/index.d.ts +11 -1
  54. package/lib/typescript/src/components/waterfall-chart/index.d.ts.map +1 -1
  55. package/lib/typescript/src/index.d.ts +2 -2
  56. package/lib/typescript/src/index.d.ts.map +1 -1
  57. package/package.json +7 -2
  58. package/src/components/area-chart/index.tsx +31 -3
  59. package/src/components/bar-chart/index.tsx +40 -3
  60. package/src/components/bottom-sheet/index.tsx +41 -11
  61. package/src/components/bubble-chart/index.tsx +23 -2
  62. package/src/components/bump-chart/index.tsx +31 -3
  63. package/src/components/candlestick-chart/index.tsx +25 -2
  64. package/src/components/line-chart/index.tsx +31 -3
  65. package/src/components/live-line-chart/index.tsx +29 -3
  66. package/src/components/mirror-area-chart/index.tsx +25 -2
  67. package/src/components/plot/index.tsx +37 -3
  68. package/src/components/pyramid-chart/index.tsx +25 -2
  69. package/src/components/scatter-chart/index.tsx +23 -2
  70. package/src/components/waterfall-chart/index.tsx +35 -2
  71. package/src/index.ts +12 -1
@@ -1453,10 +1453,29 @@ PlotYAxis.layer = 'overlay' as Layer;
1453
1453
  // plot out.
1454
1454
  PlotYAxis.axis = 'y' as const;
1455
1455
 
1456
+ /**
1457
+ * How long the cursor waits before claiming the touch, in milliseconds.
1458
+ *
1459
+ * Long enough that a tap reaches a button drawn over the chart and a swipe
1460
+ * scrolls the screen, short enough that a deliberate press does not feel
1461
+ * ignored.
1462
+ */
1463
+ const DEFAULT_HOLD = 180;
1464
+
1456
1465
  export interface PlotCursorProps {
1457
1466
  color?: string;
1458
1467
  /** Hide the vertical line and keep only the touch handling. */
1459
1468
  showLine?: boolean;
1469
+ /**
1470
+ * How long a press has to be held before the cursor takes the touch, in
1471
+ * milliseconds.
1472
+ *
1473
+ * Until then the touch belongs to whatever else wants it: a quick tap still
1474
+ * reaches a button floating over the chart, and a swipe still scrolls the
1475
+ * screen the chart sits in. Set `0` to read on contact, only for a chart with
1476
+ * nothing over it and no scroll view around it.
1477
+ */
1478
+ activateAfterLongPress?: number;
1460
1479
  }
1461
1480
 
1462
1481
  /**
@@ -1470,7 +1489,11 @@ export interface PlotCursorProps {
1470
1489
  * The hit area is the whole plot. A cursor you have to land on the line to
1471
1490
  * summon is a cursor nobody finds.
1472
1491
  */
1473
- function PlotCursor({ color, showLine = true }: PlotCursorProps) {
1492
+ function PlotCursor({
1493
+ color,
1494
+ showLine = true,
1495
+ activateAfterLongPress = DEFAULT_HOLD,
1496
+ }: PlotCursorProps) {
1474
1497
  const { data, plot, xScale, activeIndex, setActiveIndexJS, status } =
1475
1498
  useChart('Plot.Cursor');
1476
1499
  const token = useCSSVariable('--color-foreground');
@@ -1510,7 +1533,8 @@ function PlotCursor({ color, showLine = true }: PlotCursorProps) {
1510
1533
 
1511
1534
  return Gesture.Pan()
1512
1535
  .minDistance(0)
1513
- .onBegin((event) => {
1536
+ .activateAfterLongPress(activateAfterLongPress)
1537
+ .onStart((event) => {
1514
1538
  'worklet';
1515
1539
  resolve(event.x);
1516
1540
  })
@@ -1520,10 +1544,20 @@ function PlotCursor({ color, showLine = true }: PlotCursorProps) {
1520
1544
  })
1521
1545
  .onFinalize(() => {
1522
1546
  'worklet';
1547
+ // Fires whether or not the readout ever took the touch.
1548
+ if (activeIndex.value === -1) return;
1523
1549
  activeIndex.value = -1;
1524
1550
  runOnJS(setActiveIndexJS)(-1);
1525
1551
  });
1526
- }, [total, left, width, banded, activeIndex, setActiveIndexJS]);
1552
+ }, [
1553
+ total,
1554
+ left,
1555
+ width,
1556
+ banded,
1557
+ activeIndex,
1558
+ setActiveIndexJS,
1559
+ activateAfterLongPress,
1560
+ ]);
1527
1561
 
1528
1562
  const lineStyle = useAnimatedStyle(() => {
1529
1563
  const index = activeIndex.value;
@@ -1060,12 +1060,31 @@ PyramidChartYAxis.layer = 'overlay' as Layer;
1060
1060
  // drawn over unreadable too.
1061
1061
  PyramidChartYAxis.axis = 'y' as const;
1062
1062
 
1063
+ /**
1064
+ * How long the readout waits before claiming the touch, in milliseconds.
1065
+ *
1066
+ * Long enough that a tap reaches a button drawn over the chart and a swipe
1067
+ * scrolls the screen, short enough that a deliberate press does not feel
1068
+ * ignored.
1069
+ */
1070
+ const DEFAULT_HOLD = 180;
1071
+
1063
1072
  export interface PyramidChartTooltipProps {
1064
1073
  /** Format one series' value. Defaults to a compact number. */
1065
1074
  formatValue?: (value: number, key: string) => string;
1066
1075
  /** Format the readout's heading from the row. Defaults to the value at xDataKey. */
1067
1076
  formatX?: (datum: PyramidChartDatum) => string;
1068
1077
  className?: string;
1078
+ /**
1079
+ * How long a press has to be held before the readout takes the touch, in
1080
+ * milliseconds.
1081
+ *
1082
+ * Until then the touch belongs to whatever else wants it: a quick tap still
1083
+ * reaches a button floating over the chart, and a swipe still scrolls the
1084
+ * screen the chart sits in. Set `0` to read on contact, only for a chart with
1085
+ * nothing over it and no scroll view around it.
1086
+ */
1087
+ activateAfterLongPress?: number;
1069
1088
  }
1070
1089
 
1071
1090
  /**
@@ -1082,6 +1101,7 @@ function PyramidChartTooltip({
1082
1101
  formatValue,
1083
1102
  formatX,
1084
1103
  className,
1104
+ activateAfterLongPress = DEFAULT_HOLD,
1085
1105
  }: PyramidChartTooltipProps) {
1086
1106
  const {
1087
1107
  data,
@@ -1125,7 +1145,8 @@ function PyramidChartTooltip({
1125
1145
 
1126
1146
  return Gesture.Pan()
1127
1147
  .minDistance(0)
1128
- .onBegin((event) => {
1148
+ .activateAfterLongPress(activateAfterLongPress)
1149
+ .onStart((event) => {
1129
1150
  'worklet';
1130
1151
  resolve(event.y);
1131
1152
  })
@@ -1135,10 +1156,12 @@ function PyramidChartTooltip({
1135
1156
  })
1136
1157
  .onFinalize(() => {
1137
1158
  'worklet';
1159
+ // Fires whether or not the readout ever took the touch.
1160
+ if (activeIndex.value === -1) return;
1138
1161
  activeIndex.value = -1;
1139
1162
  runOnJS(setActiveIndexJS)(-1);
1140
1163
  });
1141
- }, [total, top, height, activeIndex, setActiveIndexJS]);
1164
+ }, [total, top, height, activeIndex, setActiveIndexJS, activateAfterLongPress]);
1142
1165
 
1143
1166
  /*
1144
1167
  * The readout slides down to the row it is describing and sits centred over
@@ -1028,6 +1028,15 @@ ScatterChartYAxis.layer = 'overlay' as Layer;
1028
1028
  // plot out.
1029
1029
  ScatterChartYAxis.axis = 'y' as const;
1030
1030
 
1031
+ /**
1032
+ * How long the readout waits before claiming the touch, in milliseconds.
1033
+ *
1034
+ * Long enough that a tap reaches a button drawn over the chart and a swipe
1035
+ * scrolls the screen, short enough that a deliberate press does not feel
1036
+ * ignored.
1037
+ */
1038
+ const DEFAULT_HOLD = 180;
1039
+
1031
1040
  export interface ScatterChartTooltipProps {
1032
1041
  /** Float a small readout beside the selected point. On by default. */
1033
1042
  showLabel?: boolean;
@@ -1039,6 +1048,16 @@ export interface ScatterChartTooltipProps {
1039
1048
  formatTitle?: (datum: ScatterChartDatum) => string;
1040
1049
  /** How far from a point a touch still counts as being on it, in points. */
1041
1050
  hitRadius?: number;
1051
+ /**
1052
+ * How long a press has to be held before the readout takes the touch, in
1053
+ * milliseconds.
1054
+ *
1055
+ * Until then the touch belongs to whatever else wants it: a quick tap still
1056
+ * reaches a button floating over the chart, and a swipe still scrolls the
1057
+ * screen the chart sits in. Set `0` to read on contact, only for a chart with
1058
+ * nothing over it and no scroll view around it.
1059
+ */
1060
+ activateAfterLongPress?: number;
1042
1061
  }
1043
1062
 
1044
1063
  /**
@@ -1064,6 +1083,7 @@ function ScatterChartTooltip({
1064
1083
  formatY,
1065
1084
  formatTitle,
1066
1085
  hitRadius = HIT_RADIUS,
1086
+ activateAfterLongPress = DEFAULT_HOLD,
1067
1087
  }: ScatterChartTooltipProps) {
1068
1088
  const {
1069
1089
  data,
@@ -1190,7 +1210,8 @@ function ScatterChartTooltip({
1190
1210
 
1191
1211
  return Gesture.Pan()
1192
1212
  .minDistance(0)
1193
- .onBegin((event) => {
1213
+ .activateAfterLongPress(activateAfterLongPress)
1214
+ .onStart((event) => {
1194
1215
  'worklet';
1195
1216
  resolve(event.x, event.y);
1196
1217
  })
@@ -1202,7 +1223,7 @@ function ScatterChartTooltip({
1202
1223
  'worklet';
1203
1224
  clear();
1204
1225
  });
1205
- }, [hit, hitRadius, activeId, select]);
1226
+ }, [hit, hitRadius, activeId, select, activateAfterLongPress]);
1206
1227
 
1207
1228
  // The readout sits above the point and is clamped inside the plot, so it
1208
1229
  // never runs off an edge at an extreme value.
@@ -1297,12 +1297,31 @@ function WaterfallChartValues({ format, className }: WaterfallChartValuesProps)
1297
1297
  WaterfallChartValues.displayName = 'WaterfallChart.Values';
1298
1298
  WaterfallChartValues.layer = 'overlay' as Layer;
1299
1299
 
1300
+ /**
1301
+ * How long the readout waits before claiming the touch, in milliseconds.
1302
+ *
1303
+ * Long enough that a tap reaches a button drawn over the chart and a swipe
1304
+ * scrolls the screen, short enough that a deliberate press does not feel
1305
+ * ignored.
1306
+ */
1307
+ const DEFAULT_HOLD = 180;
1308
+
1300
1309
  export interface WaterfallChartTooltipProps {
1301
1310
  /** Format the step's change. Defaults to a signed compact number. */
1302
1311
  formatValue?: (step: WaterfallStep) => string;
1303
1312
  /** Format the running total line. Return `null` to drop it. */
1304
1313
  formatTotal?: (step: WaterfallStep) => string | null;
1305
1314
  className?: string;
1315
+ /**
1316
+ * How long a press has to be held before the readout takes the touch, in
1317
+ * milliseconds.
1318
+ *
1319
+ * Until then the touch belongs to whatever else wants it: a quick tap still
1320
+ * reaches a button floating over the chart, and a swipe still scrolls the
1321
+ * screen the chart sits in. Set `0` to read on contact, only for a chart with
1322
+ * nothing over it and no scroll view around it.
1323
+ */
1324
+ activateAfterLongPress?: number;
1306
1325
  }
1307
1326
 
1308
1327
  /**
@@ -1321,6 +1340,7 @@ function WaterfallChartTooltip({
1321
1340
  formatValue,
1322
1341
  formatTotal,
1323
1342
  className,
1343
+ activateAfterLongPress = DEFAULT_HOLD,
1324
1344
  }: WaterfallChartTooltipProps) {
1325
1345
  const {
1326
1346
  steps,
@@ -1367,7 +1387,8 @@ function WaterfallChartTooltip({
1367
1387
 
1368
1388
  return Gesture.Pan()
1369
1389
  .minDistance(0)
1370
- .onBegin((event) => {
1390
+ .activateAfterLongPress(activateAfterLongPress)
1391
+ .onStart((event) => {
1371
1392
  'worklet';
1372
1393
  resolve(event.x, event.y);
1373
1394
  })
@@ -1377,10 +1398,22 @@ function WaterfallChartTooltip({
1377
1398
  })
1378
1399
  .onFinalize(() => {
1379
1400
  'worklet';
1401
+ // Fires whether or not the readout ever took the touch.
1402
+ if (activeIndex.value === -1) return;
1380
1403
  activeIndex.value = -1;
1381
1404
  runOnJS(setActiveIndexJS)(-1);
1382
1405
  });
1383
- }, [total, left, top, width, height, horizontal, activeIndex, setActiveIndexJS]);
1406
+ }, [
1407
+ total,
1408
+ left,
1409
+ top,
1410
+ width,
1411
+ height,
1412
+ horizontal,
1413
+ activeIndex,
1414
+ setActiveIndexJS,
1415
+ activateAfterLongPress,
1416
+ ]);
1384
1417
 
1385
1418
  // The readout centres over its band and is clamped inside the plot, so it
1386
1419
  // never runs off the edge at the first or last one. Which axis it follows is
package/src/index.ts CHANGED
@@ -36,7 +36,17 @@ export { Text, type TextProps } from './primitives/text';
36
36
  // What a forwarded ref points at. Name these instead of `View`, `Text` or
37
37
  // `TextInput` as a ref's type: they compile on every React Native version the
38
38
  // library supports, where the component names stopped being types in 0.88.
39
- export type { ViewRef, TextRef, TextInputRef, ScrollViewRef } from './primitives/refs';
39
+ export type {
40
+ ViewRef,
41
+ TextRef,
42
+ TextInputRef,
43
+ ScrollViewRef,
44
+ KeyPressEvent,
45
+ SubmitEditingEvent,
46
+ SelectionChangeEvent,
47
+ ContentSizeChangeEvent,
48
+ ViewTokenOf,
49
+ } from './primitives/refs';
40
50
  export { Collapse, type CollapseProps } from './primitives/collapse';
41
51
  export {
42
52
  KeyboardAvoider,
@@ -196,6 +206,7 @@ export {
196
206
  BottomSheet,
197
207
  type BottomSheetProps,
198
208
  type BottomSheetContentProps,
209
+ type BottomSheetSize,
199
210
  type BottomSheetHeaderProps,
200
211
  type BottomSheetBodyProps,
201
212
  type BottomSheetFooterProps,