@fountain-ui/core 3.0.0-alpha.46 → 3.0.0-alpha.48
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/build/commonjs/Chip/Chip.js +4 -2
- package/build/commonjs/Chip/Chip.js.map +1 -1
- package/build/commonjs/Chip/ChipProps.js +3 -1
- package/build/commonjs/Chip/ChipProps.js.map +1 -1
- package/build/commonjs/Chip/index.js +6 -0
- package/build/commonjs/Chip/index.js.map +1 -1
- package/build/commonjs/Chip/useChipStyle.js +12 -5
- package/build/commonjs/Chip/useChipStyle.js.map +1 -1
- package/build/commonjs/Radio/Radio.js +6 -3
- package/build/commonjs/Radio/Radio.js.map +1 -1
- package/build/commonjs/TextField/TextField.js +9 -2
- package/build/commonjs/TextField/TextField.js.map +1 -1
- package/build/commonjs/TextField/TextFieldProps.js +3 -1
- package/build/commonjs/TextField/TextFieldProps.js.map +1 -1
- package/build/commonjs/TextField/useVariantStyleMap.js +29 -9
- package/build/commonjs/TextField/useVariantStyleMap.js.map +1 -1
- package/build/module/Chip/Chip.js +4 -2
- package/build/module/Chip/Chip.js.map +1 -1
- package/build/module/Chip/ChipProps.js +1 -0
- package/build/module/Chip/ChipProps.js.map +1 -1
- package/build/module/Chip/index.js +1 -1
- package/build/module/Chip/index.js.map +1 -1
- package/build/module/Chip/useChipStyle.js +12 -5
- package/build/module/Chip/useChipStyle.js.map +1 -1
- package/build/module/Radio/Radio.js +6 -3
- package/build/module/Radio/Radio.js.map +1 -1
- package/build/module/TextField/TextField.js +9 -2
- package/build/module/TextField/TextField.js.map +1 -1
- package/build/module/TextField/TextFieldProps.js +1 -0
- package/build/module/TextField/TextFieldProps.js.map +1 -1
- package/build/module/TextField/useVariantStyleMap.js +28 -9
- package/build/module/TextField/useVariantStyleMap.js.map +1 -1
- package/build/typescript/Chip/ChipProps.d.ts +7 -0
- package/build/typescript/Chip/index.d.ts +2 -2
- package/build/typescript/Chip/useChipStyle.d.ts +2 -2
- package/build/typescript/TextField/TextFieldProps.d.ts +13 -0
- package/build/typescript/TextField/useVariantStyleMap.d.ts +2 -2
- package/package.json +2 -2
- package/src/Chip/Chip.tsx +5 -2
- package/src/Chip/ChipProps.ts +9 -0
- package/src/Chip/index.ts +2 -2
- package/src/Chip/useChipStyle.ts +24 -8
- package/src/Radio/Radio.tsx +6 -3
- package/src/TextField/TextField.tsx +12 -1
- package/src/TextField/TextFieldProps.ts +16 -0
- package/src/TextField/useVariantStyleMap.ts +36 -11
|
@@ -34,8 +34,10 @@ function Chip(props) {
|
|
|
34
34
|
startElement: startElementProp,
|
|
35
35
|
startElementVariant = 'default',
|
|
36
36
|
style: styleProp,
|
|
37
|
+
variant = 'filled',
|
|
37
38
|
...otherProps
|
|
38
39
|
} = props;
|
|
40
|
+
const isSelected = variant === 'outlined' ? false : selected;
|
|
39
41
|
const {
|
|
40
42
|
container: containerStyle,
|
|
41
43
|
closeButtonContainer: closeButtonContainerStyle,
|
|
@@ -43,7 +45,7 @@ function Chip(props) {
|
|
|
43
45
|
label: labelStyle,
|
|
44
46
|
startElement: startElementStyle,
|
|
45
47
|
startElementContainer: startElementContainerStyle
|
|
46
|
-
} = (0, _useChipStyle.default)(size, startElementVariant, color,
|
|
48
|
+
} = (0, _useChipStyle.default)(size, startElementVariant, color, isSelected, variant);
|
|
47
49
|
const chipStyle = (0, _styles.css)([containerStyle, styleProp]);
|
|
48
50
|
|
|
49
51
|
const startElement = /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
@@ -60,7 +62,7 @@ function Chip(props) {
|
|
|
60
62
|
children: children,
|
|
61
63
|
numberOfLines: numberOfLines,
|
|
62
64
|
style: labelStyle
|
|
63
|
-
}),
|
|
65
|
+
}), isSelected ? /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
64
66
|
style: closeButtonContainerStyle
|
|
65
67
|
}, /*#__PURE__*/_react.default.createElement(_internal.ChipClose, {
|
|
66
68
|
color: 'baseInverse',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Chip","props","children","color","numberOfLines","onPress","selected","size","startElement","startElementProp","startElementVariant","style","styleProp","otherProps","container","containerStyle","closeButtonContainer","closeButtonContainerStyle","closeIconSize","label","labelStyle","startElementStyle","startElementContainer","startElementContainerStyle","useChipStyle","chipStyle","css","cloneElementSafely","height","width"],"sources":["Chip.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, View } from 'react-native';\nimport ButtonBase from '../ButtonBase';\nimport { ChipClose } from '../internal';\nimport { css } from '../styles';\nimport { cloneElementSafely } from '../utils';\nimport type ChipProps from './ChipProps';\nimport type { ChipColor, ChipSize } from './ChipProps';\nimport useChipStyle from './useChipStyle';\n\nexport default function Chip(props: ChipProps) {\n const {\n children,\n color = 'default' as ChipColor,\n numberOfLines,\n onPress,\n selected = false,\n size = 'small' as ChipSize,\n startElement: startElementProp,\n startElementVariant = 'default',\n style: styleProp,\n ...otherProps\n } = props;\n\n const {\n container: containerStyle,\n closeButtonContainer: closeButtonContainerStyle,\n closeIconSize,\n label: labelStyle,\n startElement: startElementStyle,\n startElementContainer: startElementContainerStyle,\n } = useChipStyle(size, startElementVariant, color,
|
|
1
|
+
{"version":3,"names":["Chip","props","children","color","numberOfLines","onPress","selected","size","startElement","startElementProp","startElementVariant","style","styleProp","variant","otherProps","isSelected","container","containerStyle","closeButtonContainer","closeButtonContainerStyle","closeIconSize","label","labelStyle","startElementStyle","startElementContainer","startElementContainerStyle","useChipStyle","chipStyle","css","cloneElementSafely","height","width"],"sources":["Chip.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, View } from 'react-native';\nimport ButtonBase from '../ButtonBase';\nimport { ChipClose } from '../internal';\nimport { css } from '../styles';\nimport { cloneElementSafely } from '../utils';\nimport type ChipProps from './ChipProps';\nimport type { ChipColor, ChipSize } from './ChipProps';\nimport useChipStyle from './useChipStyle';\n\nexport default function Chip(props: ChipProps) {\n const {\n children,\n color = 'default' as ChipColor,\n numberOfLines,\n onPress,\n selected = false,\n size = 'small' as ChipSize,\n startElement: startElementProp,\n startElementVariant = 'default',\n style: styleProp,\n variant = 'filled',\n ...otherProps\n } = props;\n\n const isSelected = variant === 'outlined' ? false : selected;\n\n const {\n container: containerStyle,\n closeButtonContainer: closeButtonContainerStyle,\n closeIconSize,\n label: labelStyle,\n startElement: startElementStyle,\n startElementContainer: startElementContainerStyle,\n } = useChipStyle(size, startElementVariant, color, isSelected, variant);\n\n const chipStyle = css([\n containerStyle,\n styleProp,\n ]);\n\n const startElement = (\n <View style={startElementContainerStyle}>\n {cloneElementSafely(startElementProp, { style: startElementStyle })}\n </View>\n );\n\n return (\n <ButtonBase\n disabled={!onPress}\n onPress={onPress}\n style={chipStyle}\n {...otherProps}\n >\n {startElement}\n\n <Text\n children={children}\n numberOfLines={numberOfLines}\n style={labelStyle}\n />\n\n {isSelected ? (\n <View style={closeButtonContainerStyle}>\n <ChipClose\n color={'baseInverse'}\n height={closeIconSize?.height}\n width={closeIconSize?.width}\n />\n </View>\n ) : null}\n </ButtonBase>\n );\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;;;;;AAEe,SAASA,IAAT,CAAcC,KAAd,EAAgC;EAC3C,MAAM;IACFC,QADE;IAEFC,KAAK,GAAG,SAFN;IAGFC,aAHE;IAIFC,OAJE;IAKFC,QAAQ,GAAG,KALT;IAMFC,IAAI,GAAG,OANL;IAOFC,YAAY,EAAEC,gBAPZ;IAQFC,mBAAmB,GAAG,SARpB;IASFC,KAAK,EAAEC,SATL;IAUFC,OAAO,GAAG,QAVR;IAWF,GAAGC;EAXD,IAYFb,KAZJ;EAcA,MAAMc,UAAU,GAAGF,OAAO,KAAK,UAAZ,GAAyB,KAAzB,GAAiCP,QAApD;EAEA,MAAM;IACFU,SAAS,EAAEC,cADT;IAEFC,oBAAoB,EAAEC,yBAFpB;IAGFC,aAHE;IAIFC,KAAK,EAAEC,UAJL;IAKFd,YAAY,EAAEe,iBALZ;IAMFC,qBAAqB,EAAEC;EANrB,IAOF,IAAAC,qBAAA,EAAanB,IAAb,EAAmBG,mBAAnB,EAAwCP,KAAxC,EAA+CY,UAA/C,EAA2DF,OAA3D,CAPJ;EASA,MAAMc,SAAS,GAAG,IAAAC,WAAA,EAAI,CAClBX,cADkB,EAElBL,SAFkB,CAAJ,CAAlB;;EAKA,MAAMJ,YAAY,gBACd,6BAAC,iBAAD;IAAM,KAAK,EAAEiB;EAAb,GACK,IAAAI,yBAAA,EAAmBpB,gBAAnB,EAAqC;IAAEE,KAAK,EAAEY;EAAT,CAArC,CADL,CADJ;;EAMA,oBACI,6BAAC,mBAAD;IACI,QAAQ,EAAE,CAAClB,OADf;IAEI,OAAO,EAAEA,OAFb;IAGI,KAAK,EAAEsB;EAHX,GAIQb,UAJR,GAMKN,YANL,eAQI,6BAAC,iBAAD;IACI,QAAQ,EAAEN,QADd;IAEI,aAAa,EAAEE,aAFnB;IAGI,KAAK,EAAEkB;EAHX,EARJ,EAcKP,UAAU,gBACP,6BAAC,iBAAD;IAAM,KAAK,EAAEI;EAAb,gBACI,6BAAC,mBAAD;IACI,KAAK,EAAE,aADX;IAEI,MAAM,EAAEC,aAAF,aAAEA,aAAF,uBAAEA,aAAa,CAAEU,MAF3B;IAGI,KAAK,EAAEV,aAAF,aAAEA,aAAF,uBAAEA,aAAa,CAAEW;EAH1B,EADJ,CADO,GAQP,IAtBR,CADJ;AA0BH"}
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.chipStartElementVariants = exports.chipSizes = exports.chipColors = void 0;
|
|
6
|
+
exports.chipVariants = exports.chipStartElementVariants = exports.chipSizes = exports.chipColors = void 0;
|
|
7
7
|
const chipColors = ['default', 'white'];
|
|
8
8
|
exports.chipColors = chipColors;
|
|
9
9
|
const chipSizes = ['large', 'small'];
|
|
10
10
|
exports.chipSizes = chipSizes;
|
|
11
11
|
const chipStartElementVariants = ['default', 'avatar', 'image', 'icon'];
|
|
12
12
|
exports.chipStartElementVariants = chipStartElementVariants;
|
|
13
|
+
const chipVariants = ['filled', 'outlined'];
|
|
14
|
+
exports.chipVariants = chipVariants;
|
|
13
15
|
//# sourceMappingURL=ChipProps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["chipColors","chipSizes","chipStartElementVariants"],"sources":["ChipProps.ts"],"sourcesContent":["import React from 'react';\nimport { OverridableComponentProps } from '../types';\nimport type { ButtonBaseProps } from '../ButtonBase';\n\nexport const chipColors = ['default', 'white'] as const;\nexport type ChipColor = typeof chipColors[number];\n\nexport const chipSizes = ['large', 'small'] as const;\nexport type ChipSize = typeof chipSizes[number];\n\nexport const chipStartElementVariants = ['default', 'avatar', 'image', 'icon'] as const;\nexport type ChipStartElementVariant = typeof chipStartElementVariants[number];\n\nexport default interface ChipProps extends OverridableComponentProps<ButtonBaseProps, {\n /**\n * The content of the component.\n */\n children: string;\n\n /**\n * Set backgroundColor of the component.\n * @default 'default'\n */\n color?: ChipColor;\n\n /**\n * Number of lines of children.\n */\n numberOfLines?: number;\n\n /**\n * If `true`, showing a close icon and applying a highlighted style.\n */\n selected?: boolean;\n\n /**\n * Determines size of component.\n * @default 'small'\n */\n size?: ChipSize;\n\n /**\n * Element placed before the children.\n */\n startElement?: React.ReactElement;\n\n /**\n * Determines the style of the start element.\n */\n startElementVariant?: ChipStartElementVariant;\n}> {}\n"],"mappings":";;;;;;AAIO,MAAMA,UAAU,GAAG,CAAC,SAAD,EAAY,OAAZ,CAAnB;;AAGA,MAAMC,SAAS,GAAG,CAAC,OAAD,EAAU,OAAV,CAAlB;;AAGA,MAAMC,wBAAwB,GAAG,CAAC,SAAD,EAAY,QAAZ,EAAsB,OAAtB,EAA+B,MAA/B,CAAjC"}
|
|
1
|
+
{"version":3,"names":["chipColors","chipSizes","chipStartElementVariants","chipVariants"],"sources":["ChipProps.ts"],"sourcesContent":["import React from 'react';\nimport { OverridableComponentProps } from '../types';\nimport type { ButtonBaseProps } from '../ButtonBase';\n\nexport const chipColors = ['default', 'white'] as const;\nexport type ChipColor = typeof chipColors[number];\n\nexport const chipSizes = ['large', 'small'] as const;\nexport type ChipSize = typeof chipSizes[number];\n\nexport const chipStartElementVariants = ['default', 'avatar', 'image', 'icon'] as const;\nexport type ChipStartElementVariant = typeof chipStartElementVariants[number];\n\nexport const chipVariants = ['filled', 'outlined'] as const;\nexport type ChipVariant = typeof chipVariants[number];\n\nexport default interface ChipProps extends OverridableComponentProps<ButtonBaseProps, {\n /**\n * The content of the component.\n */\n children: string;\n\n /**\n * Set backgroundColor of the component.\n * @default 'default'\n */\n color?: ChipColor;\n\n /**\n * Number of lines of children.\n */\n numberOfLines?: number;\n\n /**\n * If `true`, showing a close icon and applying a highlighted style.\n */\n selected?: boolean;\n\n /**\n * Determines size of component.\n * @default 'small'\n */\n size?: ChipSize;\n\n /**\n * Element placed before the children.\n */\n startElement?: React.ReactElement;\n\n /**\n * Determines the visual style of the component.\n * @default 'filled'\n */\n variant?: ChipVariant;\n\n /**\n * Determines the style of the start element.\n */\n startElementVariant?: ChipStartElementVariant;\n}> {}\n"],"mappings":";;;;;;AAIO,MAAMA,UAAU,GAAG,CAAC,SAAD,EAAY,OAAZ,CAAnB;;AAGA,MAAMC,SAAS,GAAG,CAAC,OAAD,EAAU,OAAV,CAAlB;;AAGA,MAAMC,wBAAwB,GAAG,CAAC,SAAD,EAAY,QAAZ,EAAsB,OAAtB,EAA+B,MAA/B,CAAjC;;AAGA,MAAMC,YAAY,GAAG,CAAC,QAAD,EAAW,UAAX,CAArB"}
|
|
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "chipStartElementVariants", {
|
|
|
21
21
|
return _ChipProps.chipStartElementVariants;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "chipVariants", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _ChipProps.chipVariants;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
Object.defineProperty(exports, "default", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './Chip';\nexport type { default as ChipProps } from './ChipProps';\nexport { chipColors, chipSizes, chipStartElementVariants } from './ChipProps';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './Chip';\nexport type { default as ChipProps, ChipVariant } from './ChipProps';\nexport { chipColors, chipSizes, chipStartElementVariants, chipVariants } from './ChipProps';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA"}
|
|
@@ -31,26 +31,33 @@ const closeIconSize = {
|
|
|
31
31
|
}; // TODO: need to refactoring...
|
|
32
32
|
|
|
33
33
|
function useChipStyle(size, startElementVariant, color, selected) {
|
|
34
|
+
let variant = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'filled';
|
|
34
35
|
const theme = (0, _styles.useTheme)();
|
|
35
36
|
return (0, _react.useMemo)(() => {
|
|
36
37
|
var _variantStyleMap$star, _variantStyleMap$star2, _variantStyleMap$star3;
|
|
37
38
|
|
|
39
|
+
const isOutlined = variant === 'outlined';
|
|
40
|
+
const textColor = selected ? theme.palette.text.strongInverse : isOutlined ? theme.palette.text.base : theme.palette.text.strong;
|
|
38
41
|
const fontStyleMap = {
|
|
39
42
|
small: (0, _styles.createFontStyle)(theme, {
|
|
40
43
|
selector: typography => typography.caption1.medium,
|
|
41
|
-
color:
|
|
44
|
+
color: textColor
|
|
42
45
|
}),
|
|
43
46
|
large: (0, _styles.createFontStyle)(theme, {
|
|
44
47
|
selector: typography => typography.body2.medium,
|
|
45
|
-
color:
|
|
48
|
+
color: textColor
|
|
46
49
|
})
|
|
47
50
|
};
|
|
48
51
|
const baseContainerStyle = {
|
|
49
52
|
alignItems: 'center',
|
|
50
|
-
backgroundColor: selected ? theme.palette.fill.base : color === 'white' ? theme.palette.surface.base : theme.palette.fill.weaker,
|
|
53
|
+
backgroundColor: selected ? theme.palette.fill.base : isOutlined ? 'transparent' : color === 'white' ? theme.palette.surface.base : theme.palette.fill.weaker,
|
|
51
54
|
borderRadius: theme.shape.radius.full,
|
|
52
55
|
flexDirection: 'row',
|
|
53
|
-
overflow: 'hidden'
|
|
56
|
+
overflow: 'hidden',
|
|
57
|
+
...(isOutlined && {
|
|
58
|
+
borderWidth: 1,
|
|
59
|
+
borderColor: theme.palette.border.weak
|
|
60
|
+
})
|
|
54
61
|
};
|
|
55
62
|
const isLarge = size === 'large';
|
|
56
63
|
const variantStyleMap = {
|
|
@@ -124,6 +131,6 @@ function useChipStyle(size, startElementVariant, color, selected) {
|
|
|
124
131
|
startElement: (_variantStyleMap$star2 = variantStyleMap[startElementVariant]) === null || _variantStyleMap$star2 === void 0 ? void 0 : _variantStyleMap$star2.startElement,
|
|
125
132
|
startElementContainer: (_variantStyleMap$star3 = variantStyleMap[startElementVariant]) === null || _variantStyleMap$star3 === void 0 ? void 0 : _variantStyleMap$star3.startElementContainer
|
|
126
133
|
};
|
|
127
|
-
}, [theme, size, startElementVariant, color, selected]);
|
|
134
|
+
}, [theme, size, startElementVariant, color, selected, variant]);
|
|
128
135
|
}
|
|
129
136
|
//# sourceMappingURL=useChipStyle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["closeButtonContainerStyleMap","small","marginLeft","paddingTop","large","closeIconSize","height","width","useChipStyle","size","startElementVariant","color","selected","theme","useTheme","useMemo","fontStyleMap","createFontStyle","selector","typography","caption1","medium","palette","text","strongInverse","strong","body2","baseContainerStyle","alignItems","backgroundColor","fill","base","surface","weaker","borderRadius","shape","radius","full","flexDirection","overflow","isLarge","variantStyleMap","avatar","container","paddingLeft","spacing","paddingRight","paddingVertical","startElement","startElementContainer","marginRight","icon","justifyContent","image","default","paddingBottom","closeButtonContainer","label"],"sources":["useChipStyle.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { TextStyle } from 'react-native';\nimport type { FountainUiStyle } from '@fountain-ui/styles';\nimport type { SvgIconProps } from '../SvgIcon';\nimport { createFontStyle, useTheme } from '../styles';\nimport type { ChipColor, ChipSize, ChipStartElementVariant } from './ChipProps';\n\ninterface ChipStyle {\n container: FountainUiStyle;\n closeButtonContainer?: FountainUiStyle;\n closeIconSize?: Pick<SvgIconProps, 'height' | 'width'>;\n label: TextStyle;\n startElement?: FountainUiStyle;\n startElementContainer?: FountainUiStyle;\n}\n\ntype VariantStyleMap = Record<ChipStartElementVariant, Partial<ChipStyle>>;\n\nconst closeButtonContainerStyleMap: Record<ChipSize, FountainUiStyle> = {\n small: {\n marginLeft: 8,\n paddingTop: 1,\n },\n large: {\n marginLeft: 10,\n paddingTop: 1,\n },\n};\n\nconst closeIconSize: Record<ChipSize, ChipStyle['closeIconSize']> = {\n small: {\n height: 14,\n width: 8.17,\n },\n large: {\n height: 16,\n width: 9,\n },\n};\n\n// TODO: need to refactoring...\nexport default function useChipStyle(\n size: ChipSize,\n startElementVariant: ChipStartElementVariant,\n color: ChipColor,\n selected: boolean,\n): ChipStyle {\n const theme = useTheme();\n\n return useMemo<ChipStyle>(() => {\n const fontStyleMap: Record<ChipSize, TextStyle> = {\n small: createFontStyle(theme, {\n selector: (typography) => typography.caption1.medium,\n color: selected ? theme.palette.text.strongInverse : theme.palette.text.strong,\n }),\n large: createFontStyle(theme, {\n selector: (typography) => typography.body2.medium,\n color: selected ? theme.palette.text.strongInverse : theme.palette.text.strong,\n }),\n };\n\n const baseContainerStyle: FountainUiStyle = {\n alignItems: 'center',\n backgroundColor: selected ? theme.palette.fill.base\n : color === 'white'\n ? theme.palette.surface.base\n : theme.palette.fill.weaker,\n borderRadius: theme.shape.radius.full,\n flexDirection: 'row',\n overflow: 'hidden',\n };\n\n const isLarge = size === 'large';\n\n const variantStyleMap: VariantStyleMap = {\n avatar: {\n container: {\n paddingLeft: theme.spacing(isLarge ? 1.5 : 1.25),\n paddingRight: theme.spacing(isLarge ? 3.5 : 3),\n paddingVertical: theme.spacing(isLarge ? 1.25 : 1),\n },\n startElement: {\n borderRadius: theme.shape.radius.full,\n height: isLarge ? 26 : 23,\n width: isLarge ? 26 : 23,\n },\n startElementContainer: {\n marginRight: theme.spacing(isLarge ? 1.5 : 1.25),\n },\n },\n icon: {\n container: {\n paddingLeft: theme.spacing(1.5),\n paddingRight: theme.spacing(isLarge ? 3.5 : 3),\n paddingVertical: theme.spacing(isLarge ? 1.5 : 1.25),\n },\n startElement: {\n color: selected\n ? theme.palette.icon.strongInverse\n : theme.palette.icon.strong,\n height: isLarge ? 17 : 16,\n width: isLarge ? 17 : 16,\n },\n startElementContainer: {\n alignItems: 'center',\n height: isLarge ? 24 : 21,\n justifyContent: 'center',\n marginRight: theme.spacing(isLarge ? 1 : 0.75),\n width: isLarge ? 24 : 21,\n },\n },\n image: {\n container: {\n alignItems: 'center',\n paddingRight: theme.spacing(isLarge ? 3.5 : 3),\n },\n startElement: {\n borderRadius: theme.shape.radius.full,\n height: isLarge ? 36 : 31,\n width: isLarge ? 48 : 40,\n },\n startElementContainer: {\n marginRight: theme.spacing(1.5),\n },\n },\n default: {\n container: {\n paddingBottom: theme.spacing(1.75),\n paddingLeft: theme.spacing(isLarge ? 3.5 : 3),\n paddingRight: theme.spacing(isLarge ? 3.5 : 3),\n paddingTop: theme.spacing(1.5),\n },\n },\n };\n\n return {\n container: {\n ...baseContainerStyle,\n ...variantStyleMap[startElementVariant]?.container,\n ...(selected ? { paddingRight: theme.spacing(isLarge ? 2.5 : 2.25) } : {}),\n },\n closeButtonContainer: closeButtonContainerStyleMap[size],\n closeIconSize: closeIconSize[size],\n label: fontStyleMap[size],\n startElement: variantStyleMap[startElementVariant]?.startElement,\n startElementContainer: variantStyleMap[startElementVariant]?.startElementContainer,\n };\n }, [theme, size, startElementVariant, color, selected]);\n}\n"],"mappings":";;;;;;;AAAA;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N;UAGPM,YAAY,EAAEjC,KAAK,CAACgC,OAAN,CAAcL,OAAO,GAAG,GAAH,GAAS,CAA9B,CAHP;UAIPrC,UAAU,EAAEU,KAAK,CAACgC,OAAN,CAAc,GAAd;QAJL;MADN;IAnD4B,CAAzC;IA6DA,OAAO;MACHF,SAAS,EAAE,EACP,GAAGhB,kBADI;QAEP,6BAAGc,eAAe,CAAC/B,mBAAD,CAAlB,0DAAG,sBAAsCiC,SAAzC,CAFO;QAGP,IAAI/B,QAAQ,GAAG;UAAEkC,YAAY,EAAEjC,KAAK,CAACgC,OAAN,CAAcL,OAAO,GAAG,GAAH,GAAS,IAA9B;QAAhB,CAAH,GAA2D,EAAvE;MAHO,CADR;MAMHgB,oBAAoB,EAAExD,4BAA4B,CAACS,IAAD,CAN/C;MAOHJ,aAAa,EAAEA,aAAa,CAACI,IAAD,CAPzB;MAQHgD,KAAK,EAAEzC,YAAY,CAACP,IAAD,CARhB;MASHuC,YAAY,4BAAEP,eAAe,CAAC/B,mBAAD,CAAjB,2DAAE,uBAAsCsC,YATjD;MAUHC,qBAAqB,4BAAER,eAAe,CAAC/B,mBAAD,CAAjB,2DAAE,uBAAsCuC;IAV1D,CAAP;EAYH,CAlGM,EAkGJ,CAACpC,KAAD,EAAQJ,IAAR,EAAcC,mBAAd,EAAmCC,KAAnC,EAA0CC,QAA1C,CAlGI,CAAP;AAmGH"}
|
|
1
|
+
{"version":3,"names":["closeButtonContainerStyleMap","small","marginLeft","paddingTop","large","closeIconSize","height","width","useChipStyle","size","startElementVariant","color","selected","variant","theme","useTheme","useMemo","isOutlined","textColor","palette","text","strongInverse","base","strong","fontStyleMap","createFontStyle","selector","typography","caption1","medium","body2","baseContainerStyle","alignItems","backgroundColor","fill","surface","weaker","borderRadius","shape","radius","full","flexDirection","overflow","borderWidth","borderColor","border","weak","isLarge","variantStyleMap","avatar","container","paddingLeft","spacing","paddingRight","paddingVertical","startElement","startElementContainer","marginRight","icon","justifyContent","image","default","paddingBottom","closeButtonContainer","label"],"sources":["useChipStyle.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { TextStyle } from 'react-native';\nimport type { FountainUiStyle } from '@fountain-ui/styles';\nimport type { SvgIconProps } from '../SvgIcon';\nimport { createFontStyle, useTheme } from '../styles';\nimport type { ChipColor, ChipSize, ChipStartElementVariant, ChipVariant } from './ChipProps';\n\ninterface ChipStyle {\n container: FountainUiStyle;\n closeButtonContainer?: FountainUiStyle;\n closeIconSize?: Pick<SvgIconProps, 'height' | 'width'>;\n label: TextStyle;\n startElement?: FountainUiStyle;\n startElementContainer?: FountainUiStyle;\n}\n\ntype VariantStyleMap = Record<ChipStartElementVariant, Partial<ChipStyle>>;\n\nconst closeButtonContainerStyleMap: Record<ChipSize, FountainUiStyle> = {\n small: {\n marginLeft: 8,\n paddingTop: 1,\n },\n large: {\n marginLeft: 10,\n paddingTop: 1,\n },\n};\n\nconst closeIconSize: Record<ChipSize, ChipStyle['closeIconSize']> = {\n small: {\n height: 14,\n width: 8.17,\n },\n large: {\n height: 16,\n width: 9,\n },\n};\n\n// TODO: need to refactoring...\nexport default function useChipStyle(\n size: ChipSize,\n startElementVariant: ChipStartElementVariant,\n color: ChipColor,\n selected: boolean,\n variant: ChipVariant = 'filled',\n): ChipStyle {\n const theme = useTheme();\n\n return useMemo<ChipStyle>(() => {\n const isOutlined = variant === 'outlined';\n\n const textColor = selected\n ? theme.palette.text.strongInverse\n : isOutlined\n ? theme.palette.text.base\n : theme.palette.text.strong;\n\n const fontStyleMap: Record<ChipSize, TextStyle> = {\n small: createFontStyle(theme, {\n selector: (typography) => typography.caption1.medium,\n color: textColor,\n }),\n large: createFontStyle(theme, {\n selector: (typography) => typography.body2.medium,\n color: textColor,\n }),\n };\n\n const baseContainerStyle: FountainUiStyle = {\n alignItems: 'center',\n backgroundColor: selected\n ? theme.palette.fill.base\n : isOutlined\n ? 'transparent'\n : color === 'white'\n ? theme.palette.surface.base\n : theme.palette.fill.weaker,\n borderRadius: theme.shape.radius.full,\n flexDirection: 'row',\n overflow: 'hidden',\n ...(isOutlined && {\n borderWidth: 1,\n borderColor: theme.palette.border.weak,\n }),\n };\n\n const isLarge = size === 'large';\n\n const variantStyleMap: VariantStyleMap = {\n avatar: {\n container: {\n paddingLeft: theme.spacing(isLarge ? 1.5 : 1.25),\n paddingRight: theme.spacing(isLarge ? 3.5 : 3),\n paddingVertical: theme.spacing(isLarge ? 1.25 : 1),\n },\n startElement: {\n borderRadius: theme.shape.radius.full,\n height: isLarge ? 26 : 23,\n width: isLarge ? 26 : 23,\n },\n startElementContainer: {\n marginRight: theme.spacing(isLarge ? 1.5 : 1.25),\n },\n },\n icon: {\n container: {\n paddingLeft: theme.spacing(1.5),\n paddingRight: theme.spacing(isLarge ? 3.5 : 3),\n paddingVertical: theme.spacing(isLarge ? 1.5 : 1.25),\n },\n startElement: {\n color: selected\n ? theme.palette.icon.strongInverse\n : theme.palette.icon.strong,\n height: isLarge ? 17 : 16,\n width: isLarge ? 17 : 16,\n },\n startElementContainer: {\n alignItems: 'center',\n height: isLarge ? 24 : 21,\n justifyContent: 'center',\n marginRight: theme.spacing(isLarge ? 1 : 0.75),\n width: isLarge ? 24 : 21,\n },\n },\n image: {\n container: {\n alignItems: 'center',\n paddingRight: theme.spacing(isLarge ? 3.5 : 3),\n },\n startElement: {\n borderRadius: theme.shape.radius.full,\n height: isLarge ? 36 : 31,\n width: isLarge ? 48 : 40,\n },\n startElementContainer: {\n marginRight: theme.spacing(1.5),\n },\n },\n default: {\n container: {\n paddingBottom: theme.spacing(1.75),\n paddingLeft: theme.spacing(isLarge ? 3.5 : 3),\n paddingRight: theme.spacing(isLarge ? 3.5 : 3),\n paddingTop: theme.spacing(1.5),\n },\n },\n };\n\n return {\n container: {\n ...baseContainerStyle,\n ...variantStyleMap[startElementVariant]?.container,\n ...(selected ? { paddingRight: theme.spacing(isLarge ? 2.5 : 2.25) } : {}),\n },\n closeButtonContainer: closeButtonContainerStyleMap[size],\n closeIconSize: closeIconSize[size],\n label: fontStyleMap[size],\n startElement: variantStyleMap[startElementVariant]?.startElement,\n startElementContainer: variantStyleMap[startElementVariant]?.startElementContainer,\n };\n }, [theme, size, startElementVariant, color, selected, variant]);\n}\n"],"mappings":";;;;;;;AAAA;;AAIA;;AAcA,MAAMA,4BAA+D,GAAG;EACpEC,KAAK,EAAE;IACHC,UAAU,EAAE,CADT;IAEHC,UAAU,EAAE;EAFT,CAD6D;EAKpEC,KAAK,EAAE;IACHF,UAAU,EAAE,EADT;IAEHC,UAAU,EAAE;EAFT;AAL6D,CAAxE;AAWA,MAAME,aAA2D,GAAG;EAChEJ,KAAK,EAAE;IACHK,MAAM,EAAE,EADL;IAEHC,KAAK,EAAE;EAFJ,CADyD;EAKhEH,KAAK,EAAE;IACHE,MAAM,EAAE,EADL;IAEHC,KAAK,EAAE;EAFJ;AALyD,CAApE,C,CAWA;;AACe,SAASC,YAAT,CACXC,IADW,EAEXC,mBAFW,EAGXC,KAHW,EAIXC,QAJW,EAMF;EAAA,IADTC,OACS,uEADc,QACd;EACT,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO,IAAAC,cAAA,EAAmB,MAAM;IAAA;;IAC5B,MAAMC,UAAU,GAAGJ,OAAO,KAAK,UAA/B;IAEA,MAAMK,SAAS,GAAGN,QAAQ,GACpBE,KAAK,CAACK,OAAN,CAAcC,IAAd,CAAmBC,aADC,GAEpBJ,UAAU,GACNH,KAAK,CAACK,OAAN,CAAcC,IAAd,CAAmBE,IADb,GAENR,KAAK,CAACK,OAAN,CAAcC,IAAd,CAAmBG,MAJ7B;IAMA,MAAMC,YAAyC,GAAG;MAC9CvB,KAAK,EAAE,IAAAwB,uBAAA,EAAgBX,KAAhB,EAAuB;QAC1BY,QAAQ,EAAGC,UAAD,IAAgBA,UAAU,CAACC,QAAX,CAAoBC,MADpB;QAE1BlB,KAAK,EAAEO;MAFmB,CAAvB,CADuC;MAK9Cd,KAAK,EAAE,IAAAqB,uBAAA,EAAgBX,KA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P;AAkHH"}
|
|
@@ -79,14 +79,13 @@ function Radio(props) {
|
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
const isChecked =
|
|
82
|
+
const isChecked = context ? context.value === value : checked;
|
|
83
83
|
|
|
84
84
|
const defaultCheckedIcon = /*#__PURE__*/_react.default.createElement(_internal.Check, {
|
|
85
85
|
color: 'accent'
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
const checkedIcon = checkIconProp ?? defaultCheckedIcon;
|
|
89
|
-
const icon = isChecked ? checkedIcon : null;
|
|
90
89
|
const startIcon = (0, _utils.cloneElementSafely)(startIconProp, {
|
|
91
90
|
color: 'strong',
|
|
92
91
|
height: DEFAULT_START_ICON_SIZE,
|
|
@@ -115,7 +114,11 @@ function Radio(props) {
|
|
|
115
114
|
color: 'base',
|
|
116
115
|
weight: 'regular',
|
|
117
116
|
children: description
|
|
118
|
-
}) : null),
|
|
117
|
+
}) : null), /*#__PURE__*/_react.default.createElement(_Column.default, {
|
|
118
|
+
style: {
|
|
119
|
+
opacity: Number(isChecked)
|
|
120
|
+
}
|
|
121
|
+
}, checkedIcon));
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_START_ICON_SIZE","useStyles","theme","useTheme","root","alignItems","borderBottomColor","palette","border","weak","borderBottomWidth","flexDirection","gap","justifyContent","paddingVertical","content","minHeight","Radio","props","checked","children","checkedIcon","checkIconProp","disabled","onChange","onChangeProp","startIcon","startIconProp","style","value","description","otherProps","styles","context","useContext","RadioContext","handlePress","isChecked","defaultCheckedIcon","
|
|
1
|
+
{"version":3,"names":["DEFAULT_START_ICON_SIZE","useStyles","theme","useTheme","root","alignItems","borderBottomColor","palette","border","weak","borderBottomWidth","flexDirection","gap","justifyContent","paddingVertical","content","minHeight","Radio","props","checked","children","checkedIcon","checkIconProp","disabled","onChange","onChangeProp","startIcon","startIconProp","style","value","description","otherProps","styles","context","useContext","RadioContext","handlePress","isChecked","defaultCheckedIcon","cloneElementSafely","color","height","width","rootStyle","css","fontStyle","createFontStyle","selector","typography","body1","regular","text","strong","opacity","Number"],"sources":["Radio.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { Text } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport ButtonBase from '../ButtonBase';\nimport Column from '../Column';\nimport { Check as CheckedIcon } from '../internal';\nimport Row from '../Row';\nimport { createFontStyle, css, useTheme } from '../styles';\nimport { cloneElementSafely } from '../utils';\nimport { RadioContext } from '../RadioGroup/RadioContextProvider';\nimport type RadioProps from './RadioProps';\nimport Typography from '../Typography';\n\nconst DEFAULT_START_ICON_SIZE = 21;\n\ntype RadioStyles = NamedStylesStringUnion<'root' | 'content'>;\n\nconst useStyles: UseStyles<RadioStyles> = function (): RadioStyles {\n const theme = useTheme();\n\n return {\n root: {\n alignItems: 'center',\n borderBottomColor: theme.palette.border.weak,\n borderBottomWidth: 0.5,\n flexDirection: 'row',\n gap: 32,\n justifyContent: 'space-between',\n paddingVertical: 14,\n },\n content: {\n gap: 8,\n minHeight: 20,\n },\n };\n};\n\nexport default function Radio(props: RadioProps) {\n const {\n checked = false,\n children,\n checkedIcon: checkIconProp,\n disabled = false,\n onChange: onChangeProp,\n startIcon: startIconProp,\n style,\n value,\n description,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const styles = useStyles();\n\n const context = useContext(RadioContext);\n\n const handlePress = () => {\n const onChange = context?.onChange ?? onChangeProp;\n if (onChange) {\n onChange(value);\n }\n };\n\n const isChecked = context\n ? context.value === value\n : checked;\n\n const defaultCheckedIcon = (\n <CheckedIcon color={'accent'}/>\n );\n\n const checkedIcon = checkIconProp ?? defaultCheckedIcon;\n\n const startIcon = cloneElementSafely(startIconProp, {\n color: 'strong',\n height: DEFAULT_START_ICON_SIZE,\n width: DEFAULT_START_ICON_SIZE,\n });\n\n const rootStyle = css([\n styles.root,\n style,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typography) => typography.body1.regular,\n color: theme.palette.text.strong,\n });\n\n return (\n <ButtonBase\n disabled={disabled}\n onPress={handlePress}\n style={rootStyle}\n {...otherProps}\n >\n <Column\n gap={2}\n flexShrink={1}\n >\n <Row\n alignItems={'center'}\n style={styles.content}\n >\n {startIcon}\n\n <Text\n children={children}\n style={fontStyle}\n />\n </Row>\n\n {description ? (\n <Typography\n variant={'body3'}\n color={'base'}\n weight={'regular'}\n children={description}\n />\n ) : null}\n </Column>\n\n <Column style={{ opacity: Number(isChecked) }}>\n {checkedIcon}\n </Column>\n </ButtonBase>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,MAAMA,uBAAuB,GAAG,EAAhC;;AAIA,MAAMC,SAAiC,GAAG,YAAyB;EAC/D,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,UAAU,EAAE,QADV;MAEFC,iBAAiB,EAAEJ,KAAK,CAACK,OAAN,CAAcC,MAAd,CAAqBC,IAFtC;MAGFC,iBAAiB,EAAE,GAHjB;MAIFC,aAAa,EAAE,KAJb;MAKFC,GAAG,EAAE,EALH;MAMFC,cAAc,EAAE,eANd;MAOFC,eAAe,EAAE;IAPf,CADH;IAUHC,OAAO,EAAE;MACLH,GAAG,EAAE,CADA;MAELI,SAAS,EAAE;IAFN;EAVN,CAAP;AAeH,CAlBD;;AAoBe,SAASC,KAAT,CAAeC,KAAf,EAAkC;EAC7C,MAAM;IACFC,OAAO,GAAG,KADR;IAEFC,QAFE;IAGFC,WAAW,EAAEC,aAHX;IAIFC,QAAQ,GAAG,KAJT;IAKFC,QAAQ,EAAEC,YALR;IAMFC,SAAS,EAAEC,aANT;IAOFC,KAPE;IAQFC,KARE;IASFC,WATE;IAUF,GAAGC;EAVD,IAWFb,KAXJ;EAa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,EAAE;EAFhB,gBAII,6BAAC,YAAD;IACI,UAAU,EAAE,QADhB;IAEI,KAAK,EAAEC,MAAM,CAACjB;EAFlB,GAIKW,SAJL,eAMI,6BAAC,iBAAD;IACI,QAAQ,EAAEN,QADd;IAEI,KAAK,EAAEyB;EAFX,EANJ,CAJJ,EAgBKf,WAAW,gBACR,6BAAC,mBAAD;IACI,OAAO,EAAE,OADb;IAEI,KAAK,EAAE,MAFX;IAGI,MAAM,EAAE,SAHZ;IAII,QAAQ,EAAEA;EAJd,EADQ,GAOR,IAvBR,CANJ,eAgCI,6BAAC,eAAD;IAAQ,KAAK,EAAE;MAAEuB,OAAO,EAAEC,MAAM,CAACjB,SAAD;IAAjB;EAAf,GACKhB,WADL,CAhCJ,CADJ;AAsCH;;AAAA"}
|
|
@@ -79,7 +79,9 @@ const TextField = /*#__PURE__*/_react.default.forwardRef(function TextField(prop
|
|
|
79
79
|
multiline,
|
|
80
80
|
editable = true,
|
|
81
81
|
hint,
|
|
82
|
+
inputFontSize = 'large',
|
|
82
83
|
isLoading,
|
|
84
|
+
maxLength,
|
|
83
85
|
onBlur,
|
|
84
86
|
onChangeText: onChangeTextProp,
|
|
85
87
|
onFocus,
|
|
@@ -87,6 +89,7 @@ const TextField = /*#__PURE__*/_react.default.forwardRef(function TextField(prop
|
|
|
87
89
|
placeholderTextColor: placeholderTextColorProp,
|
|
88
90
|
secureTextEntry: secureTextEntryProp,
|
|
89
91
|
showClearButton: showClearButtonProp,
|
|
92
|
+
showWordCounter = false,
|
|
90
93
|
status = 'default',
|
|
91
94
|
style: styleProp,
|
|
92
95
|
title,
|
|
@@ -109,7 +112,7 @@ const TextField = /*#__PURE__*/_react.default.forwardRef(function TextField(prop
|
|
|
109
112
|
ref.current = node;
|
|
110
113
|
}
|
|
111
114
|
}, [ref]);
|
|
112
|
-
const variantStyles = (0, _useVariantStyleMap.default)(variant, status, isFocused);
|
|
115
|
+
const variantStyles = (0, _useVariantStyleMap.default)(variant, status, isFocused, inputFontSize);
|
|
113
116
|
|
|
114
117
|
const handleBlur = event => {
|
|
115
118
|
setIsFocused(false);
|
|
@@ -188,6 +191,7 @@ const TextField = /*#__PURE__*/_react.default.forwardRef(function TextField(prop
|
|
|
188
191
|
}) : null), /*#__PURE__*/_react.default.createElement(_reactNative.TextInput, _extends({
|
|
189
192
|
autoFocus: autoFocus,
|
|
190
193
|
editable: !disabled,
|
|
194
|
+
maxLength: maxLength,
|
|
191
195
|
onBlur: handleBlur,
|
|
192
196
|
onChangeText: handleChangeText,
|
|
193
197
|
onFocus: handleFocus,
|
|
@@ -216,7 +220,10 @@ const TextField = /*#__PURE__*/_react.default.forwardRef(function TextField(prop
|
|
|
216
220
|
}) : /*#__PURE__*/_react.default.createElement(_icons.EyeOn, {
|
|
217
221
|
height: 19,
|
|
218
222
|
width: 17.42
|
|
219
|
-
}))) : null),
|
|
223
|
+
}))) : null), showWordCounter && maxLength && !isSearch ? /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
224
|
+
children: `${(value === null || value === void 0 ? void 0 : value.length) ?? 0}/${maxLength}`,
|
|
225
|
+
style: variantStyles.hintStyle
|
|
226
|
+
}) : null, hint && !isSearch ? /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
220
227
|
children: hint,
|
|
221
228
|
style: variantStyles.hintStyle
|
|
222
229
|
}) : null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isWeb","Platform","OS","styles","StyleSheet","create","root","alignItems","flexGrow","input","inputWrapper","flexShrink","placeholderWrapper","absoluteFillObject","justifyContent","secureToggleButton","padding","position","right","searchIconContainer","left","loadingSinner","height","width","clearButton","secureButtonContainer","TextField","React","forwardRef","props","ref","autoFocus","containerStyle","containerStyleProp","multiline","editable","hint","isLoading","onBlur","onChangeText","onChangeTextProp","onFocus","placeholder","placeholderProp","placeholderTextColor","placeholderTextColorProp","secureTextEntry","secureTextEntryProp","showClearButton","showClearButtonProp","status","style","styleProp","title","value","variant","otherProps","isSearch","disabled","theme","useTheme","isFocused","setIsFocused","useState","setSecureTextEntry","internalRef","useRef","mergedRef","useCallback","node","current","variantStyles","useVariantStyleMap","handleBlur","event","handleFocus","handleSecureTogglePress","resizeHeight","el","scrollHeight","useLayoutEffect","shouldResizeHeight","handleChangeText","text","handleClear","titleFontStyle","createFontStyle","selector","typography","caption1","color","palette","strong","inputStyle","css","inputFontStyle","outlineWidth","placeholderFontStyle","disabledLabel","opacity","length","hintStyle"],"sources":["TextField.tsx"],"sourcesContent":["import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport type { NativeSyntheticEvent, TextInputFocusEventData } from 'react-native';\nimport { Platform, StyleSheet, Text, TextInput, View } from 'react-native';\nimport type { FountainUiStyle } from '@fountain-ui/styles';\nimport { css } from '@fountain-ui/styles';\nimport IconButton from '../IconButton/IconButton';\nimport { Clear, EyeOff, EyeOn, LoadingSpinner, Search } from '../internal/icons';\nimport Row from '../Row';\nimport { createFontStyle, useTheme } from '../styles';\nimport type TextFieldProps from './TextFieldProps';\nimport type { TextFieldStatus, TextFieldVariant } from './TextFieldProps';\nimport useVariantStyleMap from './useVariantStyleMap';\n\nconst isWeb = Platform.OS === 'web';\n\nconst styles = StyleSheet.create({\n root: {\n alignItems: 'center',\n flexGrow: 1,\n },\n input: {\n flexGrow: 1,\n },\n inputWrapper: {\n flexGrow: 1,\n flexShrink: 1,\n },\n placeholderWrapper: {\n ...StyleSheet.absoluteFillObject,\n justifyContent: 'center',\n },\n secureToggleButton: {\n alignItems: 'flex-end',\n padding: 0,\n position: 'absolute',\n right: 0,\n },\n searchIconContainer: {\n left: 12,\n position: 'absolute',\n },\n loadingSinner: {\n height: 19,\n width: 19,\n },\n clearButton: {\n height: 36,\n position: 'absolute',\n right: 2,\n width: 32,\n },\n secureButtonContainer: {\n justifyContent: 'center',\n width: 32,\n },\n});\n\nconst TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField(props, ref) {\n const {\n autoFocus,\n containerStyle: containerStyleProp,\n multiline,\n editable = true,\n hint,\n isLoading,\n onBlur,\n onChangeText: onChangeTextProp,\n onFocus,\n placeholder: placeholderProp,\n placeholderTextColor: placeholderTextColorProp,\n secureTextEntry: secureTextEntryProp,\n showClearButton: showClearButtonProp,\n status = 'default' as TextFieldStatus,\n style: styleProp,\n title,\n value,\n variant = 'default' as TextFieldVariant,\n ...otherProps\n } = props;\n\n const isSearch = variant === 'search';\n\n const disabled = !editable || isLoading;\n\n const theme = useTheme();\n\n const [isFocused, setIsFocused] = useState<boolean>(autoFocus ?? false);\n const [secureTextEntry, setSecureTextEntry] = useState<boolean>(secureTextEntryProp ?? false);\n\n const internalRef = useRef<TextInput>(null);\n\n const mergedRef = useCallback((node: TextInput | null) => {\n (internalRef as React.MutableRefObject<TextInput | null>).current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<TextInput | null>).current = node;\n }\n }, [ref]);\n\n const variantStyles = useVariantStyleMap(variant, status, isFocused);\n\n const handleBlur = (event: NativeSyntheticEvent<TextInputFocusEventData>) => {\n setIsFocused(false);\n onBlur?.(event);\n };\n\n const handleFocus = (event: NativeSyntheticEvent<TextInputFocusEventData>) => {\n setIsFocused(true);\n onFocus?.(event);\n };\n\n const handleSecureTogglePress = () => {\n setSecureTextEntry((current) => !current);\n };\n\n const resizeHeight = useCallback(() => {\n const el = internalRef.current as unknown as HTMLTextAreaElement | null;\n if (el) {\n el.style.height = 'auto';\n el.style.height = `${el.scrollHeight}px`;\n }\n }, []);\n\n useLayoutEffect(() => {\n const shouldResizeHeight = multiline && isWeb;\n if (shouldResizeHeight) {\n resizeHeight();\n }\n }, [resizeHeight, multiline, value]);\n\n const handleChangeText = (text: string) => {\n onChangeTextProp?.(text);\n };\n\n const handleClear = () => {\n handleChangeText('');\n };\n\n const showClearButton = showClearButtonProp ?? isSearch;\n\n const titleFontStyle = createFontStyle(theme, {\n selector: (typography) => typography.caption1['semiBold'],\n color: theme.palette.text.strong,\n });\n\n const inputStyle = css([\n styles.input,\n variantStyles.inputStyle,\n variantStyles.inputFontStyle,\n isWeb ? { outlineWidth: 0 } as FountainUiStyle : {},\n styleProp,\n ]);\n\n const placeholderFontStyle = css([\n variantStyles.inputFontStyle,\n { color: placeholderTextColorProp ?? theme.palette.status.disabledLabel },\n ]);\n\n const containerStyle = css([\n styles.root,\n variantStyles.containerStyle,\n { opacity: disabled ? 0.3 : 1 },\n containerStyleProp,\n ]);\n\n return (\n <View>\n {title && !isSearch ? (\n <Text\n children={title}\n style={titleFontStyle}\n />\n ) : null}\n\n <Row style={containerStyle}>\n <React.Fragment>\n {isSearch ? (\n <View style={styles.searchIconContainer}>\n {isLoading ? (\n <LoadingSpinner style={styles.loadingSinner}/>\n ) : (\n <Search\n color={'base'}\n height={19}\n width={19}\n />\n )}\n </View>\n ) : null}\n\n <View style={styles.inputWrapper}>\n <View\n pointerEvents={'none'}\n style={styles.placeholderWrapper}\n >\n {placeholderProp && !value ? (\n <Text\n children={placeholderProp}\n numberOfLines={1}\n style={placeholderFontStyle}\n />\n ) : null}\n </View>\n\n <TextInput\n autoFocus={autoFocus}\n editable={!disabled}\n onBlur={handleBlur}\n onChangeText={handleChangeText}\n onFocus={handleFocus}\n ref={mergedRef}\n secureTextEntry={secureTextEntry}\n style={inputStyle}\n value={value}\n multiline={multiline}\n {...otherProps}\n />\n </View>\n </React.Fragment>\n\n {showClearButton && value?.length && value.length > 0 ? (\n <IconButton\n color={'base'}\n children={\n <Clear\n height={17.31}\n width={15.9}\n />\n }\n onPress={handleClear}\n style={styles.clearButton}\n />\n ) : null}\n\n {secureTextEntryProp && !isSearch ? (\n <View style={styles.secureButtonContainer}>\n <IconButton\n color={'base'}\n onPress={handleSecureTogglePress}\n style={styles.secureToggleButton}\n >\n {secureTextEntry ? (\n <EyeOff\n height={19}\n width={17.42}\n />\n ) : (\n <EyeOn\n height={19}\n width={17.42}\n />\n )}\n </IconButton>\n </View>\n ) : null}\n </Row>\n\n {hint && !isSearch ? (\n <Text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AE;EAFX,EADY,gBAMZ,6BAAC,YAAD;IACI,MAAM,EAAE,EADZ;IAEI,KAAK,EAAE;EAFX,EAXR,CADJ,CADH,GAoBG,IAhFR,CARJ,EA2FKV,IAAI,IAAI,CAACqB,QAAT,gBACG,6BAAC,iBAAD;IACI,QAAQ,EAAErB,IADd;IAEI,KAAK,EAAEmC,aAAa,CAAC8B;EAFzB,EADH,GAKG,IAhGR,CADJ;AAoGH,CAjNiB,CAAlB;;eAmNe3E,S"}
|
|
1
|
+
{"version":3,"names":["isWeb","Platform","OS","styles","StyleSheet","create","root","alignItems","flexGrow","input","inputWrapper","flexShrink","placeholderWrapper","absoluteFillObject","justifyContent","secureToggleButton","padding","position","right","searchIconContainer","left","loadingSinner","height","width","clearButton","secureButtonContainer","TextField","React","forwardRef","props","ref","autoFocus","containerStyle","containerStyleProp","multiline","editable","hint","inputFontSize","isLoading","maxLength","onBlur","onChangeText","onChangeTextProp","onFocus","placeholder","placeholderProp","placeholderTextColor","placeholderTextColorProp","secureTextEntry","secureTextEntryProp","showClearButton","showClearButtonProp","showWordCounter","status","style","styleProp","title","value","variant","otherProps","isSearch","disabled","theme","useTheme","isFocused","setIsFocused","useState","setSecureTextEntry","internalRef","useRef","mergedRef","useCallback","node","current","variantStyles","useVariantStyleMap","handleBlur","event","handleFocus","handleSecureTogglePress","resizeHeight","el","scrollHeight","useLayoutEffect","shouldResizeHeight","handleChangeText","text","handleClear","titleFontStyle","createFontStyle","selector","typography","caption1","color","palette","strong","inputStyle","css","inputFontStyle","outlineWidth","placeholderFontStyle","disabledLabel","opacity","length","hintStyle"],"sources":["TextField.tsx"],"sourcesContent":["import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport type { NativeSyntheticEvent, TextInputFocusEventData } from 'react-native';\nimport { Platform, StyleSheet, Text, TextInput, View } from 'react-native';\nimport type { FountainUiStyle } from '@fountain-ui/styles';\nimport { css } from '@fountain-ui/styles';\nimport IconButton from '../IconButton/IconButton';\nimport { Clear, EyeOff, EyeOn, LoadingSpinner, Search } from '../internal/icons';\nimport Row from '../Row';\nimport { createFontStyle, useTheme } from '../styles';\nimport type TextFieldProps from './TextFieldProps';\nimport type { TextFieldStatus, TextFieldVariant } from './TextFieldProps';\nimport useVariantStyleMap from './useVariantStyleMap';\n\nconst isWeb = Platform.OS === 'web';\n\nconst styles = StyleSheet.create({\n root: {\n alignItems: 'center',\n flexGrow: 1,\n },\n input: {\n flexGrow: 1,\n },\n inputWrapper: {\n flexGrow: 1,\n flexShrink: 1,\n },\n placeholderWrapper: {\n ...StyleSheet.absoluteFillObject,\n justifyContent: 'center',\n },\n secureToggleButton: {\n alignItems: 'flex-end',\n padding: 0,\n position: 'absolute',\n right: 0,\n },\n searchIconContainer: {\n left: 12,\n position: 'absolute',\n },\n loadingSinner: {\n height: 19,\n width: 19,\n },\n clearButton: {\n height: 36,\n position: 'absolute',\n right: 2,\n width: 32,\n },\n secureButtonContainer: {\n justifyContent: 'center',\n width: 32,\n },\n});\n\nconst TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField(props, ref) {\n const {\n autoFocus,\n containerStyle: containerStyleProp,\n multiline,\n editable = true,\n hint,\n inputFontSize = 'large',\n isLoading,\n maxLength,\n onBlur,\n onChangeText: onChangeTextProp,\n onFocus,\n placeholder: placeholderProp,\n placeholderTextColor: placeholderTextColorProp,\n secureTextEntry: secureTextEntryProp,\n showClearButton: showClearButtonProp,\n showWordCounter = false,\n status = 'default' as TextFieldStatus,\n style: styleProp,\n title,\n value,\n variant = 'default' as TextFieldVariant,\n ...otherProps\n } = props;\n\n const isSearch = variant === 'search';\n\n const disabled = !editable || isLoading;\n\n const theme = useTheme();\n\n const [isFocused, setIsFocused] = useState<boolean>(autoFocus ?? false);\n const [secureTextEntry, setSecureTextEntry] = useState<boolean>(secureTextEntryProp ?? false);\n\n const internalRef = useRef<TextInput>(null);\n\n const mergedRef = useCallback((node: TextInput | null) => {\n (internalRef as React.MutableRefObject<TextInput | null>).current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<TextInput | null>).current = node;\n }\n }, [ref]);\n\n const variantStyles = useVariantStyleMap(variant, status, isFocused, inputFontSize);\n\n const handleBlur = (event: NativeSyntheticEvent<TextInputFocusEventData>) => {\n setIsFocused(false);\n onBlur?.(event);\n };\n\n const handleFocus = (event: NativeSyntheticEvent<TextInputFocusEventData>) => {\n setIsFocused(true);\n onFocus?.(event);\n };\n\n const handleSecureTogglePress = () => {\n setSecureTextEntry((current) => !current);\n };\n\n const resizeHeight = useCallback(() => {\n const el = internalRef.current as unknown as HTMLTextAreaElement | null;\n if (el) {\n el.style.height = 'auto';\n el.style.height = `${el.scrollHeight}px`;\n }\n }, []);\n\n useLayoutEffect(() => {\n const shouldResizeHeight = multiline && isWeb;\n if (shouldResizeHeight) {\n resizeHeight();\n }\n }, [resizeHeight, multiline, value]);\n\n const handleChangeText = (text: string) => {\n onChangeTextProp?.(text);\n };\n\n const handleClear = () => {\n handleChangeText('');\n };\n\n const showClearButton = showClearButtonProp ?? isSearch;\n\n const titleFontStyle = createFontStyle(theme, {\n selector: (typography) => typography.caption1['semiBold'],\n color: theme.palette.text.strong,\n });\n\n const inputStyle = css([\n styles.input,\n variantStyles.inputStyle,\n variantStyles.inputFontStyle,\n isWeb ? { outlineWidth: 0 } as FountainUiStyle : {},\n styleProp,\n ]);\n\n const placeholderFontStyle = css([\n variantStyles.inputFontStyle,\n { color: placeholderTextColorProp ?? theme.palette.status.disabledLabel },\n ]);\n\n const containerStyle = css([\n styles.root,\n variantStyles.containerStyle,\n { opacity: disabled ? 0.3 : 1 },\n containerStyleProp,\n ]);\n\n return (\n <View>\n {title && !isSearch ? (\n <Text\n children={title}\n style={titleFontStyle}\n />\n ) : null}\n\n <Row style={containerStyle}>\n <React.Fragment>\n {isSearch ? (\n <View style={styles.searchIconContainer}>\n {isLoading ? (\n <LoadingSpinner style={styles.loadingSinner}/>\n ) : (\n <Search\n color={'base'}\n height={19}\n width={19}\n />\n )}\n </View>\n ) : null}\n\n <View style={styles.inputWrapper}>\n <View\n pointerEvents={'none'}\n style={styles.placeholderWrapper}\n >\n {placeholderProp && !value ? (\n <Text\n children={placeholderProp}\n numberOfLines={1}\n style={placeholderFontStyle}\n />\n ) : null}\n </View>\n\n <TextInput\n autoFocus={autoFocus}\n editable={!disabled}\n maxLength={maxLength}\n onBlur={handleBlur}\n onChangeText={handleChangeText}\n onFocus={handleFocus}\n ref={mergedRef}\n secureTextEntry={secureTextEntry}\n style={inputStyle}\n value={value}\n multiline={multiline}\n {...otherProps}\n />\n </View>\n </React.Fragment>\n\n {showClearButton && value?.length && value.length > 0 ? (\n <IconButton\n color={'base'}\n children={\n <Clear\n height={17.31}\n width={15.9}\n />\n }\n onPress={handleClear}\n style={styles.clearButton}\n />\n ) : null}\n\n {secureTextEntryProp && !isSearch ? (\n <View style={styles.secureButtonContainer}>\n <IconButton\n color={'base'}\n onPress={handleSecureTogglePress}\n style={styles.secureToggleButton}\n >\n {secureTextEntry ? (\n <EyeOff\n height={19}\n width={17.42}\n />\n ) : (\n <EyeOn\n height={19}\n width={17.42}\n />\n )}\n </IconButton>\n </View>\n ) : null}\n </Row>\n\n {showWordCounter && maxLength && !isSearch ? (\n <Text\n children={`${value?.length ?? 0}/${maxLength}`}\n style={variantStyles.hintStyle}\n />\n ) : null}\n\n {hint && !isSearch ? (\n <Text\n children={hint}\n style={variantStyles.hintStyle}\n />\n ) : null}\n </View>\n );\n});\n\nexport default TextField;\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAGA;;;;;;;;;;AAEA,MAAMA,KAAK,GAAGC,qBAAA,CAASC,EAAT,KAAgB,KAA9B;;AAEA,MAAMC,MAAM,GAAGC,uBAAA,CAAWC,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACFC,UAAU,EAAE,QADV;IAEFC,QAAQ,EAAE;EAFR,CADuB;EAK7BC,KAAK,EAAE;IACHD,QAAQ,E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L,YAAAA,KAAK,CAAE8C,MAAP,KAAiB,CAAE,IAAGhE,SAAU,EADjD;IAEI,KAAK,EAAEmC,aAAa,CAAC8B;EAFzB,EADH,GAKG,IAjGR,EAmGKpE,IAAI,IAAI,CAACwB,QAAT,gBACG,6BAAC,iBAAD;IACI,QAAQ,EAAExB,IADd;IAEI,KAAK,EAAEsC,aAAa,CAAC8B;EAFzB,EADH,GAKG,IAxGR,CADJ;AA4GH,CA5NiB,CAAlB;;eA8Ne9E,S"}
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.textFieldVariants = exports.textFieldStatus = void 0;
|
|
6
|
+
exports.textFieldVariants = exports.textFieldStatus = exports.textFieldInputFontSizes = void 0;
|
|
7
7
|
const textFieldStatus = ['default', 'success', 'error'];
|
|
8
8
|
exports.textFieldStatus = textFieldStatus;
|
|
9
9
|
const textFieldVariants = ['default', 'search'];
|
|
10
10
|
exports.textFieldVariants = textFieldVariants;
|
|
11
|
+
const textFieldInputFontSizes = ['large', 'small'];
|
|
12
|
+
exports.textFieldInputFontSizes = textFieldInputFontSizes;
|
|
11
13
|
//# sourceMappingURL=TextFieldProps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["textFieldStatus","textFieldVariants"],"sources":["TextFieldProps.ts"],"sourcesContent":["import type { TextInputProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\nimport { StyleProp, TextStyle } from 'react-native';\nimport { ExtendedStyle } from '../types';\n\nexport const textFieldStatus = ['default', 'success', 'error'] as const;\nexport type TextFieldStatus = typeof textFieldStatus[number];\n\nexport const textFieldVariants = ['default', 'search'] as const;\nexport type TextFieldVariant = typeof textFieldVariants[number];\n\nexport default interface TextFieldProps extends OverridableComponentProps<TextInputProps, {\n /**\n * Determines the style of the container that wraps the input.\n */\n containerStyle?: ExtendedStyle | ExtendedStyle[];\n\n /**\n * Determines the text below the input.\n */\n hint?: string;\n\n /**\n * Determines whether to display the spinner when in loading state. (only search)\n */\n isLoading?: boolean;\n\n /**\n * Determines whether to expose the Clear button.\n * @default variant === search ? true : false\n */\n showClearButton?: boolean;\n\n /**\n * Determines the input color based on the status.\n * @default default\n */\n status?: TextFieldStatus;\n\n /**\n * Determines the title of the input.\n */\n title?: string;\n\n /**\n * Determines the overall style and appearance of the input.\n * @default default\n */\n variant?: TextFieldVariant;\n}> {}\n"],"mappings":";;;;;;AAKO,MAAMA,eAAe,GAAG,CAAC,SAAD,EAAY,SAAZ,EAAuB,OAAvB,CAAxB;;AAGA,MAAMC,iBAAiB,GAAG,CAAC,SAAD,EAAY,QAAZ,CAA1B"}
|
|
1
|
+
{"version":3,"names":["textFieldStatus","textFieldVariants","textFieldInputFontSizes"],"sources":["TextFieldProps.ts"],"sourcesContent":["import type { TextInputProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\nimport { StyleProp, TextStyle } from 'react-native';\nimport { ExtendedStyle } from '../types';\n\nexport const textFieldStatus = ['default', 'success', 'error'] as const;\nexport type TextFieldStatus = typeof textFieldStatus[number];\n\nexport const textFieldVariants = ['default', 'search'] as const;\nexport type TextFieldVariant = typeof textFieldVariants[number];\n\nexport const textFieldInputFontSizes = ['large', 'small'] as const;\nexport type TextFieldInputFontSize = typeof textFieldInputFontSizes[number];\n\nexport default interface TextFieldProps extends OverridableComponentProps<TextInputProps, {\n /**\n * Determines the style of the container that wraps the input.\n */\n containerStyle?: ExtendedStyle | ExtendedStyle[];\n\n /**\n * Determines the text below the input.\n */\n hint?: string;\n\n /**\n * Determines whether to display the spinner when in loading state. (only search)\n */\n isLoading?: boolean;\n\n /**\n * Determines whether to expose the Clear button.\n * @default variant === search ? true : false\n */\n showClearButton?: boolean;\n\n /**\n * Determines the input color based on the status.\n * @default default\n */\n status?: TextFieldStatus;\n\n /**\n * Determines the title of the input.\n */\n title?: string;\n\n /**\n * Determines the overall style and appearance of the input.\n * @default default\n */\n variant?: TextFieldVariant;\n\n /**\n * Determines the font size of the input.\n * @default large\n */\n inputFontSize?: TextFieldInputFontSize;\n\n /**\n * Determines whether to display the word counter below the input.\n * Requires maxLength to be set.\n * @default false\n */\n showWordCounter?: boolean;\n}> {}\n"],"mappings":";;;;;;AAKO,MAAMA,eAAe,GAAG,CAAC,SAAD,EAAY,SAAZ,EAAuB,OAAvB,CAAxB;;AAGA,MAAMC,iBAAiB,GAAG,CAAC,SAAD,EAAY,QAAZ,CAA1B;;AAGA,MAAMC,uBAAuB,GAAG,CAAC,OAAD,EAAU,OAAV,CAAhC"}
|
|
@@ -11,6 +11,30 @@ var _styles = require("@fountain-ui/styles");
|
|
|
11
11
|
|
|
12
12
|
var _styles2 = require("../styles");
|
|
13
13
|
|
|
14
|
+
const fontSizeStyleMap = {
|
|
15
|
+
large: {
|
|
16
|
+
fontSize: 18,
|
|
17
|
+
lineHeight: 27,
|
|
18
|
+
fontFamily: 'PretendardStd-SemiBold',
|
|
19
|
+
letterSpacing: 0
|
|
20
|
+
},
|
|
21
|
+
small: {
|
|
22
|
+
fontSize: 14,
|
|
23
|
+
lineHeight: 21,
|
|
24
|
+
fontFamily: 'PretendardStd-Medium',
|
|
25
|
+
letterSpacing: 0
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const containerPaddingMap = {
|
|
29
|
+
large: {
|
|
30
|
+
paddingVertical: 14
|
|
31
|
+
},
|
|
32
|
+
small: {
|
|
33
|
+
paddingTop: 18,
|
|
34
|
+
paddingBottom: 16
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
14
38
|
function useStatusColor(theme, status) {
|
|
15
39
|
switch (status) {
|
|
16
40
|
default:
|
|
@@ -35,6 +59,7 @@ function useStatusColor(theme, status) {
|
|
|
35
59
|
}
|
|
36
60
|
|
|
37
61
|
function useVariantStyleMap(variant, status, isFocused) {
|
|
62
|
+
let inputFontSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'large';
|
|
38
63
|
const theme = (0, _styles2.useTheme)();
|
|
39
64
|
const {
|
|
40
65
|
borderColor,
|
|
@@ -49,19 +74,14 @@ function useVariantStyleMap(variant, status, isFocused) {
|
|
|
49
74
|
borderBottomColor: status === 'default' && isFocused ? theme.palette.border.strong : borderColor,
|
|
50
75
|
borderBottomWidth: 1,
|
|
51
76
|
gap: 16,
|
|
52
|
-
minHeight:
|
|
53
|
-
|
|
77
|
+
minHeight: 54,
|
|
78
|
+
...containerPaddingMap[inputFontSize]
|
|
54
79
|
},
|
|
55
80
|
inputStyle: {
|
|
56
81
|
padding: 0
|
|
57
82
|
},
|
|
58
83
|
inputFontStyle: (0, _styles2.createFontStyle)(theme, {
|
|
59
|
-
selector: _ => (0, _styles.typographyOf)(
|
|
60
|
-
fontSize: 18,
|
|
61
|
-
lineHeight: 27,
|
|
62
|
-
fontFamily: 'PretendardStd-SemiBold',
|
|
63
|
-
letterSpacing: 0
|
|
64
|
-
}),
|
|
84
|
+
selector: _ => (0, _styles.typographyOf)(fontSizeStyleMap[inputFontSize]),
|
|
65
85
|
color: theme.palette.text.strong
|
|
66
86
|
}),
|
|
67
87
|
hintStyle: {
|
|
@@ -98,6 +118,6 @@ function useVariantStyleMap(variant, status, isFocused) {
|
|
|
98
118
|
})
|
|
99
119
|
};
|
|
100
120
|
}
|
|
101
|
-
}, [theme, borderColor, hintColor, variant, isFocused]);
|
|
121
|
+
}, [theme, borderColor, hintColor, variant, isFocused, inputFontSize]);
|
|
102
122
|
}
|
|
103
123
|
//# sourceMappingURL=useVariantStyleMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useStatusColor","theme","status","borderColor","palette","border","base","hintColor","text","weak","success","danger","useVariantStyleMap","variant","isFocused","useTheme","useMemo","containerStyle","borderBottomColor","strong","borderBottomWidth","gap","minHeight","
|
|
1
|
+
{"version":3,"names":["fontSizeStyleMap","large","fontSize","lineHeight","fontFamily","letterSpacing","small","containerPaddingMap","paddingVertical","paddingTop","paddingBottom","useStatusColor","theme","status","borderColor","palette","border","base","hintColor","text","weak","success","danger","useVariantStyleMap","variant","isFocused","inputFontSize","useTheme","useMemo","containerStyle","borderBottomColor","strong","borderBottomWidth","gap","minHeight","inputStyle","padding","inputFontStyle","createFontStyle","selector","_","typographyOf","color","hintStyle","marginTop","spacing","typography","caption1","backgroundColor","surface","supportive","borderRadius","shape","radius","md","borderWidth","paddingHorizontal"],"sources":["useVariantStyleMap.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { TextStyle } from 'react-native';\nimport type { FountainUiStyle, Theme } from '@fountain-ui/styles';\nimport { typographyOf } from '@fountain-ui/styles';\nimport { createFontStyle, useTheme } from '../styles';\nimport type { TextFieldInputFontSize, TextFieldStatus, TextFieldVariant } from './TextFieldProps';\n\nconst fontSizeStyleMap = {\n large: {\n fontSize: 18,\n lineHeight: 27,\n fontFamily: 'PretendardStd-SemiBold',\n letterSpacing: 0,\n },\n small: {\n fontSize: 14,\n lineHeight: 21,\n fontFamily: 'PretendardStd-Medium',\n letterSpacing: 0,\n },\n} as const;\n\nconst containerPaddingMap = {\n large: {\n paddingVertical: 14,\n },\n small: {\n paddingTop: 18,\n paddingBottom: 16,\n },\n} as const;\n\ninterface VariantStyleMap {\n containerStyle?: FountainUiStyle;\n inputFontStyle?: TextStyle;\n inputStyle?: FountainUiStyle;\n hintStyle?: FountainUiStyle;\n}\n\nfunction useStatusColor(theme: Theme, status: TextFieldStatus): { borderColor: string; hintColor: string; } {\n switch (status) {\n default:\n case 'default':\n return {\n borderColor: theme.palette.border.base,\n hintColor: theme.palette.text.weak,\n };\n case 'success':\n return {\n borderColor: theme.palette.status.success,\n hintColor: theme.palette.status.success,\n };\n case 'error':\n return {\n borderColor: theme.palette.status.danger,\n hintColor: theme.palette.status.danger,\n };\n }\n}\n\nexport default function useVariantStyleMap(\n variant: TextFieldVariant,\n status: TextFieldStatus,\n isFocused: boolean,\n inputFontSize: TextFieldInputFontSize = 'large',\n): VariantStyleMap {\n const theme = useTheme();\n\n const {\n borderColor,\n hintColor,\n } = useStatusColor(theme, status);\n\n return useMemo(() => {\n switch (variant) {\n default:\n case 'default':\n return {\n containerStyle: {\n borderBottomColor: status === 'default' && isFocused ? theme.palette.border.strong : borderColor,\n borderBottomWidth: 1,\n gap: 16,\n minHeight: 54,\n ...containerPaddingMap[inputFontSize],\n },\n inputStyle: {\n padding: 0,\n },\n inputFontStyle: createFontStyle(theme, {\n selector: (_) => typographyOf(fontSizeStyleMap[inputFontSize]),\n color: theme.palette.text.strong,\n }),\n hintStyle: {\n marginTop: theme.spacing(2),\n ...createFontStyle(theme, {\n selector: (typography) => typography.caption1['regular'],\n color: hintColor,\n }),\n },\n };\n case 'search':\n return {\n containerStyle: {\n backgroundColor: theme.palette.surface.supportive,\n borderColor: theme.palette.border.base,\n borderRadius: theme.shape.radius.md,\n borderWidth: 0.5,\n paddingBottom: 12,\n paddingHorizontal: 39,\n paddingTop: 11,\n },\n inputStyle: {\n padding: 0,\n },\n inputFontStyle: createFontStyle(theme, {\n selector: (_) => typographyOf({\n fontSize: 16,\n lineHeight: 19.2,\n fontFamily: 'PretendardStd-SemiBold',\n letterSpacing: -0.16,\n }),\n color: theme.palette.text.strong,\n }),\n };\n }\n }, [theme, borderColor, hintColor, variant, isFocused, inputFontSize]);\n}\n"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;;AAGA,MAAMA,gBAAgB,GAAG;EACrBC,KAAK,EAAE;IACHC,QAAQ,EAAE,EADP;IAEHC,UAAU,EAAE,EAFT;IAGHC,UAAU,EAAE,wBAHT;IAIHC,aAAa,EAAE;EAJZ,CADc;EAOrBC,KAAK,EAAE;IACHJ,QAAQ,EAAE,EADP;IAEHC,UAAU,EAAE,EAFT;IAGHC,UAAU,EAAE,sBAHT;IAIHC,aAAa,EAAE;EAJZ;AAPc,CAAzB;AAeA,MAAME,mBAAmB,GAAG;EACxBN,KAAK,EAAE;IACHO,eAAe,EAAE;EADd,CADiB;EAIxBF,KAAK,EAAE;I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AK,EAAE9B,KAAK,CAACG,OAAN,CAAcI,IAAd,CAAmBY;UAPS,CAAvB;QAbb,CAAP;IA3BR;EAmDH,CApDM,EAoDJ,CAACnB,KAAD,EAAQE,WAAR,EAAqBI,SAArB,EAAgCM,OAAhC,EAAyCC,SAAzC,EAAoDC,aAApD,CApDI,CAAP;AAqDH"}
|
|
@@ -18,8 +18,10 @@ export default function Chip(props) {
|
|
|
18
18
|
startElement: startElementProp,
|
|
19
19
|
startElementVariant = 'default',
|
|
20
20
|
style: styleProp,
|
|
21
|
+
variant = 'filled',
|
|
21
22
|
...otherProps
|
|
22
23
|
} = props;
|
|
24
|
+
const isSelected = variant === 'outlined' ? false : selected;
|
|
23
25
|
const {
|
|
24
26
|
container: containerStyle,
|
|
25
27
|
closeButtonContainer: closeButtonContainerStyle,
|
|
@@ -27,7 +29,7 @@ export default function Chip(props) {
|
|
|
27
29
|
label: labelStyle,
|
|
28
30
|
startElement: startElementStyle,
|
|
29
31
|
startElementContainer: startElementContainerStyle
|
|
30
|
-
} = useChipStyle(size, startElementVariant, color,
|
|
32
|
+
} = useChipStyle(size, startElementVariant, color, isSelected, variant);
|
|
31
33
|
const chipStyle = css([containerStyle, styleProp]);
|
|
32
34
|
const startElement = /*#__PURE__*/React.createElement(View, {
|
|
33
35
|
style: startElementContainerStyle
|
|
@@ -42,7 +44,7 @@ export default function Chip(props) {
|
|
|
42
44
|
children: children,
|
|
43
45
|
numberOfLines: numberOfLines,
|
|
44
46
|
style: labelStyle
|
|
45
|
-
}),
|
|
47
|
+
}), isSelected ? /*#__PURE__*/React.createElement(View, {
|
|
46
48
|
style: closeButtonContainerStyle
|
|
47
49
|
}, /*#__PURE__*/React.createElement(ChipClose, {
|
|
48
50
|
color: 'baseInverse',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Text","View","ButtonBase","ChipClose","css","cloneElementSafely","useChipStyle","Chip","props","children","color","numberOfLines","onPress","selected","size","startElement","startElementProp","startElementVariant","style","styleProp","otherProps","container","containerStyle","closeButtonContainer","closeButtonContainerStyle","closeIconSize","label","labelStyle","startElementStyle","startElementContainer","startElementContainerStyle","chipStyle","height","width"],"sources":["Chip.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, View } from 'react-native';\nimport ButtonBase from '../ButtonBase';\nimport { ChipClose } from '../internal';\nimport { css } from '../styles';\nimport { cloneElementSafely } from '../utils';\nimport type ChipProps from './ChipProps';\nimport type { ChipColor, ChipSize } from './ChipProps';\nimport useChipStyle from './useChipStyle';\n\nexport default function Chip(props: ChipProps) {\n const {\n children,\n color = 'default' as ChipColor,\n numberOfLines,\n onPress,\n selected = false,\n size = 'small' as ChipSize,\n startElement: startElementProp,\n startElementVariant = 'default',\n style: styleProp,\n ...otherProps\n } = props;\n\n const {\n container: containerStyle,\n closeButtonContainer: closeButtonContainerStyle,\n closeIconSize,\n label: labelStyle,\n startElement: startElementStyle,\n startElementContainer: startElementContainerStyle,\n } = useChipStyle(size, startElementVariant, color,
|
|
1
|
+
{"version":3,"names":["React","Text","View","ButtonBase","ChipClose","css","cloneElementSafely","useChipStyle","Chip","props","children","color","numberOfLines","onPress","selected","size","startElement","startElementProp","startElementVariant","style","styleProp","variant","otherProps","isSelected","container","containerStyle","closeButtonContainer","closeButtonContainerStyle","closeIconSize","label","labelStyle","startElementStyle","startElementContainer","startElementContainerStyle","chipStyle","height","width"],"sources":["Chip.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, View } from 'react-native';\nimport ButtonBase from '../ButtonBase';\nimport { ChipClose } from '../internal';\nimport { css } from '../styles';\nimport { cloneElementSafely } from '../utils';\nimport type ChipProps from './ChipProps';\nimport type { ChipColor, ChipSize } from './ChipProps';\nimport useChipStyle from './useChipStyle';\n\nexport default function Chip(props: ChipProps) {\n const {\n children,\n color = 'default' as ChipColor,\n numberOfLines,\n onPress,\n selected = false,\n size = 'small' as ChipSize,\n startElement: startElementProp,\n startElementVariant = 'default',\n style: styleProp,\n variant = 'filled',\n ...otherProps\n } = props;\n\n const isSelected = variant === 'outlined' ? false : selected;\n\n const {\n container: containerStyle,\n closeButtonContainer: closeButtonContainerStyle,\n closeIconSize,\n label: labelStyle,\n startElement: startElementStyle,\n startElementContainer: startElementContainerStyle,\n } = useChipStyle(size, startElementVariant, color, isSelected, variant);\n\n const chipStyle = css([\n containerStyle,\n styleProp,\n ]);\n\n const startElement = (\n <View style={startElementContainerStyle}>\n {cloneElementSafely(startElementProp, { style: startElementStyle })}\n </View>\n );\n\n return (\n <ButtonBase\n disabled={!onPress}\n onPress={onPress}\n style={chipStyle}\n {...otherProps}\n >\n {startElement}\n\n <Text\n children={children}\n numberOfLines={numberOfLines}\n style={labelStyle}\n />\n\n {isSelected ? (\n <View style={closeButtonContainerStyle}>\n <ChipClose\n color={'baseInverse'}\n height={closeIconSize?.height}\n width={closeIconSize?.width}\n />\n </View>\n ) : null}\n </ButtonBase>\n );\n}\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,cAA3B;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,GAAT,QAAoB,WAApB;AACA,SAASC,kBAAT,QAAmC,UAAnC;AAGA,OAAOC,YAAP,MAAyB,gBAAzB;AAEA,eAAe,SAASC,IAAT,CAAcC,KAAd,EAAgC;EAC3C,MAAM;IACFC,QADE;IAEFC,KAAK,GAAG,SAFN;IAGFC,aAHE;IAIFC,OAJE;IAKFC,QAAQ,GAAG,KALT;IAMFC,IAAI,GAAG,OANL;IAOFC,YAAY,EAAEC,gBAPZ;IAQFC,mBAAmB,GAAG,SARpB;IASFC,KAAK,EAAEC,SATL;IAUFC,OAAO,GAAG,QAVR;IAWF,GAAGC;EAXD,IAYFb,KAZJ;EAcA,MAAMc,UAAU,GAAGF,OAAO,KAAK,UAAZ,GAAyB,KAAzB,GAAiCP,QAApD;EAEA,MAAM;IACFU,SAAS,EAAEC,cADT;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