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.
Files changed (135) hide show
  1. package/README.md +1 -0
  2. package/lib/module/components/area-chart/index.js +826 -0
  3. package/lib/module/components/area-chart/index.js.map +1 -0
  4. package/lib/module/components/avatar/index.js +1 -1
  5. package/lib/module/components/avatar/index.js.map +1 -1
  6. package/lib/module/components/bar-chart/index.js +853 -0
  7. package/lib/module/components/bar-chart/index.js.map +1 -0
  8. package/lib/module/components/bottom-sheet/index.js +207 -23
  9. package/lib/module/components/bottom-sheet/index.js.map +1 -1
  10. package/lib/module/components/breadcrumb/index.js +275 -0
  11. package/lib/module/components/breadcrumb/index.js.map +1 -0
  12. package/lib/module/components/chip/index.js +2 -2
  13. package/lib/module/components/direction/index.js +13 -19
  14. package/lib/module/components/direction/index.js.map +1 -1
  15. package/lib/module/components/frame/index.js +17 -0
  16. package/lib/module/components/frame/index.js.map +1 -1
  17. package/lib/module/components/heatmap-chart/index.js +28 -8
  18. package/lib/module/components/heatmap-chart/index.js.map +1 -1
  19. package/lib/module/components/input-group/index.js +2 -2
  20. package/lib/module/components/input-group/index.js.map +1 -1
  21. package/lib/module/components/line-chart/index.js +4 -146
  22. package/lib/module/components/line-chart/index.js.map +1 -1
  23. package/lib/module/components/loader/index.js +758 -0
  24. package/lib/module/components/loader/index.js.map +1 -0
  25. package/lib/module/components/map/basemap.js +265 -0
  26. package/lib/module/components/map/basemap.js.map +1 -0
  27. package/lib/module/components/map/index.js +850 -0
  28. package/lib/module/components/map/index.js.map +1 -0
  29. package/lib/module/components/map/maplibre.js +87 -0
  30. package/lib/module/components/map/maplibre.js.map +1 -0
  31. package/lib/module/components/message/index.js +8 -7
  32. package/lib/module/components/message/index.js.map +1 -1
  33. package/lib/module/components/otp-input/index.js +2 -2
  34. package/lib/module/components/progress/index.js +8 -2
  35. package/lib/module/components/progress/index.js.map +1 -1
  36. package/lib/module/components/ring-chart/index.js +423 -0
  37. package/lib/module/components/ring-chart/index.js.map +1 -0
  38. package/lib/module/components/section-rail/index.js +2 -2
  39. package/lib/module/components/separator/index.js +76 -22
  40. package/lib/module/components/separator/index.js.map +1 -1
  41. package/lib/module/components/shimmer/index.js +10 -1
  42. package/lib/module/components/shimmer/index.js.map +1 -1
  43. package/lib/module/components/slider/index.js +19 -5
  44. package/lib/module/components/slider/index.js.map +1 -1
  45. package/lib/module/components/steps/index.js +1 -1
  46. package/lib/module/components/switch/index.js +6 -1
  47. package/lib/module/components/switch/index.js.map +1 -1
  48. package/lib/module/components/typography/index.js +5 -0
  49. package/lib/module/components/typography/index.js.map +1 -1
  50. package/lib/module/hooks/use-direction.js +43 -0
  51. package/lib/module/hooks/use-direction.js.map +1 -0
  52. package/lib/module/icons/index.js +117 -2
  53. package/lib/module/icons/index.js.map +1 -1
  54. package/lib/module/index.js +8 -2
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/primitives/text.js +30 -10
  57. package/lib/module/primitives/text.js.map +1 -1
  58. package/lib/module/utils/chart.js +279 -0
  59. package/lib/module/utils/chart.js.map +1 -0
  60. package/lib/typescript/src/components/area-chart/index.d.ts +197 -0
  61. package/lib/typescript/src/components/area-chart/index.d.ts.map +1 -0
  62. package/lib/typescript/src/components/bar-chart/index.d.ts +228 -0
  63. package/lib/typescript/src/components/bar-chart/index.d.ts.map +1 -0
  64. package/lib/typescript/src/components/bottom-sheet/index.d.ts +75 -4
  65. package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
  66. package/lib/typescript/src/components/breadcrumb/index.d.ts +100 -0
  67. package/lib/typescript/src/components/breadcrumb/index.d.ts.map +1 -0
  68. package/lib/typescript/src/components/direction/index.d.ts +11 -10
  69. package/lib/typescript/src/components/direction/index.d.ts.map +1 -1
  70. package/lib/typescript/src/components/frame/index.d.ts +17 -0
  71. package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
  72. package/lib/typescript/src/components/heatmap-chart/index.d.ts +22 -3
  73. package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
  74. package/lib/typescript/src/components/line-chart/index.d.ts +1 -0
  75. package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
  76. package/lib/typescript/src/components/loader/index.d.ts +38 -0
  77. package/lib/typescript/src/components/loader/index.d.ts.map +1 -0
  78. package/lib/typescript/src/components/map/basemap.d.ts +76 -0
  79. package/lib/typescript/src/components/map/basemap.d.ts.map +1 -0
  80. package/lib/typescript/src/components/map/index.d.ts +367 -0
  81. package/lib/typescript/src/components/map/index.d.ts.map +1 -0
  82. package/lib/typescript/src/components/map/maplibre.d.ts +193 -0
  83. package/lib/typescript/src/components/map/maplibre.d.ts.map +1 -0
  84. package/lib/typescript/src/components/message/index.d.ts.map +1 -1
  85. package/lib/typescript/src/components/progress/index.d.ts.map +1 -1
  86. package/lib/typescript/src/components/ring-chart/index.d.ts +156 -0
  87. package/lib/typescript/src/components/ring-chart/index.d.ts.map +1 -0
  88. package/lib/typescript/src/components/separator/index.d.ts +36 -1
  89. package/lib/typescript/src/components/separator/index.d.ts.map +1 -1
  90. package/lib/typescript/src/components/shimmer/index.d.ts.map +1 -1
  91. package/lib/typescript/src/components/slider/index.d.ts.map +1 -1
  92. package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
  93. package/lib/typescript/src/components/typography/index.d.ts +6 -0
  94. package/lib/typescript/src/components/typography/index.d.ts.map +1 -1
  95. package/lib/typescript/src/hooks/use-direction.d.ts +20 -0
  96. package/lib/typescript/src/hooks/use-direction.d.ts.map +1 -0
  97. package/lib/typescript/src/icons/index.d.ts +5 -0
  98. package/lib/typescript/src/icons/index.d.ts.map +1 -1
  99. package/lib/typescript/src/index.d.ts +9 -3
  100. package/lib/typescript/src/index.d.ts.map +1 -1
  101. package/lib/typescript/src/primitives/text.d.ts.map +1 -1
  102. package/lib/typescript/src/utils/chart.d.ts +96 -0
  103. package/lib/typescript/src/utils/chart.d.ts.map +1 -0
  104. package/package.json +9 -1
  105. package/src/components/area-chart/index.tsx +994 -0
  106. package/src/components/avatar/index.tsx +1 -1
  107. package/src/components/bar-chart/index.tsx +1048 -0
  108. package/src/components/bottom-sheet/index.tsx +280 -20
  109. package/src/components/breadcrumb/index.tsx +365 -0
  110. package/src/components/chip/index.tsx +2 -2
  111. package/src/components/direction/index.tsx +20 -21
  112. package/src/components/frame/index.tsx +17 -0
  113. package/src/components/heatmap-chart/index.tsx +58 -11
  114. package/src/components/input-group/index.tsx +2 -2
  115. package/src/components/line-chart/index.tsx +13 -181
  116. package/src/components/loader/index.tsx +812 -0
  117. package/src/components/map/basemap.ts +304 -0
  118. package/src/components/map/index.tsx +1118 -0
  119. package/src/components/map/maplibre.ts +201 -0
  120. package/src/components/message/index.tsx +8 -7
  121. package/src/components/otp-input/index.tsx +2 -2
  122. package/src/components/progress/index.tsx +10 -2
  123. package/src/components/ring-chart/index.tsx +543 -0
  124. package/src/components/section-rail/index.tsx +2 -2
  125. package/src/components/separator/index.tsx +77 -19
  126. package/src/components/shimmer/index.tsx +10 -1
  127. package/src/components/slider/index.tsx +20 -5
  128. package/src/components/steps/index.tsx +1 -1
  129. package/src/components/switch/index.tsx +6 -1
  130. package/src/components/typography/index.tsx +5 -0
  131. package/src/hooks/use-direction.ts +45 -0
  132. package/src/icons/index.tsx +66 -0
  133. package/src/index.ts +84 -0
  134. package/src/primitives/text.tsx +25 -7
  135. 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
- bubble: 'rounded-bl-md bg-muted',
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-left',
61
- footer: 'text-left',
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-br-md bg-primary',
67
+ bubble: 'rounded-ee-md bg-primary',
67
68
  bubbleContent: 'text-primary-foreground',
68
- header: 'text-right',
69
- footer: 'text-right',
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 ? 'ml-2' : ''} ${cellClassName ?? ''}`,
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()} ml-2`} />
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
- [-barWidth, trackWidth.value]
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 && 'ml-auto')}>
224
+ <Text size="sm" muted className={cn(label == null && 'ms-auto')}>
217
225
  {formatValue(clamp(value), valueLabel, formatOptions)}
218
226
  </Text>
219
227
  ) : null}