@tecsinapse/react-core 1.16.1 → 1.16.2
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 +11 -0
- package/dist/components/atoms/Text/Text.d.ts +2 -0
- package/dist/components/atoms/Text/Text.js +7 -2
- package/dist/components/atoms/Text/Text.js.map +1 -1
- package/dist/components/atoms/Text/functions.d.ts +2 -0
- package/dist/components/atoms/Text/functions.js +13 -0
- package/dist/components/atoms/Text/functions.js.map +1 -0
- package/dist/components/atoms/Text/styled.js +3 -0
- package/dist/components/atoms/Text/styled.js.map +1 -1
- package/dist/types/defaults.d.ts +2 -0
- package/package.json +2 -2
- package/src/components/atoms/Text/Text.tsx +7 -1
- package/src/components/atoms/Text/functions.ts +8 -0
- package/src/components/atoms/Text/styled.ts +1 -0
- package/src/types/defaults.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.16.2](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.16.1...@tecsinapse/react-core@1.16.2) (2022-06-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add capital option to text component ([56821ee](https://github.com/tecsinapse/design-system/commit/56821ee96eefc13a0b93d9b8b2d61af1be65e705))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.16.1](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.16.0...@tecsinapse/react-core@1.16.1) (2022-05-24)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @tecsinapse/react-core
|
|
@@ -10,6 +10,8 @@ export interface TextProps {
|
|
|
10
10
|
colorTone?: ColorGradationType;
|
|
11
11
|
numberOfLines?: number;
|
|
12
12
|
ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip';
|
|
13
|
+
textTransform?: 'none' | 'uppercase' | 'lowercase' | 'capitalize';
|
|
14
|
+
capitalFirst?: boolean;
|
|
13
15
|
style?: StyleProp<TextStyle>;
|
|
14
16
|
}
|
|
15
17
|
declare const Text: FC<TextProps>;
|
|
@@ -7,6 +7,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
7
7
|
|
|
8
8
|
var _styled = require("./styled");
|
|
9
9
|
|
|
10
|
+
var _functions = require("./functions");
|
|
11
|
+
|
|
10
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
13
|
|
|
12
14
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -21,6 +23,8 @@ const Text = ({
|
|
|
21
23
|
typography = 'base',
|
|
22
24
|
numberOfLines,
|
|
23
25
|
ellipsizeMode,
|
|
26
|
+
textTransform = 'none',
|
|
27
|
+
capitalFirst = false,
|
|
24
28
|
...rest
|
|
25
29
|
}) => {
|
|
26
30
|
return _react.default.createElement(_styled.StyledColoredText, _extends({}, rest, {
|
|
@@ -31,8 +35,9 @@ const Text = ({
|
|
|
31
35
|
fontWeight: fontWeight,
|
|
32
36
|
typography: typography,
|
|
33
37
|
numberOfLines: numberOfLines,
|
|
34
|
-
ellipsizeMode: ellipsizeMode
|
|
35
|
-
|
|
38
|
+
ellipsizeMode: ellipsizeMode,
|
|
39
|
+
textTransform: textTransform
|
|
40
|
+
}), (0, _functions.getLabel)(children, capitalFirst));
|
|
36
41
|
};
|
|
37
42
|
|
|
38
43
|
var _default = Text;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/atoms/Text/Text.tsx"],"names":["Text","children","style","fontColor","colorTone","colorVariant","fontWeight","typography","numberOfLines","ellipsizeMode","rest"],"mappings":";;;;;AAAA;;AAUA;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/atoms/Text/Text.tsx"],"names":["Text","children","style","fontColor","colorTone","colorVariant","fontWeight","typography","numberOfLines","ellipsizeMode","textTransform","capitalFirst","rest"],"mappings":";;;;;AAAA;;AAUA;;AACA;;;;;;AAuBA,MAAMA,IAAmB,GAAG,CAAC;AAC3BC,EAAAA,QAD2B;AAE3BC,EAAAA,KAF2B;AAG3BC,EAAAA,SAAS,GAAG,MAHe;AAI3BC,EAAAA,SAAS,GAAG,QAJe;AAK3BC,EAAAA,YAL2B;AAM3BC,EAAAA,UAAU,GAAG,SANc;AAO3BC,EAAAA,UAAU,GAAG,MAPc;AAQ3BC,EAAAA,aAR2B;AAS3BC,EAAAA,aAT2B;AAU3BC,EAAAA,aAAa,GAAG,MAVW;AAW3BC,EAAAA,YAAY,GAAG,KAXY;AAY3B,KAAGC;AAZwB,CAAD,KAaT;AACjB,SACE,6BAAC,yBAAD,eACMA,IADN;AAEE,IAAA,KAAK,EAAEV,KAFT;AAGE,IAAA,SAAS,EAAEC,SAHb;AAIE,IAAA,SAAS,EAAEC,SAJb;AAKE,IAAA,YAAY,EAAEC,YALhB;AAME,IAAA,UAAU,EAAEC,UANd;AAOE,IAAA,UAAU,EAAEC,UAPd;AAQE,IAAA,aAAa,EAAEC,aARjB;AASE,IAAA,aAAa,EAAEC,aATjB;AAUE,IAAA,aAAa,EAAEC;AAVjB,MAYG,yBAAST,QAAT,EAAmBU,YAAnB,CAZH,CADF;AAgBD,CA9BD;;eAgCeX,I","sourcesContent":["import React, { FC } from 'react';\nimport {\n ColorGradationType,\n ColorType,\n FontColorType,\n FontStackType,\n FontWeightType,\n TypographyVariationType,\n} from '@tecsinapse/react-core';\nimport { StyleProp, TextStyle } from 'react-native';\nimport { StyledColoredText } from './styled';\nimport { getLabel } from './functions';\n\nexport interface TextProps {\n /** Font theme text color */\n fontColor?: FontColorType;\n /** Font theme weight */\n fontWeight?: FontWeightType;\n /** Font theme sizes */\n typography?: TypographyVariationType;\n /** Font theme stack */\n fontStack?: FontStackType;\n /** Palette theme colors. You can specify this prop to override theme fontColor */\n colorVariant?: ColorType;\n /** Palette theme colors gradation */\n colorTone?: ColorGradationType;\n numberOfLines?: number;\n ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip';\n textTransform?: 'none' | 'uppercase' | 'lowercase' | 'capitalize';\n capitalFirst?: boolean;\n style?: StyleProp<TextStyle>;\n}\n\n/** NOTE: When using colors, be careful to not override fontColor by using colorVariant and colorTone, referent to theme colors and not text colors. */\nconst Text: FC<TextProps> = ({\n children,\n style,\n fontColor = 'dark',\n colorTone = 'medium',\n colorVariant,\n fontWeight = 'regular',\n typography = 'base',\n numberOfLines,\n ellipsizeMode,\n textTransform = 'none',\n capitalFirst = false,\n ...rest\n}): JSX.Element => {\n return (\n <StyledColoredText\n {...rest}\n style={style}\n fontColor={fontColor}\n colorTone={colorTone}\n colorVariant={colorVariant}\n fontWeight={fontWeight}\n typography={typography}\n numberOfLines={numberOfLines}\n ellipsizeMode={ellipsizeMode}\n textTransform={textTransform}\n >\n {getLabel(children, capitalFirst)}\n </StyledColoredText>\n );\n};\n\nexport default Text;\n"],"file":"Text.js"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.getLabel = exports.getFirstCapitalCharacter = void 0;
|
|
5
|
+
|
|
6
|
+
const getFirstCapitalCharacter = value => value.charAt(0).toUpperCase().concat(value.slice(1));
|
|
7
|
+
|
|
8
|
+
exports.getFirstCapitalCharacter = getFirstCapitalCharacter;
|
|
9
|
+
|
|
10
|
+
const getLabel = (children, capitalFirst) => typeof children === 'string' && capitalFirst ? getFirstCapitalCharacter(children) : children;
|
|
11
|
+
|
|
12
|
+
exports.getLabel = getLabel;
|
|
13
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/atoms/Text/functions.ts"],"names":["getFirstCapitalCharacter","value","charAt","toUpperCase","concat","slice","getLabel","children","capitalFirst"],"mappings":";;;;;AAAO,MAAMA,wBAAwB,GAAIC,KAAD,IACtCA,KAAK,CAACC,MAAN,CAAa,CAAb,EAAgBC,WAAhB,GAA8BC,MAA9B,CAAqCH,KAAK,CAACI,KAAN,CAAY,CAAZ,CAArC,CADK;;;;AAIA,MAAMC,QAAQ,GAAG,CAACC,QAAD,EAAWC,YAAX,KACtB,OAAOD,QAAP,KAAoB,QAApB,IAAgCC,YAAhC,GACIR,wBAAwB,CAACO,QAAD,CAD5B,GAEIA,QAHC","sourcesContent":["export const getFirstCapitalCharacter = (value: string): string =>\n value.charAt(0).toUpperCase().concat(value.slice(1));\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport const getLabel = (children, capitalFirst: boolean) =>\n typeof children === 'string' && capitalFirst\n ? getFirstCapitalCharacter(children)\n : children;\n"],"file":"functions.js"}
|
|
@@ -32,6 +32,9 @@ const StyledText = (0, _native.default)(_reactNative.Text)`
|
|
|
32
32
|
theme,
|
|
33
33
|
fontStack = 'default'
|
|
34
34
|
}) => `'${theme.font.stack[fontStack]}'`};
|
|
35
|
+
text-transform: ${({
|
|
36
|
+
textTransform = 'none'
|
|
37
|
+
}) => `${textTransform}`};
|
|
35
38
|
`;
|
|
36
39
|
exports.StyledText = StyledText;
|
|
37
40
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/atoms/Text/styled.ts"],"names":["StyledText","RNText","theme","fontColor","font","color","fontWeight","weight","typography","fontSize","lineHeight","fontStack","stack","colorStyles","colorVariant","colorTone","StyledColoredText"],"mappings":";;;;;AAAA;;AAEA;;;;;;AAEO,MAAMA,UAAU,GAAG,qBAAOC,iBAAP,CAAgD;AAC1E,WAAW,CAAC;AAAEC,EAAAA,KAAF;AAASC,EAAAA,SAAS,GAAG;AAArB,CAAD,KAAmCD,KAAK,CAACE,IAAN,CAAWC,KAAX,CAAiBF,SAAjB,CAA4B;AAC1E,iBAAiB,CAAC;AAAED,EAAAA,KAAF;AAASI,EAAAA,UAAU,GAAG;AAAtB,CAAD,KACbJ,KAAK,CAACE,IAAN,CAAWG,MAAX,CAAkBD,UAAlB,CAA8B;AAClC,eAAe,CAAC;AAAEJ,EAAAA,KAAF;AAASM,EAAAA,UAAU,GAAG;AAAtB,CAAD,KACXN,KAAK,CAACM,UAAN,CAAiBA,UAAjB,EAA6BC,QAAS;AAC1C,iBAAiB,CAAC;AAAEP,EAAAA,KAAF;AAASM,EAAAA,UAAU,GAAG;AAAtB,CAAD,KACbN,KAAK,CAACM,UAAN,CAAiBA,UAAjB,EAA6BE,UAAW;AAC5C,iBAAiB,CAAC;AAAER,EAAAA,KAAF;AAASS,EAAAA,SAAS,GAAG;AAArB,CAAD,KACZ,IAAGT,KAAK,CAACE,IAAN,CAAWQ,KAAX,CAAiBD,SAAjB,CAA4B,GAAG;AACvC,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/atoms/Text/styled.ts"],"names":["StyledText","RNText","theme","fontColor","font","color","fontWeight","weight","typography","fontSize","lineHeight","fontStack","stack","textTransform","colorStyles","colorVariant","colorTone","StyledColoredText"],"mappings":";;;;;AAAA;;AAEA;;;;;;AAEO,MAAMA,UAAU,GAAG,qBAAOC,iBAAP,CAAgD;AAC1E,WAAW,CAAC;AAAEC,EAAAA,KAAF;AAASC,EAAAA,SAAS,GAAG;AAArB,CAAD,KAAmCD,KAAK,CAACE,IAAN,CAAWC,KAAX,CAAiBF,SAAjB,CAA4B;AAC1E,iBAAiB,CAAC;AAAED,EAAAA,KAAF;AAASI,EAAAA,UAAU,GAAG;AAAtB,CAAD,KACbJ,KAAK,CAACE,IAAN,CAAWG,MAAX,CAAkBD,UAAlB,CAA8B;AAClC,eAAe,CAAC;AAAEJ,EAAAA,KAAF;AAASM,EAAAA,UAAU,GAAG;AAAtB,CAAD,KACXN,KAAK,CAACM,UAAN,CAAiBA,UAAjB,EAA6BC,QAAS;AAC1C,iBAAiB,CAAC;AAAEP,EAAAA,KAAF;AAASM,EAAAA,UAAU,GAAG;AAAtB,CAAD,KACbN,KAAK,CAACM,UAAN,CAAiBA,UAAjB,EAA6BE,UAAW;AAC5C,iBAAiB,CAAC;AAAER,EAAAA,KAAF;AAASS,EAAAA,SAAS,GAAG;AAArB,CAAD,KACZ,IAAGT,KAAK,CAACE,IAAN,CAAWQ,KAAX,CAAiBD,SAAjB,CAA4B,GAAG;AACvC,oBAAoB,CAAC;AAAEE,EAAAA,aAAa,GAAG;AAAlB,CAAD,KAAiC,GAAEA,aAAc,EAAE;AACvE,CAXO;;;AAaP,MAAMC,WAAW,GAAG,CAAC;AACnBC,EAAAA,YADmB;AAEnBC,EAAAA,SAFmB;AAGnBd,EAAAA;AAHmB,CAAD,KAKlBa,YAAY,IACZC,SADA,IAEA,gBAAI;AACN,aAAad,KAAK,CAACG,KAAN,CAAYU,YAAZ,EAA0BC,SAA1B,CAAqC;AAClD,GATA;;AAWO,MAAMC,iBAAiB,GAAG,qBAAOjB,UAAP,EAE/Bc,WAF+B,CAA1B","sourcesContent":["import styled, { css } from '@emotion/native';\nimport { StyleProps, TextProps } from '@tecsinapse/react-core';\nimport { Text as RNText } from 'react-native';\n\nexport const StyledText = styled(RNText)<TextProps & Partial<StyleProps>>`\n color: ${({ theme, fontColor = 'dark' }) => theme.font.color[fontColor]};\n font-weight: ${({ theme, fontWeight = 'regular' }) =>\n theme.font.weight[fontWeight]};\n font-size: ${({ theme, typography = 'base' }) =>\n theme.typography[typography].fontSize};\n line-height: ${({ theme, typography = 'base' }) =>\n theme.typography[typography].lineHeight};\n font-family: ${({ theme, fontStack = 'default' }) =>\n `'${theme.font.stack[fontStack]}'`};\n text-transform: ${({ textTransform = 'none' }) => `${textTransform}`};\n`;\n\nconst colorStyles = ({\n colorVariant,\n colorTone,\n theme,\n}: TextProps & StyleProps) =>\n colorVariant &&\n colorTone &&\n css`\n color: ${theme.color[colorVariant][colorTone]};\n `;\n\nexport const StyledColoredText = styled(StyledText)<\n TextProps & Partial<StyleProps>\n>(colorStyles);\n"],"file":"styled.js"}
|
package/dist/types/defaults.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare type Color = {
|
|
2
3
|
primary: ColorGradation;
|
|
3
4
|
secondary: ColorGradation;
|
|
@@ -111,6 +112,7 @@ export declare type ThemeProp = {
|
|
|
111
112
|
zIndex: ZIndex;
|
|
112
113
|
};
|
|
113
114
|
export interface ThemeProviderProps {
|
|
115
|
+
children?: React.ReactNode;
|
|
114
116
|
theme: ThemeProp;
|
|
115
117
|
}
|
|
116
118
|
export declare type StyleProps = ThemeProviderProps;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/react-core",
|
|
3
3
|
"description": "TecSinapse hybrid React components",
|
|
4
|
-
"version": "1.16.
|
|
4
|
+
"version": "1.16.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"react-native": "^0.64.0",
|
|
32
32
|
"react-native-vector-icons": "^8.1.0 || ^9.0.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "0935a2a1210e341648136e3247ec54c41815142f"
|
|
35
35
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from '@tecsinapse/react-core';
|
|
10
10
|
import { StyleProp, TextStyle } from 'react-native';
|
|
11
11
|
import { StyledColoredText } from './styled';
|
|
12
|
+
import { getLabel } from './functions';
|
|
12
13
|
|
|
13
14
|
export interface TextProps {
|
|
14
15
|
/** Font theme text color */
|
|
@@ -25,6 +26,8 @@ export interface TextProps {
|
|
|
25
26
|
colorTone?: ColorGradationType;
|
|
26
27
|
numberOfLines?: number;
|
|
27
28
|
ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip';
|
|
29
|
+
textTransform?: 'none' | 'uppercase' | 'lowercase' | 'capitalize';
|
|
30
|
+
capitalFirst?: boolean;
|
|
28
31
|
style?: StyleProp<TextStyle>;
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -39,6 +42,8 @@ const Text: FC<TextProps> = ({
|
|
|
39
42
|
typography = 'base',
|
|
40
43
|
numberOfLines,
|
|
41
44
|
ellipsizeMode,
|
|
45
|
+
textTransform = 'none',
|
|
46
|
+
capitalFirst = false,
|
|
42
47
|
...rest
|
|
43
48
|
}): JSX.Element => {
|
|
44
49
|
return (
|
|
@@ -52,8 +57,9 @@ const Text: FC<TextProps> = ({
|
|
|
52
57
|
typography={typography}
|
|
53
58
|
numberOfLines={numberOfLines}
|
|
54
59
|
ellipsizeMode={ellipsizeMode}
|
|
60
|
+
textTransform={textTransform}
|
|
55
61
|
>
|
|
56
|
-
{children}
|
|
62
|
+
{getLabel(children, capitalFirst)}
|
|
57
63
|
</StyledColoredText>
|
|
58
64
|
);
|
|
59
65
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const getFirstCapitalCharacter = (value: string): string =>
|
|
2
|
+
value.charAt(0).toUpperCase().concat(value.slice(1));
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
5
|
+
export const getLabel = (children, capitalFirst: boolean) =>
|
|
6
|
+
typeof children === 'string' && capitalFirst
|
|
7
|
+
? getFirstCapitalCharacter(children)
|
|
8
|
+
: children;
|
|
@@ -12,6 +12,7 @@ export const StyledText = styled(RNText)<TextProps & Partial<StyleProps>>`
|
|
|
12
12
|
theme.typography[typography].lineHeight};
|
|
13
13
|
font-family: ${({ theme, fontStack = 'default' }) =>
|
|
14
14
|
`'${theme.font.stack[fontStack]}'`};
|
|
15
|
+
text-transform: ${({ textTransform = 'none' }) => `${textTransform}`};
|
|
15
16
|
`;
|
|
16
17
|
|
|
17
18
|
const colorStyles = ({
|