intergalactic 15.60.1 → 15.61.0-prerelease.0-prerelease-07b38ef0

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.
Files changed (123) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/base-trigger/lib/cjs/BaseTrigger.js +18 -18
  3. package/base-trigger/lib/cjs/ButtonTrigger.js +3 -3
  4. package/base-trigger/lib/cjs/FilterTrigger.js +7 -7
  5. package/base-trigger/lib/cjs/LinkTrigger.js +12 -12
  6. package/base-trigger/lib/es6/BaseTrigger.js +18 -18
  7. package/base-trigger/lib/es6/ButtonTrigger.js +3 -3
  8. package/base-trigger/lib/es6/FilterTrigger.js +7 -7
  9. package/base-trigger/lib/es6/LinkTrigger.js +12 -12
  10. package/d3-chart/lib/cjs/Area.js +11 -11
  11. package/d3-chart/lib/cjs/Axis.js +14 -14
  12. package/d3-chart/lib/cjs/Bar.js +10 -10
  13. package/d3-chart/lib/cjs/Bubble.js +12 -12
  14. package/d3-chart/lib/cjs/Donut.js +9 -9
  15. package/d3-chart/lib/cjs/Dots.js +8 -8
  16. package/d3-chart/lib/cjs/HorizontalBar.js +10 -10
  17. package/d3-chart/lib/cjs/Hover.js +3 -3
  18. package/d3-chart/lib/cjs/Line.js +9 -9
  19. package/d3-chart/lib/cjs/Plot.js +3 -3
  20. package/d3-chart/lib/cjs/Radar.js +19 -19
  21. package/d3-chart/lib/cjs/RadialTree.js +11 -11
  22. package/d3-chart/lib/cjs/ReferenceLine.js +9 -9
  23. package/d3-chart/lib/cjs/ScatterPlot.js +9 -9
  24. package/d3-chart/lib/cjs/Tooltip.js +9 -9
  25. package/d3-chart/lib/cjs/Venn.js +9 -9
  26. package/d3-chart/lib/cjs/a11y/PlotA11yModule.js +2 -2
  27. package/d3-chart/lib/cjs/a11y/PlotA11yView.js +2 -2
  28. package/d3-chart/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
  29. package/d3-chart/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js +17 -17
  30. package/d3-chart/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js +6 -6
  31. package/d3-chart/lib/es6/Area.js +11 -11
  32. package/d3-chart/lib/es6/Axis.js +14 -14
  33. package/d3-chart/lib/es6/Bar.js +10 -10
  34. package/d3-chart/lib/es6/Bubble.js +12 -12
  35. package/d3-chart/lib/es6/Donut.js +9 -9
  36. package/d3-chart/lib/es6/Dots.js +8 -8
  37. package/d3-chart/lib/es6/HorizontalBar.js +10 -10
  38. package/d3-chart/lib/es6/Hover.js +3 -3
  39. package/d3-chart/lib/es6/Line.js +9 -9
  40. package/d3-chart/lib/es6/Plot.js +3 -3
  41. package/d3-chart/lib/es6/Radar.js +19 -19
  42. package/d3-chart/lib/es6/RadialTree.js +11 -11
  43. package/d3-chart/lib/es6/ReferenceLine.js +9 -9
  44. package/d3-chart/lib/es6/ScatterPlot.js +9 -9
  45. package/d3-chart/lib/es6/Tooltip.js +9 -9
  46. package/d3-chart/lib/es6/Venn.js +9 -9
  47. package/d3-chart/lib/es6/a11y/PlotA11yModule.js +2 -2
  48. package/d3-chart/lib/es6/a11y/PlotA11yView.js +2 -2
  49. package/d3-chart/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
  50. package/d3-chart/lib/es6/component/ChartLegend/LegendItem/LegendItem.js +17 -17
  51. package/d3-chart/lib/es6/component/ChartLegend/LegendTable/LegendTable.js +6 -6
  52. package/date-picker/lib/cjs/components/Calendar.js +21 -21
  53. package/date-picker/lib/cjs/components/DateRangeComparatorAbstract.js +26 -26
  54. package/date-picker/lib/cjs/components/InputTrigger.js +26 -26
  55. package/date-picker/lib/cjs/components/PickerAbstract.js +26 -26
  56. package/date-picker/lib/cjs/components/RangePickerAbstract.js +26 -26
  57. package/date-picker/lib/es6/components/Calendar.js +21 -21
  58. package/date-picker/lib/es6/components/DateRangeComparatorAbstract.js +26 -26
  59. package/date-picker/lib/es6/components/InputTrigger.js +26 -26
  60. package/date-picker/lib/es6/components/PickerAbstract.js +26 -26
  61. package/date-picker/lib/es6/components/RangePickerAbstract.js +26 -26
  62. package/dropdown/lib/cjs/Dropdown.js +2 -2
  63. package/dropdown/lib/es6/Dropdown.js +2 -2
  64. package/dropdown-menu/index.d.ts +9 -0
  65. package/dropdown-menu/lib/cjs/DropdownMenu.js +311 -95
  66. package/dropdown-menu/lib/cjs/DropdownMenu.js.map +1 -1
  67. package/dropdown-menu/lib/cjs/index.d.js.map +1 -1
  68. package/dropdown-menu/lib/cjs/style/dropdown-menu.shadow.css +20 -1
  69. package/dropdown-menu/lib/cjs/styleScrollArea.js +6 -6
  70. package/dropdown-menu/lib/es6/DropdownMenu.js +316 -97
  71. package/dropdown-menu/lib/es6/DropdownMenu.js.map +1 -1
  72. package/dropdown-menu/lib/es6/index.d.js.map +1 -1
  73. package/dropdown-menu/lib/es6/style/dropdown-menu.shadow.css +20 -1
  74. package/dropdown-menu/lib/es6/styleScrollArea.js +6 -6
  75. package/dropdown-menu/lib/types/index.d.ts +9 -0
  76. package/errors/lib/cjs/Error.js +9 -9
  77. package/errors/lib/es6/Error.js +9 -9
  78. package/feature-popover/lib/cjs/FeaturePopover.js +10 -10
  79. package/feature-popover/lib/es6/FeaturePopover.js +10 -10
  80. package/format-text/lib/cjs/FormatText.js +5 -5
  81. package/format-text/lib/cjs/style/format-text.shadow.css +3 -1
  82. package/format-text/lib/es6/FormatText.js +5 -5
  83. package/format-text/lib/es6/style/format-text.shadow.css +3 -1
  84. package/input-tags/lib/cjs/InputTags.js +12 -12
  85. package/input-tags/lib/es6/InputTags.js +12 -12
  86. package/link/lib/cjs/Link.js +12 -12
  87. package/link/lib/cjs/style/link.shadow.css +4 -6
  88. package/link/lib/es6/Link.js +12 -12
  89. package/link/lib/es6/style/link.shadow.css +4 -6
  90. package/package.json +6 -6
  91. package/pagination/lib/cjs/Pagination.js +10 -10
  92. package/pagination/lib/es6/Pagination.js +10 -10
  93. package/popper/lib/cjs/Popper.js +6 -6
  94. package/popper/lib/es6/Popper.js +6 -6
  95. package/select/lib/cjs/InputSearch.js +6 -6
  96. package/select/lib/cjs/Select.js +9 -9
  97. package/select/lib/es6/InputSearch.js +6 -6
  98. package/select/lib/es6/Select.js +9 -9
  99. package/tag/index.d.ts +35 -33
  100. package/tag/lib/cjs/Tag.js +89 -56
  101. package/tag/lib/cjs/Tag.js.map +1 -1
  102. package/tag/lib/cjs/index.d.js.map +1 -1
  103. package/tag/lib/cjs/style/tag.shadow.css +27 -2
  104. package/tag/lib/es6/Tag.js +89 -56
  105. package/tag/lib/es6/Tag.js.map +1 -1
  106. package/tag/lib/es6/index.d.js.map +1 -1
  107. package/tag/lib/es6/style/tag.shadow.css +27 -2
  108. package/tag/lib/types/index.d.ts +35 -33
  109. package/time-picker/lib/cjs/TimePicker.js +12 -12
  110. package/time-picker/lib/es6/TimePicker.js +12 -12
  111. package/tooltip/lib/cjs/Tooltip.js +7 -7
  112. package/tooltip/lib/es6/Tooltip.js +7 -7
  113. package/utils/lib/themes/auto.css +6 -6
  114. package/utils/lib/themes/dark.css +0 -2
  115. package/utils/lib/themes/dark.json +0 -1
  116. package/utils/lib/themes/default.css +6 -4
  117. package/utils/lib/themes/default.json +3 -2
  118. package/utils/lib/themes/light.css +6 -4
  119. package/utils/lib/themes/light.json +3 -2
  120. package/utils/lib/use/useFocusLock.js +5 -0
  121. package/utils/lib/use/useFocusLock.js.map +1 -1
  122. package/utils/lib/use/useFocusLock.mjs +5 -0
  123. package/utils/lib/use/useFocusLock.mjs.map +1 -1
@@ -9,14 +9,16 @@ import _inherits from "@babel/runtime/helpers/inherits";
9
9
  import _createSuper from "@babel/runtime/helpers/createSuper";
10
10
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
11
11
  import { sstyled as _sstyled } from 'intergalactic/core';
12
+ import { assignProps as _assignProps9 } from 'intergalactic/core';
13
+ import { assignProps as _assignProps8 } from 'intergalactic/core';
14
+ import { assignProps as _assignProps7 } from 'intergalactic/core';
12
15
  import { assignProps as _assignProps6 } from 'intergalactic/core';
13
16
  import { assignProps as _assignProps5 } from 'intergalactic/core';
14
17
  import { assignProps as _assignProps4 } from 'intergalactic/core';
15
18
  import { assignProps as _assignProps3 } from 'intergalactic/core';
16
19
  import { assignProps as _assignProps2 } from 'intergalactic/core';
17
20
  import { assignProps as _assignProps } from 'intergalactic/core';
18
- var _excluded = ["className"],
19
- _excluded2 = ["className"];
21
+ var _excluded = ["className"];
20
22
  import React from 'react';
21
23
  import cn from 'classnames';
22
24
  import createComponent, { Component, sstyled, Root } from 'intergalactic/core';
@@ -26,24 +28,28 @@ import ScrollAreaComponent from 'intergalactic/scroll-area';
26
28
  import uniqueIDEnhancement from 'intergalactic/utils/lib/uniqueID';
27
29
  import i18nEnhance from 'intergalactic/utils/lib/enhances/i18nEnhance';
28
30
  import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
29
- import { hasFocusableIn } from 'intergalactic/utils/lib/use/useFocusLock';
31
+ import { useFocusLock } from 'intergalactic/utils/lib/use/useFocusLock';
30
32
  import scrollStyles from './styleScrollArea';
31
33
  /*__reshadow-styles__:"./style/dropdown-menu.shadow.css"*/
32
- var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SDropdownMenuItem_1d6qz_gg_,.___SDropdownMenuList_1d6qz_gg_{position:relative;color:var(--intergalactic-text-primary, #191b23)}.___SDropdownMenuList_1d6qz_gg_{max-height:240px;padding:var(--intergalactic-spacing-1x, 4px)0;min-height:26px;min-width:32px;box-sizing:content-box;z-index:0}.___SDropdownMenuItem_1d6qz_gg_{display:flex;align-items:center;-webkit-text-decoration:none;text-decoration:none;box-sizing:border-box;cursor:pointer;width:100%;text-align:left;line-height:normal}@media (hover:hover){.___SDropdownMenuItem_1d6qz_gg_:hover{background-color:var(--intergalactic-dropdown-menu-item-hover, #f4f5f9)}}.___SDropdownMenuItem_1d6qz_gg_:focus{outline:0}.___SDropdownMenuItem_1d6qz_gg_.__selected_1d6qz_gg_{background-color:var(--intergalactic-dropdown-menu-item-selected, rgba(196, 229, 254, 0.7));box-shadow:2px 0 0 0 var(--intergalactic-control-primary-info, #008ff8) inset}@media (hover:hover){.___SDropdownMenuItem_1d6qz_gg_.__selected_1d6qz_gg_:hover{background-color:var(--intergalactic-dropdown-menu-item-selected-hover, #c4e5fe)}}.___SDropdownMenuItem_1d6qz_gg_.__highlighted_1d6qz_gg_{z-index:1;box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5)) inset}.___SDropdownMenuItem_1d6qz_gg_.__disabled_1d6qz_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SDropdownMenuItem_1d6qz_gg_._size_l_1d6qz_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%);padding:var(--intergalactic-spacing-2x, 8px) var(--intergalactic-spacing-3x, 12px);min-height:40px}.___SDropdownMenuItem_1d6qz_gg_._size_m_1d6qz_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%);padding:calc(var(--intergalactic-spacing-1x, 4px) + var(--intergalactic-spacing-05x, 2px)) var(--intergalactic-spacing-2x, 8px);min-height:32px}.___SDropdownMenuItem_1d6qz_gg_.__notInteractive_1d6qz_gg_{cursor:default}@media (hover:hover){.___SDropdownMenuItem_1d6qz_gg_.__notInteractive_1d6qz_gg_:hover{background:0 0}}.___SDropdownMenuItem_1d6qz_gg_._variant_hint_1d6qz_gg_{color:var(--intergalactic-text-secondary, #6c6e79);cursor:default}@media (hover:hover){.___SDropdownMenuItem_1d6qz_gg_._variant_hint_1d6qz_gg_:hover{background:0 0}}.___SDropdownMenuItem_1d6qz_gg_._variant_title_1d6qz_gg_{font-weight:var(--intergalactic-bold, 700);cursor:default}@media (hover:hover){.___SDropdownMenuItem_1d6qz_gg_._variant_title_1d6qz_gg_:hover{background:0 0}}.___SDropdownMenuItemAddon_1d6qz_gg_{display:inline-flex;margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SDropdownMenuItemAddon_1d6qz_gg_:first-child{margin-left:0}.___SDropdownMenuItemAddon_1d6qz_gg_:last-child{margin-right:0}" /*__inner_css_end__*/, "1d6qz_gg_") /*__reshadow_css_end__*/, {
33
- "__SDropdownMenuList": "___SDropdownMenuList_1d6qz_gg_",
34
- "__SDropdownMenuItem": "___SDropdownMenuItem_1d6qz_gg_",
35
- "_highlighted": "__highlighted_1d6qz_gg_",
36
- "_disabled": "__disabled_1d6qz_gg_",
37
- "_size_l": "_size_l_1d6qz_gg_",
38
- "_size_m": "_size_m_1d6qz_gg_",
39
- "_selected": "__selected_1d6qz_gg_",
40
- "_notInteractive": "__notInteractive_1d6qz_gg_",
41
- "_variant_hint": "_variant_hint_1d6qz_gg_",
42
- "_variant_title": "_variant_title_1d6qz_gg_",
43
- "__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1d6qz_gg_"
34
+ var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SDropdownMenuItem_1578a_gg_,.___SDropdownMenuList_1578a_gg_{position:relative;color:var(--intergalactic-text-primary, #191b23)}.___SDropdownMenuList_1578a_gg_{max-height:240px;padding:var(--intergalactic-spacing-1x, 4px)0;min-height:26px;min-width:32px;box-sizing:content-box;z-index:0}.___SDropdownMenuItem_1578a_gg_{display:flex;align-items:center;-webkit-text-decoration:none;text-decoration:none;box-sizing:border-box;cursor:pointer;width:100%;text-align:left;line-height:normal}@media (hover:hover){.___SDropdownMenuItem_1578a_gg_:hover{background-color:var(--intergalactic-dropdown-menu-item-hover, #f4f5f9)}}.___SDropdownMenuItem_1578a_gg_:focus{outline:0}.___SDropdownMenuItem_1578a_gg_.__selected_1578a_gg_{background-color:var(--intergalactic-dropdown-menu-item-selected, rgba(196, 229, 254, 0.7));box-shadow:2px 0 0 0 var(--intergalactic-control-primary-info, #008ff8) inset}@media (hover:hover){.___SDropdownMenuItem_1578a_gg_.__selected_1578a_gg_:hover{background-color:var(--intergalactic-dropdown-menu-item-selected-hover, #c4e5fe)}}.___SDropdownMenuItem_1578a_gg_.__highlighted_1578a_gg_:not(:focus-within){z-index:1;box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5)) inset}.___SDropdownMenuItem_1578a_gg_.__disabled_1578a_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SDropdownMenuItem_1578a_gg_._size_l_1578a_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%);padding:var(--intergalactic-spacing-2x, 8px) var(--intergalactic-spacing-3x, 12px);min-height:40px}.___SDropdownMenuItem_1578a_gg_._size_m_1578a_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%);padding:calc(var(--intergalactic-spacing-1x, 4px) + var(--intergalactic-spacing-05x, 2px)) var(--intergalactic-spacing-2x, 8px);min-height:32px}.___SDropdownMenuItem_1578a_gg_.__notInteractive_1578a_gg_{cursor:default}@media (hover:hover){.___SDropdownMenuItem_1578a_gg_.__notInteractive_1578a_gg_:hover{background:0 0}}.___SDropdownMenuItem_1578a_gg_._variant_hint_1578a_gg_{color:var(--intergalactic-text-secondary, #6c6e79);cursor:default}@media (hover:hover){.___SDropdownMenuItem_1578a_gg_._variant_hint_1578a_gg_:hover{background:0 0}}.___SDropdownMenuItem_1578a_gg_._variant_title_1578a_gg_{font-weight:var(--intergalactic-bold, 700);cursor:default}@media (hover:hover){.___SDropdownMenuItem_1578a_gg_._variant_title_1578a_gg_:hover{background:0 0}}.___SDropdownMenuItem_1578a_gg_.__visible_1578a_gg_{background-color:var(--intergalactic-dropdown-menu-item-hover, #f4f5f9)}.___SDropdownMenuItem_1578a_gg_.__nesting-trigger_1578a_gg_{justify-content:space-between}.___SDropdownMenuItemAddon_1578a_gg_{display:inline-flex;margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SDropdownMenuItemAddon_1578a_gg_:first-child{margin-left:0}.___SDropdownMenuItemAddon_1578a_gg_:last-child{margin-right:0}.___SDropdownMenuNesting_1578a_gg_,.___SDropdownMenuNesting_1578a_gg_._size_l_1578a_gg_,.___SDropdownMenuNesting_1578a_gg_._size_m_1578a_gg_{padding:0}.___SDropdownMenuNesting_1578a_gg_.__highlighted_1578a_gg_{z-index:1;box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5)) inset}" /*__inner_css_end__*/, "1578a_gg_") /*__reshadow_css_end__*/, {
35
+ "__SDropdownMenuList": "___SDropdownMenuList_1578a_gg_",
36
+ "__SDropdownMenuItem": "___SDropdownMenuItem_1578a_gg_",
37
+ "_highlighted": "__highlighted_1578a_gg_",
38
+ "_disabled": "__disabled_1578a_gg_",
39
+ "_size_l": "_size_l_1578a_gg_",
40
+ "_size_m": "_size_m_1578a_gg_",
41
+ "_visible": "__visible_1578a_gg_",
42
+ "_nesting-trigger": "__nesting-trigger_1578a_gg_",
43
+ "__SDropdownMenuNesting": "___SDropdownMenuNesting_1578a_gg_",
44
+ "_selected": "__selected_1578a_gg_",
45
+ "_notInteractive": "__notInteractive_1578a_gg_",
46
+ "_variant_hint": "_variant_hint_1578a_gg_",
47
+ "_variant_title": "_variant_title_1578a_gg_",
48
+ "__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1578a_gg_"
44
49
  });
45
- var KEYS = ['ArrowDown', 'ArrowUp', 'Enter', ' '];
46
- var INTERACTION_TAGS = ['INPUT', 'TEXTAREA', 'BUTTON'];
50
+ import { setFocus } from 'intergalactic/utils/lib/focus-lock/setFocus';
51
+ import { isFocusInside } from 'intergalactic/utils/lib/focus-lock/isFocusInside';
52
+ import { getFocusableIn } from 'intergalactic/utils/lib/focus-lock/getFocusableIn';
47
53
  var DropdownMenuRoot = /*#__PURE__*/function (_Component) {
48
54
  _inherits(DropdownMenuRoot, _Component);
49
55
  var _super = _createSuper(DropdownMenuRoot);
@@ -54,55 +60,194 @@ var DropdownMenuRoot = /*#__PURE__*/function (_Component) {
54
60
  args[_key] = arguments[_key];
55
61
  }
56
62
  _this = _super.call.apply(_super, [this].concat(args));
63
+ _defineProperty(_assertThisInitialized(_this), "state", {
64
+ focusLockItemIndex: null
65
+ });
57
66
  _defineProperty(_assertThisInitialized(_this), "popperRef", /*#__PURE__*/React.createRef());
67
+ _defineProperty(_assertThisInitialized(_this), "triggerRef", /*#__PURE__*/React.createRef());
58
68
  _defineProperty(_assertThisInitialized(_this), "itemProps", []);
69
+ _defineProperty(_assertThisInitialized(_this), "itemRefs", []);
59
70
  _defineProperty(_assertThisInitialized(_this), "highlightedItemRef", /*#__PURE__*/React.createRef());
71
+ _defineProperty(_assertThisInitialized(_this), "ignoreTriggerKeyboardFocusUntil", 0);
60
72
  _defineProperty(_assertThisInitialized(_this), "prevHighlightedIndex", null);
73
+ _defineProperty(_assertThisInitialized(_this), "focusTrigger", function () {
74
+ var trigger = _this.triggerRef.current;
75
+ if (!trigger) return;
76
+ if (isFocusInside(trigger)) return;
77
+ setFocus(trigger);
78
+ });
61
79
  _defineProperty(_assertThisInitialized(_this), "bindHandlerKeyDown", function (place) {
62
80
  return function (e) {
63
81
  var amount = e.shiftKey ? 5 : 1;
64
82
  var targetTagName = e.target.tagName;
65
- if (e.key === ' ' && INTERACTION_TAGS.includes(targetTagName)) return;
83
+ var _this$asProps = _this.asProps,
84
+ visible = _this$asProps.visible,
85
+ highlightedIndex = _this$asProps.highlightedIndex,
86
+ placement = _this$asProps.placement;
87
+ if (e.key === ' ' && ['INPUT', 'TEXTAREA', 'BUTTON'].includes(targetTagName)) return;
66
88
  if (e.key === 'Enter') {
67
89
  if (targetTagName === 'TEXTAREA') return;
68
90
  if (place === 'popper' && (targetTagName === 'BUTTON' || targetTagName === 'A')) return;
69
91
  }
70
- var visible = _this.asProps.visible;
71
- var element = _this.popperRef.current;
72
- if (place === 'popper' && visible && e.key === 'Tab' && hasFocusableIn(element)) {
73
- _this.handlers.highlightedIndex(null);
92
+ if (visible && e.key === 'Tab') {
93
+ var item = highlightedIndex !== null && _this.itemRefs[highlightedIndex];
94
+ if (item && getFocusableIn(item).length !== 0) {
95
+ _this.setState({
96
+ focusLockItemIndex: highlightedIndex
97
+ });
98
+ } else {
99
+ _this.handlers.highlightedIndex(null);
100
+ }
74
101
  return;
75
102
  }
76
- if (!KEYS.includes(e.key)) return;
77
- e.preventDefault();
78
- var isVisible = _this.asProps.visible;
79
- _this.handlers.visible(true);
103
+ if (e.key === 'Escape' && _this.state.focusLockItemIndex !== null) {
104
+ _this.setState({
105
+ focusLockItemIndex: null
106
+ });
107
+ return false;
108
+ }
109
+ var verticalPlacement = !placement || placement.startsWith('top') || placement.startsWith('bottom');
110
+ if (['ArrowDown', 'ArrowUp'].includes(e.key) && verticalPlacement) {
111
+ e.preventDefault();
112
+ _this.handlers.visible(true);
113
+ }
114
+ if (['ArrowLeft', 'ArrowRight'].includes(e.key) && !verticalPlacement) {
115
+ var show = e.key === 'ArrowRight' && placement.startsWith('right') || e.key === 'ArrowLeft' && placement.startsWith('left');
116
+ var hide = e.key === 'ArrowLeft' && placement.startsWith('right') || e.key === 'ArrowRight' && placement.startsWith('left');
117
+ var visibleChanged = visible && hide || !visible && show;
118
+ if (show) {
119
+ _this.handlers.visible(true);
120
+ } else if (hide) {
121
+ _this.handlers.visible(false);
122
+ }
123
+ if (visibleChanged) {
124
+ e.preventDefault();
125
+ e.stopPropagation();
126
+ return;
127
+ }
128
+ }
129
+ if (['ArrowLeft', 'ArrowRight'].includes(e.key)) {
130
+ var _item = highlightedIndex !== null && _this.itemRefs[highlightedIndex];
131
+ var focusable = getFocusableIn(_item);
132
+ if (focusable.length > 0 && _item) {
133
+ var focusedIndex = focusable.indexOf(document.activeElement);
134
+ if (e.key === 'ArrowRight') {
135
+ if (focusedIndex === -1) {
136
+ _this.setState({
137
+ focusLockItemIndex: highlightedIndex
138
+ });
139
+ }
140
+ var nextFocused = focusable[focusedIndex + 1];
141
+ if (nextFocused) {
142
+ e.preventDefault();
143
+ e.stopPropagation();
144
+ nextFocused.focus();
145
+ }
146
+ } else if (e.key === 'ArrowLeft') {
147
+ if (focusedIndex === 0) {
148
+ _this.setState({
149
+ focusLockItemIndex: null
150
+ });
151
+ }
152
+ var prevFocused = focusable[focusedIndex - 1];
153
+ if (prevFocused) {
154
+ e.preventDefault();
155
+ e.stopPropagation();
156
+ prevFocused.focus();
157
+ }
158
+ }
159
+ }
160
+ }
80
161
  switch (e.key) {
81
162
  case 'ArrowDown':
82
163
  {
83
- isVisible && _this.moveHighlightedIndex(amount, e);
84
- (targetTagName === 'BUTTON' || targetTagName === 'A') && (element === null || element === void 0 ? void 0 : element.focus());
164
+ if (visible) {
165
+ _this.moveHighlightedIndex(amount, e);
166
+ if (isFocusInside(_this.popperRef.current)) {
167
+ _this.focusTrigger();
168
+ }
169
+ e.preventDefault();
170
+ e.stopPropagation();
171
+ }
85
172
  break;
86
173
  }
87
174
  case 'ArrowUp':
88
175
  {
89
- isVisible && _this.moveHighlightedIndex(-amount, e);
90
- (targetTagName === 'BUTTON' || targetTagName === 'A') && (element === null || element === void 0 ? void 0 : element.focus());
176
+ if (visible) {
177
+ _this.moveHighlightedIndex(-amount, e);
178
+ if (isFocusInside(_this.popperRef.current)) {
179
+ _this.focusTrigger();
180
+ }
181
+ e.preventDefault();
182
+ e.stopPropagation();
183
+ }
91
184
  break;
92
185
  }
93
186
  case ' ':
94
187
  case 'Enter':
95
188
  if (_this.highlightedItemRef.current) {
189
+ e.stopPropagation();
190
+ e.preventDefault();
96
191
  _this.highlightedItemRef.current.click();
97
192
  } else {
98
- if (place === 'trigger') _this.handlers.visible(false);
193
+ if (place === 'trigger') {
194
+ _this.handlers.visible(false);
195
+ e.preventDefault();
196
+ }
99
197
  }
100
198
  break;
101
199
  }
102
200
  };
103
201
  });
202
+ _defineProperty(_assertThisInitialized(_this), "handleTriggerKeyboardFocus", function () {
203
+ if (_this.ignoreTriggerKeyboardFocusUntil > Date.now()) return false;
204
+ });
205
+ _defineProperty(_assertThisInitialized(_this), "handleNestingClick", function (event) {
206
+ var _focusable$;
207
+ var itemIndex = _this.itemRefs.indexOf(event.currentTarget);
208
+ if (itemIndex === -1) return;
209
+ var focusable = getFocusableIn(event.currentTarget);
210
+ (_focusable$ = focusable[0]) === null || _focusable$ === void 0 ? void 0 : _focusable$.focus();
211
+ if (focusable[0] && _this.state.focusLockItemIndex === null) {
212
+ _this.setState({
213
+ focusLockItemIndex: null
214
+ });
215
+ event.preventDefault();
216
+ event.stopPropagation();
217
+ }
218
+ });
219
+ _defineProperty(_assertThisInitialized(_this), "handleNestingKeyDown", function (event) {
220
+ if (event.key === ' ') {
221
+ _this.handleNestingClick(event);
222
+ }
223
+ });
224
+ _defineProperty(_assertThisInitialized(_this), "getNestingProps", function () {
225
+ var size = _this.asProps.size;
226
+ return {
227
+ size: size,
228
+ onClick: _this.handleNestingClick,
229
+ onKeyDown: _this.handleNestingKeyDown
230
+ };
231
+ });
232
+ _defineProperty(_assertThisInitialized(_this), "handleNestedVisibleChange", function (lastUserInteraction) {
233
+ if (_this.asProps.visible && _this.asProps.highlightedIndex === null && lastUserInteraction === 'keyboard') {
234
+ _this.handlers.highlightedIndex(0);
235
+ }
236
+ });
237
+ _defineProperty(_assertThisInitialized(_this), "getNestingTriggerProps", function () {
238
+ var _this$asProps2 = _this.asProps,
239
+ size = _this$asProps2.size,
240
+ visible = _this$asProps2.visible;
241
+ return {
242
+ size: size,
243
+ visible: visible,
244
+ onNestedVisibleChange: _this.handleNestedVisibleChange
245
+ };
246
+ });
104
247
  _defineProperty(_assertThisInitialized(_this), "scrollToNode", function (node) {
105
- _this.highlightedItemRef.current = node;
248
+ if (node) {
249
+ _this.highlightedItemRef.current = node;
250
+ }
106
251
  setTimeout(function () {
107
252
  if (node !== null && node !== void 0 && node.scrollIntoView) {
108
253
  if (_this.asProps.highlightedIndex !== _this.prevHighlightedIndex) {
@@ -120,21 +265,26 @@ var DropdownMenuRoot = /*#__PURE__*/function (_Component) {
120
265
  _createClass(DropdownMenuRoot, [{
121
266
  key: "uncontrolledProps",
122
267
  value: function uncontrolledProps() {
268
+ var _this2 = this;
123
269
  return {
124
270
  highlightedIndex: null,
125
- visible: null
271
+ visible: [null, function (visible) {
272
+ if (!visible) {
273
+ _this2.ignoreTriggerKeyboardFocusUntil = Date.now() + 100;
274
+ }
275
+ }]
126
276
  };
127
277
  }
128
278
  }, {
129
279
  key: "getTriggerProps",
130
280
  value: function getTriggerProps() {
131
- var _this$asProps = this.asProps,
132
- size = _this$asProps.size,
133
- uid = _this$asProps.uid,
134
- disablePortal = _this$asProps.disablePortal,
135
- visible = _this$asProps.visible,
136
- getI18nText = _this$asProps.getI18nText,
137
- highlightedIndex = _this$asProps.highlightedIndex;
281
+ var _this$asProps3 = this.asProps,
282
+ size = _this$asProps3.size,
283
+ uid = _this$asProps3.uid,
284
+ disablePortal = _this$asProps3.disablePortal,
285
+ visible = _this$asProps3.visible,
286
+ getI18nText = _this$asProps3.getI18nText,
287
+ highlightedIndex = _this$asProps3.highlightedIndex;
138
288
  return {
139
289
  size: size,
140
290
  id: "igc-".concat(uid, "-trigger"),
@@ -142,15 +292,17 @@ var DropdownMenuRoot = /*#__PURE__*/function (_Component) {
142
292
  focusHint: visible && !disablePortal ? getI18nText('triggerHint') : undefined,
143
293
  'aria-expanded': visible ? 'true' : 'false',
144
294
  'aria-activedescendant': visible && highlightedIndex !== null ? "igc-".concat(uid, "-option-").concat(highlightedIndex) : undefined,
145
- onKeyDown: this.bindHandlerKeyDown('trigger')
295
+ onKeyDown: this.bindHandlerKeyDown('trigger'),
296
+ ref: this.triggerRef,
297
+ onKeyboardFocus: this.handleTriggerKeyboardFocus
146
298
  };
147
299
  }
148
300
  }, {
149
301
  key: "getListProps",
150
302
  value: function getListProps() {
151
- var _this$asProps2 = this.asProps,
152
- size = _this$asProps2.size,
153
- uid = _this$asProps2.uid;
303
+ var _this$asProps4 = this.asProps,
304
+ size = _this$asProps4.size,
305
+ uid = _this$asProps4.uid;
154
306
  return {
155
307
  size: size,
156
308
  uid: uid,
@@ -160,12 +312,12 @@ var DropdownMenuRoot = /*#__PURE__*/function (_Component) {
160
312
  }, {
161
313
  key: "getPopperProps",
162
314
  value: function getPopperProps() {
163
- var _this$asProps3 = this.asProps,
164
- uid = _this$asProps3.uid,
165
- disablePortal = _this$asProps3.disablePortal,
166
- ignorePortalsStacking = _this$asProps3.ignorePortalsStacking,
167
- interaction = _this$asProps3.interaction,
168
- highlightedIndex = _this$asProps3.highlightedIndex;
315
+ var _this$asProps5 = this.asProps,
316
+ uid = _this$asProps5.uid,
317
+ disablePortal = _this$asProps5.disablePortal,
318
+ ignorePortalsStacking = _this$asProps5.ignorePortalsStacking,
319
+ interaction = _this$asProps5.interaction,
320
+ highlightedIndex = _this$asProps5.highlightedIndex;
169
321
  return {
170
322
  ref: this.popperRef,
171
323
  tabIndex: 0,
@@ -180,21 +332,29 @@ var DropdownMenuRoot = /*#__PURE__*/function (_Component) {
180
332
  }, {
181
333
  key: "getItemProps",
182
334
  value: function getItemProps(props, index) {
183
- var _this$asProps4 = this.asProps,
184
- size = _this$asProps4.size,
185
- highlightedIndex = _this$asProps4.highlightedIndex,
186
- uid = _this$asProps4.uid;
335
+ var _this3 = this;
336
+ var _this$asProps6 = this.asProps,
337
+ size = _this$asProps6.size,
338
+ highlightedIndex = _this$asProps6.highlightedIndex,
339
+ uid = _this$asProps6.uid;
187
340
  var highlighted = index === highlightedIndex;
188
- var extraProps = {};
341
+ var ref = this.itemRefs[index];
189
342
  this.itemProps[index] = props;
190
343
  if (highlighted) {
191
- extraProps.ref = this.scrollToNode;
344
+ ref = function ref(node) {
345
+ _this3.itemRefs[index] = node;
346
+ _this3.scrollToNode(node);
347
+ };
192
348
  }
193
- return _objectSpread({
349
+ return {
194
350
  id: "igc-".concat(uid, "-option-").concat(index),
195
351
  size: size,
196
- highlighted: highlighted
197
- }, extraProps);
352
+ highlighted: highlighted,
353
+ focusLock: this.state.focusLockItemIndex === index,
354
+ triggerRef: this.triggerRef,
355
+ ref: ref,
356
+ index: index
357
+ };
198
358
  }
199
359
  }, {
200
360
  key: "getItemHintProps",
@@ -225,6 +385,8 @@ var DropdownMenuRoot = /*#__PURE__*/function (_Component) {
225
385
  if (highlightedIndex == null) {
226
386
  if (selectedIndex !== -1) {
227
387
  highlightedIndex = selectedIndex;
388
+ } else if (this.highlightedItemRef.current) {
389
+ highlightedIndex = this.prevHighlightedIndex;
228
390
  } else {
229
391
  highlightedIndex = amount < 0 ? 0 : itemsLastIndex;
230
392
  }
@@ -244,22 +406,25 @@ var DropdownMenuRoot = /*#__PURE__*/function (_Component) {
244
406
  }, {
245
407
  key: "componentDidUpdate",
246
408
  value: function componentDidUpdate() {
247
- var visible = this.asProps.visible;
248
- if (!visible) {
409
+ var _this4 = this;
410
+ if (!this.asProps.visible) {
249
411
  this.handlers.highlightedIndex(null);
250
412
  }
413
+ if ((this.state.focusLockItemIndex !== this.asProps.highlightedIndex || !this.asProps.visible) && this.state.focusLockItemIndex !== null) {
414
+ setTimeout(function () {
415
+ _this4.setState({
416
+ focusLockItemIndex: null
417
+ });
418
+ }, 0);
419
+ }
251
420
  }
252
421
  }, {
253
422
  key: "render",
254
423
  value: function render() {
255
424
  var _ref = this.asProps;
256
- var _this$asProps5 = this.asProps,
257
- Children = _this$asProps5.Children,
258
- interaction = _this$asProps5.interaction,
259
- dataUiName = _this$asProps5['data-ui-name'];
260
- var props = {};
425
+ var Children = this.asProps.Children;
261
426
  this.itemProps = [];
262
- return /*#__PURE__*/React.createElement(Dropdown, _assignProps(_objectSpread({}, props), _ref), /*#__PURE__*/React.createElement(Children, null));
427
+ return /*#__PURE__*/React.createElement(Dropdown, _assignProps({}, _ref), /*#__PURE__*/React.createElement(Children, null));
263
428
  }
264
429
  }]);
265
430
  return DropdownMenuRoot;
@@ -277,10 +442,10 @@ _defineProperty(DropdownMenuRoot, "defaultProps", {
277
442
  });
278
443
  function List(props) {
279
444
  var _ref2 = arguments[0],
280
- _ref7;
445
+ _ref10;
281
446
  var SDropdownMenuList = ScrollAreaComponent;
282
447
  var uid = props.uid;
283
- return _ref7 = sstyled(props.styles), /*#__PURE__*/React.createElement(SDropdownMenuList, _ref7.cn("SDropdownMenuList", _objectSpread({}, _assignProps2({
448
+ return _ref10 = sstyled(props.styles), /*#__PURE__*/React.createElement(SDropdownMenuList, _ref10.cn("SDropdownMenuList", _objectSpread({}, _assignProps2({
284
449
  "tabIndex": null,
285
450
  "role": 'menu',
286
451
  "aria-labelledby": "igc-".concat(uid, "-trigger"),
@@ -308,22 +473,72 @@ function Menu(props) {
308
473
  };
309
474
  return /*#__PURE__*/React.createElement(DropdownMenu.Popper, popperProps, /*#__PURE__*/React.createElement(DropdownMenu.List, _assignProps3({}, _ref3)));
310
475
  }
311
- function Item(props) {
312
- var _useFlex = useFlex(props, props.forwardRef),
313
- _useFlex2 = _slicedToArray(_useFlex, 2),
314
- SDropdownMenuItem = _useFlex2[0],
315
- _useFlex2$ = _useFlex2[1],
316
- className = _useFlex2$.className,
317
- other = _objectWithoutProperties(_useFlex2$, _excluded);
318
- var styles = sstyled(props.styles);
319
- return /*#__PURE__*/React.createElement(SDropdownMenuItem, _extends({
320
- role: "menuitem",
321
- tabIndex: -1,
322
- id: props.label,
323
- className: cn(styles.cn('SDropdownMenuItem', _objectSpread(_objectSpread({}, props), {}, {
324
- highlighted: !props.disabled && props.highlighted
325
- })).className, className) || undefined
326
- }, other));
476
+ function Item(_ref16) {
477
+ var _ref4 = arguments[0],
478
+ _ref11;
479
+ var styles = _ref16.styles,
480
+ label = _ref16.label,
481
+ triggerRef = _ref16.triggerRef,
482
+ focusLock = _ref16.focusLock,
483
+ disabled = _ref16.disabled,
484
+ highlighted = _ref16.highlighted;
485
+ var SDropdownMenuItem = Flex;
486
+ var ref = React.useRef();
487
+ useFocusLock(ref, false, triggerRef, !focusLock || disabled, true);
488
+ return _ref11 = sstyled(styles), /*#__PURE__*/React.createElement(SDropdownMenuItem, _ref11.cn("SDropdownMenuItem", _objectSpread({}, _assignProps4({
489
+ "ref": ref,
490
+ "role": 'menuitem',
491
+ "tabIndex": -1,
492
+ "id": label,
493
+ "use:highlighted": !disabled && highlighted
494
+ }, _ref4))));
495
+ }
496
+ function Nesting(_ref17) {
497
+ var _ref5 = arguments[0],
498
+ _ref12;
499
+ var styles = _ref17.styles;
500
+ var SDropdownMenuNesting = DropdownMenu.Item;
501
+ return _ref12 = sstyled(styles), /*#__PURE__*/React.createElement(SDropdownMenuNesting, _ref12.cn("SDropdownMenuNesting", _objectSpread({}, _assignProps5({
502
+ "aria-haspopup": 'true'
503
+ }, _ref5))));
504
+ }
505
+ function NestingTrigger(_ref18) {
506
+ var _ref6 = arguments[0],
507
+ _ref13;
508
+ var styles = _ref18.styles,
509
+ visible = _ref18.visible,
510
+ onNestedVisibleChange = _ref18.onNestedVisibleChange;
511
+ var SDropdownMenuItem = Flex;
512
+ var lastUserInteractionRef = React.useRef(undefined);
513
+ React.useEffect(function () {
514
+ onNestedVisibleChange(lastUserInteractionRef.current);
515
+ }, [visible]);
516
+ var handleMouseEvent = React.useCallback(function () {
517
+ lastUserInteractionRef.current = 'mouse';
518
+ }, []);
519
+ var handleKeyboardEvent = React.useCallback(function () {
520
+ lastUserInteractionRef.current = 'keyboard';
521
+ }, []);
522
+ React.useEffect(function () {
523
+ document.addEventListener('mouseover', handleMouseEvent, {
524
+ capture: true
525
+ });
526
+ document.addEventListener('keydown', handleKeyboardEvent, {
527
+ capture: true
528
+ });
529
+ return function () {
530
+ document.removeEventListener('mouseover', handleMouseEvent, {
531
+ capture: true
532
+ });
533
+ document.removeEventListener('keydown', handleKeyboardEvent, {
534
+ capture: true
535
+ });
536
+ };
537
+ }, []);
538
+ return _ref13 = sstyled(styles), /*#__PURE__*/React.createElement(SDropdownMenuItem, _ref13.cn("SDropdownMenuItem", _objectSpread({}, _assignProps6({
539
+ "nesting-trigger": true,
540
+ "tabIndex": 0
541
+ }, _ref6))));
327
542
  }
328
543
  function Addon(props) {
329
544
  var _useBox = useBox(props, props.forwardRef),
@@ -331,33 +546,33 @@ function Addon(props) {
331
546
  SDropdownMenuItemAddon = _useBox2[0],
332
547
  _useBox2$ = _useBox2[1],
333
548
  className = _useBox2$.className,
334
- other = _objectWithoutProperties(_useBox2$, _excluded2);
549
+ other = _objectWithoutProperties(_useBox2$, _excluded);
335
550
  var styles = sstyled(props.styles);
336
551
  return /*#__PURE__*/React.createElement(SDropdownMenuItemAddon, _extends({
337
552
  className: cn(styles.cn('SDropdownMenuItemAddon', props).className, className) || undefined
338
553
  }, other));
339
554
  }
340
555
  function Hint(props) {
341
- var _ref4 = arguments[0],
342
- _ref8;
556
+ var _ref7 = arguments[0],
557
+ _ref14;
343
558
  var SDropdownMenuItem = Flex;
344
- return _ref8 = sstyled(props.styles), /*#__PURE__*/React.createElement(SDropdownMenuItem, _ref8.cn("SDropdownMenuItem", _objectSpread({}, _assignProps4({
559
+ return _ref14 = sstyled(props.styles), /*#__PURE__*/React.createElement(SDropdownMenuItem, _ref14.cn("SDropdownMenuItem", _objectSpread({}, _assignProps7({
345
560
  "variant": 'hint'
346
- }, _ref4))));
561
+ }, _ref7))));
347
562
  }
348
563
  function Title(props) {
349
- var _ref5 = arguments[0],
350
- _ref9;
564
+ var _ref8 = arguments[0],
565
+ _ref15;
351
566
  var SDropdownMenuItem = Flex;
352
- return _ref9 = sstyled(props.styles), /*#__PURE__*/React.createElement(SDropdownMenuItem, _ref9.cn("SDropdownMenuItem", _objectSpread({}, _assignProps5({
567
+ return _ref15 = sstyled(props.styles), /*#__PURE__*/React.createElement(SDropdownMenuItem, _ref15.cn("SDropdownMenuItem", _objectSpread({}, _assignProps8({
353
568
  "variant": 'title'
354
- }, _ref5))));
569
+ }, _ref8))));
355
570
  }
356
571
  function Trigger() {
357
- var _ref6 = arguments[0];
358
- return /*#__PURE__*/React.createElement(Dropdown.Trigger, _assignProps6({
572
+ var _ref9 = arguments[0];
573
+ return /*#__PURE__*/React.createElement(Dropdown.Trigger, _assignProps9({
359
574
  "aria-haspopup": 'true'
360
- }, _ref6));
575
+ }, _ref9));
361
576
  }
362
577
  var DropdownMenu = createComponent(DropdownMenuRoot, {
363
578
  Trigger: Trigger,
@@ -367,6 +582,10 @@ var DropdownMenu = createComponent(DropdownMenuRoot, {
367
582
  Item: [Item, {
368
583
  Addon: Addon
369
584
  }],
585
+ Nesting: [Nesting, {
586
+ Trigger: NestingTrigger,
587
+ Addon: Addon
588
+ }],
370
589
  ItemTitle: Title,
371
590
  ItemHint: Hint
372
591
  }, {