@fountain-ui/core 3.0.0-alpha.46 → 3.0.0-alpha.47
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/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/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/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
|
@@ -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={'baseIn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AFnB;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;;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,EAKF;EACT,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO,IAAAC,cAAA,EAAmB,MAAM;IAAA;;IAC5B,MAAMC,YA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AACP,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,EA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AE,EACP,GAAGnB,kBADI;QAEP,6BAAGiB,eAAe,CAACtC,mBAAD,CAAlB,0DAAG,sBAAsCwC,SAAzC,CAFO;QAGP,IAAItC,QAAQ,GAAG;UAAEyC,YAAY,EAAEvC,KAAK,CAACsC,OAAN,CAAcL,OAAO,GAAG,GAAH,GAAS,IAA9B;QAAhB,CAAH,GAA2D,EAAvE;MAHO,CADR;MAMHgB,oBAAoB,EAAE/D,4BAA4B,CAACS,IAAD,CAN/C;MAOHJ,aAAa,EAAEA,aAAa,CAACI,IAAD,CAPzB;MAQHuD,KAAK,EAAExC,YAAY,CAACf,IAAD,CARhB;MASH8C,YAAY,4BAAEP,eAAe,CAACtC,mBAAD,CAAjB,2DAAE,uBAAsC6C,YATjD;MAUHC,qBAAqB,4BAAER,eAAe,CAACtC,mBAAD,CAAjB,2DAAE,uBAAsC8C;IAV1D,CAAP;EAYH,CAjHM,EAiHJ,CAAC1C,KAAD,EAAQL,IAAR,EAAcC,mBAAd,EAAmCC,KAAnC,EAA0CC,QAA1C,EAAoDC,OAApD,CAjHI,CAAP;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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Variant = '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;IAEFC,oBAAoB,EAAEC,yBAFpB;IAGFC,aAHE;IAIFC,KAAK,EAAEC,UAJL;IAKFd,YAAY,EAAEe,iBALZ;IAMFC,qBAAqB,EAAEC;EANrB,IAOF1B,YAAY,CAACQ,IAAD,EAAOG,mBAAP,EAA4BP,KAA5B,EAAmCY,UAAnC,EAA+CF,OAA/C,CAPhB;EASA,MAAMa,SAAS,GAAG7B,GAAG,CAAC,CAClBoB,cADkB,EAElBL,SAFkB,CAAD,CAArB;EAKA,MAAMJ,YAAY,gBACd,oBAAC,IAAD;IAAM,KAAK,EAAEiB;EAAb,GACK3B,kBAAkB,CAACW,gBAAD,EAAmB;IAAEE,KAAK,EAAEY;EAAT,CAAnB,CADvB,CADJ;EAMA,oBACI,oBAAC,UAAD;IACI,QAAQ,EAAE,CAAClB,OADf;IAEI,OAAO,EAAEA,OAFb;IAGI,KAAK,EAAEqB;EAHX,GAIQZ,UAJR,GAMKN,YANL,eAQI,oBAAC,IAAD;IACI,QAAQ,EAAEN,QADd;IAEI,aAAa,EAAEE,aAFnB;IAGI,KAAK,EAAEkB;EAHX,EARJ,EAcKP,UAAU,gBACP,oBAAC,IAAD;IAAM,KAAK,EAAEI;EAAb,gBACI,oBAAC,SAAD;IACI,KAAK,EAAE,aADX;IAEI,MAAM,EAAEC,aAAF,aAAEA,aAAF,uBAAEA,aAAa,CAAEO,MAF3B;IAGI,KAAK,EAAEP,aAAF,aAAEA,aAAF,uBAAEA,aAAa,CAAEQ;EAH1B,EADJ,CADO,GAQP,IAtBR,CADJ;AA0BH"}
|
|
@@ -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":"AAIA,OAAO,MAAMA,UAAU,GAAG,CAAC,SAAD,EAAY,OAAZ,CAAnB;AAGP,OAAO,MAAMC,SAAS,GAAG,CAAC,OAAD,EAAU,OAAV,CAAlB;AAGP,OAAO,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":"AAIA,OAAO,MAAMA,UAAU,GAAG,CAAC,SAAD,EAAY,OAAZ,CAAnB;AAGP,OAAO,MAAMC,SAAS,GAAG,CAAC,OAAD,EAAU,OAAV,CAAlB;AAGP,OAAO,MAAMC,wBAAwB,GAAG,CAAC,SAAD,EAAY,QAAZ,EAAsB,OAAtB,EAA+B,MAA/B,CAAjC;AAGP,OAAO,MAAMC,YAAY,GAAG,CAAC,QAAD,EAAW,UAAX,CAArB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","chipColors","chipSizes","chipStartElementVariants"],"sources":["index.ts"],"sourcesContent":["export { default } from './Chip';\nexport type { default as ChipProps } from './ChipProps';\nexport { chipColors, chipSizes, chipStartElementVariants } from './ChipProps';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,QAAxB;AAEA,SAASC,UAAT,EAAqBC,SAArB,EAAgCC,wBAAhC,
|
|
1
|
+
{"version":3,"names":["default","chipColors","chipSizes","chipStartElementVariants","chipVariants"],"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,SAASA,OAAT,QAAwB,QAAxB;AAEA,SAASC,UAAT,EAAqBC,SAArB,EAAgCC,wBAAhC,EAA0DC,YAA1D,QAA8E,aAA9E"}
|
|
@@ -22,26 +22,33 @@ const closeIconSize = {
|
|
|
22
22
|
}; // TODO: need to refactoring...
|
|
23
23
|
|
|
24
24
|
export default function useChipStyle(size, startElementVariant, color, selected) {
|
|
25
|
+
let variant = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'filled';
|
|
25
26
|
const theme = useTheme();
|
|
26
27
|
return useMemo(() => {
|
|
27
28
|
var _variantStyleMap$star, _variantStyleMap$star2, _variantStyleMap$star3;
|
|
28
29
|
|
|
30
|
+
const isOutlined = variant === 'outlined';
|
|
31
|
+
const textColor = selected ? theme.palette.text.strongInverse : isOutlined ? theme.palette.text.base : theme.palette.text.strong;
|
|
29
32
|
const fontStyleMap = {
|
|
30
33
|
small: createFontStyle(theme, {
|
|
31
34
|
selector: typography => typography.caption1.medium,
|
|
32
|
-
color:
|
|
35
|
+
color: textColor
|
|
33
36
|
}),
|
|
34
37
|
large: createFontStyle(theme, {
|
|
35
38
|
selector: typography => typography.body2.medium,
|
|
36
|
-
color:
|
|
39
|
+
color: textColor
|
|
37
40
|
})
|
|
38
41
|
};
|
|
39
42
|
const baseContainerStyle = {
|
|
40
43
|
alignItems: 'center',
|
|
41
|
-
backgroundColor: selected ? theme.palette.fill.base : color === 'white' ? theme.palette.surface.base : theme.palette.fill.weaker,
|
|
44
|
+
backgroundColor: selected ? theme.palette.fill.base : isOutlined ? 'transparent' : color === 'white' ? theme.palette.surface.base : theme.palette.fill.weaker,
|
|
42
45
|
borderRadius: theme.shape.radius.full,
|
|
43
46
|
flexDirection: 'row',
|
|
44
|
-
overflow: 'hidden'
|
|
47
|
+
overflow: 'hidden',
|
|
48
|
+
...(isOutlined && {
|
|
49
|
+
borderWidth: 1,
|
|
50
|
+
borderColor: theme.palette.border.weak
|
|
51
|
+
})
|
|
45
52
|
};
|
|
46
53
|
const isLarge = size === 'large';
|
|
47
54
|
const variantStyleMap = {
|
|
@@ -115,6 +122,6 @@ export default function useChipStyle(size, startElementVariant, color, selected)
|
|
|
115
122
|
startElement: (_variantStyleMap$star2 = variantStyleMap[startElementVariant]) === null || _variantStyleMap$star2 === void 0 ? void 0 : _variantStyleMap$star2.startElement,
|
|
116
123
|
startElementContainer: (_variantStyleMap$star3 = variantStyleMap[startElementVariant]) === null || _variantStyleMap$star3 === void 0 ? void 0 : _variantStyleMap$star3.startElementContainer
|
|
117
124
|
};
|
|
118
|
-
}, [theme, size, startElementVariant, color, selected]);
|
|
125
|
+
}, [theme, size, startElementVariant, color, selected, variant]);
|
|
119
126
|
}
|
|
120
127
|
//# sourceMappingURL=useChipStyle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","createFontStyle","useTheme","closeButtonContainerStyleMap","small","marginLeft","paddingTop","large","closeIconSize","height","width","useChipStyle","size","startElementVariant","color","selected","theme","fontStyleMap","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,SAASA,OAAT,QAAwB,OAAxB;AAIA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,WAA1C;AAcA,MAAMC,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;;AACA,eAAe,SAASC,YAAT,CACXC,IADW,EAEXC,mBAFW,EAGXC,KAHW,EAIXC,QAJW,EAKF;EACT,MAAMC,KAAK,GAAGd,QAAQ,EAAtB;EAEA,OAAOF,OAAO,CAAY,MAAM;IAAA;;IAC5B,MAAMiB,YAAyC,GAAG;MAC9Cb,KAAK,EAAEH,eAAe,CAACe,KAAD,EAAQ;QAC1BE,QAAQ,EAAGC,UAAD,IAAgBA,UAAU,CAACC,QAAX,CAAoBC,MADpB;QAE1BP,KAAK,EAAEC,QAAQ,GAAGC,KAAK,CAACM,OAAN,CAAcC,IAAd,CAAmBC,aAAtB,GAAsCR,KAAK,CAACM,OAAN,CAAcC,IAAd,CAAmBE;MAF9C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AAd;AAmGH"}
|
|
1
|
+
{"version":3,"names":["useMemo","createFontStyle","useTheme","closeButtonContainerStyleMap","small","marginLeft","paddingTop","large","closeIconSize","height","width","useChipStyle","size","startElementVariant","color","selected","variant","theme","isOutlined","textColor","palette","text","strongInverse","base","strong","fontStyleMap","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,SAASA,OAAT,QAAwB,OAAxB;AAIA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,WAA1C;AAcA,MAAMC,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;;AACA,eAAe,SAASC,YAAT,CACXC,IADW,EAEXC,mBAFW,EAGXC,KAHW,EAIXC,QAJW,EAMF;EAAA,IADTC,OACS,uEADc,QACd;EACT,MAAMC,KAAK,GAAGf,QAAQ,EAAtB;EAEA,OAAOF,OAAO,CAAY,MAAM;IAAA;;IAC5B,MAAMkB,UAAU,GAAGF,OAAO,KAAK,UAA/B;IAEA,MAAMG,S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BAAoB,EAAE5D,4BAA4B,CAACS,IAAD,CAN/C;MAOHJ,aAAa,EAAEA,aAAa,CAACI,IAAD,CAPzB;MAQHoD,KAAK,EAAEvC,YAAY,CAACb,IAAD,CARhB;MASH2C,YAAY,4BAAEP,eAAe,CAACnC,mBAAD,CAAjB,2DAAE,uBAAsC0C,YATjD;MAUHC,qBAAqB,4BAAER,eAAe,CAACnC,mBAAD,CAAjB,2DAAE,uBAAsC2C;IAV1D,CAAP;EAYH,CAjHa,EAiHX,CAACvC,KAAD,EAAQL,IAAR,EAAcC,mBAAd,EAAmCC,KAAnC,EAA0CC,QAA1C,EAAoDC,OAApD,CAjHW,CAAd;AAkHH"}
|
|
@@ -56,12 +56,11 @@ export default function Radio(props) {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
const isChecked =
|
|
59
|
+
const isChecked = context ? context.value === value : checked;
|
|
60
60
|
const defaultCheckedIcon = /*#__PURE__*/React.createElement(CheckedIcon, {
|
|
61
61
|
color: 'accent'
|
|
62
62
|
});
|
|
63
63
|
const checkedIcon = checkIconProp ?? defaultCheckedIcon;
|
|
64
|
-
const icon = isChecked ? checkedIcon : null;
|
|
65
64
|
const startIcon = cloneElementSafely(startIconProp, {
|
|
66
65
|
color: 'strong',
|
|
67
66
|
height: DEFAULT_START_ICON_SIZE,
|
|
@@ -90,7 +89,11 @@ export default function Radio(props) {
|
|
|
90
89
|
color: 'base',
|
|
91
90
|
weight: 'regular',
|
|
92
91
|
children: description
|
|
93
|
-
}) : null),
|
|
92
|
+
}) : null), /*#__PURE__*/React.createElement(Column, {
|
|
93
|
+
style: {
|
|
94
|
+
opacity: Number(isChecked)
|
|
95
|
+
}
|
|
96
|
+
}, checkedIcon));
|
|
94
97
|
}
|
|
95
98
|
;
|
|
96
99
|
//# sourceMappingURL=Radio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useContext","Text","ButtonBase","Column","Check","CheckedIcon","Row","createFontStyle","css","useTheme","cloneElementSafely","RadioContext","Typography","DEFAULT_START_ICON_SIZE","useStyles","theme","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","handlePress","isChecked","defaultCheckedIcon","
|
|
1
|
+
{"version":3,"names":["React","useContext","Text","ButtonBase","Column","Check","CheckedIcon","Row","createFontStyle","css","useTheme","cloneElementSafely","RadioContext","Typography","DEFAULT_START_ICON_SIZE","useStyles","theme","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","handlePress","isChecked","defaultCheckedIcon","color","height","width","rootStyle","fontStyle","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,OAAOA,KAAP,IAAgBC,UAAhB,QAAkC,OAAlC;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AACA,OAAOC,GAAP,MAAgB,QAAhB;AACA,SAASC,eAAT,EAA0BC,GAA1B,EAA+BC,QAA/B,QAA+C,WAA/C;AACA,SAASC,kBAAT,QAAmC,UAAnC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@ -7,6 +7,8 @@ export declare const chipSizes: readonly ["large", "small"];
|
|
|
7
7
|
export declare type ChipSize = typeof chipSizes[number];
|
|
8
8
|
export declare const chipStartElementVariants: readonly ["default", "avatar", "image", "icon"];
|
|
9
9
|
export declare type ChipStartElementVariant = typeof chipStartElementVariants[number];
|
|
10
|
+
export declare const chipVariants: readonly ["filled", "outlined"];
|
|
11
|
+
export declare type ChipVariant = typeof chipVariants[number];
|
|
10
12
|
export default interface ChipProps extends OverridableComponentProps<ButtonBaseProps, {
|
|
11
13
|
/**
|
|
12
14
|
* The content of the component.
|
|
@@ -34,6 +36,11 @@ export default interface ChipProps extends OverridableComponentProps<ButtonBaseP
|
|
|
34
36
|
* Element placed before the children.
|
|
35
37
|
*/
|
|
36
38
|
startElement?: React.ReactElement;
|
|
39
|
+
/**
|
|
40
|
+
* Determines the visual style of the component.
|
|
41
|
+
* @default 'filled'
|
|
42
|
+
*/
|
|
43
|
+
variant?: ChipVariant;
|
|
37
44
|
/**
|
|
38
45
|
* Determines the style of the start element.
|
|
39
46
|
*/
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default } from './Chip';
|
|
2
|
-
export type { default as ChipProps } from './ChipProps';
|
|
3
|
-
export { chipColors, chipSizes, chipStartElementVariants } from './ChipProps';
|
|
2
|
+
export type { default as ChipProps, ChipVariant } from './ChipProps';
|
|
3
|
+
export { chipColors, chipSizes, chipStartElementVariants, chipVariants } from './ChipProps';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TextStyle } from 'react-native';
|
|
2
2
|
import type { FountainUiStyle } from '@fountain-ui/styles';
|
|
3
3
|
import type { SvgIconProps } from '../SvgIcon';
|
|
4
|
-
import type { ChipColor, ChipSize, ChipStartElementVariant } from './ChipProps';
|
|
4
|
+
import type { ChipColor, ChipSize, ChipStartElementVariant, ChipVariant } from './ChipProps';
|
|
5
5
|
interface ChipStyle {
|
|
6
6
|
container: FountainUiStyle;
|
|
7
7
|
closeButtonContainer?: FountainUiStyle;
|
|
@@ -10,5 +10,5 @@ interface ChipStyle {
|
|
|
10
10
|
startElement?: FountainUiStyle;
|
|
11
11
|
startElementContainer?: FountainUiStyle;
|
|
12
12
|
}
|
|
13
|
-
export default function useChipStyle(size: ChipSize, startElementVariant: ChipStartElementVariant, color: ChipColor, selected: boolean): ChipStyle;
|
|
13
|
+
export default function useChipStyle(size: ChipSize, startElementVariant: ChipStartElementVariant, color: ChipColor, selected: boolean, variant?: ChipVariant): ChipStyle;
|
|
14
14
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fountain-ui/core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.47",
|
|
4
4
|
"author": "Fountain-UI Team",
|
|
5
5
|
"description": "React components that implement Tappytoon's Fountain Design.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "b478e97e8323697e6e21635b36779fb3b7530dc9"
|
|
71
71
|
}
|
package/src/Chip/Chip.tsx
CHANGED
|
@@ -19,9 +19,12 @@ export default function Chip(props: ChipProps) {
|
|
|
19
19
|
startElement: startElementProp,
|
|
20
20
|
startElementVariant = 'default',
|
|
21
21
|
style: styleProp,
|
|
22
|
+
variant = 'filled',
|
|
22
23
|
...otherProps
|
|
23
24
|
} = props;
|
|
24
25
|
|
|
26
|
+
const isSelected = variant === 'outlined' ? false : selected;
|
|
27
|
+
|
|
25
28
|
const {
|
|
26
29
|
container: containerStyle,
|
|
27
30
|
closeButtonContainer: closeButtonContainerStyle,
|
|
@@ -29,7 +32,7 @@ export default function Chip(props: ChipProps) {
|
|
|
29
32
|
label: labelStyle,
|
|
30
33
|
startElement: startElementStyle,
|
|
31
34
|
startElementContainer: startElementContainerStyle,
|
|
32
|
-
} = useChipStyle(size, startElementVariant, color,
|
|
35
|
+
} = useChipStyle(size, startElementVariant, color, isSelected, variant);
|
|
33
36
|
|
|
34
37
|
const chipStyle = css([
|
|
35
38
|
containerStyle,
|
|
@@ -57,7 +60,7 @@ export default function Chip(props: ChipProps) {
|
|
|
57
60
|
style={labelStyle}
|
|
58
61
|
/>
|
|
59
62
|
|
|
60
|
-
{
|
|
63
|
+
{isSelected ? (
|
|
61
64
|
<View style={closeButtonContainerStyle}>
|
|
62
65
|
<ChipClose
|
|
63
66
|
color={'baseInverse'}
|
package/src/Chip/ChipProps.ts
CHANGED
|
@@ -11,6 +11,9 @@ export type ChipSize = typeof chipSizes[number];
|
|
|
11
11
|
export const chipStartElementVariants = ['default', 'avatar', 'image', 'icon'] as const;
|
|
12
12
|
export type ChipStartElementVariant = typeof chipStartElementVariants[number];
|
|
13
13
|
|
|
14
|
+
export const chipVariants = ['filled', 'outlined'] as const;
|
|
15
|
+
export type ChipVariant = typeof chipVariants[number];
|
|
16
|
+
|
|
14
17
|
export default interface ChipProps extends OverridableComponentProps<ButtonBaseProps, {
|
|
15
18
|
/**
|
|
16
19
|
* The content of the component.
|
|
@@ -44,6 +47,12 @@ export default interface ChipProps extends OverridableComponentProps<ButtonBaseP
|
|
|
44
47
|
*/
|
|
45
48
|
startElement?: React.ReactElement;
|
|
46
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Determines the visual style of the component.
|
|
52
|
+
* @default 'filled'
|
|
53
|
+
*/
|
|
54
|
+
variant?: ChipVariant;
|
|
55
|
+
|
|
47
56
|
/**
|
|
48
57
|
* Determines the style of the start element.
|
|
49
58
|
*/
|
package/src/Chip/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default } from './Chip';
|
|
2
|
-
export type { default as ChipProps } from './ChipProps';
|
|
3
|
-
export { chipColors, chipSizes, chipStartElementVariants } from './ChipProps';
|
|
2
|
+
export type { default as ChipProps, ChipVariant } from './ChipProps';
|
|
3
|
+
export { chipColors, chipSizes, chipStartElementVariants, chipVariants } from './ChipProps';
|
package/src/Chip/useChipStyle.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { TextStyle } from 'react-native';
|
|
|
3
3
|
import type { FountainUiStyle } from '@fountain-ui/styles';
|
|
4
4
|
import type { SvgIconProps } from '../SvgIcon';
|
|
5
5
|
import { createFontStyle, useTheme } from '../styles';
|
|
6
|
-
import type { ChipColor, ChipSize, ChipStartElementVariant } from './ChipProps';
|
|
6
|
+
import type { ChipColor, ChipSize, ChipStartElementVariant, ChipVariant } from './ChipProps';
|
|
7
7
|
|
|
8
8
|
interface ChipStyle {
|
|
9
9
|
container: FountainUiStyle;
|
|
@@ -44,30 +44,46 @@ export default function useChipStyle(
|
|
|
44
44
|
startElementVariant: ChipStartElementVariant,
|
|
45
45
|
color: ChipColor,
|
|
46
46
|
selected: boolean,
|
|
47
|
+
variant: ChipVariant = 'filled',
|
|
47
48
|
): ChipStyle {
|
|
48
49
|
const theme = useTheme();
|
|
49
50
|
|
|
50
51
|
return useMemo<ChipStyle>(() => {
|
|
52
|
+
const isOutlined = variant === 'outlined';
|
|
53
|
+
|
|
54
|
+
const textColor = selected
|
|
55
|
+
? theme.palette.text.strongInverse
|
|
56
|
+
: isOutlined
|
|
57
|
+
? theme.palette.text.base
|
|
58
|
+
: theme.palette.text.strong;
|
|
59
|
+
|
|
51
60
|
const fontStyleMap: Record<ChipSize, TextStyle> = {
|
|
52
61
|
small: createFontStyle(theme, {
|
|
53
62
|
selector: (typography) => typography.caption1.medium,
|
|
54
|
-
color:
|
|
63
|
+
color: textColor,
|
|
55
64
|
}),
|
|
56
65
|
large: createFontStyle(theme, {
|
|
57
66
|
selector: (typography) => typography.body2.medium,
|
|
58
|
-
color:
|
|
67
|
+
color: textColor,
|
|
59
68
|
}),
|
|
60
69
|
};
|
|
61
70
|
|
|
62
71
|
const baseContainerStyle: FountainUiStyle = {
|
|
63
72
|
alignItems: 'center',
|
|
64
|
-
backgroundColor: selected
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
backgroundColor: selected
|
|
74
|
+
? theme.palette.fill.base
|
|
75
|
+
: isOutlined
|
|
76
|
+
? 'transparent'
|
|
77
|
+
: color === 'white'
|
|
78
|
+
? theme.palette.surface.base
|
|
79
|
+
: theme.palette.fill.weaker,
|
|
68
80
|
borderRadius: theme.shape.radius.full,
|
|
69
81
|
flexDirection: 'row',
|
|
70
82
|
overflow: 'hidden',
|
|
83
|
+
...(isOutlined && {
|
|
84
|
+
borderWidth: 1,
|
|
85
|
+
borderColor: theme.palette.border.weak,
|
|
86
|
+
}),
|
|
71
87
|
};
|
|
72
88
|
|
|
73
89
|
const isLarge = size === 'large';
|
|
@@ -145,5 +161,5 @@ export default function useChipStyle(
|
|
|
145
161
|
startElement: variantStyleMap[startElementVariant]?.startElement,
|
|
146
162
|
startElementContainer: variantStyleMap[startElementVariant]?.startElementContainer,
|
|
147
163
|
};
|
|
148
|
-
}, [theme, size, startElementVariant, color, selected]);
|
|
164
|
+
}, [theme, size, startElementVariant, color, selected, variant]);
|
|
149
165
|
}
|
package/src/Radio/Radio.tsx
CHANGED
|
@@ -62,14 +62,15 @@ export default function Radio(props: RadioProps) {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
const isChecked = context
|
|
65
|
+
const isChecked = context
|
|
66
|
+
? context.value === value
|
|
67
|
+
: checked;
|
|
66
68
|
|
|
67
69
|
const defaultCheckedIcon = (
|
|
68
70
|
<CheckedIcon color={'accent'}/>
|
|
69
71
|
);
|
|
70
72
|
|
|
71
73
|
const checkedIcon = checkIconProp ?? defaultCheckedIcon;
|
|
72
|
-
const icon = isChecked ? checkedIcon : null;
|
|
73
74
|
|
|
74
75
|
const startIcon = cloneElementSafely(startIconProp, {
|
|
75
76
|
color: 'strong',
|
|
@@ -120,7 +121,9 @@ export default function Radio(props: RadioProps) {
|
|
|
120
121
|
) : null}
|
|
121
122
|
</Column>
|
|
122
123
|
|
|
123
|
-
{
|
|
124
|
+
<Column style={{ opacity: Number(isChecked) }}>
|
|
125
|
+
{checkedIcon}
|
|
126
|
+
</Column>
|
|
124
127
|
</ButtonBase>
|
|
125
128
|
);
|
|
126
129
|
};
|