@fountain-ui/core 3.0.0-alpha.47 → 3.0.0-alpha.49
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/Dialog/Dialog.js +1 -0
- package/build/commonjs/Dialog/Dialog.js.map +1 -1
- package/build/commonjs/Modal/Modal.js +28 -19
- package/build/commonjs/Modal/Modal.js.map +1 -1
- package/build/commonjs/Modal/ModalProps.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/commonjs/Toolbar/BackButton/BackButton.js +2 -2
- package/build/commonjs/Toolbar/BackButton/BackButton.js.map +1 -1
- package/build/module/Dialog/Dialog.js +1 -0
- package/build/module/Dialog/Dialog.js.map +1 -1
- package/build/module/Modal/Modal.js +29 -20
- package/build/module/Modal/Modal.js.map +1 -1
- package/build/module/Modal/ModalProps.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/module/Toolbar/BackButton/BackButton.js +2 -2
- package/build/module/Toolbar/BackButton/BackButton.js.map +1 -1
- package/build/typescript/Modal/ModalProps.d.ts +8 -0
- 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/Dialog/Dialog.tsx +1 -0
- package/src/Modal/Modal.tsx +11 -3
- package/src/Modal/ModalProps.ts +9 -0
- package/src/TextField/TextField.tsx +12 -1
- package/src/TextField/TextFieldProps.ts +16 -0
- package/src/TextField/useVariantStyleMap.ts +36 -11
- package/src/Toolbar/BackButton/BackButton.tsx +4 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","css","StyleSheet","useElevationStyle","AnimatedContainer","SimpleBackdrop","createModalCloseEvent","reason","metadata","Modal","props","animationStyle","backdropOpacity","children","closeAnimation","disableAnimation","hideBackdrop","initialOpacity","initialTranslateY","onClose","onEnter","onEnterProp","onEntered","onEnteredProp","onExit","onExitProp","onExited","onExitedProp","openAnimation","offsetAnimation","style","visible","otherProps","handleBackdropPress","exited","setExited","useState","elevationStyle","absoluteFill"],"sources":["Modal.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\nimport { css, StyleSheet } from '../styles';\nimport { useElevationStyle } from '../hooks';\nimport type ModalProps from './ModalProps';\nimport AnimatedContainer from './AnimatedContainer';\nimport SimpleBackdrop from './SimpleBackdrop';\n\nexport type ModalCloseReasonType = 'OUTSIDE_PRESS' | 'HARDWARE_BACK_PRESS' | 'CLOSE_BUTTON_PRESS' | 'UNKNOWN';\n\nexport interface ModalCloseEvent {\n metadata: {\n reason: ModalCloseReasonType\n };\n}\n\nexport const createModalCloseEvent = (reason: ModalCloseReasonType) => ({\n metadata: {\n reason,\n },\n});\n\nexport default function Modal(props: ModalProps) {\n const {\n animationStyle,\n backdropOpacity = 0.75,\n children,\n closeAnimation,\n disableAnimation = false,\n hideBackdrop = false,\n initialOpacity,\n initialTranslateY,\n onClose,\n onEnter: onEnterProp,\n onEntered: onEnteredProp,\n onExit: onExitProp,\n onExited: onExitedProp,\n openAnimation,\n offsetAnimation,\n style,\n visible,\n ...otherProps\n } = props;\n\n const handleBackdropPress = () => {\n if (onClose) {\n onClose(createModalCloseEvent('OUTSIDE_PRESS'));\n }\n };\n\n const [exited, setExited] = React.useState(true);\n\n const elevationStyle = useElevationStyle(6);\n\n const onEnter = () => {\n setExited(false);\n onEnterProp?.();\n };\n\n const onEntered = () => {\n onEnteredProp?.();\n };\n\n const onExit = () => {\n onExitProp?.();\n };\n\n const onExited = () => {\n setExited(true);\n onExitedProp?.();\n };\n\n if (!visible) {\n if (disableAnimation || exited) {\n return null;\n }\n }\n\n return (\n <
|
|
1
|
+
{"version":3,"names":["React","KeyboardAvoidingView","Platform","View","css","StyleSheet","useElevationStyle","AnimatedContainer","SimpleBackdrop","createModalCloseEvent","reason","metadata","Modal","props","animationStyle","avoidKeyboard","backdropOpacity","children","closeAnimation","disableAnimation","hideBackdrop","initialOpacity","initialTranslateY","onClose","onEnter","onEnterProp","onEntered","onEnteredProp","onExit","onExitProp","onExited","onExitedProp","openAnimation","offsetAnimation","style","visible","otherProps","handleBackdropPress","exited","setExited","useState","elevationStyle","Container","containerProps","behavior","OS","undefined","absoluteFill"],"sources":["Modal.tsx"],"sourcesContent":["import React from 'react';\nimport { KeyboardAvoidingView, Platform, View } from 'react-native';\nimport { css, StyleSheet } from '../styles';\nimport { useElevationStyle } from '../hooks';\nimport type ModalProps from './ModalProps';\nimport AnimatedContainer from './AnimatedContainer';\nimport SimpleBackdrop from './SimpleBackdrop';\n\nexport type ModalCloseReasonType = 'OUTSIDE_PRESS' | 'HARDWARE_BACK_PRESS' | 'CLOSE_BUTTON_PRESS' | 'UNKNOWN';\n\nexport interface ModalCloseEvent {\n metadata: {\n reason: ModalCloseReasonType\n };\n}\n\nexport const createModalCloseEvent = (reason: ModalCloseReasonType) => ({\n metadata: {\n reason,\n },\n});\n\nexport default function Modal(props: ModalProps) {\n const {\n animationStyle,\n avoidKeyboard = false,\n backdropOpacity = 0.75,\n children,\n closeAnimation,\n disableAnimation = false,\n hideBackdrop = false,\n initialOpacity,\n initialTranslateY,\n onClose,\n onEnter: onEnterProp,\n onEntered: onEnteredProp,\n onExit: onExitProp,\n onExited: onExitedProp,\n openAnimation,\n offsetAnimation,\n style,\n visible,\n ...otherProps\n } = props;\n\n const handleBackdropPress = () => {\n if (onClose) {\n onClose(createModalCloseEvent('OUTSIDE_PRESS'));\n }\n };\n\n const [exited, setExited] = React.useState(true);\n\n const elevationStyle = useElevationStyle(6);\n\n const onEnter = () => {\n setExited(false);\n onEnterProp?.();\n };\n\n const onEntered = () => {\n onEnteredProp?.();\n };\n\n const onExit = () => {\n onExitProp?.();\n };\n\n const onExited = () => {\n setExited(true);\n onExitedProp?.();\n };\n\n if (!visible) {\n if (disableAnimation || exited) {\n return null;\n }\n }\n\n const Container = avoidKeyboard ? KeyboardAvoidingView : View;\n const containerProps = avoidKeyboard ? {\n behavior: Platform.OS === 'ios' ? 'padding' : undefined,\n } : {};\n\n return (\n // @ts-expect-error\n <Container\n {...containerProps}\n style={css([\n StyleSheet.absoluteFill,\n elevationStyle,\n style,\n ])}\n {...otherProps}\n >\n {(!hideBackdrop && visible) ? (\n <SimpleBackdrop\n onPress={handleBackdropPress}\n opacity={backdropOpacity}\n />\n ) : null}\n\n {!disableAnimation ? (\n <AnimatedContainer\n children={children}\n closeAnimation={closeAnimation}\n initialOpacity={initialOpacity}\n initialTranslateY={initialTranslateY}\n onEnter={onEnter}\n onEntered={onEntered}\n onExit={onExit}\n onExited={onExited}\n openAnimation={openAnimation}\n offsetAnimation={offsetAnimation}\n style={animationStyle}\n visible={visible}\n />\n ) : children}\n </Container>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,oBAAT,EAA+BC,QAA/B,EAAyCC,IAAzC,QAAqD,cAArD;AACA,SAASC,GAAT,EAAcC,UAAd,QAAgC,WAAhC;AACA,SAASC,iBAAT,QAAkC,UAAlC;AAEA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,cAAP,MAA2B,kBAA3B;AAUA,OAAO,MAAMC,qBAAqB,GAAIC,MAAD,KAAmC;EACpEC,QAAQ,EAAE;IACND;EADM;AAD0D,CAAnC,CAA9B;AAMP,eAAe,SAASE,KAAT,CAAeC,KAAf,EAAkC;EAC7C,MAAM;IACFC,cADE;IAEFC,aAAa,G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,GAA0BE,IAAzD;EACA,MAAMwC,cAAc,GAAG5B,aAAa,GAAG;IACnC6B,QAAQ,EAAE1C,QAAQ,CAAC2C,EAAT,KAAgB,KAAhB,GAAwB,SAAxB,GAAoCC;EADX,CAAH,GAEhC,EAFJ;EAIA;IAAA;IACI;IACA,oBAAC,SAAD,eACQH,cADR;MAEI,KAAK,EAAEvC,GAAG,CAAC,CACPC,UAAU,CAAC0C,YADJ,EAEPN,cAFO,EAGPP,KAHO,CAAD;IAFd,GAOQE,UAPR,GASM,CAAChB,YAAD,IAAiBe,OAAlB,gBACG,oBAAC,cAAD;MACI,OAAO,EAAEE,mBADb;MAEI,OAAO,EAAErB;IAFb,EADH,GAKG,IAdR,EAgBK,CAACG,gBAAD,gBACG,oBAAC,iBAAD;MACI,QAAQ,EAAEF,QADd;MAEI,cAAc,EAAEC,cAFpB;MAGI,cAAc,EAAEG,cAHpB;MAII,iBAAiB,EAAEC,iBAJvB;MAKI,OAAO,EAAEE,OALb;MAMI,SAAS,EAAEE,SANf;MAOI,MAAM,EAAEE,MAPZ;MAQI,QAAQ,EAAEE,QARd;MASI,aAAa,EAAEE,aATnB;MAUI,eAAe,EAAEC,eAVrB;MAWI,KAAK,EAAEnB,cAXX;MAYI,OAAO,EAAEqB;IAZb,EADH,GAeGlB,QA/BR;EAFJ;AAoCH;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ANIMATION_TYPE"],"sources":["ModalProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Animated } from 'react-native';\nimport type { ComponentProps, OverridableComponentProps } from '../types';\nimport { ModalCloseEvent } from './Modal';\n\nexport const enum ANIMATION_TYPE {\n SLIDE = 'slide',\n FADE = 'fade',\n}\n\nexport type AnimationUnit = Omit<Animated.TimingAnimationConfig, 'useNativeDriver'> & {\n /**\n * Type of animation used when the dialog opens and closes.\n */\n type: ANIMATION_TYPE;\n}\n\nexport default interface ModalProps extends OverridableComponentProps<ViewProps, {\n /**\n * Style object provided to animation component.\n */\n animationStyle?: ComponentProps['style'];\n\n /**\n * Opacity for backdrop.\n * @default 0.5\n */\n backdropOpacity?: number;\n\n /**\n * A single child content element.\n */\n children: React.ReactElement;\n\n /**\n * If `true`, the animation is disabled.\n * @default false\n */\n disableAnimation?: boolean;\n\n /**\n * Animation used when the modal closes.\n */\n closeAnimation?: AnimationUnit[] | undefined;\n\n /**\n * If `true`, the backdrop is not rendered.\n * @default false\n */\n hideBackdrop?: boolean;\n\n /**\n * Set the initial value of opacity for animating.\n */\n initialOpacity?: number | undefined;\n\n /**\n * Set the initial value of transition y for animating.\n */\n initialTranslateY?: number | undefined;\n\n /**\n * Callback fired when the component requests to be closed.\n */\n onClose?: (event?: ModalCloseEvent) => void;\n\n /**\n * Callback fired when the enter animation will start.\n */\n onEnter?: () => void | undefined;\n\n /**\n * Callback fired when the enter animation is completed.\n */\n onEntered?: () => void | undefined;\n\n /**\n * Callback fired when the exit animation will start.\n */\n onExit?: () => void | undefined;\n\n /**\n * Callback fired when the exit animation is completed.\n */\n onExited?: () => void | undefined;\n\n /**\n * Animation used when the modal opens.\n */\n openAnimation?: AnimationUnit[] | undefined;\n\n /**\n * Additional offset animation applied when the modal opens.\n */\n offsetAnimation?: AnimationUnit[] | undefined;\n\n /**\n * If `true`, the modal is visible.\n */\n visible: boolean;\n}> {}\n"],"mappings":"AAMA,WAAkBA,cAAlB;;WAAkBA,c;EAAAA,c;EAAAA,c;GAAAA,c,KAAAA,c"}
|
|
1
|
+
{"version":3,"names":["ANIMATION_TYPE"],"sources":["ModalProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Animated } from 'react-native';\nimport type { ComponentProps, OverridableComponentProps } from '../types';\nimport { ModalCloseEvent } from './Modal';\n\nexport const enum ANIMATION_TYPE {\n SLIDE = 'slide',\n FADE = 'fade',\n}\n\nexport type AnimationUnit = Omit<Animated.TimingAnimationConfig, 'useNativeDriver'> & {\n /**\n * Type of animation used when the dialog opens and closes.\n */\n type: ANIMATION_TYPE;\n}\n\nexport default interface ModalProps extends OverridableComponentProps<ViewProps, {\n /**\n * Style object provided to animation component.\n */\n animationStyle?: ComponentProps['style'];\n\n /**\n * Opacity for backdrop.\n * @default 0.5\n */\n backdropOpacity?: number;\n\n /**\n * A single child content element.\n */\n children: React.ReactElement;\n\n /**\n * If `true`, the modal wraps its content in a `KeyboardAvoidingView` so\n * that on iOS the visible area shrinks when the software keyboard appears.\n * Intended for centered modals; leave `false` for bottom-anchored or\n * full-screen overlays that manage their own keyboard handling.\n * @default false\n */\n avoidKeyboard?: boolean;\n\n /**\n * If `true`, the animation is disabled.\n * @default false\n */\n disableAnimation?: boolean;\n\n /**\n * Animation used when the modal closes.\n */\n closeAnimation?: AnimationUnit[] | undefined;\n\n /**\n * If `true`, the backdrop is not rendered.\n * @default false\n */\n hideBackdrop?: boolean;\n\n /**\n * Set the initial value of opacity for animating.\n */\n initialOpacity?: number | undefined;\n\n /**\n * Set the initial value of transition y for animating.\n */\n initialTranslateY?: number | undefined;\n\n /**\n * Callback fired when the component requests to be closed.\n */\n onClose?: (event?: ModalCloseEvent) => void;\n\n /**\n * Callback fired when the enter animation will start.\n */\n onEnter?: () => void | undefined;\n\n /**\n * Callback fired when the enter animation is completed.\n */\n onEntered?: () => void | undefined;\n\n /**\n * Callback fired when the exit animation will start.\n */\n onExit?: () => void | undefined;\n\n /**\n * Callback fired when the exit animation is completed.\n */\n onExited?: () => void | undefined;\n\n /**\n * Animation used when the modal opens.\n */\n openAnimation?: AnimationUnit[] | undefined;\n\n /**\n * Additional offset animation applied when the modal opens.\n */\n offsetAnimation?: AnimationUnit[] | undefined;\n\n /**\n * If `true`, the modal is visible.\n */\n visible: boolean;\n}> {}\n"],"mappings":"AAMA,WAAkBA,cAAlB;;WAAkBA,c;EAAAA,c;EAAAA,c;GAAAA,c,KAAAA,c"}
|
|
@@ -56,7 +56,9 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(props, ref) {
|
|
|
56
56
|
multiline,
|
|
57
57
|
editable = true,
|
|
58
58
|
hint,
|
|
59
|
+
inputFontSize = 'large',
|
|
59
60
|
isLoading,
|
|
61
|
+
maxLength,
|
|
60
62
|
onBlur,
|
|
61
63
|
onChangeText: onChangeTextProp,
|
|
62
64
|
onFocus,
|
|
@@ -64,6 +66,7 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(props, ref) {
|
|
|
64
66
|
placeholderTextColor: placeholderTextColorProp,
|
|
65
67
|
secureTextEntry: secureTextEntryProp,
|
|
66
68
|
showClearButton: showClearButtonProp,
|
|
69
|
+
showWordCounter = false,
|
|
67
70
|
status = 'default',
|
|
68
71
|
style: styleProp,
|
|
69
72
|
title,
|
|
@@ -86,7 +89,7 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(props, ref) {
|
|
|
86
89
|
ref.current = node;
|
|
87
90
|
}
|
|
88
91
|
}, [ref]);
|
|
89
|
-
const variantStyles = useVariantStyleMap(variant, status, isFocused);
|
|
92
|
+
const variantStyles = useVariantStyleMap(variant, status, isFocused, inputFontSize);
|
|
90
93
|
|
|
91
94
|
const handleBlur = event => {
|
|
92
95
|
setIsFocused(false);
|
|
@@ -165,6 +168,7 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(props, ref) {
|
|
|
165
168
|
}) : null), /*#__PURE__*/React.createElement(TextInput, _extends({
|
|
166
169
|
autoFocus: autoFocus,
|
|
167
170
|
editable: !disabled,
|
|
171
|
+
maxLength: maxLength,
|
|
168
172
|
onBlur: handleBlur,
|
|
169
173
|
onChangeText: handleChangeText,
|
|
170
174
|
onFocus: handleFocus,
|
|
@@ -193,7 +197,10 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(props, ref) {
|
|
|
193
197
|
}) : /*#__PURE__*/React.createElement(EyeOn, {
|
|
194
198
|
height: 19,
|
|
195
199
|
width: 17.42
|
|
196
|
-
}))) : null),
|
|
200
|
+
}))) : null), showWordCounter && maxLength && !isSearch ? /*#__PURE__*/React.createElement(Text, {
|
|
201
|
+
children: `${(value === null || value === void 0 ? void 0 : value.length) ?? 0}/${maxLength}`,
|
|
202
|
+
style: variantStyles.hintStyle
|
|
203
|
+
}) : null, hint && !isSearch ? /*#__PURE__*/React.createElement(Text, {
|
|
197
204
|
children: hint,
|
|
198
205
|
style: variantStyles.hintStyle
|
|
199
206
|
}) : null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useLayoutEffect","useRef","useState","Platform","StyleSheet","Text","TextInput","View","css","IconButton","Clear","EyeOff","EyeOn","LoadingSpinner","Search","Row","createFontStyle","useTheme","useVariantStyleMap","isWeb","OS","styles","create","root","alignItems","flexGrow","input","inputWrapper","flexShrink","placeholderWrapper","absoluteFillObject","justifyContent","secureToggleButton","padding","position","right","searchIconContainer","left","loadingSinner","height","width","clearButton","secureButtonContainer","TextField","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","isFocused","setIsFocused","setSecureTextEntry","internalRef","mergedRef","node","current","variantStyles","handleBlur","event","handleFocus","handleSecureTogglePress","resizeHeight","el","scrollHeight","shouldResizeHeight","handleChangeText","text","handleClear","titleFontStyle","selector","typography","caption1","color","palette","strong","inputStyle","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\n children={hint}\n style={variantStyles.hintStyle}\n />\n ) : null}\n </View>\n );\n});\n\nexport default TextField;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,eAA7B,EAA8CC,MAA9C,EAAsDC,QAAtD,QAAsE,OAAtE;AAEA,SAASC,QAAT,EAAmBC,UAAnB,EAA+BC,IAA/B,EAAqCC,SAArC,EAAgDC,IAAhD,QAA4D,cAA5D;AAEA,SAASC,GAAT,QAAoB,qBAApB;AACA,OAAOC,UAAP,MAAuB,0BAAvB;AACA,SAASC,KAAT,EAAgBC,MAAhB,EAAwBC,KAAxB,EAA+BC,cAA/B,EAA+CC,MAA/C,QAA6D,mBAA7D;AACA,OAAOC,GAAP,MAAgB,QAAhB;AACA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,WAA1C;AAGA,OAAOC,kBAAP,MAA+B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AE+B,aAAa,CAAC0B;EAFzB,EADH,GAKG,IAhGR,CADJ;AAoGH,CAjNiB,CAAlB;AAmNA,eAAelE,SAAf"}
|
|
1
|
+
{"version":3,"names":["React","useCallback","useLayoutEffect","useRef","useState","Platform","StyleSheet","Text","TextInput","View","css","IconButton","Clear","EyeOff","EyeOn","LoadingSpinner","Search","Row","createFontStyle","useTheme","useVariantStyleMap","isWeb","OS","styles","create","root","alignItems","flexGrow","input","inputWrapper","flexShrink","placeholderWrapper","absoluteFillObject","justifyContent","secureToggleButton","padding","position","right","searchIconContainer","left","loadingSinner","height","width","clearButton","secureButtonContainer","TextField","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","isFocused","setIsFocused","setSecureTextEntry","internalRef","mergedRef","node","current","variantStyles","handleBlur","event","handleFocus","handleSecureTogglePress","resizeHeight","el","scrollHeight","shouldResizeHeight","handleChangeText","text","handleClear","titleFontStyle","selector","typography","caption1","color","palette","strong","inputStyle","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,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,eAA7B,EAA8CC,MAA9C,EAAsDC,QAAtD,QAAsE,OAAtE;AAEA,SAASC,QAAT,EAAmBC,UAAnB,EAA+BC,IAA/B,EAAqCC,SAArC,EAAgDC,IAAhD,QAA4D,cAA5D;AAEA,SAASC,GAAT,QAAoB,qBAApB;AACA,OAAOC,UAAP,MAAuB,0BAAvB;AACA,SAASC,KAAT,EAAgBC,MAAhB,EAAwBC,KAAxB,EAA+BC,cAA/B,EAA+CC,MAA/C,QAA6D,mBAA7D;AACA,OAAOC,GAAP,MAAgB,QAAhB;AACA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,WAA1C;AAGA,OAAOC,k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,EAXR,CADJ,CADH,GAoBG,IAjFR,CARJ,EA4FKI,eAAe,IAAIb,SAAnB,IAAgC,CAACqB,QAAjC,gBACG,oBAAC,IAAD;IACI,QAAQ,EAAG,GAAE,CAAAH,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEsC,MAAP,KAAiB,CAAE,IAAGxD,SAAU,EADjD;IAEI,KAAK,EAAE+B,aAAa,CAAC0B;EAFzB,EADH,GAKG,IAjGR,EAmGK5D,IAAI,IAAI,CAACwB,QAAT,gBACG,oBAAC,IAAD;IACI,QAAQ,EAAExB,IADd;IAEI,KAAK,EAAEkC,aAAa,CAAC0B;EAFzB,EADH,GAKG,IAxGR,CADJ;AA4GH,CA5NiB,CAAlB;AA8NA,eAAerE,SAAf"}
|
|
@@ -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":"AAKA,OAAO,MAAMA,eAAe,GAAG,CAAC,SAAD,EAAY,SAAZ,EAAuB,OAAvB,CAAxB;AAGP,OAAO,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":"AAKA,OAAO,MAAMA,eAAe,GAAG,CAAC,SAAD,EAAY,SAAZ,EAAuB,OAAvB,CAAxB;AAGP,OAAO,MAAMC,iBAAiB,GAAG,CAAC,SAAD,EAAY,QAAZ,CAA1B;AAGP,OAAO,MAAMC,uBAAuB,GAAG,CAAC,OAAD,EAAU,OAAV,CAAhC"}
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { typographyOf } from '@fountain-ui/styles';
|
|
3
3
|
import { createFontStyle, useTheme } from '../styles';
|
|
4
|
+
const fontSizeStyleMap = {
|
|
5
|
+
large: {
|
|
6
|
+
fontSize: 18,
|
|
7
|
+
lineHeight: 27,
|
|
8
|
+
fontFamily: 'PretendardStd-SemiBold',
|
|
9
|
+
letterSpacing: 0
|
|
10
|
+
},
|
|
11
|
+
small: {
|
|
12
|
+
fontSize: 14,
|
|
13
|
+
lineHeight: 21,
|
|
14
|
+
fontFamily: 'PretendardStd-Medium',
|
|
15
|
+
letterSpacing: 0
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const containerPaddingMap = {
|
|
19
|
+
large: {
|
|
20
|
+
paddingVertical: 14
|
|
21
|
+
},
|
|
22
|
+
small: {
|
|
23
|
+
paddingTop: 18,
|
|
24
|
+
paddingBottom: 16
|
|
25
|
+
}
|
|
26
|
+
};
|
|
4
27
|
|
|
5
28
|
function useStatusColor(theme, status) {
|
|
6
29
|
switch (status) {
|
|
@@ -26,6 +49,7 @@ function useStatusColor(theme, status) {
|
|
|
26
49
|
}
|
|
27
50
|
|
|
28
51
|
export default function useVariantStyleMap(variant, status, isFocused) {
|
|
52
|
+
let inputFontSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'large';
|
|
29
53
|
const theme = useTheme();
|
|
30
54
|
const {
|
|
31
55
|
borderColor,
|
|
@@ -40,19 +64,14 @@ export default function useVariantStyleMap(variant, status, isFocused) {
|
|
|
40
64
|
borderBottomColor: status === 'default' && isFocused ? theme.palette.border.strong : borderColor,
|
|
41
65
|
borderBottomWidth: 1,
|
|
42
66
|
gap: 16,
|
|
43
|
-
minHeight:
|
|
44
|
-
|
|
67
|
+
minHeight: 54,
|
|
68
|
+
...containerPaddingMap[inputFontSize]
|
|
45
69
|
},
|
|
46
70
|
inputStyle: {
|
|
47
71
|
padding: 0
|
|
48
72
|
},
|
|
49
73
|
inputFontStyle: createFontStyle(theme, {
|
|
50
|
-
selector: _ => typographyOf(
|
|
51
|
-
fontSize: 18,
|
|
52
|
-
lineHeight: 27,
|
|
53
|
-
fontFamily: 'PretendardStd-SemiBold',
|
|
54
|
-
letterSpacing: 0
|
|
55
|
-
}),
|
|
74
|
+
selector: _ => typographyOf(fontSizeStyleMap[inputFontSize]),
|
|
56
75
|
color: theme.palette.text.strong
|
|
57
76
|
}),
|
|
58
77
|
hintStyle: {
|
|
@@ -89,6 +108,6 @@ export default function useVariantStyleMap(variant, status, isFocused) {
|
|
|
89
108
|
})
|
|
90
109
|
};
|
|
91
110
|
}
|
|
92
|
-
}, [theme, borderColor, hintColor, variant, isFocused]);
|
|
111
|
+
}, [theme, borderColor, hintColor, variant, isFocused, inputFontSize]);
|
|
93
112
|
}
|
|
94
113
|
//# sourceMappingURL=useVariantStyleMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","typographyOf","createFontStyle","useTheme","useStatusColor","theme","status","borderColor","palette","border","base","hintColor","text","weak","success","danger","useVariantStyleMap","variant","isFocused","containerStyle","borderBottomColor","strong","borderBottomWidth","gap","minHeight","
|
|
1
|
+
{"version":3,"names":["useMemo","typographyOf","createFontStyle","useTheme","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","containerStyle","borderBottomColor","strong","borderBottomWidth","gap","minHeight","inputStyle","padding","inputFontStyle","selector","_","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,SAASA,OAAT,QAAwB,OAAxB;AAGA,SAASC,YAAT,QAA6B,qBAA7B;AACA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,WAA1C;AAGA,MAAMC,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;IACHG,UAAU,EAAE,EADT;IAEHC,aAAa,EAAE;EAFZ;AAJiB,CAA5B;;AAiBA,SAASC,cAAT,CAAwBC,KAAxB,EAAsCC,MAAtC,EAA4G;EACxG,QAAQA,MAAR;IACI;IACA,KAAK,SAAL;MACI,OAAO;QACHC,WAAW,EAAEF,KAAK,CAACG,O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|
const rootStyle = css([styles.root, styleProp]);
|
|
25
25
|
return /*#__PURE__*/React.createElement(IconButton, _extends({
|
|
26
26
|
style: rootStyle
|
|
27
|
-
}, otherProps), /*#__PURE__*/React.createElement(
|
|
27
|
+
}, otherProps), /*#__PURE__*/React.createElement(AppBarChevronLeft, {
|
|
28
28
|
height: 24,
|
|
29
29
|
width: 24
|
|
30
|
-
}))
|
|
30
|
+
}));
|
|
31
31
|
}
|
|
32
32
|
//# sourceMappingURL=BackButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","StyleSheet","IconButton","AppBarChevronLeft","css","styles","create","root","height","left","paddingLeft","paddingRight","paddingVertical","position","width","BackButton","props","style","styleProp","otherProps","rootStyle"],"sources":["BackButton.tsx"],"sourcesContent":["import React from 'react';\nimport { StyleSheet } from 'react-native';\nimport IconButton from '../../IconButton';\nimport { AppBarChevronLeft } from '../../internal';\nimport type BackButtonProps from './BackButtonProps';\nimport { css } from '@fountain-ui/styles';\n\nconst styles = StyleSheet.create({\n root: {\n height: 40,\n left: 4,\n paddingLeft: 5,\n paddingRight: 11,\n paddingVertical: 8,\n position: 'absolute',\n width: 40,\n },\n});\n\nexport default function BackButton(props: BackButtonProps) {\n const {\n style: styleProp,\n ...otherProps\n } = props;\n\n const rootStyle = css([\n styles.root,\n styleProp,\n ]);\n\n return (\n <IconButton\n style={rootStyle}\n {...otherProps}\n >\n <
|
|
1
|
+
{"version":3,"names":["React","StyleSheet","IconButton","AppBarChevronLeft","css","styles","create","root","height","left","paddingLeft","paddingRight","paddingVertical","position","width","BackButton","props","style","styleProp","otherProps","rootStyle"],"sources":["BackButton.tsx"],"sourcesContent":["import React from 'react';\nimport { StyleSheet } from 'react-native';\nimport IconButton from '../../IconButton';\nimport { AppBarChevronLeft } from '../../internal';\nimport type BackButtonProps from './BackButtonProps';\nimport { css } from '@fountain-ui/styles';\n\nconst styles = StyleSheet.create({\n root: {\n height: 40,\n left: 4,\n paddingLeft: 5,\n paddingRight: 11,\n paddingVertical: 8,\n position: 'absolute',\n width: 40,\n },\n});\n\nexport default function BackButton(props: BackButtonProps) {\n const {\n style: styleProp,\n ...otherProps\n } = props;\n\n const rootStyle = css([\n styles.root,\n styleProp,\n ]);\n\n return (\n <IconButton\n style={rootStyle}\n {...otherProps}\n >\n <AppBarChevronLeft\n height={24}\n width={24}\n />\n </IconButton>\n );\n}\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,OAAOC,UAAP,MAAuB,kBAAvB;AACA,SAASC,iBAAT,QAAkC,gBAAlC;AAEA,SAASC,GAAT,QAAoB,qBAApB;AAEA,MAAMC,MAAM,GAAGJ,UAAU,CAACK,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACFC,MAAM,EAAE,EADN;IAEFC,IAAI,EAAE,CAFJ;IAGFC,WAAW,EAAE,CAHX;IAIFC,YAAY,EAAE,EAJZ;IAKFC,eAAe,EAAE,CALf;IAMFC,QAAQ,EAAE,UANR;IAOFC,KAAK,EAAE;EAPL;AADuB,CAAlB,CAAf;AAYA,eAAe,SAASC,UAAT,CAAoBC,KAApB,EAA4C;EACvD,MAAM;IACFC,KAAK,EAAEC,SADL;IAEF,GAAGC;EAFD,IAGFH,KAHJ;EAKA,MAAMI,SAAS,GAAGhB,GAAG,CAAC,CAClBC,MAAM,CAACE,IADW,EAElBW,SAFkB,CAAD,CAArB;EAKA,oBACI,oBAAC,UAAD;IACI,KAAK,EAAEE;EADX,GAEQD,UAFR,gBAII,oBAAC,iBAAD;IACI,MAAM,EAAE,EADZ;IAEI,KAAK,EAAE;EAFX,EAJJ,CADJ;AAWH"}
|
|
@@ -27,6 +27,14 @@ export default interface ModalProps extends OverridableComponentProps<ViewProps,
|
|
|
27
27
|
* A single child content element.
|
|
28
28
|
*/
|
|
29
29
|
children: React.ReactElement;
|
|
30
|
+
/**
|
|
31
|
+
* If `true`, the modal wraps its content in a `KeyboardAvoidingView` so
|
|
32
|
+
* that on iOS the visible area shrinks when the software keyboard appears.
|
|
33
|
+
* Intended for centered modals; leave `false` for bottom-anchored or
|
|
34
|
+
* full-screen overlays that manage their own keyboard handling.
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
avoidKeyboard?: boolean;
|
|
30
38
|
/**
|
|
31
39
|
* If `true`, the animation is disabled.
|
|
32
40
|
* @default false
|
|
@@ -5,6 +5,8 @@ export declare const textFieldStatus: readonly ["default", "success", "error"];
|
|
|
5
5
|
export declare type TextFieldStatus = typeof textFieldStatus[number];
|
|
6
6
|
export declare const textFieldVariants: readonly ["default", "search"];
|
|
7
7
|
export declare type TextFieldVariant = typeof textFieldVariants[number];
|
|
8
|
+
export declare const textFieldInputFontSizes: readonly ["large", "small"];
|
|
9
|
+
export declare type TextFieldInputFontSize = typeof textFieldInputFontSizes[number];
|
|
8
10
|
export default interface TextFieldProps extends OverridableComponentProps<TextInputProps, {
|
|
9
11
|
/**
|
|
10
12
|
* Determines the style of the container that wraps the input.
|
|
@@ -37,5 +39,16 @@ export default interface TextFieldProps extends OverridableComponentProps<TextIn
|
|
|
37
39
|
* @default default
|
|
38
40
|
*/
|
|
39
41
|
variant?: TextFieldVariant;
|
|
42
|
+
/**
|
|
43
|
+
* Determines the font size of the input.
|
|
44
|
+
* @default large
|
|
45
|
+
*/
|
|
46
|
+
inputFontSize?: TextFieldInputFontSize;
|
|
47
|
+
/**
|
|
48
|
+
* Determines whether to display the word counter below the input.
|
|
49
|
+
* Requires maxLength to be set.
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
showWordCounter?: boolean;
|
|
40
53
|
}> {
|
|
41
54
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { TextStyle } from 'react-native';
|
|
2
2
|
import type { FountainUiStyle } from '@fountain-ui/styles';
|
|
3
|
-
import type { TextFieldStatus, TextFieldVariant } from './TextFieldProps';
|
|
3
|
+
import type { TextFieldInputFontSize, TextFieldStatus, TextFieldVariant } from './TextFieldProps';
|
|
4
4
|
interface VariantStyleMap {
|
|
5
5
|
containerStyle?: FountainUiStyle;
|
|
6
6
|
inputFontStyle?: TextStyle;
|
|
7
7
|
inputStyle?: FountainUiStyle;
|
|
8
8
|
hintStyle?: FountainUiStyle;
|
|
9
9
|
}
|
|
10
|
-
export default function useVariantStyleMap(variant: TextFieldVariant, status: TextFieldStatus, isFocused: boolean): VariantStyleMap;
|
|
10
|
+
export default function useVariantStyleMap(variant: TextFieldVariant, status: TextFieldStatus, isFocused: boolean, inputFontSize?: TextFieldInputFontSize): VariantStyleMap;
|
|
11
11
|
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.49",
|
|
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": "d105ea0485b7e7db4db0b229e615a9022af753d9"
|
|
71
71
|
}
|
package/src/Dialog/Dialog.tsx
CHANGED
|
@@ -112,6 +112,7 @@ export default function Dialog(props: DialogProps) {
|
|
|
112
112
|
return (
|
|
113
113
|
<Modal
|
|
114
114
|
animationStyle={styles.container}
|
|
115
|
+
avoidKeyboard={size !== 'full'}
|
|
115
116
|
closeAnimation={closeAnimation}
|
|
116
117
|
hideBackdrop={hideBackdrop || animationType === ANIMATION_TYPE.FADE}
|
|
117
118
|
initialOpacity={initialOpacity}
|
package/src/Modal/Modal.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
2
|
+
import { KeyboardAvoidingView, Platform, View } from 'react-native';
|
|
3
3
|
import { css, StyleSheet } from '../styles';
|
|
4
4
|
import { useElevationStyle } from '../hooks';
|
|
5
5
|
import type ModalProps from './ModalProps';
|
|
@@ -23,6 +23,7 @@ export const createModalCloseEvent = (reason: ModalCloseReasonType) => ({
|
|
|
23
23
|
export default function Modal(props: ModalProps) {
|
|
24
24
|
const {
|
|
25
25
|
animationStyle,
|
|
26
|
+
avoidKeyboard = false,
|
|
26
27
|
backdropOpacity = 0.75,
|
|
27
28
|
children,
|
|
28
29
|
closeAnimation,
|
|
@@ -76,8 +77,15 @@ export default function Modal(props: ModalProps) {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
const Container = avoidKeyboard ? KeyboardAvoidingView : View;
|
|
81
|
+
const containerProps = avoidKeyboard ? {
|
|
82
|
+
behavior: Platform.OS === 'ios' ? 'padding' : undefined,
|
|
83
|
+
} : {};
|
|
84
|
+
|
|
79
85
|
return (
|
|
80
|
-
|
|
86
|
+
// @ts-expect-error
|
|
87
|
+
<Container
|
|
88
|
+
{...containerProps}
|
|
81
89
|
style={css([
|
|
82
90
|
StyleSheet.absoluteFill,
|
|
83
91
|
elevationStyle,
|
|
@@ -108,6 +116,6 @@ export default function Modal(props: ModalProps) {
|
|
|
108
116
|
visible={visible}
|
|
109
117
|
/>
|
|
110
118
|
) : children}
|
|
111
|
-
</
|
|
119
|
+
</Container>
|
|
112
120
|
);
|
|
113
121
|
};
|
package/src/Modal/ModalProps.ts
CHANGED
|
@@ -33,6 +33,15 @@ export default interface ModalProps extends OverridableComponentProps<ViewProps,
|
|
|
33
33
|
*/
|
|
34
34
|
children: React.ReactElement;
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* If `true`, the modal wraps its content in a `KeyboardAvoidingView` so
|
|
38
|
+
* that on iOS the visible area shrinks when the software keyboard appears.
|
|
39
|
+
* Intended for centered modals; leave `false` for bottom-anchored or
|
|
40
|
+
* full-screen overlays that manage their own keyboard handling.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
avoidKeyboard?: boolean;
|
|
44
|
+
|
|
36
45
|
/**
|
|
37
46
|
* If `true`, the animation is disabled.
|
|
38
47
|
* @default false
|
|
@@ -62,7 +62,9 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
|
|
|
62
62
|
multiline,
|
|
63
63
|
editable = true,
|
|
64
64
|
hint,
|
|
65
|
+
inputFontSize = 'large',
|
|
65
66
|
isLoading,
|
|
67
|
+
maxLength,
|
|
66
68
|
onBlur,
|
|
67
69
|
onChangeText: onChangeTextProp,
|
|
68
70
|
onFocus,
|
|
@@ -70,6 +72,7 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
|
|
|
70
72
|
placeholderTextColor: placeholderTextColorProp,
|
|
71
73
|
secureTextEntry: secureTextEntryProp,
|
|
72
74
|
showClearButton: showClearButtonProp,
|
|
75
|
+
showWordCounter = false,
|
|
73
76
|
status = 'default' as TextFieldStatus,
|
|
74
77
|
style: styleProp,
|
|
75
78
|
title,
|
|
@@ -98,7 +101,7 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
|
|
|
98
101
|
}
|
|
99
102
|
}, [ref]);
|
|
100
103
|
|
|
101
|
-
const variantStyles = useVariantStyleMap(variant, status, isFocused);
|
|
104
|
+
const variantStyles = useVariantStyleMap(variant, status, isFocused, inputFontSize);
|
|
102
105
|
|
|
103
106
|
const handleBlur = (event: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
104
107
|
setIsFocused(false);
|
|
@@ -206,6 +209,7 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
|
|
|
206
209
|
<TextInput
|
|
207
210
|
autoFocus={autoFocus}
|
|
208
211
|
editable={!disabled}
|
|
212
|
+
maxLength={maxLength}
|
|
209
213
|
onBlur={handleBlur}
|
|
210
214
|
onChangeText={handleChangeText}
|
|
211
215
|
onFocus={handleFocus}
|
|
@@ -256,6 +260,13 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
|
|
|
256
260
|
) : null}
|
|
257
261
|
</Row>
|
|
258
262
|
|
|
263
|
+
{showWordCounter && maxLength && !isSearch ? (
|
|
264
|
+
<Text
|
|
265
|
+
children={`${value?.length ?? 0}/${maxLength}`}
|
|
266
|
+
style={variantStyles.hintStyle}
|
|
267
|
+
/>
|
|
268
|
+
) : null}
|
|
269
|
+
|
|
259
270
|
{hint && !isSearch ? (
|
|
260
271
|
<Text
|
|
261
272
|
children={hint}
|
|
@@ -9,6 +9,9 @@ export type TextFieldStatus = typeof textFieldStatus[number];
|
|
|
9
9
|
export const textFieldVariants = ['default', 'search'] as const;
|
|
10
10
|
export type TextFieldVariant = typeof textFieldVariants[number];
|
|
11
11
|
|
|
12
|
+
export const textFieldInputFontSizes = ['large', 'small'] as const;
|
|
13
|
+
export type TextFieldInputFontSize = typeof textFieldInputFontSizes[number];
|
|
14
|
+
|
|
12
15
|
export default interface TextFieldProps extends OverridableComponentProps<TextInputProps, {
|
|
13
16
|
/**
|
|
14
17
|
* Determines the style of the container that wraps the input.
|
|
@@ -47,4 +50,17 @@ export default interface TextFieldProps extends OverridableComponentProps<TextIn
|
|
|
47
50
|
* @default default
|
|
48
51
|
*/
|
|
49
52
|
variant?: TextFieldVariant;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Determines the font size of the input.
|
|
56
|
+
* @default large
|
|
57
|
+
*/
|
|
58
|
+
inputFontSize?: TextFieldInputFontSize;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Determines whether to display the word counter below the input.
|
|
62
|
+
* Requires maxLength to be set.
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
showWordCounter?: boolean;
|
|
50
66
|
}> {}
|