@onlynative/components 0.1.0-alpha.2 → 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/dist/appbar/index.js +43 -23
- 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 +114 -83
- package/dist/switch/index.js +23 -12
- package/dist/text-field/index.js +24 -13
- package/dist/typography/index.js +9 -0
- package/package.json +2 -2
- package/src/button/Button.tsx +4 -1
- package/src/checkbox/Checkbox.tsx +5 -1
- package/src/chip/Chip.tsx +7 -1
- package/src/icon-button/IconButton.tsx +2 -1
- package/src/switch/Switch.tsx +4 -1
- package/src/text-field/TextField.tsx +4 -1
- package/src/typography/Typography.tsx +13 -1
- package/src/utils/icon.ts +30 -0
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
|
|
@@ -35,17 +25,37 @@ __export(appbar_exports, {
|
|
|
35
25
|
module.exports = __toCommonJS(appbar_exports);
|
|
36
26
|
|
|
37
27
|
// src/appbar/AppBar.tsx
|
|
38
|
-
var
|
|
28
|
+
var import_react3 = require("react");
|
|
39
29
|
var import_react_native6 = require("react-native");
|
|
40
30
|
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
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,
|
|
@@ -577,6 +588,7 @@ function IconButton({
|
|
|
577
588
|
}
|
|
578
589
|
|
|
579
590
|
// src/typography/Typography.tsx
|
|
591
|
+
var import_react2 = require("react");
|
|
580
592
|
var import_react_native3 = require("react-native");
|
|
581
593
|
var import_core2 = require("@onlynative/core");
|
|
582
594
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -600,6 +612,13 @@ function Typography({
|
|
|
600
612
|
const theme = (0, import_core2.useTheme)();
|
|
601
613
|
const typographyStyle = theme.typography[variant];
|
|
602
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]);
|
|
603
622
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
604
623
|
Component,
|
|
605
624
|
{
|
|
@@ -609,6 +628,7 @@ function Typography({
|
|
|
609
628
|
{ color: theme.colors.onSurface },
|
|
610
629
|
typographyStyle,
|
|
611
630
|
style,
|
|
631
|
+
lineHeightFix,
|
|
612
632
|
color != null ? { color } : void 0
|
|
613
633
|
],
|
|
614
634
|
children
|
|
@@ -771,10 +791,10 @@ function AppBar({
|
|
|
771
791
|
var _a;
|
|
772
792
|
const theme = (0, import_core4.useTheme)();
|
|
773
793
|
const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core4.defaultTopAppBarTokens;
|
|
774
|
-
const styles = (0,
|
|
775
|
-
const [leadingWidth, setLeadingWidth] = (0,
|
|
776
|
-
const [actionsWidth, setActionsWidth] = (0,
|
|
777
|
-
const titleColorStyle = (0,
|
|
794
|
+
const styles = (0, import_react3.useMemo)(() => createStyles2(theme), [theme]);
|
|
795
|
+
const [leadingWidth, setLeadingWidth] = (0, import_react3.useState)(0);
|
|
796
|
+
const [actionsWidth, setActionsWidth] = (0, import_react3.useState)(0);
|
|
797
|
+
const titleColorStyle = (0, import_react3.useMemo)(
|
|
778
798
|
() => ({ color: contentColor != null ? contentColor : theme.colors.onSurface }),
|
|
779
799
|
[contentColor, theme.colors.onSurface]
|
|
780
800
|
);
|
|
@@ -785,15 +805,15 @@ function AppBar({
|
|
|
785
805
|
const titleStartInset = topAppBar.horizontalPadding + Math.max(topAppBar.titleStartInset, leadingWidth);
|
|
786
806
|
const compactTitleEndInset = topAppBar.horizontalPadding + actionsWidth;
|
|
787
807
|
const centeredSideInset = topAppBar.horizontalPadding + Math.max(leadingWidth, actionsWidth);
|
|
788
|
-
const expandedTitleInsetStyle = (0,
|
|
808
|
+
const expandedTitleInsetStyle = (0, import_react3.useMemo)(
|
|
789
809
|
() => ({ paddingStart: titleStartInset }),
|
|
790
810
|
[titleStartInset]
|
|
791
811
|
);
|
|
792
|
-
const overlayTitleInsetStyle = (0,
|
|
812
|
+
const overlayTitleInsetStyle = (0, import_react3.useMemo)(
|
|
793
813
|
() => isCenterAligned ? { start: centeredSideInset, end: centeredSideInset } : { start: titleStartInset, end: compactTitleEndInset },
|
|
794
814
|
[centeredSideInset, compactTitleEndInset, isCenterAligned, titleStartInset]
|
|
795
815
|
);
|
|
796
|
-
const leadingContent = (0,
|
|
816
|
+
const leadingContent = (0, import_react3.useMemo)(() => {
|
|
797
817
|
if (leading) {
|
|
798
818
|
return leading;
|
|
799
819
|
}
|
|
@@ -819,7 +839,7 @@ function AppBar({
|
|
|
819
839
|
styles.iconFrame,
|
|
820
840
|
theme.colors.onSurface
|
|
821
841
|
]);
|
|
822
|
-
const actionsContent = (0,
|
|
842
|
+
const actionsContent = (0, import_react3.useMemo)(() => {
|
|
823
843
|
if (trailing) {
|
|
824
844
|
return trailing;
|
|
825
845
|
}
|
|
@@ -846,7 +866,7 @@ function AppBar({
|
|
|
846
866
|
`${String(action.icon)}-${index}`
|
|
847
867
|
)) });
|
|
848
868
|
}, [actions, contentColor, styles.actionsRow, styles.iconFrame, trailing]);
|
|
849
|
-
const onLeadingLayout = (0,
|
|
869
|
+
const onLeadingLayout = (0, import_react3.useCallback)((event) => {
|
|
850
870
|
const nextWidth = measureWidth(event);
|
|
851
871
|
setLeadingWidth((currentWidth) => {
|
|
852
872
|
if (currentWidth === nextWidth) {
|
|
@@ -855,7 +875,7 @@ function AppBar({
|
|
|
855
875
|
return nextWidth;
|
|
856
876
|
});
|
|
857
877
|
}, []);
|
|
858
|
-
const onActionsLayout = (0,
|
|
878
|
+
const onActionsLayout = (0, import_react3.useCallback)((event) => {
|
|
859
879
|
const nextWidth = measureWidth(event);
|
|
860
880
|
setActionsWidth((currentWidth) => {
|
|
861
881
|
if (currentWidth === nextWidth) {
|
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,
|