panelui-native 0.22.6 → 0.25.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 +1 -0
- package/lib/module/components/area-chart/index.js +826 -0
- package/lib/module/components/area-chart/index.js.map +1 -0
- package/lib/module/components/avatar/index.js +1 -1
- package/lib/module/components/avatar/index.js.map +1 -1
- package/lib/module/components/bar-chart/index.js +853 -0
- package/lib/module/components/bar-chart/index.js.map +1 -0
- package/lib/module/components/bottom-sheet/index.js +207 -23
- package/lib/module/components/bottom-sheet/index.js.map +1 -1
- package/lib/module/components/breadcrumb/index.js +275 -0
- package/lib/module/components/breadcrumb/index.js.map +1 -0
- package/lib/module/components/chip/index.js +2 -2
- package/lib/module/components/direction/index.js +13 -19
- package/lib/module/components/direction/index.js.map +1 -1
- package/lib/module/components/frame/index.js +17 -0
- package/lib/module/components/frame/index.js.map +1 -1
- package/lib/module/components/heatmap-chart/index.js +28 -8
- package/lib/module/components/heatmap-chart/index.js.map +1 -1
- package/lib/module/components/input-group/index.js +2 -2
- package/lib/module/components/input-group/index.js.map +1 -1
- package/lib/module/components/line-chart/index.js +4 -146
- package/lib/module/components/line-chart/index.js.map +1 -1
- package/lib/module/components/loader/index.js +758 -0
- package/lib/module/components/loader/index.js.map +1 -0
- package/lib/module/components/map/basemap.js +265 -0
- package/lib/module/components/map/basemap.js.map +1 -0
- package/lib/module/components/map/index.js +850 -0
- package/lib/module/components/map/index.js.map +1 -0
- package/lib/module/components/map/maplibre.js +87 -0
- package/lib/module/components/map/maplibre.js.map +1 -0
- package/lib/module/components/message/index.js +8 -7
- package/lib/module/components/message/index.js.map +1 -1
- package/lib/module/components/otp-input/index.js +2 -2
- package/lib/module/components/progress/index.js +8 -2
- package/lib/module/components/progress/index.js.map +1 -1
- package/lib/module/components/ring-chart/index.js +423 -0
- package/lib/module/components/ring-chart/index.js.map +1 -0
- package/lib/module/components/section-rail/index.js +2 -2
- package/lib/module/components/separator/index.js +76 -22
- package/lib/module/components/separator/index.js.map +1 -1
- package/lib/module/components/shimmer/index.js +10 -1
- package/lib/module/components/shimmer/index.js.map +1 -1
- package/lib/module/components/slider/index.js +19 -5
- package/lib/module/components/slider/index.js.map +1 -1
- package/lib/module/components/steps/index.js +1 -1
- package/lib/module/components/switch/index.js +6 -1
- package/lib/module/components/switch/index.js.map +1 -1
- package/lib/module/components/typography/index.js +5 -0
- package/lib/module/components/typography/index.js.map +1 -1
- package/lib/module/hooks/use-direction.js +43 -0
- package/lib/module/hooks/use-direction.js.map +1 -0
- package/lib/module/icons/index.js +117 -2
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/index.js +8 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/primitives/text.js +30 -10
- package/lib/module/primitives/text.js.map +1 -1
- package/lib/module/utils/chart.js +279 -0
- package/lib/module/utils/chart.js.map +1 -0
- package/lib/typescript/src/components/area-chart/index.d.ts +197 -0
- package/lib/typescript/src/components/area-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/bar-chart/index.d.ts +228 -0
- package/lib/typescript/src/components/bar-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/bottom-sheet/index.d.ts +75 -4
- package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
- package/lib/typescript/src/components/breadcrumb/index.d.ts +100 -0
- package/lib/typescript/src/components/breadcrumb/index.d.ts.map +1 -0
- package/lib/typescript/src/components/direction/index.d.ts +11 -10
- package/lib/typescript/src/components/direction/index.d.ts.map +1 -1
- package/lib/typescript/src/components/frame/index.d.ts +17 -0
- package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
- package/lib/typescript/src/components/heatmap-chart/index.d.ts +22 -3
- package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/line-chart/index.d.ts +1 -0
- package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/loader/index.d.ts +38 -0
- package/lib/typescript/src/components/loader/index.d.ts.map +1 -0
- package/lib/typescript/src/components/map/basemap.d.ts +76 -0
- package/lib/typescript/src/components/map/basemap.d.ts.map +1 -0
- package/lib/typescript/src/components/map/index.d.ts +367 -0
- package/lib/typescript/src/components/map/index.d.ts.map +1 -0
- package/lib/typescript/src/components/map/maplibre.d.ts +193 -0
- package/lib/typescript/src/components/map/maplibre.d.ts.map +1 -0
- package/lib/typescript/src/components/message/index.d.ts.map +1 -1
- package/lib/typescript/src/components/progress/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ring-chart/index.d.ts +156 -0
- package/lib/typescript/src/components/ring-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/separator/index.d.ts +36 -1
- package/lib/typescript/src/components/separator/index.d.ts.map +1 -1
- package/lib/typescript/src/components/shimmer/index.d.ts.map +1 -1
- package/lib/typescript/src/components/slider/index.d.ts.map +1 -1
- package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
- package/lib/typescript/src/components/typography/index.d.ts +6 -0
- package/lib/typescript/src/components/typography/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/use-direction.d.ts +20 -0
- package/lib/typescript/src/hooks/use-direction.d.ts.map +1 -0
- package/lib/typescript/src/icons/index.d.ts +5 -0
- package/lib/typescript/src/icons/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +9 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/primitives/text.d.ts.map +1 -1
- package/lib/typescript/src/utils/chart.d.ts +96 -0
- package/lib/typescript/src/utils/chart.d.ts.map +1 -0
- package/package.json +9 -1
- package/src/components/area-chart/index.tsx +994 -0
- package/src/components/avatar/index.tsx +1 -1
- package/src/components/bar-chart/index.tsx +1048 -0
- package/src/components/bottom-sheet/index.tsx +280 -20
- package/src/components/breadcrumb/index.tsx +365 -0
- package/src/components/chip/index.tsx +2 -2
- package/src/components/direction/index.tsx +20 -21
- package/src/components/frame/index.tsx +17 -0
- package/src/components/heatmap-chart/index.tsx +58 -11
- package/src/components/input-group/index.tsx +2 -2
- package/src/components/line-chart/index.tsx +13 -181
- package/src/components/loader/index.tsx +812 -0
- package/src/components/map/basemap.ts +304 -0
- package/src/components/map/index.tsx +1118 -0
- package/src/components/map/maplibre.ts +201 -0
- package/src/components/message/index.tsx +8 -7
- package/src/components/otp-input/index.tsx +2 -2
- package/src/components/progress/index.tsx +10 -2
- package/src/components/ring-chart/index.tsx +543 -0
- package/src/components/section-rail/index.tsx +2 -2
- package/src/components/separator/index.tsx +77 -19
- package/src/components/shimmer/index.tsx +10 -1
- package/src/components/slider/index.tsx +20 -5
- package/src/components/steps/index.tsx +1 -1
- package/src/components/switch/index.tsx +6 -1
- package/src/components/typography/index.tsx +5 -0
- package/src/hooks/use-direction.ts +45 -0
- package/src/icons/index.tsx +66 -0
- package/src/index.ts +84 -0
- package/src/primitives/text.tsx +25 -7
- package/src/utils/chart.ts +355 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bridge to MapLibre.
|
|
3
|
+
*
|
|
4
|
+
* A map is the one component here that cannot be drawn in JavaScript. It needs
|
|
5
|
+
* a renderer with the tiles, the projection and the GPU work already solved,
|
|
6
|
+
* and that renderer is native code — which means `Map` is the only component
|
|
7
|
+
* in the library with a dependency you have to build for.
|
|
8
|
+
*
|
|
9
|
+
* Two things follow, and both are handled here rather than spread through the
|
|
10
|
+
* component:
|
|
11
|
+
*
|
|
12
|
+
* The package is resolved lazily and once. A project that never renders a map
|
|
13
|
+
* installs nothing, and the failure when it is missing is a readable fallback
|
|
14
|
+
* rather than a red screen — which matters because the most common way to hit
|
|
15
|
+
* it is running in a client that cannot load native modules at all.
|
|
16
|
+
*
|
|
17
|
+
* The types are declared here rather than imported from the package. They are
|
|
18
|
+
* structural and cover only what is used. Importing them would put the package
|
|
19
|
+
* in the library's published type surface, so anyone installing PanelUI would
|
|
20
|
+
* have to install a map renderer to typecheck their project, whether or not
|
|
21
|
+
* they ever draw a map.
|
|
22
|
+
*
|
|
23
|
+
* The cost of that choice is that nothing checks these declarations against the
|
|
24
|
+
* renderer, and React Native drops props it does not recognise without a word —
|
|
25
|
+
* so a renamed prop is silently ignored rather than caught. They track the
|
|
26
|
+
* renderer's **v11** API. When the peer range widens, re-read the props used
|
|
27
|
+
* below against the package rather than assuming they survived.
|
|
28
|
+
*/
|
|
29
|
+
import type { ComponentType, ReactElement, ReactNode, Ref } from 'react';
|
|
30
|
+
|
|
31
|
+
/** `[longitude, latitude]` — the order the style spec uses, not the spoken one. */
|
|
32
|
+
export type LngLat = [number, number];
|
|
33
|
+
|
|
34
|
+
/** `[west, south, east, north]`. */
|
|
35
|
+
export type LngLatBounds = [number, number, number, number];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A MapLibre style document. Left loose on purpose: the spec is large, it is
|
|
39
|
+
* versioned separately from this library, and the parts of it callers pass
|
|
40
|
+
* through are exactly the parts a narrower type would get in the way of.
|
|
41
|
+
*/
|
|
42
|
+
export type StyleSpecification = Record<string, unknown>;
|
|
43
|
+
|
|
44
|
+
/** Where the map is looking. */
|
|
45
|
+
export interface ViewState {
|
|
46
|
+
center: LngLat;
|
|
47
|
+
zoom: number;
|
|
48
|
+
bearing: number;
|
|
49
|
+
pitch: number;
|
|
50
|
+
bounds: LngLatBounds;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface MapRef {
|
|
54
|
+
getCenter(): Promise<LngLat>;
|
|
55
|
+
getZoom(): Promise<number>;
|
|
56
|
+
getBearing(): Promise<number>;
|
|
57
|
+
getPitch(): Promise<number>;
|
|
58
|
+
getBounds(): Promise<LngLatBounds>;
|
|
59
|
+
getViewState(): Promise<ViewState>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Pixel insets held off the edges of the viewport. */
|
|
63
|
+
export interface ViewPadding {
|
|
64
|
+
top?: number;
|
|
65
|
+
right?: number;
|
|
66
|
+
bottom?: number;
|
|
67
|
+
left?: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Zoom, tilt and rotation — everything about the camera except where it sits. */
|
|
71
|
+
export interface CameraOptions {
|
|
72
|
+
zoom?: number;
|
|
73
|
+
bearing?: number;
|
|
74
|
+
pitch?: number;
|
|
75
|
+
padding?: ViewPadding;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** How the camera gets there. */
|
|
79
|
+
export interface CameraAnimationOptions {
|
|
80
|
+
duration?: number;
|
|
81
|
+
easing?: 'linear' | 'ease' | 'fly';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Where the camera starts. Either a centre or a box, never both — the renderer
|
|
86
|
+
* types them as a union for the same reason: a camera framing a box has no
|
|
87
|
+
* separate centre to honour.
|
|
88
|
+
*/
|
|
89
|
+
export type InitialViewState =
|
|
90
|
+
| (CameraOptions & { center?: never; bounds?: never })
|
|
91
|
+
| (CameraOptions & { center: LngLat; bounds?: never })
|
|
92
|
+
| (CameraOptions & { bounds: LngLatBounds; center?: never });
|
|
93
|
+
|
|
94
|
+
export interface CameraRef {
|
|
95
|
+
jumpTo(options: { center: LngLat } & CameraOptions): void;
|
|
96
|
+
easeTo(options: { center?: LngLat } & CameraOptions & CameraAnimationOptions): void;
|
|
97
|
+
flyTo(options: { center?: LngLat } & CameraOptions & CameraAnimationOptions): void;
|
|
98
|
+
fitBounds(
|
|
99
|
+
bounds: LngLatBounds,
|
|
100
|
+
options?: CameraOptions & CameraAnimationOptions
|
|
101
|
+
): void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** A native event as it arrives — the payload is under `nativeEvent`. */
|
|
105
|
+
export interface NativeEvent<T> {
|
|
106
|
+
nativeEvent: T;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface MapLibreModule {
|
|
110
|
+
Map: ComponentType<{
|
|
111
|
+
ref?: Ref<MapRef>;
|
|
112
|
+
mapStyle: string | StyleSpecification;
|
|
113
|
+
style?: unknown;
|
|
114
|
+
logo?: boolean;
|
|
115
|
+
compass?: boolean;
|
|
116
|
+
attribution?: boolean;
|
|
117
|
+
scaleBar?: boolean;
|
|
118
|
+
dragPan?: boolean;
|
|
119
|
+
touchZoom?: boolean;
|
|
120
|
+
touchRotate?: boolean;
|
|
121
|
+
touchPitch?: boolean;
|
|
122
|
+
onPress?: (event: NativeEvent<{ coordinates: LngLat }>) => void;
|
|
123
|
+
onDidFinishLoadingMap?: () => void;
|
|
124
|
+
onRegionDidChange?: (event: NativeEvent<ViewState>) => void;
|
|
125
|
+
children?: ReactNode;
|
|
126
|
+
}>;
|
|
127
|
+
Camera: ComponentType<{
|
|
128
|
+
ref?: Ref<CameraRef>;
|
|
129
|
+
/**
|
|
130
|
+
* The camera's opening position. Applied once, on the first frame — every
|
|
131
|
+
* move after this one goes through the ref, so a re-render never yanks the
|
|
132
|
+
* map back out from under a gesture.
|
|
133
|
+
*/
|
|
134
|
+
initialViewState?: InitialViewState;
|
|
135
|
+
center?: LngLat;
|
|
136
|
+
bounds?: LngLatBounds;
|
|
137
|
+
zoom?: number;
|
|
138
|
+
bearing?: number;
|
|
139
|
+
pitch?: number;
|
|
140
|
+
minZoom?: number;
|
|
141
|
+
maxZoom?: number;
|
|
142
|
+
maxBounds?: LngLatBounds;
|
|
143
|
+
padding?: ViewPadding;
|
|
144
|
+
}>;
|
|
145
|
+
Marker: ComponentType<{
|
|
146
|
+
id?: string;
|
|
147
|
+
lngLat: LngLat;
|
|
148
|
+
anchor?: string;
|
|
149
|
+
children: ReactElement;
|
|
150
|
+
}>;
|
|
151
|
+
Callout: ComponentType<{ title?: string; children?: ReactNode; style?: unknown }>;
|
|
152
|
+
GeoJSONSource: ComponentType<{
|
|
153
|
+
id?: string;
|
|
154
|
+
data: unknown;
|
|
155
|
+
cluster?: boolean;
|
|
156
|
+
clusterRadius?: number;
|
|
157
|
+
clusterMaxZoom?: number;
|
|
158
|
+
lineMetrics?: boolean;
|
|
159
|
+
onPress?: (event: NativeEvent<{ features: unknown[] }>) => void;
|
|
160
|
+
children?: ReactNode;
|
|
161
|
+
}>;
|
|
162
|
+
Layer: ComponentType<Record<string, unknown>>;
|
|
163
|
+
UserLocation: ComponentType<{
|
|
164
|
+
animated?: boolean;
|
|
165
|
+
accuracy?: boolean;
|
|
166
|
+
heading?: boolean;
|
|
167
|
+
minDisplacement?: number;
|
|
168
|
+
onPress?: () => void;
|
|
169
|
+
children?: ReactNode;
|
|
170
|
+
}>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The renderer, or null when it is not installed. Resolved once at module
|
|
175
|
+
* load — the require is cheap, and caching it keeps a try/catch out of render.
|
|
176
|
+
*/
|
|
177
|
+
const maplibre: MapLibreModule | null = (() => {
|
|
178
|
+
try {
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
180
|
+
return require('@maplibre/maplibre-react-native') as MapLibreModule;
|
|
181
|
+
} catch {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
})();
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* True when a map can actually be drawn.
|
|
188
|
+
*
|
|
189
|
+
* False in any client that cannot load native modules, and in any project that
|
|
190
|
+
* has not installed the renderer. Worth checking before routing somewhere whose
|
|
191
|
+
* whole content is a map.
|
|
192
|
+
*/
|
|
193
|
+
export const hasMapLibre = maplibre !== null;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The renderer's components, or null.
|
|
197
|
+
*
|
|
198
|
+
* Returned as one object rather than as separate exports so a caller destructures
|
|
199
|
+
* once after a single null check, instead of narrowing each component in turn.
|
|
200
|
+
*/
|
|
201
|
+
export const MapLibre = maplibre;
|
|
@@ -54,19 +54,20 @@ const messageVariants = tv({
|
|
|
54
54
|
root: 'flex-row justify-start',
|
|
55
55
|
content: 'items-start',
|
|
56
56
|
// A squared corner on the side the message comes from points the
|
|
57
|
-
// bubble back at its sender.
|
|
58
|
-
|
|
57
|
+
// bubble back at its sender. Logical, so "the side it comes from"
|
|
58
|
+
// stays true when the script runs the other way.
|
|
59
|
+
bubble: 'rounded-es-md bg-muted',
|
|
59
60
|
bubbleContent: 'text-foreground',
|
|
60
|
-
header: 'text-
|
|
61
|
-
footer: 'text-
|
|
61
|
+
header: 'text-start',
|
|
62
|
+
footer: 'text-start',
|
|
62
63
|
},
|
|
63
64
|
end: {
|
|
64
65
|
root: 'flex-row-reverse justify-start',
|
|
65
66
|
content: 'items-end',
|
|
66
|
-
bubble: 'rounded-
|
|
67
|
+
bubble: 'rounded-ee-md bg-primary',
|
|
67
68
|
bubbleContent: 'text-primary-foreground',
|
|
68
|
-
header: 'text-
|
|
69
|
-
footer: 'text-
|
|
69
|
+
header: 'text-end',
|
|
70
|
+
footer: 'text-end',
|
|
70
71
|
},
|
|
71
72
|
},
|
|
72
73
|
},
|
|
@@ -323,7 +323,7 @@ export const OtpInput = forwardRef<TextInput, OtpInputProps>(
|
|
|
323
323
|
placeholder={placeholder}
|
|
324
324
|
invalid={invalid}
|
|
325
325
|
className={slots.cell({
|
|
326
|
-
className: `${i > 0 ? '
|
|
326
|
+
className: `${i > 0 ? 'ms-2' : ''} ${cellClassName ?? ''}`,
|
|
327
327
|
})}
|
|
328
328
|
charClassName={slots.char()}
|
|
329
329
|
caretClassName={slots.caret()}
|
|
@@ -331,7 +331,7 @@ export const OtpInput = forwardRef<TextInput, OtpInputProps>(
|
|
|
331
331
|
{groupEvery > 0 &&
|
|
332
332
|
(i + 1) % groupEvery === 0 &&
|
|
333
333
|
i < length - 1 ? (
|
|
334
|
-
<View className={`${slots.separator()}
|
|
334
|
+
<View className={`${slots.separator()} ms-2`} />
|
|
335
335
|
) : null}
|
|
336
336
|
</View>
|
|
337
337
|
))}
|
|
@@ -11,6 +11,7 @@ import Animated, {
|
|
|
11
11
|
withTiming,
|
|
12
12
|
} from 'react-native-reanimated';
|
|
13
13
|
import { tv, type VariantProps } from 'tailwind-variants';
|
|
14
|
+
import { useDirectionSign } from '../../hooks/use-direction';
|
|
14
15
|
import { Text } from '../../primitives/text';
|
|
15
16
|
import { cn } from '../../utils/cn';
|
|
16
17
|
|
|
@@ -135,6 +136,9 @@ export const Progress = forwardRef<View, ProgressProps>(
|
|
|
135
136
|
) => {
|
|
136
137
|
const slots = progressVariants({ color, size });
|
|
137
138
|
const trackWidth = useSharedValue(0);
|
|
139
|
+
// Yoga mirrors the track; the bar sliding along it is a transform, so it
|
|
140
|
+
// has to be turned around itself.
|
|
141
|
+
const sign = useDirectionSign();
|
|
138
142
|
const progress = useSharedValue(clamp(value) / 100);
|
|
139
143
|
const slide = useSharedValue(0);
|
|
140
144
|
|
|
@@ -167,10 +171,14 @@ export const Progress = forwardRef<View, ProgressProps>(
|
|
|
167
171
|
width: barWidth,
|
|
168
172
|
transform: [
|
|
169
173
|
{
|
|
174
|
+
// The loop travels the way the text does. Yoga mirrors the track
|
|
175
|
+
// but not the transform sliding along it.
|
|
170
176
|
translateX: interpolate(
|
|
171
177
|
slide.value,
|
|
172
178
|
[0, 1],
|
|
173
|
-
|
|
179
|
+
sign === 1
|
|
180
|
+
? [-barWidth, trackWidth.value]
|
|
181
|
+
: [trackWidth.value, -barWidth]
|
|
174
182
|
),
|
|
175
183
|
},
|
|
176
184
|
],
|
|
@@ -213,7 +221,7 @@ export const Progress = forwardRef<View, ProgressProps>(
|
|
|
213
221
|
<View />
|
|
214
222
|
)}
|
|
215
223
|
{showValue ? (
|
|
216
|
-
<Text size="sm" muted className={cn(label == null && '
|
|
224
|
+
<Text size="sm" muted className={cn(label == null && 'ms-auto')}>
|
|
217
225
|
{formatValue(clamp(value), valueLabel, formatOptions)}
|
|
218
226
|
</Text>
|
|
219
227
|
) : null}
|