@unbxd-ui/unbxd-react-components 0.2.105 → 0.2.107-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/.babelrc +4 -0
  2. package/.eslintrc.js +38 -0
  3. package/CONTRIBUTE.md +105 -0
  4. package/components/Accordian/Accordian.js +45 -13
  5. package/components/Accordian/Accordian.stories.js +25 -6
  6. package/components/Accordian/index.js +3 -0
  7. package/components/Button/Button.js +26 -9
  8. package/components/Button/Button.stories.js +14 -1
  9. package/components/Button/DropdownButton.js +31 -9
  10. package/components/Button/DropdownButton.stories.js +23 -6
  11. package/components/Button/index.js +8 -1
  12. package/components/DataLoader/DataLoader.js +40 -10
  13. package/components/DataLoader/DataLoader.stories.js +30 -5
  14. package/components/DataLoader/index.js +3 -0
  15. package/components/Form/Checkbox.js +42 -14
  16. package/components/Form/DragDropFileUploader.js +42 -12
  17. package/components/Form/Dropdown.js +181 -104
  18. package/components/Form/FileUploader.js +32 -10
  19. package/components/Form/Form.js +45 -15
  20. package/components/Form/FormElementWrapper.js +7 -2
  21. package/components/Form/Input.js +72 -27
  22. package/components/Form/RadioList.js +48 -17
  23. package/components/Form/RangeSlider.js +73 -37
  24. package/components/Form/ServerPaginatedDDList.js +130 -86
  25. package/components/Form/Textarea.js +43 -18
  26. package/components/Form/Toggle.js +48 -16
  27. package/components/Form/index.js +30 -18
  28. package/components/Form/stories/Checkbox.stories.js +12 -1
  29. package/components/Form/stories/DragDropFileUploader.stories.js +8 -0
  30. package/components/Form/stories/Dropdown.stories.js +24 -6
  31. package/components/Form/stories/FileUploader.stories.js +8 -0
  32. package/components/Form/stories/FormDefault.stories.js +21 -1
  33. package/components/Form/stories/RadioList.stories.js +12 -1
  34. package/components/Form/stories/RangeSlider.stories.js +15 -1
  35. package/components/Form/stories/TextInput.stories.js +19 -3
  36. package/components/Form/stories/Textarea.stories.js +12 -1
  37. package/components/Form/stories/Toggle.stories.js +7 -0
  38. package/components/Form/stories/form.stories.js +40 -3
  39. package/components/InlineModal/InlineModal.js +51 -14
  40. package/components/InlineModal/InlineModal.stories.js +14 -2
  41. package/components/InlineModal/index.js +6 -1
  42. package/components/List/List.js +24 -9
  43. package/components/List/index.js +3 -0
  44. package/components/List/list.stories.js +10 -0
  45. package/components/Modal/Modal.js +49 -17
  46. package/components/Modal/Modal.stories.js +15 -1
  47. package/components/Modal/index.js +3 -0
  48. package/components/NotificationComponent/NotificationComponent.js +34 -11
  49. package/components/NotificationComponent/NotificationComponent.stories.js +6 -0
  50. package/components/NotificationComponent/index.js +3 -0
  51. package/components/ProgressBar/ProgressBar.js +11 -2
  52. package/components/ProgressBar/ProgressBar.stories.js +6 -0
  53. package/components/ProgressBar/index.js +3 -0
  54. package/components/Table/BaseTable.js +134 -69
  55. package/components/Table/PaginationComponent.js +23 -11
  56. package/components/Table/Table.js +149 -68
  57. package/components/Table/Table.stories.js +67 -22
  58. package/components/Table/index.js +4 -0
  59. package/components/TabsComponent/TabsComponent.js +57 -20
  60. package/components/TabsComponent/TabsComponent.stories.js +16 -0
  61. package/components/TabsComponent/index.js +3 -0
  62. package/components/Tooltip/Tooltip.js +47 -25
  63. package/components/Tooltip/Tooltip.stories.js +6 -0
  64. package/components/Tooltip/index.js +3 -0
  65. package/components/core.css +1 -3
  66. package/components/index.js +17 -1
  67. package/components/theme.css +0 -2
  68. package/lib/Readme.md +82 -0
  69. package/lib/components/Accordian/Accordian.js +117 -0
  70. package/lib/components/Accordian/Accordian.stories.js +137 -0
  71. package/lib/components/Accordian/index.js +10 -0
  72. package/lib/components/Button/Button.js +84 -0
  73. package/lib/components/Button/Button.stories.js +89 -0
  74. package/lib/components/Button/DropdownButton.js +77 -0
  75. package/lib/components/Button/DropdownButton.stories.js +51 -0
  76. package/lib/components/Button/index.js +32 -0
  77. package/lib/components/DataLoader/DataLoader.js +88 -0
  78. package/lib/components/DataLoader/DataLoader.stories.js +77 -0
  79. package/lib/components/DataLoader/index.js +10 -0
  80. package/lib/components/Form/Checkbox.js +93 -0
  81. package/lib/components/Form/DragDropFileUploader.js +85 -0
  82. package/lib/components/Form/Dropdown.js +478 -0
  83. package/lib/components/Form/FileUploader.js +81 -0
  84. package/lib/components/Form/Form.js +106 -0
  85. package/lib/components/Form/FormElementWrapper.js +27 -0
  86. package/lib/components/Form/Input.js +140 -0
  87. package/lib/components/Form/RadioList.js +111 -0
  88. package/lib/components/Form/RangeSlider.js +142 -0
  89. package/lib/components/Form/ServerPaginatedDDList.js +267 -0
  90. package/lib/components/Form/Textarea.js +95 -0
  91. package/lib/components/Form/Toggle.js +117 -0
  92. package/lib/components/Form/index.js +73 -0
  93. package/lib/components/Form/stories/Checkbox.stories.js +54 -0
  94. package/lib/components/Form/stories/DragDropFileUploader.stories.js +27 -0
  95. package/lib/components/Form/stories/Dropdown.stories.js +114 -0
  96. package/lib/components/Form/stories/FileUploader.stories.js +31 -0
  97. package/lib/components/Form/stories/FormDefault.stories.js +117 -0
  98. package/lib/components/Form/stories/RadioList.stories.js +55 -0
  99. package/lib/components/Form/stories/RangeSlider.stories.js +82 -0
  100. package/lib/components/Form/stories/TextInput.stories.js +79 -0
  101. package/lib/components/Form/stories/Textarea.stories.js +48 -0
  102. package/lib/components/Form/stories/Toggle.stories.js +25 -0
  103. package/lib/components/Form/stories/form.stories.js +240 -0
  104. package/lib/components/InlineModal/InlineModal.js +146 -0
  105. package/lib/components/InlineModal/InlineModal.stories.js +61 -0
  106. package/lib/components/InlineModal/index.js +24 -0
  107. package/lib/components/List/List.js +76 -0
  108. package/lib/components/List/index.js +10 -0
  109. package/lib/components/List/list.stories.js +38 -0
  110. package/lib/components/Modal/Modal.js +117 -0
  111. package/lib/components/Modal/Modal.stories.js +55 -0
  112. package/lib/components/Modal/index.js +10 -0
  113. package/lib/components/NotificationComponent/NotificationComponent.js +76 -0
  114. package/lib/components/NotificationComponent/NotificationComponent.stories.js +29 -0
  115. package/lib/components/NotificationComponent/index.js +10 -0
  116. package/lib/components/ProgressBar/ProgressBar.js +49 -0
  117. package/lib/components/ProgressBar/ProgressBar.stories.js +21 -0
  118. package/lib/components/ProgressBar/index.js +10 -0
  119. package/lib/components/Table/BaseTable.js +352 -0
  120. package/lib/components/Table/PaginationComponent.js +87 -0
  121. package/lib/components/Table/Table.js +333 -0
  122. package/lib/components/Table/Table.stories.js +204 -0
  123. package/lib/components/Table/index.js +17 -0
  124. package/lib/components/TabsComponent/TabsComponent.js +134 -0
  125. package/lib/components/TabsComponent/TabsComponent.stories.js +65 -0
  126. package/lib/components/TabsComponent/index.js +10 -0
  127. package/lib/components/Tooltip/Tooltip.js +102 -0
  128. package/lib/components/Tooltip/Tooltip.stories.js +25 -0
  129. package/lib/components/Tooltip/index.js +10 -0
  130. package/lib/components/core.css +3 -0
  131. package/lib/components/core.scss +29 -0
  132. package/lib/components/index.js +159 -0
  133. package/lib/components/theme.css +3 -0
  134. package/lib/components/theme.scss +11 -0
  135. package/lib/package-lock.json +20607 -0
  136. package/lib/package.json +94 -0
  137. package/package.json +1 -1
  138. package/src/Intro.stories.mdx +119 -0
  139. package/src/components/Accordian/Accordian.js +89 -0
  140. package/src/components/Accordian/Accordian.stories.js +92 -0
  141. package/src/components/Accordian/accordianCore.css +1 -0
  142. package/src/components/Accordian/accordianCore.scss +8 -0
  143. package/src/components/Accordian/accordianTheme.css +1 -0
  144. package/src/components/Accordian/accordianTheme.scss +6 -0
  145. package/src/components/Accordian/index.js +3 -0
  146. package/src/components/Button/Button.js +67 -0
  147. package/src/components/Button/Button.stories.js +103 -0
  148. package/src/components/Button/DropdownButton.js +60 -0
  149. package/src/components/Button/DropdownButton.stories.js +38 -0
  150. package/src/components/Button/button.css +1 -0
  151. package/src/components/Button/buttonTheme.css +1 -0
  152. package/src/components/Button/buttonTheme.scss +45 -0
  153. package/src/components/Button/index.js +5 -0
  154. package/src/components/DataLoader/DataLoader.js +86 -0
  155. package/src/components/DataLoader/DataLoader.stories.js +72 -0
  156. package/src/components/DataLoader/index.js +3 -0
  157. package/src/components/Form/Checkbox.js +73 -0
  158. package/src/components/Form/DragDropFileUploader.js +67 -0
  159. package/src/components/Form/Dropdown.js +430 -0
  160. package/src/components/Form/FileUploader.js +64 -0
  161. package/src/components/Form/Form.js +83 -0
  162. package/src/components/Form/FormElementWrapper.js +22 -0
  163. package/src/components/Form/Input.js +121 -0
  164. package/src/components/Form/RadioList.js +86 -0
  165. package/src/components/Form/RangeSlider.js +100 -0
  166. package/src/components/Form/ServerPaginatedDDList.js +231 -0
  167. package/src/components/Form/Textarea.js +76 -0
  168. package/src/components/Form/Toggle.js +96 -0
  169. package/src/components/Form/form.css +1 -0
  170. package/src/components/Form/formCore.css +1 -0
  171. package/src/components/Form/formCore.scss +142 -0
  172. package/src/components/Form/formTheme.css +1 -0
  173. package/src/components/Form/formTheme.scss +27 -0
  174. package/src/components/Form/index.js +13 -0
  175. package/src/components/Form/stories/Checkbox.stories.js +41 -0
  176. package/src/components/Form/stories/DragDropFileUploader.stories.js +21 -0
  177. package/src/components/Form/stories/Dropdown.stories.js +124 -0
  178. package/src/components/Form/stories/FileUploader.stories.js +21 -0
  179. package/src/components/Form/stories/FormDefault.stories.js +87 -0
  180. package/src/components/Form/stories/RadioList.stories.js +48 -0
  181. package/src/components/Form/stories/RangeSlider.stories.js +84 -0
  182. package/src/components/Form/stories/TextInput.stories.js +77 -0
  183. package/src/components/Form/stories/Textarea.stories.js +43 -0
  184. package/src/components/Form/stories/Toggle.stories.js +14 -0
  185. package/src/components/Form/stories/form.stories.js +216 -0
  186. package/src/components/InlineModal/InlineModal.js +135 -0
  187. package/src/components/InlineModal/InlineModal.stories.js +54 -0
  188. package/src/components/InlineModal/index.js +4 -0
  189. package/src/components/InlineModal/inlineModal.css +1 -0
  190. package/src/components/InlineModal/inlineModalCore.css +1 -0
  191. package/src/components/InlineModal/inlineModalCore.scss +31 -0
  192. package/src/components/InlineModal/inlineModalTheme.css +1 -0
  193. package/src/components/InlineModal/inlineModalTheme.scss +16 -0
  194. package/src/components/List/List.js +72 -0
  195. package/src/components/List/index.js +3 -0
  196. package/src/components/List/list.css +1 -0
  197. package/src/components/List/list.stories.js +28 -0
  198. package/src/components/List/listCore.css +1 -0
  199. package/src/components/List/listCore.scss +6 -0
  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 +99 -0
  203. package/src/components/Modal/Modal.stories.js +54 -0
  204. package/src/components/Modal/index.js +3 -0
  205. package/src/components/Modal/modal.css +1 -0
  206. package/src/components/Modal/modalCore.css +1 -0
  207. package/src/components/Modal/modalCore.scss +34 -0
  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 +58 -0
  211. package/src/components/NotificationComponent/NotificationComponent.stories.js +28 -0
  212. package/src/components/NotificationComponent/index.js +3 -0
  213. package/src/components/NotificationComponent/notificationComponent.css +1 -0
  214. package/src/components/NotificationComponent/notificationTheme.css +1 -0
  215. package/src/components/NotificationComponent/notificationTheme.scss +30 -0
  216. package/src/components/ProgressBar/ProgressBar.js +45 -0
  217. package/src/components/ProgressBar/ProgressBar.stories.js +14 -0
  218. package/src/components/ProgressBar/index.js +3 -0
  219. package/src/components/ProgressBar/progressBar.css +1 -0
  220. package/src/components/ProgressBar/progressBarCore.css +1 -0
  221. package/src/components/ProgressBar/progressBarCore.scss +14 -0
  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 +306 -0
  225. package/src/components/Table/PaginationComponent.js +73 -0
  226. package/src/components/Table/Table.js +295 -0
  227. package/src/components/Table/Table.stories.js +198 -0
  228. package/src/components/Table/index.js +8 -0
  229. package/src/components/Table/table.css +1 -0
  230. package/src/components/Table/tableCore.css +1 -0
  231. package/src/components/Table/tableCore.scss +94 -0
  232. package/src/components/Table/tableTheme.css +1 -0
  233. package/src/components/Table/tableTheme.scss +34 -0
  234. package/src/components/TabsComponent/TabsComponent.js +99 -0
  235. package/src/components/TabsComponent/TabsComponent.stories.js +69 -0
  236. package/src/components/TabsComponent/index.js +3 -0
  237. package/src/components/TabsComponent/tabs.css +1 -0
  238. package/src/components/TabsComponent/tabsCore.css +1 -0
  239. package/src/components/TabsComponent/tabsCore.scss +59 -0
  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 +87 -0
  243. package/src/components/Tooltip/Tooltip.stories.js +16 -0
  244. package/src/components/Tooltip/index.js +3 -0
  245. package/src/components/Tooltip/tooltipCore.css +1 -0
  246. package/src/components/Tooltip/tooltipCore.scss +22 -0
  247. package/src/components/Tooltip/tooltipTheme.css +1 -0
  248. package/src/components/Tooltip/tooltipTheme.scss +21 -0
  249. package/src/components/core.css +1 -0
  250. package/src/components/core.scss +29 -0
  251. package/src/components/index.js +38 -0
  252. package/src/components/theme.css +1 -0
  253. package/src/components/theme.scss +11 -0
  254. package/src/core/Validators.js +34 -0
  255. package/src/core/customHooks.js +20 -0
  256. package/src/core/dataLoader.js +143 -0
  257. package/src/core/dataLoader.stories.js +123 -0
  258. package/src/core/index.js +3 -0
  259. package/src/core/utils.js +95 -0
  260. package/src/index.js +68 -0
  261. package/vscode-templates/NewStoryTemplate.stories.js +8 -0
  262. /package/{Readme.md → README.md} +0 -0
  263. /package/{components → lib/components}/Accordian/accordianCore.css +0 -0
  264. /package/{components → lib/components}/Accordian/accordianTheme.css +0 -0
  265. /package/{components → lib/components}/Button/buttonTheme.css +0 -0
  266. /package/{components → lib/components}/Form/formCore.css +0 -0
  267. /package/{components → lib/components}/Form/formTheme.css +0 -0
  268. /package/{components → lib/components}/InlineModal/inlineModalCore.css +0 -0
  269. /package/{components → lib/components}/InlineModal/inlineModalTheme.css +0 -0
  270. /package/{components → lib/components}/List/listCore.css +0 -0
  271. /package/{components → lib/components}/List/listTheme.css +0 -0
  272. /package/{components → lib/components}/Modal/modalCore.css +0 -0
  273. /package/{components → lib/components}/Modal/modalTheme.css +0 -0
  274. /package/{components → lib/components}/NotificationComponent/notificationTheme.css +0 -0
  275. /package/{components → lib/components}/ProgressBar/progressBarCore.css +0 -0
  276. /package/{components → lib/components}/ProgressBar/progressBarTheme.css +0 -0
  277. /package/{components → lib/components}/Table/tableCore.css +0 -0
  278. /package/{components → lib/components}/Table/tableTheme.css +0 -0
  279. /package/{components → lib/components}/TabsComponent/tabsCore.css +0 -0
  280. /package/{components → lib/components}/TabsComponent/tabsTheme.css +0 -0
  281. /package/{components → lib/components}/Tooltip/tooltipCore.css +0 -0
  282. /package/{components → lib/components}/Tooltip/tooltipTheme.css +0 -0
  283. /package/{core → lib/core}/Validators.js +0 -0
  284. /package/{core → lib/core}/customHooks.js +0 -0
  285. /package/{core → lib/core}/dataLoader.js +0 -0
  286. /package/{core → lib/core}/dataLoader.stories.js +0 -0
  287. /package/{core → lib/core}/index.js +0 -0
  288. /package/{core → lib/core}/utils.js +0 -0
  289. /package/{index.js → lib/index.js} +0 -0
@@ -0,0 +1,352 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _utils = _interopRequireDefault(require("../../core/utils"));
11
+ var _Checkbox = _interopRequireDefault(require("../Form/Checkbox"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
+ 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); }
14
+ 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; }
15
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
16
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
18
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
19
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
23
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
24
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
25
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
26
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
27
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
28
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
29
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
30
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
31
+ var DEFAULT_CHECKBOX_CONFIG = {
32
+ enabled: false,
33
+ showInHeader: true
34
+ };
35
+ var DefaultNoDataComponent = function DefaultNoDataComponent() {
36
+ return /*#__PURE__*/_react["default"].createElement("div", {
37
+ className: "RCB-no-data"
38
+ }, "No data found");
39
+ };
40
+
41
+ /* eslint-disable react/prop-types */
42
+
43
+ var getTDValue = function getTDValue(_ref) {
44
+ var columnValue = _ref.columnValue,
45
+ _ref$rowData = _ref.rowData,
46
+ rowData = _ref$rowData === void 0 ? {} : _ref$rowData,
47
+ _ref$columnConfig = _ref.columnConfig,
48
+ columnConfig = _ref$columnConfig === void 0 ? {} : _ref$columnConfig,
49
+ _ref$tdProps = _ref.tdProps,
50
+ tdProps = _ref$tdProps === void 0 ? {} : _ref$tdProps;
51
+ var key = columnConfig.key,
52
+ valueFormatter = columnConfig.valueFormatter,
53
+ ColumnComponent = columnConfig.ColumnComponent,
54
+ _columnConfig$compone = columnConfig.componentProps,
55
+ componentProps = _columnConfig$compone === void 0 ? {} : _columnConfig$compone;
56
+ var tdValue = columnValue;
57
+ if (typeof valueFormatter === "function") {
58
+ tdValue = valueFormatter({
59
+ value: columnValue,
60
+ record: rowData
61
+ });
62
+ } else if (ColumnComponent) {
63
+ tdValue = /*#__PURE__*/_react["default"].createElement(ColumnComponent, _extends({
64
+ record: rowData
65
+ }, componentProps));
66
+ }
67
+ return /*#__PURE__*/_react["default"].createElement("td", _extends({
68
+ key: key
69
+ }, tdProps), tdValue);
70
+ };
71
+ var ExpandableTR = function ExpandableTR(props) {
72
+ var rowIndex = props.rowIndex,
73
+ rowData = props.rowData,
74
+ columnConfigs = props.columnConfigs,
75
+ isEven = props.isEven,
76
+ ExpandedRowComponent = props.ExpandedRowComponent,
77
+ showCheckbox = props.showCheckbox,
78
+ checkboxChangeCounter = props.checkboxChangeCounter,
79
+ checkboxValue = props.checkboxValue,
80
+ onSelectionChange = props.onSelectionChange;
81
+ var _useState = (0, _react.useState)(checkboxValue || false),
82
+ _useState2 = _slicedToArray(_useState, 2),
83
+ selected = _useState2[0],
84
+ setSelected = _useState2[1];
85
+ var _useState3 = (0, _react.useState)(false),
86
+ _useState4 = _slicedToArray(_useState3, 2),
87
+ isExpanded = _useState4[0],
88
+ setIsExpanded = _useState4[1];
89
+ var onChange = function onChange(value) {
90
+ setSelected(value);
91
+ onSelectionChange(rowData, value);
92
+ };
93
+ (0, _react.useEffect)(function () {
94
+ setSelected(checkboxValue);
95
+ }, [checkboxChangeCounter, checkboxValue]);
96
+ var toggleExpanded = function toggleExpanded() {
97
+ setIsExpanded(!isExpanded);
98
+ };
99
+ var className = "RCB-tr RCB-parent-row " + (isEven ? "RCB-even-tr" : "RCB-odd-tr");
100
+ return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("tr", {
101
+ className: className
102
+ }, getTDValue({
103
+ columnValue: "",
104
+ columnConfig: {
105
+ key: "expandIcon"
106
+ },
107
+ tdProps: {
108
+ onClick: toggleExpanded,
109
+ className: isExpanded ? "expand-open" : "expand-close"
110
+ }
111
+ }), showCheckbox && /*#__PURE__*/_react["default"].createElement("td", {
112
+ key: "checkbox-colum-".concat(rowIndex)
113
+ }, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
114
+ name: "checkbox".concat(rowIndex),
115
+ type: "checkbox",
116
+ className: "table-checkbox",
117
+ onChange: onChange,
118
+ value: selected
119
+ })), columnConfigs.map(function (configObj) {
120
+ var key = configObj.key;
121
+ return getTDValue({
122
+ columnValue: rowData[key],
123
+ rowData: rowData,
124
+ columnConfig: configObj,
125
+ tdProps: {
126
+ onClick: toggleExpanded
127
+ }
128
+ });
129
+ })), isExpanded && /*#__PURE__*/_react["default"].createElement("tr", {
130
+ className: "RCB-expanded-row"
131
+ }, /*#__PURE__*/_react["default"].createElement("td", {
132
+ colSpan: columnConfigs.length + 1
133
+ }, /*#__PURE__*/_react["default"].createElement(ExpandedRowComponent, {
134
+ parentRecord: rowData
135
+ }))));
136
+ };
137
+ ExpandableTR.propTypes = {
138
+ ExpandedRowComponent: _propTypes["default"].any.isRequired // TODO : check for a React Component
139
+ };
140
+
141
+ var TR = function TR(props) {
142
+ var rowIndex = props.rowIndex,
143
+ rowData = props.rowData,
144
+ columnConfigs = props.columnConfigs,
145
+ isEven = props.isEven,
146
+ showCheckbox = props.showCheckbox,
147
+ checkboxChangeCounter = props.checkboxChangeCounter,
148
+ checkboxValue = props.checkboxValue,
149
+ onSelectionChange = props.onSelectionChange;
150
+ var _useState5 = (0, _react.useState)(checkboxValue || false),
151
+ _useState6 = _slicedToArray(_useState5, 2),
152
+ selected = _useState6[0],
153
+ setSelected = _useState6[1];
154
+ var className = "RCB-tr " + (isEven ? "RCB-even-tr" : "RCB-odd-tr");
155
+ var onChange = function onChange(value) {
156
+ setSelected(value);
157
+ onSelectionChange(rowData, value);
158
+ };
159
+ (0, _react.useEffect)(function () {
160
+ setSelected(checkboxValue);
161
+ }, [checkboxChangeCounter, checkboxValue]);
162
+ return /*#__PURE__*/_react["default"].createElement("tr", {
163
+ className: className
164
+ }, showCheckbox && /*#__PURE__*/_react["default"].createElement("td", {
165
+ key: "checkbox-colum-".concat(rowIndex)
166
+ }, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
167
+ name: "checkbox".concat(rowIndex),
168
+ type: "checkbox",
169
+ className: "table-checkbox",
170
+ onChange: onChange,
171
+ value: selected
172
+ })), columnConfigs.map(function (configObj) {
173
+ var key = configObj.key;
174
+ return getTDValue({
175
+ columnValue: rowData[key],
176
+ rowData: rowData,
177
+ columnConfig: configObj
178
+ });
179
+ }));
180
+ };
181
+ var BaseTable = function BaseTable(props, ref) {
182
+ var className = props.className,
183
+ records = props.records,
184
+ columnConfigs = props.columnConfigs,
185
+ idAttribute = props.idAttribute,
186
+ checkboxConfig = props.checkboxConfig,
187
+ isExpandableTable = props.isExpandableTable,
188
+ ExpandedRowComponent = props.ExpandedRowComponent,
189
+ noDataComponent = props.noDataComponent,
190
+ sortByConfig = props.sortByConfig,
191
+ resetPageNo = props.resetPageNo;
192
+ var _DEFAULT_CHECKBOX_CON = _objectSpread(_objectSpread({}, DEFAULT_CHECKBOX_CONFIG), checkboxConfig || {}),
193
+ showCheckbox = _DEFAULT_CHECKBOX_CON.enabled,
194
+ showInHeader = _DEFAULT_CHECKBOX_CON.showInHeader;
195
+ var sortBy = sortByConfig.sortBy,
196
+ sortOrder = sortByConfig.sortOrder;
197
+ var _useState7 = (0, _react.useState)(false),
198
+ _useState8 = _slicedToArray(_useState7, 2),
199
+ checkboxValue = _useState8[0],
200
+ setCheckboxValue = _useState8[1];
201
+ var _useState9 = (0, _react.useState)(0),
202
+ _useState10 = _slicedToArray(_useState9, 2),
203
+ checkboxChangeCounter = _useState10[0],
204
+ setChangeCounter = _useState10[1];
205
+ var _useState11 = (0, _react.useState)([]),
206
+ _useState12 = _slicedToArray(_useState11, 2),
207
+ selected = _useState12[0],
208
+ setSelected = _useState12[1];
209
+ var RowComponent = isExpandableTable ? ExpandableTR : TR;
210
+ var onSelectionChange = function onSelectionChange(record, checked) {
211
+ if (checked) {
212
+ /* add to selected array */
213
+ setSelected([].concat(_toConsumableArray(selected), [record]));
214
+ } else {
215
+ /* remove from selected array */
216
+ var newSelected = selected.filter(function (obj) {
217
+ return obj[idAttribute] !== record[idAttribute];
218
+ });
219
+ setSelected(newSelected);
220
+ }
221
+ };
222
+ var getSelectedRows = function getSelectedRows() {
223
+ return selected;
224
+ };
225
+ var updateCheckboxValue = function updateCheckboxValue(newValue) {
226
+ setCheckboxValue(newValue);
227
+ setChangeCounter(checkboxChangeCounter + 1);
228
+ };
229
+ var resetSelected = function resetSelected() {
230
+ updateCheckboxValue(false);
231
+ setSelected([]);
232
+ };
233
+ var toggleSelectAll = function toggleSelectAll() {
234
+ var checked = !checkboxValue;
235
+ updateCheckboxValue(checked);
236
+ if (checked) {
237
+ setSelected(records);
238
+ } else {
239
+ setSelected([]);
240
+ }
241
+ };
242
+ (0, _react.useImperativeHandle)(ref, function () {
243
+ return {
244
+ getSelectedRows: getSelectedRows,
245
+ resetSelected: resetSelected,
246
+ resetPageNo: resetPageNo
247
+ };
248
+ });
249
+ if (records.length === 0) {
250
+ return noDataComponent;
251
+ } else {
252
+ return /*#__PURE__*/_react["default"].createElement("table", {
253
+ className: "RCB-table ".concat(className)
254
+ }, /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, isExpandableTable && /*#__PURE__*/_react["default"].createElement("th", {
255
+ key: "expandIcon",
256
+ className: "RCB-th RCB-expand-column"
257
+ }), showCheckbox && (showInHeader ? /*#__PURE__*/_react["default"].createElement("th", {
258
+ key: "headerCheckbox"
259
+ }, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
260
+ name: "headerCheckbox",
261
+ type: "checkbox",
262
+ className: "table-checkbox",
263
+ value: checkboxValue,
264
+ onChange: toggleSelectAll
265
+ })) : /*#__PURE__*/_react["default"].createElement("th", null)), columnConfigs.map(function (columnObj) {
266
+ var key = columnObj.key,
267
+ label = columnObj.label,
268
+ sortable = columnObj.sortable,
269
+ headerClassName = columnObj.headerClassName;
270
+ var className = "RCB-th";
271
+ var thAttrs = {};
272
+ if (sortable) {
273
+ className += " RCB-th-sortable";
274
+ if (sortBy === key) {
275
+ className += " RCB-th-".concat(sortOrder.toLowerCase());
276
+ } else {
277
+ className += " RCB-th-sort";
278
+ }
279
+ thAttrs = {
280
+ onClick: function onClick() {
281
+ props.onSort(columnObj);
282
+ }
283
+ };
284
+ }
285
+ if (headerClassName) {
286
+ className += " ".concat(headerClassName);
287
+ }
288
+ return /*#__PURE__*/_react["default"].createElement("th", _extends({
289
+ className: className,
290
+ key: key
291
+ }, thAttrs), label);
292
+ }))), /*#__PURE__*/_react["default"].createElement("tbody", null, records.map(function (rowData, index) {
293
+ return /*#__PURE__*/_react["default"].createElement(RowComponent, {
294
+ key: rowData[idAttribute],
295
+ isEven: _utils["default"].isEven(index),
296
+ rowIndex: index,
297
+ rowData: rowData,
298
+ columnConfigs: columnConfigs,
299
+ ExpandedRowComponent: ExpandedRowComponent,
300
+ showCheckbox: showCheckbox,
301
+ checkboxValue: checkboxValue,
302
+ checkboxChangeCounter: checkboxChangeCounter,
303
+ onSelectionChange: onSelectionChange
304
+ });
305
+ })));
306
+ }
307
+ };
308
+ BaseTable = /*#__PURE__*/(0, _react.forwardRef)(BaseTable);
309
+
310
+ /* eslint-enable react/prop-types */
311
+
312
+ BaseTable.propTypes = {
313
+ /** Pass any additional classNames to Table component */
314
+ className: _propTypes["default"].string,
315
+ /** Array containing table row data */
316
+ records: function records(props, propName) {
317
+ if (props["paginationType"] == "CLIENT") {
318
+ if (!props[propName]) {
319
+ return new Error("Please provide the table records for paginationType 'CLIENT'!");
320
+ }
321
+ if (Object.prototype.toString.call(props[propName]) !== "[object Array]") {
322
+ return new Error("'records' must be an array");
323
+ }
324
+ }
325
+ },
326
+ /** Array containing the table columns config */
327
+ columnConfigs: _propTypes["default"].array.isRequired,
328
+ /** ID attribute key to use when rendering the dropdown items */
329
+ idAttribute: _propTypes["default"].string,
330
+ /* Config to display checkbox in the first column of the table
331
+ * {
332
+ enabled: false, // turn this on to display checkbox in first column of the table
333
+ showInHeader: true // turn this off to not display the checkbox in the table header
334
+ }
335
+ */
336
+ checkboxConfig: _propTypes["default"].object,
337
+ /** set to "true" if table rows are expandable */
338
+ isExpandableTable: _propTypes["default"].bool,
339
+ /** Component to be rendered on expanding a row */
340
+ ExpandedRowComponent: _propTypes["default"].oneOfType([_propTypes["default"].instanceOf(Element), _propTypes["default"].func]),
341
+ /** Component to be rendered if the table has no data */
342
+ noDataComponent: _propTypes["default"].any
343
+ };
344
+ BaseTable.defaultProps = {
345
+ className: "",
346
+ records: [],
347
+ idAttribute: "id",
348
+ isExpandableTable: false,
349
+ noDataComponent: /*#__PURE__*/_react["default"].createElement(DefaultNoDataComponent, null)
350
+ };
351
+ var _default = BaseTable;
352
+ exports["default"] = _default;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _Dropdown = _interopRequireDefault(require("../Form/Dropdown"));
10
+ var _utils = _interopRequireDefault(require("../../core/utils"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
13
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
18
+ var PaginationComponent = function PaginationComponent(props) {
19
+ var pageSizeList = props.pageSizeList,
20
+ pageConfig = props.pageConfig,
21
+ onPageConfigChanged = props.onPageConfigChanged;
22
+ var perPageCount = pageConfig.perPageCount,
23
+ pageNo = pageConfig.pageNo,
24
+ total = pageConfig.total;
25
+ var SelectionSummary = function SelectionSummary() {
26
+ var pagIndex = _utils["default"].getPagIndex(pageConfig);
27
+ var start = pagIndex.start,
28
+ end = pagIndex.end;
29
+ var startVal = start + 1;
30
+ var endVal = total < end ? total : end;
31
+ var summaryString = "".concat(startVal, "-").concat(endVal);
32
+ return /*#__PURE__*/_react["default"].createElement("div", {
33
+ className: "RCB-select-summary"
34
+ }, summaryString, /*#__PURE__*/_react["default"].createElement("span", {
35
+ className: "RCB-select-arrow"
36
+ }));
37
+ };
38
+ var onPerPageChanged = function onPerPageChanged(perPageObj) {
39
+ var perPage = +perPageObj.id;
40
+ onPageConfigChanged(_objectSpread(_objectSpread({}, pageConfig), {}, {
41
+ pageNo: 1,
42
+ perPageCount: perPage
43
+ }));
44
+ };
45
+ var changePage = function changePage(moveUnit, event) {
46
+ event.preventDefault();
47
+ onPageConfigChanged(_objectSpread(_objectSpread({}, pageConfig), {}, {
48
+ pageNo: pageNo + moveUnit
49
+ }));
50
+ };
51
+ var isLeftNavDisbaled = pageNo <= 1;
52
+ var isRightNavDisbaled = pageNo >= Math.ceil(total / +perPageCount);
53
+ return /*#__PURE__*/_react["default"].createElement("div", {
54
+ className: "RCB-paginate-wrapper"
55
+ }, /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
56
+ name: "perPageCount",
57
+ showLabel: false,
58
+ className: "RCB-per-page-count",
59
+ options: pageSizeList,
60
+ onChange: onPerPageChanged,
61
+ SelectionSummary: SelectionSummary
62
+ }), "of ".concat(total), /*#__PURE__*/_react["default"].createElement("div", {
63
+ className: "RCB-paginate-nav"
64
+ }, /*#__PURE__*/_react["default"].createElement("a", {
65
+ href: "javacsript:void(0)",
66
+ className: "RCB-page-nav ".concat(isLeftNavDisbaled ? "disabled" : ""),
67
+ onClick: function onClick(event) {
68
+ return changePage(-1, event);
69
+ }
70
+ }, "<"), /*#__PURE__*/_react["default"].createElement("a", {
71
+ href: "javacsript:void(0)",
72
+ className: "RCB-page-nav ".concat(isRightNavDisbaled ? "disabled" : ""),
73
+ onClick: function onClick(event) {
74
+ return changePage(1, event);
75
+ }
76
+ }, ">")));
77
+ };
78
+ PaginationComponent.propTypes = {
79
+ pageSizeList: _propTypes["default"].arrayOf(_propTypes["default"].shape({
80
+ id: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
81
+ name: _propTypes["default"].string
82
+ })),
83
+ pageConfig: _propTypes["default"].object,
84
+ onPageConfigChanged: _propTypes["default"].func.isRequired
85
+ };
86
+ var _default = PaginationComponent;
87
+ exports["default"] = _default;