panelui-native 0.77.0 → 0.79.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/area-chart/index.js +32 -25
- package/lib/module/components/area-chart/index.js.map +1 -1
- package/lib/module/components/bottom-sheet/index.js +97 -15
- package/lib/module/components/bottom-sheet/index.js.map +1 -1
- package/lib/module/components/funnel-chart/index.js +15 -2
- package/lib/module/components/funnel-chart/index.js.map +1 -1
- package/lib/module/components/heatmap-chart/index.js +19 -27
- package/lib/module/components/heatmap-chart/index.js.map +1 -1
- package/lib/module/components/hex-chart/index.js +2 -0
- package/lib/module/components/hex-chart/index.js.map +1 -1
- package/lib/module/components/line-chart/index.js +38 -31
- package/lib/module/components/line-chart/index.js.map +1 -1
- package/lib/module/components/map/index.js +63 -39
- package/lib/module/components/map/index.js.map +1 -1
- package/lib/module/components/map/map-children.js +54 -0
- package/lib/module/components/map/map-children.js.map +1 -0
- package/lib/module/components/map/maplibre.js +31 -3
- package/lib/module/components/map/maplibre.js.map +1 -1
- package/lib/module/components/markdown-editor/index.js +288 -34
- package/lib/module/components/markdown-editor/index.js.map +1 -1
- package/lib/module/components/markdown-editor/markdown-transforms.js +272 -9
- package/lib/module/components/markdown-editor/markdown-transforms.js.map +1 -1
- package/lib/module/components/marquee/index.js +205 -46
- package/lib/module/components/marquee/index.js.map +1 -1
- package/lib/module/components/panelside/index.js +162 -34
- package/lib/module/components/panelside/index.js.map +1 -1
- package/lib/module/components/pie-chart/index.js +15 -2
- package/lib/module/components/pie-chart/index.js.map +1 -1
- package/lib/module/components/plot/index.js +42 -44
- package/lib/module/components/plot/index.js.map +1 -1
- package/lib/module/components/progress-button/index.js +617 -0
- package/lib/module/components/progress-button/index.js.map +1 -0
- package/lib/module/components/progress-button/progress-button-hold.js +91 -0
- package/lib/module/components/progress-button/progress-button-hold.js.map +1 -0
- package/lib/module/components/scatter-chart/index.js +6 -25
- package/lib/module/components/scatter-chart/index.js.map +1 -1
- package/lib/module/components/section-rail/index.js +40 -17
- package/lib/module/components/section-rail/index.js.map +1 -1
- package/lib/module/components/split-view/index.js +54 -10
- package/lib/module/components/split-view/index.js.map +1 -1
- package/lib/module/components/theme-selector/index.js +239 -0
- package/lib/module/components/theme-selector/index.js.map +1 -0
- package/lib/module/components/theme-selector/theme-preview.js +320 -0
- package/lib/module/components/theme-selector/theme-preview.js.map +1 -0
- package/lib/module/components/timeline/index.js +145 -14
- package/lib/module/components/timeline/index.js.map +1 -1
- package/lib/module/components/toast/index.js +45 -11
- package/lib/module/components/toast/index.js.map +1 -1
- package/lib/module/components/treemap-chart/index.js +63 -6
- package/lib/module/components/treemap-chart/index.js.map +1 -1
- package/lib/module/components/waterfall-chart/index.js +20 -4
- package/lib/module/components/waterfall-chart/index.js.map +1 -1
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/use-scroll-sections.js +44 -2
- package/lib/module/hooks/use-scroll-sections.js.map +1 -1
- package/lib/module/hooks/use-skeleton-handoff.js +58 -0
- package/lib/module/hooks/use-skeleton-handoff.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/components/area-chart/index.d.ts +1 -1
- package/lib/typescript/src/components/area-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
- package/lib/typescript/src/components/funnel-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/hex-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/line-chart/index.d.ts +1 -1
- package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/map/index.d.ts +8 -4
- package/lib/typescript/src/components/map/index.d.ts.map +1 -1
- package/lib/typescript/src/components/map/map-children.d.ts +41 -0
- package/lib/typescript/src/components/map/map-children.d.ts.map +1 -0
- package/lib/typescript/src/components/map/maplibre.d.ts +8 -4
- package/lib/typescript/src/components/map/maplibre.d.ts.map +1 -1
- package/lib/typescript/src/components/markdown-editor/index.d.ts +64 -5
- package/lib/typescript/src/components/markdown-editor/index.d.ts.map +1 -1
- package/lib/typescript/src/components/markdown-editor/markdown-transforms.d.ts +33 -5
- package/lib/typescript/src/components/markdown-editor/markdown-transforms.d.ts.map +1 -1
- package/lib/typescript/src/components/marquee/index.d.ts +55 -2
- package/lib/typescript/src/components/marquee/index.d.ts.map +1 -1
- package/lib/typescript/src/components/panelside/index.d.ts +79 -4
- package/lib/typescript/src/components/panelside/index.d.ts.map +1 -1
- package/lib/typescript/src/components/pie-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/plot/index.d.ts +1 -3
- package/lib/typescript/src/components/plot/index.d.ts.map +1 -1
- package/lib/typescript/src/components/progress-button/index.d.ts +311 -0
- package/lib/typescript/src/components/progress-button/index.d.ts.map +1 -0
- package/lib/typescript/src/components/progress-button/progress-button-hold.d.ts +60 -0
- package/lib/typescript/src/components/progress-button/progress-button-hold.d.ts.map +1 -0
- package/lib/typescript/src/components/scatter-chart/index.d.ts +1 -1
- package/lib/typescript/src/components/scatter-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/section-rail/index.d.ts.map +1 -1
- package/lib/typescript/src/components/split-view/index.d.ts +10 -1
- package/lib/typescript/src/components/split-view/index.d.ts.map +1 -1
- package/lib/typescript/src/components/theme-selector/index.d.ts +107 -0
- package/lib/typescript/src/components/theme-selector/index.d.ts.map +1 -0
- package/lib/typescript/src/components/theme-selector/theme-preview.d.ts +32 -0
- package/lib/typescript/src/components/theme-selector/theme-preview.d.ts.map +1 -0
- package/lib/typescript/src/components/timeline/index.d.ts +7 -0
- package/lib/typescript/src/components/timeline/index.d.ts.map +1 -1
- package/lib/typescript/src/components/toast/index.d.ts.map +1 -1
- package/lib/typescript/src/components/treemap-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/waterfall-chart/index.d.ts.map +1 -1
- 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-scroll-sections.d.ts +1 -0
- package/lib/typescript/src/hooks/use-scroll-sections.d.ts.map +1 -1
- package/lib/typescript/src/hooks/use-skeleton-handoff.d.ts +11 -0
- package/lib/typescript/src/hooks/use-skeleton-handoff.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/area-chart/index.tsx +49 -37
- package/src/components/bottom-sheet/index.tsx +109 -11
- package/src/components/funnel-chart/index.tsx +10 -2
- package/src/components/heatmap-chart/index.tsx +27 -22
- package/src/components/hex-chart/index.tsx +22 -6
- package/src/components/line-chart/index.tsx +57 -43
- package/src/components/map/index.tsx +63 -36
- package/src/components/map/map-children.ts +66 -0
- package/src/components/map/maplibre.ts +32 -4
- package/src/components/markdown-editor/index.tsx +413 -35
- package/src/components/markdown-editor/markdown-transforms.ts +274 -10
- package/src/components/marquee/index.tsx +254 -58
- package/src/components/panelside/index.tsx +179 -40
- package/src/components/pie-chart/index.tsx +10 -2
- package/src/components/plot/index.tsx +66 -50
- package/src/components/progress-button/index.tsx +684 -0
- package/src/components/progress-button/progress-button-hold.ts +88 -0
- package/src/components/scatter-chart/index.tsx +4 -25
- package/src/components/section-rail/index.tsx +39 -19
- package/src/components/split-view/index.tsx +53 -8
- package/src/components/theme-selector/index.tsx +281 -0
- package/src/components/theme-selector/theme-preview.tsx +205 -0
- package/src/components/timeline/index.tsx +143 -17
- package/src/components/toast/index.tsx +60 -11
- package/src/components/treemap-chart/index.tsx +65 -8
- package/src/components/waterfall-chart/index.tsx +14 -4
- package/src/hooks/index.ts +5 -0
- package/src/hooks/use-scroll-sections.ts +52 -3
- package/src/hooks/use-skeleton-handoff.ts +69 -0
- package/src/index.ts +25 -0
|
@@ -46,16 +46,23 @@
|
|
|
46
46
|
* Screen readers get one copy. The rest are duplicates of content already
|
|
47
47
|
* announced, and hearing a sponsor list four times over is not thoroughness.
|
|
48
48
|
*/
|
|
49
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
49
|
+
import { createContext, useCallback, useContext, useEffect, useId, useMemo, useState } from 'react';
|
|
50
50
|
import { Platform, Pressable, ScrollView, StyleSheet, View } from 'react-native';
|
|
51
|
-
import Animated, { cancelAnimation, Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';
|
|
51
|
+
import Animated, { cancelAnimation, Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withRepeat, withSequence, withTiming } from 'react-native-reanimated';
|
|
52
52
|
import { useDirectionSign } from "../../hooks/use-direction.js";
|
|
53
53
|
import { Text } from "../../primitives/text.js";
|
|
54
54
|
import { cn } from "../../utils/cn.js";
|
|
55
55
|
import { DEFAULT_MARQUEE_SPEED, marqueeCopyCount, normalizeMarqueeSpeed } from "./marquee-math.js";
|
|
56
56
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
57
57
|
const InertView = View;
|
|
58
|
-
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Set by `Marquee.Group` so the marquees inside it stop drawing a pause control
|
|
61
|
+
* each and take the group's instead.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
const MarqueeGroupContext = /*#__PURE__*/createContext(null);
|
|
65
|
+
function MarqueeRoot({
|
|
59
66
|
className,
|
|
60
67
|
children,
|
|
61
68
|
speed: speedProp = DEFAULT_MARQUEE_SPEED,
|
|
@@ -63,7 +70,7 @@ export function Marquee({
|
|
|
63
70
|
direction = 'horizontal',
|
|
64
71
|
reverse = false,
|
|
65
72
|
playing = true,
|
|
66
|
-
showPauseControl
|
|
73
|
+
showPauseControl,
|
|
67
74
|
pauseLabel = 'Pause',
|
|
68
75
|
playLabel = 'Play',
|
|
69
76
|
onPlayingChange,
|
|
@@ -80,7 +87,13 @@ export function Marquee({
|
|
|
80
87
|
const [content, setContent] = useState(0);
|
|
81
88
|
const [userPaused, setUserPaused] = useState(false);
|
|
82
89
|
const speed = normalizeMarqueeSpeed(speedProp);
|
|
83
|
-
|
|
90
|
+
|
|
91
|
+
// A group's pause is the same instruction as this one's, so it is read here
|
|
92
|
+
// rather than pushed down as a `playing` prop — a caller who set `playing`
|
|
93
|
+
// themselves should not have it overwritten by the container.
|
|
94
|
+
const group = useContext(MarqueeGroupContext);
|
|
95
|
+
const showControl = showPauseControl ?? group === null;
|
|
96
|
+
const moving = playing && !userPaused && !(group?.paused ?? false);
|
|
84
97
|
|
|
85
98
|
// The distance from one copy to the same point on the next, and therefore
|
|
86
99
|
// both the layout step and the exact loop length. They are the same number
|
|
@@ -97,14 +110,46 @@ export function Marquee({
|
|
|
97
110
|
}, (_, index) => index);
|
|
98
111
|
}, [layout.count]);
|
|
99
112
|
const offset = useSharedValue(0);
|
|
113
|
+
|
|
114
|
+
/*
|
|
115
|
+
* A re-measure is the only thing allowed to move the content back to the
|
|
116
|
+
* start. The loop length has changed, so an offset taken against the old one
|
|
117
|
+
* no longer means anything.
|
|
118
|
+
*/
|
|
100
119
|
useEffect(() => {
|
|
101
120
|
cancelAnimation(offset);
|
|
102
121
|
offset.value = 0;
|
|
122
|
+
}, [offset, period]);
|
|
123
|
+
|
|
124
|
+
/*
|
|
125
|
+
* Pausing freezes where it is. `cancelAnimation` already leaves the shared
|
|
126
|
+
* value at whatever it had reached, so stopping is simply not starting again
|
|
127
|
+
* — the content stays exactly where the reader stopped it, which is the
|
|
128
|
+
* whole point of a pause control on something they are trying to read.
|
|
129
|
+
*
|
|
130
|
+
* Resuming picks up from there. The first leg is shortened to the distance
|
|
131
|
+
* actually left, or the lap after a pause would run at a fraction of the
|
|
132
|
+
* speed every other lap runs at.
|
|
133
|
+
*/
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
cancelAnimation(offset);
|
|
103
136
|
if (reducedMotion || !moving || period <= 0 || speed <= 0) return undefined;
|
|
104
|
-
|
|
105
|
-
|
|
137
|
+
const cycle = period / speed * 1000;
|
|
138
|
+
const from = (offset.value % period + period) % period;
|
|
139
|
+
const remaining = period - from;
|
|
140
|
+
offset.value = from;
|
|
141
|
+
offset.value = withSequence(withTiming(period, {
|
|
142
|
+
duration: cycle * (remaining / period),
|
|
143
|
+
easing: Easing.linear
|
|
144
|
+
}),
|
|
145
|
+
// Back to the seam in no time at all. The state at `period` is the state
|
|
146
|
+
// at `0`, so this is a bookkeeping step rather than a visible one.
|
|
147
|
+
withTiming(0, {
|
|
148
|
+
duration: 0
|
|
149
|
+
}), withRepeat(withTiming(period, {
|
|
150
|
+
duration: cycle,
|
|
106
151
|
easing: Easing.linear
|
|
107
|
-
}), -1, false);
|
|
152
|
+
}), -1, false));
|
|
108
153
|
return () => cancelAnimation(offset);
|
|
109
154
|
}, [offset, period, moving, reducedMotion, speed]);
|
|
110
155
|
const trackStyle = useAnimatedStyle(() => {
|
|
@@ -136,6 +181,24 @@ export function Marquee({
|
|
|
136
181
|
setContent(horizontal ? width : height);
|
|
137
182
|
};
|
|
138
183
|
|
|
184
|
+
/*
|
|
185
|
+
* Whether there is motion here at all: content that measured, a speed to
|
|
186
|
+
* travel it at, and a `playing` that has not already stopped it from
|
|
187
|
+
* outside. A control offering to pause a still marquee is the same lie as a
|
|
188
|
+
* disabled button with no reason on it.
|
|
189
|
+
*/
|
|
190
|
+
const live = playing && !reducedMotion && period > 0 && speed > 0;
|
|
191
|
+
|
|
192
|
+
// Reported to the group, if there is one, so its single control can be
|
|
193
|
+
// decided the same way this one's is.
|
|
194
|
+
const id = useId();
|
|
195
|
+
const report = group?.report;
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
if (!report) return undefined;
|
|
198
|
+
report(id, live);
|
|
199
|
+
return () => report(id, false);
|
|
200
|
+
}, [report, id, live]);
|
|
201
|
+
|
|
139
202
|
// Nothing to loop, so nothing to clip or clone: render the content plainly
|
|
140
203
|
// and let it sit where it falls.
|
|
141
204
|
if (reducedMotion) {
|
|
@@ -148,48 +211,58 @@ export function Marquee({
|
|
|
148
211
|
});
|
|
149
212
|
}
|
|
150
213
|
return /*#__PURE__*/_jsxs(View, {
|
|
151
|
-
className: cn('
|
|
214
|
+
className: cn('gap-3', className),
|
|
152
215
|
style: style,
|
|
153
|
-
onLayout:
|
|
216
|
+
onLayout: onLayout,
|
|
154
217
|
...props,
|
|
155
|
-
children: [/*#__PURE__*/
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
children:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
style: [StyleSheet.absoluteFill, trackStyle],
|
|
169
|
-
pointerEvents: "box-none",
|
|
170
|
-
children: copies.map(index => {
|
|
171
|
-
// Index 1 is the copy that starts flush with the container's edge,
|
|
172
|
-
// and it is the one a screen reader is given.
|
|
173
|
-
const spoken = index === 1;
|
|
174
|
-
const at = (index - 1) * period;
|
|
175
|
-
return /*#__PURE__*/_jsx(InertView, {
|
|
176
|
-
style: [styles.copy, horizontal ? {
|
|
177
|
-
left: at
|
|
178
|
-
} : {
|
|
179
|
-
top: at
|
|
180
|
-
}],
|
|
181
|
-
pointerEvents: spoken ? 'box-none' : 'none',
|
|
182
|
-
inert: Platform.OS === 'web' && !spoken ? true : undefined,
|
|
183
|
-
"aria-hidden": !spoken,
|
|
184
|
-
accessibilityElementsHidden: !spoken,
|
|
185
|
-
importantForAccessibility: spoken ? 'auto' : 'no-hide-descendants',
|
|
218
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
219
|
+
className: "flex-1 overflow-hidden",
|
|
220
|
+
onLayout: onContainerLayout,
|
|
221
|
+
children: [/*#__PURE__*/_jsx(ScrollView, {
|
|
222
|
+
horizontal: horizontal,
|
|
223
|
+
scrollEnabled: false,
|
|
224
|
+
style: styles.measure,
|
|
225
|
+
pointerEvents: "none",
|
|
226
|
+
accessibilityElementsHidden: true,
|
|
227
|
+
importantForAccessibility: "no-hide-descendants",
|
|
228
|
+
children: /*#__PURE__*/_jsx(InertView, {
|
|
229
|
+
inert: Platform.OS === 'web' ? true : undefined,
|
|
230
|
+
onLayout: onContentLayout,
|
|
186
231
|
children: children
|
|
187
|
-
}
|
|
188
|
-
})
|
|
189
|
-
|
|
232
|
+
})
|
|
233
|
+
}), /*#__PURE__*/_jsx(Animated.View, {
|
|
234
|
+
style: [StyleSheet.absoluteFill, trackStyle],
|
|
235
|
+
pointerEvents: "box-none",
|
|
236
|
+
children: copies.map(index => {
|
|
237
|
+
// Index 1 is the copy that starts flush with the container's edge,
|
|
238
|
+
// and it is the one a screen reader is given.
|
|
239
|
+
const spoken = index === 1;
|
|
240
|
+
const at = (index - 1) * period;
|
|
241
|
+
return /*#__PURE__*/_jsx(InertView, {
|
|
242
|
+
style: [styles.copy, horizontal ? {
|
|
243
|
+
left: at
|
|
244
|
+
} : {
|
|
245
|
+
top: at
|
|
246
|
+
}],
|
|
247
|
+
pointerEvents: spoken ? 'box-none' : 'none',
|
|
248
|
+
inert: Platform.OS === 'web' && !spoken ? true : undefined,
|
|
249
|
+
"aria-hidden": !spoken,
|
|
250
|
+
accessibilityElementsHidden: !spoken,
|
|
251
|
+
importantForAccessibility: spoken ? 'auto' : 'no-hide-descendants',
|
|
252
|
+
children: children
|
|
253
|
+
}, index);
|
|
254
|
+
})
|
|
255
|
+
})]
|
|
256
|
+
}), showControl && live ? /*#__PURE__*/_jsx(Pressable, {
|
|
190
257
|
accessibilityRole: "button",
|
|
191
|
-
accessibilityLabel: userPaused ? playLabel : pauseLabel
|
|
192
|
-
|
|
258
|
+
accessibilityLabel: userPaused ? playLabel : pauseLabel
|
|
259
|
+
/*
|
|
260
|
+
* Below the content, in flow, the way a group's control already is.
|
|
261
|
+
* Floating over the track it was clipped by the track's own
|
|
262
|
+
* `overflow-hidden` — a 48pt target on a strip of badges half that
|
|
263
|
+
* tall — and it covered the content it was there to let you read.
|
|
264
|
+
*/,
|
|
265
|
+
className: "min-h-12 self-end items-center justify-center rounded-full border border-border bg-background px-4",
|
|
193
266
|
onPress: () => {
|
|
194
267
|
const next = !userPaused;
|
|
195
268
|
setUserPaused(next);
|
|
@@ -202,6 +275,92 @@ export function Marquee({
|
|
|
202
275
|
}) : null]
|
|
203
276
|
});
|
|
204
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Rows of travelling content that stop and start together, under one control.
|
|
280
|
+
*
|
|
281
|
+
* Moving content needs a way to stop it, so a marquee draws its own pause
|
|
282
|
+
* button. Stacked — two rows of logos travelling against each other — that is
|
|
283
|
+
* one button per row, each pinned to its own bottom corner, and the upper one
|
|
284
|
+
* lands on top of the row beneath it. Two buttons for one piece of motion, and
|
|
285
|
+
* one of them covering the content it belongs to.
|
|
286
|
+
*
|
|
287
|
+
* A group is the answer to both: the marquees inside it stop drawing their own
|
|
288
|
+
* control, and the group draws a single one below them rather than over them.
|
|
289
|
+
*
|
|
290
|
+
* ```tsx
|
|
291
|
+
* <Marquee.Group>
|
|
292
|
+
* <Marquee>{topRow}</Marquee>
|
|
293
|
+
* <Marquee reverse>{bottomRow}</Marquee>
|
|
294
|
+
* </Marquee.Group>
|
|
295
|
+
* ```
|
|
296
|
+
*
|
|
297
|
+
* Each marquee keeps its own `playing` prop. The group's pause is an additional
|
|
298
|
+
* hold, not a replacement — a row already held still stays still.
|
|
299
|
+
*/
|
|
300
|
+
function MarqueeGroup({
|
|
301
|
+
className,
|
|
302
|
+
children,
|
|
303
|
+
playing = true,
|
|
304
|
+
showPauseControl = true,
|
|
305
|
+
pauseLabel = 'Pause',
|
|
306
|
+
playLabel = 'Play',
|
|
307
|
+
onPlayingChange,
|
|
308
|
+
...props
|
|
309
|
+
}) {
|
|
310
|
+
const [userPaused, setUserPaused] = useState(false);
|
|
311
|
+
const [liveRows, setLiveRows] = useState(() => new Set());
|
|
312
|
+
const reducedMotion = useReducedMotion();
|
|
313
|
+
|
|
314
|
+
// Each marquee inside says whether it has a loop to stop, and the group's
|
|
315
|
+
// control is drawn only if at least one of them does.
|
|
316
|
+
const report = useCallback((id, live) => {
|
|
317
|
+
setLiveRows(current => {
|
|
318
|
+
if (current.has(id) === live) return current;
|
|
319
|
+
const next = new Set(current);
|
|
320
|
+
if (live) next.add(id);else next.delete(id);
|
|
321
|
+
return next;
|
|
322
|
+
});
|
|
323
|
+
}, []);
|
|
324
|
+
const value = useMemo(() => ({
|
|
325
|
+
paused: userPaused,
|
|
326
|
+
report
|
|
327
|
+
}), [userPaused, report]);
|
|
328
|
+
|
|
329
|
+
// Nothing is moving, so there is nothing to stop. The control is not hidden
|
|
330
|
+
// to save space — offering to pause content that is already still is the
|
|
331
|
+
// same lie as a disabled button with no reason on it.
|
|
332
|
+
const showControl = showPauseControl && playing && !reducedMotion && liveRows.size > 0;
|
|
333
|
+
return /*#__PURE__*/_jsx(MarqueeGroupContext.Provider, {
|
|
334
|
+
value: value,
|
|
335
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
336
|
+
...props,
|
|
337
|
+
className: cn('w-full gap-3', className),
|
|
338
|
+
children: [children, showControl ? /*#__PURE__*/_jsx(Pressable, {
|
|
339
|
+
accessibilityRole: "button",
|
|
340
|
+
accessibilityLabel: userPaused ? playLabel : pauseLabel
|
|
341
|
+
// In flow and at the end, not floating over the last row. The
|
|
342
|
+
// control belongs to the group, and a group's control that covers
|
|
343
|
+
// one of its members is describing itself as part of that member.
|
|
344
|
+
,
|
|
345
|
+
className: "min-h-12 self-end items-center justify-center rounded-full border border-border bg-background px-4",
|
|
346
|
+
onPress: () => {
|
|
347
|
+
const next = !userPaused;
|
|
348
|
+
setUserPaused(next);
|
|
349
|
+
onPlayingChange?.(!next);
|
|
350
|
+
},
|
|
351
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
352
|
+
className: "text-xs font-medium text-foreground",
|
|
353
|
+
children: userPaused ? playLabel : pauseLabel
|
|
354
|
+
})
|
|
355
|
+
}) : null]
|
|
356
|
+
})
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
MarqueeGroup.displayName = 'Marquee.Group';
|
|
360
|
+
MarqueeRoot.displayName = 'Marquee';
|
|
361
|
+
export const Marquee = Object.assign(MarqueeRoot, {
|
|
362
|
+
Group: MarqueeGroup
|
|
363
|
+
});
|
|
205
364
|
const styles = StyleSheet.create({
|
|
206
365
|
/* Laid out so it measures, hidden so it does not draw, and behind everything
|
|
207
366
|
so it can never intercept anything. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","useState","Platform","Pressable","ScrollView","StyleSheet","View","Animated","cancelAnimation","Easing","useAnimatedStyle","useReducedMotion","useSharedValue","withRepeat","withTiming","useDirectionSign","Text","cn","DEFAULT_MARQUEE_SPEED","marqueeCopyCount","normalizeMarqueeSpeed","jsx","_jsx","jsxs","_jsxs","InertView","Marquee","className","children","speed","speedProp","spacing","direction","reverse","playing","showPauseControl","pauseLabel","playLabel","onPlayingChange","style","onLayout","props","horizontal","reducedMotion","sign","flip","viewport","setViewport","content","setContent","userPaused","setUserPaused","moving","layout","period","copies","Array","from","length","count","_","index","offset","value","undefined","duration","easing","linear","trackStyle","travel","transform","translateX","translateY","onContainerLayout","event","width","height","nativeEvent","onContentLayout","scrollEnabled","styles","measure","pointerEvents","accessibilityElementsHidden","importantForAccessibility","inert","OS","absoluteFill","map","spoken","at","copy","left","top","accessibilityRole","accessibilityLabel","onPress","next","create","opacity","zIndex","position"],"sourceRoot":"../../../../src","sources":["components/marquee/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAA4C,OAAO;AACxF,SACE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,IAAID,OAAO,IAAIoB,MAAM,GAAG,CAAC,IAAIzB,KAAK,GAAG,CAAC,gBACrDP,IAAA,CAACnB,SAAS;MACR2F,iBAAiB,EAAC,QAAQ;MAC1BC,kBAAkB,EAAE7C,UAAU,GAAGb,SAAS,GAAGD,UAAW;MACxDT,SAAS,EAAC,+HAA+H;MACzIqE,OAAO,EAAEA,CAAA,KAAM;QACb,MAAMC,IAAI,GAAG,CAAC/C,UAAU;QACxBC,aAAa,CAAC8C,IAAI,CAAC;QACnB3D,eAAe,GAAG,CAAC2D,IAAI,CAAC;MAC1B,CAAE;MAAArE,QAAA,eAEFN,IAAA,CAACN,IAAI;QAACW,SAAS,EAAC,qCAAqC;QAAAC,QAAA,EAClDsB,UAAU,GAAGb,SAAS,GAAGD;MAAU,CAChC;IAAC,CACE,CAAC,GACV,IAAI;EAAA,CACJ,CAAC;AAEX;AAEA,MAAM4C,MAAM,GAAG3E,UAAU,CAAC6F,MAAM,CAAC;EAC/B;AACF;EACEjB,OAAO,EAAE;IAAEkB,OAAO,EAAE,CAAC;IAAEC,MAAM,EAAE,CAAC;EAAE,CAAC;EACnCT,IAAI,EAAE;IAAEU,QAAQ,EAAE;EAAW;AAC/B,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["createContext","useCallback","useContext","useEffect","useId","useMemo","useState","Platform","Pressable","ScrollView","StyleSheet","View","Animated","cancelAnimation","Easing","useAnimatedStyle","useReducedMotion","useSharedValue","withRepeat","withSequence","withTiming","useDirectionSign","Text","cn","DEFAULT_MARQUEE_SPEED","marqueeCopyCount","normalizeMarqueeSpeed","jsx","_jsx","jsxs","_jsxs","InertView","MarqueeGroupContext","MarqueeRoot","className","children","speed","speedProp","spacing","direction","reverse","playing","showPauseControl","pauseLabel","playLabel","onPlayingChange","style","onLayout","props","horizontal","reducedMotion","sign","flip","viewport","setViewport","content","setContent","userPaused","setUserPaused","group","showControl","moving","paused","layout","period","copies","Array","from","length","count","_","index","offset","value","undefined","cycle","remaining","duration","easing","linear","trackStyle","travel","transform","translateX","translateY","onContainerLayout","event","width","height","nativeEvent","onContentLayout","live","id","report","scrollEnabled","styles","measure","pointerEvents","accessibilityElementsHidden","importantForAccessibility","inert","OS","absoluteFill","map","spoken","at","copy","left","top","accessibilityRole","accessibilityLabel","onPress","next","MarqueeGroup","liveRows","setLiveRows","Set","current","has","add","delete","size","Provider","displayName","Marquee","Object","assign","Group","create","opacity","zIndex","position"],"sourceRoot":"../../../../src","sources":["components/marquee/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,KAAK,EACLC,OAAO,EACPC,QAAQ,QAGH,OAAO;AACd,SACEC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,IAAI,QAGC,cAAc;AACrB,OAAOC,QAAQ,IACbC,eAAe,EACfC,MAAM,EACNC,gBAAgB,EAChBC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,EACVC,YAAY,EACZC,UAAU,QACL,yBAAyB;AAChC,SAASC,gBAAgB,QAAQ,8BAA2B;AAC5D,SAASC,IAAI,QAAQ,0BAAuB;AAC5C,SAASC,EAAE,QAAQ,mBAAgB;AACnC,SACEC,qBAAqB,EACrBC,gBAAgB,EAChBC,qBAAqB,QAChB,mBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAKxB,MAAMC,SAAS,GAAGpB,IAAqC;;AAwCvD;AACA;AACA;AACA;;AAeA,MAAMqB,mBAAmB,gBAAGhC,aAAa,CAAkC,IAAI,CAAC;AAEhF,SAASiC,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MAAM,CAAC;EAC/B;AACF;EACEhC,OAAO,EAAE;IAAEiC,OAAO,EAAE,CAAC;IAAEC,MAAM,EAAE,CAAC;EAAE,CAAC;EACnCxB,IAAI,EAAE;IAAEyB,QAAQ,EAAE;EAAW;AAC/B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -680,6 +680,42 @@ function PanelsideGroupLabel({
|
|
|
680
680
|
}))
|
|
681
681
|
});
|
|
682
682
|
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* What a row's parts read off the row, rather than being handed it.
|
|
686
|
+
*
|
|
687
|
+
* A label goes medium and un-muted when the row is the current destination,
|
|
688
|
+
* and an icon takes the matching tint. Passing that to every part would mean
|
|
689
|
+
* `<Panelside.ItemLabel active={active}>` at every call site, with an `active`
|
|
690
|
+
* that has to be kept in step with the row's own.
|
|
691
|
+
*/
|
|
692
|
+
|
|
693
|
+
const PanelsideItemContext = /*#__PURE__*/createContext(null);
|
|
694
|
+
function usePanelsideItem(part) {
|
|
695
|
+
const value = useContext(PanelsideItemContext);
|
|
696
|
+
if (!value) throw new Error(`${part} must be used inside a <Panelside.Item>.`);
|
|
697
|
+
return value;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* One destination, or one conversation.
|
|
701
|
+
*
|
|
702
|
+
* There are two ways to fill it, and they are the same row. The shorthand —
|
|
703
|
+
* `icon`, `label`, `badge` — covers the row every navigation panel has, and is
|
|
704
|
+
* what most call sites should use. The parts cover everything else: two lines
|
|
705
|
+
* of text, a label that is not a string, a badge before the label rather than
|
|
706
|
+
* after it, a trailing control that is not an overflow menu.
|
|
707
|
+
*
|
|
708
|
+
* ```tsx
|
|
709
|
+
* <Panelside.Item icon={<InboxIcon />} label="Inbox" badge={12} />
|
|
710
|
+
*
|
|
711
|
+
* <Panelside.Item active>
|
|
712
|
+
* <Panelside.ItemIcon><Avatar size="xs" src={author.avatar} /></Panelside.ItemIcon>
|
|
713
|
+
* <Panelside.ItemLabel>{thread.title}</Panelside.ItemLabel>
|
|
714
|
+
* <Panelside.ItemBadge>{thread.unread}</Panelside.ItemBadge>
|
|
715
|
+
* <Panelside.Action onPress={rename} />
|
|
716
|
+
* </Panelside.Item>
|
|
717
|
+
* ```
|
|
718
|
+
*/
|
|
683
719
|
function PanelsideItem({
|
|
684
720
|
className,
|
|
685
721
|
icon,
|
|
@@ -694,42 +730,128 @@ function PanelsideItem({
|
|
|
694
730
|
const restTint = useCSSVariable('--color-muted-foreground');
|
|
695
731
|
const activeTint = useCSSVariable('--color-foreground');
|
|
696
732
|
const tint = active ? typeof activeTint === 'string' ? activeTint : undefined : typeof restTint === 'string' ? restTint : undefined;
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
733
|
+
const context = useMemo(() => ({
|
|
734
|
+
active,
|
|
735
|
+
disabled,
|
|
736
|
+
size,
|
|
737
|
+
tint
|
|
738
|
+
}), [active, disabled, size, tint]);
|
|
739
|
+
|
|
740
|
+
/*
|
|
741
|
+
* The row needs something flexible in the middle or its trailing content
|
|
742
|
+
* floats next to the icon instead of sitting at the end. A label supplies
|
|
743
|
+
* that, and a written-out `Panelside.ItemLabel` supplies it too — so the
|
|
744
|
+
* spacer is only for the row that has neither, which is a row of nothing but
|
|
745
|
+
* an icon and a badge.
|
|
746
|
+
*/
|
|
747
|
+
const filled = label !== undefined || children !== undefined;
|
|
748
|
+
return /*#__PURE__*/_jsx(PanelsideItemContext.Provider, {
|
|
749
|
+
value: context,
|
|
750
|
+
children: /*#__PURE__*/_jsxs(AnimatedPressable, {
|
|
751
|
+
className: itemVariants({
|
|
752
|
+
active,
|
|
753
|
+
disabled,
|
|
754
|
+
size,
|
|
755
|
+
className
|
|
756
|
+
}),
|
|
757
|
+
disabled: disabled,
|
|
758
|
+
accessibilityRole: "button",
|
|
759
|
+
accessibilityState: {
|
|
760
|
+
selected: active,
|
|
761
|
+
disabled
|
|
762
|
+
},
|
|
763
|
+
accessibilityLabel: label,
|
|
764
|
+
pressScale: 0.985,
|
|
765
|
+
...props,
|
|
766
|
+
children: [icon ? /*#__PURE__*/_jsx(PanelsideItemIcon, {
|
|
767
|
+
children: icon
|
|
768
|
+
}) : null, label !== undefined ? /*#__PURE__*/_jsx(PanelsideItemLabel, {
|
|
769
|
+
children: label
|
|
770
|
+
}) : null, filled ? null : /*#__PURE__*/_jsx(View, {
|
|
771
|
+
className: "flex-1"
|
|
772
|
+
}), badge !== undefined && badge !== null ? /*#__PURE__*/_jsx(PanelsideItemBadge, {
|
|
773
|
+
children: badge
|
|
774
|
+
}) : null, children]
|
|
775
|
+
})
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* The leading slot on a row.
|
|
780
|
+
*
|
|
781
|
+
* Whatever is inside it inherits the row's own tint rather than each call site
|
|
782
|
+
* passing a colour that stops being right the moment the row goes active.
|
|
783
|
+
*/
|
|
784
|
+
function PanelsideItemIcon({
|
|
785
|
+
className,
|
|
786
|
+
children,
|
|
787
|
+
...props
|
|
788
|
+
}) {
|
|
789
|
+
const {
|
|
790
|
+
tint
|
|
791
|
+
} = usePanelsideItem('Panelside.ItemIcon');
|
|
792
|
+
|
|
793
|
+
// No wrapper unless one was asked for: an icon is already the right size,
|
|
794
|
+
// and a `View` around it is a layout node between the row and its glyph.
|
|
795
|
+
if (className === undefined && Object.keys(props).length === 0) {
|
|
796
|
+
return /*#__PURE__*/_jsx(IconColorProvider, {
|
|
797
|
+
color: tint,
|
|
798
|
+
children: children
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
return /*#__PURE__*/_jsx(View, {
|
|
802
|
+
className: className,
|
|
712
803
|
...props,
|
|
713
|
-
children:
|
|
804
|
+
children: /*#__PURE__*/_jsx(IconColorProvider, {
|
|
714
805
|
color: tint,
|
|
715
|
-
children:
|
|
716
|
-
})
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
806
|
+
children: children
|
|
807
|
+
})
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* The row's text. It takes the flexible middle, so a long title truncates
|
|
812
|
+
* rather than pushing the badge and the action off the end of the panel.
|
|
813
|
+
*/
|
|
814
|
+
function PanelsideItemLabel({
|
|
815
|
+
className,
|
|
816
|
+
children,
|
|
817
|
+
...props
|
|
818
|
+
}) {
|
|
819
|
+
const {
|
|
820
|
+
active
|
|
821
|
+
} = usePanelsideItem('Panelside.ItemLabel');
|
|
822
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
823
|
+
size: "base",
|
|
824
|
+
weight: active ? 'medium' : 'normal',
|
|
825
|
+
muted: !active,
|
|
826
|
+
numberOfLines: 1,
|
|
827
|
+
className: cn('flex-1', className),
|
|
828
|
+
...props,
|
|
829
|
+
children: children
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* The trailing count or status on a row. Text becomes a pill; anything else is
|
|
834
|
+
* drawn as given, so a dot or a chip needs no opting out of the pill.
|
|
835
|
+
*/
|
|
836
|
+
function PanelsideItemBadge({
|
|
837
|
+
className,
|
|
838
|
+
children,
|
|
839
|
+
...props
|
|
840
|
+
}) {
|
|
841
|
+
usePanelsideItem('Panelside.ItemBadge');
|
|
842
|
+
if (typeof children !== 'string' && typeof children !== 'number') {
|
|
843
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
844
|
+
children: children
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
return /*#__PURE__*/_jsx(View, {
|
|
848
|
+
className: cn('rounded-full bg-secondary px-2 py-0.5', className),
|
|
849
|
+
...props,
|
|
850
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
851
|
+
size: "xs",
|
|
852
|
+
muted: true,
|
|
853
|
+
children: children
|
|
854
|
+
})
|
|
733
855
|
});
|
|
734
856
|
}
|
|
735
857
|
function PanelsideAction({
|
|
@@ -1057,6 +1179,9 @@ PanelsideContent.displayName = 'Panelside.Content';
|
|
|
1057
1179
|
PanelsideGroup.displayName = 'Panelside.Group';
|
|
1058
1180
|
PanelsideGroupLabel.displayName = 'Panelside.GroupLabel';
|
|
1059
1181
|
PanelsideItem.displayName = 'Panelside.Item';
|
|
1182
|
+
PanelsideItemIcon.displayName = 'Panelside.ItemIcon';
|
|
1183
|
+
PanelsideItemLabel.displayName = 'Panelside.ItemLabel';
|
|
1184
|
+
PanelsideItemBadge.displayName = 'Panelside.ItemBadge';
|
|
1060
1185
|
PanelsideAction.displayName = 'Panelside.Action';
|
|
1061
1186
|
PanelsideFooter.displayName = 'Panelside.Footer';
|
|
1062
1187
|
PanelsideCta.displayName = 'Panelside.Cta';
|
|
@@ -1070,6 +1195,9 @@ export const Panelside = Object.assign(PanelsideRoot, {
|
|
|
1070
1195
|
Group: PanelsideGroup,
|
|
1071
1196
|
GroupLabel: PanelsideGroupLabel,
|
|
1072
1197
|
Item: PanelsideItem,
|
|
1198
|
+
ItemIcon: PanelsideItemIcon,
|
|
1199
|
+
ItemLabel: PanelsideItemLabel,
|
|
1200
|
+
ItemBadge: PanelsideItemBadge,
|
|
1073
1201
|
Action: PanelsideAction,
|
|
1074
1202
|
Footer: PanelsideFooter,
|
|
1075
1203
|
Cta: PanelsideCta,
|