@sproutsocial/racine 12.22.0 → 12.23.0
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/CHANGELOG.md +12 -0
- package/README.md +2 -0
- package/__flow__/Avatar/__tests__/features.test.js +98 -0
- package/__flow__/Banner/index.js +2 -1
- package/__flow__/CharacterCounter/index.test.js +1 -1
- package/__flow__/Collapsible/index.js +2 -2
- package/__flow__/Drawer/index.js +11 -0
- package/__flow__/Drawer/index.stories.js +2 -1
- package/__flow__/EmptyState/index.test.js +1 -1
- package/__flow__/EnumIllustrationNames.js +1 -1
- package/__flow__/Fieldset/index.js +1 -1
- package/__flow__/IllustrationViewBoxes.js +1 -1
- package/__flow__/Indicator/index.js +1 -1
- package/__flow__/Input/index.js +2 -1
- package/__flow__/Link/index.js +2 -1
- package/__flow__/Link/index.test.js +2 -0
- package/__flow__/Listbox/index.stories.js +1 -0
- package/__flow__/Loader/index.js +1 -1
- package/__flow__/Modal/index.stories.js +1 -1
- package/__flow__/Numeral/tests/testNumeral.js +1 -0
- package/__flow__/Popout/index.js +1 -1
- package/__flow__/Portal/index.stories.js +7 -7
- package/__flow__/SegmentedControl/index.js +1 -1
- package/__flow__/SpotIllustration/illustrationNames.js +1 -0
- package/__flow__/SpotIllustration/spotIllustrations/campaign-tag.svg +6 -0
- package/__flow__/SpotIllustration/spotIllustrations/tag.svg +4 -4
- package/__flow__/Table/index.js +4 -4
- package/__flow__/TableCell/index.js +1 -1
- package/__flow__/TableHeaderCell/index.js +1 -1
- package/__flow__/Tabs/index.js +1 -1
- package/__flow__/Textarea/index.js +1 -1
- package/__flow__/Toast/index.js +1 -1
- package/__flow__/Toast/styles.js +1 -1
- package/__flow__/TokenInput/index.stories.js +4 -4
- package/__flow__/TokenInput/tests/default/pasting.test.js +6 -2
- package/__flow__/code-guidelines.mdx +244 -0
- package/__flow__/setupTests.js +1 -0
- package/__flow__/utils/a11yTest.js +1 -0
- package/__flow__/utils/system-props.js +1 -0
- package/commonjs/Avatar/index.js +19 -10
- package/commonjs/Badge/constants.js +3 -1
- package/commonjs/Badge/index.js +7 -3
- package/commonjs/Badge/styles.js +4 -2
- package/commonjs/Banner/index.js +9 -4
- package/commonjs/Banner/styles.js +5 -2
- package/commonjs/Box/index.js +5 -2
- package/commonjs/Box/styles.js +3 -1
- package/commonjs/Breadcrumb/index.js +12 -5
- package/commonjs/Breadcrumb/styles.js +3 -1
- package/commonjs/Button/index.js +7 -3
- package/commonjs/Button/styles.js +6 -3
- package/commonjs/Card/index.js +7 -3
- package/commonjs/Card/styles.js +3 -1
- package/commonjs/CharacterCounter/index.js +39 -22
- package/commonjs/CharacterCounter/styles.js +5 -2
- package/commonjs/ChartLegend/index.js +7 -3
- package/commonjs/ChartLegend/styles.js +5 -2
- package/commonjs/Checkbox/index.js +117 -97
- package/commonjs/Checkbox/styles.js +5 -2
- package/commonjs/Collapsible/index.js +27 -12
- package/commonjs/Collapsible/styles.js +4 -2
- package/commonjs/DatePicker/DateRangePicker.js +7 -3
- package/commonjs/DatePicker/SingleDatePicker.js +7 -3
- package/commonjs/DatePicker/StatefulDateRangePicker.js +19 -7
- package/commonjs/DatePicker/StatefulSingleDatePicker.js +16 -5
- package/commonjs/DatePicker/common.js +4 -2
- package/commonjs/DatePicker/index.js +15 -3
- package/commonjs/DatePicker/styles.js +5 -2
- package/commonjs/Drawer/SlideTransition.js +9 -5
- package/commonjs/Drawer/index.js +15 -7
- package/commonjs/Drawer/styles.js +5 -2
- package/commonjs/EmptyState/index.js +7 -3
- package/commonjs/Fieldset/index.js +10 -6
- package/commonjs/Fieldset/styles.js +5 -2
- package/commonjs/FormField/index.js +17 -6
- package/commonjs/Icon/deprecatedIcons.js +3 -1
- package/commonjs/Icon/index.js +9 -5
- package/commonjs/Icon/styles.js +6 -3
- package/commonjs/IllustrationViewBoxes.js +2 -1
- package/commonjs/Image/index.js +78 -58
- package/commonjs/Image/styles.js +5 -2
- package/commonjs/Indicator/index.js +40 -23
- package/commonjs/Indicator/styles.js +4 -2
- package/commonjs/Input/index.js +156 -132
- package/commonjs/Input/styles.js +5 -2
- package/commonjs/KeyboardKey/index.js +30 -14
- package/commonjs/KeyboardKey/styles.js +3 -1
- package/commonjs/Label/index.js +32 -16
- package/commonjs/Link/constants.js +3 -1
- package/commonjs/Link/index.js +9 -4
- package/commonjs/Link/styles.js +5 -2
- package/commonjs/Listbox/index.js +15 -8
- package/commonjs/Loader/index.js +43 -26
- package/commonjs/Loader/styles.js +5 -2
- package/commonjs/LoaderButton/index.js +7 -3
- package/commonjs/Menu/constants.js +3 -1
- package/commonjs/Menu/descendants.js +35 -20
- package/commonjs/Menu/hooks.js +8 -8
- package/commonjs/Menu/index.flow.js +2 -1
- package/commonjs/Menu/index.js +44 -27
- package/commonjs/Menu/names.js +3 -1
- package/commonjs/Menu/styles.js +6 -3
- package/commonjs/Message/index.js +7 -3
- package/commonjs/Message/styles.js +4 -2
- package/commonjs/Modal/index.js +9 -5
- package/commonjs/Modal/styles.js +9 -5
- package/commonjs/Numeral/constants.js +3 -1
- package/commonjs/Numeral/index.js +16 -5
- package/commonjs/Numeral/styles.js +3 -1
- package/commonjs/Numeral/tests/testNumeral.js +16 -11
- package/commonjs/OverflowList/index.flow.js +2 -1
- package/commonjs/OverflowList/index.js +6 -3
- package/commonjs/OverflowList/styles.js +5 -2
- package/commonjs/PartnerLogo/index.js +9 -6
- package/commonjs/PartnerLogo/styles.js +5 -2
- package/commonjs/Popout/index.js +28 -13
- package/commonjs/Popout/styles.js +3 -1
- package/commonjs/Portal/index.js +50 -30
- package/commonjs/Radio/index.js +73 -56
- package/commonjs/Radio/styles.js +5 -2
- package/commonjs/SegmentedControl/index.js +21 -9
- package/commonjs/SegmentedControl/styles.js +5 -2
- package/commonjs/Select/index.js +78 -61
- package/commonjs/Select/styles.js +8 -5
- package/commonjs/Skeleton/index.js +4 -2
- package/commonjs/SpotIllustration/illustrationNames.js +4 -2
- package/commonjs/SpotIllustration/index.js +5 -3
- package/commonjs/Stack/index.js +7 -3
- package/commonjs/Switch/index.js +52 -35
- package/commonjs/Switch/styles.js +6 -3
- package/commonjs/Table/index.js +14 -10
- package/commonjs/Table/styles.js +3 -1
- package/commonjs/TableCell/index.js +39 -23
- package/commonjs/TableCell/styles.js +3 -1
- package/commonjs/TableHeaderCell/index.js +54 -37
- package/commonjs/TableHeaderCell/styles.js +5 -2
- package/commonjs/TableRowAccordion/index.js +61 -44
- package/commonjs/TableRowAccordion/styles.js +5 -2
- package/commonjs/Tabs/index.js +116 -90
- package/commonjs/Tabs/styles.js +8 -5
- package/commonjs/Text/index.js +7 -3
- package/commonjs/Text/styles.js +5 -2
- package/commonjs/Textarea/index.js +104 -87
- package/commonjs/Textarea/styles.js +5 -2
- package/commonjs/ThemeProvider/index.js +5 -2
- package/commonjs/Toast/index.js +7 -8
- package/commonjs/Toast/styles.js +5 -2
- package/commonjs/ToggleHint/index.js +43 -26
- package/commonjs/ToggleHint/styles.js +6 -3
- package/commonjs/Token/index.js +7 -3
- package/commonjs/Token/styles.js +5 -2
- package/commonjs/TokenInput/index.js +221 -192
- package/commonjs/TokenInput/styles.js +5 -2
- package/commonjs/TokenInput/util.js +5 -3
- package/commonjs/Tooltip/index.js +30 -14
- package/commonjs/Tooltip/styles.js +3 -1
- package/commonjs/VisuallyHidden/index.js +3 -1
- package/commonjs/dataviz/index.js +3 -1
- package/commonjs/index.js +451 -84
- package/commonjs/systemProps/background.js +3 -1
- package/commonjs/systemProps/border.js +3 -1
- package/commonjs/systemProps/color.js +3 -1
- package/commonjs/systemProps/custom.js +3 -1
- package/commonjs/systemProps/flexbox.js +3 -1
- package/commonjs/systemProps/grid.js +3 -1
- package/commonjs/systemProps/index.js +87 -15
- package/commonjs/systemProps/layout.js +3 -1
- package/commonjs/systemProps/position.js +3 -1
- package/commonjs/systemProps/shadow.js +3 -1
- package/commonjs/systemProps/space.js +3 -1
- package/commonjs/systemProps/systemProps.js +3 -1
- package/commonjs/systemProps/typography.js +3 -1
- package/commonjs/systemProps/variant.js +3 -1
- package/commonjs/themes/dark/dataviz-palette.js +3 -1
- package/commonjs/themes/dark/decorative-palettes.js +3 -1
- package/commonjs/themes/dark/theme.js +11 -7
- package/commonjs/themes/extendedThemes/sproutTheme/dark/theme.js +9 -5
- package/commonjs/themes/extendedThemes/sproutTheme/index.js +15 -4
- package/commonjs/themes/extendedThemes/sproutTheme/light/theme.js +8 -4
- package/commonjs/themes/light/dataviz-palette.js +3 -1
- package/commonjs/themes/light/decorative-palettes.js +3 -1
- package/commonjs/themes/light/literal-colors.js +3 -1
- package/commonjs/themes/light/theme.js +17 -13
- package/commonjs/utils/a11yTest.js +5 -2
- package/commonjs/utils/chartColors.js +3 -1
- package/commonjs/utils/constants.js +3 -1
- package/commonjs/utils/dataQaLabelQueries.js +26 -16
- package/commonjs/utils/hooks.js +39 -26
- package/commonjs/utils/index.js +18 -8
- package/commonjs/utils/innerText.js +4 -2
- package/commonjs/utils/mixins.js +3 -1
- package/commonjs/utils/react-testing-library.js +74 -18
- package/commonjs/utils/responsiveProps/index.js +16 -8
- package/commonjs/utils/system-props.js +6 -2
- package/commonjs/utils/useInteractiveColor.js +3 -1
- package/dist/illustration.svg +1 -1
- package/dist/illustrationList.js +1 -1
- package/dist/themes/dark/theme.scss +0 -1
- package/dist/themes/extendedThemes/sproutTheme/dark/theme.scss +0 -1
- package/dist/themes/extendedThemes/sproutTheme/light/theme.scss +0 -1
- package/dist/themes/light/theme.scss +0 -1
- package/lib/Avatar/index.js +17 -11
- package/lib/Badge/index.js +5 -4
- package/lib/Badge/styles.js +3 -3
- package/lib/Banner/index.js +7 -5
- package/lib/Banner/styles.js +1 -1
- package/lib/Box/index.js +1 -1
- package/lib/Box/styles.js +1 -1
- package/lib/Breadcrumb/index.js +11 -7
- package/lib/Button/index.js +3 -2
- package/lib/Button/styles.js +4 -4
- package/lib/Card/index.js +3 -2
- package/lib/Card/styles.js +2 -2
- package/lib/CharacterCounter/index.js +36 -21
- package/lib/CharacterCounter/styles.js +1 -1
- package/lib/ChartLegend/index.js +5 -4
- package/lib/ChartLegend/styles.js +1 -1
- package/lib/Checkbox/index.js +114 -96
- package/lib/Checkbox/styles.js +5 -5
- package/lib/Collapsible/index.js +24 -12
- package/lib/Collapsible/styles.js +2 -2
- package/lib/DatePicker/DateRangePicker.js +4 -3
- package/lib/DatePicker/SingleDatePicker.js +4 -3
- package/lib/DatePicker/StatefulDateRangePicker.js +15 -6
- package/lib/DatePicker/StatefulSingleDatePicker.js +12 -4
- package/lib/DatePicker/common.js +3 -3
- package/lib/DatePicker/index.js +2 -2
- package/lib/DatePicker/styles.js +2 -2
- package/lib/Drawer/SlideTransition.js +4 -3
- package/lib/Drawer/index.js +17 -12
- package/lib/Drawer/styles.js +2 -2
- package/lib/EmptyState/index.js +4 -3
- package/lib/Fieldset/index.js +8 -7
- package/lib/Fieldset/styles.js +1 -1
- package/lib/FormField/index.js +17 -9
- package/lib/Icon/index.js +8 -7
- package/lib/Icon/styles.js +2 -2
- package/lib/IllustrationViewBoxes.js +2 -1
- package/lib/Image/index.js +75 -57
- package/lib/Image/styles.js +1 -1
- package/lib/Indicator/index.js +38 -23
- package/lib/Indicator/styles.js +3 -3
- package/lib/Input/index.js +157 -135
- package/lib/Input/styles.js +2 -2
- package/lib/KeyboardKey/index.js +28 -14
- package/lib/KeyboardKey/styles.js +1 -1
- package/lib/Label/index.js +29 -15
- package/lib/Link/index.js +5 -3
- package/lib/Link/styles.js +3 -3
- package/lib/Listbox/index.js +14 -10
- package/lib/Loader/index.js +40 -25
- package/lib/Loader/styles.js +2 -2
- package/lib/LoaderButton/index.js +5 -4
- package/lib/Menu/descendants.js +30 -18
- package/lib/Menu/hooks.js +7 -9
- package/lib/Menu/index.flow.js +4 -4
- package/lib/Menu/index.js +54 -40
- package/lib/Menu/styles.js +3 -3
- package/lib/Message/index.js +6 -5
- package/lib/Message/styles.js +4 -4
- package/lib/Modal/index.js +9 -8
- package/lib/Modal/styles.js +6 -5
- package/lib/Numeral/index.js +15 -7
- package/lib/Numeral/styles.js +1 -1
- package/lib/Numeral/tests/testNumeral.js +15 -11
- package/lib/OverflowList/index.js +3 -3
- package/lib/OverflowList/styles.js +1 -1
- package/lib/PartnerLogo/index.js +8 -7
- package/lib/PartnerLogo/styles.js +1 -1
- package/lib/Popout/index.js +27 -15
- package/lib/Popout/styles.js +1 -1
- package/lib/Portal/index.js +47 -29
- package/lib/Radio/index.js +70 -55
- package/lib/Radio/styles.js +3 -3
- package/lib/SegmentedControl/index.js +18 -9
- package/lib/SegmentedControl/styles.js +3 -3
- package/lib/Select/index.js +76 -61
- package/lib/Select/styles.js +5 -5
- package/lib/Skeleton/index.js +2 -2
- package/lib/SpotIllustration/illustrationNames.js +1 -1
- package/lib/SpotIllustration/index.js +3 -3
- package/lib/Stack/index.js +4 -3
- package/lib/Switch/index.js +51 -36
- package/lib/Switch/styles.js +4 -4
- package/lib/Table/index.js +12 -11
- package/lib/Table/styles.js +1 -1
- package/lib/TableCell/index.js +36 -22
- package/lib/TableCell/styles.js +1 -1
- package/lib/TableHeaderCell/index.js +52 -37
- package/lib/TableHeaderCell/styles.js +1 -1
- package/lib/TableRowAccordion/index.js +60 -45
- package/lib/TableRowAccordion/styles.js +1 -1
- package/lib/Tabs/index.js +113 -89
- package/lib/Tabs/styles.js +5 -5
- package/lib/Text/index.js +3 -2
- package/lib/Text/styles.js +1 -1
- package/lib/Textarea/index.js +101 -86
- package/lib/Textarea/styles.js +2 -2
- package/lib/ThemeProvider/index.js +1 -1
- package/lib/Toast/index.js +6 -10
- package/lib/Toast/styles.js +4 -3
- package/lib/ToggleHint/index.js +41 -26
- package/lib/ToggleHint/styles.js +3 -3
- package/lib/Token/index.js +6 -5
- package/lib/Token/styles.js +3 -3
- package/lib/TokenInput/index.js +223 -196
- package/lib/TokenInput/styles.js +2 -2
- package/lib/TokenInput/util.js +2 -2
- package/lib/Tooltip/index.js +28 -14
- package/lib/Tooltip/styles.js +1 -1
- package/lib/VisuallyHidden/index.js +1 -1
- package/lib/dataviz/index.js +1 -1
- package/lib/index.js +64 -64
- package/lib/systemProps/index.js +14 -14
- package/lib/systemProps/systemProps.js +12 -12
- package/lib/themes/dark/theme.js +11 -9
- package/lib/themes/extendedThemes/sproutTheme/dark/theme.js +7 -5
- package/lib/themes/extendedThemes/sproutTheme/index.js +2 -2
- package/lib/themes/extendedThemes/sproutTheme/light/theme.js +6 -4
- package/lib/themes/light/theme.js +17 -15
- package/lib/types/theme.colors.flow.js +2 -2
- package/lib/types/theme.flow.js +2 -2
- package/lib/utils/a11yTest.js +3 -1
- package/lib/utils/dataQaLabelQueries.js +23 -15
- package/lib/utils/hooks.js +37 -26
- package/lib/utils/index.js +15 -7
- package/lib/utils/innerText.js +1 -1
- package/lib/utils/mixins.js +1 -1
- package/lib/utils/react-testing-library.js +11 -8
- package/lib/utils/responsiveProps/index.js +14 -8
- package/lib/utils/system-props.js +1 -0
- package/package.json +16 -27
- package/__flow__/Avatar/index.test.js +0 -23
package/lib/Listbox/index.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
var _excluded = ["role", "children"],
|
|
2
2
|
_excluded2 = ["children"];
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
+
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; }
|
|
3
6
|
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); }
|
|
7
|
+
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; }
|
|
4
8
|
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; }
|
|
5
9
|
import * as React from 'react';
|
|
6
10
|
import styled, { css } from 'styled-components';
|
|
7
|
-
import Menu, { MenuButton } from
|
|
8
|
-
import { Arrow } from
|
|
9
|
-
import Icon from
|
|
10
|
-
import { MENU_ROLES } from
|
|
11
|
+
import Menu, { MenuButton } from "../Menu";
|
|
12
|
+
import { Arrow } from "../Select/styles";
|
|
13
|
+
import Icon from "../Icon";
|
|
14
|
+
import { MENU_ROLES } from "../Menu/constants";
|
|
11
15
|
export var Listbox = function Listbox(_ref) {
|
|
12
16
|
var _ref$role = _ref.role,
|
|
13
17
|
role = _ref$role === void 0 ? MENU_ROLES.LISTBOX : _ref$role,
|
|
14
18
|
children = _ref.children,
|
|
15
|
-
rest =
|
|
19
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
16
20
|
return /*#__PURE__*/React.createElement(Menu, _extends({}, rest, {
|
|
17
21
|
role: role
|
|
18
22
|
}), children);
|
|
@@ -50,12 +54,12 @@ export var ListboxButtonContainer = styled(MenuButton).withConfig({
|
|
|
50
54
|
}, function (props) {
|
|
51
55
|
switch (props.size) {
|
|
52
56
|
case 'large':
|
|
53
|
-
return props.theme.space[400]
|
|
57
|
+
return "".concat(props.theme.space[400], " ").concat(props.theme.space[600], " ").concat(props.theme.space[400], " ").concat(props.theme.space[400]);
|
|
54
58
|
case 'small':
|
|
55
|
-
return props.theme.space[200]
|
|
59
|
+
return "".concat(props.theme.space[200], " ").concat(props.theme.space[500], " ").concat(props.theme.space[200], " ").concat(props.theme.space[200]);
|
|
56
60
|
case 'default':
|
|
57
61
|
default:
|
|
58
|
-
return props.theme.space[300]
|
|
62
|
+
return "".concat(props.theme.space[300], " ").concat(props.theme.space[500], " ").concat(props.theme.space[300], " ").concat(props.theme.space[300]);
|
|
59
63
|
}
|
|
60
64
|
}, function (props) {
|
|
61
65
|
switch (props.size) {
|
|
@@ -75,9 +79,9 @@ export var ListboxButtonContainer = styled(MenuButton).withConfig({
|
|
|
75
79
|
});
|
|
76
80
|
export var ListboxButton = function ListboxButton(_ref2) {
|
|
77
81
|
var children = _ref2.children,
|
|
78
|
-
restProps =
|
|
82
|
+
restProps = _objectWithoutProperties(_ref2, _excluded2);
|
|
79
83
|
return /*#__PURE__*/React.createElement(ListboxButtonContainer, _extends({}, restProps, {
|
|
80
|
-
popoutProps:
|
|
84
|
+
popoutProps: _objectSpread({
|
|
81
85
|
placement: 'bottom-start'
|
|
82
86
|
}, restProps.popoutProps || {})
|
|
83
87
|
}), children, /*#__PURE__*/React.createElement(Arrow, {
|
package/lib/Loader/index.js
CHANGED
|
@@ -1,40 +1,55 @@
|
|
|
1
|
+
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); }
|
|
1
2
|
var _excluded = ["text", "size", "delay", "color", "qa"];
|
|
2
3
|
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); }
|
|
4
|
+
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; }
|
|
3
5
|
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; }
|
|
4
|
-
function
|
|
6
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
8
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
9
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
5
10
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
11
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
13
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
14
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
15
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
16
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
17
|
import * as React from 'react';
|
|
7
|
-
import Container, { Text } from
|
|
18
|
+
import Container, { Text } from "./styles";
|
|
8
19
|
var Loader = /*#__PURE__*/function (_React$Component) {
|
|
9
|
-
|
|
20
|
+
_inherits(Loader, _React$Component);
|
|
21
|
+
var _super = _createSuper(Loader);
|
|
10
22
|
function Loader() {
|
|
11
|
-
|
|
23
|
+
_classCallCheck(this, Loader);
|
|
24
|
+
return _super.apply(this, arguments);
|
|
12
25
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
_createClass(Loader, [{
|
|
27
|
+
key: "render",
|
|
28
|
+
value: function render() {
|
|
29
|
+
var _this$props = this.props,
|
|
30
|
+
text = _this$props.text,
|
|
31
|
+
size = _this$props.size,
|
|
32
|
+
delay = _this$props.delay,
|
|
33
|
+
color = _this$props.color,
|
|
34
|
+
qa = _this$props.qa,
|
|
35
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
36
|
+
return /*#__PURE__*/React.createElement(Container, _extends({
|
|
37
|
+
small: size === 'small',
|
|
38
|
+
dark: color === 'dark',
|
|
39
|
+
delay: delay,
|
|
40
|
+
"data-qa-loader": ""
|
|
41
|
+
}, qa, rest), /*#__PURE__*/React.createElement(Text, {
|
|
42
|
+
as: "div",
|
|
43
|
+
fontSize: 200
|
|
44
|
+
}, text || 'Loading'));
|
|
45
|
+
}
|
|
46
|
+
}]);
|
|
32
47
|
return Loader;
|
|
33
48
|
}(React.Component);
|
|
34
|
-
Loader
|
|
49
|
+
_defineProperty(Loader, "defaultProps", {
|
|
35
50
|
size: 'large',
|
|
36
51
|
text: '',
|
|
37
52
|
delay: true,
|
|
38
53
|
color: 'dark'
|
|
39
|
-
};
|
|
54
|
+
});
|
|
40
55
|
export { Loader as default };
|
package/lib/Loader/styles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import styled, { css, keyframes } from 'styled-components';
|
|
3
|
-
import { COMMON } from
|
|
4
|
-
import { visuallyHidden } from
|
|
3
|
+
import { COMMON } from "../utils/system-props";
|
|
4
|
+
import { visuallyHidden } from "../utils/mixins";
|
|
5
5
|
import { rgba } from 'polished';
|
|
6
6
|
var getSize = function getSize(size) {
|
|
7
7
|
var spinnerSize = Math.ceil(size * 0.9);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
var _excluded = ["appearance", "isLoading", "disabled", "loaderLabel", "children"];
|
|
2
2
|
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); }
|
|
3
|
+
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; }
|
|
3
4
|
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; }
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
import styled, { css } from 'styled-components';
|
|
6
|
-
import Box from
|
|
7
|
-
import Button from
|
|
8
|
-
import Loader from
|
|
7
|
+
import Box from "../Box";
|
|
8
|
+
import Button from "../Button";
|
|
9
|
+
import Loader from "../Loader";
|
|
9
10
|
import { useTheme } from 'styled-components';
|
|
10
11
|
import { rgba } from 'polished';
|
|
11
12
|
import { COLOR_NEUTRAL_0, COLOR_NEUTRAL_1000 } from '@sproutsocial/seeds-color';
|
|
@@ -52,7 +53,7 @@ export var LoaderButton = function LoaderButton(_ref) {
|
|
|
52
53
|
disabled = _ref.disabled,
|
|
53
54
|
loaderLabel = _ref.loaderLabel,
|
|
54
55
|
children = _ref.children,
|
|
55
|
-
rest =
|
|
56
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
56
57
|
var isLoading = Boolean(_isLoading);
|
|
57
58
|
var _useTheme = useTheme(),
|
|
58
59
|
themeColorMode = _useTheme.mode;
|
package/lib/Menu/descendants.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
var _excluded = ["context", "element"],
|
|
2
2
|
_excluded2 = ["element"];
|
|
3
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
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."); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
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; }
|
|
3
14
|
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; }
|
|
4
|
-
function
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
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; }
|
|
5
18
|
/* eslint-disable */
|
|
6
19
|
import * as React from 'react';
|
|
7
20
|
import { createContext, useState, useLayoutEffect, useEffect, useContext, useCallback, useMemo, useRef } from 'react';
|
|
@@ -52,11 +65,9 @@ export function createNamedContext(name, defaultValue) {
|
|
|
52
65
|
Ctx.displayName = name;
|
|
53
66
|
return Ctx;
|
|
54
67
|
}
|
|
55
|
-
export function createDescendantContext(name
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
return createNamedContext(name, _extends({
|
|
68
|
+
export function createDescendantContext(name) {
|
|
69
|
+
var initialValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
70
|
+
return createNamedContext(name, _objectSpread({
|
|
60
71
|
descendants: [],
|
|
61
72
|
registerDescendant: noop,
|
|
62
73
|
unregisterDescendant: noop
|
|
@@ -89,9 +100,10 @@ export function createDescendantContext(name, initialValue) {
|
|
|
89
100
|
export function useDescendant(_ref, indexProp) {
|
|
90
101
|
var context = _ref.context,
|
|
91
102
|
element = _ref.element,
|
|
92
|
-
rest =
|
|
103
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
93
104
|
var _useState = useState(),
|
|
94
|
-
|
|
105
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
106
|
+
forceUpdate = _useState2[1];
|
|
95
107
|
var _useContext = useContext(context),
|
|
96
108
|
registerDescendant = _useContext.registerDescendant,
|
|
97
109
|
unregisterDescendant = _useContext.unregisterDescendant,
|
|
@@ -100,13 +112,13 @@ export function useDescendant(_ref, indexProp) {
|
|
|
100
112
|
// Prevent any flashing
|
|
101
113
|
useIsomorphicLayoutEffect(function () {
|
|
102
114
|
if (!element) forceUpdate({});
|
|
103
|
-
registerDescendant(
|
|
115
|
+
registerDescendant(_objectSpread({
|
|
104
116
|
element: element
|
|
105
117
|
}, rest));
|
|
106
118
|
return function () {
|
|
107
119
|
return unregisterDescendant(element);
|
|
108
120
|
};
|
|
109
|
-
}, [element].concat(Object.values(rest)));
|
|
121
|
+
}, [element].concat(_toConsumableArray(Object.values(rest))));
|
|
110
122
|
return indexProp ? indexProp : descendants.findIndex(function (item) {
|
|
111
123
|
return item.element === element;
|
|
112
124
|
});
|
|
@@ -121,7 +133,7 @@ export function DescendantProvider(_ref2) {
|
|
|
121
133
|
set = _ref2.set;
|
|
122
134
|
var registerDescendant = useCallback(function (_ref3) {
|
|
123
135
|
var element = _ref3.element,
|
|
124
|
-
rest =
|
|
136
|
+
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
125
137
|
if (!element) {
|
|
126
138
|
return;
|
|
127
139
|
}
|
|
@@ -130,11 +142,11 @@ export function DescendantProvider(_ref2) {
|
|
|
130
142
|
var newItems;
|
|
131
143
|
// If there are no items, register at index 0 and bail.
|
|
132
144
|
if (items.length === 0) {
|
|
133
|
-
newItem =
|
|
145
|
+
newItem = _objectSpread({
|
|
134
146
|
element: element,
|
|
135
147
|
index: 0
|
|
136
148
|
}, rest);
|
|
137
|
-
newItems = [].concat(items, [newItem]);
|
|
149
|
+
newItems = [].concat(_toConsumableArray(items), [newItem]);
|
|
138
150
|
} else if (items.find(function (item) {
|
|
139
151
|
return item.element === element;
|
|
140
152
|
})) {
|
|
@@ -163,20 +175,20 @@ export function DescendantProvider(_ref2) {
|
|
|
163
175
|
// element.
|
|
164
176
|
return Boolean(item.element.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_PRECEDING);
|
|
165
177
|
});
|
|
166
|
-
newItem =
|
|
178
|
+
newItem = _objectSpread({
|
|
167
179
|
element: element,
|
|
168
180
|
index: index
|
|
169
181
|
}, rest);
|
|
170
182
|
|
|
171
183
|
// If an index is not found we will push the element to the end.
|
|
172
184
|
if (index === -1) {
|
|
173
|
-
newItems = [].concat(items, [newItem]);
|
|
185
|
+
newItems = [].concat(_toConsumableArray(items), [newItem]);
|
|
174
186
|
} else {
|
|
175
|
-
newItems = [].concat(items.slice(0, index), [newItem], items.slice(index));
|
|
187
|
+
newItems = [].concat(_toConsumableArray(items.slice(0, index)), [newItem], _toConsumableArray(items.slice(index)));
|
|
176
188
|
}
|
|
177
189
|
}
|
|
178
190
|
return newItems.map(function (item, index) {
|
|
179
|
-
return
|
|
191
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
180
192
|
index: index
|
|
181
193
|
});
|
|
182
194
|
});
|
|
@@ -195,7 +207,7 @@ export function DescendantProvider(_ref2) {
|
|
|
195
207
|
return items.filter(function (item) {
|
|
196
208
|
return element !== item.element;
|
|
197
209
|
}).map(function (item, index) {
|
|
198
|
-
return
|
|
210
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
199
211
|
index: index
|
|
200
212
|
});
|
|
201
213
|
});
|
package/lib/Menu/hooks.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import { createContext, useContext, useEffect } from 'react';
|
|
3
3
|
import scrollIntoViewIfNeeded from 'scroll-into-view-if-needed';
|
|
4
|
-
import { MENU_ROLES } from
|
|
5
|
-
import { createDescendantContext, useDescendantKeyDown, usePrevious, wrapEvent } from
|
|
4
|
+
import { MENU_ROLES } from "./constants";
|
|
5
|
+
import { createDescendantContext, useDescendantKeyDown, usePrevious, wrapEvent } from "./descendants";
|
|
6
6
|
export var MenuContext = /*#__PURE__*/createContext({
|
|
7
7
|
role: MENU_ROLES.MENU,
|
|
8
8
|
menuRef: {
|
|
@@ -33,17 +33,15 @@ export var MenuDescendantContext = createDescendantContext('MenuDescendantContex
|
|
|
33
33
|
* expected that the matching menu item is selected. This is our matching
|
|
34
34
|
* function.
|
|
35
35
|
*/
|
|
36
|
-
function filterItemsFromTypeahead(items
|
|
37
|
-
|
|
38
|
-
string = '';
|
|
39
|
-
}
|
|
36
|
+
function filterItemsFromTypeahead(items) {
|
|
37
|
+
var string = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
40
38
|
if (!string) {
|
|
41
39
|
return null;
|
|
42
40
|
}
|
|
43
41
|
return items.filter(function (_ref) {
|
|
44
42
|
var value = _ref.value,
|
|
45
43
|
label = _ref.label;
|
|
46
|
-
return (value
|
|
44
|
+
return (value === null || value === void 0 ? void 0 : value.toLowerCase().includes(string.toLocaleLowerCase())) || (label === null || label === void 0 ? void 0 : label.toLowerCase().includes(string.toLocaleLowerCase()));
|
|
47
45
|
}).map(function (_ref2) {
|
|
48
46
|
var index = _ref2.index;
|
|
49
47
|
return index;
|
|
@@ -94,7 +92,7 @@ export function useMenuKeyDown() {
|
|
|
94
92
|
}, [setState, items, prevMenuItemsLength, prevSelected, prevSelectionIndex, selectionIndex]);
|
|
95
93
|
useEffect(function () {
|
|
96
94
|
var newFilteredItems = filterItemsFromTypeahead(items, filterQuery);
|
|
97
|
-
if (filterQuery && newFilteredItems && (filteredItems
|
|
95
|
+
if (filterQuery && newFilteredItems && (filteredItems === null || filteredItems === void 0 ? void 0 : filteredItems.length) !== (newFilteredItems === null || newFilteredItems === void 0 ? void 0 : newFilteredItems.length)) {
|
|
98
96
|
setState({
|
|
99
97
|
filteredItems: newFilteredItems,
|
|
100
98
|
selectionIndex: newFilteredItems[0]
|
|
@@ -125,7 +123,7 @@ export function useMenuKeyDown() {
|
|
|
125
123
|
if (selected) {
|
|
126
124
|
event.preventDefault();
|
|
127
125
|
var func = selectCallbacks.current[selected.index];
|
|
128
|
-
(func
|
|
126
|
+
(func === null || func === void 0 ? void 0 : func.call) && func();
|
|
129
127
|
onChange && selected.value && onChange(selected.value);
|
|
130
128
|
shouldClosePopout && closePopout && closePopout();
|
|
131
129
|
}
|
package/lib/Menu/index.flow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import Box from
|
|
4
|
-
import Button from
|
|
5
|
-
import Popout from
|
|
6
|
-
import { MENU_ITEM_ROLES, MENU_ROLES } from
|
|
3
|
+
import Box from "../Box";
|
|
4
|
+
import Button from "../Button";
|
|
5
|
+
import Popout from "../Popout";
|
|
6
|
+
import { MENU_ITEM_ROLES, MENU_ROLES } from "./constants";
|
package/lib/Menu/index.js
CHANGED
|
@@ -4,27 +4,37 @@ var _excluded = ["id", "index", "as", "children", "role", "elemBefore", "elemAft
|
|
|
4
4
|
_excluded3 = ["children", "role", "multiselect", "innerRef"],
|
|
5
5
|
_excluded4 = ["role", "children", "onChange", "value", "multiselect", "innerRef"],
|
|
6
6
|
_excluded5 = ["content", "popoutProps", "children", "onClick", "closeOnItemClick", "id", "placement"];
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
|
+
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; }
|
|
7
10
|
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); }
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
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."); }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
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; }
|
|
8
18
|
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; }
|
|
9
19
|
import * as React from 'react';
|
|
10
20
|
import styled from 'styled-components';
|
|
11
21
|
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
12
22
|
import uniqueId from 'lodash.uniqueid';
|
|
13
|
-
import { MenuItemContainer, MenuItemsContainer } from
|
|
14
|
-
import { MENU_ITEM_ROLES, MENU_ROLES } from
|
|
15
|
-
import Box from
|
|
16
|
-
import Button from
|
|
17
|
-
import Checkbox from
|
|
18
|
-
import Icon from
|
|
19
|
-
import Input from
|
|
20
|
-
import Popout from
|
|
21
|
-
import Radio from
|
|
22
|
-
import Text from
|
|
23
|
-
import { disabled } from
|
|
24
|
-
import innerText from
|
|
25
|
-
import { useTextContent } from
|
|
26
|
-
import { DescendantProvider, useDescendant, useDescendants } from
|
|
27
|
-
import { MenuButtonContext, MenuContext, MenuDescendantContext, useMenuKeyDown } from
|
|
23
|
+
import { MenuItemContainer, MenuItemsContainer } from "./styles";
|
|
24
|
+
import { MENU_ITEM_ROLES, MENU_ROLES } from "./constants";
|
|
25
|
+
import Box from "../Box";
|
|
26
|
+
import Button from "../Button";
|
|
27
|
+
import Checkbox from "../Checkbox";
|
|
28
|
+
import Icon from "../Icon";
|
|
29
|
+
import Input from "../Input";
|
|
30
|
+
import Popout from "../Popout";
|
|
31
|
+
import Radio from "../Radio";
|
|
32
|
+
import Text from "../Text";
|
|
33
|
+
import { disabled } from "../utils/mixins";
|
|
34
|
+
import innerText from "../utils/innerText";
|
|
35
|
+
import { useTextContent } from "../utils/hooks";
|
|
36
|
+
import { DescendantProvider, useDescendant, useDescendants } from "./descendants";
|
|
37
|
+
import { MenuButtonContext, MenuContext, MenuDescendantContext, useMenuKeyDown } from "./hooks";
|
|
28
38
|
var noop = function noop() {};
|
|
29
39
|
var getMenuItemRole = function getMenuItemRole(menuRole) {
|
|
30
40
|
switch (menuRole) {
|
|
@@ -61,7 +71,7 @@ export var MenuItem = function MenuItem(_ref) {
|
|
|
61
71
|
disabled = _ref.disabled,
|
|
62
72
|
indeterminate = _ref.indeterminate,
|
|
63
73
|
labelProp = _ref.label,
|
|
64
|
-
props =
|
|
74
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
65
75
|
var _useContext = useContext(MenuContext),
|
|
66
76
|
menuRole = _useContext.role,
|
|
67
77
|
onChange = _useContext.onChange,
|
|
@@ -96,8 +106,9 @@ export var MenuItem = function MenuItem(_ref) {
|
|
|
96
106
|
var isFocused = index === selectionIndex;
|
|
97
107
|
selectCallbacks.current[index] = onClick;
|
|
98
108
|
var _useState = useState(false),
|
|
99
|
-
|
|
100
|
-
|
|
109
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
110
|
+
keyPressed = _useState2[0],
|
|
111
|
+
setKeyPressed = _useState2[1];
|
|
101
112
|
var isCheckboxOrRadio = [MENU_ITEM_ROLES.CHECKBOX, MENU_ITEM_ROLES.RADIO].includes(itemRole);
|
|
102
113
|
var interactive = onClick || onKeyPress || [MENU_ITEM_ROLES.OPTION, MENU_ITEM_ROLES.MENUITEM, MENU_ITEM_ROLES.CHECKBOX, MENU_ITEM_ROLES.RADIO].includes(itemRole);
|
|
103
114
|
|
|
@@ -123,7 +134,7 @@ export var MenuItem = function MenuItem(_ref) {
|
|
|
123
134
|
}, [selectionIndex, filteredItems]);
|
|
124
135
|
var handleClick = useCallback(function (e) {
|
|
125
136
|
var _menuRef$current;
|
|
126
|
-
(_menuRef$current = menuRef.current)
|
|
137
|
+
(_menuRef$current = menuRef.current) === null || _menuRef$current === void 0 ? void 0 : _menuRef$current.focus();
|
|
127
138
|
if (onChange && itemRole !== MENU_ITEM_ROLES.LISTITEM) {
|
|
128
139
|
onChange(valueProp || label);
|
|
129
140
|
}
|
|
@@ -134,7 +145,7 @@ export var MenuItem = function MenuItem(_ref) {
|
|
|
134
145
|
if (elemBefore) return elemBefore;
|
|
135
146
|
if (itemRole === MENU_ITEM_ROLES.CHECKBOX) {
|
|
136
147
|
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
137
|
-
id: "Checkbox-"
|
|
148
|
+
id: "Checkbox-".concat(id),
|
|
138
149
|
checked: isSelected,
|
|
139
150
|
"aria-hidden": "true",
|
|
140
151
|
onChange: noop,
|
|
@@ -143,8 +154,8 @@ export var MenuItem = function MenuItem(_ref) {
|
|
|
143
154
|
});
|
|
144
155
|
} else if (itemRole === MENU_ITEM_ROLES.RADIO) {
|
|
145
156
|
return /*#__PURE__*/React.createElement(Radio, {
|
|
146
|
-
id: "Radio-"
|
|
147
|
-
name: "Radio-"
|
|
157
|
+
id: "Radio-".concat(id),
|
|
158
|
+
name: "Radio-".concat(id),
|
|
148
159
|
checked: isSelected,
|
|
149
160
|
"aria-hidden": "true",
|
|
150
161
|
onChange: noop,
|
|
@@ -215,7 +226,7 @@ export var MenuGroup = function MenuGroup(_ref2) {
|
|
|
215
226
|
titleAs = _ref2.titleAs,
|
|
216
227
|
_ref2$disabled = _ref2.disabled,
|
|
217
228
|
isDisabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
218
|
-
props =
|
|
229
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
219
230
|
return /*#__PURE__*/React.createElement(React.Fragment, null, title && /*#__PURE__*/React.createElement(Box, {
|
|
220
231
|
pl: 400,
|
|
221
232
|
borderTop: "1px solid",
|
|
@@ -278,7 +289,7 @@ var MenuItems = function MenuItems(_ref3) {
|
|
|
278
289
|
role = _ref3.role,
|
|
279
290
|
multiselect = _ref3.multiselect,
|
|
280
291
|
innerRef = _ref3.innerRef,
|
|
281
|
-
props =
|
|
292
|
+
props = _objectWithoutProperties(_ref3, _excluded3);
|
|
282
293
|
var _useMenuKeyDown = useMenuKeyDown(),
|
|
283
294
|
handleKeyDown = _useMenuKeyDown.handleKeyDown,
|
|
284
295
|
activeDescendent = _useMenuKeyDown.activeDescendent;
|
|
@@ -286,7 +297,7 @@ var MenuItems = function MenuItems(_ref3) {
|
|
|
286
297
|
forwardedAs: "ul",
|
|
287
298
|
ref: innerRef,
|
|
288
299
|
role: role,
|
|
289
|
-
"aria-activedescendant": activeDescendent
|
|
300
|
+
"aria-activedescendant": activeDescendent === null || activeDescendent === void 0 ? void 0 : activeDescendent.id,
|
|
290
301
|
"aria-multiselectable": multiselect ? true : undefined,
|
|
291
302
|
tabIndex: 0,
|
|
292
303
|
onKeyDown: handleKeyDown,
|
|
@@ -303,22 +314,24 @@ export var Menu = function Menu(_ref4) {
|
|
|
303
314
|
value = _ref4.value,
|
|
304
315
|
multiselect = _ref4.multiselect,
|
|
305
316
|
innerRef = _ref4.innerRef,
|
|
306
|
-
props =
|
|
317
|
+
props = _objectWithoutProperties(_ref4, _excluded4);
|
|
307
318
|
var _useDescendants = useDescendants(),
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
319
|
+
_useDescendants2 = _slicedToArray(_useDescendants, 2),
|
|
320
|
+
descendants = _useDescendants2[0],
|
|
321
|
+
setDescendants = _useDescendants2[1];
|
|
322
|
+
var _useState3 = useState({
|
|
311
323
|
selectionIndex: 0,
|
|
312
324
|
filterQuery: '',
|
|
313
325
|
filteredItems: null,
|
|
314
326
|
isFilterInputFocused: false
|
|
315
327
|
}),
|
|
316
|
-
|
|
317
|
-
|
|
328
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
329
|
+
state = _useState4[0],
|
|
330
|
+
setState = _useState4[1];
|
|
318
331
|
var selectCallbacks = useRef([]);
|
|
319
332
|
var menuRef = useRef(null);
|
|
320
333
|
var setContextState = useCallback(function (newState) {
|
|
321
|
-
setState(
|
|
334
|
+
setState(_objectSpread(_objectSpread({}, state), newState));
|
|
322
335
|
}, [state]);
|
|
323
336
|
return (
|
|
324
337
|
/*#__PURE__*/
|
|
@@ -373,15 +386,16 @@ export var MenuButton = function MenuButton(_ref5) {
|
|
|
373
386
|
id = _ref5$id === void 0 ? uniqueId('MenuButton-') : _ref5$id,
|
|
374
387
|
_ref5$placement = _ref5.placement,
|
|
375
388
|
placement = _ref5$placement === void 0 ? 'bottom' : _ref5$placement,
|
|
376
|
-
props =
|
|
377
|
-
var
|
|
378
|
-
|
|
379
|
-
|
|
389
|
+
props = _objectWithoutProperties(_ref5, _excluded5);
|
|
390
|
+
var _useState5 = useState(false),
|
|
391
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
392
|
+
isOpen = _useState6[0],
|
|
393
|
+
setIsOpen = _useState6[1];
|
|
380
394
|
var closePopout = useCallback(function () {
|
|
381
395
|
return setIsOpen(false);
|
|
382
396
|
}, [setIsOpen]);
|
|
383
|
-
var ariaLabelledBy = props['aria-labelledby'] ? props['aria-labelledby']
|
|
384
|
-
var ariaLabel = props['aria-label'] ? props['aria-label']
|
|
397
|
+
var ariaLabelledBy = props['aria-labelledby'] ? "".concat(props['aria-labelledby'], " ").concat(id) : undefined;
|
|
398
|
+
var ariaLabel = props['aria-label'] ? "".concat(props['aria-label'], " ").concat(innerText(children)) : undefined;
|
|
385
399
|
return /*#__PURE__*/React.createElement(MenuButtonContext.Provider, {
|
|
386
400
|
value: {
|
|
387
401
|
closePopout: closePopout,
|
|
@@ -397,8 +411,8 @@ export var MenuButton = function MenuButton(_ref5) {
|
|
|
397
411
|
width: props.width
|
|
398
412
|
}), /*#__PURE__*/React.createElement(Button, _extends({}, props, {
|
|
399
413
|
id: id,
|
|
400
|
-
"aria-labelledby": ariaLabelledBy
|
|
401
|
-
"aria-label": ariaLabel
|
|
414
|
+
"aria-labelledby": ariaLabelledBy === null || ariaLabelledBy === void 0 ? void 0 : ariaLabelledBy.trim(),
|
|
415
|
+
"aria-label": ariaLabel === null || ariaLabel === void 0 ? void 0 : ariaLabel.trim(),
|
|
402
416
|
active: isOpen,
|
|
403
417
|
onKeyDown: function onKeyDown(e) {
|
|
404
418
|
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
package/lib/Menu/styles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
|
-
import Box from
|
|
4
|
-
import { disabled, focusRing } from
|
|
3
|
+
import Box from "../Box";
|
|
4
|
+
import { disabled, focusRing } from "../utils/mixins";
|
|
5
5
|
export var MenuItemContainer = styled(Box).withConfig({
|
|
6
6
|
displayName: "styles__MenuItemContainer",
|
|
7
7
|
componentId: "sc-fjvae4-0"
|
|
@@ -18,7 +18,7 @@ export var MenuItemContainer = styled(Box).withConfig({
|
|
|
18
18
|
}, function (props) {
|
|
19
19
|
return props.theme.fontWeights.normal;
|
|
20
20
|
}, function (props) {
|
|
21
|
-
return "6px "
|
|
21
|
+
return "6px ".concat(props.theme.space[300]);
|
|
22
22
|
}, function (props) {
|
|
23
23
|
return css(["", ";"], props.theme.typography[200]);
|
|
24
24
|
}, function (props) {
|
package/lib/Message/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
var _excluded = ["children", "density", "borderColor", "bg", "indentContent", "innerRef", "qa"];
|
|
2
2
|
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); }
|
|
3
|
+
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; }
|
|
3
4
|
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; }
|
|
4
5
|
import * as React from 'react';
|
|
5
|
-
import Container, { MessageBody, MessageFooter, MessageHeader, MessageMeta } from
|
|
6
|
-
import Checkbox from
|
|
7
|
-
import Button from
|
|
8
|
-
import Avatar from
|
|
6
|
+
import Container, { MessageBody, MessageFooter, MessageHeader, MessageMeta } from "./styles";
|
|
7
|
+
import Checkbox from "../Checkbox";
|
|
8
|
+
import Button from "../Button";
|
|
9
|
+
import Avatar from "../Avatar";
|
|
9
10
|
var MESSAGE_DENSITIES = {
|
|
10
11
|
COMPACT: 'compact',
|
|
11
12
|
// Compact is deprecated. New applications should use condensed instead.
|
|
@@ -45,7 +46,7 @@ var Message = function Message(_ref) {
|
|
|
45
46
|
indentContent = _ref$indentContent === void 0 ? true : _ref$indentContent,
|
|
46
47
|
innerRef = _ref.innerRef,
|
|
47
48
|
qa = _ref.qa,
|
|
48
|
-
rest =
|
|
49
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
49
50
|
return /*#__PURE__*/React.createElement(MessageContext.Provider, {
|
|
50
51
|
value: {
|
|
51
52
|
density: density,
|