@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
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
+
var FormElementWrapper = function FormElementWrapper(props) {
|
|
11
|
+
var className = props.className,
|
|
12
|
+
children = props.children,
|
|
13
|
+
appearance = props.appearance;
|
|
14
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
15
|
+
className: "RCB-form-el-cont RCB-form-el-".concat(appearance, " ").concat(className)
|
|
16
|
+
}, children);
|
|
17
|
+
};
|
|
18
|
+
FormElementWrapper.propTypes = {
|
|
19
|
+
/** Pass any additional classNames to Form component */
|
|
20
|
+
className: _propTypes["default"].string,
|
|
21
|
+
appearance: _propTypes["default"].string
|
|
22
|
+
};
|
|
23
|
+
FormElementWrapper.defaultProps = {
|
|
24
|
+
appearance: "inline"
|
|
25
|
+
};
|
|
26
|
+
var _default = FormElementWrapper;
|
|
27
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,140 @@
|
|
|
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 _Form = require("./Form");
|
|
11
|
+
var _FormElementWrapper = _interopRequireDefault(require("./FormElementWrapper"));
|
|
12
|
+
var _Validators = _interopRequireDefault(require("../../core/Validators"));
|
|
13
|
+
var _utils = _interopRequireDefault(require("../../core/utils"));
|
|
14
|
+
var _excluded = ["label", "name", "type", "className", "value", "defaultValue", "placeholder", "appearance", "onChange", "validations", "autoComplete", "showLabel"];
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
+
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); }
|
|
17
|
+
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
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
21
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
22
|
+
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); }
|
|
23
|
+
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; }
|
|
24
|
+
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; }
|
|
25
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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
|
+
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
|
+
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; }
|
|
29
|
+
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; } }
|
|
30
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
31
|
+
var Input = function Input(props, ref) {
|
|
32
|
+
var _useState = (0, _react.useState)(),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
error = _useState2[0],
|
|
35
|
+
setError = _useState2[1];
|
|
36
|
+
var label = props.label,
|
|
37
|
+
name = props.name,
|
|
38
|
+
type = props.type,
|
|
39
|
+
className = props.className,
|
|
40
|
+
value = props.value,
|
|
41
|
+
defaultValue = props.defaultValue,
|
|
42
|
+
placeholder = props.placeholder,
|
|
43
|
+
appearance = props.appearance,
|
|
44
|
+
onChange = props.onChange,
|
|
45
|
+
validations = props.validations,
|
|
46
|
+
autoComplete = props.autoComplete,
|
|
47
|
+
showLabel = props.showLabel,
|
|
48
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
49
|
+
var _useContext = (0, _react.useContext)(_Form.FormContext),
|
|
50
|
+
onValueChange = _useContext.onValueChange;
|
|
51
|
+
var postFormValueChange = function postFormValueChange(value, error) {
|
|
52
|
+
typeof onValueChange === "function" && onValueChange(name, value, error);
|
|
53
|
+
};
|
|
54
|
+
var onInputChange = function onInputChange(event) {
|
|
55
|
+
var value = event.target.value;
|
|
56
|
+
var _utils$checkIfValid = _utils["default"].checkIfValid(value, validations),
|
|
57
|
+
isValid = _utils$checkIfValid.isValid,
|
|
58
|
+
error = _utils$checkIfValid.error;
|
|
59
|
+
if (isValid) {
|
|
60
|
+
setError("");
|
|
61
|
+
} else {
|
|
62
|
+
setError(error);
|
|
63
|
+
}
|
|
64
|
+
if (typeof onChange === "function") {
|
|
65
|
+
onChange(value, error);
|
|
66
|
+
}
|
|
67
|
+
postFormValueChange(value, error);
|
|
68
|
+
};
|
|
69
|
+
(0, _react.useEffect)(function () {
|
|
70
|
+
/* set the initial form element value in the form context */
|
|
71
|
+
var postValue = typeof onChange === "function" ? value : defaultValue;
|
|
72
|
+
var _utils$checkIfValid2 = _utils["default"].checkIfValid(postValue, validations),
|
|
73
|
+
error = _utils$checkIfValid2.error;
|
|
74
|
+
postFormValueChange(postValue, error);
|
|
75
|
+
}, [value, defaultValue]);
|
|
76
|
+
var inputProps = _objectSpread({
|
|
77
|
+
type: type,
|
|
78
|
+
label: label,
|
|
79
|
+
name: name,
|
|
80
|
+
id: name,
|
|
81
|
+
defaultValue: defaultValue,
|
|
82
|
+
placeholder: placeholder,
|
|
83
|
+
autoComplete: autoComplete,
|
|
84
|
+
className: "RCB-form-el",
|
|
85
|
+
onChange: onInputChange,
|
|
86
|
+
ref: ref
|
|
87
|
+
}, restProps);
|
|
88
|
+
if (typeof onChange === "function") {
|
|
89
|
+
/* make it a controlled component if onChange function is given */
|
|
90
|
+
inputProps.value = value;
|
|
91
|
+
}
|
|
92
|
+
return /*#__PURE__*/_react["default"].createElement(_FormElementWrapper["default"], {
|
|
93
|
+
className: className,
|
|
94
|
+
appearance: appearance
|
|
95
|
+
}, showLabel && label && /*#__PURE__*/_react["default"].createElement("label", {
|
|
96
|
+
className: "RCB-form-el-label",
|
|
97
|
+
htmlFor: name
|
|
98
|
+
}, label), /*#__PURE__*/_react["default"].createElement("input", inputProps), error && /*#__PURE__*/_react["default"].createElement("div", {
|
|
99
|
+
className: "RCB-form-error"
|
|
100
|
+
}, error));
|
|
101
|
+
};
|
|
102
|
+
Input = /*#__PURE__*/(0, _react.forwardRef)(Input);
|
|
103
|
+
Input.propTypes = {
|
|
104
|
+
/** Pass any additional classNames to Input component */
|
|
105
|
+
className: _propTypes["default"].string,
|
|
106
|
+
/** Use it to render different input types like text, password etc. */
|
|
107
|
+
type: _propTypes["default"].string,
|
|
108
|
+
/** indicates whether to show or hide label */
|
|
109
|
+
showLabel: _propTypes["default"].bool,
|
|
110
|
+
/** Label for the input element */
|
|
111
|
+
label: _propTypes["default"].string,
|
|
112
|
+
/** Unique ID for the input element */
|
|
113
|
+
name: _propTypes["default"].string.isRequired,
|
|
114
|
+
/** Will be used only with onChange function, or else ignored */
|
|
115
|
+
value: _propTypes["default"].any,
|
|
116
|
+
defaultValue: _propTypes["default"].any,
|
|
117
|
+
/** Array of validations to perform on the form element value.
|
|
118
|
+
* If the validation fails, you will get an "error" field in the form onSubmit event */
|
|
119
|
+
validations: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
120
|
+
type: _propTypes["default"].oneOf(Object.keys(_Validators["default"])).isRequired,
|
|
121
|
+
message: _propTypes["default"].string.isRequired,
|
|
122
|
+
validator: _propTypes["default"].func
|
|
123
|
+
})),
|
|
124
|
+
placeholder: _propTypes["default"].string,
|
|
125
|
+
/** Define the appearance of the form element. Accepted values are either "inline" or "block" */
|
|
126
|
+
appearance: _propTypes["default"].oneOf(["inline", "block"]),
|
|
127
|
+
/** Becomes a controlled component if onChange function is given */
|
|
128
|
+
onChange: _propTypes["default"].func,
|
|
129
|
+
/* HTML 5 autocomplete attribute */
|
|
130
|
+
autoComplete: _propTypes["default"].string
|
|
131
|
+
};
|
|
132
|
+
Input.defaultProps = {
|
|
133
|
+
className: "",
|
|
134
|
+
showLabel: true,
|
|
135
|
+
appearance: "inline",
|
|
136
|
+
validations: [],
|
|
137
|
+
autoComplete: "off"
|
|
138
|
+
};
|
|
139
|
+
var _default = Input;
|
|
140
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,111 @@
|
|
|
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 _Form = require("./Form");
|
|
11
|
+
var _FormElementWrapper = _interopRequireDefault(require("./FormElementWrapper"));
|
|
12
|
+
var _excluded = ["options", "label", "name", "className", "value", "defaultValue", "appearance", "onChange"];
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
+
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); }
|
|
15
|
+
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
|
+
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); }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
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); }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
var RadioList = function RadioList(props) {
|
|
25
|
+
var options = props.options,
|
|
26
|
+
label = props.label,
|
|
27
|
+
name = props.name,
|
|
28
|
+
className = props.className,
|
|
29
|
+
value = props.value,
|
|
30
|
+
defaultValue = props.defaultValue,
|
|
31
|
+
appearance = props.appearance,
|
|
32
|
+
onChange = props.onChange,
|
|
33
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
34
|
+
var _useContext = (0, _react.useContext)(_Form.FormContext),
|
|
35
|
+
onValueChange = _useContext.onValueChange;
|
|
36
|
+
var postFormValueChange = function postFormValueChange(value) {
|
|
37
|
+
typeof onValueChange === "function" && onValueChange(name, value);
|
|
38
|
+
};
|
|
39
|
+
var onInputChange = function onInputChange(event) {
|
|
40
|
+
var value = event.target.value;
|
|
41
|
+
if (typeof onChange === "function") {
|
|
42
|
+
onChange(value);
|
|
43
|
+
}
|
|
44
|
+
postFormValueChange(value);
|
|
45
|
+
};
|
|
46
|
+
(0, _react.useEffect)(function () {
|
|
47
|
+
/* set the initial form element value in the form context */
|
|
48
|
+
var postValue = typeof onChange === "function" ? value : defaultValue;
|
|
49
|
+
postFormValueChange(postValue);
|
|
50
|
+
}, [value, defaultValue]);
|
|
51
|
+
var inputProps = _objectSpread({
|
|
52
|
+
type: "radio",
|
|
53
|
+
label: label,
|
|
54
|
+
name: name,
|
|
55
|
+
className: "RCB-form-el",
|
|
56
|
+
onChange: onInputChange
|
|
57
|
+
}, restProps);
|
|
58
|
+
return /*#__PURE__*/_react["default"].createElement(_FormElementWrapper["default"], {
|
|
59
|
+
className: className,
|
|
60
|
+
appearance: appearance
|
|
61
|
+
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
62
|
+
className: "RCB-form-el-label"
|
|
63
|
+
}, label), options.map(function (option) {
|
|
64
|
+
var id = option.id,
|
|
65
|
+
name = option.name;
|
|
66
|
+
var additionalProps = {
|
|
67
|
+
defaultChecked: defaultValue === id
|
|
68
|
+
};
|
|
69
|
+
if (typeof onChange === "function") {
|
|
70
|
+
/* make it a controlled component if onChange function is given */
|
|
71
|
+
additionalProps.checked = value === id;
|
|
72
|
+
}
|
|
73
|
+
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, {
|
|
74
|
+
key: id
|
|
75
|
+
}, /*#__PURE__*/_react["default"].createElement("input", _extends({}, inputProps, {
|
|
76
|
+
id: id,
|
|
77
|
+
value: id
|
|
78
|
+
}, additionalProps, {
|
|
79
|
+
"data-hj-allow": true
|
|
80
|
+
})), /*#__PURE__*/_react["default"].createElement("label", {
|
|
81
|
+
className: "RCB-radio-label",
|
|
82
|
+
htmlFor: id
|
|
83
|
+
}, name));
|
|
84
|
+
}));
|
|
85
|
+
};
|
|
86
|
+
RadioList.propTypes = {
|
|
87
|
+
/** Pass any additional classNames to Input component */
|
|
88
|
+
className: _propTypes["default"].string,
|
|
89
|
+
/** radio items list */
|
|
90
|
+
options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
91
|
+
id: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
92
|
+
name: _propTypes["default"].string
|
|
93
|
+
})).isRequired,
|
|
94
|
+
/** Label for the input element */
|
|
95
|
+
label: _propTypes["default"].string,
|
|
96
|
+
/** Unique ID for the input element */
|
|
97
|
+
name: _propTypes["default"].string.isRequired,
|
|
98
|
+
/** ID of the selected radio item, will be used only with onChange function, or else ignored */
|
|
99
|
+
value: _propTypes["default"].any,
|
|
100
|
+
defaultValue: _propTypes["default"].any,
|
|
101
|
+
/** Define the appearance of the form element. Accepted values are either "inline" or "block" */
|
|
102
|
+
appearance: _propTypes["default"].oneOf(["inline", "block"]),
|
|
103
|
+
/** Becomes a controlled component if onChange function is given */
|
|
104
|
+
onChange: _propTypes["default"].func
|
|
105
|
+
};
|
|
106
|
+
RadioList.defaultProps = {
|
|
107
|
+
className: "",
|
|
108
|
+
appearance: "inline"
|
|
109
|
+
};
|
|
110
|
+
var _default = RadioList;
|
|
111
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,142 @@
|
|
|
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 _Form = require("./Form");
|
|
11
|
+
var _FormElementWrapper = _interopRequireDefault(require("./FormElementWrapper"));
|
|
12
|
+
var _excluded = ["label", "name", "min", "max", "className", "value", "defaultValue", "appearance", "onChange", "disabled", "showBubble", "inputStyle", "bubbleStyle", "inputClassName"];
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
+
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); }
|
|
15
|
+
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
|
+
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); }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
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); }
|
|
22
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
23
|
+
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."); }
|
|
24
|
+
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); }
|
|
25
|
+
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; }
|
|
26
|
+
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; } }
|
|
27
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
28
|
+
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; }
|
|
29
|
+
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; }
|
|
30
|
+
var RangeSlider = function RangeSlider(props) {
|
|
31
|
+
var label = props.label,
|
|
32
|
+
name = props.name,
|
|
33
|
+
min = props.min,
|
|
34
|
+
max = props.max,
|
|
35
|
+
className = props.className,
|
|
36
|
+
value = props.value,
|
|
37
|
+
defaultValue = props.defaultValue,
|
|
38
|
+
appearance = props.appearance,
|
|
39
|
+
onChange = props.onChange,
|
|
40
|
+
disabled = props.disabled,
|
|
41
|
+
showBubble = props.showBubble,
|
|
42
|
+
_props$inputStyle = props.inputStyle,
|
|
43
|
+
inputStyle = _props$inputStyle === void 0 ? {} : _props$inputStyle,
|
|
44
|
+
_props$bubbleStyle = props.bubbleStyle,
|
|
45
|
+
bubbleStyle = _props$bubbleStyle === void 0 ? {} : _props$bubbleStyle,
|
|
46
|
+
inputClassName = props.inputClassName,
|
|
47
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
48
|
+
var _useContext = (0, _react.useContext)(_Form.FormContext),
|
|
49
|
+
onValueChange = _useContext.onValueChange;
|
|
50
|
+
var _useState = (0, _react.useState)(value || defaultValue),
|
|
51
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
+
val = _useState2[0],
|
|
53
|
+
setVal = _useState2[1];
|
|
54
|
+
var postFormValueChange = function postFormValueChange(value) {
|
|
55
|
+
typeof onValueChange === "function" && onValueChange(name, value);
|
|
56
|
+
};
|
|
57
|
+
var onInputChange = function onInputChange(event) {
|
|
58
|
+
var value = event.target.value;
|
|
59
|
+
|
|
60
|
+
// TODO : do validations
|
|
61
|
+
|
|
62
|
+
if (typeof onChange === "function") {
|
|
63
|
+
onChange(value);
|
|
64
|
+
}
|
|
65
|
+
postFormValueChange(value);
|
|
66
|
+
setVal(value);
|
|
67
|
+
};
|
|
68
|
+
(0, _react.useEffect)(function () {
|
|
69
|
+
/* set the initial form element value in the form context */
|
|
70
|
+
var postValue = typeof onChange === "function" ? value : defaultValue;
|
|
71
|
+
postFormValueChange(postValue);
|
|
72
|
+
}, [value, defaultValue]);
|
|
73
|
+
var inputProps = _objectSpread(_objectSpread({
|
|
74
|
+
type: "range",
|
|
75
|
+
min: min,
|
|
76
|
+
max: max,
|
|
77
|
+
label: label,
|
|
78
|
+
name: name,
|
|
79
|
+
id: name,
|
|
80
|
+
defaultValue: defaultValue,
|
|
81
|
+
disabled: disabled,
|
|
82
|
+
className: "RCB-form-el RCB-input-range ".concat(inputClassName),
|
|
83
|
+
onChange: onInputChange
|
|
84
|
+
}, restProps), {}, {
|
|
85
|
+
showBubble: showBubble
|
|
86
|
+
});
|
|
87
|
+
if (typeof onChange === "function") {
|
|
88
|
+
/* make it a controlled component if onChange function is given */
|
|
89
|
+
inputProps.value = value;
|
|
90
|
+
}
|
|
91
|
+
return /*#__PURE__*/_react["default"].createElement(_FormElementWrapper["default"], {
|
|
92
|
+
className: className,
|
|
93
|
+
appearance: appearance
|
|
94
|
+
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
95
|
+
className: "RCB-form-el-label",
|
|
96
|
+
htmlFor: name
|
|
97
|
+
}, label), /*#__PURE__*/_react["default"].createElement("div", {
|
|
98
|
+
className: "RCB-range-wrapper"
|
|
99
|
+
}, showBubble && /*#__PURE__*/_react["default"].createElement("div", {
|
|
100
|
+
className: "RCB-range-value",
|
|
101
|
+
style: bubbleStyle
|
|
102
|
+
}, /*#__PURE__*/_react["default"].createElement("span", null, val)), /*#__PURE__*/_react["default"].createElement("input", _extends({}, inputProps, {
|
|
103
|
+
style: inputStyle,
|
|
104
|
+
disabled: disabled,
|
|
105
|
+
"data-hj-allow": true
|
|
106
|
+
}))));
|
|
107
|
+
};
|
|
108
|
+
RangeSlider.propTypes = {
|
|
109
|
+
/** Pass any additional classNames to Input component container */
|
|
110
|
+
className: _propTypes["default"].string,
|
|
111
|
+
/** Pass any additional classNames to Input component */
|
|
112
|
+
inputClassName: _propTypes["default"].string,
|
|
113
|
+
/** Minimum value for range slider */
|
|
114
|
+
min: _propTypes["default"].string.isRequired,
|
|
115
|
+
/** Maximum value for range slider */
|
|
116
|
+
max: _propTypes["default"].string.isRequired,
|
|
117
|
+
/** Label for the input element */
|
|
118
|
+
label: _propTypes["default"].string,
|
|
119
|
+
/** Unique ID for the input element */
|
|
120
|
+
name: _propTypes["default"].string.isRequired,
|
|
121
|
+
/** Will be used only with onChange function, or else ignored */
|
|
122
|
+
value: _propTypes["default"].any,
|
|
123
|
+
defaultValue: _propTypes["default"].any,
|
|
124
|
+
/** Define the appearance of the form element. Accepted values are either "inline" or "block" */
|
|
125
|
+
appearance: _propTypes["default"].oneOf(["inline", "block"]),
|
|
126
|
+
/** Becomes a controlled component if onChange function is given */
|
|
127
|
+
onChange: _propTypes["default"].func,
|
|
128
|
+
/** Custom Style changes of slider track */
|
|
129
|
+
inputStyle: _propTypes["default"].object,
|
|
130
|
+
/** Custom Style changes of value bubble */
|
|
131
|
+
bubbleStyle: _propTypes["default"].object,
|
|
132
|
+
/** Show bubble with values */
|
|
133
|
+
showBubble: _propTypes["default"].bool,
|
|
134
|
+
/** Indicates if the slider is disabled or enabled */
|
|
135
|
+
disabled: _propTypes["default"].bool
|
|
136
|
+
};
|
|
137
|
+
RangeSlider.defaultProps = {
|
|
138
|
+
className: "",
|
|
139
|
+
appearance: "inline"
|
|
140
|
+
};
|
|
141
|
+
var _default = RangeSlider;
|
|
142
|
+
exports["default"] = _default;
|