@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,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Switch", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Switch;
|
|
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_W = 56;
|
|
58
|
+
const TRACK_H = 32;
|
|
59
|
+
const THUMB_SIZE = 24;
|
|
60
|
+
function Switch({ value: valueProp, defaultValue = false, onValueChange, disabled = false, accessibilityLabel, style }) {
|
|
61
|
+
const { colorRoles: cr, dimensions: dim } = (0, _theme.useTheme)();
|
|
62
|
+
const trackPadding = (0, _react.useMemo)(()=>dim.spacing.padding.sysPadding4, [
|
|
63
|
+
dim
|
|
64
|
+
]);
|
|
65
|
+
// Thumb translateX: off=left edge, on=right edge
|
|
66
|
+
const thumbOff = trackPadding; // 4
|
|
67
|
+
const thumbOn = TRACK_W - trackPadding - THUMB_SIZE; // 56 - 4 - 24 = 28
|
|
68
|
+
// Controlled vs uncontrolled
|
|
69
|
+
const isControlled = valueProp !== undefined;
|
|
70
|
+
const [internalValue, setInternalValue] = (0, _react.useState)(defaultValue);
|
|
71
|
+
const toggled = isControlled ? valueProp : internalValue;
|
|
72
|
+
const [focused, setFocused] = (0, _react.useState)(false);
|
|
73
|
+
// ── Animation ──────────────────────────────────────────────────────────────
|
|
74
|
+
const thumbAnim = (0, _react.useRef)(new _reactnative.Animated.Value(toggled ? thumbOn : thumbOff)).current;
|
|
75
|
+
const bgAnim = (0, _react.useRef)(new _reactnative.Animated.Value(toggled ? 1 : 0)).current;
|
|
76
|
+
(0, _react.useEffect)(()=>{
|
|
77
|
+
_reactnative.Animated.parallel([
|
|
78
|
+
_reactnative.Animated.timing(thumbAnim, {
|
|
79
|
+
toValue: toggled ? thumbOn : thumbOff,
|
|
80
|
+
duration: 150,
|
|
81
|
+
useNativeDriver: true
|
|
82
|
+
}),
|
|
83
|
+
_reactnative.Animated.timing(bgAnim, {
|
|
84
|
+
toValue: toggled ? 1 : 0,
|
|
85
|
+
duration: 150,
|
|
86
|
+
useNativeDriver: false
|
|
87
|
+
})
|
|
88
|
+
]).start();
|
|
89
|
+
}, [
|
|
90
|
+
toggled
|
|
91
|
+
]);
|
|
92
|
+
// Interpolate background color
|
|
93
|
+
const trackBg = bgAnim.interpolate({
|
|
94
|
+
inputRange: [
|
|
95
|
+
0,
|
|
96
|
+
1
|
|
97
|
+
],
|
|
98
|
+
outputRange: [
|
|
99
|
+
cr.surface.surfaceContainer.sysSurfaceContainerHighest,
|
|
100
|
+
cr.accent.primary.sysPrimary
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
// Thumb color: on=sysOnPrimary, off=sysSurface
|
|
104
|
+
const thumbBg = bgAnim.interpolate({
|
|
105
|
+
inputRange: [
|
|
106
|
+
0,
|
|
107
|
+
1
|
|
108
|
+
],
|
|
109
|
+
outputRange: [
|
|
110
|
+
cr.surface.surface.sysSurface,
|
|
111
|
+
cr.accent.primary.sysOnPrimary
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
// ── Handler ────────────────────────────────────────────────────────────────
|
|
115
|
+
function handlePress() {
|
|
116
|
+
if (disabled) return;
|
|
117
|
+
const next = !toggled;
|
|
118
|
+
if (!isControlled) setInternalValue(next);
|
|
119
|
+
onValueChange?.(next);
|
|
120
|
+
}
|
|
121
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.Pressable, {
|
|
122
|
+
onPress: handlePress,
|
|
123
|
+
onFocus: ()=>setFocused(true),
|
|
124
|
+
onBlur: ()=>setFocused(false),
|
|
125
|
+
disabled: disabled,
|
|
126
|
+
accessibilityRole: "switch",
|
|
127
|
+
accessibilityLabel: accessibilityLabel,
|
|
128
|
+
accessibilityState: {
|
|
129
|
+
checked: toggled,
|
|
130
|
+
disabled
|
|
131
|
+
},
|
|
132
|
+
style: [
|
|
133
|
+
styles.pressable,
|
|
134
|
+
style
|
|
135
|
+
],
|
|
136
|
+
children: [
|
|
137
|
+
focused && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
138
|
+
style: [
|
|
139
|
+
styles.focusRing,
|
|
140
|
+
{
|
|
141
|
+
borderColor: cr.addOn.primaryFixed.sysOnPrimaryFixedVariant,
|
|
142
|
+
borderWidth: dim.borderWidth.sysStrokeMedium
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
pointerEvents: "none"
|
|
146
|
+
}),
|
|
147
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Animated.View, {
|
|
148
|
+
style: [
|
|
149
|
+
styles.track,
|
|
150
|
+
{
|
|
151
|
+
backgroundColor: trackBg
|
|
152
|
+
},
|
|
153
|
+
disabled && styles.trackDisabled
|
|
154
|
+
],
|
|
155
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Animated.View, {
|
|
156
|
+
style: [
|
|
157
|
+
styles.thumb,
|
|
158
|
+
{
|
|
159
|
+
top: trackPadding,
|
|
160
|
+
backgroundColor: thumbBg,
|
|
161
|
+
transform: [
|
|
162
|
+
{
|
|
163
|
+
translateX: thumbAnim
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
disabled && styles.thumbDisabled
|
|
168
|
+
]
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
const styles = _reactnative.StyleSheet.create({
|
|
175
|
+
pressable: {
|
|
176
|
+
// Sized to the track; focus ring is absolutely overlaid
|
|
177
|
+
width: TRACK_W,
|
|
178
|
+
height: TRACK_H,
|
|
179
|
+
alignSelf: 'flex-start'
|
|
180
|
+
},
|
|
181
|
+
track: {
|
|
182
|
+
width: TRACK_W,
|
|
183
|
+
height: TRACK_H,
|
|
184
|
+
borderRadius: 9999,
|
|
185
|
+
// Thumb is absolutely positioned inside the track
|
|
186
|
+
position: 'relative'
|
|
187
|
+
},
|
|
188
|
+
trackDisabled: {
|
|
189
|
+
opacity: 0.48
|
|
190
|
+
},
|
|
191
|
+
thumb: {
|
|
192
|
+
position: 'absolute',
|
|
193
|
+
left: 0,
|
|
194
|
+
width: THUMB_SIZE,
|
|
195
|
+
height: THUMB_SIZE,
|
|
196
|
+
borderRadius: 9999,
|
|
197
|
+
// lv2 shadow
|
|
198
|
+
shadowColor: '#000',
|
|
199
|
+
shadowOffset: {
|
|
200
|
+
width: 0,
|
|
201
|
+
height: 2
|
|
202
|
+
},
|
|
203
|
+
shadowOpacity: 0.08,
|
|
204
|
+
shadowRadius: 4,
|
|
205
|
+
elevation: 2
|
|
206
|
+
},
|
|
207
|
+
thumbDisabled: {
|
|
208
|
+
opacity: 0.64
|
|
209
|
+
},
|
|
210
|
+
// Focus ring: 1px outside the track on all sides
|
|
211
|
+
focusRing: {
|
|
212
|
+
position: 'absolute',
|
|
213
|
+
top: -2,
|
|
214
|
+
left: -2,
|
|
215
|
+
right: -2,
|
|
216
|
+
bottom: -2,
|
|
217
|
+
borderRadius: 9999
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/react-native/src/components/Switch/index.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } 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 { useTheme } from '../../theme';\r\n\r\nexport interface SwitchProps {\r\n /** Controlled value. Omit to use internal state. */\r\n value?: boolean;\r\n /** Default value for uncontrolled usage */\r\n defaultValue?: boolean;\r\n /** Called when the user toggles the switch */\r\n onValueChange?: (value: boolean) => void;\r\n disabled?: boolean;\r\n accessibilityLabel?: string;\r\n style?: StyleProp<ViewStyle>;\r\n}\r\n\r\n// ── Layout constants ──────────────────────────────────────────────────────────\r\nconst TRACK_W = 56;\r\nconst TRACK_H = 32;\r\nconst THUMB_SIZE = 24;\r\n\r\n// ── Component ─────────────────────────────────────────────────────────────────\r\n\r\nexport function Switch({\r\n value: valueProp,\r\n defaultValue = false,\r\n onValueChange,\r\n disabled = false,\r\n accessibilityLabel,\r\n style,\r\n}: SwitchProps) {\r\n const { colorRoles: cr, dimensions: dim } = useTheme();\r\n\r\n const trackPadding = useMemo(() => dim.spacing.padding.sysPadding4, [dim]);\r\n\r\n // Thumb translateX: off=left edge, on=right edge\r\n const thumbOff = trackPadding; // 4\r\n const thumbOn = TRACK_W - trackPadding - THUMB_SIZE; // 56 - 4 - 24 = 28\r\n\r\n // Controlled vs uncontrolled\r\n const isControlled = valueProp !== undefined;\r\n const [internalValue, setInternalValue] = useState(defaultValue);\r\n const toggled = isControlled ? valueProp! : internalValue;\r\n\r\n const [focused, setFocused] = useState(false);\r\n\r\n // ── Animation ──────────────────────────────────────────────────────────────\r\n const thumbAnim = useRef(\r\n new Animated.Value(toggled ? thumbOn : thumbOff),\r\n ).current;\r\n const bgAnim = useRef(new Animated.Value(toggled ? 1 : 0)).current;\r\n\r\n useEffect(() => {\r\n Animated.parallel([\r\n Animated.timing(thumbAnim, {\r\n toValue: toggled ? thumbOn : thumbOff,\r\n duration: 150,\r\n useNativeDriver: true,\r\n }),\r\n Animated.timing(bgAnim, {\r\n toValue: toggled ? 1 : 0,\r\n duration: 150,\r\n useNativeDriver: false, // backgroundColor not supported by native driver\r\n }),\r\n ]).start();\r\n }, [toggled]);\r\n\r\n // Interpolate background color\r\n const trackBg = bgAnim.interpolate({\r\n inputRange: [0, 1],\r\n outputRange: [\r\n cr.surface.surfaceContainer.sysSurfaceContainerHighest,\r\n cr.accent.primary.sysPrimary,\r\n ],\r\n });\r\n\r\n // Thumb color: on=sysOnPrimary, off=sysSurface\r\n const thumbBg = bgAnim.interpolate({\r\n inputRange: [0, 1],\r\n outputRange: [\r\n cr.surface.surface.sysSurface,\r\n cr.accent.primary.sysOnPrimary,\r\n ],\r\n });\r\n\r\n // ── Handler ────────────────────────────────────────────────────────────────\r\n function handlePress() {\r\n if (disabled) return;\r\n const next = !toggled;\r\n if (!isControlled) setInternalValue(next);\r\n onValueChange?.(next);\r\n }\r\n\r\n return (\r\n <Pressable\r\n onPress={handlePress}\r\n onFocus={() => setFocused(true)}\r\n onBlur={() => setFocused(false)}\r\n disabled={disabled}\r\n accessibilityRole=\"switch\"\r\n accessibilityLabel={accessibilityLabel}\r\n accessibilityState={{ checked: toggled, disabled }}\r\n style={[styles.pressable, style]}\r\n >\r\n {/* ── Focus ring (outside track by 1px) ─────────────────────────────── */}\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\r\n {/* ── Track ─────────────────────────────────────────────────────────── */}\r\n <Animated.View\r\n style={[\r\n styles.track,\r\n { backgroundColor: trackBg },\r\n disabled && styles.trackDisabled,\r\n ]}\r\n >\r\n {/* ── Thumb ───────────────────────────────────────────────────────── */}\r\n <Animated.View\r\n style={[\r\n styles.thumb,\r\n {\r\n top: trackPadding,\r\n backgroundColor: thumbBg,\r\n transform: [{ translateX: thumbAnim }],\r\n },\r\n disabled && styles.thumbDisabled,\r\n ]}\r\n />\r\n </Animated.View>\r\n </Pressable>\r\n );\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n pressable: {\r\n // Sized to the track; focus ring is absolutely overlaid\r\n width: TRACK_W,\r\n height: TRACK_H,\r\n alignSelf: 'flex-start',\r\n },\r\n track: {\r\n width: TRACK_W,\r\n height: TRACK_H,\r\n borderRadius: 9999,\r\n // Thumb is absolutely positioned inside the track\r\n position: 'relative',\r\n },\r\n trackDisabled: {\r\n opacity: 0.48,\r\n },\r\n thumb: {\r\n position: 'absolute',\r\n left: 0, // translateX drives actual X position\r\n width: THUMB_SIZE,\r\n height: THUMB_SIZE,\r\n borderRadius: 9999,\r\n // lv2 shadow\r\n shadowColor: '#000',\r\n shadowOffset: { width: 0, height: 2 },\r\n shadowOpacity: 0.08,\r\n shadowRadius: 4,\r\n elevation: 2,\r\n },\r\n thumbDisabled: {\r\n opacity: 0.64,\r\n },\r\n // Focus ring: 1px outside the track on all sides\r\n focusRing: {\r\n position: 'absolute',\r\n top: -2, // 1px gap + sysStrokeMedium (1.5px) ≈ 2px\r\n left: -2,\r\n right: -2,\r\n bottom: -2,\r\n borderRadius: 9999,\r\n },\r\n});\r\n"],"names":["Switch","TRACK_W","TRACK_H","THUMB_SIZE","value","valueProp","defaultValue","onValueChange","disabled","accessibilityLabel","style","colorRoles","cr","dimensions","dim","useTheme","trackPadding","useMemo","spacing","padding","sysPadding4","thumbOff","thumbOn","isControlled","undefined","internalValue","setInternalValue","useState","toggled","focused","setFocused","thumbAnim","useRef","Animated","Value","current","bgAnim","useEffect","parallel","timing","toValue","duration","useNativeDriver","start","trackBg","interpolate","inputRange","outputRange","surface","surfaceContainer","sysSurfaceContainerHighest","accent","primary","sysPrimary","thumbBg","sysSurface","sysOnPrimary","handlePress","next","Pressable","onPress","onFocus","onBlur","accessibilityRole","accessibilityState","checked","styles","pressable","View","focusRing","borderColor","addOn","primaryFixed","sysOnPrimaryFixedVariant","borderWidth","sysStrokeMedium","pointerEvents","track","backgroundColor","trackDisabled","thumb","top","transform","translateX","thumbDisabled","StyleSheet","create","width","height","alignSelf","borderRadius","position","opacity","left","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","right","bottom"],"mappings":";;;;+BAgCgBA;;;eAAAA;;;;+DAhC4C;6BASrD;uBAE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Z1D,OAAO;wBACLwD,OAAOc,KAAK;wBACZ;4BACEC,KAAKjE;4BACL8D,iBAAiBxB;4BACjB4B,WAAW;gCAAC;oCAAEC,YAAYpD;gCAAU;6BAAE;wBACxC;wBACAvB,YAAY0D,OAAOkB,aAAa;qBACjC;;;;;AAKX;AAEA,MAAMlB,SAASmB,uBAAU,CAACC,MAAM,CAAC;IAC/BnB,WAAW;QACT,wDAAwD;QACxDoB,OAAOtF;QACPuF,QAAQtF;QACRuF,WAAW;IACb;IACAZ,OAAO;QACLU,OAAOtF;QACPuF,QAAQtF;QACRwF,cAAc;QACd,kDAAkD;QAClDC,UAAU;IACZ;IACAZ,eAAe;QACba,SAAS;IACX;IACAZ,OAAO;QACLW,UAAU;QACVE,MAAM;QACNN,OAAOpF;QACPqF,QAAQrF;QACRuF,cAAc;QACd,aAAa;QACbI,aAAa;QACbC,cAAc;YAAER,OAAO;YAAGC,QAAQ;QAAE;QACpCQ,eAAe;QACfC,cAAc;QACdC,WAAW;IACb;IACAd,eAAe;QACbQ,SAAS;IACX;IACA,iDAAiD;IACjDvB,WAAW;QACTsB,UAAU;QACVV,KAAK,CAAC;QACNY,MAAM,CAAC;QACPM,OAAO,CAAC;QACRC,QAAQ,CAAC;QACTV,cAAc;IAChB;AACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export type TooltipVariant = 'filled' | 'elevated';
|
|
4
|
+
/**
|
|
5
|
+
* The direction the arrow points — i.e. where the tooltip's target is
|
|
6
|
+
* relative to the bubble.
|
|
7
|
+
*
|
|
8
|
+
* `bottom` → bubble sits above target, arrow points down
|
|
9
|
+
* `top` → bubble sits below target, arrow points up
|
|
10
|
+
* `left` → bubble sits right of target, arrow points left
|
|
11
|
+
* `right` → bubble sits left of target, arrow points right
|
|
12
|
+
* `none` → no arrow
|
|
13
|
+
*/
|
|
14
|
+
export type TooltipDirection = 'none' | 'top' | 'bottom' | 'left' | 'right';
|
|
15
|
+
export interface TooltipProps {
|
|
16
|
+
text: string;
|
|
17
|
+
variant?: TooltipVariant;
|
|
18
|
+
direction?: TooltipDirection;
|
|
19
|
+
style?: StyleProp<ViewStyle>;
|
|
20
|
+
}
|
|
21
|
+
export declare function Tooltip({ text, variant, direction, style, }: TooltipProps): React.JSX.Element;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Tooltip", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Tooltip;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
13
|
+
const _reactnative = require("react-native");
|
|
14
|
+
const _theme = require("../../theme");
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// ── Arrow dimensions ─────────────────────────────────────────────────────────
|
|
21
|
+
const ARROW_BASE = 16; // px — wide axis
|
|
22
|
+
const ARROW_HEIGHT = 6; // px — narrow axis
|
|
23
|
+
function Tooltip({ text, variant = 'filled', direction = 'none', style }) {
|
|
24
|
+
const { colorRoles: cr, dimensions: dim, typeScale: ts } = (0, _theme.useTheme)();
|
|
25
|
+
const isFilled = variant === 'filled';
|
|
26
|
+
const bg = isFilled ? cr.surface.inverse.sysInverseSurface : cr.surface.surfaceContainer.sysSurfaceContainerLowest;
|
|
27
|
+
const textColor = isFilled ? cr.surface.inverse.sysInverseOnSurface : cr.surface.surface.sysOnSurface;
|
|
28
|
+
// ── Arrow (CSS triangle using zero-size View + borders) ───────────────────
|
|
29
|
+
// Half-base for side calculations
|
|
30
|
+
const half = ARROW_BASE / 2;
|
|
31
|
+
function renderArrow() {
|
|
32
|
+
if (direction === 'none') return null;
|
|
33
|
+
// Shared transparent sides
|
|
34
|
+
const transparent = 'transparent';
|
|
35
|
+
let arrowStyle;
|
|
36
|
+
switch(direction){
|
|
37
|
+
case 'bottom':
|
|
38
|
+
// Triangle pointing down — sits below bubble
|
|
39
|
+
arrowStyle = {
|
|
40
|
+
width: 0,
|
|
41
|
+
height: 0,
|
|
42
|
+
borderLeftWidth: half,
|
|
43
|
+
borderRightWidth: half,
|
|
44
|
+
borderTopWidth: ARROW_HEIGHT,
|
|
45
|
+
borderLeftColor: transparent,
|
|
46
|
+
borderRightColor: transparent,
|
|
47
|
+
borderTopColor: bg
|
|
48
|
+
};
|
|
49
|
+
break;
|
|
50
|
+
case 'top':
|
|
51
|
+
// Triangle pointing up — sits above bubble
|
|
52
|
+
arrowStyle = {
|
|
53
|
+
width: 0,
|
|
54
|
+
height: 0,
|
|
55
|
+
borderLeftWidth: half,
|
|
56
|
+
borderRightWidth: half,
|
|
57
|
+
borderBottomWidth: ARROW_HEIGHT,
|
|
58
|
+
borderLeftColor: transparent,
|
|
59
|
+
borderRightColor: transparent,
|
|
60
|
+
borderBottomColor: bg
|
|
61
|
+
};
|
|
62
|
+
break;
|
|
63
|
+
case 'left':
|
|
64
|
+
// Triangle pointing left — sits to the left of bubble
|
|
65
|
+
arrowStyle = {
|
|
66
|
+
width: 0,
|
|
67
|
+
height: 0,
|
|
68
|
+
borderTopWidth: half,
|
|
69
|
+
borderBottomWidth: half,
|
|
70
|
+
borderRightWidth: ARROW_HEIGHT,
|
|
71
|
+
borderTopColor: transparent,
|
|
72
|
+
borderBottomColor: transparent,
|
|
73
|
+
borderRightColor: bg
|
|
74
|
+
};
|
|
75
|
+
break;
|
|
76
|
+
case 'right':
|
|
77
|
+
// Triangle pointing right — sits to the right of bubble
|
|
78
|
+
arrowStyle = {
|
|
79
|
+
width: 0,
|
|
80
|
+
height: 0,
|
|
81
|
+
borderTopWidth: half,
|
|
82
|
+
borderBottomWidth: half,
|
|
83
|
+
borderLeftWidth: ARROW_HEIGHT,
|
|
84
|
+
borderTopColor: transparent,
|
|
85
|
+
borderBottomColor: transparent,
|
|
86
|
+
borderLeftColor: bg
|
|
87
|
+
};
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
91
|
+
accessible: false,
|
|
92
|
+
style: arrowStyle
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// ── Bubble ────────────────────────────────────────────────────────────────
|
|
96
|
+
const bubble = /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
97
|
+
accessible: true,
|
|
98
|
+
accessibilityRole: "text",
|
|
99
|
+
accessibilityLabel: text,
|
|
100
|
+
style: [
|
|
101
|
+
styles.bubble,
|
|
102
|
+
{
|
|
103
|
+
backgroundColor: bg,
|
|
104
|
+
paddingHorizontal: dim.spacing.padding.sysPadding12,
|
|
105
|
+
paddingVertical: dim.spacing.padding.sysPadding8,
|
|
106
|
+
borderRadius: dim.borderRadius.sysRadiusSm
|
|
107
|
+
},
|
|
108
|
+
!isFilled && styles.elevated,
|
|
109
|
+
!isFilled && {
|
|
110
|
+
borderWidth: dim.borderWidth.sysStrokeThin,
|
|
111
|
+
borderColor: cr.outline.sysOutline
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Text, {
|
|
115
|
+
style: {
|
|
116
|
+
color: textColor,
|
|
117
|
+
fontSize: ts.bodySmall.sysFontSize,
|
|
118
|
+
lineHeight: ts.bodySmall.sysLineHeight,
|
|
119
|
+
fontWeight: '400',
|
|
120
|
+
textAlign: 'center',
|
|
121
|
+
includeFontPadding: false
|
|
122
|
+
},
|
|
123
|
+
children: text
|
|
124
|
+
})
|
|
125
|
+
});
|
|
126
|
+
// ── Layout — arrow position determines stacking order ────────────────────
|
|
127
|
+
if (direction === 'none') {
|
|
128
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
129
|
+
style: style,
|
|
130
|
+
children: bubble
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (direction === 'bottom') {
|
|
134
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
135
|
+
style: [
|
|
136
|
+
styles.colCenter,
|
|
137
|
+
style
|
|
138
|
+
],
|
|
139
|
+
children: [
|
|
140
|
+
bubble,
|
|
141
|
+
renderArrow()
|
|
142
|
+
]
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (direction === 'top') {
|
|
146
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
147
|
+
style: [
|
|
148
|
+
styles.colCenter,
|
|
149
|
+
style
|
|
150
|
+
],
|
|
151
|
+
children: [
|
|
152
|
+
renderArrow(),
|
|
153
|
+
bubble
|
|
154
|
+
]
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (direction === 'right') {
|
|
158
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
159
|
+
style: [
|
|
160
|
+
styles.rowCenter,
|
|
161
|
+
style
|
|
162
|
+
],
|
|
163
|
+
children: [
|
|
164
|
+
bubble,
|
|
165
|
+
renderArrow()
|
|
166
|
+
]
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
// left
|
|
170
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
171
|
+
style: [
|
|
172
|
+
styles.rowCenter,
|
|
173
|
+
style
|
|
174
|
+
],
|
|
175
|
+
children: [
|
|
176
|
+
renderArrow(),
|
|
177
|
+
bubble
|
|
178
|
+
]
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const styles = _reactnative.StyleSheet.create({
|
|
182
|
+
bubble: {
|
|
183
|
+
alignSelf: 'flex-start'
|
|
184
|
+
},
|
|
185
|
+
elevated: {
|
|
186
|
+
shadowColor: '#000',
|
|
187
|
+
shadowOffset: {
|
|
188
|
+
width: 0,
|
|
189
|
+
height: 2
|
|
190
|
+
},
|
|
191
|
+
shadowOpacity: 0.06,
|
|
192
|
+
shadowRadius: 4,
|
|
193
|
+
elevation: 1
|
|
194
|
+
},
|
|
195
|
+
colCenter: {
|
|
196
|
+
alignItems: 'center',
|
|
197
|
+
alignSelf: 'flex-start'
|
|
198
|
+
},
|
|
199
|
+
rowCenter: {
|
|
200
|
+
flexDirection: 'row',
|
|
201
|
+
alignItems: 'center',
|
|
202
|
+
alignSelf: 'flex-start'
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/react-native/src/components/Tooltip/index.tsx"],"sourcesContent":["import React from 'react';\r\n\r\nimport { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native';\r\n\r\nimport { useTheme } from '../../theme';\r\n\r\nexport type TooltipVariant = 'filled' | 'elevated';\r\n/**\r\n * The direction the arrow points — i.e. where the tooltip's target is\r\n * relative to the bubble.\r\n *\r\n * `bottom` → bubble sits above target, arrow points down\r\n * `top` → bubble sits below target, arrow points up\r\n * `left` → bubble sits right of target, arrow points left\r\n * `right` → bubble sits left of target, arrow points right\r\n * `none` → no arrow\r\n */\r\nexport type TooltipDirection = 'none' | 'top' | 'bottom' | 'left' | 'right';\r\n\r\nexport interface TooltipProps {\r\n text: string;\r\n variant?: TooltipVariant;\r\n direction?: TooltipDirection;\r\n style?: StyleProp<ViewStyle>;\r\n}\r\n\r\n// ── Arrow dimensions ─────────────────────────────────────────────────────────\r\nconst ARROW_BASE = 16; // px — wide axis\r\nconst ARROW_HEIGHT = 6; // px — narrow axis\r\n\r\n// ── Component ────────────────────────────────────────────────────────────────\r\n\r\nexport function Tooltip({\r\n text,\r\n variant = 'filled',\r\n direction = 'none',\r\n style,\r\n}: TooltipProps) {\r\n const { colorRoles: cr, dimensions: dim, typeScale: ts } = useTheme();\r\n\r\n const isFilled = variant === 'filled';\r\n\r\n const bg = isFilled\r\n ? cr.surface.inverse.sysInverseSurface\r\n : cr.surface.surfaceContainer.sysSurfaceContainerLowest;\r\n\r\n const textColor = isFilled\r\n ? cr.surface.inverse.sysInverseOnSurface\r\n : cr.surface.surface.sysOnSurface;\r\n\r\n // ── Arrow (CSS triangle using zero-size View + borders) ───────────────────\r\n // Half-base for side calculations\r\n const half = ARROW_BASE / 2;\r\n\r\n function renderArrow() {\r\n if (direction === 'none') return null;\r\n\r\n // Shared transparent sides\r\n const transparent = 'transparent';\r\n\r\n let arrowStyle: object;\r\n\r\n switch (direction) {\r\n case 'bottom':\r\n // Triangle pointing down — sits below bubble\r\n arrowStyle = {\r\n width: 0,\r\n height: 0,\r\n borderLeftWidth: half,\r\n borderRightWidth: half,\r\n borderTopWidth: ARROW_HEIGHT,\r\n borderLeftColor: transparent,\r\n borderRightColor: transparent,\r\n borderTopColor: bg,\r\n };\r\n break;\r\n case 'top':\r\n // Triangle pointing up — sits above bubble\r\n arrowStyle = {\r\n width: 0,\r\n height: 0,\r\n borderLeftWidth: half,\r\n borderRightWidth: half,\r\n borderBottomWidth: ARROW_HEIGHT,\r\n borderLeftColor: transparent,\r\n borderRightColor: transparent,\r\n borderBottomColor: bg,\r\n };\r\n break;\r\n case 'left':\r\n // Triangle pointing left — sits to the left of bubble\r\n arrowStyle = {\r\n width: 0,\r\n height: 0,\r\n borderTopWidth: half,\r\n borderBottomWidth: half,\r\n borderRightWidth: ARROW_HEIGHT,\r\n borderTopColor: transparent,\r\n borderBottomColor: transparent,\r\n borderRightColor: bg,\r\n };\r\n break;\r\n case 'right':\r\n // Triangle pointing right — sits to the right of bubble\r\n arrowStyle = {\r\n width: 0,\r\n height: 0,\r\n borderTopWidth: half,\r\n borderBottomWidth: half,\r\n borderLeftWidth: ARROW_HEIGHT,\r\n borderTopColor: transparent,\r\n borderBottomColor: transparent,\r\n borderLeftColor: bg,\r\n };\r\n break;\r\n }\r\n\r\n return <View accessible={false} style={arrowStyle!} />;\r\n }\r\n\r\n // ── Bubble ────────────────────────────────────────────────────────────────\r\n const bubble = (\r\n <View\r\n accessible\r\n accessibilityRole=\"text\"\r\n accessibilityLabel={text}\r\n style={[\r\n styles.bubble,\r\n {\r\n backgroundColor: bg,\r\n paddingHorizontal: dim.spacing.padding.sysPadding12,\r\n paddingVertical: dim.spacing.padding.sysPadding8,\r\n borderRadius: dim.borderRadius.sysRadiusSm,\r\n },\r\n !isFilled && styles.elevated,\r\n !isFilled && {\r\n borderWidth: dim.borderWidth.sysStrokeThin,\r\n borderColor: cr.outline.sysOutline,\r\n },\r\n ]}\r\n >\r\n <Text\r\n style={{\r\n color: textColor,\r\n fontSize: ts.bodySmall.sysFontSize,\r\n lineHeight: ts.bodySmall.sysLineHeight,\r\n fontWeight: '400',\r\n textAlign: 'center',\r\n includeFontPadding: false,\r\n }}\r\n >\r\n {text}\r\n </Text>\r\n </View>\r\n );\r\n\r\n // ── Layout — arrow position determines stacking order ────────────────────\r\n if (direction === 'none') {\r\n return <View style={style}>{bubble}</View>;\r\n }\r\n\r\n if (direction === 'bottom') {\r\n return (\r\n <View style={[styles.colCenter, style]}>\r\n {bubble}\r\n {renderArrow()}\r\n </View>\r\n );\r\n }\r\n\r\n if (direction === 'top') {\r\n return (\r\n <View style={[styles.colCenter, style]}>\r\n {renderArrow()}\r\n {bubble}\r\n </View>\r\n );\r\n }\r\n\r\n if (direction === 'right') {\r\n return (\r\n <View style={[styles.rowCenter, style]}>\r\n {bubble}\r\n {renderArrow()}\r\n </View>\r\n );\r\n }\r\n\r\n // left\r\n return (\r\n <View style={[styles.rowCenter, style]}>\r\n {renderArrow()}\r\n {bubble}\r\n </View>\r\n );\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n bubble: {\r\n alignSelf: 'flex-start',\r\n },\r\n elevated: {\r\n shadowColor: '#000',\r\n shadowOffset: { width: 0, height: 2 },\r\n shadowOpacity: 0.06,\r\n shadowRadius: 4,\r\n elevation: 1,\r\n },\r\n colCenter: {\r\n alignItems: 'center',\r\n alignSelf: 'flex-start',\r\n },\r\n rowCenter: {\r\n flexDirection: 'row',\r\n alignItems: 'center',\r\n alignSelf: 'flex-start',\r\n },\r\n});\r\n"],"names":["Tooltip","ARROW_BASE","ARROW_HEIGHT","text","variant","direction","style","colorRoles","cr","dimensions","dim","typeScale","ts","useTheme","isFilled","bg","surface","inverse","sysInverseSurface","surfaceContainer","sysSurfaceContainerLowest","textColor","sysInverseOnSurface","sysOnSurface","half","renderArrow","transparent","arrowStyle","width","height","borderLeftWidth","borderRightWidth","borderTopWidth","borderLeftColor","borderRightColor","borderTopColor","borderBottomWidth","borderBottomColor","View","accessible","bubble","accessibilityRole","accessibilityLabel","styles","backgroundColor","paddingHorizontal","spacing","padding","sysPadding12","paddingVertical","sysPadding8","borderRadius","sysRadiusSm","elevated","borderWidth","sysStrokeThin","borderColor","outline","sysOutline","Text","color","fontSize","bodySmall","sysFontSize","lineHeight","sysLineHeight","fontWeight","textAlign","includeFontPadding","colCenter","rowCenter","StyleSheet","create","alignSelf","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","alignItems","flexDirection"],"mappings":";;;;+BAgCgBA;;;eAAAA;;;;8DAhCE;6BAE2C;uBAEpC;;;;;;AAsBzB,gFAAgF;AAChF,MAAMC,aAAa,IAAI,iBAAiB;AACxC,MAAMC,eAAe,GAAG,mBAAmB;AAIpC,SAASF,QAAQ,EACtBG,IAAI,EACJC,UAAU,QAAQ,EAClBC,YAAY,MAAM,EAClBC,KAAK,EACQ;IACb,MAAM,EAAEC,YAAYC,EAAE,EAAEC,YAAYC,GAAG,EAAEC,WAAWC,EAAE,EAAE,GAAGC,IAAAA,eAAQ;IAEnE,MAAMC,WAAWV,YAAY;IAE7B,MAAMW,KAAKD,WACPN,GAAGQ,OAAO,CAACC,OA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YACnCmB;YACAe;;;AAGP;AAEA,MAAMG,SAAS4B,uBAAU,CAACC,MAAM,CAAC;IAC/BhC,QAAQ;QACNiC,WAAW;IACb;IACApB,UAAU;QACRqB,aAAa;QACbC,cAAc;YAAE/C,OAAO;YAAGC,QAAQ;QAAE;QACpC+C,eAAe;QACfC,cAAc;QACdC,WAAW;IACb;IACAT,WAAW;QACTU,YAAY;QACZN,WAAW;IACb;IACAH,WAAW;QACTU,eAAe;QACfD,YAAY;QACZN,WAAW;IACb;AACF"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "AtomIcon", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return AtomIcon;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
const _reactnativesvg = /*#__PURE__*/ _interop_require_wildcard(require("react-native-svg"));
|
|
13
|
+
const _types = require("./types");
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
15
|
+
if (typeof WeakMap !== "function") return null;
|
|
16
|
+
var cacheBabelInterop = new WeakMap();
|
|
17
|
+
var cacheNodeInterop = new WeakMap();
|
|
18
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
19
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
20
|
+
})(nodeInterop);
|
|
21
|
+
}
|
|
22
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
23
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
27
|
+
return {
|
|
28
|
+
default: obj
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
32
|
+
if (cache && cache.has(obj)) {
|
|
33
|
+
return cache.get(obj);
|
|
34
|
+
}
|
|
35
|
+
var newObj = {
|
|
36
|
+
__proto__: null
|
|
37
|
+
};
|
|
38
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
39
|
+
for(var key in obj){
|
|
40
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
42
|
+
if (desc && (desc.get || desc.set)) {
|
|
43
|
+
Object.defineProperty(newObj, key, desc);
|
|
44
|
+
} else {
|
|
45
|
+
newObj[key] = obj[key];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
newObj.default = obj;
|
|
50
|
+
if (cache) {
|
|
51
|
+
cache.set(obj, newObj);
|
|
52
|
+
}
|
|
53
|
+
return newObj;
|
|
54
|
+
}
|
|
55
|
+
function AtomIcon({ size = 'medium', color = _types.DEFAULT_ICON_COLOR }) {
|
|
56
|
+
const { size: px, strokeWidth } = _types.SIZE_MAP[size];
|
|
57
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnativesvg.default, {
|
|
58
|
+
width: px,
|
|
59
|
+
height: px,
|
|
60
|
+
viewBox: "0 0 48 48",
|
|
61
|
+
fill: "none",
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnativesvg.Path, {
|
|
64
|
+
d: "M24 26C25.1046 26 26 25.1046 26 24C26 22.8954 25.1046 22 24 22C22.8954 22 22 22.8954 22 24C22 25.1046 22.8954 26 24 26Z",
|
|
65
|
+
stroke: color,
|
|
66
|
+
strokeWidth: strokeWidth,
|
|
67
|
+
..._types.COMMON
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnativesvg.Path, {
|
|
70
|
+
d: "M40.4 40.4C44.48 36.34 40.44 25.68 31.4 16.6C22.32 7.56002 11.66 3.52002 7.60002 7.60002C3.52002 11.66 7.56002 22.32 16.6 31.4C25.68 40.44 36.34 44.48 40.4 40.4Z",
|
|
71
|
+
stroke: color,
|
|
72
|
+
strokeWidth: strokeWidth,
|
|
73
|
+
..._types.COMMON
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnativesvg.Path, {
|
|
76
|
+
d: "M31.4 31.4C40.44 22.32 44.48 11.66 40.4 7.60002C36.34 3.52002 25.68 7.56002 16.6 16.6C7.56002 25.68 3.52002 36.34 7.60002 40.4C11.66 44.48 22.32 40.44 31.4 31.4Z",
|
|
77
|
+
stroke: color,
|
|
78
|
+
strokeWidth: strokeWidth,
|
|
79
|
+
..._types.COMMON
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=AtomIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/react-native/src/icons/AtomIcon.tsx"],"sourcesContent":["import Svg, { Path } from 'react-native-svg';\r\n\r\nimport { COMMON, DEFAULT_ICON_COLOR, type IconProps, SIZE_MAP } from './types';\r\n\r\nexport function AtomIcon({\r\n size = 'medium',\r\n color = DEFAULT_ICON_COLOR,\r\n}: IconProps) {\r\n const { size: px, strokeWidth } = SIZE_MAP[size];\r\n return (\r\n <Svg width={px} height={px} viewBox=\"0 0 48 48\" fill=\"none\">\r\n <Path\r\n d=\"M24 26C25.1046 26 26 25.1046 26 24C26 22.8954 25.1046 22 24 22C22.8954 22 22 22.8954 22 24C22 25.1046 22.8954 26 24 26Z\"\r\n stroke={color}\r\n strokeWidth={strokeWidth}\r\n {...COMMON}\r\n />\r\n <Path\r\n d=\"M40.4 40.4C44.48 36.34 40.44 25.68 31.4 16.6C22.32 7.56002 11.66 3.52002 7.60002 7.60002C3.52002 11.66 7.56002 22.32 16.6 31.4C25.68 40.44 36.34 44.48 40.4 40.4Z\"\r\n stroke={color}\r\n strokeWidth={strokeWidth}\r\n {...COMMON}\r\n />\r\n <Path\r\n d=\"M31.4 31.4C40.44 22.32 44.48 11.66 40.4 7.60002C36.34 3.52002 25.68 7.56002 16.6 16.6C7.56002 25.68 3.52002 36.34 7.60002 40.4C11.66 44.48 22.32 40.44 31.4 31.4Z\"\r\n stroke={color}\r\n strokeWidth={strokeWidth}\r\n {...COMMON}\r\n />\r\n </Svg>\r\n );\r\n}\r\n"],"names":["AtomIcon","size","color","DEFAULT_ICON_COLOR","px","strokeWidth","SIZE_MAP","Svg","width","height","viewBox","fill","Path","d","stroke","COMMON"],"mappings":";;;;+BAIgBA;;;eAAAA;;;;wEAJU;uBAE2C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9D,SAASA,SAAS,EACvBC,OAAO,QAAQ,EACfC,QAAQC,yBAAkB,EAChB;IACV,MAAM,EAAEF,MAAMG,EAAE,EAAEC,WAAW,EAAE,GAAGC,eAAQ,CAACL,KAAK;IAChD,qBACE,sBAACM,uBAAG;QAACC,OAAOJ;QAAIK,QAAQL;QAAIM,SAAQ;QAAYC,MAAK;;0BACnD,qBAACC,oBAAI;gBACHC,GAAE;gBACFC,QAAQZ;gBACRG,aAAaA;gBACZ,GAAGU,aAAM;;0BAEZ,qBAACH,oBAAI;gBACHC,GAAE;gBACFC,QAAQZ;gBACRG,aAAaA;gBACZ,GAAGU,aAAM;;0BAEZ,qBAACH,oBAAI;gBACHC,GAAE;gBACFC,QAAQZ;gBACRG,aAAaA;gBACZ,GAAGU,aAAM;;;;AAIlB"}
|