@bigbinary/neetoui-rn 0.0.96 → 0.0.99
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/README.md +5 -4
- package/lib/components/CheckBox.js +1 -0
- package/lib/components/RadioButton.js +1 -0
- package/lib/components/TopBar.js +1 -0
- package/lib/components/index.js +1 -1
- package/package.json +2 -2
- package/src/components/CheckBox.js +156 -0
- package/src/components/RadioButton.js +174 -0
- package/src/components/TopBar.js +107 -0
- package/src/components/index.js +3 -0
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
[](https://app.netlify.com/sites/neetoui-rn/deploys)
|
|
2
2
|
[](https://app.netlify.com/sites/neetoui-rn-docs/deploys)
|
|
3
3
|
|
|
4
|
-
**neetoUI-RN** is the library that drives the experience in all
|
|
5
|
-
|
|
4
|
+
**neetoUI-RN** is the library that drives the experience in all
|
|
5
|
+
[neeto product's](https://neeto.com/) React Native application built at
|
|
6
|
+
[BigBinary](https://www.bigbinary.com).
|
|
6
7
|
|
|
7
8
|
## Documentation
|
|
8
9
|
|
|
@@ -80,8 +81,8 @@ You can use below commands for running storybook in different platforms:
|
|
|
80
81
|
## Auto Publish to NPM
|
|
81
82
|
|
|
82
83
|
neetoUI-RN version gets patched, auto-incremented and auto-published to npm on
|
|
83
|
-
new commit to master. You can checkout the `publish` workflow in Github actions
|
|
84
|
-
get a live update.
|
|
84
|
+
new commit to master. You can checkout the `publish` workflow in Github actions
|
|
85
|
+
to get a live update.
|
|
85
86
|
|
|
86
87
|
## Building Storybook
|
|
87
88
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.CheckBox=void 0;var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _react=_interopRequireDefault(require("react"));var _propTypes=_interopRequireDefault(require("prop-types"));var _=require("./");var _excluded=["selected","onSelect","checkedComponent","checkedItemProp","disabled","label","labelComponent","labelProp","labelPosition","checkboxContainerProp"];var _this=this,_jsxFileName="/Users/runner/work/neeto-ui-rn/neeto-ui-rn/src/components/CheckBox.js";var LABEL_POSITIONS=["left","right"];var LabelComponent=function LabelComponent(_ref){var label=_ref.label,labelComponent=_ref.labelComponent,labelProp=_ref.labelProp;return labelComponent||_react.default.createElement(_.Typography,(0,_extends2.default)({},labelProp,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:8,columnNumber:28}}),label);};var CheckBox=function CheckBox(_ref2){var _ref2$selected=_ref2.selected,selected=_ref2$selected===void 0?false:_ref2$selected,_ref2$onSelect=_ref2.onSelect,onSelect=_ref2$onSelect===void 0?function(){}:_ref2$onSelect,_ref2$checkedComponen=_ref2.checkedComponent,checkedComponent=_ref2$checkedComponen===void 0?null:_ref2$checkedComponen,_ref2$checkedItemProp=_ref2.checkedItemProp,checkedItemProp=_ref2$checkedItemProp===void 0?{}:_ref2$checkedItemProp,_ref2$disabled=_ref2.disabled,disabled=_ref2$disabled===void 0?false:_ref2$disabled,_ref2$label=_ref2.label,label=_ref2$label===void 0?"Option":_ref2$label,_ref2$labelComponent=_ref2.labelComponent,labelComponent=_ref2$labelComponent===void 0?null:_ref2$labelComponent,_ref2$labelProp=_ref2.labelProp,labelProp=_ref2$labelProp===void 0?{}:_ref2$labelProp,_ref2$labelPosition=_ref2.labelPosition,labelPosition=_ref2$labelPosition===void 0?"right":_ref2$labelPosition,_ref2$checkboxContain=_ref2.checkboxContainerProp,checkboxContainerProp=_ref2$checkboxContain===void 0?{}:_ref2$checkboxContain,rest=(0,_objectWithoutProperties2.default)(_ref2,_excluded);return _react.default.createElement(_.Touchable,(0,_extends2.default)({disabled:disabled,onPress:onSelect,opacity:disabled?0.5:1,flexDirection:"row",alignItems:"center"},rest,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:65,columnNumber:5}}),labelPosition===LABEL_POSITIONS[0]?_react.default.createElement(LabelComponent,{label:label,labelComponent:labelComponent,labelProp:(0,_extends2.default)({mr:2},labelProp),__self:_this,__source:{fileName:_jsxFileName,lineNumber:74,columnNumber:9}}):null,_react.default.createElement(_.Container,(0,_extends2.default)({borderColor:"background.base",borderWidth:1,borderRadius:5,justifyContent:"center",alignItems:"center",width:20,height:20},checkboxContainerProp,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:80,columnNumber:7}}),selected&&_react.default.createElement(_.Container,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:91,columnNumber:11}},checkedComponent||_react.default.createElement(_.Typography,(0,_extends2.default)({},checkedItemProp,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:93,columnNumber:15}}),"\u2713"))),labelPosition===LABEL_POSITIONS[1]?_react.default.createElement(LabelComponent,{label:label,labelComponent:labelComponent,labelProp:(0,_extends2.default)({ml:2},labelProp),__self:_this,__source:{fileName:_jsxFileName,lineNumber:99,columnNumber:9}}):null);};exports.CheckBox=CheckBox;CheckBox.propTypes={selected:_propTypes.default.bool.isRequired,onSelect:_propTypes.default.func.isRequired,disabled:_propTypes.default.bool,checkedComponent:_propTypes.default.element,checkedItemProp:_propTypes.default.object,label:_propTypes.default.string,labelProp:_propTypes.default.object,labelComponent:_propTypes.default.element,labelPosition:_propTypes.default.oneOf(LABEL_POSITIONS),checkboxContainerProp:_propTypes.default.object};LabelComponent.propTypes={label:_propTypes.default.string,labelComponent:_propTypes.default.element,labelProp:_propTypes.default.object};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.RadioButton=void 0;var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _react=_interopRequireDefault(require("react"));var _propTypes=_interopRequireDefault(require("prop-types"));var _=require("./");var _excluded=["radioButtonWidth","radioButtonSelectedWidth","containerBg","innerActiveBg","innerInActiveBg","onSelect","selected","density","label","labelComponent","labelProp","labelPosition","disabled"];var _this=this,_jsxFileName="/Users/runner/work/neeto-ui-rn/neeto-ui-rn/src/components/RadioButton.js";var LABEL_POSITIONS=["left","right"];var LabelComponent=function LabelComponent(_ref){var label=_ref.label,labelComponent=_ref.labelComponent,labelProp=_ref.labelProp;return labelComponent||_react.default.createElement(_.Typography,(0,_extends2.default)({},labelProp,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:8,columnNumber:28}}),label);};var RadioButton=function RadioButton(_ref2){var _ref2$radioButtonWidt=_ref2.radioButtonWidth,radioButtonWidth=_ref2$radioButtonWidt===void 0?20:_ref2$radioButtonWidt,_ref2$radioButtonSele=_ref2.radioButtonSelectedWidth,radioButtonSelectedWidth=_ref2$radioButtonSele===void 0?10:_ref2$radioButtonSele,_ref2$containerBg=_ref2.containerBg,containerBg=_ref2$containerBg===void 0?"background.grey":_ref2$containerBg,_ref2$innerActiveBg=_ref2.innerActiveBg,innerActiveBg=_ref2$innerActiveBg===void 0?"background.base":_ref2$innerActiveBg,_ref2$innerInActiveBg=_ref2.innerInActiveBg,innerInActiveBg=_ref2$innerInActiveBg===void 0?"background.secondary":_ref2$innerInActiveBg,_ref2$onSelect=_ref2.onSelect,onSelect=_ref2$onSelect===void 0?function(){}:_ref2$onSelect,_ref2$selected=_ref2.selected,selected=_ref2$selected===void 0?null:_ref2$selected,_ref2$density=_ref2.density,density=_ref2$density===void 0?5:_ref2$density,_ref2$label=_ref2.label,label=_ref2$label===void 0?"Option":_ref2$label,_ref2$labelComponent=_ref2.labelComponent,labelComponent=_ref2$labelComponent===void 0?null:_ref2$labelComponent,_ref2$labelProp=_ref2.labelProp,labelProp=_ref2$labelProp===void 0?{}:_ref2$labelProp,_ref2$labelPosition=_ref2.labelPosition,labelPosition=_ref2$labelPosition===void 0?"right":_ref2$labelPosition,_ref2$disabled=_ref2.disabled,disabled=_ref2$disabled===void 0?false:_ref2$disabled,rest=(0,_objectWithoutProperties2.default)(_ref2,_excluded);return _react.default.createElement(_.Touchable,(0,_extends2.default)({disabled:disabled,opacity:disabled?0.5:1,onPress:onSelect,flexDirection:"row",alignItems:"center",py:1},rest,{__self:_this,__source:{fileName:_jsxFileName,lineNumber:63,columnNumber:5}}),labelPosition===LABEL_POSITIONS[0]?_react.default.createElement(LabelComponent,{label:label,labelComponent:labelComponent,labelProp:(0,_extends2.default)({mr:2},labelProp),__self:_this,__source:{fileName:_jsxFileName,lineNumber:73,columnNumber:9}}):null,_react.default.createElement(_.Container,{bg:containerBg,height:radioButtonWidth,width:radioButtonWidth,borderRadius:radioButtonWidth/2,justifyContent:"center",alignItems:"center",__self:_this,__source:{fileName:_jsxFileName,lineNumber:79,columnNumber:7}},_react.default.createElement(_.Container,{height:radioButtonSelectedWidth+density,width:radioButtonSelectedWidth+density,borderRadius:(radioButtonSelectedWidth+density)/2,bg:"background.white",justifyContent:"center",alignItems:"center",__self:_this,__source:{fileName:_jsxFileName,lineNumber:87,columnNumber:9}},_react.default.createElement(_.Container,{bg:selected?innerActiveBg:innerInActiveBg,height:radioButtonSelectedWidth,width:radioButtonSelectedWidth,borderRadius:radioButtonSelectedWidth/2,m:1,__self:_this,__source:{fileName:_jsxFileName,lineNumber:95,columnNumber:11}}))),labelPosition===LABEL_POSITIONS[1]?_react.default.createElement(LabelComponent,{label:label,labelComponent:labelComponent,labelProp:(0,_extends2.default)({ml:2},labelProp),__self:_this,__source:{fileName:_jsxFileName,lineNumber:105,columnNumber:9}}):null);};exports.RadioButton=RadioButton;RadioButton.propTypes={onSelect:_propTypes.default.func.isRequired,selected:_propTypes.default.any.isRequired,label:_propTypes.default.string,labelProp:_propTypes.default.object,labelComponent:_propTypes.default.element,labelPosition:_propTypes.default.oneOf(LABEL_POSITIONS),disabled:_propTypes.default.bool,radioButtonWidth:_propTypes.default.number,radioButtonSelectedWidth:_propTypes.default.number,containerBg:_propTypes.default.string,innerActiveBg:_propTypes.default.string,innerInActiveBg:_propTypes.default.string,density:_propTypes.default.number};LabelComponent.propTypes={label:_propTypes.default.string,labelComponent:_propTypes.default.element,labelProp:_propTypes.default.object};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.TopBar=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _propTypes=_interopRequireDefault(require("prop-types"));var _=require("./");var _theme=require("../theme");var _this=this,_jsxFileName="/Users/runner/work/neeto-ui-rn/neeto-ui-rn/src/components/TopBar.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 TopBar=function TopBar(_ref){var data=_ref.data,_ref$activeIndex=_ref.activeIndex,activeIndex=_ref$activeIndex===void 0?0:_ref$activeIndex,_ref$onActiveTabChang=_ref.onActiveTabChange,onActiveTabChange=_ref$onActiveTabChang===void 0?function(){}:_ref$onActiveTabChang,activeTabTextStyle=_ref.activeTabTextStyle,activeTabContainerStyle=_ref.activeTabContainerStyle,inActiveTabTextStyle=_ref.inActiveTabTextStyle,inActiveTabContainerStyle=_ref.inActiveTabContainerStyle,tabContainerStyle=_ref.tabContainerStyle;var _useState=(0,_react.useState)(activeIndex),_useState2=(0,_slicedToArray2.default)(_useState,2),selectedIndex=_useState2[0],setSelectedIndex=_useState2[1];(0,_react.useEffect)(function(){onActiveTabChange(selectedIndex);},[selectedIndex]);(0,_react.useEffect)(function(){setSelectedIndex(activeIndex);},[activeIndex]);return _react.default.createElement(_.Container,{height:50,style:[styles.defaultTabContainerStyle,tabContainerStyle],__self:_this,__source:{fileName:_jsxFileName,lineNumber:30,columnNumber:5}},_react.default.createElement(_reactNative.ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,__self:_this,__source:{fileName:_jsxFileName,lineNumber:34,columnNumber:7}},data.map(function(item,index){return _react.default.createElement(_.Touchable,{key:index,onPress:function onPress(){return setSelectedIndex(index);},style:selectedIndex===index?(0,_extends2.default)({},styles.defaultActiveContainerStyle,activeTabContainerStyle):(0,_extends2.default)({},styles.defaultInActiveTabContainerStyle,inActiveTabContainerStyle),justifyContent:"center",alignItems:"center",__self:_this,__source:{fileName:_jsxFileName,lineNumber:36,columnNumber:11}},_react.default.createElement(_.Typography,{style:selectedIndex===index?(0,_extends2.default)({},styles.defaultActiveTabTextStyle,activeTabTextStyle):(0,_extends2.default)({},styles.defaultInActiveTabTextStyle,inActiveTabTextStyle),__self:_this,__source:{fileName:_jsxFileName,lineNumber:53,columnNumber:13}},item));})));};exports.TopBar=TopBar;var styles=_reactNative.StyleSheet.create({defaultActiveContainerStyle:{backgroundColor:_theme.theme.colors.background.grey800,marginHorizontal:10,paddingHorizontal:10,marginVertical:5,borderRadius:5},defaultInActiveTabContainerStyle:{backgroundColor:_theme.theme.colors.background.white,marginHorizontal:20},defaultActiveTabTextStyle:{color:_theme.theme.colors.font.white},defaultInActiveTabTextStyle:{color:_theme.theme.colors.font.black},defaultTabContainerStyle:{backgroundColor:_theme.theme.colors.font.white}});TopBar.propTypes={data:_propTypes.default.array.isRequired,activeIndex:_propTypes.default.number,onActiveTabChange:_propTypes.default.func.isRequired,activeTabTextStyle:_propTypes.default.object,activeTabContainerStyle:_propTypes.default.object,inActiveTabTextStyle:_propTypes.default.object,inActiveTabContainerStyle:_propTypes.default.object,tabContainerStyle:_propTypes.default.object};
|
package/lib/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Alert",{enumerable:true,get:function get(){return _Alert.Alert;}});Object.defineProperty(exports,"Avatar",{enumerable:true,get:function get(){return _Avatar.Avatar;}});Object.defineProperty(exports,"Badge",{enumerable:true,get:function get(){return _Badge.Badge;}});Object.defineProperty(exports,"BottomSheet",{enumerable:true,get:function get(){return _BottomSheet.BottomSheet;}});Object.defineProperty(exports,"Button",{enumerable:true,get:function get(){return _Button.Button;}});Object.defineProperty(exports,"ButtonGroup",{enumerable:true,get:function get(){return _ButtonGroup.ButtonGroup;}});Object.defineProperty(exports,"Card",{enumerable:true,get:function get(){return _Card.Card;}});Object.defineProperty(exports,"Chip",{enumerable:true,get:function get(){return _Chip.Chip;}});Object.defineProperty(exports,"Container",{enumerable:true,get:function get(){return _Container.Container;}});Object.defineProperty(exports,"FAB",{enumerable:true,get:function get(){return _FAB.FAB;}});Object.defineProperty(exports,"Input",{enumerable:true,get:function get(){return _Input.Input;}});Object.defineProperty(exports,"OtpInputs",{enumerable:true,get:function get(){return _OtpInputs.OtpInputs;}});Object.defineProperty(exports,"ParentView",{enumerable:true,get:function get(){return _ParentView.ParentView;}});Object.defineProperty(exports,"Popover",{enumerable:true,get:function get(){return _Popover.Popover;}});Object.defineProperty(exports,"RichTextEditor",{enumerable:true,get:function get(){return _RichTextEditor.RichTextEditor;}});Object.defineProperty(exports,"Toast",{enumerable:true,get:function get(){return _Toast.Toast;}});Object.defineProperty(exports,"ToggleSwitch",{enumerable:true,get:function get(){return _ToggleSwitch.ToggleSwitch;}});Object.defineProperty(exports,"Touchable",{enumerable:true,get:function get(){return _Touchable.Touchable;}});Object.defineProperty(exports,"Typography",{enumerable:true,get:function get(){return _Typography.Typography;}});var _Button=require("./Button");var _Container=require("./Container");var _Typography=require("./Typography");var _Input=require("./Input");var _FAB=require("./FAB");var _ToggleSwitch=require("./ToggleSwitch");var _Avatar=require("./Avatar");var _Badge=require("./Badge");var _Toast=require("./Toast");var _Alert=require("./Alert");var _BottomSheet=require("./BottomSheet");var _Chip=require("./Chip");var _ParentView=require("./ParentView");var _RichTextEditor=require("./RichTextEditor");var _ButtonGroup=require("./ButtonGroup");var _OtpInputs=require("./OtpInputs");var _Popover=require("./Popover");var _Touchable=require("./Touchable");var _Card=require("./Card");
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Alert",{enumerable:true,get:function get(){return _Alert.Alert;}});Object.defineProperty(exports,"Avatar",{enumerable:true,get:function get(){return _Avatar.Avatar;}});Object.defineProperty(exports,"Badge",{enumerable:true,get:function get(){return _Badge.Badge;}});Object.defineProperty(exports,"BottomSheet",{enumerable:true,get:function get(){return _BottomSheet.BottomSheet;}});Object.defineProperty(exports,"Button",{enumerable:true,get:function get(){return _Button.Button;}});Object.defineProperty(exports,"ButtonGroup",{enumerable:true,get:function get(){return _ButtonGroup.ButtonGroup;}});Object.defineProperty(exports,"Card",{enumerable:true,get:function get(){return _Card.Card;}});Object.defineProperty(exports,"CheckBox",{enumerable:true,get:function get(){return _CheckBox.CheckBox;}});Object.defineProperty(exports,"Chip",{enumerable:true,get:function get(){return _Chip.Chip;}});Object.defineProperty(exports,"Container",{enumerable:true,get:function get(){return _Container.Container;}});Object.defineProperty(exports,"FAB",{enumerable:true,get:function get(){return _FAB.FAB;}});Object.defineProperty(exports,"Input",{enumerable:true,get:function get(){return _Input.Input;}});Object.defineProperty(exports,"OtpInputs",{enumerable:true,get:function get(){return _OtpInputs.OtpInputs;}});Object.defineProperty(exports,"ParentView",{enumerable:true,get:function get(){return _ParentView.ParentView;}});Object.defineProperty(exports,"Popover",{enumerable:true,get:function get(){return _Popover.Popover;}});Object.defineProperty(exports,"RadioButton",{enumerable:true,get:function get(){return _RadioButton.RadioButton;}});Object.defineProperty(exports,"RichTextEditor",{enumerable:true,get:function get(){return _RichTextEditor.RichTextEditor;}});Object.defineProperty(exports,"Toast",{enumerable:true,get:function get(){return _Toast.Toast;}});Object.defineProperty(exports,"ToggleSwitch",{enumerable:true,get:function get(){return _ToggleSwitch.ToggleSwitch;}});Object.defineProperty(exports,"TopBar",{enumerable:true,get:function get(){return _TopBar.TopBar;}});Object.defineProperty(exports,"Touchable",{enumerable:true,get:function get(){return _Touchable.Touchable;}});Object.defineProperty(exports,"Typography",{enumerable:true,get:function get(){return _Typography.Typography;}});var _Button=require("./Button");var _Container=require("./Container");var _Typography=require("./Typography");var _Input=require("./Input");var _FAB=require("./FAB");var _ToggleSwitch=require("./ToggleSwitch");var _Avatar=require("./Avatar");var _Badge=require("./Badge");var _Toast=require("./Toast");var _Alert=require("./Alert");var _BottomSheet=require("./BottomSheet");var _Chip=require("./Chip");var _ParentView=require("./ParentView");var _RichTextEditor=require("./RichTextEditor");var _ButtonGroup=require("./ButtonGroup");var _OtpInputs=require("./OtpInputs");var _Popover=require("./Popover");var _Touchable=require("./Touchable");var _Card=require("./Card");var _TopBar=require("./TopBar");var _RadioButton=require("./RadioButton");var _CheckBox=require("./CheckBox");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neetoui-rn",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.99",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "BigBinary",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"assets"
|
|
35
35
|
],
|
|
36
36
|
"lint-staged": {
|
|
37
|
-
"src/**/*.{js,es6,jsx,ts,tsx}": [
|
|
37
|
+
"src/**/*.{js,es6,jsx,ts,tsx}|storybook/stories**/*.js": [
|
|
38
38
|
"./node_modules/prettier/bin-prettier.js --write",
|
|
39
39
|
"prettier --write",
|
|
40
40
|
"eslint --fix"
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Proptypes from "prop-types";
|
|
3
|
+
|
|
4
|
+
import { Container, Typography, Touchable } from "@components";
|
|
5
|
+
const LABEL_POSITIONS = ["left", "right"];
|
|
6
|
+
|
|
7
|
+
const LabelComponent = ({ label, labelComponent, labelProp }) => {
|
|
8
|
+
return labelComponent || <Typography {...labelProp}>{label}</Typography>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* This component supports below props categories from [styled-system ](/styled-system).
|
|
14
|
+
* <ul>
|
|
15
|
+
* <li>flexbox</li>
|
|
16
|
+
* <li>space</li>
|
|
17
|
+
* <li>border</li>
|
|
18
|
+
* <li>layout</li>
|
|
19
|
+
* <li>color</li>
|
|
20
|
+
* <li>buttonStyle</li>
|
|
21
|
+
* </ul>
|
|
22
|
+
*
|
|
23
|
+
* ## Usage
|
|
24
|
+
* ```js
|
|
25
|
+
* import * as React from "react";
|
|
26
|
+
* import { Container, CheckBox, Typography } from "@bigbinary/neetoui-rn";
|
|
27
|
+
*
|
|
28
|
+
* export default function Main() {
|
|
29
|
+
* const [selected, setSelected] = React.useState(false);
|
|
30
|
+
*
|
|
31
|
+
*
|
|
32
|
+
* return (
|
|
33
|
+
* <Container>
|
|
34
|
+
* <Container flexDirection="row" my={2}>
|
|
35
|
+
* <CheckBox
|
|
36
|
+
* selected={selected}
|
|
37
|
+
* onSelect={() => setSelected(!selected)}
|
|
38
|
+
* checkedComponent={
|
|
39
|
+
* <Container width={10} height={10} bg="background.base" />
|
|
40
|
+
* }
|
|
41
|
+
* label="Agree"
|
|
42
|
+
* />
|
|
43
|
+
* </Container>
|
|
44
|
+
* </Container>
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
export const CheckBox = ({
|
|
52
|
+
selected = false,
|
|
53
|
+
onSelect = () => {},
|
|
54
|
+
checkedComponent = null,
|
|
55
|
+
checkedItemProp = {},
|
|
56
|
+
disabled = false,
|
|
57
|
+
label = "Option",
|
|
58
|
+
labelComponent = null,
|
|
59
|
+
labelProp = {},
|
|
60
|
+
labelPosition = "right",
|
|
61
|
+
checkboxContainerProp = {},
|
|
62
|
+
...rest
|
|
63
|
+
}) => {
|
|
64
|
+
return (
|
|
65
|
+
<Touchable
|
|
66
|
+
disabled={disabled}
|
|
67
|
+
onPress={onSelect}
|
|
68
|
+
opacity={disabled ? 0.5 : 1}
|
|
69
|
+
flexDirection="row"
|
|
70
|
+
alignItems="center"
|
|
71
|
+
{...rest}
|
|
72
|
+
>
|
|
73
|
+
{labelPosition === LABEL_POSITIONS[0] ? (
|
|
74
|
+
<LabelComponent
|
|
75
|
+
label={label}
|
|
76
|
+
labelComponent={labelComponent}
|
|
77
|
+
labelProp={{ mr: 2, ...labelProp }}
|
|
78
|
+
/>
|
|
79
|
+
) : null}
|
|
80
|
+
<Container
|
|
81
|
+
borderColor="background.base"
|
|
82
|
+
borderWidth={1}
|
|
83
|
+
borderRadius={5}
|
|
84
|
+
justifyContent="center"
|
|
85
|
+
alignItems="center"
|
|
86
|
+
width={20}
|
|
87
|
+
height={20}
|
|
88
|
+
{...checkboxContainerProp}
|
|
89
|
+
>
|
|
90
|
+
{selected && (
|
|
91
|
+
<Container>
|
|
92
|
+
{checkedComponent || (
|
|
93
|
+
<Typography {...checkedItemProp}>✓</Typography>
|
|
94
|
+
)}
|
|
95
|
+
</Container>
|
|
96
|
+
)}
|
|
97
|
+
</Container>
|
|
98
|
+
{labelPosition === LABEL_POSITIONS[1] ? (
|
|
99
|
+
<LabelComponent
|
|
100
|
+
label={label}
|
|
101
|
+
labelComponent={labelComponent}
|
|
102
|
+
labelProp={{ ml: 2, ...labelProp }}
|
|
103
|
+
/>
|
|
104
|
+
) : null}
|
|
105
|
+
</Touchable>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
CheckBox.propTypes = {
|
|
110
|
+
/**
|
|
111
|
+
* Whether checkbox is selected.
|
|
112
|
+
*/
|
|
113
|
+
selected: Proptypes.bool.isRequired,
|
|
114
|
+
/**
|
|
115
|
+
* Function to execute on press.
|
|
116
|
+
*/
|
|
117
|
+
onSelect: Proptypes.func.isRequired,
|
|
118
|
+
/**
|
|
119
|
+
* To disable the component.
|
|
120
|
+
*/
|
|
121
|
+
disabled: Proptypes.bool,
|
|
122
|
+
/**
|
|
123
|
+
* Render custom checked component.
|
|
124
|
+
*/
|
|
125
|
+
checkedComponent: Proptypes.element,
|
|
126
|
+
/**
|
|
127
|
+
* Check mark style.
|
|
128
|
+
*/
|
|
129
|
+
checkedItemProp: Proptypes.object,
|
|
130
|
+
/**
|
|
131
|
+
* Text label to be shown with radio button.
|
|
132
|
+
*/
|
|
133
|
+
label: Proptypes.string,
|
|
134
|
+
/**
|
|
135
|
+
* Props for the label.
|
|
136
|
+
*/
|
|
137
|
+
labelProp: Proptypes.object,
|
|
138
|
+
/**
|
|
139
|
+
* Label can passed as a component as well.
|
|
140
|
+
*/
|
|
141
|
+
labelComponent: Proptypes.element,
|
|
142
|
+
/**
|
|
143
|
+
* Position of label relative to the radio button. It can be either `left` or `right`
|
|
144
|
+
*/
|
|
145
|
+
labelPosition: Proptypes.oneOf(LABEL_POSITIONS),
|
|
146
|
+
/**
|
|
147
|
+
* Extra param to customize checkbox container
|
|
148
|
+
*/
|
|
149
|
+
checkboxContainerProp: Proptypes.object,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
LabelComponent.propTypes = {
|
|
153
|
+
label: Proptypes.string,
|
|
154
|
+
labelComponent: Proptypes.element,
|
|
155
|
+
labelProp: Proptypes.object,
|
|
156
|
+
};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
|
|
4
|
+
import { Container, Touchable, Typography } from "@components";
|
|
5
|
+
const LABEL_POSITIONS = ["left", "right"];
|
|
6
|
+
|
|
7
|
+
const LabelComponent = ({ label, labelComponent, labelProp }) => {
|
|
8
|
+
return labelComponent || <Typography {...labelProp}>{label}</Typography>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* This component supports below props categories from [styled-system ](/styled-system).
|
|
14
|
+
* <ul>
|
|
15
|
+
* <li>flexbox</li>
|
|
16
|
+
* <li>space</li>
|
|
17
|
+
* <li>border</li>
|
|
18
|
+
* <li>layout</li>
|
|
19
|
+
* <li>color</li>
|
|
20
|
+
* <li>buttonStyle</li>
|
|
21
|
+
* </ul>
|
|
22
|
+
*
|
|
23
|
+
* ## Usage
|
|
24
|
+
* ```js
|
|
25
|
+
* import * as React from "react";
|
|
26
|
+
* import { Container, RadioButton } from "@bigbinary/neetoui-rn";
|
|
27
|
+
*
|
|
28
|
+
* export default function Main() {
|
|
29
|
+
* const [selected, setSelected] = useState(false);
|
|
30
|
+
*
|
|
31
|
+
* return (
|
|
32
|
+
* <Container>
|
|
33
|
+
* <RadioButton
|
|
34
|
+
* selected={selected}
|
|
35
|
+
* onSelect={() => setSelected(!selected)}
|
|
36
|
+
* label="option label 1"
|
|
37
|
+
* labelPosition="left"
|
|
38
|
+
* />
|
|
39
|
+
* </Container>
|
|
40
|
+
* );
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
export const RadioButton = ({
|
|
47
|
+
radioButtonWidth = 20,
|
|
48
|
+
radioButtonSelectedWidth = 10,
|
|
49
|
+
containerBg = "background.grey",
|
|
50
|
+
innerActiveBg = "background.base",
|
|
51
|
+
innerInActiveBg = "background.secondary",
|
|
52
|
+
onSelect = () => {},
|
|
53
|
+
selected = null,
|
|
54
|
+
density = 5,
|
|
55
|
+
label = "Option",
|
|
56
|
+
labelComponent = null,
|
|
57
|
+
labelProp = {},
|
|
58
|
+
labelPosition = "right",
|
|
59
|
+
disabled = false,
|
|
60
|
+
...rest
|
|
61
|
+
}) => {
|
|
62
|
+
return (
|
|
63
|
+
<Touchable
|
|
64
|
+
disabled={disabled}
|
|
65
|
+
opacity={disabled ? 0.5 : 1}
|
|
66
|
+
onPress={onSelect}
|
|
67
|
+
flexDirection="row"
|
|
68
|
+
alignItems="center"
|
|
69
|
+
py={1}
|
|
70
|
+
{...rest}
|
|
71
|
+
>
|
|
72
|
+
{labelPosition === LABEL_POSITIONS[0] ? (
|
|
73
|
+
<LabelComponent
|
|
74
|
+
label={label}
|
|
75
|
+
labelComponent={labelComponent}
|
|
76
|
+
labelProp={{ mr: 2, ...labelProp }}
|
|
77
|
+
/>
|
|
78
|
+
) : null}
|
|
79
|
+
<Container
|
|
80
|
+
bg={containerBg}
|
|
81
|
+
height={radioButtonWidth}
|
|
82
|
+
width={radioButtonWidth}
|
|
83
|
+
borderRadius={radioButtonWidth / 2}
|
|
84
|
+
justifyContent="center"
|
|
85
|
+
alignItems="center"
|
|
86
|
+
>
|
|
87
|
+
<Container
|
|
88
|
+
height={radioButtonSelectedWidth + density}
|
|
89
|
+
width={radioButtonSelectedWidth + density}
|
|
90
|
+
borderRadius={(radioButtonSelectedWidth + density) / 2}
|
|
91
|
+
bg="background.white"
|
|
92
|
+
justifyContent="center"
|
|
93
|
+
alignItems="center"
|
|
94
|
+
>
|
|
95
|
+
<Container
|
|
96
|
+
bg={selected ? innerActiveBg : innerInActiveBg}
|
|
97
|
+
height={radioButtonSelectedWidth}
|
|
98
|
+
width={radioButtonSelectedWidth}
|
|
99
|
+
borderRadius={radioButtonSelectedWidth / 2}
|
|
100
|
+
m={1}
|
|
101
|
+
/>
|
|
102
|
+
</Container>
|
|
103
|
+
</Container>
|
|
104
|
+
{labelPosition === LABEL_POSITIONS[1] ? (
|
|
105
|
+
<LabelComponent
|
|
106
|
+
label={label}
|
|
107
|
+
labelComponent={labelComponent}
|
|
108
|
+
labelProp={{ ml: 2, ...labelProp }}
|
|
109
|
+
/>
|
|
110
|
+
) : null}
|
|
111
|
+
</Touchable>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
RadioButton.propTypes = {
|
|
116
|
+
/**
|
|
117
|
+
* Function to execute on press.
|
|
118
|
+
*/
|
|
119
|
+
onSelect: PropTypes.func.isRequired,
|
|
120
|
+
/**
|
|
121
|
+
* Whether radio is selected.
|
|
122
|
+
*/
|
|
123
|
+
selected: PropTypes.any.isRequired,
|
|
124
|
+
/**
|
|
125
|
+
* Text label to be shown with radio button.
|
|
126
|
+
*/
|
|
127
|
+
label: PropTypes.string,
|
|
128
|
+
/**
|
|
129
|
+
* Props for the label.
|
|
130
|
+
*/
|
|
131
|
+
labelProp: PropTypes.object,
|
|
132
|
+
/**
|
|
133
|
+
* Label can passed as a component as well.
|
|
134
|
+
*/
|
|
135
|
+
labelComponent: PropTypes.element,
|
|
136
|
+
/**
|
|
137
|
+
* Position of label relative to the radio button. It can be either `left` or `right`
|
|
138
|
+
*/
|
|
139
|
+
labelPosition: PropTypes.oneOf(LABEL_POSITIONS),
|
|
140
|
+
/**
|
|
141
|
+
* Whether radio is disabled.
|
|
142
|
+
*/
|
|
143
|
+
disabled: PropTypes.bool,
|
|
144
|
+
/**
|
|
145
|
+
* Size of radio button.
|
|
146
|
+
*/
|
|
147
|
+
radioButtonWidth: PropTypes.number,
|
|
148
|
+
/**
|
|
149
|
+
* Size of radio button when selected.
|
|
150
|
+
*/
|
|
151
|
+
radioButtonSelectedWidth: PropTypes.number,
|
|
152
|
+
/**
|
|
153
|
+
* Background color of radio button.
|
|
154
|
+
*/
|
|
155
|
+
containerBg: PropTypes.string,
|
|
156
|
+
/**
|
|
157
|
+
* Color of radio button when selected.
|
|
158
|
+
*/
|
|
159
|
+
innerActiveBg: PropTypes.string,
|
|
160
|
+
/**
|
|
161
|
+
* Color of radio button when not selected.
|
|
162
|
+
*/
|
|
163
|
+
innerInActiveBg: PropTypes.string,
|
|
164
|
+
/**
|
|
165
|
+
* Thickness of radio button container component.
|
|
166
|
+
*/
|
|
167
|
+
density: PropTypes.number,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
LabelComponent.propTypes = {
|
|
171
|
+
label: PropTypes.string,
|
|
172
|
+
labelComponent: PropTypes.element,
|
|
173
|
+
labelProp: PropTypes.object,
|
|
174
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { ScrollView, StyleSheet } from "react-native";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
|
|
5
|
+
import { Container, Touchable, Typography } from "@components";
|
|
6
|
+
import { theme } from "@theme";
|
|
7
|
+
|
|
8
|
+
export const TopBar = ({
|
|
9
|
+
data,
|
|
10
|
+
activeIndex = 0,
|
|
11
|
+
onActiveTabChange = () => {},
|
|
12
|
+
activeTabTextStyle,
|
|
13
|
+
activeTabContainerStyle,
|
|
14
|
+
inActiveTabTextStyle,
|
|
15
|
+
inActiveTabContainerStyle,
|
|
16
|
+
tabContainerStyle,
|
|
17
|
+
}) => {
|
|
18
|
+
const [selectedIndex, setSelectedIndex] = useState(activeIndex);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
onActiveTabChange(selectedIndex);
|
|
22
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
+
}, [selectedIndex]);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setSelectedIndex(activeIndex);
|
|
27
|
+
}, [activeIndex]);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Container
|
|
31
|
+
height={50}
|
|
32
|
+
style={[styles.defaultTabContainerStyle, tabContainerStyle]}
|
|
33
|
+
>
|
|
34
|
+
<ScrollView horizontal showsHorizontalScrollIndicator={false}>
|
|
35
|
+
{data.map((item, index) => (
|
|
36
|
+
<Touchable
|
|
37
|
+
key={index}
|
|
38
|
+
onPress={() => setSelectedIndex(index)}
|
|
39
|
+
style={
|
|
40
|
+
selectedIndex === index
|
|
41
|
+
? {
|
|
42
|
+
...styles.defaultActiveContainerStyle,
|
|
43
|
+
...activeTabContainerStyle,
|
|
44
|
+
}
|
|
45
|
+
: {
|
|
46
|
+
...styles.defaultInActiveTabContainerStyle,
|
|
47
|
+
...inActiveTabContainerStyle,
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
justifyContent="center"
|
|
51
|
+
alignItems="center"
|
|
52
|
+
>
|
|
53
|
+
<Typography
|
|
54
|
+
style={
|
|
55
|
+
selectedIndex === index
|
|
56
|
+
? {
|
|
57
|
+
...styles.defaultActiveTabTextStyle,
|
|
58
|
+
...activeTabTextStyle,
|
|
59
|
+
}
|
|
60
|
+
: {
|
|
61
|
+
...styles.defaultInActiveTabTextStyle,
|
|
62
|
+
...inActiveTabTextStyle,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
>
|
|
66
|
+
{item}
|
|
67
|
+
</Typography>
|
|
68
|
+
</Touchable>
|
|
69
|
+
))}
|
|
70
|
+
</ScrollView>
|
|
71
|
+
</Container>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const styles = StyleSheet.create({
|
|
76
|
+
defaultActiveContainerStyle: {
|
|
77
|
+
backgroundColor: theme.colors.background.grey800,
|
|
78
|
+
marginHorizontal: 10,
|
|
79
|
+
paddingHorizontal: 10,
|
|
80
|
+
marginVertical: 5,
|
|
81
|
+
borderRadius: 5,
|
|
82
|
+
},
|
|
83
|
+
defaultInActiveTabContainerStyle: {
|
|
84
|
+
backgroundColor: theme.colors.background.white,
|
|
85
|
+
marginHorizontal: 20,
|
|
86
|
+
},
|
|
87
|
+
defaultActiveTabTextStyle: {
|
|
88
|
+
color: theme.colors.font.white,
|
|
89
|
+
},
|
|
90
|
+
defaultInActiveTabTextStyle: {
|
|
91
|
+
color: theme.colors.font.black,
|
|
92
|
+
},
|
|
93
|
+
defaultTabContainerStyle: {
|
|
94
|
+
backgroundColor: theme.colors.font.white,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
TopBar.propTypes = {
|
|
99
|
+
data: PropTypes.array.isRequired,
|
|
100
|
+
activeIndex: PropTypes.number,
|
|
101
|
+
onActiveTabChange: PropTypes.func.isRequired,
|
|
102
|
+
activeTabTextStyle: PropTypes.object,
|
|
103
|
+
activeTabContainerStyle: PropTypes.object,
|
|
104
|
+
inActiveTabTextStyle: PropTypes.object,
|
|
105
|
+
inActiveTabContainerStyle: PropTypes.object,
|
|
106
|
+
tabContainerStyle: PropTypes.object,
|
|
107
|
+
};
|
package/src/components/index.js
CHANGED
|
@@ -17,3 +17,6 @@ export { OtpInputs } from "./OtpInputs";
|
|
|
17
17
|
export { Popover } from "./Popover";
|
|
18
18
|
export { Touchable } from "./Touchable";
|
|
19
19
|
export { Card } from "./Card";
|
|
20
|
+
export { TopBar } from "./TopBar";
|
|
21
|
+
export { RadioButton } from "./RadioButton";
|
|
22
|
+
export { CheckBox } from "./CheckBox";
|