@councilbox/councilbox-ui 2.0.52 → 2.0.54
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/dist/HOCs/overlayA11yStack.js +47 -0
- package/dist/HOCs/useA11yGuard.js +38 -0
- package/dist/HOCs/useDynamicStyles.js +18 -38
- package/dist/HOCs/useMenuNavigation.js +110 -0
- package/dist/HOCs/useOverlay.js +87 -0
- package/dist/HOCs/usePopoverPosition.js +228 -0
- package/dist/HOCs/useRipple.js +17 -35
- package/dist/HOCs/useWindowSize.js +24 -42
- package/dist/build-index.js +49 -99
- package/dist/components/1.Introduction.stories.mdx +1 -1
- package/dist/components/2.Changelog.stories.mdx +45 -0
- package/dist/components/3.Guide.stories.mdx +1 -1
- package/dist/components/Accordion/Accordion.css +7 -0
- package/dist/components/Accordion/Accordion.js +97 -102
- package/dist/components/Accordion/Accordion.stories.js +10 -12
- package/dist/components/Accordion/AccordionOld.js +32 -56
- package/dist/components/Accordion/DesignAccordion.stories.js +10 -21
- package/dist/components/Alert/Alert.js +55 -55
- package/dist/components/Alert/Alert.stories.js +10 -11
- package/dist/components/Avatar/Avatar.js +82 -74
- package/dist/components/Avatar/Avatar.stories.js +19 -23
- package/dist/components/Avatar/AvatarOld.js +46 -60
- package/dist/components/Avatar/DesignAvatar.stories.js +18 -26
- package/dist/components/Avatar/DesignAvatarText.stories.js +31 -40
- package/dist/components/AvatarGroup/AvatarGroup.js +7 -14
- package/dist/components/AvatarGroup/AvatarGroup.stories.js +6 -13
- package/dist/components/AvatarGroup/DesignAvatarGroup.stories.js +34 -45
- package/dist/components/Block/Block.css +3 -3
- package/dist/components/Block/Block.js +31 -45
- package/dist/components/Block/Block.stories.js +5 -12
- package/dist/components/Block/DesignBlock.stories.js +7 -13
- package/dist/components/Button/Button.js +44 -66
- package/dist/components/Button/Button.stories.js +8 -14
- package/dist/components/Button/button.css +1 -1
- package/dist/components/ButtonBasic/ButtonBasic.css +6 -1
- package/dist/components/ButtonBasic/ButtonBasic.js +96 -118
- package/dist/components/ButtonBasic/ButtonBasic.stories.js +14 -15
- package/dist/components/ButtonBasic/ButtonBasicOld.js +57 -77
- package/dist/components/Checkbox/Checkbox.css +6 -0
- package/dist/components/Checkbox/Checkbox.js +81 -100
- package/dist/components/Checkbox/Checkbox.stories.js +10 -11
- package/dist/components/Checkbox/CheckboxOld.js +19 -35
- package/dist/components/DragDrop/DragDrop.css +20 -9
- package/dist/components/DragDrop/DragDrop.js +80 -76
- package/dist/components/DragDrop/DragDrop.stories.js +9 -16
- package/dist/components/DrawerPanel/DesignDrawerPanel.js +35 -53
- package/dist/components/DrawerPanel/DrawerPanel.js +157 -146
- package/dist/components/DrawerPanel/DrawerPanel.stories.js +10 -12
- package/dist/components/DrawerPanel/DrawerPanelOld.js +76 -98
- package/dist/components/DropDown/DesignDropDown.stories.js +79 -97
- package/dist/components/DropDown/DropDown.js +168 -342
- package/dist/components/DropDown/DropDown.stories.js +6 -12
- package/dist/components/DropDown/DropDownOld.js +57 -89
- package/dist/components/DropDown/PopoverPlayground.js +68 -98
- package/dist/components/EnhancedTable/DesignEnhancedTable.stories.js +26 -36
- package/dist/components/EnhancedTable/EnhancedMyTable.js +16 -19
- package/dist/components/EnhancedTable/EnhancedTable.js +77 -136
- package/dist/components/EnhancedTable/EnhancedTable.stories.js +5 -12
- package/dist/components/EnhancedTable/EnhancedTableBody.js +11 -14
- package/dist/components/EnhancedTable/EnhancedTableCell.js +25 -34
- package/dist/components/EnhancedTable/EnhancedTableContainer.js +11 -14
- package/dist/components/EnhancedTable/EnhancedTableHead.js +11 -14
- package/dist/components/EnhancedTable/EnhancedTableRow.js +15 -18
- package/dist/components/EnhancedTable/EnhancedTableSortLabel.js +15 -18
- package/dist/components/FabButton/DesignFabButton.stories.js +9 -16
- package/dist/components/FabButton/FabButton.js +51 -54
- package/dist/components/FabButton/FabButton.stories.js +10 -12
- package/dist/components/Grid/DesignGrid.stories.js +7 -14
- package/dist/components/Grid/Grid.js +38 -46
- package/dist/components/Grid/Grid.stories.js +6 -13
- package/dist/components/Grid/GridItem.js +37 -39
- package/dist/components/Grid/GridItemOld.js +13 -18
- package/dist/components/Grid/GridOld.js +14 -21
- package/dist/components/Header/DesignHeader.stories.js +20 -24
- package/dist/components/Header/Header.js +201 -242
- package/dist/components/Header/Header.stories.js +9 -21
- package/dist/components/Header/header.css +10 -5
- package/dist/components/IconButton/DesignIconButton.stories.js +31 -36
- package/dist/components/IconButton/IconButton.css +6 -1
- package/dist/components/IconButton/IconButton.js +132 -138
- package/dist/components/IconButton/IconButton.stories.js +12 -13
- package/dist/components/IconButton/IconButtonOld.js +41 -57
- package/dist/components/IconButtonSquare/DesignIconButtonSquare.stories.js +5 -11
- package/dist/components/IconButtonSquare/IconButtonSquare.js +11 -25
- package/dist/components/IconButtonSquare/IconButtonSquare.stories.js +7 -13
- package/dist/components/IconButtonSquare/IconButtonSquareOld.js +44 -62
- package/dist/components/IconFont/IconFont.js +27 -48
- package/dist/components/IconFont/IconFont.stories.js +5 -11
- package/dist/components/InputAutocomplete/InputAutocomplete.css +6 -0
- package/dist/components/InputAutocomplete/InputAutocomplete.js +184 -260
- package/dist/components/InputAutocomplete/InputAutocomplete.stories.js +5 -11
- package/dist/components/InputAutocomplete/InputAutocompleteOld.js +43 -62
- package/dist/components/InputPassword/InputPassword.css +0 -6
- package/dist/components/InputPassword/InputPassword.js +58 -73
- package/dist/components/InputPassword/InputPassword.stories.js +5 -11
- package/dist/components/InputText/InputText.css +86 -78
- package/dist/components/InputText/InputText.js +207 -211
- package/dist/components/InputText/InputText.stories.js +11 -11
- package/dist/components/InputText/InputTextOld.js +48 -74
- package/dist/components/InputTextArea/DesignInputTextArea.stories.js +38 -51
- package/dist/components/InputTextArea/InputTextArea.js +84 -93
- package/dist/components/InputTextArea/InputTextArea.stories.js +5 -12
- package/dist/components/LoadingSection/LoadingSection.js +44 -51
- package/dist/components/LoadingSection/LoadingSection.stories.js +5 -11
- package/dist/components/MenuItem/DesignMenuItem.stories.js +20 -34
- package/dist/components/MenuItem/MenuItem.css +7 -2
- package/dist/components/MenuItem/MenuItem.js +100 -113
- package/dist/components/MenuItem/MenuItem.stories.js +6 -15
- package/dist/components/MenuItem/MenuItemOld.js +40 -56
- package/dist/components/MenuLateralLeft/MenuLateralLeft.css +24 -0
- package/dist/components/MenuLateralLeft/MenuLateralLeft.js +123 -160
- package/dist/components/MenuLateralLeft/MenuLateralLeft.stories.js +5 -12
- package/dist/components/MenuLateralRight/MenuLateralRight.css +2 -2
- package/dist/components/MenuLateralRight/MenuLateralRight.js +73 -77
- package/dist/components/MenuLateralRight/MenuLateralRight.stories.js +5 -12
- package/dist/components/Modal/DesignModal.stories.js +15 -30
- package/dist/components/Modal/Modal.css +35 -15
- package/dist/components/Modal/Modal.js +154 -145
- package/dist/components/Modal/Modal.stories.js +7 -16
- package/dist/components/Modal/ModalOld.js +73 -90
- package/dist/components/PaginationFooter/DesignPaginationFooter.stories.js +4 -10
- package/dist/components/PaginationFooter/PaginationFooter.css +10 -0
- package/dist/components/PaginationFooter/PaginationFooter.js +99 -91
- package/dist/components/PaginationFooter/PaginationFooter.stories.js +5 -12
- package/dist/components/RadioButton/Radio.css +19 -18
- package/dist/components/RadioButton/Radio.js +65 -83
- package/dist/components/RadioButton/Radio.stories.js +27 -36
- package/dist/components/RadioButton/RadioOld.js +23 -39
- package/dist/components/Ripple/DesignRipple.js +25 -41
- package/dist/components/Ripple/Ripple.stories.js +5 -11
- package/dist/components/Scrollbar/DesignScrollbar.js +5 -10
- package/dist/components/Scrollbar/Scrollbar.js +37 -56
- package/dist/components/Scrollbar/Scrollbar.stories.js +5 -12
- package/dist/components/SelectInput/DesignSelectInput.js +22 -45
- package/dist/components/SelectInput/SelectInput.js +101 -155
- package/dist/components/SelectInput/SelectInput.stories.js +6 -15
- package/dist/components/SelectInput/SelectInputOld.js +52 -81
- package/dist/components/Slider/DesignSlider.js +8 -14
- package/dist/components/Slider/Slider.css +57 -37
- package/dist/components/Slider/Slider.js +85 -84
- package/dist/components/Slider/Slider.stories.js +5 -12
- package/dist/components/Spacing/Spacing.js +38 -45
- package/dist/components/Spacing/Spacing.stories.js +5 -11
- package/dist/components/Stars/DesignStars.js +17 -30
- package/dist/components/Stars/Stars.css +55 -104
- package/dist/components/Stars/Stars.js +89 -73
- package/dist/components/Stars/Stars.stories.js +5 -12
- package/dist/components/Stepper/DesignStepper.stories.js +16 -30
- package/dist/components/Stepper/Stepper.css +46 -10
- package/dist/components/Stepper/Stepper.js +118 -134
- package/dist/components/Stepper/Stepper.stories.js +5 -12
- package/dist/components/Table/DesignTable.stories.js +200 -211
- package/dist/components/Table/Table.css +33 -2
- package/dist/components/Table/Table.js +30 -38
- package/dist/components/Table/Table.stories.js +5 -12
- package/dist/components/Table/TableBody.js +22 -34
- package/dist/components/Table/TableCell.js +71 -61
- package/dist/components/Table/TableContainer.js +22 -34
- package/dist/components/Table/TableHead.js +22 -34
- package/dist/components/Table/TableOld.js +52 -84
- package/dist/components/Table/TableRow.js +33 -37
- package/dist/components/Table/TableSortLabel.js +42 -52
- package/dist/components/Tabs/DesignTabs.js +14 -28
- package/dist/components/Tabs/Tabs.css +30 -11
- package/dist/components/Tabs/Tabs.js +151 -137
- package/dist/components/Tabs/Tabs.stories.js +5 -12
- package/dist/components/Tabs/TabsOld.js +28 -42
- package/dist/components/Tag/DesignTags.stories.js +24 -39
- package/dist/components/Tag/Tag.css +61 -42
- package/dist/components/Tag/Tag.js +93 -91
- package/dist/components/Tag/Tag.stories.js +5 -12
- package/dist/components/TextInput/TextInput.js +38 -54
- package/dist/components/TextInput/TextInput.stories.js +5 -11
- package/dist/components/ThemeProvider/Colors.js +2 -2
- package/dist/components/ThemeProvider/CouncilboxThemeContext.js +7 -10
- package/dist/components/ThemeProvider/ThemeProvider.js +34 -52
- package/dist/components/Timeline/DesignTimeline.stories.js +4 -10
- package/dist/components/Timeline/Timeline.js +66 -46
- package/dist/components/Timeline/Timeline.stories.js +5 -12
- package/dist/components/Toggle/Toggle.css +10 -0
- package/dist/components/Toggle/Toggle.js +115 -98
- package/dist/components/Toggle/Toggle.stories.js +10 -11
- package/dist/components/Tooltip/DesignTooltip.stories.js +10 -16
- package/dist/components/Tooltip/Tooltip.css +17 -1
- package/dist/components/Tooltip/Tooltip.js +190 -366
- package/dist/components/Tooltip/Tooltip.stories.js +5 -12
- package/dist/components/Typography/Typography.css +57 -6
- package/dist/components/Typography/Typography.js +44 -97
- package/dist/components/Typography/Typography.stories.js +5 -11
- package/dist/components/Typography/TypographyOld.js +29 -42
- package/dist/index.js +2 -6
- package/dist/reportWebVitals.js +8 -14
- package/dist/storybook.test.js +2 -4
- package/dist/styles/colorConsts.css +4 -4
- package/dist/styles/main.css +16 -0
- package/dist/styles/stylesheet.js +10 -22
- package/dist/testing/TestAutocomplete.js +74 -97
- package/dist/testing/TestComponents.js +5 -10
- package/dist/testing/TestDropdown.js +33 -41
- package/dist/utils/autoDetectScroll.js +12 -35
- package/dist/utils/index.js +37 -63
- package/dist/utils/useFallbackId.js +19 -0
- package/package.json +5 -2
|
@@ -1,122 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
7
|
+
exports["default"] = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
10
|
var _reactDom = require("react-dom");
|
|
13
|
-
|
|
14
11
|
require("../../styles/main.css");
|
|
15
|
-
|
|
16
12
|
require("./SelectInput.css");
|
|
17
|
-
|
|
18
13
|
var _InputText = _interopRequireDefault(require("../InputText/InputText"));
|
|
19
|
-
|
|
20
14
|
var _useDynamicStyles2 = _interopRequireDefault(require("../../HOCs/useDynamicStyles"));
|
|
21
|
-
|
|
22
15
|
var _utils = require("../../utils");
|
|
23
|
-
|
|
24
|
-
var _excluded = ["children", "onChange", "label", "value", "style", "sx", "multiple", "renderValue", "prefixClass", "fullWidth", "width", "disabled"];
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
|
-
|
|
36
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
37
|
-
|
|
16
|
+
var _useFallbackId = _interopRequireDefault(require("../../utils/useFallbackId"));
|
|
17
|
+
var _excluded = ["children", "onChange", "label", "value", "style", "sx", "multiple", "renderValue", "prefixClass", "fullWidth", "width", "disabled", "id"];
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
19
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) { ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } } return n; }, _extends.apply(null, arguments); }
|
|
20
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
23
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
24
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
25
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
38
26
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
43
|
-
|
|
44
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
45
|
-
|
|
27
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
28
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
29
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
46
30
|
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."); }
|
|
47
|
-
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
55
|
-
|
|
56
|
-
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; }
|
|
57
|
-
|
|
58
|
-
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; }
|
|
59
|
-
|
|
31
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
32
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; }
|
|
33
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
34
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
35
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) { o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } } return i; }
|
|
36
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) { if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } } return t; }
|
|
60
37
|
var SelectInput = function SelectInput(_ref) {
|
|
61
38
|
var children = _ref.children,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
39
|
+
onChange = _ref.onChange,
|
|
40
|
+
label = _ref.label,
|
|
41
|
+
value = _ref.value,
|
|
42
|
+
style = _ref.style,
|
|
43
|
+
sx = _ref.sx,
|
|
44
|
+
_ref$multiple = _ref.multiple,
|
|
45
|
+
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
46
|
+
_ref$renderValue = _ref.renderValue,
|
|
47
|
+
renderValue = _ref$renderValue === void 0 ? null : _ref$renderValue,
|
|
48
|
+
propPrefixClass = _ref.prefixClass,
|
|
49
|
+
fullWidth = _ref.fullWidth,
|
|
50
|
+
width = _ref.width,
|
|
51
|
+
disabled = _ref.disabled,
|
|
52
|
+
id = _ref.id,
|
|
53
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
77
54
|
var getDefaultValue = function getDefaultValue() {
|
|
78
55
|
if (value !== undefined) return value;
|
|
79
56
|
if (multiple) return [];
|
|
80
57
|
return '';
|
|
81
58
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
dynamicPrefixClass = _useDynamicStyles.prefixClass;
|
|
86
|
-
|
|
59
|
+
var _useDynamicStyles = (0, _useDynamicStyles2["default"])(sx),
|
|
60
|
+
stylesInLine = _useDynamicStyles.stylesInLine,
|
|
61
|
+
dynamicPrefixClass = _useDynamicStyles.prefixClass;
|
|
87
62
|
var prefixClass = propPrefixClass || dynamicPrefixClass;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
var dropdownRef = _react.default.useRef(null);
|
|
107
|
-
|
|
108
|
-
var optionContainerRef = _react.default.useRef(null);
|
|
109
|
-
|
|
63
|
+
var _React$useState = _react["default"].useState(false),
|
|
64
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
65
|
+
isOpen = _React$useState2[0],
|
|
66
|
+
setIsOpen = _React$useState2[1];
|
|
67
|
+
var _React$useState3 = _react["default"].useState(false),
|
|
68
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
69
|
+
isClosing = _React$useState4[0],
|
|
70
|
+
setIsClosing = _React$useState4[1];
|
|
71
|
+
var _React$useState5 = _react["default"].useState(getDefaultValue()),
|
|
72
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
73
|
+
internalValue = _React$useState6[0],
|
|
74
|
+
setInternalValue = _React$useState6[1];
|
|
75
|
+
var selectRef = _react["default"].useRef(null);
|
|
76
|
+
var dropdownRef = _react["default"].useRef(null);
|
|
77
|
+
var optionContainerRef = _react["default"].useRef(null);
|
|
78
|
+
var fallbackId = (0, _useFallbackId["default"])('cbx-selectInput-id');
|
|
79
|
+
var selectId = id || fallbackId;
|
|
80
|
+
var listboxId = "".concat(selectId, "-listbox");
|
|
110
81
|
var _useKeyItemNavigation = (0, _utils.useKeyItemNavigation)({
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
82
|
+
containerRef: optionContainerRef,
|
|
83
|
+
canLoop: false
|
|
84
|
+
}),
|
|
85
|
+
handleKeyDown = _useKeyItemNavigation.handleKeyDown;
|
|
116
86
|
if (width === '100%') {
|
|
117
87
|
fullWidth = true;
|
|
118
88
|
}
|
|
119
|
-
|
|
120
89
|
var closeDropdown = function closeDropdown() {
|
|
121
90
|
setIsClosing(true);
|
|
122
91
|
setTimeout(function () {
|
|
@@ -124,14 +93,11 @@ var SelectInput = function SelectInput(_ref) {
|
|
|
124
93
|
setIsClosing(false);
|
|
125
94
|
}, 150);
|
|
126
95
|
};
|
|
127
|
-
|
|
128
96
|
var handleOptionClick = function handleOptionClick(option, event) {
|
|
129
97
|
var optionValue = option.props.value;
|
|
130
98
|
var optionText = option.props.children;
|
|
131
|
-
|
|
132
99
|
if (multiple) {
|
|
133
100
|
var newSelected;
|
|
134
|
-
|
|
135
101
|
if (internalValue.some(function (opt) {
|
|
136
102
|
return opt.value === optionValue;
|
|
137
103
|
})) {
|
|
@@ -144,9 +110,7 @@ var SelectInput = function SelectInput(_ref) {
|
|
|
144
110
|
text: optionText
|
|
145
111
|
}]);
|
|
146
112
|
}
|
|
147
|
-
|
|
148
113
|
setInternalValue(newSelected);
|
|
149
|
-
|
|
150
114
|
if (onChange) {
|
|
151
115
|
onChange(_objectSpread(_objectSpread({}, event), {}, {
|
|
152
116
|
preventDefault: function preventDefault() {},
|
|
@@ -165,7 +129,6 @@ var SelectInput = function SelectInput(_ref) {
|
|
|
165
129
|
value: optionValue,
|
|
166
130
|
text: optionText
|
|
167
131
|
});
|
|
168
|
-
|
|
169
132
|
if (onChange) {
|
|
170
133
|
onChange(_objectSpread(_objectSpread({}, event), {}, {
|
|
171
134
|
preventDefault: function preventDefault() {},
|
|
@@ -175,15 +138,12 @@ var SelectInput = function SelectInput(_ref) {
|
|
|
175
138
|
}
|
|
176
139
|
}));
|
|
177
140
|
}
|
|
178
|
-
|
|
179
141
|
closeDropdown();
|
|
180
142
|
}
|
|
181
143
|
};
|
|
182
|
-
|
|
183
144
|
var updateDropdownPosition = function updateDropdownPosition() {
|
|
184
145
|
if (selectRef.current && dropdownRef.current) {
|
|
185
146
|
var _selectRef$current$cl;
|
|
186
|
-
|
|
187
147
|
var inputText = selectRef.current;
|
|
188
148
|
var inputRect = inputText.getBoundingClientRect();
|
|
189
149
|
var dropdownHeight = dropdownRef.current.offsetHeight;
|
|
@@ -198,40 +158,37 @@ var SelectInput = function SelectInput(_ref) {
|
|
|
198
158
|
dropdownRef.current.style.width = "".concat(inputRect.width, "px");
|
|
199
159
|
}
|
|
200
160
|
};
|
|
201
|
-
|
|
202
|
-
_react.default.useEffect(function () {
|
|
161
|
+
_react["default"].useEffect(function () {
|
|
203
162
|
updateDropdownPosition();
|
|
204
163
|
}, [isOpen]);
|
|
205
|
-
|
|
206
|
-
_react.default.useEffect(function () {
|
|
164
|
+
_react["default"].useEffect(function () {
|
|
207
165
|
var handleResize = function handleResize() {
|
|
208
166
|
if (isOpen) {
|
|
209
167
|
updateDropdownPosition();
|
|
210
168
|
}
|
|
211
169
|
};
|
|
212
|
-
|
|
213
170
|
window.addEventListener('resize', handleResize);
|
|
214
171
|
return function () {
|
|
215
172
|
window.removeEventListener('resize', handleResize);
|
|
216
173
|
};
|
|
217
174
|
}, [isOpen]);
|
|
218
|
-
|
|
219
175
|
var checkSelectedOptions = function checkSelectedOptions(optionValue) {
|
|
220
176
|
if (multiple) {
|
|
221
177
|
return (value === null || value === void 0 ? void 0 : value.includes(optionValue)) || (internalValue === null || internalValue === void 0 ? void 0 : internalValue.includes(optionValue));
|
|
222
178
|
}
|
|
223
|
-
|
|
224
179
|
return String(optionValue) === String(value !== undefined ? value : internalValue);
|
|
225
180
|
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if ( /*#__PURE__*/_react.default.isValidElement(child)) {
|
|
181
|
+
var enhancedChildren = _react["default"].Children.map(children, function (child, index) {
|
|
182
|
+
if (/*#__PURE__*/_react["default"].isValidElement(child)) {
|
|
229
183
|
var _dropdownRef$current;
|
|
230
|
-
|
|
231
|
-
return /*#__PURE__*/_react
|
|
184
|
+
var isSelected = checkSelectedOptions(child.props.value);
|
|
185
|
+
return /*#__PURE__*/_react["default"].cloneElement(child, {
|
|
232
186
|
key: child.key || "".concat(child.props.value, "-").concat(index),
|
|
233
|
-
|
|
234
|
-
|
|
187
|
+
id: "".concat(selectId, "-option-").concat(index),
|
|
188
|
+
role: 'option',
|
|
189
|
+
'aria-selected': isSelected,
|
|
190
|
+
active: isSelected,
|
|
191
|
+
selected: isSelected,
|
|
235
192
|
onClick: function onClick(event) {
|
|
236
193
|
return handleOptionClick(child, event);
|
|
237
194
|
},
|
|
@@ -240,43 +197,33 @@ var SelectInput = function SelectInput(_ref) {
|
|
|
240
197
|
className: "".concat(child.props.className || '', " ").concat(isOpen && ((_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : _dropdownRef$current.querySelector("[data-index=\"".concat(index, "\"]"))) === document.activeElement ? 'cbx-selectInput-option-focused' : '').trim()
|
|
241
198
|
});
|
|
242
199
|
}
|
|
243
|
-
|
|
244
200
|
return child;
|
|
245
201
|
});
|
|
246
|
-
|
|
247
202
|
var getSelectedOptions = function getSelectedOptions() {
|
|
248
203
|
var _React$Children$toArr;
|
|
249
|
-
|
|
250
204
|
if (multiple) {
|
|
251
|
-
return _react
|
|
205
|
+
return _react["default"].Children.toArray(children).reduce(function (acc, curr) {
|
|
252
206
|
if (checkSelectedOptions(curr.props.value)) {
|
|
253
207
|
acc.push(curr.props);
|
|
254
208
|
}
|
|
255
|
-
|
|
256
209
|
return acc;
|
|
257
210
|
}, []);
|
|
258
211
|
}
|
|
259
|
-
|
|
260
|
-
return ((_React$Children$toArr = _react.default.Children.toArray(children).find(function (child) {
|
|
212
|
+
return ((_React$Children$toArr = _react["default"].Children.toArray(children).find(function (child) {
|
|
261
213
|
return checkSelectedOptions(child.props.value);
|
|
262
214
|
})) === null || _React$Children$toArr === void 0 ? void 0 : _React$Children$toArr.props) || {};
|
|
263
215
|
};
|
|
264
|
-
|
|
265
216
|
var selectedOption = getSelectedOptions();
|
|
266
|
-
|
|
267
217
|
var getRenderValue = function getRenderValue() {
|
|
268
218
|
if (renderValue) {
|
|
269
219
|
return renderValue(value);
|
|
270
220
|
}
|
|
271
|
-
|
|
272
221
|
if (multiple && Array.isArray(selectedOption)) {
|
|
273
222
|
return value.join(', ');
|
|
274
223
|
}
|
|
275
|
-
|
|
276
224
|
return (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.children) || '';
|
|
277
225
|
};
|
|
278
|
-
|
|
279
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
226
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
280
227
|
className: prefixClass("cbx-selectInput-container ".concat(isOpen ? 'cbx-selectInput-container-open' : '', " ").concat(fullWidth ? 'cbx-selectInput-container-fullWidth' : '', " ").concat(disabled ? 'cbx-selectInput-container-disabled' : '')),
|
|
281
228
|
onClick: function onClick(e) {
|
|
282
229
|
e.preventDefault();
|
|
@@ -288,7 +235,7 @@ var SelectInput = function SelectInput(_ref) {
|
|
|
288
235
|
width: width !== '100%' && width
|
|
289
236
|
}, style), stylesInLine),
|
|
290
237
|
ref: selectRef
|
|
291
|
-
}, /*#__PURE__*/_react
|
|
238
|
+
}, /*#__PURE__*/_react["default"].createElement(_InputText["default"], _extends({
|
|
292
239
|
label: label,
|
|
293
240
|
renderValue: getRenderValue(),
|
|
294
241
|
value: getRenderValue(),
|
|
@@ -297,6 +244,11 @@ var SelectInput = function SelectInput(_ref) {
|
|
|
297
244
|
prefixClass: prefixClass,
|
|
298
245
|
fullWidth: fullWidth || width !== '100%',
|
|
299
246
|
disabled: disabled,
|
|
247
|
+
role: "combobox",
|
|
248
|
+
"aria-expanded": isOpen,
|
|
249
|
+
"aria-haspopup": "listbox",
|
|
250
|
+
"aria-controls": isOpen ? listboxId : undefined,
|
|
251
|
+
"aria-autocomplete": "none",
|
|
300
252
|
tabIndex: disabled ? -1 : 0
|
|
301
253
|
}, props, {
|
|
302
254
|
onFocus: function onFocus() {
|
|
@@ -304,74 +256,68 @@ var SelectInput = function SelectInput(_ref) {
|
|
|
304
256
|
},
|
|
305
257
|
onKeyDown: function onKeyDown(e) {
|
|
306
258
|
e.stopPropagation();
|
|
307
|
-
|
|
308
259
|
switch (e.key) {
|
|
309
260
|
case 'ArrowDown':
|
|
310
261
|
case 'ArrowUp':
|
|
311
262
|
setIsOpen(true);
|
|
312
263
|
handleKeyDown(e);
|
|
313
264
|
break;
|
|
314
|
-
|
|
315
265
|
case 'Enter':
|
|
316
266
|
case ' ':
|
|
317
267
|
if (!isOpen) {
|
|
318
268
|
setIsOpen(true);
|
|
319
269
|
} else {
|
|
320
270
|
var _optionContainerRef$c;
|
|
321
|
-
|
|
322
271
|
var activeOption = (_optionContainerRef$c = optionContainerRef.current) === null || _optionContainerRef$c === void 0 ? void 0 : _optionContainerRef$c.querySelector('.cbx-selectInput-option-focused');
|
|
323
|
-
|
|
324
272
|
if (activeOption) {
|
|
325
273
|
activeOption.click();
|
|
326
274
|
}
|
|
327
275
|
}
|
|
328
|
-
|
|
329
276
|
e.preventDefault();
|
|
330
277
|
break;
|
|
331
|
-
|
|
332
278
|
case 'Escape':
|
|
333
279
|
if (isOpen) closeDropdown();
|
|
334
280
|
break;
|
|
335
|
-
|
|
336
281
|
case 'Tab':
|
|
337
282
|
if (isOpen) closeDropdown();
|
|
338
283
|
break;
|
|
339
|
-
|
|
340
284
|
default:
|
|
341
285
|
break;
|
|
342
286
|
}
|
|
343
287
|
},
|
|
344
288
|
type: 'select'
|
|
345
|
-
})), isOpen && /*#__PURE__*/(0, _reactDom.createPortal)(
|
|
289
|
+
})), isOpen && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react["default"].createElement("div", {
|
|
346
290
|
className: prefixClass('cbx-selectInput-presentation'),
|
|
347
291
|
onKeyDown: handleKeyDown
|
|
348
|
-
}, /*#__PURE__*/_react
|
|
292
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
349
293
|
className: prefixClass('cbx-selectInput-backdrop'),
|
|
350
294
|
onClick: function onClick() {
|
|
351
295
|
closeDropdown();
|
|
352
296
|
}
|
|
353
|
-
}), /*#__PURE__*/_react
|
|
297
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
354
298
|
className: prefixClass("cbx-selectInput-options-container ".concat(isOpen && !isClosing ? 'cbx-selectInput-options-container-open' : 'cbx-selectInput-options-container-close')),
|
|
355
299
|
ref: dropdownRef
|
|
356
|
-
}, /*#__PURE__*/_react
|
|
300
|
+
}, /*#__PURE__*/_react["default"].createElement("ul", {
|
|
357
301
|
className: prefixClass('cbx-selectInput-options'),
|
|
358
|
-
ref: optionContainerRef
|
|
302
|
+
ref: optionContainerRef,
|
|
303
|
+
id: listboxId,
|
|
304
|
+
role: "listbox",
|
|
305
|
+
"aria-multiselectable": multiple || undefined
|
|
359
306
|
}, enhancedChildren))), document.body));
|
|
360
307
|
};
|
|
361
|
-
|
|
362
308
|
SelectInput.displayName = "SelectInput";
|
|
363
309
|
SelectInput.propTypes = {
|
|
364
|
-
label: _propTypes
|
|
365
|
-
width: _propTypes
|
|
366
|
-
id: _propTypes
|
|
367
|
-
className: _propTypes
|
|
368
|
-
onChange: _propTypes
|
|
369
|
-
disabled: _propTypes
|
|
370
|
-
children: _propTypes
|
|
371
|
-
helperText: _propTypes
|
|
372
|
-
error: _propTypes
|
|
373
|
-
helper: _propTypes
|
|
374
|
-
fullWidth: _propTypes
|
|
310
|
+
label: _propTypes["default"].string,
|
|
311
|
+
width: _propTypes["default"].string,
|
|
312
|
+
id: _propTypes["default"].string,
|
|
313
|
+
className: _propTypes["default"].string,
|
|
314
|
+
onChange: _propTypes["default"].func,
|
|
315
|
+
disabled: _propTypes["default"].bool,
|
|
316
|
+
children: _propTypes["default"].node,
|
|
317
|
+
helperText: _propTypes["default"].node,
|
|
318
|
+
error: _propTypes["default"].node,
|
|
319
|
+
helper: _propTypes["default"].node,
|
|
320
|
+
fullWidth: _propTypes["default"].bool
|
|
375
321
|
};
|
|
376
322
|
SelectInput.defaultProps = {
|
|
377
323
|
label: '',
|
|
@@ -387,4 +333,4 @@ SelectInput.defaultProps = {
|
|
|
387
333
|
fullWidth: false
|
|
388
334
|
};
|
|
389
335
|
var _default = SelectInput;
|
|
390
|
-
exports
|
|
336
|
+
exports["default"] = _default;
|
|
@@ -3,19 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
6
|
+
exports["default"] = exports.Success = exports.Helper = exports.ErrorTemplate = exports.Disabled = exports.DesignSelectInputTemplate = exports.Default = void 0;
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _SelectInput = _interopRequireDefault(require("./SelectInput"));
|
|
11
|
-
|
|
12
9
|
var _DesignSelectInput = _interopRequireDefault(require("./DesignSelectInput"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
16
11
|
var _default = {
|
|
17
12
|
title: 'Components/SelectInput',
|
|
18
|
-
component: _SelectInput
|
|
13
|
+
component: _SelectInput["default"],
|
|
19
14
|
argTypes: {
|
|
20
15
|
variant: {
|
|
21
16
|
options: ['outlined', 'filled', 'standard'],
|
|
@@ -39,12 +34,10 @@ var _default = {
|
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
36
|
};
|
|
42
|
-
exports
|
|
43
|
-
|
|
37
|
+
exports["default"] = _default;
|
|
44
38
|
var Template = function Template(args) {
|
|
45
|
-
return /*#__PURE__*/_react
|
|
39
|
+
return /*#__PURE__*/_react["default"].createElement(_SelectInput["default"], args);
|
|
46
40
|
};
|
|
47
|
-
|
|
48
41
|
Template.displayName = "Template";
|
|
49
42
|
var Default = Template.bind({});
|
|
50
43
|
exports.Default = Default;
|
|
@@ -79,11 +72,9 @@ ErrorTemplate.args = {
|
|
|
79
72
|
error: 'Error',
|
|
80
73
|
label: 'Example'
|
|
81
74
|
};
|
|
82
|
-
|
|
83
75
|
var TemplateSelectInput = function TemplateSelectInput(args) {
|
|
84
|
-
return /*#__PURE__*/_react
|
|
76
|
+
return /*#__PURE__*/_react["default"].createElement(_DesignSelectInput["default"], args);
|
|
85
77
|
};
|
|
86
|
-
|
|
87
78
|
TemplateSelectInput.displayName = "TemplateSelectInput";
|
|
88
79
|
var DesignSelectInputTemplate = TemplateSelectInput.bind({});
|
|
89
80
|
exports.DesignSelectInputTemplate = DesignSelectInputTemplate;
|