@compsych-ui-components/react-native 4.0.0 → 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 +203 -1
- 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 -43
- package/src/lib/button.js.map +0 -1
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "RadioButton", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return RadioButton;
|
|
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
|
+
function RadioButton({ checked: checkedProp, defaultChecked = false, onChange, size = 'md', label, description, disabled = false, invalid = false, style }) {
|
|
57
|
+
const { colorRoles: cr, dimensions: dim, typeScale: ts } = (0, _theme.useTheme)();
|
|
58
|
+
const [internalChecked, setInternalChecked] = (0, _react.useState)(defaultChecked);
|
|
59
|
+
const isControlled = checkedProp !== undefined;
|
|
60
|
+
const isChecked = isControlled ? checkedProp : internalChecked;
|
|
61
|
+
const sizeTokens = (0, _react.useMemo)(()=>({
|
|
62
|
+
sm: {
|
|
63
|
+
// Container (overall hit area)
|
|
64
|
+
hitArea: 36,
|
|
65
|
+
// Visible circle
|
|
66
|
+
circle: 20,
|
|
67
|
+
// Inner dot when selected
|
|
68
|
+
dot: 8,
|
|
69
|
+
fontSize: ts.bodySmall.sysFontSize,
|
|
70
|
+
lineHeight: ts.bodySmall.sysLineHeight
|
|
71
|
+
},
|
|
72
|
+
md: {
|
|
73
|
+
hitArea: 40,
|
|
74
|
+
circle: 24,
|
|
75
|
+
dot: 10,
|
|
76
|
+
fontSize: ts.bodyMedium.sysFontSize,
|
|
77
|
+
lineHeight: ts.bodyMedium.sysLineHeight
|
|
78
|
+
}
|
|
79
|
+
}), [
|
|
80
|
+
ts
|
|
81
|
+
]);
|
|
82
|
+
const s = sizeTokens[size];
|
|
83
|
+
function handlePress() {
|
|
84
|
+
if (disabled) return;
|
|
85
|
+
const next = !isChecked;
|
|
86
|
+
if (!isControlled) setInternalChecked(next);
|
|
87
|
+
onChange?.(next);
|
|
88
|
+
}
|
|
89
|
+
// Border/fill colours
|
|
90
|
+
const borderColor = invalid ? cr.error.sysError : isChecked ? cr.accent.primary.sysPrimary : cr.outline.sysOutlineFixed;
|
|
91
|
+
const circleBg = isChecked ? cr.accent.primary.sysPrimary : 'transparent';
|
|
92
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Pressable, {
|
|
93
|
+
onPress: handlePress,
|
|
94
|
+
accessibilityRole: "radio",
|
|
95
|
+
accessibilityLabel: label,
|
|
96
|
+
accessibilityState: {
|
|
97
|
+
checked: isChecked,
|
|
98
|
+
disabled
|
|
99
|
+
},
|
|
100
|
+
style: ()=>[
|
|
101
|
+
styles.root,
|
|
102
|
+
disabled && styles.disabled,
|
|
103
|
+
style
|
|
104
|
+
],
|
|
105
|
+
children: ({ pressed })=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
106
|
+
children: [
|
|
107
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
108
|
+
style: [
|
|
109
|
+
styles.hitArea,
|
|
110
|
+
{
|
|
111
|
+
width: s.hitArea,
|
|
112
|
+
height: s.hitArea,
|
|
113
|
+
borderRadius: s.hitArea / 2,
|
|
114
|
+
backgroundColor: pressed && !disabled ? cr.transparent.neutral.sysBlack10 : 'transparent'
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
118
|
+
style: {
|
|
119
|
+
width: s.circle,
|
|
120
|
+
height: s.circle,
|
|
121
|
+
borderRadius: s.circle / 2,
|
|
122
|
+
borderWidth: dim.borderWidth.sysStrokeMedium,
|
|
123
|
+
borderColor,
|
|
124
|
+
backgroundColor: circleBg,
|
|
125
|
+
alignItems: 'center',
|
|
126
|
+
justifyContent: 'center'
|
|
127
|
+
},
|
|
128
|
+
children: isChecked && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
129
|
+
style: {
|
|
130
|
+
width: s.dot,
|
|
131
|
+
height: s.dot,
|
|
132
|
+
borderRadius: s.dot / 2,
|
|
133
|
+
backgroundColor: cr.accent.primary.sysOnPrimary
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
}),
|
|
138
|
+
(label || description) && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
139
|
+
style: [
|
|
140
|
+
styles.textBlock,
|
|
141
|
+
{
|
|
142
|
+
gap: 2
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
children: [
|
|
146
|
+
label && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Text, {
|
|
147
|
+
style: {
|
|
148
|
+
color: cr.surface.surface.sysOnSurface,
|
|
149
|
+
fontSize: s.fontSize,
|
|
150
|
+
lineHeight: s.lineHeight,
|
|
151
|
+
includeFontPadding: false
|
|
152
|
+
},
|
|
153
|
+
children: label
|
|
154
|
+
}),
|
|
155
|
+
description && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.Text, {
|
|
156
|
+
style: {
|
|
157
|
+
color: cr.surface.surface.sysOnSurfaceVariant,
|
|
158
|
+
fontSize: s.fontSize - 2,
|
|
159
|
+
lineHeight: s.lineHeight - 2,
|
|
160
|
+
includeFontPadding: false
|
|
161
|
+
},
|
|
162
|
+
children: description
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
})
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const styles = _reactnative.StyleSheet.create({
|
|
171
|
+
root: {
|
|
172
|
+
flexDirection: 'row',
|
|
173
|
+
alignItems: 'center'
|
|
174
|
+
},
|
|
175
|
+
hitArea: {
|
|
176
|
+
alignItems: 'center',
|
|
177
|
+
justifyContent: 'center'
|
|
178
|
+
},
|
|
179
|
+
textBlock: {
|
|
180
|
+
flex: 1,
|
|
181
|
+
flexDirection: 'column'
|
|
182
|
+
},
|
|
183
|
+
disabled: {
|
|
184
|
+
opacity: 0.48
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/react-native/src/components/RadioButton/index.tsx"],"sourcesContent":["import React, { useMemo, useState } from 'react';\r\n\r\nimport {\r\n Pressable,\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 type RadioButtonSize = 'sm' | 'md';\r\n\r\nexport interface RadioButtonProps {\r\n checked?: boolean;\r\n defaultChecked?: boolean;\r\n onChange?: (checked: boolean) => void;\r\n size?: RadioButtonSize;\r\n label?: string;\r\n description?: string;\r\n disabled?: boolean;\r\n invalid?: boolean;\r\n style?: StyleProp<ViewStyle>;\r\n}\r\n\r\nexport function RadioButton({\r\n checked: checkedProp,\r\n defaultChecked = false,\r\n onChange,\r\n size = 'md',\r\n label,\r\n description,\r\n disabled = false,\r\n invalid = false,\r\n style,\r\n}: RadioButtonProps) {\r\n const { colorRoles: cr, dimensions: dim, typeScale: ts } = useTheme();\r\n const [internalChecked, setInternalChecked] =\r\n useState<boolean>(defaultChecked);\r\n const isControlled = checkedProp !== undefined;\r\n const isChecked: boolean = isControlled\r\n ? (checkedProp as boolean)\r\n : internalChecked;\r\n\r\n const sizeTokens = useMemo(\r\n () => ({\r\n sm: {\r\n // Container (overall hit area)\r\n hitArea: 36,\r\n // Visible circle\r\n circle: 20,\r\n // Inner dot when selected\r\n dot: 8,\r\n fontSize: ts.bodySmall.sysFontSize,\r\n lineHeight: ts.bodySmall.sysLineHeight,\r\n },\r\n md: {\r\n hitArea: 40,\r\n circle: 24,\r\n dot: 10,\r\n fontSize: ts.bodyMedium.sysFontSize,\r\n lineHeight: ts.bodyMedium.sysLineHeight,\r\n },\r\n }),\r\n [ts],\r\n );\r\n\r\n const s = sizeTokens[size];\r\n\r\n function handlePress() {\r\n if (disabled) return;\r\n const next = !isChecked;\r\n if (!isControlled) setInternalChecked(next);\r\n onChange?.(next);\r\n }\r\n\r\n // Border/fill colours\r\n const borderColor = invalid\r\n ? cr.error.sysError\r\n : isChecked\r\n ? cr.accent.primary.sysPrimary\r\n : cr.outline.sysOutlineFixed;\r\n\r\n const circleBg = isChecked ? cr.accent.primary.sysPrimary : 'transparent';\r\n\r\n return (\r\n <Pressable\r\n onPress={handlePress}\r\n accessibilityRole=\"radio\"\r\n accessibilityLabel={label}\r\n accessibilityState={{ checked: isChecked, disabled }}\r\n style={() => [styles.root, disabled && styles.disabled, style]}\r\n >\r\n {({ pressed }: { pressed: boolean }) => (\r\n <>\r\n {/* Hit-area / state-layer circle */}\r\n <View\r\n style={[\r\n styles.hitArea,\r\n {\r\n width: s.hitArea,\r\n height: s.hitArea,\r\n borderRadius: s.hitArea / 2,\r\n backgroundColor:\r\n pressed && !disabled\r\n ? cr.transparent.neutral.sysBlack10\r\n : 'transparent',\r\n },\r\n ]}\r\n >\r\n {/* Visible radio circle */}\r\n <View\r\n style={{\r\n width: s.circle,\r\n height: s.circle,\r\n borderRadius: s.circle / 2,\r\n borderWidth: dim.borderWidth.sysStrokeMedium,\r\n borderColor,\r\n backgroundColor: circleBg,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n }}\r\n >\r\n {/* Inner white dot — only visible when selected */}\r\n {isChecked && (\r\n <View\r\n style={{\r\n width: s.dot,\r\n height: s.dot,\r\n borderRadius: s.dot / 2,\r\n backgroundColor: cr.accent.primary.sysOnPrimary,\r\n }}\r\n />\r\n )}\r\n </View>\r\n </View>\r\n\r\n {(label || description) && (\r\n <View style={[styles.textBlock, { gap: 2 }]}>\r\n {label && (\r\n <Text\r\n style={{\r\n color: cr.surface.surface.sysOnSurface,\r\n fontSize: s.fontSize,\r\n lineHeight: s.lineHeight,\r\n includeFontPadding: false,\r\n }}\r\n >\r\n {label}\r\n </Text>\r\n )}\r\n {description && (\r\n <Text\r\n style={{\r\n color: cr.surface.surface.sysOnSurfaceVariant,\r\n fontSize: s.fontSize - 2,\r\n lineHeight: s.lineHeight - 2,\r\n includeFontPadding: false,\r\n }}\r\n >\r\n {description}\r\n </Text>\r\n )}\r\n </View>\r\n )}\r\n </>\r\n )}\r\n </Pressable>\r\n );\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n root: {\r\n flexDirection: 'row',\r\n alignItems: 'center',\r\n },\r\n hitArea: {\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n textBlock: {\r\n flex: 1,\r\n flexDirection: 'column',\r\n },\r\n disabled: {\r\n opacity: 0.48,\r\n },\r\n});\r\n"],"names":["RadioButton","checked","checkedProp","defaultChecked","onChange","size","label","description","disabled","invalid","style","colorRoles","cr","dimensions","dim","typeScale","ts","useTheme","internalChecked","setInternalChecked","useState","isControlled","undefined","isChecked","sizeTokens","useMemo","sm","hitArea","circle","dot","fontSize","bodySmall","sysFontSize","lineHeight","sysLineHeight","md","bodyMedium","s","handlePress","next","borderColor","error","sysError","accent","primary","sysPrimary","outline","sysOutlineFixed","circleBg","Pressable","onPress","accessibilityRole","accessibilityLabel","accessibilityState","styles","root","pressed","View","width","height","borderRadius","backgroundColor","transparent","neutral","sysBlack10","borderWidth","sysStrokeMedium","alignItems","justifyContent","sysOnPrimary","textBlock","gap","Text","color","surface","sysOnSurface","includeFontPadding","sysOnSurfaceVariant","StyleSheet","create","flexDirection","flex","opacity"],"mappings":";;;;+BA2BgBA;;;eAAAA;;;;+DA3ByB;6BASlC;uBAEkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBlB,SAASA,YAAY,EAC1BC,SAASC,WAAW,EACpBC,iBAAiB,KAAK,EACtBC,QAAQ,EACRC,OAAO,IAAI,EACXC,KAAK,EACLC,WAAW,EACXC,WAAW,KAAK,EAChBC,UAAU,K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CAC7C/C,UAAUO,EAAEP,QAAQ,GAAG;oCACvBG,YAAYI,EAAEJ,UAAU,GAAG;oCAC3B2C,oBAAoB;gCACtB;0CAECrE;;;;;;;AASnB;AAEA,MAAM+C,SAASwB,uBAAU,CAACC,MAAM,CAAC;IAC/BxB,MAAM;QACJyB,eAAe;QACfb,YAAY;IACd;IACAxC,SAAS;QACPwC,YAAY;QACZC,gBAAgB;IAClB;IACAE,WAAW;QACTW,MAAM;QACND,eAAe;IACjB;IACAxE,UAAU;QACR0E,SAAS;IACX;AACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView, type ScrollViewProps } from 'react-native';
|
|
3
|
+
export interface ScreenContainerProps extends ScrollViewProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Scrollable screen wrapper that applies the default surface background and
|
|
8
|
+
* standard padding. The ref is forwarded to the underlying ScrollView so
|
|
9
|
+
* callers can imperatively scroll, measure, or attach scroll listeners.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const scrollRef = useRef<ScrollView>(null);
|
|
13
|
+
* <ScreenContainer ref={scrollRef}>...</ScreenContainer>
|
|
14
|
+
*/
|
|
15
|
+
export declare const ScreenContainer: React.ForwardRefExoticComponent<ScreenContainerProps & React.RefAttributes<ScrollView>>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ScreenContainer", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ScreenContainer;
|
|
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
|
+
const ScreenContainer = /*#__PURE__*/ _react.default.forwardRef(function ScreenContainer({ children, style, contentContainerStyle, ...rest }, ref) {
|
|
21
|
+
const { dimensions: dim, colorRoles: cr } = (0, _theme.useTheme)();
|
|
22
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.ScrollView, {
|
|
23
|
+
ref: ref,
|
|
24
|
+
style: [
|
|
25
|
+
{
|
|
26
|
+
flex: 1,
|
|
27
|
+
backgroundColor: cr.surface.surface.sysSurface
|
|
28
|
+
},
|
|
29
|
+
style
|
|
30
|
+
],
|
|
31
|
+
contentContainerStyle: [
|
|
32
|
+
{
|
|
33
|
+
paddingHorizontal: dim.spacing.padding.sysPadding16,
|
|
34
|
+
paddingVertical: dim.spacing.padding.sysPadding8
|
|
35
|
+
},
|
|
36
|
+
contentContainerStyle
|
|
37
|
+
],
|
|
38
|
+
...rest,
|
|
39
|
+
children: children
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/react-native/src/components/ScreenContainer/index.tsx"],"sourcesContent":["import React from 'react';\r\n\r\nimport { ScrollView, type ScrollViewProps } from 'react-native';\r\n\r\nimport { useTheme } from '../../theme';\r\n\r\nexport interface ScreenContainerProps extends ScrollViewProps {\r\n children?: React.ReactNode;\r\n}\r\n\r\n/**\r\n * Scrollable screen wrapper that applies the default surface background and\r\n * standard padding. The ref is forwarded to the underlying ScrollView so\r\n * callers can imperatively scroll, measure, or attach scroll listeners.\r\n *\r\n * @example\r\n * const scrollRef = useRef<ScrollView>(null);\r\n * <ScreenContainer ref={scrollRef}>...</ScreenContainer>\r\n */\r\nexport const ScreenContainer = React.forwardRef<\r\n ScrollView,\r\n ScreenContainerProps\r\n>(function ScreenContainer(\r\n { children, style, contentContainerStyle, ...rest },\r\n ref,\r\n) {\r\n const { dimensions: dim, colorRoles: cr } = useTheme();\r\n\r\n return (\r\n <ScrollView\r\n ref={ref}\r\n style={[\r\n {\r\n flex: 1,\r\n backgroundColor: cr.surface.surface.sysSurface,\r\n },\r\n style,\r\n ]}\r\n contentContainerStyle={[\r\n {\r\n paddingHorizontal: dim.spacing.padding.sysPadding16,\r\n paddingVertical: dim.spacing.padding.sysPadding8,\r\n },\r\n contentContainerStyle,\r\n ]}\r\n {...rest}\r\n >\r\n {children}\r\n </ScrollView>\r\n );\r\n});\r\n"],"names":["ScreenContainer","React","forwardRef","children","style","contentContainerStyle","rest","ref","dimensions","dim","colorRoles","cr","useTheme","ScrollView","flex","backgroundColor","surface","sysSurface","paddingHorizontal","spacing","padding","sysPadding16","paddingVertical","sysPadding8"],"mappings":";;;;+BAmBaA;;;eAAAA;;;;8DAnBK;6BAE+B;uBAExB;;;;;;AAelB,MAAMA,gCAAkBC,cAAK,CAACC,UAAU,CAG7C,SAASF,gBACT,EAAEG,QAAQ,EAAEC,KAAK,EAAEC,qBAAqB,EAAE,GAAGC,MAAM,EACnDC,GAAG;IAEH,MAAM,EAAEC,YAAYC,GAAG,EAAEC,YAAYC,EAAE,EAAE,GAAGC,IAAAA,eAAQ;IAEpD,qBACE,qBAACC,uBAAU;QACTN,KAAKA;QACLH,OAAO;YACL;gBACEU,MAAM;gBACNC,iBAAiBJ,GAAGK,OAAO,CAACA,OAAO,CAACC,UAAU;YAChD;YACAb;SACD;QACDC,uBAAuB;YACrB;gBACEa,mBAAmBT,IAAIU,OAAO,CAACC,OAAO,CAACC,YAAY;gBACnDC,iBAAiBb,IAAIU,OAAO,CAACC,OAAO,CAACG,WAAW;YAClD;YACAlB;SACD;QACA,GAAGC,IAAI;kBAEPH;;AAGP"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export interface SegmentedControlOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: React.ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface SegmentedControlProps {
|
|
10
|
+
options: SegmentedControlOption[];
|
|
11
|
+
value: string;
|
|
12
|
+
onChange: (value: string) => void;
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
style?: StyleProp<ViewStyle>;
|
|
15
|
+
}
|
|
16
|
+
export declare function SegmentedControl({ options, value, onChange, fullWidth, style, }: SegmentedControlProps): React.JSX.Element;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "SegmentedControl", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return SegmentedControl;
|
|
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
|
+
const _BodyText = require("../BodyText");
|
|
16
|
+
function _interop_require_default(obj) {
|
|
17
|
+
return obj && obj.__esModule ? obj : {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function SegmentedControl({ options, value, onChange, fullWidth = false, style }) {
|
|
22
|
+
const { colorRoles: cr, dimensions: dim } = (0, _theme.useTheme)();
|
|
23
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
24
|
+
style: [
|
|
25
|
+
styles.container,
|
|
26
|
+
{
|
|
27
|
+
backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerLowest,
|
|
28
|
+
borderWidth: dim.borderWidth.sysStrokeThin,
|
|
29
|
+
borderColor: cr.outline.sysOutline,
|
|
30
|
+
borderRadius: dim.borderRadius.sysRadiusFull,
|
|
31
|
+
padding: dim.spacing.padding.sysPadding4,
|
|
32
|
+
gap: dim.spacing.padding.sysPadding4
|
|
33
|
+
},
|
|
34
|
+
fullWidth && styles.fullWidth,
|
|
35
|
+
style
|
|
36
|
+
],
|
|
37
|
+
children: options.map((option)=>{
|
|
38
|
+
const isActive = option.value === value;
|
|
39
|
+
const isDisabled = option.disabled ?? false;
|
|
40
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.Pressable, {
|
|
41
|
+
onPress: isDisabled ? undefined : ()=>onChange(option.value),
|
|
42
|
+
accessibilityRole: "tab",
|
|
43
|
+
accessibilityLabel: option.label,
|
|
44
|
+
accessibilityState: {
|
|
45
|
+
selected: isActive,
|
|
46
|
+
disabled: isDisabled
|
|
47
|
+
},
|
|
48
|
+
style: ({ pressed })=>[
|
|
49
|
+
styles.item,
|
|
50
|
+
{
|
|
51
|
+
paddingHorizontal: dim.spacing.padding.sysPadding12,
|
|
52
|
+
paddingVertical: dim.spacing.padding.sysPadding6,
|
|
53
|
+
gap: dim.spacing.padding.sysPadding4,
|
|
54
|
+
borderRadius: dim.borderRadius.sysRadiusFull
|
|
55
|
+
},
|
|
56
|
+
isActive && {
|
|
57
|
+
backgroundColor: cr.accent.primary.sysPrimary
|
|
58
|
+
},
|
|
59
|
+
!isActive && pressed && !isDisabled && {
|
|
60
|
+
backgroundColor: cr.transparent.neutral.sysBlack10
|
|
61
|
+
},
|
|
62
|
+
isDisabled && styles.disabled
|
|
63
|
+
],
|
|
64
|
+
children: [
|
|
65
|
+
option.icon && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
66
|
+
style: styles.iconSlot,
|
|
67
|
+
children: option.icon
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_BodyText.BodyText, {
|
|
70
|
+
variant: "small",
|
|
71
|
+
emphasized: isActive,
|
|
72
|
+
color: isActive ? cr.accent.primary.sysOnPrimary : cr.surface.surface.sysOnSurfaceVariant,
|
|
73
|
+
numberOfLines: 1,
|
|
74
|
+
children: option.label
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
}, option.value);
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const styles = _reactnative.StyleSheet.create({
|
|
82
|
+
container: {
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
alignSelf: 'flex-start',
|
|
86
|
+
shadowColor: '#000',
|
|
87
|
+
shadowOffset: {
|
|
88
|
+
width: 0,
|
|
89
|
+
height: 2
|
|
90
|
+
},
|
|
91
|
+
shadowOpacity: 0.06,
|
|
92
|
+
shadowRadius: 4,
|
|
93
|
+
elevation: 1
|
|
94
|
+
},
|
|
95
|
+
fullWidth: {
|
|
96
|
+
alignSelf: 'stretch'
|
|
97
|
+
},
|
|
98
|
+
item: {
|
|
99
|
+
flex: 1,
|
|
100
|
+
flexDirection: 'row',
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
justifyContent: 'center'
|
|
103
|
+
},
|
|
104
|
+
iconSlot: {
|
|
105
|
+
width: 16,
|
|
106
|
+
height: 16,
|
|
107
|
+
alignItems: 'center',
|
|
108
|
+
justifyContent: 'center'
|
|
109
|
+
},
|
|
110
|
+
disabled: {
|
|
111
|
+
opacity: 0.48
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/react-native/src/components/SegmentedControl/index.tsx"],"sourcesContent":["import React from 'react';\r\n\r\nimport {\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\nimport { BodyText } from '../BodyText';\r\n\r\nexport interface SegmentedControlOption {\r\n value: string;\r\n label: string;\r\n icon?: React.ReactNode;\r\n disabled?: boolean;\r\n}\r\n\r\nexport interface SegmentedControlProps {\r\n options: SegmentedControlOption[];\r\n value: string;\r\n onChange: (value: string) => void;\r\n fullWidth?: boolean;\r\n style?: StyleProp<ViewStyle>;\r\n}\r\n\r\nexport function SegmentedControl({\r\n options,\r\n value,\r\n onChange,\r\n fullWidth = false,\r\n style,\r\n}: SegmentedControlProps) {\r\n const { colorRoles: cr, dimensions: dim } = useTheme();\r\n\r\n return (\r\n <View\r\n style={[\r\n styles.container,\r\n {\r\n backgroundColor:\r\n cr.surface.surfaceContainer.sysSurfaceContainerLowest,\r\n borderWidth: dim.borderWidth.sysStrokeThin,\r\n borderColor: cr.outline.sysOutline,\r\n borderRadius: dim.borderRadius.sysRadiusFull,\r\n padding: dim.spacing.padding.sysPadding4,\r\n gap: dim.spacing.padding.sysPadding4,\r\n },\r\n fullWidth && styles.fullWidth,\r\n style,\r\n ]}\r\n >\r\n {options.map((option) => {\r\n const isActive = option.value === value;\r\n const isDisabled = option.disabled ?? false;\r\n\r\n return (\r\n <Pressable\r\n key={option.value}\r\n onPress={isDisabled ? undefined : () => onChange(option.value)}\r\n accessibilityRole=\"tab\"\r\n accessibilityLabel={option.label}\r\n accessibilityState={{ selected: isActive, disabled: isDisabled }}\r\n style={({ pressed }) => [\r\n styles.item,\r\n {\r\n paddingHorizontal: dim.spacing.padding.sysPadding12,\r\n paddingVertical: dim.spacing.padding.sysPadding6,\r\n gap: dim.spacing.padding.sysPadding4,\r\n borderRadius: dim.borderRadius.sysRadiusFull,\r\n },\r\n isActive && { backgroundColor: cr.accent.primary.sysPrimary },\r\n !isActive &&\r\n pressed &&\r\n !isDisabled && {\r\n backgroundColor: cr.transparent.neutral.sysBlack10,\r\n },\r\n isDisabled && styles.disabled,\r\n ]}\r\n >\r\n {option.icon && <View style={styles.iconSlot}>{option.icon}</View>}\r\n <BodyText\r\n variant=\"small\"\r\n emphasized={isActive}\r\n color={\r\n isActive\r\n ? cr.accent.primary.sysOnPrimary\r\n : cr.surface.surface.sysOnSurfaceVariant\r\n }\r\n numberOfLines={1}\r\n >\r\n {option.label}\r\n </BodyText>\r\n </Pressable>\r\n );\r\n })}\r\n </View>\r\n );\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n container: {\r\n flexDirection: 'row',\r\n alignItems: 'center',\r\n alignSelf: 'flex-start',\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 fullWidth: {\r\n alignSelf: 'stretch',\r\n },\r\n item: {\r\n flex: 1,\r\n flexDirection: 'row',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n iconSlot: {\r\n width: 16,\r\n height: 16,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n disabled: {\r\n opacity: 0.48,\r\n },\r\n});\r\n"],"names":["SegmentedControl","options","value","onChange","fullWidth","style","colorRoles","cr","dimensions","dim","useTheme","View","styles","container","backgroundColor","surface","surfaceContainer","sysSurfaceContainerLowest","borderWidth","sysStrokeThin","borderColor","outline","sysOutline","borderRadius","sysRadiusFull","padding","spacing","sysPadding4","gap","map","option","isActive","isDisabled","disabled","Pressable","onPress","undefined","accessibilityRole","accessibilityLabel","label","accessibilityState","selected","pressed","item","paddingHorizontal","sysPadding12","paddingVertical","sysPadding6","accent","primary","sysPrimary","transparent","neutral","sysBlack10","icon","iconSlot","BodyText","variant","emphasized","color","sysOnPrimary","sysOnSurfaceVariant","numberOfLines","StyleSheet","create","flexDirection","alignItems","alignSelf","shadowColor","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","flex","justifyContent","opacity"],"mappings":";;;;+BA4BgBA;;;eAAAA;;;;8DA5BE;6BAQX;uBAEkB;0BACA;;;;;;AAiBlB,SAASA,iBAAiB,EAC/BC,OAAO,EACPC,KA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;wBAC5D,CAACnB,YACCW,WACA,CAACV,cAAc;4BACblB,iBAAiBP,GAAG4C,WAAW,CAACC,OAAO,CAACC,UAAU;wBACpD;wBACFrB,cAAcpB,OAAOqB,QAAQ;qBAC9B;;oBAEAH,OAAOwB,IAAI,kBAAI,qBAAC3C,iBAAI;wBAACN,OAAOO,OAAO2C,QAAQ;kCAAGzB,OAAOwB,IAAI;;kCAC1D,qBAACE,kBAAQ;wBACPC,SAAQ;wBACRC,YAAY3B;wBACZ4B,OACE5B,WACIxB,GAAGyC,MAAM,CAACC,OAAO,CAACW,YAAY,GAC9BrD,GAAGQ,OAAO,CAACA,OAAO,CAAC8C,mBAAmB;wBAE5CC,eAAe;kCAEdhC,OAAOS,KAAK;;;eAjCVT,OAAO5B,KAAK;QAqCvB;;AAGN;AAEA,MAAMU,SAASmD,uBAAU,CAACC,MAAM,CAAC;IAC/BnD,WAAW;QACToD,eAAe;QACfC,YAAY;QACZC,WAAW;QACXC,aAAa;QACbC,cAAc;YAAEC,OAAO;YAAGC,QAAQ;QAAE;QACpCC,eAAe;QACfC,cAAc;QACdC,WAAW;IACb;IACAtE,WAAW;QACT+D,WAAW;IACb;IACAxB,MAAM;QACJgC,MAAM;QACNV,eAAe;QACfC,YAAY;QACZU,gBAAgB;IAClB;IACArB,UAAU;QACRe,OAAO;QACPC,QAAQ;QACRL,YAAY;QACZU,gBAAgB;IAClB;IACA3C,UAAU;QACR4C,SAAS;IACX;AACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { type IconName } from '../../icons';
|
|
4
|
+
export type SelectionCardSize = 'sm' | 'md';
|
|
5
|
+
export interface SelectionCardProps {
|
|
6
|
+
title: string;
|
|
7
|
+
icon?: IconName;
|
|
8
|
+
size?: SelectionCardSize;
|
|
9
|
+
multiSelect?: boolean;
|
|
10
|
+
selected?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
onPress?: () => void;
|
|
13
|
+
accessibilityLabel?: string;
|
|
14
|
+
style?: StyleProp<ViewStyle>;
|
|
15
|
+
}
|
|
16
|
+
export declare function SelectionCard({ title, icon, size, multiSelect, selected, disabled, onPress, accessibilityLabel, style, }: SelectionCardProps): React.JSX.Element;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "SelectionCard", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return SelectionCard;
|
|
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 _icons = require("../../icons");
|
|
16
|
+
const _theme = require("../../theme");
|
|
17
|
+
const _BodyText = require("../BodyText");
|
|
18
|
+
const _HeaderText = require("../HeaderText");
|
|
19
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
20
|
+
if (typeof WeakMap !== "function") return null;
|
|
21
|
+
var cacheBabelInterop = new WeakMap();
|
|
22
|
+
var cacheNodeInterop = new WeakMap();
|
|
23
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
24
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
25
|
+
})(nodeInterop);
|
|
26
|
+
}
|
|
27
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
28
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
32
|
+
return {
|
|
33
|
+
default: obj
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
37
|
+
if (cache && cache.has(obj)) {
|
|
38
|
+
return cache.get(obj);
|
|
39
|
+
}
|
|
40
|
+
var newObj = {
|
|
41
|
+
__proto__: null
|
|
42
|
+
};
|
|
43
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
44
|
+
for(var key in obj){
|
|
45
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
46
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
47
|
+
if (desc && (desc.get || desc.set)) {
|
|
48
|
+
Object.defineProperty(newObj, key, desc);
|
|
49
|
+
} else {
|
|
50
|
+
newObj[key] = obj[key];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
newObj.default = obj;
|
|
55
|
+
if (cache) {
|
|
56
|
+
cache.set(obj, newObj);
|
|
57
|
+
}
|
|
58
|
+
return newObj;
|
|
59
|
+
}
|
|
60
|
+
function SelectionCard({ title, icon, size = 'md', multiSelect = false, selected = false, disabled = false, onPress, accessibilityLabel, style }) {
|
|
61
|
+
const { colorRoles: cr, dimensions: dim } = (0, _theme.useTheme)();
|
|
62
|
+
const selectedRing = (0, _react.useMemo)(()=>({
|
|
63
|
+
shadowColor: cr.accent.primary.sysPrimary,
|
|
64
|
+
shadowOffset: {
|
|
65
|
+
width: 1,
|
|
66
|
+
height: 2
|
|
67
|
+
},
|
|
68
|
+
shadowOpacity: 1,
|
|
69
|
+
shadowRadius: 0,
|
|
70
|
+
elevation: 2
|
|
71
|
+
}), [
|
|
72
|
+
cr
|
|
73
|
+
]);
|
|
74
|
+
const IconComponent = icon ? _icons.ICON_MAP[icon] : null;
|
|
75
|
+
const a11yState = {
|
|
76
|
+
disabled,
|
|
77
|
+
...multiSelect ? {
|
|
78
|
+
checked: selected
|
|
79
|
+
} : {
|
|
80
|
+
selected
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const checkboxNode = /*#__PURE__*/ (0, _jsxruntime.jsx)(_vectoricons.Ionicons, {
|
|
84
|
+
name: selected ? 'checkbox' : 'square-outline',
|
|
85
|
+
size: 20,
|
|
86
|
+
color: selected ? cr.accent.primary.sysPrimary : cr.outline.sysOutline,
|
|
87
|
+
accessible: false
|
|
88
|
+
});
|
|
89
|
+
if (size === 'sm') {
|
|
90
|
+
const iconColor = selected ? cr.accent.primary.sysPrimary : cr.surface.surface.sysOnSurface;
|
|
91
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.Pressable, {
|
|
92
|
+
onPress: disabled ? undefined : onPress,
|
|
93
|
+
accessibilityRole: multiSelect ? 'checkbox' : 'radio',
|
|
94
|
+
accessibilityLabel: accessibilityLabel ?? title,
|
|
95
|
+
accessibilityState: a11yState,
|
|
96
|
+
style: ({ pressed })=>[
|
|
97
|
+
styles.smRoot,
|
|
98
|
+
{
|
|
99
|
+
gap: dim.spacing.padding.sysPadding12,
|
|
100
|
+
paddingHorizontal: dim.spacing.padding.sysPadding20,
|
|
101
|
+
paddingVertical: dim.spacing.padding.sysPadding16,
|
|
102
|
+
borderRadius: dim.borderRadius.sysRadiusMd,
|
|
103
|
+
backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerLowest,
|
|
104
|
+
borderColor: selected ? cr.accent.primary.sysPrimary : cr.outline.sysOutline,
|
|
105
|
+
borderWidth: selected ? dim.borderWidth.sysStrokeMedium : dim.borderWidth.sysStrokeThin,
|
|
106
|
+
opacity: disabled ? 0.38 : 1
|
|
107
|
+
},
|
|
108
|
+
selected && selectedRing,
|
|
109
|
+
pressed && !disabled && styles.pressed,
|
|
110
|
+
style
|
|
111
|
+
],
|
|
112
|
+
children: [
|
|
113
|
+
IconComponent && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
114
|
+
style: styles.smIconWrap,
|
|
115
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(IconComponent, {
|
|
116
|
+
size: "small",
|
|
117
|
+
color: iconColor
|
|
118
|
+
})
|
|
119
|
+
}),
|
|
120
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_BodyText.BodyText, {
|
|
121
|
+
variant: "labelLarge",
|
|
122
|
+
color: cr.surface.surface.sysOnSurface,
|
|
123
|
+
emphasized: selected,
|
|
124
|
+
style: styles.smTitle,
|
|
125
|
+
children: title
|
|
126
|
+
}),
|
|
127
|
+
multiSelect && checkboxNode
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// ── Medium ──────────────────────────────────────────────────────────────────
|
|
132
|
+
const iconBgColor = selected ? cr.accent.primary.sysPrimary : cr.surface.surfaceContainer.sysSurfaceContainer;
|
|
133
|
+
const iconColor = selected ? cr.accent.primary.sysOnPrimary : cr.surface.surface.sysOnSurface;
|
|
134
|
+
const titleColor = selected ? cr.accent.primary.sysPrimary : cr.surface.surface.sysOnSurface;
|
|
135
|
+
const iconCircle = IconComponent ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactnative.View, {
|
|
136
|
+
style: [
|
|
137
|
+
styles.mdIconCircle,
|
|
138
|
+
{
|
|
139
|
+
padding: dim.spacing.padding.sysPadding12,
|
|
140
|
+
borderRadius: dim.borderRadius.sysRadiusFull,
|
|
141
|
+
backgroundColor: iconBgColor
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(IconComponent, {
|
|
145
|
+
size: "small",
|
|
146
|
+
color: iconColor
|
|
147
|
+
})
|
|
148
|
+
}) : null;
|
|
149
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.Pressable, {
|
|
150
|
+
onPress: disabled ? undefined : onPress,
|
|
151
|
+
accessibilityRole: multiSelect ? 'checkbox' : 'radio',
|
|
152
|
+
accessibilityLabel: accessibilityLabel ?? title,
|
|
153
|
+
accessibilityState: a11yState,
|
|
154
|
+
style: ({ pressed })=>[
|
|
155
|
+
styles.mdRoot,
|
|
156
|
+
{
|
|
157
|
+
padding: dim.spacing.padding.sysPadding24,
|
|
158
|
+
gap: dim.spacing.padding.sysPadding24,
|
|
159
|
+
borderRadius: dim.borderRadius.sysRadiusLg,
|
|
160
|
+
backgroundColor: cr.surface.surfaceContainer.sysSurfaceContainerLowest,
|
|
161
|
+
borderColor: selected ? cr.accent.primary.sysPrimary : cr.outline.sysOutline,
|
|
162
|
+
borderWidth: selected ? dim.borderWidth.sysStrokeThick : dim.borderWidth.sysStrokeMedium,
|
|
163
|
+
opacity: disabled ? 0.38 : 1
|
|
164
|
+
},
|
|
165
|
+
selected && selectedRing,
|
|
166
|
+
pressed && !disabled && styles.pressed,
|
|
167
|
+
style
|
|
168
|
+
],
|
|
169
|
+
children: [
|
|
170
|
+
multiSelect ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactnative.View, {
|
|
171
|
+
style: styles.mdIconCheckboxRow,
|
|
172
|
+
children: [
|
|
173
|
+
iconCircle,
|
|
174
|
+
checkboxNode
|
|
175
|
+
]
|
|
176
|
+
}) : iconCircle,
|
|
177
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_HeaderText.HeaderText, {
|
|
178
|
+
variant: "titleSmall",
|
|
179
|
+
color: titleColor,
|
|
180
|
+
emphasized: selected,
|
|
181
|
+
children: title
|
|
182
|
+
})
|
|
183
|
+
]
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
const styles = _reactnative.StyleSheet.create({
|
|
187
|
+
mdRoot: {
|
|
188
|
+
flexDirection: 'column',
|
|
189
|
+
alignItems: 'flex-start',
|
|
190
|
+
overflow: 'hidden'
|
|
191
|
+
},
|
|
192
|
+
mdIconCircle: {
|
|
193
|
+
alignItems: 'center',
|
|
194
|
+
justifyContent: 'center',
|
|
195
|
+
overflow: 'hidden'
|
|
196
|
+
},
|
|
197
|
+
mdIconCheckboxRow: {
|
|
198
|
+
flexDirection: 'row',
|
|
199
|
+
alignItems: 'flex-start',
|
|
200
|
+
justifyContent: 'space-between',
|
|
201
|
+
width: '100%'
|
|
202
|
+
},
|
|
203
|
+
smRoot: {
|
|
204
|
+
flexDirection: 'row',
|
|
205
|
+
alignItems: 'center',
|
|
206
|
+
overflow: 'hidden'
|
|
207
|
+
},
|
|
208
|
+
smIconWrap: {
|
|
209
|
+
width: 24,
|
|
210
|
+
height: 24,
|
|
211
|
+
alignItems: 'center',
|
|
212
|
+
justifyContent: 'center'
|
|
213
|
+
},
|
|
214
|
+
smTitle: {
|
|
215
|
+
flex: 1
|
|
216
|
+
},
|
|
217
|
+
pressed: {
|
|
218
|
+
opacity: 0.84
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
//# sourceMappingURL=index.js.map
|