react-native-mantine 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -6
- package/lib/commonjs/components/Anchor/index.js +6 -1
- package/lib/commonjs/components/Anchor/index.js.map +1 -1
- package/lib/commonjs/components/Badge/index.js +12 -13
- package/lib/commonjs/components/Badge/index.js.map +1 -1
- package/lib/commonjs/components/Blockquote/index.js +8 -12
- package/lib/commonjs/components/Blockquote/index.js.map +1 -1
- package/lib/commonjs/components/Button/index.js +5 -6
- package/lib/commonjs/components/Button/index.js.map +1 -1
- package/lib/commonjs/components/Chip/index.js +8 -9
- package/lib/commonjs/components/Chip/index.js.map +1 -1
- package/lib/commonjs/components/Code/index.js +13 -8
- package/lib/commonjs/components/Code/index.js.map +1 -1
- package/lib/commonjs/components/Group/index.js.map +1 -1
- package/lib/commonjs/components/Kbd/index.js +7 -8
- package/lib/commonjs/components/Kbd/index.js.map +1 -1
- package/lib/commonjs/components/List/index.js +6 -5
- package/lib/commonjs/components/List/index.js.map +1 -1
- package/lib/commonjs/components/Mark/index.js +4 -0
- package/lib/commonjs/components/Mark/index.js.map +1 -1
- package/lib/commonjs/components/Menu/index.js +12 -15
- package/lib/commonjs/components/Menu/index.js.map +1 -1
- package/lib/commonjs/components/NavLink/index.js +7 -11
- package/lib/commonjs/components/NavLink/index.js.map +1 -1
- package/lib/commonjs/components/Notification/index.js +5 -15
- package/lib/commonjs/components/Notification/index.js.map +1 -1
- package/lib/commonjs/components/Radio/index.js +62 -6
- package/lib/commonjs/components/Radio/index.js.map +1 -1
- package/lib/commonjs/components/Table/Table.example.js +131 -0
- package/lib/commonjs/components/Table/Table.example.js.map +1 -0
- package/lib/commonjs/components/Table/index.js +69 -15
- package/lib/commonjs/components/Table/index.js.map +1 -1
- package/lib/commonjs/components/Title/index.js +4 -0
- package/lib/commonjs/components/Title/index.js.map +1 -1
- package/lib/commonjs/hooks/index.js +28 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/use-form/index.js +40 -0
- package/lib/commonjs/hooks/use-form/index.js.map +1 -0
- package/lib/commonjs/hooks/use-form/types.js +2 -0
- package/lib/commonjs/hooks/use-form/types.js.map +1 -0
- package/lib/commonjs/hooks/use-form/useForm.js +418 -0
- package/lib/commonjs/hooks/use-form/useForm.js.map +1 -0
- package/lib/commonjs/hooks/use-form/validators.js +135 -0
- package/lib/commonjs/hooks/use-form/validators.js.map +1 -0
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/theme/utils/index.js +26 -0
- package/lib/commonjs/theme/utils/index.js.map +1 -0
- package/lib/commonjs/theme/utils/withTextWrapper.js +49 -0
- package/lib/commonjs/theme/utils/withTextWrapper.js.map +1 -0
- package/lib/module/components/Anchor/index.js +6 -1
- package/lib/module/components/Anchor/index.js.map +1 -1
- package/lib/module/components/Badge/index.js +5 -6
- package/lib/module/components/Badge/index.js.map +1 -1
- package/lib/module/components/Blockquote/index.js +6 -10
- package/lib/module/components/Blockquote/index.js.map +1 -1
- package/lib/module/components/Button/index.js +5 -6
- package/lib/module/components/Button/index.js.map +1 -1
- package/lib/module/components/Chip/index.js +5 -6
- package/lib/module/components/Chip/index.js.map +1 -1
- package/lib/module/components/Code/index.js +13 -8
- package/lib/module/components/Code/index.js.map +1 -1
- package/lib/module/components/Group/index.js.map +1 -1
- package/lib/module/components/Kbd/index.js +5 -6
- package/lib/module/components/Kbd/index.js.map +1 -1
- package/lib/module/components/List/index.js +6 -5
- package/lib/module/components/List/index.js.map +1 -1
- package/lib/module/components/Mark/index.js +4 -0
- package/lib/module/components/Mark/index.js.map +1 -1
- package/lib/module/components/Menu/index.js +7 -10
- package/lib/module/components/Menu/index.js.map +1 -1
- package/lib/module/components/NavLink/index.js +5 -9
- package/lib/module/components/NavLink/index.js.map +1 -1
- package/lib/module/components/Notification/index.js +5 -15
- package/lib/module/components/Notification/index.js.map +1 -1
- package/lib/module/components/Radio/index.js +64 -8
- package/lib/module/components/Radio/index.js.map +1 -1
- package/lib/module/components/Table/Table.example.js +128 -0
- package/lib/module/components/Table/Table.example.js.map +1 -0
- package/lib/module/components/Table/index.js +70 -16
- package/lib/module/components/Table/index.js.map +1 -1
- package/lib/module/components/Title/index.js +4 -0
- package/lib/module/components/Title/index.js.map +1 -1
- package/lib/module/hooks/index.js +5 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/use-form/index.js +6 -0
- package/lib/module/hooks/use-form/index.js.map +1 -0
- package/lib/module/hooks/use-form/types.js +2 -0
- package/lib/module/hooks/use-form/types.js.map +1 -0
- package/lib/module/hooks/use-form/useForm.js +414 -0
- package/lib/module/hooks/use-form/useForm.js.map +1 -0
- package/lib/module/hooks/use-form/validators.js +122 -0
- package/lib/module/hooks/use-form/validators.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/theme/utils/index.js +5 -0
- package/lib/module/theme/utils/index.js.map +1 -0
- package/lib/module/theme/utils/withTextWrapper.js +45 -0
- package/lib/module/theme/utils/withTextWrapper.js.map +1 -0
- package/lib/typescript/commonjs/src/components/Anchor/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/Anchor/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Badge/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/Badge/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Blockquote/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/Blockquote/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Button/index.d.ts +2 -2
- package/lib/typescript/commonjs/src/components/Button/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Chip/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/Chip/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Code/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/Code/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Group/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/components/Group/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Kbd/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/Kbd/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/List/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/List/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Mark/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/Mark/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Menu/index.d.ts +3 -2
- package/lib/typescript/commonjs/src/components/Menu/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/NavLink/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/NavLink/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Notification/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/Notification/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Radio/index.d.ts +22 -1
- package/lib/typescript/commonjs/src/components/Radio/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Table/Table.example.d.ts +3 -0
- package/lib/typescript/commonjs/src/components/Table/Table.example.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/Table/index.d.ts +7 -2
- package/lib/typescript/commonjs/src/components/Table/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Title/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/Title/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hooks/index.d.ts +3 -0
- package/lib/typescript/commonjs/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/use-form/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/hooks/use-form/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/use-form/types.d.ts +119 -0
- package/lib/typescript/commonjs/src/hooks/use-form/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/use-form/useForm.d.ts +30 -0
- package/lib/typescript/commonjs/src/hooks/use-form/useForm.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/use-form/validators.d.ts +41 -0
- package/lib/typescript/commonjs/src/hooks/use-form/validators.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/utils/index.d.ts +3 -0
- package/lib/typescript/commonjs/src/theme/utils/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theme/utils/withTextWrapper.d.ts +41 -0
- package/lib/typescript/commonjs/src/theme/utils/withTextWrapper.d.ts.map +1 -0
- package/lib/typescript/module/src/components/Anchor/index.d.ts +2 -1
- package/lib/typescript/module/src/components/Anchor/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Badge/index.d.ts +2 -1
- package/lib/typescript/module/src/components/Badge/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Blockquote/index.d.ts +2 -1
- package/lib/typescript/module/src/components/Blockquote/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Button/index.d.ts +2 -2
- package/lib/typescript/module/src/components/Button/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Chip/index.d.ts +2 -1
- package/lib/typescript/module/src/components/Chip/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Code/index.d.ts +2 -1
- package/lib/typescript/module/src/components/Code/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Group/index.d.ts +1 -0
- package/lib/typescript/module/src/components/Group/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Kbd/index.d.ts +2 -1
- package/lib/typescript/module/src/components/Kbd/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/List/index.d.ts +2 -1
- package/lib/typescript/module/src/components/List/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Mark/index.d.ts +2 -1
- package/lib/typescript/module/src/components/Mark/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Menu/index.d.ts +3 -2
- package/lib/typescript/module/src/components/Menu/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/NavLink/index.d.ts +2 -1
- package/lib/typescript/module/src/components/NavLink/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Notification/index.d.ts +2 -1
- package/lib/typescript/module/src/components/Notification/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Radio/index.d.ts +22 -1
- package/lib/typescript/module/src/components/Radio/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Table/Table.example.d.ts +3 -0
- package/lib/typescript/module/src/components/Table/Table.example.d.ts.map +1 -0
- package/lib/typescript/module/src/components/Table/index.d.ts +7 -2
- package/lib/typescript/module/src/components/Table/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Title/index.d.ts +2 -1
- package/lib/typescript/module/src/components/Title/index.d.ts.map +1 -1
- package/lib/typescript/module/src/hooks/index.d.ts +3 -0
- package/lib/typescript/module/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/use-form/index.d.ts +4 -0
- package/lib/typescript/module/src/hooks/use-form/index.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/use-form/types.d.ts +119 -0
- package/lib/typescript/module/src/hooks/use-form/types.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/use-form/useForm.d.ts +30 -0
- package/lib/typescript/module/src/hooks/use-form/useForm.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/use-form/validators.d.ts +41 -0
- package/lib/typescript/module/src/hooks/use-form/validators.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +1 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/utils/index.d.ts +3 -0
- package/lib/typescript/module/src/theme/utils/index.d.ts.map +1 -0
- package/lib/typescript/module/src/theme/utils/withTextWrapper.d.ts +41 -0
- package/lib/typescript/module/src/theme/utils/withTextWrapper.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/Anchor/index.tsx +8 -2
- package/src/components/Badge/index.tsx +5 -3
- package/src/components/Blockquote/index.tsx +6 -5
- package/src/components/Button/index.tsx +5 -6
- package/src/components/Chip/index.tsx +5 -3
- package/src/components/Code/index.tsx +19 -14
- package/src/components/Group/index.tsx +1 -0
- package/src/components/Kbd/index.tsx +5 -4
- package/src/components/List/index.tsx +7 -8
- package/src/components/Mark/index.tsx +7 -2
- package/src/components/Menu/index.tsx +8 -7
- package/src/components/NavLink/index.tsx +6 -4
- package/src/components/Notification/index.tsx +6 -15
- package/src/components/Radio/index.tsx +99 -8
- package/src/components/Table/Table.example.tsx +85 -0
- package/src/components/Table/index.tsx +93 -11
- package/src/components/Title/index.tsx +7 -2
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-form/index.ts +3 -0
- package/src/hooks/use-form/types.ts +169 -0
- package/src/hooks/use-form/useForm.ts +436 -0
- package/src/hooks/use-form/validators.ts +143 -0
- package/src/index.tsx +1 -0
- package/src/theme/utils/index.ts +2 -0
- package/src/theme/utils/withTextWrapper.tsx +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../../../../src/hooks/use-form/useForm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAQV,YAAY,EACZ,iBAAiB,EAClB,MAAM,SAAS,CAAC;AA4DjB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,OAAO,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAChF,aAA4B,EAC5B,aAAkB,EAClB,cAAmB,EACnB,YAAiB,EACjB,QAAQ,EAAE,eAAe,EACzB,uBAA8B,EAC9B,qBAA6B,EAC7B,mBAA2B,EAC3B,eAA4C,GAC7C,GAAE,YAAY,CAAC,MAAM,CAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAuUvD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { FormValidator } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Built-in validators
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Validates that a value is not empty
|
|
7
|
+
*/
|
|
8
|
+
export declare const isNotEmpty: (message?: string) => FormValidator<any>;
|
|
9
|
+
/**
|
|
10
|
+
* Validates minimum length
|
|
11
|
+
*/
|
|
12
|
+
export declare const minLength: (min: number, message?: string) => FormValidator<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Validates maximum length
|
|
15
|
+
*/
|
|
16
|
+
export declare const maxLength: (max: number, message?: string) => FormValidator<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Validates that value matches a pattern
|
|
19
|
+
*/
|
|
20
|
+
export declare const matches: (pattern: RegExp, message?: string) => FormValidator<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Validates email format
|
|
23
|
+
*/
|
|
24
|
+
export declare const isEmail: (message?: string) => FormValidator<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Validates minimum value
|
|
27
|
+
*/
|
|
28
|
+
export declare const min: (minValue: number, message?: string) => FormValidator<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Validates maximum value
|
|
31
|
+
*/
|
|
32
|
+
export declare const max: (maxValue: number, message?: string) => FormValidator<number>;
|
|
33
|
+
/**
|
|
34
|
+
* Validates that value is in a range
|
|
35
|
+
*/
|
|
36
|
+
export declare const inRange: (minValue: number, maxValue: number, message?: string) => FormValidator<number>;
|
|
37
|
+
/**
|
|
38
|
+
* Validates that value is in a list
|
|
39
|
+
*/
|
|
40
|
+
export declare const isInArray: <T>(array: T[], message?: string) => FormValidator<T>;
|
|
41
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../../../../src/hooks/use-form/validators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,gBAAkC,KAAG,aAAa,CAAC,GAAG,CAahF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,GACpB,KAAK,MAAM,EACX,UAAU,MAAM,KACf,aAAa,CAAC,MAAM,CAQtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,GACpB,KAAK,MAAM,EACX,UAAU,MAAM,KACf,aAAa,CAAC,MAAM,CAQtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,GAClB,SAAS,MAAM,EACf,gBAA0B,KACzB,aAAa,CAAC,MAAM,CAQtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,gBAAyB,KAAG,aAAa,CAAC,MAAM,CAGvE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,GAAG,GACd,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,aAAa,CAAC,MAAM,CAQtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,GAAG,GACd,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,aAAa,CAAC,MAAM,CAQtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,GAClB,UAAU,MAAM,EAChB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,aAAa,CAAC,MAAM,CAQtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EACzB,OAAO,CAAC,EAAE,EACV,gBAAyB,KACxB,aAAa,CAAC,CAAC,CAOjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/theme/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { TextProps } from '../../components/Text';
|
|
3
|
+
/**
|
|
4
|
+
* Conditionally wraps content in a Text component based on the withTextWrapper prop.
|
|
5
|
+
*
|
|
6
|
+
* In React Native, all text must be wrapped in a Text component. However, some
|
|
7
|
+
* components may need flexibility to render with or without this wrapper depending
|
|
8
|
+
* on whether their content is text or other components (like icons, views, etc.).
|
|
9
|
+
*
|
|
10
|
+
* @param children - The content to potentially wrap
|
|
11
|
+
* @param shouldWrap - Whether to wrap the content in a Text component
|
|
12
|
+
* @param textStyle - Optional style to apply to the Text wrapper
|
|
13
|
+
* @param textProps - Optional additional props to pass to the Text component
|
|
14
|
+
* @returns The children wrapped in Text if shouldWrap is true, otherwise just the children
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Wrap text content
|
|
18
|
+
* withTextWrapper('Hello', true, styles.text)
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Don't wrap components
|
|
22
|
+
* withTextWrapper(<Icon />, false)
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Default behavior (wrap)
|
|
26
|
+
* withTextWrapper('Text', true, styles.text, { numberOfLines: 1 })
|
|
27
|
+
*/
|
|
28
|
+
export declare function withTextWrapper(children: ReactNode, shouldWrap?: boolean, textStyle?: any, textProps?: Omit<TextProps, 'children' | 'style'>): ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Type helper for components that support the withTextWrapper pattern.
|
|
31
|
+
* Add this to your component props interface.
|
|
32
|
+
*/
|
|
33
|
+
export interface WithTextWrapperProps {
|
|
34
|
+
/**
|
|
35
|
+
* If false, children will not be wrapped in a Text component.
|
|
36
|
+
* This is useful when the children contain non-text elements like icons or custom components.
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
withTextWrapper?: boolean;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=withTextWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withTextWrapper.d.ts","sourceRoot":"","sources":["../../../../../../src/theme/utils/withTextWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,SAAS,EACnB,UAAU,GAAE,OAAc,EAC1B,SAAS,CAAC,EAAE,GAAG,EACf,SAAS,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,GAChD,SAAS,CAUX;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B"}
|
package/package.json
CHANGED
|
@@ -10,8 +10,9 @@ import type {
|
|
|
10
10
|
import { useComponentDefaultProps } from '../../theme/theme-provider';
|
|
11
11
|
import { createStyles } from '../../theme';
|
|
12
12
|
import { rem } from '../../theme/utils/rem';
|
|
13
|
+
import type { WithTextWrapperProps } from '../../theme/utils/withTextWrapper';
|
|
13
14
|
|
|
14
|
-
export interface AnchorProps extends DefaultProps {
|
|
15
|
+
export interface AnchorProps extends DefaultProps, WithTextWrapperProps {
|
|
15
16
|
/** Anchor text color from theme */
|
|
16
17
|
color?: MantineColor;
|
|
17
18
|
|
|
@@ -103,10 +104,11 @@ const defaultProps: Partial<AnchorProps> = {
|
|
|
103
104
|
weight: '400',
|
|
104
105
|
underline: true,
|
|
105
106
|
variant: 'link',
|
|
107
|
+
withTextWrapper: true,
|
|
106
108
|
};
|
|
107
109
|
|
|
108
110
|
export const Anchor = forwardRef<RNText, AnchorProps>((props, ref) => {
|
|
109
|
-
const { color, size, weight, underline, variant, href, onPress, children, style, ...others} =
|
|
111
|
+
const { color, size, weight, underline, variant, href, onPress, children, style, withTextWrapper: shouldWrapInText, ...others} =
|
|
110
112
|
useComponentDefaultProps('Anchor', defaultProps, props);
|
|
111
113
|
|
|
112
114
|
const { styles, sx} = useStyles(
|
|
@@ -124,6 +126,10 @@ export const Anchor = forwardRef<RNText, AnchorProps>((props, ref) => {
|
|
|
124
126
|
}
|
|
125
127
|
};
|
|
126
128
|
|
|
129
|
+
if (!shouldWrapInText) {
|
|
130
|
+
return children;
|
|
131
|
+
}
|
|
132
|
+
|
|
127
133
|
return (
|
|
128
134
|
<Text
|
|
129
135
|
ref={ref}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
-
import { Text } from '../Text';
|
|
3
2
|
import { BoxView } from '../BoxView';
|
|
4
3
|
import type {
|
|
5
4
|
DefaultProps,
|
|
@@ -11,8 +10,9 @@ import type {
|
|
|
11
10
|
import { useComponentDefaultProps } from '../../theme/theme-provider';
|
|
12
11
|
import { createStyles } from '../../theme';
|
|
13
12
|
import { rem } from '../../theme/utils/rem';
|
|
13
|
+
import { withTextWrapper, type WithTextWrapperProps } from '../../theme/utils/withTextWrapper';
|
|
14
14
|
|
|
15
|
-
export interface BadgeProps extends DefaultProps {
|
|
15
|
+
export interface BadgeProps extends DefaultProps, WithTextWrapperProps {
|
|
16
16
|
/** Badge color from theme */
|
|
17
17
|
color?: MantineColor;
|
|
18
18
|
|
|
@@ -157,6 +157,7 @@ const defaultProps: Partial<BadgeProps> = {
|
|
|
157
157
|
size: 'md',
|
|
158
158
|
radius: 'xl',
|
|
159
159
|
fullWidth: false,
|
|
160
|
+
withTextWrapper: true,
|
|
160
161
|
};
|
|
161
162
|
|
|
162
163
|
export const Badge = forwardRef<any, BadgeProps>((props, ref) => {
|
|
@@ -170,6 +171,7 @@ export const Badge = forwardRef<any, BadgeProps>((props, ref) => {
|
|
|
170
171
|
rightSection,
|
|
171
172
|
children,
|
|
172
173
|
style,
|
|
174
|
+
withTextWrapper: shouldWrapInText,
|
|
173
175
|
...others
|
|
174
176
|
} = useComponentDefaultProps('Badge', defaultProps, props);
|
|
175
177
|
|
|
@@ -183,7 +185,7 @@ export const Badge = forwardRef<any, BadgeProps>((props, ref) => {
|
|
|
183
185
|
<BoxView style={styles.inner}>
|
|
184
186
|
{variant === 'dot' && <BoxView style={styles.dot} />}
|
|
185
187
|
{leftSection && <BoxView style={styles.leftSection}>{leftSection}</BoxView>}
|
|
186
|
-
|
|
188
|
+
{withTextWrapper(children, shouldWrapInText, styles.label)}
|
|
187
189
|
{rightSection && <BoxView style={styles.rightSection}>{rightSection}</BoxView>}
|
|
188
190
|
</BoxView>
|
|
189
191
|
</BoxView>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import { BoxView } from '../BoxView';
|
|
3
|
-
import { Text } from '../Text';
|
|
4
3
|
import type {
|
|
5
4
|
DefaultProps,
|
|
6
5
|
MantineColor,
|
|
@@ -9,8 +8,9 @@ import type {
|
|
|
9
8
|
import { useComponentDefaultProps } from '../../theme/theme-provider';
|
|
10
9
|
import { createStyles } from '../../theme';
|
|
11
10
|
import { rem } from '../../theme/utils/rem';
|
|
11
|
+
import { withTextWrapper, type WithTextWrapperProps } from '../../theme/utils/withTextWrapper';
|
|
12
12
|
|
|
13
|
-
export interface BlockquoteProps extends DefaultProps {
|
|
13
|
+
export interface BlockquoteProps extends DefaultProps, WithTextWrapperProps {
|
|
14
14
|
/** Blockquote color from theme */
|
|
15
15
|
color?: MantineColor;
|
|
16
16
|
|
|
@@ -80,10 +80,11 @@ const useStyles = createStyles(
|
|
|
80
80
|
const defaultProps: Partial<BlockquoteProps> = {
|
|
81
81
|
color: 'blue',
|
|
82
82
|
radius: 'sm',
|
|
83
|
+
withTextWrapper: true,
|
|
83
84
|
};
|
|
84
85
|
|
|
85
86
|
export const Blockquote = forwardRef<any, BlockquoteProps>((props, ref) => {
|
|
86
|
-
const { color, icon, cite, radius, children, style} =
|
|
87
|
+
const { color, icon, cite, radius, children, style, withTextWrapper: shouldWrapInText} =
|
|
87
88
|
useComponentDefaultProps('Blockquote', defaultProps, props);
|
|
88
89
|
|
|
89
90
|
const { styles, sx, ...others} = useStyles({ color, radius}, { name: 'Blockquote' }) as any;
|
|
@@ -93,8 +94,8 @@ export const Blockquote = forwardRef<any, BlockquoteProps>((props, ref) => {
|
|
|
93
94
|
<BoxView style={styles.inner}>
|
|
94
95
|
{icon && <BoxView style={styles.icon}>{icon}</BoxView>}
|
|
95
96
|
<BoxView style={styles.body}>
|
|
96
|
-
|
|
97
|
-
{cite &&
|
|
97
|
+
{withTextWrapper(children, shouldWrapInText, styles.content)}
|
|
98
|
+
{cite && withTextWrapper(cite, shouldWrapInText, styles.cite)}
|
|
98
99
|
</BoxView>
|
|
99
100
|
</BoxView>
|
|
100
101
|
</BoxView>
|
|
@@ -13,11 +13,11 @@ import { ActivityIndicator, View } from 'react-native';
|
|
|
13
13
|
import { useComponentDefaultProps } from '../../theme/theme-provider';
|
|
14
14
|
import useStyles from './Button.styles';
|
|
15
15
|
import { BoxView } from '../BoxView';
|
|
16
|
-
import {
|
|
16
|
+
import { withTextWrapper, type WithTextWrapperProps } from '../../theme/utils/withTextWrapper';
|
|
17
17
|
|
|
18
18
|
export type ButtonStylesNames = any;
|
|
19
19
|
|
|
20
|
-
export interface ButtonProps extends DefaultProps {
|
|
20
|
+
export interface ButtonProps extends DefaultProps, WithTextWrapperProps {
|
|
21
21
|
/** Predefined button size */
|
|
22
22
|
size?: MantineSize;
|
|
23
23
|
|
|
@@ -69,8 +69,6 @@ export interface ButtonProps extends DefaultProps {
|
|
|
69
69
|
disabled?: boolean;
|
|
70
70
|
|
|
71
71
|
style?: any;
|
|
72
|
-
|
|
73
|
-
withTextWrapper?: boolean;
|
|
74
72
|
}
|
|
75
73
|
|
|
76
74
|
const defaultProps: Partial<ButtonProps> = {
|
|
@@ -78,6 +76,7 @@ const defaultProps: Partial<ButtonProps> = {
|
|
|
78
76
|
type: 'button',
|
|
79
77
|
variant: 'filled',
|
|
80
78
|
loaderPosition: 'left',
|
|
79
|
+
withTextWrapper: true,
|
|
81
80
|
};
|
|
82
81
|
|
|
83
82
|
export const _Button = forwardRef<View, ButtonProps>((props, ref) => {
|
|
@@ -99,7 +98,7 @@ export const _Button = forwardRef<View, ButtonProps>((props, ref) => {
|
|
|
99
98
|
loaderProps,
|
|
100
99
|
gradient,
|
|
101
100
|
style,
|
|
102
|
-
withTextWrapper
|
|
101
|
+
withTextWrapper: shouldWrapInText,
|
|
103
102
|
...others
|
|
104
103
|
} = useComponentDefaultProps('Button', defaultProps, props);
|
|
105
104
|
|
|
@@ -142,7 +141,7 @@ export const _Button = forwardRef<View, ButtonProps>((props, ref) => {
|
|
|
142
141
|
{loading && loaderPosition === 'center' && (
|
|
143
142
|
<BoxView style={styles.centerLoader}>{loader}</BoxView>
|
|
144
143
|
)}
|
|
145
|
-
{withTextWrapper
|
|
144
|
+
{withTextWrapper(children, shouldWrapInText)}
|
|
146
145
|
{(rightIcon || (loading && loaderPosition === 'right')) && (
|
|
147
146
|
<BoxView style={sx(styles.icon, styles.rightIcon)}>
|
|
148
147
|
{loading && loaderPosition === 'right' ? loader : rightIcon}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { BoxView } from '../BoxView';
|
|
4
|
-
import { Text } from '../Text';
|
|
5
4
|
import type {
|
|
6
5
|
DefaultProps,
|
|
7
6
|
MantineColor,
|
|
@@ -12,8 +11,9 @@ import type {
|
|
|
12
11
|
import { useComponentDefaultProps } from '../../theme/theme-provider';
|
|
13
12
|
import { createStyles } from '../../theme';
|
|
14
13
|
import { rem } from '../../theme/utils/rem';
|
|
14
|
+
import { withTextWrapper, type WithTextWrapperProps } from '../../theme/utils/withTextWrapper';
|
|
15
15
|
|
|
16
|
-
export interface ChipProps extends DefaultProps {
|
|
16
|
+
export interface ChipProps extends DefaultProps, WithTextWrapperProps {
|
|
17
17
|
/** Chip label */
|
|
18
18
|
children: React.ReactNode;
|
|
19
19
|
|
|
@@ -174,6 +174,7 @@ const defaultProps: Partial<ChipProps> = {
|
|
|
174
174
|
variant: 'filled',
|
|
175
175
|
disabled: false,
|
|
176
176
|
type: 'checkbox',
|
|
177
|
+
withTextWrapper: true,
|
|
177
178
|
};
|
|
178
179
|
|
|
179
180
|
export const Chip = forwardRef<any, ChipProps>((props, ref) => {
|
|
@@ -192,6 +193,7 @@ export const Chip = forwardRef<any, ChipProps>((props, ref) => {
|
|
|
192
193
|
textStyle,
|
|
193
194
|
value,
|
|
194
195
|
type,
|
|
196
|
+
withTextWrapper: shouldWrapInText,
|
|
195
197
|
...others
|
|
196
198
|
} = useComponentDefaultProps('Chip', defaultProps, props);
|
|
197
199
|
|
|
@@ -226,7 +228,7 @@ export const Chip = forwardRef<any, ChipProps>((props, ref) => {
|
|
|
226
228
|
{...others}
|
|
227
229
|
>
|
|
228
230
|
{showIcon && <BoxView style={styles.icon}>{icon}</BoxView>}
|
|
229
|
-
|
|
231
|
+
{withTextWrapper(children, shouldWrapInText, sx(styles.text, textStyle))}
|
|
230
232
|
</TouchableOpacity>
|
|
231
233
|
);
|
|
232
234
|
});
|
|
@@ -3,8 +3,9 @@ import { Text } from '../Text';
|
|
|
3
3
|
import type { TextProps } from '../Text';
|
|
4
4
|
import { useTheme } from '../../theme/theme-provider';
|
|
5
5
|
import { BoxView } from '../BoxView';
|
|
6
|
+
import { withTextWrapper, type WithTextWrapperProps } from '../../theme/utils/withTextWrapper';
|
|
6
7
|
|
|
7
|
-
export interface CodeProps extends Omit<TextProps, 'children'
|
|
8
|
+
export interface CodeProps extends Omit<TextProps, 'children'>, WithTextWrapperProps {
|
|
8
9
|
/** Code content */
|
|
9
10
|
children?: React.ReactNode;
|
|
10
11
|
|
|
@@ -19,7 +20,7 @@ export interface CodeProps extends Omit<TextProps, 'children'> {
|
|
|
19
20
|
* Code component renders inline code or code blocks with monospace font
|
|
20
21
|
*/
|
|
21
22
|
export const Code = forwardRef<any, CodeProps>((props, ref) => {
|
|
22
|
-
const { children, color, block = false, style, ...others} = props;
|
|
23
|
+
const { children, color, block = false, style, withTextWrapper: shouldWrapInText = true, ...others} = props;
|
|
23
24
|
|
|
24
25
|
const theme = useTheme();
|
|
25
26
|
|
|
@@ -52,23 +53,27 @@ export const Code = forwardRef<any, CodeProps>((props, ref) => {
|
|
|
52
53
|
},
|
|
53
54
|
style,
|
|
54
55
|
]}
|
|
56
|
+
{...others}
|
|
55
57
|
>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
>
|
|
66
|
-
{children}
|
|
67
|
-
</Text>
|
|
58
|
+
{withTextWrapper(
|
|
59
|
+
children,
|
|
60
|
+
shouldWrapInText,
|
|
61
|
+
{
|
|
62
|
+
fontFamily: 'Courier',
|
|
63
|
+
fontSize: theme.fontSizes.sm as number || 14,
|
|
64
|
+
color: textColor,
|
|
65
|
+
}
|
|
66
|
+
)}
|
|
68
67
|
</BoxView>
|
|
69
68
|
);
|
|
70
69
|
}
|
|
71
70
|
|
|
71
|
+
// For inline code, we need to return a component that can accept the ref
|
|
72
|
+
// So we wrap in a View-like Text component
|
|
73
|
+
if (!shouldWrapInText) {
|
|
74
|
+
return children;
|
|
75
|
+
}
|
|
76
|
+
|
|
72
77
|
return (
|
|
73
78
|
<Text
|
|
74
79
|
ref={ref}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import { BoxView } from '../BoxView';
|
|
3
|
-
import { Text } from '../Text';
|
|
4
3
|
import type { DefaultProps, MantineSize } from '../../theme/types';
|
|
5
4
|
import { useComponentDefaultProps } from '../../theme/theme-provider';
|
|
6
5
|
import { createStyles } from '../../theme';
|
|
7
6
|
import { rem } from '../../theme/utils/rem';
|
|
7
|
+
import { withTextWrapper, type WithTextWrapperProps } from '../../theme/utils/withTextWrapper';
|
|
8
8
|
|
|
9
|
-
export interface KbdProps extends DefaultProps {
|
|
9
|
+
export interface KbdProps extends DefaultProps, WithTextWrapperProps {
|
|
10
10
|
/** Kbd size */
|
|
11
11
|
size?: MantineSize;
|
|
12
12
|
|
|
@@ -63,10 +63,11 @@ const useStyles = createStyles(
|
|
|
63
63
|
|
|
64
64
|
const defaultProps: Partial<KbdProps> = {
|
|
65
65
|
size: 'md',
|
|
66
|
+
withTextWrapper: true,
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
export const Kbd = forwardRef<any, KbdProps>((props, ref) => {
|
|
69
|
-
const { size, children, style, ...otherProps} = useComponentDefaultProps(
|
|
70
|
+
const { size, children, style, withTextWrapper: shouldWrapInText, ...otherProps} = useComponentDefaultProps(
|
|
70
71
|
'Kbd',
|
|
71
72
|
defaultProps,
|
|
72
73
|
props
|
|
@@ -76,7 +77,7 @@ export const Kbd = forwardRef<any, KbdProps>((props, ref) => {
|
|
|
76
77
|
|
|
77
78
|
return (
|
|
78
79
|
<BoxView ref={ref} style={sx(styles.root, style)} {...otherProps}>
|
|
79
|
-
|
|
80
|
+
{withTextWrapper(children, shouldWrapInText, styles.label)}
|
|
80
81
|
</BoxView>
|
|
81
82
|
);
|
|
82
83
|
});
|
|
@@ -5,6 +5,7 @@ import type { DefaultProps, SpacingValue } from '../../theme/types';
|
|
|
5
5
|
import { useComponentDefaultProps } from '../../theme/theme-provider';
|
|
6
6
|
import { createStyles } from '../../theme';
|
|
7
7
|
import { rem } from '../../theme/utils/rem';
|
|
8
|
+
import { withTextWrapper, type WithTextWrapperProps } from '../../theme/utils/withTextWrapper';
|
|
8
9
|
|
|
9
10
|
interface ListContextValue {
|
|
10
11
|
type: 'ordered' | 'unordered';
|
|
@@ -59,7 +60,7 @@ export interface ListProps extends DefaultProps {
|
|
|
59
60
|
style?: any;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
export interface ListItemProps extends DefaultProps {
|
|
63
|
+
export interface ListItemProps extends DefaultProps, WithTextWrapperProps {
|
|
63
64
|
/** Item children */
|
|
64
65
|
children?: React.ReactNode;
|
|
65
66
|
|
|
@@ -156,7 +157,9 @@ const defaultProps: Partial<ListProps> = {
|
|
|
156
157
|
startIndex: 1,
|
|
157
158
|
};
|
|
158
159
|
|
|
159
|
-
const defaultItemProps: Partial<ListItemProps> = {
|
|
160
|
+
const defaultItemProps: Partial<ListItemProps> = {
|
|
161
|
+
withTextWrapper: true,
|
|
162
|
+
};
|
|
160
163
|
|
|
161
164
|
const getListMarker = (
|
|
162
165
|
type: 'ordered' | 'unordered',
|
|
@@ -239,7 +242,7 @@ const ListRoot = forwardRef<any, ListProps>((props, ref) => {
|
|
|
239
242
|
});
|
|
240
243
|
|
|
241
244
|
export const ListItem = forwardRef<any, ListItemProps>((props, ref) => {
|
|
242
|
-
const { children, icon: itemIcon, style, __index, ...others} = {
|
|
245
|
+
const { children, icon: itemIcon, style, __index, withTextWrapper: shouldWrapInText, ...others} = {
|
|
243
246
|
...defaultItemProps,
|
|
244
247
|
...props,
|
|
245
248
|
};
|
|
@@ -271,11 +274,7 @@ export const ListItem = forwardRef<any, ListItemProps>((props, ref) => {
|
|
|
271
274
|
<BoxView ref={ref} style={sx(styles.item, style)} {...others}>
|
|
272
275
|
<BoxView style={styles.icon}>{renderIcon()}</BoxView>
|
|
273
276
|
<BoxView style={styles.content}>
|
|
274
|
-
{
|
|
275
|
-
<Text style={styles.contentText}>{children}</Text>
|
|
276
|
-
) : (
|
|
277
|
-
children
|
|
278
|
-
)}
|
|
277
|
+
{withTextWrapper(children, shouldWrapInText, styles.contentText)}
|
|
279
278
|
</BoxView>
|
|
280
279
|
</BoxView>
|
|
281
280
|
);
|
|
@@ -2,8 +2,9 @@ import React, { forwardRef } from 'react';
|
|
|
2
2
|
import { Text } from '../Text';
|
|
3
3
|
import type { TextProps } from '../Text';
|
|
4
4
|
import { useTheme } from '../../theme/theme-provider';
|
|
5
|
+
import type { WithTextWrapperProps } from '../../theme/utils/withTextWrapper';
|
|
5
6
|
|
|
6
|
-
export interface MarkProps extends TextProps {
|
|
7
|
+
export interface MarkProps extends TextProps, WithTextWrapperProps {
|
|
7
8
|
/** Background color key from theme.colors or CSS color value */
|
|
8
9
|
color?: string;
|
|
9
10
|
|
|
@@ -16,7 +17,7 @@ export interface MarkProps extends TextProps {
|
|
|
16
17
|
* Default background is yellow
|
|
17
18
|
*/
|
|
18
19
|
export const Mark = forwardRef<any, MarkProps>((props, ref) => {
|
|
19
|
-
const { children, color = 'yellow', style, ...others} = props;
|
|
20
|
+
const { children, color = 'yellow', style, withTextWrapper: shouldWrapInText = true, ...others} = props;
|
|
20
21
|
|
|
21
22
|
const theme = useTheme();
|
|
22
23
|
|
|
@@ -30,6 +31,10 @@ export const Mark = forwardRef<any, MarkProps>((props, ref) => {
|
|
|
30
31
|
return color;
|
|
31
32
|
};
|
|
32
33
|
|
|
34
|
+
if (!shouldWrapInText) {
|
|
35
|
+
return children;
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
return (
|
|
34
39
|
<Text
|
|
35
40
|
ref={ref}
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
Modal,
|
|
7
7
|
} from 'react-native';
|
|
8
8
|
import { BoxView } from '../BoxView';
|
|
9
|
-
import { Text } from '../Text';
|
|
10
9
|
import { Divider } from '../Divider';
|
|
11
10
|
import type {
|
|
12
11
|
DefaultProps,
|
|
@@ -15,6 +14,7 @@ import type {
|
|
|
15
14
|
} from '../../theme/types';
|
|
16
15
|
import { useComponentDefaultProps } from '../../theme/theme-provider';
|
|
17
16
|
import { createStyles } from '../../theme';
|
|
17
|
+
import { withTextWrapper, type WithTextWrapperProps } from '../../theme/utils/withTextWrapper';
|
|
18
18
|
|
|
19
19
|
export interface MenuProps extends DefaultProps {
|
|
20
20
|
/** Controlled opened state */
|
|
@@ -68,7 +68,7 @@ export interface MenuDropdownProps extends DefaultProps {
|
|
|
68
68
|
style?: any;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export interface MenuItemProps extends DefaultProps {
|
|
71
|
+
export interface MenuItemProps extends DefaultProps, WithTextWrapperProps {
|
|
72
72
|
/** Item icon */
|
|
73
73
|
icon?: React.ReactNode;
|
|
74
74
|
|
|
@@ -91,7 +91,7 @@ export interface MenuItemProps extends DefaultProps {
|
|
|
91
91
|
style?: any;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export interface MenuLabelProps extends DefaultProps {
|
|
94
|
+
export interface MenuLabelProps extends DefaultProps, WithTextWrapperProps {
|
|
95
95
|
children: React.ReactNode;
|
|
96
96
|
style?: any;
|
|
97
97
|
}
|
|
@@ -198,6 +198,7 @@ const defaultMenuProps: Partial<MenuProps> = {
|
|
|
198
198
|
|
|
199
199
|
const defaultItemProps: Partial<MenuItemProps> = {
|
|
200
200
|
disabled: false,
|
|
201
|
+
withTextWrapper: true,
|
|
201
202
|
};
|
|
202
203
|
|
|
203
204
|
const MenuTarget: React.FC<MenuTargetProps> = ({ children }) => {
|
|
@@ -276,7 +277,7 @@ const MenuDropdown: React.FC<MenuDropdownProps> = ({ children, style, ...others
|
|
|
276
277
|
};
|
|
277
278
|
|
|
278
279
|
const MenuItem = forwardRef<any, MenuItemProps>((props, ref) => {
|
|
279
|
-
const { icon, color, children, onPress, disabled, rightSection, style, ...others } =
|
|
280
|
+
const { icon, color, children, onPress, disabled, rightSection, style, withTextWrapper: shouldWrapInText, ...others } =
|
|
280
281
|
useComponentDefaultProps('MenuItem', defaultItemProps, props);
|
|
281
282
|
|
|
282
283
|
const { setOpened, closeOnItemClick } = useMenuContext();
|
|
@@ -307,19 +308,19 @@ const MenuItem = forwardRef<any, MenuItemProps>((props, ref) => {
|
|
|
307
308
|
{...others}
|
|
308
309
|
>
|
|
309
310
|
{icon && <BoxView style={styles.icon}>{icon}</BoxView>}
|
|
310
|
-
|
|
311
|
+
{withTextWrapper(children, shouldWrapInText, styles.label)}
|
|
311
312
|
{rightSection && <BoxView style={styles.rightSection}>{rightSection}</BoxView>}
|
|
312
313
|
</TouchableOpacity>
|
|
313
314
|
);
|
|
314
315
|
});
|
|
315
316
|
|
|
316
317
|
const MenuLabel = forwardRef<any, MenuLabelProps>((props, ref) => {
|
|
317
|
-
const { children, style, ...others } = props;
|
|
318
|
+
const { children, style, withTextWrapper: shouldWrapInText = true, ...others } = props;
|
|
318
319
|
const { styles, sx } = useLabelStyles({}, { name: 'MenuLabel' }) as any;
|
|
319
320
|
|
|
320
321
|
return (
|
|
321
322
|
<BoxView ref={ref} style={sx(styles.label, style)} {...others}>
|
|
322
|
-
|
|
323
|
+
{withTextWrapper(children, shouldWrapInText, styles.label)}
|
|
323
324
|
</BoxView>
|
|
324
325
|
);
|
|
325
326
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import { UnstyledButton } from '../UnstyledButton';
|
|
3
3
|
import { BoxView } from '../BoxView';
|
|
4
|
-
import { Text } from '../Text';
|
|
5
4
|
import type {
|
|
6
5
|
DefaultProps,
|
|
7
6
|
MantineColor,
|
|
@@ -10,8 +9,9 @@ import type {
|
|
|
10
9
|
import { useComponentDefaultProps } from '../../theme/theme-provider';
|
|
11
10
|
import { createStyles } from '../../theme';
|
|
12
11
|
import { rem } from '../../theme/utils/rem';
|
|
12
|
+
import { withTextWrapper, type WithTextWrapperProps } from '../../theme/utils/withTextWrapper';
|
|
13
13
|
|
|
14
|
-
export interface NavLinkProps extends DefaultProps {
|
|
14
|
+
export interface NavLinkProps extends DefaultProps, WithTextWrapperProps {
|
|
15
15
|
/** Link label */
|
|
16
16
|
label?: React.ReactNode;
|
|
17
17
|
|
|
@@ -156,6 +156,7 @@ const defaultProps: Partial<NavLinkProps> = {
|
|
|
156
156
|
active: false,
|
|
157
157
|
disabled: false,
|
|
158
158
|
disableIfNoPress: true,
|
|
159
|
+
withTextWrapper: true,
|
|
159
160
|
};
|
|
160
161
|
|
|
161
162
|
export const NavLink = forwardRef<any, NavLinkProps>((props, ref) => {
|
|
@@ -172,6 +173,7 @@ export const NavLink = forwardRef<any, NavLinkProps>((props, ref) => {
|
|
|
172
173
|
onPress,
|
|
173
174
|
style,
|
|
174
175
|
disableIfNoPress,
|
|
176
|
+
withTextWrapper: shouldWrapInText,
|
|
175
177
|
...others
|
|
176
178
|
} = useComponentDefaultProps('NavLink', defaultProps, props);
|
|
177
179
|
|
|
@@ -192,8 +194,8 @@ export const NavLink = forwardRef<any, NavLinkProps>((props, ref) => {
|
|
|
192
194
|
>
|
|
193
195
|
{icon && <BoxView style={styles.icon}>{icon}</BoxView>}
|
|
194
196
|
<BoxView style={styles.body}>
|
|
195
|
-
{label &&
|
|
196
|
-
{description &&
|
|
197
|
+
{label && withTextWrapper(label, shouldWrapInText, styles.label)}
|
|
198
|
+
{description && withTextWrapper(description, shouldWrapInText, styles.description)}
|
|
197
199
|
</BoxView>
|
|
198
200
|
{rightSection && <BoxView style={styles.rightSection}>{rightSection}</BoxView>}
|
|
199
201
|
</UnstyledButton>
|