@onlynative/components 0.0.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.
- package/README.md +105 -0
- package/dist/appbar/index.d.ts +90 -0
- package/dist/appbar/index.js +1030 -0
- package/dist/avatar/index.d.ts +46 -0
- package/dist/avatar/index.js +250 -0
- package/dist/button/index.d.ts +41 -0
- package/dist/button/index.js +468 -0
- package/dist/card/index.d.ts +31 -0
- package/dist/card/index.js +263 -0
- package/dist/checkbox/index.d.ts +25 -0
- package/dist/checkbox/index.js +308 -0
- package/dist/chip/index.d.ts +62 -0
- package/dist/chip/index.js +467 -0
- package/dist/icon-button/index.d.ts +10 -0
- package/dist/icon-button/index.js +592 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +3681 -0
- package/dist/keyboard-avoiding-wrapper/index.d.ts +36 -0
- package/dist/keyboard-avoiding-wrapper/index.js +98 -0
- package/dist/layout/index.d.ts +98 -0
- package/dist/layout/index.js +282 -0
- package/dist/list/index.d.ts +60 -0
- package/dist/list/index.js +302 -0
- package/dist/radio/index.d.ts +25 -0
- package/dist/radio/index.js +252 -0
- package/dist/switch/index.d.ts +37 -0
- package/dist/switch/index.js +332 -0
- package/dist/text-field/index.d.ts +52 -0
- package/dist/text-field/index.js +510 -0
- package/dist/types-D3hlyvz-.d.ts +51 -0
- package/dist/typography/index.d.ts +28 -0
- package/dist/typography/index.js +78 -0
- package/llms.txt +458 -0
- package/package.json +202 -0
|
@@ -0,0 +1,468 @@
|
|
|
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/button/index.ts
|
|
21
|
+
var button_exports = {};
|
|
22
|
+
__export(button_exports, {
|
|
23
|
+
Button: () => Button
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(button_exports);
|
|
26
|
+
|
|
27
|
+
// src/button/Button.tsx
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_react_native4 = require("react-native");
|
|
30
|
+
var import_react_native5 = require("react-native");
|
|
31
|
+
var import_react_native6 = require("react-native");
|
|
32
|
+
var import_core = require("@onlynative/core");
|
|
33
|
+
|
|
34
|
+
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
35
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
36
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
37
|
+
}) : x)(function(x) {
|
|
38
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
39
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// ../utils/dist/index.mjs
|
|
43
|
+
var import_react_native = require("react-native");
|
|
44
|
+
var import_react_native2 = require("react-native");
|
|
45
|
+
function parseHexColor(color) {
|
|
46
|
+
const normalized = color.replace("#", "");
|
|
47
|
+
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const r = Number.parseInt(normalized.slice(0, 2), 16);
|
|
51
|
+
const g = Number.parseInt(normalized.slice(2, 4), 16);
|
|
52
|
+
const b = Number.parseInt(normalized.slice(4, 6), 16);
|
|
53
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return { r, g, b };
|
|
57
|
+
}
|
|
58
|
+
function clampAlpha(alpha) {
|
|
59
|
+
return Math.max(0, Math.min(1, alpha));
|
|
60
|
+
}
|
|
61
|
+
function alphaColor(color, alpha) {
|
|
62
|
+
const channels = parseHexColor(color);
|
|
63
|
+
const boundedAlpha = clampAlpha(alpha);
|
|
64
|
+
if (!channels) {
|
|
65
|
+
return color;
|
|
66
|
+
}
|
|
67
|
+
return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
|
|
68
|
+
}
|
|
69
|
+
function blendColor(base, overlay, overlayAlpha) {
|
|
70
|
+
const baseChannels = parseHexColor(base);
|
|
71
|
+
const overlayChannels = parseHexColor(overlay);
|
|
72
|
+
const boundedAlpha = clampAlpha(overlayAlpha);
|
|
73
|
+
if (!baseChannels || !overlayChannels) {
|
|
74
|
+
return alphaColor(overlay, boundedAlpha);
|
|
75
|
+
}
|
|
76
|
+
const r = Math.round(
|
|
77
|
+
(1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
|
|
78
|
+
);
|
|
79
|
+
const g = Math.round(
|
|
80
|
+
(1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
|
|
81
|
+
);
|
|
82
|
+
const b = Math.round(
|
|
83
|
+
(1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
|
|
84
|
+
);
|
|
85
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
86
|
+
}
|
|
87
|
+
function elevationStyle(level) {
|
|
88
|
+
if (import_react_native.Platform.OS === "web") {
|
|
89
|
+
const { shadowOffset, shadowOpacity, shadowRadius } = level;
|
|
90
|
+
if (shadowOpacity === 0) {
|
|
91
|
+
return { boxShadow: "none" };
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
boxShadow: `${shadowOffset.width}px ${shadowOffset.height}px ${shadowRadius}px rgba(0, 0, 0, ${shadowOpacity})`
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
shadowColor: level.shadowColor,
|
|
99
|
+
shadowOffset: {
|
|
100
|
+
width: level.shadowOffset.width,
|
|
101
|
+
height: level.shadowOffset.height
|
|
102
|
+
},
|
|
103
|
+
shadowOpacity: level.shadowOpacity,
|
|
104
|
+
shadowRadius: level.shadowRadius,
|
|
105
|
+
elevation: level.elevation
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
var _MCIcons = null;
|
|
109
|
+
var _resolved = false;
|
|
110
|
+
function getMaterialCommunityIcons() {
|
|
111
|
+
if (!_resolved) {
|
|
112
|
+
_resolved = true;
|
|
113
|
+
try {
|
|
114
|
+
const mod = __require("@expo/vector-icons/MaterialCommunityIcons");
|
|
115
|
+
_MCIcons = mod.default || mod;
|
|
116
|
+
} catch {
|
|
117
|
+
_MCIcons = null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (!_MCIcons) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return _MCIcons;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// src/button/styles.ts
|
|
129
|
+
var import_react_native3 = require("react-native");
|
|
130
|
+
function getVariantColors(theme, variant) {
|
|
131
|
+
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
132
|
+
const disabledLabelColor = alphaColor(theme.colors.onSurface, 0.38);
|
|
133
|
+
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
134
|
+
if (variant === "outlined") {
|
|
135
|
+
return {
|
|
136
|
+
backgroundColor: "transparent",
|
|
137
|
+
textColor: theme.colors.primary,
|
|
138
|
+
borderColor: theme.colors.outline,
|
|
139
|
+
borderWidth: 1,
|
|
140
|
+
hoveredBackgroundColor: alphaColor(
|
|
141
|
+
theme.colors.primary,
|
|
142
|
+
theme.stateLayer.hoveredOpacity
|
|
143
|
+
),
|
|
144
|
+
pressedBackgroundColor: alphaColor(
|
|
145
|
+
theme.colors.primary,
|
|
146
|
+
theme.stateLayer.pressedOpacity
|
|
147
|
+
),
|
|
148
|
+
disabledBackgroundColor: "transparent",
|
|
149
|
+
disabledTextColor: disabledLabelColor,
|
|
150
|
+
disabledBorderColor: disabledOutlineColor
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (variant === "text") {
|
|
154
|
+
return {
|
|
155
|
+
backgroundColor: "transparent",
|
|
156
|
+
textColor: theme.colors.primary,
|
|
157
|
+
borderColor: "transparent",
|
|
158
|
+
borderWidth: 0,
|
|
159
|
+
hoveredBackgroundColor: alphaColor(
|
|
160
|
+
theme.colors.primary,
|
|
161
|
+
theme.stateLayer.hoveredOpacity
|
|
162
|
+
),
|
|
163
|
+
pressedBackgroundColor: alphaColor(
|
|
164
|
+
theme.colors.primary,
|
|
165
|
+
theme.stateLayer.pressedOpacity
|
|
166
|
+
),
|
|
167
|
+
disabledBackgroundColor: "transparent",
|
|
168
|
+
disabledTextColor: disabledLabelColor,
|
|
169
|
+
disabledBorderColor: "transparent"
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (variant === "elevated") {
|
|
173
|
+
return {
|
|
174
|
+
backgroundColor: theme.colors.surfaceContainerLow,
|
|
175
|
+
textColor: theme.colors.primary,
|
|
176
|
+
borderColor: theme.colors.surfaceContainerLow,
|
|
177
|
+
borderWidth: 0,
|
|
178
|
+
hoveredBackgroundColor: blendColor(
|
|
179
|
+
theme.colors.surfaceContainerLow,
|
|
180
|
+
theme.colors.primary,
|
|
181
|
+
theme.stateLayer.hoveredOpacity
|
|
182
|
+
),
|
|
183
|
+
pressedBackgroundColor: blendColor(
|
|
184
|
+
theme.colors.surfaceContainerLow,
|
|
185
|
+
theme.colors.primary,
|
|
186
|
+
theme.stateLayer.pressedOpacity
|
|
187
|
+
),
|
|
188
|
+
disabledBackgroundColor: disabledContainerColor,
|
|
189
|
+
disabledTextColor: disabledLabelColor,
|
|
190
|
+
disabledBorderColor: disabledContainerColor
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (variant === "tonal") {
|
|
194
|
+
return {
|
|
195
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
196
|
+
textColor: theme.colors.onSecondaryContainer,
|
|
197
|
+
borderColor: theme.colors.secondaryContainer,
|
|
198
|
+
borderWidth: 0,
|
|
199
|
+
hoveredBackgroundColor: blendColor(
|
|
200
|
+
theme.colors.secondaryContainer,
|
|
201
|
+
theme.colors.onSecondaryContainer,
|
|
202
|
+
theme.stateLayer.hoveredOpacity
|
|
203
|
+
),
|
|
204
|
+
pressedBackgroundColor: blendColor(
|
|
205
|
+
theme.colors.secondaryContainer,
|
|
206
|
+
theme.colors.onSecondaryContainer,
|
|
207
|
+
theme.stateLayer.pressedOpacity
|
|
208
|
+
),
|
|
209
|
+
disabledBackgroundColor: disabledContainerColor,
|
|
210
|
+
disabledTextColor: disabledLabelColor,
|
|
211
|
+
disabledBorderColor: disabledContainerColor
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
backgroundColor: theme.colors.primary,
|
|
216
|
+
textColor: theme.colors.onPrimary,
|
|
217
|
+
borderColor: theme.colors.primary,
|
|
218
|
+
borderWidth: 0,
|
|
219
|
+
hoveredBackgroundColor: blendColor(
|
|
220
|
+
theme.colors.primary,
|
|
221
|
+
theme.colors.onPrimary,
|
|
222
|
+
theme.stateLayer.hoveredOpacity
|
|
223
|
+
),
|
|
224
|
+
pressedBackgroundColor: blendColor(
|
|
225
|
+
theme.colors.primary,
|
|
226
|
+
theme.colors.onPrimary,
|
|
227
|
+
theme.stateLayer.pressedOpacity
|
|
228
|
+
),
|
|
229
|
+
disabledBackgroundColor: disabledContainerColor,
|
|
230
|
+
disabledTextColor: disabledLabelColor,
|
|
231
|
+
disabledBorderColor: disabledContainerColor
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function getHorizontalPadding(theme, variant, hasLeadingIcon, hasTrailingIcon) {
|
|
235
|
+
if (variant === "text") {
|
|
236
|
+
return {
|
|
237
|
+
paddingStart: hasLeadingIcon ? 12 : hasTrailingIcon ? theme.spacing.md : 12,
|
|
238
|
+
paddingEnd: hasTrailingIcon ? 12 : hasLeadingIcon ? theme.spacing.md : 12
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
paddingStart: hasLeadingIcon ? theme.spacing.md : theme.spacing.lg,
|
|
243
|
+
paddingEnd: hasTrailingIcon ? theme.spacing.md : theme.spacing.lg
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function applyColorOverrides(theme, colors, containerColor, contentColor) {
|
|
247
|
+
if (!containerColor && !contentColor) return colors;
|
|
248
|
+
const result = { ...colors };
|
|
249
|
+
if (contentColor) {
|
|
250
|
+
result.textColor = contentColor;
|
|
251
|
+
}
|
|
252
|
+
if (containerColor) {
|
|
253
|
+
const overlay = contentColor != null ? contentColor : colors.textColor;
|
|
254
|
+
result.backgroundColor = containerColor;
|
|
255
|
+
result.borderColor = containerColor;
|
|
256
|
+
result.hoveredBackgroundColor = blendColor(
|
|
257
|
+
containerColor,
|
|
258
|
+
overlay,
|
|
259
|
+
theme.stateLayer.hoveredOpacity
|
|
260
|
+
);
|
|
261
|
+
result.pressedBackgroundColor = blendColor(
|
|
262
|
+
containerColor,
|
|
263
|
+
overlay,
|
|
264
|
+
theme.stateLayer.pressedOpacity
|
|
265
|
+
);
|
|
266
|
+
} else if (contentColor) {
|
|
267
|
+
if (colors.backgroundColor === "transparent") {
|
|
268
|
+
result.hoveredBackgroundColor = alphaColor(
|
|
269
|
+
contentColor,
|
|
270
|
+
theme.stateLayer.hoveredOpacity
|
|
271
|
+
);
|
|
272
|
+
result.pressedBackgroundColor = alphaColor(
|
|
273
|
+
contentColor,
|
|
274
|
+
theme.stateLayer.pressedOpacity
|
|
275
|
+
);
|
|
276
|
+
} else {
|
|
277
|
+
result.hoveredBackgroundColor = blendColor(
|
|
278
|
+
colors.backgroundColor,
|
|
279
|
+
contentColor,
|
|
280
|
+
theme.stateLayer.hoveredOpacity
|
|
281
|
+
);
|
|
282
|
+
result.pressedBackgroundColor = blendColor(
|
|
283
|
+
colors.backgroundColor,
|
|
284
|
+
contentColor,
|
|
285
|
+
theme.stateLayer.pressedOpacity
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return result;
|
|
290
|
+
}
|
|
291
|
+
function createStyles(theme, variant, hasLeadingIcon, hasTrailingIcon, containerColor, contentColor) {
|
|
292
|
+
const baseColors = getVariantColors(theme, variant);
|
|
293
|
+
const colors = applyColorOverrides(
|
|
294
|
+
theme,
|
|
295
|
+
baseColors,
|
|
296
|
+
containerColor,
|
|
297
|
+
contentColor
|
|
298
|
+
);
|
|
299
|
+
const labelStyle = theme.typography.labelLarge;
|
|
300
|
+
const padding = getHorizontalPadding(
|
|
301
|
+
theme,
|
|
302
|
+
variant,
|
|
303
|
+
hasLeadingIcon,
|
|
304
|
+
hasTrailingIcon
|
|
305
|
+
);
|
|
306
|
+
const elevationLevel0 = elevationStyle(theme.elevation.level0);
|
|
307
|
+
const elevationLevel1 = elevationStyle(theme.elevation.level1);
|
|
308
|
+
const elevationLevel2 = elevationStyle(theme.elevation.level2);
|
|
309
|
+
const baseElevation = variant === "elevated" ? elevationLevel1 : elevationLevel0;
|
|
310
|
+
return import_react_native3.StyleSheet.create({
|
|
311
|
+
container: {
|
|
312
|
+
alignSelf: "flex-start",
|
|
313
|
+
alignItems: "center",
|
|
314
|
+
flexDirection: "row",
|
|
315
|
+
justifyContent: "center",
|
|
316
|
+
minWidth: 58,
|
|
317
|
+
minHeight: 40,
|
|
318
|
+
paddingStart: padding.paddingStart,
|
|
319
|
+
paddingEnd: padding.paddingEnd,
|
|
320
|
+
paddingVertical: 10,
|
|
321
|
+
borderRadius: theme.shape.cornerFull,
|
|
322
|
+
backgroundColor: colors.backgroundColor,
|
|
323
|
+
borderColor: colors.borderColor,
|
|
324
|
+
borderWidth: colors.borderWidth,
|
|
325
|
+
cursor: "pointer",
|
|
326
|
+
...baseElevation
|
|
327
|
+
},
|
|
328
|
+
hoveredContainer: {
|
|
329
|
+
backgroundColor: colors.hoveredBackgroundColor,
|
|
330
|
+
...variant === "elevated" ? elevationLevel2 : void 0
|
|
331
|
+
},
|
|
332
|
+
pressedContainer: {
|
|
333
|
+
backgroundColor: colors.pressedBackgroundColor
|
|
334
|
+
},
|
|
335
|
+
disabledContainer: {
|
|
336
|
+
backgroundColor: colors.disabledBackgroundColor,
|
|
337
|
+
borderColor: colors.disabledBorderColor,
|
|
338
|
+
cursor: "auto",
|
|
339
|
+
...elevationLevel0
|
|
340
|
+
},
|
|
341
|
+
label: {
|
|
342
|
+
fontFamily: labelStyle.fontFamily,
|
|
343
|
+
fontSize: labelStyle.fontSize,
|
|
344
|
+
lineHeight: labelStyle.lineHeight,
|
|
345
|
+
fontWeight: labelStyle.fontWeight,
|
|
346
|
+
letterSpacing: labelStyle.letterSpacing,
|
|
347
|
+
color: colors.textColor
|
|
348
|
+
},
|
|
349
|
+
leadingIcon: {
|
|
350
|
+
marginEnd: theme.spacing.sm
|
|
351
|
+
},
|
|
352
|
+
trailingIcon: {
|
|
353
|
+
marginStart: theme.spacing.sm
|
|
354
|
+
},
|
|
355
|
+
disabledLabel: {
|
|
356
|
+
color: colors.disabledTextColor
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/button/Button.tsx
|
|
362
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
363
|
+
function resolveStyle(containerStyle, hoveredContainerStyle, pressedContainerStyle, disabledContainerStyle, disabled, style) {
|
|
364
|
+
if (typeof style === "function") {
|
|
365
|
+
return (state) => [
|
|
366
|
+
containerStyle,
|
|
367
|
+
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
368
|
+
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
369
|
+
disabled ? disabledContainerStyle : void 0,
|
|
370
|
+
style(state)
|
|
371
|
+
];
|
|
372
|
+
}
|
|
373
|
+
return (state) => [
|
|
374
|
+
containerStyle,
|
|
375
|
+
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
376
|
+
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
377
|
+
disabled ? disabledContainerStyle : void 0,
|
|
378
|
+
style
|
|
379
|
+
];
|
|
380
|
+
}
|
|
381
|
+
function Button({
|
|
382
|
+
children,
|
|
383
|
+
style,
|
|
384
|
+
variant = "filled",
|
|
385
|
+
leadingIcon,
|
|
386
|
+
trailingIcon,
|
|
387
|
+
iconSize = 18,
|
|
388
|
+
containerColor,
|
|
389
|
+
contentColor,
|
|
390
|
+
labelStyle: labelStyleOverride,
|
|
391
|
+
disabled = false,
|
|
392
|
+
...props
|
|
393
|
+
}) {
|
|
394
|
+
const isDisabled = Boolean(disabled);
|
|
395
|
+
const hasLeading = Boolean(leadingIcon);
|
|
396
|
+
const hasTrailing = Boolean(trailingIcon);
|
|
397
|
+
const theme = (0, import_core.useTheme)();
|
|
398
|
+
const styles = (0, import_react.useMemo)(
|
|
399
|
+
() => createStyles(
|
|
400
|
+
theme,
|
|
401
|
+
variant,
|
|
402
|
+
hasLeading,
|
|
403
|
+
hasTrailing,
|
|
404
|
+
containerColor,
|
|
405
|
+
contentColor
|
|
406
|
+
),
|
|
407
|
+
[theme, variant, hasLeading, hasTrailing, containerColor, contentColor]
|
|
408
|
+
);
|
|
409
|
+
const MaterialCommunityIcons = leadingIcon || trailingIcon ? getMaterialCommunityIcons() : null;
|
|
410
|
+
const resolvedIconColor = (0, import_react.useMemo)(() => {
|
|
411
|
+
const base = import_react_native5.StyleSheet.flatten([
|
|
412
|
+
styles.label,
|
|
413
|
+
isDisabled ? styles.disabledLabel : void 0
|
|
414
|
+
]);
|
|
415
|
+
return typeof (base == null ? void 0 : base.color) === "string" ? base.color : void 0;
|
|
416
|
+
}, [styles.label, styles.disabledLabel, isDisabled]);
|
|
417
|
+
const computedLabelStyle = (0, import_react.useMemo)(
|
|
418
|
+
() => [
|
|
419
|
+
styles.label,
|
|
420
|
+
isDisabled ? styles.disabledLabel : void 0,
|
|
421
|
+
labelStyleOverride
|
|
422
|
+
],
|
|
423
|
+
[isDisabled, styles.disabledLabel, styles.label, labelStyleOverride]
|
|
424
|
+
);
|
|
425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
426
|
+
import_react_native4.Pressable,
|
|
427
|
+
{
|
|
428
|
+
...props,
|
|
429
|
+
accessibilityRole: "button",
|
|
430
|
+
accessibilityState: { disabled: isDisabled },
|
|
431
|
+
hitSlop: import_react_native4.Platform.OS === "web" ? void 0 : 4,
|
|
432
|
+
disabled: isDisabled,
|
|
433
|
+
style: resolveStyle(
|
|
434
|
+
styles.container,
|
|
435
|
+
styles.hoveredContainer,
|
|
436
|
+
styles.pressedContainer,
|
|
437
|
+
styles.disabledContainer,
|
|
438
|
+
isDisabled,
|
|
439
|
+
style
|
|
440
|
+
),
|
|
441
|
+
children: [
|
|
442
|
+
leadingIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
443
|
+
MaterialCommunityIcons,
|
|
444
|
+
{
|
|
445
|
+
name: leadingIcon,
|
|
446
|
+
size: iconSize,
|
|
447
|
+
color: resolvedIconColor,
|
|
448
|
+
style: styles.leadingIcon
|
|
449
|
+
}
|
|
450
|
+
) : null,
|
|
451
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native6.Text, { style: computedLabelStyle, children }),
|
|
452
|
+
trailingIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
453
|
+
MaterialCommunityIcons,
|
|
454
|
+
{
|
|
455
|
+
name: trailingIcon,
|
|
456
|
+
size: iconSize,
|
|
457
|
+
color: resolvedIconColor,
|
|
458
|
+
style: styles.trailingIcon
|
|
459
|
+
}
|
|
460
|
+
) : null
|
|
461
|
+
]
|
|
462
|
+
}
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
466
|
+
0 && (module.exports = {
|
|
467
|
+
Button
|
|
468
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ViewProps } from 'react-native';
|
|
4
|
+
|
|
5
|
+
/** Surface style variant of the card following Material Design 3 roles. */
|
|
6
|
+
type CardVariant = 'elevated' | 'filled' | 'outlined';
|
|
7
|
+
interface CardProps extends ViewProps {
|
|
8
|
+
/** Content rendered inside the card surface. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Surface style variant.
|
|
12
|
+
* @default 'elevated'
|
|
13
|
+
*/
|
|
14
|
+
variant?: CardVariant;
|
|
15
|
+
/** When provided, the card becomes interactive (Pressable). Omit to render as a plain View. */
|
|
16
|
+
onPress?: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Disables the press interaction and reduces opacity. Only effective when `onPress` is provided.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Override the container (background) color.
|
|
24
|
+
* State-layer colors (hover, press) are derived automatically.
|
|
25
|
+
*/
|
|
26
|
+
containerColor?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare function Card({ children, style, variant, onPress, disabled, containerColor, ...props }: CardProps): react_jsx_runtime.JSX.Element;
|
|
30
|
+
|
|
31
|
+
export { Card, type CardProps, type CardVariant };
|