@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,46 @@
|
|
|
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 { ViewProps, StyleProp, ViewStyle } from 'react-native';
|
|
5
|
+
|
|
6
|
+
/** Size of the avatar container. */
|
|
7
|
+
type AvatarSize = 'xSmall' | 'small' | 'medium' | 'large' | 'xLarge';
|
|
8
|
+
interface AvatarProps extends Omit<ViewProps, 'style'> {
|
|
9
|
+
/**
|
|
10
|
+
* URI of the image to display.
|
|
11
|
+
* Takes priority over `icon` and `label`.
|
|
12
|
+
*/
|
|
13
|
+
imageUri?: string;
|
|
14
|
+
/**
|
|
15
|
+
* MaterialCommunityIcons icon name.
|
|
16
|
+
* Takes priority over `label` when `imageUri` is not set.
|
|
17
|
+
*/
|
|
18
|
+
icon?: ComponentProps<typeof MaterialCommunityIcons>['name'];
|
|
19
|
+
/**
|
|
20
|
+
* Text initials to display (1–2 characters recommended).
|
|
21
|
+
* Shown when `imageUri` and `icon` are not set.
|
|
22
|
+
*/
|
|
23
|
+
label?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Size of the avatar.
|
|
26
|
+
* @default 'medium'
|
|
27
|
+
*/
|
|
28
|
+
size?: AvatarSize;
|
|
29
|
+
/**
|
|
30
|
+
* Override the container (background) color.
|
|
31
|
+
* State-layer colors (hover, press) are derived automatically when `onPress` is set.
|
|
32
|
+
*/
|
|
33
|
+
containerColor?: string;
|
|
34
|
+
/** Override the content (icon / initials) color. */
|
|
35
|
+
contentColor?: string;
|
|
36
|
+
/** Custom style applied to the root container. */
|
|
37
|
+
style?: StyleProp<ViewStyle>;
|
|
38
|
+
/** When provided, the avatar becomes interactive (Pressable). */
|
|
39
|
+
onPress?: () => void;
|
|
40
|
+
/** Required when `onPress` is provided — labels the button for screen readers. */
|
|
41
|
+
accessibilityLabel?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare function Avatar({ imageUri, icon, label, size, containerColor, contentColor, style, onPress, accessibilityLabel, ...props }: AvatarProps): react_jsx_runtime.JSX.Element;
|
|
45
|
+
|
|
46
|
+
export { Avatar, type AvatarProps, type AvatarSize };
|
|
@@ -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/avatar/index.ts
|
|
21
|
+
var avatar_exports = {};
|
|
22
|
+
__export(avatar_exports, {
|
|
23
|
+
Avatar: () => Avatar
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(avatar_exports);
|
|
26
|
+
|
|
27
|
+
// src/avatar/Avatar.tsx
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_react_native4 = require("react-native");
|
|
30
|
+
var import_core = require("@onlynative/core");
|
|
31
|
+
|
|
32
|
+
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
33
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
34
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
35
|
+
}) : x)(function(x) {
|
|
36
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
37
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// ../utils/dist/index.mjs
|
|
41
|
+
var import_react_native = require("react-native");
|
|
42
|
+
var import_react_native2 = require("react-native");
|
|
43
|
+
function parseHexColor(color) {
|
|
44
|
+
const normalized = color.replace("#", "");
|
|
45
|
+
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const r = Number.parseInt(normalized.slice(0, 2), 16);
|
|
49
|
+
const g = Number.parseInt(normalized.slice(2, 4), 16);
|
|
50
|
+
const b = Number.parseInt(normalized.slice(4, 6), 16);
|
|
51
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return { r, g, b };
|
|
55
|
+
}
|
|
56
|
+
function clampAlpha(alpha) {
|
|
57
|
+
return Math.max(0, Math.min(1, alpha));
|
|
58
|
+
}
|
|
59
|
+
function alphaColor(color, alpha) {
|
|
60
|
+
const channels = parseHexColor(color);
|
|
61
|
+
const boundedAlpha = clampAlpha(alpha);
|
|
62
|
+
if (!channels) {
|
|
63
|
+
return color;
|
|
64
|
+
}
|
|
65
|
+
return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
|
|
66
|
+
}
|
|
67
|
+
function blendColor(base, overlay, overlayAlpha) {
|
|
68
|
+
const baseChannels = parseHexColor(base);
|
|
69
|
+
const overlayChannels = parseHexColor(overlay);
|
|
70
|
+
const boundedAlpha = clampAlpha(overlayAlpha);
|
|
71
|
+
if (!baseChannels || !overlayChannels) {
|
|
72
|
+
return alphaColor(overlay, boundedAlpha);
|
|
73
|
+
}
|
|
74
|
+
const r = Math.round(
|
|
75
|
+
(1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
|
|
76
|
+
);
|
|
77
|
+
const g = Math.round(
|
|
78
|
+
(1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
|
|
79
|
+
);
|
|
80
|
+
const b = Math.round(
|
|
81
|
+
(1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
|
|
82
|
+
);
|
|
83
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
84
|
+
}
|
|
85
|
+
var _MCIcons = null;
|
|
86
|
+
var _resolved = false;
|
|
87
|
+
function getMaterialCommunityIcons() {
|
|
88
|
+
if (!_resolved) {
|
|
89
|
+
_resolved = true;
|
|
90
|
+
try {
|
|
91
|
+
const mod = __require("@expo/vector-icons/MaterialCommunityIcons");
|
|
92
|
+
_MCIcons = mod.default || mod;
|
|
93
|
+
} catch {
|
|
94
|
+
_MCIcons = null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!_MCIcons) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return _MCIcons;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/avatar/styles.ts
|
|
106
|
+
var import_react_native3 = require("react-native");
|
|
107
|
+
function createStyles(theme) {
|
|
108
|
+
return import_react_native3.StyleSheet.create({
|
|
109
|
+
container: {
|
|
110
|
+
borderRadius: theme.shape.cornerFull,
|
|
111
|
+
alignItems: "center",
|
|
112
|
+
justifyContent: "center",
|
|
113
|
+
overflow: "hidden"
|
|
114
|
+
},
|
|
115
|
+
interactive: {
|
|
116
|
+
cursor: "pointer"
|
|
117
|
+
},
|
|
118
|
+
sizeXSmall: { width: 24, height: 24 },
|
|
119
|
+
sizeSmall: { width: 32, height: 32 },
|
|
120
|
+
sizeMedium: { width: 40, height: 40 },
|
|
121
|
+
sizeLarge: { width: 56, height: 56 },
|
|
122
|
+
sizeXLarge: { width: 112, height: 112 },
|
|
123
|
+
image: {
|
|
124
|
+
width: "100%",
|
|
125
|
+
height: "100%"
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// src/avatar/Avatar.tsx
|
|
131
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
132
|
+
var ICON_PX = {
|
|
133
|
+
xSmall: 14,
|
|
134
|
+
small: 18,
|
|
135
|
+
medium: 24,
|
|
136
|
+
large: 32,
|
|
137
|
+
xLarge: 56
|
|
138
|
+
};
|
|
139
|
+
var LABEL_FONT_SIZE = {
|
|
140
|
+
xSmall: 10,
|
|
141
|
+
small: 12,
|
|
142
|
+
medium: 14,
|
|
143
|
+
large: 22,
|
|
144
|
+
xLarge: 36
|
|
145
|
+
};
|
|
146
|
+
function getSizeStyle(styles, size) {
|
|
147
|
+
if (size === "xSmall") return styles.sizeXSmall;
|
|
148
|
+
if (size === "small") return styles.sizeSmall;
|
|
149
|
+
if (size === "large") return styles.sizeLarge;
|
|
150
|
+
if (size === "xLarge") return styles.sizeXLarge;
|
|
151
|
+
return styles.sizeMedium;
|
|
152
|
+
}
|
|
153
|
+
function Avatar({
|
|
154
|
+
imageUri,
|
|
155
|
+
icon,
|
|
156
|
+
label,
|
|
157
|
+
size = "medium",
|
|
158
|
+
containerColor,
|
|
159
|
+
contentColor,
|
|
160
|
+
style,
|
|
161
|
+
onPress,
|
|
162
|
+
accessibilityLabel,
|
|
163
|
+
...props
|
|
164
|
+
}) {
|
|
165
|
+
const MaterialCommunityIcons = getMaterialCommunityIcons();
|
|
166
|
+
const theme = (0, import_core.useTheme)();
|
|
167
|
+
const styles = (0, import_react.useMemo)(() => createStyles(theme), [theme]);
|
|
168
|
+
const bgColor = containerColor != null ? containerColor : theme.colors.primaryContainer;
|
|
169
|
+
const fgColor = contentColor != null ? contentColor : theme.colors.onPrimaryContainer;
|
|
170
|
+
const isInteractive = onPress !== void 0;
|
|
171
|
+
const sizeStyle = getSizeStyle(styles, size);
|
|
172
|
+
const iconPx = ICON_PX[size];
|
|
173
|
+
const labelFontSize = LABEL_FONT_SIZE[size];
|
|
174
|
+
const initials = label ? label.slice(0, 2).toUpperCase() : void 0;
|
|
175
|
+
const initialsStyle = (0, import_react.useMemo)(
|
|
176
|
+
() => ({
|
|
177
|
+
color: fgColor,
|
|
178
|
+
fontSize: labelFontSize,
|
|
179
|
+
fontWeight: "500"
|
|
180
|
+
}),
|
|
181
|
+
[fgColor, labelFontSize]
|
|
182
|
+
);
|
|
183
|
+
const containerOverrides = (0, import_react.useMemo)(
|
|
184
|
+
() => ({
|
|
185
|
+
base: { backgroundColor: bgColor },
|
|
186
|
+
hovered: {
|
|
187
|
+
backgroundColor: blendColor(
|
|
188
|
+
bgColor,
|
|
189
|
+
fgColor,
|
|
190
|
+
theme.stateLayer.hoveredOpacity
|
|
191
|
+
)
|
|
192
|
+
},
|
|
193
|
+
pressed: {
|
|
194
|
+
backgroundColor: blendColor(
|
|
195
|
+
bgColor,
|
|
196
|
+
fgColor,
|
|
197
|
+
theme.stateLayer.pressedOpacity
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
201
|
+
[bgColor, fgColor, theme.stateLayer]
|
|
202
|
+
);
|
|
203
|
+
const content = imageUri ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native4.Image, { source: { uri: imageUri }, style: styles.image, accessible: false }) : label && !icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native4.Text, { style: initialsStyle, numberOfLines: 1, allowFontScaling: false, children: initials }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
204
|
+
MaterialCommunityIcons,
|
|
205
|
+
{
|
|
206
|
+
name: icon != null ? icon : "account",
|
|
207
|
+
size: iconPx,
|
|
208
|
+
color: fgColor
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
if (!isInteractive) {
|
|
212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
213
|
+
import_react_native4.View,
|
|
214
|
+
{
|
|
215
|
+
...props,
|
|
216
|
+
accessibilityLabel,
|
|
217
|
+
style: [styles.container, sizeStyle, containerOverrides.base, style],
|
|
218
|
+
children: content
|
|
219
|
+
}
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
223
|
+
import_react_native4.Pressable,
|
|
224
|
+
{
|
|
225
|
+
...props,
|
|
226
|
+
accessibilityRole: "button",
|
|
227
|
+
accessibilityLabel,
|
|
228
|
+
onPress,
|
|
229
|
+
style: ({
|
|
230
|
+
pressed,
|
|
231
|
+
hovered
|
|
232
|
+
}) => {
|
|
233
|
+
return [
|
|
234
|
+
styles.container,
|
|
235
|
+
sizeStyle,
|
|
236
|
+
containerOverrides.base,
|
|
237
|
+
styles.interactive,
|
|
238
|
+
hovered && !pressed ? containerOverrides.hovered : void 0,
|
|
239
|
+
pressed ? containerOverrides.pressed : void 0,
|
|
240
|
+
style
|
|
241
|
+
];
|
|
242
|
+
},
|
|
243
|
+
children: content
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
248
|
+
0 && (module.exports = {
|
|
249
|
+
Avatar
|
|
250
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
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, StyleProp, TextStyle } from 'react-native';
|
|
5
|
+
|
|
6
|
+
/** Visual style variant of the button following Material Design 3 roles. */
|
|
7
|
+
type ButtonVariant = 'filled' | 'elevated' | 'outlined' | 'text' | 'tonal';
|
|
8
|
+
interface ButtonProps extends Omit<PressableProps, 'children'> {
|
|
9
|
+
/** Text label rendered inside the button. */
|
|
10
|
+
children: string;
|
|
11
|
+
/**
|
|
12
|
+
* Visual variant. Controls background, border, and text color.
|
|
13
|
+
* @default 'filled'
|
|
14
|
+
*/
|
|
15
|
+
variant?: ButtonVariant;
|
|
16
|
+
/** Name of a MaterialCommunityIcons icon to show before the label. */
|
|
17
|
+
leadingIcon?: ComponentProps<typeof MaterialCommunityIcons>['name'];
|
|
18
|
+
/** Name of a MaterialCommunityIcons icon to show after the label. */
|
|
19
|
+
trailingIcon?: ComponentProps<typeof MaterialCommunityIcons>['name'];
|
|
20
|
+
/**
|
|
21
|
+
* Size of leading and trailing icons in dp.
|
|
22
|
+
* @default 18
|
|
23
|
+
*/
|
|
24
|
+
iconSize?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Override the container (background) color.
|
|
27
|
+
* State-layer colors (hover, press) are derived automatically.
|
|
28
|
+
*/
|
|
29
|
+
containerColor?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Override the content (label and icon) color.
|
|
32
|
+
* State-layer colors are derived automatically when no containerColor is set.
|
|
33
|
+
*/
|
|
34
|
+
contentColor?: string;
|
|
35
|
+
/** Additional style applied to the label text. */
|
|
36
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare function Button({ children, style, variant, leadingIcon, trailingIcon, iconSize, containerColor, contentColor, labelStyle: labelStyleOverride, disabled, ...props }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
40
|
+
|
|
41
|
+
export { Button, type ButtonProps, type ButtonVariant };
|