@chayns-components/core 5.0.58 → 5.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +37 -0
- package/lib/cjs/components/multi-action-button/MultiActionButton.js +133 -32
- package/lib/cjs/components/multi-action-button/MultiActionButton.js.map +1 -1
- package/lib/cjs/components/multi-action-button/MultiActionButton.styles.js +16 -2
- package/lib/cjs/components/multi-action-button/MultiActionButton.styles.js.map +1 -1
- package/lib/cjs/components/multi-action-button/MultiActionButton.types.js.map +1 -1
- package/lib/cjs/components/multi-action-button/MultiActionButton.utils.js +85 -1
- package/lib/cjs/components/multi-action-button/MultiActionButton.utils.js.map +1 -1
- package/lib/cjs/hooks/container.js +1 -2
- package/lib/cjs/hooks/container.js.map +1 -1
- package/lib/esm/components/multi-action-button/MultiActionButton.js +135 -34
- package/lib/esm/components/multi-action-button/MultiActionButton.js.map +1 -1
- package/lib/esm/components/multi-action-button/MultiActionButton.styles.js +16 -2
- package/lib/esm/components/multi-action-button/MultiActionButton.styles.js.map +1 -1
- package/lib/esm/components/multi-action-button/MultiActionButton.types.js.map +1 -1
- package/lib/esm/components/multi-action-button/MultiActionButton.utils.js +81 -0
- package/lib/esm/components/multi-action-button/MultiActionButton.utils.js.map +1 -1
- package/lib/esm/hooks/container.js +1 -2
- package/lib/esm/hooks/container.js.map +1 -1
- package/lib/types/components/multi-action-button/MultiActionButton.styles.d.ts +1 -0
- package/lib/types/components/multi-action-button/MultiActionButton.types.d.ts +8 -0
- package/lib/types/components/multi-action-button/MultiActionButton.utils.d.ts +22 -0
- package/lib/types/hooks/container.d.ts +1 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiActionButton.utils.js","names":["
|
|
1
|
+
{"version":3,"file":"MultiActionButton.utils.js","names":["MultiActionButtonAutoCollapseMode","exports","AUTO_COLLAPSE_HYSTERESIS_PX","MULTI_ACTION_BUTTON_LABEL_GAP_PX","MULTI_ACTION_BUTTON_LABEL_RIGHT_PADDING_PX","MULTI_ACTION_BUTTON_SEPARATOR_WIDTH_PX","getMinimumMultiActionButtonIconsWidth","hasSecondaryAction","height","minimumPrimaryActionWidth","getMinimumPrimaryLabelVisibleWidth","hasVisibleSecondaryAction","minimumPrimaryIconWidth","minimumPrimaryLabelWidth","minimumSecondaryWidth","getMultiActionButtonAutoCollapseMode","availableWidth","expandedWidth","previousMode","Expanded","minimumIconsWidth","PrimaryOnly","IconsOnly","getSecondaryContextMenuTriggerStyle","isCollapsed","isExpanded","shouldUseContentWidth","display","minWidth","opacity","pointerEvents","width","flex"],"sources":["../../../../src/components/multi-action-button/MultiActionButton.utils.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport enum MultiActionButtonAutoCollapseMode {\n Expanded = 'expanded',\n IconsOnly = 'icons-only',\n PrimaryOnly = 'primary-only',\n}\n\nconst AUTO_COLLAPSE_HYSTERESIS_PX = 12;\nexport const MULTI_ACTION_BUTTON_LABEL_GAP_PX = 6;\nexport const MULTI_ACTION_BUTTON_LABEL_RIGHT_PADDING_PX = 18;\nexport const MULTI_ACTION_BUTTON_SEPARATOR_WIDTH_PX = 1;\n\nexport interface GetMultiActionButtonAutoCollapseModeOptions {\n availableWidth?: number;\n expandedWidth: number;\n hasSecondaryAction: boolean;\n height: number;\n previousMode?: MultiActionButtonAutoCollapseMode;\n}\n\nexport const getMinimumMultiActionButtonIconsWidth = ({\n hasSecondaryAction,\n height,\n}: Pick<GetMultiActionButtonAutoCollapseModeOptions, 'hasSecondaryAction' | 'height'>): number => {\n const minimumPrimaryActionWidth = height;\n\n if (!hasSecondaryAction) {\n return minimumPrimaryActionWidth;\n }\n\n return minimumPrimaryActionWidth * 2 + 1;\n};\n\nexport interface GetMinimumPrimaryLabelVisibleWidthOptions {\n hasVisibleSecondaryAction: boolean;\n height: number;\n}\n\nexport const getMinimumPrimaryLabelVisibleWidth = ({\n hasVisibleSecondaryAction,\n height,\n}: GetMinimumPrimaryLabelVisibleWidthOptions): number => {\n const minimumPrimaryIconWidth = height;\n const minimumPrimaryLabelWidth =\n MULTI_ACTION_BUTTON_LABEL_GAP_PX + MULTI_ACTION_BUTTON_LABEL_RIGHT_PADDING_PX;\n const minimumSecondaryWidth = hasVisibleSecondaryAction\n ? height + MULTI_ACTION_BUTTON_SEPARATOR_WIDTH_PX\n : 0;\n\n return minimumPrimaryIconWidth + minimumPrimaryLabelWidth + minimumSecondaryWidth;\n};\n\nexport const getMultiActionButtonAutoCollapseMode = ({\n availableWidth,\n expandedWidth,\n hasSecondaryAction,\n height,\n previousMode = MultiActionButtonAutoCollapseMode.Expanded,\n}: GetMultiActionButtonAutoCollapseModeOptions): MultiActionButtonAutoCollapseMode => {\n if (!availableWidth || expandedWidth <= 0) {\n return MultiActionButtonAutoCollapseMode.Expanded;\n }\n\n const minimumIconsWidth = getMinimumMultiActionButtonIconsWidth({\n hasSecondaryAction,\n height,\n });\n\n if (!hasSecondaryAction) {\n if (availableWidth < expandedWidth) {\n return MultiActionButtonAutoCollapseMode.PrimaryOnly;\n }\n\n if (\n previousMode === MultiActionButtonAutoCollapseMode.PrimaryOnly &&\n availableWidth < expandedWidth + AUTO_COLLAPSE_HYSTERESIS_PX\n ) {\n return MultiActionButtonAutoCollapseMode.PrimaryOnly;\n }\n\n return MultiActionButtonAutoCollapseMode.Expanded;\n }\n\n if (previousMode === MultiActionButtonAutoCollapseMode.Expanded) {\n if (availableWidth < minimumIconsWidth) {\n return MultiActionButtonAutoCollapseMode.PrimaryOnly;\n }\n\n if (availableWidth < expandedWidth) {\n return MultiActionButtonAutoCollapseMode.IconsOnly;\n }\n\n return MultiActionButtonAutoCollapseMode.Expanded;\n }\n\n if (previousMode === MultiActionButtonAutoCollapseMode.IconsOnly) {\n if (availableWidth < minimumIconsWidth) {\n return MultiActionButtonAutoCollapseMode.PrimaryOnly;\n }\n\n if (availableWidth < expandedWidth + AUTO_COLLAPSE_HYSTERESIS_PX) {\n return MultiActionButtonAutoCollapseMode.IconsOnly;\n }\n\n return MultiActionButtonAutoCollapseMode.Expanded;\n }\n\n if (availableWidth < minimumIconsWidth + AUTO_COLLAPSE_HYSTERESIS_PX) {\n return MultiActionButtonAutoCollapseMode.PrimaryOnly;\n }\n\n if (availableWidth < expandedWidth) {\n return MultiActionButtonAutoCollapseMode.IconsOnly;\n }\n\n if (availableWidth < expandedWidth + AUTO_COLLAPSE_HYSTERESIS_PX) {\n return MultiActionButtonAutoCollapseMode.IconsOnly;\n }\n\n return MultiActionButtonAutoCollapseMode.Expanded;\n};\n\nexport interface GetSecondaryContextMenuTriggerStyleOptions {\n height: number;\n isCollapsed: boolean;\n isExpanded: boolean;\n shouldUseContentWidth: boolean;\n}\n\nexport const getSecondaryContextMenuTriggerStyle = ({\n height,\n isCollapsed,\n isExpanded,\n shouldUseContentWidth,\n}: GetSecondaryContextMenuTriggerStyleOptions): CSSProperties => {\n if (isCollapsed) {\n return {\n display: 'inline-flex',\n minWidth: 0,\n opacity: 0,\n pointerEvents: 'none',\n width: 0,\n };\n }\n\n if (shouldUseContentWidth) {\n return {\n display: 'inline-flex',\n flex: '0 1 auto',\n minWidth: 0,\n };\n }\n\n if (isExpanded) {\n return {\n display: 'inline-flex',\n flex: '1 1 auto',\n minWidth: 0,\n };\n }\n\n return {\n display: 'inline-flex',\n flex: '0 0 auto',\n minWidth: 0,\n width: height,\n };\n};\n"],"mappings":";;;;;;IAEYA,iCAAiC,GAAAC,OAAA,CAAAD,iCAAA,0BAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAA,OAAjCA,iCAAiC;AAAA;AAM7C,MAAME,2BAA2B,GAAG,EAAE;AAC/B,MAAMC,gCAAgC,GAAAF,OAAA,CAAAE,gCAAA,GAAG,CAAC;AAC1C,MAAMC,0CAA0C,GAAAH,OAAA,CAAAG,0CAAA,GAAG,EAAE;AACrD,MAAMC,sCAAsC,GAAAJ,OAAA,CAAAI,sCAAA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;IACvB,OAAO;MACHC,OAAO,EAAE,aAAa;MACtBK,IAAI,EAAE,UAAU;MAChBJ,QAAQ,EAAE;IACd,CAAC;EACL;EAEA,IAAIH,UAAU,EAAE;IACZ,OAAO;MACHE,OAAO,EAAE,aAAa;MACtBK,IAAI,EAAE,UAAU;MAChBJ,QAAQ,EAAE;IACd,CAAC;EACL;EAEA,OAAO;IACHD,OAAO,EAAE,aAAa;IACtBK,IAAI,EAAE,UAAU;IAChBJ,QAAQ,EAAE,CAAC;IACXG,KAAK,EAAEvB;EACX,CAAC;AACL,CAAC;AAACP,OAAA,CAAAsB,mCAAA,GAAAA,mCAAA","ignoreList":[]}
|
|
@@ -13,10 +13,9 @@ let ContainerAnchor = exports.ContainerAnchor = /*#__PURE__*/function (Container
|
|
|
13
13
|
ContainerAnchor["ROOT"] = "#root";
|
|
14
14
|
ContainerAnchor["TAPP"] = ".tapp";
|
|
15
15
|
ContainerAnchor["WALLET"] = ".wallet";
|
|
16
|
-
ContainerAnchor["COLOR_SCHEME"] = ".color-scheme-provider";
|
|
17
16
|
return ContainerAnchor;
|
|
18
17
|
}({});
|
|
19
|
-
const DEFAULT_CONTAINER_ANCHORS = [ContainerAnchor.BODY, ContainerAnchor.DIALOG, ContainerAnchor.PAGE, ContainerAnchor.ROOT, ContainerAnchor.TAPP
|
|
18
|
+
const DEFAULT_CONTAINER_ANCHORS = [ContainerAnchor.BODY, ContainerAnchor.DIALOG, ContainerAnchor.PAGE, ContainerAnchor.ROOT, ContainerAnchor.TAPP];
|
|
20
19
|
const useContainer = ({
|
|
21
20
|
ref,
|
|
22
21
|
anchorElement,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","names":["_react","require","ContainerAnchor","exports","DEFAULT_CONTAINER_ANCHORS","BODY","DIALOG","PAGE","ROOT","TAPP","
|
|
1
|
+
{"version":3,"file":"container.js","names":["_react","require","ContainerAnchor","exports","DEFAULT_CONTAINER_ANCHORS","BODY","DIALOG","PAGE","ROOT","TAPP","useContainer","ref","anchorElement","container","anchors","newContainer","setNewContainer","useState","undefined","useEffect","el","current","reservationWrapperContainer","document","querySelector","RESERVATION_WRAPPER","rootContainer","walletContainer","WALLET","isInWallet","contains","element","closest","join","Element"],"sources":["../../../src/hooks/container.ts"],"sourcesContent":["import { MutableRefObject, useEffect, useState } from 'react';\n\nexport enum ContainerAnchor {\n BODY = 'body',\n DIALOG = '.dialog-inner',\n PAGE = '.page-provider',\n RESERVATION_WRAPPER = '.reservation-wrapper',\n ROOT = '#root',\n TAPP = '.tapp',\n WALLET = '.wallet',\n}\n\nconst DEFAULT_CONTAINER_ANCHORS = [\n ContainerAnchor.BODY,\n ContainerAnchor.DIALOG,\n ContainerAnchor.PAGE,\n ContainerAnchor.ROOT,\n ContainerAnchor.TAPP,\n];\n\ninterface UseContainerProps {\n ref?: MutableRefObject<HTMLDivElement | HTMLLabelElement | HTMLSpanElement | null>;\n anchorElement?: Element;\n container?: Element | null;\n anchors?: ContainerAnchor[];\n}\n\nexport const useContainer = ({\n ref,\n anchorElement,\n container,\n anchors = DEFAULT_CONTAINER_ANCHORS,\n}: UseContainerProps) => {\n const [newContainer, setNewContainer] = useState<Element | undefined>(container ?? undefined);\n\n // Get the closest container if none is set\n useEffect(() => {\n let el = anchorElement as HTMLElement;\n\n if (ref?.current) {\n el = ref.current as HTMLElement;\n }\n\n if (!container) {\n const reservationWrapperContainer = document.querySelector(\n ContainerAnchor.RESERVATION_WRAPPER,\n );\n\n const rootContainer = document.querySelector(ContainerAnchor.ROOT);\n const walletContainer = document.querySelector(ContainerAnchor.WALLET);\n\n const isInWallet =\n (reservationWrapperContainer && reservationWrapperContainer.contains(el)) ||\n (walletContainer && walletContainer.contains(el));\n\n if (isInWallet && rootContainer && rootContainer.contains(el)) {\n setNewContainer(rootContainer);\n\n return;\n }\n\n const element = el.closest(anchors?.join(', '));\n\n setNewContainer(element ?? undefined);\n }\n }, [anchors, container, anchorElement, ref]);\n\n useEffect(() => {\n if (container instanceof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AE;MAErD,IAAIS,UAAU,IAAIH,aAAa,IAAIA,aAAa,CAACI,QAAQ,CAACV,EAAE,CAAC,EAAE;QAC3DJ,eAAe,CAACU,aAAa,CAAC;QAE9B;MACJ;MAEA,MAAMK,OAAO,GAAGX,EAAE,CAACY,OAAO,CAAClB,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEmB,IAAI,CAAC,IAAI,CAAC,CAAC;MAE/CjB,eAAe,CAACe,OAAO,IAAIb,SAAS,CAAC;IACzC;EACJ,CAAC,EAAE,CAACJ,OAAO,EAAED,SAAS,EAAED,aAAa,EAAED,GAAG,CAAC,CAAC;EAE5C,IAAAQ,gBAAS,EAAC,MAAM;IACZ,IAAIN,SAAS,YAAYqB,OAAO,EAAE;MAC9BlB,eAAe,CAACH,SAAS,CAAC;IAC9B;EACJ,CAAC,EAAE,CAACA,SAAS,CAAC,CAAC;EAEf,OAAOE,YAAY;AACvB,CAAC;AAACZ,OAAA,CAAAO,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -1,15 +1,52 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { useElementSize, useMeasuredClone } from '../../hooks/element';
|
|
3
4
|
import { useIsTouch } from '../../utils/environment';
|
|
4
5
|
import ContextMenu from '../context-menu/ContextMenu';
|
|
5
6
|
import ActionButton from './action-button/ActionButton';
|
|
6
7
|
import { StyledMultiActionButton, StyledSeparator } from './MultiActionButton.styles';
|
|
7
|
-
import { getSecondaryContextMenuTriggerStyle } from './MultiActionButton.utils';
|
|
8
|
+
import { getMinimumPrimaryLabelVisibleWidth, getMultiActionButtonAutoCollapseMode, getSecondaryContextMenuTriggerStyle, MultiActionButtonAutoCollapseMode } from './MultiActionButton.utils';
|
|
8
9
|
import { MultiActionButtonHeight } from './MultiActionButton.types';
|
|
9
10
|
const SECONDARY_CONTEXT_MENU_ACTION = {
|
|
10
11
|
icon: 'fa fa-chevron-down',
|
|
11
12
|
label: undefined
|
|
12
13
|
};
|
|
14
|
+
const createMeasuredMultiActionButtonContent = ({
|
|
15
|
+
backgroundColor,
|
|
16
|
+
gapColor,
|
|
17
|
+
height,
|
|
18
|
+
primaryAction,
|
|
19
|
+
secondaryAction
|
|
20
|
+
}) => /*#__PURE__*/React.createElement(StyledMultiActionButton, {
|
|
21
|
+
style: {
|
|
22
|
+
width: 'fit-content'
|
|
23
|
+
}
|
|
24
|
+
}, /*#__PURE__*/React.createElement(ActionButton, {
|
|
25
|
+
action: primaryAction,
|
|
26
|
+
actionType: "primary",
|
|
27
|
+
backgroundColor: primaryAction.backgroundColor ?? backgroundColor,
|
|
28
|
+
isCollapsed: false,
|
|
29
|
+
isDisabled: false,
|
|
30
|
+
isShrunk: false,
|
|
31
|
+
isSolo: !secondaryAction,
|
|
32
|
+
showLabel: true,
|
|
33
|
+
shouldUseContentWidth: true,
|
|
34
|
+
height: height
|
|
35
|
+
}), secondaryAction && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledSeparator, {
|
|
36
|
+
$gapColor: gapColor,
|
|
37
|
+
$isHidden: false
|
|
38
|
+
}), /*#__PURE__*/React.createElement(ActionButton, {
|
|
39
|
+
action: secondaryAction,
|
|
40
|
+
actionType: "secondary",
|
|
41
|
+
backgroundColor: secondaryAction.backgroundColor ?? backgroundColor,
|
|
42
|
+
isCollapsed: false,
|
|
43
|
+
isDisabled: false,
|
|
44
|
+
isExpanded: false,
|
|
45
|
+
isHidden: false,
|
|
46
|
+
showLabel: false,
|
|
47
|
+
shouldUseContentWidth: true,
|
|
48
|
+
height: height
|
|
49
|
+
})));
|
|
13
50
|
|
|
14
51
|
/**
|
|
15
52
|
* Multi-action button with optional secondary action that can expand on hover/click.
|
|
@@ -25,6 +62,7 @@ const MultiActionButton = ({
|
|
|
25
62
|
primaryAction,
|
|
26
63
|
secondaryAction,
|
|
27
64
|
secondaryContextMenu,
|
|
65
|
+
shouldAutoCollapse = false,
|
|
28
66
|
shouldUseFullWidth,
|
|
29
67
|
width
|
|
30
68
|
}) => {
|
|
@@ -32,18 +70,73 @@ const MultiActionButton = ({
|
|
|
32
70
|
const [isSecondaryExpanded, setIsSecondaryExpanded] = useState(false);
|
|
33
71
|
const [isSecondaryHovered, setIsSecondaryHovered] = useState(false);
|
|
34
72
|
const autoCollapseTimeoutRef = useRef(null);
|
|
73
|
+
const multiActionButtonRef = useRef(null);
|
|
35
74
|
const secondaryContextMenuRef = useRef(null);
|
|
75
|
+
const [autoCollapseMode, setAutoCollapseMode] = useState(MultiActionButtonAutoCollapseMode.Expanded);
|
|
36
76
|
const isTouch = useIsTouch();
|
|
77
|
+
const parentSize = useElementSize(multiActionButtonRef, {
|
|
78
|
+
shouldUseParentElement: true
|
|
79
|
+
});
|
|
37
80
|
const hasSecondaryContextMenu = Boolean(secondaryContextMenu?.length);
|
|
81
|
+
const secondaryTriggerAction = hasSecondaryContextMenu ? SECONDARY_CONTEXT_MENU_ACTION : secondaryAction;
|
|
38
82
|
const hasExpandableSecondaryAction = Boolean(secondaryAction) && !hasSecondaryContextMenu;
|
|
39
|
-
const hasSecondaryAction =
|
|
40
|
-
const resolvedSecondaryAction = hasSecondaryContextMenu ? SECONDARY_CONTEXT_MENU_ACTION : secondaryAction;
|
|
83
|
+
const hasSecondaryAction = Boolean(secondaryTriggerAction);
|
|
41
84
|
const shouldUseContentWidth = !width && !shouldUseFullWidth;
|
|
42
|
-
const
|
|
85
|
+
const expandedMeasuredContent = useMemo(() => createMeasuredMultiActionButtonContent({
|
|
86
|
+
backgroundColor,
|
|
87
|
+
gapColor,
|
|
88
|
+
height,
|
|
89
|
+
primaryAction,
|
|
90
|
+
secondaryAction: secondaryTriggerAction
|
|
91
|
+
}), [backgroundColor, gapColor, height, primaryAction, secondaryTriggerAction]);
|
|
92
|
+
const {
|
|
93
|
+
measuredElement,
|
|
94
|
+
width: expandedMeasuredWidth
|
|
95
|
+
} = useMeasuredClone({
|
|
96
|
+
content: expandedMeasuredContent
|
|
97
|
+
});
|
|
98
|
+
const availableWidth = useMemo(() => {
|
|
99
|
+
const parentWidth = parentSize?.width;
|
|
100
|
+
if (typeof width === 'number') {
|
|
101
|
+
return typeof parentWidth === 'number' ? Math.min(parentWidth, width) : width;
|
|
102
|
+
}
|
|
103
|
+
return parentWidth;
|
|
104
|
+
}, [parentSize?.width, width]);
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (!shouldAutoCollapse || isCollapsed) {
|
|
107
|
+
setAutoCollapseMode(MultiActionButtonAutoCollapseMode.Expanded);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (expandedMeasuredWidth <= 0) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
setAutoCollapseMode(previousMode => getMultiActionButtonAutoCollapseMode({
|
|
114
|
+
availableWidth,
|
|
115
|
+
expandedWidth: expandedMeasuredWidth,
|
|
116
|
+
hasSecondaryAction,
|
|
117
|
+
height,
|
|
118
|
+
previousMode
|
|
119
|
+
}));
|
|
120
|
+
}, [availableWidth, expandedMeasuredWidth, hasSecondaryAction, height, isCollapsed, shouldAutoCollapse]);
|
|
121
|
+
const isAutoIconsOnly = shouldAutoCollapse && autoCollapseMode === MultiActionButtonAutoCollapseMode.IconsOnly;
|
|
122
|
+
const isAutoPrimaryOnly = shouldAutoCollapse && autoCollapseMode === MultiActionButtonAutoCollapseMode.PrimaryOnly;
|
|
123
|
+
const shouldKeepFullWidth = Boolean(shouldUseFullWidth);
|
|
124
|
+
const shouldHideSecondaryForAutoCollapse = hasSecondaryAction && isAutoPrimaryOnly;
|
|
125
|
+
const effectiveIsCollapsed = isCollapsed || !shouldKeepFullWidth && isAutoPrimaryOnly;
|
|
126
|
+
const resolvedSecondaryAction = hasSecondaryAction ? secondaryTriggerAction : undefined;
|
|
127
|
+
const isSecondaryHidden = effectiveIsCollapsed || shouldHideSecondaryForAutoCollapse;
|
|
128
|
+
const shouldPreventSecondaryExpansion = isAutoIconsOnly || isSecondaryHidden;
|
|
129
|
+
const shouldKeepPrimaryLabelVisible = shouldKeepFullWidth && shouldAutoCollapse;
|
|
130
|
+
const minimumPrimaryLabelVisibleWidth = getMinimumPrimaryLabelVisibleWidth({
|
|
131
|
+
hasVisibleSecondaryAction: hasSecondaryAction,
|
|
132
|
+
height
|
|
133
|
+
});
|
|
134
|
+
const shouldHidePrimaryLabelForMinimumWidth = shouldKeepPrimaryLabelVisible && typeof availableWidth === 'number' && availableWidth <= minimumPrimaryLabelVisibleWidth;
|
|
135
|
+
const resolvedWidth = shouldKeepFullWidth ? '100%' : effectiveIsCollapsed ? height : width ?? 'fit-content';
|
|
43
136
|
const secondaryContextMenuTriggerStyle = getSecondaryContextMenuTriggerStyle({
|
|
44
137
|
height,
|
|
45
|
-
isCollapsed,
|
|
46
|
-
isExpanded:
|
|
138
|
+
isCollapsed: isSecondaryHidden,
|
|
139
|
+
isExpanded: false,
|
|
47
140
|
shouldUseContentWidth
|
|
48
141
|
});
|
|
49
142
|
|
|
@@ -91,11 +184,13 @@ const MultiActionButton = ({
|
|
|
91
184
|
* Collapsing the control should also reset any temporary expansion state.
|
|
92
185
|
*/
|
|
93
186
|
useEffect(() => {
|
|
94
|
-
if (
|
|
187
|
+
if (effectiveIsCollapsed || shouldPreventSecondaryExpansion) {
|
|
188
|
+
clearAutoCollapseTimeout();
|
|
95
189
|
setIsSecondaryExpanded(false);
|
|
96
190
|
setIsExtendedByClick(false);
|
|
191
|
+
setIsSecondaryHovered(false);
|
|
97
192
|
}
|
|
98
|
-
}, [
|
|
193
|
+
}, [clearAutoCollapseTimeout, effectiveIsCollapsed, shouldPreventSecondaryExpansion]);
|
|
99
194
|
|
|
100
195
|
/**
|
|
101
196
|
* Handler for the primary action button.
|
|
@@ -117,7 +212,7 @@ const MultiActionButton = ({
|
|
|
117
212
|
* Handler for the secondary action button.
|
|
118
213
|
*/
|
|
119
214
|
const handleSecondaryClick = useCallback(event => {
|
|
120
|
-
if (!resolvedSecondaryAction ||
|
|
215
|
+
if (!resolvedSecondaryAction || isSecondaryHidden || isDisabled || resolvedSecondaryAction.isDisabled) {
|
|
121
216
|
return;
|
|
122
217
|
}
|
|
123
218
|
if (hasSecondaryContextMenu) {
|
|
@@ -131,37 +226,40 @@ const MultiActionButton = ({
|
|
|
131
226
|
isTouch
|
|
132
227
|
};
|
|
133
228
|
resolvedSecondaryAction.onClick?.(payload);
|
|
134
|
-
|
|
135
|
-
|
|
229
|
+
if (!shouldPreventSecondaryExpansion) {
|
|
230
|
+
expandSecondaryByClick();
|
|
231
|
+
}
|
|
232
|
+
}, [expandSecondaryByClick, hasSecondaryContextMenu, isSecondaryHidden, isDisabled, isSecondaryExpanded, isTouch, resolvedSecondaryAction, shouldPreventSecondaryExpansion]);
|
|
136
233
|
|
|
137
234
|
/**
|
|
138
235
|
* Desktop hover behavior keeps the secondary action expanded while hovered.
|
|
139
236
|
*/
|
|
140
237
|
const handleSecondaryMouseEnter = useCallback(() => {
|
|
141
|
-
if (!secondaryAction ||
|
|
238
|
+
if (!secondaryAction || isSecondaryHidden || isTouch || isDisabled || shouldPreventSecondaryExpansion || secondaryAction.isDisabled) {
|
|
142
239
|
return;
|
|
143
240
|
}
|
|
144
241
|
setIsSecondaryHovered(true);
|
|
145
242
|
if (!isExtendedByClick) {
|
|
146
243
|
setIsSecondaryExpanded(true);
|
|
147
244
|
}
|
|
148
|
-
}, [
|
|
245
|
+
}, [isSecondaryHidden, isDisabled, isExtendedByClick, isTouch, secondaryAction, shouldPreventSecondaryExpansion]);
|
|
149
246
|
const handleSecondaryMouseLeave = useCallback(() => {
|
|
150
247
|
if (isTouch) {
|
|
151
248
|
return;
|
|
152
249
|
}
|
|
153
250
|
setIsSecondaryHovered(false);
|
|
154
|
-
if (!isExtendedByClick && !
|
|
251
|
+
if (!isExtendedByClick && !effectiveIsCollapsed) {
|
|
155
252
|
setIsSecondaryExpanded(false);
|
|
156
253
|
}
|
|
157
|
-
}, [
|
|
254
|
+
}, [effectiveIsCollapsed, isExtendedByClick, isTouch]);
|
|
158
255
|
|
|
159
256
|
/**
|
|
160
257
|
* Secondary label is visible when expanded or when hovered (desktop only).
|
|
161
258
|
*/
|
|
162
259
|
const isSecondaryLabelVisible = isSecondaryExpanded || !isTouch && isSecondaryHovered;
|
|
163
|
-
return /*#__PURE__*/React.createElement(StyledMultiActionButton, {
|
|
260
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, measuredElement, /*#__PURE__*/React.createElement(StyledMultiActionButton, {
|
|
164
261
|
className: clsx('beta-chayns-multi-action', className),
|
|
262
|
+
ref: multiActionButtonRef,
|
|
165
263
|
style: {
|
|
166
264
|
maxWidth: '100%',
|
|
167
265
|
width: resolvedWidth
|
|
@@ -170,16 +268,17 @@ const MultiActionButton = ({
|
|
|
170
268
|
action: primaryAction,
|
|
171
269
|
actionType: "primary",
|
|
172
270
|
backgroundColor: primaryAction.backgroundColor ?? backgroundColor,
|
|
173
|
-
isCollapsed:
|
|
271
|
+
isCollapsed: effectiveIsCollapsed,
|
|
174
272
|
isDisabled: isDisabled,
|
|
175
|
-
isShrunk:
|
|
176
|
-
isSolo: !hasSecondaryAction
|
|
273
|
+
isShrunk: hasSecondaryAction && (!shouldKeepFullWidth && isAutoIconsOnly || isSecondaryExpanded),
|
|
274
|
+
isSolo: !hasSecondaryAction || isSecondaryHidden || effectiveIsCollapsed,
|
|
177
275
|
onClick: handlePrimaryClick,
|
|
178
|
-
showLabel: !
|
|
276
|
+
showLabel: !effectiveIsCollapsed && !shouldHidePrimaryLabelForMinimumWidth && (shouldKeepPrimaryLabelVisible || !isAutoIconsOnly) && (shouldKeepPrimaryLabelVisible || !shouldHideSecondaryForAutoCollapse) && (!hasExpandableSecondaryAction || !isSecondaryExpanded),
|
|
179
277
|
shouldUseContentWidth: shouldUseContentWidth,
|
|
180
278
|
height: height
|
|
181
|
-
}),
|
|
182
|
-
$gapColor: gapColor
|
|
279
|
+
}), hasSecondaryAction && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledSeparator, {
|
|
280
|
+
$gapColor: gapColor,
|
|
281
|
+
$isHidden: isSecondaryHidden
|
|
183
282
|
}), hasSecondaryContextMenu ? /*#__PURE__*/React.createElement(ContextMenu, {
|
|
184
283
|
items: secondaryContextMenu ?? [],
|
|
185
284
|
ref: secondaryContextMenuRef,
|
|
@@ -189,32 +288,34 @@ const MultiActionButton = ({
|
|
|
189
288
|
yOffset: -6,
|
|
190
289
|
style: secondaryContextMenuTriggerStyle
|
|
191
290
|
}, /*#__PURE__*/React.createElement(ActionButton, {
|
|
192
|
-
action: resolvedSecondaryAction,
|
|
291
|
+
action: resolvedSecondaryAction ?? SECONDARY_CONTEXT_MENU_ACTION,
|
|
193
292
|
actionType: "secondary",
|
|
194
|
-
backgroundColor: resolvedSecondaryAction
|
|
195
|
-
isCollapsed:
|
|
293
|
+
backgroundColor: resolvedSecondaryAction?.backgroundColor ?? backgroundColor,
|
|
294
|
+
isCollapsed: false,
|
|
196
295
|
isDisabled: isDisabled,
|
|
197
296
|
isExpanded: false,
|
|
198
|
-
isHidden:
|
|
297
|
+
isHidden: isSecondaryHidden,
|
|
298
|
+
key: "multi-action-secondary-context-menu",
|
|
199
299
|
onClick: handleSecondaryClick,
|
|
200
300
|
showLabel: false,
|
|
201
301
|
shouldUseContentWidth: shouldUseContentWidth,
|
|
202
302
|
height: height
|
|
203
303
|
})) : /*#__PURE__*/React.createElement(ActionButton, {
|
|
204
|
-
action: resolvedSecondaryAction,
|
|
304
|
+
action: resolvedSecondaryAction ?? secondaryAction ?? SECONDARY_CONTEXT_MENU_ACTION,
|
|
205
305
|
actionType: "secondary",
|
|
206
|
-
backgroundColor: resolvedSecondaryAction
|
|
207
|
-
isCollapsed:
|
|
306
|
+
backgroundColor: resolvedSecondaryAction?.backgroundColor ?? backgroundColor,
|
|
307
|
+
isCollapsed: false,
|
|
208
308
|
isDisabled: isDisabled,
|
|
209
|
-
isExpanded: isSecondaryExpanded,
|
|
210
|
-
isHidden:
|
|
309
|
+
isExpanded: !isAutoIconsOnly && isSecondaryExpanded,
|
|
310
|
+
isHidden: isSecondaryHidden,
|
|
311
|
+
key: "multi-action-secondary-button",
|
|
211
312
|
onClick: handleSecondaryClick,
|
|
212
313
|
onMouseEnter: handleSecondaryMouseEnter,
|
|
213
314
|
onMouseLeave: handleSecondaryMouseLeave,
|
|
214
|
-
showLabel: isSecondaryLabelVisible,
|
|
315
|
+
showLabel: !isSecondaryHidden && !isAutoIconsOnly && isSecondaryLabelVisible,
|
|
215
316
|
shouldUseContentWidth: shouldUseContentWidth,
|
|
216
317
|
height: height
|
|
217
|
-
})));
|
|
318
|
+
}))));
|
|
218
319
|
};
|
|
219
320
|
MultiActionButton.displayName = 'MultiActionButton';
|
|
220
321
|
export default MultiActionButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiActionButton.js","names":["clsx","React","useCallback","useEffect","useRef","useState","useIsTouch","ContextMenu","ActionButton","StyledMultiActionButton","StyledSeparator","getSecondaryContextMenuTriggerStyle","MultiActionButtonHeight","SECONDARY_CONTEXT_MENU_ACTION","icon","label","undefined","MultiActionButton","backgroundColor","className","extendedTimeoutMs","gapColor","height","Medium","isCollapsed","isDisabled","primaryAction","secondaryAction","secondaryContextMenu","shouldUseFullWidth","width","isExtendedByClick","setIsExtendedByClick","isSecondaryExpanded","setIsSecondaryExpanded","isSecondaryHovered","setIsSecondaryHovered","autoCollapseTimeoutRef","secondaryContextMenuRef","isTouch","hasSecondaryContextMenu","Boolean","length","hasExpandableSecondaryAction","hasSecondaryAction","resolvedSecondaryAction","shouldUseContentWidth","resolvedWidth","secondaryContextMenuTriggerStyle","isExpanded","clearAutoCollapseTimeout","current","window","clearTimeout","resetAutoCollapseTimeout","setTimeout","expandSecondaryByClick","handlePrimaryClick","event","payload","action","isExtended","onClick","handleSecondaryClick","show","handleSecondaryMouseEnter","handleSecondaryMouseLeave","isSecondaryLabelVisible","createElement","style","maxWidth","actionType","isShrunk","isSolo","showLabel","Fragment","$gapColor","items","ref","shouldDisableClick","shouldUseDefaultTriggerStyles","shouldHidePopupArrow","yOffset","isHidden","onMouseEnter","onMouseLeave","displayName"],"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,OAAOA,IAAI,MAAM,MAAM;AACvB,OAAOC,KAAK,IAAoBC,WAAW,EAAEC,SAAS,EAAEC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e,IAAIA,eAC9C;IACDM,WAAW,EAAEA,WAAY;IACzBC,UAAU,EAAEA,UAAW;IACvBwB,UAAU,EAAEhB,mBAAoB;IAChCkD,QAAQ,EAAE3D,WAAY;IACtBsC,OAAO,EAAEC,oBAAqB;IAC9BqB,YAAY,EAAEnB,yBAA0B;IACxCoB,YAAY,EAAEnB,yBAA0B;IACxCQ,SAAS,EAAEP,uBAAwB;IACnCrB,qBAAqB,EAAEA,qBAAsB;IAC7CxB,MAAM,EAAEA;EAAO,CAClB,CAEP,CAEe,CAAC;AAElC,CAAC;AAEDL,iBAAiB,CAACqE,WAAW,GAAG,mBAAmB;AAEnD,eAAerE,iBAAiB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MultiActionButton.js","names":["clsx","React","useCallback","useEffect","useMemo","useRef","useState","useElementSize","useMeasuredClone","useIsTouch","ContextMenu","ActionButton","StyledMultiActionButton","StyledSeparator","getMinimumPrimaryLabelVisibleWidth","getMultiActionButtonAutoCollapseMode","getSecondaryContextMenuTriggerStyle","MultiActionButtonAutoCollapseMode","MultiActionButtonHeight","SECONDARY_CONTEXT_MENU_ACTION","icon","label","undefined","createMeasuredMultiActionButtonContent","backgroundColor","gapColor","height","primaryAction","secondaryAction","createElement","style","width","action","actionType","isCollapsed","isDisabled","isShrunk","isSolo","showLabel","shouldUseContentWidth","Fragment","$gapColor","$isHidden","isExpanded","isHidden","MultiActionButton","className","extendedTimeoutMs","Medium","secondaryContextMenu","shouldAutoCollapse","shouldUseFullWidth","isExtendedByClick","setIsExtendedByClick","isSecondaryExpanded","setIsSecondaryExpanded","isSecondaryHovered","setIsSecondaryHovered","autoCollapseTimeoutRef","multiActionButtonRef","secondaryContextMenuRef","autoCollapseMode","setAutoCollapseMode","Expanded","isTouch","parentSize","shouldUseParentElement","hasSecondaryContextMenu","Boolean","length","secondaryTriggerAction","hasExpandableSecondaryAction","hasSecondaryAction","expandedMeasuredContent","measuredElement","expandedMeasuredWidth","content","availableWidth","parentWidth","Math","min","previousMode","expandedWidth","isAutoIconsOnly","IconsOnly","isAutoPrimaryOnly","PrimaryOnly","shouldKeepFullWidth","shouldHideSecondaryForAutoCollapse","effectiveIsCollapsed","resolvedSecondaryAction","isSecondaryHidden","shouldPreventSecondaryExpansion","shouldKeepPrimaryLabelVisible","minimumPrimaryLabelVisibleWidth","hasVisibleSecondaryAction","shouldHidePrimaryLabelForMinimumWidth","resolvedWidth","secondaryContextMenuTriggerStyle","clearAutoCollapseTimeout","current","window","clearTimeout","resetAutoCollapseTimeout","setTimeout","expandSecondaryByClick","handlePrimaryClick","event","payload","isExtended","onClick","handleSecondaryClick","show","handleSecondaryMouseEnter","handleSecondaryMouseLeave","isSecondaryLabelVisible","ref","maxWidth","items","shouldDisableClick","shouldUseDefaultTriggerStyles","shouldHidePopupArrow","yOffset","key","onMouseEnter","onMouseLeave","displayName"],"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,OAAOA,IAAI,MAAM,MAAM;AACvB,OAAOC,KAAK,IAIRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,qBAAqB;AACtE,SAASC,UAAU,QAAQ,yBAAyB;AACpD,OAAOC,WAAW,MAAM,6BAA6B;AAErD,OAAOC,YAAY,MAAM,8BAA8B;AACvD,SAASC,uBAAuB,EAAEC,eAAe,QAAQ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B,IACvB9D,eAAe,IACfT,6BACH;IACDc,UAAU,EAAC,WAAW;IACtBT,eAAe,EACXkE,uBAAuB,EAAElE,eAAe,IAAIA,eAC/C;IACDU,WAAW,EAAE,KAAM;IACnBC,UAAU,EAAEA,UAAW;IACvBQ,UAAU,EAAE,CAACwC,eAAe,IAAI7B,mBAAoB;IACpDV,QAAQ,EAAE+C,iBAAkB;IAC5BgC,GAAG,EAAC,+BAA+B;IACnCb,OAAO,EAAEC,oBAAqB;IAC9Ba,YAAY,EAAEX,yBAA0B;IACxCY,YAAY,EAAEX,yBAA0B;IACxC5E,SAAS,EACL,CAACqD,iBAAiB,IAClB,CAACR,eAAe,IAChBgC,uBACH;IACD5E,qBAAqB,EAAEA,qBAAsB;IAC7Cb,MAAM,EAAEA;EAAO,CAClB,CAEP,CAEe,CAC3B,CAAC;AAEX,CAAC;AAEDmB,iBAAiB,CAACiF,WAAW,GAAG,mBAAmB;AAEnD,eAAejF,iBAAiB","ignoreList":[]}
|
|
@@ -4,6 +4,8 @@ export const StyledMultiActionButton = styled(motion.div)`
|
|
|
4
4
|
align-items: stretch;
|
|
5
5
|
display: inline-flex;
|
|
6
6
|
max-width: 100%;
|
|
7
|
+
min-width: 0;
|
|
8
|
+
overflow: hidden;
|
|
7
9
|
position: relative;
|
|
8
10
|
transition: width 0.2s ease;
|
|
9
11
|
width: fit-content;
|
|
@@ -14,7 +16,19 @@ export const StyledSeparator = styled.span`
|
|
|
14
16
|
$gapColor,
|
|
15
17
|
theme
|
|
16
18
|
}) => $gapColor || theme?.['cw-body-background'] || '#fff'};
|
|
17
|
-
flex: 0 0
|
|
18
|
-
|
|
19
|
+
flex: 0 0 ${({
|
|
20
|
+
$isHidden
|
|
21
|
+
}) => $isHidden ? 0 : 1}px;
|
|
22
|
+
opacity: ${({
|
|
23
|
+
$isHidden
|
|
24
|
+
}) => $isHidden ? 0 : 1};
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
transition:
|
|
27
|
+
flex-basis 0.2s ease,
|
|
28
|
+
opacity 0.2s ease,
|
|
29
|
+
width 0.2s ease;
|
|
30
|
+
width: ${({
|
|
31
|
+
$isHidden
|
|
32
|
+
}) => $isHidden ? 0 : 1}px;
|
|
19
33
|
`;
|
|
20
34
|
//# sourceMappingURL=MultiActionButton.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiActionButton.styles.js","names":["motion","styled","StyledMultiActionButton","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
|
|
1
|
+
{"version":3,"file":"MultiActionButton.styles.js","names":["motion","styled","StyledMultiActionButton","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,SAASA,MAAM,QAAQ,cAAc;AACrC,OAAOC,MAAM,MAAM,mBAAmB;AAGtC,OAAO,MAAMC,uBAAuB,GAAGD,MAAM,CAACD,MAAM,CAACG,GAAG,CAAC;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAOD,OAAO,MAAMC,eAAe,GAAGH,MAAM,CAACI,IAA0B;AAChE;AACA,kBAAkB,CAAC;EAAEC,SAAS;EAAEC;AAAM,CAAC,KAAKD,SAAS,IAAIC,KAAK,GAAG,oBAAoB,CAAC,IAAI,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","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;AACA,WAAYA,2BAA2B,0BAA3BA,2BAA2B;EACnC;AACJ;AACA;AACA;AACA;EALYA,2BAA2B;EAAA,OAA3BA,2BAA2B;AAAA;;AASvC;AACA;AACA;AACA,WAAYC,uBAAuB,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","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;AACA,WAAYA,2BAA2B,0BAA3BA,2BAA2B;EACnC;AACJ;AACA;AACA;AACA;EALYA,2BAA2B;EAAA,OAA3BA,2BAA2B;AAAA;;AASvC;AACA;AACA;AACA,WAAYC,uBAAuB,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":[]}
|