@onlynative/components 0.1.0-alpha.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/appbar/index.js +75 -123
- package/dist/button/index.js +33 -111
- package/dist/card/index.js +20 -89
- package/dist/checkbox/index.js +11 -65
- package/dist/chip/index.js +33 -110
- package/dist/icon-button/index.js +33 -87
- package/dist/index.d.ts +1 -0
- package/dist/index.js +535 -517
- package/dist/keyboard-avoiding-wrapper/index.d.ts +36 -0
- package/dist/keyboard-avoiding-wrapper/index.js +98 -0
- package/dist/list/index.js +5 -50
- package/dist/radio/index.js +8 -35
- package/dist/switch/index.js +13 -67
- package/dist/text-field/index.js +27 -69
- package/dist/typography/index.js +9 -0
- package/package.json +13 -3
- package/src/appbar/AppBar.tsx +1 -1
- package/src/button/Button.tsx +4 -1
- package/src/button/styles.ts +1 -2
- package/src/card/styles.ts +1 -2
- package/src/checkbox/Checkbox.tsx +5 -1
- package/src/checkbox/styles.ts +1 -1
- package/src/chip/Chip.tsx +7 -1
- package/src/chip/styles.ts +1 -2
- package/src/icon-button/IconButton.tsx +6 -2
- package/src/icon-button/styles.ts +1 -1
- package/src/index.ts +3 -0
- package/src/keyboard-avoiding-wrapper/KeyboardAvoidingWrapper.tsx +69 -0
- package/src/keyboard-avoiding-wrapper/index.ts +2 -0
- package/src/keyboard-avoiding-wrapper/styles.ts +10 -0
- package/src/keyboard-avoiding-wrapper/types.ts +37 -0
- package/src/list/styles.ts +1 -1
- package/src/radio/styles.ts +1 -1
- package/src/switch/Switch.tsx +4 -1
- package/src/switch/styles.ts +1 -1
- package/src/text-field/TextField.tsx +4 -1
- package/src/text-field/styles.ts +1 -2
- package/src/typography/Typography.tsx +15 -1
- package/src/test-utils/render-with-theme.tsx +0 -13
- package/src/utils/color.ts +0 -64
- package/src/utils/elevation.ts +0 -33
- package/src/utils/rtl.ts +0 -19
package/dist/chip/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/chip/index.ts
|
|
@@ -35,99 +25,30 @@ __export(chip_exports, {
|
|
|
35
25
|
module.exports = __toCommonJS(chip_exports);
|
|
36
26
|
|
|
37
27
|
// src/chip/Chip.tsx
|
|
38
|
-
var import_MaterialCommunityIcons = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
|
|
39
28
|
var import_react = require("react");
|
|
40
|
-
var
|
|
29
|
+
var import_react_native2 = require("react-native");
|
|
41
30
|
var import_core = require("@onlynative/core");
|
|
31
|
+
var import_utils2 = require("@onlynative/utils");
|
|
42
32
|
|
|
43
33
|
// src/chip/styles.ts
|
|
44
|
-
var import_react_native2 = require("react-native");
|
|
45
|
-
|
|
46
|
-
// src/utils/color.ts
|
|
47
|
-
function parseHexColor(color) {
|
|
48
|
-
const normalized = color.replace("#", "");
|
|
49
|
-
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
const r = Number.parseInt(normalized.slice(0, 2), 16);
|
|
53
|
-
const g = Number.parseInt(normalized.slice(2, 4), 16);
|
|
54
|
-
const b = Number.parseInt(normalized.slice(4, 6), 16);
|
|
55
|
-
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
return { r, g, b };
|
|
59
|
-
}
|
|
60
|
-
function clampAlpha(alpha) {
|
|
61
|
-
return Math.max(0, Math.min(1, alpha));
|
|
62
|
-
}
|
|
63
|
-
function alphaColor(color, alpha) {
|
|
64
|
-
const channels = parseHexColor(color);
|
|
65
|
-
const boundedAlpha = clampAlpha(alpha);
|
|
66
|
-
if (!channels) {
|
|
67
|
-
return color;
|
|
68
|
-
}
|
|
69
|
-
return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
|
|
70
|
-
}
|
|
71
|
-
function blendColor(base, overlay, overlayAlpha) {
|
|
72
|
-
const baseChannels = parseHexColor(base);
|
|
73
|
-
const overlayChannels = parseHexColor(overlay);
|
|
74
|
-
const boundedAlpha = clampAlpha(overlayAlpha);
|
|
75
|
-
if (!baseChannels || !overlayChannels) {
|
|
76
|
-
return alphaColor(overlay, boundedAlpha);
|
|
77
|
-
}
|
|
78
|
-
const r = Math.round(
|
|
79
|
-
(1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
|
|
80
|
-
);
|
|
81
|
-
const g = Math.round(
|
|
82
|
-
(1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
|
|
83
|
-
);
|
|
84
|
-
const b = Math.round(
|
|
85
|
-
(1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
|
|
86
|
-
);
|
|
87
|
-
return `rgb(${r}, ${g}, ${b})`;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// src/utils/elevation.ts
|
|
91
34
|
var import_react_native = require("react-native");
|
|
92
|
-
|
|
93
|
-
if (import_react_native.Platform.OS === "web") {
|
|
94
|
-
const { shadowOffset, shadowOpacity, shadowRadius } = level;
|
|
95
|
-
if (shadowOpacity === 0) {
|
|
96
|
-
return { boxShadow: "none" };
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
boxShadow: `${shadowOffset.width}px ${shadowOffset.height}px ${shadowRadius}px rgba(0, 0, 0, ${shadowOpacity})`
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
shadowColor: level.shadowColor,
|
|
104
|
-
shadowOffset: {
|
|
105
|
-
width: level.shadowOffset.width,
|
|
106
|
-
height: level.shadowOffset.height
|
|
107
|
-
},
|
|
108
|
-
shadowOpacity: level.shadowOpacity,
|
|
109
|
-
shadowRadius: level.shadowRadius,
|
|
110
|
-
elevation: level.elevation
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/chip/styles.ts
|
|
35
|
+
var import_utils = require("@onlynative/utils");
|
|
115
36
|
function getVariantColors(theme, variant, elevated, selected) {
|
|
116
|
-
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
117
|
-
const disabledLabelColor = alphaColor(theme.colors.onSurface, 0.38);
|
|
118
|
-
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
37
|
+
const disabledContainerColor = (0, import_utils.alphaColor)(theme.colors.onSurface, 0.12);
|
|
38
|
+
const disabledLabelColor = (0, import_utils.alphaColor)(theme.colors.onSurface, 0.38);
|
|
39
|
+
const disabledOutlineColor = (0, import_utils.alphaColor)(theme.colors.onSurface, 0.12);
|
|
119
40
|
if (variant === "filter" && selected) {
|
|
120
41
|
return {
|
|
121
42
|
backgroundColor: theme.colors.secondaryContainer,
|
|
122
43
|
textColor: theme.colors.onSecondaryContainer,
|
|
123
44
|
borderColor: "transparent",
|
|
124
45
|
borderWidth: 0,
|
|
125
|
-
hoveredBackgroundColor: blendColor(
|
|
46
|
+
hoveredBackgroundColor: (0, import_utils.blendColor)(
|
|
126
47
|
theme.colors.secondaryContainer,
|
|
127
48
|
theme.colors.onSecondaryContainer,
|
|
128
49
|
theme.stateLayer.hoveredOpacity
|
|
129
50
|
),
|
|
130
|
-
pressedBackgroundColor: blendColor(
|
|
51
|
+
pressedBackgroundColor: (0, import_utils.blendColor)(
|
|
131
52
|
theme.colors.secondaryContainer,
|
|
132
53
|
theme.colors.onSecondaryContainer,
|
|
133
54
|
theme.stateLayer.pressedOpacity
|
|
@@ -144,12 +65,12 @@ function getVariantColors(theme, variant, elevated, selected) {
|
|
|
144
65
|
textColor: textColor2,
|
|
145
66
|
borderColor: "transparent",
|
|
146
67
|
borderWidth: 0,
|
|
147
|
-
hoveredBackgroundColor: blendColor(
|
|
68
|
+
hoveredBackgroundColor: (0, import_utils.blendColor)(
|
|
148
69
|
theme.colors.surfaceContainerLow,
|
|
149
70
|
textColor2,
|
|
150
71
|
theme.stateLayer.hoveredOpacity
|
|
151
72
|
),
|
|
152
|
-
pressedBackgroundColor: blendColor(
|
|
73
|
+
pressedBackgroundColor: (0, import_utils.blendColor)(
|
|
153
74
|
theme.colors.surfaceContainerLow,
|
|
154
75
|
textColor2,
|
|
155
76
|
theme.stateLayer.pressedOpacity
|
|
@@ -165,12 +86,12 @@ function getVariantColors(theme, variant, elevated, selected) {
|
|
|
165
86
|
textColor,
|
|
166
87
|
borderColor: theme.colors.outline,
|
|
167
88
|
borderWidth: 1,
|
|
168
|
-
hoveredBackgroundColor: blendColor(
|
|
89
|
+
hoveredBackgroundColor: (0, import_utils.blendColor)(
|
|
169
90
|
theme.colors.surface,
|
|
170
91
|
textColor,
|
|
171
92
|
theme.stateLayer.hoveredOpacity
|
|
172
93
|
),
|
|
173
|
-
pressedBackgroundColor: blendColor(
|
|
94
|
+
pressedBackgroundColor: (0, import_utils.blendColor)(
|
|
174
95
|
theme.colors.surface,
|
|
175
96
|
textColor,
|
|
176
97
|
theme.stateLayer.pressedOpacity
|
|
@@ -190,33 +111,33 @@ function applyColorOverrides(theme, colors, containerColor, contentColor) {
|
|
|
190
111
|
const overlay = contentColor != null ? contentColor : colors.textColor;
|
|
191
112
|
result.backgroundColor = containerColor;
|
|
192
113
|
result.borderColor = containerColor;
|
|
193
|
-
result.hoveredBackgroundColor = blendColor(
|
|
114
|
+
result.hoveredBackgroundColor = (0, import_utils.blendColor)(
|
|
194
115
|
containerColor,
|
|
195
116
|
overlay,
|
|
196
117
|
theme.stateLayer.hoveredOpacity
|
|
197
118
|
);
|
|
198
|
-
result.pressedBackgroundColor = blendColor(
|
|
119
|
+
result.pressedBackgroundColor = (0, import_utils.blendColor)(
|
|
199
120
|
containerColor,
|
|
200
121
|
overlay,
|
|
201
122
|
theme.stateLayer.pressedOpacity
|
|
202
123
|
);
|
|
203
124
|
} else if (contentColor) {
|
|
204
125
|
if (colors.backgroundColor === "transparent") {
|
|
205
|
-
result.hoveredBackgroundColor = alphaColor(
|
|
126
|
+
result.hoveredBackgroundColor = (0, import_utils.alphaColor)(
|
|
206
127
|
contentColor,
|
|
207
128
|
theme.stateLayer.hoveredOpacity
|
|
208
129
|
);
|
|
209
|
-
result.pressedBackgroundColor = alphaColor(
|
|
130
|
+
result.pressedBackgroundColor = (0, import_utils.alphaColor)(
|
|
210
131
|
contentColor,
|
|
211
132
|
theme.stateLayer.pressedOpacity
|
|
212
133
|
);
|
|
213
134
|
} else {
|
|
214
|
-
result.hoveredBackgroundColor = blendColor(
|
|
135
|
+
result.hoveredBackgroundColor = (0, import_utils.blendColor)(
|
|
215
136
|
colors.backgroundColor,
|
|
216
137
|
contentColor,
|
|
217
138
|
theme.stateLayer.hoveredOpacity
|
|
218
139
|
);
|
|
219
|
-
result.pressedBackgroundColor = blendColor(
|
|
140
|
+
result.pressedBackgroundColor = (0, import_utils.blendColor)(
|
|
220
141
|
colors.backgroundColor,
|
|
221
142
|
contentColor,
|
|
222
143
|
theme.stateLayer.pressedOpacity
|
|
@@ -234,12 +155,12 @@ function createStyles(theme, variant, elevated, selected, hasLeadingContent, has
|
|
|
234
155
|
contentColor
|
|
235
156
|
);
|
|
236
157
|
const labelStyle = theme.typography.labelLarge;
|
|
237
|
-
const elevationLevel0 = elevationStyle(theme.elevation.level0);
|
|
238
|
-
const elevationLevel1 = elevationStyle(theme.elevation.level1);
|
|
239
|
-
const elevationLevel2 = elevationStyle(theme.elevation.level2);
|
|
158
|
+
const elevationLevel0 = (0, import_utils.elevationStyle)(theme.elevation.level0);
|
|
159
|
+
const elevationLevel1 = (0, import_utils.elevationStyle)(theme.elevation.level1);
|
|
160
|
+
const elevationLevel2 = (0, import_utils.elevationStyle)(theme.elevation.level2);
|
|
240
161
|
const isElevated = elevated && variant !== "input";
|
|
241
162
|
const baseElevation = isElevated ? elevationLevel1 : elevationLevel0;
|
|
242
|
-
return
|
|
163
|
+
return import_react_native.StyleSheet.create({
|
|
243
164
|
container: {
|
|
244
165
|
alignSelf: "flex-start",
|
|
245
166
|
alignItems: "center",
|
|
@@ -336,6 +257,8 @@ function Chip({
|
|
|
336
257
|
const hasLeadingContent = Boolean(
|
|
337
258
|
variant === "input" && avatar || leadingIcon || variant === "filter" && isSelected
|
|
338
259
|
);
|
|
260
|
+
const needsIcons = Boolean(leadingIcon) || variant === "filter" && isSelected || showCloseIcon;
|
|
261
|
+
const MaterialCommunityIcons = needsIcons ? (0, import_utils2.getMaterialCommunityIcons)() : null;
|
|
339
262
|
const theme = (0, import_core.useTheme)();
|
|
340
263
|
const styles = (0, import_react.useMemo)(
|
|
341
264
|
() => createStyles(
|
|
@@ -360,7 +283,7 @@ function Chip({
|
|
|
360
283
|
]
|
|
361
284
|
);
|
|
362
285
|
const resolvedIconColor = (0, import_react.useMemo)(() => {
|
|
363
|
-
const base =
|
|
286
|
+
const base = import_react_native2.StyleSheet.flatten([
|
|
364
287
|
styles.label,
|
|
365
288
|
isDisabled ? styles.disabledLabel : void 0
|
|
366
289
|
]);
|
|
@@ -376,11 +299,11 @@ function Chip({
|
|
|
376
299
|
);
|
|
377
300
|
const renderLeadingContent = () => {
|
|
378
301
|
if (variant === "input" && avatar) {
|
|
379
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: styles.avatar, children: avatar });
|
|
380
303
|
}
|
|
381
304
|
if (leadingIcon) {
|
|
382
305
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
383
|
-
|
|
306
|
+
MaterialCommunityIcons,
|
|
384
307
|
{
|
|
385
308
|
name: leadingIcon,
|
|
386
309
|
size: iconSize,
|
|
@@ -391,7 +314,7 @@ function Chip({
|
|
|
391
314
|
}
|
|
392
315
|
if (variant === "filter" && isSelected) {
|
|
393
316
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
394
|
-
|
|
317
|
+
MaterialCommunityIcons,
|
|
395
318
|
{
|
|
396
319
|
name: "check",
|
|
397
320
|
size: iconSize,
|
|
@@ -403,7 +326,7 @@ function Chip({
|
|
|
403
326
|
return null;
|
|
404
327
|
};
|
|
405
328
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
406
|
-
|
|
329
|
+
import_react_native2.Pressable,
|
|
407
330
|
{
|
|
408
331
|
...props,
|
|
409
332
|
accessibilityRole: "button",
|
|
@@ -411,7 +334,7 @@ function Chip({
|
|
|
411
334
|
disabled: isDisabled,
|
|
412
335
|
...variant === "filter" ? { selected: isSelected } : void 0
|
|
413
336
|
},
|
|
414
|
-
hitSlop:
|
|
337
|
+
hitSlop: import_react_native2.Platform.OS === "web" ? void 0 : 4,
|
|
415
338
|
disabled: isDisabled,
|
|
416
339
|
style: resolveStyle(
|
|
417
340
|
styles.container,
|
|
@@ -423,9 +346,9 @@ function Chip({
|
|
|
423
346
|
),
|
|
424
347
|
children: [
|
|
425
348
|
renderLeadingContent(),
|
|
426
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
349
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: computedLabelStyle, children }),
|
|
427
350
|
showCloseIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
428
|
-
|
|
351
|
+
import_react_native2.Pressable,
|
|
429
352
|
{
|
|
430
353
|
onPress: onClose,
|
|
431
354
|
accessibilityRole: "button",
|
|
@@ -433,7 +356,7 @@ function Chip({
|
|
|
433
356
|
hitSlop: 4,
|
|
434
357
|
style: styles.closeButton,
|
|
435
358
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
436
|
-
|
|
359
|
+
MaterialCommunityIcons,
|
|
437
360
|
{
|
|
438
361
|
name: "close",
|
|
439
362
|
size: iconSize,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/icon-button/index.ts
|
|
@@ -35,62 +25,17 @@ __export(icon_button_exports, {
|
|
|
35
25
|
module.exports = __toCommonJS(icon_button_exports);
|
|
36
26
|
|
|
37
27
|
// src/icon-button/IconButton.tsx
|
|
38
|
-
var import_MaterialCommunityIcons = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
|
|
39
28
|
var import_react = require("react");
|
|
40
29
|
var import_react_native2 = require("react-native");
|
|
41
30
|
var import_core = require("@onlynative/core");
|
|
31
|
+
var import_utils2 = require("@onlynative/utils");
|
|
42
32
|
|
|
43
33
|
// src/icon-button/styles.ts
|
|
44
34
|
var import_react_native = require("react-native");
|
|
45
|
-
|
|
46
|
-
// src/utils/color.ts
|
|
47
|
-
function parseHexColor(color) {
|
|
48
|
-
const normalized = color.replace("#", "");
|
|
49
|
-
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
const r = Number.parseInt(normalized.slice(0, 2), 16);
|
|
53
|
-
const g = Number.parseInt(normalized.slice(2, 4), 16);
|
|
54
|
-
const b = Number.parseInt(normalized.slice(4, 6), 16);
|
|
55
|
-
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
return { r, g, b };
|
|
59
|
-
}
|
|
60
|
-
function clampAlpha(alpha) {
|
|
61
|
-
return Math.max(0, Math.min(1, alpha));
|
|
62
|
-
}
|
|
63
|
-
function alphaColor(color, alpha) {
|
|
64
|
-
const channels = parseHexColor(color);
|
|
65
|
-
const boundedAlpha = clampAlpha(alpha);
|
|
66
|
-
if (!channels) {
|
|
67
|
-
return color;
|
|
68
|
-
}
|
|
69
|
-
return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
|
|
70
|
-
}
|
|
71
|
-
function blendColor(base, overlay, overlayAlpha) {
|
|
72
|
-
const baseChannels = parseHexColor(base);
|
|
73
|
-
const overlayChannels = parseHexColor(overlay);
|
|
74
|
-
const boundedAlpha = clampAlpha(overlayAlpha);
|
|
75
|
-
if (!baseChannels || !overlayChannels) {
|
|
76
|
-
return alphaColor(overlay, boundedAlpha);
|
|
77
|
-
}
|
|
78
|
-
const r = Math.round(
|
|
79
|
-
(1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
|
|
80
|
-
);
|
|
81
|
-
const g = Math.round(
|
|
82
|
-
(1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
|
|
83
|
-
);
|
|
84
|
-
const b = Math.round(
|
|
85
|
-
(1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
|
|
86
|
-
);
|
|
87
|
-
return `rgb(${r}, ${g}, ${b})`;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// src/icon-button/styles.ts
|
|
35
|
+
var import_utils = require("@onlynative/utils");
|
|
91
36
|
function createStyles(theme) {
|
|
92
|
-
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
93
|
-
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
37
|
+
const disabledContainerColor = (0, import_utils.alphaColor)(theme.colors.onSurface, 0.12);
|
|
38
|
+
const disabledOutlineColor = (0, import_utils.alphaColor)(theme.colors.onSurface, 0.12);
|
|
94
39
|
const toggleUnselectedContainerColor = theme.colors.surfaceContainerHighest;
|
|
95
40
|
return import_react_native.StyleSheet.create({
|
|
96
41
|
container: {
|
|
@@ -158,160 +103,160 @@ function createStyles(theme) {
|
|
|
158
103
|
},
|
|
159
104
|
// Hover states (M3: 8% state layer)
|
|
160
105
|
hoveredFilled: {
|
|
161
|
-
backgroundColor: blendColor(
|
|
106
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
162
107
|
theme.colors.primary,
|
|
163
108
|
theme.colors.onPrimary,
|
|
164
109
|
theme.stateLayer.hoveredOpacity
|
|
165
110
|
)
|
|
166
111
|
},
|
|
167
112
|
hoveredFilledToggleUnselected: {
|
|
168
|
-
backgroundColor: blendColor(
|
|
113
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
169
114
|
toggleUnselectedContainerColor,
|
|
170
115
|
theme.colors.primary,
|
|
171
116
|
theme.stateLayer.hoveredOpacity
|
|
172
117
|
)
|
|
173
118
|
},
|
|
174
119
|
hoveredFilledToggleSelected: {
|
|
175
|
-
backgroundColor: blendColor(
|
|
120
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
176
121
|
theme.colors.primary,
|
|
177
122
|
theme.colors.onPrimary,
|
|
178
123
|
theme.stateLayer.hoveredOpacity
|
|
179
124
|
)
|
|
180
125
|
},
|
|
181
126
|
hoveredTonal: {
|
|
182
|
-
backgroundColor: blendColor(
|
|
127
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
183
128
|
theme.colors.secondaryContainer,
|
|
184
129
|
theme.colors.onSecondaryContainer,
|
|
185
130
|
theme.stateLayer.hoveredOpacity
|
|
186
131
|
)
|
|
187
132
|
},
|
|
188
133
|
hoveredTonalToggleUnselected: {
|
|
189
|
-
backgroundColor: blendColor(
|
|
134
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
190
135
|
toggleUnselectedContainerColor,
|
|
191
136
|
theme.colors.onSurfaceVariant,
|
|
192
137
|
theme.stateLayer.hoveredOpacity
|
|
193
138
|
)
|
|
194
139
|
},
|
|
195
140
|
hoveredTonalToggleSelected: {
|
|
196
|
-
backgroundColor: blendColor(
|
|
141
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
197
142
|
theme.colors.secondaryContainer,
|
|
198
143
|
theme.colors.onSecondaryContainer,
|
|
199
144
|
theme.stateLayer.hoveredOpacity
|
|
200
145
|
)
|
|
201
146
|
},
|
|
202
147
|
hoveredOutlined: {
|
|
203
|
-
backgroundColor: alphaColor(
|
|
148
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
204
149
|
theme.colors.onSurfaceVariant,
|
|
205
150
|
theme.stateLayer.hoveredOpacity
|
|
206
151
|
)
|
|
207
152
|
},
|
|
208
153
|
hoveredOutlinedToggleUnselected: {
|
|
209
|
-
backgroundColor: alphaColor(
|
|
154
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
210
155
|
theme.colors.onSurfaceVariant,
|
|
211
156
|
theme.stateLayer.hoveredOpacity
|
|
212
157
|
)
|
|
213
158
|
},
|
|
214
159
|
hoveredOutlinedToggleSelected: {
|
|
215
|
-
backgroundColor: blendColor(
|
|
160
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
216
161
|
theme.colors.inverseSurface,
|
|
217
162
|
theme.colors.inverseOnSurface,
|
|
218
163
|
theme.stateLayer.hoveredOpacity
|
|
219
164
|
)
|
|
220
165
|
},
|
|
221
166
|
hoveredStandard: {
|
|
222
|
-
backgroundColor: alphaColor(
|
|
167
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
223
168
|
theme.colors.onSurfaceVariant,
|
|
224
169
|
theme.stateLayer.hoveredOpacity
|
|
225
170
|
)
|
|
226
171
|
},
|
|
227
172
|
hoveredStandardToggleUnselected: {
|
|
228
|
-
backgroundColor: alphaColor(
|
|
173
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
229
174
|
theme.colors.onSurfaceVariant,
|
|
230
175
|
theme.stateLayer.hoveredOpacity
|
|
231
176
|
)
|
|
232
177
|
},
|
|
233
178
|
hoveredStandardToggleSelected: {
|
|
234
|
-
backgroundColor: alphaColor(
|
|
179
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
235
180
|
theme.colors.primary,
|
|
236
181
|
theme.stateLayer.hoveredOpacity
|
|
237
182
|
)
|
|
238
183
|
},
|
|
239
184
|
// Pressed states (M3: 12% state layer)
|
|
240
185
|
pressedFilled: {
|
|
241
|
-
backgroundColor: blendColor(
|
|
186
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
242
187
|
theme.colors.primary,
|
|
243
188
|
theme.colors.onPrimary,
|
|
244
189
|
theme.stateLayer.pressedOpacity
|
|
245
190
|
)
|
|
246
191
|
},
|
|
247
192
|
pressedFilledToggleUnselected: {
|
|
248
|
-
backgroundColor: blendColor(
|
|
193
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
249
194
|
toggleUnselectedContainerColor,
|
|
250
195
|
theme.colors.primary,
|
|
251
196
|
theme.stateLayer.pressedOpacity
|
|
252
197
|
)
|
|
253
198
|
},
|
|
254
199
|
pressedFilledToggleSelected: {
|
|
255
|
-
backgroundColor: blendColor(
|
|
200
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
256
201
|
theme.colors.primary,
|
|
257
202
|
theme.colors.onPrimary,
|
|
258
203
|
theme.stateLayer.pressedOpacity
|
|
259
204
|
)
|
|
260
205
|
},
|
|
261
206
|
pressedTonal: {
|
|
262
|
-
backgroundColor: blendColor(
|
|
207
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
263
208
|
theme.colors.secondaryContainer,
|
|
264
209
|
theme.colors.onSecondaryContainer,
|
|
265
210
|
theme.stateLayer.pressedOpacity
|
|
266
211
|
)
|
|
267
212
|
},
|
|
268
213
|
pressedTonalToggleUnselected: {
|
|
269
|
-
backgroundColor: blendColor(
|
|
214
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
270
215
|
toggleUnselectedContainerColor,
|
|
271
216
|
theme.colors.onSurfaceVariant,
|
|
272
217
|
theme.stateLayer.pressedOpacity
|
|
273
218
|
)
|
|
274
219
|
},
|
|
275
220
|
pressedTonalToggleSelected: {
|
|
276
|
-
backgroundColor: blendColor(
|
|
221
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
277
222
|
theme.colors.secondaryContainer,
|
|
278
223
|
theme.colors.onSecondaryContainer,
|
|
279
224
|
theme.stateLayer.pressedOpacity
|
|
280
225
|
)
|
|
281
226
|
},
|
|
282
227
|
pressedOutlined: {
|
|
283
|
-
backgroundColor: alphaColor(
|
|
228
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
284
229
|
theme.colors.onSurfaceVariant,
|
|
285
230
|
theme.stateLayer.pressedOpacity
|
|
286
231
|
)
|
|
287
232
|
},
|
|
288
233
|
pressedOutlinedToggleUnselected: {
|
|
289
|
-
backgroundColor: alphaColor(
|
|
234
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
290
235
|
theme.colors.onSurfaceVariant,
|
|
291
236
|
theme.stateLayer.pressedOpacity
|
|
292
237
|
)
|
|
293
238
|
},
|
|
294
239
|
pressedOutlinedToggleSelected: {
|
|
295
|
-
backgroundColor: blendColor(
|
|
240
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
296
241
|
theme.colors.inverseSurface,
|
|
297
242
|
theme.colors.inverseOnSurface,
|
|
298
243
|
theme.stateLayer.pressedOpacity
|
|
299
244
|
)
|
|
300
245
|
},
|
|
301
246
|
pressedStandard: {
|
|
302
|
-
backgroundColor: alphaColor(
|
|
247
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
303
248
|
theme.colors.onSurfaceVariant,
|
|
304
249
|
theme.stateLayer.pressedOpacity
|
|
305
250
|
)
|
|
306
251
|
},
|
|
307
252
|
pressedStandardToggleUnselected: {
|
|
308
|
-
backgroundColor: alphaColor(
|
|
253
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
309
254
|
theme.colors.onSurfaceVariant,
|
|
310
255
|
theme.stateLayer.pressedOpacity
|
|
311
256
|
)
|
|
312
257
|
},
|
|
313
258
|
pressedStandardToggleSelected: {
|
|
314
|
-
backgroundColor: alphaColor(
|
|
259
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
315
260
|
theme.colors.primary,
|
|
316
261
|
theme.stateLayer.pressedOpacity
|
|
317
262
|
)
|
|
@@ -344,7 +289,7 @@ function createStyles(theme) {
|
|
|
344
289
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
345
290
|
function getIconColor(variant, theme, disabled, isToggle, selected) {
|
|
346
291
|
if (disabled) {
|
|
347
|
-
return alphaColor(theme.colors.onSurface, 0.38);
|
|
292
|
+
return (0, import_utils2.alphaColor)(theme.colors.onSurface, 0.38);
|
|
348
293
|
}
|
|
349
294
|
if (isToggle) {
|
|
350
295
|
if (variant === "filled") {
|
|
@@ -494,6 +439,7 @@ function IconButton({
|
|
|
494
439
|
...props
|
|
495
440
|
}) {
|
|
496
441
|
var _a;
|
|
442
|
+
const MaterialCommunityIcons = (0, import_utils2.getMaterialCommunityIcons)();
|
|
497
443
|
const theme = (0, import_core.useTheme)();
|
|
498
444
|
const styles = (0, import_react.useMemo)(() => createStyles(theme), [theme]);
|
|
499
445
|
const isDisabled = Boolean(disabled);
|
|
@@ -513,14 +459,14 @@ function IconButton({
|
|
|
513
459
|
borderWidth: 0
|
|
514
460
|
},
|
|
515
461
|
hovered: {
|
|
516
|
-
backgroundColor: blendColor(
|
|
462
|
+
backgroundColor: (0, import_utils2.blendColor)(
|
|
517
463
|
containerColor,
|
|
518
464
|
overlay,
|
|
519
465
|
theme.stateLayer.hoveredOpacity
|
|
520
466
|
)
|
|
521
467
|
},
|
|
522
468
|
pressed: {
|
|
523
|
-
backgroundColor: blendColor(
|
|
469
|
+
backgroundColor: (0, import_utils2.blendColor)(
|
|
524
470
|
containerColor,
|
|
525
471
|
overlay,
|
|
526
472
|
theme.stateLayer.pressedOpacity
|
|
@@ -559,7 +505,7 @@ function IconButton({
|
|
|
559
505
|
return base;
|
|
560
506
|
},
|
|
561
507
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
562
|
-
|
|
508
|
+
MaterialCommunityIcons,
|
|
563
509
|
{
|
|
564
510
|
name: displayIcon,
|
|
565
511
|
size: iconPixelSize,
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { Radio, RadioProps } from './radio/index.js';
|
|
|
11
11
|
export { Switch, SwitchProps } from './switch/index.js';
|
|
12
12
|
export { TextField, TextFieldProps, TextFieldVariant } from './text-field/index.js';
|
|
13
13
|
export { List, ListDivider, ListDividerProps, ListItem, ListItemLines, ListItemProps, ListProps } from './list/index.js';
|
|
14
|
+
export { KeyboardAvoidingWrapper, KeyboardAvoidingWrapperProps } from './keyboard-avoiding-wrapper/index.js';
|
|
14
15
|
import 'react/jsx-runtime';
|
|
15
16
|
import 'react';
|
|
16
17
|
import 'react-native';
|