@unbxd-ui/unbxd-react-components 0.2.101-beta.1 → 0.2.101-beta.3

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 (140) hide show
  1. package/components/Form/RangeSlider.js +7 -3
  2. package/components/Tooltip/Tooltip.js +11 -2
  3. package/components/core.css +3 -1
  4. package/components/theme.css +2 -0
  5. package/core/Validators.js +48 -0
  6. package/core/customHooks.js +41 -0
  7. package/core/dataLoader.js +235 -0
  8. package/core/dataLoader.stories.js +153 -0
  9. package/core/index.js +31 -0
  10. package/core/utils.js +112 -0
  11. package/index.js +193 -0
  12. package/package.json +1 -1
  13. package/.babelrc +0 -4
  14. package/.eslintrc.js +0 -38
  15. package/CONTRIBUTE.md +0 -105
  16. package/src/Intro.stories.mdx +0 -119
  17. package/src/components/Accordian/Accordian.js +0 -89
  18. package/src/components/Accordian/Accordian.stories.js +0 -92
  19. package/src/components/Accordian/accordianCore.scss +0 -8
  20. package/src/components/Accordian/accordianTheme.scss +0 -6
  21. package/src/components/Accordian/index.js +0 -3
  22. package/src/components/Button/Button.js +0 -67
  23. package/src/components/Button/Button.stories.js +0 -103
  24. package/src/components/Button/DropdownButton.js +0 -60
  25. package/src/components/Button/DropdownButton.stories.js +0 -38
  26. package/src/components/Button/button.css +0 -1
  27. package/src/components/Button/buttonTheme.scss +0 -45
  28. package/src/components/Button/index.js +0 -5
  29. package/src/components/DataLoader/DataLoader.js +0 -86
  30. package/src/components/DataLoader/DataLoader.stories.js +0 -72
  31. package/src/components/DataLoader/index.js +0 -3
  32. package/src/components/Form/Checkbox.js +0 -73
  33. package/src/components/Form/DragDropFileUploader.js +0 -67
  34. package/src/components/Form/Dropdown.js +0 -415
  35. package/src/components/Form/FileUploader.js +0 -64
  36. package/src/components/Form/Form.js +0 -83
  37. package/src/components/Form/FormElementWrapper.js +0 -22
  38. package/src/components/Form/Input.js +0 -121
  39. package/src/components/Form/RadioList.js +0 -86
  40. package/src/components/Form/RangeSlider.js +0 -100
  41. package/src/components/Form/ServerPaginatedDDList.js +0 -226
  42. package/src/components/Form/Textarea.js +0 -76
  43. package/src/components/Form/Toggle.js +0 -96
  44. package/src/components/Form/form.css +0 -1
  45. package/src/components/Form/formCore.scss +0 -142
  46. package/src/components/Form/formTheme.scss +0 -27
  47. package/src/components/Form/index.js +0 -13
  48. package/src/components/Form/stories/Checkbox.stories.js +0 -41
  49. package/src/components/Form/stories/DragDropFileUploader.stories.js +0 -21
  50. package/src/components/Form/stories/Dropdown.stories.js +0 -124
  51. package/src/components/Form/stories/FileUploader.stories.js +0 -21
  52. package/src/components/Form/stories/FormDefault.stories.js +0 -87
  53. package/src/components/Form/stories/RadioList.stories.js +0 -48
  54. package/src/components/Form/stories/RangeSlider.stories.js +0 -84
  55. package/src/components/Form/stories/TextInput.stories.js +0 -77
  56. package/src/components/Form/stories/Textarea.stories.js +0 -43
  57. package/src/components/Form/stories/Toggle.stories.js +0 -14
  58. package/src/components/Form/stories/form.stories.js +0 -216
  59. package/src/components/InlineModal/InlineModal.js +0 -135
  60. package/src/components/InlineModal/InlineModal.stories.js +0 -54
  61. package/src/components/InlineModal/index.js +0 -4
  62. package/src/components/InlineModal/inlineModal.css +0 -1
  63. package/src/components/InlineModal/inlineModalCore.scss +0 -31
  64. package/src/components/InlineModal/inlineModalTheme.scss +0 -16
  65. package/src/components/List/List.js +0 -72
  66. package/src/components/List/index.js +0 -3
  67. package/src/components/List/list.css +0 -1
  68. package/src/components/List/list.stories.js +0 -28
  69. package/src/components/List/listCore.scss +0 -6
  70. package/src/components/List/listTheme.scss +0 -0
  71. package/src/components/Modal/Modal.js +0 -99
  72. package/src/components/Modal/Modal.stories.js +0 -54
  73. package/src/components/Modal/index.js +0 -3
  74. package/src/components/Modal/modal.css +0 -1
  75. package/src/components/Modal/modalCore.scss +0 -34
  76. package/src/components/Modal/modalTheme.scss +0 -0
  77. package/src/components/NotificationComponent/NotificationComponent.js +0 -58
  78. package/src/components/NotificationComponent/NotificationComponent.stories.js +0 -28
  79. package/src/components/NotificationComponent/index.js +0 -3
  80. package/src/components/NotificationComponent/notificationComponent.css +0 -1
  81. package/src/components/NotificationComponent/notificationTheme.scss +0 -30
  82. package/src/components/ProgressBar/ProgressBar.js +0 -45
  83. package/src/components/ProgressBar/ProgressBar.stories.js +0 -14
  84. package/src/components/ProgressBar/index.js +0 -3
  85. package/src/components/ProgressBar/progressBar.css +0 -1
  86. package/src/components/ProgressBar/progressBarCore.scss +0 -14
  87. package/src/components/ProgressBar/progressBarTheme.scss +0 -0
  88. package/src/components/Table/BaseTable.js +0 -306
  89. package/src/components/Table/PaginationComponent.js +0 -73
  90. package/src/components/Table/Table.js +0 -295
  91. package/src/components/Table/Table.stories.js +0 -198
  92. package/src/components/Table/index.js +0 -8
  93. package/src/components/Table/table.css +0 -1
  94. package/src/components/Table/tableCore.scss +0 -94
  95. package/src/components/Table/tableTheme.scss +0 -34
  96. package/src/components/TabsComponent/TabsComponent.js +0 -99
  97. package/src/components/TabsComponent/TabsComponent.stories.js +0 -69
  98. package/src/components/TabsComponent/index.js +0 -3
  99. package/src/components/TabsComponent/tabs.css +0 -1
  100. package/src/components/TabsComponent/tabsCore.scss +0 -59
  101. package/src/components/TabsComponent/tabsTheme.scss +0 -0
  102. package/src/components/Tooltip/Tooltip.js +0 -87
  103. package/src/components/Tooltip/Tooltip.stories.js +0 -16
  104. package/src/components/Tooltip/index.js +0 -3
  105. package/src/components/Tooltip/tooltipCore.scss +0 -22
  106. package/src/components/Tooltip/tooltipTheme.scss +0 -21
  107. package/src/components/core.css +0 -1
  108. package/src/components/core.scss +0 -29
  109. package/src/components/index.js +0 -38
  110. package/src/components/theme.css +0 -1
  111. package/src/components/theme.scss +0 -11
  112. package/src/core/Validators.js +0 -34
  113. package/src/core/customHooks.js +0 -20
  114. package/src/core/dataLoader.js +0 -143
  115. package/src/core/dataLoader.stories.js +0 -123
  116. package/src/core/index.js +0 -3
  117. package/src/core/utils.js +0 -95
  118. package/src/index.js +0 -68
  119. package/vscode-templates/NewStoryTemplate.stories.js +0 -8
  120. /package/{README.md → Readme.md} +0 -0
  121. /package/{src/components → components}/Accordian/accordianCore.css +0 -0
  122. /package/{src/components → components}/Accordian/accordianTheme.css +0 -0
  123. /package/{src/components → components}/Button/buttonTheme.css +0 -0
  124. /package/{src/components → components}/Form/formCore.css +0 -0
  125. /package/{src/components → components}/Form/formTheme.css +0 -0
  126. /package/{src/components → components}/InlineModal/inlineModalCore.css +0 -0
  127. /package/{src/components → components}/InlineModal/inlineModalTheme.css +0 -0
  128. /package/{src/components → components}/List/listCore.css +0 -0
  129. /package/{src/components → components}/List/listTheme.css +0 -0
  130. /package/{src/components → components}/Modal/modalCore.css +0 -0
  131. /package/{src/components → components}/Modal/modalTheme.css +0 -0
  132. /package/{src/components → components}/NotificationComponent/notificationTheme.css +0 -0
  133. /package/{src/components → components}/ProgressBar/progressBarCore.css +0 -0
  134. /package/{src/components → components}/ProgressBar/progressBarTheme.css +0 -0
  135. /package/{src/components → components}/Table/tableCore.css +0 -0
  136. /package/{src/components → components}/Table/tableTheme.css +0 -0
  137. /package/{src/components → components}/TabsComponent/tabsCore.css +0 -0
  138. /package/{src/components → components}/TabsComponent/tabsTheme.css +0 -0
  139. /package/{src/components → components}/Tooltip/tooltipCore.css +0 -0
  140. /package/{src/components → components}/Tooltip/tooltipTheme.css +0 -0
package/core/utils.js ADDED
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _Validators = _interopRequireDefault(require("./Validators"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+
12
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
13
+
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15
+
16
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+
18
+ var uniqueCounter = 1;
19
+ var utils = {
20
+ configs: {},
21
+ setDefaultConfigs: function setDefaultConfigs(configs) {
22
+ this.configs = _objectSpread(_objectSpread({}, this.configs), configs);
23
+ },
24
+ getDefaultConfigs: function getDefaultConfigs() {
25
+ return this.configs;
26
+ },
27
+ getDefaultConfig: function getDefaultConfig(key) {
28
+ return this.configs ? this.configs[key] : "";
29
+ },
30
+ getQueryParams: function getQueryParams() {
31
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
32
+ var queryParams = [];
33
+ queryParams = Object.keys(params).map(function (key) {
34
+ return "".concat(key, "=").concat(params[key]);
35
+ });
36
+ return queryParams.join("&");
37
+ },
38
+ isEven: function isEven(value) {
39
+ return value % 2 === 0;
40
+ },
41
+ getPagIndex: function getPagIndex(pageConfig) {
42
+ var perPageCount = pageConfig.perPageCount,
43
+ pageNo = pageConfig.pageNo;
44
+ var startIndex = (pageNo - 1) * perPageCount;
45
+ var endIndex = pageNo * perPageCount;
46
+ return {
47
+ start: startIndex,
48
+ end: endIndex
49
+ };
50
+ },
51
+ omit: function omit() {
52
+ var object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
53
+ var omitKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
54
+ var newObject = {};
55
+
56
+ for (var key in object) {
57
+ if (omitKeys.indexOf(key) === -1) {
58
+ newObject[key] = object[key];
59
+ }
60
+ }
61
+
62
+ return newObject;
63
+ },
64
+ getUniqueId: function getUniqueId() {
65
+ return uniqueCounter++;
66
+ },
67
+ isObjectEmpty: function isObjectEmpty(obj) {
68
+ return Object.keys(obj).length ? false : true;
69
+ },
70
+ debounce: function debounce(func, debounceTime) {
71
+ var timeout;
72
+ return function () {
73
+ var context = this,
74
+ args = arguments;
75
+ clearTimeout(timeout);
76
+ timeout = setTimeout(function () {
77
+ timeout = null;
78
+ func.apply(context, args);
79
+ }, debounceTime);
80
+ };
81
+ },
82
+ checkIfValid: function checkIfValid(value, validations) {
83
+ var isValidValue = true;
84
+ var errorMessage;
85
+
86
+ for (var i = 0; i < validations.length; i++) {
87
+ var validationObj = validations[i];
88
+ var type = validationObj.type,
89
+ _validationObj$messag = validationObj.message,
90
+ message = _validationObj$messag === void 0 ? "Invalid field value" : _validationObj$messag;
91
+ isValidValue = _Validators["default"][type](value, validationObj);
92
+
93
+ if (!isValidValue) {
94
+ errorMessage = message;
95
+ break;
96
+ }
97
+ }
98
+
99
+ return {
100
+ isValid: isValidValue,
101
+ error: errorMessage
102
+ };
103
+ },
104
+ isObject: function isObject(value) {
105
+ return Object.prototype.toString.call(value) === "[object Object]";
106
+ },
107
+ isArray: function isArray(value) {
108
+ return Object.prototype.toString.call(value) === "[object Array]";
109
+ }
110
+ };
111
+ var _default = utils;
112
+ exports["default"] = _default;
package/index.js ADDED
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Accordian", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _components.Accordian;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "Button", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _components.Button;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "ButtonAppearance", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _Button.ButtonAppearance;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "ButtonSize", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _Button.ButtonSize;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "Checkbox", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _components.Checkbox;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "DataLoader", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _components.DataLoader;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "DragDropFileUploader", {
43
+ enumerable: true,
44
+ get: function get() {
45
+ return _components.DragDropFileUploader;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "Dropdown", {
49
+ enumerable: true,
50
+ get: function get() {
51
+ return _components.Dropdown;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "DropdownButton", {
55
+ enumerable: true,
56
+ get: function get() {
57
+ return _components.DropdownButton;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "FileUploader", {
61
+ enumerable: true,
62
+ get: function get() {
63
+ return _components.FileUploader;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "Form", {
67
+ enumerable: true,
68
+ get: function get() {
69
+ return _components.Form;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "InlineModal", {
73
+ enumerable: true,
74
+ get: function get() {
75
+ return _components.InlineModal;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "InlineModalActivator", {
79
+ enumerable: true,
80
+ get: function get() {
81
+ return _InlineModal.InlineModalActivator;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "InlineModalBody", {
85
+ enumerable: true,
86
+ get: function get() {
87
+ return _InlineModal.InlineModalBody;
88
+ }
89
+ });
90
+ Object.defineProperty(exports, "Input", {
91
+ enumerable: true,
92
+ get: function get() {
93
+ return _components.Input;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, "List", {
97
+ enumerable: true,
98
+ get: function get() {
99
+ return _components.List;
100
+ }
101
+ });
102
+ Object.defineProperty(exports, "Modal", {
103
+ enumerable: true,
104
+ get: function get() {
105
+ return _components.Modal;
106
+ }
107
+ });
108
+ Object.defineProperty(exports, "NotificationComponent", {
109
+ enumerable: true,
110
+ get: function get() {
111
+ return _components.NotificationComponent;
112
+ }
113
+ });
114
+ Object.defineProperty(exports, "PaginationComponent", {
115
+ enumerable: true,
116
+ get: function get() {
117
+ return _components.PaginationComponent;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, "ProgressBar", {
121
+ enumerable: true,
122
+ get: function get() {
123
+ return _components.ProgressBar;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, "RadioList", {
127
+ enumerable: true,
128
+ get: function get() {
129
+ return _components.RadioList;
130
+ }
131
+ });
132
+ Object.defineProperty(exports, "RangeSlider", {
133
+ enumerable: true,
134
+ get: function get() {
135
+ return _components.RangeSlider;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "Table", {
139
+ enumerable: true,
140
+ get: function get() {
141
+ return _components.Table;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "TabsComponent", {
145
+ enumerable: true,
146
+ get: function get() {
147
+ return _components.TabsComponent;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, "Textarea", {
151
+ enumerable: true,
152
+ get: function get() {
153
+ return _components.Textarea;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "Toggle", {
157
+ enumerable: true,
158
+ get: function get() {
159
+ return _components.Toggle;
160
+ }
161
+ });
162
+ Object.defineProperty(exports, "Tooltip", {
163
+ enumerable: true,
164
+ get: function get() {
165
+ return _components.Tooltip;
166
+ }
167
+ });
168
+ Object.defineProperty(exports, "customHooks", {
169
+ enumerable: true,
170
+ get: function get() {
171
+ return _core.customHooks;
172
+ }
173
+ });
174
+ Object.defineProperty(exports, "dataLoader", {
175
+ enumerable: true,
176
+ get: function get() {
177
+ return _core.dataLoader;
178
+ }
179
+ });
180
+ Object.defineProperty(exports, "utils", {
181
+ enumerable: true,
182
+ get: function get() {
183
+ return _core.utils;
184
+ }
185
+ });
186
+
187
+ var _components = require("./components");
188
+
189
+ var _core = require("./core");
190
+
191
+ var _Button = require("./components/Button");
192
+
193
+ var _InlineModal = require("./components/InlineModal");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbxd-ui/unbxd-react-components",
3
- "version": "0.2.101-beta.1",
3
+ "version": "0.2.101-beta.3",
4
4
  "description": "React components library",
5
5
  "keywords": [
6
6
  "react components",
package/.babelrc DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "presets": ["@babel/preset-env", "@babel/preset-react"],
3
- "plugins": [ "@babel/plugin-proposal-export-default-from", "@babel/plugin-proposal-class-properties"]
4
- }
package/.eslintrc.js DELETED
@@ -1,38 +0,0 @@
1
- module.exports = {
2
- "env": {
3
- "browser": true,
4
- "es6": true,
5
- "amd": true,
6
- "node": true
7
- },
8
- "extends": [
9
- "eslint:recommended",
10
- "plugin:react/recommended"
11
- ],
12
- "globals": {
13
- "Atomics": "readonly",
14
- "SharedArrayBuffer": "readonly"
15
- },
16
- "parser": "babel-eslint",
17
- "parserOptions": {
18
- "ecmaFeatures": {
19
- "jsx": true
20
- },
21
- "ecmaVersion": 2018,
22
- "sourceType": "module"
23
- },
24
- "plugins": [
25
- "react",
26
- "babel"
27
- ],
28
- "rules": {
29
- "react/prop-types": [2, { ignore: ["children"] }],
30
- "no-unsafe-finally": 0,
31
- "no-func-assign": 0
32
- },
33
- "settings": {
34
- "react": {
35
- "version": "detect"
36
- }
37
- }
38
- };
package/CONTRIBUTE.md DELETED
@@ -1,105 +0,0 @@
1
- ## Setting up the project for development
2
-
3
- ### Prerequisites
4
-
5
- Install [npm](https://www.npmjs.com/get-npm)
6
-
7
- ### Setting Up
8
-
9
- Install the npm packages using the following command
10
-
11
- ```
12
- npm install
13
- ```
14
-
15
- Start the JS build with watcher using the following command
16
-
17
- ```
18
- npm run build -- --watch
19
- ```
20
-
21
- To watch SCSS files & compile them to CSS use the following command
22
-
23
- ```
24
- npm run scss -- --watch
25
- ```
26
-
27
- **Note:** Prefix all the CSS classNames with namespace `"RCB-"`
28
-
29
- ### Linting your JS files
30
-
31
- Run the following command to lint the JS code
32
-
33
- ```
34
- npm run lint
35
- ```
36
-
37
- Or Install your editor specific plugin by referring to [this link](https://eslint.org/docs/user-guide/integrations)
38
-
39
- ### Viewing the components
40
-
41
- View the available components along with their accepted props using [storybook](https://storybook.js.org/)
42
-
43
- To start the storybook run the following command
44
-
45
- ```
46
- npm run storybook
47
- ```
48
-
49
- The storybook can then be viewed at http://localhost:6006/
50
-
51
- ### Publishing the storybook to github pages
52
-
53
- Run the following command to publish the storybook to github pages:
54
-
55
- ```
56
- npm run deploy-storybook
57
- ```
58
-
59
- ### Publishing the package to npm
60
-
61
- First login to npm using the following command:
62
-
63
- ```
64
- npm login
65
- ```
66
-
67
- Then run the following command to publish the package to npm:
68
-
69
- ```
70
- npm run publish
71
- ```
72
-
73
- This publishes the package to [unbxd-ui](https://www.npmjs.com/settings/unbxd-ui/packages) org on npm.
74
- To be able to publish to this org you need to get yourself added on the team. Contact Divya or Manu for the same.
75
-
76
-
77
- ### Creating new stories for the components
78
-
79
- To help boostrap a new story file, use the following steps
80
-
81
- 1. Install the VS Code extension [File Templates](https://marketplace.visualstudio.com/items?itemName=brpaz.file-templates)
82
- 2. Place the templates in the location expected by the extension
83
- - In Mac,
84
- ```cp ./vscode-templates/NewStoryTemplate.stories.js $HOME/Library/Application\ Support/Code/User/FileTemplates```
85
-
86
- - In Linux,
87
- ```cp ./vscode-templates/NewStoryTemplate.stories.js $HOME/.config/Code/User/FileTemplates```
88
-
89
- - In Windows,
90
- ```cp ./vscode-templates/NewStoryTemplate.stories.js C:\Users\User\AppData\Roaming\Code\User\FileTemplates```
91
- 3. To use the templates you can do one of the following:
92
- - In VSCode, right click on the folder where you want to generate the new file. You should see an option "Files : New from template". Selecting this option a list of available templates should appear. Just select your template and the file will be created.
93
- - You can also do the same from the Command Palette. In this case the new file will be created in the root directory of the project.
94
- - Its also possible to do the other way around and create a template based on an open file. For that "right-click" on any opened file and you should see the option of the context menu.
95
-
96
- **Note:** The template will expect the Component name as a parameter
97
-
98
- ## FAQs
99
- 1) I am getting error "No PostCSS Config found"
100
-
101
- Create a file called postcss.config.js in `/lib/components/` folder
102
-
103
- ## TODO
104
-
105
- - Minify JS / CSS
@@ -1,119 +0,0 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
2
-
3
- <Meta title="Design System|Introduction" />
4
-
5
- ## Introduction to the RCB (React Components Bundle) library
6
-
7
- RCB contains a bunch of low level components (atoms of a design system) that you can use individually
8
- or combine them to make additional components (molecules of a design system) to build web pages.
9
-
10
- ## Using the components library
11
-
12
- First, install the package from npm
13
-
14
- ```
15
- npm install react-components-bundle
16
- ```
17
-
18
- Next, import the required components. There are 2 ways to achieve this.
19
-
20
- If you want a minimal footprint from the RCB library and include only the components which you use,
21
- then import the components individually as shown below.
22
- This enables tree shaking and therefore components that you did not use will not get included in your final bundle.
23
-
24
- ```
25
- import Button from "react-components-bundle/components/Button";
26
- ```
27
-
28
- If size of the bundle does not matter or you will use all/most of the components in the RCB library,
29
- then you can import the components as shown below:
30
-
31
- ```
32
- import { Button } from "react-components-bundle";
33
- ```
34
-
35
- ### Using core CSS
36
-
37
- Finally, include the core CSS like below,
38
-
39
- ```
40
- import "react-components-bundle/components/core.css";
41
- ```
42
-
43
- The core CSS file will contain the core styles without which the component will not behave as expected.
44
- Hence do not forget to include this.
45
-
46
- ### Using theme CSS
47
-
48
- Theme CSS file will contain the styles which suggests a theme for all the components but is not a must have to use the library.
49
-
50
- You can use the theme CSS in 2 ways:
51
-
52
- **1. Use individual component CSS**
53
-
54
- You can import the individual files for each of the components like below:
55
-
56
- ```
57
- import "react-components-bundle/components/Table/tableTheme.css";
58
- ```
59
-
60
- **2. Include the bundled CSS file which has all component's CSS**
61
-
62
- You can import the bundled CSS file which contains all the component's CSS like below:
63
-
64
- ```
65
- import "react-components-bundle/components/theme.css";
66
- ```
67
-
68
- ## Library structure
69
-
70
- ```
71
- react-components-bundle
72
-
73
-
74
- └─── components
75
- │ │
76
- │ └─── Button
77
- │ │
78
- │ └─── DataLoader
79
- │ │
80
- │ └─── Form
81
- │ │ │
82
- │ │ └─── Input
83
- │ │ │
84
- │ │ └─── Checkbox
85
- │ │ │
86
- │ │ └─── DragDropFileUploader
87
- │ │ │
88
- │ │ └─── Dropdown
89
- │ │ │
90
- │ │ └─── FileUploader
91
- │ │ │
92
- │ │ └─── RadioList
93
- │ │ │
94
- │ │ └─── RangeSlider
95
- │ │ │
96
- │ │ └─── TextArea
97
- │ │ │
98
- │ │ └─── Toggle
99
- │ │
100
- │ └─── InlineModal
101
- │ │
102
- │ └─── List
103
- │ │
104
- │ └─── Modal
105
- │ │
106
- │ └─── NotificationComponent
107
- │ │
108
- │ └─── ProgressBar
109
- │ │
110
- │ └─── Table
111
- │ │
112
- │ └─── TabsComponent
113
-
114
- └─── core
115
-
116
- └─── dataLoader
117
-
118
- └─── utils
119
- ```
@@ -1,89 +0,0 @@
1
- import React, { useState, cloneElement } from "react";
2
- import PropTypes from "prop-types";
3
- import List from "../List";
4
-
5
- const ALL = "ALL";
6
-
7
- const getDefaultOpenedItems = (items = [], defaultOpen) =>{
8
- let arr = [];
9
- if(items.length > 0) {
10
- items.forEach((item) => {
11
- const {
12
- id
13
- } = item;
14
- if(id === defaultOpen || defaultOpen === ALL ) {
15
- arr.push(id)
16
- }
17
- })
18
- }
19
- return arr;
20
- }
21
-
22
- const AccordianItem = (props) => {
23
- const {
24
- itemData,
25
- allowOneOpen,
26
- openedItems,
27
- setOpenedItems
28
- } = props;
29
- const { titleComponent, bodyComponent, id } = itemData;
30
- const isOpen = openedItems.find(item => item === id) ? true: false;
31
- const onItemClick = () => {
32
- let newList = [id];
33
- if(!allowOneOpen) {
34
- newList = isOpen ? openedItems.filter(item => item !== id) : [...openedItems, id]
35
- }
36
- setOpenedItems(newList)
37
- }
38
- return <li className={`RCB-accordian-item ${isOpen ? "RCB-accordian-open" : "RCB-accordian-close"}`}>
39
- <div className="RCB-accordian-title" onClick={onItemClick}>{cloneElement(titleComponent, { isOpen: isOpen })}</div>
40
- {isOpen && <div className="RCB-accordian-body">{bodyComponent}</div>}
41
- </li>
42
- };
43
-
44
- AccordianItem.propTypes = {
45
- itemData: PropTypes.shape({
46
- id: PropTypes.string.isRequired,
47
- titleComponent: PropTypes.element.isRequired,
48
- bodyComponent: PropTypes.element.isRequired,
49
- }),
50
- setOpenedItems: PropTypes.func,
51
- openedItems: PropTypes.array,
52
- allowOneOpen: PropTypes.bool
53
- };
54
-
55
-
56
- const Accordian = ({defaultOpen, items, allowOneOpen}) => {
57
- const defaultOpened = getDefaultOpenedItems(items, defaultOpen);
58
- const [openedItems, setOpenedItems] = useState(defaultOpened);
59
- return (<div className={`RCB-accordian`}>
60
- {
61
- <List
62
- items={items}
63
- openedItems={openedItems}
64
- defaultOpen={defaultOpen}
65
- allowOneOpen={allowOneOpen}
66
- setOpenedItems={setOpenedItems}
67
- ListItem={AccordianItem} />
68
- }
69
- </div>);
70
- };
71
-
72
- Accordian.propTypes = {
73
- defaultOpen: PropTypes.string,
74
- items: PropTypes.arrayOf(PropTypes.shape({
75
- id: PropTypes.string.isRequired,
76
- titleComponent: PropTypes.element.isRequired,
77
- bodyComponent: PropTypes.element.isRequired,
78
- })).isRequired,
79
- // /* set to false if you want more than one accordian item to be open at a time */
80
- allowOneOpen: PropTypes.bool
81
- };
82
-
83
- Accordian.defaultProps = {
84
- allowOneOpen: false,
85
- defaultOpen:"",//"ALL","ID","",
86
- items:[]
87
- };
88
-
89
- export default Accordian;