@onlynative/components 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +99 -0
  2. package/dist/appbar/index.d.ts +71 -0
  3. package/dist/appbar/index.js +952 -0
  4. package/dist/button/index.d.ts +41 -0
  5. package/dist/button/index.js +454 -0
  6. package/dist/card/index.d.ts +31 -0
  7. package/dist/card/index.js +264 -0
  8. package/dist/checkbox/index.d.ts +25 -0
  9. package/dist/checkbox/index.js +291 -0
  10. package/dist/chip/index.d.ts +62 -0
  11. package/dist/chip/index.js +452 -0
  12. package/dist/icon-button/index.d.ts +10 -0
  13. package/dist/icon-button/index.js +575 -0
  14. package/dist/index.d.ts +19 -0
  15. package/dist/index.js +3374 -0
  16. package/dist/layout/index.d.ts +98 -0
  17. package/dist/layout/index.js +282 -0
  18. package/dist/list/index.d.ts +60 -0
  19. package/dist/list/index.js +300 -0
  20. package/dist/radio/index.d.ts +25 -0
  21. package/dist/radio/index.js +250 -0
  22. package/dist/switch/index.d.ts +37 -0
  23. package/dist/switch/index.js +315 -0
  24. package/dist/text-field/index.d.ts +52 -0
  25. package/dist/text-field/index.js +496 -0
  26. package/dist/types-D3hlyvz-.d.ts +51 -0
  27. package/dist/typography/index.d.ts +28 -0
  28. package/dist/typography/index.js +69 -0
  29. package/package.json +166 -0
  30. package/src/appbar/AppBar.tsx +302 -0
  31. package/src/appbar/index.ts +2 -0
  32. package/src/appbar/styles.ts +92 -0
  33. package/src/appbar/types.ts +67 -0
  34. package/src/button/Button.tsx +130 -0
  35. package/src/button/index.ts +2 -0
  36. package/src/button/styles.ts +288 -0
  37. package/src/button/types.ts +42 -0
  38. package/src/card/Card.tsx +69 -0
  39. package/src/card/index.ts +2 -0
  40. package/src/card/styles.ts +151 -0
  41. package/src/card/types.ts +27 -0
  42. package/src/checkbox/Checkbox.tsx +109 -0
  43. package/src/checkbox/index.ts +2 -0
  44. package/src/checkbox/styles.ts +155 -0
  45. package/src/checkbox/types.ts +20 -0
  46. package/src/chip/Chip.tsx +182 -0
  47. package/src/chip/index.ts +2 -0
  48. package/src/chip/styles.ts +240 -0
  49. package/src/chip/types.ts +58 -0
  50. package/src/icon-button/IconButton.tsx +358 -0
  51. package/src/icon-button/index.ts +6 -0
  52. package/src/icon-button/styles.ts +259 -0
  53. package/src/icon-button/types.ts +55 -0
  54. package/src/index.ts +51 -0
  55. package/src/layout/Box.tsx +99 -0
  56. package/src/layout/Column.tsx +16 -0
  57. package/src/layout/Grid.tsx +49 -0
  58. package/src/layout/Layout.tsx +81 -0
  59. package/src/layout/Row.tsx +22 -0
  60. package/src/layout/index.ts +13 -0
  61. package/src/layout/resolveSpacing.ts +11 -0
  62. package/src/layout/types.ts +82 -0
  63. package/src/list/List.tsx +17 -0
  64. package/src/list/ListDivider.tsx +20 -0
  65. package/src/list/ListItem.tsx +128 -0
  66. package/src/list/index.ts +9 -0
  67. package/src/list/styles.ts +132 -0
  68. package/src/list/types.ts +54 -0
  69. package/src/radio/Radio.tsx +103 -0
  70. package/src/radio/index.ts +2 -0
  71. package/src/radio/styles.ts +139 -0
  72. package/src/radio/types.ts +20 -0
  73. package/src/switch/Switch.tsx +118 -0
  74. package/src/switch/index.ts +2 -0
  75. package/src/switch/styles.ts +172 -0
  76. package/src/switch/types.ts +32 -0
  77. package/src/test-utils/render-with-theme.tsx +13 -0
  78. package/src/text-field/TextField.tsx +298 -0
  79. package/src/text-field/index.ts +2 -0
  80. package/src/text-field/styles.ts +240 -0
  81. package/src/text-field/types.ts +49 -0
  82. package/src/typography/Typography.tsx +65 -0
  83. package/src/typography/index.ts +3 -0
  84. package/src/typography/types.ts +17 -0
  85. package/src/utils/color.ts +64 -0
  86. package/src/utils/elevation.ts +33 -0
  87. package/src/utils/rtl.ts +19 -0
@@ -0,0 +1,300 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/list/index.ts
21
+ var list_exports = {};
22
+ __export(list_exports, {
23
+ List: () => List,
24
+ ListDivider: () => ListDivider,
25
+ ListItem: () => ListItem
26
+ });
27
+ module.exports = __toCommonJS(list_exports);
28
+
29
+ // src/list/List.tsx
30
+ var import_react = require("react");
31
+ var import_react_native2 = require("react-native");
32
+ var import_core = require("@onlynative/core");
33
+
34
+ // src/list/styles.ts
35
+ var import_react_native = require("react-native");
36
+
37
+ // src/utils/color.ts
38
+ function parseHexColor(color) {
39
+ const normalized = color.replace("#", "");
40
+ if (normalized.length !== 6 && normalized.length !== 8) {
41
+ return null;
42
+ }
43
+ const r = Number.parseInt(normalized.slice(0, 2), 16);
44
+ const g = Number.parseInt(normalized.slice(2, 4), 16);
45
+ const b = Number.parseInt(normalized.slice(4, 6), 16);
46
+ if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
47
+ return null;
48
+ }
49
+ return { r, g, b };
50
+ }
51
+ function clampAlpha(alpha) {
52
+ return Math.max(0, Math.min(1, alpha));
53
+ }
54
+ function alphaColor(color, alpha) {
55
+ const channels = parseHexColor(color);
56
+ const boundedAlpha = clampAlpha(alpha);
57
+ if (!channels) {
58
+ return color;
59
+ }
60
+ return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
61
+ }
62
+ function blendColor(base, overlay, overlayAlpha) {
63
+ const baseChannels = parseHexColor(base);
64
+ const overlayChannels = parseHexColor(overlay);
65
+ const boundedAlpha = clampAlpha(overlayAlpha);
66
+ if (!baseChannels || !overlayChannels) {
67
+ return alphaColor(overlay, boundedAlpha);
68
+ }
69
+ const r = Math.round(
70
+ (1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
71
+ );
72
+ const g = Math.round(
73
+ (1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
74
+ );
75
+ const b = Math.round(
76
+ (1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
77
+ );
78
+ return `rgb(${r}, ${g}, ${b})`;
79
+ }
80
+
81
+ // src/list/styles.ts
82
+ var ITEM_PADDING_VERTICAL = 12;
83
+ var INSET_START = 56;
84
+ var MIN_HEIGHT = {
85
+ 1: 56,
86
+ 2: 72,
87
+ 3: 88
88
+ };
89
+ function createListStyles(theme) {
90
+ return import_react_native.StyleSheet.create({
91
+ container: {
92
+ paddingVertical: theme.spacing.sm
93
+ }
94
+ });
95
+ }
96
+ function getItemColors(theme, containerColor) {
97
+ const base = containerColor != null ? containerColor : "transparent";
98
+ if (containerColor) {
99
+ return {
100
+ backgroundColor: containerColor,
101
+ hoveredBackgroundColor: blendColor(
102
+ containerColor,
103
+ theme.colors.onSurface,
104
+ theme.stateLayer.hoveredOpacity
105
+ ),
106
+ pressedBackgroundColor: blendColor(
107
+ containerColor,
108
+ theme.colors.onSurface,
109
+ theme.stateLayer.pressedOpacity
110
+ )
111
+ };
112
+ }
113
+ return {
114
+ backgroundColor: base,
115
+ hoveredBackgroundColor: alphaColor(
116
+ theme.colors.onSurface,
117
+ theme.stateLayer.hoveredOpacity
118
+ ),
119
+ pressedBackgroundColor: alphaColor(
120
+ theme.colors.onSurface,
121
+ theme.stateLayer.pressedOpacity
122
+ )
123
+ };
124
+ }
125
+ function createListItemStyles(theme, lines, containerColor) {
126
+ const colors = getItemColors(theme, containerColor);
127
+ return import_react_native.StyleSheet.create({
128
+ container: {
129
+ flexDirection: "row",
130
+ alignItems: lines === 3 ? "flex-start" : "center",
131
+ minHeight: MIN_HEIGHT[lines],
132
+ paddingHorizontal: theme.spacing.md,
133
+ paddingVertical: ITEM_PADDING_VERTICAL,
134
+ backgroundColor: colors.backgroundColor
135
+ },
136
+ interactiveContainer: {
137
+ cursor: "pointer"
138
+ },
139
+ hoveredContainer: {
140
+ backgroundColor: colors.hoveredBackgroundColor
141
+ },
142
+ pressedContainer: {
143
+ backgroundColor: colors.pressedBackgroundColor
144
+ },
145
+ disabledContainer: {
146
+ cursor: "auto"
147
+ },
148
+ disabledContentWrapper: {
149
+ flexDirection: "row",
150
+ flex: 1,
151
+ opacity: theme.stateLayer.disabledOpacity
152
+ },
153
+ leadingContent: {
154
+ marginEnd: theme.spacing.md
155
+ },
156
+ textBlock: {
157
+ flex: 1
158
+ },
159
+ overlineText: {
160
+ ...theme.typography.labelSmall,
161
+ color: theme.colors.onSurfaceVariant
162
+ },
163
+ headlineText: {
164
+ ...theme.typography.bodyLarge,
165
+ color: theme.colors.onSurface
166
+ },
167
+ supportingText: {
168
+ ...theme.typography.bodyMedium,
169
+ color: theme.colors.onSurfaceVariant
170
+ },
171
+ trailingBlock: {
172
+ marginStart: theme.spacing.md,
173
+ alignItems: "flex-end"
174
+ },
175
+ trailingSupportingText: {
176
+ ...theme.typography.labelSmall,
177
+ color: theme.colors.onSurfaceVariant
178
+ }
179
+ });
180
+ }
181
+ function createDividerStyles(theme, inset) {
182
+ return import_react_native.StyleSheet.create({
183
+ divider: {
184
+ height: 1,
185
+ backgroundColor: theme.colors.outlineVariant,
186
+ ...inset ? { marginStart: INSET_START } : void 0
187
+ }
188
+ });
189
+ }
190
+
191
+ // src/list/List.tsx
192
+ var import_jsx_runtime = require("react/jsx-runtime");
193
+ function List({ children, style, ...props }) {
194
+ const theme = (0, import_core.useTheme)();
195
+ const styles = (0, import_react.useMemo)(() => createListStyles(theme), [theme]);
196
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { ...props, style: [styles.container, style], children });
197
+ }
198
+
199
+ // src/list/ListItem.tsx
200
+ var import_react2 = require("react");
201
+ var import_react_native3 = require("react-native");
202
+ var import_core2 = require("@onlynative/core");
203
+ var import_jsx_runtime2 = require("react/jsx-runtime");
204
+ function getLines(supportingText, overlineText, supportingTextNumberOfLines) {
205
+ if (supportingText && overlineText || supportingText && supportingTextNumberOfLines && supportingTextNumberOfLines > 1) {
206
+ return 3;
207
+ }
208
+ if (supportingText || overlineText) return 2;
209
+ return 1;
210
+ }
211
+ function ListItem({
212
+ headlineText,
213
+ supportingText,
214
+ overlineText,
215
+ trailingSupportingText,
216
+ leadingContent,
217
+ trailingContent,
218
+ onPress,
219
+ disabled = false,
220
+ containerColor,
221
+ supportingTextNumberOfLines = 1,
222
+ style,
223
+ ...props
224
+ }) {
225
+ const isDisabled = Boolean(disabled);
226
+ const isInteractive = onPress !== void 0;
227
+ const theme = (0, import_core2.useTheme)();
228
+ const lines = getLines(supportingText, overlineText, supportingTextNumberOfLines);
229
+ const styles = (0, import_react2.useMemo)(
230
+ () => createListItemStyles(theme, lines, containerColor),
231
+ [theme, lines, containerColor]
232
+ );
233
+ const content = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
234
+ leadingContent != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.View, { style: styles.leadingContent, children: leadingContent }),
235
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native3.View, { style: styles.textBlock, children: [
236
+ overlineText != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.Text, { style: styles.overlineText, numberOfLines: 1, children: overlineText }),
237
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.Text, { style: styles.headlineText, numberOfLines: 1, children: headlineText }),
238
+ supportingText != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
239
+ import_react_native3.Text,
240
+ {
241
+ style: styles.supportingText,
242
+ numberOfLines: supportingTextNumberOfLines,
243
+ children: supportingText
244
+ }
245
+ )
246
+ ] }),
247
+ (trailingContent != null || trailingSupportingText != null) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native3.View, { style: styles.trailingBlock, children: [
248
+ trailingSupportingText != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.Text, { style: styles.trailingSupportingText, numberOfLines: 1, children: trailingSupportingText }),
249
+ trailingContent
250
+ ] })
251
+ ] });
252
+ if (!isInteractive) {
253
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.View, { ...props, style: [styles.container, style], children: content });
254
+ }
255
+ const resolvedStyle = (state) => [
256
+ styles.container,
257
+ styles.interactiveContainer,
258
+ state.hovered && !state.pressed && !isDisabled ? styles.hoveredContainer : void 0,
259
+ state.pressed && !isDisabled ? styles.pressedContainer : void 0,
260
+ isDisabled ? styles.disabledContainer : void 0,
261
+ typeof style === "function" ? style(state) : style
262
+ ];
263
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
264
+ import_react_native3.Pressable,
265
+ {
266
+ ...props,
267
+ role: "button",
268
+ accessibilityState: { disabled: isDisabled },
269
+ hitSlop: import_react_native3.Platform.OS === "web" ? void 0 : 4,
270
+ disabled: isDisabled,
271
+ onPress,
272
+ style: resolvedStyle,
273
+ children: isDisabled ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.View, { style: styles.disabledContentWrapper, children: content }) : content
274
+ }
275
+ );
276
+ }
277
+
278
+ // src/list/ListDivider.tsx
279
+ var import_react3 = require("react");
280
+ var import_react_native4 = require("react-native");
281
+ var import_core3 = require("@onlynative/core");
282
+ var import_jsx_runtime3 = require("react/jsx-runtime");
283
+ function ListDivider({
284
+ inset = false,
285
+ style,
286
+ ...props
287
+ }) {
288
+ const theme = (0, import_core3.useTheme)();
289
+ const styles = (0, import_react3.useMemo)(
290
+ () => createDividerStyles(theme, inset),
291
+ [theme, inset]
292
+ );
293
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native4.View, { ...props, style: [styles.divider, style] });
294
+ }
295
+ // Annotate the CommonJS export names for ESM import in node:
296
+ 0 && (module.exports = {
297
+ List,
298
+ ListDivider,
299
+ ListItem
300
+ });
@@ -0,0 +1,25 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { PressableProps } from 'react-native';
3
+
4
+ interface RadioProps extends Omit<PressableProps, 'children'> {
5
+ /**
6
+ * Whether the radio button is selected.
7
+ * @default false
8
+ */
9
+ value?: boolean;
10
+ /** Callback fired when the radio is pressed. Receives the new value. */
11
+ onValueChange?: (value: boolean) => void;
12
+ /**
13
+ * Override the outer ring and inner dot color when selected.
14
+ * State-layer colors (hover, press) are derived automatically.
15
+ */
16
+ containerColor?: string;
17
+ /**
18
+ * Override the outer ring color when unselected.
19
+ */
20
+ contentColor?: string;
21
+ }
22
+
23
+ declare function Radio({ style, value, onValueChange, containerColor, contentColor, disabled, ...props }: RadioProps): react_jsx_runtime.JSX.Element;
24
+
25
+ export { Radio, type RadioProps };
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/radio/index.ts
21
+ var radio_exports = {};
22
+ __export(radio_exports, {
23
+ Radio: () => Radio
24
+ });
25
+ module.exports = __toCommonJS(radio_exports);
26
+
27
+ // src/radio/Radio.tsx
28
+ var import_react = require("react");
29
+ var import_react_native2 = require("react-native");
30
+ var import_core = require("@onlynative/core");
31
+
32
+ // src/radio/styles.ts
33
+ var import_react_native = require("react-native");
34
+
35
+ // src/utils/color.ts
36
+ function parseHexColor(color) {
37
+ const normalized = color.replace("#", "");
38
+ if (normalized.length !== 6 && normalized.length !== 8) {
39
+ return null;
40
+ }
41
+ const r = Number.parseInt(normalized.slice(0, 2), 16);
42
+ const g = Number.parseInt(normalized.slice(2, 4), 16);
43
+ const b = Number.parseInt(normalized.slice(4, 6), 16);
44
+ if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
45
+ return null;
46
+ }
47
+ return { r, g, b };
48
+ }
49
+ function clampAlpha(alpha) {
50
+ return Math.max(0, Math.min(1, alpha));
51
+ }
52
+ function alphaColor(color, alpha) {
53
+ const channels = parseHexColor(color);
54
+ const boundedAlpha = clampAlpha(alpha);
55
+ if (!channels) {
56
+ return color;
57
+ }
58
+ return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
59
+ }
60
+
61
+ // src/radio/styles.ts
62
+ function getColors(theme, selected) {
63
+ const disabledOnSurface38 = alphaColor(theme.colors.onSurface, 0.38);
64
+ if (selected) {
65
+ return {
66
+ borderColor: theme.colors.primary,
67
+ dotColor: theme.colors.primary,
68
+ hoveredBackgroundColor: alphaColor(
69
+ theme.colors.primary,
70
+ theme.stateLayer.hoveredOpacity
71
+ ),
72
+ pressedBackgroundColor: alphaColor(
73
+ theme.colors.primary,
74
+ theme.stateLayer.pressedOpacity
75
+ ),
76
+ disabledBorderColor: disabledOnSurface38,
77
+ disabledDotColor: disabledOnSurface38
78
+ };
79
+ }
80
+ return {
81
+ borderColor: theme.colors.onSurfaceVariant,
82
+ dotColor: "transparent",
83
+ hoveredBackgroundColor: alphaColor(
84
+ theme.colors.onSurface,
85
+ theme.stateLayer.hoveredOpacity
86
+ ),
87
+ pressedBackgroundColor: alphaColor(
88
+ theme.colors.onSurface,
89
+ theme.stateLayer.pressedOpacity
90
+ ),
91
+ disabledBorderColor: disabledOnSurface38,
92
+ disabledDotColor: "transparent"
93
+ };
94
+ }
95
+ function applyColorOverrides(theme, colors, containerColor, contentColor) {
96
+ if (!containerColor && !contentColor) return colors;
97
+ const result = { ...colors };
98
+ if (containerColor) {
99
+ result.borderColor = containerColor;
100
+ result.dotColor = containerColor;
101
+ result.hoveredBackgroundColor = alphaColor(
102
+ containerColor,
103
+ theme.stateLayer.hoveredOpacity
104
+ );
105
+ result.pressedBackgroundColor = alphaColor(
106
+ containerColor,
107
+ theme.stateLayer.pressedOpacity
108
+ );
109
+ }
110
+ if (contentColor) {
111
+ result.borderColor = contentColor;
112
+ }
113
+ return result;
114
+ }
115
+ function createStyles(theme, selected, containerColor, contentColor) {
116
+ const colors = applyColorOverrides(
117
+ theme,
118
+ getColors(theme, selected),
119
+ containerColor,
120
+ contentColor
121
+ );
122
+ const outerSize = 20;
123
+ const innerSize = 10;
124
+ const touchTarget = 48;
125
+ return import_react_native.StyleSheet.create({
126
+ container: {
127
+ width: touchTarget,
128
+ height: touchTarget,
129
+ alignItems: "center",
130
+ justifyContent: "center",
131
+ cursor: "pointer"
132
+ },
133
+ hoveredContainer: {
134
+ borderRadius: touchTarget / 2,
135
+ backgroundColor: colors.hoveredBackgroundColor
136
+ },
137
+ pressedContainer: {
138
+ borderRadius: touchTarget / 2,
139
+ backgroundColor: colors.pressedBackgroundColor
140
+ },
141
+ disabledContainer: {
142
+ cursor: "auto"
143
+ },
144
+ outer: {
145
+ width: outerSize,
146
+ height: outerSize,
147
+ borderRadius: outerSize / 2,
148
+ borderWidth: 2,
149
+ borderColor: colors.borderColor,
150
+ alignItems: "center",
151
+ justifyContent: "center"
152
+ },
153
+ disabledOuter: {
154
+ borderColor: colors.disabledBorderColor
155
+ },
156
+ inner: {
157
+ width: innerSize,
158
+ height: innerSize,
159
+ borderRadius: innerSize / 2,
160
+ backgroundColor: colors.dotColor
161
+ },
162
+ disabledInner: {
163
+ backgroundColor: colors.disabledDotColor
164
+ }
165
+ });
166
+ }
167
+
168
+ // src/radio/Radio.tsx
169
+ var import_jsx_runtime = require("react/jsx-runtime");
170
+ function resolveStyle(containerStyle, hoveredContainerStyle, pressedContainerStyle, disabledContainerStyle, disabled, style) {
171
+ if (typeof style === "function") {
172
+ return (state) => [
173
+ containerStyle,
174
+ state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
175
+ state.pressed && !disabled ? pressedContainerStyle : void 0,
176
+ disabled ? disabledContainerStyle : void 0,
177
+ style(state)
178
+ ];
179
+ }
180
+ return (state) => [
181
+ containerStyle,
182
+ state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
183
+ state.pressed && !disabled ? pressedContainerStyle : void 0,
184
+ disabled ? disabledContainerStyle : void 0,
185
+ style
186
+ ];
187
+ }
188
+ function Radio({
189
+ style,
190
+ value = false,
191
+ onValueChange,
192
+ containerColor,
193
+ contentColor,
194
+ disabled = false,
195
+ ...props
196
+ }) {
197
+ const isDisabled = Boolean(disabled);
198
+ const isSelected = Boolean(value);
199
+ const theme = (0, import_core.useTheme)();
200
+ const styles = (0, import_react.useMemo)(
201
+ () => createStyles(theme, isSelected, containerColor, contentColor),
202
+ [theme, isSelected, containerColor, contentColor]
203
+ );
204
+ const handlePress = () => {
205
+ if (!isDisabled) {
206
+ onValueChange == null ? void 0 : onValueChange(!isSelected);
207
+ }
208
+ };
209
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
210
+ import_react_native2.Pressable,
211
+ {
212
+ ...props,
213
+ accessibilityRole: "radio",
214
+ accessibilityState: {
215
+ disabled: isDisabled,
216
+ checked: isSelected
217
+ },
218
+ hitSlop: import_react_native2.Platform.OS === "web" ? void 0 : 4,
219
+ disabled: isDisabled,
220
+ onPress: handlePress,
221
+ style: resolveStyle(
222
+ styles.container,
223
+ styles.hoveredContainer,
224
+ styles.pressedContainer,
225
+ styles.disabledContainer,
226
+ isDisabled,
227
+ style
228
+ ),
229
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
230
+ import_react_native2.View,
231
+ {
232
+ style: [styles.outer, isDisabled ? styles.disabledOuter : void 0],
233
+ children: isSelected ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
234
+ import_react_native2.View,
235
+ {
236
+ style: [
237
+ styles.inner,
238
+ isDisabled ? styles.disabledInner : void 0
239
+ ]
240
+ }
241
+ ) : null
242
+ }
243
+ )
244
+ }
245
+ );
246
+ }
247
+ // Annotate the CommonJS export names for ESM import in node:
248
+ 0 && (module.exports = {
249
+ Radio
250
+ });
@@ -0,0 +1,37 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons';
3
+ import { ComponentProps } from 'react';
4
+ import { PressableProps } from 'react-native';
5
+
6
+ interface SwitchProps extends Omit<PressableProps, 'children'> {
7
+ /**
8
+ * Whether the switch is toggled on.
9
+ * @default false
10
+ */
11
+ value?: boolean;
12
+ /** Callback fired when the switch is toggled. Receives the new value. */
13
+ onValueChange?: (value: boolean) => void;
14
+ /**
15
+ * Name of a MaterialCommunityIcons icon to show on the thumb when selected.
16
+ * @default 'check'
17
+ */
18
+ selectedIcon?: ComponentProps<typeof MaterialCommunityIcons>['name'];
19
+ /**
20
+ * Name of a MaterialCommunityIcons icon to show on the thumb when unselected.
21
+ * When provided, the thumb renders at the larger selected size.
22
+ */
23
+ unselectedIcon?: ComponentProps<typeof MaterialCommunityIcons>['name'];
24
+ /**
25
+ * Override the track color.
26
+ * State-layer colors (hover, press) are derived automatically.
27
+ */
28
+ containerColor?: string;
29
+ /**
30
+ * Override the thumb and icon color.
31
+ */
32
+ contentColor?: string;
33
+ }
34
+
35
+ declare function Switch({ style, value, onValueChange, selectedIcon, unselectedIcon, containerColor, contentColor, disabled, ...props }: SwitchProps): react_jsx_runtime.JSX.Element;
36
+
37
+ export { Switch, type SwitchProps };