@onlynative/components 0.0.0-alpha.0 → 0.0.0-alpha.2
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/LICENSE +21 -0
- package/dist/appbar/index.js +51 -46
- package/dist/avatar/index.js +13 -19
- package/dist/button/index.js +43 -41
- package/dist/card/index.js +38 -17
- package/dist/checkbox/index.js +44 -43
- package/dist/chip/index.js +42 -38
- package/dist/icon-button/index.js +13 -17
- package/dist/index.js +226 -287
- package/dist/keyboard-avoiding-wrapper/index.js +2 -6
- package/dist/layout/index.js +3 -3
- package/dist/list/index.js +57 -37
- package/dist/radio/index.js +33 -32
- package/dist/switch/index.js +44 -43
- package/dist/text-field/index.js +28 -31
- package/dist/typography/index.js +1 -1
- package/llms.txt +2 -2
- package/package.json +28 -43
package/dist/checkbox/index.js
CHANGED
|
@@ -25,21 +25,9 @@ __export(checkbox_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(checkbox_exports);
|
|
26
26
|
|
|
27
27
|
// src/checkbox/Checkbox.tsx
|
|
28
|
-
var import_react = require("react");
|
|
29
|
-
var import_react_native4 = require("react-native");
|
|
30
28
|
var import_core = require("@onlynative/core");
|
|
31
29
|
|
|
32
|
-
// ../utils/
|
|
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");
|
|
30
|
+
// ../utils/src/color.ts
|
|
43
31
|
function parseHexColor(color) {
|
|
44
32
|
const normalized = color.replace("#", "");
|
|
45
33
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -82,13 +70,15 @@ function blendColor(base, overlay, overlayAlpha) {
|
|
|
82
70
|
);
|
|
83
71
|
return `rgb(${r}, ${g}, ${b})`;
|
|
84
72
|
}
|
|
73
|
+
|
|
74
|
+
// ../utils/src/icon.ts
|
|
85
75
|
var _MCIcons = null;
|
|
86
76
|
var _resolved = false;
|
|
87
77
|
function getMaterialCommunityIcons() {
|
|
88
78
|
if (!_resolved) {
|
|
89
79
|
_resolved = true;
|
|
90
80
|
try {
|
|
91
|
-
const mod =
|
|
81
|
+
const mod = require("@expo/vector-icons/MaterialCommunityIcons");
|
|
92
82
|
_MCIcons = mod.default || mod;
|
|
93
83
|
} catch {
|
|
94
84
|
_MCIcons = null;
|
|
@@ -102,8 +92,37 @@ function getMaterialCommunityIcons() {
|
|
|
102
92
|
return _MCIcons;
|
|
103
93
|
}
|
|
104
94
|
|
|
105
|
-
// src/
|
|
95
|
+
// ../utils/src/pressable.ts
|
|
96
|
+
var import_react_native = require("react-native");
|
|
97
|
+
function resolvePressableStyle(base, hovered, pressed, disabled, isDisabled, style) {
|
|
98
|
+
if (typeof style === "function") {
|
|
99
|
+
return (state) => [
|
|
100
|
+
base,
|
|
101
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
102
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
103
|
+
isDisabled ? disabled : void 0,
|
|
104
|
+
style(state)
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
return (state) => [
|
|
108
|
+
base,
|
|
109
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
110
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
111
|
+
isDisabled ? disabled : void 0,
|
|
112
|
+
style
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
function resolveColorFromStyle(...styles) {
|
|
116
|
+
const flattened = import_react_native.StyleSheet.flatten(styles);
|
|
117
|
+
return typeof (flattened == null ? void 0 : flattened.color) === "string" ? flattened.color : void 0;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/checkbox/Checkbox.tsx
|
|
121
|
+
var import_react = require("react");
|
|
106
122
|
var import_react_native3 = require("react-native");
|
|
123
|
+
|
|
124
|
+
// src/checkbox/styles.ts
|
|
125
|
+
var import_react_native2 = require("react-native");
|
|
107
126
|
function getColors(theme, checked) {
|
|
108
127
|
const disabledOnSurface38 = alphaColor(theme.colors.onSurface, 0.38);
|
|
109
128
|
if (checked) {
|
|
@@ -179,7 +198,7 @@ function createStyles(theme, checked, containerColor, contentColor) {
|
|
|
179
198
|
);
|
|
180
199
|
const size = 18;
|
|
181
200
|
const touchTarget = 48;
|
|
182
|
-
return
|
|
201
|
+
return import_react_native2.StyleSheet.create({
|
|
183
202
|
container: {
|
|
184
203
|
width: touchTarget,
|
|
185
204
|
height: touchTarget,
|
|
@@ -224,24 +243,6 @@ function createStyles(theme, checked, containerColor, contentColor) {
|
|
|
224
243
|
|
|
225
244
|
// src/checkbox/Checkbox.tsx
|
|
226
245
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
227
|
-
function resolveStyle(containerStyle, hoveredContainerStyle, pressedContainerStyle, disabledContainerStyle, disabled, style) {
|
|
228
|
-
if (typeof style === "function") {
|
|
229
|
-
return (state) => [
|
|
230
|
-
containerStyle,
|
|
231
|
-
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
232
|
-
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
233
|
-
disabled ? disabledContainerStyle : void 0,
|
|
234
|
-
style(state)
|
|
235
|
-
];
|
|
236
|
-
}
|
|
237
|
-
return (state) => [
|
|
238
|
-
containerStyle,
|
|
239
|
-
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
240
|
-
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
241
|
-
disabled ? disabledContainerStyle : void 0,
|
|
242
|
-
style
|
|
243
|
-
];
|
|
244
|
-
}
|
|
245
246
|
function Checkbox({
|
|
246
247
|
style,
|
|
247
248
|
value = false,
|
|
@@ -259,20 +260,20 @@ function Checkbox({
|
|
|
259
260
|
() => createStyles(theme, isChecked, containerColor, contentColor),
|
|
260
261
|
[theme, isChecked, containerColor, contentColor]
|
|
261
262
|
);
|
|
262
|
-
const resolvedIconColor = (0, import_react.useMemo)(
|
|
263
|
-
|
|
263
|
+
const resolvedIconColor = (0, import_react.useMemo)(
|
|
264
|
+
() => resolveColorFromStyle(
|
|
264
265
|
styles.iconColor,
|
|
265
266
|
isDisabled ? styles.disabledIconColor : void 0
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
),
|
|
268
|
+
[styles.iconColor, styles.disabledIconColor, isDisabled]
|
|
269
|
+
);
|
|
269
270
|
const handlePress = () => {
|
|
270
271
|
if (!isDisabled) {
|
|
271
272
|
onValueChange == null ? void 0 : onValueChange(!isChecked);
|
|
272
273
|
}
|
|
273
274
|
};
|
|
274
275
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
275
|
-
|
|
276
|
+
import_react_native3.Pressable,
|
|
276
277
|
{
|
|
277
278
|
...props,
|
|
278
279
|
accessibilityRole: "checkbox",
|
|
@@ -280,10 +281,10 @@ function Checkbox({
|
|
|
280
281
|
disabled: isDisabled,
|
|
281
282
|
checked: isChecked
|
|
282
283
|
},
|
|
283
|
-
hitSlop:
|
|
284
|
+
hitSlop: import_react_native3.Platform.OS === "web" ? void 0 : 4,
|
|
284
285
|
disabled: isDisabled,
|
|
285
286
|
onPress: handlePress,
|
|
286
|
-
style:
|
|
287
|
+
style: resolvePressableStyle(
|
|
287
288
|
styles.container,
|
|
288
289
|
styles.hoveredContainer,
|
|
289
290
|
styles.pressedContainer,
|
|
@@ -291,7 +292,7 @@ function Checkbox({
|
|
|
291
292
|
isDisabled,
|
|
292
293
|
style
|
|
293
294
|
),
|
|
294
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
295
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native3.View, { style: [styles.box, isDisabled ? styles.disabledBox : void 0], children: isChecked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
295
296
|
MaterialCommunityIcons,
|
|
296
297
|
{
|
|
297
298
|
name: "check",
|
package/dist/chip/index.js
CHANGED
|
@@ -25,21 +25,9 @@ __export(chip_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(chip_exports);
|
|
26
26
|
|
|
27
27
|
// src/chip/Chip.tsx
|
|
28
|
-
var import_react = require("react");
|
|
29
|
-
var import_react_native4 = require("react-native");
|
|
30
28
|
var import_core = require("@onlynative/core");
|
|
31
29
|
|
|
32
|
-
// ../utils/
|
|
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");
|
|
30
|
+
// ../utils/src/color.ts
|
|
43
31
|
function parseHexColor(color) {
|
|
44
32
|
const normalized = color.replace("#", "");
|
|
45
33
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -82,6 +70,9 @@ function blendColor(base, overlay, overlayAlpha) {
|
|
|
82
70
|
);
|
|
83
71
|
return `rgb(${r}, ${g}, ${b})`;
|
|
84
72
|
}
|
|
73
|
+
|
|
74
|
+
// ../utils/src/elevation.ts
|
|
75
|
+
var import_react_native = require("react-native");
|
|
85
76
|
function elevationStyle(level) {
|
|
86
77
|
if (import_react_native.Platform.OS === "web") {
|
|
87
78
|
const { shadowOffset, shadowOpacity, shadowRadius } = level;
|
|
@@ -103,13 +94,15 @@ function elevationStyle(level) {
|
|
|
103
94
|
elevation: level.elevation
|
|
104
95
|
};
|
|
105
96
|
}
|
|
97
|
+
|
|
98
|
+
// ../utils/src/icon.ts
|
|
106
99
|
var _MCIcons = null;
|
|
107
100
|
var _resolved = false;
|
|
108
101
|
function getMaterialCommunityIcons() {
|
|
109
102
|
if (!_resolved) {
|
|
110
103
|
_resolved = true;
|
|
111
104
|
try {
|
|
112
|
-
const mod =
|
|
105
|
+
const mod = require("@expo/vector-icons/MaterialCommunityIcons");
|
|
113
106
|
_MCIcons = mod.default || mod;
|
|
114
107
|
} catch {
|
|
115
108
|
_MCIcons = null;
|
|
@@ -123,6 +116,35 @@ function getMaterialCommunityIcons() {
|
|
|
123
116
|
return _MCIcons;
|
|
124
117
|
}
|
|
125
118
|
|
|
119
|
+
// ../utils/src/pressable.ts
|
|
120
|
+
var import_react_native2 = require("react-native");
|
|
121
|
+
function resolvePressableStyle(base, hovered, pressed, disabled, isDisabled, style) {
|
|
122
|
+
if (typeof style === "function") {
|
|
123
|
+
return (state) => [
|
|
124
|
+
base,
|
|
125
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
126
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
127
|
+
isDisabled ? disabled : void 0,
|
|
128
|
+
style(state)
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
return (state) => [
|
|
132
|
+
base,
|
|
133
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
134
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
135
|
+
isDisabled ? disabled : void 0,
|
|
136
|
+
style
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
function resolveColorFromStyle(...styles) {
|
|
140
|
+
const flattened = import_react_native2.StyleSheet.flatten(styles);
|
|
141
|
+
return typeof (flattened == null ? void 0 : flattened.color) === "string" ? flattened.color : void 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/chip/Chip.tsx
|
|
145
|
+
var import_react = require("react");
|
|
146
|
+
var import_react_native4 = require("react-native");
|
|
147
|
+
|
|
126
148
|
// src/chip/styles.ts
|
|
127
149
|
var import_react_native3 = require("react-native");
|
|
128
150
|
function getVariantColors(theme, variant, elevated, selected) {
|
|
@@ -309,24 +331,6 @@ function createStyles(theme, variant, elevated, selected, hasLeadingContent, has
|
|
|
309
331
|
|
|
310
332
|
// src/chip/Chip.tsx
|
|
311
333
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
312
|
-
function resolveStyle(containerStyle, hoveredContainerStyle, pressedContainerStyle, disabledContainerStyle, disabled, style) {
|
|
313
|
-
if (typeof style === "function") {
|
|
314
|
-
return (state) => [
|
|
315
|
-
containerStyle,
|
|
316
|
-
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
317
|
-
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
318
|
-
disabled ? disabledContainerStyle : void 0,
|
|
319
|
-
style(state)
|
|
320
|
-
];
|
|
321
|
-
}
|
|
322
|
-
return (state) => [
|
|
323
|
-
containerStyle,
|
|
324
|
-
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
325
|
-
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
326
|
-
disabled ? disabledContainerStyle : void 0,
|
|
327
|
-
style
|
|
328
|
-
];
|
|
329
|
-
}
|
|
330
334
|
function Chip({
|
|
331
335
|
children,
|
|
332
336
|
style,
|
|
@@ -374,13 +378,13 @@ function Chip({
|
|
|
374
378
|
contentColor
|
|
375
379
|
]
|
|
376
380
|
);
|
|
377
|
-
const resolvedIconColor = (0, import_react.useMemo)(
|
|
378
|
-
|
|
381
|
+
const resolvedIconColor = (0, import_react.useMemo)(
|
|
382
|
+
() => resolveColorFromStyle(
|
|
379
383
|
styles.label,
|
|
380
384
|
isDisabled ? styles.disabledLabel : void 0
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
385
|
+
),
|
|
386
|
+
[styles.label, styles.disabledLabel, isDisabled]
|
|
387
|
+
);
|
|
384
388
|
const computedLabelStyle = (0, import_react.useMemo)(
|
|
385
389
|
() => [
|
|
386
390
|
styles.label,
|
|
@@ -428,7 +432,7 @@ function Chip({
|
|
|
428
432
|
},
|
|
429
433
|
hitSlop: import_react_native4.Platform.OS === "web" ? void 0 : 4,
|
|
430
434
|
disabled: isDisabled,
|
|
431
|
-
style:
|
|
435
|
+
style: resolvePressableStyle(
|
|
432
436
|
styles.container,
|
|
433
437
|
styles.hoveredContainer,
|
|
434
438
|
styles.pressedContainer,
|
|
@@ -25,21 +25,9 @@ __export(icon_button_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(icon_button_exports);
|
|
26
26
|
|
|
27
27
|
// src/icon-button/IconButton.tsx
|
|
28
|
-
var import_react = require("react");
|
|
29
|
-
var import_react_native4 = require("react-native");
|
|
30
28
|
var import_core = require("@onlynative/core");
|
|
31
29
|
|
|
32
|
-
// ../utils/
|
|
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");
|
|
30
|
+
// ../utils/src/color.ts
|
|
43
31
|
function parseHexColor(color) {
|
|
44
32
|
const normalized = color.replace("#", "");
|
|
45
33
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -82,13 +70,15 @@ function blendColor(base, overlay, overlayAlpha) {
|
|
|
82
70
|
);
|
|
83
71
|
return `rgb(${r}, ${g}, ${b})`;
|
|
84
72
|
}
|
|
73
|
+
|
|
74
|
+
// ../utils/src/icon.ts
|
|
85
75
|
var _MCIcons = null;
|
|
86
76
|
var _resolved = false;
|
|
87
77
|
function getMaterialCommunityIcons() {
|
|
88
78
|
if (!_resolved) {
|
|
89
79
|
_resolved = true;
|
|
90
80
|
try {
|
|
91
|
-
const mod =
|
|
81
|
+
const mod = require("@expo/vector-icons/MaterialCommunityIcons");
|
|
92
82
|
_MCIcons = mod.default || mod;
|
|
93
83
|
} catch {
|
|
94
84
|
_MCIcons = null;
|
|
@@ -102,13 +92,17 @@ function getMaterialCommunityIcons() {
|
|
|
102
92
|
return _MCIcons;
|
|
103
93
|
}
|
|
104
94
|
|
|
95
|
+
// src/icon-button/IconButton.tsx
|
|
96
|
+
var import_react = require("react");
|
|
97
|
+
var import_react_native2 = require("react-native");
|
|
98
|
+
|
|
105
99
|
// src/icon-button/styles.ts
|
|
106
|
-
var
|
|
100
|
+
var import_react_native = require("react-native");
|
|
107
101
|
function createStyles(theme) {
|
|
108
102
|
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
109
103
|
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
110
104
|
const toggleUnselectedContainerColor = theme.colors.surfaceContainerHighest;
|
|
111
|
-
return
|
|
105
|
+
return import_react_native.StyleSheet.create({
|
|
112
106
|
container: {
|
|
113
107
|
borderRadius: theme.shape.cornerFull,
|
|
114
108
|
alignItems: "center",
|
|
@@ -343,11 +337,13 @@ function createStyles(theme) {
|
|
|
343
337
|
borderColor: disabledContainerColor,
|
|
344
338
|
cursor: "auto"
|
|
345
339
|
},
|
|
340
|
+
// eslint-disable-next-line react-native/no-color-literals
|
|
346
341
|
disabledOutlined: {
|
|
347
342
|
backgroundColor: "transparent",
|
|
348
343
|
borderColor: disabledOutlineColor,
|
|
349
344
|
cursor: "auto"
|
|
350
345
|
},
|
|
346
|
+
// eslint-disable-next-line react-native/no-color-literals
|
|
351
347
|
disabledStandard: {
|
|
352
348
|
backgroundColor: "transparent",
|
|
353
349
|
borderColor: "transparent",
|
|
@@ -546,7 +542,7 @@ function IconButton({
|
|
|
546
542
|
};
|
|
547
543
|
}, [containerColor, resolvedIconColor, theme.stateLayer]);
|
|
548
544
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
549
|
-
|
|
545
|
+
import_react_native2.Pressable,
|
|
550
546
|
{
|
|
551
547
|
...props,
|
|
552
548
|
accessibilityRole: "button",
|