@onlynative/components 0.0.0-alpha.0 → 0.0.0-alpha.1
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/dist/appbar/index.js +27 -26
- package/dist/avatar/index.js +7 -6
- package/dist/button/index.js +34 -31
- package/dist/card/index.js +34 -18
- package/dist/checkbox/index.js +35 -30
- package/dist/chip/index.js +37 -32
- package/dist/icon-button/index.js +5 -4
- package/dist/index.js +185 -252
- package/dist/list/index.js +52 -30
- package/dist/radio/index.js +27 -28
- package/dist/switch/index.js +35 -30
- package/dist/text-field/index.js +19 -18
- package/llms.txt +2 -2
- package/package.json +3 -18
package/dist/appbar/index.js
CHANGED
|
@@ -26,13 +26,13 @@ module.exports = __toCommonJS(appbar_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/appbar/AppBar.tsx
|
|
28
28
|
var import_react3 = require("react");
|
|
29
|
-
var
|
|
29
|
+
var import_react_native8 = require("react-native");
|
|
30
30
|
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
31
31
|
var import_core4 = require("@onlynative/core");
|
|
32
32
|
|
|
33
33
|
// src/icon-button/IconButton.tsx
|
|
34
34
|
var import_react = require("react");
|
|
35
|
-
var
|
|
35
|
+
var import_react_native5 = require("react-native");
|
|
36
36
|
var import_core = require("@onlynative/core");
|
|
37
37
|
|
|
38
38
|
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
@@ -46,6 +46,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
46
46
|
// ../utils/dist/index.mjs
|
|
47
47
|
var import_react_native = require("react-native");
|
|
48
48
|
var import_react_native2 = require("react-native");
|
|
49
|
+
var import_react_native3 = require("react-native");
|
|
49
50
|
function parseHexColor(color) {
|
|
50
51
|
const normalized = color.replace("#", "");
|
|
51
52
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -108,16 +109,16 @@ function getMaterialCommunityIcons() {
|
|
|
108
109
|
return _MCIcons;
|
|
109
110
|
}
|
|
110
111
|
function selectRTL(ltr, rtl) {
|
|
111
|
-
return
|
|
112
|
+
return import_react_native3.I18nManager.isRTL ? rtl : ltr;
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
// src/icon-button/styles.ts
|
|
115
|
-
var
|
|
116
|
+
var import_react_native4 = require("react-native");
|
|
116
117
|
function createStyles(theme) {
|
|
117
118
|
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
118
119
|
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
119
120
|
const toggleUnselectedContainerColor = theme.colors.surfaceContainerHighest;
|
|
120
|
-
return
|
|
121
|
+
return import_react_native4.StyleSheet.create({
|
|
121
122
|
container: {
|
|
122
123
|
borderRadius: theme.shape.cornerFull,
|
|
123
124
|
alignItems: "center",
|
|
@@ -555,7 +556,7 @@ function IconButton({
|
|
|
555
556
|
};
|
|
556
557
|
}, [containerColor, resolvedIconColor, theme.stateLayer]);
|
|
557
558
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
558
|
-
|
|
559
|
+
import_react_native5.Pressable,
|
|
559
560
|
{
|
|
560
561
|
...props,
|
|
561
562
|
accessibilityRole: "button",
|
|
@@ -598,7 +599,7 @@ function IconButton({
|
|
|
598
599
|
|
|
599
600
|
// src/typography/Typography.tsx
|
|
600
601
|
var import_react2 = require("react");
|
|
601
|
-
var
|
|
602
|
+
var import_react_native6 = require("react-native");
|
|
602
603
|
var import_core2 = require("@onlynative/core");
|
|
603
604
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
604
605
|
var HEADING_VARIANTS = /* @__PURE__ */ new Set([
|
|
@@ -614,7 +615,7 @@ function Typography({
|
|
|
614
615
|
variant = "bodyMedium",
|
|
615
616
|
color,
|
|
616
617
|
style,
|
|
617
|
-
as: Component =
|
|
618
|
+
as: Component = import_react_native6.Text,
|
|
618
619
|
accessibilityRole,
|
|
619
620
|
...textProps
|
|
620
621
|
}) {
|
|
@@ -623,7 +624,7 @@ function Typography({
|
|
|
623
624
|
const resolvedRole = accessibilityRole != null ? accessibilityRole : HEADING_VARIANTS.has(variant) ? "header" : void 0;
|
|
624
625
|
const lineHeightFix = (0, import_react2.useMemo)(() => {
|
|
625
626
|
if (!style) return void 0;
|
|
626
|
-
const flat =
|
|
627
|
+
const flat = import_react_native6.StyleSheet.flatten(style);
|
|
627
628
|
if (!(flat == null ? void 0 : flat.fontSize) || flat.lineHeight) return void 0;
|
|
628
629
|
const ratio = typographyStyle.lineHeight / typographyStyle.fontSize;
|
|
629
630
|
return { lineHeight: Math.ceil(flat.fontSize * ratio) };
|
|
@@ -646,7 +647,7 @@ function Typography({
|
|
|
646
647
|
}
|
|
647
648
|
|
|
648
649
|
// src/appbar/styles.ts
|
|
649
|
-
var
|
|
650
|
+
var import_react_native7 = require("react-native");
|
|
650
651
|
var import_core3 = require("@onlynative/core");
|
|
651
652
|
function getColorSchemeColors(theme, colorScheme) {
|
|
652
653
|
switch (colorScheme) {
|
|
@@ -704,7 +705,7 @@ function getColorSchemeColors(theme, colorScheme) {
|
|
|
704
705
|
function createStyles2(theme, schemeColors) {
|
|
705
706
|
var _a;
|
|
706
707
|
const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core3.defaultTopAppBarTokens;
|
|
707
|
-
return
|
|
708
|
+
return import_react_native7.StyleSheet.create({
|
|
708
709
|
root: {
|
|
709
710
|
backgroundColor: schemeColors.containerColor
|
|
710
711
|
},
|
|
@@ -793,7 +794,7 @@ function createStyles2(theme, schemeColors) {
|
|
|
793
794
|
// src/appbar/AppBar.tsx
|
|
794
795
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
795
796
|
function getBackIcon() {
|
|
796
|
-
if (
|
|
797
|
+
if (import_react_native8.Platform.OS === "ios") {
|
|
797
798
|
return selectRTL("chevron-left", "chevron-right");
|
|
798
799
|
}
|
|
799
800
|
return selectRTL("arrow-left", "arrow-right");
|
|
@@ -824,7 +825,7 @@ function withTopInset(enabled, content, style) {
|
|
|
824
825
|
if (enabled) {
|
|
825
826
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_safe_area_context.SafeAreaView, { edges: ["top"], style, children: content });
|
|
826
827
|
}
|
|
827
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native8.View, { style, children: content });
|
|
828
829
|
}
|
|
829
830
|
function measureWidth(event) {
|
|
830
831
|
return Math.round(event.nativeEvent.layout.width);
|
|
@@ -885,7 +886,7 @@ function AppBar({
|
|
|
885
886
|
if (!canGoBack) {
|
|
886
887
|
return null;
|
|
887
888
|
}
|
|
888
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native8.View, { style: styles.iconFrame, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
889
890
|
IconButton,
|
|
890
891
|
{
|
|
891
892
|
icon: getBackIcon(),
|
|
@@ -904,8 +905,8 @@ function AppBar({
|
|
|
904
905
|
if (!actions || actions.length === 0) {
|
|
905
906
|
return null;
|
|
906
907
|
}
|
|
907
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
908
|
-
|
|
908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native8.View, { style: styles.actionsRow, children: actions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
909
|
+
import_react_native8.View,
|
|
909
910
|
{
|
|
910
911
|
style: styles.iconFrame,
|
|
911
912
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -942,9 +943,9 @@ function AppBar({
|
|
|
942
943
|
return nextWidth;
|
|
943
944
|
});
|
|
944
945
|
}, []);
|
|
945
|
-
const topRow = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
946
|
+
const topRow = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native8.View, { style: styles.topRow, children: [
|
|
946
947
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
947
|
-
|
|
948
|
+
import_react_native8.View,
|
|
948
949
|
{
|
|
949
950
|
collapsable: false,
|
|
950
951
|
onLayout: onLeadingLayout,
|
|
@@ -952,9 +953,9 @@ function AppBar({
|
|
|
952
953
|
children: leadingContent
|
|
953
954
|
}
|
|
954
955
|
),
|
|
955
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
956
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native8.View, { style: styles.topRowSpacer }),
|
|
956
957
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
957
|
-
|
|
958
|
+
import_react_native8.View,
|
|
958
959
|
{
|
|
959
960
|
collapsable: false,
|
|
960
961
|
onLayout: onActionsLayout,
|
|
@@ -976,10 +977,10 @@ function AppBar({
|
|
|
976
977
|
containerOverride
|
|
977
978
|
];
|
|
978
979
|
if (isExpanded) {
|
|
979
|
-
const content2 = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
980
|
+
const content2 = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native8.View, { style: [styles.expandedContainer, getSizeStyle2(styles, size)], children: [
|
|
980
981
|
topRow,
|
|
981
982
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
982
|
-
|
|
983
|
+
import_react_native8.View,
|
|
983
984
|
{
|
|
984
985
|
style: [
|
|
985
986
|
styles.expandedTitleContainer,
|
|
@@ -1003,11 +1004,11 @@ function AppBar({
|
|
|
1003
1004
|
}
|
|
1004
1005
|
)
|
|
1005
1006
|
] });
|
|
1006
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native8.View, { style: rootStyle, children: withTopInset(insetTop, content2, safeAreaStyle) });
|
|
1007
1008
|
}
|
|
1008
|
-
const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1009
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native8.View, { style: styles.smallContainer, children: [
|
|
1009
1010
|
topRow,
|
|
1010
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1011
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native8.View, { style: [styles.overlayTitleContainer, overlayTitleInsetStyle], children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1011
1012
|
Typography,
|
|
1012
1013
|
{
|
|
1013
1014
|
...APP_BAR_TITLE_TEXT_PROPS,
|
|
@@ -1022,7 +1023,7 @@ function AppBar({
|
|
|
1022
1023
|
}
|
|
1023
1024
|
) })
|
|
1024
1025
|
] });
|
|
1025
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native8.View, { style: rootStyle, children: withTopInset(insetTop, content, safeAreaStyle) });
|
|
1026
1027
|
}
|
|
1027
1028
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1028
1029
|
0 && (module.exports = {
|
package/dist/avatar/index.js
CHANGED
|
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(avatar_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/avatar/Avatar.tsx
|
|
28
28
|
var import_react = require("react");
|
|
29
|
-
var
|
|
29
|
+
var import_react_native5 = require("react-native");
|
|
30
30
|
var import_core = require("@onlynative/core");
|
|
31
31
|
|
|
32
32
|
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
@@ -40,6 +40,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
40
40
|
// ../utils/dist/index.mjs
|
|
41
41
|
var import_react_native = require("react-native");
|
|
42
42
|
var import_react_native2 = require("react-native");
|
|
43
|
+
var import_react_native3 = require("react-native");
|
|
43
44
|
function parseHexColor(color) {
|
|
44
45
|
const normalized = color.replace("#", "");
|
|
45
46
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -103,9 +104,9 @@ function getMaterialCommunityIcons() {
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
// src/avatar/styles.ts
|
|
106
|
-
var
|
|
107
|
+
var import_react_native4 = require("react-native");
|
|
107
108
|
function createStyles(theme) {
|
|
108
|
-
return
|
|
109
|
+
return import_react_native4.StyleSheet.create({
|
|
109
110
|
container: {
|
|
110
111
|
borderRadius: theme.shape.cornerFull,
|
|
111
112
|
alignItems: "center",
|
|
@@ -200,7 +201,7 @@ function Avatar({
|
|
|
200
201
|
}),
|
|
201
202
|
[bgColor, fgColor, theme.stateLayer]
|
|
202
203
|
);
|
|
203
|
-
const content = imageUri ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
204
|
+
const content = imageUri ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Image, { source: { uri: imageUri }, style: styles.image, accessible: false }) : label && !icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Text, { style: initialsStyle, numberOfLines: 1, allowFontScaling: false, children: initials }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
204
205
|
MaterialCommunityIcons,
|
|
205
206
|
{
|
|
206
207
|
name: icon != null ? icon : "account",
|
|
@@ -210,7 +211,7 @@ function Avatar({
|
|
|
210
211
|
);
|
|
211
212
|
if (!isInteractive) {
|
|
212
213
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
213
|
-
|
|
214
|
+
import_react_native5.View,
|
|
214
215
|
{
|
|
215
216
|
...props,
|
|
216
217
|
accessibilityLabel,
|
|
@@ -220,7 +221,7 @@ function Avatar({
|
|
|
220
221
|
);
|
|
221
222
|
}
|
|
222
223
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
223
|
-
|
|
224
|
+
import_react_native5.Pressable,
|
|
224
225
|
{
|
|
225
226
|
...props,
|
|
226
227
|
accessibilityRole: "button",
|
package/dist/button/index.js
CHANGED
|
@@ -26,9 +26,7 @@ module.exports = __toCommonJS(button_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/button/Button.tsx
|
|
28
28
|
var import_react = require("react");
|
|
29
|
-
var import_react_native4 = require("react-native");
|
|
30
29
|
var import_react_native5 = require("react-native");
|
|
31
|
-
var import_react_native6 = require("react-native");
|
|
32
30
|
var import_core = require("@onlynative/core");
|
|
33
31
|
|
|
34
32
|
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
@@ -42,6 +40,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
42
40
|
// ../utils/dist/index.mjs
|
|
43
41
|
var import_react_native = require("react-native");
|
|
44
42
|
var import_react_native2 = require("react-native");
|
|
43
|
+
var import_react_native3 = require("react-native");
|
|
45
44
|
function parseHexColor(color) {
|
|
46
45
|
const normalized = color.replace("#", "");
|
|
47
46
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -124,9 +123,31 @@ function getMaterialCommunityIcons() {
|
|
|
124
123
|
}
|
|
125
124
|
return _MCIcons;
|
|
126
125
|
}
|
|
126
|
+
function resolvePressableStyle(base, hovered, pressed, disabled, isDisabled, style) {
|
|
127
|
+
if (typeof style === "function") {
|
|
128
|
+
return (state) => [
|
|
129
|
+
base,
|
|
130
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
131
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
132
|
+
isDisabled ? disabled : void 0,
|
|
133
|
+
style(state)
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
return (state) => [
|
|
137
|
+
base,
|
|
138
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
139
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
140
|
+
isDisabled ? disabled : void 0,
|
|
141
|
+
style
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
function resolveColorFromStyle(...styles) {
|
|
145
|
+
const flattened = import_react_native2.StyleSheet.flatten(styles);
|
|
146
|
+
return typeof (flattened == null ? void 0 : flattened.color) === "string" ? flattened.color : void 0;
|
|
147
|
+
}
|
|
127
148
|
|
|
128
149
|
// src/button/styles.ts
|
|
129
|
-
var
|
|
150
|
+
var import_react_native4 = require("react-native");
|
|
130
151
|
function getVariantColors(theme, variant) {
|
|
131
152
|
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
132
153
|
const disabledLabelColor = alphaColor(theme.colors.onSurface, 0.38);
|
|
@@ -307,7 +328,7 @@ function createStyles(theme, variant, hasLeadingIcon, hasTrailingIcon, container
|
|
|
307
328
|
const elevationLevel1 = elevationStyle(theme.elevation.level1);
|
|
308
329
|
const elevationLevel2 = elevationStyle(theme.elevation.level2);
|
|
309
330
|
const baseElevation = variant === "elevated" ? elevationLevel1 : elevationLevel0;
|
|
310
|
-
return
|
|
331
|
+
return import_react_native4.StyleSheet.create({
|
|
311
332
|
container: {
|
|
312
333
|
alignSelf: "flex-start",
|
|
313
334
|
alignItems: "center",
|
|
@@ -360,24 +381,6 @@ function createStyles(theme, variant, hasLeadingIcon, hasTrailingIcon, container
|
|
|
360
381
|
|
|
361
382
|
// src/button/Button.tsx
|
|
362
383
|
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
384
|
function Button({
|
|
382
385
|
children,
|
|
383
386
|
style,
|
|
@@ -407,13 +410,13 @@ function Button({
|
|
|
407
410
|
[theme, variant, hasLeading, hasTrailing, containerColor, contentColor]
|
|
408
411
|
);
|
|
409
412
|
const MaterialCommunityIcons = leadingIcon || trailingIcon ? getMaterialCommunityIcons() : null;
|
|
410
|
-
const resolvedIconColor = (0, import_react.useMemo)(
|
|
411
|
-
|
|
413
|
+
const resolvedIconColor = (0, import_react.useMemo)(
|
|
414
|
+
() => resolveColorFromStyle(
|
|
412
415
|
styles.label,
|
|
413
416
|
isDisabled ? styles.disabledLabel : void 0
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
+
),
|
|
418
|
+
[styles.label, styles.disabledLabel, isDisabled]
|
|
419
|
+
);
|
|
417
420
|
const computedLabelStyle = (0, import_react.useMemo)(
|
|
418
421
|
() => [
|
|
419
422
|
styles.label,
|
|
@@ -423,14 +426,14 @@ function Button({
|
|
|
423
426
|
[isDisabled, styles.disabledLabel, styles.label, labelStyleOverride]
|
|
424
427
|
);
|
|
425
428
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
426
|
-
|
|
429
|
+
import_react_native5.Pressable,
|
|
427
430
|
{
|
|
428
431
|
...props,
|
|
429
432
|
accessibilityRole: "button",
|
|
430
433
|
accessibilityState: { disabled: isDisabled },
|
|
431
|
-
hitSlop:
|
|
434
|
+
hitSlop: import_react_native5.Platform.OS === "web" ? void 0 : 4,
|
|
432
435
|
disabled: isDisabled,
|
|
433
|
-
style:
|
|
436
|
+
style: resolvePressableStyle(
|
|
434
437
|
styles.container,
|
|
435
438
|
styles.hoveredContainer,
|
|
436
439
|
styles.pressedContainer,
|
|
@@ -448,7 +451,7 @@ function Button({
|
|
|
448
451
|
style: styles.leadingIcon
|
|
449
452
|
}
|
|
450
453
|
) : null,
|
|
451
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
454
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Text, { style: computedLabelStyle, children }),
|
|
452
455
|
trailingIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
453
456
|
MaterialCommunityIcons,
|
|
454
457
|
{
|
package/dist/card/index.js
CHANGED
|
@@ -26,15 +26,13 @@ module.exports = __toCommonJS(card_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/card/Card.tsx
|
|
28
28
|
var import_react = require("react");
|
|
29
|
-
var
|
|
29
|
+
var import_react_native5 = require("react-native");
|
|
30
30
|
var import_core = require("@onlynative/core");
|
|
31
31
|
|
|
32
|
-
// src/card/styles.ts
|
|
33
|
-
var import_react_native3 = require("react-native");
|
|
34
|
-
|
|
35
32
|
// ../utils/dist/index.mjs
|
|
36
33
|
var import_react_native = require("react-native");
|
|
37
34
|
var import_react_native2 = require("react-native");
|
|
35
|
+
var import_react_native3 = require("react-native");
|
|
38
36
|
function parseHexColor(color) {
|
|
39
37
|
const normalized = color.replace("#", "");
|
|
40
38
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -98,8 +96,27 @@ function elevationStyle(level) {
|
|
|
98
96
|
elevation: level.elevation
|
|
99
97
|
};
|
|
100
98
|
}
|
|
99
|
+
function resolvePressableStyle(base, hovered, pressed, disabled, isDisabled, style) {
|
|
100
|
+
if (typeof style === "function") {
|
|
101
|
+
return (state) => [
|
|
102
|
+
base,
|
|
103
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
104
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
105
|
+
isDisabled ? disabled : void 0,
|
|
106
|
+
style(state)
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
return (state) => [
|
|
110
|
+
base,
|
|
111
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
112
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
113
|
+
isDisabled ? disabled : void 0,
|
|
114
|
+
style
|
|
115
|
+
];
|
|
116
|
+
}
|
|
101
117
|
|
|
102
118
|
// src/card/styles.ts
|
|
119
|
+
var import_react_native4 = require("react-native");
|
|
103
120
|
function getVariantColors(theme, variant) {
|
|
104
121
|
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
105
122
|
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
@@ -183,7 +200,7 @@ function createStyles(theme, variant, containerColor) {
|
|
|
183
200
|
const elevationLevel1 = elevationStyle(theme.elevation.level1);
|
|
184
201
|
const elevationLevel2 = elevationStyle(theme.elevation.level2);
|
|
185
202
|
const baseElevation = variant === "elevated" ? elevationLevel1 : elevationLevel0;
|
|
186
|
-
return
|
|
203
|
+
return import_react_native4.StyleSheet.create({
|
|
187
204
|
container: {
|
|
188
205
|
borderRadius: theme.shape.cornerMedium,
|
|
189
206
|
backgroundColor: colors.backgroundColor,
|
|
@@ -233,27 +250,26 @@ function Card({
|
|
|
233
250
|
[theme, variant, containerColor]
|
|
234
251
|
);
|
|
235
252
|
if (!isInteractive) {
|
|
236
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { ...props, style: [styles.container, style], children });
|
|
237
254
|
}
|
|
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
255
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
247
|
-
|
|
256
|
+
import_react_native5.Pressable,
|
|
248
257
|
{
|
|
249
258
|
...props,
|
|
250
259
|
role: "button",
|
|
251
260
|
accessibilityState: { disabled: isDisabled },
|
|
252
|
-
hitSlop:
|
|
261
|
+
hitSlop: import_react_native5.Platform.OS === "web" ? void 0 : 4,
|
|
253
262
|
disabled: isDisabled,
|
|
254
263
|
onPress,
|
|
255
|
-
style:
|
|
256
|
-
|
|
264
|
+
style: resolvePressableStyle(
|
|
265
|
+
[styles.container, styles.interactiveContainer],
|
|
266
|
+
styles.hoveredContainer,
|
|
267
|
+
styles.pressedContainer,
|
|
268
|
+
styles.disabledContainer,
|
|
269
|
+
isDisabled,
|
|
270
|
+
style
|
|
271
|
+
),
|
|
272
|
+
children: isDisabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { style: styles.disabledContent, children }) : children
|
|
257
273
|
}
|
|
258
274
|
);
|
|
259
275
|
}
|
package/dist/checkbox/index.js
CHANGED
|
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(checkbox_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/checkbox/Checkbox.tsx
|
|
28
28
|
var import_react = require("react");
|
|
29
|
-
var
|
|
29
|
+
var import_react_native5 = require("react-native");
|
|
30
30
|
var import_core = require("@onlynative/core");
|
|
31
31
|
|
|
32
32
|
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
@@ -40,6 +40,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
40
40
|
// ../utils/dist/index.mjs
|
|
41
41
|
var import_react_native = require("react-native");
|
|
42
42
|
var import_react_native2 = require("react-native");
|
|
43
|
+
var import_react_native3 = require("react-native");
|
|
43
44
|
function parseHexColor(color) {
|
|
44
45
|
const normalized = color.replace("#", "");
|
|
45
46
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -101,9 +102,31 @@ function getMaterialCommunityIcons() {
|
|
|
101
102
|
}
|
|
102
103
|
return _MCIcons;
|
|
103
104
|
}
|
|
105
|
+
function resolvePressableStyle(base, hovered, pressed, disabled, isDisabled, style) {
|
|
106
|
+
if (typeof style === "function") {
|
|
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(state)
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
return (state) => [
|
|
116
|
+
base,
|
|
117
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
118
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
119
|
+
isDisabled ? disabled : void 0,
|
|
120
|
+
style
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
function resolveColorFromStyle(...styles) {
|
|
124
|
+
const flattened = import_react_native2.StyleSheet.flatten(styles);
|
|
125
|
+
return typeof (flattened == null ? void 0 : flattened.color) === "string" ? flattened.color : void 0;
|
|
126
|
+
}
|
|
104
127
|
|
|
105
128
|
// src/checkbox/styles.ts
|
|
106
|
-
var
|
|
129
|
+
var import_react_native4 = require("react-native");
|
|
107
130
|
function getColors(theme, checked) {
|
|
108
131
|
const disabledOnSurface38 = alphaColor(theme.colors.onSurface, 0.38);
|
|
109
132
|
if (checked) {
|
|
@@ -179,7 +202,7 @@ function createStyles(theme, checked, containerColor, contentColor) {
|
|
|
179
202
|
);
|
|
180
203
|
const size = 18;
|
|
181
204
|
const touchTarget = 48;
|
|
182
|
-
return
|
|
205
|
+
return import_react_native4.StyleSheet.create({
|
|
183
206
|
container: {
|
|
184
207
|
width: touchTarget,
|
|
185
208
|
height: touchTarget,
|
|
@@ -224,24 +247,6 @@ function createStyles(theme, checked, containerColor, contentColor) {
|
|
|
224
247
|
|
|
225
248
|
// src/checkbox/Checkbox.tsx
|
|
226
249
|
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
250
|
function Checkbox({
|
|
246
251
|
style,
|
|
247
252
|
value = false,
|
|
@@ -259,20 +264,20 @@ function Checkbox({
|
|
|
259
264
|
() => createStyles(theme, isChecked, containerColor, contentColor),
|
|
260
265
|
[theme, isChecked, containerColor, contentColor]
|
|
261
266
|
);
|
|
262
|
-
const resolvedIconColor = (0, import_react.useMemo)(
|
|
263
|
-
|
|
267
|
+
const resolvedIconColor = (0, import_react.useMemo)(
|
|
268
|
+
() => resolveColorFromStyle(
|
|
264
269
|
styles.iconColor,
|
|
265
270
|
isDisabled ? styles.disabledIconColor : void 0
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
271
|
+
),
|
|
272
|
+
[styles.iconColor, styles.disabledIconColor, isDisabled]
|
|
273
|
+
);
|
|
269
274
|
const handlePress = () => {
|
|
270
275
|
if (!isDisabled) {
|
|
271
276
|
onValueChange == null ? void 0 : onValueChange(!isChecked);
|
|
272
277
|
}
|
|
273
278
|
};
|
|
274
279
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
275
|
-
|
|
280
|
+
import_react_native5.Pressable,
|
|
276
281
|
{
|
|
277
282
|
...props,
|
|
278
283
|
accessibilityRole: "checkbox",
|
|
@@ -280,10 +285,10 @@ function Checkbox({
|
|
|
280
285
|
disabled: isDisabled,
|
|
281
286
|
checked: isChecked
|
|
282
287
|
},
|
|
283
|
-
hitSlop:
|
|
288
|
+
hitSlop: import_react_native5.Platform.OS === "web" ? void 0 : 4,
|
|
284
289
|
disabled: isDisabled,
|
|
285
290
|
onPress: handlePress,
|
|
286
|
-
style:
|
|
291
|
+
style: resolvePressableStyle(
|
|
287
292
|
styles.container,
|
|
288
293
|
styles.hoveredContainer,
|
|
289
294
|
styles.pressedContainer,
|
|
@@ -291,7 +296,7 @@ function Checkbox({
|
|
|
291
296
|
isDisabled,
|
|
292
297
|
style
|
|
293
298
|
),
|
|
294
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
299
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { style: [styles.box, isDisabled ? styles.disabledBox : void 0], children: isChecked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
295
300
|
MaterialCommunityIcons,
|
|
296
301
|
{
|
|
297
302
|
name: "check",
|