panelui-native 0.7.0 → 0.12.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 +5 -3
- package/lib/module/components/attachment/index.js +219 -0
- package/lib/module/components/attachment/index.js.map +1 -0
- package/lib/module/components/bottom-sheet/index.js +53 -3
- package/lib/module/components/bottom-sheet/index.js.map +1 -1
- package/lib/module/components/button/index.js +19 -1
- package/lib/module/components/button/index.js.map +1 -1
- package/lib/module/components/dialog/index.js +6 -2
- package/lib/module/components/dialog/index.js.map +1 -1
- package/lib/module/components/empty-state/index.js +94 -17
- package/lib/module/components/empty-state/index.js.map +1 -1
- package/lib/module/components/frame/index.js +128 -15
- package/lib/module/components/frame/index.js.map +1 -1
- package/lib/module/components/input/index.js +107 -15
- package/lib/module/components/input/index.js.map +1 -1
- package/lib/module/components/line-chart/index.js +1024 -0
- package/lib/module/components/line-chart/index.js.map +1 -0
- package/lib/module/components/marker/index.js +190 -0
- package/lib/module/components/marker/index.js.map +1 -0
- package/lib/module/components/message/index.js +24 -8
- package/lib/module/components/message/index.js.map +1 -1
- package/lib/module/components/message-scroller/index.js +451 -0
- package/lib/module/components/message-scroller/index.js.map +1 -0
- package/lib/module/components/popover/index.js +511 -0
- package/lib/module/components/popover/index.js.map +1 -0
- package/lib/module/components/progress/index.js +52 -2
- package/lib/module/components/progress/index.js.map +1 -1
- package/lib/module/components/radio-group/index.js +132 -17
- package/lib/module/components/radio-group/index.js.map +1 -1
- package/lib/module/components/section-rail/index.js +355 -0
- package/lib/module/components/section-rail/index.js.map +1 -0
- package/lib/module/components/select/index.js +245 -56
- package/lib/module/components/select/index.js.map +1 -1
- package/lib/module/components/separator/index.js +91 -0
- package/lib/module/components/separator/index.js.map +1 -0
- package/lib/module/components/slider/index.js +355 -0
- package/lib/module/components/slider/index.js.map +1 -0
- package/lib/module/components/surface/index.js +21 -2
- package/lib/module/components/surface/index.js.map +1 -1
- package/lib/module/components/switch/index.js +10 -1
- package/lib/module/components/switch/index.js.map +1 -1
- package/lib/module/components/tabs/index.js +186 -16
- package/lib/module/components/tabs/index.js.map +1 -1
- package/lib/module/components/toggle-button/index.js +297 -0
- package/lib/module/components/toggle-button/index.js.map +1 -0
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/use-keyboard-avoidance.js +57 -8
- package/lib/module/hooks/use-keyboard-avoidance.js.map +1 -1
- package/lib/module/hooks/use-scroll-sections.js +89 -0
- package/lib/module/hooks/use-scroll-sections.js.map +1 -0
- package/lib/module/icons/index.js +69 -0
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/index.js +11 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/native/index.js.map +1 -1
- package/lib/module/primitives/keyboard-avoider.js +2 -0
- package/lib/module/primitives/keyboard-avoider.js.map +1 -1
- package/lib/module/primitives/scrim.js +72 -0
- package/lib/module/primitives/scrim.js.map +1 -0
- package/lib/module/utils/haptics.js +57 -0
- package/lib/module/utils/haptics.js.map +1 -0
- package/lib/typescript/src/components/attachment/index.d.ts +93 -0
- package/lib/typescript/src/components/attachment/index.d.ts.map +1 -0
- package/lib/typescript/src/components/bottom-sheet/index.d.ts +6 -1
- package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button/index.d.ts +9 -4
- package/lib/typescript/src/components/button/index.d.ts.map +1 -1
- package/lib/typescript/src/components/dialog/index.d.ts +7 -1
- package/lib/typescript/src/components/dialog/index.d.ts.map +1 -1
- package/lib/typescript/src/components/empty-state/index.d.ts +152 -2
- package/lib/typescript/src/components/empty-state/index.d.ts.map +1 -1
- package/lib/typescript/src/components/frame/index.d.ts +47 -7
- package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
- package/lib/typescript/src/components/input/index.d.ts +113 -2
- package/lib/typescript/src/components/input/index.d.ts.map +1 -1
- package/lib/typescript/src/components/line-chart/index.d.ts +247 -0
- package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/marker/index.d.ts +137 -0
- package/lib/typescript/src/components/marker/index.d.ts.map +1 -0
- package/lib/typescript/src/components/message/index.d.ts +8 -1
- package/lib/typescript/src/components/message/index.d.ts.map +1 -1
- package/lib/typescript/src/components/message-scroller/index.d.ts +150 -0
- package/lib/typescript/src/components/message-scroller/index.d.ts.map +1 -0
- package/lib/typescript/src/components/popover/index.d.ts +136 -0
- package/lib/typescript/src/components/popover/index.d.ts.map +1 -0
- package/lib/typescript/src/components/progress/index.d.ts +33 -0
- package/lib/typescript/src/components/progress/index.d.ts.map +1 -1
- package/lib/typescript/src/components/radio-group/index.d.ts +39 -0
- package/lib/typescript/src/components/radio-group/index.d.ts.map +1 -1
- package/lib/typescript/src/components/section-rail/index.d.ts +115 -0
- package/lib/typescript/src/components/section-rail/index.d.ts.map +1 -0
- package/lib/typescript/src/components/select/index.d.ts +46 -7
- package/lib/typescript/src/components/select/index.d.ts.map +1 -1
- package/lib/typescript/src/components/separator/index.d.ts +47 -0
- package/lib/typescript/src/components/separator/index.d.ts.map +1 -0
- package/lib/typescript/src/components/slider/index.d.ts +203 -0
- package/lib/typescript/src/components/slider/index.d.ts.map +1 -0
- package/lib/typescript/src/components/surface/index.d.ts +51 -2
- package/lib/typescript/src/components/surface/index.d.ts.map +1 -1
- package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
- package/lib/typescript/src/components/tabs/index.d.ts +46 -4
- package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
- package/lib/typescript/src/components/toggle-button/index.d.ts +244 -0
- package/lib/typescript/src/components/toggle-button/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +1 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts +10 -1
- package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts.map +1 -1
- package/lib/typescript/src/hooks/use-scroll-sections.d.ts +31 -0
- package/lib/typescript/src/hooks/use-scroll-sections.d.ts.map +1 -0
- package/lib/typescript/src/icons/index.d.ts +6 -0
- package/lib/typescript/src/icons/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +13 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native/index.d.ts +16 -1
- package/lib/typescript/src/native/index.d.ts.map +1 -1
- package/lib/typescript/src/primitives/keyboard-avoider.d.ts +8 -1
- package/lib/typescript/src/primitives/keyboard-avoider.d.ts.map +1 -1
- package/lib/typescript/src/primitives/scrim.d.ts +21 -0
- package/lib/typescript/src/primitives/scrim.d.ts.map +1 -0
- package/lib/typescript/src/utils/haptics.d.ts +12 -0
- package/lib/typescript/src/utils/haptics.d.ts.map +1 -0
- package/package.json +9 -1
- package/src/components/attachment/index.tsx +279 -0
- package/src/components/bottom-sheet/index.tsx +58 -2
- package/src/components/button/index.tsx +26 -5
- package/src/components/dialog/index.tsx +10 -1
- package/src/components/empty-state/index.tsx +60 -14
- package/src/components/frame/index.tsx +175 -29
- package/src/components/input/index.tsx +122 -16
- package/src/components/line-chart/index.tsx +1224 -0
- package/src/components/marker/index.tsx +194 -0
- package/src/components/message/index.tsx +29 -5
- package/src/components/message-scroller/index.tsx +574 -0
- package/src/components/popover/index.tsx +624 -0
- package/src/components/progress/index.tsx +81 -1
- package/src/components/radio-group/index.tsx +156 -18
- package/src/components/section-rail/index.tsx +459 -0
- package/src/components/select/index.tsx +265 -52
- package/src/components/separator/index.tsx +97 -0
- package/src/components/slider/index.tsx +371 -0
- package/src/components/surface/index.tsx +29 -3
- package/src/components/switch/index.tsx +8 -1
- package/src/components/tabs/index.tsx +208 -28
- package/src/components/toggle-button/index.tsx +374 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/use-keyboard-avoidance.ts +73 -7
- package/src/hooks/use-scroll-sections.ts +127 -0
- package/src/icons/index.tsx +48 -0
- package/src/index.ts +97 -6
- package/src/native/index.ts +13 -1
- package/src/primitives/keyboard-avoider.tsx +9 -1
- package/src/primitives/scrim.tsx +95 -0
- package/src/utils/haptics.ts +63 -0
- package/theme.css +64 -2
- package/lib/module/components/inline-select/index.js +0 -284
- package/lib/module/components/inline-select/index.js.map +0 -1
- package/lib/typescript/src/components/inline-select/index.d.ts +0 -48
- package/lib/typescript/src/components/inline-select/index.d.ts.map +0 -1
- package/src/components/inline-select/index.tsx +0 -332
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LineChart — a time series, drawn and animated on the UI thread.
|
|
3
|
+
*
|
|
4
|
+
* The chart is composed rather than configured: the grid, each series, the
|
|
5
|
+
* axis and the crosshair are separate children, so a chart that wants no grid
|
|
6
|
+
* simply does not have one. A single component with twenty booleans is how
|
|
7
|
+
* charts end up unreadable at the call site.
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <LineChart data={visits} xDataKey="date">
|
|
11
|
+
* <LineChart.Grid />
|
|
12
|
+
* <LineChart.Area dataKey="visits" />
|
|
13
|
+
* <LineChart.Line dataKey="visits" />
|
|
14
|
+
* <LineChart.XAxis />
|
|
15
|
+
* <LineChart.Tooltip />
|
|
16
|
+
* </LineChart>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Internally there are two layers, and the parts sort themselves into the
|
|
20
|
+
* right one: the geometry is SVG, and anything with text or a gesture on it is
|
|
21
|
+
* a React Native view laid over the top. That split is not a detail — SVG text
|
|
22
|
+
* ignores the platform's text scaling and the theme's font, and a gesture
|
|
23
|
+
* handler cannot be attached to an SVG node at all.
|
|
24
|
+
*
|
|
25
|
+
* Three things animate, each for a different reason:
|
|
26
|
+
*
|
|
27
|
+
* - **The reveal.** On mount the plot is uncovered left to right by an animated
|
|
28
|
+
* clip rectangle. Everything inside shares that clip, so the line, its fill
|
|
29
|
+
* and its markers arrive together rather than as three separate effects.
|
|
30
|
+
* - **The y-domain.** When the data changes the *scale* is tweened rather than
|
|
31
|
+
* the path swapped, so a series that grows is redrawn against a moving axis
|
|
32
|
+
* instead of jumping to a new shape. The reveal does not replay — it happened
|
|
33
|
+
* once, and repeating it on every refresh turns a data update into an
|
|
34
|
+
* animation.
|
|
35
|
+
* - **The crosshair.** A drag resolves the nearest index on the UI thread and
|
|
36
|
+
* moves the line and the dots from there. Only the index crosses back into
|
|
37
|
+
* JS, and only when it changes, so a drag costs a handful of re-renders
|
|
38
|
+
* rather than one per frame.
|
|
39
|
+
*
|
|
40
|
+
* Colours come from the `--color-chart-*` tokens, so a chart follows the active
|
|
41
|
+
* theme and is put on brand by overriding those five in the app's own
|
|
42
|
+
* global.css. Nothing here hardcodes a hex.
|
|
43
|
+
*/
|
|
44
|
+
import { type ReactNode } from 'react';
|
|
45
|
+
import { type ViewProps } from 'react-native';
|
|
46
|
+
/**
|
|
47
|
+
* Which layer a part belongs to. Read off the component itself, so composition
|
|
48
|
+
* stays a flat list of children instead of two nested slots the caller has to
|
|
49
|
+
* remember the order of.
|
|
50
|
+
*/
|
|
51
|
+
type Layer = 'svg' | 'overlay';
|
|
52
|
+
export type LineChartStatus = 'loading' | 'ready';
|
|
53
|
+
export type LineChartCurve = 'monotone' | 'linear';
|
|
54
|
+
export type LineChartDatum = Record<string, string | number | null | undefined>;
|
|
55
|
+
/**
|
|
56
|
+
* The point under the crosshair, for something rendered *inside* the chart.
|
|
57
|
+
*
|
|
58
|
+
* A readout usually belongs in the card's header, which is outside this
|
|
59
|
+
* provider — use `onActiveIndexChange` for that. A hook cannot reach up out of
|
|
60
|
+
* the subtree it is called in, and pretending otherwise is how a component
|
|
61
|
+
* ends up with a context that has to wrap half the screen.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useLineChart(): {
|
|
64
|
+
activeIndex: number;
|
|
65
|
+
activePoint: LineChartDatum | null;
|
|
66
|
+
xDataKey: string;
|
|
67
|
+
};
|
|
68
|
+
export interface LineChartProps extends ViewProps {
|
|
69
|
+
className?: string;
|
|
70
|
+
/** The rows. Each one is a point along the x-axis. */
|
|
71
|
+
data: LineChartDatum[];
|
|
72
|
+
/** Key holding the x label. Used by the axis and the crosshair readout. */
|
|
73
|
+
xDataKey?: string;
|
|
74
|
+
/**
|
|
75
|
+
* `loading` draws a flat skeleton with a sweep running along it, and morphs
|
|
76
|
+
* into the real series when it turns `ready`. One component throughout,
|
|
77
|
+
* rather than a spinner swapped for a chart — swapping loses the transition.
|
|
78
|
+
*/
|
|
79
|
+
status?: LineChartStatus;
|
|
80
|
+
/** Width ÷ height. `2` is the wide card shape; `1.6` suits a narrow column. */
|
|
81
|
+
aspectRatio?: number;
|
|
82
|
+
/** Milliseconds for the reveal on mount. */
|
|
83
|
+
animationDuration?: number;
|
|
84
|
+
/** Milliseconds for the y-axis to settle after the data changes. */
|
|
85
|
+
domainDuration?: number;
|
|
86
|
+
/** Fix the y-axis instead of deriving it from the data. */
|
|
87
|
+
yDomain?: [number, number];
|
|
88
|
+
/** `monotone` never overshoots between points; `linear` joins them straight. */
|
|
89
|
+
curve?: LineChartCurve;
|
|
90
|
+
/**
|
|
91
|
+
* The point under the crosshair as it moves, and `-1`/`null` when the finger
|
|
92
|
+
* lifts. This is how a readout in the card's header gets its value — that
|
|
93
|
+
* header is outside the chart, so it cannot use `useLineChart`.
|
|
94
|
+
*
|
|
95
|
+
* Fires when the index changes, not per frame.
|
|
96
|
+
*/
|
|
97
|
+
onActiveIndexChange?: (index: number, datum: LineChartDatum | null) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Drop the axis padding so the line reaches the edges — for a sparkline with
|
|
100
|
+
* no grid, axis or crosshair, where the shape is the whole point.
|
|
101
|
+
*/
|
|
102
|
+
compact?: boolean;
|
|
103
|
+
children?: ReactNode;
|
|
104
|
+
}
|
|
105
|
+
/** Imperative handle: re-run the reveal on demand, for a "replay" control. */
|
|
106
|
+
export interface LineChartHandle {
|
|
107
|
+
replay: () => void;
|
|
108
|
+
}
|
|
109
|
+
export interface LineChartGridProps {
|
|
110
|
+
/** Horizontal rules across the plot. */
|
|
111
|
+
rows?: number;
|
|
112
|
+
color?: string;
|
|
113
|
+
/** Dash pattern, e.g. `"4,6"`. Omit for a solid rule. */
|
|
114
|
+
dashArray?: string;
|
|
115
|
+
opacity?: number;
|
|
116
|
+
}
|
|
117
|
+
/** Horizontal reference lines. Drawn under everything, outside the reveal clip. */
|
|
118
|
+
declare function LineChartGrid({ rows, color, dashArray, opacity }: LineChartGridProps): import("react").JSX.Element;
|
|
119
|
+
declare namespace LineChartGrid {
|
|
120
|
+
var displayName: string;
|
|
121
|
+
var layer: Layer;
|
|
122
|
+
}
|
|
123
|
+
export interface LineChartLineProps {
|
|
124
|
+
/** Key holding this series' y values. */
|
|
125
|
+
dataKey: string;
|
|
126
|
+
/**
|
|
127
|
+
* Stroke colour. Defaults to the `--color-chart-*` token at `colorIndex`, so
|
|
128
|
+
* a series follows the theme without the call site naming a colour.
|
|
129
|
+
*/
|
|
130
|
+
color?: string;
|
|
131
|
+
/** Which `--color-chart-*` token to take when `color` is not given. */
|
|
132
|
+
colorIndex?: 1 | 2 | 3 | 4 | 5;
|
|
133
|
+
strokeWidth?: number;
|
|
134
|
+
/** Dash pattern, e.g. `"6,4"` — for a projection or a secondary series. */
|
|
135
|
+
dashArray?: string;
|
|
136
|
+
/** A dot at every point. Best kept for short series. */
|
|
137
|
+
showMarkers?: boolean;
|
|
138
|
+
}
|
|
139
|
+
/** One series. */
|
|
140
|
+
declare function LineChartLine({ dataKey, color, colorIndex, strokeWidth, dashArray, showMarkers, }: LineChartLineProps): import("react").JSX.Element;
|
|
141
|
+
declare namespace LineChartLine {
|
|
142
|
+
var displayName: string;
|
|
143
|
+
var layer: Layer;
|
|
144
|
+
}
|
|
145
|
+
export interface LineChartAreaProps {
|
|
146
|
+
dataKey: string;
|
|
147
|
+
color?: string;
|
|
148
|
+
colorIndex?: 1 | 2 | 3 | 4 | 5;
|
|
149
|
+
/** Opacity at the line. Fades to nothing at the baseline. */
|
|
150
|
+
opacity?: number;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The fill under a series. A separate child from the line, because a chart with
|
|
154
|
+
* two series usually wants the fill on only one of them — two translucent
|
|
155
|
+
* fills over each other make a third colour that means nothing.
|
|
156
|
+
*/
|
|
157
|
+
declare function LineChartArea({ dataKey, color, colorIndex, opacity }: LineChartAreaProps): import("react").JSX.Element;
|
|
158
|
+
declare namespace LineChartArea {
|
|
159
|
+
var displayName: string;
|
|
160
|
+
var layer: Layer;
|
|
161
|
+
}
|
|
162
|
+
export interface LineChartSkeletonProps {
|
|
163
|
+
/** Milliseconds for one pass of the sweep. */
|
|
164
|
+
duration?: number;
|
|
165
|
+
color?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The loading state: a flat rule where the series will be, with a highlight
|
|
169
|
+
* travelling along it. Drawn inside the same SVG rather than as an overlay, so
|
|
170
|
+
* arriving data is one tree changing rather than one view replacing another —
|
|
171
|
+
* which is what lets the flat line become the series instead of cutting to it.
|
|
172
|
+
*/
|
|
173
|
+
declare function LineChartSkeleton({ duration, color }: LineChartSkeletonProps): import("react").JSX.Element | null;
|
|
174
|
+
declare namespace LineChartSkeleton {
|
|
175
|
+
var displayName: string;
|
|
176
|
+
var layer: Layer;
|
|
177
|
+
}
|
|
178
|
+
export interface LineChartXAxisProps {
|
|
179
|
+
/** How many labels to show. The rest are dropped, evenly. */
|
|
180
|
+
ticks?: number;
|
|
181
|
+
/** Turn a row into its label. Defaults to the value at `xDataKey`. */
|
|
182
|
+
format?: (datum: LineChartDatum, index: number) => string;
|
|
183
|
+
className?: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The x labels. Real text rather than SVG text, so they follow the theme's font
|
|
187
|
+
* and the platform's text scaling — SVG text does neither.
|
|
188
|
+
*/
|
|
189
|
+
declare function LineChartXAxis({ ticks, format, className }: LineChartXAxisProps): import("react").JSX.Element;
|
|
190
|
+
declare namespace LineChartXAxis {
|
|
191
|
+
var displayName: string;
|
|
192
|
+
var layer: Layer;
|
|
193
|
+
}
|
|
194
|
+
export interface LineChartTooltipProps {
|
|
195
|
+
color?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Float a small label at the crosshair showing the x-value and each series'
|
|
198
|
+
* value at that point — the minimal readout a drag wants. On by default.
|
|
199
|
+
*/
|
|
200
|
+
showLabel?: boolean;
|
|
201
|
+
/** Format one series' value for the label. Defaults to a compact number. */
|
|
202
|
+
formatValue?: (value: number, key: string) => string;
|
|
203
|
+
/** Format the label's heading from the row. Defaults to the value at xDataKey. */
|
|
204
|
+
formatX?: (datum: LineChartDatum) => string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The crosshair, the gesture that drives it, and the label that rides it.
|
|
208
|
+
*
|
|
209
|
+
* They live in the view layer: a gesture handler cannot be attached to an SVG
|
|
210
|
+
* node, and once the gesture is a view the crosshair may as well be one too —
|
|
211
|
+
* a 1px view moved by `translateX` costs less than re-rendering an SVG line.
|
|
212
|
+
* The label follows on the UI thread the same way; only its *text* crosses back
|
|
213
|
+
* into JS, and only when the active index changes.
|
|
214
|
+
*
|
|
215
|
+
* The hit area is the whole plot. A crosshair you have to land on the line to
|
|
216
|
+
* summon is a crosshair nobody finds.
|
|
217
|
+
*/
|
|
218
|
+
declare function LineChartTooltip({ color, showLabel, formatValue, formatX }: LineChartTooltipProps): import("react").JSX.Element | null;
|
|
219
|
+
declare namespace LineChartTooltip {
|
|
220
|
+
var displayName: string;
|
|
221
|
+
var layer: Layer;
|
|
222
|
+
}
|
|
223
|
+
export interface LineChartLegendProps extends ViewProps {
|
|
224
|
+
className?: string;
|
|
225
|
+
/** Label per series key. A key with no label falls back to the key itself. */
|
|
226
|
+
labels?: Record<string, string>;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* A swatch and a name per registered series. Sits in the top-left of the plot
|
|
230
|
+
* by default — move it with `className`.
|
|
231
|
+
*/
|
|
232
|
+
declare function LineChartLegend({ className, labels, ...props }: LineChartLegendProps): import("react").JSX.Element;
|
|
233
|
+
declare namespace LineChartLegend {
|
|
234
|
+
var displayName: string;
|
|
235
|
+
var layer: Layer;
|
|
236
|
+
}
|
|
237
|
+
export declare const LineChart: import("react").ForwardRefExoticComponent<LineChartProps & import("react").RefAttributes<LineChartHandle>> & {
|
|
238
|
+
Grid: typeof LineChartGrid;
|
|
239
|
+
Area: typeof LineChartArea;
|
|
240
|
+
Line: typeof LineChartLine;
|
|
241
|
+
Skeleton: typeof LineChartSkeleton;
|
|
242
|
+
XAxis: typeof LineChartXAxis;
|
|
243
|
+
Tooltip: typeof LineChartTooltip;
|
|
244
|
+
Legend: typeof LineChartLegend;
|
|
245
|
+
};
|
|
246
|
+
export {};
|
|
247
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;AAqCxF;;;;GAIG;AACH,KAAK,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC;AAE/B,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;AAuChF;;;;;;;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;IACl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,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACrD,kFAAkF;IAClF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC;CAC7C;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,gBAAgB,CAAC,EAAE,KAAK,EAAE,SAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,qBAAqB,sCAoKjG;kBApKQ,gBAAgB;;;;AAoOzB,MAAM,WAAW,oBAAqB,SAAQ,SAAS;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED;;;GAGG;AACH,iBAAS,eAAe,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,oBAAoB,+BAmB7E;kBAnBQ,eAAe;;;;AAiMxB,eAAO,MAAM,SAAS;;;;;;;;CAQpB,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marker — an inline note in a conversation.
|
|
3
|
+
*
|
|
4
|
+
* Transcripts are not only messages. Between the turns sit things the
|
|
5
|
+
* conversation did rather than said: a tool that ran, a file that was read, a
|
|
6
|
+
* model that changed, the point where yesterday ended. Those are not messages
|
|
7
|
+
* and should not look like one — a bubble implies a speaker, and none of these
|
|
8
|
+
* have one. A marker is the quieter row that carries them: small, muted, and
|
|
9
|
+
* aligned to the transcript rather than to a side of it.
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Marker>
|
|
13
|
+
* <Marker.Icon><CheckIcon /></Marker.Icon>
|
|
14
|
+
* <Marker.Content>Explored 4 files</Marker.Content>
|
|
15
|
+
* </Marker>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* `shimmer` on the content is for the row that is still happening — the sweep
|
|
19
|
+
* runs through the glyphs while a step is in flight, and is dropped the moment
|
|
20
|
+
* it finishes.
|
|
21
|
+
*/
|
|
22
|
+
import { type ReactNode } from 'react';
|
|
23
|
+
import { View, type Text as RNText, type ViewProps } from 'react-native';
|
|
24
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
25
|
+
import { type AnimatedPressableProps } from '../../primitives/animated-pressable.js';
|
|
26
|
+
import { type TextProps } from '../../primitives/text.js';
|
|
27
|
+
type MarkerVariant = 'default' | 'border' | 'separator';
|
|
28
|
+
declare const markerVariants: import("tailwind-variants").TVReturnType<{
|
|
29
|
+
variant: {
|
|
30
|
+
/** The plain row: an icon and a line of muted text. */
|
|
31
|
+
default: {};
|
|
32
|
+
/** Same row, closed by a hairline — for a step that ends a section. */
|
|
33
|
+
border: {
|
|
34
|
+
root: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A centred label with a rule running out to each edge. The rules are
|
|
38
|
+
* `Separator`s rather than borders so they follow the same token and
|
|
39
|
+
* thickness as every other rule in the app.
|
|
40
|
+
*/
|
|
41
|
+
separator: {
|
|
42
|
+
root: string;
|
|
43
|
+
content: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
disabled: {
|
|
47
|
+
true: {
|
|
48
|
+
root: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}, {
|
|
52
|
+
root: string;
|
|
53
|
+
content: string;
|
|
54
|
+
}, undefined, {
|
|
55
|
+
variant: {
|
|
56
|
+
/** The plain row: an icon and a line of muted text. */
|
|
57
|
+
default: {};
|
|
58
|
+
/** Same row, closed by a hairline — for a step that ends a section. */
|
|
59
|
+
border: {
|
|
60
|
+
root: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A centred label with a rule running out to each edge. The rules are
|
|
64
|
+
* `Separator`s rather than borders so they follow the same token and
|
|
65
|
+
* thickness as every other rule in the app.
|
|
66
|
+
*/
|
|
67
|
+
separator: {
|
|
68
|
+
root: string;
|
|
69
|
+
content: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
disabled: {
|
|
73
|
+
true: {
|
|
74
|
+
root: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}, {
|
|
78
|
+
root: string;
|
|
79
|
+
content: string;
|
|
80
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
81
|
+
variant: {
|
|
82
|
+
/** The plain row: an icon and a line of muted text. */
|
|
83
|
+
default: {};
|
|
84
|
+
/** Same row, closed by a hairline — for a step that ends a section. */
|
|
85
|
+
border: {
|
|
86
|
+
root: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* A centred label with a rule running out to each edge. The rules are
|
|
90
|
+
* `Separator`s rather than borders so they follow the same token and
|
|
91
|
+
* thickness as every other rule in the app.
|
|
92
|
+
*/
|
|
93
|
+
separator: {
|
|
94
|
+
root: string;
|
|
95
|
+
content: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
disabled: {
|
|
99
|
+
true: {
|
|
100
|
+
root: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
}, {
|
|
104
|
+
root: string;
|
|
105
|
+
content: string;
|
|
106
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
107
|
+
export interface MarkerProps extends Omit<AnimatedPressableProps, 'children' | 'disabled'>, Omit<VariantProps<typeof markerVariants>, 'disabled'> {
|
|
108
|
+
className?: string;
|
|
109
|
+
disabled?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* `default` is the inline status row. `border` closes it with a hairline.
|
|
112
|
+
* `separator` centres the content between two rules — the "Yesterday"
|
|
113
|
+
* divider shape.
|
|
114
|
+
*/
|
|
115
|
+
variant?: MarkerVariant;
|
|
116
|
+
children?: ReactNode;
|
|
117
|
+
}
|
|
118
|
+
export interface MarkerIconProps extends ViewProps {
|
|
119
|
+
className?: string;
|
|
120
|
+
children?: ReactNode;
|
|
121
|
+
}
|
|
122
|
+
export interface MarkerContentProps extends TextProps {
|
|
123
|
+
className?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Sweep a highlight through the text, for a step that is still running.
|
|
126
|
+
* Drop it when the step finishes — a marker that shimmers forever reads as
|
|
127
|
+
* a stuck one.
|
|
128
|
+
*/
|
|
129
|
+
shimmer?: boolean;
|
|
130
|
+
children?: ReactNode;
|
|
131
|
+
}
|
|
132
|
+
export declare const Marker: import("react").ForwardRefExoticComponent<MarkerProps & import("react").RefAttributes<View>> & {
|
|
133
|
+
Icon: import("react").ForwardRefExoticComponent<MarkerIconProps & import("react").RefAttributes<View>>;
|
|
134
|
+
Content: import("react").ForwardRefExoticComponent<MarkerContentProps & import("react").RefAttributes<RNText>>;
|
|
135
|
+
};
|
|
136
|
+
export {};
|
|
137
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/marker/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAyC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,KAAK,IAAI,IAAI,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,wCAAqC,CAAC;AACrG,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,0BAAuB,CAAC;AAK7D,KAAK,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAExD,QAAA,MAAM,cAAc;;QAOd,uDAAuD;;QAEvD,uEAAuE;;;;QAEvE;;;;WAIG;;;;;;;;;;;;;;;;QARH,uDAAuD;;QAEvD,uEAAuE;;;;QAEvE;;;;WAIG;;;;;;;;;;;;;;;;QARH,uDAAuD;;QAEvD,uEAAuE;;;;QAEvE;;;;WAIG;;;;;;;;;;;;;;2CAUP,CAAC;AAKH,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,sBAAsB,EAAE,UAAU,GAAG,UAAU,CAAC,EAC3D,IAAI,CAAC,YAAY,CAAC,OAAO,cAAc,CAAC,EAAE,UAAU,CAAC;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAmDD,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AA6BD,MAAM,WAAW,kBAAmB,SAAQ,SAAS;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAsBD,eAAO,MAAM,MAAM;;;CAGjB,CAAC"}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
import { type ReactNode } from 'react';
|
|
24
|
-
import { View, type ViewProps } from 'react-native';
|
|
24
|
+
import { View, type GestureResponderEvent, type ViewProps } from 'react-native';
|
|
25
25
|
import { type VariantProps } from 'tailwind-variants';
|
|
26
26
|
import { type TextProps } from '../../primitives/text.js';
|
|
27
27
|
declare const messageVariants: import("tailwind-variants").TVReturnType<{
|
|
@@ -123,6 +123,13 @@ export interface MessageProps extends ViewProps, VariantProps<typeof messageVari
|
|
|
123
123
|
* this for you.
|
|
124
124
|
*/
|
|
125
125
|
stacked?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Fires on a long press anywhere on the turn — the gesture a chat uses to
|
|
128
|
+
* surface per-message actions (copy, reply, react). Open a menu from it; the
|
|
129
|
+
* component only exposes the press. When set, the whole row gains press
|
|
130
|
+
* feedback. A plain tap should still do nothing, so there is no `onPress`.
|
|
131
|
+
*/
|
|
132
|
+
onLongPress?: (event: GestureResponderEvent) => void;
|
|
126
133
|
children?: ReactNode;
|
|
127
134
|
}
|
|
128
135
|
export interface MessageGroupProps extends ViewProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/message/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/message/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAE,KAAK,qBAAqB,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,0BAAuB,CAAC;AAG7D,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAoCnB,CAAC;AAEH,KAAK,KAAK,GAAG,OAAO,GAAG,KAAK,CAAC;AAoB7B,MAAM,WAAW,YACf,SAAQ,SAAS,EACf,YAAY,CAAC,OAAO,eAAe,CAAC;IACtC,SAAS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
|
+
/**
|
|
2
|
+
* MessageScroller — the scroll behaviour a chat transcript needs.
|
|
3
|
+
*
|
|
4
|
+
* A transcript is the one list where the interesting end is the bottom, the
|
|
5
|
+
* content grows while you are reading it, and history is added to the top. A
|
|
6
|
+
* plain scroll view gets all three wrong: it opens at the top, it stays put
|
|
7
|
+
* while a reply streams in below the fold, and it jumps a screen when older
|
|
8
|
+
* messages load. This owns those three behaviours so a screen does not have to
|
|
9
|
+
* rebuild them.
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <MessageScroller autoScroll className="flex-1">
|
|
13
|
+
* <MessageScroller.Viewport>
|
|
14
|
+
* <MessageScroller.Content>
|
|
15
|
+
* {messages.map((m) => (
|
|
16
|
+
* <MessageScroller.Item key={m.id} messageId={m.id} scrollAnchor={m.role === 'user'}>
|
|
17
|
+
* <Message>…</Message>
|
|
18
|
+
* </MessageScroller.Item>
|
|
19
|
+
* ))}
|
|
20
|
+
* </MessageScroller.Content>
|
|
21
|
+
* </MessageScroller.Viewport>
|
|
22
|
+
* <MessageScroller.Button />
|
|
23
|
+
* </MessageScroller>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* The rule behind every part of it: **the reader's position is theirs**. New
|
|
27
|
+
* content follows the bottom only while they are already at the bottom, and
|
|
28
|
+
* scrolling away hands control back to them until they ask for it again.
|
|
29
|
+
* Content added above them never moves what they are looking at.
|
|
30
|
+
*
|
|
31
|
+
* Needs a bounded height — from `flex-1` in a column, or an explicit one.
|
|
32
|
+
* Given an unbounded parent it grows to fit its content and never scrolls.
|
|
33
|
+
*/
|
|
34
|
+
import { type ReactNode } from 'react';
|
|
35
|
+
import { type ViewProps } from 'react-native';
|
|
36
|
+
import { type AnimatedScrollViewProps } from 'react-native-reanimated';
|
|
37
|
+
export type MessageScrollerPosition = 'start' | 'end' | 'last-anchor';
|
|
38
|
+
/** Scroll commands, for a control that lives outside the viewport. */
|
|
39
|
+
export declare function useMessageScroller(): {
|
|
40
|
+
scrollToEnd: (animated?: boolean) => void;
|
|
41
|
+
scrollToStart: (animated?: boolean) => void;
|
|
42
|
+
scrollToMessage: (id: string, animated?: boolean) => void;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Where the reader is: the turn they are inside, and whether they are at the
|
|
46
|
+
* live edge. Both settle after a scroll rather than updating per frame — this
|
|
47
|
+
* is for a header that names the current turn, not for anything animated.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useMessageScrollerVisibility(): {
|
|
50
|
+
currentAnchorId: string | null;
|
|
51
|
+
atEnd: boolean;
|
|
52
|
+
};
|
|
53
|
+
export interface MessageScrollerProps extends ViewProps {
|
|
54
|
+
className?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Follow new content down as it arrives — but only while the reader is
|
|
57
|
+
* already at the bottom. Scrolling up disengages it until they come back or
|
|
58
|
+
* press the button.
|
|
59
|
+
*/
|
|
60
|
+
autoScroll?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Keep the reader on the same message when older ones are added above. Without
|
|
63
|
+
* it, loading history throws them a screen backwards.
|
|
64
|
+
*/
|
|
65
|
+
preserveScrollOnPrepend?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Where a freshly mounted transcript opens. `last-anchor` is the one to want
|
|
68
|
+
* for a saved thread: it lands on the last turn that started something,
|
|
69
|
+
* rather than at the very bottom of whatever the reply happened to be.
|
|
70
|
+
*/
|
|
71
|
+
defaultScrollPosition?: MessageScrollerPosition;
|
|
72
|
+
children?: ReactNode;
|
|
73
|
+
}
|
|
74
|
+
declare function MessageScrollerRoot({ className, autoScroll, preserveScrollOnPrepend, defaultScrollPosition, children, ...props }: MessageScrollerProps): import("react").JSX.Element;
|
|
75
|
+
declare namespace MessageScrollerRoot {
|
|
76
|
+
var displayName: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The four scroll events are owned by the component and taken off the props
|
|
80
|
+
* type rather than merged with a consumer's. They are not decoration on top of
|
|
81
|
+
* a scroll view — they *are* the behaviour, and a call site that quietly
|
|
82
|
+
* replaced one would look like a bug in the scrolling.
|
|
83
|
+
*/
|
|
84
|
+
export interface MessageScrollerViewportProps extends Omit<AnimatedScrollViewProps, 'onScroll' | 'onScrollEndDrag' | 'onMomentumScrollEnd' | 'onContentSizeChange'> {
|
|
85
|
+
className?: string;
|
|
86
|
+
children?: ReactNode;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The scrollable itself. Owns the three behaviours, because all three are
|
|
90
|
+
* reactions to scroll and content-size events and this is where they arrive.
|
|
91
|
+
*/
|
|
92
|
+
declare function MessageScrollerViewport({ className, children, ...props }: MessageScrollerViewportProps): import("react").JSX.Element;
|
|
93
|
+
declare namespace MessageScrollerViewport {
|
|
94
|
+
var displayName: string;
|
|
95
|
+
}
|
|
96
|
+
export interface MessageScrollerContentProps extends ViewProps {
|
|
97
|
+
className?: string;
|
|
98
|
+
children?: ReactNode;
|
|
99
|
+
}
|
|
100
|
+
/** The transcript column. Announces additions rather than the whole list. */
|
|
101
|
+
declare function MessageScrollerContent({ className, children, ...props }: MessageScrollerContentProps): import("react").JSX.Element;
|
|
102
|
+
declare namespace MessageScrollerContent {
|
|
103
|
+
var displayName: string;
|
|
104
|
+
}
|
|
105
|
+
export interface MessageScrollerItemProps extends ViewProps {
|
|
106
|
+
className?: string;
|
|
107
|
+
/** Stable id for this turn. `scrollToMessage` takes the same value. */
|
|
108
|
+
messageId: string;
|
|
109
|
+
/**
|
|
110
|
+
* Marks this row as the start of a turn. `defaultScrollPosition="last-anchor"`
|
|
111
|
+
* opens on the last one, and it is what a saved thread should land on — the
|
|
112
|
+
* question, not the tail of the answer to it.
|
|
113
|
+
*/
|
|
114
|
+
scrollAnchor?: boolean;
|
|
115
|
+
children?: ReactNode;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* One row of the transcript. It exists to be measured: without a boundary per
|
|
119
|
+
* turn there is nothing to scroll *to*, and nothing to measure the prepend
|
|
120
|
+
* shift against.
|
|
121
|
+
*/
|
|
122
|
+
declare function MessageScrollerItem({ className, messageId, scrollAnchor, children, ...props }: MessageScrollerItemProps): import("react").JSX.Element;
|
|
123
|
+
declare namespace MessageScrollerItem {
|
|
124
|
+
var displayName: string;
|
|
125
|
+
}
|
|
126
|
+
export interface MessageScrollerButtonProps extends ViewProps {
|
|
127
|
+
className?: string;
|
|
128
|
+
/** `end` jumps to the newest message, `start` to the beginning of the thread. */
|
|
129
|
+
target?: 'start' | 'end';
|
|
130
|
+
accessibilityLabel?: string;
|
|
131
|
+
children?: ReactNode;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The way back to the live edge, shown only when there is one to go back to.
|
|
135
|
+
*
|
|
136
|
+
* Its visibility is driven from the same shared value the scroll handler
|
|
137
|
+
* writes, so it fades on the UI thread while the transcript is still moving.
|
|
138
|
+
*/
|
|
139
|
+
declare function MessageScrollerButton({ className, target, accessibilityLabel, children, ...props }: MessageScrollerButtonProps): import("react").JSX.Element;
|
|
140
|
+
declare namespace MessageScrollerButton {
|
|
141
|
+
var displayName: string;
|
|
142
|
+
}
|
|
143
|
+
export declare const MessageScroller: typeof MessageScrollerRoot & {
|
|
144
|
+
Viewport: typeof MessageScrollerViewport;
|
|
145
|
+
Content: typeof MessageScrollerContent;
|
|
146
|
+
Item: typeof MessageScrollerItem;
|
|
147
|
+
Button: typeof MessageScrollerButton;
|
|
148
|
+
};
|
|
149
|
+
export {};
|
|
150
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/message-scroller/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAiB,EAQf,K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