@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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 OnlyNative
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/appbar/index.js
CHANGED
|
@@ -25,27 +25,9 @@ __export(appbar_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(appbar_exports);
|
|
26
26
|
|
|
27
27
|
// src/appbar/AppBar.tsx
|
|
28
|
-
var import_react3 = require("react");
|
|
29
|
-
var import_react_native7 = require("react-native");
|
|
30
|
-
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
31
28
|
var import_core4 = require("@onlynative/core");
|
|
32
29
|
|
|
33
|
-
// src/
|
|
34
|
-
var import_react = require("react");
|
|
35
|
-
var import_react_native4 = require("react-native");
|
|
36
|
-
var import_core = require("@onlynative/core");
|
|
37
|
-
|
|
38
|
-
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
39
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
40
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
41
|
-
}) : x)(function(x) {
|
|
42
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
43
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// ../utils/dist/index.mjs
|
|
47
|
-
var import_react_native = require("react-native");
|
|
48
|
-
var import_react_native2 = require("react-native");
|
|
30
|
+
// ../utils/src/color.ts
|
|
49
31
|
function parseHexColor(color) {
|
|
50
32
|
const normalized = color.replace("#", "");
|
|
51
33
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -88,13 +70,15 @@ function blendColor(base, overlay, overlayAlpha) {
|
|
|
88
70
|
);
|
|
89
71
|
return `rgb(${r}, ${g}, ${b})`;
|
|
90
72
|
}
|
|
73
|
+
|
|
74
|
+
// ../utils/src/icon.ts
|
|
91
75
|
var _MCIcons = null;
|
|
92
76
|
var _resolved = false;
|
|
93
77
|
function getMaterialCommunityIcons() {
|
|
94
78
|
if (!_resolved) {
|
|
95
79
|
_resolved = true;
|
|
96
80
|
try {
|
|
97
|
-
const mod =
|
|
81
|
+
const mod = require("@expo/vector-icons/MaterialCommunityIcons");
|
|
98
82
|
_MCIcons = mod.default || mod;
|
|
99
83
|
} catch {
|
|
100
84
|
_MCIcons = null;
|
|
@@ -107,17 +91,30 @@ function getMaterialCommunityIcons() {
|
|
|
107
91
|
}
|
|
108
92
|
return _MCIcons;
|
|
109
93
|
}
|
|
94
|
+
|
|
95
|
+
// ../utils/src/rtl.ts
|
|
96
|
+
var import_react_native = require("react-native");
|
|
110
97
|
function selectRTL(ltr, rtl) {
|
|
111
|
-
return
|
|
98
|
+
return import_react_native.I18nManager.isRTL ? rtl : ltr;
|
|
112
99
|
}
|
|
113
100
|
|
|
114
|
-
// src/
|
|
101
|
+
// src/appbar/AppBar.tsx
|
|
102
|
+
var import_react3 = require("react");
|
|
103
|
+
var import_react_native6 = require("react-native");
|
|
104
|
+
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
105
|
+
|
|
106
|
+
// src/icon-button/IconButton.tsx
|
|
107
|
+
var import_core = require("@onlynative/core");
|
|
108
|
+
var import_react = require("react");
|
|
115
109
|
var import_react_native3 = require("react-native");
|
|
110
|
+
|
|
111
|
+
// src/icon-button/styles.ts
|
|
112
|
+
var import_react_native2 = require("react-native");
|
|
116
113
|
function createStyles(theme) {
|
|
117
114
|
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
118
115
|
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
119
116
|
const toggleUnselectedContainerColor = theme.colors.surfaceContainerHighest;
|
|
120
|
-
return
|
|
117
|
+
return import_react_native2.StyleSheet.create({
|
|
121
118
|
container: {
|
|
122
119
|
borderRadius: theme.shape.cornerFull,
|
|
123
120
|
alignItems: "center",
|
|
@@ -352,11 +349,13 @@ function createStyles(theme) {
|
|
|
352
349
|
borderColor: disabledContainerColor,
|
|
353
350
|
cursor: "auto"
|
|
354
351
|
},
|
|
352
|
+
// eslint-disable-next-line react-native/no-color-literals
|
|
355
353
|
disabledOutlined: {
|
|
356
354
|
backgroundColor: "transparent",
|
|
357
355
|
borderColor: disabledOutlineColor,
|
|
358
356
|
cursor: "auto"
|
|
359
357
|
},
|
|
358
|
+
// eslint-disable-next-line react-native/no-color-literals
|
|
360
359
|
disabledStandard: {
|
|
361
360
|
backgroundColor: "transparent",
|
|
362
361
|
borderColor: "transparent",
|
|
@@ -555,7 +554,7 @@ function IconButton({
|
|
|
555
554
|
};
|
|
556
555
|
}, [containerColor, resolvedIconColor, theme.stateLayer]);
|
|
557
556
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
558
|
-
|
|
557
|
+
import_react_native3.Pressable,
|
|
559
558
|
{
|
|
560
559
|
...props,
|
|
561
560
|
accessibilityRole: "button",
|
|
@@ -597,9 +596,9 @@ function IconButton({
|
|
|
597
596
|
}
|
|
598
597
|
|
|
599
598
|
// src/typography/Typography.tsx
|
|
600
|
-
var import_react2 = require("react");
|
|
601
|
-
var import_react_native5 = require("react-native");
|
|
602
599
|
var import_core2 = require("@onlynative/core");
|
|
600
|
+
var import_react2 = require("react");
|
|
601
|
+
var import_react_native4 = require("react-native");
|
|
603
602
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
604
603
|
var HEADING_VARIANTS = /* @__PURE__ */ new Set([
|
|
605
604
|
"displayLarge",
|
|
@@ -614,7 +613,7 @@ function Typography({
|
|
|
614
613
|
variant = "bodyMedium",
|
|
615
614
|
color,
|
|
616
615
|
style,
|
|
617
|
-
as: Component =
|
|
616
|
+
as: Component = import_react_native4.Text,
|
|
618
617
|
accessibilityRole,
|
|
619
618
|
...textProps
|
|
620
619
|
}) {
|
|
@@ -623,7 +622,7 @@ function Typography({
|
|
|
623
622
|
const resolvedRole = accessibilityRole != null ? accessibilityRole : HEADING_VARIANTS.has(variant) ? "header" : void 0;
|
|
624
623
|
const lineHeightFix = (0, import_react2.useMemo)(() => {
|
|
625
624
|
if (!style) return void 0;
|
|
626
|
-
const flat =
|
|
625
|
+
const flat = import_react_native4.StyleSheet.flatten(style);
|
|
627
626
|
if (!(flat == null ? void 0 : flat.fontSize) || flat.lineHeight) return void 0;
|
|
628
627
|
const ratio = typographyStyle.lineHeight / typographyStyle.fontSize;
|
|
629
628
|
return { lineHeight: Math.ceil(flat.fontSize * ratio) };
|
|
@@ -646,8 +645,8 @@ function Typography({
|
|
|
646
645
|
}
|
|
647
646
|
|
|
648
647
|
// src/appbar/styles.ts
|
|
649
|
-
var import_react_native6 = require("react-native");
|
|
650
648
|
var import_core3 = require("@onlynative/core");
|
|
649
|
+
var import_react_native5 = require("react-native");
|
|
651
650
|
function getColorSchemeColors(theme, colorScheme) {
|
|
652
651
|
switch (colorScheme) {
|
|
653
652
|
case "surfaceContainerLowest":
|
|
@@ -704,7 +703,7 @@ function getColorSchemeColors(theme, colorScheme) {
|
|
|
704
703
|
function createStyles2(theme, schemeColors) {
|
|
705
704
|
var _a;
|
|
706
705
|
const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core3.defaultTopAppBarTokens;
|
|
707
|
-
return
|
|
706
|
+
return import_react_native5.StyleSheet.create({
|
|
708
707
|
root: {
|
|
709
708
|
backgroundColor: schemeColors.containerColor
|
|
710
709
|
},
|
|
@@ -793,7 +792,7 @@ function createStyles2(theme, schemeColors) {
|
|
|
793
792
|
// src/appbar/AppBar.tsx
|
|
794
793
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
795
794
|
function getBackIcon() {
|
|
796
|
-
if (
|
|
795
|
+
if (import_react_native6.Platform.OS === "ios") {
|
|
797
796
|
return selectRTL("chevron-left", "chevron-right");
|
|
798
797
|
}
|
|
799
798
|
return selectRTL("arrow-left", "arrow-right");
|
|
@@ -824,7 +823,7 @@ function withTopInset(enabled, content, style) {
|
|
|
824
823
|
if (enabled) {
|
|
825
824
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_safe_area_context.SafeAreaView, { edges: ["top"], style, children: content });
|
|
826
825
|
}
|
|
827
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
826
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style, children: content });
|
|
828
827
|
}
|
|
829
828
|
function measureWidth(event) {
|
|
830
829
|
return Math.round(event.nativeEvent.layout.width);
|
|
@@ -885,7 +884,7 @@ function AppBar({
|
|
|
885
884
|
if (!canGoBack) {
|
|
886
885
|
return null;
|
|
887
886
|
}
|
|
888
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: styles.iconFrame, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
889
888
|
IconButton,
|
|
890
889
|
{
|
|
891
890
|
icon: getBackIcon(),
|
|
@@ -904,8 +903,8 @@ function AppBar({
|
|
|
904
903
|
if (!actions || actions.length === 0) {
|
|
905
904
|
return null;
|
|
906
905
|
}
|
|
907
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
908
|
-
|
|
906
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: styles.actionsRow, children: actions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
907
|
+
import_react_native6.View,
|
|
909
908
|
{
|
|
910
909
|
style: styles.iconFrame,
|
|
911
910
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -923,7 +922,13 @@ function AppBar({
|
|
|
923
922
|
},
|
|
924
923
|
`${String(action.icon)}-${index}`
|
|
925
924
|
)) });
|
|
926
|
-
}, [
|
|
925
|
+
}, [
|
|
926
|
+
actions,
|
|
927
|
+
resolvedContentColor,
|
|
928
|
+
styles.actionsRow,
|
|
929
|
+
styles.iconFrame,
|
|
930
|
+
trailing
|
|
931
|
+
]);
|
|
927
932
|
const onLeadingLayout = (0, import_react3.useCallback)((event) => {
|
|
928
933
|
const nextWidth = measureWidth(event);
|
|
929
934
|
setLeadingWidth((currentWidth) => {
|
|
@@ -942,9 +947,9 @@ function AppBar({
|
|
|
942
947
|
return nextWidth;
|
|
943
948
|
});
|
|
944
949
|
}, []);
|
|
945
|
-
const topRow = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
950
|
+
const topRow = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native6.View, { style: styles.topRow, children: [
|
|
946
951
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
947
|
-
|
|
952
|
+
import_react_native6.View,
|
|
948
953
|
{
|
|
949
954
|
collapsable: false,
|
|
950
955
|
onLayout: onLeadingLayout,
|
|
@@ -952,9 +957,9 @@ function AppBar({
|
|
|
952
957
|
children: leadingContent
|
|
953
958
|
}
|
|
954
959
|
),
|
|
955
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
960
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: styles.topRowSpacer }),
|
|
956
961
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
957
|
-
|
|
962
|
+
import_react_native6.View,
|
|
958
963
|
{
|
|
959
964
|
collapsable: false,
|
|
960
965
|
onLayout: onActionsLayout,
|
|
@@ -976,10 +981,10 @@ function AppBar({
|
|
|
976
981
|
containerOverride
|
|
977
982
|
];
|
|
978
983
|
if (isExpanded) {
|
|
979
|
-
const content2 = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
984
|
+
const content2 = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native6.View, { style: [styles.expandedContainer, getSizeStyle2(styles, size)], children: [
|
|
980
985
|
topRow,
|
|
981
986
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
982
|
-
|
|
987
|
+
import_react_native6.View,
|
|
983
988
|
{
|
|
984
989
|
style: [
|
|
985
990
|
styles.expandedTitleContainer,
|
|
@@ -1003,11 +1008,11 @@ function AppBar({
|
|
|
1003
1008
|
}
|
|
1004
1009
|
)
|
|
1005
1010
|
] });
|
|
1006
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: rootStyle, children: withTopInset(insetTop, content2, safeAreaStyle) });
|
|
1007
1012
|
}
|
|
1008
|
-
const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1013
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native6.View, { style: styles.smallContainer, children: [
|
|
1009
1014
|
topRow,
|
|
1010
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1015
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: [styles.overlayTitleContainer, overlayTitleInsetStyle], children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1011
1016
|
Typography,
|
|
1012
1017
|
{
|
|
1013
1018
|
...APP_BAR_TITLE_TEXT_PROPS,
|
|
@@ -1022,7 +1027,7 @@ function AppBar({
|
|
|
1022
1027
|
}
|
|
1023
1028
|
) })
|
|
1024
1029
|
] });
|
|
1025
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1030
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: rootStyle, children: withTopInset(insetTop, content, safeAreaStyle) });
|
|
1026
1031
|
}
|
|
1027
1032
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1028
1033
|
0 && (module.exports = {
|
package/dist/avatar/index.js
CHANGED
|
@@ -25,21 +25,9 @@ __export(avatar_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(avatar_exports);
|
|
26
26
|
|
|
27
27
|
// src/avatar/Avatar.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,10 +92,14 @@ function getMaterialCommunityIcons() {
|
|
|
102
92
|
return _MCIcons;
|
|
103
93
|
}
|
|
104
94
|
|
|
95
|
+
// src/avatar/Avatar.tsx
|
|
96
|
+
var import_react = require("react");
|
|
97
|
+
var import_react_native2 = require("react-native");
|
|
98
|
+
|
|
105
99
|
// src/avatar/styles.ts
|
|
106
|
-
var
|
|
100
|
+
var import_react_native = require("react-native");
|
|
107
101
|
function createStyles(theme) {
|
|
108
|
-
return
|
|
102
|
+
return import_react_native.StyleSheet.create({
|
|
109
103
|
container: {
|
|
110
104
|
borderRadius: theme.shape.cornerFull,
|
|
111
105
|
alignItems: "center",
|
|
@@ -200,7 +194,7 @@ function Avatar({
|
|
|
200
194
|
}),
|
|
201
195
|
[bgColor, fgColor, theme.stateLayer]
|
|
202
196
|
);
|
|
203
|
-
const content = imageUri ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
197
|
+
const content = imageUri ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Image, { source: { uri: imageUri }, style: styles.image, accessible: false }) : label && !icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: initialsStyle, numberOfLines: 1, allowFontScaling: false, children: initials }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
204
198
|
MaterialCommunityIcons,
|
|
205
199
|
{
|
|
206
200
|
name: icon != null ? icon : "account",
|
|
@@ -210,7 +204,7 @@ function Avatar({
|
|
|
210
204
|
);
|
|
211
205
|
if (!isInteractive) {
|
|
212
206
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
213
|
-
|
|
207
|
+
import_react_native2.View,
|
|
214
208
|
{
|
|
215
209
|
...props,
|
|
216
210
|
accessibilityLabel,
|
|
@@ -220,7 +214,7 @@ function Avatar({
|
|
|
220
214
|
);
|
|
221
215
|
}
|
|
222
216
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
223
|
-
|
|
217
|
+
import_react_native2.Pressable,
|
|
224
218
|
{
|
|
225
219
|
...props,
|
|
226
220
|
accessibilityRole: "button",
|
package/dist/button/index.js
CHANGED
|
@@ -25,23 +25,9 @@ __export(button_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(button_exports);
|
|
26
26
|
|
|
27
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
28
|
var import_core = require("@onlynative/core");
|
|
33
29
|
|
|
34
|
-
// ../utils/
|
|
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");
|
|
30
|
+
// ../utils/src/color.ts
|
|
45
31
|
function parseHexColor(color) {
|
|
46
32
|
const normalized = color.replace("#", "");
|
|
47
33
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -84,6 +70,9 @@ function blendColor(base, overlay, overlayAlpha) {
|
|
|
84
70
|
);
|
|
85
71
|
return `rgb(${r}, ${g}, ${b})`;
|
|
86
72
|
}
|
|
73
|
+
|
|
74
|
+
// ../utils/src/elevation.ts
|
|
75
|
+
var import_react_native = require("react-native");
|
|
87
76
|
function elevationStyle(level) {
|
|
88
77
|
if (import_react_native.Platform.OS === "web") {
|
|
89
78
|
const { shadowOffset, shadowOpacity, shadowRadius } = level;
|
|
@@ -105,13 +94,15 @@ function elevationStyle(level) {
|
|
|
105
94
|
elevation: level.elevation
|
|
106
95
|
};
|
|
107
96
|
}
|
|
97
|
+
|
|
98
|
+
// ../utils/src/icon.ts
|
|
108
99
|
var _MCIcons = null;
|
|
109
100
|
var _resolved = false;
|
|
110
101
|
function getMaterialCommunityIcons() {
|
|
111
102
|
if (!_resolved) {
|
|
112
103
|
_resolved = true;
|
|
113
104
|
try {
|
|
114
|
-
const mod =
|
|
105
|
+
const mod = require("@expo/vector-icons/MaterialCommunityIcons");
|
|
115
106
|
_MCIcons = mod.default || mod;
|
|
116
107
|
} catch {
|
|
117
108
|
_MCIcons = null;
|
|
@@ -125,6 +116,35 @@ function getMaterialCommunityIcons() {
|
|
|
125
116
|
return _MCIcons;
|
|
126
117
|
}
|
|
127
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/button/Button.tsx
|
|
145
|
+
var import_react = require("react");
|
|
146
|
+
var import_react_native4 = require("react-native");
|
|
147
|
+
|
|
128
148
|
// src/button/styles.ts
|
|
129
149
|
var import_react_native3 = require("react-native");
|
|
130
150
|
function getVariantColors(theme, variant) {
|
|
@@ -360,24 +380,6 @@ function createStyles(theme, variant, hasLeadingIcon, hasTrailingIcon, container
|
|
|
360
380
|
|
|
361
381
|
// src/button/Button.tsx
|
|
362
382
|
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
383
|
function Button({
|
|
382
384
|
children,
|
|
383
385
|
style,
|
|
@@ -407,13 +409,13 @@ function Button({
|
|
|
407
409
|
[theme, variant, hasLeading, hasTrailing, containerColor, contentColor]
|
|
408
410
|
);
|
|
409
411
|
const MaterialCommunityIcons = leadingIcon || trailingIcon ? getMaterialCommunityIcons() : null;
|
|
410
|
-
const resolvedIconColor = (0, import_react.useMemo)(
|
|
411
|
-
|
|
412
|
+
const resolvedIconColor = (0, import_react.useMemo)(
|
|
413
|
+
() => resolveColorFromStyle(
|
|
412
414
|
styles.label,
|
|
413
415
|
isDisabled ? styles.disabledLabel : void 0
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
416
|
+
),
|
|
417
|
+
[styles.label, styles.disabledLabel, isDisabled]
|
|
418
|
+
);
|
|
417
419
|
const computedLabelStyle = (0, import_react.useMemo)(
|
|
418
420
|
() => [
|
|
419
421
|
styles.label,
|
|
@@ -430,7 +432,7 @@ function Button({
|
|
|
430
432
|
accessibilityState: { disabled: isDisabled },
|
|
431
433
|
hitSlop: import_react_native4.Platform.OS === "web" ? void 0 : 4,
|
|
432
434
|
disabled: isDisabled,
|
|
433
|
-
style:
|
|
435
|
+
style: resolvePressableStyle(
|
|
434
436
|
styles.container,
|
|
435
437
|
styles.hoveredContainer,
|
|
436
438
|
styles.pressedContainer,
|
|
@@ -448,7 +450,7 @@ function Button({
|
|
|
448
450
|
style: styles.leadingIcon
|
|
449
451
|
}
|
|
450
452
|
) : null,
|
|
451
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
453
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native4.Text, { style: computedLabelStyle, children }),
|
|
452
454
|
trailingIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
453
455
|
MaterialCommunityIcons,
|
|
454
456
|
{
|
package/dist/card/index.js
CHANGED
|
@@ -25,16 +25,9 @@ __export(card_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(card_exports);
|
|
26
26
|
|
|
27
27
|
// src/card/Card.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
|
-
// src/
|
|
33
|
-
var import_react_native3 = require("react-native");
|
|
34
|
-
|
|
35
|
-
// ../utils/dist/index.mjs
|
|
36
|
-
var import_react_native = require("react-native");
|
|
37
|
-
var import_react_native2 = require("react-native");
|
|
30
|
+
// ../utils/src/color.ts
|
|
38
31
|
function parseHexColor(color) {
|
|
39
32
|
const normalized = color.replace("#", "");
|
|
40
33
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -77,6 +70,9 @@ function blendColor(base, overlay, overlayAlpha) {
|
|
|
77
70
|
);
|
|
78
71
|
return `rgb(${r}, ${g}, ${b})`;
|
|
79
72
|
}
|
|
73
|
+
|
|
74
|
+
// ../utils/src/elevation.ts
|
|
75
|
+
var import_react_native = require("react-native");
|
|
80
76
|
function elevationStyle(level) {
|
|
81
77
|
if (import_react_native.Platform.OS === "web") {
|
|
82
78
|
const { shadowOffset, shadowOpacity, shadowRadius } = level;
|
|
@@ -99,7 +95,33 @@ function elevationStyle(level) {
|
|
|
99
95
|
};
|
|
100
96
|
}
|
|
101
97
|
|
|
98
|
+
// ../utils/src/pressable.ts
|
|
99
|
+
var import_react_native2 = require("react-native");
|
|
100
|
+
function resolvePressableStyle(base, hovered, pressed, disabled, isDisabled, style) {
|
|
101
|
+
if (typeof style === "function") {
|
|
102
|
+
return (state) => [
|
|
103
|
+
base,
|
|
104
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
105
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
106
|
+
isDisabled ? disabled : void 0,
|
|
107
|
+
style(state)
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
return (state) => [
|
|
111
|
+
base,
|
|
112
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
113
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
114
|
+
isDisabled ? disabled : void 0,
|
|
115
|
+
style
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/card/Card.tsx
|
|
120
|
+
var import_react = require("react");
|
|
121
|
+
var import_react_native4 = require("react-native");
|
|
122
|
+
|
|
102
123
|
// src/card/styles.ts
|
|
124
|
+
var import_react_native3 = require("react-native");
|
|
103
125
|
function getVariantColors(theme, variant) {
|
|
104
126
|
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
105
127
|
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
@@ -235,14 +257,6 @@ function Card({
|
|
|
235
257
|
if (!isInteractive) {
|
|
236
258
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native4.View, { ...props, style: [styles.container, style], children });
|
|
237
259
|
}
|
|
238
|
-
const resolvedStyle = (state) => [
|
|
239
|
-
styles.container,
|
|
240
|
-
styles.interactiveContainer,
|
|
241
|
-
state.hovered && !state.pressed && !isDisabled ? styles.hoveredContainer : void 0,
|
|
242
|
-
state.pressed && !isDisabled ? styles.pressedContainer : void 0,
|
|
243
|
-
isDisabled ? styles.disabledContainer : void 0,
|
|
244
|
-
typeof style === "function" ? style(state) : style
|
|
245
|
-
];
|
|
246
260
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
247
261
|
import_react_native4.Pressable,
|
|
248
262
|
{
|
|
@@ -252,7 +266,14 @@ function Card({
|
|
|
252
266
|
hitSlop: import_react_native4.Platform.OS === "web" ? void 0 : 4,
|
|
253
267
|
disabled: isDisabled,
|
|
254
268
|
onPress,
|
|
255
|
-
style:
|
|
269
|
+
style: resolvePressableStyle(
|
|
270
|
+
[styles.container, styles.interactiveContainer],
|
|
271
|
+
styles.hoveredContainer,
|
|
272
|
+
styles.pressedContainer,
|
|
273
|
+
styles.disabledContainer,
|
|
274
|
+
isDisabled,
|
|
275
|
+
style
|
|
276
|
+
),
|
|
256
277
|
children: isDisabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native4.View, { style: styles.disabledContent, children }) : children
|
|
257
278
|
}
|
|
258
279
|
);
|