@plexui/react-native 0.1.1 → 0.2.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 +34 -0
- package/dist/es/components/ActionSheet/ActionSheet.js +53 -19
- package/dist/es/components/Alert/Alert.js +163 -0
- package/dist/es/components/Avatar/Avatar.js +20 -8
- package/dist/es/components/BottomActions/BottomActions.js +34 -0
- package/dist/es/components/BottomSheet/BottomSheet.js +85 -17
- package/dist/es/components/Button/Button.js +108 -28
- package/dist/es/components/Card/Card.js +16 -8
- package/dist/es/components/Checkbox/Checkbox.js +67 -99
- package/dist/es/components/Chip/Chip.js +16 -7
- package/dist/es/components/Dialog/Dialog.js +38 -24
- package/dist/es/components/Field/Field.js +91 -0
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +59 -0
- package/dist/es/components/Icon/createIcon.js +13 -2
- package/dist/es/components/Indicator/CircularProgress.js +80 -0
- package/dist/es/components/Indicator/LoadingDots.js +46 -0
- package/dist/es/components/Indicator/LoadingIndicator.js +101 -0
- package/dist/es/components/Indicator/index.js +3 -0
- package/dist/es/components/Input/Input.js +69 -60
- package/dist/es/components/InputGroup/InputGroup.js +130 -0
- package/dist/es/components/List/List.js +175 -59
- package/dist/es/components/Menu/Menu.js +69 -40
- package/dist/es/components/NavigationButton/NavigationButton.js +20 -4
- package/dist/es/components/OTPInput/OTPInput.js +9 -3
- package/dist/es/components/PageControl/PageControl.js +13 -7
- package/dist/es/components/Popover/Popover.js +128 -0
- package/dist/es/components/Progress/Progress.js +142 -0
- package/dist/es/components/ProgressSteps/ProgressSteps.js +207 -0
- package/dist/es/components/RollingNumber/RollingNumber.js +125 -0
- package/dist/es/components/Select/Select.js +97 -34
- package/dist/es/components/Separator/Separator.js +31 -0
- package/dist/es/components/ShimmerText/ShimmerText.js +98 -0
- package/dist/es/components/Stepper/Stepper.js +219 -0
- package/dist/es/components/Switch/Switch.js +26 -12
- package/dist/es/components/TagInput/TagInput.js +121 -0
- package/dist/es/components/Text/Text.js +7 -4
- package/dist/es/components/TextLink/TextLink.js +42 -0
- package/dist/es/components/Textarea/Textarea.js +12 -0
- package/dist/es/components/Tip/Tip.js +193 -0
- package/dist/es/components/Toolbar/Toolbar.js +6 -2
- package/dist/es/components/Tooltip/Tooltip.js +272 -0
- package/dist/es/index.js +20 -2
- package/dist/es/internal/FloatingPanel.js +111 -0
- package/dist/es/internal/fieldStack.js +73 -0
- package/dist/es/internal/floating.js +97 -0
- package/dist/es/internal/ripple.js +119 -0
- package/dist/es/internal/row.js +2 -1
- package/dist/es/internal/transition.js +113 -0
- package/dist/es/theme/ThemeProvider.js +41 -9
- package/dist/es/theme/material.js +37 -7
- package/dist/types/components/ActionSheet/ActionSheet.d.ts +15 -7
- package/dist/types/components/Alert/Alert.d.ts +51 -0
- package/dist/types/components/Avatar/Avatar.d.ts +4 -2
- package/dist/types/components/BottomActions/BottomActions.d.ts +18 -0
- package/dist/types/components/BottomSheet/BottomSheet.d.ts +4 -2
- package/dist/types/components/Button/Button.d.ts +20 -5
- package/dist/types/components/Card/Card.d.ts +14 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts +4 -3
- package/dist/types/components/Chip/Chip.d.ts +12 -1
- package/dist/types/components/Dialog/Dialog.d.ts +9 -5
- package/dist/types/components/Field/Field.d.ts +64 -0
- package/dist/types/components/FloatingLabelInput/FloatingLabelInput.d.ts +42 -0
- package/dist/types/components/Indicator/CircularProgress.d.ts +34 -0
- package/dist/types/components/Indicator/LoadingDots.d.ts +17 -0
- package/dist/types/components/Indicator/LoadingIndicator.d.ts +46 -0
- package/dist/types/components/Indicator/index.d.ts +3 -0
- package/dist/types/components/Input/Input.d.ts +13 -3
- package/dist/types/components/InputGroup/InputGroup.d.ts +71 -0
- package/dist/types/components/List/List.d.ts +57 -14
- package/dist/types/components/Menu/Menu.d.ts +4 -0
- package/dist/types/components/NavigationButton/NavigationButton.d.ts +11 -3
- package/dist/types/components/OTPInput/OTPInput.d.ts +10 -1
- package/dist/types/components/PageControl/PageControl.d.ts +11 -1
- package/dist/types/components/Popover/Popover.d.ts +86 -0
- package/dist/types/components/Progress/Progress.d.ts +56 -0
- package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +61 -0
- package/dist/types/components/RollingNumber/RollingNumber.d.ts +36 -0
- package/dist/types/components/Select/Select.d.ts +36 -8
- package/dist/types/components/Separator/Separator.d.ts +19 -0
- package/dist/types/components/ShimmerText/ShimmerText.d.ts +28 -0
- package/dist/types/components/Stepper/Stepper.d.ts +61 -0
- package/dist/types/components/Switch/Switch.d.ts +5 -5
- package/dist/types/components/TagInput/TagInput.d.ts +44 -0
- package/dist/types/components/TextLink/TextLink.d.ts +30 -0
- package/dist/types/components/Textarea/Textarea.d.ts +19 -0
- package/dist/types/components/Tip/Tip.d.ts +71 -0
- package/dist/types/components/Toolbar/Toolbar.d.ts +9 -1
- package/dist/types/components/Tooltip/Tooltip.d.ts +84 -0
- package/dist/types/index.d.ts +20 -2
- package/dist/types/internal/FloatingPanel.d.ts +70 -0
- package/dist/types/internal/fieldStack.d.ts +48 -0
- package/dist/types/internal/floating.d.ts +71 -0
- package/dist/types/internal/ripple.d.ts +17 -0
- package/dist/types/internal/row.d.ts +15 -3
- package/dist/types/internal/transition.d.ts +37 -0
- package/dist/types/theme/ThemeProvider.d.ts +28 -4
- package/dist/types/theme/material.d.ts +20 -6
- package/dist/types/theme/types.d.ts +8 -0
- package/package.json +2 -2
- package/src/components/ActionSheet/ActionSheet.tsx +107 -38
- package/src/components/Alert/Alert.tsx +279 -0
- package/src/components/Avatar/Avatar.tsx +21 -9
- package/src/components/BottomActions/BottomActions.tsx +54 -0
- package/src/components/BottomSheet/BottomSheet.tsx +111 -25
- package/src/components/Button/Button.tsx +170 -35
- package/src/components/Card/Card.tsx +33 -9
- package/src/components/Checkbox/Checkbox.tsx +89 -124
- package/src/components/Chip/Chip.tsx +49 -6
- package/src/components/Dialog/Dialog.tsx +68 -37
- package/src/components/Field/Field.tsx +227 -0
- package/src/components/FloatingLabelInput/FloatingLabelInput.tsx +144 -0
- package/src/components/Icon/createIcon.tsx +16 -6
- package/src/components/Indicator/CircularProgress.tsx +141 -0
- package/src/components/Indicator/LoadingDots.tsx +79 -0
- package/src/components/Indicator/LoadingIndicator.tsx +166 -0
- package/src/components/Indicator/index.ts +3 -0
- package/src/components/Input/Input.tsx +126 -97
- package/src/components/InputGroup/InputGroup.tsx +261 -0
- package/src/components/List/List.tsx +345 -88
- package/src/components/Menu/Menu.tsx +83 -41
- package/src/components/NavigationButton/NavigationButton.tsx +35 -5
- package/src/components/OTPInput/OTPInput.tsx +21 -2
- package/src/components/PageControl/PageControl.tsx +36 -8
- package/src/components/Popover/Popover.tsx +261 -0
- package/src/components/Progress/Progress.tsx +255 -0
- package/src/components/ProgressSteps/ProgressSteps.tsx +415 -0
- package/src/components/RollingNumber/RollingNumber.tsx +189 -0
- package/src/components/Select/Select.tsx +175 -71
- package/src/components/Separator/Separator.tsx +51 -0
- package/src/components/ShimmerText/ShimmerText.tsx +144 -0
- package/src/components/Stepper/Stepper.tsx +386 -0
- package/src/components/Switch/Switch.tsx +26 -12
- package/src/components/TagInput/TagInput.tsx +227 -0
- package/src/components/Text/Text.tsx +8 -4
- package/src/components/TextLink/TextLink.tsx +77 -0
- package/src/components/Textarea/Textarea.tsx +23 -0
- package/src/components/Tip/Tip.tsx +410 -0
- package/src/components/Toolbar/Toolbar.tsx +27 -2
- package/src/components/Tooltip/Tooltip.tsx +478 -0
- package/src/index.ts +36 -2
- package/src/internal/FloatingPanel.tsx +199 -0
- package/src/internal/fieldStack.tsx +179 -0
- package/src/internal/floating.ts +131 -0
- package/src/internal/ripple.tsx +132 -0
- package/src/internal/row.ts +16 -3
- package/src/internal/transition.ts +124 -0
- package/src/theme/ThemeProvider.tsx +65 -15
- package/src/theme/material.ts +39 -7
- package/src/theme/types.ts +8 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
import { Animated, Easing, Platform, StyleSheet, View } from "react-native";
|
|
4
|
+
/** Android's RippleForeground: the wave grows and slides to the middle over 225ms on Material's standard curve. */
|
|
5
|
+
const ENTER = 225;
|
|
6
|
+
/** It fades in over 75ms, shows at least 225ms in all, and fades out over 150ms once let go. */
|
|
7
|
+
const FADE_IN = 75;
|
|
8
|
+
const HOLD = FADE_IN + 150;
|
|
9
|
+
const FADE_OUT = 150;
|
|
10
|
+
const STANDARD = Easing.bezier(0.4, 0, 0.2, 1);
|
|
11
|
+
/**
|
|
12
|
+
* Android's ripple where the platform draws none: the web's Android look, and a List row held through the control at
|
|
13
|
+
* its end. A wave starts at the touch point, 60% of the view's larger side across, and grows to cover the view as its
|
|
14
|
+
* centre slides to the view's middle, as Android's bounded ripple does; no scale and no flat layer. `clip` places and
|
|
15
|
+
* sizes the layer (the 40dp circle of a bar's borderless icon); by default it fills the view.
|
|
16
|
+
*/
|
|
17
|
+
export function useRipple(color, enabled, reduced, clip) {
|
|
18
|
+
const node = useRef(null);
|
|
19
|
+
const [wave, setWave] = useState(null);
|
|
20
|
+
const [grow] = useState(() => new Animated.Value(0));
|
|
21
|
+
const [shown] = useState(() => new Animated.Value(0));
|
|
22
|
+
const [gone] = useState(() => new Animated.Value(0));
|
|
23
|
+
const count = useRef(0);
|
|
24
|
+
// The wave on screen, and whether the finger is still down
|
|
25
|
+
const live = useRef(null);
|
|
26
|
+
const down = useRef(false);
|
|
27
|
+
const started = useRef(0);
|
|
28
|
+
const end = () => {
|
|
29
|
+
down.current = false;
|
|
30
|
+
const key = live.current;
|
|
31
|
+
if (key == null)
|
|
32
|
+
return;
|
|
33
|
+
live.current = null;
|
|
34
|
+
const clear = () => setWave((current) => (current?.key === key ? null : current));
|
|
35
|
+
if (reduced)
|
|
36
|
+
return clear();
|
|
37
|
+
const delay = Math.max(0, HOLD - (Date.now() - started.current));
|
|
38
|
+
Animated.timing(gone, { toValue: 1, duration: FADE_OUT, delay, easing: Easing.linear, useNativeDriver: false }).start(({ finished }) => {
|
|
39
|
+
if (finished)
|
|
40
|
+
clear();
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const start = (event) => {
|
|
44
|
+
if (!enabled)
|
|
45
|
+
return;
|
|
46
|
+
const touch = event?.nativeEvent;
|
|
47
|
+
const pageX = typeof touch?.pageX === "number" && Number.isFinite(touch.pageX) ? touch.pageX : null;
|
|
48
|
+
const pageY = typeof touch?.pageY === "number" && Number.isFinite(touch.pageY) ? touch.pageY : null;
|
|
49
|
+
const key = ++count.current;
|
|
50
|
+
down.current = true;
|
|
51
|
+
const begin = (left, top, width, height) => {
|
|
52
|
+
if (key !== count.current || !width || !height)
|
|
53
|
+
return;
|
|
54
|
+
const x = pageX == null ? width / 2 : pageX - left;
|
|
55
|
+
const y = pageY == null ? height / 2 : pageY - top;
|
|
56
|
+
live.current = key;
|
|
57
|
+
started.current = Date.now();
|
|
58
|
+
setWave({ key, x, y, width, height });
|
|
59
|
+
grow.stopAnimation();
|
|
60
|
+
shown.stopAnimation();
|
|
61
|
+
gone.stopAnimation();
|
|
62
|
+
gone.setValue(0);
|
|
63
|
+
if (reduced) {
|
|
64
|
+
grow.setValue(1);
|
|
65
|
+
shown.setValue(1);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
grow.setValue(0);
|
|
69
|
+
shown.setValue(0);
|
|
70
|
+
Animated.parallel([
|
|
71
|
+
Animated.timing(grow, { toValue: 1, duration: ENTER, easing: STANDARD, useNativeDriver: false }),
|
|
72
|
+
Animated.timing(shown, { toValue: 1, duration: FADE_IN, easing: Easing.linear, useNativeDriver: false }),
|
|
73
|
+
]).start();
|
|
74
|
+
}
|
|
75
|
+
// Let go before the view was measured
|
|
76
|
+
if (!down.current)
|
|
77
|
+
end();
|
|
78
|
+
};
|
|
79
|
+
if (Platform.OS === "web") {
|
|
80
|
+
// The page's measure of the element, in the same frame as the event's page point
|
|
81
|
+
const element = node.current;
|
|
82
|
+
const rect = element?.getBoundingClientRect?.();
|
|
83
|
+
if (!rect)
|
|
84
|
+
return;
|
|
85
|
+
const scroll = globalThis;
|
|
86
|
+
begin(rect.left + (scroll.scrollX ?? 0), rect.top + (scroll.scrollY ?? 0), rect.width, rect.height);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
node.current?.measure((_x, _y, width, height, left, top) => begin(left, top, width, height));
|
|
90
|
+
};
|
|
91
|
+
let drawn = null;
|
|
92
|
+
if (wave) {
|
|
93
|
+
const { x, y, width, height } = wave;
|
|
94
|
+
// The radius that covers the view from its middle, and the wave's first: 30% of the larger side
|
|
95
|
+
const radius = Math.hypot(width, height) / 2;
|
|
96
|
+
const first = Math.min(1, (Math.max(width, height) * 0.3) / radius);
|
|
97
|
+
drawn = (_jsx(Animated.View, { style: {
|
|
98
|
+
position: "absolute",
|
|
99
|
+
left: width / 2 - radius,
|
|
100
|
+
top: height / 2 - radius,
|
|
101
|
+
width: radius * 2,
|
|
102
|
+
height: radius * 2,
|
|
103
|
+
borderRadius: radius,
|
|
104
|
+
backgroundColor: color,
|
|
105
|
+
opacity: Animated.multiply(shown, Animated.subtract(1, gone)),
|
|
106
|
+
transform: [
|
|
107
|
+
{ translateX: grow.interpolate({ inputRange: [0, 1], outputRange: [x - width / 2, 0] }) },
|
|
108
|
+
{ translateY: grow.interpolate({ inputRange: [0, 1], outputRange: [y - height / 2, 0] }) },
|
|
109
|
+
{ scale: grow.interpolate({ inputRange: [0, 1], outputRange: [first, 1] }) },
|
|
110
|
+
],
|
|
111
|
+
} }));
|
|
112
|
+
}
|
|
113
|
+
const layer = enabled ? (_jsx(View, { ref: node, pointerEvents: "none", collapsable: false, style: [clip ? styles.placed : StyleSheet.absoluteFill, styles.clip, clip], children: drawn })) : null;
|
|
114
|
+
return { start, end, layer };
|
|
115
|
+
}
|
|
116
|
+
const styles = StyleSheet.create({
|
|
117
|
+
clip: { overflow: "hidden" },
|
|
118
|
+
placed: { position: "absolute" },
|
|
119
|
+
});
|
package/dist/es/internal/row.js
CHANGED
|
@@ -20,5 +20,6 @@ export const RowStartContext = createContext(false);
|
|
|
20
20
|
export const RowFrameContext = createContext(null);
|
|
21
21
|
/** A control's press handlers that hold its row while a finger is on it (none outside a pressable row). */
|
|
22
22
|
export function rowHold(hold) {
|
|
23
|
-
|
|
23
|
+
// The touch goes with the hold: Android's row ripples from it
|
|
24
|
+
return hold ? { onPressIn: (event) => hold(true, event), onPressOut: () => hold(false) } : null;
|
|
24
25
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect, useState } from "react";
|
|
2
|
+
import { Animated, Easing, Platform } from "react-native";
|
|
3
|
+
/** Transforms and opacity run on the native driver on a phone; react-native-web has none. */
|
|
4
|
+
export const nativeDriver = Platform.OS !== "web";
|
|
5
|
+
/** CSS's `ease`, the default curve of a CSS transition and of each keyframe of a CSS animation. */
|
|
6
|
+
export const cssEase = Easing.bezier(0.25, 0.1, 0.25, 1);
|
|
7
|
+
const beziers = new Map();
|
|
8
|
+
/** A `cubic-bezier()` value (a motion token) as an easing; CSS's named curves too. Anything else is `fallback`. */
|
|
9
|
+
export function cssEasing(value, fallback = cssEase) {
|
|
10
|
+
if (typeof value !== "string")
|
|
11
|
+
return fallback;
|
|
12
|
+
const named = {
|
|
13
|
+
ease: [0.25, 0.1, 0.25, 1],
|
|
14
|
+
"ease-in": [0.42, 0, 1, 1],
|
|
15
|
+
"ease-out": [0, 0, 0.58, 1],
|
|
16
|
+
"ease-in-out": [0.42, 0, 0.58, 1],
|
|
17
|
+
linear: [0, 0, 1, 1],
|
|
18
|
+
};
|
|
19
|
+
const match = /cubic-bezier\(\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*\)/.exec(value);
|
|
20
|
+
const points = match ? match.slice(1).map(Number) : named[value.trim()];
|
|
21
|
+
if (!points)
|
|
22
|
+
return fallback;
|
|
23
|
+
const key = points.join(",");
|
|
24
|
+
let easing = beziers.get(key);
|
|
25
|
+
if (!easing) {
|
|
26
|
+
easing = Easing.bezier(...points);
|
|
27
|
+
beziers.set(key, easing);
|
|
28
|
+
}
|
|
29
|
+
return easing;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A number that moves to `target` as a CSS transition does: from where it stands, over `duration` on `easing`; at
|
|
33
|
+
* once with reduced motion or a zero duration.
|
|
34
|
+
*/
|
|
35
|
+
export function useTransitionValue(target, { duration, easing, native = false, reducedMotion = false }) {
|
|
36
|
+
const [value] = useState(() => new Animated.Value(target));
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (reducedMotion || duration <= 0) {
|
|
39
|
+
value.stopAnimation();
|
|
40
|
+
value.setValue(target);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const animation = Animated.timing(value, { toValue: target, duration, easing, useNativeDriver: native && nativeDriver, isInteraction: false });
|
|
44
|
+
animation.start();
|
|
45
|
+
return () => animation.stop();
|
|
46
|
+
}, [value, target, duration, easing, native, reducedMotion]);
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A color that changes as a CSS `transition: background-color` does: from the color it showed to the new one over
|
|
51
|
+
* `duration`; at once with reduced motion or a zero duration (a pressed fill that lands at once).
|
|
52
|
+
*/
|
|
53
|
+
export function useColorTransition(color, { duration, easing, reducedMotion = false }) {
|
|
54
|
+
const [progress] = useState(() => new Animated.Value(1));
|
|
55
|
+
const [pair, setPair] = useState({ from: color, to: color });
|
|
56
|
+
if (pair.to !== color)
|
|
57
|
+
setPair({ from: pair.to, to: color });
|
|
58
|
+
const instant = reducedMotion || duration <= 0;
|
|
59
|
+
// The new pair starts from its first color before it is drawn
|
|
60
|
+
useLayoutEffect(() => {
|
|
61
|
+
progress.stopAnimation();
|
|
62
|
+
progress.setValue(pair.from === pair.to || instant ? 1 : 0);
|
|
63
|
+
}, [pair, instant, progress]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (pair.from === pair.to || instant)
|
|
66
|
+
return;
|
|
67
|
+
const animation = Animated.timing(progress, { toValue: 1, duration, easing, useNativeDriver: false, isInteraction: false });
|
|
68
|
+
animation.start();
|
|
69
|
+
return () => animation.stop();
|
|
70
|
+
}, [pair, instant, duration, easing, progress]);
|
|
71
|
+
if (pair.from === pair.to || instant)
|
|
72
|
+
return color;
|
|
73
|
+
return progress.interpolate({ inputRange: [0, 1], outputRange: [pair.from, pair.to] });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A clock for a looping animation: 0 to `period` ms, linear, over and over while `running`, after `delay` ms (a CSS
|
|
77
|
+
* animation's delay: only before the first turn). Parts of the animation read it through `interpolate`, as a CSS
|
|
78
|
+
* animation's keyframes read its time.
|
|
79
|
+
*/
|
|
80
|
+
export function useLoopClock(period, running, native, delay = 0) {
|
|
81
|
+
const [clock] = useState(() => new Animated.Value(0));
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
clock.stopAnimation();
|
|
84
|
+
clock.setValue(0);
|
|
85
|
+
if (!running)
|
|
86
|
+
return;
|
|
87
|
+
const loop = Animated.loop(Animated.timing(clock, { toValue: period, duration: period, easing: Easing.linear, useNativeDriver: native && nativeDriver, isInteraction: false }));
|
|
88
|
+
if (delay <= 0) {
|
|
89
|
+
loop.start();
|
|
90
|
+
return () => loop.stop();
|
|
91
|
+
}
|
|
92
|
+
const timer = setTimeout(() => loop.start(), delay);
|
|
93
|
+
return () => {
|
|
94
|
+
clearTimeout(timer);
|
|
95
|
+
loop.stop();
|
|
96
|
+
};
|
|
97
|
+
}, [clock, period, running, native, delay]);
|
|
98
|
+
return clock;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A number that moves to `target` as a CSS transition does, handed back as a plain number on each frame: for a value
|
|
102
|
+
* an animated prop cannot carry (an SVG stroke, which does not reach the element on the web).
|
|
103
|
+
*/
|
|
104
|
+
export function useTweenedNumber(target, { duration, easing, reducedMotion = false }) {
|
|
105
|
+
const value = useTransitionValue(target, { duration, easing, reducedMotion });
|
|
106
|
+
const [shown, setShown] = useState(target);
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
const id = value.addListener(({ value: next }) => setShown(next));
|
|
109
|
+
return () => value.removeListener(id);
|
|
110
|
+
}, [value]);
|
|
111
|
+
// A value set at once (reduced motion) reaches no listener before the next frame
|
|
112
|
+
return reducedMotion || duration <= 0 ? target : shown;
|
|
113
|
+
}
|
|
@@ -15,13 +15,29 @@ import { materialColors } from "./material";
|
|
|
15
15
|
export const interFonts = {
|
|
16
16
|
sans: { regular: "Inter_400Regular", medium: "Inter_500Medium", semibold: "Inter_600SemiBold", bold: "Inter_700Bold" },
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* The family names `@expo-google-fonts/roboto` registers, for `fonts`: the face of Material 3. An Android device has
|
|
20
|
+
* Roboto as its system face already; the web needs it loaded, for the Android look in a browser.
|
|
21
|
+
*
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const [loaded] = useFonts({ Roboto_400Regular, Roboto_500Medium, Roboto_600SemiBold, Roboto_700Bold })
|
|
24
|
+
* <ThemeProvider platform={platform} fonts={{ android: robotoFonts }}>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export const robotoFonts = {
|
|
28
|
+
sans: { regular: "Roboto_400Regular", medium: "Roboto_500Medium", semibold: "Roboto_600SemiBold", bold: "Roboto_700Bold" },
|
|
29
|
+
};
|
|
30
|
+
const isPlatformFonts = (fonts) => "ios" in fonts || "android" in fonts;
|
|
18
31
|
const ThemeContext = createContext(null);
|
|
19
32
|
const ThemeSettingsContext = createContext(null);
|
|
20
|
-
// On the web (react-native-web) the
|
|
21
|
-
//
|
|
33
|
+
// On the web (react-native-web) a family the app sets (Inter's variable font in the docs) takes the Plex UI tokens' SF
|
|
34
|
+
// strokes, Medium 510 and Semibold 590 (touch.css); a device's system font takes the named weights
|
|
22
35
|
const WEIGHTS = Platform.OS === "web"
|
|
23
36
|
? { regular: "400", medium: "510", semibold: "590", bold: "700" }
|
|
24
37
|
: { regular: "400", medium: "500", semibold: "600", bold: "700" };
|
|
38
|
+
// The web's system font (react-native-web's own stack, no family set): Chromium draws 501–549 of it as a synthesized bold,
|
|
39
|
+
// heavier than 590, so Medium is 500 there; 590 is SF's own Semibold, as an iPhone draws it
|
|
40
|
+
const SYSTEM_WEIGHTS = Platform.OS === "web" ? { ...WEIGHTS, medium: "500" } : WEIGHTS;
|
|
25
41
|
/** The platform a ThemeProvider draws by default. */
|
|
26
42
|
export function defaultPlatform() {
|
|
27
43
|
return Platform.OS === "android" ? "android" : "ios";
|
|
@@ -82,7 +98,7 @@ function fontFor(fonts, weight) {
|
|
|
82
98
|
// A family per weight carries its weight: a weight on top would be synthesized on Android
|
|
83
99
|
if (family && sans?.[weight])
|
|
84
100
|
return { fontFamily: family };
|
|
85
|
-
return family ? { fontFamily: family, fontWeight: WEIGHTS[weight] } : { fontWeight:
|
|
101
|
+
return family ? { fontFamily: family, fontWeight: WEIGHTS[weight] } : { fontWeight: SYSTEM_WEIGHTS[weight] };
|
|
86
102
|
}
|
|
87
103
|
/** Builds a theme for a scheme and a platform (ThemeProvider does it for its children). */
|
|
88
104
|
export function createTheme(options) {
|
|
@@ -137,7 +153,11 @@ export function createTheme(options) {
|
|
|
137
153
|
textInverse: color("--color-text-inverse"),
|
|
138
154
|
textAccent: color("--color-text-accent"),
|
|
139
155
|
textDanger: color("--color-text-danger"),
|
|
156
|
+
textSuccess: color("--color-text-success"),
|
|
140
157
|
accent: color("--color-accent"),
|
|
158
|
+
success: color("--color-background-success-solid"),
|
|
159
|
+
onSuccess: color("--color-text-success-solid"),
|
|
160
|
+
danger: color("--color-background-danger-solid"),
|
|
141
161
|
background: color("--mobile-surface-plain-primary", color("--color-surface")),
|
|
142
162
|
groupedBackground: color("--mobile-surface-grouped-primary", color("--color-surface-secondary")),
|
|
143
163
|
groupedSurface: color("--mobile-surface-grouped-secondary", color("--color-surface")),
|
|
@@ -158,13 +178,14 @@ export function createTheme(options) {
|
|
|
158
178
|
* Gives its children the Plex UI theme: tokens resolved from @plexui/styles for the scheme, the brand and a phone,
|
|
159
179
|
* and the platform the components draw. Nest one to theme a part of a screen (a dark sheet on a light page).
|
|
160
180
|
*/
|
|
161
|
-
export function ThemeProvider({ scheme, platform, selectionColor, brand, fonts, children }) {
|
|
181
|
+
export function ThemeProvider({ scheme, platform, selectionColor, brand, fonts: fontsProp, viewportWidth, children }) {
|
|
162
182
|
// A nested provider starts from its parent: a dark sheet on a light page keeps the page's platform, brand and faces
|
|
163
183
|
const parent = useContext(ThemeSettingsContext);
|
|
164
184
|
const system = useColorScheme();
|
|
165
185
|
const wantedScheme = scheme ?? parent?.scheme ?? "system";
|
|
166
186
|
const resolvedScheme = wantedScheme === "system" ? (system === "dark" ? "dark" : "light") : wantedScheme;
|
|
167
|
-
const
|
|
187
|
+
const window = useWindowDimensions();
|
|
188
|
+
const width = viewportWidth ?? parent?.viewportWidth ?? window.width;
|
|
168
189
|
const reducedMotion = useReducedMotion();
|
|
169
190
|
// The phone layers of the CSS apply up to 767px: a tablet keeps the touch sizes. Only the bands of the CSS matter.
|
|
170
191
|
const band = width >= 414 ? 414 : 393;
|
|
@@ -180,10 +201,14 @@ export function ThemeProvider({ scheme, platform, selectionColor, brand, fonts,
|
|
|
180
201
|
useEffect(() => {
|
|
181
202
|
warnUnresolvedColors(JSON.parse(brandKey) === null ? undefined : { colors: JSON.parse(brandKey) }, resolver);
|
|
182
203
|
}, [brandKey, resolver]);
|
|
183
|
-
const faces = brand?.fonts ?? fonts ?? parent?.fonts;
|
|
184
|
-
const facesKey = JSON.stringify(faces ?? null);
|
|
185
204
|
const resolvedPlatform = platform ?? parent?.platform ?? defaultPlatform();
|
|
186
|
-
const
|
|
205
|
+
const fonts = fontsProp && isPlatformFonts(fontsProp) ? (fontsProp[resolvedPlatform] ?? null) : fontsProp;
|
|
206
|
+
// `null`: faces per platform that leave this platform out draw the system face, not the parent's
|
|
207
|
+
const faces = brand?.fonts ?? (fonts === null ? undefined : (fonts ?? parent?.fonts));
|
|
208
|
+
const facesKey = JSON.stringify(faces ?? null);
|
|
209
|
+
// The color a provider was given (or its parent's); unset, iOS takes the ink and Android its accent
|
|
210
|
+
const chosenSelection = selectionColor ?? parent?.selectionColor;
|
|
211
|
+
const selection = chosenSelection ?? (resolvedPlatform === "android" ? "accent" : "primary");
|
|
187
212
|
const theme = useMemo(() => createTheme({
|
|
188
213
|
resolver,
|
|
189
214
|
scheme: resolvedScheme,
|
|
@@ -192,7 +217,14 @@ export function ThemeProvider({ scheme, platform, selectionColor, brand, fonts,
|
|
|
192
217
|
reducedMotion,
|
|
193
218
|
selectionColor: selection,
|
|
194
219
|
}), [resolver, resolvedScheme, resolvedPlatform, facesKey, reducedMotion, selection]);
|
|
195
|
-
const settings = useMemo(() => ({
|
|
220
|
+
const settings = useMemo(() => ({
|
|
221
|
+
scheme: wantedScheme,
|
|
222
|
+
platform: resolvedPlatform,
|
|
223
|
+
selectionColor: chosenSelection,
|
|
224
|
+
overrides: JSON.parse(overridesKey) ?? undefined,
|
|
225
|
+
fonts: JSON.parse(facesKey) ?? undefined,
|
|
226
|
+
viewportWidth: viewportWidth ?? parent?.viewportWidth,
|
|
227
|
+
}), [wantedScheme, resolvedPlatform, chosenSelection, overridesKey, facesKey, viewportWidth, parent?.viewportWidth]);
|
|
196
228
|
return (_jsx(ThemeSettingsContext.Provider, { value: settings, children: _jsx(ThemeContext.Provider, { value: theme, children: children }) }));
|
|
197
229
|
}
|
|
198
230
|
let fallbackTheme;
|
|
@@ -143,10 +143,16 @@ export function materialColors(resolve, scheme) {
|
|
|
143
143
|
*/
|
|
144
144
|
export const stateLayer = { hover: 0.08, focus: 0.1, pressed: 0.1, dragged: 0.16 };
|
|
145
145
|
/**
|
|
146
|
-
* The press of a row in a section on Android:
|
|
147
|
-
*
|
|
146
|
+
* The press of a row in a section on Android: black at 4.7% over a light card, as the reference's phone build draws a
|
|
147
|
+
* held card row (its public source's settings selector, #1D000010 at 11%, reads too dark beside it), and the dark
|
|
148
|
+
* theme's list selector, white at 5%, over a dark one.
|
|
148
149
|
*/
|
|
149
|
-
export const controlHighlight = (scheme) => (scheme === "dark" ? "rgba(255, 255, 255, 0.05)" : "rgba(0, 0,
|
|
150
|
+
export const controlHighlight = (scheme) => (scheme === "dark" ? "rgba(255, 255, 255, 0.05)" : "rgba(0, 0, 0, 0.047)");
|
|
151
|
+
/**
|
|
152
|
+
* Android's list selector outside a section, the ripple of a popup's item and of a dialog's row: black at 0x0F of
|
|
153
|
+
* 255 over a light surface, white at 0x0D at night.
|
|
154
|
+
*/
|
|
155
|
+
export const androidSelector = (scheme) => (scheme === "dark" ? "rgba(255, 255, 255, 0.051)" : "rgba(0, 0, 0, 0.059)");
|
|
150
156
|
/**
|
|
151
157
|
* Text in the accent on Android, as the blue text over a card (a section header, a row's value). Light: #298ACF,
|
|
152
158
|
* which the bright Plex accent (`primary`) is closest to. At night the blues get lighter (#79C4FC in the dark theme):
|
|
@@ -164,12 +170,36 @@ export function dangerText(theme) {
|
|
|
164
170
|
return theme.scheme === "dark" ? theme.color("--color-text-danger-soft", theme.material.error) : theme.material.error;
|
|
165
171
|
}
|
|
166
172
|
/**
|
|
167
|
-
* The divider between the rows of a card on Android: a light gray over a light card (#D9D9D9
|
|
168
|
-
*
|
|
169
|
-
*
|
|
173
|
+
* The divider between the rows of a card on Android: a light gray over a light card (#D9D9D9) and darker than the
|
|
174
|
+
* card at night (#000000 under a #181819 card; the darkest Plex gray, `--gray-0`, the grouped canvas), as the web's
|
|
175
|
+
* `--android-divider`.
|
|
170
176
|
*/
|
|
171
177
|
export function divider(theme) {
|
|
172
|
-
return theme.
|
|
178
|
+
return theme.scheme === "dark" ? theme.color("--gray-0", theme.colors.separator) : "#D9D9D9";
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The fixed grays of the Plex Android look, each with its night pair, as the web's android.css sets them: an off
|
|
182
|
+
* switch's track (`--android-switch-off`: #A7ADB2, `--gray-500` at night), an empty checkbox's ring
|
|
183
|
+
* (`--android-checkbox-ring`: #B0B9C2, `--gray-500`), a field's idle line (`--android-field-line`: #DBDBDB, the text
|
|
184
|
+
* at 24%), a field's hint (`--android-hint`: #A8A8A8, #7D7D7D), the gap between a row menu's groups
|
|
185
|
+
* (`--android-popup-gap`: #F5F5F5, #262626) and a header menu's (`--android-menu-band`: the text at 6%).
|
|
186
|
+
*/
|
|
187
|
+
export function androidGray(theme, role) {
|
|
188
|
+
const dark = theme.scheme === "dark";
|
|
189
|
+
switch (role) {
|
|
190
|
+
case "switchOff":
|
|
191
|
+
return dark ? theme.color("--gray-500") : "#A7ADB2";
|
|
192
|
+
case "checkboxRing":
|
|
193
|
+
return dark ? theme.color("--gray-500") : "#B0B9C2";
|
|
194
|
+
case "fieldLine":
|
|
195
|
+
return dark ? withAlpha(theme.colors.text, 0.24) : "#DBDBDB";
|
|
196
|
+
case "hint":
|
|
197
|
+
return dark ? "#7D7D7D" : "#A8A8A8";
|
|
198
|
+
case "popupGap":
|
|
199
|
+
return dark ? "#262626" : "#F5F5F5";
|
|
200
|
+
case "menuBand":
|
|
201
|
+
return withAlpha(theme.colors.text, 0.06);
|
|
202
|
+
}
|
|
173
203
|
}
|
|
174
204
|
/**
|
|
175
205
|
* Material's shadow elevations as CSS box shadows (the key and ambient shadows of the Material web components'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
1
|
+
import { type ReactNode, type RefObject } from "react";
|
|
2
2
|
export type ActionSheetAction = {
|
|
3
3
|
label: string;
|
|
4
4
|
onPress?: () => void;
|
|
@@ -14,14 +14,22 @@ export type ActionSheetProps = {
|
|
|
14
14
|
title?: ReactNode;
|
|
15
15
|
message?: ReactNode;
|
|
16
16
|
actions: ActionSheetAction[];
|
|
17
|
-
/** The cancel action of iOS,
|
|
17
|
+
/** The cancel action of iOS, the last of the panel. Android closes the sheet with a tap outside or Back. @default "Cancel" */
|
|
18
18
|
cancelLabel?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The control the sheet opens from (a ref to a Button, a Pressable, a View). On iOS 26 the sheet then stands at it
|
|
21
|
+
* as a glass panel, over or under it, with no Cancel: a tap anywhere else closes it (an iPhone's action sheet with a
|
|
22
|
+
* `sourceItem`, WWDC25 "Build a UIKit app with the new design"). Android keeps its sheet from the bottom.
|
|
23
|
+
*/
|
|
24
|
+
source?: RefObject<unknown>;
|
|
19
25
|
testID?: string;
|
|
20
26
|
};
|
|
21
27
|
/**
|
|
22
|
-
* A choice of actions
|
|
23
|
-
* UIAlertController's `.actionSheet` on an iPhone: a glass panel
|
|
24
|
-
*
|
|
25
|
-
*
|
|
28
|
+
* A choice of actions (React Native only: the web has a Menu, a Popover or an alert Dialog). iOS 26 draws
|
|
29
|
+
* UIAlertController's `.actionSheet` on an iPhone: with a `source`, a glass panel at that control (as the web's
|
|
30
|
+
* Popover "Confirmation"), its 48pt capsule actions under the title and message, no Cancel, closed by a tap outside;
|
|
31
|
+
* with no source, the same panel in the middle of the screen, Cancel its last capsule (as the web's alert Dialog with a
|
|
32
|
+
* stacked footer). Android a menu sheet (its items: 48dp rows of Regular 16, the icon in a 56dp slot in the ink, gray
|
|
33
|
+
* at night, the text 16 in with no icons, a gray title of 16 over them).
|
|
26
34
|
*/
|
|
27
|
-
export declare function ActionSheet({ open, onOpenChange, title, message, actions, cancelLabel, testID }: ActionSheetProps): import("react").JSX.Element;
|
|
35
|
+
export declare function ActionSheet({ open, onOpenChange, title, message, actions, cancelLabel, source, testID }: ActionSheetProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type StyleProp, type ViewStyle } from "react-native";
|
|
3
|
+
import type { Theme } from "../../theme/types";
|
|
4
|
+
export type AlertColor = "primary" | "danger" | "success" | "info" | "discovery" | "caution" | "warning";
|
|
5
|
+
export type AlertVariant = "solid" | "soft" | "outline";
|
|
6
|
+
export type AlertMobileActions = "capsules" | "own";
|
|
7
|
+
export type AlertProps = {
|
|
8
|
+
/** @default "primary" */
|
|
9
|
+
color?: AlertColor;
|
|
10
|
+
/** On a phone a soft or outline alert is gray, only its icon in the color; a solid one keeps its color. @default "outline" */
|
|
11
|
+
variant?: AlertVariant;
|
|
12
|
+
/** The alert's title. */
|
|
13
|
+
title?: ReactNode;
|
|
14
|
+
/** Its description. */
|
|
15
|
+
description?: ReactNode;
|
|
16
|
+
/** Buttons for the alert's actions, under the message. */
|
|
17
|
+
actions?: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* `capsules`: each action a capsule as wide as half the alert at least, side by side (an iOS tip's buttons); `own`:
|
|
20
|
+
* the buttons as given, starting where the text starts, for an alert inside a block of buttons of its own.
|
|
21
|
+
* @default "capsules"
|
|
22
|
+
*/
|
|
23
|
+
mobileActions?: AlertMobileActions;
|
|
24
|
+
/** An icon in place of the one of the color; `false` shows none. */
|
|
25
|
+
indicator?: ReactNode | false;
|
|
26
|
+
/** Shows a close button in the alert's corner, which calls this. */
|
|
27
|
+
onDismiss?: () => void;
|
|
28
|
+
/** @default "Dismiss" */
|
|
29
|
+
dismissLabel?: string;
|
|
30
|
+
/** A full-width strip across the top or bottom of a screen: square corners. @default false */
|
|
31
|
+
banner?: boolean;
|
|
32
|
+
testID?: string;
|
|
33
|
+
style?: StyleProp<ViewStyle>;
|
|
34
|
+
/** The style of the actions' row. */
|
|
35
|
+
actionsStyle?: StyleProp<ViewStyle>;
|
|
36
|
+
};
|
|
37
|
+
/** The colors of an alert on a phone (Alert.module.css, `max-width: 767px`). */
|
|
38
|
+
export declare function alertColors(theme: Theme, color: AlertColor, variant: AlertVariant): {
|
|
39
|
+
background: string;
|
|
40
|
+
title: string;
|
|
41
|
+
description: string;
|
|
42
|
+
icon: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* An inline message (a notice, a warning), as @plexui/ui's Alert on a phone: the shape and text of an iOS tip
|
|
46
|
+
* (TipKit), the system's message inside a screen. A soft or outline alert is gray with the icon in its color, a solid
|
|
47
|
+
* one keeps its color; the actions stand under the message as capsules side by side; `onDismiss` puts a close button
|
|
48
|
+
* in the corner. Neither platform has an inline alert of its own: Android draws the same card in its own sizes. A
|
|
49
|
+
* danger alert is announced as an `alert`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function Alert({ color, variant, title, description, actions, mobileActions, indicator, onDismiss, dismissLabel, banner, testID, style, actionsStyle, }: AlertProps): import("react").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ComponentType, type ReactNode } from "react";
|
|
2
|
-
import { type StyleProp, type ViewStyle } from "react-native";
|
|
2
|
+
import { type ImageSourcePropType, type StyleProp, type ViewStyle } from "react-native";
|
|
3
3
|
import type { Theme } from "../../theme/types";
|
|
4
4
|
import type { IconProps } from "../Icon/createIcon";
|
|
5
5
|
export type AvatarColor = "primary" | "secondary" | "success" | "info" | "discovery" | "danger";
|
|
@@ -10,6 +10,8 @@ export type AvatarProps = {
|
|
|
10
10
|
name?: string;
|
|
11
11
|
/** A picture over the placeholder; when it fails to load, the placeholder stays. */
|
|
12
12
|
imageUrl?: string;
|
|
13
|
+
/** A picture as an Image source (a `require()`d asset, `{ uri }`), as `Card.Media` takes it; it wins over `imageUrl`. */
|
|
14
|
+
source?: ImageSourcePropType;
|
|
13
15
|
/**
|
|
14
16
|
* @default "secondary". A `gradient` avatar in the secondary color takes one of the seven gradients from its name,
|
|
15
17
|
* the same each time; the other colors take the nearest gradient
|
|
@@ -43,7 +45,7 @@ export declare function avatarColors(theme: Theme, color: AvatarColor, variant:
|
|
|
43
45
|
* `variant="gradient"` it is a gradient of one of seven colors from top to bottom with up to two white initials,
|
|
44
46
|
* Medium at 18/50 of the circle.
|
|
45
47
|
*/
|
|
46
|
-
export declare function Avatar({ name, imageUrl, color, variant, size: sizeProp, Icon, overflowCount, onPress, accessibilityLabel, testID, style }: AvatarProps): import("react").JSX.Element;
|
|
48
|
+
export declare function Avatar({ name, imageUrl, source: sourceProp, color, variant, size: sizeProp, Icon, overflowCount, onPress, accessibilityLabel, testID, style }: AvatarProps): import("react").JSX.Element;
|
|
47
49
|
export type AvatarGroupProps = {
|
|
48
50
|
children: ReactNode;
|
|
49
51
|
/** The size of every avatar. @default 28 */
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type StyleProp, type ViewStyle } from "react-native";
|
|
3
|
+
export type BottomActionsProps = {
|
|
4
|
+
/** The screen's main action, a Button, and an optional second Button under it (a ghost "Not now"). */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** Puts the actions over the content (a scroll view under them); off, they take their room at the end of the screen. @default false */
|
|
7
|
+
floating?: boolean;
|
|
8
|
+
testID?: string;
|
|
9
|
+
style?: StyleProp<ViewStyle>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The main action at the bottom of a phone screen: an onboarding's "Continue", a form's "Create account". iOS 26: a
|
|
13
|
+
* capsule across the screen, 36pt from its sides, 52pt tall, its bottom just over the home indicator (2pt above the
|
|
14
|
+
* safe area, about 36pt from the screen's edge on a Face ID iPhone), as iOS 26's own setup screens set it; a second
|
|
15
|
+
* action stands under it, 8 apart. Android: the Plex Android look's 48dp full-width button, 16dp from the sides and
|
|
16
|
+
* 16 above the gesture bar. Each Button inside is a block of the size `3xl` unless it sets its own.
|
|
17
|
+
*/
|
|
18
|
+
export declare function BottomActions({ children, floating, testID, style }: BottomActionsProps): import("react").JSX.Element;
|
|
@@ -44,8 +44,10 @@ export declare function BottomSheetBase({ open, onOpenChange, title, children, d
|
|
|
44
44
|
/**
|
|
45
45
|
* A sheet from the bottom edge: on iOS 26 the sheet of the phone layer (`--dialog-sheet-radius` 38 on its top corners,
|
|
46
46
|
* a bar 16 under its top edge with Close at the leading edge and the title centered, as the web's phone Sheet; no
|
|
47
|
-
* grabber, since its height does not change), on Android
|
|
48
|
-
*
|
|
47
|
+
* grabber, since its height does not change), on Android the reference's sheet (35dp top corners, white, no handle,
|
|
48
|
+
* a bar of 46dp glass circles 12 under the top edge and 12 from the sides, concentric with the corners, with the title
|
|
49
|
+
* 17 Medium centered, the
|
|
50
|
+
* content 12 from the sides, a 20% dim, the screen's width in portrait). Drag it down to close it: its bar on iOS, anywhere on
|
|
49
51
|
* Android (from content that scrolls once it is at its top, and on a phone only from its rows and fields, since its
|
|
50
52
|
* plain parts keep the drag for the scroll).
|
|
51
53
|
* `BottomSheet.Footer` pins actions under the content.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
2
|
-
import { type PressableProps, type StyleProp, type ViewStyle } from "react-native";
|
|
1
|
+
import { type ComponentRef, type ReactNode, type Ref } from "react";
|
|
2
|
+
import { View, type PressableProps, type StyleProp, type ViewStyle } from "react-native";
|
|
3
3
|
import type { Theme } from "../../theme/types";
|
|
4
4
|
export type ButtonColor = "primary" | "secondary" | "danger" | "success" | "info" | "discovery" | "caution" | "warning";
|
|
5
5
|
export type ButtonVariant = "solid" | "soft" | "outline" | "ghost";
|
|
@@ -7,7 +7,11 @@ export type ControlSize = "3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2x
|
|
|
7
7
|
export type ButtonProps = Omit<PressableProps, "children" | "style"> & {
|
|
8
8
|
/** @default "primary" */
|
|
9
9
|
color?: ButtonColor;
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* iOS's styles are Filled (`solid`), Tinted or Gray (`soft`) and Plain (`ghost`); it has no outlined button, so on
|
|
12
|
+
* iOS `outline` is the Gray button (the neutral soft fill, the label in the button's color). Android draws the
|
|
13
|
+
* outline. @default "solid"
|
|
14
|
+
*/
|
|
11
15
|
variant?: ButtonVariant;
|
|
12
16
|
/**
|
|
13
17
|
* Height step of the Plex UI scale. iOS takes the native sizes of the phone layer (small 28, medium 34, large 50);
|
|
@@ -39,6 +43,8 @@ export type ButtonProps = Omit<PressableProps, "children" | "style"> & {
|
|
|
39
43
|
/** Icons and text; an icon element takes the label's color and the size of the button's icons. */
|
|
40
44
|
children?: ReactNode;
|
|
41
45
|
style?: StyleProp<ViewStyle>;
|
|
46
|
+
/** The button's native view: an ActionSheet's `source`, a measure. */
|
|
47
|
+
ref?: Ref<ComponentRef<typeof View>>;
|
|
42
48
|
};
|
|
43
49
|
type Metrics = {
|
|
44
50
|
height: number;
|
|
@@ -83,6 +89,8 @@ export type BarItemStyle = {
|
|
|
83
89
|
* action is the accent's ink, as Android's classic bars draw them.
|
|
84
90
|
*/
|
|
85
91
|
plain?: boolean;
|
|
92
|
+
/** A bottom bar's item (Android: a confirm there keeps its circle, not a top bar's text pill). */
|
|
93
|
+
bottom?: boolean;
|
|
86
94
|
};
|
|
87
95
|
export declare const BarItemContext: import("react").Context<BarItemStyle | null>;
|
|
88
96
|
/**
|
|
@@ -98,6 +106,12 @@ export declare const BarFieldContext: import("react").Context<{
|
|
|
98
106
|
/** The color of the screen under the bar. */
|
|
99
107
|
canvas?: string;
|
|
100
108
|
} | null>;
|
|
109
|
+
/**
|
|
110
|
+
* A ghost Button in a List: in its `header` it is the list header's text action, in a `row` (a Button among a List's
|
|
111
|
+
* rows) the row is the button, as the web's ghost Button in a FieldGroup's header or in a `[data-row]`. Null elsewhere.
|
|
112
|
+
*/
|
|
113
|
+
export type ListAction = "header" | "row";
|
|
114
|
+
export declare const ListActionContext: import("react").Context<ListAction | null>;
|
|
101
115
|
export declare function buttonMetrics(theme: Theme, size: ControlSize, shape?: "round" | "square", uniform?: boolean): Metrics;
|
|
102
116
|
type Colors = {
|
|
103
117
|
background: string;
|
|
@@ -114,7 +128,8 @@ export declare function useMaterialPress(theme: Theme): boolean;
|
|
|
114
128
|
/**
|
|
115
129
|
* A button after the platform: an iOS 26 capsule (the native sizes of the Plex UI phone layer, its colors and glass)
|
|
116
130
|
* or the Android button (a pill, 14 Medium, the Plex colors; a disabled one keeps its fill and dims its label to
|
|
117
|
-
* half). Props follow @plexui/ui.
|
|
131
|
+
* half). Props follow @plexui/ui. A ghost Button in a List's header or among its rows is drawn as the list's text action
|
|
132
|
+
* (`ListActionContext`).
|
|
118
133
|
*/
|
|
119
|
-
export declare function Button(
|
|
134
|
+
export declare function Button(props: ButtonProps): import("react").JSX.Element;
|
|
120
135
|
export {};
|