@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,264 @@
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/card/index.ts
21
+ var card_exports = {};
22
+ __export(card_exports, {
23
+ Card: () => Card
24
+ });
25
+ module.exports = __toCommonJS(card_exports);
26
+
27
+ // src/card/Card.tsx
28
+ var import_react = require("react");
29
+ var import_react_native3 = require("react-native");
30
+ var import_core = require("@onlynative/core");
31
+
32
+ // src/card/styles.ts
33
+ var import_react_native2 = 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
+ function blendColor(base, overlay, overlayAlpha) {
61
+ const baseChannels = parseHexColor(base);
62
+ const overlayChannels = parseHexColor(overlay);
63
+ const boundedAlpha = clampAlpha(overlayAlpha);
64
+ if (!baseChannels || !overlayChannels) {
65
+ return alphaColor(overlay, boundedAlpha);
66
+ }
67
+ const r = Math.round(
68
+ (1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
69
+ );
70
+ const g = Math.round(
71
+ (1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
72
+ );
73
+ const b = Math.round(
74
+ (1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
75
+ );
76
+ return `rgb(${r}, ${g}, ${b})`;
77
+ }
78
+
79
+ // src/utils/elevation.ts
80
+ var import_react_native = require("react-native");
81
+ function elevationStyle(level) {
82
+ if (import_react_native.Platform.OS === "web") {
83
+ const { shadowOffset, shadowOpacity, shadowRadius } = level;
84
+ if (shadowOpacity === 0) {
85
+ return { boxShadow: "none" };
86
+ }
87
+ return {
88
+ boxShadow: `${shadowOffset.width}px ${shadowOffset.height}px ${shadowRadius}px rgba(0, 0, 0, ${shadowOpacity})`
89
+ };
90
+ }
91
+ return {
92
+ shadowColor: level.shadowColor,
93
+ shadowOffset: {
94
+ width: level.shadowOffset.width,
95
+ height: level.shadowOffset.height
96
+ },
97
+ shadowOpacity: level.shadowOpacity,
98
+ shadowRadius: level.shadowRadius,
99
+ elevation: level.elevation
100
+ };
101
+ }
102
+
103
+ // src/card/styles.ts
104
+ function getVariantColors(theme, variant) {
105
+ const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
106
+ const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
107
+ if (variant === "outlined") {
108
+ return {
109
+ backgroundColor: theme.colors.surface,
110
+ borderColor: theme.colors.outline,
111
+ borderWidth: 1,
112
+ hoveredBackgroundColor: alphaColor(
113
+ theme.colors.onSurface,
114
+ theme.stateLayer.hoveredOpacity
115
+ ),
116
+ pressedBackgroundColor: alphaColor(
117
+ theme.colors.onSurface,
118
+ theme.stateLayer.pressedOpacity
119
+ ),
120
+ disabledBackgroundColor: theme.colors.surface,
121
+ disabledBorderColor: disabledOutlineColor
122
+ };
123
+ }
124
+ if (variant === "filled") {
125
+ return {
126
+ backgroundColor: theme.colors.surfaceContainerHighest,
127
+ borderColor: "transparent",
128
+ borderWidth: 0,
129
+ hoveredBackgroundColor: blendColor(
130
+ theme.colors.surfaceContainerHighest,
131
+ theme.colors.onSurface,
132
+ theme.stateLayer.hoveredOpacity
133
+ ),
134
+ pressedBackgroundColor: blendColor(
135
+ theme.colors.surfaceContainerHighest,
136
+ theme.colors.onSurface,
137
+ theme.stateLayer.pressedOpacity
138
+ ),
139
+ disabledBackgroundColor: disabledContainerColor,
140
+ disabledBorderColor: "transparent"
141
+ };
142
+ }
143
+ return {
144
+ backgroundColor: theme.colors.surface,
145
+ borderColor: "transparent",
146
+ borderWidth: 0,
147
+ hoveredBackgroundColor: blendColor(
148
+ theme.colors.surface,
149
+ theme.colors.onSurface,
150
+ theme.stateLayer.hoveredOpacity
151
+ ),
152
+ pressedBackgroundColor: blendColor(
153
+ theme.colors.surface,
154
+ theme.colors.onSurface,
155
+ theme.stateLayer.pressedOpacity
156
+ ),
157
+ disabledBackgroundColor: disabledContainerColor,
158
+ disabledBorderColor: "transparent"
159
+ };
160
+ }
161
+ function applyColorOverrides(theme, colors, containerColor) {
162
+ if (!containerColor) return colors;
163
+ return {
164
+ ...colors,
165
+ backgroundColor: containerColor,
166
+ borderColor: containerColor,
167
+ borderWidth: 0,
168
+ hoveredBackgroundColor: blendColor(
169
+ containerColor,
170
+ theme.colors.onSurface,
171
+ theme.stateLayer.hoveredOpacity
172
+ ),
173
+ pressedBackgroundColor: blendColor(
174
+ containerColor,
175
+ theme.colors.onSurface,
176
+ theme.stateLayer.pressedOpacity
177
+ )
178
+ };
179
+ }
180
+ function createStyles(theme, variant, containerColor) {
181
+ const baseColors = getVariantColors(theme, variant);
182
+ const colors = applyColorOverrides(theme, baseColors, containerColor);
183
+ const elevationLevel0 = elevationStyle(theme.elevation.level0);
184
+ const elevationLevel1 = elevationStyle(theme.elevation.level1);
185
+ const elevationLevel2 = elevationStyle(theme.elevation.level2);
186
+ const baseElevation = variant === "elevated" ? elevationLevel1 : elevationLevel0;
187
+ return import_react_native2.StyleSheet.create({
188
+ container: {
189
+ borderRadius: theme.shape.cornerMedium,
190
+ backgroundColor: colors.backgroundColor,
191
+ borderColor: colors.borderColor,
192
+ borderWidth: colors.borderWidth,
193
+ overflow: "hidden",
194
+ ...baseElevation
195
+ },
196
+ interactiveContainer: {
197
+ cursor: "pointer"
198
+ },
199
+ hoveredContainer: {
200
+ backgroundColor: colors.hoveredBackgroundColor,
201
+ ...variant === "elevated" ? elevationLevel2 : variant === "filled" ? elevationLevel1 : void 0
202
+ },
203
+ pressedContainer: {
204
+ backgroundColor: colors.pressedBackgroundColor
205
+ },
206
+ disabledContainer: {
207
+ backgroundColor: colors.disabledBackgroundColor,
208
+ borderColor: colors.disabledBorderColor,
209
+ cursor: "auto",
210
+ ...elevationLevel0
211
+ },
212
+ disabledContent: {
213
+ opacity: theme.stateLayer.disabledOpacity
214
+ }
215
+ });
216
+ }
217
+
218
+ // src/card/Card.tsx
219
+ var import_jsx_runtime = require("react/jsx-runtime");
220
+ function Card({
221
+ children,
222
+ style,
223
+ variant = "elevated",
224
+ onPress,
225
+ disabled = false,
226
+ containerColor,
227
+ ...props
228
+ }) {
229
+ const isDisabled = Boolean(disabled);
230
+ const isInteractive = onPress !== void 0;
231
+ const theme = (0, import_core.useTheme)();
232
+ const styles = (0, import_react.useMemo)(
233
+ () => createStyles(theme, variant, containerColor),
234
+ [theme, variant, containerColor]
235
+ );
236
+ if (!isInteractive) {
237
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native3.View, { ...props, style: [styles.container, style], children });
238
+ }
239
+ const resolvedStyle = (state) => [
240
+ styles.container,
241
+ styles.interactiveContainer,
242
+ state.hovered && !state.pressed && !isDisabled ? styles.hoveredContainer : void 0,
243
+ state.pressed && !isDisabled ? styles.pressedContainer : void 0,
244
+ isDisabled ? styles.disabledContainer : void 0,
245
+ typeof style === "function" ? style(state) : style
246
+ ];
247
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
248
+ import_react_native3.Pressable,
249
+ {
250
+ ...props,
251
+ role: "button",
252
+ accessibilityState: { disabled: isDisabled },
253
+ hitSlop: import_react_native3.Platform.OS === "web" ? void 0 : 4,
254
+ disabled: isDisabled,
255
+ onPress,
256
+ style: resolvedStyle,
257
+ children: isDisabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native3.View, { style: styles.disabledContent, children }) : children
258
+ }
259
+ );
260
+ }
261
+ // Annotate the CommonJS export names for ESM import in node:
262
+ 0 && (module.exports = {
263
+ Card
264
+ });
@@ -0,0 +1,25 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { PressableProps } from 'react-native';
3
+
4
+ interface CheckboxProps extends Omit<PressableProps, 'children'> {
5
+ /**
6
+ * Whether the checkbox is checked.
7
+ * @default false
8
+ */
9
+ value?: boolean;
10
+ /** Callback fired when the checkbox is toggled. Receives the new value. */
11
+ onValueChange?: (value: boolean) => void;
12
+ /**
13
+ * Override the container (box) color when checked.
14
+ * State-layer colors (hover, press) are derived automatically.
15
+ */
16
+ containerColor?: string;
17
+ /**
18
+ * Override the checkmark icon color.
19
+ */
20
+ contentColor?: string;
21
+ }
22
+
23
+ declare function Checkbox({ style, value, onValueChange, containerColor, contentColor, disabled, ...props }: CheckboxProps): react_jsx_runtime.JSX.Element;
24
+
25
+ export { Checkbox, type CheckboxProps };
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/checkbox/index.ts
31
+ var checkbox_exports = {};
32
+ __export(checkbox_exports, {
33
+ Checkbox: () => Checkbox
34
+ });
35
+ module.exports = __toCommonJS(checkbox_exports);
36
+
37
+ // src/checkbox/Checkbox.tsx
38
+ var import_MaterialCommunityIcons = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
39
+ var import_react = require("react");
40
+ var import_react_native2 = require("react-native");
41
+ var import_core = require("@onlynative/core");
42
+
43
+ // src/checkbox/styles.ts
44
+ var import_react_native = require("react-native");
45
+
46
+ // src/utils/color.ts
47
+ function parseHexColor(color) {
48
+ const normalized = color.replace("#", "");
49
+ if (normalized.length !== 6 && normalized.length !== 8) {
50
+ return null;
51
+ }
52
+ const r = Number.parseInt(normalized.slice(0, 2), 16);
53
+ const g = Number.parseInt(normalized.slice(2, 4), 16);
54
+ const b = Number.parseInt(normalized.slice(4, 6), 16);
55
+ if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
56
+ return null;
57
+ }
58
+ return { r, g, b };
59
+ }
60
+ function clampAlpha(alpha) {
61
+ return Math.max(0, Math.min(1, alpha));
62
+ }
63
+ function alphaColor(color, alpha) {
64
+ const channels = parseHexColor(color);
65
+ const boundedAlpha = clampAlpha(alpha);
66
+ if (!channels) {
67
+ return color;
68
+ }
69
+ return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
70
+ }
71
+ function blendColor(base, overlay, overlayAlpha) {
72
+ const baseChannels = parseHexColor(base);
73
+ const overlayChannels = parseHexColor(overlay);
74
+ const boundedAlpha = clampAlpha(overlayAlpha);
75
+ if (!baseChannels || !overlayChannels) {
76
+ return alphaColor(overlay, boundedAlpha);
77
+ }
78
+ const r = Math.round(
79
+ (1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
80
+ );
81
+ const g = Math.round(
82
+ (1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
83
+ );
84
+ const b = Math.round(
85
+ (1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
86
+ );
87
+ return `rgb(${r}, ${g}, ${b})`;
88
+ }
89
+
90
+ // src/checkbox/styles.ts
91
+ function getColors(theme, checked) {
92
+ const disabledOnSurface38 = alphaColor(theme.colors.onSurface, 0.38);
93
+ if (checked) {
94
+ return {
95
+ backgroundColor: theme.colors.primary,
96
+ borderColor: "transparent",
97
+ borderWidth: 0,
98
+ iconColor: theme.colors.onPrimary,
99
+ hoveredBackgroundColor: blendColor(
100
+ theme.colors.primary,
101
+ theme.colors.onPrimary,
102
+ theme.stateLayer.hoveredOpacity
103
+ ),
104
+ pressedBackgroundColor: blendColor(
105
+ theme.colors.primary,
106
+ theme.colors.onPrimary,
107
+ theme.stateLayer.pressedOpacity
108
+ ),
109
+ disabledBackgroundColor: disabledOnSurface38,
110
+ disabledBorderColor: "transparent",
111
+ disabledBorderWidth: 0,
112
+ disabledIconColor: theme.colors.surface
113
+ };
114
+ }
115
+ return {
116
+ backgroundColor: "transparent",
117
+ borderColor: theme.colors.onSurfaceVariant,
118
+ borderWidth: 2,
119
+ iconColor: "transparent",
120
+ hoveredBackgroundColor: alphaColor(
121
+ theme.colors.onSurface,
122
+ theme.stateLayer.hoveredOpacity
123
+ ),
124
+ pressedBackgroundColor: alphaColor(
125
+ theme.colors.onSurface,
126
+ theme.stateLayer.pressedOpacity
127
+ ),
128
+ disabledBackgroundColor: "transparent",
129
+ disabledBorderColor: disabledOnSurface38,
130
+ disabledBorderWidth: 2,
131
+ disabledIconColor: "transparent"
132
+ };
133
+ }
134
+ function applyColorOverrides(theme, colors, containerColor, contentColor) {
135
+ if (!containerColor && !contentColor) return colors;
136
+ const result = { ...colors };
137
+ if (contentColor) {
138
+ result.iconColor = contentColor;
139
+ }
140
+ if (containerColor) {
141
+ const overlay = contentColor != null ? contentColor : colors.iconColor;
142
+ result.backgroundColor = containerColor;
143
+ result.borderColor = containerColor;
144
+ result.hoveredBackgroundColor = blendColor(
145
+ containerColor,
146
+ overlay,
147
+ theme.stateLayer.hoveredOpacity
148
+ );
149
+ result.pressedBackgroundColor = blendColor(
150
+ containerColor,
151
+ overlay,
152
+ theme.stateLayer.pressedOpacity
153
+ );
154
+ }
155
+ return result;
156
+ }
157
+ function createStyles(theme, checked, containerColor, contentColor) {
158
+ const colors = applyColorOverrides(
159
+ theme,
160
+ getColors(theme, checked),
161
+ containerColor,
162
+ contentColor
163
+ );
164
+ const size = 18;
165
+ const touchTarget = 48;
166
+ return import_react_native.StyleSheet.create({
167
+ container: {
168
+ width: touchTarget,
169
+ height: touchTarget,
170
+ alignItems: "center",
171
+ justifyContent: "center",
172
+ cursor: "pointer"
173
+ },
174
+ hoveredContainer: {
175
+ borderRadius: touchTarget / 2,
176
+ backgroundColor: colors.hoveredBackgroundColor
177
+ },
178
+ pressedContainer: {
179
+ borderRadius: touchTarget / 2,
180
+ backgroundColor: colors.pressedBackgroundColor
181
+ },
182
+ disabledContainer: {
183
+ cursor: "auto"
184
+ },
185
+ box: {
186
+ width: size,
187
+ height: size,
188
+ borderRadius: theme.shape.cornerExtraSmall,
189
+ backgroundColor: colors.backgroundColor,
190
+ borderColor: colors.borderColor,
191
+ borderWidth: colors.borderWidth,
192
+ alignItems: "center",
193
+ justifyContent: "center"
194
+ },
195
+ disabledBox: {
196
+ backgroundColor: colors.disabledBackgroundColor,
197
+ borderColor: colors.disabledBorderColor,
198
+ borderWidth: colors.disabledBorderWidth
199
+ },
200
+ iconColor: {
201
+ color: colors.iconColor
202
+ },
203
+ disabledIconColor: {
204
+ color: colors.disabledIconColor
205
+ }
206
+ });
207
+ }
208
+
209
+ // src/checkbox/Checkbox.tsx
210
+ var import_jsx_runtime = require("react/jsx-runtime");
211
+ function resolveStyle(containerStyle, hoveredContainerStyle, pressedContainerStyle, disabledContainerStyle, disabled, style) {
212
+ if (typeof style === "function") {
213
+ return (state) => [
214
+ containerStyle,
215
+ state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
216
+ state.pressed && !disabled ? pressedContainerStyle : void 0,
217
+ disabled ? disabledContainerStyle : void 0,
218
+ style(state)
219
+ ];
220
+ }
221
+ return (state) => [
222
+ containerStyle,
223
+ state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
224
+ state.pressed && !disabled ? pressedContainerStyle : void 0,
225
+ disabled ? disabledContainerStyle : void 0,
226
+ style
227
+ ];
228
+ }
229
+ function Checkbox({
230
+ style,
231
+ value = false,
232
+ onValueChange,
233
+ containerColor,
234
+ contentColor,
235
+ disabled = false,
236
+ ...props
237
+ }) {
238
+ const isDisabled = Boolean(disabled);
239
+ const isChecked = Boolean(value);
240
+ const theme = (0, import_core.useTheme)();
241
+ const styles = (0, import_react.useMemo)(
242
+ () => createStyles(theme, isChecked, containerColor, contentColor),
243
+ [theme, isChecked, containerColor, contentColor]
244
+ );
245
+ const resolvedIconColor = (0, import_react.useMemo)(() => {
246
+ const base = import_react_native2.StyleSheet.flatten([
247
+ styles.iconColor,
248
+ isDisabled ? styles.disabledIconColor : void 0
249
+ ]);
250
+ return typeof (base == null ? void 0 : base.color) === "string" ? base.color : void 0;
251
+ }, [styles.iconColor, styles.disabledIconColor, isDisabled]);
252
+ const handlePress = () => {
253
+ if (!isDisabled) {
254
+ onValueChange == null ? void 0 : onValueChange(!isChecked);
255
+ }
256
+ };
257
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
258
+ import_react_native2.Pressable,
259
+ {
260
+ ...props,
261
+ accessibilityRole: "checkbox",
262
+ accessibilityState: {
263
+ disabled: isDisabled,
264
+ checked: isChecked
265
+ },
266
+ hitSlop: import_react_native2.Platform.OS === "web" ? void 0 : 4,
267
+ disabled: isDisabled,
268
+ onPress: handlePress,
269
+ style: resolveStyle(
270
+ styles.container,
271
+ styles.hoveredContainer,
272
+ styles.pressedContainer,
273
+ styles.disabledContainer,
274
+ isDisabled,
275
+ style
276
+ ),
277
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.box, isDisabled ? styles.disabledBox : void 0], children: isChecked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
278
+ import_MaterialCommunityIcons.default,
279
+ {
280
+ name: "check",
281
+ size: 14,
282
+ color: resolvedIconColor
283
+ }
284
+ ) : null })
285
+ }
286
+ );
287
+ }
288
+ // Annotate the CommonJS export names for ESM import in node:
289
+ 0 && (module.exports = {
290
+ Checkbox
291
+ });
@@ -0,0 +1,62 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons';
3
+ import { ComponentProps, ReactNode } from 'react';
4
+ import { PressableProps, StyleProp, TextStyle } from 'react-native';
5
+
6
+ /** Visual variant of the chip following Material Design 3 chip types. */
7
+ type ChipVariant = 'assist' | 'filter' | 'input' | 'suggestion';
8
+ interface ChipProps extends Omit<PressableProps, 'children'> {
9
+ /** Text label rendered inside the chip. */
10
+ children: string;
11
+ /**
12
+ * Chip type variant. Controls appearance, allowed interactions, and icon behavior.
13
+ * @default 'assist'
14
+ */
15
+ variant?: ChipVariant;
16
+ /**
17
+ * Whether the chip uses an elevated surface instead of an outline border.
18
+ * Available on `assist`, `filter`, and `suggestion` variants.
19
+ * Ignored on `input` variant (always outlined).
20
+ * @default false
21
+ */
22
+ elevated?: boolean;
23
+ /**
24
+ * Whether the chip is in a selected (toggled-on) state.
25
+ * Only meaningful for the `filter` variant. Ignored by other variants.
26
+ */
27
+ selected?: boolean;
28
+ /** Name of a MaterialCommunityIcons icon to show before the label. */
29
+ leadingIcon?: ComponentProps<typeof MaterialCommunityIcons>['name'];
30
+ /**
31
+ * Size of the leading icon in dp.
32
+ * @default 18
33
+ */
34
+ iconSize?: number;
35
+ /**
36
+ * Custom avatar content (e.g. a small Image or View) to render before the label.
37
+ * Only applicable to the `input` variant. Takes precedence over `leadingIcon`.
38
+ */
39
+ avatar?: ReactNode;
40
+ /**
41
+ * Callback fired when the close/remove icon is pressed.
42
+ * When provided, renders a trailing close icon.
43
+ * Only renders on `input` and `filter` (when selected) variants.
44
+ */
45
+ onClose?: () => void;
46
+ /**
47
+ * Override the container (background) color.
48
+ * State-layer colors (hover, press) are derived automatically.
49
+ */
50
+ containerColor?: string;
51
+ /**
52
+ * Override the content (label and icon) color.
53
+ * State-layer colors are derived automatically when no containerColor is set.
54
+ */
55
+ contentColor?: string;
56
+ /** Additional style applied to the label text. */
57
+ labelStyle?: StyleProp<TextStyle>;
58
+ }
59
+
60
+ declare function Chip({ children, style, variant, elevated, selected, leadingIcon, iconSize, avatar, onClose, containerColor, contentColor, labelStyle: labelStyleOverride, disabled, ...props }: ChipProps): react_jsx_runtime.JSX.Element;
61
+
62
+ export { Chip, type ChipProps, type ChipVariant };