@unbxd-ui/unbxd-react-components 0.2.100 → 0.2.101-beta.1
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/.babelrc +4 -0
- package/.eslintrc.js +38 -0
- package/CONTRIBUTE.md +105 -0
- package/components/Form/RangeSlider.js +3 -7
- package/components/Tooltip/Tooltip.js +2 -11
- package/components/core.css +1 -3
- package/components/theme.css +0 -2
- package/package.json +23 -13
- package/src/Intro.stories.mdx +119 -0
- package/src/components/Accordian/Accordian.js +89 -0
- package/src/components/Accordian/Accordian.stories.js +92 -0
- package/src/components/Accordian/accordianCore.scss +8 -0
- package/src/components/Accordian/accordianTheme.scss +6 -0
- package/src/components/Accordian/index.js +3 -0
- package/src/components/Button/Button.js +67 -0
- package/src/components/Button/Button.stories.js +103 -0
- package/src/components/Button/DropdownButton.js +60 -0
- package/src/components/Button/DropdownButton.stories.js +38 -0
- package/src/components/Button/buttonTheme.css +1 -0
- package/src/components/Button/buttonTheme.scss +45 -0
- package/src/components/Button/index.js +5 -0
- package/src/components/DataLoader/DataLoader.js +86 -0
- package/src/components/DataLoader/DataLoader.stories.js +72 -0
- package/src/components/DataLoader/index.js +3 -0
- package/src/components/Form/Checkbox.js +73 -0
- package/src/components/Form/DragDropFileUploader.js +67 -0
- package/src/components/Form/Dropdown.js +415 -0
- package/src/components/Form/FileUploader.js +64 -0
- package/src/components/Form/Form.js +83 -0
- package/src/components/Form/FormElementWrapper.js +22 -0
- package/src/components/Form/Input.js +121 -0
- package/src/components/Form/RadioList.js +86 -0
- package/src/components/Form/RangeSlider.js +100 -0
- package/src/components/Form/ServerPaginatedDDList.js +226 -0
- package/src/components/Form/Textarea.js +76 -0
- package/src/components/Form/Toggle.js +96 -0
- package/src/components/Form/form.css +1 -0
- package/src/components/Form/formCore.scss +142 -0
- package/src/components/Form/formTheme.scss +27 -0
- package/src/components/Form/index.js +13 -0
- package/src/components/Form/stories/Checkbox.stories.js +41 -0
- package/src/components/Form/stories/DragDropFileUploader.stories.js +21 -0
- package/src/components/Form/stories/Dropdown.stories.js +124 -0
- package/src/components/Form/stories/FileUploader.stories.js +21 -0
- package/src/components/Form/stories/FormDefault.stories.js +87 -0
- package/src/components/Form/stories/RadioList.stories.js +48 -0
- package/src/components/Form/stories/RangeSlider.stories.js +84 -0
- package/src/components/Form/stories/TextInput.stories.js +77 -0
- package/src/components/Form/stories/Textarea.stories.js +43 -0
- package/src/components/Form/stories/Toggle.stories.js +14 -0
- package/src/components/Form/stories/form.stories.js +216 -0
- package/src/components/InlineModal/InlineModal.js +135 -0
- package/src/components/InlineModal/InlineModal.stories.js +54 -0
- package/src/components/InlineModal/index.js +4 -0
- package/src/components/InlineModal/inlineModal.css +1 -0
- package/src/components/InlineModal/inlineModalCore.scss +31 -0
- package/src/components/InlineModal/inlineModalTheme.scss +16 -0
- package/src/components/List/List.js +72 -0
- package/src/components/List/index.js +3 -0
- package/src/components/List/list.stories.js +28 -0
- package/src/components/List/listCore.css +1 -0
- package/src/components/List/listCore.scss +6 -0
- package/src/components/Modal/Modal.js +99 -0
- package/src/components/Modal/Modal.stories.js +54 -0
- package/src/components/Modal/index.js +3 -0
- package/src/components/Modal/modal.css +1 -0
- package/src/components/Modal/modalCore.scss +34 -0
- package/src/components/NotificationComponent/NotificationComponent.js +58 -0
- package/src/components/NotificationComponent/NotificationComponent.stories.js +28 -0
- package/src/components/NotificationComponent/index.js +3 -0
- package/src/components/NotificationComponent/notificationComponent.css +1 -0
- package/src/components/NotificationComponent/notificationTheme.scss +30 -0
- package/src/components/ProgressBar/ProgressBar.js +45 -0
- package/src/components/ProgressBar/ProgressBar.stories.js +14 -0
- package/src/components/ProgressBar/index.js +3 -0
- package/src/components/ProgressBar/progressBarCore.css +1 -0
- package/src/components/ProgressBar/progressBarCore.scss +14 -0
- package/src/components/ProgressBar/progressBarTheme.css +0 -0
- package/src/components/ProgressBar/progressBarTheme.scss +0 -0
- package/src/components/Table/BaseTable.js +306 -0
- package/src/components/Table/PaginationComponent.js +73 -0
- package/src/components/Table/Table.js +295 -0
- package/src/components/Table/Table.stories.js +198 -0
- package/src/components/Table/index.js +8 -0
- package/src/components/Table/table.css +1 -0
- package/src/components/Table/tableCore.scss +94 -0
- package/src/components/Table/tableTheme.scss +34 -0
- package/src/components/TabsComponent/TabsComponent.js +99 -0
- package/src/components/TabsComponent/TabsComponent.stories.js +69 -0
- package/src/components/TabsComponent/index.js +3 -0
- package/src/components/TabsComponent/tabs.css +1 -0
- package/src/components/TabsComponent/tabsCore.scss +59 -0
- package/src/components/TabsComponent/tabsTheme.css +0 -0
- package/src/components/TabsComponent/tabsTheme.scss +0 -0
- package/src/components/Tooltip/Tooltip.js +87 -0
- package/src/components/Tooltip/Tooltip.stories.js +16 -0
- package/src/components/Tooltip/index.js +3 -0
- package/src/components/Tooltip/tooltipCore.scss +22 -0
- package/src/components/Tooltip/tooltipTheme.scss +21 -0
- package/src/components/core.css +1 -0
- package/src/components/core.scss +29 -0
- package/src/components/index.js +38 -0
- package/src/components/theme.css +1 -0
- package/src/components/theme.scss +11 -0
- package/src/core/Validators.js +34 -0
- package/src/core/customHooks.js +20 -0
- package/src/core/dataLoader.js +143 -0
- package/src/core/dataLoader.stories.js +123 -0
- package/src/core/index.js +3 -0
- package/src/core/utils.js +95 -0
- package/src/index.js +68 -0
- package/vscode-templates/NewStoryTemplate.stories.js +8 -0
- package/core/Validators.js +0 -48
- package/core/customHooks.js +0 -41
- package/core/dataLoader.js +0 -235
- package/core/dataLoader.stories.js +0 -153
- package/core/index.js +0 -31
- package/core/utils.js +0 -112
- package/index.js +0 -193
- /package/{Readme.md → README.md} +0 -0
- /package/{components → src/components}/Accordian/accordianCore.css +0 -0
- /package/{components → src/components}/Accordian/accordianTheme.css +0 -0
- /package/{components/Button/buttonTheme.css → src/components/Button/button.css} +0 -0
- /package/{components → src/components}/Form/formCore.css +0 -0
- /package/{components → src/components}/Form/formTheme.css +0 -0
- /package/{components → src/components}/InlineModal/inlineModalCore.css +0 -0
- /package/{components → src/components}/InlineModal/inlineModalTheme.css +0 -0
- /package/{components/List/listCore.css → src/components/List/list.css} +0 -0
- /package/{components → src/components}/List/listTheme.css +0 -0
- /package/{components/Modal/modalTheme.css → src/components/List/listTheme.scss} +0 -0
- /package/{components → src/components}/Modal/modalCore.css +0 -0
- /package/{components/ProgressBar/progressBarTheme.css → src/components/Modal/modalTheme.css} +0 -0
- /package/{components/TabsComponent/tabsTheme.css → src/components/Modal/modalTheme.scss} +0 -0
- /package/{components → src/components}/NotificationComponent/notificationTheme.css +0 -0
- /package/{components/ProgressBar/progressBarCore.css → src/components/ProgressBar/progressBar.css} +0 -0
- /package/{components → src/components}/Table/tableCore.css +0 -0
- /package/{components → src/components}/Table/tableTheme.css +0 -0
- /package/{components → src/components}/TabsComponent/tabsCore.css +0 -0
- /package/{components → src/components}/Tooltip/tooltipCore.css +0 -0
- /package/{components → src/components}/Tooltip/tooltipTheme.css +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { useState, useContext, useEffect } from "react";
|
|
2
|
+
import { useDidUpdateEffect } from "../../core/customHooks";
|
|
3
|
+
import { FormContext } from "./Form";
|
|
4
|
+
import FormElementWrapper from "./FormElementWrapper";
|
|
5
|
+
import PropTypes from "prop-types";
|
|
6
|
+
|
|
7
|
+
const Toggle = (props) => {
|
|
8
|
+
const { name, label, value, defaultValue, className, appearance, toggleElWidth, toggleKnobSize, onChange, disabled } = props;
|
|
9
|
+
const initialValue = typeof(onChange) === "function" ? value : defaultValue;
|
|
10
|
+
const [ isActive, setIsActive ] = useState(initialValue);
|
|
11
|
+
const { onValueChange } = useContext(FormContext);
|
|
12
|
+
|
|
13
|
+
const toggleActive = () => {
|
|
14
|
+
if (typeof(onChange) === "function") {
|
|
15
|
+
onChange(!isActive);
|
|
16
|
+
} else {
|
|
17
|
+
setIsActive(!isActive);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const postFormValueChange = (value) => {
|
|
22
|
+
typeof(onValueChange) === "function" && onValueChange(name, value);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
useDidUpdateEffect(() => {
|
|
26
|
+
/* runs only when isActive changes, hence call the onChange function then */
|
|
27
|
+
const value = isActive;
|
|
28
|
+
postFormValueChange(value);
|
|
29
|
+
}, [isActive]);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
/* set the initial form element value in the form context */
|
|
33
|
+
postFormValueChange(defaultValue);
|
|
34
|
+
}, [defaultValue]);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setIsActive(initialValue);
|
|
38
|
+
}, [initialValue]);
|
|
39
|
+
|
|
40
|
+
let toggleElCSS = {
|
|
41
|
+
width: `${toggleElWidth}px`
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
let toggleKnobCSS = {
|
|
45
|
+
width: `${toggleKnobSize}px`,
|
|
46
|
+
height: `${toggleKnobSize}px`
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (isActive) {
|
|
50
|
+
toggleKnobCSS.transform = `translateX(${toggleElWidth - toggleKnobSize}px)`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const toggleClasses = `RCB-form-el RCB-toggle ${isActive ? "active" : ""} ${disabled ? "RCB-toggle-disable" : ""}`
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
return (<FormElementWrapper className={className} appearance={appearance}>
|
|
57
|
+
<label className="RCB-form-el-label" htmlFor={name}>{label}</label>
|
|
58
|
+
<div className={toggleClasses}
|
|
59
|
+
onClick={disabled ? () => {} : toggleActive}
|
|
60
|
+
style={toggleElCSS}>
|
|
61
|
+
<div className="RCB-toggle-knob" style={toggleKnobCSS}></div>
|
|
62
|
+
</div>
|
|
63
|
+
</FormElementWrapper>);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
Toggle.propTypes = {
|
|
67
|
+
/** Pass any additional classNames to Input component */
|
|
68
|
+
className: PropTypes.string,
|
|
69
|
+
/** Label for the input element */
|
|
70
|
+
label: PropTypes.string,
|
|
71
|
+
/** Unique ID for the input element */
|
|
72
|
+
name: PropTypes.string.isRequired,
|
|
73
|
+
/** Will be used only with onChange function, or else ignored */
|
|
74
|
+
value: PropTypes.bool,
|
|
75
|
+
defaultValue: PropTypes.bool,
|
|
76
|
+
/** Set this to true to disable the toggle component */
|
|
77
|
+
disabled: PropTypes.bool,
|
|
78
|
+
/** Define the appearance of the form element. Accepted values are either "inline" or "block" */
|
|
79
|
+
appearance: PropTypes.oneOf(["inline", "block"]),
|
|
80
|
+
/** Becomes a controlled component if onChange function is given */
|
|
81
|
+
onChange: PropTypes.func,
|
|
82
|
+
/** width of the toggle element in pixels */
|
|
83
|
+
toggleElWidth: PropTypes.number,
|
|
84
|
+
/** size of the toggle inner knob in pixels */
|
|
85
|
+
toggleKnobSize: PropTypes.number
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
Toggle.defaultProps = {
|
|
89
|
+
className: "",
|
|
90
|
+
disabled: false,
|
|
91
|
+
appearance: "inline",
|
|
92
|
+
toggleElWidth: 40,
|
|
93
|
+
toggleKnobSize: 13
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default Toggle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.RCB-form-el-inline{margin:20px 0;display:inline-block}.RCB-form-el-inline .RCB-form-el-label{margin-right:15px}.RCB-form-el-block{margin:20px 0}.RCB-form-el-block .RCB-form-el-label{display:block}.RCB-dropdown .RCB-list-item{list-style-type:none;padding:10px;cursor:pointer}.RCB-dropdown .RCB-list-item:hover{background-color:#eee}.RCB-dropdown .RCB-list-item.selected{background-color:#eee}.RCB-select-arrow{float:right;font-size:12px;color:#96a9bc;margin-right:12px;margin-left:8px}.RCB-select-arrow:after{content:"\25BC";vertical-align:middle}.RCB-file-input{cursor:pointer}.RCB-drag-drop-uploader{border:2px dashed rgba(104,128,145,0.42);padding:20px;text-align:center}.RCB-drag-over{background:#f3f3f3}.RCB-toggle{padding:2px 3px;background-color:#FFF;border:1px solid #CCC;border-radius:20px;cursor:pointer}.RCB-toggle.active{background-color:#2cb191}.RCB-toggle.active .RCB-toggle-knob{background-color:#FFF}.RCB-toggle-knob{background-color:#8399ae;border-radius:50%;-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-ms-transition:transform .3s ease;transition:transform .3s ease}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
.RCB {
|
|
2
|
+
&-form-el {
|
|
3
|
+
&-inline {
|
|
4
|
+
margin: 20px 0;
|
|
5
|
+
display: inline-block;
|
|
6
|
+
|
|
7
|
+
.RCB-form-el-label {
|
|
8
|
+
margin-right: 15px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.RCB-toggle {
|
|
12
|
+
display: inline-block;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&-block {
|
|
17
|
+
margin: 20px 0;
|
|
18
|
+
|
|
19
|
+
.RCB-form-el-label {
|
|
20
|
+
display: block;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&-dropdown {
|
|
26
|
+
.RCB-list-item {
|
|
27
|
+
list-style-type: none;
|
|
28
|
+
padding: 10px;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
|
|
31
|
+
&:hover {
|
|
32
|
+
background-color: #eee;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.selected {
|
|
36
|
+
background-color: #eee;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&-dd-with-create {
|
|
42
|
+
.RCB-inline-modal-body {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
|
|
46
|
+
.RCB-list {
|
|
47
|
+
flex: 1;
|
|
48
|
+
overflow: scroll;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.RCB-dd-create-cta {
|
|
53
|
+
padding: 10px;
|
|
54
|
+
text-align: center;
|
|
55
|
+
border: 1px solid #bfbfbf;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&-clear-selected {
|
|
61
|
+
background: #f2f0f0;
|
|
62
|
+
padding: 3px 6px;
|
|
63
|
+
font-size: 11px;
|
|
64
|
+
border-radius: 15px;
|
|
65
|
+
border: 1px solid #ccc;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&-selection-wrapper {
|
|
69
|
+
float: right;
|
|
70
|
+
|
|
71
|
+
.RCB-select-arrow {
|
|
72
|
+
float: unset;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&-select-arrow {
|
|
77
|
+
float: right;
|
|
78
|
+
font-size: 12px;
|
|
79
|
+
color: #96a9bc;
|
|
80
|
+
margin-right: 12px;
|
|
81
|
+
margin-left: 8px;
|
|
82
|
+
|
|
83
|
+
&:after {
|
|
84
|
+
content: "\25BC";
|
|
85
|
+
vertical-align: middle;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&-dd-label {
|
|
90
|
+
display: inline-block;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
text-overflow: ellipsis;
|
|
93
|
+
max-width: 70%;
|
|
94
|
+
vertical-align: top;
|
|
95
|
+
white-space: nowrap;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&-file-input {
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&-drag-drop-uploader {
|
|
103
|
+
border: 2px dashed rgba(104,128,145,.42);
|
|
104
|
+
padding: 20px;
|
|
105
|
+
text-align: center;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&-drag-over {
|
|
109
|
+
background: #f3f3f3;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&-toggle {
|
|
113
|
+
padding: 2px 3px;
|
|
114
|
+
background-color: #FFF;
|
|
115
|
+
border: 1px solid #CCC;
|
|
116
|
+
border-radius: 20px;
|
|
117
|
+
box-sizing: content-box;
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
|
|
120
|
+
&.active {
|
|
121
|
+
background-color: #2cb191;
|
|
122
|
+
|
|
123
|
+
.RCB-toggle-knob {
|
|
124
|
+
background-color: #FFF;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&-disable {
|
|
129
|
+
cursor: not-allowed;
|
|
130
|
+
opacity: 0.8;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&-toggle-knob {
|
|
135
|
+
background-color: #8399ae;
|
|
136
|
+
border-radius: 50%;
|
|
137
|
+
-webkit-transition: transform .3s ease;
|
|
138
|
+
-moz-transition: transform .3s ease;
|
|
139
|
+
-ms-transition: transform .3s ease;
|
|
140
|
+
transition: transform .3s ease;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.RCB {
|
|
2
|
+
&-form-error {
|
|
3
|
+
font-size: 12px;
|
|
4
|
+
color: #d25b5b;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
&-dd-search {
|
|
8
|
+
position: relative;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&-dd-search-icon {
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: 5px;
|
|
14
|
+
left: 10px;
|
|
15
|
+
|
|
16
|
+
&:before {
|
|
17
|
+
content: "\1F50D";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&-dd-search-ip {
|
|
22
|
+
width: 100%;
|
|
23
|
+
padding: 10px 30px;
|
|
24
|
+
border: none;
|
|
25
|
+
border-bottom: 1px solid #CCC;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Form from "./Form";
|
|
2
|
+
|
|
3
|
+
export Input from "./Input";
|
|
4
|
+
export Checkbox from "./Checkbox";
|
|
5
|
+
export RadioList from "./RadioList";
|
|
6
|
+
export Textarea from "./Textarea";
|
|
7
|
+
export Dropdown from "./Dropdown";
|
|
8
|
+
export RangeSlider from "./RangeSlider";
|
|
9
|
+
export FileUploader from "./FileUploader";
|
|
10
|
+
export DragDropFileUploader from "./DragDropFileUploader";
|
|
11
|
+
export Toggle from "./Toggle";
|
|
12
|
+
|
|
13
|
+
export default Form;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Form from "../Form";
|
|
3
|
+
import Checkbox from "../Checkbox";
|
|
4
|
+
import Button, { ButtonAppearance } from "../../Button";
|
|
5
|
+
|
|
6
|
+
export const _Checkbox = () => {
|
|
7
|
+
const onSubmit = formData => {
|
|
8
|
+
const { data } = formData;
|
|
9
|
+
|
|
10
|
+
console.log("Submitted data: ", data);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Form onSubmit={onSubmit}>
|
|
15
|
+
<Checkbox name="orange" label="Orange" />
|
|
16
|
+
<Checkbox name="pineapple" label="Pineapple" value={true} onChange={()=>{}} />
|
|
17
|
+
<Checkbox name="grapes" label="Grapes" />
|
|
18
|
+
<br />
|
|
19
|
+
<Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">
|
|
20
|
+
Submit
|
|
21
|
+
</Button>
|
|
22
|
+
</Form>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
_Checkbox.story = {
|
|
27
|
+
parameters: {
|
|
28
|
+
info: {
|
|
29
|
+
propTables: [Checkbox]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
title: "Form|Checkbox",
|
|
36
|
+
parameters: {
|
|
37
|
+
info: {
|
|
38
|
+
propTables: [Checkbox]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import DragDropFileUploader from "../DragDropFileUploader";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "DragDropFileUploader",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const SimpleUsage = () => {
|
|
9
|
+
const onFileChange = (files = []) => {
|
|
10
|
+
console.log("SELECTED FILES");
|
|
11
|
+
for (let i = 0; i < files.length; i++) {
|
|
12
|
+
console.log(files[i].name);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<DragDropFileUploader onChange={onFileChange} appearance="block">
|
|
18
|
+
<div>Drag & drop files into this area</div>
|
|
19
|
+
</DragDropFileUploader>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FRUITS_LIST } from "../../../../public/Constants";
|
|
3
|
+
import Dropdown from "../Dropdown";
|
|
4
|
+
import dataLoader from "../../../core/dataLoader";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: "Dropdown",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const SimpleUsage = () => {
|
|
11
|
+
const onChange = selectedFruit => {
|
|
12
|
+
console.log("Selected Fruit: ", selectedFruit);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Dropdown
|
|
17
|
+
name="fruit"
|
|
18
|
+
label="Select a fruit"
|
|
19
|
+
options={FRUITS_LIST}
|
|
20
|
+
halign="left"
|
|
21
|
+
appearance="block"
|
|
22
|
+
onChange={onChange}
|
|
23
|
+
noSelectionLabel="Select"
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
SimpleUsage.story = {
|
|
29
|
+
name: "Simple Usage ",
|
|
30
|
+
|
|
31
|
+
parameters: {
|
|
32
|
+
info: {
|
|
33
|
+
propTables: [Dropdown],
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
dataLoader.addRequestConfig("getPaginatedUsers", {
|
|
39
|
+
method: "GET",
|
|
40
|
+
url: "https://reqres.in/api/users",
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const PaginatedDropdown = () => {
|
|
44
|
+
const onChange = selected => {
|
|
45
|
+
console.log("Selected User: ", selected);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const responseFormatter = (response) => {
|
|
49
|
+
return {
|
|
50
|
+
...response,
|
|
51
|
+
entries: response.data
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Dropdown
|
|
57
|
+
paginationType="SERVER"
|
|
58
|
+
requestId="getPaginatedUsers"
|
|
59
|
+
pageSize={3}
|
|
60
|
+
maxHeight={50}
|
|
61
|
+
name="user"
|
|
62
|
+
label="Select user"
|
|
63
|
+
appearance="block"
|
|
64
|
+
nameAttribute="first_name"
|
|
65
|
+
onChange={onChange}
|
|
66
|
+
noSelectionLabel="Select"
|
|
67
|
+
responseFormatter={responseFormatter}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
PaginatedDropdown.story = {
|
|
73
|
+
name: "Dropdown with server side pagination",
|
|
74
|
+
|
|
75
|
+
parameters: {
|
|
76
|
+
info: {
|
|
77
|
+
propTables: [Dropdown],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
export const SearchEnbaledDropdown = () => {
|
|
86
|
+
const onChange = selected => {
|
|
87
|
+
console.log("Selected User: ", selected);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const responseFormatter = (response) => {
|
|
91
|
+
return {
|
|
92
|
+
...response,
|
|
93
|
+
entries: response.data
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Dropdown
|
|
99
|
+
paginationType="SERVER"
|
|
100
|
+
requestId="getPaginatedUsers"
|
|
101
|
+
pageSize={3}
|
|
102
|
+
maxHeight={50}
|
|
103
|
+
name="user"
|
|
104
|
+
label="Select user"
|
|
105
|
+
appearance="block"
|
|
106
|
+
nameAttribute="first_name"
|
|
107
|
+
onChange={onChange}
|
|
108
|
+
noSelectionLabel="Select"
|
|
109
|
+
showSearch={true}
|
|
110
|
+
perPageKey={"per_page"}
|
|
111
|
+
responseFormatter={responseFormatter}
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
PaginatedDropdown.story = {
|
|
117
|
+
name: "Dropdown with server side search and pagination",
|
|
118
|
+
|
|
119
|
+
parameters: {
|
|
120
|
+
info: {
|
|
121
|
+
propTables: [Dropdown],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import FileUploader from "../FileUploader";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "FileUploader",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const SimpleUsage = () => {
|
|
9
|
+
const onFileChange = (files = []) => {
|
|
10
|
+
console.log("SELECTED FILES");
|
|
11
|
+
for (let i = 0; i < files.length; i++) {
|
|
12
|
+
console.log(files[i].name);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<FileUploader name="files" appearance="block" onChange={onFileChange} multiple={true}>
|
|
18
|
+
<a href="javascript:void(0)">Upload File</a>
|
|
19
|
+
</FileUploader>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Form from "../Form";
|
|
3
|
+
import Dropdown from "../Dropdown";
|
|
4
|
+
import Input from "../Input";
|
|
5
|
+
import Textarea from "../Textarea";
|
|
6
|
+
import RadioList from "../RadioList";
|
|
7
|
+
import Checkbox from "../Checkbox";
|
|
8
|
+
import Toggle from "../Toggle";
|
|
9
|
+
import RangeSlider from "../RangeSlider";
|
|
10
|
+
import Button, { ButtonAppearance } from "../../Button";
|
|
11
|
+
import { FRUITS_LIST } from "../../../../public/Constants";
|
|
12
|
+
|
|
13
|
+
const formValues = {
|
|
14
|
+
email: "anuhosad@gmail.com",
|
|
15
|
+
description: "This is some temporary description",
|
|
16
|
+
yesNoOption: "NO",
|
|
17
|
+
fruits: ["pineapple"],
|
|
18
|
+
fruit: FRUITS_LIST.find(obj => obj.id === 4),
|
|
19
|
+
isActive: true,
|
|
20
|
+
price: 75
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const FormExample = () => {
|
|
24
|
+
const onSubmit = formData => {
|
|
25
|
+
const { data } = formData;
|
|
26
|
+
|
|
27
|
+
console.log("On submit ----> ", data);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const onChange = formData => {
|
|
31
|
+
const { data } = formData;
|
|
32
|
+
|
|
33
|
+
console.log("On change ----> ", data);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return (<Form onSubmit={onSubmit} onChange={onChange}>
|
|
37
|
+
<Input defaultValue={formValues["email"]}
|
|
38
|
+
type="text"
|
|
39
|
+
name="email"
|
|
40
|
+
label="Name"
|
|
41
|
+
placeholder="Enter your email"
|
|
42
|
+
appearance="block"
|
|
43
|
+
/>
|
|
44
|
+
<Textarea defaultValue={formValues["description"]}
|
|
45
|
+
name="description"
|
|
46
|
+
label="Description"
|
|
47
|
+
placeholder="Enter your description"
|
|
48
|
+
appearance="block"
|
|
49
|
+
/>
|
|
50
|
+
<RadioList defaultValue={formValues["yesNoOption"]}
|
|
51
|
+
name="yesNoOption"
|
|
52
|
+
label="Are you sure?"
|
|
53
|
+
options={[
|
|
54
|
+
{ id: "YES", name: "Yes" },
|
|
55
|
+
{ id: "NO", name: "No" },
|
|
56
|
+
]}
|
|
57
|
+
appearance="block"
|
|
58
|
+
/>
|
|
59
|
+
<Checkbox name="orange" label="Orange" defaultValue={formValues["fruits"].includes("orange")}/>
|
|
60
|
+
<Checkbox name="pineapple" label="Pineapple" defaultValue={formValues["fruits"].includes("pineapple")} />
|
|
61
|
+
<Checkbox name="grapes" label="Grapes" defaultValue={formValues["fruits"].includes("grapes")} />
|
|
62
|
+
<br />
|
|
63
|
+
<Dropdown name="fruit" defaultValue={formValues["fruit"]} label="Select fruit" options={FRUITS_LIST} appearance="block" />
|
|
64
|
+
<Toggle name="isActive" defaultValue={formValues["isActive"]} label="Is Active?" appearance="block" />
|
|
65
|
+
<RangeSlider defaultValue={formValues["price"]}
|
|
66
|
+
name="price"
|
|
67
|
+
label="Select price range"
|
|
68
|
+
min="10"
|
|
69
|
+
max="100"
|
|
70
|
+
appearance="block"
|
|
71
|
+
/>
|
|
72
|
+
<Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">Submit</Button>
|
|
73
|
+
</Form>);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
FormExample.story = {
|
|
77
|
+
name: "Form"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
title: "Form|Form",
|
|
82
|
+
parameters: {
|
|
83
|
+
info: {
|
|
84
|
+
propTables: [Form],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Form from "../Form";
|
|
3
|
+
import RadioList from "../RadioList";
|
|
4
|
+
import Button, { ButtonAppearance } from "../../Button";
|
|
5
|
+
|
|
6
|
+
export const _RadioList = () => {
|
|
7
|
+
const onSubmit = formData => {
|
|
8
|
+
const { data } = formData;
|
|
9
|
+
|
|
10
|
+
console.log("Submitted data: ", data);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Form onSubmit={onSubmit}>
|
|
15
|
+
<RadioList
|
|
16
|
+
name="yesNoOption"
|
|
17
|
+
label="Are you sure?"
|
|
18
|
+
options={[
|
|
19
|
+
{ id: "YES", name: "Yes" },
|
|
20
|
+
{ id: "NO", name: "No" },
|
|
21
|
+
]}
|
|
22
|
+
appearance="block"
|
|
23
|
+
/>
|
|
24
|
+
<Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">
|
|
25
|
+
Submit
|
|
26
|
+
</Button>
|
|
27
|
+
</Form>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
_RadioList.story = {
|
|
32
|
+
name: "RadioList",
|
|
33
|
+
|
|
34
|
+
parameters: {
|
|
35
|
+
info: {
|
|
36
|
+
propTables: [RadioList]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
title: "Form|RadioList",
|
|
43
|
+
parameters: {
|
|
44
|
+
info: {
|
|
45
|
+
propTables: [RadioList]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|