@bigbinary/neetoui-rn 0.0.39 → 0.0.40
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/lib/components/Input.js +1 -1
- package/package.json +1 -1
- package/src/components/Input.js +34 -5
package/lib/components/Input.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.TextInput=exports.Input=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _taggedTemplateLiteralLoose2=_interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));var _react=_interopRequireWildcard(require("react"));var _styledSystem=require("styled-system");var _native=_interopRequireWildcard(require("styled-components/native"));var _propTypes=_interopRequireDefault(require("@styled-system/prop-types"));var _propTypes2=_interopRequireDefault(require("prop-types"));var _=require("./");var _excluded=["label","message","error","onFocus","onBlur","inline","brandRight","brandLeft","disabled"];var _templateObject,_templateObject2,_this=this,_jsxFileName="/Users/runner/work/neeto-ui-rn/neeto-ui-rn/src/components/Input.js";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var TextInput=_native.default.TextInput(_templateObject||(_templateObject=(0,_taggedTemplateLiteralLoose2.default)(["\n ","\n ","\n ","\n ","\n ","\n"])),_styledSystem.flexbox,_styledSystem.space,_styledSystem.border,_styledSystem.buttonStyle,_styledSystem.typography);exports.TextInput=TextInput;var View=_native.default.View(_templateObject2||(_templateObject2=(0,_taggedTemplateLiteralLoose2.default)(["\n ","\n ","\n ","\n ","\n ","\n"])),_styledSystem.flexbox,_styledSystem.space,_styledSystem.border,_styledSystem.color,_styledSystem.layout);var Input=function Input(_ref){var _ref$label=_ref.label,label=_ref$label===void 0?"":_ref$label,_ref$message=_ref.message,message=_ref$message===void 0?"":_ref$message,_ref$error=_ref.error,error=_ref$error===void 0?false:_ref$error,onFocus=_ref.onFocus,onBlur=_ref.onBlur,_ref$inline=_ref.inline,inline=_ref$inline===void 0?false:_ref$inline,brandRight=_ref.brandRight,brandLeft=_ref.brandLeft,_ref$disabled=_ref.disabled,disabled=_ref$disabled===void 0?false:_ref$disabled,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var theme=(0,_react.useContext)(_native.ThemeContext);var _useState=(0,_react.useState)(false),_useState2=(0,_slicedToArray2.default)(_useState,2),isFocus=_useState2[0],setIsFocus=_useState2[1];var borderColor=error?theme.colors.border.danger:theme.colors.border.primary;var handleFocus=function handleFocus(e){onFocus&&onFocus(e);setIsFocus(true);};var handleBlur=function handleBlur(e){onBlur&&onBlur(e);setIsFocus(false);};var focusStyles=isFocus&&{borderRadius:4,borderColor:error?"rgba(255, 105, 105, 0.3)":theme.colors.border.grey400,borderWidth:inline?"0px":"3px",borderStyle:"solid"};var disabledStyles=disabled&&{opacity:0.5,bg:theme.colors.background.secondary};var inlineInputStyles=isFocus&&{backgroundColor:error?theme.colors.border.danger:theme.colors.border.base};return _react.default.createElement(_.Container,{mb:20,__self:_this,__source:{fileName:_jsxFileName,lineNumber:
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.TextInput=exports.Input=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _taggedTemplateLiteralLoose2=_interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));var _react=_interopRequireWildcard(require("react"));var _styledSystem=require("styled-system");var _native=_interopRequireWildcard(require("styled-components/native"));var _propTypes=_interopRequireDefault(require("@styled-system/prop-types"));var _propTypes2=_interopRequireDefault(require("prop-types"));var _=require("./");var _excluded=["label","message","error","onFocus","onBlur","inline","brandRight","brandLeft","brandColor","brandBackground","disabled"];var _templateObject,_templateObject2,_this=this,_jsxFileName="/Users/runner/work/neeto-ui-rn/neeto-ui-rn/src/components/Input.js";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var TextInput=_native.default.TextInput(_templateObject||(_templateObject=(0,_taggedTemplateLiteralLoose2.default)(["\n ","\n ","\n ","\n ","\n ","\n"])),_styledSystem.flexbox,_styledSystem.space,_styledSystem.border,_styledSystem.buttonStyle,_styledSystem.typography);exports.TextInput=TextInput;var View=_native.default.View(_templateObject2||(_templateObject2=(0,_taggedTemplateLiteralLoose2.default)(["\n ","\n ","\n ","\n ","\n ","\n"])),_styledSystem.flexbox,_styledSystem.space,_styledSystem.border,_styledSystem.color,_styledSystem.layout);var Input=function Input(_ref){var _ref$label=_ref.label,label=_ref$label===void 0?"":_ref$label,_ref$message=_ref.message,message=_ref$message===void 0?"":_ref$message,_ref$error=_ref.error,error=_ref$error===void 0?false:_ref$error,onFocus=_ref.onFocus,onBlur=_ref.onBlur,_ref$inline=_ref.inline,inline=_ref$inline===void 0?false:_ref$inline,brandRight=_ref.brandRight,brandLeft=_ref.brandLeft,_ref$brandColor=_ref.brandColor,brandColor=_ref$brandColor===void 0?"font.grey600":_ref$brandColor,_ref$brandBackground=_ref.brandBackground,brandBackground=_ref$brandBackground===void 0?"background.menubackground":_ref$brandBackground,_ref$disabled=_ref.disabled,disabled=_ref$disabled===void 0?false:_ref$disabled,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var theme=(0,_react.useContext)(_native.ThemeContext);var _useState=(0,_react.useState)(false),_useState2=(0,_slicedToArray2.default)(_useState,2),isFocus=_useState2[0],setIsFocus=_useState2[1];var borderColor=error?theme.colors.border.danger:theme.colors.border.primary;var handleFocus=function handleFocus(e){onFocus&&onFocus(e);setIsFocus(true);};var handleBlur=function handleBlur(e){onBlur&&onBlur(e);setIsFocus(false);};var focusStyles=isFocus&&{borderRadius:4,borderColor:error?"rgba(255, 105, 105, 0.3)":theme.colors.border.grey400,borderWidth:inline?"0px":"3px",borderStyle:"solid"};var disabledStyles=disabled&&{opacity:0.5,bg:theme.colors.background.secondary};var inlineInputStyles=isFocus&&{backgroundColor:error?theme.colors.border.danger:theme.colors.border.base};return _react.default.createElement(_.Container,{mb:20,__self:_this,__source:{fileName:_jsxFileName,lineNumber:111,columnNumber:5}},!inline&&_react.default.createElement(LabelText,{inline:inline,label:label,__self:_this,__source:{fileName:_jsxFileName,lineNumber:112,columnNumber:19}}),_react.default.createElement(_.Container,(0,_extends2.default)({},focusStyles,disabledStyles,{flexDirection:inline?"row":"column",onBlur:handleBlur,onFocus:handleFocus,__self:_this,__source:{fileName:_jsxFileName,lineNumber:113,columnNumber:7}}),inline&&_react.default.createElement(_.Container,{alignSelf:"flex-end",maxWidth:100,px:2,__self:_this,__source:{fileName:_jsxFileName,lineNumber:121,columnNumber:11}},_react.default.createElement(LabelText,{inline:inline,label:label,__self:_this,__source:{fileName:_jsxFileName,lineNumber:122,columnNumber:13}})),_react.default.createElement(_.Container,{flexDirection:"row",width:"100%",__self:_this,__source:{fileName:_jsxFileName,lineNumber:125,columnNumber:9}},brandLeft&&_react.default.createElement(InputText,{text:brandLeft,borderColor:borderColor,brandColor:brandColor,brandBackground:brandBackground,__self:_this,__source:{fileName:_jsxFileName,lineNumber:127,columnNumber:13}}),_react.default.createElement(TextInput,(0,_extends2.default)({height:40,flex:1,textStyle:"subtext"},rest,{border:!inline&&borderColor,editable:!disabled,color:error?theme.colors.font.danger:theme.colors.font.primary,__self:_this,__source:{fileName:_jsxFileName,lineNumber:134,columnNumber:11}})),brandRight&&_react.default.createElement(InputText,{text:brandRight,borderColor:borderColor,brandColor:brandColor,brandBackground:brandBackground,__self:_this,__source:{fileName:_jsxFileName,lineNumber:144,columnNumber:13}}))),inline&&_react.default.createElement(View,(0,_extends2.default)({backgroundColor:theme.colors.border.primary,height:1},inlineInputStyles,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:154,columnNumber:9}})),_react.default.createElement(ErrorMessage,{theme:theme,error:error,message:message,__self:_this,__source:{fileName:_jsxFileName,lineNumber:160,columnNumber:7}}));};exports.Input=Input;var InputText=function InputText(_ref2){var text=_ref2.text,borderColor=_ref2.borderColor,brandColor=_ref2.brandColor,brandBackground=_ref2.brandBackground;return _react.default.createElement(_.Container,{bg:brandBackground,justifyContent:"center",px:2,borderColor:borderColor,borderWidth:"1px",__self:_this,__source:{fileName:_jsxFileName,lineNumber:166,columnNumber:3}},text&&_react.default.createElement(_.Typography,{color:brandColor,__self:_this,__source:{fileName:_jsxFileName,lineNumber:173,columnNumber:14}},text));};var LabelText=function LabelText(_ref3){var inline=_ref3.inline,label=_ref3.label;return _react.default.createElement(_.Typography,{numberOfLines:1,textStyle:"subtext",mb:inline?"12px":"7px",__self:_this,__source:{fileName:_jsxFileName,lineNumber:178,columnNumber:3}},label);};var ErrorMessage=function ErrorMessage(_ref4){var error=_ref4.error,message=_ref4.message,theme=_ref4.theme;if(error){return _react.default.createElement(_.Typography,{textStyle:"subtext",color:theme.colors.font.danger,__self:_this,__source:{fileName:_jsxFileName,lineNumber:190,columnNumber:7}},message);}return null;};Input.propTypes=(0,_extends2.default)({},_propTypes.default.flexbox,_propTypes.default.space,_propTypes.default.border,_propTypes.default.buttonStyle,{label:_propTypes2.default.string.isRequired,message:_propTypes2.default.string,error:_propTypes2.default.bool,inline:_propTypes2.default.bool,brandRight:_propTypes2.default.string,brandLeft:_propTypes2.default.string,disabled:_propTypes2.default.bool,brandColor:_propTypes2.default.string,brandBackground:_propTypes2.default.string,children:_propTypes2.default.node});InputText.propTypes={text:_propTypes2.default.string,borderColor:_propTypes2.default.string,brandColor:_propTypes2.default.string,brandBackground:_propTypes2.default.string};LabelText.propTypes={inline:_propTypes2.default.bool,label:_propTypes2.default.string};ErrorMessage.propTypes={error:_propTypes2.default.bool,message:_propTypes2.default.string};TextInput.defaultProps={height:40,border:1,px:2,fontFamily:"inter400",fontSize:"14px",borderRadius:2};
|
package/package.json
CHANGED
package/src/components/Input.js
CHANGED
|
@@ -66,6 +66,8 @@ export const Input = ({
|
|
|
66
66
|
inline = false,
|
|
67
67
|
brandRight,
|
|
68
68
|
brandLeft,
|
|
69
|
+
brandColor = "font.grey600",
|
|
70
|
+
brandBackground = "background.menubackground",
|
|
69
71
|
disabled = false,
|
|
70
72
|
...rest
|
|
71
73
|
}) => {
|
|
@@ -121,7 +123,14 @@ export const Input = ({
|
|
|
121
123
|
</Container>
|
|
122
124
|
)}
|
|
123
125
|
<Container flexDirection="row" width="100%">
|
|
124
|
-
{brandLeft &&
|
|
126
|
+
{brandLeft && (
|
|
127
|
+
<InputText
|
|
128
|
+
text={brandLeft}
|
|
129
|
+
borderColor={borderColor}
|
|
130
|
+
brandColor={brandColor}
|
|
131
|
+
brandBackground={brandBackground}
|
|
132
|
+
/>
|
|
133
|
+
)}
|
|
125
134
|
<TextInput
|
|
126
135
|
height={40}
|
|
127
136
|
flex={1}
|
|
@@ -131,7 +140,14 @@ export const Input = ({
|
|
|
131
140
|
editable={!disabled}
|
|
132
141
|
color={error ? theme.colors.font.danger : theme.colors.font.primary}
|
|
133
142
|
/>
|
|
134
|
-
{brandRight &&
|
|
143
|
+
{brandRight && (
|
|
144
|
+
<InputText
|
|
145
|
+
text={brandRight}
|
|
146
|
+
borderColor={borderColor}
|
|
147
|
+
brandColor={brandColor}
|
|
148
|
+
brandBackground={brandBackground}
|
|
149
|
+
/>
|
|
150
|
+
)}
|
|
135
151
|
</Container>
|
|
136
152
|
</Container>
|
|
137
153
|
{inline && (
|
|
@@ -146,13 +162,15 @@ export const Input = ({
|
|
|
146
162
|
);
|
|
147
163
|
};
|
|
148
164
|
|
|
149
|
-
const InputText = ({
|
|
165
|
+
const InputText = ({ text, borderColor, brandColor, brandBackground }) => (
|
|
150
166
|
<Container
|
|
151
|
-
bg={
|
|
167
|
+
bg={brandBackground}
|
|
152
168
|
justifyContent="center"
|
|
153
169
|
px={2}
|
|
170
|
+
borderColor={borderColor}
|
|
171
|
+
borderWidth="1px"
|
|
154
172
|
>
|
|
155
|
-
{text && <Typography>{text}</Typography>}
|
|
173
|
+
{text && <Typography color={brandColor}>{text}</Typography>}
|
|
156
174
|
</Container>
|
|
157
175
|
);
|
|
158
176
|
|
|
@@ -210,11 +228,22 @@ Input.propTypes = {
|
|
|
210
228
|
* If true, user won't be able to interact with the component.
|
|
211
229
|
*/
|
|
212
230
|
disabled: PropTypes.bool,
|
|
231
|
+
/**
|
|
232
|
+
* To change the color of brand text
|
|
233
|
+
*/
|
|
234
|
+
brandColor: PropTypes.string,
|
|
235
|
+
/**
|
|
236
|
+
* To change the color of brand text
|
|
237
|
+
*/
|
|
238
|
+
brandBackground: PropTypes.string,
|
|
213
239
|
children: PropTypes.node,
|
|
214
240
|
};
|
|
215
241
|
|
|
216
242
|
InputText.propTypes = {
|
|
217
243
|
text: PropTypes.string,
|
|
244
|
+
borderColor: PropTypes.string,
|
|
245
|
+
brandColor: PropTypes.string,
|
|
246
|
+
brandBackground: PropTypes.string,
|
|
218
247
|
};
|
|
219
248
|
|
|
220
249
|
LabelText.propTypes = {
|