@fountain-ui/core 3.0.0-alpha.23 → 3.0.0-alpha.25
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 +8 -4
- package/build/commonjs/Chip/Chip.js.map +1 -1
- package/build/commonjs/Chip/useChipStyle.js +25 -15
- package/build/commonjs/Chip/useChipStyle.js.map +1 -1
- package/build/commonjs/Dialog/useDialogStyle.js +1 -1
- package/build/commonjs/Dialog/useDialogStyle.js.map +1 -1
- package/build/commonjs/TextField/TextField.js +22 -5
- package/build/commonjs/TextField/TextField.js.map +1 -1
- package/build/commonjs/TextField/useVariantStyleMap.js +21 -21
- package/build/commonjs/TextField/useVariantStyleMap.js.map +1 -1
- package/build/commonjs/internal/icons/ChipClose.js +23 -0
- package/build/commonjs/internal/icons/ChipClose.js.map +1 -0
- package/build/commonjs/internal/icons/index.js +8 -0
- package/build/commonjs/internal/icons/index.js.map +1 -1
- package/build/module/Chip/Chip.js +9 -5
- package/build/module/Chip/Chip.js.map +1 -1
- package/build/module/Chip/useChipStyle.js +25 -15
- package/build/module/Chip/useChipStyle.js.map +1 -1
- package/build/module/Dialog/useDialogStyle.js +1 -1
- package/build/module/Dialog/useDialogStyle.js.map +1 -1
- package/build/module/TextField/TextField.js +22 -5
- package/build/module/TextField/TextField.js.map +1 -1
- package/build/module/TextField/useVariantStyleMap.js +21 -21
- package/build/module/TextField/useVariantStyleMap.js.map +1 -1
- package/build/module/internal/icons/ChipClose.js +9 -0
- package/build/module/internal/icons/ChipClose.js.map +1 -0
- package/build/module/internal/icons/index.js +1 -0
- package/build/module/internal/icons/index.js.map +1 -1
- package/build/typescript/Chip/useChipStyle.d.ts +3 -1
- package/build/typescript/TextField/useVariantStyleMap.d.ts +2 -0
- package/build/typescript/internal/icons/ChipClose.d.ts +131 -0
- package/build/typescript/internal/icons/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/Chip/Chip.tsx +10 -6
- package/src/Chip/useChipStyle.ts +29 -16
- package/src/Dialog/useDialogStyle.ts +1 -1
- package/src/TextField/TextField.tsx +40 -14
- package/src/TextField/useVariantStyleMap.ts +20 -18
- package/src/internal/icons/ChipClose.tsx +13 -0
- package/src/internal/icons/index.ts +1 -0
package/src/Chip/Chip.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text, View } from 'react-native';
|
|
3
3
|
import ButtonBase from '../ButtonBase';
|
|
4
|
-
import {
|
|
4
|
+
import { ChipClose } from '../internal';
|
|
5
5
|
import { css } from '../styles';
|
|
6
6
|
import { cloneElementSafely } from '../utils';
|
|
7
7
|
import type ChipProps from './ChipProps';
|
|
@@ -24,7 +24,8 @@ export default function Chip(props: ChipProps) {
|
|
|
24
24
|
|
|
25
25
|
const {
|
|
26
26
|
container: containerStyle,
|
|
27
|
-
|
|
27
|
+
closeButtonContainer: closeButtonContainerStyle,
|
|
28
|
+
closeIconSize,
|
|
28
29
|
label: labelStyle,
|
|
29
30
|
startElement: startElementStyle,
|
|
30
31
|
startElementContainer: startElementContainerStyle,
|
|
@@ -57,10 +58,13 @@ export default function Chip(props: ChipProps) {
|
|
|
57
58
|
/>
|
|
58
59
|
|
|
59
60
|
{selected ? (
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
<View style={closeButtonContainerStyle}>
|
|
62
|
+
<ChipClose
|
|
63
|
+
color={'baseInverse'}
|
|
64
|
+
height={closeIconSize?.height}
|
|
65
|
+
width={closeIconSize?.width}
|
|
66
|
+
/>
|
|
67
|
+
</View>
|
|
64
68
|
) : null}
|
|
65
69
|
</ButtonBase>
|
|
66
70
|
);
|
package/src/Chip/useChipStyle.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import type { TextStyle } from 'react-native';
|
|
3
3
|
import type { FountainUiStyle } from '@fountain-ui/styles';
|
|
4
|
+
import type { SvgIconProps } from '../SvgIcon';
|
|
4
5
|
import { createFontStyle, useTheme } from '../styles';
|
|
5
6
|
import type { ChipColor, ChipSize, ChipStartElementVariant } from './ChipProps';
|
|
6
7
|
|
|
7
8
|
interface ChipStyle {
|
|
8
9
|
container: FountainUiStyle;
|
|
9
|
-
|
|
10
|
+
closeButtonContainer?: FountainUiStyle;
|
|
11
|
+
closeIconSize?: Pick<SvgIconProps, 'height' | 'width'>;
|
|
10
12
|
label: TextStyle;
|
|
11
13
|
startElement?: FountainUiStyle;
|
|
12
14
|
startElementContainer?: FountainUiStyle;
|
|
@@ -14,6 +16,28 @@ interface ChipStyle {
|
|
|
14
16
|
|
|
15
17
|
type VariantStyleMap = Record<ChipStartElementVariant, Partial<ChipStyle>>;
|
|
16
18
|
|
|
19
|
+
const closeButtonContainerStyleMap: Record<ChipSize, FountainUiStyle> = {
|
|
20
|
+
small: {
|
|
21
|
+
marginLeft: 8,
|
|
22
|
+
paddingTop: 1,
|
|
23
|
+
},
|
|
24
|
+
large: {
|
|
25
|
+
marginLeft: 10,
|
|
26
|
+
paddingTop: 1,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const closeIconSize: Record<ChipSize, ChipStyle['closeIconSize']> = {
|
|
31
|
+
small: {
|
|
32
|
+
height: 14,
|
|
33
|
+
width: 8.17,
|
|
34
|
+
},
|
|
35
|
+
large: {
|
|
36
|
+
height: 16,
|
|
37
|
+
width: 9,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
17
41
|
// TODO: need to refactoring...
|
|
18
42
|
export default function useChipStyle(
|
|
19
43
|
size: ChipSize,
|
|
@@ -35,19 +59,6 @@ export default function useChipStyle(
|
|
|
35
59
|
}),
|
|
36
60
|
};
|
|
37
61
|
|
|
38
|
-
const closeButtonStyleMap: Record<ChipSize, FountainUiStyle> = {
|
|
39
|
-
small: {
|
|
40
|
-
height: 14,
|
|
41
|
-
marginLeft: theme.spacing(2),
|
|
42
|
-
width: 8.17,
|
|
43
|
-
},
|
|
44
|
-
large: {
|
|
45
|
-
height: 17,
|
|
46
|
-
marginLeft: theme.spacing(2.5),
|
|
47
|
-
width: 9,
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
62
|
const baseContainerStyle: FountainUiStyle = {
|
|
52
63
|
alignItems: 'center',
|
|
53
64
|
backgroundColor: selected ? theme.palette.fill.base
|
|
@@ -115,7 +126,8 @@ export default function useChipStyle(
|
|
|
115
126
|
default: {
|
|
116
127
|
container: {
|
|
117
128
|
paddingBottom: theme.spacing(1.75),
|
|
118
|
-
|
|
129
|
+
paddingLeft: theme.spacing(isLarge ? 3.5 : 3),
|
|
130
|
+
paddingRight: theme.spacing(isLarge ? 3.5 : 3),
|
|
119
131
|
paddingTop: theme.spacing(1.5),
|
|
120
132
|
},
|
|
121
133
|
},
|
|
@@ -127,7 +139,8 @@ export default function useChipStyle(
|
|
|
127
139
|
...variantStyleMap[startElementVariant]?.container,
|
|
128
140
|
...(selected ? { paddingRight: theme.spacing(isLarge ? 2.5 : 2.25) } : {}),
|
|
129
141
|
},
|
|
130
|
-
|
|
142
|
+
closeButtonContainer: closeButtonContainerStyleMap[size],
|
|
143
|
+
closeIconSize: closeIconSize[size],
|
|
131
144
|
label: fontStyleMap[size],
|
|
132
145
|
startElement: variantStyleMap[startElementVariant]?.startElement,
|
|
133
146
|
startElementContainer: variantStyleMap[startElementVariant]?.startElementContainer,
|
|
@@ -19,6 +19,13 @@ const styles = StyleSheet.create({
|
|
|
19
19
|
input: {
|
|
20
20
|
flexGrow: 1,
|
|
21
21
|
},
|
|
22
|
+
inputWrapper: {
|
|
23
|
+
flexGrow: 1,
|
|
24
|
+
},
|
|
25
|
+
placeholderWrapper: {
|
|
26
|
+
...StyleSheet.absoluteFillObject,
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
},
|
|
22
29
|
secureToggleButton: {
|
|
23
30
|
alignItems: 'flex-end',
|
|
24
31
|
padding: 0,
|
|
@@ -49,6 +56,7 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
|
|
|
49
56
|
onBlur,
|
|
50
57
|
onChangeText: onChangeTextProp,
|
|
51
58
|
onFocus,
|
|
59
|
+
placeholder: placeholderProp,
|
|
52
60
|
placeholderTextColor: placeholderTextColorProp,
|
|
53
61
|
secureTextEntry: secureTextEntryProp,
|
|
54
62
|
showClearButton: showClearButtonProp,
|
|
@@ -103,11 +111,15 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
|
|
|
103
111
|
const inputStyle = css([
|
|
104
112
|
styles.input,
|
|
105
113
|
variantStyles.inputStyle,
|
|
114
|
+
variantStyles.inputFontStyle,
|
|
106
115
|
Platform.OS === 'web' ? { outlineWidth: 0 } as FountainUiStyle : {},
|
|
107
116
|
styleProp,
|
|
108
117
|
]);
|
|
109
118
|
|
|
110
|
-
const
|
|
119
|
+
const placeholderFontStyle = css([
|
|
120
|
+
variantStyles.inputFontStyle,
|
|
121
|
+
{ color: placeholderTextColorProp ?? theme.palette.status.disabledLabel },
|
|
122
|
+
]);
|
|
111
123
|
|
|
112
124
|
const containerStyle = css([
|
|
113
125
|
styles.root,
|
|
@@ -140,19 +152,33 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
|
|
|
140
152
|
</View>
|
|
141
153
|
) : null}
|
|
142
154
|
|
|
143
|
-
<
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
<View style={styles.inputWrapper}>
|
|
156
|
+
<View
|
|
157
|
+
pointerEvents={'none'}
|
|
158
|
+
style={styles.placeholderWrapper}
|
|
159
|
+
>
|
|
160
|
+
{placeholderProp && !value ? (
|
|
161
|
+
<Text
|
|
162
|
+
children={placeholderProp}
|
|
163
|
+
numberOfLines={1}
|
|
164
|
+
style={placeholderFontStyle}
|
|
165
|
+
/>
|
|
166
|
+
) : null}
|
|
167
|
+
</View>
|
|
168
|
+
|
|
169
|
+
<TextInput
|
|
170
|
+
autoFocus={autoFocus}
|
|
171
|
+
editable={!disabled}
|
|
172
|
+
onBlur={handleBlur}
|
|
173
|
+
onChangeText={handleChangeText}
|
|
174
|
+
onFocus={handleFocus}
|
|
175
|
+
ref={ref}
|
|
176
|
+
secureTextEntry={secureTextEntry}
|
|
177
|
+
style={inputStyle}
|
|
178
|
+
value={value}
|
|
179
|
+
{...otherProps}
|
|
180
|
+
/>
|
|
181
|
+
</View>
|
|
156
182
|
|
|
157
183
|
{showClearButton && value?.length && value.length > 0 ? (
|
|
158
184
|
<IconButton
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
+
import type { TextStyle } from 'react-native';
|
|
2
3
|
import type { FountainUiStyle, Theme } from '@fountain-ui/styles';
|
|
3
4
|
import { typographyOf } from '@fountain-ui/styles';
|
|
4
5
|
import { createFontStyle, useTheme } from '../styles';
|
|
@@ -6,6 +7,7 @@ import type { TextFieldStatus, TextFieldVariant } from './TextFieldProps';
|
|
|
6
7
|
|
|
7
8
|
interface VariantStyleMap {
|
|
8
9
|
containerStyle?: FountainUiStyle;
|
|
10
|
+
inputFontStyle?: TextStyle;
|
|
9
11
|
inputStyle?: FountainUiStyle;
|
|
10
12
|
hintStyle?: FountainUiStyle;
|
|
11
13
|
}
|
|
@@ -53,16 +55,16 @@ export default function useVariantStyleMap(variant: TextFieldVariant, status: Te
|
|
|
53
55
|
inputStyle: {
|
|
54
56
|
padding: 0,
|
|
55
57
|
paddingRight: 16,
|
|
56
|
-
...createFontStyle(theme, {
|
|
57
|
-
selector: (_) => typographyOf({
|
|
58
|
-
fontSize: 18,
|
|
59
|
-
lineHeight: 27,
|
|
60
|
-
fontFamily: 'PretendardStd-SemiBold',
|
|
61
|
-
letterSpacing: 0,
|
|
62
|
-
}),
|
|
63
|
-
color: theme.palette.text.strong,
|
|
64
|
-
}),
|
|
65
58
|
},
|
|
59
|
+
inputFontStyle: createFontStyle(theme, {
|
|
60
|
+
selector: (_) => typographyOf({
|
|
61
|
+
fontSize: 18,
|
|
62
|
+
lineHeight: 27,
|
|
63
|
+
fontFamily: 'PretendardStd-SemiBold',
|
|
64
|
+
letterSpacing: 0,
|
|
65
|
+
}),
|
|
66
|
+
color: theme.palette.text.strong,
|
|
67
|
+
}),
|
|
66
68
|
hintStyle: {
|
|
67
69
|
marginTop: theme.spacing(2),
|
|
68
70
|
...createFontStyle(theme, {
|
|
@@ -84,16 +86,16 @@ export default function useVariantStyleMap(variant: TextFieldVariant, status: Te
|
|
|
84
86
|
},
|
|
85
87
|
inputStyle: {
|
|
86
88
|
padding: 0,
|
|
87
|
-
...createFontStyle(theme, {
|
|
88
|
-
selector: (_) => typographyOf({
|
|
89
|
-
fontSize: 16,
|
|
90
|
-
lineHeight: 19.2,
|
|
91
|
-
fontFamily: 'PretendardStd-SemiBold',
|
|
92
|
-
letterSpacing: -0.16,
|
|
93
|
-
}),
|
|
94
|
-
color: theme.palette.text.strong,
|
|
95
|
-
}),
|
|
96
89
|
},
|
|
90
|
+
inputFontStyle: createFontStyle(theme, {
|
|
91
|
+
selector: (_) => typographyOf({
|
|
92
|
+
fontSize: 16,
|
|
93
|
+
lineHeight: 19.2,
|
|
94
|
+
fontFamily: 'PretendardStd-SemiBold',
|
|
95
|
+
letterSpacing: -0.16,
|
|
96
|
+
}),
|
|
97
|
+
color: theme.palette.text.strong,
|
|
98
|
+
}),
|
|
97
99
|
};
|
|
98
100
|
}
|
|
99
101
|
}, [theme, borderColor, hintColor, variant, isFocused]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Path } from 'react-native-svg';
|
|
3
|
+
import { createSvgIcon } from '../../utils';
|
|
4
|
+
|
|
5
|
+
export default createSvgIcon(
|
|
6
|
+
<Path
|
|
7
|
+
fillRule="evenodd"
|
|
8
|
+
clipRule="evenodd"
|
|
9
|
+
d="M0.170854 3.58753C0.39866 3.35972 0.768006 3.35972 0.995812 3.58753L4.08333 6.67505L7.17085 3.58753C7.39866 3.35972 7.76801 3.35972 7.99581 3.58753C8.22362 3.81533 8.22362 4.18468 7.99581 4.41248L4.90829 7.5L7.99581 10.5875C8.22362 10.8153 8.22362 11.1847 7.99581 11.4125C7.76801 11.6403 7.39866 11.6403 7.17085 11.4125L4.08333 8.32496L0.995812 11.4125C0.768006 11.6403 0.39866 11.6403 0.170854 11.4125C-0.0569515 11.1847 -0.0569515 10.8153 0.170854 10.5875L3.25838 7.5L0.170854 4.41248C-0.0569515 4.18468 -0.0569515 3.81533 0.170854 3.58753Z"
|
|
10
|
+
/>,
|
|
11
|
+
'ChipClose',
|
|
12
|
+
'0 0 9 15',
|
|
13
|
+
);
|
|
@@ -7,6 +7,7 @@ export { default as CheckCircle } from './CheckCircle';
|
|
|
7
7
|
export { default as ChevronDown } from './ChevronDown';
|
|
8
8
|
export { default as ChevronLeft } from './ChevronLeft';
|
|
9
9
|
export { default as ChevronRight } from './ChevronRight';
|
|
10
|
+
export { default as ChipClose } from './ChipClose';
|
|
10
11
|
export { default as CircularProgress } from './CircularProgress';
|
|
11
12
|
export { default as Clear } from './Clear';
|
|
12
13
|
export { default as Close } from './Close';
|