@metamask-previews/design-system-react-native 0.26.0-preview.620b9f3 → 0.27.0-preview.a0fe3894
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/CHANGELOG.md +24 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.cjs +2 -6
- package/dist/components/BottomSheetHeader/BottomSheetHeader.cjs.map +1 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.d.cts.map +1 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.d.mts.map +1 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.mjs +2 -6
- package/dist/components/BottomSheetHeader/BottomSheetHeader.mjs.map +1 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.types.cjs +0 -11
- package/dist/components/BottomSheetHeader/BottomSheetHeader.types.cjs.map +1 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.types.d.cts +6 -20
- package/dist/components/BottomSheetHeader/BottomSheetHeader.types.d.cts.map +1 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.types.d.mts +6 -20
- package/dist/components/BottomSheetHeader/BottomSheetHeader.types.d.mts.map +1 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.types.mjs +1 -10
- package/dist/components/BottomSheetHeader/BottomSheetHeader.types.mjs.map +1 -1
- package/dist/components/BottomSheetHeader/index.cjs +1 -3
- package/dist/components/BottomSheetHeader/index.cjs.map +1 -1
- package/dist/components/BottomSheetHeader/index.d.cts +0 -1
- package/dist/components/BottomSheetHeader/index.d.cts.map +1 -1
- package/dist/components/BottomSheetHeader/index.d.mts +0 -1
- package/dist/components/BottomSheetHeader/index.d.mts.map +1 -1
- package/dist/components/BottomSheetHeader/index.mjs +0 -1
- package/dist/components/BottomSheetHeader/index.mjs.map +1 -1
- package/dist/components/Content/Content.cjs +71 -0
- package/dist/components/Content/Content.cjs.map +1 -0
- package/dist/components/Content/Content.constants.cjs +9 -0
- package/dist/components/Content/Content.constants.cjs.map +1 -0
- package/dist/components/Content/Content.constants.d.cts +3 -0
- package/dist/components/Content/Content.constants.d.cts.map +1 -0
- package/dist/components/Content/Content.constants.d.mts +3 -0
- package/dist/components/Content/Content.constants.d.mts.map +1 -0
- package/dist/components/Content/Content.constants.mjs +6 -0
- package/dist/components/Content/Content.constants.mjs.map +1 -0
- package/dist/components/Content/Content.d.cts +4 -0
- package/dist/components/Content/Content.d.cts.map +1 -0
- package/dist/components/Content/Content.d.mts +4 -0
- package/dist/components/Content/Content.d.mts.map +1 -0
- package/dist/components/Content/Content.mjs +71 -0
- package/dist/components/Content/Content.mjs.map +1 -0
- package/dist/components/Content/Content.types.cjs +3 -0
- package/dist/components/Content/Content.types.cjs.map +1 -0
- package/dist/components/Content/Content.types.d.cts +31 -0
- package/dist/components/Content/Content.types.d.cts.map +1 -0
- package/dist/components/Content/Content.types.d.mts +31 -0
- package/dist/components/Content/Content.types.d.mts.map +1 -0
- package/dist/components/Content/Content.types.mjs +2 -0
- package/dist/components/Content/Content.types.mjs.map +1 -0
- package/dist/components/Content/index.cjs +8 -0
- package/dist/components/Content/index.cjs.map +1 -0
- package/dist/components/Content/index.d.cts +4 -0
- package/dist/components/Content/index.d.cts.map +1 -0
- package/dist/components/Content/index.d.mts +4 -0
- package/dist/components/Content/index.d.mts.map +1 -0
- package/dist/components/Content/index.mjs +3 -0
- package/dist/components/Content/index.mjs.map +1 -0
- package/dist/components/HeaderBase/HeaderBase.cjs +93 -72
- package/dist/components/HeaderBase/HeaderBase.cjs.map +1 -1
- package/dist/components/HeaderBase/HeaderBase.d.cts.map +1 -1
- package/dist/components/HeaderBase/HeaderBase.d.mts.map +1 -1
- package/dist/components/HeaderBase/HeaderBase.mjs +93 -72
- package/dist/components/HeaderBase/HeaderBase.mjs.map +1 -1
- package/dist/components/HeaderBase/HeaderBase.types.cjs +0 -12
- package/dist/components/HeaderBase/HeaderBase.types.cjs.map +1 -1
- package/dist/components/HeaderBase/HeaderBase.types.d.cts +11 -19
- package/dist/components/HeaderBase/HeaderBase.types.d.cts.map +1 -1
- package/dist/components/HeaderBase/HeaderBase.types.d.mts +11 -19
- package/dist/components/HeaderBase/HeaderBase.types.d.mts.map +1 -1
- package/dist/components/HeaderBase/HeaderBase.types.mjs +1 -11
- package/dist/components/HeaderBase/HeaderBase.types.mjs.map +1 -1
- package/dist/components/HeaderBase/index.cjs +1 -3
- package/dist/components/HeaderBase/index.cjs.map +1 -1
- package/dist/components/HeaderBase/index.d.cts +0 -1
- package/dist/components/HeaderBase/index.d.cts.map +1 -1
- package/dist/components/HeaderBase/index.d.mts +0 -1
- package/dist/components/HeaderBase/index.d.mts.map +1 -1
- package/dist/components/HeaderBase/index.mjs +0 -1
- package/dist/components/HeaderBase/index.mjs.map +1 -1
- package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.cjs +4 -12
- package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.cjs.map +1 -1
- package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.cts +0 -8
- package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.cts.map +1 -1
- package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.mts +0 -8
- package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.mts.map +1 -1
- package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.mjs +3 -10
- package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.mjs.map +1 -1
- package/dist/components/Icon/Icon.assets.cjs +2 -0
- package/dist/components/Icon/Icon.assets.cjs.map +1 -1
- package/dist/components/Icon/Icon.assets.d.cts.map +1 -1
- package/dist/components/Icon/Icon.assets.d.mts.map +1 -1
- package/dist/components/Icon/Icon.assets.mjs +2 -0
- package/dist/components/Icon/Icon.assets.mjs.map +1 -1
- package/dist/components/Icon/assets/flash-filled.svg +1 -0
- package/dist/components/SegmentGroup/SegmentGroup.cjs +4 -6
- package/dist/components/SegmentGroup/SegmentGroup.cjs.map +1 -1
- package/dist/components/SegmentGroup/SegmentGroup.d.cts.map +1 -1
- package/dist/components/SegmentGroup/SegmentGroup.d.mts.map +1 -1
- package/dist/components/SegmentGroup/SegmentGroup.mjs +5 -7
- package/dist/components/SegmentGroup/SegmentGroup.mjs.map +1 -1
- package/dist/components/Toast/Toast.constants.cjs +4 -7
- package/dist/components/Toast/Toast.constants.cjs.map +1 -1
- package/dist/components/Toast/Toast.constants.d.cts +1 -6
- package/dist/components/Toast/Toast.constants.d.cts.map +1 -1
- package/dist/components/Toast/Toast.constants.d.mts +1 -6
- package/dist/components/Toast/Toast.constants.d.mts.map +1 -1
- package/dist/components/Toast/Toast.constants.mjs +1 -6
- package/dist/components/Toast/Toast.constants.mjs.map +1 -1
- package/dist/components/Toast/Toast.types.cjs +2 -10
- package/dist/components/Toast/Toast.types.cjs.map +1 -1
- package/dist/components/Toast/Toast.types.d.cts +4 -11
- package/dist/components/Toast/Toast.types.d.cts.map +1 -1
- package/dist/components/Toast/Toast.types.d.mts +4 -11
- package/dist/components/Toast/Toast.types.d.mts.map +1 -1
- package/dist/components/Toast/Toast.types.mjs +2 -10
- package/dist/components/Toast/Toast.types.mjs.map +1 -1
- package/dist/components/Toast/index.cjs +3 -5
- package/dist/components/Toast/index.cjs.map +1 -1
- package/dist/components/Toast/index.d.cts +2 -2
- package/dist/components/Toast/index.d.cts.map +1 -1
- package/dist/components/Toast/index.d.mts +2 -2
- package/dist/components/Toast/index.d.mts.map +1 -1
- package/dist/components/Toast/index.mjs +2 -2
- package/dist/components/Toast/index.mjs.map +1 -1
- package/dist/components/index.cjs +5 -4
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +4 -2
- package/dist/components/index.d.cts.map +1 -1
- package/dist/components/index.d.mts +4 -2
- package/dist/components/index.d.mts.map +1 -1
- package/dist/components/index.mjs +3 -2
- package/dist/components/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.cjs +0 -15
- package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.cjs.map +0 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.d.cts +0 -7
- package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.d.cts.map +0 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.d.mts +0 -7
- package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.d.mts.map +0 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.mjs +0 -12
- package/dist/components/BottomSheetHeader/BottomSheetHeader.constants.mjs.map +0 -1
- package/dist/components/HeaderBase/HeaderBase.constants.cjs +0 -15
- package/dist/components/HeaderBase/HeaderBase.constants.cjs.map +0 -1
- package/dist/components/HeaderBase/HeaderBase.constants.d.cts +0 -7
- package/dist/components/HeaderBase/HeaderBase.constants.d.cts.map +0 -1
- package/dist/components/HeaderBase/HeaderBase.constants.d.mts +0 -7
- package/dist/components/HeaderBase/HeaderBase.constants.d.mts.map +0 -1
- package/dist/components/HeaderBase/HeaderBase.constants.mjs +0 -12
- package/dist/components/HeaderBase/HeaderBase.constants.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.types.cjs","sourceRoot":"","sources":["../../../src/components/Content/Content.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentPropsShared } from '@metamask-previews/design-system-shared';\n\nimport type { BoxProps } from '../Box/Box.types';\nimport type { TextProps } from '../Text/Text.types';\n\n/**\n * Content component props.\n *\n * Props-only layout for list rows (`title`, `avatar`, accessories, etc.).\n */\nexport type ContentProps = Omit<BoxProps, 'children'> &\n ContentPropsShared & {\n /**\n * Optional props for the title Text when `title` is a string.\n * Default: TextVariant.BodyMd, FontWeight.Medium, TextColor.TextDefault.\n */\n titleProps?: Partial<Omit<TextProps, 'children'>>;\n /**\n * Optional props for the description Text when `description` is a string.\n * Default: TextVariant.BodySm, FontWeight.Medium, TextColor.TextAlternative.\n */\n descriptionProps?: Partial<Omit<TextProps, 'children'>>;\n /**\n * Optional props for the value Text when `value` is a string.\n * Default: TextVariant.BodyMd, FontWeight.Medium, TextColor.TextDefault.\n */\n valueProps?: Partial<Omit<TextProps, 'children'>>;\n /**\n * Optional props for the subvalue Text when `subvalue` is a string.\n * Default: TextVariant.BodySm, FontWeight.Medium, TextColor.TextAlternative.\n */\n subvalueProps?: Partial<Omit<TextProps, 'children'>>;\n };\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ContentPropsShared } from "@metamask-previews/design-system-shared";
|
|
2
|
+
import type { BoxProps } from "../Box/Box.types.cjs";
|
|
3
|
+
import type { TextProps } from "../Text/Text.types.cjs";
|
|
4
|
+
/**
|
|
5
|
+
* Content component props.
|
|
6
|
+
*
|
|
7
|
+
* Props-only layout for list rows (`title`, `avatar`, accessories, etc.).
|
|
8
|
+
*/
|
|
9
|
+
export type ContentProps = Omit<BoxProps, 'children'> & ContentPropsShared & {
|
|
10
|
+
/**
|
|
11
|
+
* Optional props for the title Text when `title` is a string.
|
|
12
|
+
* Default: TextVariant.BodyMd, FontWeight.Medium, TextColor.TextDefault.
|
|
13
|
+
*/
|
|
14
|
+
titleProps?: Partial<Omit<TextProps, 'children'>>;
|
|
15
|
+
/**
|
|
16
|
+
* Optional props for the description Text when `description` is a string.
|
|
17
|
+
* Default: TextVariant.BodySm, FontWeight.Medium, TextColor.TextAlternative.
|
|
18
|
+
*/
|
|
19
|
+
descriptionProps?: Partial<Omit<TextProps, 'children'>>;
|
|
20
|
+
/**
|
|
21
|
+
* Optional props for the value Text when `value` is a string.
|
|
22
|
+
* Default: TextVariant.BodyMd, FontWeight.Medium, TextColor.TextDefault.
|
|
23
|
+
*/
|
|
24
|
+
valueProps?: Partial<Omit<TextProps, 'children'>>;
|
|
25
|
+
/**
|
|
26
|
+
* Optional props for the subvalue Text when `subvalue` is a string.
|
|
27
|
+
* Default: TextVariant.BodySm, FontWeight.Medium, TextColor.TextAlternative.
|
|
28
|
+
*/
|
|
29
|
+
subvalueProps?: Partial<Omit<TextProps, 'children'>>;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=Content.types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.types.d.cts","sourceRoot":"","sources":["../../../src/components/Content/Content.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gDAAgD;AAElF,OAAO,KAAK,EAAE,QAAQ,EAAE,6BAAyB;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,+BAA2B;AAEpD;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,GACnD,kBAAkB,GAAG;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IAClD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IACxD;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IAClD;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;CACtD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ContentPropsShared } from "@metamask-previews/design-system-shared";
|
|
2
|
+
import type { BoxProps } from "../Box/Box.types.mjs";
|
|
3
|
+
import type { TextProps } from "../Text/Text.types.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Content component props.
|
|
6
|
+
*
|
|
7
|
+
* Props-only layout for list rows (`title`, `avatar`, accessories, etc.).
|
|
8
|
+
*/
|
|
9
|
+
export type ContentProps = Omit<BoxProps, 'children'> & ContentPropsShared & {
|
|
10
|
+
/**
|
|
11
|
+
* Optional props for the title Text when `title` is a string.
|
|
12
|
+
* Default: TextVariant.BodyMd, FontWeight.Medium, TextColor.TextDefault.
|
|
13
|
+
*/
|
|
14
|
+
titleProps?: Partial<Omit<TextProps, 'children'>>;
|
|
15
|
+
/**
|
|
16
|
+
* Optional props for the description Text when `description` is a string.
|
|
17
|
+
* Default: TextVariant.BodySm, FontWeight.Medium, TextColor.TextAlternative.
|
|
18
|
+
*/
|
|
19
|
+
descriptionProps?: Partial<Omit<TextProps, 'children'>>;
|
|
20
|
+
/**
|
|
21
|
+
* Optional props for the value Text when `value` is a string.
|
|
22
|
+
* Default: TextVariant.BodyMd, FontWeight.Medium, TextColor.TextDefault.
|
|
23
|
+
*/
|
|
24
|
+
valueProps?: Partial<Omit<TextProps, 'children'>>;
|
|
25
|
+
/**
|
|
26
|
+
* Optional props for the subvalue Text when `subvalue` is a string.
|
|
27
|
+
* Default: TextVariant.BodySm, FontWeight.Medium, TextColor.TextAlternative.
|
|
28
|
+
*/
|
|
29
|
+
subvalueProps?: Partial<Omit<TextProps, 'children'>>;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=Content.types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.types.d.mts","sourceRoot":"","sources":["../../../src/components/Content/Content.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gDAAgD;AAElF,OAAO,KAAK,EAAE,QAAQ,EAAE,6BAAyB;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,+BAA2B;AAEpD;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,GACnD,kBAAkB,GAAG;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IAClD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IACxD;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IAClD;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;CACtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.types.mjs","sourceRoot":"","sources":["../../../src/components/Content/Content.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContentPropsShared } from '@metamask-previews/design-system-shared';\n\nimport type { BoxProps } from '../Box/Box.types';\nimport type { TextProps } from '../Text/Text.types';\n\n/**\n * Content component props.\n *\n * Props-only layout for list rows (`title`, `avatar`, accessories, etc.).\n */\nexport type ContentProps = Omit<BoxProps, 'children'> &\n ContentPropsShared & {\n /**\n * Optional props for the title Text when `title` is a string.\n * Default: TextVariant.BodyMd, FontWeight.Medium, TextColor.TextDefault.\n */\n titleProps?: Partial<Omit<TextProps, 'children'>>;\n /**\n * Optional props for the description Text when `description` is a string.\n * Default: TextVariant.BodySm, FontWeight.Medium, TextColor.TextAlternative.\n */\n descriptionProps?: Partial<Omit<TextProps, 'children'>>;\n /**\n * Optional props for the value Text when `value` is a string.\n * Default: TextVariant.BodyMd, FontWeight.Medium, TextColor.TextDefault.\n */\n valueProps?: Partial<Omit<TextProps, 'children'>>;\n /**\n * Optional props for the subvalue Text when `subvalue` is a string.\n * Default: TextVariant.BodySm, FontWeight.Medium, TextColor.TextAlternative.\n */\n subvalueProps?: Partial<Omit<TextProps, 'children'>>;\n };\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Content = exports.ContentVerticalAlignment = void 0;
|
|
4
|
+
var design_system_shared_1 = require("@metamask-previews/design-system-shared");
|
|
5
|
+
Object.defineProperty(exports, "ContentVerticalAlignment", { enumerable: true, get: function () { return design_system_shared_1.ContentVerticalAlignment; } });
|
|
6
|
+
var Content_1 = require("./Content.cjs");
|
|
7
|
+
Object.defineProperty(exports, "Content", { enumerable: true, get: function () { return Content_1.Content; } });
|
|
8
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/Content/index.ts"],"names":[],"mappings":";;;AAAA,gFAAmF;AAA1E,gIAAA,wBAAwB,OAAA;AACjC,yCAAoC;AAA3B,kGAAA,OAAO,OAAA","sourcesContent":["export { ContentVerticalAlignment } from '@metamask-previews/design-system-shared';\nexport { Content } from './Content';\nexport type { ContentProps } from './Content.types';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Content/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,gDAAgD;AACnF,OAAO,EAAE,OAAO,EAAE,sBAAkB;AACpC,YAAY,EAAE,YAAY,EAAE,4BAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/Content/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,gDAAgD;AACnF,OAAO,EAAE,OAAO,EAAE,sBAAkB;AACpC,YAAY,EAAE,YAAY,EAAE,4BAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/components/Content/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,gDAAgD;AACnF,OAAO,EAAE,OAAO,EAAE,sBAAkB","sourcesContent":["export { ContentVerticalAlignment } from '@metamask-previews/design-system-shared';\nexport { Content } from './Content';\nexport type { ContentProps } from './Content.types';\n"]}
|
|
@@ -25,18 +25,54 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.HeaderBase = void 0;
|
|
27
27
|
// Third party dependencies.
|
|
28
|
+
const design_system_shared_1 = require("@metamask-previews/design-system-shared");
|
|
28
29
|
const design_system_twrnc_preset_1 = require("@metamask-previews/design-system-twrnc-preset");
|
|
29
30
|
const react_1 = __importStar(require("react"));
|
|
30
31
|
const react_native_1 = require("react-native");
|
|
31
32
|
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
32
33
|
// External dependencies.
|
|
33
|
-
const Box_1 = require("../Box/index.cjs");
|
|
34
34
|
const ButtonIcon_1 = require("../ButtonIcon/index.cjs");
|
|
35
|
-
const
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
35
|
+
const TextOrChildren_1 = require("../temp-components/TextOrChildren/index.cjs");
|
|
36
|
+
// `startAccessory` is the primary escape hatch. `startButtonIconProps`
|
|
37
|
+
// remains as a convenience path for the common single-back-button case.
|
|
38
|
+
const resolveStartAccessory = ({ startAccessory, startButtonIconProps, }) => {
|
|
39
|
+
if (startAccessory) {
|
|
40
|
+
return startAccessory;
|
|
41
|
+
}
|
|
42
|
+
if (startButtonIconProps) {
|
|
43
|
+
return <ButtonIcon_1.ButtonIcon size={ButtonIcon_1.ButtonIconSize.Md} {...startButtonIconProps}/>;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
};
|
|
47
|
+
// Only the end side supports built-in multiple buttons. More complex
|
|
48
|
+
// start-side layouts should be composed explicitly with `startAccessory`.
|
|
49
|
+
const renderEndButtonIcons = (endButtonIconProps) => endButtonIconProps
|
|
50
|
+
.map((iconProps, originalIndex) => ({
|
|
51
|
+
iconProps,
|
|
52
|
+
originalIndex,
|
|
53
|
+
}))
|
|
54
|
+
.reverse()
|
|
55
|
+
.map(({ iconProps, originalIndex }) => (<ButtonIcon_1.ButtonIcon key={`end-button-icon-${originalIndex}`} size={ButtonIcon_1.ButtonIconSize.Md} {...iconProps}/>));
|
|
56
|
+
// `endAccessory` takes precedence over the shorthand icon-props array.
|
|
57
|
+
const resolveEndAccessory = ({ endAccessory, endButtonIconProps, }) => {
|
|
58
|
+
if (endAccessory) {
|
|
59
|
+
return {
|
|
60
|
+
resolvedEndAccessory: endAccessory,
|
|
61
|
+
hasMultipleEndButtons: false,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (endButtonIconProps && endButtonIconProps.length > 0) {
|
|
65
|
+
return {
|
|
66
|
+
resolvedEndAccessory: renderEndButtonIcons(endButtonIconProps),
|
|
67
|
+
hasMultipleEndButtons: endButtonIconProps.length > 1,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
resolvedEndAccessory: null,
|
|
72
|
+
hasMultipleEndButtons: false,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
const HeaderBase = ({ children, style, startAccessory, endAccessory, startButtonIconProps, endButtonIconProps, includesTopInset = false, startAccessoryWrapperProps, endAccessoryWrapperProps, childrenWrapperProps, textProps, twClassName, ...props }) => {
|
|
40
76
|
const tw = (0, design_system_twrnc_preset_1.useTailwind)();
|
|
41
77
|
const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
|
|
42
78
|
const [startAccessoryWidth, setStartAccessoryWidth] = (0, react_1.useState)(0);
|
|
@@ -47,86 +83,71 @@ const HeaderBase = ({ children, style, variant = HeaderBase_types_1.HeaderBaseVa
|
|
|
47
83
|
const handleEndAccessoryLayout = (0, react_1.useCallback)((e) => {
|
|
48
84
|
setEndAccessoryWidth(e.nativeEvent.layout.width);
|
|
49
85
|
}, []);
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// Calculate equal width for both accessory wrappers to ensure title stays centered
|
|
64
|
-
const accessoryWrapperWidth =
|
|
86
|
+
// Normalize the public API into resolved slots so the render path only deals
|
|
87
|
+
// with layout and title rendering.
|
|
88
|
+
const resolvedStartAccessory = resolveStartAccessory({
|
|
89
|
+
startAccessory,
|
|
90
|
+
startButtonIconProps,
|
|
91
|
+
});
|
|
92
|
+
const { resolvedEndAccessory, hasMultipleEndButtons } = resolveEndAccessory({
|
|
93
|
+
endAccessory,
|
|
94
|
+
endButtonIconProps,
|
|
95
|
+
});
|
|
96
|
+
const hasStartAccessory = Boolean(resolvedStartAccessory);
|
|
97
|
+
const hasEndAccessory = Boolean(resolvedEndAccessory);
|
|
98
|
+
const hasAnyAccessory = hasStartAccessory || hasEndAccessory;
|
|
99
|
+
// Calculate equal width for both accessory wrappers to ensure title stays centered.
|
|
100
|
+
const accessoryWrapperWidth = hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)
|
|
65
101
|
? Math.max(startAccessoryWidth, endAccessoryWidth)
|
|
66
102
|
: undefined;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
if (startButtonIconProps) {
|
|
72
|
-
return <ButtonIcon_1.ButtonIcon size={ButtonIcon_1.ButtonIconSize.Md} {...startButtonIconProps}/>;
|
|
73
|
-
}
|
|
74
|
-
return null;
|
|
75
|
-
};
|
|
76
|
-
const renderEndContent = () => {
|
|
77
|
-
if (endAccessory) {
|
|
78
|
-
return endAccessory;
|
|
79
|
-
}
|
|
80
|
-
if (endButtonIconProps && endButtonIconProps.length > 0) {
|
|
81
|
-
// Reverse the array so first item appears rightmost
|
|
82
|
-
// Use original index (before reversal) for stable React keys
|
|
83
|
-
const reversedProps = endButtonIconProps
|
|
84
|
-
.map((iconProps, originalIndex) => ({
|
|
85
|
-
iconProps,
|
|
86
|
-
originalIndex,
|
|
87
|
-
}))
|
|
88
|
-
.reverse();
|
|
89
|
-
return reversedProps.map(({ iconProps, originalIndex }) => (<ButtonIcon_1.ButtonIcon key={`end-button-icon-${originalIndex}`} size={ButtonIcon_1.ButtonIconSize.Md} {...iconProps}/>));
|
|
103
|
+
const renderAccessoryWrapper = ({ wrapperProps, alignment, onLayout, content, measuredContentStyle, }) => {
|
|
104
|
+
if (!hasAnyAccessory) {
|
|
105
|
+
return null;
|
|
90
106
|
}
|
|
91
|
-
return
|
|
107
|
+
return (<react_native_1.View style={accessoryWrapperWidth
|
|
108
|
+
? tw.style(alignment, { width: accessoryWrapperWidth })
|
|
109
|
+
: undefined} {...wrapperProps}>
|
|
110
|
+
<react_native_1.View onLayout={onLayout} style={measuredContentStyle}>
|
|
111
|
+
{content}
|
|
112
|
+
</react_native_1.View>
|
|
113
|
+
</react_native_1.View>);
|
|
92
114
|
};
|
|
93
|
-
// Check if we have multiple end buttons for layout styling
|
|
94
|
-
const hasMultipleEndButtons = !endAccessory && endButtonIconProps && endButtonIconProps.length > 1;
|
|
95
|
-
// Merge default styles with passed-in twClassName
|
|
96
|
-
const baseStyles = 'flex-row items-center gap-4 h-14';
|
|
97
|
-
const resolvedTwClassName = twClassName
|
|
98
|
-
? `${baseStyles} ${twClassName}`
|
|
99
|
-
: baseStyles;
|
|
100
115
|
return (<react_native_1.View style={[
|
|
101
|
-
tw.style(
|
|
116
|
+
tw.style('flex-row items-center gap-4 h-14', twClassName),
|
|
102
117
|
includesTopInset && { marginTop: insets.top },
|
|
103
118
|
style,
|
|
104
119
|
]} {...props}>
|
|
105
120
|
{/* Start accessory */}
|
|
106
|
-
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
</react_native_1.View>)}
|
|
121
|
+
{renderAccessoryWrapper({
|
|
122
|
+
wrapperProps: startAccessoryWrapperProps,
|
|
123
|
+
alignment: 'items-start',
|
|
124
|
+
onLayout: handleStartAccessoryLayout,
|
|
125
|
+
content: resolvedStartAccessory,
|
|
126
|
+
})}
|
|
113
127
|
|
|
114
128
|
{/* Title */}
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
<react_native_1.View style={tw.style('flex-1 items-center')} {...childrenWrapperProps}>
|
|
130
|
+
<TextOrChildren_1.TextOrChildren textProps={{
|
|
131
|
+
variant: design_system_shared_1.TextVariant.HeadingSm,
|
|
132
|
+
...textProps,
|
|
133
|
+
style: [tw.style('text-center'), textProps?.style],
|
|
134
|
+
}}>
|
|
135
|
+
{children}
|
|
136
|
+
</TextOrChildren_1.TextOrChildren>
|
|
137
|
+
</react_native_1.View>
|
|
120
138
|
|
|
121
139
|
{/* End accessory */}
|
|
122
|
-
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
140
|
+
{renderAccessoryWrapper({
|
|
141
|
+
wrapperProps: endAccessoryWrapperProps,
|
|
142
|
+
alignment: 'items-end',
|
|
143
|
+
onLayout: handleEndAccessoryLayout,
|
|
144
|
+
content: resolvedEndAccessory,
|
|
145
|
+
measuredContentStyle: hasMultipleEndButtons
|
|
146
|
+
? tw.style('flex-row gap-2')
|
|
147
|
+
: undefined,
|
|
148
|
+
})}
|
|
129
149
|
</react_native_1.View>);
|
|
130
150
|
};
|
|
131
151
|
exports.HeaderBase = HeaderBase;
|
|
152
|
+
exports.HeaderBase.displayName = 'HeaderBase';
|
|
132
153
|
//# sourceMappingURL=HeaderBase.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderBase.cjs","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA4B;AAC5B,8FAA4E;AAC5E,+CAAqD;AAErD,+CAAoC;AACpC,mFAAmE;AAEnE,yBAAyB;AACzB,0CAA6B;AAC7B,wDAA2D;AAC3D,4CAA+B;AAE/B,yBAAyB;AACzB,qEAA0E;AAE1E,6DAAuD;AAEhD,MAAM,UAAU,GAA8B,CAAC,EACpD,Q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C,CAAC,uDAAgC,CAAC,OAAO,CAAC,CAAC,CACnD,MAAM,CAAC,CAAC,WAAW,CAAC,CACpB,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAEvD;YAAA,CAAC,QAAQ,CACX;UAAA,EAAE,WAAI,CAAC,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CACH;MAAA,EAAE,SAAG,CAEL;;MAAA,CAAC,mBAAmB,CACpB;MAAA,CAAC,sBAAsB,IAAI,CACzB,CAAC,mBAAI,CACH,KAAK,CAAC,CACJ,qBAAqB;gBACnB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;gBACzD,CAAC,CAAC,SAAS,CACd,CACD,IAAI,wBAAwB,CAAC,CAE7B;UAAA,CAAC,mBAAI,CACH,QAAQ,CAAC,CAAC,wBAAwB,CAAC,CACnC,KAAK,CAAC,CACJ,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAC/D,CAED;YAAA,CAAC,gBAAgB,EAAE,CACrB;UAAA,EAAE,mBAAI,CACR;QAAA,EAAE,mBAAI,CAAC,CACR,CACH;IAAA,EAAE,mBAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC;AA9JW,QAAA,UAAU,cA8JrB","sourcesContent":["// Third party dependencies.\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useCallback, useState } from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport { View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\n// External dependencies.\nimport { Box } from '../Box';\nimport { ButtonIcon, ButtonIconSize } from '../ButtonIcon';\nimport { Text } from '../Text';\n\n// Internal dependencies.\nimport { HEADERBASE_VARIANT_TEXT_VARIANTS } from './HeaderBase.constants';\nimport type { HeaderBaseProps } from './HeaderBase.types';\nimport { HeaderBaseVariant } from './HeaderBase.types';\n\nexport const HeaderBase: React.FC<HeaderBaseProps> = ({\n children,\n style,\n variant = HeaderBaseVariant.Compact,\n startAccessory,\n endAccessory,\n startButtonIconProps,\n endButtonIconProps,\n includesTopInset = false,\n startAccessoryWrapperProps,\n endAccessoryWrapperProps,\n titleTestID,\n twClassName,\n ...props\n}) => {\n const tw = useTailwind();\n const insets = useSafeAreaInsets();\n\n const [startAccessoryWidth, setStartAccessoryWidth] = useState(0);\n const [endAccessoryWidth, setEndAccessoryWidth] = useState(0);\n\n const handleStartAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setStartAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n const handleEndAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setEndAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n // Determine what to render for start/end\n const hasStartContent = startAccessory || startButtonIconProps;\n const hasEndContent =\n endAccessory || (endButtonIconProps && endButtonIconProps.length > 0);\n const hasAnyAccessory = hasStartContent || hasEndContent;\n\n const isCompact = variant === HeaderBaseVariant.Compact;\n\n // For Compact variant, render both wrappers if any accessory exists (for centering)\n // For Display variant, only render wrappers when they have content\n const shouldRenderStartWrapper = isCompact\n ? Boolean(hasAnyAccessory)\n : Boolean(hasStartContent);\n const shouldRenderEndWrapper = isCompact\n ? Boolean(hasAnyAccessory)\n : Boolean(hasEndContent);\n\n // Calculate equal width for both accessory wrappers to ensure title stays centered (Compact only)\n const accessoryWrapperWidth =\n isCompact && hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)\n ? Math.max(startAccessoryWidth, endAccessoryWidth)\n : undefined;\n\n const renderStartContent = () => {\n if (startAccessory) {\n return startAccessory;\n }\n if (startButtonIconProps) {\n return <ButtonIcon size={ButtonIconSize.Md} {...startButtonIconProps} />;\n }\n return null;\n };\n\n const renderEndContent = () => {\n if (endAccessory) {\n return endAccessory;\n }\n if (endButtonIconProps && endButtonIconProps.length > 0) {\n // Reverse the array so first item appears rightmost\n // Use original index (before reversal) for stable React keys\n const reversedProps = endButtonIconProps\n .map((iconProps, originalIndex) => ({\n iconProps,\n originalIndex,\n }))\n .reverse();\n return reversedProps.map(({ iconProps, originalIndex }) => (\n <ButtonIcon\n key={`end-button-icon-${originalIndex}`}\n size={ButtonIconSize.Md}\n {...iconProps}\n />\n ));\n }\n return null;\n };\n\n // Check if we have multiple end buttons for layout styling\n const hasMultipleEndButtons =\n !endAccessory && endButtonIconProps && endButtonIconProps.length > 1;\n\n // Merge default styles with passed-in twClassName\n const baseStyles = 'flex-row items-center gap-4 h-14';\n const resolvedTwClassName = twClassName\n ? `${baseStyles} ${twClassName}`\n : baseStyles;\n\n return (\n <View\n style={[\n tw.style(resolvedTwClassName),\n includesTopInset && { marginTop: insets.top },\n style,\n ]}\n {...props}\n >\n {/* Start accessory */}\n {shouldRenderStartWrapper && (\n <View\n style={\n accessoryWrapperWidth\n ? tw.style('items-start', { width: accessoryWrapperWidth })\n : undefined\n }\n {...startAccessoryWrapperProps}\n >\n <View onLayout={handleStartAccessoryLayout}>\n {renderStartContent()}\n </View>\n </View>\n )}\n\n {/* Title */}\n <Box twClassName={isCompact ? 'flex-1 items-center' : 'flex-1'}>\n {typeof children === 'string' ? (\n <Text\n variant={HEADERBASE_VARIANT_TEXT_VARIANTS[variant]}\n testID={titleTestID}\n style={isCompact ? tw.style('text-center') : undefined}\n >\n {children}\n </Text>\n ) : (\n children\n )}\n </Box>\n\n {/* End accessory */}\n {shouldRenderEndWrapper && (\n <View\n style={\n accessoryWrapperWidth\n ? tw.style('items-end', { width: accessoryWrapperWidth })\n : undefined\n }\n {...endAccessoryWrapperProps}\n >\n <View\n onLayout={handleEndAccessoryLayout}\n style={\n hasMultipleEndButtons ? tw.style('flex-row gap-2') : undefined\n }\n >\n {renderEndContent()}\n </View>\n </View>\n )}\n </View>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"HeaderBase.cjs","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA4B;AAC5B,kFAAsE;AACtE,8FAA4E;AAC5E,+CAAqD;AAErD,+CAAoC;AACpC,mFAAmE;AAEnE,yBAAyB;AACzB,wDAA2D;AAE3D,gFAAmE;AAInE,uEAAuE;AACvE,wEAAwE;AACxE,MAAM,qBAAqB,GAAG,CAAC,EAC7B,cAAc,EACd,oBAAoB,GAC6C,EAAE,EAAE;IACrE,IAAI,cAAc,EAAE;QAClB,OAAO,cAAc,CAAC;KACvB;IAED,IAAI,oBAAoB,EAAE;QACxB,OAAO,CAAC,uBAAU,CAAC,IAAI,CAAC,CAAC,2BAAc,CAAC,EAAE,CAAC,CAAC,IAAI,oBAAoB,CAAC,EAAG,CAAC;KAC1E;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,qEAAqE;AACrE,0EAA0E;AAC1E,MAAM,oBAAoB,GAAG,CAAC,kBAAqC,EAAE,EAAE,CACrE,kBAAkB;KACf,GAAG,CAAC,CAAC,SAAS,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;IAClC,SAAS;IACT,aAAa;CACd,CAAC,CAAC;KACF,OAAO,EAAE;KACT,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CACrC,CAAC,uBAAU,CACT,GAAG,CAAC,CAAC,mBAAmB,aAAa,EAAE,CAAC,CACxC,IAAI,CAAC,CAAC,2BAAc,CAAC,EAAE,CAAC,CACxB,IAAI,SAAS,CAAC,EACd,CACH,CAAC,CAAC;AAEP,uEAAuE;AACvE,MAAM,mBAAmB,GAAG,CAAC,EAC3B,YAAY,EACZ,kBAAkB,GAC2C,EAAE,EAAE;IACjE,IAAI,YAAY,EAAE;QAChB,OAAO;YACL,oBAAoB,EAAE,YAAY;YAClC,qBAAqB,EAAE,KAAK;SA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AAC;YACzD,gBAAgB,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,EAAE;YAC7C,KAAK;SACN,CAAC,CACF,IAAI,KAAK,CAAC,CAEV;MAAA,CAAC,qBAAqB,CACtB;MAAA,CAAC,sBAAsB,CAAC;YACtB,YAAY,EAAE,0BAA0B;YACxC,SAAS,EAAE,aAAa;YACxB,QAAQ,EAAE,0BAA0B;YACpC,OAAO,EAAE,sBAAsB;SAChC,CAAC,CAEF;;MAAA,CAAC,WAAW,CACZ;MAAA,CAAC,mBAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC,CACrE;QAAA,CAAC,+BAAc,CACb,SAAS,CAAC,CAAC;YACT,OAAO,EAAE,kCAAW,CAAC,SAAS;YAC9B,GAAG,SAAS;YACZ,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC;SACnD,CAAC,CAEF;UAAA,CAAC,QAAQ,CACX;QAAA,EAAE,+BAAc,CAClB;MAAA,EAAE,mBAAI,CAEN;;MAAA,CAAC,mBAAmB,CACpB;MAAA,CAAC,sBAAsB,CAAC;YACtB,YAAY,EAAE,wBAAwB;YACtC,SAAS,EAAE,WAAW;YACtB,QAAQ,EAAE,wBAAwB;YAClC,OAAO,EAAE,oBAAoB;YAC7B,oBAAoB,EAAE,qBAAqB;gBACzC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC;gBAC5B,CAAC,CAAC,SAAS;SACd,CAAC,CACJ;IAAA,EAAE,mBAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC;AA7HW,QAAA,UAAU,cA6HrB;AAEF,kBAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["// Third party dependencies.\nimport { TextVariant } from '@metamask-previews/design-system-shared';\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useCallback, useState } from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport { View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\n// External dependencies.\nimport { ButtonIcon, ButtonIconSize } from '../ButtonIcon';\nimport type { ButtonIconProps } from '../ButtonIcon';\nimport { TextOrChildren } from '../temp-components/TextOrChildren';\n\nimport type { HeaderBaseProps } from './HeaderBase.types';\n\n// `startAccessory` is the primary escape hatch. `startButtonIconProps`\n// remains as a convenience path for the common single-back-button case.\nconst resolveStartAccessory = ({\n startAccessory,\n startButtonIconProps,\n}: Pick<HeaderBaseProps, 'startAccessory' | 'startButtonIconProps'>) => {\n if (startAccessory) {\n return startAccessory;\n }\n\n if (startButtonIconProps) {\n return <ButtonIcon size={ButtonIconSize.Md} {...startButtonIconProps} />;\n }\n\n return null;\n};\n\n// Only the end side supports built-in multiple buttons. More complex\n// start-side layouts should be composed explicitly with `startAccessory`.\nconst renderEndButtonIcons = (endButtonIconProps: ButtonIconProps[]) =>\n endButtonIconProps\n .map((iconProps, originalIndex) => ({\n iconProps,\n originalIndex,\n }))\n .reverse()\n .map(({ iconProps, originalIndex }) => (\n <ButtonIcon\n key={`end-button-icon-${originalIndex}`}\n size={ButtonIconSize.Md}\n {...iconProps}\n />\n ));\n\n// `endAccessory` takes precedence over the shorthand icon-props array.\nconst resolveEndAccessory = ({\n endAccessory,\n endButtonIconProps,\n}: Pick<HeaderBaseProps, 'endAccessory' | 'endButtonIconProps'>) => {\n if (endAccessory) {\n return {\n resolvedEndAccessory: endAccessory,\n hasMultipleEndButtons: false,\n };\n }\n\n if (endButtonIconProps && endButtonIconProps.length > 0) {\n return {\n resolvedEndAccessory: renderEndButtonIcons(endButtonIconProps),\n hasMultipleEndButtons: endButtonIconProps.length > 1,\n };\n }\n\n return {\n resolvedEndAccessory: null,\n hasMultipleEndButtons: false,\n };\n};\n\nexport const HeaderBase: React.FC<HeaderBaseProps> = ({\n children,\n style,\n startAccessory,\n endAccessory,\n startButtonIconProps,\n endButtonIconProps,\n includesTopInset = false,\n startAccessoryWrapperProps,\n endAccessoryWrapperProps,\n childrenWrapperProps,\n textProps,\n twClassName,\n ...props\n}) => {\n const tw = useTailwind();\n const insets = useSafeAreaInsets();\n\n const [startAccessoryWidth, setStartAccessoryWidth] = useState(0);\n const [endAccessoryWidth, setEndAccessoryWidth] = useState(0);\n\n const handleStartAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setStartAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n const handleEndAccessoryLayout = useCallback((e: LayoutChangeEvent) => {\n setEndAccessoryWidth(e.nativeEvent.layout.width);\n }, []);\n\n // Normalize the public API into resolved slots so the render path only deals\n // with layout and title rendering.\n const resolvedStartAccessory = resolveStartAccessory({\n startAccessory,\n startButtonIconProps,\n });\n const { resolvedEndAccessory, hasMultipleEndButtons } = resolveEndAccessory({\n endAccessory,\n endButtonIconProps,\n });\n\n const hasStartAccessory = Boolean(resolvedStartAccessory);\n const hasEndAccessory = Boolean(resolvedEndAccessory);\n const hasAnyAccessory = hasStartAccessory || hasEndAccessory;\n\n // Calculate equal width for both accessory wrappers to ensure title stays centered.\n const accessoryWrapperWidth =\n hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)\n ? Math.max(startAccessoryWidth, endAccessoryWidth)\n : undefined;\n\n const renderAccessoryWrapper = ({\n wrapperProps,\n alignment,\n onLayout,\n content,\n measuredContentStyle,\n }: {\n wrapperProps?: HeaderBaseProps['startAccessoryWrapperProps'];\n alignment: 'items-start' | 'items-end';\n onLayout: (e: LayoutChangeEvent) => void;\n content: React.ReactNode;\n measuredContentStyle?: ReturnType<typeof tw.style>;\n }) => {\n if (!hasAnyAccessory) {\n return null;\n }\n\n return (\n <View\n style={\n accessoryWrapperWidth\n ? tw.style(alignment, { width: accessoryWrapperWidth })\n : undefined\n }\n {...wrapperProps}\n >\n <View onLayout={onLayout} style={measuredContentStyle}>\n {content}\n </View>\n </View>\n );\n };\n\n return (\n <View\n style={[\n tw.style('flex-row items-center gap-4 h-14', twClassName),\n includesTopInset && { marginTop: insets.top },\n style,\n ]}\n {...props}\n >\n {/* Start accessory */}\n {renderAccessoryWrapper({\n wrapperProps: startAccessoryWrapperProps,\n alignment: 'items-start',\n onLayout: handleStartAccessoryLayout,\n content: resolvedStartAccessory,\n })}\n\n {/* Title */}\n <View style={tw.style('flex-1 items-center')} {...childrenWrapperProps}>\n <TextOrChildren\n textProps={{\n variant: TextVariant.HeadingSm,\n ...textProps,\n style: [tw.style('text-center'), textProps?.style],\n }}\n >\n {children}\n </TextOrChildren>\n </View>\n\n {/* End accessory */}\n {renderAccessoryWrapper({\n wrapperProps: endAccessoryWrapperProps,\n alignment: 'items-end',\n onLayout: handleEndAccessoryLayout,\n content: resolvedEndAccessory,\n measuredContentStyle: hasMultipleEndButtons\n ? tw.style('flex-row gap-2')\n : undefined,\n })}\n </View>\n );\n};\n\nHeaderBase.displayName = 'HeaderBase';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderBase.d.cts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HeaderBase.d.cts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgC,cAAc;AAUrD,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AA6D1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA6HhD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderBase.d.mts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HeaderBase.d.mts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgC,cAAc;AAUrD,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AA6D1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA6HhD,CAAC"}
|
|
@@ -5,19 +5,55 @@ function $importDefault(module) {
|
|
|
5
5
|
return module;
|
|
6
6
|
}
|
|
7
7
|
// Third party dependencies.
|
|
8
|
+
import { TextVariant } from "@metamask-previews/design-system-shared";
|
|
8
9
|
import { useTailwind } from "@metamask-previews/design-system-twrnc-preset";
|
|
9
10
|
import $React, { useCallback, useState } from "react";
|
|
10
11
|
const React = $importDefault($React);
|
|
11
12
|
import { View } from "react-native";
|
|
12
13
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
13
14
|
// External dependencies.
|
|
14
|
-
import { Box } from "../Box/index.mjs";
|
|
15
15
|
import { ButtonIcon, ButtonIconSize } from "../ButtonIcon/index.mjs";
|
|
16
|
-
import {
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
import { TextOrChildren } from "../temp-components/TextOrChildren/index.mjs";
|
|
17
|
+
// `startAccessory` is the primary escape hatch. `startButtonIconProps`
|
|
18
|
+
// remains as a convenience path for the common single-back-button case.
|
|
19
|
+
const resolveStartAccessory = ({ startAccessory, startButtonIconProps, }) => {
|
|
20
|
+
if (startAccessory) {
|
|
21
|
+
return startAccessory;
|
|
22
|
+
}
|
|
23
|
+
if (startButtonIconProps) {
|
|
24
|
+
return <ButtonIcon size={ButtonIconSize.Md} {...startButtonIconProps}/>;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
// Only the end side supports built-in multiple buttons. More complex
|
|
29
|
+
// start-side layouts should be composed explicitly with `startAccessory`.
|
|
30
|
+
const renderEndButtonIcons = (endButtonIconProps) => endButtonIconProps
|
|
31
|
+
.map((iconProps, originalIndex) => ({
|
|
32
|
+
iconProps,
|
|
33
|
+
originalIndex,
|
|
34
|
+
}))
|
|
35
|
+
.reverse()
|
|
36
|
+
.map(({ iconProps, originalIndex }) => (<ButtonIcon key={`end-button-icon-${originalIndex}`} size={ButtonIconSize.Md} {...iconProps}/>));
|
|
37
|
+
// `endAccessory` takes precedence over the shorthand icon-props array.
|
|
38
|
+
const resolveEndAccessory = ({ endAccessory, endButtonIconProps, }) => {
|
|
39
|
+
if (endAccessory) {
|
|
40
|
+
return {
|
|
41
|
+
resolvedEndAccessory: endAccessory,
|
|
42
|
+
hasMultipleEndButtons: false,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (endButtonIconProps && endButtonIconProps.length > 0) {
|
|
46
|
+
return {
|
|
47
|
+
resolvedEndAccessory: renderEndButtonIcons(endButtonIconProps),
|
|
48
|
+
hasMultipleEndButtons: endButtonIconProps.length > 1,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
resolvedEndAccessory: null,
|
|
53
|
+
hasMultipleEndButtons: false,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export const HeaderBase = ({ children, style, startAccessory, endAccessory, startButtonIconProps, endButtonIconProps, includesTopInset = false, startAccessoryWrapperProps, endAccessoryWrapperProps, childrenWrapperProps, textProps, twClassName, ...props }) => {
|
|
21
57
|
const tw = useTailwind();
|
|
22
58
|
const insets = useSafeAreaInsets();
|
|
23
59
|
const [startAccessoryWidth, setStartAccessoryWidth] = useState(0);
|
|
@@ -28,85 +64,70 @@ export const HeaderBase = ({ children, style, variant = HeaderBaseVariant.Compac
|
|
|
28
64
|
const handleEndAccessoryLayout = useCallback((e) => {
|
|
29
65
|
setEndAccessoryWidth(e.nativeEvent.layout.width);
|
|
30
66
|
}, []);
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// Calculate equal width for both accessory wrappers to ensure title stays centered
|
|
45
|
-
const accessoryWrapperWidth =
|
|
67
|
+
// Normalize the public API into resolved slots so the render path only deals
|
|
68
|
+
// with layout and title rendering.
|
|
69
|
+
const resolvedStartAccessory = resolveStartAccessory({
|
|
70
|
+
startAccessory,
|
|
71
|
+
startButtonIconProps,
|
|
72
|
+
});
|
|
73
|
+
const { resolvedEndAccessory, hasMultipleEndButtons } = resolveEndAccessory({
|
|
74
|
+
endAccessory,
|
|
75
|
+
endButtonIconProps,
|
|
76
|
+
});
|
|
77
|
+
const hasStartAccessory = Boolean(resolvedStartAccessory);
|
|
78
|
+
const hasEndAccessory = Boolean(resolvedEndAccessory);
|
|
79
|
+
const hasAnyAccessory = hasStartAccessory || hasEndAccessory;
|
|
80
|
+
// Calculate equal width for both accessory wrappers to ensure title stays centered.
|
|
81
|
+
const accessoryWrapperWidth = hasAnyAccessory && (startAccessoryWidth || endAccessoryWidth)
|
|
46
82
|
? Math.max(startAccessoryWidth, endAccessoryWidth)
|
|
47
83
|
: undefined;
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
if (startButtonIconProps) {
|
|
53
|
-
return <ButtonIcon size={ButtonIconSize.Md} {...startButtonIconProps}/>;
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
};
|
|
57
|
-
const renderEndContent = () => {
|
|
58
|
-
if (endAccessory) {
|
|
59
|
-
return endAccessory;
|
|
60
|
-
}
|
|
61
|
-
if (endButtonIconProps && endButtonIconProps.length > 0) {
|
|
62
|
-
// Reverse the array so first item appears rightmost
|
|
63
|
-
// Use original index (before reversal) for stable React keys
|
|
64
|
-
const reversedProps = endButtonIconProps
|
|
65
|
-
.map((iconProps, originalIndex) => ({
|
|
66
|
-
iconProps,
|
|
67
|
-
originalIndex,
|
|
68
|
-
}))
|
|
69
|
-
.reverse();
|
|
70
|
-
return reversedProps.map(({ iconProps, originalIndex }) => (<ButtonIcon key={`end-button-icon-${originalIndex}`} size={ButtonIconSize.Md} {...iconProps}/>));
|
|
84
|
+
const renderAccessoryWrapper = ({ wrapperProps, alignment, onLayout, content, measuredContentStyle, }) => {
|
|
85
|
+
if (!hasAnyAccessory) {
|
|
86
|
+
return null;
|
|
71
87
|
}
|
|
72
|
-
return
|
|
88
|
+
return (<View style={accessoryWrapperWidth
|
|
89
|
+
? tw.style(alignment, { width: accessoryWrapperWidth })
|
|
90
|
+
: undefined} {...wrapperProps}>
|
|
91
|
+
<View onLayout={onLayout} style={measuredContentStyle}>
|
|
92
|
+
{content}
|
|
93
|
+
</View>
|
|
94
|
+
</View>);
|
|
73
95
|
};
|
|
74
|
-
// Check if we have multiple end buttons for layout styling
|
|
75
|
-
const hasMultipleEndButtons = !endAccessory && endButtonIconProps && endButtonIconProps.length > 1;
|
|
76
|
-
// Merge default styles with passed-in twClassName
|
|
77
|
-
const baseStyles = 'flex-row items-center gap-4 h-14';
|
|
78
|
-
const resolvedTwClassName = twClassName
|
|
79
|
-
? `${baseStyles} ${twClassName}`
|
|
80
|
-
: baseStyles;
|
|
81
96
|
return (<View style={[
|
|
82
|
-
tw.style(
|
|
97
|
+
tw.style('flex-row items-center gap-4 h-14', twClassName),
|
|
83
98
|
includesTopInset && { marginTop: insets.top },
|
|
84
99
|
style,
|
|
85
100
|
]} {...props}>
|
|
86
101
|
{/* Start accessory */}
|
|
87
|
-
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</View>)}
|
|
102
|
+
{renderAccessoryWrapper({
|
|
103
|
+
wrapperProps: startAccessoryWrapperProps,
|
|
104
|
+
alignment: 'items-start',
|
|
105
|
+
onLayout: handleStartAccessoryLayout,
|
|
106
|
+
content: resolvedStartAccessory,
|
|
107
|
+
})}
|
|
94
108
|
|
|
95
109
|
{/* Title */}
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
110
|
+
<View style={tw.style('flex-1 items-center')} {...childrenWrapperProps}>
|
|
111
|
+
<TextOrChildren textProps={{
|
|
112
|
+
variant: TextVariant.HeadingSm,
|
|
113
|
+
...textProps,
|
|
114
|
+
style: [tw.style('text-center'), textProps?.style],
|
|
115
|
+
}}>
|
|
116
|
+
{children}
|
|
117
|
+
</TextOrChildren>
|
|
118
|
+
</View>
|
|
101
119
|
|
|
102
120
|
{/* End accessory */}
|
|
103
|
-
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
121
|
+
{renderAccessoryWrapper({
|
|
122
|
+
wrapperProps: endAccessoryWrapperProps,
|
|
123
|
+
alignment: 'items-end',
|
|
124
|
+
onLayout: handleEndAccessoryLayout,
|
|
125
|
+
content: resolvedEndAccessory,
|
|
126
|
+
measuredContentStyle: hasMultipleEndButtons
|
|
127
|
+
? tw.style('flex-row gap-2')
|
|
128
|
+
: undefined,
|
|
129
|
+
})}
|
|
110
130
|
</View>);
|
|
111
131
|
};
|
|
132
|
+
HeaderBase.displayName = 'HeaderBase';
|
|
112
133
|
//# sourceMappingURL=HeaderBase.mjs.map
|