@compsych-ui-components/react-native 4.0.4 → 4.0.13
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/package.json +22 -14
- package/src/components/ActionSheet/index.d.ts +16 -0
- package/src/components/ActionSheet/index.js +256 -0
- package/src/components/ActionSheet/index.js.map +1 -0
- package/src/components/Alert/index.d.ts +24 -0
- package/src/components/Alert/index.js +304 -0
- package/src/components/Alert/index.js.map +1 -0
- package/src/components/Avatar/index.d.ts +22 -0
- package/src/components/Avatar/index.js +253 -0
- package/src/components/Avatar/index.js.map +1 -0
- package/src/components/Badge/index.d.ts +12 -0
- package/src/components/Badge/index.js +206 -0
- package/src/components/Badge/index.js.map +1 -0
- package/src/components/BodyText/index.d.ts +9 -0
- package/src/components/BodyText/index.js +58 -0
- package/src/components/BodyText/index.js.map +1 -0
- package/src/components/Breadcrumb/index.d.ts +24 -0
- package/src/components/Breadcrumb/index.js +194 -0
- package/src/components/Breadcrumb/index.js.map +1 -0
- package/src/components/Button/index.d.ts +16 -0
- package/src/components/Button/index.js +260 -0
- package/src/components/Button/index.js.map +1 -0
- package/src/components/Checkbox/index.d.ts +16 -0
- package/src/components/Checkbox/index.js +196 -0
- package/src/components/Checkbox/index.js.map +1 -0
- package/src/components/Chip/index.d.ts +18 -0
- package/src/components/Chip/index.js +280 -0
- package/src/components/Chip/index.js.map +1 -0
- package/src/components/Divider/index.d.ts +11 -0
- package/src/components/Divider/index.js +59 -0
- package/src/components/Divider/index.js.map +1 -0
- package/src/components/EmptyState/index.d.ts +25 -0
- package/src/components/EmptyState/index.js +376 -0
- package/src/components/EmptyState/index.js.map +1 -0
- package/src/components/HeaderText/index.d.ts +9 -0
- package/src/components/HeaderText/index.js +62 -0
- package/src/components/HeaderText/index.js.map +1 -0
- package/src/components/Input/index.d.ts +13 -0
- package/src/components/Input/index.js +231 -0
- package/src/components/Input/index.js.map +1 -0
- package/src/components/List/index.d.ts +19 -0
- package/src/components/List/index.js +170 -0
- package/src/components/List/index.js.map +1 -0
- package/src/components/Pagination/index.d.ts +15 -0
- package/src/components/Pagination/index.js +322 -0
- package/src/components/Pagination/index.js.map +1 -0
- package/src/components/PlanCard/index.d.ts +27 -0
- package/src/components/PlanCard/index.js +364 -0
- package/src/components/PlanCard/index.js.map +1 -0
- package/src/components/ProgressTracker/index.d.ts +26 -0
- package/src/components/ProgressTracker/index.js +180 -0
- package/src/components/ProgressTracker/index.js.map +1 -0
- package/src/components/PromotionCard/index.d.ts +23 -0
- package/src/components/PromotionCard/index.js +496 -0
- package/src/components/PromotionCard/index.js.map +1 -0
- package/src/components/RadioButton/index.d.ts +15 -0
- package/src/components/RadioButton/index.js +188 -0
- package/src/components/RadioButton/index.js.map +1 -0
- package/src/components/ScreenContainer/index.d.ts +15 -0
- package/src/components/ScreenContainer/index.js +43 -0
- package/src/components/ScreenContainer/index.js.map +1 -0
- package/src/components/SegmentedControl/index.d.ts +16 -0
- package/src/components/SegmentedControl/index.js +115 -0
- package/src/components/SegmentedControl/index.js.map +1 -0
- package/src/components/SelectionCard/index.d.ts +16 -0
- package/src/components/SelectionCard/index.js +222 -0
- package/src/components/SelectionCard/index.js.map +1 -0
- package/src/components/ServiceCard/index.d.ts +22 -0
- package/src/components/ServiceCard/index.js +385 -0
- package/src/components/ServiceCard/index.js.map +1 -0
- package/src/components/Slider/index.d.ts +24 -0
- package/src/components/Slider/index.js +320 -0
- package/src/components/Slider/index.js.map +1 -0
- package/src/components/Snackbar/index.d.ts +13 -0
- package/src/components/Snackbar/index.js +229 -0
- package/src/components/Snackbar/index.js.map +1 -0
- package/src/components/Switch/index.d.ts +14 -0
- package/src/components/Switch/index.js +221 -0
- package/src/components/Switch/index.js.map +1 -0
- package/src/components/Tooltip/index.d.ts +21 -0
- package/src/components/Tooltip/index.js +206 -0
- package/src/components/Tooltip/index.js.map +1 -0
- package/src/icons/AtomIcon.d.ts +2 -0
- package/src/icons/AtomIcon.js +85 -0
- package/src/icons/AtomIcon.js.map +1 -0
- package/src/icons/BinocularsIcon.d.ts +2 -0
- package/src/icons/BinocularsIcon.js +103 -0
- package/src/icons/BinocularsIcon.js.map +1 -0
- package/src/icons/FileChartColumnIncreasingIcon.d.ts +2 -0
- package/src/icons/FileChartColumnIncreasingIcon.js +97 -0
- package/src/icons/FileChartColumnIncreasingIcon.js.map +1 -0
- package/src/icons/FlagIcon.d.ts +2 -0
- package/src/icons/FlagIcon.js +71 -0
- package/src/icons/FlagIcon.js.map +1 -0
- package/src/icons/GlobeIcon.d.ts +2 -0
- package/src/icons/GlobeIcon.js +71 -0
- package/src/icons/GlobeIcon.js.map +1 -0
- package/src/icons/GraduationCapIcon.d.ts +2 -0
- package/src/icons/GraduationCapIcon.js +85 -0
- package/src/icons/GraduationCapIcon.js.map +1 -0
- package/src/icons/HandHeartIcon.d.ts +2 -0
- package/src/icons/HandHeartIcon.js +91 -0
- package/src/icons/HandHeartIcon.js.map +1 -0
- package/src/icons/HandshakeIcon.d.ts +2 -0
- package/src/icons/HandshakeIcon.js +97 -0
- package/src/icons/HandshakeIcon.js.map +1 -0
- package/src/icons/HazeIcon.d.ts +2 -0
- package/src/icons/HazeIcon.js +115 -0
- package/src/icons/HazeIcon.js.map +1 -0
- package/src/icons/HeartHandshakeIcon.d.ts +2 -0
- package/src/icons/HeartHandshakeIcon.js +71 -0
- package/src/icons/HeartHandshakeIcon.js.map +1 -0
- package/src/icons/HourglassIcon.d.ts +2 -0
- package/src/icons/HourglassIcon.js +91 -0
- package/src/icons/HourglassIcon.js.map +1 -0
- package/src/icons/IdCardIcon.d.ts +2 -0
- package/src/icons/IdCardIcon.js +97 -0
- package/src/icons/IdCardIcon.js.map +1 -0
- package/src/icons/MessageCirclePlusIcon.d.ts +2 -0
- package/src/icons/MessageCirclePlusIcon.js +85 -0
- package/src/icons/MessageCirclePlusIcon.js.map +1 -0
- package/src/icons/MountainSnowIcon.d.ts +2 -0
- package/src/icons/MountainSnowIcon.js +79 -0
- package/src/icons/MountainSnowIcon.js.map +1 -0
- package/src/icons/SnowflakeIcon.d.ts +2 -0
- package/src/icons/SnowflakeIcon.js +139 -0
- package/src/icons/SnowflakeIcon.js.map +1 -0
- package/src/icons/StethoscopeIcon.d.ts +2 -0
- package/src/icons/StethoscopeIcon.js +97 -0
- package/src/icons/StethoscopeIcon.js.map +1 -0
- package/src/icons/UserRoundIcon.d.ts +2 -0
- package/src/icons/UserRoundIcon.js +79 -0
- package/src/icons/UserRoundIcon.js.map +1 -0
- package/src/icons/WheatIcon.d.ts +2 -0
- package/src/icons/WheatIcon.js +115 -0
- package/src/icons/WheatIcon.js.map +1 -0
- package/src/icons/index.d.ts +22 -0
- package/src/icons/index.js +109 -0
- package/src/icons/index.js.map +1 -0
- package/src/icons/types.d.ts +16 -0
- package/src/icons/types.js +52 -0
- package/src/icons/types.js.map +1 -0
- package/src/index.d.ts +60 -2
- package/src/index.js +197 -5
- package/src/index.js.map +1 -1
- package/src/theme/ThemeContext.d.ts +258 -0
- package/src/theme/ThemeContext.js +15 -0
- package/src/theme/ThemeContext.js.map +1 -0
- package/src/theme/ThemeProvider.d.ts +27 -0
- package/src/theme/ThemeProvider.js +66 -0
- package/src/theme/ThemeProvider.js.map +1 -0
- package/src/theme/defaultTheme.d.ts +13 -0
- package/src/theme/defaultTheme.js +14 -0
- package/src/theme/defaultTheme.js.map +1 -0
- package/src/theme/index.d.ts +5 -0
- package/src/theme/index.js +26 -0
- package/src/theme/index.js.map +1 -0
- package/src/theme/mergeTheme.d.ts +7 -0
- package/src/theme/mergeTheme.js +40 -0
- package/src/theme/mergeTheme.js.map +1 -0
- package/src/theme/types.d.ts +25 -0
- package/src/theme/types.js +6 -0
- package/src/theme/types.js.map +1 -0
- package/src/theme/useTheme.d.ts +10 -0
- package/src/theme/useTheme.js +17 -0
- package/src/theme/useTheme.js.map +1 -0
- package/src/tokens.d.ts +253 -0
- package/src/tokens.js +265 -0
- package/src/tokens.js.map +1 -0
- package/src/lib/button.d.ts +0 -7
- package/src/lib/button.js +0 -58
- package/src/lib/button.js.map +0 -1
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Slider", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Slider;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
13
|
+
const _reactnative = require("react-native");
|
|
14
|
+
const _theme = require("../../theme");
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
16
|
+
if (typeof WeakMap !== "function") return null;
|
|
17
|
+
var cacheBabelInterop = new WeakMap();
|
|
18
|
+
var cacheNodeInterop = new WeakMap();
|
|
19
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
20
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
21
|
+
})(nodeInterop);
|
|
22
|
+
}
|
|
23
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
24
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
28
|
+
return {
|
|
29
|
+
default: obj
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
33
|
+
if (cache && cache.has(obj)) {
|
|
34
|
+
return cache.get(obj);
|
|
35
|
+
}
|
|
36
|
+
var newObj = {
|
|
37
|
+
__proto__: null
|
|
38
|
+
};
|
|
39
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
40
|
+
for(var key in obj){
|
|
41
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
42
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
43
|
+
if (desc && (desc.get || desc.set)) {
|
|
44
|
+
Object.defineProperty(newObj, key, desc);
|
|
45
|
+
} else {
|
|
46
|
+
newObj[key] = obj[key];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
newObj.default = obj;
|
|
51
|
+
if (cache) {
|
|
52
|
+
cache.set(obj, newObj);
|
|
53
|
+
}
|
|
54
|
+
return newObj;
|
|
55
|
+
}
|
|
56
|
+
// ── Layout constants ──────────────────────────────────────────────────────────
|
|
57
|
+
const TRACK_HEIGHT = 8;
|
|
58
|
+
const THUMB_SIZE = 24;
|
|
59
|
+
const THUMB_HALF = THUMB_SIZE / 2; // 12
|
|
60
|
+
const HIT_HEIGHT = 48; // symbol height from Figma — contains track + thumb
|
|
61
|
+
// Vertical offsets within the 48px container
|
|
62
|
+
const TRACK_TOP = (HIT_HEIGHT - TRACK_HEIGHT) / 2; // 20
|
|
63
|
+
const THUMB_TOP = (HIT_HEIGHT - THUMB_SIZE) / 2; // 12
|
|
64
|
+
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
65
|
+
function clamp(v, lo, hi) {
|
|
66
|
+
return Math.max(lo, Math.min(hi, v));
|
|
67
|
+
}
|
|
68
|
+
function Slider({ value: valueProp, defaultValue, min = 0, max = 100, step = 1, onValueChange, onSlidingComplete, label, showMinMax = true, disabled = false, accessibilityLabel, style }) {
|
|
69
|
+
const { colorRoles: cr, dimensions: dim, typeScale: ts } = (0, _theme.useTheme)();
|
|
70
|
+
const isControlled = valueProp !== undefined;
|
|
71
|
+
const [internalValue, setInternalValue] = (0, _react.useState)(defaultValue ?? min);
|
|
72
|
+
const displayValue = isControlled ? valueProp : internalValue;
|
|
73
|
+
const [focused, setFocused] = (0, _react.useState)(false);
|
|
74
|
+
const [pressed, setPressed] = (0, _react.useState)(false);
|
|
75
|
+
// ── Track width (measured on layout) ────────────────────────────────────────
|
|
76
|
+
const trackWidthRef = (0, _react.useRef)(0);
|
|
77
|
+
const [trackWidth, setTrackWidth] = (0, _react.useState)(0);
|
|
78
|
+
const handleTrackLayout = (0, _react.useCallback)((e)=>{
|
|
79
|
+
const w = e.nativeEvent.layout.width;
|
|
80
|
+
trackWidthRef.current = w;
|
|
81
|
+
setTrackWidth(w);
|
|
82
|
+
}, []);
|
|
83
|
+
// Keep a ref to the latest displayValue so PanResponder can read it
|
|
84
|
+
const displayValueRef = (0, _react.useRef)(displayValue);
|
|
85
|
+
(0, _react.useEffect)(()=>{
|
|
86
|
+
displayValueRef.current = displayValue;
|
|
87
|
+
}, [
|
|
88
|
+
displayValue
|
|
89
|
+
]);
|
|
90
|
+
// ── Value conversion ─────────────────────────────────────────────────────────
|
|
91
|
+
function fractionToValue(frac) {
|
|
92
|
+
const raw = min + clamp(frac, 0, 1) * (max - min);
|
|
93
|
+
const stepped = Math.round(raw / step) * step;
|
|
94
|
+
return clamp(stepped, min, max);
|
|
95
|
+
}
|
|
96
|
+
function valueToFraction(v) {
|
|
97
|
+
return (v - min) / (max - min);
|
|
98
|
+
}
|
|
99
|
+
function commitValue(v, isFinal) {
|
|
100
|
+
if (!isControlled) setInternalValue(v);
|
|
101
|
+
onValueChange?.(v);
|
|
102
|
+
if (isFinal) onSlidingComplete?.(v);
|
|
103
|
+
}
|
|
104
|
+
// ── PanResponder ─────────────────────────────────────────────────────────────
|
|
105
|
+
const panStartFraction = (0, _react.useRef)(0);
|
|
106
|
+
const panResponder = (0, _react.useRef)(_reactnative.PanResponder.create({
|
|
107
|
+
onStartShouldSetPanResponder: ()=>!disabled && trackWidthRef.current > 0,
|
|
108
|
+
onMoveShouldSetPanResponder: ()=>!disabled && trackWidthRef.current > 0,
|
|
109
|
+
// Don't let parent ScrollView steal the gesture once we've started
|
|
110
|
+
onPanResponderTerminationRequest: ()=>false,
|
|
111
|
+
onPanResponderGrant: (evt)=>{
|
|
112
|
+
setPressed(true);
|
|
113
|
+
// Jump thumb to the tapped position on the track
|
|
114
|
+
const tapped = clamp(evt.nativeEvent.locationX, 0, trackWidthRef.current);
|
|
115
|
+
panStartFraction.current = tapped / trackWidthRef.current;
|
|
116
|
+
const v = fractionToValue(panStartFraction.current);
|
|
117
|
+
commitValue(v, false);
|
|
118
|
+
},
|
|
119
|
+
onPanResponderMove: (_, gs)=>{
|
|
120
|
+
const newFrac = clamp(panStartFraction.current + gs.dx / trackWidthRef.current, 0, 1);
|
|
121
|
+
const v = fractionToValue(newFrac);
|
|
122
|
+
commitValue(v, false);
|
|
123
|
+
},
|
|
124
|
+
onPanResponderRelease: (_, gs)=>{
|
|
125
|
+
setPressed(false);
|
|
126
|
+
const newFrac = clamp(panStartFraction.current + gs.dx / trackWidthRef.current, 0, 1);
|
|
127
|
+
commitValue(fractionToValue(newFrac), true);
|
|
128
|
+
},
|
|
129
|
+
onPanResponderTerminate: ()=>setPressed(false)
|
|
130
|
+
})).current;
|
|
131
|
+
// ── Derived geometry ──────────────────────────────────────────────────────────
|
|
132
|
+
const fraction = trackWidth > 0 ? valueToFraction(displayValue) : 0;
|
|
133
|
+
const thumbCenterX = fraction * trackWidth;
|
|
134
|
+
const thumbLeft = thumbCenterX - THUMB_HALF;
|
|
135
|
+
const fillWidth = thumbCenterX;
|
|
136
|
+
// ── Thumb shadow — lv3 when pressed/hovered, lv1 otherwise ──────────────────
|
|
137
|
+
const thumbShadow = pressed ? {
|
|
138
|
+
shadowColor: '#000',
|
|
139
|
+
shadowOffset: {
|
|
140
|
+
width: 0,
|
|
141
|
+
height: 4
|
|
142
|
+
},
|
|
143
|
+
shadowOpacity: 0.16,
|
|
144
|
+
shadowRadius: 16,
|
|
145
|
+
elevation: 3
|
|
146
|
+
} : {
|
|
147
|
+
shadowColor: '#000',
|
|
148
|
+
shadowOffset: {
|
|
149
|
+
width: 0,
|
|
150
|
+
height: 2
|
|
151
|
+
},
|
|
152
|
+
shadowOpacity: 0.06,
|
|
153
|
+
shadowRadius: 8,
|
|
154
|
+
elevation: 1
|
|
155
|
+
};
|
|
156
|
+
// ── Token-derived styles ──────────────────────────────────────────────────────
|
|
157
|
+
const tokenStyles = (0, _react.useMemo)(()=>({
|
|
158
|
+
root: {
|
|
159
|
+
gap: dim.spacing.padding.sysPadding8,
|
|
160
|
+
alignSelf: 'stretch'
|
|
161
|
+
},
|
|
162
|
+
label: {
|
|
163
|
+
color: cr.surface.surface.sysOnSurface,
|
|
164
|
+
fontSize: ts.labelMedium.sysFontSize,
|
|
165
|
+
lineHeight: ts.labelMedium.sysLineHeight,
|
|
166
|
+
letterSpacing: ts.labelMedium.sysTracking,
|
|
167
|
+
fontWeight: '400',
|
|
168
|
+
includeFontPadding: false
|
|
169
|
+
},
|
|
170
|
+
row: {
|
|
171
|
+
flexDirection: 'row',
|
|
172
|
+
alignItems: 'center',
|
|
173
|
+
gap: dim.spacing.padding.sysPadding8
|
|
174
|
+
},
|
|
175
|
+
rangeLabel: {
|
|
176
|
+
color: cr.surface.surface.sysOnSurfaceVariant,
|
|
177
|
+
fontSize: ts.bodySmall.sysFontSize,
|
|
178
|
+
lineHeight: ts.bodySmall.sysLineHeight,
|
|
179
|
+
fontWeight: '400',
|
|
180
|
+
includeFontPadding: false,
|
|
181
|
+
flexShrink: 0
|
|
182
|
+
},
|
|
183
|
+
trackBg: {
|
|
184
|
+
position: 'absolute',
|
|
185
|
+
top: TRACK_TOP,
|
|
186
|
+
left: 0,
|
|
187
|
+
right: 0,
|
|
188
|
+
height: TRACK_HEIGHT,
|
|
189
|
+
borderRadius: 9999,
|
|
190
|
+
backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerHighest
|
|
191
|
+
},
|
|
192
|
+
trackFill: {
|
|
193
|
+
position: 'absolute',
|
|
194
|
+
top: TRACK_TOP,
|
|
195
|
+
left: 0,
|
|
196
|
+
height: TRACK_HEIGHT,
|
|
197
|
+
borderRadius: 9999,
|
|
198
|
+
backgroundColor: cr.accent.primary.sysPrimary
|
|
199
|
+
},
|
|
200
|
+
thumb: {
|
|
201
|
+
position: 'absolute',
|
|
202
|
+
top: THUMB_TOP,
|
|
203
|
+
width: THUMB_SIZE,
|
|
204
|
+
height: THUMB_SIZE,
|
|
205
|
+
borderRadius: 9999,
|
|
206
|
+
backgroundColor: cr.surface.surface.sysSurface,
|
|
207
|
+
alignItems: 'center',
|
|
208
|
+
justifyContent: 'center'
|
|
209
|
+
}
|
|
210
|
+
}), [
|
|
211
|
+
cr,
|
|
212
|
+
dim,
|
|
213
|
+
ts
|
|
214
|
+
]);
|
|
215
|
+
// ── Render ────────────────────────────────────────────────────────────────────
|
|
216
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
217
|
+
style: [
|
|
218
|
+
tokenStyles.root,
|
|
219
|
+
style
|
|
220
|
+
],
|
|
221
|
+
accessible: true,
|
|
222
|
+
accessibilityRole: "adjustable",
|
|
223
|
+
accessibilityLabel: accessibilityLabel ?? label,
|
|
224
|
+
accessibilityValue: {
|
|
225
|
+
min,
|
|
226
|
+
max,
|
|
227
|
+
now: displayValue
|
|
228
|
+
},
|
|
229
|
+
onAccessibilityAction: (e)=>{
|
|
230
|
+
if (disabled) return;
|
|
231
|
+
const delta = e.nativeEvent.actionName === 'increment' ? step : -step;
|
|
232
|
+
commitValue(clamp(displayValue + delta, min, max), true);
|
|
233
|
+
},
|
|
234
|
+
onFocus: ()=>setFocused(true),
|
|
235
|
+
onBlur: ()=>setFocused(false),
|
|
236
|
+
children: [
|
|
237
|
+
label && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Text, {
|
|
238
|
+
style: tokenStyles.label,
|
|
239
|
+
children: label
|
|
240
|
+
}),
|
|
241
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
242
|
+
style: [
|
|
243
|
+
tokenStyles.row,
|
|
244
|
+
disabled && styles.rowDisabled
|
|
245
|
+
],
|
|
246
|
+
children: [
|
|
247
|
+
showMinMax && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Text, {
|
|
248
|
+
style: tokenStyles.rangeLabel,
|
|
249
|
+
children: min
|
|
250
|
+
}),
|
|
251
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
252
|
+
style: styles.trackContainer,
|
|
253
|
+
onLayout: handleTrackLayout,
|
|
254
|
+
...panResponder.panHandlers,
|
|
255
|
+
children: [
|
|
256
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
257
|
+
style: tokenStyles.trackBg
|
|
258
|
+
}),
|
|
259
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
260
|
+
style: [
|
|
261
|
+
tokenStyles.trackFill,
|
|
262
|
+
{
|
|
263
|
+
width: fillWidth
|
|
264
|
+
}
|
|
265
|
+
]
|
|
266
|
+
}),
|
|
267
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
268
|
+
style: [
|
|
269
|
+
tokenStyles.thumb,
|
|
270
|
+
{
|
|
271
|
+
left: thumbLeft
|
|
272
|
+
},
|
|
273
|
+
thumbShadow
|
|
274
|
+
],
|
|
275
|
+
children: focused && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
276
|
+
style: [
|
|
277
|
+
styles.focusRing,
|
|
278
|
+
{
|
|
279
|
+
borderColor: cr.addOn.primaryFixed.sysOnPrimaryFixedVariant,
|
|
280
|
+
borderWidth: dim.borderWidth.sysStrokeMedium
|
|
281
|
+
}
|
|
282
|
+
],
|
|
283
|
+
pointerEvents: "none"
|
|
284
|
+
})
|
|
285
|
+
})
|
|
286
|
+
]
|
|
287
|
+
}),
|
|
288
|
+
showMinMax && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Text, {
|
|
289
|
+
style: tokenStyles.rangeLabel,
|
|
290
|
+
children: max
|
|
291
|
+
})
|
|
292
|
+
]
|
|
293
|
+
})
|
|
294
|
+
]
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
const styles = _reactnative.StyleSheet.create({
|
|
298
|
+
rowDisabled: {
|
|
299
|
+
opacity: 0.48
|
|
300
|
+
},
|
|
301
|
+
// ── Track container ───────────────────────────────────────────────────────
|
|
302
|
+
trackContainer: {
|
|
303
|
+
flex: 1,
|
|
304
|
+
height: HIT_HEIGHT,
|
|
305
|
+
// Overflow visible so the thumb (which extends ±12px from track centre)
|
|
306
|
+
// and its focus ring are not clipped at the extremes.
|
|
307
|
+
overflow: 'visible'
|
|
308
|
+
},
|
|
309
|
+
// ── Focus ring: 1px outside the 24×24 thumb → 26×26 ─────────────────────
|
|
310
|
+
focusRing: {
|
|
311
|
+
position: 'absolute',
|
|
312
|
+
top: -2,
|
|
313
|
+
left: -2,
|
|
314
|
+
right: -2,
|
|
315
|
+
bottom: -2,
|
|
316
|
+
borderRadius: 9999
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/react-native/src/components/Slider/index.tsx"],"sourcesContent":["import React, {\r\n useCallback,\r\n useEffect,\r\n useMemo,\r\n useRef,\r\n useState,\r\n} from 'react';\r\n\r\nimport {\r\n LayoutChangeEvent,\r\n PanResponder,\r\n StyleProp,\r\n StyleSheet,\r\n Text,\r\n View,\r\n ViewStyle,\r\n} from 'react-native';\r\n\r\nimport { useTheme } from '../../theme';\r\n\r\nexport interface SliderProps {\r\n /** Controlled value */\r\n value?: number;\r\n /** Default value for uncontrolled usage (default: min) */\r\n defaultValue?: number;\r\n min?: number;\r\n max?: number;\r\n /** Snapping interval (default: 1) */\r\n step?: number;\r\n /** Called continuously while dragging */\r\n onValueChange?: (value: number) => void;\r\n /** Called when the user releases the thumb */\r\n onSlidingComplete?: (value: number) => void;\r\n /** Label rendered above the track */\r\n label?: string;\r\n /** Show min/max value labels on either side of the track */\r\n showMinMax?: boolean;\r\n disabled?: boolean;\r\n accessibilityLabel?: string;\r\n style?: StyleProp<ViewStyle>;\r\n}\r\n\r\n// ── Layout constants ──────────────────────────────────────────────────────────\r\nconst TRACK_HEIGHT = 8;\r\nconst THUMB_SIZE = 24;\r\nconst THUMB_HALF = THUMB_SIZE / 2; // 12\r\nconst HIT_HEIGHT = 48; // symbol height from Figma — contains track + thumb\r\n// Vertical offsets within the 48px container\r\nconst TRACK_TOP = (HIT_HEIGHT - TRACK_HEIGHT) / 2; // 20\r\nconst THUMB_TOP = (HIT_HEIGHT - THUMB_SIZE) / 2; // 12\r\n\r\n// ── Helpers ───────────────────────────────────────────────────────────────────\r\n\r\nfunction clamp(v: number, lo: number, hi: number): number {\r\n return Math.max(lo, Math.min(hi, v));\r\n}\r\n\r\n// ── Component ─────────────────────────────────────────────────────────────────\r\n\r\nexport function Slider({\r\n value: valueProp,\r\n defaultValue,\r\n min = 0,\r\n max = 100,\r\n step = 1,\r\n onValueChange,\r\n onSlidingComplete,\r\n label,\r\n showMinMax = true,\r\n disabled = false,\r\n accessibilityLabel,\r\n style,\r\n}: SliderProps) {\r\n const { colorRoles: cr, dimensions: dim, typeScale: ts } = useTheme();\r\n\r\n const isControlled = valueProp !== undefined;\r\n const [internalValue, setInternalValue] = useState<number>(\r\n defaultValue ?? min,\r\n );\r\n const displayValue = isControlled ? valueProp! : internalValue;\r\n\r\n const [focused, setFocused] = useState(false);\r\n const [pressed, setPressed] = useState(false);\r\n\r\n // ── Track width (measured on layout) ────────────────────────────────────────\r\n const trackWidthRef = useRef(0);\r\n const [trackWidth, setTrackWidth] = useState(0);\r\n\r\n const handleTrackLayout = useCallback((e: LayoutChangeEvent) => {\r\n const w = e.nativeEvent.layout.width;\r\n trackWidthRef.current = w;\r\n setTrackWidth(w);\r\n }, []);\r\n\r\n // Keep a ref to the latest displayValue so PanResponder can read it\r\n const displayValueRef = useRef(displayValue);\r\n useEffect(() => {\r\n displayValueRef.current = displayValue;\r\n }, [displayValue]);\r\n\r\n // ── Value conversion ─────────────────────────────────────────────────────────\r\n\r\n function fractionToValue(frac: number): number {\r\n const raw = min + clamp(frac, 0, 1) * (max - min);\r\n const stepped = Math.round(raw / step) * step;\r\n return clamp(stepped, min, max);\r\n }\r\n\r\n function valueToFraction(v: number): number {\r\n return (v - min) / (max - min);\r\n }\r\n\r\n function commitValue(v: number, isFinal: boolean) {\r\n if (!isControlled) setInternalValue(v);\r\n onValueChange?.(v);\r\n if (isFinal) onSlidingComplete?.(v);\r\n }\r\n\r\n // ── PanResponder ─────────────────────────────────────────────────────────────\r\n const panStartFraction = useRef(0);\r\n\r\n const panResponder = useRef(\r\n PanResponder.create({\r\n onStartShouldSetPanResponder: () =>\r\n !disabled && trackWidthRef.current > 0,\r\n onMoveShouldSetPanResponder: () => !disabled && trackWidthRef.current > 0,\r\n // Don't let parent ScrollView steal the gesture once we've started\r\n onPanResponderTerminationRequest: () => false,\r\n\r\n onPanResponderGrant: (evt) => {\r\n setPressed(true);\r\n // Jump thumb to the tapped position on the track\r\n const tapped = clamp(\r\n evt.nativeEvent.locationX,\r\n 0,\r\n trackWidthRef.current,\r\n );\r\n panStartFraction.current = tapped / trackWidthRef.current;\r\n const v = fractionToValue(panStartFraction.current);\r\n commitValue(v, false);\r\n },\r\n\r\n onPanResponderMove: (_, gs) => {\r\n const newFrac = clamp(\r\n panStartFraction.current + gs.dx / trackWidthRef.current,\r\n 0,\r\n 1,\r\n );\r\n const v = fractionToValue(newFrac);\r\n commitValue(v, false);\r\n },\r\n\r\n onPanResponderRelease: (_, gs) => {\r\n setPressed(false);\r\n const newFrac = clamp(\r\n panStartFraction.current + gs.dx / trackWidthRef.current,\r\n 0,\r\n 1,\r\n );\r\n commitValue(fractionToValue(newFrac), true);\r\n },\r\n\r\n onPanResponderTerminate: () => setPressed(false),\r\n }),\r\n ).current;\r\n\r\n // ── Derived geometry ──────────────────────────────────────────────────────────\r\n const fraction = trackWidth > 0 ? valueToFraction(displayValue) : 0;\r\n const thumbCenterX = fraction * trackWidth;\r\n const thumbLeft = thumbCenterX - THUMB_HALF;\r\n const fillWidth = thumbCenterX;\r\n\r\n // ── Thumb shadow — lv3 when pressed/hovered, lv1 otherwise ──────────────────\r\n const thumbShadow = pressed\r\n ? {\r\n shadowColor: '#000',\r\n shadowOffset: { width: 0, height: 4 },\r\n shadowOpacity: 0.16,\r\n shadowRadius: 16,\r\n elevation: 3,\r\n }\r\n : {\r\n shadowColor: '#000',\r\n shadowOffset: { width: 0, height: 2 },\r\n shadowOpacity: 0.06,\r\n shadowRadius: 8,\r\n elevation: 1,\r\n };\r\n\r\n // ── Token-derived styles ──────────────────────────────────────────────────────\r\n const tokenStyles = useMemo(\r\n () => ({\r\n root: {\r\n gap: dim.spacing.padding.sysPadding8,\r\n alignSelf: 'stretch' as const,\r\n },\r\n label: {\r\n color: cr.surface.surface.sysOnSurface,\r\n fontSize: ts.labelMedium.sysFontSize,\r\n lineHeight: ts.labelMedium.sysLineHeight,\r\n letterSpacing: ts.labelMedium.sysTracking,\r\n fontWeight: '400' as const,\r\n includeFontPadding: false,\r\n },\r\n row: {\r\n flexDirection: 'row' as const,\r\n alignItems: 'center' as const,\r\n gap: dim.spacing.padding.sysPadding8,\r\n },\r\n rangeLabel: {\r\n color: cr.surface.surface.sysOnSurfaceVariant,\r\n fontSize: ts.bodySmall.sysFontSize,\r\n lineHeight: ts.bodySmall.sysLineHeight,\r\n fontWeight: '400' as const,\r\n includeFontPadding: false,\r\n flexShrink: 0,\r\n },\r\n trackBg: {\r\n position: 'absolute' as const,\r\n top: TRACK_TOP,\r\n left: 0,\r\n right: 0,\r\n height: TRACK_HEIGHT,\r\n borderRadius: 9999,\r\n backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerHighest,\r\n },\r\n trackFill: {\r\n position: 'absolute' as const,\r\n top: TRACK_TOP,\r\n left: 0,\r\n height: TRACK_HEIGHT,\r\n borderRadius: 9999,\r\n backgroundColor: cr.accent.primary.sysPrimary,\r\n },\r\n thumb: {\r\n position: 'absolute' as const,\r\n top: THUMB_TOP,\r\n width: THUMB_SIZE,\r\n height: THUMB_SIZE,\r\n borderRadius: 9999,\r\n backgroundColor: cr.surface.surface.sysSurface,\r\n alignItems: 'center' as const,\r\n justifyContent: 'center' as const,\r\n },\r\n }),\r\n [cr, dim, ts],\r\n );\r\n\r\n // ── Render ────────────────────────────────────────────────────────────────────\r\n return (\r\n <View\r\n style={[tokenStyles.root, style]}\r\n accessible\r\n accessibilityRole=\"adjustable\"\r\n accessibilityLabel={accessibilityLabel ?? label}\r\n accessibilityValue={{\r\n min,\r\n max,\r\n now: displayValue,\r\n }}\r\n onAccessibilityAction={(e) => {\r\n if (disabled) return;\r\n const delta = e.nativeEvent.actionName === 'increment' ? step : -step;\r\n commitValue(clamp(displayValue + delta, min, max), true);\r\n }}\r\n onFocus={() => setFocused(true)}\r\n onBlur={() => setFocused(false)}\r\n >\r\n {/* ── Optional label ────────────────────────────────────────────────── */}\r\n {label && <Text style={tokenStyles.label}>{label}</Text>}\r\n\r\n {/* ── Slider row ────────────────────────────────────────────────────── */}\r\n <View style={[tokenStyles.row, disabled && styles.rowDisabled]}>\r\n {/* Min label */}\r\n {showMinMax && <Text style={tokenStyles.rangeLabel}>{min}</Text>}\r\n\r\n {/* ── Track container — the gesture zone ──────────────────────────── */}\r\n <View\r\n style={styles.trackContainer}\r\n onLayout={handleTrackLayout}\r\n {...panResponder.panHandlers}\r\n >\r\n {/* Track background (unfilled — full width) */}\r\n <View style={tokenStyles.trackBg} />\r\n\r\n {/* Track fill (filled — up to thumb center) */}\r\n <View style={[tokenStyles.trackFill, { width: fillWidth }]} />\r\n\r\n {/* ── Thumb ─────────────────────────────────────────────────────── */}\r\n <View style={[tokenStyles.thumb, { left: thumbLeft }, thumbShadow]}>\r\n {/* Focus ring — 1px outside thumb (26×26 centered over 24×24) */}\r\n {focused && (\r\n <View\r\n style={[\r\n styles.focusRing,\r\n {\r\n borderColor: cr.addOn.primaryFixed.sysOnPrimaryFixedVariant,\r\n borderWidth: dim.borderWidth.sysStrokeMedium,\r\n },\r\n ]}\r\n pointerEvents=\"none\"\r\n />\r\n )}\r\n </View>\r\n </View>\r\n\r\n {/* Max label */}\r\n {showMinMax && <Text style={tokenStyles.rangeLabel}>{max}</Text>}\r\n </View>\r\n </View>\r\n );\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n rowDisabled: {\r\n opacity: 0.48,\r\n },\r\n\r\n // ── Track container ───────────────────────────────────────────────────────\r\n trackContainer: {\r\n flex: 1,\r\n height: HIT_HEIGHT,\r\n // Overflow visible so the thumb (which extends ±12px from track centre)\r\n // and its focus ring are not clipped at the extremes.\r\n overflow: 'visible',\r\n },\r\n\r\n // ── Focus ring: 1px outside the 24×24 thumb → 26×26 ─────────────────────\r\n focusRing: {\r\n position: 'absolute',\r\n top: -2,\r\n left: -2,\r\n right: -2,\r\n bottom: -2,\r\n borderRadius: 9999,\r\n },\r\n});\r\n"],"names":["Slider","TRACK_HEIGHT","THUMB_SIZE","THUMB_HALF","HIT_HEIGHT","TRACK_TOP","THUMB_TOP","clamp","v","lo","hi","Math","max","min","value","valueProp","defaultValue","step","onValueChange","onSlidingComplete","label","showMinMax","disabled","accessibilityLabel","style","colorRoles","cr","dimensions","dim","typeScale","ts","useTheme","isControlled","undefined","internalValue","setInternalValue","useState","displayValue","focused","setFocused","pressed","setPressed","trackWidthRef","useRef","trackWidth","setTrackWidth","handleTrackLayout","useCallback","e","w","nativeEvent","layout","width","current","displayValueRef","useEffect","fractionToValue","frac","raw","stepped","round","valueToFraction","commitValue","isFinal","panStartFraction","panResponder","PanResponder","create","onStartShouldSetPanResponder","onMoveShouldSetPanResponder","onPanResponderTerminationRequest","onPanResponderGrant","evt","tapped","locationX","onPanResponderMove","_","gs","newFrac","dx","onPanResponderRelease","onPanResponderTerminate","fraction","thumbCenterX","thumbLeft","fillWidth","thumbShadow","shadowColor","shadowOffset","height","shadowOpacity","shadowRadius","elevation","tokenStyles","useMemo","root","gap","spacing","padding","sysPadding8","alignSelf","color","surface","sysOnSurface","fontSize","labelMedium","sysFontSize","lineHeight","sysLineHeight","letterSpacing","sysTracking","fontWeight","includeFontPadding","row","flexDirection","alignItems","rangeLabel","sysOnSurfaceVariant","bodySmall","flexShrink","trackBg","position","top","left","right","borderRadius","backgroundColor","surfaceContainer","sysSurfaceContainerHighest","trackFill","accent","primary","sysPrimary","thumb","sysSurface","justifyContent","View","accessible","accessibilityRole","accessibilityValue","now","onAccessibilityAction","delta","actionName","onFocus","onBlur","Text","styles","rowDisabled","trackContainer","onLayout","panHandlers","focusRing","borderColor","addOn","primaryFixed","sysOnPrimaryFixedVariant","borderWidth","sysStrokeMedium","pointerEvents","StyleSheet","opacity","flex","overflow","bottom"],"mappings":";;;;+BA2DgBA;;;eAAAA;;;;+DArDT;6BAUA;uBAEkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBzB,iFAAiF;AACjF,MAAMC,eAAe;AACrB,MAAMC,aAAa;AACnB,MAAMC,aAAaD,aAAa,GAAG,KAAK;AACxC,MAAME,aAAa,IAAI,oDAAoD;AAC3E,6CAA6C;AAC7C,MAAMC,YAAY,AAACD,CAAAA,aAAaH,YAAW,IAAK,GAAG,KAAK;AACxD,MAAMK,YAAY,AAACF,CAAAA,aAAaF,UAAS,IAAK,GAAG,KAAK;AAEtD,iFAAiF;AAEjF,SAASK,MAAMC,CAAS,EAAEC,EAAU,EAAEC,EAAU;IAC9C,OAAOC,KAAKC,GAAG,CAACH,IAAIE,KAAKE,GAAG,CAACH,IAAIF;AACnC;AAIO,SAASR,OAAO,EACrBc,OAAOC,SAAS,EAChBC,YAAY,EACZH,MAAM,CAAC,EACPD,MAAM,GAAG,EACTK,OAAO,CAAC,EACRC,aAAa,EACbC,iBAAiB,EACjBC,KAAK,EACLC,aAAa,IAAI,EACjBC,WAAW,KAAK,EAChBC,kBAAkB,EAClBC,KAAK,EACO;IACZ,MAAM,EAAEC,YAAYC,EAAE,EAAEC,YAAYC,GAAG,EAAEC,W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AO;wCACL2H,OAAOK,SAAS;wCAChB;4CACEC,aAAa/H,GAAGgI,KAAK,CAACC,YAAY,CAACC,wBAAwB;4CAC3DC,aAAajI,IAAIiI,WAAW,CAACC,eAAe;wCAC9C;qCACD;oCACDC,eAAc;;;;;oBAOrB1I,4BAAc,qBAAC6H,iBAAI;wBAAC1H,OAAOqE,YAAYuB,UAAU;kCAAGxG;;;;;;AAI7D;AAEA,MAAMuI,SAASa,uBAAU,CAAC7F,MAAM,CAAC;IAC/BiF,aAAa;QACXa,SAAS;IACX;IAEA,6EAA6E;IAC7EZ,gBAAgB;QACda,MAAM;QACNzE,QAAQrF;QACR,wEAAwE;QACxE,sDAAsD;QACtD+J,UAAU;IACZ;IAEA,2EAA2E;IAC3EX,WAAW;QACT/B,UAAU;QACVC,KAAK,CAAC;QACNC,MAAM,CAAC;QACPC,OAAO,CAAC;QACRwC,QAAQ,CAAC;QACTvC,cAAc;IAChB;AACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export type SnackbarVariant = 'filled' | 'outlined';
|
|
4
|
+
export interface SnackbarProps {
|
|
5
|
+
visible: boolean;
|
|
6
|
+
message: string;
|
|
7
|
+
variant?: SnackbarVariant;
|
|
8
|
+
actionLabel?: string;
|
|
9
|
+
onAction?: () => void;
|
|
10
|
+
onClose?: () => void;
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
|
+
}
|
|
13
|
+
export declare function Snackbar({ visible, message, variant, actionLabel, onAction, onClose, style, }: SnackbarProps): React.JSX.Element;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Snackbar", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Snackbar;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
13
|
+
const _reactnative = require("react-native");
|
|
14
|
+
const _vectoricons = require("@expo/vector-icons");
|
|
15
|
+
const _theme = require("../../theme");
|
|
16
|
+
const _BodyText = require("../BodyText");
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
18
|
+
if (typeof WeakMap !== "function") return null;
|
|
19
|
+
var cacheBabelInterop = new WeakMap();
|
|
20
|
+
var cacheNodeInterop = new WeakMap();
|
|
21
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
22
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
23
|
+
})(nodeInterop);
|
|
24
|
+
}
|
|
25
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
26
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
30
|
+
return {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
35
|
+
if (cache && cache.has(obj)) {
|
|
36
|
+
return cache.get(obj);
|
|
37
|
+
}
|
|
38
|
+
var newObj = {
|
|
39
|
+
__proto__: null
|
|
40
|
+
};
|
|
41
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
42
|
+
for(var key in obj){
|
|
43
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
44
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
45
|
+
if (desc && (desc.get || desc.set)) {
|
|
46
|
+
Object.defineProperty(newObj, key, desc);
|
|
47
|
+
} else {
|
|
48
|
+
newObj[key] = obj[key];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
newObj.default = obj;
|
|
53
|
+
if (cache) {
|
|
54
|
+
cache.set(obj, newObj);
|
|
55
|
+
}
|
|
56
|
+
return newObj;
|
|
57
|
+
}
|
|
58
|
+
function Snackbar({ visible, message, variant = 'filled', actionLabel, onAction, onClose, style }) {
|
|
59
|
+
const { colorRoles: cr, dimensions: dim } = (0, _theme.useTheme)();
|
|
60
|
+
const translateY = (0, _react.useRef)(new _reactnative.Animated.Value(100)).current;
|
|
61
|
+
const opacity = (0, _react.useRef)(new _reactnative.Animated.Value(0)).current;
|
|
62
|
+
(0, _react.useEffect)(()=>{
|
|
63
|
+
if (visible) {
|
|
64
|
+
_reactnative.Animated.parallel([
|
|
65
|
+
_reactnative.Animated.spring(translateY, {
|
|
66
|
+
toValue: 0,
|
|
67
|
+
useNativeDriver: true,
|
|
68
|
+
damping: 20,
|
|
69
|
+
stiffness: 300
|
|
70
|
+
}),
|
|
71
|
+
_reactnative.Animated.timing(opacity, {
|
|
72
|
+
toValue: 1,
|
|
73
|
+
duration: 200,
|
|
74
|
+
useNativeDriver: true
|
|
75
|
+
})
|
|
76
|
+
]).start();
|
|
77
|
+
} else {
|
|
78
|
+
_reactnative.Animated.parallel([
|
|
79
|
+
_reactnative.Animated.timing(translateY, {
|
|
80
|
+
toValue: 100,
|
|
81
|
+
duration: 200,
|
|
82
|
+
useNativeDriver: true
|
|
83
|
+
}),
|
|
84
|
+
_reactnative.Animated.timing(opacity, {
|
|
85
|
+
toValue: 0,
|
|
86
|
+
duration: 150,
|
|
87
|
+
useNativeDriver: true
|
|
88
|
+
})
|
|
89
|
+
]).start();
|
|
90
|
+
}
|
|
91
|
+
}, [
|
|
92
|
+
visible
|
|
93
|
+
]);
|
|
94
|
+
const isFilled = variant === 'filled';
|
|
95
|
+
const tokenStyles = (0, _react.useMemo)(()=>({
|
|
96
|
+
wrapper: {
|
|
97
|
+
position: 'absolute',
|
|
98
|
+
bottom: dim.spacing.padding.sysPadding24,
|
|
99
|
+
left: dim.spacing.padding.sysPadding16,
|
|
100
|
+
right: dim.spacing.padding.sysPadding16,
|
|
101
|
+
alignItems: 'center'
|
|
102
|
+
},
|
|
103
|
+
container: {
|
|
104
|
+
flexDirection: 'row',
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
paddingVertical: dim.spacing.padding.sysPadding12,
|
|
107
|
+
paddingHorizontal: dim.spacing.padding.sysPadding16,
|
|
108
|
+
borderRadius: dim.borderRadius.sysRadiusMd,
|
|
109
|
+
gap: dim.spacing.padding.sysPadding16,
|
|
110
|
+
width: '100%',
|
|
111
|
+
shadowColor: '#000',
|
|
112
|
+
shadowOffset: {
|
|
113
|
+
width: 0,
|
|
114
|
+
height: 4
|
|
115
|
+
},
|
|
116
|
+
shadowOpacity: 0.12,
|
|
117
|
+
shadowRadius: 12,
|
|
118
|
+
elevation: 6
|
|
119
|
+
},
|
|
120
|
+
containerFilled: {
|
|
121
|
+
backgroundColor: cr.accent.primary.sysPrimaryContainer
|
|
122
|
+
},
|
|
123
|
+
containerOutlined: {
|
|
124
|
+
backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerLowest,
|
|
125
|
+
borderWidth: dim.borderWidth.sysStrokeThin,
|
|
126
|
+
borderColor: cr.outline.sysOutline
|
|
127
|
+
},
|
|
128
|
+
actionSlot: {
|
|
129
|
+
flexDirection: 'row',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
gap: dim.spacing.padding.sysPadding12
|
|
132
|
+
},
|
|
133
|
+
actionButton: {
|
|
134
|
+
paddingVertical: dim.spacing.padding.sysPadding4
|
|
135
|
+
},
|
|
136
|
+
closeButton: {
|
|
137
|
+
width: 24,
|
|
138
|
+
height: 24,
|
|
139
|
+
borderRadius: dim.borderRadius.sysRadiusFull,
|
|
140
|
+
alignItems: 'center',
|
|
141
|
+
justifyContent: 'center'
|
|
142
|
+
}
|
|
143
|
+
}), [
|
|
144
|
+
cr,
|
|
145
|
+
dim
|
|
146
|
+
]);
|
|
147
|
+
const containerVariantStyle = isFilled ? tokenStyles.containerFilled : tokenStyles.containerOutlined;
|
|
148
|
+
const labelColor = isFilled ? cr.accent.primary.sysOnPrimary : cr.surface.surface.sysOnSurface;
|
|
149
|
+
const actionColor = isFilled ? cr.accent.primary.sysOnPrimary : cr.accent.primary.sysPrimary;
|
|
150
|
+
const closeBg = isFilled ? cr.transparent.neutral.sysWhite10 : cr.surface.surfaceContainer.sysSurfaceContainer;
|
|
151
|
+
const closeIconColor = isFilled ? cr.accent.primary.sysOnPrimary : cr.surface.surface.sysOnSurfaceVariant;
|
|
152
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Animated.View, {
|
|
153
|
+
style: [
|
|
154
|
+
tokenStyles.wrapper,
|
|
155
|
+
{
|
|
156
|
+
opacity,
|
|
157
|
+
transform: [
|
|
158
|
+
{
|
|
159
|
+
translateY
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
style
|
|
164
|
+
],
|
|
165
|
+
pointerEvents: visible ? 'box-none' : 'none',
|
|
166
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
167
|
+
style: [
|
|
168
|
+
tokenStyles.container,
|
|
169
|
+
containerVariantStyle
|
|
170
|
+
],
|
|
171
|
+
children: [
|
|
172
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_BodyText.BodyText, {
|
|
173
|
+
variant: "medium",
|
|
174
|
+
color: labelColor,
|
|
175
|
+
style: styles.label,
|
|
176
|
+
numberOfLines: 2,
|
|
177
|
+
children: message
|
|
178
|
+
}),
|
|
179
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
180
|
+
style: tokenStyles.actionSlot,
|
|
181
|
+
children: [
|
|
182
|
+
actionLabel && onAction && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Pressable, {
|
|
183
|
+
onPress: onAction,
|
|
184
|
+
accessibilityRole: "button",
|
|
185
|
+
accessibilityLabel: actionLabel,
|
|
186
|
+
style: ({ pressed })=>[
|
|
187
|
+
tokenStyles.actionButton,
|
|
188
|
+
pressed && styles.pressed
|
|
189
|
+
],
|
|
190
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_BodyText.BodyText, {
|
|
191
|
+
variant: "small",
|
|
192
|
+
emphasized: true,
|
|
193
|
+
color: actionColor,
|
|
194
|
+
children: actionLabel
|
|
195
|
+
})
|
|
196
|
+
}),
|
|
197
|
+
onClose && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Pressable, {
|
|
198
|
+
onPress: onClose,
|
|
199
|
+
accessibilityRole: "button",
|
|
200
|
+
accessibilityLabel: "Dismiss",
|
|
201
|
+
style: ({ pressed })=>[
|
|
202
|
+
tokenStyles.closeButton,
|
|
203
|
+
{
|
|
204
|
+
backgroundColor: closeBg
|
|
205
|
+
},
|
|
206
|
+
pressed && styles.pressed
|
|
207
|
+
],
|
|
208
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_vectoricons.Ionicons, {
|
|
209
|
+
name: "close",
|
|
210
|
+
size: 16,
|
|
211
|
+
color: closeIconColor
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
]
|
|
215
|
+
})
|
|
216
|
+
]
|
|
217
|
+
})
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
const styles = _reactnative.StyleSheet.create({
|
|
221
|
+
label: {
|
|
222
|
+
flex: 1
|
|
223
|
+
},
|
|
224
|
+
pressed: {
|
|
225
|
+
opacity: 0.7
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/react-native/src/components/Snackbar/index.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from 'react';\r\n\r\nimport {\r\n Animated,\r\n Pressable,\r\n StyleProp,\r\n StyleSheet,\r\n View,\r\n ViewStyle,\r\n} from 'react-native';\r\n\r\nimport { Ionicons } from '@expo/vector-icons';\r\n\r\nimport { useTheme } from '../../theme';\r\nimport { BodyText } from '../BodyText';\r\n\r\nexport type SnackbarVariant = 'filled' | 'outlined';\r\n\r\nexport interface SnackbarProps {\r\n visible: boolean;\r\n message: string;\r\n variant?: SnackbarVariant;\r\n actionLabel?: string;\r\n onAction?: () => void;\r\n onClose?: () => void;\r\n style?: StyleProp<ViewStyle>;\r\n}\r\n\r\nexport function Snackbar({\r\n visible,\r\n message,\r\n variant = 'filled',\r\n actionLabel,\r\n onAction,\r\n onClose,\r\n style,\r\n}: SnackbarProps) {\r\n const { colorRoles: cr, dimensions: dim } = useTheme();\r\n\r\n const translateY = useRef(new Animated.Value(100)).current;\r\n const opacity = useRef(new Animated.Value(0)).current;\r\n\r\n useEffect(() => {\r\n if (visible) {\r\n Animated.parallel([\r\n Animated.spring(translateY, {\r\n toValue: 0,\r\n useNativeDriver: true,\r\n damping: 20,\r\n stiffness: 300,\r\n }),\r\n Animated.timing(opacity, {\r\n toValue: 1,\r\n duration: 200,\r\n useNativeDriver: true,\r\n }),\r\n ]).start();\r\n } else {\r\n Animated.parallel([\r\n Animated.timing(translateY, {\r\n toValue: 100,\r\n duration: 200,\r\n useNativeDriver: true,\r\n }),\r\n Animated.timing(opacity, {\r\n toValue: 0,\r\n duration: 150,\r\n useNativeDriver: true,\r\n }),\r\n ]).start();\r\n }\r\n }, [visible]);\r\n\r\n const isFilled = variant === 'filled';\r\n\r\n const tokenStyles = useMemo(\r\n () => ({\r\n wrapper: {\r\n position: 'absolute' as const,\r\n bottom: dim.spacing.padding.sysPadding24,\r\n left: dim.spacing.padding.sysPadding16,\r\n right: dim.spacing.padding.sysPadding16,\r\n alignItems: 'center' as const,\r\n },\r\n container: {\r\n flexDirection: 'row' as const,\r\n alignItems: 'center' as const,\r\n paddingVertical: dim.spacing.padding.sysPadding12,\r\n paddingHorizontal: dim.spacing.padding.sysPadding16,\r\n borderRadius: dim.borderRadius.sysRadiusMd,\r\n gap: dim.spacing.padding.sysPadding16,\r\n width: '100%' as const,\r\n shadowColor: '#000',\r\n shadowOffset: { width: 0, height: 4 },\r\n shadowOpacity: 0.12,\r\n shadowRadius: 12,\r\n elevation: 6,\r\n },\r\n containerFilled: {\r\n backgroundColor: cr.accent.primary.sysPrimaryContainer,\r\n },\r\n containerOutlined: {\r\n backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerLowest,\r\n borderWidth: dim.borderWidth.sysStrokeThin,\r\n borderColor: cr.outline.sysOutline,\r\n },\r\n actionSlot: {\r\n flexDirection: 'row' as const,\r\n alignItems: 'center' as const,\r\n gap: dim.spacing.padding.sysPadding12,\r\n },\r\n actionButton: {\r\n paddingVertical: dim.spacing.padding.sysPadding4,\r\n },\r\n closeButton: {\r\n width: 24,\r\n height: 24,\r\n borderRadius: dim.borderRadius.sysRadiusFull,\r\n alignItems: 'center' as const,\r\n justifyContent: 'center' as const,\r\n },\r\n }),\r\n [cr, dim],\r\n );\r\n\r\n const containerVariantStyle = isFilled\r\n ? tokenStyles.containerFilled\r\n : tokenStyles.containerOutlined;\r\n const labelColor = isFilled\r\n ? cr.accent.primary.sysOnPrimary\r\n : cr.surface.surface.sysOnSurface;\r\n const actionColor = isFilled\r\n ? cr.accent.primary.sysOnPrimary\r\n : cr.accent.primary.sysPrimary;\r\n const closeBg = isFilled\r\n ? cr.transparent.neutral.sysWhite10\r\n : cr.surface.surfaceContainer.sysSurfaceContainer;\r\n const closeIconColor = isFilled\r\n ? cr.accent.primary.sysOnPrimary\r\n : cr.surface.surface.sysOnSurfaceVariant;\r\n\r\n return (\r\n <Animated.View\r\n style={[\r\n tokenStyles.wrapper,\r\n { opacity, transform: [{ translateY }] },\r\n style,\r\n ]}\r\n pointerEvents={visible ? 'box-none' : 'none'}\r\n >\r\n <View style={[tokenStyles.container, containerVariantStyle]}>\r\n <BodyText\r\n variant=\"medium\"\r\n color={labelColor}\r\n style={styles.label}\r\n numberOfLines={2}\r\n >\r\n {message}\r\n </BodyText>\r\n\r\n <View style={tokenStyles.actionSlot}>\r\n {actionLabel && onAction && (\r\n <Pressable\r\n onPress={onAction}\r\n accessibilityRole=\"button\"\r\n accessibilityLabel={actionLabel}\r\n style={({ pressed }) => [\r\n tokenStyles.actionButton,\r\n pressed && styles.pressed,\r\n ]}\r\n >\r\n <BodyText variant=\"small\" emphasized color={actionColor}>\r\n {actionLabel}\r\n </BodyText>\r\n </Pressable>\r\n )}\r\n\r\n {onClose && (\r\n <Pressable\r\n onPress={onClose}\r\n accessibilityRole=\"button\"\r\n accessibilityLabel=\"Dismiss\"\r\n style={({ pressed }) => [\r\n tokenStyles.closeButton,\r\n { backgroundColor: closeBg },\r\n pressed && styles.pressed,\r\n ]}\r\n >\r\n <Ionicons name=\"close\" size={16} color={closeIconColor} />\r\n </Pressable>\r\n )}\r\n </View>\r\n </View>\r\n </Animated.View>\r\n );\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n label: {\r\n flex: 1,\r\n },\r\n pressed: {\r\n opacity: 0.7,\r\n },\r\n});\r\n"],"names":["Snackbar","visible","message","variant","actionLabel","onAction","onClose","style","colorRoles","cr","dimensions","dim","useTheme","translateY","useRef","Animated","Value","current","opacity","useEffect","parallel","spring","toValue","useNativeDriver","damping","stiffness","timing","duration","start","isFilled","tokenStyles","useMemo","wrapper","position","bottom","spacing","padding","sysPadding24","left","sysPadding16","right","alignItems","container","flexDirection","paddingVertical","sysPadding12","paddingHorizontal","borderRadius","sysRadiusMd","gap","width","shadowColor","shadowOffset","height","shadowOpacity","shadowRadius","elevation","containerFilled","backgroundColor","accent","primary","sysPrimaryContainer","containerOutlined","surface","surfaceContainer","sysSurfaceContainerLowest","borderWidth","sysStrokeThin","borderColor","outline","sysOutline","actionSlot","actionButton","sysPadding4","closeButton","sysRadiusFull","justifyContent","containerVariantStyle","labelColor","sysOnPrimary","sysOnSurface","actionColor","sysPrimary","closeBg","transparent","neutral","sysWhite10","sysSurfaceContainer","closeIconColor","sysOnSurfaceVariant","View","transform","pointerEvents","BodyText","color","styles","label","numberOfLines","Pressable","onPress","accessibilityRole","accessibilityLabel","pressed","emphasized","Ionicons","name","size","StyleSheet","create","flex"],"mappings":";;;;+BA4BgBA;;;eAAAA;;;;+DA5BkC;6BAS3C;6BAEkB;uBAEA;0BACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAclB,SAASA,SAAS,EACvBC,OAAO,EACPC,OAAO,EACPC,UAAU,QAAQ,EAClBC,WAAW,EACXC,QAAQ,EACRC,OAAO,EACPC,KAAK,EACS;IACd,MAAM,EAAEC,YAAYC,EAAE,EAAEC,YAAYC,GAAG,EAAE,GAAGC,IAAAA,eAAQ;IAEpD,MAAMC,aAAaC,IAAAA,aAAM,EAAC,IAAIC,qBAAQ,CAACC,KAAK,CAAC,MAAMC,OAAO;IAC1D,MAAMC,UAAUJ,IAAAA,aAAM,EAAC,IAAIC,qBAAQ,CAACC,KAAK,CAAC,IAAIC,OAAO;IAErDE,IAAAA,gBAAS,EAAC;QACR,IAAIlB,SAAS;YACXc,qBAAQ,CAACK,QAAQ,CAAC;gBAChBL,qBAAQ,CAACM,MAAM,CAACR,YAAY;oBAC1BS,SAAS;oBACTC,iBAAiB;oBACjBC,SAAS;oBACTC,WAAW;gBACb;gBACAV,qBAAQ,CAACW,MAAM,CAACR,SAAS;oBACvBI,SAAS;oBACTK,UAAU;oBACVJ,iBAAiB;gBACnB;aACD,EAAEK,KAAK;QACV,OAAO;YACLb,qBAAQ,CAACK,QAAQ,CAAC;gBAChBL,qBAAQ,CAACW,MAAM,CAACb,YAAY;oBAC1BS,SAAS;oBACTK,UAAU;oBACVJ,iBAAiB;gBACnB;gBACAR,qBAAQ,CAACW,MAAM,CAACR,SAAS;oBACvBI,SAAS;oBACTK,UAAU;oBACVJ,iBAAiB;gBACnB;aACD,EAAEK,KAAK;QACV;IACF,GAAG;QAAC3B;KAAQ;IAEZ,MAAM4B,WAAW1B,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AC1F,SAAQ;gCAAQoG,UAAU;gCAACT,OAAOb;0CACzC7E;;;wBAKNE,yBACC,qBAAC4F,sBAAS;4BACRC,SAAS7F;4BACT8F,mBAAkB;4BAClBC,oBAAmB;4BACnB9F,OAAO,CAAC,EAAE+F,OAAO,EAAE,GAAK;oCACtBxE,YAAY4C,WAAW;oCACvB;wCAAEhB,iBAAiByB;oCAAQ;oCAC3BmB,WAAWP,OAAOO,OAAO;iCAC1B;sCAED,cAAA,qBAACE,qBAAQ;gCAACC,MAAK;gCAAQC,MAAM;gCAAIZ,OAAON;;;;;;;;AAOtD;AAEA,MAAMO,SAASY,uBAAU,CAACC,MAAM,CAAC;IAC/BZ,OAAO;QACLa,MAAM;IACR;IACAP,SAAS;QACPpF,SAAS;IACX;AACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export interface SwitchProps {
|
|
4
|
+
/** Controlled value. Omit to use internal state. */
|
|
5
|
+
value?: boolean;
|
|
6
|
+
/** Default value for uncontrolled usage */
|
|
7
|
+
defaultValue?: boolean;
|
|
8
|
+
/** Called when the user toggles the switch */
|
|
9
|
+
onValueChange?: (value: boolean) => void;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
accessibilityLabel?: string;
|
|
12
|
+
style?: StyleProp<ViewStyle>;
|
|
13
|
+
}
|
|
14
|
+
export declare function Switch({ value: valueProp, defaultValue, onValueChange, disabled, accessibilityLabel, style, }: SwitchProps): React.JSX.Element;
|