@unbxd-ui/unbxd-react-components 0.2.107-beta.2 → 0.2.108-beta.2

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.
Files changed (289) hide show
  1. package/components/Accordian/Accordian.js +13 -45
  2. package/components/Accordian/Accordian.stories.js +6 -25
  3. package/components/Accordian/index.js +0 -3
  4. package/components/Button/Button.js +9 -26
  5. package/components/Button/Button.stories.js +1 -14
  6. package/components/Button/DropdownButton.js +9 -31
  7. package/components/Button/DropdownButton.stories.js +6 -23
  8. package/components/Button/index.js +1 -8
  9. package/components/DataLoader/DataLoader.js +10 -40
  10. package/components/DataLoader/DataLoader.stories.js +5 -30
  11. package/components/DataLoader/index.js +0 -3
  12. package/components/Form/Checkbox.js +18 -43
  13. package/components/Form/DragDropFileUploader.js +12 -42
  14. package/components/Form/Dropdown.js +106 -182
  15. package/components/Form/FileUploader.js +10 -32
  16. package/components/Form/Form.js +15 -45
  17. package/components/Form/FormElementWrapper.js +2 -7
  18. package/components/Form/Input.js +27 -72
  19. package/components/Form/RadioList.js +20 -49
  20. package/components/Form/RangeSlider.js +39 -74
  21. package/components/Form/ServerPaginatedDDList.js +86 -130
  22. package/components/Form/Textarea.js +18 -43
  23. package/components/Form/Toggle.js +16 -48
  24. package/components/Form/index.js +18 -30
  25. package/components/Form/stories/Checkbox.stories.js +1 -12
  26. package/components/Form/stories/DragDropFileUploader.stories.js +0 -8
  27. package/components/Form/stories/Dropdown.stories.js +6 -24
  28. package/components/Form/stories/FileUploader.stories.js +0 -8
  29. package/components/Form/stories/FormDefault.stories.js +1 -21
  30. package/components/Form/stories/RadioList.stories.js +1 -12
  31. package/components/Form/stories/RangeSlider.stories.js +1 -15
  32. package/components/Form/stories/TextInput.stories.js +3 -19
  33. package/components/Form/stories/Textarea.stories.js +1 -12
  34. package/components/Form/stories/Toggle.stories.js +0 -7
  35. package/components/Form/stories/form.stories.js +3 -40
  36. package/components/InlineModal/InlineModal.js +14 -51
  37. package/components/InlineModal/InlineModal.stories.js +2 -14
  38. package/components/InlineModal/index.js +1 -6
  39. package/components/List/List.js +9 -24
  40. package/components/List/index.js +0 -3
  41. package/components/List/list.stories.js +0 -10
  42. package/components/Modal/Modal.js +17 -49
  43. package/components/Modal/Modal.stories.js +1 -15
  44. package/components/Modal/index.js +0 -3
  45. package/components/NotificationComponent/NotificationComponent.js +11 -34
  46. package/components/NotificationComponent/NotificationComponent.stories.js +0 -6
  47. package/components/NotificationComponent/index.js +0 -3
  48. package/components/ProgressBar/ProgressBar.js +2 -11
  49. package/components/ProgressBar/ProgressBar.stories.js +0 -6
  50. package/components/ProgressBar/index.js +0 -3
  51. package/components/Table/BaseTable.js +69 -134
  52. package/components/Table/PaginationComponent.js +11 -23
  53. package/components/Table/Table.js +68 -149
  54. package/components/Table/Table.stories.js +22 -67
  55. package/components/Table/index.js +0 -4
  56. package/components/TabsComponent/TabsComponent.js +20 -57
  57. package/components/TabsComponent/TabsComponent.stories.js +0 -16
  58. package/components/TabsComponent/index.js +0 -3
  59. package/components/Tooltip/Tooltip.js +25 -47
  60. package/components/Tooltip/Tooltip.stories.js +0 -6
  61. package/components/Tooltip/index.js +0 -3
  62. package/components/core.css +3 -1
  63. package/components/index.js +1 -17
  64. package/components/theme.css +2 -0
  65. package/package.json +3 -2
  66. package/.babelrc +0 -4
  67. package/.eslintrc.js +0 -38
  68. package/CONTRIBUTE.md +0 -105
  69. package/README.md +0 -82
  70. package/lib/components/Accordian/Accordian.js +0 -117
  71. package/lib/components/Accordian/Accordian.stories.js +0 -137
  72. package/lib/components/Accordian/index.js +0 -10
  73. package/lib/components/Button/Button.js +0 -84
  74. package/lib/components/Button/Button.stories.js +0 -89
  75. package/lib/components/Button/DropdownButton.js +0 -77
  76. package/lib/components/Button/DropdownButton.stories.js +0 -51
  77. package/lib/components/Button/index.js +0 -32
  78. package/lib/components/DataLoader/DataLoader.js +0 -88
  79. package/lib/components/DataLoader/DataLoader.stories.js +0 -77
  80. package/lib/components/DataLoader/index.js +0 -10
  81. package/lib/components/Form/Checkbox.js +0 -93
  82. package/lib/components/Form/DragDropFileUploader.js +0 -85
  83. package/lib/components/Form/Dropdown.js +0 -478
  84. package/lib/components/Form/FileUploader.js +0 -81
  85. package/lib/components/Form/Form.js +0 -106
  86. package/lib/components/Form/FormElementWrapper.js +0 -27
  87. package/lib/components/Form/Input.js +0 -140
  88. package/lib/components/Form/RadioList.js +0 -111
  89. package/lib/components/Form/RangeSlider.js +0 -142
  90. package/lib/components/Form/ServerPaginatedDDList.js +0 -267
  91. package/lib/components/Form/Textarea.js +0 -95
  92. package/lib/components/Form/Toggle.js +0 -117
  93. package/lib/components/Form/index.js +0 -73
  94. package/lib/components/Form/stories/Checkbox.stories.js +0 -54
  95. package/lib/components/Form/stories/DragDropFileUploader.stories.js +0 -27
  96. package/lib/components/Form/stories/Dropdown.stories.js +0 -114
  97. package/lib/components/Form/stories/FileUploader.stories.js +0 -31
  98. package/lib/components/Form/stories/FormDefault.stories.js +0 -117
  99. package/lib/components/Form/stories/RadioList.stories.js +0 -55
  100. package/lib/components/Form/stories/RangeSlider.stories.js +0 -82
  101. package/lib/components/Form/stories/TextInput.stories.js +0 -79
  102. package/lib/components/Form/stories/Textarea.stories.js +0 -48
  103. package/lib/components/Form/stories/Toggle.stories.js +0 -25
  104. package/lib/components/Form/stories/form.stories.js +0 -240
  105. package/lib/components/InlineModal/InlineModal.js +0 -146
  106. package/lib/components/InlineModal/InlineModal.stories.js +0 -61
  107. package/lib/components/InlineModal/index.js +0 -24
  108. package/lib/components/List/List.js +0 -76
  109. package/lib/components/List/index.js +0 -10
  110. package/lib/components/List/list.stories.js +0 -38
  111. package/lib/components/Modal/Modal.js +0 -117
  112. package/lib/components/Modal/Modal.stories.js +0 -55
  113. package/lib/components/Modal/index.js +0 -10
  114. package/lib/components/NotificationComponent/NotificationComponent.js +0 -76
  115. package/lib/components/NotificationComponent/NotificationComponent.stories.js +0 -29
  116. package/lib/components/NotificationComponent/index.js +0 -10
  117. package/lib/components/ProgressBar/ProgressBar.js +0 -49
  118. package/lib/components/ProgressBar/ProgressBar.stories.js +0 -21
  119. package/lib/components/ProgressBar/index.js +0 -10
  120. package/lib/components/Table/BaseTable.js +0 -352
  121. package/lib/components/Table/PaginationComponent.js +0 -87
  122. package/lib/components/Table/Table.js +0 -333
  123. package/lib/components/Table/Table.stories.js +0 -204
  124. package/lib/components/Table/index.js +0 -17
  125. package/lib/components/TabsComponent/TabsComponent.js +0 -134
  126. package/lib/components/TabsComponent/TabsComponent.stories.js +0 -65
  127. package/lib/components/TabsComponent/index.js +0 -10
  128. package/lib/components/Tooltip/Tooltip.js +0 -102
  129. package/lib/components/Tooltip/Tooltip.stories.js +0 -25
  130. package/lib/components/Tooltip/index.js +0 -10
  131. package/lib/components/core.css +0 -3
  132. package/lib/components/core.scss +0 -29
  133. package/lib/components/index.js +0 -159
  134. package/lib/components/theme.css +0 -3
  135. package/lib/components/theme.scss +0 -11
  136. package/lib/package-lock.json +0 -20607
  137. package/lib/package.json +0 -94
  138. package/src/Intro.stories.mdx +0 -119
  139. package/src/components/Accordian/Accordian.js +0 -89
  140. package/src/components/Accordian/Accordian.stories.js +0 -92
  141. package/src/components/Accordian/accordianCore.css +0 -1
  142. package/src/components/Accordian/accordianCore.scss +0 -8
  143. package/src/components/Accordian/accordianTheme.css +0 -1
  144. package/src/components/Accordian/accordianTheme.scss +0 -6
  145. package/src/components/Accordian/index.js +0 -3
  146. package/src/components/Button/Button.js +0 -67
  147. package/src/components/Button/Button.stories.js +0 -103
  148. package/src/components/Button/DropdownButton.js +0 -60
  149. package/src/components/Button/DropdownButton.stories.js +0 -38
  150. package/src/components/Button/button.css +0 -1
  151. package/src/components/Button/buttonTheme.css +0 -1
  152. package/src/components/Button/buttonTheme.scss +0 -45
  153. package/src/components/Button/index.js +0 -5
  154. package/src/components/DataLoader/DataLoader.js +0 -86
  155. package/src/components/DataLoader/DataLoader.stories.js +0 -72
  156. package/src/components/DataLoader/index.js +0 -3
  157. package/src/components/Form/Checkbox.js +0 -73
  158. package/src/components/Form/DragDropFileUploader.js +0 -67
  159. package/src/components/Form/Dropdown.js +0 -430
  160. package/src/components/Form/FileUploader.js +0 -64
  161. package/src/components/Form/Form.js +0 -83
  162. package/src/components/Form/FormElementWrapper.js +0 -22
  163. package/src/components/Form/Input.js +0 -121
  164. package/src/components/Form/RadioList.js +0 -86
  165. package/src/components/Form/RangeSlider.js +0 -100
  166. package/src/components/Form/ServerPaginatedDDList.js +0 -231
  167. package/src/components/Form/Textarea.js +0 -76
  168. package/src/components/Form/Toggle.js +0 -96
  169. package/src/components/Form/form.css +0 -1
  170. package/src/components/Form/formCore.css +0 -1
  171. package/src/components/Form/formCore.scss +0 -142
  172. package/src/components/Form/formTheme.css +0 -1
  173. package/src/components/Form/formTheme.scss +0 -27
  174. package/src/components/Form/index.js +0 -13
  175. package/src/components/Form/stories/Checkbox.stories.js +0 -41
  176. package/src/components/Form/stories/DragDropFileUploader.stories.js +0 -21
  177. package/src/components/Form/stories/Dropdown.stories.js +0 -124
  178. package/src/components/Form/stories/FileUploader.stories.js +0 -21
  179. package/src/components/Form/stories/FormDefault.stories.js +0 -87
  180. package/src/components/Form/stories/RadioList.stories.js +0 -48
  181. package/src/components/Form/stories/RangeSlider.stories.js +0 -84
  182. package/src/components/Form/stories/TextInput.stories.js +0 -77
  183. package/src/components/Form/stories/Textarea.stories.js +0 -43
  184. package/src/components/Form/stories/Toggle.stories.js +0 -14
  185. package/src/components/Form/stories/form.stories.js +0 -216
  186. package/src/components/InlineModal/InlineModal.js +0 -135
  187. package/src/components/InlineModal/InlineModal.stories.js +0 -54
  188. package/src/components/InlineModal/index.js +0 -4
  189. package/src/components/InlineModal/inlineModal.css +0 -1
  190. package/src/components/InlineModal/inlineModalCore.css +0 -1
  191. package/src/components/InlineModal/inlineModalCore.scss +0 -31
  192. package/src/components/InlineModal/inlineModalTheme.css +0 -1
  193. package/src/components/InlineModal/inlineModalTheme.scss +0 -16
  194. package/src/components/List/List.js +0 -72
  195. package/src/components/List/index.js +0 -3
  196. package/src/components/List/list.css +0 -1
  197. package/src/components/List/list.stories.js +0 -28
  198. package/src/components/List/listCore.css +0 -1
  199. package/src/components/List/listCore.scss +0 -6
  200. package/src/components/List/listTheme.css +0 -0
  201. package/src/components/List/listTheme.scss +0 -0
  202. package/src/components/Modal/Modal.js +0 -99
  203. package/src/components/Modal/Modal.stories.js +0 -54
  204. package/src/components/Modal/index.js +0 -3
  205. package/src/components/Modal/modal.css +0 -1
  206. package/src/components/Modal/modalCore.css +0 -1
  207. package/src/components/Modal/modalCore.scss +0 -34
  208. package/src/components/Modal/modalTheme.css +0 -0
  209. package/src/components/Modal/modalTheme.scss +0 -0
  210. package/src/components/NotificationComponent/NotificationComponent.js +0 -58
  211. package/src/components/NotificationComponent/NotificationComponent.stories.js +0 -28
  212. package/src/components/NotificationComponent/index.js +0 -3
  213. package/src/components/NotificationComponent/notificationComponent.css +0 -1
  214. package/src/components/NotificationComponent/notificationTheme.css +0 -1
  215. package/src/components/NotificationComponent/notificationTheme.scss +0 -30
  216. package/src/components/ProgressBar/ProgressBar.js +0 -45
  217. package/src/components/ProgressBar/ProgressBar.stories.js +0 -14
  218. package/src/components/ProgressBar/index.js +0 -3
  219. package/src/components/ProgressBar/progressBar.css +0 -1
  220. package/src/components/ProgressBar/progressBarCore.css +0 -1
  221. package/src/components/ProgressBar/progressBarCore.scss +0 -14
  222. package/src/components/ProgressBar/progressBarTheme.css +0 -0
  223. package/src/components/ProgressBar/progressBarTheme.scss +0 -0
  224. package/src/components/Table/BaseTable.js +0 -306
  225. package/src/components/Table/PaginationComponent.js +0 -73
  226. package/src/components/Table/Table.js +0 -295
  227. package/src/components/Table/Table.stories.js +0 -198
  228. package/src/components/Table/index.js +0 -8
  229. package/src/components/Table/table.css +0 -1
  230. package/src/components/Table/tableCore.css +0 -1
  231. package/src/components/Table/tableCore.scss +0 -94
  232. package/src/components/Table/tableTheme.css +0 -1
  233. package/src/components/Table/tableTheme.scss +0 -34
  234. package/src/components/TabsComponent/TabsComponent.js +0 -99
  235. package/src/components/TabsComponent/TabsComponent.stories.js +0 -69
  236. package/src/components/TabsComponent/index.js +0 -3
  237. package/src/components/TabsComponent/tabs.css +0 -1
  238. package/src/components/TabsComponent/tabsCore.css +0 -1
  239. package/src/components/TabsComponent/tabsCore.scss +0 -59
  240. package/src/components/TabsComponent/tabsTheme.css +0 -0
  241. package/src/components/TabsComponent/tabsTheme.scss +0 -0
  242. package/src/components/Tooltip/Tooltip.js +0 -87
  243. package/src/components/Tooltip/Tooltip.stories.js +0 -16
  244. package/src/components/Tooltip/index.js +0 -3
  245. package/src/components/Tooltip/tooltipCore.css +0 -1
  246. package/src/components/Tooltip/tooltipCore.scss +0 -22
  247. package/src/components/Tooltip/tooltipTheme.css +0 -1
  248. package/src/components/Tooltip/tooltipTheme.scss +0 -21
  249. package/src/components/core.css +0 -1
  250. package/src/components/core.scss +0 -29
  251. package/src/components/index.js +0 -38
  252. package/src/components/theme.css +0 -1
  253. package/src/components/theme.scss +0 -11
  254. package/src/core/Validators.js +0 -34
  255. package/src/core/customHooks.js +0 -20
  256. package/src/core/dataLoader.js +0 -143
  257. package/src/core/dataLoader.stories.js +0 -123
  258. package/src/core/index.js +0 -3
  259. package/src/core/utils.js +0 -95
  260. package/src/index.js +0 -68
  261. package/vscode-templates/NewStoryTemplate.stories.js +0 -8
  262. /package/{lib/Readme.md → Readme.md} +0 -0
  263. /package/{lib/components → components}/Accordian/accordianCore.css +0 -0
  264. /package/{lib/components → components}/Accordian/accordianTheme.css +0 -0
  265. /package/{lib/components → components}/Button/buttonTheme.css +0 -0
  266. /package/{lib/components → components}/Form/formCore.css +0 -0
  267. /package/{lib/components → components}/Form/formTheme.css +0 -0
  268. /package/{lib/components → components}/InlineModal/inlineModalCore.css +0 -0
  269. /package/{lib/components → components}/InlineModal/inlineModalTheme.css +0 -0
  270. /package/{lib/components → components}/List/listCore.css +0 -0
  271. /package/{lib/components → components}/List/listTheme.css +0 -0
  272. /package/{lib/components → components}/Modal/modalCore.css +0 -0
  273. /package/{lib/components → components}/Modal/modalTheme.css +0 -0
  274. /package/{lib/components → components}/NotificationComponent/notificationTheme.css +0 -0
  275. /package/{lib/components → components}/ProgressBar/progressBarCore.css +0 -0
  276. /package/{lib/components → components}/ProgressBar/progressBarTheme.css +0 -0
  277. /package/{lib/components → components}/Table/tableCore.css +0 -0
  278. /package/{lib/components → components}/Table/tableTheme.css +0 -0
  279. /package/{lib/components → components}/TabsComponent/tabsCore.css +0 -0
  280. /package/{lib/components → components}/TabsComponent/tabsTheme.css +0 -0
  281. /package/{lib/components → components}/Tooltip/tooltipCore.css +0 -0
  282. /package/{lib/components → components}/Tooltip/tooltipTheme.css +0 -0
  283. /package/{lib/core → core}/Validators.js +0 -0
  284. /package/{lib/core → core}/customHooks.js +0 -0
  285. /package/{lib/core → core}/dataLoader.js +0 -0
  286. /package/{lib/core → core}/dataLoader.stories.js +0 -0
  287. /package/{lib/core → core}/index.js +0 -0
  288. /package/{lib/core → core}/utils.js +0 -0
  289. /package/{lib/index.js → index.js} +0 -0
@@ -1,84 +0,0 @@
1
- import React from "react";
2
- import Form from "../Form";
3
- import RangeSlider from "../RangeSlider";
4
- import Button, { ButtonAppearance } from "../../Button";
5
-
6
- export const _RangeSlider = () => {
7
- const onSubmit = formData => {
8
- const { data } = formData;
9
- const { price } = data;
10
-
11
- console.log("Selected price: ", price);
12
- };
13
-
14
- return (
15
- <Form onSubmit={onSubmit}>
16
- <RangeSlider
17
- name="price"
18
- label="Select price range"
19
- min="10"
20
- max="100"
21
- appearance="block"
22
- defaultValue="10"
23
- />
24
- <Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">
25
- Submit
26
- </Button>
27
- </Form>
28
- );
29
- };
30
-
31
- _RangeSlider.story = {
32
- name: "Range Slider ",
33
-
34
- parameters: {
35
- info: {
36
- propTables: [RangeSlider]
37
- }
38
- },
39
- };
40
-
41
- export const BubbleRangeSlider = () => {
42
- const onSubmit = formData => {
43
- const { data } = formData;
44
- const { price } = data;
45
-
46
- console.log("Selected price: ", price);
47
- };
48
-
49
- return (
50
- <Form onSubmit={onSubmit}>
51
- <RangeSlider
52
- name="price"
53
- label="Select price range"
54
- min="10"
55
- max="100"
56
- appearance="block"
57
- defaultValue="10"
58
- showBubble={true}
59
- />
60
- <Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">
61
- Submit
62
- </Button>
63
- </Form>
64
- );
65
- };
66
-
67
- BubbleRangeSlider.story = {
68
- name: "Range Slider with Bubble",
69
-
70
- parameters: {
71
- info: {
72
- propTables: [RangeSlider]
73
- }
74
- },
75
- };
76
-
77
- export default {
78
- title: "Form|RangeSlider",
79
- parameters: {
80
- info: {
81
- propTables: [RangeSlider],
82
- }
83
- }
84
- };
@@ -1,77 +0,0 @@
1
- import React, { Fragment, useRef } from "react";
2
- import Form from "../Form";
3
- import Input from "../Input";
4
- import Button, { ButtonAppearance } from "../../Button";
5
-
6
- export const TextInput = () => {
7
- const onSubmit = formData => {
8
- const { data, errors = {} } = formData;
9
-
10
- if (Object.keys(errors).length) {
11
- console.log("ERRORS FOUND : ");
12
- console.log(errors);
13
- } else {
14
- console.log("Submitted data: ", data);
15
- }
16
- };
17
-
18
- return (
19
- <Form onSubmit={onSubmit}>
20
- <Input
21
- type="text"
22
- name="email"
23
- label="Name"
24
- placeholder="Enter your email"
25
- appearance="block"
26
- validations={[
27
- {
28
- type: "EMAIL",
29
- message: "Please enter a valid email address",
30
- },
31
- ]}
32
- />
33
- <Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">
34
- Submit
35
- </Button>
36
- </Form>
37
- );
38
- };
39
-
40
- TextInput.story = {
41
- parameters: {
42
- info: {
43
- propTables: [Input]
44
- }
45
- },
46
- };
47
-
48
- export const RefUsage = () => {
49
- const inputRef = useRef();
50
-
51
- const focusInput = () => {
52
- inputRef.current.focus();
53
- };
54
-
55
- return (
56
- <Fragment>
57
- <Button appearance={ButtonAppearance.SECONDARY} className="full-width-btn" onClick={focusInput}>Focus input</Button>
58
- <Input
59
- ref={inputRef}
60
- type="text"
61
- name="email"
62
- label="Name"
63
- placeholder="Enter your email"
64
- appearance="block"
65
- />
66
- </Fragment>
67
- );
68
- };
69
-
70
- export default {
71
- title: "Form|Text Input",
72
- parameters: {
73
- info: {
74
- propTables: [TextInput]
75
- }
76
- }
77
- };
@@ -1,43 +0,0 @@
1
- import React from "react";
2
- import Form from "../Form";
3
- import Textarea from "../Textarea";
4
- import Button, { ButtonAppearance } from "../../Button";
5
-
6
- export const _Textarea = () => {
7
- const onSubmit = formData => {
8
- const { data } = formData;
9
-
10
- console.log("Submitted data: ", data);
11
- };
12
-
13
- return (
14
- <Form onSubmit={onSubmit}>
15
- <Textarea
16
- name="description"
17
- label="Description"
18
- placeholder="Enter your description"
19
- appearance="block"
20
- />
21
- <Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">
22
- Submit
23
- </Button>
24
- </Form>
25
- );
26
- };
27
-
28
- _Textarea.story = {
29
- parameters: {
30
- info: {
31
- propTables: [Textarea],
32
- },
33
- },
34
- };
35
-
36
- export default {
37
- title: "Form|Textarea",
38
- parameters: {
39
- info: {
40
- propTables: [Textarea]
41
- }
42
- }
43
- };
@@ -1,14 +0,0 @@
1
- import React from "react";
2
- import Toggle from "../Toggle";
3
-
4
- export default {
5
- title: "Toggle",
6
- };
7
-
8
- export const SimpleUsage = () => {
9
- const onChange = isActive => {
10
- console.log("isActive: ", isActive);
11
- };
12
-
13
- return <Toggle label="Is Active?" name="isActive" appearance="block" onChange={onChange} />;
14
- };
@@ -1,216 +0,0 @@
1
- import React, { Fragment, useRef } 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 FileUploader from "../FileUploader";
9
- import DragDropFileUploader from "../DragDropFileUploader";
10
- import Toggle from "../Toggle";
11
- import RangeSlider from "../RangeSlider";
12
- import Button, { ButtonAppearance } from "../../Button";
13
- import { FRUITS_LIST } from "../../../../public/Constants";
14
-
15
- export const FormExample = () => {
16
- const onSubmit = formData => {
17
- const { data, errors = {} } = formData;
18
-
19
- if (Object.keys(errors).length) {
20
- console.log("ERRORS FOUND : ");
21
- console.log(errors);
22
- } else {
23
- console.log("Submitted data: ", data);
24
- }
25
- };
26
-
27
- return (<Form onSubmit={onSubmit}>
28
- <Input
29
- type="text"
30
- name="email"
31
- label="Name"
32
- placeholder="Enter your email"
33
- appearance="block"
34
- />
35
- <Textarea
36
- name="description"
37
- label="Description"
38
- placeholder="Enter your description"
39
- appearance="block"
40
- />
41
- <RadioList
42
- name="yesNoOption"
43
- label="Are you sure?"
44
- options={[
45
- { id: "YES", name: "Yes" },
46
- { id: "NO", name: "No" },
47
- ]}
48
- appearance="block"
49
- />
50
- <Checkbox name="orange" label="Orange" />
51
- <Checkbox name="pineapple" label="Pineapple" value={true} onChange={()=>{}} />
52
- <Checkbox name="grapes" label="Grapes" />
53
- <br />
54
- <Dropdown name="fruit" label="Select fruit"
55
- options={FRUITS_LIST} appearance="block"
56
- validations={[{ type: "REQUIRED", message: "Please select a fruit" }]} />
57
- <Toggle label="Is Active?" name="isActive" appearance="block" />
58
- <RangeSlider
59
- name="price"
60
- label="Select price range"
61
- min="10"
62
- max="100"
63
- appearance="block"
64
- defaultValue="10"
65
- />
66
- <Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">Submit</Button>
67
- </Form>);
68
- };
69
-
70
- FormExample.story = {
71
- name: "Form"
72
- }
73
-
74
- export const _Dropdown = () => {
75
- const onSubmit = formData => {
76
- const { data } = formData;
77
- const { fruit } = data;
78
-
79
- console.log("Selected Fruit: ", fruit);
80
- };
81
-
82
- return (
83
- <Form onSubmit={onSubmit}>
84
- <Dropdown name="fruit" label="Select fruit" options={FRUITS_LIST} appearance="block" />
85
- <Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">
86
- Submit
87
- </Button>
88
- </Form>
89
- );
90
- };
91
-
92
- _Dropdown.story = {
93
- name: "Dropdown ",
94
-
95
- parameters: {
96
- info: {
97
- propTables: [Dropdown],
98
- },
99
- },
100
- };
101
-
102
- export const _FileUploader = () => {
103
- const onSubmit = formData => {
104
- const { data } = formData;
105
- const { file } = data;
106
-
107
- console.log("Selected file: ", file[0].name);
108
- };
109
-
110
- return (
111
- <Form onSubmit={onSubmit}>
112
- <FileUploader name="file" appearance="block">
113
- <a href="javascript:void(0)">Upload File</a>
114
- </FileUploader>
115
- <Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">
116
- Submit
117
- </Button>
118
- </Form>
119
- );
120
- };
121
-
122
- _FileUploader.story = {
123
- name: "File Uploader ",
124
-
125
- parameters: {
126
- info: {
127
- propTables: [FileUploader],
128
- },
129
- },
130
- };
131
-
132
- export const _DragDropFileUploader = () => {
133
- const onSubmit = formData => {
134
- const { data } = formData;
135
- const { filesList } = data;
136
-
137
- console.log("Selected file: ", filesList[0].name);
138
- };
139
-
140
- return (
141
- <Form onSubmit={onSubmit}>
142
- <DragDropFileUploader name="filesList" appearance="block">
143
- <div>Drag & drop files into this area</div>
144
- </DragDropFileUploader>
145
- <Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">
146
- Submit
147
- </Button>
148
- </Form>
149
- );
150
- };
151
-
152
- _DragDropFileUploader.story = {
153
- name: "DragDrop File Uploader ",
154
-
155
- parameters: {
156
- info: {
157
- propTables: [DragDropFileUploader],
158
- },
159
- },
160
- };
161
-
162
- export const _Toggle = () => {
163
- const onSubmit = formData => {
164
- const { data } = formData;
165
- const { isActive } = data;
166
-
167
- console.log("isActive: ", isActive);
168
- };
169
-
170
- return (
171
- <Form onSubmit={onSubmit}>
172
- <Toggle label="Is Active?" name="isActive" appearance="block" />
173
- <Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn">
174
- Submit
175
- </Button>
176
- </Form>
177
- );
178
- };
179
-
180
- _Toggle.story = {
181
- name: "Toggle ",
182
-
183
- parameters: {
184
- info: {
185
- propTables: [Toggle],
186
- },
187
- },
188
- };
189
-
190
- export const GetFormData = () => {
191
- const formRef = useRef();
192
- const submitFormData = () => {
193
- const formData = formRef.current.getFormData();
194
- const { data } = formData;
195
-
196
- console.log("Got data", data);
197
- };
198
-
199
- return (<Fragment>
200
- <Form ref={formRef}>
201
- <Input name="name" label="Enter name" />
202
- <Input name="email" label="Enter Email ID" />
203
- <Dropdown name="fruit" label="Select fruit" options={FRUITS_LIST} appearance="block" />
204
- </Form>
205
- <Button appearance={ButtonAppearance.PRIMARY} className="full-width-btn" onClick={submitFormData}>Click to submit</Button>
206
- </Fragment>);
207
- };
208
-
209
- export default {
210
- title: "Form|Miscellanious",
211
- parameters: {
212
- info: {
213
- propTables: [Form],
214
- },
215
- },
216
- };
@@ -1,135 +0,0 @@
1
- import React, { forwardRef, useState, useRef, useEffect, useImperativeHandle } from "react";
2
- import PropTypes from "prop-types";
3
-
4
- export const InlineModalActivator = (props) => {
5
- return props.children;
6
- }
7
-
8
- export const InlineModalBody = (props) => {
9
- return props.children;
10
- }
11
-
12
- let InlineModal = (props, ref) => {
13
- const { children, activatorAction, className, isModalOpen:propIsOpen, halign, onModalStateChange } = props;
14
- let [ isModalOpen, setIsModalOpen ] = useState(propIsOpen);
15
- let activatorProps = {};
16
- let inlineModalClassName = `RCB-inline-modal ${className}`;
17
- let showModalBody = isModalOpen;
18
- const inlineModalRef = useRef();
19
- const isFirstRun = useRef(true);
20
-
21
- const changeModalState = (newState) => {
22
- setIsModalOpen(newState);
23
- }
24
-
25
- const onActivatorClick = (e) => {
26
- e.stopPropagation();
27
- changeModalState(!isModalOpen);
28
- }
29
-
30
- const onBodyClick = (e) => {
31
- const eventTarget = e.target;
32
- const inlineModalNode = inlineModalRef.current;
33
- let eventPathNodes = e.composedPath();
34
- let isWithinModal = false;
35
-
36
- if (inlineModalNode.contains(eventTarget)) {
37
- isWithinModal = true;
38
- } else {
39
- for (let i = 0; i < eventPathNodes.length; i++) {
40
- const node = eventPathNodes[i];
41
- if (node!== window && inlineModalNode.contains(node)) {
42
- isWithinModal = true;
43
- break;
44
- }
45
- }
46
- }
47
-
48
- if (!isWithinModal) {
49
- /* outside click -> close modal */
50
- changeModalState(false);
51
- }
52
- }
53
-
54
- useEffect(() => {
55
- /* add when mounted */
56
- document.addEventListener("click", onBodyClick);
57
-
58
- /* return function to be called when unmounted */
59
- return () => {
60
- document.removeEventListener("click", onBodyClick);
61
- };
62
- }, []);
63
-
64
- useEffect(() => {
65
- if (isFirstRun.current) {
66
- /* skip first run */
67
- isFirstRun.current = false;
68
- return;
69
- }
70
- typeof(onModalStateChange) === "function" && onModalStateChange(isModalOpen);
71
- }, [isModalOpen]);
72
-
73
- if (activatorAction === "click") {
74
- activatorProps = {
75
- onClick: onActivatorClick
76
- };
77
- } else if (activatorAction === "hover") {
78
- inlineModalClassName += " hover-open";
79
- showModalBody = true;
80
- }
81
-
82
- /* add methods that can be accessed via this component's ref */
83
- useImperativeHandle(ref, () => ({
84
- hideModal: () => {
85
- changeModalState(false);
86
- }
87
- }));
88
-
89
- return (<div className={inlineModalClassName} ref={inlineModalRef}>
90
- <div {...activatorProps} className="RCB-inline-modal-btn">{children[0]}</div>
91
- {showModalBody && <div className={`RCB-inline-modal-body RCB-align-${halign}`}>{children[1]}</div>}
92
- </div>);
93
- }
94
-
95
- InlineModal = forwardRef(InlineModal);
96
-
97
- InlineModal.propTypes = {
98
- /** Pass any additional classNames to InlineModal component */
99
- className: PropTypes.string,
100
- /** Horizontal alignment of the inline modal body */
101
- halign: PropTypes.oneOf(["left", "right"]),
102
- /** Event on which the modal should be opened */
103
- activatorAction: PropTypes.oneOf(["click", "hover"]),
104
- children: (props, propName, componentName) => {
105
- const children = props[propName];
106
-
107
- if (React.Children.count(children) !== 2) {
108
- return new Error(
109
- `${componentName} should have 2 children`
110
- );
111
- }
112
-
113
- if (children[0].type !== InlineModalActivator ||
114
- children[1].type !== InlineModalBody) {
115
- return new Error(
116
- `${componentName} should have an InlineModalActivator & InlineModalBody components as children`
117
- );
118
- }
119
- },
120
- /** Boolean prop to have the modal open or close */
121
- isModalOpen: PropTypes.bool,
122
- /** callback function that gets called when the modal state changes (either opens or closes) */
123
- onModalStateChange: PropTypes.func
124
- };
125
-
126
- InlineModal.defaultProps = {
127
- className: "",
128
- halign: "left",
129
- activatorAction: "click", // or "hover"
130
- isModalOpen: false
131
- };
132
-
133
- InlineModal.displayName = "InlineModal";
134
-
135
- export default InlineModal;
@@ -1,54 +0,0 @@
1
- import React, { Fragment, useState } from "react";
2
- import { linkTo } from "@storybook/addon-links";
3
-
4
- import { FRUITS_LIST } from "../../../public/Constants";
5
- import InlineModal, { InlineModalActivator, InlineModalBody } from "./InlineModal";
6
- import { List } from "../";
7
-
8
- /* eslint-disable react/prop-types */
9
- const CustomListItem = (props) => {
10
- const { itemData } = props;
11
- const { id, name } = itemData;
12
-
13
- return (<li>
14
- <input type="checkbox" id={id}></input>
15
- <label htmlFor={id}>{name}</label>
16
- </li>)
17
- };
18
- /* eslint-enable react/prop-types */
19
-
20
- export const SimpleUsage = () => {
21
- const onModalStateChange = (isModalOpen) => {
22
- console.log("Modal state change 1");
23
- console.log({isModalOpen});
24
- };
25
-
26
- return (<Fragment>
27
- <InlineModal onModalStateChange={onModalStateChange}>
28
- <InlineModalActivator>
29
- <div>Select a fruit</div>
30
- </InlineModalActivator>
31
- <InlineModalBody>
32
- <List items={FRUITS_LIST} showApp={linkTo("List")} ListItem={CustomListItem} />
33
- </InlineModalBody>
34
- </InlineModal>
35
- </Fragment>);
36
- };
37
-
38
- SimpleUsage.story = {
39
- parameters: {
40
- info: {
41
- text: "Displaying a dropdown list of items",
42
- }
43
- }
44
- };
45
-
46
- export default {
47
- title: "Modals|Inline modal",
48
- parameters: {
49
- info: {
50
- propTables: [InlineModal, InlineModalActivator, InlineModalBody],
51
- propTablesExclude: [List],
52
- }
53
- }
54
- };
@@ -1,4 +0,0 @@
1
- import InlineModal, { InlineModalActivator, InlineModalBody } from "./InlineModal";
2
-
3
- export default InlineModal;
4
- export { InlineModalActivator, InlineModalBody };
@@ -1 +0,0 @@
1
- .RCB-inline-modal{position:relative;display:inline-block}.RCB-inline-modal.hover-open .RCB-inline-modal-body{display:none}.RCB-inline-modal.hover-open:hover .RCB-inline-modal-body{display:block}.RCB-inline-modal-btn{display:inline-block;background:#FFF;border:1px solid #eee;padding:10px;border-radius:3px;cursor:pointer}.RCB-inline-modal-body{position:absolute;background:#FFF;border:1px solid #efeeee;box-shadow:0 9px 12px 0 rgba(0,0,0,0.15);z-index:1}.RCB-inline-modal-body.RCB-align-left{left:0}.RCB-inline-modal-body.RCB-align-right{right:0}
@@ -1 +0,0 @@
1
- .RCB-inline-modal{position:relative;display:inline-block}.RCB-inline-modal.hover-open .RCB-inline-modal-body{display:none}.RCB-inline-modal.hover-open:hover .RCB-inline-modal-body{display:block}.RCB-inline-modal-body{position:absolute;z-index:1}.RCB-inline-modal-body.RCB-align-left{left:0}.RCB-inline-modal-body.RCB-align-right{right:0}
@@ -1,31 +0,0 @@
1
- .RCB {
2
- &-inline-modal {
3
- position: relative;
4
- display: inline-block;
5
-
6
- &.hover-open {
7
- .RCB-inline-modal-body {
8
- display: none;
9
- }
10
-
11
- &:hover {
12
- .RCB-inline-modal-body {
13
- display: block;
14
- }
15
- }
16
- }
17
- }
18
-
19
- &-inline-modal-body {
20
- position: absolute;
21
- z-index: 1;
22
-
23
- &.RCB-align-left {
24
- left: 0;
25
- }
26
-
27
- &.RCB-align-right {
28
- right: 0;
29
- }
30
- }
31
- }
@@ -1 +0,0 @@
1
- .RCB-inline-modal-btn{display:inline-block;background:#FFF;border:1px solid #eee;padding:10px;border-radius:3px;cursor:pointer}.RCB-inline-modal-body{background:#FFF;border:1px solid #efeeee;box-shadow:0 9px 12px 0 rgba(0,0,0,0.15)}
@@ -1,16 +0,0 @@
1
- .RCB {
2
- &-inline-modal-btn {
3
- display: inline-block;
4
- background: #FFF;
5
- border: 1px solid #eee;
6
- padding: 10px;
7
- border-radius: 3px;
8
- cursor: pointer;
9
- }
10
-
11
- &-inline-modal-body {
12
- background: #FFF;
13
- border: 1px solid #efeeee;
14
- box-shadow: 0 9px 12px 0 rgba(0,0,0,0.15);
15
- }
16
- }