@sproutsocial/racine 11.0.0-mixin-beta.0 → 11.0.1

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/lib/Menu/index.js CHANGED
@@ -66,9 +66,8 @@ export var MenuItem = function MenuItem(_ref) {
66
66
  selected = _ref.selected,
67
67
  disabled = _ref.disabled,
68
68
  indeterminate = _ref.indeterminate,
69
- active = _ref.active,
70
69
  labelProp = _ref.label,
71
- props = _objectWithoutPropertiesLoose(_ref, ["id", "index", "as", "children", "role", "elemBefore", "elemAfter", "value", "onKeyPress", "onClick", "selected", "disabled", "indeterminate", "active", "label"]);
70
+ props = _objectWithoutPropertiesLoose(_ref, ["id", "index", "as", "children", "role", "elemBefore", "elemAfter", "value", "onKeyPress", "onClick", "selected", "disabled", "indeterminate", "label"]);
72
71
 
73
72
  var _useContext = useContext(MenuContext),
74
73
  menuRole = _useContext.role,
@@ -106,6 +105,11 @@ export var MenuItem = function MenuItem(_ref) {
106
105
  var isHidden = filteredItems && !filteredItems.includes(index);
107
106
  var isFocused = index === selectionIndex;
108
107
  selectCallbacks.current[index] = onClick;
108
+
109
+ var _useState = useState(false),
110
+ keyPressed = _useState[0],
111
+ setKeyPressed = _useState[1];
112
+
109
113
  var isCheckboxOrRadio = [MENU_ITEM_ROLES.CHECKBOX, MENU_ITEM_ROLES.RADIO].includes(itemRole);
110
114
  var interactive = onClick || onKeyPress || [MENU_ITEM_ROLES.OPTION, MENU_ITEM_ROLES.MENUITEM, MENU_ITEM_ROLES.CHECKBOX, MENU_ITEM_ROLES.RADIO].includes(itemRole);
111
115
  /**
@@ -123,6 +127,13 @@ export var MenuItem = function MenuItem(_ref) {
123
127
  }
124
128
  }
125
129
  }, [ref, isCheckboxOrRadio]);
130
+ useEffect(function () {
131
+ if (filteredItems) {
132
+ setKeyPressed(true);
133
+ } else if (selectionIndex !== 0) {
134
+ setKeyPressed(true);
135
+ }
136
+ }, [selectionIndex, filteredItems]);
126
137
  var handleClick = useCallback(function (e) {
127
138
  var _menuRef$current;
128
139
 
@@ -173,7 +184,7 @@ export var MenuItem = function MenuItem(_ref) {
173
184
  return /*#__PURE__*/React.createElement(MenuItemContainer, _extends({
174
185
  "data-qa-menu-item": label
175
186
  }, props, {
176
- active: active || isFocused,
187
+ active: isFocused && keyPressed,
177
188
  id: id,
178
189
  "aria-label": labelProp,
179
190
  value: valueProp,
@@ -245,7 +256,6 @@ export var MenuGroup = function MenuGroup(_ref2) {
245
256
  color: "text.headline",
246
257
  _css: isDisabled && disabled
247
258
  }, title)), /*#__PURE__*/React.createElement(Box, _extends({}, props, {
248
- m: 300,
249
259
  p: 300,
250
260
  role: "group"
251
261
  }), children));
@@ -333,14 +343,14 @@ export var Menu = function Menu(_ref4) {
333
343
  descendants = _useDescendants[0],
334
344
  setDescendants = _useDescendants[1];
335
345
 
336
- var _useState = useState({
346
+ var _useState2 = useState({
337
347
  selectionIndex: 0,
338
348
  filterQuery: "",
339
349
  filteredItems: null,
340
350
  isFilterInputFocused: false
341
351
  }),
342
- state = _useState[0],
343
- setState = _useState[1];
352
+ state = _useState2[0],
353
+ setState = _useState2[1];
344
354
 
345
355
  var selectCallbacks = useRef([]);
346
356
  var menuRef = useRef(null);
@@ -396,9 +406,9 @@ export var MenuButton = function MenuButton(_ref5) {
396
406
  placement = _ref5$placement === void 0 ? "bottom" : _ref5$placement,
397
407
  props = _objectWithoutPropertiesLoose(_ref5, ["content", "popoutProps", "children", "onClick", "closeOnItemClick", "id", "placement"]);
398
408
 
399
- var _useState2 = useState(false),
400
- isOpen = _useState2[0],
401
- setIsOpen = _useState2[1];
409
+ var _useState3 = useState(false),
410
+ isOpen = _useState3[0],
411
+ setIsOpen = _useState3[1];
402
412
 
403
413
  var closePopout = useCallback(function () {
404
414
  return setIsOpen(false);
@@ -1,6 +1,6 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import Box from "../Box";
3
- import { disabled } from "../utils/mixins";
3
+ import { disabled, focusRing } from "../utils/mixins";
4
4
  export var MenuItemContainer = styled(Box).withConfig({
5
5
  displayName: "styles__MenuItemContainer",
6
6
  componentId: "fjvae4-0"
@@ -20,16 +20,16 @@ export var MenuItemContainer = styled(Box).withConfig({
20
20
  return "6px " + props.theme.space[300];
21
21
  }, function (props) {
22
22
  return css(["", ";"], props.theme.typography[200]);
23
+ }, function (props) {
24
+ return props.selected && !props.isCheckboxOrRadio && css(["font-weight:", ";"], function (props) {
25
+ return props.theme.fontWeights.semibold;
26
+ });
23
27
  }, function (props) {
24
28
  return props.active && !props.disabled && css(["color:", ";background-color:", ";.Icon-svg{color:", ";}"], function (props) {
25
29
  return props.theme.colors.text.inverse;
26
30
  }, props.theme.colors.listItem.background.selected, function (props) {
27
31
  return props.theme.colors.text.inverse;
28
32
  });
29
- }, function (props) {
30
- return props.selected && !props.isCheckboxOrRadio && css(["font-weight:", ";"], function (props) {
31
- return props.theme.fontWeights.semibold;
32
- });
33
33
  }, function (props) {
34
34
  return !props.disabled && css(["&:focus,&:hover{color:", ";background-color:", ";.Icon-svg{color:unset;}}"], function (props) {
35
35
  return props.theme.colors.text.body;
@@ -44,4 +44,4 @@ export var MenuItemContainer = styled(Box).withConfig({
44
44
  export var MenuItemsContainer = styled(Box).withConfig({
45
45
  displayName: "styles__MenuItemsContainer",
46
46
  componentId: "fjvae4-1"
47
- })(["list-style-type:none;outline:0;"]);
47
+ })(["list-style-type:none;&:focus{", "}"], focusRing);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/racine",
3
- "version": "11.0.0-mixin-beta.0",
3
+ "version": "11.0.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "__flow__",