@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,478 @@
|
|
|
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"] = exports.DefaultDropdownItem = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _InlineModal = _interopRequireWildcard(require("../InlineModal"));
|
|
11
|
+
var _List = _interopRequireDefault(require("../List"));
|
|
12
|
+
var _Form = require("./Form");
|
|
13
|
+
var _FormElementWrapper = _interopRequireDefault(require("./FormElementWrapper"));
|
|
14
|
+
var _ServerPaginatedDDList = _interopRequireDefault(require("./ServerPaginatedDDList"));
|
|
15
|
+
var _utils = _interopRequireDefault(require("../../core/utils"));
|
|
16
|
+
var _excluded = ["items", "selectedItems", "selectItem", "idAttribute", "nameAttribute", "DropdownItem", "ListHeaderItem", "showClippedContentTitle"],
|
|
17
|
+
_excluded2 = ["halign", "label", "showLabel", "name", "SelectionSummary", "className", "value", "defaultValue", "onChange", "disabled", "options", "showSearch", "searchPlaceholder", "idAttribute", "nameAttribute", "noSelectionLabel", "appearance", "multiSelect", "DropdownItem", "validations", "paginationType", "requestId", "requestParams", "pageNoKey", "perPageKey", "pageSize", "searchAttribute", "maxHeight", "responseFormatter", "getUrlParams", "showCreateCTA", "createCTAComponent", "onCreateCTAClick", "serverListClassName", "showClear", "onClear", "minPageNo", "ListHeaderItem", "onSearchChange", "showClippedContentTitle"];
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
22
|
+
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."); }
|
|
23
|
+
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); }
|
|
24
|
+
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; }
|
|
25
|
+
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; } }
|
|
26
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
|
+
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); }
|
|
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 convertToArray = function convertToArray(value) {
|
|
31
|
+
if (!value) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
return Array.isArray(value) ? value : [value];
|
|
35
|
+
};
|
|
36
|
+
var getFilteredOptions = function getFilteredOptions() {
|
|
37
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
38
|
+
var searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
39
|
+
var nameAttribute = arguments.length > 2 ? arguments[2] : undefined;
|
|
40
|
+
return options.filter(function (obj) {
|
|
41
|
+
var nameValue = obj[nameAttribute].toLowerCase();
|
|
42
|
+
return nameValue.indexOf(searchQuery.toLowerCase()) !== -1;
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/* eslint-disable react/prop-types */
|
|
47
|
+
var DefaultSelectionSummary = function DefaultSelectionSummary(_ref) {
|
|
48
|
+
var _ref$selectedItems = _ref.selectedItems,
|
|
49
|
+
selectedItems = _ref$selectedItems === void 0 ? [] : _ref$selectedItems,
|
|
50
|
+
multiSelect = _ref.multiSelect,
|
|
51
|
+
noSelectionLabel = _ref.noSelectionLabel,
|
|
52
|
+
nameAttribute = _ref.nameAttribute,
|
|
53
|
+
showClear = _ref.showClear,
|
|
54
|
+
clearSelectedItems = _ref.clearSelectedItems;
|
|
55
|
+
var summaryString = "";
|
|
56
|
+
var selectedCount = selectedItems.length;
|
|
57
|
+
if (multiSelect) {
|
|
58
|
+
summaryString = selectedCount ? "".concat(selectedCount, " selected") : noSelectionLabel;
|
|
59
|
+
} else {
|
|
60
|
+
summaryString = selectedCount ? selectedItems[0][nameAttribute] : noSelectionLabel;
|
|
61
|
+
}
|
|
62
|
+
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
63
|
+
className: "RCB-dd-label"
|
|
64
|
+
}, summaryString), /*#__PURE__*/_react["default"].createElement("span", {
|
|
65
|
+
className: "RCB-selection-wrapper"
|
|
66
|
+
}, showClear && /*#__PURE__*/_react["default"].createElement("span", {
|
|
67
|
+
className: "RCB-clear-selected",
|
|
68
|
+
onClick: clearSelectedItems
|
|
69
|
+
}, "Clear"), /*#__PURE__*/_react["default"].createElement("span", {
|
|
70
|
+
className: "RCB-select-arrow"
|
|
71
|
+
})));
|
|
72
|
+
};
|
|
73
|
+
var DefaultDropdownItem = function DefaultDropdownItem(props) {
|
|
74
|
+
var itemData = props.itemData,
|
|
75
|
+
selectItem = props.selectItem,
|
|
76
|
+
_props$selectedItems = props.selectedItems,
|
|
77
|
+
selectedItems = _props$selectedItems === void 0 ? [] : _props$selectedItems,
|
|
78
|
+
idAttribute = props.idAttribute,
|
|
79
|
+
nameAttribute = props.nameAttribute,
|
|
80
|
+
showClippedContentTitle = props.showClippedContentTitle;
|
|
81
|
+
var idValue = itemData[idAttribute];
|
|
82
|
+
var name = itemData[nameAttribute];
|
|
83
|
+
var isSelected = selectedItems.find(function (obj) {
|
|
84
|
+
return obj[idAttribute] === idValue;
|
|
85
|
+
}) ? true : false;
|
|
86
|
+
var className = "RCB-list-item " + (isSelected ? "selected" : "");
|
|
87
|
+
if (showClippedContentTitle) {
|
|
88
|
+
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
89
|
+
onClick: function onClick() {
|
|
90
|
+
return selectItem(itemData);
|
|
91
|
+
},
|
|
92
|
+
className: className,
|
|
93
|
+
title: name
|
|
94
|
+
}, name);
|
|
95
|
+
} else {
|
|
96
|
+
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
97
|
+
onClick: function onClick() {
|
|
98
|
+
return selectItem(itemData);
|
|
99
|
+
},
|
|
100
|
+
className: className
|
|
101
|
+
}, name);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
exports.DefaultDropdownItem = DefaultDropdownItem;
|
|
105
|
+
DefaultDropdownItem.propTypes = {
|
|
106
|
+
itemData: _propTypes["default"].object.isRequired,
|
|
107
|
+
selectItem: _propTypes["default"].func.isRequired,
|
|
108
|
+
selectedItems: _propTypes["default"].array,
|
|
109
|
+
idAttribute: _propTypes["default"].string,
|
|
110
|
+
nameAttribute: _propTypes["default"].string,
|
|
111
|
+
showClippedContentTitle: _propTypes["default"].bool
|
|
112
|
+
};
|
|
113
|
+
var NormalList = function NormalList(_ref2) {
|
|
114
|
+
var _ref2$items = _ref2.items,
|
|
115
|
+
items = _ref2$items === void 0 ? [] : _ref2$items,
|
|
116
|
+
selectedItems = _ref2.selectedItems,
|
|
117
|
+
selectItem = _ref2.selectItem,
|
|
118
|
+
idAttribute = _ref2.idAttribute,
|
|
119
|
+
nameAttribute = _ref2.nameAttribute,
|
|
120
|
+
DropdownItem = _ref2.DropdownItem,
|
|
121
|
+
ListHeaderItem = _ref2.ListHeaderItem,
|
|
122
|
+
showClippedContentTitle = _ref2.showClippedContentTitle,
|
|
123
|
+
restProps = _objectWithoutProperties(_ref2, _excluded);
|
|
124
|
+
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, items.length ? ListHeaderItem : "", /*#__PURE__*/_react["default"].createElement(_List["default"], _extends({
|
|
125
|
+
items: items
|
|
126
|
+
}, restProps, {
|
|
127
|
+
showNoDataMsg: true,
|
|
128
|
+
ListItem: DropdownItem,
|
|
129
|
+
selectedItems: selectedItems,
|
|
130
|
+
selectItem: selectItem,
|
|
131
|
+
showClippedContentTitle: showClippedContentTitle,
|
|
132
|
+
idAttribute: idAttribute,
|
|
133
|
+
nameAttribute: nameAttribute
|
|
134
|
+
})));
|
|
135
|
+
};
|
|
136
|
+
NormalList.defaultProps = {
|
|
137
|
+
DropdownItem: DefaultDropdownItem
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/* eslint-enable react/prop-types */
|
|
141
|
+
|
|
142
|
+
var Dropdown = function Dropdown(props, ref) {
|
|
143
|
+
var halign = props.halign,
|
|
144
|
+
label = props.label,
|
|
145
|
+
showLabel = props.showLabel,
|
|
146
|
+
name = props.name,
|
|
147
|
+
SelectionSummary = props.SelectionSummary,
|
|
148
|
+
className = props.className,
|
|
149
|
+
value = props.value,
|
|
150
|
+
defaultValue = props.defaultValue,
|
|
151
|
+
onChange = props.onChange,
|
|
152
|
+
disabled = props.disabled,
|
|
153
|
+
options = props.options,
|
|
154
|
+
showSearch = props.showSearch,
|
|
155
|
+
searchPlaceholder = props.searchPlaceholder,
|
|
156
|
+
idAttribute = props.idAttribute,
|
|
157
|
+
nameAttribute = props.nameAttribute,
|
|
158
|
+
noSelectionLabel = props.noSelectionLabel,
|
|
159
|
+
appearance = props.appearance,
|
|
160
|
+
multiSelect = props.multiSelect,
|
|
161
|
+
DropdownItem = props.DropdownItem,
|
|
162
|
+
validations = props.validations,
|
|
163
|
+
paginationType = props.paginationType,
|
|
164
|
+
requestId = props.requestId,
|
|
165
|
+
requestParams = props.requestParams,
|
|
166
|
+
pageNoKey = props.pageNoKey,
|
|
167
|
+
perPageKey = props.perPageKey,
|
|
168
|
+
pageSize = props.pageSize,
|
|
169
|
+
searchAttribute = props.searchAttribute,
|
|
170
|
+
maxHeight = props.maxHeight,
|
|
171
|
+
responseFormatter = props.responseFormatter,
|
|
172
|
+
getUrlParams = props.getUrlParams,
|
|
173
|
+
showCreateCTA = props.showCreateCTA,
|
|
174
|
+
createCTAComponent = props.createCTAComponent,
|
|
175
|
+
onCreateCTAClick = props.onCreateCTAClick,
|
|
176
|
+
serverListClassName = props.serverListClassName,
|
|
177
|
+
showClear = props.showClear,
|
|
178
|
+
onClear = props.onClear,
|
|
179
|
+
minPageNo = props.minPageNo,
|
|
180
|
+
ListHeaderItem = props.ListHeaderItem,
|
|
181
|
+
propSearchChange = props.onSearchChange,
|
|
182
|
+
showClippedContentTitle = props.showClippedContentTitle,
|
|
183
|
+
restProps = _objectWithoutProperties(props, _excluded2);
|
|
184
|
+
var _useState = (0, _react.useState)(""),
|
|
185
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
186
|
+
searchQuery = _useState2[0],
|
|
187
|
+
setSearchQuery = _useState2[1];
|
|
188
|
+
var debouncedFn = (0, _react.useRef)();
|
|
189
|
+
var searchIpRef = (0, _react.useRef)();
|
|
190
|
+
var initialSelected = [];
|
|
191
|
+
var initialValue = typeof onChange === "function" ? value : defaultValue;
|
|
192
|
+
if (typeof initialValue !== "undefined") {
|
|
193
|
+
initialSelected = convertToArray(initialValue);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* array of selected item objects */
|
|
197
|
+
var _useState3 = (0, _react.useState)(initialSelected),
|
|
198
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
199
|
+
selectedItems = _useState4[0],
|
|
200
|
+
setSelectedItems = _useState4[1];
|
|
201
|
+
var _useContext = (0, _react.useContext)(_Form.FormContext),
|
|
202
|
+
onValueChange = _useContext.onValueChange;
|
|
203
|
+
var inlineModalRef = (0, _react.useRef)();
|
|
204
|
+
var hideModal = function hideModal() {
|
|
205
|
+
inlineModalRef.current.hideModal();
|
|
206
|
+
};
|
|
207
|
+
var postFormValueChange = function postFormValueChange(value) {
|
|
208
|
+
var _utils$checkIfValid = _utils["default"].checkIfValid(value, validations),
|
|
209
|
+
error = _utils$checkIfValid.error;
|
|
210
|
+
typeof onValueChange === "function" && onValueChange(name, value, error);
|
|
211
|
+
};
|
|
212
|
+
var selectItem = function selectItem(item) {
|
|
213
|
+
var id = item[idAttribute];
|
|
214
|
+
if (multiSelect) {
|
|
215
|
+
var isPresent = selectedItems.find(function (obj) {
|
|
216
|
+
return obj[idAttribute] === id;
|
|
217
|
+
});
|
|
218
|
+
if (!isPresent) {
|
|
219
|
+
selectedItems.push(item);
|
|
220
|
+
postFormValueChange(selectedItems);
|
|
221
|
+
typeof onChange === "function" && onChange(selectedItems);
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
selectedItems = [item];
|
|
225
|
+
postFormValueChange(item);
|
|
226
|
+
typeof onChange === "function" && onChange(item);
|
|
227
|
+
/* close the dropdown */
|
|
228
|
+
hideModal();
|
|
229
|
+
}
|
|
230
|
+
setSelectedItems(selectedItems);
|
|
231
|
+
};
|
|
232
|
+
(0, _react.useEffect)(function () {
|
|
233
|
+
/* set the initial form element value in the form context */
|
|
234
|
+
var postValue = typeof onChange === "function" ? value : defaultValue;
|
|
235
|
+
if (typeof postValue !== "undefined") {
|
|
236
|
+
var arrayPostValue = convertToArray(postValue);
|
|
237
|
+
postValue = multiSelect ? arrayPostValue : postValue;
|
|
238
|
+
setSelectedItems(arrayPostValue);
|
|
239
|
+
}
|
|
240
|
+
postFormValueChange(postValue);
|
|
241
|
+
}, [value, defaultValue]);
|
|
242
|
+
var debouncedSearchChange = function debouncedSearchChange(value) {
|
|
243
|
+
setSearchQuery(value);
|
|
244
|
+
if (typeof propSearchChange === "function") {
|
|
245
|
+
propSearchChange(value);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
var onSearchChange = function onSearchChange(event) {
|
|
249
|
+
event.persist();
|
|
250
|
+
if (!debouncedFn.current) {
|
|
251
|
+
debouncedFn.current = _utils["default"].debounce(debouncedSearchChange, 300);
|
|
252
|
+
}
|
|
253
|
+
return debouncedFn.current(event.target.value);
|
|
254
|
+
};
|
|
255
|
+
var onModalStateChange = function onModalStateChange(isModalOpen) {
|
|
256
|
+
if (isModalOpen && showSearch) {
|
|
257
|
+
searchIpRef.current && searchIpRef.current.focus();
|
|
258
|
+
} else {
|
|
259
|
+
/* modal is closed */
|
|
260
|
+
setSearchQuery("");
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
var clearSelectedItems = function clearSelectedItems(evnt) {
|
|
264
|
+
evnt.stopPropagation();
|
|
265
|
+
setSelectedItems([]);
|
|
266
|
+
typeof onClear === "function" && onClear();
|
|
267
|
+
typeof onChange === "function" && onChange(null);
|
|
268
|
+
/** Close modal after reset */
|
|
269
|
+
hideModal();
|
|
270
|
+
};
|
|
271
|
+
var commonAttributes = {
|
|
272
|
+
selectedItems: selectedItems,
|
|
273
|
+
selectItem: selectItem,
|
|
274
|
+
idAttribute: idAttribute,
|
|
275
|
+
nameAttribute: nameAttribute,
|
|
276
|
+
DropdownItem: DropdownItem,
|
|
277
|
+
ListHeaderItem: ListHeaderItem,
|
|
278
|
+
showClippedContentTitle: showClippedContentTitle
|
|
279
|
+
};
|
|
280
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
|
281
|
+
return {
|
|
282
|
+
closeDropdown: hideModal
|
|
283
|
+
};
|
|
284
|
+
});
|
|
285
|
+
var serverListAttrs = {
|
|
286
|
+
requestId: requestId,
|
|
287
|
+
requestParams: requestParams,
|
|
288
|
+
pageNoKey: pageNoKey,
|
|
289
|
+
perPageKey: perPageKey,
|
|
290
|
+
pageSize: pageSize,
|
|
291
|
+
maxHeight: maxHeight,
|
|
292
|
+
searchQuery: searchQuery,
|
|
293
|
+
searchAttribute: searchAttribute,
|
|
294
|
+
responseFormatter: responseFormatter,
|
|
295
|
+
getUrlParams: getUrlParams,
|
|
296
|
+
serverListClassName: serverListClassName,
|
|
297
|
+
minPageNo: minPageNo
|
|
298
|
+
};
|
|
299
|
+
var inlineModalClasses = "RCB-form-el " + (showCreateCTA ? "RCB-dd-with-create" : "");
|
|
300
|
+
return /*#__PURE__*/_react["default"].createElement(_FormElementWrapper["default"], {
|
|
301
|
+
className: "RCB-dropdown ".concat(disabled ? "RCB-disabled" : "", " ").concat(className),
|
|
302
|
+
appearance: appearance
|
|
303
|
+
}, showLabel && /*#__PURE__*/_react["default"].createElement("label", {
|
|
304
|
+
className: "RCB-form-el-label",
|
|
305
|
+
htmlFor: name
|
|
306
|
+
}, label), /*#__PURE__*/_react["default"].createElement(_InlineModal["default"], {
|
|
307
|
+
className: inlineModalClasses,
|
|
308
|
+
ref: inlineModalRef,
|
|
309
|
+
halign: halign,
|
|
310
|
+
onModalStateChange: onModalStateChange
|
|
311
|
+
}, /*#__PURE__*/_react["default"].createElement(_InlineModal.InlineModalActivator, null, /*#__PURE__*/_react["default"].createElement(SelectionSummary, _extends({
|
|
312
|
+
selectedItems: selectedItems,
|
|
313
|
+
noSelectionLabel: noSelectionLabel,
|
|
314
|
+
multiSelect: multiSelect,
|
|
315
|
+
nameAttribute: nameAttribute
|
|
316
|
+
}, restProps, {
|
|
317
|
+
showClear: showClear,
|
|
318
|
+
clearSelectedItems: clearSelectedItems
|
|
319
|
+
}))), /*#__PURE__*/_react["default"].createElement(_InlineModal.InlineModalBody, null, showSearch && /*#__PURE__*/_react["default"].createElement("div", {
|
|
320
|
+
className: "RCB-dd-search"
|
|
321
|
+
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
322
|
+
className: "RCB-dd-search-icon"
|
|
323
|
+
}), /*#__PURE__*/_react["default"].createElement("input", {
|
|
324
|
+
type: "text",
|
|
325
|
+
className: "RCB-dd-search-ip",
|
|
326
|
+
placeholder: searchPlaceholder,
|
|
327
|
+
onChange: onSearchChange,
|
|
328
|
+
ref: searchIpRef,
|
|
329
|
+
"data-hj-allow": true
|
|
330
|
+
})), paginationType === "SERVER" ? /*#__PURE__*/_react["default"].createElement(_ServerPaginatedDDList["default"], _extends({}, commonAttributes, serverListAttrs, restProps)) : /*#__PURE__*/_react["default"].createElement(NormalList, _extends({}, commonAttributes, restProps, {
|
|
331
|
+
items: getFilteredOptions(options, searchQuery, nameAttribute)
|
|
332
|
+
})), showCreateCTA && /*#__PURE__*/_react["default"].createElement("div", {
|
|
333
|
+
className: "RCB-dd-create-cta",
|
|
334
|
+
onClick: onCreateCTAClick
|
|
335
|
+
}, createCTAComponent))));
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// const VALUE_SHAPE = PropTypes.shape({
|
|
339
|
+
// id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
340
|
+
// name: PropTypes.string
|
|
341
|
+
// });
|
|
342
|
+
|
|
343
|
+
Dropdown = /*#__PURE__*/(0, _react.forwardRef)(Dropdown);
|
|
344
|
+
Dropdown.propTypes = {
|
|
345
|
+
/** Pass any additional classNames to Dropdown component */
|
|
346
|
+
className: _propTypes["default"].string,
|
|
347
|
+
/** Pass infinite fixed list classname to Dropdown component */
|
|
348
|
+
serverListClassName: _propTypes["default"].string,
|
|
349
|
+
/** Horizontal alignment of the dropdown body */
|
|
350
|
+
halign: _propTypes["default"].oneOf(["left", "right"]),
|
|
351
|
+
/** Label for the dropdown element */
|
|
352
|
+
label: _propTypes["default"].string,
|
|
353
|
+
/** indicates whether to show or hide label */
|
|
354
|
+
showLabel: _propTypes["default"].bool,
|
|
355
|
+
/** Unique ID for the input element */
|
|
356
|
+
name: _propTypes["default"].string.isRequired,
|
|
357
|
+
/** Label for dropdown activator */
|
|
358
|
+
noSelectionLabel: _propTypes["default"].string,
|
|
359
|
+
/** Selection items list */
|
|
360
|
+
options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
361
|
+
id: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
362
|
+
name: _propTypes["default"].string
|
|
363
|
+
})),
|
|
364
|
+
/** array of selected item objects, only considered if onChange event is given */
|
|
365
|
+
value: _propTypes["default"].any,
|
|
366
|
+
/** array of default selected item objects */
|
|
367
|
+
defaultValue: _propTypes["default"].any,
|
|
368
|
+
onChange: _propTypes["default"].func,
|
|
369
|
+
/** pass true if dropdown has to be disabled */
|
|
370
|
+
disabled: _propTypes["default"].bool,
|
|
371
|
+
/* set to true if you want search ability for dropdown items */
|
|
372
|
+
showSearch: _propTypes["default"].bool,
|
|
373
|
+
/* placeholder to show in the search box */
|
|
374
|
+
searchPlaceholder: _propTypes["default"].string,
|
|
375
|
+
/** Is dropdown multi select or single select */
|
|
376
|
+
multiSelect: _propTypes["default"].bool,
|
|
377
|
+
/** ID attribute key to use when rendering the dropdown items, if the ID attribute is other than "id" */
|
|
378
|
+
idAttribute: _propTypes["default"].string,
|
|
379
|
+
/** name attribute key to use when rendering the dropdown items, if the name attribute is other than "name" */
|
|
380
|
+
nameAttribute: _propTypes["default"].string,
|
|
381
|
+
/** Add title attribute to list element for large data */
|
|
382
|
+
showClippedContentTitle: _propTypes["default"].bool,
|
|
383
|
+
/** Provide a custom element for rendering dropdown item */
|
|
384
|
+
DropdownItem: _propTypes["default"].oneOfType([_propTypes["default"].instanceOf(Element), _propTypes["default"].func]),
|
|
385
|
+
/** Pass true to show a create CTA at the end of the dropdown */
|
|
386
|
+
showCreateCTA: _propTypes["default"].bool,
|
|
387
|
+
/** Customize the create CTA HTML by passing a createCTAComponent */
|
|
388
|
+
createCTAComponent: _propTypes["default"].any,
|
|
389
|
+
/** Callback that gets called when Create CTA button is clicked */
|
|
390
|
+
onCreateCTAClick: _propTypes["default"].func,
|
|
391
|
+
/** Pass this component to customise the selection summary HTML.
|
|
392
|
+
* The array of selected item objects will be sent as props
|
|
393
|
+
*/
|
|
394
|
+
SelectionSummary: _propTypes["default"].func,
|
|
395
|
+
/** Define the appearance of the form element. Accepted values are either "inline" or "block" */
|
|
396
|
+
appearance: _propTypes["default"].oneOf(["inline", "block"]),
|
|
397
|
+
/** Array of validations to perform on the form element value.
|
|
398
|
+
* If the validation fails, you will get an "error" field in the form onSubmit event */
|
|
399
|
+
validations: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
400
|
+
type: _propTypes["default"].oneOf(["REQUIRED", "CUSTOM"]).isRequired,
|
|
401
|
+
message: _propTypes["default"].string.isRequired,
|
|
402
|
+
validator: _propTypes["default"].func
|
|
403
|
+
})),
|
|
404
|
+
/** Type of pagination for the dropdown list items. Send "SERVER" for server side pagination */
|
|
405
|
+
paginationType: _propTypes["default"].oneOf(["NONE", "SERVER"]),
|
|
406
|
+
/** If paginationType is "SERVER", pass the requestId for the server request */
|
|
407
|
+
requestId: function requestId(props, propName) {
|
|
408
|
+
if (props["paginationType"] == "SERVER" && (!props[propName] || typeof props[propName] === "undefined")) {
|
|
409
|
+
return new Error("Please provide a requestId for paginationType 'SERVER'!");
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
/** If paginationType is "SERVER", pass any additional params to be sent to the server request */
|
|
413
|
+
requestParams: _propTypes["default"].object,
|
|
414
|
+
/** If paginationType is "SERVER", pass the pageNo. attribute to be sent to the server request */
|
|
415
|
+
pageNoKey: _propTypes["default"].string,
|
|
416
|
+
/** If paginationType is "SERVER", pass the pageSize attribute to be sent to the server request */
|
|
417
|
+
perPageKey: _propTypes["default"].string,
|
|
418
|
+
/** If paginationType is "SERVER", max height of the dropdown container */
|
|
419
|
+
maxHeight: _propTypes["default"].number,
|
|
420
|
+
/** If paginationType is "SERVER", height of each dropdown item */
|
|
421
|
+
ddItemHeight: _propTypes["default"].number,
|
|
422
|
+
/** If paginationType is "SERVER", max number of items to show for one page in the dropdown container */
|
|
423
|
+
pageSize: _propTypes["default"].number,
|
|
424
|
+
/** Default page number to use for server paginated list */
|
|
425
|
+
minPageNo: _propTypes["default"].number,
|
|
426
|
+
/** If paginationType is "SERVER" & showSearch is true, pass the search attribute to be sent to the server request */
|
|
427
|
+
searchAttribute: _propTypes["default"].string,
|
|
428
|
+
/** If paginationType is "SERVER",
|
|
429
|
+
* component expects the response to be of the form
|
|
430
|
+
* { [pageNoKey]: <pageNo>, [perPageKey]: <pageSize>, total: <totalCount>, entries: [{}] }
|
|
431
|
+
* If your data is not in this format, use the responseFormatter to format the data to this structure.
|
|
432
|
+
* Input to this function is the response received from your API
|
|
433
|
+
* */
|
|
434
|
+
responseFormatter: _propTypes["default"].func,
|
|
435
|
+
/** If paginationType is "SERVER", function that is expected to return the URL Params object */
|
|
436
|
+
getUrlParams: _propTypes["default"].func,
|
|
437
|
+
/** Show the optional clear button for resetting selections */
|
|
438
|
+
showClear: _propTypes["default"].bool,
|
|
439
|
+
/** Custom on clear function */
|
|
440
|
+
onClear: _propTypes["default"].func,
|
|
441
|
+
/** Callback on query search in dropdown */
|
|
442
|
+
onSearchChange: _propTypes["default"].func,
|
|
443
|
+
/** List header Component */
|
|
444
|
+
ListHeaderItem: _propTypes["default"].string
|
|
445
|
+
};
|
|
446
|
+
Dropdown.defaultProps = {
|
|
447
|
+
className: "",
|
|
448
|
+
label: "",
|
|
449
|
+
showLabel: true,
|
|
450
|
+
showSearch: false,
|
|
451
|
+
searchPlaceholder: "Search",
|
|
452
|
+
searchAttribute: "search",
|
|
453
|
+
multiSelect: false,
|
|
454
|
+
idAttribute: "id",
|
|
455
|
+
nameAttribute: "name",
|
|
456
|
+
noSelectionLabel: "Select",
|
|
457
|
+
appearance: "inline",
|
|
458
|
+
halign: "left",
|
|
459
|
+
validations: [],
|
|
460
|
+
paginationType: "NONE",
|
|
461
|
+
pageNoKey: "page",
|
|
462
|
+
perPageKey: "count",
|
|
463
|
+
maxHeight: 200,
|
|
464
|
+
pageSize: 10,
|
|
465
|
+
getUrlParams: function getUrlParams() {
|
|
466
|
+
return {};
|
|
467
|
+
},
|
|
468
|
+
SelectionSummary: DefaultSelectionSummary,
|
|
469
|
+
showCreateCTA: false,
|
|
470
|
+
serverListClassName: "",
|
|
471
|
+
createCTAComponent: /*#__PURE__*/_react["default"].createElement("span", null, "Create New"),
|
|
472
|
+
onCreateCTAClick: function onCreateCTAClick() {},
|
|
473
|
+
showClear: false,
|
|
474
|
+
ListHeaderItem: "",
|
|
475
|
+
onClear: function onClear() {}
|
|
476
|
+
};
|
|
477
|
+
var _default = Dropdown;
|
|
478
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
function _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); }
|
|
16
|
+
var FileUploader = function FileUploader(props) {
|
|
17
|
+
var label = props.label,
|
|
18
|
+
name = props.name,
|
|
19
|
+
multiple = props.multiple,
|
|
20
|
+
accept = props.accept,
|
|
21
|
+
className = props.className,
|
|
22
|
+
appearance = props.appearance,
|
|
23
|
+
onChange = props.onChange,
|
|
24
|
+
children = props.children;
|
|
25
|
+
var _useContext = (0, _react.useContext)(_Form.FormContext),
|
|
26
|
+
onValueChange = _useContext.onValueChange;
|
|
27
|
+
var onFileChange = function onFileChange(event) {
|
|
28
|
+
var value = event.target.files;
|
|
29
|
+
if (typeof onChange === "function") {
|
|
30
|
+
onChange(value);
|
|
31
|
+
}
|
|
32
|
+
typeof onValueChange === "function" && onValueChange(name, value);
|
|
33
|
+
};
|
|
34
|
+
var inputProps = {
|
|
35
|
+
type: "file",
|
|
36
|
+
label: label,
|
|
37
|
+
name: name,
|
|
38
|
+
id: name,
|
|
39
|
+
multiple: multiple,
|
|
40
|
+
accept: accept,
|
|
41
|
+
className: "RCB-form-el",
|
|
42
|
+
onChange: onFileChange
|
|
43
|
+
};
|
|
44
|
+
return /*#__PURE__*/_react["default"].createElement(_FormElementWrapper["default"], {
|
|
45
|
+
className: className,
|
|
46
|
+
appearance: appearance
|
|
47
|
+
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
48
|
+
className: "RCB-form-el-label"
|
|
49
|
+
}, label), /*#__PURE__*/_react["default"].createElement("input", _extends({}, inputProps, {
|
|
50
|
+
className: "RCB-hidden"
|
|
51
|
+
})), /*#__PURE__*/_react["default"].createElement("label", {
|
|
52
|
+
htmlFor: name,
|
|
53
|
+
className: "RCB-file-input"
|
|
54
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
55
|
+
className: "RCB-no-pointer"
|
|
56
|
+
}, children)));
|
|
57
|
+
};
|
|
58
|
+
FileUploader.propTypes = {
|
|
59
|
+
/** Pass any additional classNames to Input component */
|
|
60
|
+
className: _propTypes["default"].string,
|
|
61
|
+
/** Label for the input element */
|
|
62
|
+
label: _propTypes["default"].string,
|
|
63
|
+
/** Unique ID for the input element */
|
|
64
|
+
name: _propTypes["default"].string.isRequired,
|
|
65
|
+
/** set to true to upload multiple files at once */
|
|
66
|
+
multiple: _propTypes["default"].bool,
|
|
67
|
+
/** mime type of the acceptable files */
|
|
68
|
+
accept: _propTypes["default"].string,
|
|
69
|
+
/** Define the appearance of the form element. Accepted values are either "inline" or "block" */
|
|
70
|
+
appearance: _propTypes["default"].oneOf(["inline", "block"]),
|
|
71
|
+
/** Becomes a controlled component if onChange function is given */
|
|
72
|
+
onChange: _propTypes["default"].func
|
|
73
|
+
};
|
|
74
|
+
FileUploader.defaultProps = {
|
|
75
|
+
className: "",
|
|
76
|
+
appearance: "inline",
|
|
77
|
+
multiple: false,
|
|
78
|
+
accept: "image/*"
|
|
79
|
+
};
|
|
80
|
+
var _default = FileUploader;
|
|
81
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,106 @@
|
|
|
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"] = exports.FormContext = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _dequal = _interopRequireDefault(require("dequal"));
|
|
11
|
+
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
|
+
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."); }
|
|
17
|
+
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
|
+
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; }
|
|
19
|
+
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; } }
|
|
20
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
+
var FormContext = /*#__PURE__*/(0, _react.createContext)({
|
|
22
|
+
onValueChange: function onValueChange() {}
|
|
23
|
+
});
|
|
24
|
+
exports.FormContext = FormContext;
|
|
25
|
+
var Form = function Form(props, ref) {
|
|
26
|
+
var _useState = (0, _react.useState)({}),
|
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
+
formData = _useState2[0],
|
|
29
|
+
setFormData = _useState2[1];
|
|
30
|
+
var _useState3 = (0, _react.useState)({}),
|
|
31
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
32
|
+
formErrors = _useState4[0],
|
|
33
|
+
setFormErrors = _useState4[1];
|
|
34
|
+
var _useState5 = (0, _react.useState)(0),
|
|
35
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
36
|
+
formRefreshCount = _useState6[0],
|
|
37
|
+
setFormRefreshCount = _useState6[1];
|
|
38
|
+
var className = props.className,
|
|
39
|
+
onChange = props.onChange,
|
|
40
|
+
onSubmit = props.onSubmit;
|
|
41
|
+
var dataRef = (0, _react.useRef)();
|
|
42
|
+
var getFormData = function getFormData() {
|
|
43
|
+
return {
|
|
44
|
+
data: formData,
|
|
45
|
+
errors: formErrors
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/* add methods that can be accessed via this component's ref */
|
|
50
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
|
51
|
+
return {
|
|
52
|
+
getFormData: getFormData
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
var onValueChange = function onValueChange(key, value, error) {
|
|
56
|
+
formData[key] = value;
|
|
57
|
+
setFormData(formData);
|
|
58
|
+
if (error) {
|
|
59
|
+
formErrors[key] = error;
|
|
60
|
+
} else {
|
|
61
|
+
/* remove the error value */
|
|
62
|
+
delete formErrors[key];
|
|
63
|
+
}
|
|
64
|
+
setFormErrors(formErrors);
|
|
65
|
+
setFormRefreshCount(formRefreshCount + 1);
|
|
66
|
+
};
|
|
67
|
+
var onFormSubmit = function onFormSubmit(event) {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
onSubmit(getFormData());
|
|
70
|
+
};
|
|
71
|
+
(0, _react.useEffect)(function () {
|
|
72
|
+
/*
|
|
73
|
+
As useEffect does not do a deep comparision on dependent props,
|
|
74
|
+
do a manual deep comparision to decide whether data changed
|
|
75
|
+
*/
|
|
76
|
+
if (typeof onChange === "function") {
|
|
77
|
+
var _formData = getFormData();
|
|
78
|
+
if (!(0, _dequal["default"])(_formData, dataRef.current)) {
|
|
79
|
+
dataRef.current = (0, _lodash["default"])(_formData);
|
|
80
|
+
onChange(_formData);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}, [formRefreshCount]);
|
|
84
|
+
return /*#__PURE__*/_react["default"].createElement("form", {
|
|
85
|
+
onSubmit: onFormSubmit,
|
|
86
|
+
className: className
|
|
87
|
+
}, /*#__PURE__*/_react["default"].createElement(FormContext.Provider, {
|
|
88
|
+
value: {
|
|
89
|
+
onValueChange: onValueChange
|
|
90
|
+
}
|
|
91
|
+
}, props.children));
|
|
92
|
+
};
|
|
93
|
+
Form = /*#__PURE__*/(0, _react.forwardRef)(Form);
|
|
94
|
+
Form.propTypes = {
|
|
95
|
+
/** Pass any additional classNames to Form component */
|
|
96
|
+
className: _propTypes["default"].string,
|
|
97
|
+
/** Pass a callback function to listen to changes on any of the form elements */
|
|
98
|
+
onChange: _propTypes["default"].func,
|
|
99
|
+
/** Pass a callback function to listen to form submit event */
|
|
100
|
+
onSubmit: _propTypes["default"].func
|
|
101
|
+
};
|
|
102
|
+
Form.defaultProps = {
|
|
103
|
+
className: ""
|
|
104
|
+
};
|
|
105
|
+
var _default = Form;
|
|
106
|
+
exports["default"] = _default;
|