@plexui/react-native 0.2.7 → 0.2.8
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/dist/es/components/ActionSheet/ActionSheet.js +2 -1
- package/dist/es/components/Alert/Alert.js +2 -1
- package/dist/es/components/Avatar/Avatar.js +2 -1
- package/dist/es/components/Badge/Badge.js +2 -1
- package/dist/es/components/BottomActions/BottomActions.js +3 -3
- package/dist/es/components/BottomSheet/BottomSheet.js +2 -1
- package/dist/es/components/Button/Button.js +2 -1
- package/dist/es/components/Card/Card.js +2 -1
- package/dist/es/components/Checkbox/Checkbox.js +2 -1
- package/dist/es/components/Chip/Chip.js +2 -1
- package/dist/es/components/DatePicker/Calendar.js +2 -1
- package/dist/es/components/DatePicker/DatePicker.js +2 -1
- package/dist/es/components/DatePicker/TimeDial.js +2 -1
- package/dist/es/components/DatePicker/Wheel.js +2 -1
- package/dist/es/components/Dialog/Dialog.js +2 -1
- package/dist/es/components/Input/Input.js +2 -1
- package/dist/es/components/InputGroup/InputGroup.js +2 -1
- package/dist/es/components/List/List.js +31 -8
- package/dist/es/components/Menu/Menu.js +2 -1
- package/dist/es/components/RadioGroup/RadioGroup.js +2 -1
- package/dist/es/components/SegmentedControl/SegmentedControl.js +52 -54
- package/dist/es/components/Select/Select.js +2 -1
- package/dist/es/components/Stepper/Stepper.js +2 -1
- package/dist/es/components/Switch/Switch.js +2 -1
- package/dist/es/components/TabBar/TabBar.js +2 -1
- package/dist/es/components/TagInput/TagInput.js +2 -1
- package/dist/es/components/Tip/Tip.js +2 -1
- package/dist/es/components/Toast/Toast.js +2 -1
- package/dist/es/internal/Pressable.js +10 -0
- package/dist/es/theme/material.js +11 -2
- package/dist/types/components/BottomActions/BottomActions.d.ts +10 -1
- package/dist/types/components/SegmentedControl/SegmentedControl.d.ts +11 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/Pressable.d.ts +3 -0
- package/package.json +1 -1
- package/src/components/ActionSheet/ActionSheet.tsx +2 -1
- package/src/components/Alert/Alert.tsx +2 -1
- package/src/components/Avatar/Avatar.tsx +2 -1
- package/src/components/Badge/Badge.tsx +2 -1
- package/src/components/BottomActions/BottomActions.tsx +14 -2
- package/src/components/BottomSheet/BottomSheet.tsx +2 -1
- package/src/components/Button/Button.tsx +2 -13
- package/src/components/Card/Card.tsx +2 -1
- package/src/components/Checkbox/Checkbox.tsx +2 -1
- package/src/components/Chip/Chip.tsx +2 -1
- package/src/components/DatePicker/Calendar.tsx +2 -1
- package/src/components/DatePicker/DatePicker.tsx +2 -1
- package/src/components/DatePicker/TimeDial.tsx +2 -1
- package/src/components/DatePicker/Wheel.tsx +2 -1
- package/src/components/Dialog/Dialog.tsx +2 -1
- package/src/components/Input/Input.tsx +2 -17
- package/src/components/InputGroup/InputGroup.tsx +2 -1
- package/src/components/List/List.tsx +39 -9
- package/src/components/Menu/Menu.tsx +2 -1
- package/src/components/RadioGroup/RadioGroup.tsx +2 -1
- package/src/components/SegmentedControl/SegmentedControl.tsx +68 -48
- package/src/components/Select/Select.tsx +2 -1
- package/src/components/Stepper/Stepper.tsx +2 -1
- package/src/components/Switch/Switch.tsx +2 -1
- package/src/components/TabBar/TabBar.tsx +2 -13
- package/src/components/TagInput/TagInput.tsx +2 -1
- package/src/components/Tip/Tip.tsx +2 -1
- package/src/components/Toast/Toast.tsx +2 -1
- package/src/index.ts +1 -1
- package/src/internal/Pressable.tsx +17 -0
- package/src/theme/material.ts +9 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContext, isValidElement, useContext, useEffect, useRef, useState, type ReactElement, type ReactNode } from "react"
|
|
2
|
-
import { Animated, Easing,
|
|
2
|
+
import { Animated, Easing, StyleSheet, View, type LayoutChangeEvent, type StyleProp, type ViewStyle } from "react-native"
|
|
3
|
+
import { Pressable } from "../../internal/Pressable"
|
|
3
4
|
import { childrenOfType, isRenderable, textOf } from "../../internal/children"
|
|
4
5
|
import { Glass } from "../../internal/Glass"
|
|
5
6
|
import { curves } from "../../internal/motion"
|
|
@@ -44,6 +45,12 @@ export type SegmentedControlProps<T extends string> = {
|
|
|
44
45
|
* @default "equal"
|
|
45
46
|
*/
|
|
46
47
|
mobileSegmentWidth?: "equal" | "content"
|
|
48
|
+
/**
|
|
49
|
+
* Draws each tab's `badge`: a count in a small capsule after its label, as a messenger's folder tabs set their
|
|
50
|
+
* unread counts; each segment then takes its own width (`mobileSegmentWidth` content), 10 beside its label and
|
|
51
|
+
* count. Off, the count is only read with the segment's name, as the native controls draw none. @default false
|
|
52
|
+
*/
|
|
53
|
+
showBadges?: boolean
|
|
47
54
|
style?: StyleProp<ViewStyle>
|
|
48
55
|
testID?: string
|
|
49
56
|
/** `SegmentedControl.Tab` elements. */
|
|
@@ -60,7 +67,10 @@ export type SegmentedControlOptionProps = {
|
|
|
60
67
|
children?: ReactNode
|
|
61
68
|
/** A symbol before the label; with a label, iOS shows the symbol alone, as UISegmentedControl. */
|
|
62
69
|
icon?: ReactNode
|
|
63
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* A count. Read with the segment's name; drawn only with the control's `showBadges`, as the native controls (iOS and
|
|
72
|
+
* Material alike) draw none.
|
|
73
|
+
*/
|
|
64
74
|
badge?: SegmentedControlBadgeProp
|
|
65
75
|
disabled?: boolean
|
|
66
76
|
testID?: string
|
|
@@ -105,7 +115,7 @@ function iosLook(theme: Theme, size: ControlSize, material: "glass" | "flat" | u
|
|
|
105
115
|
glass: true,
|
|
106
116
|
fill: theme.color("--segmented-control-mobile-glass-background"),
|
|
107
117
|
thumb: theme.color("--segmented-control-mobile-thumb-background"),
|
|
108
|
-
duration:
|
|
118
|
+
duration: 300,
|
|
109
119
|
}
|
|
110
120
|
}
|
|
111
121
|
return {
|
|
@@ -124,42 +134,6 @@ function iosLook(theme: Theme, size: ControlSize, material: "glass" | "flat" | u
|
|
|
124
134
|
}
|
|
125
135
|
}
|
|
126
136
|
|
|
127
|
-
/**
|
|
128
|
-
* The curve the large control's lens lands on (touch.css `--tabs-thumb-transition-easing`, iOS 27.2 frame by frame):
|
|
129
|
-
* CSS `linear()` stops, each [progress, time], read between them as the browser does.
|
|
130
|
-
*/
|
|
131
|
-
const LENS_STOPS: [number, number][] = [
|
|
132
|
-
[0, 0],
|
|
133
|
-
[0.2, 0.03],
|
|
134
|
-
[0.33, 0.0625],
|
|
135
|
-
[0.45, 0.1],
|
|
136
|
-
[0.538, 0.1225],
|
|
137
|
-
[0.623, 0.1625],
|
|
138
|
-
[0.69, 0.2],
|
|
139
|
-
[0.747, 0.2425],
|
|
140
|
-
[0.793, 0.2875],
|
|
141
|
-
[0.83, 0.325],
|
|
142
|
-
[0.862, 0.3675],
|
|
143
|
-
[0.887, 0.41],
|
|
144
|
-
[0.908, 0.45],
|
|
145
|
-
[0.925, 0.4925],
|
|
146
|
-
[0.943, 0.535],
|
|
147
|
-
[0.956, 0.58],
|
|
148
|
-
[0.975, 0.66],
|
|
149
|
-
[0.981, 0.7],
|
|
150
|
-
[0.989, 0.7475],
|
|
151
|
-
[0.994, 0.825],
|
|
152
|
-
[1, 1],
|
|
153
|
-
]
|
|
154
|
-
const lensEasing = (t: number) => {
|
|
155
|
-
if (t <= 0) return 0
|
|
156
|
-
if (t >= 1) return 1
|
|
157
|
-
const after = LENS_STOPS.findIndex(([, at]) => at >= t)
|
|
158
|
-
const [fromValue, fromAt] = LENS_STOPS[after - 1]
|
|
159
|
-
const [toValue, toAt] = LENS_STOPS[after]
|
|
160
|
-
return fromValue + ((toValue - fromValue) * (t - fromAt)) / (toAt - fromAt)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
137
|
type ControlContext = { inRow: boolean }
|
|
164
138
|
/** A Toolbar.Row tells the control in it that it is in a row, not in the bar's own row. */
|
|
165
139
|
export const SegmentedControlRowContext = createContext<ControlContext>({ inRow: false })
|
|
@@ -197,6 +171,7 @@ function SegmentedControlRoot<T extends string>({
|
|
|
197
171
|
block = false,
|
|
198
172
|
mobileMaterial,
|
|
199
173
|
mobileSegmentWidth = "equal",
|
|
174
|
+
showBadges = false,
|
|
200
175
|
style,
|
|
201
176
|
testID,
|
|
202
177
|
children,
|
|
@@ -215,7 +190,9 @@ function SegmentedControlRoot<T extends string>({
|
|
|
215
190
|
if (option) select(option)
|
|
216
191
|
},
|
|
217
192
|
)
|
|
218
|
-
|
|
193
|
+
// Drawn counts differ from tab to tab, so each segment takes its own width with them, as a messenger's folder tabs
|
|
194
|
+
const counted = showBadges && options.some((option) => option.badge != null)
|
|
195
|
+
const common = { options, value, select, keys, disabled, block, equal: mobileSegmentWidth === "equal" && !counted, showBadges }
|
|
219
196
|
return (
|
|
220
197
|
<View accessibilityRole="tablist" aria-label={ariaLabel} accessibilityState={{ disabled }} testID={testID} style={[block ? styles.block : styles.hug, style]}>
|
|
221
198
|
{theme.isAndroid ? <AndroidControl {...common} size={size} /> : <IOSControl {...common} size={size} material={mobileMaterial} />}
|
|
@@ -232,9 +209,10 @@ type ControlProps = {
|
|
|
232
209
|
disabled: boolean
|
|
233
210
|
block: boolean
|
|
234
211
|
equal: boolean
|
|
212
|
+
showBadges: boolean
|
|
235
213
|
}
|
|
236
214
|
|
|
237
|
-
function IOSControl({ options, value, select, keys, disabled, block, equal, size, material }: ControlProps & { size: ControlSize; material?: "glass" | "flat" }) {
|
|
215
|
+
function IOSControl({ options, value, select, keys, disabled, block, equal, showBadges, size, material }: ControlProps & { size: ControlSize; material?: "glass" | "flat" }) {
|
|
238
216
|
const theme = useTheme()
|
|
239
217
|
const inBar = !!useContext(BarItemContext)
|
|
240
218
|
const { inRow } = useContext(SegmentedControlRowContext)
|
|
@@ -244,6 +222,9 @@ function IOSControl({ options, value, select, keys, disabled, block, equal, size
|
|
|
244
222
|
const [widths, setWidths] = useState<Record<string, number>>({})
|
|
245
223
|
const widest = Math.max(0, ...options.map((option) => labels[option.value] ?? 0))
|
|
246
224
|
const optionRadius = look.height / 2 - look.gutter
|
|
225
|
+
// A drawn count ends a label in a capsule of its own: the thumb keeps 10 beside the label and the capsule, so the
|
|
226
|
+
// capsule does not touch the thumb's end
|
|
227
|
+
const gutter = showBadges && options.some((option) => option.badge != null) ? Math.max(look.optionGutter, 10) : look.optionGutter
|
|
247
228
|
// The large glass control held down, as the phone CSS ports it: the capsule grows 7% and whitens, the held label
|
|
248
229
|
// fades to 20%, with no capsule of its own under the finger
|
|
249
230
|
const largeGlass = look.glass && look.height >= 40
|
|
@@ -266,13 +247,14 @@ function IOSControl({ options, value, select, keys, disabled, block, equal, size
|
|
|
266
247
|
placed.current = true
|
|
267
248
|
return
|
|
268
249
|
}
|
|
269
|
-
// The
|
|
270
|
-
|
|
250
|
+
// The thumb eases (CSS `ease`): in 300ms on the large control, 250 on the small one. The lens's own curve (fast,
|
|
251
|
+
// then a long settle) reads as a jump and a crawl when no lens is drawn over it (owner, 24.11)
|
|
252
|
+
const easing = Easing.bezier(0.25, 0.1, 0.25, 1)
|
|
271
253
|
Animated.parallel([
|
|
272
254
|
Animated.timing(x, { toValue: selectedX, duration: look.duration, easing, useNativeDriver: false }),
|
|
273
255
|
Animated.timing(width, { toValue: selectedWidth, duration: look.duration, easing, useNativeDriver: false }),
|
|
274
256
|
]).start()
|
|
275
|
-
}, [selectedX, selectedWidth, look.duration,
|
|
257
|
+
}, [selectedX, selectedWidth, look.duration, theme.reducedMotion, x, width])
|
|
276
258
|
// The segments take the capsule's whole height, so a press anywhere on it lands (the thumb keeps its inset); a
|
|
277
259
|
// minimum, so text a person enlarges is not cut
|
|
278
260
|
const track: ViewStyle = {
|
|
@@ -317,8 +299,8 @@ function IOSControl({ options, value, select, keys, disabled, block, equal, size
|
|
|
317
299
|
}}
|
|
318
300
|
style={[
|
|
319
301
|
styles.option,
|
|
320
|
-
{ paddingHorizontal:
|
|
321
|
-
block ? styles.grow : equal && widest ? { width: widest + 2 *
|
|
302
|
+
{ paddingHorizontal: gutter, borderRadius: look.height / 2 },
|
|
303
|
+
block ? styles.grow : equal && widest ? { width: widest + 2 * gutter } : null,
|
|
322
304
|
]}
|
|
323
305
|
>
|
|
324
306
|
<View
|
|
@@ -343,6 +325,7 @@ function IOSControl({ options, value, select, keys, disabled, block, equal, size
|
|
|
343
325
|
{option.children}
|
|
344
326
|
</Text>
|
|
345
327
|
)}
|
|
328
|
+
{showBadges ? <SegmentCount badge={option.badge} selected={isSelected} off={off} /> : null}
|
|
346
329
|
</View>
|
|
347
330
|
</Pressable>
|
|
348
331
|
)
|
|
@@ -382,7 +365,7 @@ const ANDROID_MOVE = { duration: 320, easing: curves.easeOutQuint }
|
|
|
382
365
|
* its label in the accent, the others in the secondary gray. The pill slides to a new selection and takes its width.
|
|
383
366
|
* In a bar's row of controls the capsule takes the height of the circles beside it (46dp).
|
|
384
367
|
*/
|
|
385
|
-
function AndroidControl({ options, value, select, keys, disabled, block, equal, size }: ControlProps & { size: ControlSize }) {
|
|
368
|
+
function AndroidControl({ options, value, select, keys, disabled, block, equal, showBadges, size }: ControlProps & { size: ControlSize }) {
|
|
386
369
|
const theme = useTheme()
|
|
387
370
|
const m = theme.material
|
|
388
371
|
const bar = useContext(BarItemContext)
|
|
@@ -434,6 +417,7 @@ function AndroidControl({ options, value, select, keys, disabled, block, equal,
|
|
|
434
417
|
selected={option.value === value}
|
|
435
418
|
off={disabled || !!option.disabled}
|
|
436
419
|
framed={frame}
|
|
420
|
+
showBadges={showBadges}
|
|
437
421
|
height={inner}
|
|
438
422
|
// In a filled row equal segments share the width and the others take their label and share what is left; a
|
|
439
423
|
// control that hugs its segments gives equal ones the widest one's width
|
|
@@ -453,6 +437,7 @@ type AndroidSegmentProps = {
|
|
|
453
437
|
off: boolean
|
|
454
438
|
/** The pill is placed: the selected segment draws none of its own. */
|
|
455
439
|
framed: boolean
|
|
440
|
+
showBadges: boolean
|
|
456
441
|
height: number
|
|
457
442
|
size: ViewStyle | null
|
|
458
443
|
keys: ReturnType<typeof useTabKeys>
|
|
@@ -461,7 +446,7 @@ type AndroidSegmentProps = {
|
|
|
461
446
|
}
|
|
462
447
|
|
|
463
448
|
/** One segment of the capsule: its label turns from the gray to the accent as the pill comes, and back as it goes. */
|
|
464
|
-
function AndroidSegment({ option, selected, off, framed, height, size, keys, select, onWidth }: AndroidSegmentProps) {
|
|
449
|
+
function AndroidSegment({ option, selected, off, framed, showBadges, height, size, keys, select, onWidth }: AndroidSegmentProps) {
|
|
465
450
|
const theme = useTheme()
|
|
466
451
|
const m = theme.material
|
|
467
452
|
const [tint] = useState(() => new Animated.Value(selected ? 1 : 0))
|
|
@@ -509,10 +494,42 @@ function AndroidSegment({ option, selected, off, framed, height, size, keys, sel
|
|
|
509
494
|
{option.children}
|
|
510
495
|
</Animated.Text>
|
|
511
496
|
) : null}
|
|
497
|
+
{showBadges ? <SegmentCount badge={option.badge} selected={selected} off={off} /> : null}
|
|
512
498
|
</Pressable>
|
|
513
499
|
)
|
|
514
500
|
}
|
|
515
501
|
|
|
502
|
+
/**
|
|
503
|
+
* A tab's count drawn after its label (`showBadges`): a capsule 18 tall, the digits 12 semibold in the screen's color.
|
|
504
|
+
* iOS: the label's color on the selected segment, so it reads on the thumb, the secondary label on the others.
|
|
505
|
+
* Android: the accent on the selected segment, as its label, the gray on the others.
|
|
506
|
+
*/
|
|
507
|
+
function SegmentCount({ badge, selected, off }: { badge: SegmentedControlBadgeProp | undefined; selected: boolean; off: boolean }) {
|
|
508
|
+
const theme = useTheme()
|
|
509
|
+
const text = badge != null ? badgeText(badge) : undefined
|
|
510
|
+
if (!text) return null
|
|
511
|
+
// iOS: the label's color in a capsule, the bar's ink in it; Android: the segment's own ink, the selected one's
|
|
512
|
+
// container in it (onSecondaryContainer on secondaryContainer), the others' onSurfaceVariant on the surface, so the
|
|
513
|
+
// small digits keep their contrast
|
|
514
|
+
const fill = off
|
|
515
|
+
? theme.color("--alpha-20")
|
|
516
|
+
: theme.isAndroid
|
|
517
|
+
? selected
|
|
518
|
+
? theme.material.onSecondaryContainer
|
|
519
|
+
: theme.material.onSurfaceVariant
|
|
520
|
+
: selected
|
|
521
|
+
? theme.colors.text
|
|
522
|
+
: theme.colors.labelSecondary
|
|
523
|
+
const ink = theme.isAndroid ? (selected ? theme.material.secondaryContainer : theme.material.surface) : theme.colors.background
|
|
524
|
+
return (
|
|
525
|
+
<View aria-hidden style={[styles.count, { backgroundColor: fill }]}>
|
|
526
|
+
<Text numberOfLines={1} weight="semibold" color={ink} style={styles.countText}>
|
|
527
|
+
{text}
|
|
528
|
+
</Text>
|
|
529
|
+
</View>
|
|
530
|
+
)
|
|
531
|
+
}
|
|
532
|
+
|
|
516
533
|
export const SegmentedControl = Object.assign(SegmentedControlRoot, { Tab: SegmentedControlTab, Option: SegmentedControlTab })
|
|
517
534
|
|
|
518
535
|
const styles = StyleSheet.create({
|
|
@@ -523,6 +540,9 @@ const styles = StyleSheet.create({
|
|
|
523
540
|
stretch: { alignSelf: "stretch" },
|
|
524
541
|
heldControl: { transform: [{ scale: 1.07 }] },
|
|
525
542
|
heldLabel: { opacity: 0.2 },
|
|
543
|
+
// 18 tall, taller with a larger text size: the capsule grows round its digits
|
|
544
|
+
count: { minWidth: 18, minHeight: 18, paddingHorizontal: 5, borderRadius: 999, alignItems: "center", justifyContent: "center" },
|
|
545
|
+
countText: { fontSize: 12, lineHeight: 16, fontVariant: ["tabular-nums"] },
|
|
526
546
|
thumb: { position: "absolute", borderCurve: "continuous" },
|
|
527
547
|
option: { alignItems: "center", justifyContent: "center", minWidth: 0 },
|
|
528
548
|
label: { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 8 },
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useContext, useEffect, useLayoutEffect, useState, type ReactNode } from "react"
|
|
2
|
-
import { Platform,
|
|
2
|
+
import { Platform, StyleSheet, View, type StyleProp, type ViewStyle } from "react-native"
|
|
3
|
+
import { Pressable } from "../../internal/Pressable"
|
|
3
4
|
import Svg, { Path } from "react-native-svg"
|
|
4
5
|
import ChevronUpDown from "../../icons/plex/ChevronUpDown"
|
|
5
6
|
import { spaceToggles } from "../../internal/a11y"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react"
|
|
2
|
-
import { Animated, Platform,
|
|
2
|
+
import { Animated, Platform, StyleSheet, View, type AccessibilityActionEvent, type StyleProp, type ViewStyle } from "react-native"
|
|
3
|
+
import { Pressable } from "../../internal/Pressable"
|
|
3
4
|
import Minus from "../../icons/plex/Minus"
|
|
4
5
|
import Plus from "../../icons/plex/Plus"
|
|
5
6
|
import RemoveTrash from "../../icons/plex/RemoveTrash"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useContext, useEffect, useState, type ReactNode } from "react"
|
|
2
|
-
import { Animated, Easing,
|
|
2
|
+
import { Animated, Easing, StyleSheet, View, type StyleProp, type ViewStyle } from "react-native"
|
|
3
|
+
import { Pressable } from "../../internal/Pressable"
|
|
3
4
|
import { spaceToggles, useDescription } from "../../internal/a11y"
|
|
4
5
|
import { ControlLabel } from "../../internal/ControlLabel"
|
|
5
6
|
import { RowEndContext, RowHoldContext, rowHold } from "../../internal/row"
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { createContext, useCallback, useContext, useEffect, useRef, useState, type ReactElement, type ReactNode } from "react"
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
Easing,
|
|
5
|
-
Pressable,
|
|
6
|
-
StyleSheet,
|
|
7
|
-
View,
|
|
8
|
-
type LayoutChangeEvent,
|
|
9
|
-
type NativeScrollEvent,
|
|
10
|
-
type NativeSyntheticEvent,
|
|
11
|
-
type StyleProp,
|
|
12
|
-
type ViewProps,
|
|
13
|
-
type ViewStyle,
|
|
14
|
-
} from "react-native"
|
|
2
|
+
import { Animated, Easing, StyleSheet, View, type LayoutChangeEvent, type NativeScrollEvent, type NativeSyntheticEvent, type StyleProp, type ViewProps, type ViewStyle } from "react-native"
|
|
3
|
+
import { Pressable } from "../../internal/Pressable"
|
|
15
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
|
16
5
|
import Search from "../../icons/plex/Search"
|
|
17
6
|
import { BarBackdrop, SoftBottomEdge, TabBarFade, ANDROID_FADE_ALPHA, ANDROID_FADE_STOPS, glassBarBlur, useAndroidGlass } from "../../internal/BarBackdrop"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useContext, useRef, useState, type ComponentRef } from "react"
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet, TextInput, View, type StyleProp, type TextInputKeyPressEvent, type ViewStyle } from "react-native"
|
|
3
|
+
import { Pressable } from "../../internal/Pressable"
|
|
3
4
|
import X from "../../icons/plex/X"
|
|
4
5
|
import { RowEndContext } from "../../internal/row"
|
|
5
6
|
import { dangerText, withAlpha } from "../../theme/material"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cloneElement, isValidElement, useState, type ReactElement, type ReactNode } from "react"
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet, View, useWindowDimensions, type GestureResponderEvent, type StyleProp, type ViewStyle } from "react-native"
|
|
3
|
+
import { Pressable } from "../../internal/Pressable"
|
|
3
4
|
import Svg, { Path } from "react-native-svg"
|
|
4
5
|
import X from "../../icons/plex/X"
|
|
5
6
|
import { flattenChildren, isRenderable, textOf } from "../../internal/children"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, type ReactNode } from "react"
|
|
2
|
-
import { AccessibilityInfo, Animated, Easing, PanResponder, PixelRatio, Platform,
|
|
2
|
+
import { AccessibilityInfo, Animated, Easing, PanResponder, PixelRatio, Platform, StyleSheet, View, useWindowDimensions } from "react-native"
|
|
3
|
+
import { Pressable } from "../../internal/Pressable"
|
|
3
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
|
4
5
|
import CheckCircle from "../../icons/plex/CheckCircle"
|
|
5
6
|
import InfoCircle from "../../icons/plex/InfoCircle"
|
package/src/index.ts
CHANGED
|
@@ -91,7 +91,7 @@ export { Toaster, toast, type ToasterProps, type ToastId, type ToastOptions, typ
|
|
|
91
91
|
|
|
92
92
|
export { Avatar, AvatarGroup, type AvatarColor, type AvatarGroupProps, type AvatarProps, type AvatarVariant } from "./components/Avatar/Avatar"
|
|
93
93
|
export { Badge, type BadgeColor, type BadgeProps, type BadgeSize, type BadgeVariant } from "./components/Badge/Badge"
|
|
94
|
-
export { BottomActions, type BottomActionsProps } from "./components/BottomActions/BottomActions"
|
|
94
|
+
export { BottomActions, type BottomActionsBackground, type BottomActionsProps } from "./components/BottomActions/BottomActions"
|
|
95
95
|
export { Card, cardColors, type CardColor, type CardMediaProps, type CardProps, type CardSize, type CardVariant } from "./components/Card/Card"
|
|
96
96
|
export { List, ListItem, type ListItemProps, type ListProps } from "./components/List/List"
|
|
97
97
|
export { Chip, type ChipProps } from "./components/Chip/Chip"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { forwardRef, type ComponentRef } from "react"
|
|
2
|
+
import { Platform, Pressable as NativePressable, type PressableProps } from "react-native"
|
|
3
|
+
|
|
4
|
+
// A press target takes no text selection on the web: a drag or a long press over a row, a button or a segment selects
|
|
5
|
+
// nothing, as on iOS and Android, where a control's label is never selectable
|
|
6
|
+
const NO_SELECT = Platform.OS === "web" ? ({ userSelect: "none" } as object) : null
|
|
7
|
+
|
|
8
|
+
/** react-native's Pressable that selects no text on the web; every pressable control of the kit is drawn with it. */
|
|
9
|
+
export const Pressable = forwardRef<ComponentRef<typeof NativePressable>, PressableProps>(function Pressable({ style, ...props }, ref) {
|
|
10
|
+
return (
|
|
11
|
+
<NativePressable
|
|
12
|
+
ref={ref}
|
|
13
|
+
{...props}
|
|
14
|
+
style={typeof style === "function" ? (state) => [NO_SELECT, style(state)] : [NO_SELECT, style]}
|
|
15
|
+
/>
|
|
16
|
+
)
|
|
17
|
+
})
|
package/src/theme/material.ts
CHANGED
|
@@ -242,13 +242,20 @@ export const elevationShadow = {
|
|
|
242
242
|
|
|
243
243
|
/** A color with its alpha multiplied: a state layer or a disabled container. */
|
|
244
244
|
export function withAlpha(color: string, alpha: number): string {
|
|
245
|
-
// `#rrggbb(aa)`, `rgb()
|
|
245
|
+
// `#rgb(a)`, `#rrggbb(aa)`, `rgb()`, `rgba()`, `white` or `black`; any other form is returned as it is
|
|
246
246
|
const c = channels(color)
|
|
247
247
|
return c ? `rgba(${c[0]}, ${c[1]}, ${c[2]}, ${Math.round(c[3] * alpha * 1000) / 1000})` : color
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
/** The channels of a `#rrggbb(aa)
|
|
250
|
+
/** The channels of a `#rgb(a)`, `#rrggbb(aa)`, `rgb(a)()`, `white` or `black` color, alpha 0–1; undefined for any other form. */
|
|
251
251
|
function channels(color: string): [number, number, number, number] | undefined {
|
|
252
|
+
// `#rgb(a)` reads as `#rrggbb(aa)`; `white` and `black`, the names a canvas is likeliest to be given
|
|
253
|
+
if (color === "white") return [255, 255, 255, 1]
|
|
254
|
+
if (color === "black") return [0, 0, 0, 1]
|
|
255
|
+
if (color.startsWith("#") && (color.length === 4 || color.length === 5)) {
|
|
256
|
+
const [r, g, b, a = "f"] = color.slice(1)
|
|
257
|
+
return [parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), parseInt(a + a, 16) / 255]
|
|
258
|
+
}
|
|
252
259
|
if (color.startsWith("#") && (color.length === 7 || color.length === 9)) {
|
|
253
260
|
const a = color.length === 9 ? parseInt(color.slice(7, 9), 16) / 255 : 1
|
|
254
261
|
return [parseInt(color.slice(1, 3), 16), parseInt(color.slice(3, 5), 16), parseInt(color.slice(5, 7), 16), a]
|