@onlynative/components 0.1.0-alpha.0 → 0.1.0-alpha.3
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/README.md +1 -1
- package/dist/appbar/index.js +37 -17
- package/dist/button/index.js +24 -13
- package/dist/checkbox/index.js +23 -12
- package/dist/chip/index.js +26 -14
- package/dist/icon-button/index.js +23 -12
- package/dist/index.js +52 -21
- package/dist/layout/index.d.ts +2 -2
- package/dist/switch/index.js +23 -12
- package/dist/text-field/index.js +24 -13
- package/dist/typography/index.d.ts +2 -2
- package/dist/typography/index.js +14 -5
- package/package.json +9 -3
- package/src/appbar/styles.ts +2 -2
- package/src/button/Button.tsx +4 -1
- package/src/button/styles.ts +5 -5
- package/src/card/styles.ts +4 -4
- package/src/checkbox/Checkbox.tsx +5 -1
- package/src/checkbox/styles.ts +4 -4
- package/src/chip/Chip.tsx +7 -1
- package/src/chip/styles.ts +4 -4
- package/src/icon-button/IconButton.tsx +2 -1
- package/src/icon-button/styles.ts +2 -2
- package/src/layout/resolveSpacing.ts +2 -2
- package/src/layout/types.ts +2 -2
- package/src/list/styles.ts +5 -5
- package/src/radio/styles.ts +5 -5
- package/src/switch/Switch.tsx +4 -1
- package/src/switch/styles.ts +4 -4
- package/src/test-utils/render-with-theme.tsx +2 -2
- package/src/text-field/TextField.tsx +4 -1
- package/src/text-field/styles.ts +3 -3
- package/src/typography/Typography.tsx +22 -10
- package/src/utils/icon.ts +30 -0
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Material Design 3 UI components for React Native, part of [OnlyNative UI](https:
|
|
|
8
8
|
pnpm add @onlynative/core @onlynative/components @expo/vector-icons react-native-safe-area-context
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Wrap your app with `
|
|
11
|
+
Wrap your app with `ThemeProvider` from `@onlynative/core` (see [@onlynative/core](https://www.npmjs.com/package/@onlynative/core)).
|
|
12
12
|
|
|
13
13
|
## Import
|
|
14
14
|
|
package/dist/appbar/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/appbar/index.ts
|
|
@@ -41,11 +31,31 @@ var import_react_native_safe_area_context = require("react-native-safe-area-cont
|
|
|
41
31
|
var import_core4 = require("@onlynative/core");
|
|
42
32
|
|
|
43
33
|
// src/icon-button/IconButton.tsx
|
|
44
|
-
var import_MaterialCommunityIcons = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
|
|
45
34
|
var import_react = require("react");
|
|
46
35
|
var import_react_native2 = require("react-native");
|
|
47
36
|
var import_core = require("@onlynative/core");
|
|
48
37
|
|
|
38
|
+
// src/utils/icon.ts
|
|
39
|
+
var _MCIcons = null;
|
|
40
|
+
var _resolved = false;
|
|
41
|
+
function getMaterialCommunityIcons() {
|
|
42
|
+
if (!_resolved) {
|
|
43
|
+
_resolved = true;
|
|
44
|
+
try {
|
|
45
|
+
const mod = require("@expo/vector-icons/MaterialCommunityIcons");
|
|
46
|
+
_MCIcons = mod.default || mod;
|
|
47
|
+
} catch {
|
|
48
|
+
_MCIcons = null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!_MCIcons) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return _MCIcons;
|
|
57
|
+
}
|
|
58
|
+
|
|
49
59
|
// src/icon-button/styles.ts
|
|
50
60
|
var import_react_native = require("react-native");
|
|
51
61
|
|
|
@@ -500,6 +510,7 @@ function IconButton({
|
|
|
500
510
|
...props
|
|
501
511
|
}) {
|
|
502
512
|
var _a;
|
|
513
|
+
const MaterialCommunityIcons = getMaterialCommunityIcons();
|
|
503
514
|
const theme = (0, import_core.useTheme)();
|
|
504
515
|
const styles = (0, import_react.useMemo)(() => createStyles(theme), [theme]);
|
|
505
516
|
const isDisabled = Boolean(disabled);
|
|
@@ -565,7 +576,7 @@ function IconButton({
|
|
|
565
576
|
return base;
|
|
566
577
|
},
|
|
567
578
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
568
|
-
|
|
579
|
+
MaterialCommunityIcons,
|
|
569
580
|
{
|
|
570
581
|
name: displayIcon,
|
|
571
582
|
size: iconPixelSize,
|
|
@@ -600,17 +611,26 @@ function Typography({
|
|
|
600
611
|
}) {
|
|
601
612
|
const theme = (0, import_core2.useTheme)();
|
|
602
613
|
const typographyStyle = theme.typography[variant];
|
|
603
|
-
const colorStyle = (0, import_react2.useMemo)(
|
|
604
|
-
() => ({ color: color != null ? color : theme.colors.onSurface }),
|
|
605
|
-
[color, theme.colors.onSurface]
|
|
606
|
-
);
|
|
607
614
|
const resolvedRole = accessibilityRole != null ? accessibilityRole : HEADING_VARIANTS.has(variant) ? "header" : void 0;
|
|
615
|
+
const lineHeightFix = (0, import_react2.useMemo)(() => {
|
|
616
|
+
if (!style) return void 0;
|
|
617
|
+
const flat = import_react_native3.StyleSheet.flatten(style);
|
|
618
|
+
if (!(flat == null ? void 0 : flat.fontSize) || flat.lineHeight) return void 0;
|
|
619
|
+
const ratio = typographyStyle.lineHeight / typographyStyle.fontSize;
|
|
620
|
+
return { lineHeight: Math.ceil(flat.fontSize * ratio) };
|
|
621
|
+
}, [style, typographyStyle.fontSize, typographyStyle.lineHeight]);
|
|
608
622
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
609
623
|
Component,
|
|
610
624
|
{
|
|
611
625
|
...textProps,
|
|
612
626
|
accessibilityRole: resolvedRole,
|
|
613
|
-
style: [
|
|
627
|
+
style: [
|
|
628
|
+
{ color: theme.colors.onSurface },
|
|
629
|
+
typographyStyle,
|
|
630
|
+
style,
|
|
631
|
+
lineHeightFix,
|
|
632
|
+
color != null ? { color } : void 0
|
|
633
|
+
],
|
|
614
634
|
children
|
|
615
635
|
}
|
|
616
636
|
);
|
package/dist/button/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/button/index.ts
|
|
@@ -35,13 +25,33 @@ __export(button_exports, {
|
|
|
35
25
|
module.exports = __toCommonJS(button_exports);
|
|
36
26
|
|
|
37
27
|
// src/button/Button.tsx
|
|
38
|
-
var import_MaterialCommunityIcons = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
|
|
39
28
|
var import_react = require("react");
|
|
40
29
|
var import_react_native3 = require("react-native");
|
|
41
30
|
var import_react_native4 = require("react-native");
|
|
42
31
|
var import_react_native5 = require("react-native");
|
|
43
32
|
var import_core = require("@onlynative/core");
|
|
44
33
|
|
|
34
|
+
// src/utils/icon.ts
|
|
35
|
+
var _MCIcons = null;
|
|
36
|
+
var _resolved = false;
|
|
37
|
+
function getMaterialCommunityIcons() {
|
|
38
|
+
if (!_resolved) {
|
|
39
|
+
_resolved = true;
|
|
40
|
+
try {
|
|
41
|
+
const mod = require("@expo/vector-icons/MaterialCommunityIcons");
|
|
42
|
+
_MCIcons = mod.default || mod;
|
|
43
|
+
} catch {
|
|
44
|
+
_MCIcons = null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!_MCIcons) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return _MCIcons;
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
// src/button/styles.ts
|
|
46
56
|
var import_react_native2 = require("react-native");
|
|
47
57
|
|
|
@@ -393,6 +403,7 @@ function Button({
|
|
|
393
403
|
),
|
|
394
404
|
[theme, variant, hasLeading, hasTrailing, containerColor, contentColor]
|
|
395
405
|
);
|
|
406
|
+
const MaterialCommunityIcons = leadingIcon || trailingIcon ? getMaterialCommunityIcons() : null;
|
|
396
407
|
const resolvedIconColor = (0, import_react.useMemo)(() => {
|
|
397
408
|
const base = import_react_native4.StyleSheet.flatten([
|
|
398
409
|
styles.label,
|
|
@@ -426,7 +437,7 @@ function Button({
|
|
|
426
437
|
),
|
|
427
438
|
children: [
|
|
428
439
|
leadingIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
429
|
-
|
|
440
|
+
MaterialCommunityIcons,
|
|
430
441
|
{
|
|
431
442
|
name: leadingIcon,
|
|
432
443
|
size: iconSize,
|
|
@@ -436,7 +447,7 @@ function Button({
|
|
|
436
447
|
) : null,
|
|
437
448
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Text, { style: computedLabelStyle, children }),
|
|
438
449
|
trailingIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
439
|
-
|
|
450
|
+
MaterialCommunityIcons,
|
|
440
451
|
{
|
|
441
452
|
name: trailingIcon,
|
|
442
453
|
size: iconSize,
|
package/dist/checkbox/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/checkbox/index.ts
|
|
@@ -35,11 +25,31 @@ __export(checkbox_exports, {
|
|
|
35
25
|
module.exports = __toCommonJS(checkbox_exports);
|
|
36
26
|
|
|
37
27
|
// src/checkbox/Checkbox.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");
|
|
42
31
|
|
|
32
|
+
// src/utils/icon.ts
|
|
33
|
+
var _MCIcons = null;
|
|
34
|
+
var _resolved = false;
|
|
35
|
+
function getMaterialCommunityIcons() {
|
|
36
|
+
if (!_resolved) {
|
|
37
|
+
_resolved = true;
|
|
38
|
+
try {
|
|
39
|
+
const mod = require("@expo/vector-icons/MaterialCommunityIcons");
|
|
40
|
+
_MCIcons = mod.default || mod;
|
|
41
|
+
} catch {
|
|
42
|
+
_MCIcons = null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!_MCIcons) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return _MCIcons;
|
|
51
|
+
}
|
|
52
|
+
|
|
43
53
|
// src/checkbox/styles.ts
|
|
44
54
|
var import_react_native = require("react-native");
|
|
45
55
|
|
|
@@ -237,6 +247,7 @@ function Checkbox({
|
|
|
237
247
|
}) {
|
|
238
248
|
const isDisabled = Boolean(disabled);
|
|
239
249
|
const isChecked = Boolean(value);
|
|
250
|
+
const MaterialCommunityIcons = isChecked ? getMaterialCommunityIcons() : null;
|
|
240
251
|
const theme = (0, import_core.useTheme)();
|
|
241
252
|
const styles = (0, import_react.useMemo)(
|
|
242
253
|
() => createStyles(theme, isChecked, containerColor, contentColor),
|
|
@@ -275,7 +286,7 @@ function Checkbox({
|
|
|
275
286
|
style
|
|
276
287
|
),
|
|
277
288
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.box, isDisabled ? styles.disabledBox : void 0], children: isChecked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
278
|
-
|
|
289
|
+
MaterialCommunityIcons,
|
|
279
290
|
{
|
|
280
291
|
name: "check",
|
|
281
292
|
size: 14,
|
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,11 +25,31 @@ __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
29
|
var import_react_native3 = require("react-native");
|
|
41
30
|
var import_core = require("@onlynative/core");
|
|
42
31
|
|
|
32
|
+
// src/utils/icon.ts
|
|
33
|
+
var _MCIcons = null;
|
|
34
|
+
var _resolved = false;
|
|
35
|
+
function getMaterialCommunityIcons() {
|
|
36
|
+
if (!_resolved) {
|
|
37
|
+
_resolved = true;
|
|
38
|
+
try {
|
|
39
|
+
const mod = require("@expo/vector-icons/MaterialCommunityIcons");
|
|
40
|
+
_MCIcons = mod.default || mod;
|
|
41
|
+
} catch {
|
|
42
|
+
_MCIcons = null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!_MCIcons) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return _MCIcons;
|
|
51
|
+
}
|
|
52
|
+
|
|
43
53
|
// src/chip/styles.ts
|
|
44
54
|
var import_react_native2 = require("react-native");
|
|
45
55
|
|
|
@@ -336,6 +346,8 @@ function Chip({
|
|
|
336
346
|
const hasLeadingContent = Boolean(
|
|
337
347
|
variant === "input" && avatar || leadingIcon || variant === "filter" && isSelected
|
|
338
348
|
);
|
|
349
|
+
const needsIcons = Boolean(leadingIcon) || variant === "filter" && isSelected || showCloseIcon;
|
|
350
|
+
const MaterialCommunityIcons = needsIcons ? getMaterialCommunityIcons() : null;
|
|
339
351
|
const theme = (0, import_core.useTheme)();
|
|
340
352
|
const styles = (0, import_react.useMemo)(
|
|
341
353
|
() => createStyles(
|
|
@@ -380,7 +392,7 @@ function Chip({
|
|
|
380
392
|
}
|
|
381
393
|
if (leadingIcon) {
|
|
382
394
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
383
|
-
|
|
395
|
+
MaterialCommunityIcons,
|
|
384
396
|
{
|
|
385
397
|
name: leadingIcon,
|
|
386
398
|
size: iconSize,
|
|
@@ -391,7 +403,7 @@ function Chip({
|
|
|
391
403
|
}
|
|
392
404
|
if (variant === "filter" && isSelected) {
|
|
393
405
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
394
|
-
|
|
406
|
+
MaterialCommunityIcons,
|
|
395
407
|
{
|
|
396
408
|
name: "check",
|
|
397
409
|
size: iconSize,
|
|
@@ -433,7 +445,7 @@ function Chip({
|
|
|
433
445
|
hitSlop: 4,
|
|
434
446
|
style: styles.closeButton,
|
|
435
447
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
436
|
-
|
|
448
|
+
MaterialCommunityIcons,
|
|
437
449
|
{
|
|
438
450
|
name: "close",
|
|
439
451
|
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,11 +25,31 @@ __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");
|
|
42
31
|
|
|
32
|
+
// src/utils/icon.ts
|
|
33
|
+
var _MCIcons = null;
|
|
34
|
+
var _resolved = false;
|
|
35
|
+
function getMaterialCommunityIcons() {
|
|
36
|
+
if (!_resolved) {
|
|
37
|
+
_resolved = true;
|
|
38
|
+
try {
|
|
39
|
+
const mod = require("@expo/vector-icons/MaterialCommunityIcons");
|
|
40
|
+
_MCIcons = mod.default || mod;
|
|
41
|
+
} catch {
|
|
42
|
+
_MCIcons = null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!_MCIcons) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return _MCIcons;
|
|
51
|
+
}
|
|
52
|
+
|
|
43
53
|
// src/icon-button/styles.ts
|
|
44
54
|
var import_react_native = require("react-native");
|
|
45
55
|
|
|
@@ -494,6 +504,7 @@ function IconButton({
|
|
|
494
504
|
...props
|
|
495
505
|
}) {
|
|
496
506
|
var _a;
|
|
507
|
+
const MaterialCommunityIcons = getMaterialCommunityIcons();
|
|
497
508
|
const theme = (0, import_core.useTheme)();
|
|
498
509
|
const styles = (0, import_react.useMemo)(() => createStyles(theme), [theme]);
|
|
499
510
|
const isDisabled = Boolean(disabled);
|
|
@@ -559,7 +570,7 @@ function IconButton({
|
|
|
559
570
|
return base;
|
|
560
571
|
},
|
|
561
572
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
562
|
-
|
|
573
|
+
MaterialCommunityIcons,
|
|
563
574
|
{
|
|
564
575
|
name: displayIcon,
|
|
565
576
|
size: iconPixelSize,
|
package/dist/index.js
CHANGED
|
@@ -75,17 +75,26 @@ function Typography({
|
|
|
75
75
|
}) {
|
|
76
76
|
const theme = (0, import_core.useTheme)();
|
|
77
77
|
const typographyStyle = theme.typography[variant];
|
|
78
|
-
const colorStyle = (0, import_react.useMemo)(
|
|
79
|
-
() => ({ color: color != null ? color : theme.colors.onSurface }),
|
|
80
|
-
[color, theme.colors.onSurface]
|
|
81
|
-
);
|
|
82
78
|
const resolvedRole = accessibilityRole != null ? accessibilityRole : HEADING_VARIANTS.has(variant) ? "header" : void 0;
|
|
79
|
+
const lineHeightFix = (0, import_react.useMemo)(() => {
|
|
80
|
+
if (!style) return void 0;
|
|
81
|
+
const flat = import_react_native.StyleSheet.flatten(style);
|
|
82
|
+
if (!(flat == null ? void 0 : flat.fontSize) || flat.lineHeight) return void 0;
|
|
83
|
+
const ratio = typographyStyle.lineHeight / typographyStyle.fontSize;
|
|
84
|
+
return { lineHeight: Math.ceil(flat.fontSize * ratio) };
|
|
85
|
+
}, [style, typographyStyle.fontSize, typographyStyle.lineHeight]);
|
|
83
86
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
84
87
|
Component,
|
|
85
88
|
{
|
|
86
89
|
...textProps,
|
|
87
90
|
accessibilityRole: resolvedRole,
|
|
88
|
-
style: [
|
|
91
|
+
style: [
|
|
92
|
+
{ color: theme.colors.onSurface },
|
|
93
|
+
typographyStyle,
|
|
94
|
+
style,
|
|
95
|
+
lineHeightFix,
|
|
96
|
+
color != null ? { color } : void 0
|
|
97
|
+
],
|
|
89
98
|
children
|
|
90
99
|
}
|
|
91
100
|
);
|
|
@@ -327,13 +336,33 @@ function Grid({
|
|
|
327
336
|
}
|
|
328
337
|
|
|
329
338
|
// src/button/Button.tsx
|
|
330
|
-
var import_MaterialCommunityIcons = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
|
|
331
339
|
var import_react7 = require("react");
|
|
332
340
|
var import_react_native7 = require("react-native");
|
|
333
341
|
var import_react_native8 = require("react-native");
|
|
334
342
|
var import_react_native9 = require("react-native");
|
|
335
343
|
var import_core5 = require("@onlynative/core");
|
|
336
344
|
|
|
345
|
+
// src/utils/icon.ts
|
|
346
|
+
var _MCIcons = null;
|
|
347
|
+
var _resolved = false;
|
|
348
|
+
function getMaterialCommunityIcons() {
|
|
349
|
+
if (!_resolved) {
|
|
350
|
+
_resolved = true;
|
|
351
|
+
try {
|
|
352
|
+
const mod = require("@expo/vector-icons/MaterialCommunityIcons");
|
|
353
|
+
_MCIcons = mod.default || mod;
|
|
354
|
+
} catch {
|
|
355
|
+
_MCIcons = null;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (!_MCIcons) {
|
|
359
|
+
throw new Error(
|
|
360
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
return _MCIcons;
|
|
364
|
+
}
|
|
365
|
+
|
|
337
366
|
// src/button/styles.ts
|
|
338
367
|
var import_react_native6 = require("react-native");
|
|
339
368
|
|
|
@@ -685,6 +714,7 @@ function Button({
|
|
|
685
714
|
),
|
|
686
715
|
[theme, variant, hasLeading, hasTrailing, containerColor, contentColor]
|
|
687
716
|
);
|
|
717
|
+
const MaterialCommunityIcons = leadingIcon || trailingIcon ? getMaterialCommunityIcons() : null;
|
|
688
718
|
const resolvedIconColor = (0, import_react7.useMemo)(() => {
|
|
689
719
|
const base = import_react_native8.StyleSheet.flatten([
|
|
690
720
|
styles2.label,
|
|
@@ -718,7 +748,7 @@ function Button({
|
|
|
718
748
|
),
|
|
719
749
|
children: [
|
|
720
750
|
leadingIcon ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
721
|
-
|
|
751
|
+
MaterialCommunityIcons,
|
|
722
752
|
{
|
|
723
753
|
name: leadingIcon,
|
|
724
754
|
size: iconSize,
|
|
@@ -728,7 +758,7 @@ function Button({
|
|
|
728
758
|
) : null,
|
|
729
759
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native9.Text, { style: computedLabelStyle, children }),
|
|
730
760
|
trailingIcon ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
731
|
-
|
|
761
|
+
MaterialCommunityIcons,
|
|
732
762
|
{
|
|
733
763
|
name: trailingIcon,
|
|
734
764
|
size: iconSize,
|
|
@@ -742,7 +772,6 @@ function Button({
|
|
|
742
772
|
}
|
|
743
773
|
|
|
744
774
|
// src/icon-button/IconButton.tsx
|
|
745
|
-
var import_MaterialCommunityIcons2 = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
|
|
746
775
|
var import_react8 = require("react");
|
|
747
776
|
var import_react_native11 = require("react-native");
|
|
748
777
|
var import_core6 = require("@onlynative/core");
|
|
@@ -1155,6 +1184,7 @@ function IconButton({
|
|
|
1155
1184
|
...props
|
|
1156
1185
|
}) {
|
|
1157
1186
|
var _a;
|
|
1187
|
+
const MaterialCommunityIcons = getMaterialCommunityIcons();
|
|
1158
1188
|
const theme = (0, import_core6.useTheme)();
|
|
1159
1189
|
const styles2 = (0, import_react8.useMemo)(() => createStyles2(theme), [theme]);
|
|
1160
1190
|
const isDisabled = Boolean(disabled);
|
|
@@ -1220,7 +1250,7 @@ function IconButton({
|
|
|
1220
1250
|
return base;
|
|
1221
1251
|
},
|
|
1222
1252
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1223
|
-
|
|
1253
|
+
MaterialCommunityIcons,
|
|
1224
1254
|
{
|
|
1225
1255
|
name: displayIcon,
|
|
1226
1256
|
size: iconPixelSize,
|
|
@@ -1737,7 +1767,6 @@ function Card({
|
|
|
1737
1767
|
}
|
|
1738
1768
|
|
|
1739
1769
|
// src/chip/Chip.tsx
|
|
1740
|
-
var import_MaterialCommunityIcons3 = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
|
|
1741
1770
|
var import_react11 = require("react");
|
|
1742
1771
|
var import_react_native18 = require("react-native");
|
|
1743
1772
|
var import_core10 = require("@onlynative/core");
|
|
@@ -1968,6 +1997,8 @@ function Chip({
|
|
|
1968
1997
|
const hasLeadingContent = Boolean(
|
|
1969
1998
|
variant === "input" && avatar || leadingIcon || variant === "filter" && isSelected
|
|
1970
1999
|
);
|
|
2000
|
+
const needsIcons = Boolean(leadingIcon) || variant === "filter" && isSelected || showCloseIcon;
|
|
2001
|
+
const MaterialCommunityIcons = needsIcons ? getMaterialCommunityIcons() : null;
|
|
1971
2002
|
const theme = (0, import_core10.useTheme)();
|
|
1972
2003
|
const styles2 = (0, import_react11.useMemo)(
|
|
1973
2004
|
() => createStyles5(
|
|
@@ -2012,7 +2043,7 @@ function Chip({
|
|
|
2012
2043
|
}
|
|
2013
2044
|
if (leadingIcon) {
|
|
2014
2045
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2015
|
-
|
|
2046
|
+
MaterialCommunityIcons,
|
|
2016
2047
|
{
|
|
2017
2048
|
name: leadingIcon,
|
|
2018
2049
|
size: iconSize,
|
|
@@ -2023,7 +2054,7 @@ function Chip({
|
|
|
2023
2054
|
}
|
|
2024
2055
|
if (variant === "filter" && isSelected) {
|
|
2025
2056
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2026
|
-
|
|
2057
|
+
MaterialCommunityIcons,
|
|
2027
2058
|
{
|
|
2028
2059
|
name: "check",
|
|
2029
2060
|
size: iconSize,
|
|
@@ -2065,7 +2096,7 @@ function Chip({
|
|
|
2065
2096
|
hitSlop: 4,
|
|
2066
2097
|
style: styles2.closeButton,
|
|
2067
2098
|
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2068
|
-
|
|
2099
|
+
MaterialCommunityIcons,
|
|
2069
2100
|
{
|
|
2070
2101
|
name: "close",
|
|
2071
2102
|
size: iconSize,
|
|
@@ -2080,7 +2111,6 @@ function Chip({
|
|
|
2080
2111
|
}
|
|
2081
2112
|
|
|
2082
2113
|
// src/checkbox/Checkbox.tsx
|
|
2083
|
-
var import_MaterialCommunityIcons4 = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
|
|
2084
2114
|
var import_react12 = require("react");
|
|
2085
2115
|
var import_react_native20 = require("react-native");
|
|
2086
2116
|
var import_core11 = require("@onlynative/core");
|
|
@@ -2236,6 +2266,7 @@ function Checkbox({
|
|
|
2236
2266
|
}) {
|
|
2237
2267
|
const isDisabled = Boolean(disabled);
|
|
2238
2268
|
const isChecked = Boolean(value);
|
|
2269
|
+
const MaterialCommunityIcons = isChecked ? getMaterialCommunityIcons() : null;
|
|
2239
2270
|
const theme = (0, import_core11.useTheme)();
|
|
2240
2271
|
const styles2 = (0, import_react12.useMemo)(
|
|
2241
2272
|
() => createStyles6(theme, isChecked, containerColor, contentColor),
|
|
@@ -2274,7 +2305,7 @@ function Checkbox({
|
|
|
2274
2305
|
style
|
|
2275
2306
|
),
|
|
2276
2307
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native20.View, { style: [styles2.box, isDisabled ? styles2.disabledBox : void 0], children: isChecked ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2277
|
-
|
|
2308
|
+
MaterialCommunityIcons,
|
|
2278
2309
|
{
|
|
2279
2310
|
name: "check",
|
|
2280
2311
|
size: 14,
|
|
@@ -2479,7 +2510,6 @@ function Radio({
|
|
|
2479
2510
|
}
|
|
2480
2511
|
|
|
2481
2512
|
// src/switch/Switch.tsx
|
|
2482
|
-
var import_MaterialCommunityIcons5 = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
|
|
2483
2513
|
var import_react14 = require("react");
|
|
2484
2514
|
var import_react_native24 = require("react-native");
|
|
2485
2515
|
var import_core13 = require("@onlynative/core");
|
|
@@ -2669,6 +2699,7 @@ function Switch({
|
|
|
2669
2699
|
}
|
|
2670
2700
|
};
|
|
2671
2701
|
const iconName = isSelected ? selectedIcon : unselectedIcon;
|
|
2702
|
+
const MaterialCommunityIcons = iconName ? getMaterialCommunityIcons() : null;
|
|
2672
2703
|
const iconSize = 16;
|
|
2673
2704
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2674
2705
|
import_react_native24.Pressable,
|
|
@@ -2695,7 +2726,7 @@ function Switch({
|
|
|
2695
2726
|
{
|
|
2696
2727
|
style: [styles2.thumb, isDisabled ? styles2.disabledThumb : void 0],
|
|
2697
2728
|
children: iconName ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2698
|
-
|
|
2729
|
+
MaterialCommunityIcons,
|
|
2699
2730
|
{
|
|
2700
2731
|
name: iconName,
|
|
2701
2732
|
size: iconSize,
|
|
@@ -2709,7 +2740,6 @@ function Switch({
|
|
|
2709
2740
|
}
|
|
2710
2741
|
|
|
2711
2742
|
// src/text-field/TextField.tsx
|
|
2712
|
-
var import_MaterialCommunityIcons6 = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
|
|
2713
2743
|
var import_react15 = require("react");
|
|
2714
2744
|
var import_react_native26 = require("react-native");
|
|
2715
2745
|
var import_core14 = require("@onlynative/core");
|
|
@@ -2938,6 +2968,7 @@ function TextField({
|
|
|
2938
2968
|
const isError = Boolean(error) || Boolean(errorText);
|
|
2939
2969
|
const isFilled = variant === "filled";
|
|
2940
2970
|
const hasLeadingIcon = Boolean(leadingIcon);
|
|
2971
|
+
const MaterialCommunityIcons = leadingIcon || trailingIcon ? getMaterialCommunityIcons() : null;
|
|
2941
2972
|
const { colors, styles: styles2 } = (0, import_react15.useMemo)(
|
|
2942
2973
|
() => createStyles9(theme, variant),
|
|
2943
2974
|
[theme, variant]
|
|
@@ -3037,7 +3068,7 @@ function TextField({
|
|
|
3037
3068
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native26.View, { style: [styles2.root, style], children: [
|
|
3038
3069
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native26.Pressable, { onPress: handleContainerPress, disabled: isDisabled, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native26.View, { style: containerStyle, children: [
|
|
3039
3070
|
leadingIcon ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native26.View, { style: styles2.leadingIcon, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3040
|
-
|
|
3071
|
+
MaterialCommunityIcons,
|
|
3041
3072
|
{
|
|
3042
3073
|
name: leadingIcon,
|
|
3043
3074
|
size: ICON_SIZE2,
|
|
@@ -3086,7 +3117,7 @@ function TextField({
|
|
|
3086
3117
|
hitSlop: 12,
|
|
3087
3118
|
style: styles2.trailingIconPressable,
|
|
3088
3119
|
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native26.View, { style: styles2.trailingIcon, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3089
|
-
|
|
3120
|
+
MaterialCommunityIcons,
|
|
3090
3121
|
{
|
|
3091
3122
|
name: trailingIcon,
|
|
3092
3123
|
size: ICON_SIZE2,
|