@chayns-components/core 5.0.57 → 5.0.59

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 (24) hide show
  1. package/AGENTS.md +37 -0
  2. package/lib/cjs/components/multi-action-button/MultiActionButton.js +133 -32
  3. package/lib/cjs/components/multi-action-button/MultiActionButton.js.map +1 -1
  4. package/lib/cjs/components/multi-action-button/MultiActionButton.styles.js +16 -2
  5. package/lib/cjs/components/multi-action-button/MultiActionButton.styles.js.map +1 -1
  6. package/lib/cjs/components/multi-action-button/MultiActionButton.types.js.map +1 -1
  7. package/lib/cjs/components/multi-action-button/MultiActionButton.utils.js +85 -1
  8. package/lib/cjs/components/multi-action-button/MultiActionButton.utils.js.map +1 -1
  9. package/lib/cjs/hooks/container.js +2 -1
  10. package/lib/cjs/hooks/container.js.map +1 -1
  11. package/lib/esm/components/multi-action-button/MultiActionButton.js +135 -34
  12. package/lib/esm/components/multi-action-button/MultiActionButton.js.map +1 -1
  13. package/lib/esm/components/multi-action-button/MultiActionButton.styles.js +16 -2
  14. package/lib/esm/components/multi-action-button/MultiActionButton.styles.js.map +1 -1
  15. package/lib/esm/components/multi-action-button/MultiActionButton.types.js.map +1 -1
  16. package/lib/esm/components/multi-action-button/MultiActionButton.utils.js +81 -0
  17. package/lib/esm/components/multi-action-button/MultiActionButton.utils.js.map +1 -1
  18. package/lib/esm/hooks/container.js +2 -1
  19. package/lib/esm/hooks/container.js.map +1 -1
  20. package/lib/types/components/multi-action-button/MultiActionButton.styles.d.ts +1 -0
  21. package/lib/types/components/multi-action-button/MultiActionButton.types.d.ts +8 -0
  22. package/lib/types/components/multi-action-button/MultiActionButton.utils.d.ts +22 -0
  23. package/lib/types/hooks/container.d.ts +2 -1
  24. package/package.json +2 -2
package/AGENTS.md CHANGED
@@ -3320,6 +3320,43 @@ import { MultiActionButton } from '@chayns-components/core';
3320
3320
  />
3321
3321
  ```
3322
3322
 
3323
+ #### Auto Collapse Responsive
3324
+
3325
+ ```tsx
3326
+ <MultiActionButton
3327
+ isDisabled={false}
3328
+ extendedTimeoutMs={2000}
3329
+ primaryAction={{
3330
+ icon: 'fa fa-pen',
3331
+ label: 'Chatten',
3332
+ }}
3333
+ secondaryAction={{
3334
+ icon: 'fa fa-microphone',
3335
+ label: 'Mitschnitt starten',
3336
+ }}
3337
+ shouldAutoCollapse
3338
+ />
3339
+ ```
3340
+
3341
+ #### Auto Collapse Responsive Full Width
3342
+
3343
+ ```tsx
3344
+ <MultiActionButton
3345
+ isDisabled={false}
3346
+ extendedTimeoutMs={2000}
3347
+ primaryAction={{
3348
+ icon: 'fa fa-pen',
3349
+ label: 'Chatten',
3350
+ }}
3351
+ secondaryAction={{
3352
+ icon: 'fa fa-microphone',
3353
+ label: 'Mitschnitt starten',
3354
+ }}
3355
+ shouldAutoCollapse
3356
+ shouldUseFullWidth
3357
+ />
3358
+ ```
3359
+
3323
3360
  #### Pulsing Secondary
3324
3361
 
3325
3362
  ```tsx
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _clsx = _interopRequireDefault(require("clsx"));
8
8
  var _react = _interopRequireWildcard(require("react"));
9
+ var _element = require("../../hooks/element");
9
10
  var _environment = require("../../utils/environment");
10
11
  var _ContextMenu = _interopRequireDefault(require("../context-menu/ContextMenu"));
11
12
  var _ActionButton = _interopRequireDefault(require("./action-button/ActionButton"));
@@ -18,6 +19,42 @@ const SECONDARY_CONTEXT_MENU_ACTION = {
18
19
  icon: 'fa fa-chevron-down',
19
20
  label: undefined
20
21
  };
22
+ const createMeasuredMultiActionButtonContent = ({
23
+ backgroundColor,
24
+ gapColor,
25
+ height,
26
+ primaryAction,
27
+ secondaryAction
28
+ }) => /*#__PURE__*/_react.default.createElement(_MultiActionButton.StyledMultiActionButton, {
29
+ style: {
30
+ width: 'fit-content'
31
+ }
32
+ }, /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
33
+ action: primaryAction,
34
+ actionType: "primary",
35
+ backgroundColor: primaryAction.backgroundColor ?? backgroundColor,
36
+ isCollapsed: false,
37
+ isDisabled: false,
38
+ isShrunk: false,
39
+ isSolo: !secondaryAction,
40
+ showLabel: true,
41
+ shouldUseContentWidth: true,
42
+ height: height
43
+ }), secondaryAction && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_MultiActionButton.StyledSeparator, {
44
+ $gapColor: gapColor,
45
+ $isHidden: false
46
+ }), /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
47
+ action: secondaryAction,
48
+ actionType: "secondary",
49
+ backgroundColor: secondaryAction.backgroundColor ?? backgroundColor,
50
+ isCollapsed: false,
51
+ isDisabled: false,
52
+ isExpanded: false,
53
+ isHidden: false,
54
+ showLabel: false,
55
+ shouldUseContentWidth: true,
56
+ height: height
57
+ })));
21
58
 
22
59
  /**
23
60
  * Multi-action button with optional secondary action that can expand on hover/click.
@@ -33,6 +70,7 @@ const MultiActionButton = ({
33
70
  primaryAction,
34
71
  secondaryAction,
35
72
  secondaryContextMenu,
73
+ shouldAutoCollapse = false,
36
74
  shouldUseFullWidth,
37
75
  width
38
76
  }) => {
@@ -40,18 +78,73 @@ const MultiActionButton = ({
40
78
  const [isSecondaryExpanded, setIsSecondaryExpanded] = (0, _react.useState)(false);
41
79
  const [isSecondaryHovered, setIsSecondaryHovered] = (0, _react.useState)(false);
42
80
  const autoCollapseTimeoutRef = (0, _react.useRef)(null);
81
+ const multiActionButtonRef = (0, _react.useRef)(null);
43
82
  const secondaryContextMenuRef = (0, _react.useRef)(null);
83
+ const [autoCollapseMode, setAutoCollapseMode] = (0, _react.useState)(_MultiActionButton2.MultiActionButtonAutoCollapseMode.Expanded);
44
84
  const isTouch = (0, _environment.useIsTouch)();
85
+ const parentSize = (0, _element.useElementSize)(multiActionButtonRef, {
86
+ shouldUseParentElement: true
87
+ });
45
88
  const hasSecondaryContextMenu = Boolean(secondaryContextMenu === null || secondaryContextMenu === void 0 ? void 0 : secondaryContextMenu.length);
89
+ const secondaryTriggerAction = hasSecondaryContextMenu ? SECONDARY_CONTEXT_MENU_ACTION : secondaryAction;
46
90
  const hasExpandableSecondaryAction = Boolean(secondaryAction) && !hasSecondaryContextMenu;
47
- const hasSecondaryAction = hasExpandableSecondaryAction || hasSecondaryContextMenu;
48
- const resolvedSecondaryAction = hasSecondaryContextMenu ? SECONDARY_CONTEXT_MENU_ACTION : secondaryAction;
91
+ const hasSecondaryAction = Boolean(secondaryTriggerAction);
49
92
  const shouldUseContentWidth = !width && !shouldUseFullWidth;
50
- const resolvedWidth = isCollapsed ? height : width ?? (shouldUseFullWidth ? '100%' : 'fit-content');
93
+ const expandedMeasuredContent = (0, _react.useMemo)(() => createMeasuredMultiActionButtonContent({
94
+ backgroundColor,
95
+ gapColor,
96
+ height,
97
+ primaryAction,
98
+ secondaryAction: secondaryTriggerAction
99
+ }), [backgroundColor, gapColor, height, primaryAction, secondaryTriggerAction]);
100
+ const {
101
+ measuredElement,
102
+ width: expandedMeasuredWidth
103
+ } = (0, _element.useMeasuredClone)({
104
+ content: expandedMeasuredContent
105
+ });
106
+ const availableWidth = (0, _react.useMemo)(() => {
107
+ const parentWidth = parentSize === null || parentSize === void 0 ? void 0 : parentSize.width;
108
+ if (typeof width === 'number') {
109
+ return typeof parentWidth === 'number' ? Math.min(parentWidth, width) : width;
110
+ }
111
+ return parentWidth;
112
+ }, [parentSize === null || parentSize === void 0 ? void 0 : parentSize.width, width]);
113
+ (0, _react.useEffect)(() => {
114
+ if (!shouldAutoCollapse || isCollapsed) {
115
+ setAutoCollapseMode(_MultiActionButton2.MultiActionButtonAutoCollapseMode.Expanded);
116
+ return;
117
+ }
118
+ if (expandedMeasuredWidth <= 0) {
119
+ return;
120
+ }
121
+ setAutoCollapseMode(previousMode => (0, _MultiActionButton2.getMultiActionButtonAutoCollapseMode)({
122
+ availableWidth,
123
+ expandedWidth: expandedMeasuredWidth,
124
+ hasSecondaryAction,
125
+ height,
126
+ previousMode
127
+ }));
128
+ }, [availableWidth, expandedMeasuredWidth, hasSecondaryAction, height, isCollapsed, shouldAutoCollapse]);
129
+ const isAutoIconsOnly = shouldAutoCollapse && autoCollapseMode === _MultiActionButton2.MultiActionButtonAutoCollapseMode.IconsOnly;
130
+ const isAutoPrimaryOnly = shouldAutoCollapse && autoCollapseMode === _MultiActionButton2.MultiActionButtonAutoCollapseMode.PrimaryOnly;
131
+ const shouldKeepFullWidth = Boolean(shouldUseFullWidth);
132
+ const shouldHideSecondaryForAutoCollapse = hasSecondaryAction && isAutoPrimaryOnly;
133
+ const effectiveIsCollapsed = isCollapsed || !shouldKeepFullWidth && isAutoPrimaryOnly;
134
+ const resolvedSecondaryAction = hasSecondaryAction ? secondaryTriggerAction : undefined;
135
+ const isSecondaryHidden = effectiveIsCollapsed || shouldHideSecondaryForAutoCollapse;
136
+ const shouldPreventSecondaryExpansion = isAutoIconsOnly || isSecondaryHidden;
137
+ const shouldKeepPrimaryLabelVisible = shouldKeepFullWidth && shouldAutoCollapse;
138
+ const minimumPrimaryLabelVisibleWidth = (0, _MultiActionButton2.getMinimumPrimaryLabelVisibleWidth)({
139
+ hasVisibleSecondaryAction: hasSecondaryAction,
140
+ height
141
+ });
142
+ const shouldHidePrimaryLabelForMinimumWidth = shouldKeepPrimaryLabelVisible && typeof availableWidth === 'number' && availableWidth <= minimumPrimaryLabelVisibleWidth;
143
+ const resolvedWidth = shouldKeepFullWidth ? '100%' : effectiveIsCollapsed ? height : width ?? 'fit-content';
51
144
  const secondaryContextMenuTriggerStyle = (0, _MultiActionButton2.getSecondaryContextMenuTriggerStyle)({
52
145
  height,
53
- isCollapsed,
54
- isExpanded: isSecondaryExpanded,
146
+ isCollapsed: isSecondaryHidden,
147
+ isExpanded: false,
55
148
  shouldUseContentWidth
56
149
  });
57
150
 
@@ -99,11 +192,13 @@ const MultiActionButton = ({
99
192
  * Collapsing the control should also reset any temporary expansion state.
100
193
  */
101
194
  (0, _react.useEffect)(() => {
102
- if (isCollapsed) {
195
+ if (effectiveIsCollapsed || shouldPreventSecondaryExpansion) {
196
+ clearAutoCollapseTimeout();
103
197
  setIsSecondaryExpanded(false);
104
198
  setIsExtendedByClick(false);
199
+ setIsSecondaryHovered(false);
105
200
  }
106
- }, [isCollapsed]);
201
+ }, [clearAutoCollapseTimeout, effectiveIsCollapsed, shouldPreventSecondaryExpansion]);
107
202
 
108
203
  /**
109
204
  * Handler for the primary action button.
@@ -127,7 +222,7 @@ const MultiActionButton = ({
127
222
  */
128
223
  const handleSecondaryClick = (0, _react.useCallback)(event => {
129
224
  var _resolvedSecondaryAct;
130
- if (!resolvedSecondaryAction || isCollapsed || isDisabled || resolvedSecondaryAction.isDisabled) {
225
+ if (!resolvedSecondaryAction || isSecondaryHidden || isDisabled || resolvedSecondaryAction.isDisabled) {
131
226
  return;
132
227
  }
133
228
  if (hasSecondaryContextMenu) {
@@ -142,37 +237,40 @@ const MultiActionButton = ({
142
237
  isTouch
143
238
  };
144
239
  (_resolvedSecondaryAct = resolvedSecondaryAction.onClick) === null || _resolvedSecondaryAct === void 0 || _resolvedSecondaryAct.call(resolvedSecondaryAction, payload);
145
- expandSecondaryByClick();
146
- }, [expandSecondaryByClick, hasSecondaryContextMenu, isCollapsed, isDisabled, isSecondaryExpanded, isTouch, resolvedSecondaryAction]);
240
+ if (!shouldPreventSecondaryExpansion) {
241
+ expandSecondaryByClick();
242
+ }
243
+ }, [expandSecondaryByClick, hasSecondaryContextMenu, isSecondaryHidden, isDisabled, isSecondaryExpanded, isTouch, resolvedSecondaryAction, shouldPreventSecondaryExpansion]);
147
244
 
148
245
  /**
149
246
  * Desktop hover behavior keeps the secondary action expanded while hovered.
150
247
  */
151
248
  const handleSecondaryMouseEnter = (0, _react.useCallback)(() => {
152
- if (!secondaryAction || isCollapsed || isTouch || isDisabled || secondaryAction.isDisabled) {
249
+ if (!secondaryAction || isSecondaryHidden || isTouch || isDisabled || shouldPreventSecondaryExpansion || secondaryAction.isDisabled) {
153
250
  return;
154
251
  }
155
252
  setIsSecondaryHovered(true);
156
253
  if (!isExtendedByClick) {
157
254
  setIsSecondaryExpanded(true);
158
255
  }
159
- }, [isCollapsed, isDisabled, isExtendedByClick, isTouch, secondaryAction]);
256
+ }, [isSecondaryHidden, isDisabled, isExtendedByClick, isTouch, secondaryAction, shouldPreventSecondaryExpansion]);
160
257
  const handleSecondaryMouseLeave = (0, _react.useCallback)(() => {
161
258
  if (isTouch) {
162
259
  return;
163
260
  }
164
261
  setIsSecondaryHovered(false);
165
- if (!isExtendedByClick && !isCollapsed) {
262
+ if (!isExtendedByClick && !effectiveIsCollapsed) {
166
263
  setIsSecondaryExpanded(false);
167
264
  }
168
- }, [isCollapsed, isExtendedByClick, isTouch]);
265
+ }, [effectiveIsCollapsed, isExtendedByClick, isTouch]);
169
266
 
170
267
  /**
171
268
  * Secondary label is visible when expanded or when hovered (desktop only).
172
269
  */
173
270
  const isSecondaryLabelVisible = isSecondaryExpanded || !isTouch && isSecondaryHovered;
174
- return /*#__PURE__*/_react.default.createElement(_MultiActionButton.StyledMultiActionButton, {
271
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, measuredElement, /*#__PURE__*/_react.default.createElement(_MultiActionButton.StyledMultiActionButton, {
175
272
  className: (0, _clsx.default)('beta-chayns-multi-action', className),
273
+ ref: multiActionButtonRef,
176
274
  style: {
177
275
  maxWidth: '100%',
178
276
  width: resolvedWidth
@@ -181,16 +279,17 @@ const MultiActionButton = ({
181
279
  action: primaryAction,
182
280
  actionType: "primary",
183
281
  backgroundColor: primaryAction.backgroundColor ?? backgroundColor,
184
- isCollapsed: isCollapsed,
282
+ isCollapsed: effectiveIsCollapsed,
185
283
  isDisabled: isDisabled,
186
- isShrunk: hasExpandableSecondaryAction && isSecondaryExpanded,
187
- isSolo: !hasSecondaryAction && !isCollapsed,
284
+ isShrunk: hasSecondaryAction && (!shouldKeepFullWidth && isAutoIconsOnly || isSecondaryExpanded),
285
+ isSolo: !hasSecondaryAction || isSecondaryHidden || effectiveIsCollapsed,
188
286
  onClick: handlePrimaryClick,
189
- showLabel: !isCollapsed && (!hasExpandableSecondaryAction || !isSecondaryExpanded),
287
+ showLabel: !effectiveIsCollapsed && !shouldHidePrimaryLabelForMinimumWidth && (shouldKeepPrimaryLabelVisible || !isAutoIconsOnly) && (shouldKeepPrimaryLabelVisible || !shouldHideSecondaryForAutoCollapse) && (!hasExpandableSecondaryAction || !isSecondaryExpanded),
190
288
  shouldUseContentWidth: shouldUseContentWidth,
191
289
  height: height
192
- }), resolvedSecondaryAction && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !isCollapsed && /*#__PURE__*/_react.default.createElement(_MultiActionButton.StyledSeparator, {
193
- $gapColor: gapColor
290
+ }), hasSecondaryAction && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_MultiActionButton.StyledSeparator, {
291
+ $gapColor: gapColor,
292
+ $isHidden: isSecondaryHidden
194
293
  }), hasSecondaryContextMenu ? /*#__PURE__*/_react.default.createElement(_ContextMenu.default, {
195
294
  items: secondaryContextMenu ?? [],
196
295
  ref: secondaryContextMenuRef,
@@ -200,32 +299,34 @@ const MultiActionButton = ({
200
299
  yOffset: -6,
201
300
  style: secondaryContextMenuTriggerStyle
202
301
  }, /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
203
- action: resolvedSecondaryAction,
302
+ action: resolvedSecondaryAction ?? SECONDARY_CONTEXT_MENU_ACTION,
204
303
  actionType: "secondary",
205
- backgroundColor: resolvedSecondaryAction.backgroundColor ?? backgroundColor,
206
- isCollapsed: isCollapsed,
304
+ backgroundColor: (resolvedSecondaryAction === null || resolvedSecondaryAction === void 0 ? void 0 : resolvedSecondaryAction.backgroundColor) ?? backgroundColor,
305
+ isCollapsed: false,
207
306
  isDisabled: isDisabled,
208
307
  isExpanded: false,
209
- isHidden: isCollapsed,
308
+ isHidden: isSecondaryHidden,
309
+ key: "multi-action-secondary-context-menu",
210
310
  onClick: handleSecondaryClick,
211
311
  showLabel: false,
212
312
  shouldUseContentWidth: shouldUseContentWidth,
213
313
  height: height
214
314
  })) : /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
215
- action: resolvedSecondaryAction,
315
+ action: resolvedSecondaryAction ?? secondaryAction ?? SECONDARY_CONTEXT_MENU_ACTION,
216
316
  actionType: "secondary",
217
- backgroundColor: resolvedSecondaryAction.backgroundColor ?? backgroundColor,
218
- isCollapsed: isCollapsed,
317
+ backgroundColor: (resolvedSecondaryAction === null || resolvedSecondaryAction === void 0 ? void 0 : resolvedSecondaryAction.backgroundColor) ?? backgroundColor,
318
+ isCollapsed: false,
219
319
  isDisabled: isDisabled,
220
- isExpanded: isSecondaryExpanded,
221
- isHidden: isCollapsed,
320
+ isExpanded: !isAutoIconsOnly && isSecondaryExpanded,
321
+ isHidden: isSecondaryHidden,
322
+ key: "multi-action-secondary-button",
222
323
  onClick: handleSecondaryClick,
223
324
  onMouseEnter: handleSecondaryMouseEnter,
224
325
  onMouseLeave: handleSecondaryMouseLeave,
225
- showLabel: isSecondaryLabelVisible,
326
+ showLabel: !isSecondaryHidden && !isAutoIconsOnly && isSecondaryLabelVisible,
226
327
  shouldUseContentWidth: shouldUseContentWidth,
227
328
  height: height
228
- })));
329
+ }))));
229
330
  };
230
331
  MultiActionButton.displayName = 'MultiActionButton';
231
332
  var _default = exports.default = MultiActionButton;
@@ -1 +1 @@
1
- {"version":3,"file":"MultiActionButton.js","names":["_clsx","_interopRequireDefault","require","_react","_interopRequireWildcard","_environment","_ContextMenu","_ActionButton","_MultiActionButton","_MultiActionButton2","_MultiActionButton3","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SECONDARY_CONTEXT_MENU_ACTION","icon","label","undefined","MultiActionButton","backgroundColor","className","extendedTimeoutMs","gapColor","height","MultiActionButtonHeight","Medium","isCollapsed","isDisabled","primaryAction","secondaryAction","secondaryContextMenu","shouldUseFullWidth","width","isExtendedByClick","setIsExtendedByClick","useState","isSecondaryExpanded","setIsSecondaryExpanded","isSecondaryHovered","setIsSecondaryHovered","autoCollapseTimeoutRef","useRef","secondaryContextMenuRef","isTouch","useIsTouch","hasSecondaryContextMenu","Boolean","length","hasExpandableSecondaryAction","hasSecondaryAction","resolvedSecondaryAction","shouldUseContentWidth","resolvedWidth","secondaryContextMenuTriggerStyle","getSecondaryContextMenuTriggerStyle","isExpanded","clearAutoCollapseTimeout","useCallback","current","window","clearTimeout","resetAutoCollapseTimeout","setTimeout","expandSecondaryByClick","useEffect","handlePrimaryClick","event","_primaryAction$onClic","payload","action","isExtended","onClick","handleSecondaryClick","_resolvedSecondaryAct","_secondaryContextMenu","show","handleSecondaryMouseEnter","handleSecondaryMouseLeave","isSecondaryLabelVisible","createElement","StyledMultiActionButton","clsx","style","maxWidth","actionType","isShrunk","isSolo","showLabel","Fragment","StyledSeparator","$gapColor","items","ref","shouldDisableClick","shouldUseDefaultTriggerStyles","shouldHidePopupArrow","yOffset","isHidden","onMouseEnter","onMouseLeave","displayName","_default","exports"],"sources":["../../../../src/components/multi-action-button/MultiActionButton.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React, { FC, MouseEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport { useIsTouch } from '../../utils/environment';\nimport ContextMenu from '../context-menu/ContextMenu';\nimport type { ContextMenuRef } from '../context-menu/ContextMenu.types';\nimport ActionButton from './action-button/ActionButton';\nimport { StyledMultiActionButton, StyledSeparator } from './MultiActionButton.styles';\nimport { getSecondaryContextMenuTriggerStyle } from './MultiActionButton.utils';\nimport { MultiActionButtonHeight } from './MultiActionButton.types';\nimport type {\n MultiActionButtonAction,\n MultiActionButtonActionEvent,\n MultiActionButtonProps,\n} from './MultiActionButton.types';\n\nconst SECONDARY_CONTEXT_MENU_ACTION: MultiActionButtonAction = {\n icon: 'fa fa-chevron-down',\n label: undefined,\n};\n\n/**\n * Multi-action button with optional secondary action that can expand on hover/click.\n */\nconst MultiActionButton: FC<MultiActionButtonProps> = ({\n backgroundColor,\n className,\n extendedTimeoutMs = 3000,\n gapColor,\n height = MultiActionButtonHeight.Medium,\n isCollapsed = false,\n isDisabled = false,\n primaryAction,\n secondaryAction,\n secondaryContextMenu,\n shouldUseFullWidth,\n width,\n}) => {\n const [isExtendedByClick, setIsExtendedByClick] = useState(false);\n const [isSecondaryExpanded, setIsSecondaryExpanded] = useState(false);\n const [isSecondaryHovered, setIsSecondaryHovered] = useState(false);\n\n const autoCollapseTimeoutRef = useRef<number | null>(null);\n const secondaryContextMenuRef = useRef<ContextMenuRef>(null);\n\n const isTouch = useIsTouch();\n\n const hasSecondaryContextMenu = Boolean(secondaryContextMenu?.length);\n const hasExpandableSecondaryAction = Boolean(secondaryAction) && !hasSecondaryContextMenu;\n const hasSecondaryAction = hasExpandableSecondaryAction || hasSecondaryContextMenu;\n const resolvedSecondaryAction = hasSecondaryContextMenu\n ? SECONDARY_CONTEXT_MENU_ACTION\n : secondaryAction;\n const shouldUseContentWidth = !width && !shouldUseFullWidth;\n\n const resolvedWidth = isCollapsed\n ? height\n : (width ?? (shouldUseFullWidth ? '100%' : 'fit-content'));\n\n const secondaryContextMenuTriggerStyle = getSecondaryContextMenuTriggerStyle({\n height,\n isCollapsed,\n isExpanded: isSecondaryExpanded,\n shouldUseContentWidth,\n });\n\n /**\n * Clears the current auto-collapse timer without changing visual state.\n */\n const clearAutoCollapseTimeout = useCallback(() => {\n if (autoCollapseTimeoutRef.current) {\n window.clearTimeout(autoCollapseTimeoutRef.current);\n autoCollapseTimeoutRef.current = null;\n }\n }, []);\n\n /**\n * Clears and restarts the auto-collapse timer used after click-triggered expansion.\n */\n const resetAutoCollapseTimeout = useCallback(() => {\n clearAutoCollapseTimeout();\n\n if (extendedTimeoutMs <= 0) {\n return;\n }\n\n autoCollapseTimeoutRef.current = window.setTimeout(() => {\n setIsSecondaryExpanded(false);\n setIsExtendedByClick(false);\n }, extendedTimeoutMs);\n }, [clearAutoCollapseTimeout, extendedTimeoutMs]);\n\n /**\n * Expands the secondary action and remembers that it originated from a click.\n */\n const expandSecondaryByClick = useCallback(() => {\n setIsSecondaryExpanded(true);\n setIsExtendedByClick(true);\n resetAutoCollapseTimeout();\n }, [resetAutoCollapseTimeout]);\n\n /**\n * Cleanup timers on unmount.\n */\n useEffect(\n () => () => {\n clearAutoCollapseTimeout();\n },\n [clearAutoCollapseTimeout],\n );\n\n /**\n * Collapsing the control should also reset any temporary expansion state.\n */\n useEffect(() => {\n if (isCollapsed) {\n setIsSecondaryExpanded(false);\n setIsExtendedByClick(false);\n }\n }, [isCollapsed]);\n\n /**\n * Handler for the primary action button.\n */\n const handlePrimaryClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n if (isDisabled || primaryAction.isDisabled) {\n return;\n }\n\n const payload: MultiActionButtonActionEvent = {\n action: 'primary',\n event,\n isExtended: isSecondaryExpanded,\n isTouch,\n };\n\n primaryAction.onClick?.(payload);\n },\n [isDisabled, isSecondaryExpanded, isTouch, primaryAction],\n );\n\n /**\n * Handler for the secondary action button.\n */\n const handleSecondaryClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n if (\n !resolvedSecondaryAction ||\n isCollapsed ||\n isDisabled ||\n resolvedSecondaryAction.isDisabled\n ) {\n return;\n }\n\n if (hasSecondaryContextMenu) {\n secondaryContextMenuRef.current?.show();\n return;\n }\n\n const payload: MultiActionButtonActionEvent = {\n action: 'secondary',\n event,\n isExtended: isSecondaryExpanded,\n isTouch,\n };\n\n resolvedSecondaryAction.onClick?.(payload);\n expandSecondaryByClick();\n },\n [\n expandSecondaryByClick,\n hasSecondaryContextMenu,\n isCollapsed,\n isDisabled,\n isSecondaryExpanded,\n isTouch,\n resolvedSecondaryAction,\n ],\n );\n\n /**\n * Desktop hover behavior keeps the secondary action expanded while hovered.\n */\n const handleSecondaryMouseEnter = useCallback(() => {\n if (\n !secondaryAction ||\n isCollapsed ||\n isTouch ||\n isDisabled ||\n secondaryAction.isDisabled\n ) {\n return;\n }\n\n setIsSecondaryHovered(true);\n if (!isExtendedByClick) {\n setIsSecondaryExpanded(true);\n }\n }, [isCollapsed, isDisabled, isExtendedByClick, isTouch, secondaryAction]);\n\n const handleSecondaryMouseLeave = useCallback(() => {\n if (isTouch) {\n return;\n }\n\n setIsSecondaryHovered(false);\n if (!isExtendedByClick && !isCollapsed) {\n setIsSecondaryExpanded(false);\n }\n }, [isCollapsed, isExtendedByClick, isTouch]);\n\n /**\n * Secondary label is visible when expanded or when hovered (desktop only).\n */\n const isSecondaryLabelVisible = isSecondaryExpanded || (!isTouch && isSecondaryHovered);\n\n return (\n <StyledMultiActionButton\n className={clsx('beta-chayns-multi-action', className)}\n style={{ maxWidth: '100%', width: resolvedWidth }}\n >\n <ActionButton\n action={primaryAction}\n actionType=\"primary\"\n backgroundColor={primaryAction.backgroundColor ?? backgroundColor}\n isCollapsed={isCollapsed}\n isDisabled={isDisabled}\n isShrunk={hasExpandableSecondaryAction && isSecondaryExpanded}\n isSolo={!hasSecondaryAction && !isCollapsed}\n onClick={handlePrimaryClick}\n showLabel={!isCollapsed && (!hasExpandableSecondaryAction || !isSecondaryExpanded)}\n shouldUseContentWidth={shouldUseContentWidth}\n height={height}\n />\n {resolvedSecondaryAction && (\n <>\n {!isCollapsed && <StyledSeparator $gapColor={gapColor} />}\n {hasSecondaryContextMenu ? (\n <ContextMenu\n items={secondaryContextMenu ?? []}\n ref={secondaryContextMenuRef}\n shouldDisableClick\n shouldUseDefaultTriggerStyles={false}\n shouldHidePopupArrow\n yOffset={-6}\n style={secondaryContextMenuTriggerStyle}\n >\n <ActionButton\n action={resolvedSecondaryAction}\n actionType=\"secondary\"\n backgroundColor={\n resolvedSecondaryAction.backgroundColor ?? backgroundColor\n }\n isCollapsed={isCollapsed}\n isDisabled={isDisabled}\n isExpanded={false}\n isHidden={isCollapsed}\n onClick={handleSecondaryClick}\n showLabel={false}\n shouldUseContentWidth={shouldUseContentWidth}\n height={height}\n />\n </ContextMenu>\n ) : (\n <ActionButton\n action={resolvedSecondaryAction}\n actionType=\"secondary\"\n backgroundColor={\n resolvedSecondaryAction.backgroundColor ?? backgroundColor\n }\n isCollapsed={isCollapsed}\n isDisabled={isDisabled}\n isExpanded={isSecondaryExpanded}\n isHidden={isCollapsed}\n onClick={handleSecondaryClick}\n onMouseEnter={handleSecondaryMouseEnter}\n onMouseLeave={handleSecondaryMouseLeave}\n showLabel={isSecondaryLabelVisible}\n shouldUseContentWidth={shouldUseContentWidth}\n height={height}\n />\n )}\n </>\n )}\n </StyledMultiActionButton>\n );\n};\n\nMultiActionButton.displayName = 'MultiActionButton';\n\nexport default MultiActionButton;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,IAAAK,aAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;AACA,IAAAO,mBAAA,GAAAP,OAAA;AACA,IAAAQ,mBAAA,GAAAR,OAAA;AAAoE,SAAAE,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAA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EAAO,CAClB,CAEP,CAEe,CAAC;AAElC,CAAC;AAEDL,iBAAiB,CAACkF,WAAW,GAAG,mBAAmB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjG,OAAA,GAErCa,iBAAiB","ignoreList":[]}
1
+ {"version":3,"file":"MultiActionButton.js","names":["_clsx","_interopRequireDefault","require","_react","_interopRequireWildcard","_element","_environment","_ContextMenu","_ActionButton","_MultiActionButton","_MultiActionButton2","_MultiActionButton3","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SECONDARY_CONTEXT_MENU_ACTION","icon","label","undefined","createMeasuredMultiActionButtonContent","backgroundColor","gapColor","height","primaryAction","secondaryAction","createElement","StyledMultiActionButton","style","width","action","actionType","isCollapsed","isDisabled","isShrunk","isSolo","showLabel","shouldUseContentWidth","Fragment","StyledSeparator","$gapColor","$isHidden","isExpanded","isHidden","MultiActionButton","className","extendedTimeoutMs","MultiActionButtonHeight","Medium","secondaryContextMenu","shouldAutoCollapse","shouldUseFullWidth","isExtendedByClick","setIsExtendedByClick","useState","isSecondaryExpanded","setIsSecondaryExpanded","isSecondaryHovered","setIsSecondaryHovered","autoCollapseTimeoutRef","useRef","multiActionButtonRef","secondaryContextMenuRef","autoCollapseMode","setAutoCollapseMode","MultiActionButtonAutoCollapseMode","Expanded","isTouch","useIsTouch","parentSize","useElementSize","shouldUseParentElement","hasSecondaryContextMenu","Boolean","length","secondaryTriggerAction","hasExpandableSecondaryAction","hasSecondaryAction","expandedMeasuredContent","useMemo","measuredElement","expandedMeasuredWidth","useMeasuredClone","content","availableWidth","parentWidth","Math","min","useEffect","previousMode","getMultiActionButtonAutoCollapseMode","expandedWidth","isAutoIconsOnly","IconsOnly","isAutoPrimaryOnly","PrimaryOnly","shouldKeepFullWidth","shouldHideSecondaryForAutoCollapse","effectiveIsCollapsed","resolvedSecondaryAction","isSecondaryHidden","shouldPreventSecondaryExpansion","shouldKeepPrimaryLabelVisible","minimumPrimaryLabelVisibleWidth","getMinimumPrimaryLabelVisibleWidth","hasVisibleSecondaryAction","shouldHidePrimaryLabelForMinimumWidth","resolvedWidth","secondaryContextMenuTriggerStyle","getSecondaryContextMenuTriggerStyle","clearAutoCollapseTimeout","useCallback","current","window","clearTimeout","resetAutoCollapseTimeout","setTimeout","expandSecondaryByClick","handlePrimaryClick","event","_primaryAction$onClic","payload","isExtended","onClick","handleSecondaryClick","_resolvedSecondaryAct","_secondaryContextMenu","show","handleSecondaryMouseEnter","handleSecondaryMouseLeave","isSecondaryLabelVisible","clsx","ref","maxWidth","items","shouldDisableClick","shouldUseDefaultTriggerStyles","shouldHidePopupArrow","yOffset","key","onMouseEnter","onMouseLeave","displayName","_default","exports"],"sources":["../../../../src/components/multi-action-button/MultiActionButton.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React, {\n FC,\n MouseEvent,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useElementSize, useMeasuredClone } from '../../hooks/element';\nimport { useIsTouch } from '../../utils/environment';\nimport ContextMenu from '../context-menu/ContextMenu';\nimport type { ContextMenuRef } from '../context-menu/ContextMenu.types';\nimport ActionButton from './action-button/ActionButton';\nimport { StyledMultiActionButton, StyledSeparator } from './MultiActionButton.styles';\nimport {\n getMinimumPrimaryLabelVisibleWidth,\n getMultiActionButtonAutoCollapseMode,\n getSecondaryContextMenuTriggerStyle,\n MultiActionButtonAutoCollapseMode,\n} from './MultiActionButton.utils';\nimport { MultiActionButtonHeight } from './MultiActionButton.types';\nimport type {\n MultiActionButtonAction,\n MultiActionButtonActionEvent,\n MultiActionButtonProps,\n} from './MultiActionButton.types';\n\nconst SECONDARY_CONTEXT_MENU_ACTION: MultiActionButtonAction = {\n icon: 'fa fa-chevron-down',\n label: undefined,\n};\n\ninterface CreateMeasuredMultiActionButtonContentOptions {\n backgroundColor?: string;\n gapColor?: string;\n height: number;\n primaryAction: MultiActionButtonAction;\n secondaryAction?: MultiActionButtonAction;\n}\n\nconst createMeasuredMultiActionButtonContent = ({\n backgroundColor,\n gapColor,\n height,\n primaryAction,\n secondaryAction,\n}: CreateMeasuredMultiActionButtonContentOptions): ReactNode => (\n <StyledMultiActionButton style={{ width: 'fit-content' }}>\n <ActionButton\n action={primaryAction}\n actionType=\"primary\"\n backgroundColor={primaryAction.backgroundColor ?? backgroundColor}\n isCollapsed={false}\n isDisabled={false}\n isShrunk={false}\n isSolo={!secondaryAction}\n showLabel\n shouldUseContentWidth\n height={height}\n />\n {secondaryAction && (\n <>\n <StyledSeparator $gapColor={gapColor} $isHidden={false} />\n <ActionButton\n action={secondaryAction}\n actionType=\"secondary\"\n backgroundColor={secondaryAction.backgroundColor ?? backgroundColor}\n isCollapsed={false}\n isDisabled={false}\n isExpanded={false}\n isHidden={false}\n showLabel={false}\n shouldUseContentWidth\n height={height}\n />\n </>\n )}\n </StyledMultiActionButton>\n);\n\n/**\n * Multi-action button with optional secondary action that can expand on hover/click.\n */\nconst MultiActionButton: FC<MultiActionButtonProps> = ({\n backgroundColor,\n className,\n extendedTimeoutMs = 3000,\n gapColor,\n height = MultiActionButtonHeight.Medium,\n isCollapsed = false,\n isDisabled = false,\n primaryAction,\n secondaryAction,\n secondaryContextMenu,\n shouldAutoCollapse = false,\n shouldUseFullWidth,\n width,\n}) => {\n const [isExtendedByClick, setIsExtendedByClick] = useState(false);\n const [isSecondaryExpanded, setIsSecondaryExpanded] = useState(false);\n const [isSecondaryHovered, setIsSecondaryHovered] = useState(false);\n\n const autoCollapseTimeoutRef = useRef<number | null>(null);\n const multiActionButtonRef = useRef<HTMLDivElement | null>(null);\n const secondaryContextMenuRef = useRef<ContextMenuRef>(null);\n const [autoCollapseMode, setAutoCollapseMode] = useState<MultiActionButtonAutoCollapseMode>(\n MultiActionButtonAutoCollapseMode.Expanded,\n );\n\n const isTouch = useIsTouch();\n const parentSize = useElementSize(multiActionButtonRef, { shouldUseParentElement: true });\n\n const hasSecondaryContextMenu = Boolean(secondaryContextMenu?.length);\n const secondaryTriggerAction = hasSecondaryContextMenu\n ? SECONDARY_CONTEXT_MENU_ACTION\n : secondaryAction;\n const hasExpandableSecondaryAction = Boolean(secondaryAction) && !hasSecondaryContextMenu;\n const hasSecondaryAction = Boolean(secondaryTriggerAction);\n const shouldUseContentWidth = !width && !shouldUseFullWidth;\n\n const expandedMeasuredContent = useMemo(\n () =>\n createMeasuredMultiActionButtonContent({\n backgroundColor,\n gapColor,\n height,\n primaryAction,\n secondaryAction: secondaryTriggerAction,\n }),\n [backgroundColor, gapColor, height, primaryAction, secondaryTriggerAction],\n );\n\n const { measuredElement, width: expandedMeasuredWidth } = useMeasuredClone({\n content: expandedMeasuredContent,\n });\n\n const availableWidth = useMemo(() => {\n const parentWidth = parentSize?.width;\n\n if (typeof width === 'number') {\n return typeof parentWidth === 'number' ? Math.min(parentWidth, width) : width;\n }\n\n return parentWidth;\n }, [parentSize?.width, width]);\n\n useEffect(() => {\n if (!shouldAutoCollapse || isCollapsed) {\n setAutoCollapseMode(MultiActionButtonAutoCollapseMode.Expanded);\n return;\n }\n\n if (expandedMeasuredWidth <= 0) {\n return;\n }\n\n setAutoCollapseMode((previousMode) =>\n getMultiActionButtonAutoCollapseMode({\n availableWidth,\n expandedWidth: expandedMeasuredWidth,\n hasSecondaryAction,\n height,\n previousMode,\n }),\n );\n }, [\n availableWidth,\n expandedMeasuredWidth,\n hasSecondaryAction,\n height,\n isCollapsed,\n shouldAutoCollapse,\n ]);\n\n const isAutoIconsOnly =\n shouldAutoCollapse && autoCollapseMode === MultiActionButtonAutoCollapseMode.IconsOnly;\n const isAutoPrimaryOnly =\n shouldAutoCollapse && autoCollapseMode === MultiActionButtonAutoCollapseMode.PrimaryOnly;\n const shouldKeepFullWidth = Boolean(shouldUseFullWidth);\n const shouldHideSecondaryForAutoCollapse = hasSecondaryAction && isAutoPrimaryOnly;\n const effectiveIsCollapsed = isCollapsed || (!shouldKeepFullWidth && isAutoPrimaryOnly);\n const resolvedSecondaryAction = hasSecondaryAction ? secondaryTriggerAction : undefined;\n const isSecondaryHidden = effectiveIsCollapsed || shouldHideSecondaryForAutoCollapse;\n const shouldPreventSecondaryExpansion = isAutoIconsOnly || isSecondaryHidden;\n const shouldKeepPrimaryLabelVisible = shouldKeepFullWidth && shouldAutoCollapse;\n const minimumPrimaryLabelVisibleWidth = getMinimumPrimaryLabelVisibleWidth({\n hasVisibleSecondaryAction: hasSecondaryAction,\n height,\n });\n const shouldHidePrimaryLabelForMinimumWidth =\n shouldKeepPrimaryLabelVisible &&\n typeof availableWidth === 'number' &&\n availableWidth <= minimumPrimaryLabelVisibleWidth;\n\n const resolvedWidth = shouldKeepFullWidth\n ? '100%'\n : effectiveIsCollapsed\n ? height\n : (width ?? 'fit-content');\n\n const secondaryContextMenuTriggerStyle = getSecondaryContextMenuTriggerStyle({\n height,\n isCollapsed: isSecondaryHidden,\n isExpanded: false,\n shouldUseContentWidth,\n });\n\n /**\n * Clears the current auto-collapse timer without changing visual state.\n */\n const clearAutoCollapseTimeout = useCallback(() => {\n if (autoCollapseTimeoutRef.current) {\n window.clearTimeout(autoCollapseTimeoutRef.current);\n autoCollapseTimeoutRef.current = null;\n }\n }, []);\n\n /**\n * Clears and restarts the auto-collapse timer used after click-triggered expansion.\n */\n const resetAutoCollapseTimeout = useCallback(() => {\n clearAutoCollapseTimeout();\n\n if (extendedTimeoutMs <= 0) {\n return;\n }\n\n autoCollapseTimeoutRef.current = window.setTimeout(() => {\n setIsSecondaryExpanded(false);\n setIsExtendedByClick(false);\n }, extendedTimeoutMs);\n }, [clearAutoCollapseTimeout, extendedTimeoutMs]);\n\n /**\n * Expands the secondary action and remembers that it originated from a click.\n */\n const expandSecondaryByClick = useCallback(() => {\n setIsSecondaryExpanded(true);\n setIsExtendedByClick(true);\n resetAutoCollapseTimeout();\n }, [resetAutoCollapseTimeout]);\n\n /**\n * Cleanup timers on unmount.\n */\n useEffect(\n () => () => {\n clearAutoCollapseTimeout();\n },\n [clearAutoCollapseTimeout],\n );\n\n /**\n * Collapsing the control should also reset any temporary expansion state.\n */\n useEffect(() => {\n if (effectiveIsCollapsed || shouldPreventSecondaryExpansion) {\n clearAutoCollapseTimeout();\n setIsSecondaryExpanded(false);\n setIsExtendedByClick(false);\n setIsSecondaryHovered(false);\n }\n }, [clearAutoCollapseTimeout, effectiveIsCollapsed, shouldPreventSecondaryExpansion]);\n\n /**\n * Handler for the primary action button.\n */\n const handlePrimaryClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n if (isDisabled || primaryAction.isDisabled) {\n return;\n }\n\n const payload: MultiActionButtonActionEvent = {\n action: 'primary',\n event,\n isExtended: isSecondaryExpanded,\n isTouch,\n };\n\n primaryAction.onClick?.(payload);\n },\n [isDisabled, isSecondaryExpanded, isTouch, primaryAction],\n );\n\n /**\n * Handler for the secondary action button.\n */\n const handleSecondaryClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n if (\n !resolvedSecondaryAction ||\n isSecondaryHidden ||\n isDisabled ||\n resolvedSecondaryAction.isDisabled\n ) {\n return;\n }\n\n if (hasSecondaryContextMenu) {\n secondaryContextMenuRef.current?.show();\n return;\n }\n\n const payload: MultiActionButtonActionEvent = {\n action: 'secondary',\n event,\n isExtended: isSecondaryExpanded,\n isTouch,\n };\n\n resolvedSecondaryAction.onClick?.(payload);\n if (!shouldPreventSecondaryExpansion) {\n expandSecondaryByClick();\n }\n },\n [\n expandSecondaryByClick,\n hasSecondaryContextMenu,\n isSecondaryHidden,\n isDisabled,\n isSecondaryExpanded,\n isTouch,\n resolvedSecondaryAction,\n shouldPreventSecondaryExpansion,\n ],\n );\n\n /**\n * Desktop hover behavior keeps the secondary action expanded while hovered.\n */\n const handleSecondaryMouseEnter = useCallback(() => {\n if (\n !secondaryAction ||\n isSecondaryHidden ||\n isTouch ||\n isDisabled ||\n shouldPreventSecondaryExpansion ||\n secondaryAction.isDisabled\n ) {\n return;\n }\n\n setIsSecondaryHovered(true);\n if (!isExtendedByClick) {\n setIsSecondaryExpanded(true);\n }\n }, [\n isSecondaryHidden,\n isDisabled,\n isExtendedByClick,\n isTouch,\n secondaryAction,\n shouldPreventSecondaryExpansion,\n ]);\n\n const handleSecondaryMouseLeave = useCallback(() => {\n if (isTouch) {\n return;\n }\n\n setIsSecondaryHovered(false);\n if (!isExtendedByClick && !effectiveIsCollapsed) {\n setIsSecondaryExpanded(false);\n }\n }, [effectiveIsCollapsed, isExtendedByClick, isTouch]);\n\n /**\n * Secondary label is visible when expanded or when hovered (desktop only).\n */\n const isSecondaryLabelVisible = isSecondaryExpanded || (!isTouch && isSecondaryHovered);\n\n return (\n <>\n {measuredElement}\n <StyledMultiActionButton\n className={clsx('beta-chayns-multi-action', className)}\n ref={multiActionButtonRef}\n style={{ maxWidth: '100%', width: resolvedWidth }}\n >\n <ActionButton\n action={primaryAction}\n actionType=\"primary\"\n backgroundColor={primaryAction.backgroundColor ?? backgroundColor}\n isCollapsed={effectiveIsCollapsed}\n isDisabled={isDisabled}\n isShrunk={\n hasSecondaryAction &&\n ((!shouldKeepFullWidth && isAutoIconsOnly) || isSecondaryExpanded)\n }\n isSolo={!hasSecondaryAction || isSecondaryHidden || effectiveIsCollapsed}\n onClick={handlePrimaryClick}\n showLabel={\n !effectiveIsCollapsed &&\n !shouldHidePrimaryLabelForMinimumWidth &&\n (shouldKeepPrimaryLabelVisible || !isAutoIconsOnly) &&\n (shouldKeepPrimaryLabelVisible || !shouldHideSecondaryForAutoCollapse) &&\n (!hasExpandableSecondaryAction || !isSecondaryExpanded)\n }\n shouldUseContentWidth={shouldUseContentWidth}\n height={height}\n />\n {hasSecondaryAction && (\n <>\n <StyledSeparator $gapColor={gapColor} $isHidden={isSecondaryHidden} />\n {hasSecondaryContextMenu ? (\n <ContextMenu\n items={secondaryContextMenu ?? []}\n ref={secondaryContextMenuRef}\n shouldDisableClick\n shouldUseDefaultTriggerStyles={false}\n shouldHidePopupArrow\n yOffset={-6}\n style={secondaryContextMenuTriggerStyle}\n >\n <ActionButton\n action={\n resolvedSecondaryAction ?? SECONDARY_CONTEXT_MENU_ACTION\n }\n actionType=\"secondary\"\n backgroundColor={\n resolvedSecondaryAction?.backgroundColor ?? backgroundColor\n }\n isCollapsed={false}\n isDisabled={isDisabled}\n isExpanded={false}\n isHidden={isSecondaryHidden}\n key=\"multi-action-secondary-context-menu\"\n onClick={handleSecondaryClick}\n showLabel={false}\n shouldUseContentWidth={shouldUseContentWidth}\n height={height}\n />\n </ContextMenu>\n ) : (\n <ActionButton\n action={\n resolvedSecondaryAction ??\n secondaryAction ??\n SECONDARY_CONTEXT_MENU_ACTION\n }\n actionType=\"secondary\"\n backgroundColor={\n resolvedSecondaryAction?.backgroundColor ?? backgroundColor\n }\n isCollapsed={false}\n isDisabled={isDisabled}\n isExpanded={!isAutoIconsOnly && isSecondaryExpanded}\n isHidden={isSecondaryHidden}\n key=\"multi-action-secondary-button\"\n onClick={handleSecondaryClick}\n onMouseEnter={handleSecondaryMouseEnter}\n onMouseLeave={handleSecondaryMouseLeave}\n showLabel={\n !isSecondaryHidden &&\n !isAutoIconsOnly &&\n isSecondaryLabelVisible\n }\n shouldUseContentWidth={shouldUseContentWidth}\n height={height}\n />\n )}\n </>\n )}\n </StyledMultiActionButton>\n </>\n );\n};\n\nMultiActionButton.displayName = 'MultiActionButton';\n\nexport default MultiActionButton;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAUA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,IAAAM,aAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;AACA,IAAAQ,mBAAA,GAAAR,OAAA;AAMA,IAAAS,mBAAA,GAAAT,OAAA;AAAoE,SAAAE,wB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OAAA,CAAAzI,OAAA,GAErCqC,iBAAiB","ignoreList":[]}
@@ -11,6 +11,8 @@ const StyledMultiActionButton = exports.StyledMultiActionButton = (0, _styledCom
11
11
  align-items: stretch;
12
12
  display: inline-flex;
13
13
  max-width: 100%;
14
+ min-width: 0;
15
+ overflow: hidden;
14
16
  position: relative;
15
17
  transition: width 0.2s ease;
16
18
  width: fit-content;
@@ -21,7 +23,19 @@ const StyledSeparator = exports.StyledSeparator = _styledComponents.default.span
21
23
  $gapColor,
22
24
  theme
23
25
  }) => $gapColor || (theme === null || theme === void 0 ? void 0 : theme['cw-body-background']) || '#fff'};
24
- flex: 0 0 1px;
25
- width: 1px;
26
+ flex: 0 0 ${({
27
+ $isHidden
28
+ }) => $isHidden ? 0 : 1}px;
29
+ opacity: ${({
30
+ $isHidden
31
+ }) => $isHidden ? 0 : 1};
32
+ overflow: hidden;
33
+ transition:
34
+ flex-basis 0.2s ease,
35
+ opacity 0.2s ease,
36
+ width 0.2s ease;
37
+ width: ${({
38
+ $isHidden
39
+ }) => $isHidden ? 0 : 1}px;
26
40
  `;
27
41
  //# sourceMappingURL=MultiActionButton.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MultiActionButton.styles.js","names":["_react","require","_styledComponents","_interopRequireDefault","e","__esModule","default","StyledMultiActionButton","exports","styled","motion","div","StyledSeparator","span","$gapColor","theme"],"sources":["../../../../src/components/multi-action-button/MultiActionButton.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledMultiActionButton = styled(motion.div)`\n align-items: stretch;\n display: inline-flex;\n max-width: 100%;\n position: relative;\n transition: width 0.2s ease;\n width: fit-content;\n`;\n\ntype StyledSeparatorProps = WithTheme<{\n $gapColor?: string;\n}>;\n\nexport const StyledSeparator = styled.span<StyledSeparatorProps>`\n align-self: stretch;\n background: ${({ $gapColor, theme }) => $gapColor || theme?.['cw-body-background'] || '#fff'};\n flex: 0 0 1px;\n width: 1px;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGhC,MAAMG,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,IAAAE,yBAAM,EAACC,aAAM,CAACC,GAAG,CAAC;AACzD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAMM,MAAMC,eAAe,GAAAJ,OAAA,CAAAI,eAAA,GAAGH,yBAAM,CAACI,IAA0B;AAChE;AACA,kBAAkB,CAAC;EAAEC,SAAS;EAAEC;AAAM,CAAC,KAAKD,SAAS,KAAIC,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAG,oBAAoB,CAAC,KAAI,MAAM;AAChG;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"MultiActionButton.styles.js","names":["_react","require","_styledComponents","_interopRequireDefault","e","__esModule","default","StyledMultiActionButton","exports","styled","motion","div","StyledSeparator","span","$gapColor","theme","$isHidden"],"sources":["../../../../src/components/multi-action-button/MultiActionButton.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledMultiActionButton = styled(motion.div)`\n align-items: stretch;\n display: inline-flex;\n max-width: 100%;\n min-width: 0;\n overflow: hidden;\n position: relative;\n transition: width 0.2s ease;\n width: fit-content;\n`;\n\ntype StyledSeparatorProps = WithTheme<{\n $gapColor?: string;\n $isHidden?: boolean;\n}>;\n\nexport const StyledSeparator = styled.span<StyledSeparatorProps>`\n align-self: stretch;\n background: ${({ $gapColor, theme }) => $gapColor || theme?.['cw-body-background'] || '#fff'};\n flex: 0 0 ${({ $isHidden }) => ($isHidden ? 0 : 1)}px;\n opacity: ${({ $isHidden }) => ($isHidden ? 0 : 1)};\n overflow: hidden;\n transition:\n flex-basis 0.2s ease,\n opacity 0.2s ease,\n width 0.2s ease;\n width: ${({ $isHidden }) => ($isHidden ? 0 : 1)}px;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGhC,MAAMG,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,IAAAE,yBAAM,EAACC,aAAM,CAACC,GAAG,CAAC;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAOM,MAAMC,eAAe,GAAAJ,OAAA,CAAAI,eAAA,GAAGH,yBAAM,CAACI,IAA0B;AAChE;AACA,kBAAkB,CAAC;EAAEC,SAAS;EAAEC;AAAM,CAAC,KAAKD,SAAS,KAAIC,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAG,oBAAoB,CAAC,KAAI,MAAM;AAChG,gBAAgB,CAAC;EAAEC;AAAU,CAAC,KAAMA,SAAS,GAAG,CAAC,GAAG,CAAE;AACtD,eAAe,CAAC;EAAEA;AAAU,CAAC,KAAMA,SAAS,GAAG,CAAC,GAAG,CAAE;AACrD;AACA;AACA;AACA;AACA;AACA,aAAa,CAAC;EAAEA;AAAU,CAAC,KAAMA,SAAS,GAAG,CAAC,GAAG,CAAE;AACnD,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"MultiActionButton.types.js","names":["MultiActionButtonStatusType","exports","MultiActionButtonHeight"],"sources":["../../../../src/components/multi-action-button/MultiActionButton.types.ts"],"sourcesContent":["import type { MouseEvent, ReactElement, ReactNode } from 'react';\nimport type { MotionValue } from 'motion/react';\nimport type { ContextMenuItem } from '../context-menu/ContextMenu.types';\n\n/**\n * Supported status types for the multi action button.\n */\nexport enum MultiActionButtonStatusType {\n /**\n * Pulsing background effect.\n * @description Applies a subtle animated overlay on the action background to draw attention.\n * This is intended for temporary states like recording or live activity indicators.\n */\n Pulse = 'pulse',\n}\n\n/**\n * Supported heights for the multi action button.\n */\nexport enum MultiActionButtonHeight {\n /**\n * Medium height (42px).\n */\n Medium = 42,\n /**\n * Large height (48px).\n */\n Large = 48,\n}\n\n/**\n * Minimal status configuration for an action.\n */\nexport type MultiActionButtonActionStatus = {\n /**\n * Optional pulse colors for the animation.\n * @description Defines the two colors for the pulsing background animation. If not provided, defaults to ['#A50000', '#630000'].\n * @optional\n */\n pulseColors?: [string, string];\n /**\n * Status type to apply.\n * @description Selects the visual emphasis type applied to the action. The component currently\n * supports a pulsing overlay, and additional types may be added later.\n * @optional\n */\n type?: MultiActionButtonStatusType;\n};\n\n/**\n * Event payload emitted on action click.\n */\nexport type MultiActionButtonActionEvent = {\n /**\n * Which action was clicked.\n * @description Indicates whether the primary or secondary action fired. This is helpful when\n * sharing a handler between both actions.\n */\n action: 'primary' | 'secondary';\n /**\n * Original click event.\n * @description Useful to access modifier keys, prevent default, or stop propagation.\n */\n event: MouseEvent<HTMLButtonElement>;\n /**\n * Whether the secondary action is currently extended.\n * @description Useful for flows that need to distinguish between a collapsed and expanded\n * secondary action, especially on touch devices.\n */\n isExtended: boolean;\n /**\n * Whether the device is considered touch.\n * @description Derived from pointer capabilities and used to decide between hover and click behavior.\n */\n isTouch: boolean;\n};\n\n/**\n * Configuration for a single action.\n */\nexport type MultiActionButtonAction = {\n /**\n * Optional background color for this action.\n * @description Overrides the component-level background color for this specific action.\n * If omitted, `MultiActionButton.backgroundColor` is used as fallback.\n * @optional\n */\n backgroundColor?: string;\n /**\n * Optional color for the icon and label.\n * @description Overrides the default text/icon color. If omitted, the current theme text color is used.\n * @optional\n */\n color?: string;\n /**\n * The icon for the action.\n * @description Can be a FontAwesome class string (e.g., 'fa fa-microphone') or a custom React element.\n * The icon is always rendered inside a fixed-size slot to keep alignment stable.\n */\n icon: string | ReactElement;\n /**\n * Whether the action is disabled.\n * @description Disabled actions do not respond to hover or click and are visually dimmed.\n * @optional\n */\n isDisabled?: boolean;\n /**\n * Optional reason shown in a tooltip when the action is disabled.\n * @description Use this to explain why the action is currently unavailable.\n * @optional\n */\n disabledReason?: string;\n /**\n * The optional label for the action.\n * @description The label is shown next to the icon and will be truncated with ellipsis when\n * there is not enough horizontal space.\n * @optional\n */\n label: ReactNode;\n /**\n * Click handler for the action.\n * @description Receives a payload that includes the action type, extension state, and device info.\n * This allows external logic to decide whether the click should trigger an action immediately.\n * @optional\n */\n onClick?: (info: MultiActionButtonActionEvent) => void;\n /**\n * Status effect configuration for the action.\n * @description Controls optional visual emphasis like pulsing, without changing layout or sizing.\n * @optional\n */\n status?: MultiActionButtonActionStatus;\n};\n\nexport type MultiActionButtonSecondaryContextMenu = ContextMenuItem[];\n\n/**\n * Props for the MultiActionButton component.\n */\nexport type MultiActionButtonProps = {\n /**\n * Optional background color for both actions.\n * @description Overrides the default background color for the action buttons. This is useful\n * when the button is used on different backgrounds or when a specific brand color is needed.\n * If omitted, the primary color from the theme is used.\n * @default theme.primary\n * @optional\n */\n backgroundColor?: string;\n /**\n * Additional class name for the wrapper element.\n * @description Useful for custom styling or testing hooks.\n * @optional\n */\n className?: string;\n /**\n * Timeout in ms before the secondary action collapses after a click.\n * @description Set to 0 to keep the secondary action extended until the user collapses it.\n * @example\n * <MultiActionButton\n * primaryAction={primaryAction}\n * secondaryAction={secondaryAction}\n * extendedTimeoutMs={0}\n * />\n * @default 3000\n * @optional\n */\n extendedTimeoutMs?: number;\n /**\n * Height of the button.\n * @description Controls the height of the button. Use values from MultiActionButtonHeight enum or custom number.\n * @default MultiActionButtonHeight.Medium\n * @optional\n */\n height?: number;\n /**\n * Optional color for the 1px separator line between actions.\n * @description Defaults to theme.cw-body-background and falls back to #fff if not available.\n * @optional\n */\n gapColor?: string;\n /**\n * Whether the button is collapsed to a single icon.\n * @description When collapsed, only the primary icon is shown and the overall width shrinks to a circle.\n * Use this to provide compact states or toolbar modes.\n * @default false\n * @optional\n */\n isCollapsed?: boolean;\n /**\n * Whether the whole control is disabled.\n * @description Disables interactions for both actions, including hover expansion and clicks.\n * @default false\n * @optional\n */\n isDisabled?: boolean;\n /**\n * Primary action configuration.\n * @description Required action shown on the left side (or as the only action when no secondary is provided).\n */\n primaryAction: MultiActionButtonAction;\n /**\n * Secondary action configuration.\n * @description Optional action shown on the right side. When present, it can expand on hover or click.\n * @optional\n */\n secondaryAction?: MultiActionButtonAction;\n /**\n * Context menu rendered as the secondary action.\n * @description When the list contains entries, the secondary slot renders a fixed down-arrow\n * trigger that opens a ContextMenu. If the list is empty or undefined, no context menu trigger\n * is shown and `secondaryAction` can be used as usual.\n * @optional\n */\n secondaryContextMenu?: MultiActionButtonSecondaryContextMenu;\n /**\n * Whether the button should take the full width of its parent.\n * @description When true, the control stretches to 100% width unless `width` is provided.\n * @optional\n */\n shouldUseFullWidth?: boolean;\n /**\n * Optional width override for the whole button.\n * @description Can be a fixed number or a MotionValue for external animations. When omitted,\n * the width is driven by the content unless `shouldUseFullWidth` is true.\n * @optional\n */\n width?: number | MotionValue<number>;\n};\n"],"mappings":";;;;;;AAIA;AACA;AACA;AAFA,IAGYA,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,0BAA3BA,2BAA2B;EACnC;AACJ;AACA;AACA;AACA;EALYA,2BAA2B;EAAA,OAA3BA,2BAA2B;AAAA;AASvC;AACA;AACA;AAFA,IAGYE,uBAAuB,GAAAD,OAAA,CAAAC,uBAAA,0BAAvBA,uBAAuB;EAC/B;AACJ;AACA;EAHYA,uBAAuB,CAAvBA,uBAAuB;EAK/B;AACJ;AACA;EAPYA,uBAAuB,CAAvBA,uBAAuB;EAAA,OAAvBA,uBAAuB;AAAA;AAWnC;AACA;AACA;AAiBA;AACA;AACA;AA0BA;AACA;AACA;AAyDA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"MultiActionButton.types.js","names":["MultiActionButtonStatusType","exports","MultiActionButtonHeight"],"sources":["../../../../src/components/multi-action-button/MultiActionButton.types.ts"],"sourcesContent":["import type { MouseEvent, ReactElement, ReactNode } from 'react';\nimport type { MotionValue } from 'motion/react';\nimport type { ContextMenuItem } from '../context-menu/ContextMenu.types';\n\n/**\n * Supported status types for the multi action button.\n */\nexport enum MultiActionButtonStatusType {\n /**\n * Pulsing background effect.\n * @description Applies a subtle animated overlay on the action background to draw attention.\n * This is intended for temporary states like recording or live activity indicators.\n */\n Pulse = 'pulse',\n}\n\n/**\n * Supported heights for the multi action button.\n */\nexport enum MultiActionButtonHeight {\n /**\n * Medium height (42px).\n */\n Medium = 42,\n /**\n * Large height (48px).\n */\n Large = 48,\n}\n\n/**\n * Minimal status configuration for an action.\n */\nexport type MultiActionButtonActionStatus = {\n /**\n * Optional pulse colors for the animation.\n * @description Defines the two colors for the pulsing background animation. If not provided, defaults to ['#A50000', '#630000'].\n * @optional\n */\n pulseColors?: [string, string];\n /**\n * Status type to apply.\n * @description Selects the visual emphasis type applied to the action. The component currently\n * supports a pulsing overlay, and additional types may be added later.\n * @optional\n */\n type?: MultiActionButtonStatusType;\n};\n\n/**\n * Event payload emitted on action click.\n */\nexport type MultiActionButtonActionEvent = {\n /**\n * Which action was clicked.\n * @description Indicates whether the primary or secondary action fired. This is helpful when\n * sharing a handler between both actions.\n */\n action: 'primary' | 'secondary';\n /**\n * Original click event.\n * @description Useful to access modifier keys, prevent default, or stop propagation.\n */\n event: MouseEvent<HTMLButtonElement>;\n /**\n * Whether the secondary action is currently extended.\n * @description Useful for flows that need to distinguish between a collapsed and expanded\n * secondary action, especially on touch devices.\n */\n isExtended: boolean;\n /**\n * Whether the device is considered touch.\n * @description Derived from pointer capabilities and used to decide between hover and click behavior.\n */\n isTouch: boolean;\n};\n\n/**\n * Configuration for a single action.\n */\nexport type MultiActionButtonAction = {\n /**\n * Optional background color for this action.\n * @description Overrides the component-level background color for this specific action.\n * If omitted, `MultiActionButton.backgroundColor` is used as fallback.\n * @optional\n */\n backgroundColor?: string;\n /**\n * Optional color for the icon and label.\n * @description Overrides the default text/icon color. If omitted, the current theme text color is used.\n * @optional\n */\n color?: string;\n /**\n * The icon for the action.\n * @description Can be a FontAwesome class string (e.g., 'fa fa-microphone') or a custom React element.\n * The icon is always rendered inside a fixed-size slot to keep alignment stable.\n */\n icon: string | ReactElement;\n /**\n * Whether the action is disabled.\n * @description Disabled actions do not respond to hover or click and are visually dimmed.\n * @optional\n */\n isDisabled?: boolean;\n /**\n * Optional reason shown in a tooltip when the action is disabled.\n * @description Use this to explain why the action is currently unavailable.\n * @optional\n */\n disabledReason?: string;\n /**\n * The optional label for the action.\n * @description The label is shown next to the icon and will be truncated with ellipsis when\n * there is not enough horizontal space.\n * @optional\n */\n label: ReactNode;\n /**\n * Click handler for the action.\n * @description Receives a payload that includes the action type, extension state, and device info.\n * This allows external logic to decide whether the click should trigger an action immediately.\n * @optional\n */\n onClick?: (info: MultiActionButtonActionEvent) => void;\n /**\n * Status effect configuration for the action.\n * @description Controls optional visual emphasis like pulsing, without changing layout or sizing.\n * @optional\n */\n status?: MultiActionButtonActionStatus;\n};\n\nexport type MultiActionButtonSecondaryContextMenu = ContextMenuItem[];\n\n/**\n * Props for the MultiActionButton component.\n */\nexport type MultiActionButtonProps = {\n /**\n * Optional background color for both actions.\n * @description Overrides the default background color for the action buttons. This is useful\n * when the button is used on different backgrounds or when a specific brand color is needed.\n * If omitted, the primary color from the theme is used.\n * @default theme.primary\n * @optional\n */\n backgroundColor?: string;\n /**\n * Additional class name for the wrapper element.\n * @description Useful for custom styling or testing hooks.\n * @optional\n */\n className?: string;\n /**\n * Timeout in ms before the secondary action collapses after a click.\n * @description Set to 0 to keep the secondary action extended until the user collapses it.\n * @example\n * <MultiActionButton\n * primaryAction={primaryAction}\n * secondaryAction={secondaryAction}\n * extendedTimeoutMs={0}\n * />\n * @default 3000\n * @optional\n */\n extendedTimeoutMs?: number;\n /**\n * Height of the button.\n * @description Controls the height of the button. Use values from MultiActionButtonHeight enum or custom number.\n * @default MultiActionButtonHeight.Medium\n * @optional\n */\n height?: number;\n /**\n * Optional color for the 1px separator line between actions.\n * @description Defaults to theme.cw-body-background and falls back to #fff if not available.\n * @optional\n */\n gapColor?: string;\n /**\n * Whether the button is collapsed to a single icon.\n * @description When collapsed, only the primary icon is shown and the overall width shrinks to a circle.\n * Use this to provide compact states or toolbar modes.\n * @default false\n * @optional\n */\n isCollapsed?: boolean;\n /**\n * Whether the whole control is disabled.\n * @description Disables interactions for both actions, including hover expansion and clicks.\n * @default false\n * @optional\n */\n isDisabled?: boolean;\n /**\n * Primary action configuration.\n * @description Required action shown on the left side (or as the only action when no secondary is provided).\n */\n primaryAction: MultiActionButtonAction;\n /**\n * Secondary action configuration.\n * @description Optional action shown on the right side. When present, it can expand on hover or click.\n * @optional\n */\n secondaryAction?: MultiActionButtonAction;\n /**\n * Context menu rendered as the secondary action.\n * @description When the list contains entries, the secondary slot renders a fixed down-arrow\n * trigger that opens a ContextMenu. If the list is empty or undefined, no context menu trigger\n * is shown and `secondaryAction` can be used as usual.\n * @optional\n */\n secondaryContextMenu?: MultiActionButtonSecondaryContextMenu;\n /**\n * Whether the button should collapse automatically based on the available width.\n * @description When enabled, the control switches from the default layout to an icon-only\n * layout and finally to a primary-only icon layout as space becomes tighter.\n * @default false\n * @optional\n */\n shouldAutoCollapse?: boolean;\n /**\n * Whether the button should take the full width of its parent.\n * @description When true, the control stretches to 100% width unless `width` is provided.\n * @optional\n */\n shouldUseFullWidth?: boolean;\n /**\n * Optional width override for the whole button.\n * @description Can be a fixed number or a MotionValue for external animations. When omitted,\n * the width is driven by the content unless `shouldUseFullWidth` is true.\n * @optional\n */\n width?: number | MotionValue<number>;\n};\n"],"mappings":";;;;;;AAIA;AACA;AACA;AAFA,IAGYA,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,0BAA3BA,2BAA2B;EACnC;AACJ;AACA;AACA;AACA;EALYA,2BAA2B;EAAA,OAA3BA,2BAA2B;AAAA;AASvC;AACA;AACA;AAFA,IAGYE,uBAAuB,GAAAD,OAAA,CAAAC,uBAAA,0BAAvBA,uBAAuB;EAC/B;AACJ;AACA;EAHYA,uBAAuB,CAAvBA,uBAAuB;EAK/B;AACJ;AACA;EAPYA,uBAAuB,CAAvBA,uBAAuB;EAAA,OAAvBA,uBAAuB;AAAA;AAWnC;AACA;AACA;AAiBA;AACA;AACA;AA0BA;AACA;AACA;AAyDA;AACA;AACA","ignoreList":[]}
@@ -3,7 +3,91 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getSecondaryContextMenuTriggerStyle = void 0;
6
+ exports.getSecondaryContextMenuTriggerStyle = exports.getMultiActionButtonAutoCollapseMode = exports.getMinimumPrimaryLabelVisibleWidth = exports.getMinimumMultiActionButtonIconsWidth = exports.MultiActionButtonAutoCollapseMode = exports.MULTI_ACTION_BUTTON_SEPARATOR_WIDTH_PX = exports.MULTI_ACTION_BUTTON_LABEL_RIGHT_PADDING_PX = exports.MULTI_ACTION_BUTTON_LABEL_GAP_PX = void 0;
7
+ let MultiActionButtonAutoCollapseMode = exports.MultiActionButtonAutoCollapseMode = /*#__PURE__*/function (MultiActionButtonAutoCollapseMode) {
8
+ MultiActionButtonAutoCollapseMode["Expanded"] = "expanded";
9
+ MultiActionButtonAutoCollapseMode["IconsOnly"] = "icons-only";
10
+ MultiActionButtonAutoCollapseMode["PrimaryOnly"] = "primary-only";
11
+ return MultiActionButtonAutoCollapseMode;
12
+ }({});
13
+ const AUTO_COLLAPSE_HYSTERESIS_PX = 12;
14
+ const MULTI_ACTION_BUTTON_LABEL_GAP_PX = exports.MULTI_ACTION_BUTTON_LABEL_GAP_PX = 6;
15
+ const MULTI_ACTION_BUTTON_LABEL_RIGHT_PADDING_PX = exports.MULTI_ACTION_BUTTON_LABEL_RIGHT_PADDING_PX = 18;
16
+ const MULTI_ACTION_BUTTON_SEPARATOR_WIDTH_PX = exports.MULTI_ACTION_BUTTON_SEPARATOR_WIDTH_PX = 1;
17
+ const getMinimumMultiActionButtonIconsWidth = ({
18
+ hasSecondaryAction,
19
+ height
20
+ }) => {
21
+ const minimumPrimaryActionWidth = height;
22
+ if (!hasSecondaryAction) {
23
+ return minimumPrimaryActionWidth;
24
+ }
25
+ return minimumPrimaryActionWidth * 2 + 1;
26
+ };
27
+ exports.getMinimumMultiActionButtonIconsWidth = getMinimumMultiActionButtonIconsWidth;
28
+ const getMinimumPrimaryLabelVisibleWidth = ({
29
+ hasVisibleSecondaryAction,
30
+ height
31
+ }) => {
32
+ const minimumPrimaryIconWidth = height;
33
+ const minimumPrimaryLabelWidth = MULTI_ACTION_BUTTON_LABEL_GAP_PX + MULTI_ACTION_BUTTON_LABEL_RIGHT_PADDING_PX;
34
+ const minimumSecondaryWidth = hasVisibleSecondaryAction ? height + MULTI_ACTION_BUTTON_SEPARATOR_WIDTH_PX : 0;
35
+ return minimumPrimaryIconWidth + minimumPrimaryLabelWidth + minimumSecondaryWidth;
36
+ };
37
+ exports.getMinimumPrimaryLabelVisibleWidth = getMinimumPrimaryLabelVisibleWidth;
38
+ const getMultiActionButtonAutoCollapseMode = ({
39
+ availableWidth,
40
+ expandedWidth,
41
+ hasSecondaryAction,
42
+ height,
43
+ previousMode = MultiActionButtonAutoCollapseMode.Expanded
44
+ }) => {
45
+ if (!availableWidth || expandedWidth <= 0) {
46
+ return MultiActionButtonAutoCollapseMode.Expanded;
47
+ }
48
+ const minimumIconsWidth = getMinimumMultiActionButtonIconsWidth({
49
+ hasSecondaryAction,
50
+ height
51
+ });
52
+ if (!hasSecondaryAction) {
53
+ if (availableWidth < expandedWidth) {
54
+ return MultiActionButtonAutoCollapseMode.PrimaryOnly;
55
+ }
56
+ if (previousMode === MultiActionButtonAutoCollapseMode.PrimaryOnly && availableWidth < expandedWidth + AUTO_COLLAPSE_HYSTERESIS_PX) {
57
+ return MultiActionButtonAutoCollapseMode.PrimaryOnly;
58
+ }
59
+ return MultiActionButtonAutoCollapseMode.Expanded;
60
+ }
61
+ if (previousMode === MultiActionButtonAutoCollapseMode.Expanded) {
62
+ if (availableWidth < minimumIconsWidth) {
63
+ return MultiActionButtonAutoCollapseMode.PrimaryOnly;
64
+ }
65
+ if (availableWidth < expandedWidth) {
66
+ return MultiActionButtonAutoCollapseMode.IconsOnly;
67
+ }
68
+ return MultiActionButtonAutoCollapseMode.Expanded;
69
+ }
70
+ if (previousMode === MultiActionButtonAutoCollapseMode.IconsOnly) {
71
+ if (availableWidth < minimumIconsWidth) {
72
+ return MultiActionButtonAutoCollapseMode.PrimaryOnly;
73
+ }
74
+ if (availableWidth < expandedWidth + AUTO_COLLAPSE_HYSTERESIS_PX) {
75
+ return MultiActionButtonAutoCollapseMode.IconsOnly;
76
+ }
77
+ return MultiActionButtonAutoCollapseMode.Expanded;
78
+ }
79
+ if (availableWidth < minimumIconsWidth + AUTO_COLLAPSE_HYSTERESIS_PX) {
80
+ return MultiActionButtonAutoCollapseMode.PrimaryOnly;
81
+ }
82
+ if (availableWidth < expandedWidth) {
83
+ return MultiActionButtonAutoCollapseMode.IconsOnly;
84
+ }
85
+ if (availableWidth < expandedWidth + AUTO_COLLAPSE_HYSTERESIS_PX) {
86
+ return MultiActionButtonAutoCollapseMode.IconsOnly;
87
+ }
88
+ return MultiActionButtonAutoCollapseMode.Expanded;
89
+ };
90
+ exports.getMultiActionButtonAutoCollapseMode = getMultiActionButtonAutoCollapseMode;
7
91
  const getSecondaryContextMenuTriggerStyle = ({
8
92
  height,
9
93
  isCollapsed,