@unbxd-ui/unbxd-react-components 0.2.104 → 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.
- package/.babelrc +4 -0
- package/.eslintrc.js +38 -0
- package/CONTRIBUTE.md +105 -0
- package/components/Accordian/Accordian.js +45 -13
- package/components/Accordian/Accordian.stories.js +25 -6
- package/components/Accordian/index.js +3 -0
- package/components/Button/Button.js +26 -9
- package/components/Button/Button.stories.js +14 -1
- package/components/Button/DropdownButton.js +31 -9
- package/components/Button/DropdownButton.stories.js +23 -6
- package/components/Button/index.js +8 -1
- package/components/DataLoader/DataLoader.js +40 -10
- package/components/DataLoader/DataLoader.stories.js +30 -5
- package/components/DataLoader/index.js +3 -0
- package/components/Form/Checkbox.js +42 -14
- package/components/Form/DragDropFileUploader.js +42 -12
- package/components/Form/Dropdown.js +181 -104
- package/components/Form/FileUploader.js +32 -10
- package/components/Form/Form.js +45 -15
- package/components/Form/FormElementWrapper.js +7 -2
- package/components/Form/Input.js +72 -27
- package/components/Form/RadioList.js +48 -17
- package/components/Form/RangeSlider.js +73 -37
- package/components/Form/ServerPaginatedDDList.js +130 -87
- package/components/Form/Textarea.js +43 -18
- package/components/Form/Toggle.js +48 -16
- package/components/Form/index.js +30 -18
- package/components/Form/stories/Checkbox.stories.js +12 -1
- package/components/Form/stories/DragDropFileUploader.stories.js +8 -0
- package/components/Form/stories/Dropdown.stories.js +24 -6
- package/components/Form/stories/FileUploader.stories.js +8 -0
- package/components/Form/stories/FormDefault.stories.js +21 -1
- package/components/Form/stories/RadioList.stories.js +12 -1
- package/components/Form/stories/RangeSlider.stories.js +15 -1
- package/components/Form/stories/TextInput.stories.js +19 -3
- package/components/Form/stories/Textarea.stories.js +12 -1
- package/components/Form/stories/Toggle.stories.js +7 -0
- package/components/Form/stories/form.stories.js +40 -3
- package/components/InlineModal/InlineModal.js +51 -14
- package/components/InlineModal/InlineModal.stories.js +14 -2
- package/components/InlineModal/index.js +6 -1
- package/components/List/List.js +24 -9
- package/components/List/index.js +3 -0
- package/components/List/list.stories.js +10 -0
- package/components/Modal/Modal.js +49 -17
- package/components/Modal/Modal.stories.js +15 -1
- package/components/Modal/index.js +3 -0
- package/components/NotificationComponent/NotificationComponent.js +34 -11
- package/components/NotificationComponent/NotificationComponent.stories.js +6 -0
- package/components/NotificationComponent/index.js +3 -0
- package/components/ProgressBar/ProgressBar.js +11 -2
- package/components/ProgressBar/ProgressBar.stories.js +6 -0
- package/components/ProgressBar/index.js +3 -0
- package/components/Table/BaseTable.js +134 -69
- package/components/Table/PaginationComponent.js +23 -11
- package/components/Table/Table.js +149 -68
- package/components/Table/Table.stories.js +67 -22
- package/components/Table/index.js +4 -0
- package/components/TabsComponent/TabsComponent.js +57 -20
- package/components/TabsComponent/TabsComponent.stories.js +16 -0
- package/components/TabsComponent/index.js +3 -0
- package/components/Tooltip/Tooltip.js +47 -25
- package/components/Tooltip/Tooltip.stories.js +6 -0
- package/components/Tooltip/index.js +3 -0
- package/components/core.css +1 -3
- package/components/index.js +17 -1
- package/components/theme.css +0 -2
- package/lib/Readme.md +82 -0
- package/lib/components/Accordian/Accordian.js +117 -0
- package/lib/components/Accordian/Accordian.stories.js +137 -0
- package/lib/components/Accordian/index.js +10 -0
- package/lib/components/Button/Button.js +84 -0
- package/lib/components/Button/Button.stories.js +89 -0
- package/lib/components/Button/DropdownButton.js +77 -0
- package/lib/components/Button/DropdownButton.stories.js +51 -0
- package/lib/components/Button/index.js +32 -0
- package/lib/components/DataLoader/DataLoader.js +88 -0
- package/lib/components/DataLoader/DataLoader.stories.js +77 -0
- package/lib/components/DataLoader/index.js +10 -0
- package/lib/components/Form/Checkbox.js +93 -0
- package/lib/components/Form/DragDropFileUploader.js +85 -0
- package/lib/components/Form/Dropdown.js +478 -0
- package/lib/components/Form/FileUploader.js +81 -0
- package/lib/components/Form/Form.js +106 -0
- package/lib/components/Form/FormElementWrapper.js +27 -0
- package/lib/components/Form/Input.js +140 -0
- package/lib/components/Form/RadioList.js +111 -0
- package/lib/components/Form/RangeSlider.js +142 -0
- package/lib/components/Form/ServerPaginatedDDList.js +267 -0
- package/lib/components/Form/Textarea.js +95 -0
- package/lib/components/Form/Toggle.js +117 -0
- package/lib/components/Form/index.js +73 -0
- package/lib/components/Form/stories/Checkbox.stories.js +54 -0
- package/lib/components/Form/stories/DragDropFileUploader.stories.js +27 -0
- package/lib/components/Form/stories/Dropdown.stories.js +114 -0
- package/lib/components/Form/stories/FileUploader.stories.js +31 -0
- package/lib/components/Form/stories/FormDefault.stories.js +117 -0
- package/lib/components/Form/stories/RadioList.stories.js +55 -0
- package/lib/components/Form/stories/RangeSlider.stories.js +82 -0
- package/lib/components/Form/stories/TextInput.stories.js +79 -0
- package/lib/components/Form/stories/Textarea.stories.js +48 -0
- package/lib/components/Form/stories/Toggle.stories.js +25 -0
- package/lib/components/Form/stories/form.stories.js +240 -0
- package/lib/components/InlineModal/InlineModal.js +146 -0
- package/lib/components/InlineModal/InlineModal.stories.js +61 -0
- package/lib/components/InlineModal/index.js +24 -0
- package/lib/components/List/List.js +76 -0
- package/lib/components/List/index.js +10 -0
- package/lib/components/List/list.stories.js +38 -0
- package/lib/components/Modal/Modal.js +117 -0
- package/lib/components/Modal/Modal.stories.js +55 -0
- package/lib/components/Modal/index.js +10 -0
- package/lib/components/NotificationComponent/NotificationComponent.js +76 -0
- package/lib/components/NotificationComponent/NotificationComponent.stories.js +29 -0
- package/lib/components/NotificationComponent/index.js +10 -0
- package/lib/components/ProgressBar/ProgressBar.js +49 -0
- package/lib/components/ProgressBar/ProgressBar.stories.js +21 -0
- package/lib/components/ProgressBar/index.js +10 -0
- package/lib/components/Table/BaseTable.js +352 -0
- package/lib/components/Table/PaginationComponent.js +87 -0
- package/lib/components/Table/Table.js +333 -0
- package/lib/components/Table/Table.stories.js +204 -0
- package/lib/components/Table/index.js +17 -0
- package/lib/components/TabsComponent/TabsComponent.js +134 -0
- package/lib/components/TabsComponent/TabsComponent.stories.js +65 -0
- package/lib/components/TabsComponent/index.js +10 -0
- package/lib/components/Tooltip/Tooltip.js +102 -0
- package/lib/components/Tooltip/Tooltip.stories.js +25 -0
- package/lib/components/Tooltip/index.js +10 -0
- package/lib/components/core.css +3 -0
- package/lib/components/core.scss +29 -0
- package/lib/components/index.js +159 -0
- package/lib/components/theme.css +3 -0
- package/lib/components/theme.scss +11 -0
- package/lib/package-lock.json +20607 -0
- package/lib/package.json +94 -0
- package/package.json +1 -1
- package/src/Intro.stories.mdx +119 -0
- package/src/components/Accordian/Accordian.js +89 -0
- package/src/components/Accordian/Accordian.stories.js +92 -0
- package/src/components/Accordian/accordianCore.css +1 -0
- package/src/components/Accordian/accordianCore.scss +8 -0
- package/src/components/Accordian/accordianTheme.css +1 -0
- package/src/components/Accordian/accordianTheme.scss +6 -0
- package/src/components/Accordian/index.js +3 -0
- package/src/components/Button/Button.js +67 -0
- package/src/components/Button/Button.stories.js +103 -0
- package/src/components/Button/DropdownButton.js +60 -0
- package/src/components/Button/DropdownButton.stories.js +38 -0
- package/src/components/Button/button.css +1 -0
- package/src/components/Button/buttonTheme.css +1 -0
- package/src/components/Button/buttonTheme.scss +45 -0
- package/src/components/Button/index.js +5 -0
- package/src/components/DataLoader/DataLoader.js +86 -0
- package/src/components/DataLoader/DataLoader.stories.js +72 -0
- package/src/components/DataLoader/index.js +3 -0
- package/src/components/Form/Checkbox.js +73 -0
- package/src/components/Form/DragDropFileUploader.js +67 -0
- package/src/components/Form/Dropdown.js +430 -0
- package/src/components/Form/FileUploader.js +64 -0
- package/src/components/Form/Form.js +83 -0
- package/src/components/Form/FormElementWrapper.js +22 -0
- package/src/components/Form/Input.js +121 -0
- package/src/components/Form/RadioList.js +86 -0
- package/src/components/Form/RangeSlider.js +100 -0
- package/src/components/Form/ServerPaginatedDDList.js +231 -0
- package/src/components/Form/Textarea.js +76 -0
- package/src/components/Form/Toggle.js +96 -0
- package/src/components/Form/form.css +1 -0
- package/src/components/Form/formCore.css +1 -0
- package/src/components/Form/formCore.scss +142 -0
- package/src/components/Form/formTheme.css +1 -0
- package/src/components/Form/formTheme.scss +27 -0
- package/src/components/Form/index.js +13 -0
- package/src/components/Form/stories/Checkbox.stories.js +41 -0
- package/src/components/Form/stories/DragDropFileUploader.stories.js +21 -0
- package/src/components/Form/stories/Dropdown.stories.js +124 -0
- package/src/components/Form/stories/FileUploader.stories.js +21 -0
- package/src/components/Form/stories/FormDefault.stories.js +87 -0
- package/src/components/Form/stories/RadioList.stories.js +48 -0
- package/src/components/Form/stories/RangeSlider.stories.js +84 -0
- package/src/components/Form/stories/TextInput.stories.js +77 -0
- package/src/components/Form/stories/Textarea.stories.js +43 -0
- package/src/components/Form/stories/Toggle.stories.js +14 -0
- package/src/components/Form/stories/form.stories.js +216 -0
- package/src/components/InlineModal/InlineModal.js +135 -0
- package/src/components/InlineModal/InlineModal.stories.js +54 -0
- package/src/components/InlineModal/index.js +4 -0
- package/src/components/InlineModal/inlineModal.css +1 -0
- package/src/components/InlineModal/inlineModalCore.css +1 -0
- package/src/components/InlineModal/inlineModalCore.scss +31 -0
- package/src/components/InlineModal/inlineModalTheme.css +1 -0
- package/src/components/InlineModal/inlineModalTheme.scss +16 -0
- package/src/components/List/List.js +72 -0
- package/src/components/List/index.js +3 -0
- package/src/components/List/list.css +1 -0
- package/src/components/List/list.stories.js +28 -0
- package/src/components/List/listCore.css +1 -0
- package/src/components/List/listCore.scss +6 -0
- package/src/components/List/listTheme.css +0 -0
- package/src/components/List/listTheme.scss +0 -0
- package/src/components/Modal/Modal.js +99 -0
- package/src/components/Modal/Modal.stories.js +54 -0
- package/src/components/Modal/index.js +3 -0
- package/src/components/Modal/modal.css +1 -0
- package/src/components/Modal/modalCore.css +1 -0
- package/src/components/Modal/modalCore.scss +34 -0
- package/src/components/Modal/modalTheme.css +0 -0
- package/src/components/Modal/modalTheme.scss +0 -0
- package/src/components/NotificationComponent/NotificationComponent.js +58 -0
- package/src/components/NotificationComponent/NotificationComponent.stories.js +28 -0
- package/src/components/NotificationComponent/index.js +3 -0
- package/src/components/NotificationComponent/notificationComponent.css +1 -0
- package/src/components/NotificationComponent/notificationTheme.css +1 -0
- package/src/components/NotificationComponent/notificationTheme.scss +30 -0
- package/src/components/ProgressBar/ProgressBar.js +45 -0
- package/src/components/ProgressBar/ProgressBar.stories.js +14 -0
- package/src/components/ProgressBar/index.js +3 -0
- package/src/components/ProgressBar/progressBar.css +1 -0
- package/src/components/ProgressBar/progressBarCore.css +1 -0
- package/src/components/ProgressBar/progressBarCore.scss +14 -0
- package/src/components/ProgressBar/progressBarTheme.css +0 -0
- package/src/components/ProgressBar/progressBarTheme.scss +0 -0
- package/src/components/Table/BaseTable.js +306 -0
- package/src/components/Table/PaginationComponent.js +73 -0
- package/src/components/Table/Table.js +295 -0
- package/src/components/Table/Table.stories.js +198 -0
- package/src/components/Table/index.js +8 -0
- package/src/components/Table/table.css +1 -0
- package/src/components/Table/tableCore.css +1 -0
- package/src/components/Table/tableCore.scss +94 -0
- package/src/components/Table/tableTheme.css +1 -0
- package/src/components/Table/tableTheme.scss +34 -0
- package/src/components/TabsComponent/TabsComponent.js +99 -0
- package/src/components/TabsComponent/TabsComponent.stories.js +69 -0
- package/src/components/TabsComponent/index.js +3 -0
- package/src/components/TabsComponent/tabs.css +1 -0
- package/src/components/TabsComponent/tabsCore.css +1 -0
- package/src/components/TabsComponent/tabsCore.scss +59 -0
- package/src/components/TabsComponent/tabsTheme.css +0 -0
- package/src/components/TabsComponent/tabsTheme.scss +0 -0
- package/src/components/Tooltip/Tooltip.js +87 -0
- package/src/components/Tooltip/Tooltip.stories.js +16 -0
- package/src/components/Tooltip/index.js +3 -0
- package/src/components/Tooltip/tooltipCore.css +1 -0
- package/src/components/Tooltip/tooltipCore.scss +22 -0
- package/src/components/Tooltip/tooltipTheme.css +1 -0
- package/src/components/Tooltip/tooltipTheme.scss +21 -0
- package/src/components/core.css +1 -0
- package/src/components/core.scss +29 -0
- package/src/components/index.js +38 -0
- package/src/components/theme.css +1 -0
- package/src/components/theme.scss +11 -0
- package/src/core/Validators.js +34 -0
- package/src/core/customHooks.js +20 -0
- package/src/core/dataLoader.js +143 -0
- package/src/core/dataLoader.stories.js +123 -0
- package/src/core/index.js +3 -0
- package/src/core/utils.js +95 -0
- package/src/index.js +68 -0
- package/vscode-templates/NewStoryTemplate.stories.js +8 -0
- /package/{Readme.md → README.md} +0 -0
- /package/{components → lib/components}/Accordian/accordianCore.css +0 -0
- /package/{components → lib/components}/Accordian/accordianTheme.css +0 -0
- /package/{components → lib/components}/Button/buttonTheme.css +0 -0
- /package/{components → lib/components}/Form/formCore.css +0 -0
- /package/{components → lib/components}/Form/formTheme.css +0 -0
- /package/{components → lib/components}/InlineModal/inlineModalCore.css +0 -0
- /package/{components → lib/components}/InlineModal/inlineModalTheme.css +0 -0
- /package/{components → lib/components}/List/listCore.css +0 -0
- /package/{components → lib/components}/List/listTheme.css +0 -0
- /package/{components → lib/components}/Modal/modalCore.css +0 -0
- /package/{components → lib/components}/Modal/modalTheme.css +0 -0
- /package/{components → lib/components}/NotificationComponent/notificationTheme.css +0 -0
- /package/{components → lib/components}/ProgressBar/progressBarCore.css +0 -0
- /package/{components → lib/components}/ProgressBar/progressBarTheme.css +0 -0
- /package/{components → lib/components}/Table/tableCore.css +0 -0
- /package/{components → lib/components}/Table/tableTheme.css +0 -0
- /package/{components → lib/components}/TabsComponent/tabsCore.css +0 -0
- /package/{components → lib/components}/TabsComponent/tabsTheme.css +0 -0
- /package/{components → lib/components}/Tooltip/tooltipCore.css +0 -0
- /package/{components → lib/components}/Tooltip/tooltipTheme.css +0 -0
- /package/{core → lib/core}/Validators.js +0 -0
- /package/{core → lib/core}/customHooks.js +0 -0
- /package/{core → lib/core}/dataLoader.js +0 -0
- /package/{core → lib/core}/dataLoader.stories.js +0 -0
- /package/{core → lib/core}/index.js +0 -0
- /package/{core → lib/core}/utils.js +0 -0
- /package/{index.js → lib/index.js} +0 -0
package/components/Form/Form.js
CHANGED
|
@@ -1,73 +1,99 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = exports.FormContext = void 0;
|
|
9
|
+
|
|
8
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
9
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
10
14
|
var _dequal = _interopRequireDefault(require("dequal"));
|
|
15
|
+
|
|
11
16
|
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
|
17
|
+
|
|
12
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
13
20
|
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); }
|
|
21
|
+
|
|
14
22
|
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; }
|
|
23
|
+
|
|
15
24
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
25
|
+
|
|
16
26
|
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."); }
|
|
27
|
+
|
|
17
28
|
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); }
|
|
18
|
-
|
|
19
|
-
function
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
33
|
+
|
|
20
34
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
35
|
+
|
|
21
36
|
var FormContext = /*#__PURE__*/(0, _react.createContext)({
|
|
22
37
|
onValueChange: function onValueChange() {}
|
|
23
38
|
});
|
|
24
39
|
exports.FormContext = FormContext;
|
|
40
|
+
|
|
25
41
|
var Form = function Form(props, ref) {
|
|
26
42
|
var _useState = (0, _react.useState)({}),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
43
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
44
|
+
formData = _useState2[0],
|
|
45
|
+
setFormData = _useState2[1];
|
|
46
|
+
|
|
30
47
|
var _useState3 = (0, _react.useState)({}),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
49
|
+
formErrors = _useState4[0],
|
|
50
|
+
setFormErrors = _useState4[1];
|
|
51
|
+
|
|
34
52
|
var _useState5 = (0, _react.useState)(0),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
54
|
+
formRefreshCount = _useState6[0],
|
|
55
|
+
setFormRefreshCount = _useState6[1];
|
|
56
|
+
|
|
38
57
|
var className = props.className,
|
|
39
|
-
|
|
40
|
-
|
|
58
|
+
onChange = props.onChange,
|
|
59
|
+
onSubmit = props.onSubmit;
|
|
41
60
|
var dataRef = (0, _react.useRef)();
|
|
61
|
+
|
|
42
62
|
var getFormData = function getFormData() {
|
|
43
63
|
return {
|
|
44
64
|
data: formData,
|
|
45
65
|
errors: formErrors
|
|
46
66
|
};
|
|
47
67
|
};
|
|
48
|
-
|
|
49
68
|
/* add methods that can be accessed via this component's ref */
|
|
69
|
+
|
|
70
|
+
|
|
50
71
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
51
72
|
return {
|
|
52
73
|
getFormData: getFormData
|
|
53
74
|
};
|
|
54
75
|
});
|
|
76
|
+
|
|
55
77
|
var onValueChange = function onValueChange(key, value, error) {
|
|
56
78
|
formData[key] = value;
|
|
57
79
|
setFormData(formData);
|
|
80
|
+
|
|
58
81
|
if (error) {
|
|
59
82
|
formErrors[key] = error;
|
|
60
83
|
} else {
|
|
61
84
|
/* remove the error value */
|
|
62
85
|
delete formErrors[key];
|
|
63
86
|
}
|
|
87
|
+
|
|
64
88
|
setFormErrors(formErrors);
|
|
65
89
|
setFormRefreshCount(formRefreshCount + 1);
|
|
66
90
|
};
|
|
91
|
+
|
|
67
92
|
var onFormSubmit = function onFormSubmit(event) {
|
|
68
93
|
event.preventDefault();
|
|
69
94
|
onSubmit(getFormData());
|
|
70
95
|
};
|
|
96
|
+
|
|
71
97
|
(0, _react.useEffect)(function () {
|
|
72
98
|
/*
|
|
73
99
|
As useEffect does not do a deep comparision on dependent props,
|
|
@@ -75,6 +101,7 @@ var Form = function Form(props, ref) {
|
|
|
75
101
|
*/
|
|
76
102
|
if (typeof onChange === "function") {
|
|
77
103
|
var _formData = getFormData();
|
|
104
|
+
|
|
78
105
|
if (!(0, _dequal["default"])(_formData, dataRef.current)) {
|
|
79
106
|
dataRef.current = (0, _lodash["default"])(_formData);
|
|
80
107
|
onChange(_formData);
|
|
@@ -90,12 +117,15 @@ var Form = function Form(props, ref) {
|
|
|
90
117
|
}
|
|
91
118
|
}, props.children));
|
|
92
119
|
};
|
|
120
|
+
|
|
93
121
|
Form = /*#__PURE__*/(0, _react.forwardRef)(Form);
|
|
94
122
|
Form.propTypes = {
|
|
95
123
|
/** Pass any additional classNames to Form component */
|
|
96
124
|
className: _propTypes["default"].string,
|
|
125
|
+
|
|
97
126
|
/** Pass a callback function to listen to changes on any of the form elements */
|
|
98
127
|
onChange: _propTypes["default"].func,
|
|
128
|
+
|
|
99
129
|
/** Pass a callback function to listen to form submit event */
|
|
100
130
|
onSubmit: _propTypes["default"].func
|
|
101
131
|
};
|
|
@@ -4,17 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
+
|
|
7
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
8
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
9
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
|
|
10
14
|
var FormElementWrapper = function FormElementWrapper(props) {
|
|
11
15
|
var className = props.className,
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
children = props.children,
|
|
17
|
+
appearance = props.appearance;
|
|
14
18
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
15
19
|
className: "RCB-form-el-cont RCB-form-el-".concat(appearance, " ").concat(className)
|
|
16
20
|
}, children);
|
|
17
21
|
};
|
|
22
|
+
|
|
18
23
|
FormElementWrapper.propTypes = {
|
|
19
24
|
/** Pass any additional classNames to Form component */
|
|
20
25
|
className: _propTypes["default"].string,
|
package/components/Form/Input.js
CHANGED
|
@@ -1,78 +1,111 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
9
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
10
14
|
var _Form = require("./Form");
|
|
15
|
+
|
|
11
16
|
var _FormElementWrapper = _interopRequireDefault(require("./FormElementWrapper"));
|
|
17
|
+
|
|
12
18
|
var _Validators = _interopRequireDefault(require("../../core/Validators"));
|
|
19
|
+
|
|
13
20
|
var _utils = _interopRequireDefault(require("../../core/utils"));
|
|
21
|
+
|
|
14
22
|
var _excluded = ["label", "name", "type", "className", "value", "defaultValue", "placeholder", "appearance", "onChange", "validations", "autoComplete", "showLabel"];
|
|
23
|
+
|
|
15
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
+
|
|
16
26
|
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); }
|
|
27
|
+
|
|
17
28
|
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; }
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
function
|
|
22
|
-
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
23
36
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
37
|
+
|
|
24
38
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
39
|
+
|
|
25
40
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
41
|
+
|
|
26
42
|
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."); }
|
|
43
|
+
|
|
27
44
|
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); }
|
|
28
|
-
|
|
29
|
-
function
|
|
45
|
+
|
|
46
|
+
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; }
|
|
47
|
+
|
|
48
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
49
|
+
|
|
30
50
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
51
|
+
|
|
31
52
|
var Input = function Input(props, ref) {
|
|
32
53
|
var _useState = (0, _react.useState)(),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
55
|
+
error = _useState2[0],
|
|
56
|
+
setError = _useState2[1];
|
|
57
|
+
|
|
36
58
|
var label = props.label,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
name = props.name,
|
|
60
|
+
type = props.type,
|
|
61
|
+
className = props.className,
|
|
62
|
+
value = props.value,
|
|
63
|
+
defaultValue = props.defaultValue,
|
|
64
|
+
placeholder = props.placeholder,
|
|
65
|
+
appearance = props.appearance,
|
|
66
|
+
onChange = props.onChange,
|
|
67
|
+
validations = props.validations,
|
|
68
|
+
autoComplete = props.autoComplete,
|
|
69
|
+
showLabel = props.showLabel,
|
|
70
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
71
|
+
|
|
49
72
|
var _useContext = (0, _react.useContext)(_Form.FormContext),
|
|
50
|
-
|
|
73
|
+
onValueChange = _useContext.onValueChange;
|
|
74
|
+
|
|
51
75
|
var postFormValueChange = function postFormValueChange(value, error) {
|
|
52
76
|
typeof onValueChange === "function" && onValueChange(name, value, error);
|
|
53
77
|
};
|
|
78
|
+
|
|
54
79
|
var onInputChange = function onInputChange(event) {
|
|
55
80
|
var value = event.target.value;
|
|
81
|
+
|
|
56
82
|
var _utils$checkIfValid = _utils["default"].checkIfValid(value, validations),
|
|
57
|
-
|
|
58
|
-
|
|
83
|
+
isValid = _utils$checkIfValid.isValid,
|
|
84
|
+
error = _utils$checkIfValid.error;
|
|
85
|
+
|
|
59
86
|
if (isValid) {
|
|
60
87
|
setError("");
|
|
61
88
|
} else {
|
|
62
89
|
setError(error);
|
|
63
90
|
}
|
|
91
|
+
|
|
64
92
|
if (typeof onChange === "function") {
|
|
65
93
|
onChange(value, error);
|
|
66
94
|
}
|
|
95
|
+
|
|
67
96
|
postFormValueChange(value, error);
|
|
68
97
|
};
|
|
98
|
+
|
|
69
99
|
(0, _react.useEffect)(function () {
|
|
70
100
|
/* set the initial form element value in the form context */
|
|
71
101
|
var postValue = typeof onChange === "function" ? value : defaultValue;
|
|
102
|
+
|
|
72
103
|
var _utils$checkIfValid2 = _utils["default"].checkIfValid(postValue, validations),
|
|
73
|
-
|
|
104
|
+
error = _utils$checkIfValid2.error;
|
|
105
|
+
|
|
74
106
|
postFormValueChange(postValue, error);
|
|
75
107
|
}, [value, defaultValue]);
|
|
108
|
+
|
|
76
109
|
var inputProps = _objectSpread({
|
|
77
110
|
type: type,
|
|
78
111
|
label: label,
|
|
@@ -85,10 +118,12 @@ var Input = function Input(props, ref) {
|
|
|
85
118
|
onChange: onInputChange,
|
|
86
119
|
ref: ref
|
|
87
120
|
}, restProps);
|
|
121
|
+
|
|
88
122
|
if (typeof onChange === "function") {
|
|
89
123
|
/* make it a controlled component if onChange function is given */
|
|
90
124
|
inputProps.value = value;
|
|
91
125
|
}
|
|
126
|
+
|
|
92
127
|
return /*#__PURE__*/_react["default"].createElement(_FormElementWrapper["default"], {
|
|
93
128
|
className: className,
|
|
94
129
|
appearance: appearance
|
|
@@ -99,21 +134,28 @@ var Input = function Input(props, ref) {
|
|
|
99
134
|
className: "RCB-form-error"
|
|
100
135
|
}, error));
|
|
101
136
|
};
|
|
137
|
+
|
|
102
138
|
Input = /*#__PURE__*/(0, _react.forwardRef)(Input);
|
|
103
139
|
Input.propTypes = {
|
|
104
140
|
/** Pass any additional classNames to Input component */
|
|
105
141
|
className: _propTypes["default"].string,
|
|
142
|
+
|
|
106
143
|
/** Use it to render different input types like text, password etc. */
|
|
107
144
|
type: _propTypes["default"].string,
|
|
145
|
+
|
|
108
146
|
/** indicates whether to show or hide label */
|
|
109
147
|
showLabel: _propTypes["default"].bool,
|
|
148
|
+
|
|
110
149
|
/** Label for the input element */
|
|
111
150
|
label: _propTypes["default"].string,
|
|
151
|
+
|
|
112
152
|
/** Unique ID for the input element */
|
|
113
153
|
name: _propTypes["default"].string.isRequired,
|
|
154
|
+
|
|
114
155
|
/** Will be used only with onChange function, or else ignored */
|
|
115
156
|
value: _propTypes["default"].any,
|
|
116
157
|
defaultValue: _propTypes["default"].any,
|
|
158
|
+
|
|
117
159
|
/** Array of validations to perform on the form element value.
|
|
118
160
|
* If the validation fails, you will get an "error" field in the form onSubmit event */
|
|
119
161
|
validations: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
@@ -122,10 +164,13 @@ Input.propTypes = {
|
|
|
122
164
|
validator: _propTypes["default"].func
|
|
123
165
|
})),
|
|
124
166
|
placeholder: _propTypes["default"].string,
|
|
167
|
+
|
|
125
168
|
/** Define the appearance of the form element. Accepted values are either "inline" or "block" */
|
|
126
169
|
appearance: _propTypes["default"].oneOf(["inline", "block"]),
|
|
170
|
+
|
|
127
171
|
/** Becomes a controlled component if onChange function is given */
|
|
128
172
|
onChange: _propTypes["default"].func,
|
|
173
|
+
|
|
129
174
|
/* HTML 5 autocomplete attribute */
|
|
130
175
|
autoComplete: _propTypes["default"].string
|
|
131
176
|
};
|
|
@@ -1,53 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
9
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
10
14
|
var _Form = require("./Form");
|
|
15
|
+
|
|
11
16
|
var _FormElementWrapper = _interopRequireDefault(require("./FormElementWrapper"));
|
|
17
|
+
|
|
12
18
|
var _excluded = ["options", "label", "name", "className", "value", "defaultValue", "appearance", "onChange"];
|
|
19
|
+
|
|
13
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
|
|
14
22
|
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); }
|
|
23
|
+
|
|
15
24
|
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; }
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
function
|
|
25
|
+
|
|
26
|
+
function _extends() { _extends = Object.assign || 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); }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
22
34
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
35
|
+
|
|
23
36
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
37
|
+
|
|
24
38
|
var RadioList = function RadioList(props) {
|
|
25
39
|
var options = props.options,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
label = props.label,
|
|
41
|
+
name = props.name,
|
|
42
|
+
className = props.className,
|
|
43
|
+
value = props.value,
|
|
44
|
+
defaultValue = props.defaultValue,
|
|
45
|
+
appearance = props.appearance,
|
|
46
|
+
onChange = props.onChange,
|
|
47
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
48
|
+
|
|
34
49
|
var _useContext = (0, _react.useContext)(_Form.FormContext),
|
|
35
|
-
|
|
50
|
+
onValueChange = _useContext.onValueChange;
|
|
51
|
+
|
|
36
52
|
var postFormValueChange = function postFormValueChange(value) {
|
|
37
53
|
typeof onValueChange === "function" && onValueChange(name, value);
|
|
38
54
|
};
|
|
55
|
+
|
|
39
56
|
var onInputChange = function onInputChange(event) {
|
|
40
57
|
var value = event.target.value;
|
|
58
|
+
|
|
41
59
|
if (typeof onChange === "function") {
|
|
42
60
|
onChange(value);
|
|
43
61
|
}
|
|
62
|
+
|
|
44
63
|
postFormValueChange(value);
|
|
45
64
|
};
|
|
65
|
+
|
|
46
66
|
(0, _react.useEffect)(function () {
|
|
47
67
|
/* set the initial form element value in the form context */
|
|
48
68
|
var postValue = typeof onChange === "function" ? value : defaultValue;
|
|
49
69
|
postFormValueChange(postValue);
|
|
50
70
|
}, [value, defaultValue]);
|
|
71
|
+
|
|
51
72
|
var inputProps = _objectSpread({
|
|
52
73
|
type: "radio",
|
|
53
74
|
label: label,
|
|
@@ -55,6 +76,7 @@ var RadioList = function RadioList(props) {
|
|
|
55
76
|
className: "RCB-form-el",
|
|
56
77
|
onChange: onInputChange
|
|
57
78
|
}, restProps);
|
|
79
|
+
|
|
58
80
|
return /*#__PURE__*/_react["default"].createElement(_FormElementWrapper["default"], {
|
|
59
81
|
className: className,
|
|
60
82
|
appearance: appearance
|
|
@@ -62,14 +84,16 @@ var RadioList = function RadioList(props) {
|
|
|
62
84
|
className: "RCB-form-el-label"
|
|
63
85
|
}, label), options.map(function (option) {
|
|
64
86
|
var id = option.id,
|
|
65
|
-
|
|
87
|
+
name = option.name;
|
|
66
88
|
var additionalProps = {
|
|
67
89
|
defaultChecked: defaultValue === id
|
|
68
90
|
};
|
|
91
|
+
|
|
69
92
|
if (typeof onChange === "function") {
|
|
70
93
|
/* make it a controlled component if onChange function is given */
|
|
71
94
|
additionalProps.checked = value === id;
|
|
72
95
|
}
|
|
96
|
+
|
|
73
97
|
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, {
|
|
74
98
|
key: id
|
|
75
99
|
}, /*#__PURE__*/_react["default"].createElement("input", _extends({}, inputProps, {
|
|
@@ -81,23 +105,30 @@ var RadioList = function RadioList(props) {
|
|
|
81
105
|
}, name));
|
|
82
106
|
}));
|
|
83
107
|
};
|
|
108
|
+
|
|
84
109
|
RadioList.propTypes = {
|
|
85
110
|
/** Pass any additional classNames to Input component */
|
|
86
111
|
className: _propTypes["default"].string,
|
|
112
|
+
|
|
87
113
|
/** radio items list */
|
|
88
114
|
options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
89
115
|
id: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
90
116
|
name: _propTypes["default"].string
|
|
91
117
|
})).isRequired,
|
|
118
|
+
|
|
92
119
|
/** Label for the input element */
|
|
93
120
|
label: _propTypes["default"].string,
|
|
121
|
+
|
|
94
122
|
/** Unique ID for the input element */
|
|
95
123
|
name: _propTypes["default"].string.isRequired,
|
|
124
|
+
|
|
96
125
|
/** ID of the selected radio item, will be used only with onChange function, or else ignored */
|
|
97
126
|
value: _propTypes["default"].any,
|
|
98
127
|
defaultValue: _propTypes["default"].any,
|
|
128
|
+
|
|
99
129
|
/** Define the appearance of the form element. Accepted values are either "inline" or "block" */
|
|
100
130
|
appearance: _propTypes["default"].oneOf(["inline", "block"]),
|
|
131
|
+
|
|
101
132
|
/** Becomes a controlled component if onChange function is given */
|
|
102
133
|
onChange: _propTypes["default"].func
|
|
103
134
|
};
|