@onlynative/components 0.1.0 → 0.1.1-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 +133 -62
- package/dist/button/index.js +125 -33
- package/dist/card/index.js +88 -20
- package/dist/checkbox/index.js +88 -17
- package/dist/chip/index.js +122 -30
- package/dist/icon-button/index.js +107 -36
- package/dist/index.js +335 -251
- package/dist/list/index.js +71 -24
- package/dist/radio/index.js +43 -14
- package/dist/switch/index.js +90 -19
- package/dist/text-field/index.js +82 -26
- package/package.json +4 -23
- package/src/appbar/AppBar.tsx +0 -302
- package/src/appbar/index.ts +0 -2
- package/src/appbar/styles.ts +0 -92
- package/src/appbar/types.ts +0 -67
- package/src/button/Button.tsx +0 -133
- package/src/button/index.ts +0 -2
- package/src/button/styles.ts +0 -287
- package/src/button/types.ts +0 -42
- package/src/card/Card.tsx +0 -69
- package/src/card/index.ts +0 -2
- package/src/card/styles.ts +0 -150
- package/src/card/types.ts +0 -27
- package/src/checkbox/Checkbox.tsx +0 -113
- package/src/checkbox/index.ts +0 -2
- package/src/checkbox/styles.ts +0 -155
- package/src/checkbox/types.ts +0 -20
- package/src/chip/Chip.tsx +0 -188
- package/src/chip/index.ts +0 -2
- package/src/chip/styles.ts +0 -239
- package/src/chip/types.ts +0 -58
- package/src/icon-button/IconButton.tsx +0 -362
- package/src/icon-button/index.ts +0 -6
- package/src/icon-button/styles.ts +0 -259
- package/src/icon-button/types.ts +0 -55
- package/src/index.ts +0 -54
- package/src/keyboard-avoiding-wrapper/KeyboardAvoidingWrapper.tsx +0 -69
- package/src/keyboard-avoiding-wrapper/index.ts +0 -2
- package/src/keyboard-avoiding-wrapper/styles.ts +0 -10
- package/src/keyboard-avoiding-wrapper/types.ts +0 -37
- package/src/layout/Box.tsx +0 -99
- package/src/layout/Column.tsx +0 -16
- package/src/layout/Grid.tsx +0 -49
- package/src/layout/Layout.tsx +0 -81
- package/src/layout/Row.tsx +0 -22
- package/src/layout/index.ts +0 -13
- package/src/layout/resolveSpacing.ts +0 -11
- package/src/layout/types.ts +0 -82
- package/src/list/List.tsx +0 -17
- package/src/list/ListDivider.tsx +0 -20
- package/src/list/ListItem.tsx +0 -128
- package/src/list/index.ts +0 -9
- package/src/list/styles.ts +0 -132
- package/src/list/types.ts +0 -54
- package/src/radio/Radio.tsx +0 -103
- package/src/radio/index.ts +0 -2
- package/src/radio/styles.ts +0 -139
- package/src/radio/types.ts +0 -20
- package/src/switch/Switch.tsx +0 -121
- package/src/switch/index.ts +0 -2
- package/src/switch/styles.ts +0 -172
- package/src/switch/types.ts +0 -32
- package/src/text-field/TextField.tsx +0 -301
- package/src/text-field/index.ts +0 -2
- package/src/text-field/styles.ts +0 -239
- package/src/text-field/types.ts +0 -49
- package/src/typography/Typography.tsx +0 -79
- package/src/typography/index.ts +0 -3
- package/src/typography/types.ts +0 -17
package/dist/button/index.js
CHANGED
|
@@ -26,30 +26,122 @@ module.exports = __toCommonJS(button_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/button/Button.tsx
|
|
28
28
|
var import_react = require("react");
|
|
29
|
-
var import_react_native2 = require("react-native");
|
|
30
|
-
var import_react_native3 = require("react-native");
|
|
31
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
32
|
var import_core = require("@onlynative/core");
|
|
33
|
-
var import_utils2 = require("@onlynative/utils");
|
|
34
33
|
|
|
35
|
-
//
|
|
34
|
+
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
35
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
36
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
37
|
+
}) : x)(function(x) {
|
|
38
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
39
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// ../utils/dist/index.mjs
|
|
36
43
|
var import_react_native = require("react-native");
|
|
37
|
-
var
|
|
44
|
+
var import_react_native2 = require("react-native");
|
|
45
|
+
function parseHexColor(color) {
|
|
46
|
+
const normalized = color.replace("#", "");
|
|
47
|
+
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const r = Number.parseInt(normalized.slice(0, 2), 16);
|
|
51
|
+
const g = Number.parseInt(normalized.slice(2, 4), 16);
|
|
52
|
+
const b = Number.parseInt(normalized.slice(4, 6), 16);
|
|
53
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return { r, g, b };
|
|
57
|
+
}
|
|
58
|
+
function clampAlpha(alpha) {
|
|
59
|
+
return Math.max(0, Math.min(1, alpha));
|
|
60
|
+
}
|
|
61
|
+
function alphaColor(color, alpha) {
|
|
62
|
+
const channels = parseHexColor(color);
|
|
63
|
+
const boundedAlpha = clampAlpha(alpha);
|
|
64
|
+
if (!channels) {
|
|
65
|
+
return color;
|
|
66
|
+
}
|
|
67
|
+
return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
|
|
68
|
+
}
|
|
69
|
+
function blendColor(base, overlay, overlayAlpha) {
|
|
70
|
+
const baseChannels = parseHexColor(base);
|
|
71
|
+
const overlayChannels = parseHexColor(overlay);
|
|
72
|
+
const boundedAlpha = clampAlpha(overlayAlpha);
|
|
73
|
+
if (!baseChannels || !overlayChannels) {
|
|
74
|
+
return alphaColor(overlay, boundedAlpha);
|
|
75
|
+
}
|
|
76
|
+
const r = Math.round(
|
|
77
|
+
(1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
|
|
78
|
+
);
|
|
79
|
+
const g = Math.round(
|
|
80
|
+
(1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
|
|
81
|
+
);
|
|
82
|
+
const b = Math.round(
|
|
83
|
+
(1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
|
|
84
|
+
);
|
|
85
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
86
|
+
}
|
|
87
|
+
function elevationStyle(level) {
|
|
88
|
+
if (import_react_native.Platform.OS === "web") {
|
|
89
|
+
const { shadowOffset, shadowOpacity, shadowRadius } = level;
|
|
90
|
+
if (shadowOpacity === 0) {
|
|
91
|
+
return { boxShadow: "none" };
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
boxShadow: `${shadowOffset.width}px ${shadowOffset.height}px ${shadowRadius}px rgba(0, 0, 0, ${shadowOpacity})`
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
shadowColor: level.shadowColor,
|
|
99
|
+
shadowOffset: {
|
|
100
|
+
width: level.shadowOffset.width,
|
|
101
|
+
height: level.shadowOffset.height
|
|
102
|
+
},
|
|
103
|
+
shadowOpacity: level.shadowOpacity,
|
|
104
|
+
shadowRadius: level.shadowRadius,
|
|
105
|
+
elevation: level.elevation
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
var _MCIcons = null;
|
|
109
|
+
var _resolved = false;
|
|
110
|
+
function getMaterialCommunityIcons() {
|
|
111
|
+
if (!_resolved) {
|
|
112
|
+
_resolved = true;
|
|
113
|
+
try {
|
|
114
|
+
const mod = __require("@expo/vector-icons/MaterialCommunityIcons");
|
|
115
|
+
_MCIcons = mod.default || mod;
|
|
116
|
+
} catch {
|
|
117
|
+
_MCIcons = null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (!_MCIcons) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return _MCIcons;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// src/button/styles.ts
|
|
129
|
+
var import_react_native3 = require("react-native");
|
|
38
130
|
function getVariantColors(theme, variant) {
|
|
39
|
-
const disabledContainerColor =
|
|
40
|
-
const disabledLabelColor =
|
|
41
|
-
const disabledOutlineColor =
|
|
131
|
+
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
132
|
+
const disabledLabelColor = alphaColor(theme.colors.onSurface, 0.38);
|
|
133
|
+
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
42
134
|
if (variant === "outlined") {
|
|
43
135
|
return {
|
|
44
136
|
backgroundColor: "transparent",
|
|
45
137
|
textColor: theme.colors.primary,
|
|
46
138
|
borderColor: theme.colors.outline,
|
|
47
139
|
borderWidth: 1,
|
|
48
|
-
hoveredBackgroundColor:
|
|
140
|
+
hoveredBackgroundColor: alphaColor(
|
|
49
141
|
theme.colors.primary,
|
|
50
142
|
theme.stateLayer.hoveredOpacity
|
|
51
143
|
),
|
|
52
|
-
pressedBackgroundColor:
|
|
144
|
+
pressedBackgroundColor: alphaColor(
|
|
53
145
|
theme.colors.primary,
|
|
54
146
|
theme.stateLayer.pressedOpacity
|
|
55
147
|
),
|
|
@@ -64,11 +156,11 @@ function getVariantColors(theme, variant) {
|
|
|
64
156
|
textColor: theme.colors.primary,
|
|
65
157
|
borderColor: "transparent",
|
|
66
158
|
borderWidth: 0,
|
|
67
|
-
hoveredBackgroundColor:
|
|
159
|
+
hoveredBackgroundColor: alphaColor(
|
|
68
160
|
theme.colors.primary,
|
|
69
161
|
theme.stateLayer.hoveredOpacity
|
|
70
162
|
),
|
|
71
|
-
pressedBackgroundColor:
|
|
163
|
+
pressedBackgroundColor: alphaColor(
|
|
72
164
|
theme.colors.primary,
|
|
73
165
|
theme.stateLayer.pressedOpacity
|
|
74
166
|
),
|
|
@@ -83,12 +175,12 @@ function getVariantColors(theme, variant) {
|
|
|
83
175
|
textColor: theme.colors.primary,
|
|
84
176
|
borderColor: theme.colors.surfaceContainerLow,
|
|
85
177
|
borderWidth: 0,
|
|
86
|
-
hoveredBackgroundColor:
|
|
178
|
+
hoveredBackgroundColor: blendColor(
|
|
87
179
|
theme.colors.surfaceContainerLow,
|
|
88
180
|
theme.colors.primary,
|
|
89
181
|
theme.stateLayer.hoveredOpacity
|
|
90
182
|
),
|
|
91
|
-
pressedBackgroundColor:
|
|
183
|
+
pressedBackgroundColor: blendColor(
|
|
92
184
|
theme.colors.surfaceContainerLow,
|
|
93
185
|
theme.colors.primary,
|
|
94
186
|
theme.stateLayer.pressedOpacity
|
|
@@ -104,12 +196,12 @@ function getVariantColors(theme, variant) {
|
|
|
104
196
|
textColor: theme.colors.onSecondaryContainer,
|
|
105
197
|
borderColor: theme.colors.secondaryContainer,
|
|
106
198
|
borderWidth: 0,
|
|
107
|
-
hoveredBackgroundColor:
|
|
199
|
+
hoveredBackgroundColor: blendColor(
|
|
108
200
|
theme.colors.secondaryContainer,
|
|
109
201
|
theme.colors.onSecondaryContainer,
|
|
110
202
|
theme.stateLayer.hoveredOpacity
|
|
111
203
|
),
|
|
112
|
-
pressedBackgroundColor:
|
|
204
|
+
pressedBackgroundColor: blendColor(
|
|
113
205
|
theme.colors.secondaryContainer,
|
|
114
206
|
theme.colors.onSecondaryContainer,
|
|
115
207
|
theme.stateLayer.pressedOpacity
|
|
@@ -124,12 +216,12 @@ function getVariantColors(theme, variant) {
|
|
|
124
216
|
textColor: theme.colors.onPrimary,
|
|
125
217
|
borderColor: theme.colors.primary,
|
|
126
218
|
borderWidth: 0,
|
|
127
|
-
hoveredBackgroundColor:
|
|
219
|
+
hoveredBackgroundColor: blendColor(
|
|
128
220
|
theme.colors.primary,
|
|
129
221
|
theme.colors.onPrimary,
|
|
130
222
|
theme.stateLayer.hoveredOpacity
|
|
131
223
|
),
|
|
132
|
-
pressedBackgroundColor:
|
|
224
|
+
pressedBackgroundColor: blendColor(
|
|
133
225
|
theme.colors.primary,
|
|
134
226
|
theme.colors.onPrimary,
|
|
135
227
|
theme.stateLayer.pressedOpacity
|
|
@@ -161,33 +253,33 @@ function applyColorOverrides(theme, colors, containerColor, contentColor) {
|
|
|
161
253
|
const overlay = contentColor != null ? contentColor : colors.textColor;
|
|
162
254
|
result.backgroundColor = containerColor;
|
|
163
255
|
result.borderColor = containerColor;
|
|
164
|
-
result.hoveredBackgroundColor =
|
|
256
|
+
result.hoveredBackgroundColor = blendColor(
|
|
165
257
|
containerColor,
|
|
166
258
|
overlay,
|
|
167
259
|
theme.stateLayer.hoveredOpacity
|
|
168
260
|
);
|
|
169
|
-
result.pressedBackgroundColor =
|
|
261
|
+
result.pressedBackgroundColor = blendColor(
|
|
170
262
|
containerColor,
|
|
171
263
|
overlay,
|
|
172
264
|
theme.stateLayer.pressedOpacity
|
|
173
265
|
);
|
|
174
266
|
} else if (contentColor) {
|
|
175
267
|
if (colors.backgroundColor === "transparent") {
|
|
176
|
-
result.hoveredBackgroundColor =
|
|
268
|
+
result.hoveredBackgroundColor = alphaColor(
|
|
177
269
|
contentColor,
|
|
178
270
|
theme.stateLayer.hoveredOpacity
|
|
179
271
|
);
|
|
180
|
-
result.pressedBackgroundColor =
|
|
272
|
+
result.pressedBackgroundColor = alphaColor(
|
|
181
273
|
contentColor,
|
|
182
274
|
theme.stateLayer.pressedOpacity
|
|
183
275
|
);
|
|
184
276
|
} else {
|
|
185
|
-
result.hoveredBackgroundColor =
|
|
277
|
+
result.hoveredBackgroundColor = blendColor(
|
|
186
278
|
colors.backgroundColor,
|
|
187
279
|
contentColor,
|
|
188
280
|
theme.stateLayer.hoveredOpacity
|
|
189
281
|
);
|
|
190
|
-
result.pressedBackgroundColor =
|
|
282
|
+
result.pressedBackgroundColor = blendColor(
|
|
191
283
|
colors.backgroundColor,
|
|
192
284
|
contentColor,
|
|
193
285
|
theme.stateLayer.pressedOpacity
|
|
@@ -211,11 +303,11 @@ function createStyles(theme, variant, hasLeadingIcon, hasTrailingIcon, container
|
|
|
211
303
|
hasLeadingIcon,
|
|
212
304
|
hasTrailingIcon
|
|
213
305
|
);
|
|
214
|
-
const elevationLevel0 =
|
|
215
|
-
const elevationLevel1 =
|
|
216
|
-
const elevationLevel2 =
|
|
306
|
+
const elevationLevel0 = elevationStyle(theme.elevation.level0);
|
|
307
|
+
const elevationLevel1 = elevationStyle(theme.elevation.level1);
|
|
308
|
+
const elevationLevel2 = elevationStyle(theme.elevation.level2);
|
|
217
309
|
const baseElevation = variant === "elevated" ? elevationLevel1 : elevationLevel0;
|
|
218
|
-
return
|
|
310
|
+
return import_react_native3.StyleSheet.create({
|
|
219
311
|
container: {
|
|
220
312
|
alignSelf: "flex-start",
|
|
221
313
|
alignItems: "center",
|
|
@@ -314,9 +406,9 @@ function Button({
|
|
|
314
406
|
),
|
|
315
407
|
[theme, variant, hasLeading, hasTrailing, containerColor, contentColor]
|
|
316
408
|
);
|
|
317
|
-
const MaterialCommunityIcons = leadingIcon || trailingIcon ?
|
|
409
|
+
const MaterialCommunityIcons = leadingIcon || trailingIcon ? getMaterialCommunityIcons() : null;
|
|
318
410
|
const resolvedIconColor = (0, import_react.useMemo)(() => {
|
|
319
|
-
const base =
|
|
411
|
+
const base = import_react_native5.StyleSheet.flatten([
|
|
320
412
|
styles.label,
|
|
321
413
|
isDisabled ? styles.disabledLabel : void 0
|
|
322
414
|
]);
|
|
@@ -331,12 +423,12 @@ function Button({
|
|
|
331
423
|
[isDisabled, styles.disabledLabel, styles.label, labelStyleOverride]
|
|
332
424
|
);
|
|
333
425
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
334
|
-
|
|
426
|
+
import_react_native4.Pressable,
|
|
335
427
|
{
|
|
336
428
|
...props,
|
|
337
429
|
accessibilityRole: "button",
|
|
338
430
|
accessibilityState: { disabled: isDisabled },
|
|
339
|
-
hitSlop:
|
|
431
|
+
hitSlop: import_react_native4.Platform.OS === "web" ? void 0 : 4,
|
|
340
432
|
disabled: isDisabled,
|
|
341
433
|
style: resolveStyle(
|
|
342
434
|
styles.container,
|
|
@@ -356,7 +448,7 @@ function Button({
|
|
|
356
448
|
style: styles.leadingIcon
|
|
357
449
|
}
|
|
358
450
|
) : null,
|
|
359
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
451
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native6.Text, { style: computedLabelStyle, children }),
|
|
360
452
|
trailingIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
361
453
|
MaterialCommunityIcons,
|
|
362
454
|
{
|
package/dist/card/index.js
CHANGED
|
@@ -26,25 +26,93 @@ 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_native4 = require("react-native");
|
|
30
30
|
var import_core = require("@onlynative/core");
|
|
31
31
|
|
|
32
32
|
// src/card/styles.ts
|
|
33
|
+
var import_react_native3 = require("react-native");
|
|
34
|
+
|
|
35
|
+
// ../utils/dist/index.mjs
|
|
33
36
|
var import_react_native = require("react-native");
|
|
34
|
-
var
|
|
37
|
+
var import_react_native2 = require("react-native");
|
|
38
|
+
function parseHexColor(color) {
|
|
39
|
+
const normalized = color.replace("#", "");
|
|
40
|
+
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const r = Number.parseInt(normalized.slice(0, 2), 16);
|
|
44
|
+
const g = Number.parseInt(normalized.slice(2, 4), 16);
|
|
45
|
+
const b = Number.parseInt(normalized.slice(4, 6), 16);
|
|
46
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return { r, g, b };
|
|
50
|
+
}
|
|
51
|
+
function clampAlpha(alpha) {
|
|
52
|
+
return Math.max(0, Math.min(1, alpha));
|
|
53
|
+
}
|
|
54
|
+
function alphaColor(color, alpha) {
|
|
55
|
+
const channels = parseHexColor(color);
|
|
56
|
+
const boundedAlpha = clampAlpha(alpha);
|
|
57
|
+
if (!channels) {
|
|
58
|
+
return color;
|
|
59
|
+
}
|
|
60
|
+
return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
|
|
61
|
+
}
|
|
62
|
+
function blendColor(base, overlay, overlayAlpha) {
|
|
63
|
+
const baseChannels = parseHexColor(base);
|
|
64
|
+
const overlayChannels = parseHexColor(overlay);
|
|
65
|
+
const boundedAlpha = clampAlpha(overlayAlpha);
|
|
66
|
+
if (!baseChannels || !overlayChannels) {
|
|
67
|
+
return alphaColor(overlay, boundedAlpha);
|
|
68
|
+
}
|
|
69
|
+
const r = Math.round(
|
|
70
|
+
(1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
|
|
71
|
+
);
|
|
72
|
+
const g = Math.round(
|
|
73
|
+
(1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
|
|
74
|
+
);
|
|
75
|
+
const b = Math.round(
|
|
76
|
+
(1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
|
|
77
|
+
);
|
|
78
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
79
|
+
}
|
|
80
|
+
function elevationStyle(level) {
|
|
81
|
+
if (import_react_native.Platform.OS === "web") {
|
|
82
|
+
const { shadowOffset, shadowOpacity, shadowRadius } = level;
|
|
83
|
+
if (shadowOpacity === 0) {
|
|
84
|
+
return { boxShadow: "none" };
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
boxShadow: `${shadowOffset.width}px ${shadowOffset.height}px ${shadowRadius}px rgba(0, 0, 0, ${shadowOpacity})`
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
shadowColor: level.shadowColor,
|
|
92
|
+
shadowOffset: {
|
|
93
|
+
width: level.shadowOffset.width,
|
|
94
|
+
height: level.shadowOffset.height
|
|
95
|
+
},
|
|
96
|
+
shadowOpacity: level.shadowOpacity,
|
|
97
|
+
shadowRadius: level.shadowRadius,
|
|
98
|
+
elevation: level.elevation
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/card/styles.ts
|
|
35
103
|
function getVariantColors(theme, variant) {
|
|
36
|
-
const disabledContainerColor =
|
|
37
|
-
const disabledOutlineColor =
|
|
104
|
+
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
105
|
+
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
38
106
|
if (variant === "outlined") {
|
|
39
107
|
return {
|
|
40
108
|
backgroundColor: theme.colors.surface,
|
|
41
109
|
borderColor: theme.colors.outline,
|
|
42
110
|
borderWidth: 1,
|
|
43
|
-
hoveredBackgroundColor:
|
|
111
|
+
hoveredBackgroundColor: alphaColor(
|
|
44
112
|
theme.colors.onSurface,
|
|
45
113
|
theme.stateLayer.hoveredOpacity
|
|
46
114
|
),
|
|
47
|
-
pressedBackgroundColor:
|
|
115
|
+
pressedBackgroundColor: alphaColor(
|
|
48
116
|
theme.colors.onSurface,
|
|
49
117
|
theme.stateLayer.pressedOpacity
|
|
50
118
|
),
|
|
@@ -57,12 +125,12 @@ function getVariantColors(theme, variant) {
|
|
|
57
125
|
backgroundColor: theme.colors.surfaceContainerHighest,
|
|
58
126
|
borderColor: "transparent",
|
|
59
127
|
borderWidth: 0,
|
|
60
|
-
hoveredBackgroundColor:
|
|
128
|
+
hoveredBackgroundColor: blendColor(
|
|
61
129
|
theme.colors.surfaceContainerHighest,
|
|
62
130
|
theme.colors.onSurface,
|
|
63
131
|
theme.stateLayer.hoveredOpacity
|
|
64
132
|
),
|
|
65
|
-
pressedBackgroundColor:
|
|
133
|
+
pressedBackgroundColor: blendColor(
|
|
66
134
|
theme.colors.surfaceContainerHighest,
|
|
67
135
|
theme.colors.onSurface,
|
|
68
136
|
theme.stateLayer.pressedOpacity
|
|
@@ -75,12 +143,12 @@ function getVariantColors(theme, variant) {
|
|
|
75
143
|
backgroundColor: theme.colors.surface,
|
|
76
144
|
borderColor: "transparent",
|
|
77
145
|
borderWidth: 0,
|
|
78
|
-
hoveredBackgroundColor:
|
|
146
|
+
hoveredBackgroundColor: blendColor(
|
|
79
147
|
theme.colors.surface,
|
|
80
148
|
theme.colors.onSurface,
|
|
81
149
|
theme.stateLayer.hoveredOpacity
|
|
82
150
|
),
|
|
83
|
-
pressedBackgroundColor:
|
|
151
|
+
pressedBackgroundColor: blendColor(
|
|
84
152
|
theme.colors.surface,
|
|
85
153
|
theme.colors.onSurface,
|
|
86
154
|
theme.stateLayer.pressedOpacity
|
|
@@ -96,12 +164,12 @@ function applyColorOverrides(theme, colors, containerColor) {
|
|
|
96
164
|
backgroundColor: containerColor,
|
|
97
165
|
borderColor: containerColor,
|
|
98
166
|
borderWidth: 0,
|
|
99
|
-
hoveredBackgroundColor:
|
|
167
|
+
hoveredBackgroundColor: blendColor(
|
|
100
168
|
containerColor,
|
|
101
169
|
theme.colors.onSurface,
|
|
102
170
|
theme.stateLayer.hoveredOpacity
|
|
103
171
|
),
|
|
104
|
-
pressedBackgroundColor:
|
|
172
|
+
pressedBackgroundColor: blendColor(
|
|
105
173
|
containerColor,
|
|
106
174
|
theme.colors.onSurface,
|
|
107
175
|
theme.stateLayer.pressedOpacity
|
|
@@ -111,11 +179,11 @@ function applyColorOverrides(theme, colors, containerColor) {
|
|
|
111
179
|
function createStyles(theme, variant, containerColor) {
|
|
112
180
|
const baseColors = getVariantColors(theme, variant);
|
|
113
181
|
const colors = applyColorOverrides(theme, baseColors, containerColor);
|
|
114
|
-
const elevationLevel0 =
|
|
115
|
-
const elevationLevel1 =
|
|
116
|
-
const elevationLevel2 =
|
|
182
|
+
const elevationLevel0 = elevationStyle(theme.elevation.level0);
|
|
183
|
+
const elevationLevel1 = elevationStyle(theme.elevation.level1);
|
|
184
|
+
const elevationLevel2 = elevationStyle(theme.elevation.level2);
|
|
117
185
|
const baseElevation = variant === "elevated" ? elevationLevel1 : elevationLevel0;
|
|
118
|
-
return
|
|
186
|
+
return import_react_native3.StyleSheet.create({
|
|
119
187
|
container: {
|
|
120
188
|
borderRadius: theme.shape.cornerMedium,
|
|
121
189
|
backgroundColor: colors.backgroundColor,
|
|
@@ -165,7 +233,7 @@ function Card({
|
|
|
165
233
|
[theme, variant, containerColor]
|
|
166
234
|
);
|
|
167
235
|
if (!isInteractive) {
|
|
168
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native4.View, { ...props, style: [styles.container, style], children });
|
|
169
237
|
}
|
|
170
238
|
const resolvedStyle = (state) => [
|
|
171
239
|
styles.container,
|
|
@@ -176,16 +244,16 @@ function Card({
|
|
|
176
244
|
typeof style === "function" ? style(state) : style
|
|
177
245
|
];
|
|
178
246
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
179
|
-
|
|
247
|
+
import_react_native4.Pressable,
|
|
180
248
|
{
|
|
181
249
|
...props,
|
|
182
250
|
role: "button",
|
|
183
251
|
accessibilityState: { disabled: isDisabled },
|
|
184
|
-
hitSlop:
|
|
252
|
+
hitSlop: import_react_native4.Platform.OS === "web" ? void 0 : 4,
|
|
185
253
|
disabled: isDisabled,
|
|
186
254
|
onPress,
|
|
187
255
|
style: resolvedStyle,
|
|
188
|
-
children: isDisabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
256
|
+
children: isDisabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native4.View, { style: styles.disabledContent, children }) : children
|
|
189
257
|
}
|
|
190
258
|
);
|
|
191
259
|
}
|
package/dist/checkbox/index.js
CHANGED
|
@@ -26,27 +26,98 @@ 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_native4 = require("react-native");
|
|
30
30
|
var import_core = require("@onlynative/core");
|
|
31
|
-
var import_utils2 = require("@onlynative/utils");
|
|
32
31
|
|
|
33
|
-
//
|
|
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
|
|
34
41
|
var import_react_native = require("react-native");
|
|
35
|
-
var
|
|
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/checkbox/styles.ts
|
|
106
|
+
var import_react_native3 = require("react-native");
|
|
36
107
|
function getColors(theme, checked) {
|
|
37
|
-
const disabledOnSurface38 =
|
|
108
|
+
const disabledOnSurface38 = alphaColor(theme.colors.onSurface, 0.38);
|
|
38
109
|
if (checked) {
|
|
39
110
|
return {
|
|
40
111
|
backgroundColor: theme.colors.primary,
|
|
41
112
|
borderColor: "transparent",
|
|
42
113
|
borderWidth: 0,
|
|
43
114
|
iconColor: theme.colors.onPrimary,
|
|
44
|
-
hoveredBackgroundColor:
|
|
115
|
+
hoveredBackgroundColor: blendColor(
|
|
45
116
|
theme.colors.primary,
|
|
46
117
|
theme.colors.onPrimary,
|
|
47
118
|
theme.stateLayer.hoveredOpacity
|
|
48
119
|
),
|
|
49
|
-
pressedBackgroundColor:
|
|
120
|
+
pressedBackgroundColor: blendColor(
|
|
50
121
|
theme.colors.primary,
|
|
51
122
|
theme.colors.onPrimary,
|
|
52
123
|
theme.stateLayer.pressedOpacity
|
|
@@ -62,11 +133,11 @@ function getColors(theme, checked) {
|
|
|
62
133
|
borderColor: theme.colors.onSurfaceVariant,
|
|
63
134
|
borderWidth: 2,
|
|
64
135
|
iconColor: "transparent",
|
|
65
|
-
hoveredBackgroundColor:
|
|
136
|
+
hoveredBackgroundColor: alphaColor(
|
|
66
137
|
theme.colors.onSurface,
|
|
67
138
|
theme.stateLayer.hoveredOpacity
|
|
68
139
|
),
|
|
69
|
-
pressedBackgroundColor:
|
|
140
|
+
pressedBackgroundColor: alphaColor(
|
|
70
141
|
theme.colors.onSurface,
|
|
71
142
|
theme.stateLayer.pressedOpacity
|
|
72
143
|
),
|
|
@@ -86,12 +157,12 @@ function applyColorOverrides(theme, colors, containerColor, contentColor) {
|
|
|
86
157
|
const overlay = contentColor != null ? contentColor : colors.iconColor;
|
|
87
158
|
result.backgroundColor = containerColor;
|
|
88
159
|
result.borderColor = containerColor;
|
|
89
|
-
result.hoveredBackgroundColor =
|
|
160
|
+
result.hoveredBackgroundColor = blendColor(
|
|
90
161
|
containerColor,
|
|
91
162
|
overlay,
|
|
92
163
|
theme.stateLayer.hoveredOpacity
|
|
93
164
|
);
|
|
94
|
-
result.pressedBackgroundColor =
|
|
165
|
+
result.pressedBackgroundColor = blendColor(
|
|
95
166
|
containerColor,
|
|
96
167
|
overlay,
|
|
97
168
|
theme.stateLayer.pressedOpacity
|
|
@@ -108,7 +179,7 @@ function createStyles(theme, checked, containerColor, contentColor) {
|
|
|
108
179
|
);
|
|
109
180
|
const size = 18;
|
|
110
181
|
const touchTarget = 48;
|
|
111
|
-
return
|
|
182
|
+
return import_react_native3.StyleSheet.create({
|
|
112
183
|
container: {
|
|
113
184
|
width: touchTarget,
|
|
114
185
|
height: touchTarget,
|
|
@@ -182,14 +253,14 @@ function Checkbox({
|
|
|
182
253
|
}) {
|
|
183
254
|
const isDisabled = Boolean(disabled);
|
|
184
255
|
const isChecked = Boolean(value);
|
|
185
|
-
const MaterialCommunityIcons = isChecked ?
|
|
256
|
+
const MaterialCommunityIcons = isChecked ? getMaterialCommunityIcons() : null;
|
|
186
257
|
const theme = (0, import_core.useTheme)();
|
|
187
258
|
const styles = (0, import_react.useMemo)(
|
|
188
259
|
() => createStyles(theme, isChecked, containerColor, contentColor),
|
|
189
260
|
[theme, isChecked, containerColor, contentColor]
|
|
190
261
|
);
|
|
191
262
|
const resolvedIconColor = (0, import_react.useMemo)(() => {
|
|
192
|
-
const base =
|
|
263
|
+
const base = import_react_native4.StyleSheet.flatten([
|
|
193
264
|
styles.iconColor,
|
|
194
265
|
isDisabled ? styles.disabledIconColor : void 0
|
|
195
266
|
]);
|
|
@@ -201,7 +272,7 @@ function Checkbox({
|
|
|
201
272
|
}
|
|
202
273
|
};
|
|
203
274
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
204
|
-
|
|
275
|
+
import_react_native4.Pressable,
|
|
205
276
|
{
|
|
206
277
|
...props,
|
|
207
278
|
accessibilityRole: "checkbox",
|
|
@@ -209,7 +280,7 @@ function Checkbox({
|
|
|
209
280
|
disabled: isDisabled,
|
|
210
281
|
checked: isChecked
|
|
211
282
|
},
|
|
212
|
-
hitSlop:
|
|
283
|
+
hitSlop: import_react_native4.Platform.OS === "web" ? void 0 : 4,
|
|
213
284
|
disabled: isDisabled,
|
|
214
285
|
onPress: handlePress,
|
|
215
286
|
style: resolveStyle(
|
|
@@ -220,7 +291,7 @@ function Checkbox({
|
|
|
220
291
|
isDisabled,
|
|
221
292
|
style
|
|
222
293
|
),
|
|
223
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
294
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native4.View, { style: [styles.box, isDisabled ? styles.disabledBox : void 0], children: isChecked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
224
295
|
MaterialCommunityIcons,
|
|
225
296
|
{
|
|
226
297
|
name: "check",
|