panelui-native 0.98.0 → 0.100.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/lib/module/components/animated-badge/index.js +24 -2
- package/lib/module/components/animated-badge/index.js.map +1 -1
- package/lib/module/components/bump-chart/index.js +1236 -0
- package/lib/module/components/bump-chart/index.js.map +1 -0
- package/lib/module/components/image-viewer/image-viewer-geometry.js +203 -0
- package/lib/module/components/image-viewer/image-viewer-geometry.js.map +1 -0
- package/lib/module/components/image-viewer/index.js +1100 -0
- package/lib/module/components/image-viewer/index.js.map +1 -0
- package/lib/module/components/mirror-area-chart/index.js +1113 -0
- package/lib/module/components/mirror-area-chart/index.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/primitives/scrim.js +65 -1
- package/lib/module/primitives/scrim.js.map +1 -1
- package/lib/module/utils/chart.js +70 -0
- package/lib/module/utils/chart.js.map +1 -1
- package/lib/typescript/src/components/animated-badge/index.d.ts +5 -0
- package/lib/typescript/src/components/animated-badge/index.d.ts.map +1 -1
- package/lib/typescript/src/components/bump-chart/index.d.ts +267 -0
- package/lib/typescript/src/components/bump-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/image-viewer/image-viewer-geometry.d.ts +83 -0
- package/lib/typescript/src/components/image-viewer/image-viewer-geometry.d.ts.map +1 -0
- package/lib/typescript/src/components/image-viewer/index.d.ts +148 -0
- package/lib/typescript/src/components/image-viewer/index.d.ts.map +1 -0
- package/lib/typescript/src/components/mirror-area-chart/index.d.ts +263 -0
- package/lib/typescript/src/components/mirror-area-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/primitives/scrim.d.ts +11 -1
- package/lib/typescript/src/primitives/scrim.d.ts.map +1 -1
- package/lib/typescript/src/utils/chart.d.ts +23 -0
- package/lib/typescript/src/utils/chart.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/animated-badge/index.tsx +35 -2
- package/src/components/bump-chart/index.tsx +1455 -0
- package/src/components/image-viewer/image-viewer-geometry.ts +205 -0
- package/src/components/image-viewer/index.tsx +1329 -0
- package/src/components/mirror-area-chart/index.tsx +1333 -0
- package/src/index.ts +42 -0
- package/src/primitives/scrim.tsx +96 -1
- package/src/utils/chart.ts +70 -0
package/src/index.ts
CHANGED
|
@@ -569,6 +569,11 @@ export {
|
|
|
569
569
|
type ImageGenerationFieldProps,
|
|
570
570
|
type ImageGenerationStatus,
|
|
571
571
|
} from './components/image-generation';
|
|
572
|
+
export {
|
|
573
|
+
ImageViewer,
|
|
574
|
+
type ImageViewerProps,
|
|
575
|
+
type ImageViewerTriggerProps,
|
|
576
|
+
} from './components/image-viewer';
|
|
572
577
|
export { Input, type InputProps } from './components/input';
|
|
573
578
|
export {
|
|
574
579
|
InputGroup,
|
|
@@ -706,6 +711,25 @@ export {
|
|
|
706
711
|
type BubbleChartPoint,
|
|
707
712
|
type BubbleChartStatus,
|
|
708
713
|
} from './components/bubble-chart';
|
|
714
|
+
export {
|
|
715
|
+
BumpChart,
|
|
716
|
+
useBumpChart,
|
|
717
|
+
bumpRanks,
|
|
718
|
+
type BumpChartProps,
|
|
719
|
+
type BumpChartHandle,
|
|
720
|
+
type BumpChartHeaderProps,
|
|
721
|
+
type BumpChartGridProps,
|
|
722
|
+
type BumpChartLineProps,
|
|
723
|
+
type BumpChartSkeletonProps,
|
|
724
|
+
type BumpChartXAxisProps,
|
|
725
|
+
type BumpChartYAxisProps,
|
|
726
|
+
type BumpChartLabelsProps,
|
|
727
|
+
type BumpChartTooltipProps,
|
|
728
|
+
type BumpChartLegendProps,
|
|
729
|
+
type BumpChartStatus,
|
|
730
|
+
type BumpChartDatum,
|
|
731
|
+
type BumpRanks,
|
|
732
|
+
} from './components/bump-chart';
|
|
709
733
|
export {
|
|
710
734
|
PyramidChart,
|
|
711
735
|
usePyramidChart,
|
|
@@ -922,6 +946,24 @@ export {
|
|
|
922
946
|
type MessageScrollerButtonProps,
|
|
923
947
|
type MessageScrollerPosition,
|
|
924
948
|
} from './components/message-scroller';
|
|
949
|
+
export {
|
|
950
|
+
MirrorAreaChart,
|
|
951
|
+
useMirrorAreaChart,
|
|
952
|
+
type MirrorAreaChartProps,
|
|
953
|
+
type MirrorAreaChartHandle,
|
|
954
|
+
type MirrorAreaChartHeaderProps,
|
|
955
|
+
type MirrorAreaChartGridProps,
|
|
956
|
+
type MirrorAreaChartBaselineProps,
|
|
957
|
+
type MirrorAreaChartAreaProps,
|
|
958
|
+
type MirrorAreaChartSkeletonProps,
|
|
959
|
+
type MirrorAreaChartXAxisProps,
|
|
960
|
+
type MirrorAreaChartYAxisProps,
|
|
961
|
+
type MirrorAreaChartTooltipProps,
|
|
962
|
+
type MirrorAreaChartLegendProps,
|
|
963
|
+
type MirrorAreaChartStatus,
|
|
964
|
+
type MirrorAreaChartSide,
|
|
965
|
+
type MirrorAreaChartDatum,
|
|
966
|
+
} from './components/mirror-area-chart';
|
|
925
967
|
export {
|
|
926
968
|
Message,
|
|
927
969
|
type MessageProps,
|
package/src/primitives/scrim.tsx
CHANGED
|
@@ -17,7 +17,13 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { useEffect, useState, type ComponentType } from 'react';
|
|
19
19
|
import { AccessibilityInfo, StyleSheet, View, type ViewProps } from 'react-native';
|
|
20
|
-
import Animated, {
|
|
20
|
+
import Animated, {
|
|
21
|
+
FadeIn,
|
|
22
|
+
FadeOut,
|
|
23
|
+
useAnimatedProps,
|
|
24
|
+
useAnimatedStyle,
|
|
25
|
+
type DerivedValue,
|
|
26
|
+
} from 'react-native-reanimated';
|
|
21
27
|
|
|
22
28
|
type BlurTint = 'light' | 'dark' | 'default' | 'systemMaterial';
|
|
23
29
|
|
|
@@ -46,6 +52,15 @@ const BlurView: ComponentType<BlurViewProps> | null = (() => {
|
|
|
46
52
|
/** True when a real blur can be drawn — for a caller that wants to know. */
|
|
47
53
|
export const hasBlur = BlurView !== null;
|
|
48
54
|
|
|
55
|
+
/**
|
|
56
|
+
* The same view, able to take its `intensity` from the UI thread. The package
|
|
57
|
+
* names the native view as the one to animate, so the radius itself moves
|
|
58
|
+
* rather than a finished blur being faded in over the page.
|
|
59
|
+
*/
|
|
60
|
+
const AnimatedBlurView = BlurView
|
|
61
|
+
? Animated.createAnimatedComponent(BlurView as ComponentType<BlurViewProps>)
|
|
62
|
+
: null;
|
|
63
|
+
|
|
49
64
|
type ReduceTransparencySource = {
|
|
50
65
|
isReduceTransparencyEnabled?: () => Promise<boolean>;
|
|
51
66
|
addEventListener?: (
|
|
@@ -160,6 +175,15 @@ export interface ScrimProps extends Omit<ViewProps, 'children'> {
|
|
|
160
175
|
* opaque Reduce Transparency fallback. A popover passes a lighter one than a dialog.
|
|
161
176
|
*/
|
|
162
177
|
dimClassName?: string;
|
|
178
|
+
/**
|
|
179
|
+
* How far the backdrop is in, from `0` to `1`, read on the UI thread.
|
|
180
|
+
*
|
|
181
|
+
* For an overlay the finger can pull partway out — a viewer dragged towards
|
|
182
|
+
* dismissal — where the backdrop has to follow the finger instead of running
|
|
183
|
+
* its own fade. The blur's radius tracks it, and the dim and the opaque
|
|
184
|
+
* fallback track it as opacity. Left out, the scrim fades itself in and out.
|
|
185
|
+
*/
|
|
186
|
+
progress?: DerivedValue<number>;
|
|
163
187
|
}
|
|
164
188
|
|
|
165
189
|
export function Scrim({
|
|
@@ -167,12 +191,27 @@ export function Scrim({
|
|
|
167
191
|
intensity = 24,
|
|
168
192
|
tint = 'default',
|
|
169
193
|
dimClassName = 'bg-black/50',
|
|
194
|
+
progress,
|
|
170
195
|
style,
|
|
171
196
|
...props
|
|
172
197
|
}: ScrimProps) {
|
|
173
198
|
const reduceTransparency = useReduceTransparency();
|
|
174
199
|
const mode = scrimMode(blur, BlurView !== null, reduceTransparency);
|
|
175
200
|
|
|
201
|
+
if (progress) {
|
|
202
|
+
return (
|
|
203
|
+
<ProgressScrim
|
|
204
|
+
mode={mode}
|
|
205
|
+
progress={progress}
|
|
206
|
+
intensity={intensity}
|
|
207
|
+
tint={tint}
|
|
208
|
+
dimClassName={dimClassName}
|
|
209
|
+
style={style}
|
|
210
|
+
{...props}
|
|
211
|
+
/>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
176
215
|
if (mode === 'blur' && BlurView) {
|
|
177
216
|
return (
|
|
178
217
|
<Animated.View
|
|
@@ -219,3 +258,59 @@ export function Scrim({
|
|
|
219
258
|
}
|
|
220
259
|
|
|
221
260
|
Scrim.displayName = 'Scrim';
|
|
261
|
+
|
|
262
|
+
interface ProgressScrimProps extends Omit<ViewProps, 'children'> {
|
|
263
|
+
mode: ScrimMode;
|
|
264
|
+
progress: DerivedValue<number>;
|
|
265
|
+
intensity: number;
|
|
266
|
+
tint: BlurTint;
|
|
267
|
+
dimClassName: string;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** The scrim with its three layers driven by a shared value instead of a fade. */
|
|
271
|
+
function ProgressScrim({
|
|
272
|
+
mode,
|
|
273
|
+
progress,
|
|
274
|
+
intensity,
|
|
275
|
+
tint,
|
|
276
|
+
dimClassName,
|
|
277
|
+
style,
|
|
278
|
+
...props
|
|
279
|
+
}: ProgressScrimProps) {
|
|
280
|
+
const blurProps = useAnimatedProps(() => ({
|
|
281
|
+
intensity: Math.min(Math.max(progress.value, 0), 1) * intensity,
|
|
282
|
+
}));
|
|
283
|
+
const fade = useAnimatedStyle(() => ({
|
|
284
|
+
opacity: Math.min(Math.max(progress.value, 0), 1),
|
|
285
|
+
}));
|
|
286
|
+
|
|
287
|
+
if (mode === 'blur' && AnimatedBlurView) {
|
|
288
|
+
return (
|
|
289
|
+
<View style={[StyleSheet.absoluteFill, style]} {...props}>
|
|
290
|
+
<AnimatedBlurView
|
|
291
|
+
tint={tint}
|
|
292
|
+
animatedProps={blurProps}
|
|
293
|
+
style={StyleSheet.absoluteFill}
|
|
294
|
+
/>
|
|
295
|
+
<Animated.View
|
|
296
|
+
pointerEvents="none"
|
|
297
|
+
style={[StyleSheet.absoluteFill, fade]}
|
|
298
|
+
className="bg-black/10"
|
|
299
|
+
/>
|
|
300
|
+
</View>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return (
|
|
305
|
+
<Animated.View style={[StyleSheet.absoluteFill, fade, style]} {...props}>
|
|
306
|
+
{mode === 'opaque' ? (
|
|
307
|
+
<View
|
|
308
|
+
pointerEvents="none"
|
|
309
|
+
style={StyleSheet.absoluteFill}
|
|
310
|
+
className={opaqueClassName(tint)}
|
|
311
|
+
/>
|
|
312
|
+
) : null}
|
|
313
|
+
<View pointerEvents="none" style={StyleSheet.absoluteFill} className={dimClassName} />
|
|
314
|
+
</Animated.View>
|
|
315
|
+
);
|
|
316
|
+
}
|
package/src/utils/chart.ts
CHANGED
|
@@ -560,6 +560,76 @@ export function areaPath(
|
|
|
560
560
|
.join(' ');
|
|
561
561
|
}
|
|
562
562
|
|
|
563
|
+
/**
|
|
564
|
+
* A colour as a gradient stop: the colour without its alpha, and the alpha as
|
|
565
|
+
* the stop's opacity. A `<Stop>` given `rgba(255,255,255,0.13)` as its colour
|
|
566
|
+
* draws it opaque on native, so a translucent token such as `--color-skeleton`
|
|
567
|
+
* comes out solid white in a dark theme.
|
|
568
|
+
*/
|
|
569
|
+
export function colorStop(color: string): { stopColor: string; stopOpacity: number } {
|
|
570
|
+
const value = color.trim();
|
|
571
|
+
const clamp = (alpha: number) => (Number.isFinite(alpha) ? Math.min(Math.max(alpha, 0), 1) : 1);
|
|
572
|
+
|
|
573
|
+
// #rgba and #rrggbbaa
|
|
574
|
+
if (/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.test(value)) {
|
|
575
|
+
const body =
|
|
576
|
+
value.length === 5
|
|
577
|
+
? value
|
|
578
|
+
.slice(1)
|
|
579
|
+
.split('')
|
|
580
|
+
.map((digit) => digit + digit)
|
|
581
|
+
.join('')
|
|
582
|
+
: value.slice(1);
|
|
583
|
+
return {
|
|
584
|
+
stopColor: `#${body.slice(0, 6)}`,
|
|
585
|
+
stopOpacity: clamp(parseInt(body.slice(6, 8), 16) / 255),
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// rgba(r, g, b, a) and rgb(r g b / a)
|
|
590
|
+
const match = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)\s*[,/]\s*([\d.]+%?)\s*\)$/i.exec(value);
|
|
591
|
+
if (match) {
|
|
592
|
+
const raw = match[4]!;
|
|
593
|
+
const alpha = raw.endsWith('%') ? Number(raw.slice(0, -1)) / 100 : Number(raw);
|
|
594
|
+
return { stopColor: `rgb(${match[1]}, ${match[2]}, ${match[3]})`, stopOpacity: clamp(alpha) };
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
return { stopColor: value, stopOpacity: 1 };
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* One unbroken run of points joined by S-curves, for a chart of positions.
|
|
602
|
+
*
|
|
603
|
+
* Each join leaves one point level and arrives at the next one level, with
|
|
604
|
+
* both control points at the midpoint between them. A line that holds its
|
|
605
|
+
* position stays flat, and a line that changes position crosses over in the
|
|
606
|
+
* middle of the gap. The monotone curve suits values, not places: it bends
|
|
607
|
+
* through every point, so a series holding its rank would still look like it
|
|
608
|
+
* was moving.
|
|
609
|
+
*/
|
|
610
|
+
export function bumpSegment(points: ChartPoint[]): string {
|
|
611
|
+
'worklet';
|
|
612
|
+
if (!points.length) return '';
|
|
613
|
+
let d = `M${points[0]!.x},${points[0]!.y}`;
|
|
614
|
+
for (let i = 1; i < points.length; i += 1) {
|
|
615
|
+
const from = points[i - 1]!;
|
|
616
|
+
const to = points[i]!;
|
|
617
|
+
const mid = (from.x + to.x) / 2;
|
|
618
|
+
d += ` C${mid},${from.y} ${mid},${to.y} ${to.x},${to.y}`;
|
|
619
|
+
}
|
|
620
|
+
return d;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/** A dot at every point, as one path, so a series' markers cost one node. */
|
|
624
|
+
export function dotsPath(points: ChartPoint[], radius: number): string {
|
|
625
|
+
'worklet';
|
|
626
|
+
let d = '';
|
|
627
|
+
for (const point of points) {
|
|
628
|
+
d += `M${point.x - radius},${point.y} a${radius},${radius} 0 1,0 ${radius * 2},0 a${radius},${radius} 0 1,0 ${-radius * 2},0 `;
|
|
629
|
+
}
|
|
630
|
+
return d;
|
|
631
|
+
}
|
|
632
|
+
|
|
563
633
|
/**
|
|
564
634
|
* A rounded rectangle, built as a path rather than drawn as a `Rect`.
|
|
565
635
|
*
|