@react-spectrum/actiongroup 3.11.6 → 3.12.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.
Files changed (205) hide show
  1. package/dist/import.mjs +3 -3
  2. package/dist/main.js +4 -4
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +3 -3
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +3 -0
  7. package/package.json +14 -41
  8. package/src/index.ts +4 -3
  9. package/dist/ActionGroup.main.js +0 -398
  10. package/dist/ActionGroup.main.js.map +0 -1
  11. package/dist/ActionGroup.mjs +0 -393
  12. package/dist/ActionGroup.module.js +0 -393
  13. package/dist/ActionGroup.module.js.map +0 -1
  14. package/dist/actiongroup.bb161279.css +0 -1669
  15. package/dist/actiongroup.bb161279.css.map +0 -1
  16. package/dist/actiongroup.c0b1ee3f.css +0 -254
  17. package/dist/actiongroup.c0b1ee3f.css.map +0 -1
  18. package/dist/actiongroup_vars_css.main.js +0 -56
  19. package/dist/actiongroup_vars_css.main.js.map +0 -1
  20. package/dist/actiongroup_vars_css.mjs +0 -58
  21. package/dist/actiongroup_vars_css.module.js +0 -58
  22. package/dist/actiongroup_vars_css.module.js.map +0 -1
  23. package/dist/ar-AE.main.js +0 -6
  24. package/dist/ar-AE.main.js.map +0 -1
  25. package/dist/ar-AE.mjs +0 -8
  26. package/dist/ar-AE.module.js +0 -8
  27. package/dist/ar-AE.module.js.map +0 -1
  28. package/dist/bg-BG.main.js +0 -6
  29. package/dist/bg-BG.main.js.map +0 -1
  30. package/dist/bg-BG.mjs +0 -8
  31. package/dist/bg-BG.module.js +0 -8
  32. package/dist/bg-BG.module.js.map +0 -1
  33. package/dist/button_vars_css.main.js +0 -125
  34. package/dist/button_vars_css.main.js.map +0 -1
  35. package/dist/button_vars_css.mjs +0 -127
  36. package/dist/button_vars_css.module.js +0 -127
  37. package/dist/button_vars_css.module.js.map +0 -1
  38. package/dist/cs-CZ.main.js +0 -6
  39. package/dist/cs-CZ.main.js.map +0 -1
  40. package/dist/cs-CZ.mjs +0 -8
  41. package/dist/cs-CZ.module.js +0 -8
  42. package/dist/cs-CZ.module.js.map +0 -1
  43. package/dist/da-DK.main.js +0 -6
  44. package/dist/da-DK.main.js.map +0 -1
  45. package/dist/da-DK.mjs +0 -8
  46. package/dist/da-DK.module.js +0 -8
  47. package/dist/da-DK.module.js.map +0 -1
  48. package/dist/de-DE.main.js +0 -6
  49. package/dist/de-DE.main.js.map +0 -1
  50. package/dist/de-DE.mjs +0 -8
  51. package/dist/de-DE.module.js +0 -8
  52. package/dist/de-DE.module.js.map +0 -1
  53. package/dist/el-GR.main.js +0 -6
  54. package/dist/el-GR.main.js.map +0 -1
  55. package/dist/el-GR.mjs +0 -8
  56. package/dist/el-GR.module.js +0 -8
  57. package/dist/el-GR.module.js.map +0 -1
  58. package/dist/en-US.main.js +0 -6
  59. package/dist/en-US.main.js.map +0 -1
  60. package/dist/en-US.mjs +0 -8
  61. package/dist/en-US.module.js +0 -8
  62. package/dist/en-US.module.js.map +0 -1
  63. package/dist/es-ES.main.js +0 -6
  64. package/dist/es-ES.main.js.map +0 -1
  65. package/dist/es-ES.mjs +0 -8
  66. package/dist/es-ES.module.js +0 -8
  67. package/dist/es-ES.module.js.map +0 -1
  68. package/dist/et-EE.main.js +0 -6
  69. package/dist/et-EE.main.js.map +0 -1
  70. package/dist/et-EE.mjs +0 -8
  71. package/dist/et-EE.module.js +0 -8
  72. package/dist/et-EE.module.js.map +0 -1
  73. package/dist/fi-FI.main.js +0 -6
  74. package/dist/fi-FI.main.js.map +0 -1
  75. package/dist/fi-FI.mjs +0 -8
  76. package/dist/fi-FI.module.js +0 -8
  77. package/dist/fi-FI.module.js.map +0 -1
  78. package/dist/fr-FR.main.js +0 -6
  79. package/dist/fr-FR.main.js.map +0 -1
  80. package/dist/fr-FR.mjs +0 -8
  81. package/dist/fr-FR.module.js +0 -8
  82. package/dist/fr-FR.module.js.map +0 -1
  83. package/dist/he-IL.main.js +0 -6
  84. package/dist/he-IL.main.js.map +0 -1
  85. package/dist/he-IL.mjs +0 -8
  86. package/dist/he-IL.module.js +0 -8
  87. package/dist/he-IL.module.js.map +0 -1
  88. package/dist/hr-HR.main.js +0 -6
  89. package/dist/hr-HR.main.js.map +0 -1
  90. package/dist/hr-HR.mjs +0 -8
  91. package/dist/hr-HR.module.js +0 -8
  92. package/dist/hr-HR.module.js.map +0 -1
  93. package/dist/hu-HU.main.js +0 -6
  94. package/dist/hu-HU.main.js.map +0 -1
  95. package/dist/hu-HU.mjs +0 -8
  96. package/dist/hu-HU.module.js +0 -8
  97. package/dist/hu-HU.module.js.map +0 -1
  98. package/dist/intlStrings.main.js +0 -108
  99. package/dist/intlStrings.main.js.map +0 -1
  100. package/dist/intlStrings.mjs +0 -110
  101. package/dist/intlStrings.module.js +0 -110
  102. package/dist/intlStrings.module.js.map +0 -1
  103. package/dist/it-IT.main.js +0 -6
  104. package/dist/it-IT.main.js.map +0 -1
  105. package/dist/it-IT.mjs +0 -8
  106. package/dist/it-IT.module.js +0 -8
  107. package/dist/it-IT.module.js.map +0 -1
  108. package/dist/ja-JP.main.js +0 -6
  109. package/dist/ja-JP.main.js.map +0 -1
  110. package/dist/ja-JP.mjs +0 -8
  111. package/dist/ja-JP.module.js +0 -8
  112. package/dist/ja-JP.module.js.map +0 -1
  113. package/dist/ko-KR.main.js +0 -6
  114. package/dist/ko-KR.main.js.map +0 -1
  115. package/dist/ko-KR.mjs +0 -8
  116. package/dist/ko-KR.module.js +0 -8
  117. package/dist/ko-KR.module.js.map +0 -1
  118. package/dist/lt-LT.main.js +0 -6
  119. package/dist/lt-LT.main.js.map +0 -1
  120. package/dist/lt-LT.mjs +0 -8
  121. package/dist/lt-LT.module.js +0 -8
  122. package/dist/lt-LT.module.js.map +0 -1
  123. package/dist/lv-LV.main.js +0 -6
  124. package/dist/lv-LV.main.js.map +0 -1
  125. package/dist/lv-LV.mjs +0 -8
  126. package/dist/lv-LV.module.js +0 -8
  127. package/dist/lv-LV.module.js.map +0 -1
  128. package/dist/nb-NO.main.js +0 -6
  129. package/dist/nb-NO.main.js.map +0 -1
  130. package/dist/nb-NO.mjs +0 -8
  131. package/dist/nb-NO.module.js +0 -8
  132. package/dist/nb-NO.module.js.map +0 -1
  133. package/dist/nl-NL.main.js +0 -6
  134. package/dist/nl-NL.main.js.map +0 -1
  135. package/dist/nl-NL.mjs +0 -8
  136. package/dist/nl-NL.module.js +0 -8
  137. package/dist/nl-NL.module.js.map +0 -1
  138. package/dist/pl-PL.main.js +0 -6
  139. package/dist/pl-PL.main.js.map +0 -1
  140. package/dist/pl-PL.mjs +0 -8
  141. package/dist/pl-PL.module.js +0 -8
  142. package/dist/pl-PL.module.js.map +0 -1
  143. package/dist/pt-BR.main.js +0 -6
  144. package/dist/pt-BR.main.js.map +0 -1
  145. package/dist/pt-BR.mjs +0 -8
  146. package/dist/pt-BR.module.js +0 -8
  147. package/dist/pt-BR.module.js.map +0 -1
  148. package/dist/pt-PT.main.js +0 -6
  149. package/dist/pt-PT.main.js.map +0 -1
  150. package/dist/pt-PT.mjs +0 -8
  151. package/dist/pt-PT.module.js +0 -8
  152. package/dist/pt-PT.module.js.map +0 -1
  153. package/dist/ro-RO.main.js +0 -6
  154. package/dist/ro-RO.main.js.map +0 -1
  155. package/dist/ro-RO.mjs +0 -8
  156. package/dist/ro-RO.module.js +0 -8
  157. package/dist/ro-RO.module.js.map +0 -1
  158. package/dist/ru-RU.main.js +0 -6
  159. package/dist/ru-RU.main.js.map +0 -1
  160. package/dist/ru-RU.mjs +0 -8
  161. package/dist/ru-RU.module.js +0 -8
  162. package/dist/ru-RU.module.js.map +0 -1
  163. package/dist/sk-SK.main.js +0 -6
  164. package/dist/sk-SK.main.js.map +0 -1
  165. package/dist/sk-SK.mjs +0 -8
  166. package/dist/sk-SK.module.js +0 -8
  167. package/dist/sk-SK.module.js.map +0 -1
  168. package/dist/sl-SI.main.js +0 -6
  169. package/dist/sl-SI.main.js.map +0 -1
  170. package/dist/sl-SI.mjs +0 -8
  171. package/dist/sl-SI.module.js +0 -8
  172. package/dist/sl-SI.module.js.map +0 -1
  173. package/dist/sr-SP.main.js +0 -6
  174. package/dist/sr-SP.main.js.map +0 -1
  175. package/dist/sr-SP.mjs +0 -8
  176. package/dist/sr-SP.module.js +0 -8
  177. package/dist/sr-SP.module.js.map +0 -1
  178. package/dist/sv-SE.main.js +0 -6
  179. package/dist/sv-SE.main.js.map +0 -1
  180. package/dist/sv-SE.mjs +0 -8
  181. package/dist/sv-SE.module.js +0 -8
  182. package/dist/sv-SE.module.js.map +0 -1
  183. package/dist/tr-TR.main.js +0 -6
  184. package/dist/tr-TR.main.js.map +0 -1
  185. package/dist/tr-TR.mjs +0 -8
  186. package/dist/tr-TR.module.js +0 -8
  187. package/dist/tr-TR.module.js.map +0 -1
  188. package/dist/types.d.ts +0 -13
  189. package/dist/types.d.ts.map +0 -1
  190. package/dist/uk-UA.main.js +0 -6
  191. package/dist/uk-UA.main.js.map +0 -1
  192. package/dist/uk-UA.mjs +0 -8
  193. package/dist/uk-UA.module.js +0 -8
  194. package/dist/uk-UA.module.js.map +0 -1
  195. package/dist/zh-CN.main.js +0 -6
  196. package/dist/zh-CN.main.js.map +0 -1
  197. package/dist/zh-CN.mjs +0 -8
  198. package/dist/zh-CN.module.js +0 -8
  199. package/dist/zh-CN.module.js.map +0 -1
  200. package/dist/zh-TW.main.js +0 -6
  201. package/dist/zh-TW.main.js.map +0 -1
  202. package/dist/zh-TW.mjs +0 -8
  203. package/dist/zh-TW.module.js +0 -8
  204. package/dist/zh-TW.module.js.map +0 -1
  205. package/src/ActionGroup.tsx +0 -500
@@ -1,393 +0,0 @@
1
- import "./actiongroup.bb161279.css";
2
- import $lajJX$button_vars_cssmodulejs from "./button_vars_css.mjs";
3
- import $lajJX$intlStringsmodulejs from "./intlStrings.mjs";
4
- import "./actiongroup.c0b1ee3f.css";
5
- import $lajJX$actiongroup_vars_cssmodulejs from "./actiongroup_vars_css.mjs";
6
- import {ActionButton as $lajJX$ActionButton} from "@react-spectrum/button";
7
- import $lajJX$spectrumiconsuiChevronDownMedium from "@spectrum-icons/ui/ChevronDownMedium";
8
- import {useSlotProps as $lajJX$useSlotProps, useDOMRef as $lajJX$useDOMRef, useStyleProps as $lajJX$useStyleProps, classNames as $lajJX$classNames, ClearSlots as $lajJX$ClearSlots, SlotProvider as $lajJX$SlotProvider} from "@react-spectrum/utils";
9
- import {useValueEffect as $lajJX$useValueEffect, useResizeObserver as $lajJX$useResizeObserver, useLayoutEffect as $lajJX$useLayoutEffect, filterDOMProps as $lajJX$filterDOMProps, mergeProps as $lajJX$mergeProps, useId as $lajJX$useId} from "@react-aria/utils";
10
- import {FocusScope as $lajJX$FocusScope} from "@react-aria/focus";
11
- import {MenuTrigger as $lajJX$MenuTrigger, Menu as $lajJX$Menu, Item as $lajJX$Item} from "@react-spectrum/menu";
12
- import {useListState as $lajJX$useListState} from "@react-stately/list";
13
- import $lajJX$spectrumiconsworkflowMore from "@spectrum-icons/workflow/More";
14
- import {useHover as $lajJX$useHover, PressResponder as $lajJX$PressResponder} from "@react-aria/interactions";
15
- import {useProviderProps as $lajJX$useProviderProps, Provider as $lajJX$Provider} from "@react-spectrum/provider";
16
- import $lajJX$react, {forwardRef as $lajJX$forwardRef, useRef as $lajJX$useRef, useMemo as $lajJX$useMemo, useCallback as $lajJX$useCallback, useState as $lajJX$useState} from "react";
17
- import {Text as $lajJX$Text} from "@react-spectrum/text";
18
- import {TooltipTrigger as $lajJX$TooltipTrigger, Tooltip as $lajJX$Tooltip} from "@react-spectrum/tooltip";
19
- import {useActionGroup as $lajJX$useActionGroup, useActionGroupItem as $lajJX$useActionGroupItem} from "@react-aria/actiongroup";
20
- import {useLocalizedStringFormatter as $lajJX$useLocalizedStringFormatter} from "@react-aria/i18n";
21
-
22
-
23
- function $parcel$interopDefault(a) {
24
- return a && a.__esModule ? a.default : a;
25
- }
26
- /*
27
- * Copyright 2020 Adobe. All rights reserved.
28
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
29
- * you may not use this file except in compliance with the License. You may obtain a copy
30
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
31
- *
32
- * Unless required by applicable law or agreed to in writing, software distributed under
33
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
34
- * OF ANY KIND, either express or implied. See the License for the specific language
35
- * governing permissions and limitations under the License.
36
- */
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
- const $a04ee251ffcc2690$export$c21a5597f732a168 = /*#__PURE__*/ (0, $lajJX$forwardRef)(function ActionGroup(props, ref) {
55
- props = (0, $lajJX$useProviderProps)(props);
56
- props = (0, $lajJX$useSlotProps)(props, 'actionGroup');
57
- let { isEmphasized: isEmphasized, density: density, isJustified: isJustified, isDisabled: isDisabled, orientation: orientation = 'horizontal', isQuiet: isQuiet, staticColor: staticColor, overflowMode: overflowMode = 'wrap', onAction: onAction, buttonLabelBehavior: buttonLabelBehavior, summaryIcon: summaryIcon, ...otherProps } = props;
58
- let domRef = (0, $lajJX$useDOMRef)(ref);
59
- let wrapperRef = (0, $lajJX$useRef)(null);
60
- let state = (0, $lajJX$useListState)({
61
- ...props,
62
- suppressTextValueWarning: true
63
- });
64
- let { actionGroupProps: actionGroupProps } = (0, $lajJX$useActionGroup)(props, state, domRef);
65
- let isVertical = orientation === 'vertical';
66
- let providerProps = {
67
- isEmphasized: isEmphasized,
68
- isDisabled: isDisabled,
69
- isQuiet: isQuiet
70
- };
71
- let { styleProps: styleProps } = (0, $lajJX$useStyleProps)(props);
72
- // Only hide button text if every item contains more than just plain text (we assume an icon).
73
- let isIconCollapsible = (0, $lajJX$useMemo)(()=>[
74
- ...state.collection
75
- ].every((item)=>typeof item.rendered !== 'string'), [
76
- state.collection
77
- ]);
78
- let [{ visibleItems: visibleItems, hideButtonText: hideButtonText, isMeasuring: isMeasuring }, setVisibleItems] = (0, $lajJX$useValueEffect)({
79
- visibleItems: state.collection.size,
80
- hideButtonText: buttonLabelBehavior === 'hide' && isIconCollapsible,
81
- isMeasuring: false
82
- });
83
- let selectionMode = state.selectionManager.selectionMode;
84
- let updateOverflow = (0, $lajJX$useCallback)(()=>{
85
- if (overflowMode === 'wrap') return;
86
- if (orientation === 'vertical' && selectionMode !== 'none') // Collapsing vertical action groups with selection is currently unsupported by Spectrum.
87
- return;
88
- let computeVisibleItems = (visibleItems)=>{
89
- if (domRef.current && wrapperRef.current) {
90
- let listItems = Array.from(domRef.current.children);
91
- let containerSize = orientation === 'horizontal' ? wrapperRef.current.getBoundingClientRect().width : wrapperRef.current.getBoundingClientRect().height;
92
- let isShowingMenu = visibleItems < state.collection.size;
93
- let calculatedSize = 0;
94
- let newVisibleItems = 0;
95
- if (isShowingMenu) {
96
- let item = listItems.pop();
97
- if (item) calculatedSize += orientation === 'horizontal' ? $a04ee251ffcc2690$var$outerWidth(item, false, true) : $a04ee251ffcc2690$var$outerHeight(item, false, true);
98
- }
99
- for (let [i, item] of listItems.entries()){
100
- calculatedSize += orientation === 'horizontal' ? $a04ee251ffcc2690$var$outerWidth(item, i === 0, i === listItems.length - 1) : $a04ee251ffcc2690$var$outerHeight(item, i === 0, i === listItems.length - 1);
101
- if (Math.round(calculatedSize) <= Math.round(containerSize)) newVisibleItems++;
102
- else break;
103
- }
104
- // If selection is enabled, and not all of the items fit, collapse all of them into a dropdown
105
- // immediately rather than having some visible and some not.
106
- if (selectionMode !== 'none' && newVisibleItems < state.collection.size) return 0;
107
- return newVisibleItems;
108
- }
109
- return visibleItems;
110
- };
111
- setVisibleItems(function*() {
112
- let hideButtonText = buttonLabelBehavior === 'hide' && isIconCollapsible;
113
- // Update to show all items.
114
- yield {
115
- visibleItems: state.collection.size,
116
- hideButtonText: hideButtonText,
117
- isMeasuring: true
118
- };
119
- // Measure, and update to show the items that fit.
120
- let newVisibleItems = computeVisibleItems(state.collection.size);
121
- let isMeasuring = newVisibleItems < state.collection.size && newVisibleItems > 0;
122
- // If not all of the buttons fit, and buttonLabelBehavior is 'collapse', then first try hiding
123
- // the button text and only showing icons. Only if that still doesn't fit collapse into a menu.
124
- if (newVisibleItems < state.collection.size && buttonLabelBehavior === 'collapse' && isIconCollapsible) {
125
- yield {
126
- visibleItems: state.collection.size,
127
- hideButtonText: true,
128
- isMeasuring: true
129
- };
130
- newVisibleItems = computeVisibleItems(state.collection.size);
131
- isMeasuring = newVisibleItems < state.collection.size && newVisibleItems > 0;
132
- hideButtonText = true;
133
- }
134
- yield {
135
- visibleItems: newVisibleItems,
136
- hideButtonText: hideButtonText,
137
- isMeasuring: isMeasuring
138
- };
139
- // If the number of items is less than the number of children,
140
- // then update again to ensure that the menu fits.
141
- if (isMeasuring) yield {
142
- visibleItems: computeVisibleItems(newVisibleItems),
143
- hideButtonText: hideButtonText,
144
- isMeasuring: false
145
- };
146
- });
147
- }, [
148
- domRef,
149
- state.collection,
150
- setVisibleItems,
151
- overflowMode,
152
- selectionMode,
153
- buttonLabelBehavior,
154
- isIconCollapsible,
155
- orientation
156
- ]);
157
- // Watch the parent element for size changes. Watching only the action group itself may not work
158
- // in all scenarios because it may not shrink when available space is reduced.
159
- let parentRef = (0, $lajJX$useMemo)(()=>({
160
- get current () {
161
- var _wrapperRef_current;
162
- return (_wrapperRef_current = wrapperRef.current) === null || _wrapperRef_current === void 0 ? void 0 : _wrapperRef_current.parentElement;
163
- }
164
- }), [
165
- wrapperRef
166
- ]);
167
- (0, $lajJX$useResizeObserver)({
168
- ref: overflowMode !== 'wrap' ? parentRef : undefined,
169
- onResize: updateOverflow
170
- });
171
- (0, $lajJX$useLayoutEffect)(updateOverflow, [
172
- updateOverflow,
173
- state.collection
174
- ]);
175
- let children = [
176
- ...state.collection
177
- ];
178
- let menuItem = null;
179
- let menuProps = {};
180
- // If there are no visible items, don't apply any props to the action group container
181
- // and pass all aria labeling props through to the menu button.
182
- if (overflowMode === 'collapse' && visibleItems === 0) {
183
- menuProps = (0, $lajJX$filterDOMProps)(props, {
184
- labelable: true
185
- });
186
- actionGroupProps = {};
187
- }
188
- if (overflowMode === 'collapse' && visibleItems < state.collection.size) {
189
- let menuChildren = children.slice(visibleItems);
190
- children = children.slice(0, visibleItems);
191
- menuItem = /*#__PURE__*/ (0, $lajJX$react).createElement($a04ee251ffcc2690$var$ActionGroupMenu, {
192
- ...menuProps,
193
- items: menuChildren,
194
- onAction: onAction,
195
- isDisabled: isDisabled,
196
- isEmphasized: isEmphasized,
197
- staticColor: staticColor,
198
- state: state,
199
- summaryIcon: summaryIcon,
200
- hideButtonText: hideButtonText,
201
- isOnlyItem: visibleItems === 0,
202
- orientation: orientation
203
- });
204
- }
205
- let style = {
206
- ...styleProps.style,
207
- // While measuring, take up as much space as possible.
208
- flexBasis: isMeasuring ? '100%' : undefined
209
- };
210
- return /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$FocusScope), null, /*#__PURE__*/ (0, $lajJX$react).createElement("div", {
211
- ...styleProps,
212
- style: style,
213
- className: (0, $lajJX$classNames)((0, ($parcel$interopDefault($lajJX$actiongroup_vars_cssmodulejs))), 'flex-container', styleProps.className),
214
- ref: wrapperRef
215
- }, /*#__PURE__*/ (0, $lajJX$react).createElement("div", {
216
- ...actionGroupProps,
217
- ref: domRef,
218
- className: (0, $lajJX$classNames)((0, ($parcel$interopDefault($lajJX$actiongroup_vars_cssmodulejs))), 'flex-gap', 'spectrum-ActionGroup', {
219
- 'spectrum-ActionGroup--quiet': isQuiet,
220
- 'spectrum-ActionGroup--vertical': isVertical,
221
- 'spectrum-ActionGroup--compact': density === 'compact',
222
- 'spectrum-ActionGroup--justified': isJustified && !isMeasuring,
223
- 'spectrum-ActionGroup--overflowCollapse': overflowMode === 'collapse'
224
- }, otherProps.UNSAFE_className)
225
- }, /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$Provider), providerProps, children.map((item)=>/*#__PURE__*/ (0, $lajJX$react).createElement($a04ee251ffcc2690$var$ActionGroupItem, {
226
- key: item.key,
227
- onAction: onAction,
228
- isDisabled: isDisabled,
229
- isEmphasized: isEmphasized,
230
- staticColor: staticColor,
231
- item: item,
232
- state: state,
233
- hideButtonText: hideButtonText,
234
- orientation: orientation
235
- })), menuItem))));
236
- });
237
- function $a04ee251ffcc2690$var$ActionGroupItem({ item: item, state: state, isDisabled: isDisabled, isEmphasized: isEmphasized, staticColor: staticColor, onAction: onAction, hideButtonText: hideButtonText, orientation: orientation }) {
238
- let ref = (0, $lajJX$useRef)(null);
239
- let { buttonProps: buttonProps } = (0, $lajJX$useActionGroupItem)({
240
- key: item.key
241
- }, state);
242
- isDisabled = isDisabled || state.disabledKeys.has(item.key);
243
- let isSelected = state.selectionManager.isSelected(item.key);
244
- let { hoverProps: hoverProps, isHovered: isHovered } = (0, $lajJX$useHover)({
245
- isDisabled: isDisabled
246
- });
247
- let domProps = (0, $lajJX$filterDOMProps)(item.props);
248
- if (onAction && !isDisabled) buttonProps = (0, $lajJX$mergeProps)(buttonProps, {
249
- onPress: ()=>onAction(item.key)
250
- });
251
- // If button text is hidden, we need to show it as a tooltip instead, so
252
- // go find the text element in the DOM after rendering.
253
- let textId = (0, $lajJX$useId)();
254
- let [textContent, setTextContent] = (0, $lajJX$useState)('');
255
- (0, $lajJX$useLayoutEffect)(()=>{
256
- var _document_getElementById;
257
- if (hideButtonText) setTextContent((_document_getElementById = document.getElementById(textId)) === null || _document_getElementById === void 0 ? void 0 : _document_getElementById.textContent);
258
- }, [
259
- hideButtonText,
260
- item.rendered,
261
- textId
262
- ]);
263
- let button = // Use a PressResponder to send DOM props through.
264
- // ActionButton doesn't allow overriding the role by default.
265
- /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$PressResponder), (0, $lajJX$mergeProps)(buttonProps, hoverProps, domProps), /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$ClearSlots), null, /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$SlotProvider), {
266
- slots: {
267
- text: {
268
- id: hideButtonText ? textId : null,
269
- isHidden: hideButtonText
270
- }
271
- }
272
- }, /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$ActionButton), {
273
- ref: ref,
274
- // @ts-ignore (private)
275
- hideButtonText: hideButtonText,
276
- UNSAFE_className: (0, $lajJX$classNames)((0, ($parcel$interopDefault($lajJX$actiongroup_vars_cssmodulejs))), 'spectrum-ActionGroup-item', {
277
- 'is-selected': isSelected,
278
- 'is-hovered': isHovered,
279
- 'spectrum-ActionGroup-item--iconOnly': hideButtonText,
280
- 'spectrum-ActionGroup-item--isDisabled': isDisabled
281
- }, (0, $lajJX$classNames)((0, ($parcel$interopDefault($lajJX$button_vars_cssmodulejs))), {
282
- 'spectrum-ActionButton--emphasized': isEmphasized,
283
- 'is-selected': isSelected
284
- })),
285
- isDisabled: isDisabled,
286
- staticColor: staticColor,
287
- "aria-label": item['aria-label'],
288
- "aria-labelledby": item['aria-label'] == null && hideButtonText ? textId : undefined
289
- }, item.rendered))));
290
- if (hideButtonText && textContent) button = /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$TooltipTrigger), {
291
- placement: orientation === 'vertical' ? 'end' : 'top'
292
- }, button, /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$Tooltip), null, textContent));
293
- if (item.wrapper) button = item.wrapper(button);
294
- return button;
295
- }
296
- function $a04ee251ffcc2690$var$ActionGroupMenu({ state: state, isDisabled: isDisabled, isEmphasized: isEmphasized, staticColor: staticColor, items: items, onAction: onAction, summaryIcon: summaryIcon, hideButtonText: hideButtonText, isOnlyItem: isOnlyItem, orientation: orientation, ...otherProps }) {
297
- // Use the key of the first item within the menu as the key of the button.
298
- // The key must actually exist in the collection for focus to work correctly.
299
- let key = items[0].key;
300
- let { buttonProps: buttonProps } = (0, $lajJX$useActionGroupItem)({
301
- key: key
302
- }, state);
303
- let stringFormatter = (0, $lajJX$useLocalizedStringFormatter)((0, ($parcel$interopDefault($lajJX$intlStringsmodulejs))), '@react-spectrum/actiongroup');
304
- // The menu button shouldn't act like an actual action group item.
305
- delete buttonProps.onPress;
306
- delete buttonProps.role;
307
- delete buttonProps['aria-checked'];
308
- let { hoverProps: hoverProps, isHovered: isHovered } = (0, $lajJX$useHover)({
309
- isDisabled: isDisabled
310
- });
311
- // If no aria-label or aria-labelledby is given, provide a default one.
312
- let ariaLabel = otherProps['aria-label'] || (otherProps['aria-labelledby'] ? undefined : stringFormatter.format('more'));
313
- let ariaLabelledby = otherProps['aria-labelledby'];
314
- let textId = (0, $lajJX$useId)();
315
- let id = (0, $lajJX$useId)();
316
- // Summary icon only applies when selection is enabled.
317
- if (state.selectionManager.selectionMode === 'none') summaryIcon = null;
318
- let iconOnly = false;
319
- // If there is a selection, show the selected state on the menu button.
320
- let isSelected = state.selectionManager.selectionMode !== 'none' && !state.selectionManager.isEmpty;
321
- // If single selection and empty selection is not allowed, swap the contents of the button to the selected item (like a Picker).
322
- if (!summaryIcon && state.selectionManager.selectionMode === 'single' && state.selectionManager.disallowEmptySelection && state.selectionManager.firstSelectedKey != null) {
323
- let selectedItem = state.collection.getItem(state.selectionManager.firstSelectedKey);
324
- if (selectedItem) {
325
- summaryIcon = selectedItem.rendered;
326
- if (typeof summaryIcon === 'string') summaryIcon = /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$Text), null, summaryIcon);
327
- iconOnly = !!hideButtonText;
328
- ariaLabelledby = `${ariaLabelledby !== null && ariaLabelledby !== void 0 ? ariaLabelledby : id} ${textId}`;
329
- }
330
- }
331
- if (summaryIcon) // If there's a custom summary icon, also add a chevron.
332
- summaryIcon = /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$react).Fragment, null, /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$spectrumiconsuiChevronDownMedium), {
333
- UNSAFE_className: (0, $lajJX$classNames)((0, ($parcel$interopDefault($lajJX$actiongroup_vars_cssmodulejs))), 'spectrum-ActionGroup-menu-chevron')
334
- }), /*#__PURE__*/ (0, $lajJX$react).createElement("span", {
335
- className: (0, $lajJX$classNames)((0, ($parcel$interopDefault($lajJX$actiongroup_vars_cssmodulejs))), 'spectrum-ActionGroup-menu-contents', {
336
- 'spectrum-ActionGroup-item--iconOnly': iconOnly
337
- })
338
- }, summaryIcon));
339
- return(// Use a PressResponder to send DOM props through.
340
- /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$MenuTrigger), {
341
- align: isOnlyItem ? 'start' : 'end',
342
- direction: orientation === 'vertical' ? 'end' : 'bottom'
343
- }, /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$SlotProvider), {
344
- slots: {
345
- text: {
346
- id: hideButtonText ? textId : null,
347
- isHidden: hideButtonText,
348
- UNSAFE_className: (0, $lajJX$classNames)((0, ($parcel$interopDefault($lajJX$actiongroup_vars_cssmodulejs))), 'spectrum-ActionGroup-menu-text')
349
- }
350
- }
351
- }, /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$PressResponder), (0, $lajJX$mergeProps)(buttonProps, hoverProps), /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$ActionButton), {
352
- ...otherProps,
353
- id: id,
354
- "aria-label": ariaLabel,
355
- "aria-labelledby": ariaLabelledby,
356
- UNSAFE_className: (0, $lajJX$classNames)((0, ($parcel$interopDefault($lajJX$actiongroup_vars_cssmodulejs))), 'spectrum-ActionGroup-item', 'spectrum-ActionGroup-menu', {
357
- 'is-hovered': isHovered,
358
- 'is-selected': isSelected
359
- }, (0, $lajJX$classNames)((0, ($parcel$interopDefault($lajJX$button_vars_cssmodulejs))), {
360
- 'is-selected': isSelected,
361
- 'spectrum-ActionButton--emphasized': isEmphasized
362
- })),
363
- isDisabled: isDisabled,
364
- staticColor: staticColor
365
- }, summaryIcon || /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$spectrumiconsworkflowMore), null)))), /*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$Menu), {
366
- items: items,
367
- disabledKeys: state.disabledKeys,
368
- selectionMode: state.selectionManager.selectionMode,
369
- selectedKeys: state.selectionManager.selectedKeys,
370
- disallowEmptySelection: state.selectionManager.disallowEmptySelection,
371
- onSelectionChange: (keys)=>state.selectionManager.setSelectedKeys(keys),
372
- onAction: onAction
373
- }, (node)=>/*#__PURE__*/ (0, $lajJX$react).createElement((0, $lajJX$Item), {
374
- textValue: node.textValue,
375
- ...(0, $lajJX$filterDOMProps)(node.props)
376
- }, node.rendered))));
377
- }
378
- function $a04ee251ffcc2690$var$outerWidth(element, ignoreLeftMargin, ignoreRightMargin) {
379
- let style = window.getComputedStyle(element);
380
- return element.getBoundingClientRect().width + (ignoreLeftMargin ? 0 : $a04ee251ffcc2690$var$toNumber(style.marginLeft)) + (ignoreRightMargin ? 0 : $a04ee251ffcc2690$var$toNumber(style.marginRight));
381
- }
382
- function $a04ee251ffcc2690$var$outerHeight(element, ignoreTopMargin, ignoreBottomMargin) {
383
- let style = window.getComputedStyle(element);
384
- return element.getBoundingClientRect().height + (ignoreTopMargin ? 0 : $a04ee251ffcc2690$var$toNumber(style.marginTop)) + (ignoreBottomMargin ? 0 : $a04ee251ffcc2690$var$toNumber(style.marginBottom));
385
- }
386
- function $a04ee251ffcc2690$var$toNumber(value) {
387
- let parsed = parseInt(value, 10);
388
- return isNaN(parsed) ? 0 : parsed;
389
- }
390
-
391
-
392
- export {$a04ee251ffcc2690$export$c21a5597f732a168 as ActionGroup};
393
- //# sourceMappingURL=ActionGroup.module.js.map