@chayns-components/core 5.0.0-beta.1408 → 5.0.0-beta.1409
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/icon/Icon.styles.js +0 -1
- package/lib/cjs/components/icon/Icon.styles.js.map +1 -1
- package/lib/cjs/components/multi-action-button/MultiActionButton.js +221 -0
- package/lib/cjs/components/multi-action-button/MultiActionButton.js.map +1 -0
- package/lib/cjs/components/multi-action-button/MultiActionButton.styles.js +201 -0
- package/lib/cjs/components/multi-action-button/MultiActionButton.styles.js.map +1 -0
- package/lib/cjs/components/multi-action-button/MultiActionButton.types.js +31 -0
- package/lib/cjs/components/multi-action-button/MultiActionButton.types.js.map +1 -0
- package/lib/cjs/index.js +7 -7
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/components/icon/Icon.styles.js +0 -1
- package/lib/esm/components/icon/Icon.styles.js.map +1 -1
- package/lib/esm/components/multi-action-button/MultiActionButton.js +210 -0
- package/lib/esm/components/multi-action-button/MultiActionButton.js.map +1 -0
- package/lib/esm/components/multi-action-button/MultiActionButton.styles.js +194 -0
- package/lib/esm/components/multi-action-button/MultiActionButton.styles.js.map +1 -0
- package/lib/esm/components/multi-action-button/MultiActionButton.types.js +29 -0
- package/lib/esm/components/multi-action-button/MultiActionButton.types.js.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/types/components/multi-action-button/MultiActionButton.d.ts +4 -0
- package/lib/types/components/multi-action-button/MultiActionButton.styles.d.ts +24 -0
- package/lib/types/components/multi-action-button/MultiActionButton.types.d.ts +154 -0
- package/lib/types/index.d.ts +2 -1
- package/package.json +4 -4
- package/lib/cjs/components/action-menu-button/ActionMenuButton.js +0 -110
- package/lib/cjs/components/action-menu-button/ActionMenuButton.js.map +0 -1
- package/lib/cjs/components/action-menu-button/ActionMenuButton.styles.js +0 -96
- package/lib/cjs/components/action-menu-button/ActionMenuButton.styles.js.map +0 -1
- package/lib/cjs/components/action-menu-button/ActionMenuButton.types.js +0 -6
- package/lib/cjs/components/action-menu-button/ActionMenuButton.types.js.map +0 -1
- package/lib/esm/components/action-menu-button/ActionMenuButton.js +0 -101
- package/lib/esm/components/action-menu-button/ActionMenuButton.js.map +0 -1
- package/lib/esm/components/action-menu-button/ActionMenuButton.styles.js +0 -89
- package/lib/esm/components/action-menu-button/ActionMenuButton.styles.js.map +0 -1
- package/lib/esm/components/action-menu-button/ActionMenuButton.types.js +0 -2
- package/lib/esm/components/action-menu-button/ActionMenuButton.types.js.map +0 -1
- package/lib/types/components/action-menu-button/ActionMenuButton.d.ts +0 -7
- package/lib/types/components/action-menu-button/ActionMenuButton.styles.d.ts +0 -25
- package/lib/types/components/action-menu-button/ActionMenuButton.types.d.ts +0 -61
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.styles.js","names":["_styledComponents","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledIconWrapper","exports","styled","span","$isDisabled","$isOnClick","$size","StyledIcon","$color","theme","iconColor","text","$isStacked","undefined","$fontSize","css","StyledUnicodeIcon","headline","$icon"],"sources":["../../../../src/components/icon/Icon.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { motion } from 'motion/react';\n\ntype StyledIconWrapperProps = {\n $isDisabled?: boolean;\n $isOnClick: boolean;\n $size: number;\n};\n\nexport const StyledIconWrapper = styled.span<StyledIconWrapperProps>`\n align-items: center;\n cursor: ${({ $isDisabled, $isOnClick }) =>\n $isOnClick && !$isDisabled ? 'pointer' : 'inherit'};\n display: inline-flex;\n min-height: ${({ $size }) => `${$size}px`};\n justify-content: center;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n position: relative;\n transition: opacity 0.3s ease;\n min-width: ${({ $size }) => `${$size}px`};\n\n // To insure that stacked icons have the same size as normal icons.\n &&.fa-stack {\n height: fit-content;\n width: fit-content;\n line-height: ${({ $size }) => $size}px;\n }\n`;\n\ntype StyledIconProps = WithTheme<{\n $fontSize: number;\n $isStacked?: boolean;\n $color?: string;\n $size: number;\n}>;\n\nexport const StyledIcon = styled.i<StyledIconProps>`\n color: ${({ $color, theme }: StyledIconProps) => $color || theme.iconColor || theme.text};\n display: ${({ $isStacked }) => ($isStacked ? undefined : 'inline-flex')};\n font-size: ${({ $fontSize }) => `${$fontSize}px`};\n\n ${({ $fontSize, $size }) =>\n $fontSize !== $size &&\n css`\n top: 50%;\n transform: translateY(-50%);\n `}\n`;\n\ntype StyledUnicodeIconProps = WithTheme<{ $icon: string }>;\n\nexport const StyledUnicodeIcon = styled.i<StyledUnicodeIconProps>`\n align-items: center;\n justify-content: center;\n display: flex;\n color: ${({ theme }: StyledUnicodeIconProps) => theme.iconColor || theme.headline};\n\n &:before {\n content: ${({ $icon }) => `\"\\\\${$icon}\"`};\n
|
|
1
|
+
{"version":3,"file":"Icon.styles.js","names":["_styledComponents","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledIconWrapper","exports","styled","span","$isDisabled","$isOnClick","$size","StyledIcon","$color","theme","iconColor","text","$isStacked","undefined","$fontSize","css","StyledUnicodeIcon","headline","$icon"],"sources":["../../../../src/components/icon/Icon.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { motion } from 'motion/react';\n\ntype StyledIconWrapperProps = {\n $isDisabled?: boolean;\n $isOnClick: boolean;\n $size: number;\n};\n\nexport const StyledIconWrapper = styled.span<StyledIconWrapperProps>`\n align-items: center;\n cursor: ${({ $isDisabled, $isOnClick }) =>\n $isOnClick && !$isDisabled ? 'pointer' : 'inherit'};\n display: inline-flex;\n min-height: ${({ $size }) => `${$size}px`};\n justify-content: center;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n position: relative;\n transition: opacity 0.3s ease;\n min-width: ${({ $size }) => `${$size}px`};\n\n // To insure that stacked icons have the same size as normal icons.\n &&.fa-stack {\n height: fit-content;\n width: fit-content;\n line-height: ${({ $size }) => $size}px;\n }\n`;\n\ntype StyledIconProps = WithTheme<{\n $fontSize: number;\n $isStacked?: boolean;\n $color?: string;\n $size: number;\n}>;\n\nexport const StyledIcon = styled.i<StyledIconProps>`\n color: ${({ $color, theme }: StyledIconProps) => $color || theme.iconColor || theme.text};\n display: ${({ $isStacked }) => ($isStacked ? undefined : 'inline-flex')};\n font-size: ${({ $fontSize }) => `${$fontSize}px`};\n\n ${({ $fontSize, $size }) =>\n $fontSize !== $size &&\n css`\n top: 50%;\n transform: translateY(-50%);\n `}\n`;\n\ntype StyledUnicodeIconProps = WithTheme<{ $icon: string }>;\n\nexport const StyledUnicodeIcon = styled.i<StyledUnicodeIconProps>`\n align-items: center;\n justify-content: center;\n display: flex;\n color: ${({ theme }: StyledUnicodeIconProps) => theme.iconColor || theme.headline};\n\n &:before {\n content: ${({ $icon }) => `\"\\\\${$icon}\"`};\n }\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAgD,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,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,GA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AAK,CAACE,IAAI;AAC5F,eAAe,CAAC;EAAEC;AAAW,CAAC,KAAMA,UAAU,GAAGC,SAAS,GAAG,aAAc;AAC3E,iBAAiB,CAAC;EAAEC;AAAU,CAAC,KAAK,GAAGA,SAAS,IAAI;AACpD;AACA,MAAM,CAAC;EAAEA,SAAS;EAAER;AAAM,CAAC,KACnBQ,SAAS,KAAKR,KAAK,IACnB,IAAAS,qBAAG;AACX;AACA;AACA,SAAS;AACT,CAAC;AAIM,MAAMC,iBAAiB,GAAAf,OAAA,CAAAe,iBAAA,GAAGd,yBAAM,CAACd,CAAyB;AACjE;AACA;AACA;AACA,aAAa,CAAC;EAAEqB;AAA8B,CAAC,KAAKA,KAAK,CAACC,SAAS,IAAID,KAAK,CAACQ,QAAQ;AACrF;AACA;AACA,mBAAmB,CAAC;EAAEC;AAAM,CAAC,KAAK,MAAMA,KAAK,GAAG;AAChD;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
8
|
+
var _react = require("motion/react");
|
|
9
|
+
var _react2 = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _styledComponents = require("styled-components");
|
|
11
|
+
var _Icon = _interopRequireDefault(require("../icon/Icon"));
|
|
12
|
+
var _environment = require("../../utils/environment");
|
|
13
|
+
var _MultiActionButton = require("./MultiActionButton.styles");
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
const MultiActionButton = ({
|
|
17
|
+
className,
|
|
18
|
+
isDisabled,
|
|
19
|
+
primaryAction,
|
|
20
|
+
secondaryAction,
|
|
21
|
+
extendedTimeoutMs = 2000,
|
|
22
|
+
width,
|
|
23
|
+
isCollapsed = false
|
|
24
|
+
}) => {
|
|
25
|
+
var _primaryAction$status, _primaryAction$status2, _secondaryAction$stat, _secondaryAction$stat2;
|
|
26
|
+
const [isSecondaryExtended, setIsSecondaryExtended] = (0, _react2.useState)(false);
|
|
27
|
+
const [isSecondaryHovered, setIsSecondaryHovered] = (0, _react2.useState)(false);
|
|
28
|
+
const [isExtendedFromClick, setIsExtendedFromClick] = (0, _react2.useState)(false);
|
|
29
|
+
const timeoutRef = (0, _react2.useRef)(null);
|
|
30
|
+
const isTouch = (0, _environment.useIsTouch)();
|
|
31
|
+
const hasSecondaryAction = Boolean(secondaryAction);
|
|
32
|
+
const theme = (0, _styledComponents.useTheme)();
|
|
33
|
+
const defaultColor = (theme === null || theme === void 0 ? void 0 : theme.text) ?? '#fff';
|
|
34
|
+
|
|
35
|
+
// Ensure the extended state resets after the timeout window (click-only).
|
|
36
|
+
// Reset the auto-collapse timeout after click-based extension.
|
|
37
|
+
const resetTimeout = (0, _react2.useCallback)(() => {
|
|
38
|
+
if (timeoutRef.current) {
|
|
39
|
+
window.clearTimeout(timeoutRef.current);
|
|
40
|
+
}
|
|
41
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
42
|
+
setIsSecondaryExtended(false);
|
|
43
|
+
setIsExtendedFromClick(false);
|
|
44
|
+
}, extendedTimeoutMs);
|
|
45
|
+
}, [extendedTimeoutMs]);
|
|
46
|
+
|
|
47
|
+
// Extend the secondary action due to a click.
|
|
48
|
+
const extendSecondaryByClick = (0, _react2.useCallback)(() => {
|
|
49
|
+
setIsSecondaryExtended(true);
|
|
50
|
+
setIsExtendedFromClick(true);
|
|
51
|
+
resetTimeout();
|
|
52
|
+
}, [resetTimeout]);
|
|
53
|
+
|
|
54
|
+
// Cleanup timers on unmount.
|
|
55
|
+
(0, _react2.useEffect)(() => () => {
|
|
56
|
+
if (timeoutRef.current) {
|
|
57
|
+
window.clearTimeout(timeoutRef.current);
|
|
58
|
+
}
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
// Collapsing the whole button should also clear any secondary expansion.
|
|
62
|
+
(0, _react2.useEffect)(() => {
|
|
63
|
+
if (isCollapsed) {
|
|
64
|
+
setIsSecondaryExtended(false);
|
|
65
|
+
setIsExtendedFromClick(false);
|
|
66
|
+
}
|
|
67
|
+
}, [isCollapsed]);
|
|
68
|
+
|
|
69
|
+
// Primary action click handler.
|
|
70
|
+
// Primary action click handler.
|
|
71
|
+
const handlePrimaryClick = (0, _react2.useCallback)(event => {
|
|
72
|
+
var _primaryAction$onClic;
|
|
73
|
+
if (isDisabled || primaryAction.isDisabled) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const payload = {
|
|
77
|
+
action: 'primary',
|
|
78
|
+
isExtended: isSecondaryExtended,
|
|
79
|
+
isTouch,
|
|
80
|
+
event
|
|
81
|
+
};
|
|
82
|
+
(_primaryAction$onClic = primaryAction.onClick) === null || _primaryAction$onClic === void 0 || _primaryAction$onClic.call(primaryAction, payload);
|
|
83
|
+
}, [isDisabled, primaryAction, isSecondaryExtended, isTouch]);
|
|
84
|
+
|
|
85
|
+
// Secondary action click handler.
|
|
86
|
+
const handleSecondaryClick = (0, _react2.useCallback)(event => {
|
|
87
|
+
var _secondaryAction$onCl;
|
|
88
|
+
if (!secondaryAction || isCollapsed || isDisabled || secondaryAction.isDisabled) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const payload = {
|
|
92
|
+
action: 'secondary',
|
|
93
|
+
isExtended: isSecondaryExtended,
|
|
94
|
+
isTouch,
|
|
95
|
+
event
|
|
96
|
+
};
|
|
97
|
+
(_secondaryAction$onCl = secondaryAction.onClick) === null || _secondaryAction$onCl === void 0 || _secondaryAction$onCl.call(secondaryAction, payload);
|
|
98
|
+
extendSecondaryByClick();
|
|
99
|
+
}, [extendSecondaryByClick, isCollapsed, isDisabled, isSecondaryExtended, isTouch, secondaryAction]);
|
|
100
|
+
|
|
101
|
+
// Hovering the secondary action should extend it immediately on desktop.
|
|
102
|
+
const handleSecondaryMouseEnter = (0, _react2.useCallback)(() => {
|
|
103
|
+
if (!secondaryAction || isCollapsed || isTouch || isDisabled || secondaryAction.isDisabled) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
setIsSecondaryHovered(true);
|
|
107
|
+
if (!isExtendedFromClick) {
|
|
108
|
+
setIsSecondaryExtended(true);
|
|
109
|
+
}
|
|
110
|
+
}, [isCollapsed, isDisabled, isExtendedFromClick, isTouch, secondaryAction]);
|
|
111
|
+
|
|
112
|
+
// Leaving the secondary action should collapse it immediately on desktop.
|
|
113
|
+
const handleSecondaryMouseLeave = (0, _react2.useCallback)(() => {
|
|
114
|
+
if (isTouch) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
setIsSecondaryHovered(false);
|
|
118
|
+
if (!isExtendedFromClick && !isCollapsed) {
|
|
119
|
+
setIsSecondaryExtended(false);
|
|
120
|
+
}
|
|
121
|
+
}, [isCollapsed, isExtendedFromClick, isTouch]);
|
|
122
|
+
|
|
123
|
+
// Secondary label is shown whenever the button is extended or hovered on desktop.
|
|
124
|
+
const shouldShowSecondaryLabel = isSecondaryExtended || !isTouch && isSecondaryHovered;
|
|
125
|
+
return /*#__PURE__*/_react2.default.createElement(_MultiActionButton.StyledMultiActionButton, {
|
|
126
|
+
className: (0, _clsx.default)('beta-chayns-multi-action', className),
|
|
127
|
+
style: {
|
|
128
|
+
width: isCollapsed ? 42 : width ?? '100%'
|
|
129
|
+
}
|
|
130
|
+
}, /*#__PURE__*/_react2.default.createElement(_MultiActionButton.StyledActionButton, {
|
|
131
|
+
disabled: isDisabled || primaryAction.isDisabled,
|
|
132
|
+
$isPrimary: hasSecondaryAction,
|
|
133
|
+
$isCollapsed: isCollapsed,
|
|
134
|
+
$isShrunk: hasSecondaryAction && isSecondaryExtended,
|
|
135
|
+
$isSolo: !hasSecondaryAction && !isCollapsed,
|
|
136
|
+
$statusType: (_primaryAction$status = primaryAction.status) === null || _primaryAction$status === void 0 ? void 0 : _primaryAction$status.type,
|
|
137
|
+
$pulseColor: (_primaryAction$status2 = primaryAction.status) === null || _primaryAction$status2 === void 0 ? void 0 : _primaryAction$status2.pulseColor,
|
|
138
|
+
onClick: handlePrimaryClick,
|
|
139
|
+
type: "button"
|
|
140
|
+
}, /*#__PURE__*/_react2.default.createElement(_MultiActionButton.StyledActionContent, null, /*#__PURE__*/_react2.default.createElement(_MultiActionButton.StyledIconSlot, null, typeof primaryAction.icon === 'string' ? /*#__PURE__*/_react2.default.createElement(_Icon.default, {
|
|
141
|
+
icons: [primaryAction.icon],
|
|
142
|
+
color: primaryAction.color ?? defaultColor,
|
|
143
|
+
size: 18
|
|
144
|
+
}) : primaryAction.icon), /*#__PURE__*/_react2.default.createElement(_react.AnimatePresence, {
|
|
145
|
+
initial: false
|
|
146
|
+
}, (!hasSecondaryAction || !isSecondaryExtended) && !isCollapsed && /*#__PURE__*/_react2.default.createElement(_react.motion.span, {
|
|
147
|
+
animate: {
|
|
148
|
+
opacity: 1,
|
|
149
|
+
width: 'auto'
|
|
150
|
+
},
|
|
151
|
+
exit: {
|
|
152
|
+
opacity: 0,
|
|
153
|
+
width: 0
|
|
154
|
+
},
|
|
155
|
+
initial: {
|
|
156
|
+
opacity: 0,
|
|
157
|
+
width: 0
|
|
158
|
+
},
|
|
159
|
+
key: "primary-label",
|
|
160
|
+
style: {
|
|
161
|
+
flex: '1 1 auto',
|
|
162
|
+
minWidth: 0,
|
|
163
|
+
overflow: 'hidden',
|
|
164
|
+
textAlign: 'left'
|
|
165
|
+
},
|
|
166
|
+
transition: {
|
|
167
|
+
duration: 0.3
|
|
168
|
+
}
|
|
169
|
+
}, /*#__PURE__*/_react2.default.createElement(_MultiActionButton.StyledPrimaryLabel, {
|
|
170
|
+
style: {
|
|
171
|
+
color: primaryAction.color ?? defaultColor
|
|
172
|
+
}
|
|
173
|
+
}, primaryAction.label))))), secondaryAction && /*#__PURE__*/_react2.default.createElement(_MultiActionButton.StyledActionButton, {
|
|
174
|
+
disabled: isDisabled || secondaryAction.isDisabled,
|
|
175
|
+
$isSecondary: true,
|
|
176
|
+
$isExpanded: isSecondaryExtended,
|
|
177
|
+
$isHidden: isCollapsed,
|
|
178
|
+
$statusType: (_secondaryAction$stat = secondaryAction.status) === null || _secondaryAction$stat === void 0 ? void 0 : _secondaryAction$stat.type,
|
|
179
|
+
$pulseColor: (_secondaryAction$stat2 = secondaryAction.status) === null || _secondaryAction$stat2 === void 0 ? void 0 : _secondaryAction$stat2.pulseColor,
|
|
180
|
+
onClick: handleSecondaryClick,
|
|
181
|
+
onMouseEnter: handleSecondaryMouseEnter,
|
|
182
|
+
onMouseLeave: handleSecondaryMouseLeave,
|
|
183
|
+
type: "button"
|
|
184
|
+
}, /*#__PURE__*/_react2.default.createElement(_MultiActionButton.StyledActionContent, null, /*#__PURE__*/_react2.default.createElement(_MultiActionButton.StyledIconSlot, null, typeof secondaryAction.icon === 'string' ? /*#__PURE__*/_react2.default.createElement(_Icon.default, {
|
|
185
|
+
icons: [secondaryAction.icon],
|
|
186
|
+
color: secondaryAction.color ?? defaultColor,
|
|
187
|
+
size: 18
|
|
188
|
+
}) : secondaryAction.icon), /*#__PURE__*/_react2.default.createElement(_react.AnimatePresence, {
|
|
189
|
+
initial: false
|
|
190
|
+
}, shouldShowSecondaryLabel && secondaryAction.label && /*#__PURE__*/_react2.default.createElement(_react.motion.span, {
|
|
191
|
+
animate: {
|
|
192
|
+
opacity: 1,
|
|
193
|
+
width: 'auto'
|
|
194
|
+
},
|
|
195
|
+
exit: {
|
|
196
|
+
opacity: 0,
|
|
197
|
+
width: 0
|
|
198
|
+
},
|
|
199
|
+
initial: {
|
|
200
|
+
opacity: 0,
|
|
201
|
+
width: 0
|
|
202
|
+
},
|
|
203
|
+
key: "secondary-label",
|
|
204
|
+
style: {
|
|
205
|
+
flex: '1 1 auto',
|
|
206
|
+
minWidth: 0,
|
|
207
|
+
overflow: 'hidden',
|
|
208
|
+
textAlign: 'left'
|
|
209
|
+
},
|
|
210
|
+
transition: {
|
|
211
|
+
duration: 0.3
|
|
212
|
+
}
|
|
213
|
+
}, /*#__PURE__*/_react2.default.createElement(_MultiActionButton.StyledSecondaryLabel, {
|
|
214
|
+
style: {
|
|
215
|
+
color: secondaryAction.color ?? defaultColor
|
|
216
|
+
}
|
|
217
|
+
}, secondaryAction.label))))));
|
|
218
|
+
};
|
|
219
|
+
MultiActionButton.displayName = 'MultiActionButton';
|
|
220
|
+
var _default = exports.default = MultiActionButton;
|
|
221
|
+
//# sourceMappingURL=MultiActionButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiActionButton.js","names":["_clsx","_interopRequireDefault","require","_react","_react2","_interopRequireWildcard","_styledComponents","_Icon","_environment","_MultiActionButton","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MultiActionButton","className","isDisabled","primaryAction","secondaryAction","extendedTimeoutMs","width","isCollapsed","_primaryAction$status","_primaryAction$status2","_secondaryAction$stat","_secondaryAction$stat2","isSecondaryExtended","setIsSecondaryExtended","useState","isSecondaryHovered","setIsSecondaryHovered","isExtendedFromClick","setIsExtendedFromClick","timeoutRef","useRef","isTouch","useIsTouch","hasSecondaryAction","Boolean","theme","useTheme","defaultColor","text","resetTimeout","useCallback","current","window","clearTimeout","setTimeout","extendSecondaryByClick","useEffect","handlePrimaryClick","event","_primaryAction$onClic","payload","action","isExtended","onClick","handleSecondaryClick","_secondaryAction$onCl","handleSecondaryMouseEnter","handleSecondaryMouseLeave","shouldShowSecondaryLabel","createElement","StyledMultiActionButton","clsx","style","StyledActionButton","disabled","$isPrimary","$isCollapsed","$isShrunk","$isSolo","$statusType","status","type","$pulseColor","pulseColor","StyledActionContent","StyledIconSlot","icon","icons","color","size","AnimatePresence","initial","motion","span","animate","opacity","exit","key","flex","minWidth","overflow","textAlign","transition","duration","StyledPrimaryLabel","label","$isSecondary","$isExpanded","$isHidden","onMouseEnter","onMouseLeave","StyledSecondaryLabel","displayName","_default","exports"],"sources":["../../../../src/components/multi-action-button/MultiActionButton.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { AnimatePresence, motion } from 'motion/react';\nimport React, { FC, MouseEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport { useIsTouch } from '../../utils/environment';\nimport {\n StyledActionButton,\n StyledActionContent,\n StyledIconSlot,\n StyledMultiActionButton,\n StyledPrimaryLabel,\n StyledSecondaryLabel,\n} from './MultiActionButton.styles';\nimport type {\n MultiActionButtonActionEvent,\n MultiActionButtonProps,\n} from './MultiActionButton.types';\n\nconst MultiActionButton: FC<MultiActionButtonProps> = ({\n className,\n isDisabled,\n primaryAction,\n secondaryAction,\n extendedTimeoutMs = 2000,\n width,\n isCollapsed = false,\n}) => {\n const [isSecondaryExtended, setIsSecondaryExtended] = useState(false);\n const [isSecondaryHovered, setIsSecondaryHovered] = useState(false);\n const [isExtendedFromClick, setIsExtendedFromClick] = useState(false);\n\n const timeoutRef = useRef<number | null>(null);\n\n const isTouch = useIsTouch();\n\n const hasSecondaryAction = Boolean(secondaryAction);\n\n const theme = useTheme() as Theme;\n\n const defaultColor = theme?.text ?? '#fff';\n\n // Ensure the extended state resets after the timeout window (click-only).\n // Reset the auto-collapse timeout after click-based extension.\n const resetTimeout = useCallback(() => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n\n timeoutRef.current = window.setTimeout(() => {\n setIsSecondaryExtended(false);\n setIsExtendedFromClick(false);\n }, extendedTimeoutMs);\n }, [extendedTimeoutMs]);\n\n // Extend the secondary action due to a click.\n const extendSecondaryByClick = useCallback(() => {\n setIsSecondaryExtended(true);\n setIsExtendedFromClick(true);\n resetTimeout();\n }, [resetTimeout]);\n\n // Cleanup timers on unmount.\n useEffect(\n () => () => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n },\n [],\n );\n\n // Collapsing the whole button should also clear any secondary expansion.\n useEffect(() => {\n if (isCollapsed) {\n setIsSecondaryExtended(false);\n setIsExtendedFromClick(false);\n }\n }, [isCollapsed]);\n\n // Primary action click handler.\n // Primary action click handler.\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 isExtended: isSecondaryExtended,\n isTouch,\n event,\n };\n\n primaryAction.onClick?.(payload);\n },\n [isDisabled, primaryAction, isSecondaryExtended, isTouch],\n );\n\n // Secondary action click handler.\n const handleSecondaryClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n if (!secondaryAction || isCollapsed || isDisabled || secondaryAction.isDisabled) {\n return;\n }\n\n const payload: MultiActionButtonActionEvent = {\n action: 'secondary',\n isExtended: isSecondaryExtended,\n isTouch,\n event,\n };\n\n secondaryAction.onClick?.(payload);\n\n extendSecondaryByClick();\n },\n [\n extendSecondaryByClick,\n isCollapsed,\n isDisabled,\n isSecondaryExtended,\n isTouch,\n secondaryAction,\n ],\n );\n\n // Hovering the secondary action should extend it immediately on desktop.\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 (!isExtendedFromClick) {\n setIsSecondaryExtended(true);\n }\n }, [isCollapsed, isDisabled, isExtendedFromClick, isTouch, secondaryAction]);\n\n // Leaving the secondary action should collapse it immediately on desktop.\n const handleSecondaryMouseLeave = useCallback(() => {\n if (isTouch) {\n return;\n }\n\n setIsSecondaryHovered(false);\n if (!isExtendedFromClick && !isCollapsed) {\n setIsSecondaryExtended(false);\n }\n }, [isCollapsed, isExtendedFromClick, isTouch]);\n\n // Secondary label is shown whenever the button is extended or hovered on desktop.\n const shouldShowSecondaryLabel = isSecondaryExtended || (!isTouch && isSecondaryHovered);\n\n return (\n <StyledMultiActionButton\n className={clsx('beta-chayns-multi-action', className)}\n style={{ width: isCollapsed ? 42 : (width ?? '100%') }}\n >\n <StyledActionButton\n disabled={isDisabled || primaryAction.isDisabled}\n $isPrimary={hasSecondaryAction}\n $isCollapsed={isCollapsed}\n $isShrunk={hasSecondaryAction && isSecondaryExtended}\n $isSolo={!hasSecondaryAction && !isCollapsed}\n $statusType={primaryAction.status?.type}\n $pulseColor={primaryAction.status?.pulseColor}\n onClick={handlePrimaryClick}\n type=\"button\"\n >\n <StyledActionContent>\n <StyledIconSlot>\n {typeof primaryAction.icon === 'string' ? (\n <Icon\n icons={[primaryAction.icon]}\n color={primaryAction.color ?? defaultColor}\n size={18}\n />\n ) : (\n primaryAction.icon\n )}\n </StyledIconSlot>\n <AnimatePresence initial={false}>\n {(!hasSecondaryAction || !isSecondaryExtended) && !isCollapsed && (\n <motion.span\n animate={{ opacity: 1, width: 'auto' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"primary-label\"\n style={{\n flex: '1 1 auto',\n minWidth: 0,\n overflow: 'hidden',\n textAlign: 'left',\n }}\n transition={{ duration: 0.3 }}\n >\n <StyledPrimaryLabel\n style={{ color: primaryAction.color ?? defaultColor }}\n >\n {primaryAction.label}\n </StyledPrimaryLabel>\n </motion.span>\n )}\n </AnimatePresence>\n </StyledActionContent>\n </StyledActionButton>\n {secondaryAction && (\n <StyledActionButton\n disabled={isDisabled || secondaryAction.isDisabled}\n $isSecondary\n $isExpanded={isSecondaryExtended}\n $isHidden={isCollapsed}\n $statusType={secondaryAction.status?.type}\n $pulseColor={secondaryAction.status?.pulseColor}\n onClick={handleSecondaryClick}\n onMouseEnter={handleSecondaryMouseEnter}\n onMouseLeave={handleSecondaryMouseLeave}\n type=\"button\"\n >\n <StyledActionContent>\n <StyledIconSlot>\n {typeof secondaryAction.icon === 'string' ? (\n <Icon\n icons={[secondaryAction.icon]}\n color={secondaryAction.color ?? defaultColor}\n size={18}\n />\n ) : (\n secondaryAction.icon\n )}\n </StyledIconSlot>\n <AnimatePresence initial={false}>\n {shouldShowSecondaryLabel && secondaryAction.label && (\n <motion.span\n animate={{ opacity: 1, width: 'auto' }}\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n key=\"secondary-label\"\n style={{\n flex: '1 1 auto',\n minWidth: 0,\n overflow: 'hidden',\n textAlign: 'left',\n }}\n transition={{ duration: 0.3 }}\n >\n <StyledSecondaryLabel\n style={{ color: secondaryAction.color ?? defaultColor }}\n >\n {secondaryAction.label}\n </StyledSecondaryLabel>\n </motion.span>\n )}\n </AnimatePresence>\n </StyledActionContent>\n </StyledActionButton>\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,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;AAOoC,SAAAG,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,O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mBAAmB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAvG,OAAA,GAErCS,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledSecondaryLabel = exports.StyledPrimaryLabel = exports.StyledMultiActionButton = exports.StyledIconSlot = exports.StyledActionContent = exports.StyledActionButton = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
+
var _react = require("motion/react");
|
|
9
|
+
var _MultiActionButton = require("./MultiActionButton.types");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
const pulse = (0, _styledComponents.keyframes)`
|
|
12
|
+
0% {
|
|
13
|
+
opacity: 0.25;
|
|
14
|
+
}
|
|
15
|
+
50% {
|
|
16
|
+
opacity: 0.5;
|
|
17
|
+
}
|
|
18
|
+
100% {
|
|
19
|
+
opacity: 0.25;
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
const StyledMultiActionButton = exports.StyledMultiActionButton = (0, _styledComponents.default)(_react.motion.div)`
|
|
23
|
+
align-items: stretch;
|
|
24
|
+
background: transparent;
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
position: relative;
|
|
27
|
+
transition: width 0.2s ease;
|
|
28
|
+
width: 100%;
|
|
29
|
+
`;
|
|
30
|
+
const StyledActionButton = exports.StyledActionButton = _styledComponents.default.button`
|
|
31
|
+
align-items: center;
|
|
32
|
+
border: none;
|
|
33
|
+
border-radius: 21px;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
display: inline-flex;
|
|
36
|
+
flex: 0 0 auto;
|
|
37
|
+
height: 42px;
|
|
38
|
+
line-height: 22px;
|
|
39
|
+
min-height: 42px;
|
|
40
|
+
padding: 0;
|
|
41
|
+
position: relative;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
transition:
|
|
44
|
+
background-color 0.2s ease,
|
|
45
|
+
border-radius 0.2s ease,
|
|
46
|
+
color 0.2s ease,
|
|
47
|
+
flex-grow 0.2s ease,
|
|
48
|
+
opacity 0.2s ease,
|
|
49
|
+
width 0.2s ease,
|
|
50
|
+
margin-left 0.2s ease,
|
|
51
|
+
padding 0.2s ease;
|
|
52
|
+
user-select: none;
|
|
53
|
+
white-space: nowrap;
|
|
54
|
+
|
|
55
|
+
background-color: rgba(0, 0, 0, 0.25);
|
|
56
|
+
color: #fff;
|
|
57
|
+
|
|
58
|
+
${({
|
|
59
|
+
$isExpanded
|
|
60
|
+
}) => $isExpanded && (0, _styledComponents.css)`
|
|
61
|
+
flex: 1 1 auto;
|
|
62
|
+
min-width: 0;
|
|
63
|
+
`}
|
|
64
|
+
|
|
65
|
+
${({
|
|
66
|
+
$isCollapsed
|
|
67
|
+
}) => $isCollapsed && (0, _styledComponents.css)`
|
|
68
|
+
flex: 0 0 auto;
|
|
69
|
+
padding: 0;
|
|
70
|
+
width: 42px;
|
|
71
|
+
`}
|
|
72
|
+
|
|
73
|
+
${({
|
|
74
|
+
$isPrimary,
|
|
75
|
+
$isCollapsed
|
|
76
|
+
}) => $isPrimary && !$isCollapsed && (0, _styledComponents.css)`
|
|
77
|
+
flex: 1 1 auto;
|
|
78
|
+
min-width: 0;
|
|
79
|
+
`}
|
|
80
|
+
|
|
81
|
+
${({
|
|
82
|
+
$isShrunk
|
|
83
|
+
}) => $isShrunk && (0, _styledComponents.css)`
|
|
84
|
+
flex: 0 0 auto;
|
|
85
|
+
padding: 0;
|
|
86
|
+
width: 42px;
|
|
87
|
+
`}
|
|
88
|
+
|
|
89
|
+
${({
|
|
90
|
+
$isSecondary,
|
|
91
|
+
$isExpanded
|
|
92
|
+
}) => $isSecondary && !$isExpanded && (0, _styledComponents.css)`
|
|
93
|
+
flex: 0 0 auto;
|
|
94
|
+
padding: 0;
|
|
95
|
+
width: 42px;
|
|
96
|
+
`}
|
|
97
|
+
|
|
98
|
+
${({
|
|
99
|
+
$isSecondary
|
|
100
|
+
}) => $isSecondary && (0, _styledComponents.css)`
|
|
101
|
+
margin-left: 2px;
|
|
102
|
+
`}
|
|
103
|
+
|
|
104
|
+
${({
|
|
105
|
+
$isHidden
|
|
106
|
+
}) => $isHidden && (0, _styledComponents.css)`
|
|
107
|
+
margin-left: 0;
|
|
108
|
+
opacity: 0;
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
width: 0;
|
|
111
|
+
`}
|
|
112
|
+
|
|
113
|
+
${({
|
|
114
|
+
$isPrimary
|
|
115
|
+
}) => $isPrimary && (0, _styledComponents.css)`
|
|
116
|
+
border-bottom-right-radius: 0;
|
|
117
|
+
border-top-right-radius: 0;
|
|
118
|
+
`}
|
|
119
|
+
|
|
120
|
+
${({
|
|
121
|
+
$isPrimary,
|
|
122
|
+
$isCollapsed
|
|
123
|
+
}) => $isPrimary && $isCollapsed && (0, _styledComponents.css)`
|
|
124
|
+
border-bottom-right-radius: 21px;
|
|
125
|
+
border-top-right-radius: 21px;
|
|
126
|
+
`}
|
|
127
|
+
|
|
128
|
+
${({
|
|
129
|
+
$isSecondary
|
|
130
|
+
}) => $isSecondary && (0, _styledComponents.css)`
|
|
131
|
+
border-bottom-left-radius: 0;
|
|
132
|
+
border-top-left-radius: 0;
|
|
133
|
+
`}
|
|
134
|
+
|
|
135
|
+
${({
|
|
136
|
+
$isSolo
|
|
137
|
+
}) => $isSolo && (0, _styledComponents.css)`
|
|
138
|
+
border-radius: 21px;
|
|
139
|
+
`}
|
|
140
|
+
|
|
141
|
+
${({
|
|
142
|
+
$isCollapsed
|
|
143
|
+
}) => $isCollapsed && (0, _styledComponents.css)`
|
|
144
|
+
border-radius: 21px;
|
|
145
|
+
`}
|
|
146
|
+
|
|
147
|
+
${({
|
|
148
|
+
$statusType,
|
|
149
|
+
$pulseColor
|
|
150
|
+
}) => $statusType === _MultiActionButton.MultiActionButtonStatusType.Pulse && (0, _styledComponents.css)`
|
|
151
|
+
overflow: hidden;
|
|
152
|
+
|
|
153
|
+
&::before {
|
|
154
|
+
animation: ${pulse} 1.6s ease-in-out infinite;
|
|
155
|
+
background: ${$pulseColor || 'rgba(255, 0, 0, 0.85)'};
|
|
156
|
+
border-radius: 3px;
|
|
157
|
+
content: '';
|
|
158
|
+
inset: 0;
|
|
159
|
+
opacity: 0.1;
|
|
160
|
+
pointer-events: none;
|
|
161
|
+
position: absolute;
|
|
162
|
+
}
|
|
163
|
+
`}
|
|
164
|
+
|
|
165
|
+
&:disabled {
|
|
166
|
+
cursor: default;
|
|
167
|
+
opacity: 0.5;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
&:hover:not(:disabled) {
|
|
171
|
+
filter: brightness(1.05);
|
|
172
|
+
}
|
|
173
|
+
`;
|
|
174
|
+
const StyledActionContent = exports.StyledActionContent = _styledComponents.default.span`
|
|
175
|
+
align-items: center;
|
|
176
|
+
display: inline-flex;
|
|
177
|
+
flex: 1 1 auto;
|
|
178
|
+
min-width: 0;
|
|
179
|
+
position: relative;
|
|
180
|
+
z-index: 1;
|
|
181
|
+
`;
|
|
182
|
+
const StyledIconSlot = exports.StyledIconSlot = _styledComponents.default.span`
|
|
183
|
+
align-items: center;
|
|
184
|
+
display: inline-flex;
|
|
185
|
+
flex: 0 0 auto;
|
|
186
|
+
height: 42px;
|
|
187
|
+
justify-content: center;
|
|
188
|
+
width: 42px;
|
|
189
|
+
`;
|
|
190
|
+
const StyledSecondaryLabel = exports.StyledSecondaryLabel = _styledComponents.default.span`
|
|
191
|
+
display: block;
|
|
192
|
+
flex: 1 1 auto;
|
|
193
|
+
min-width: 0;
|
|
194
|
+
max-width: 100%;
|
|
195
|
+
overflow: hidden;
|
|
196
|
+
padding-right: 12px;
|
|
197
|
+
text-overflow: ellipsis;
|
|
198
|
+
white-space: nowrap;
|
|
199
|
+
`;
|
|
200
|
+
const StyledPrimaryLabel = exports.StyledPrimaryLabel = (0, _styledComponents.default)(StyledSecondaryLabel)``;
|
|
201
|
+
//# sourceMappingURL=MultiActionButton.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiActionButton.styles.js","names":["_styledComponents","_interopRequireWildcard","require","_react","_MultiActionButton","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","pulse","keyframes","StyledMultiActionButton","exports","styled","motion","div","StyledActionButton","button","$isExpanded","css","$isCollapsed","$isPrimary","$isShrunk","$isSecondary","$isHidden","$isSolo","$statusType","$pulseColor","MultiActionButtonStatusType","Pulse","StyledActionContent","span","StyledIconSlot","StyledSecondaryLabel","StyledPrimaryLabel"],"sources":["../../../../src/components/multi-action-button/MultiActionButton.styles.ts"],"sourcesContent":["import styled, { css, keyframes } from 'styled-components';\nimport { motion } from 'motion/react';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { MultiActionButtonStatusType } from './MultiActionButton.types';\n\ntype StyledActionButtonProps = WithTheme<{\n $isExpanded?: boolean;\n $isCollapsed?: boolean;\n $isShrunk?: boolean;\n $isPrimary?: boolean;\n $isSecondary?: boolean;\n $isSolo?: boolean;\n $isHidden?: boolean;\n $statusType?: MultiActionButtonStatusType;\n $pulseColor?: string;\n}>;\n\nconst pulse = keyframes`\n 0% {\n opacity: 0.25;\n }\n 50% {\n opacity: 0.5;\n }\n 100% {\n opacity: 0.25;\n }\n`;\n\nexport const StyledMultiActionButton = styled(motion.div)`\n align-items: stretch;\n background: transparent;\n display: inline-flex;\n position: relative;\n transition: width 0.2s ease;\n width: 100%;\n`;\n\nexport const StyledActionButton = styled.button<StyledActionButtonProps>`\n align-items: center;\n border: none;\n border-radius: 21px;\n cursor: pointer;\n display: inline-flex;\n flex: 0 0 auto;\n height: 42px;\n line-height: 22px;\n min-height: 42px;\n padding: 0;\n position: relative;\n overflow: hidden;\n transition:\n background-color 0.2s ease,\n border-radius 0.2s ease,\n color 0.2s ease,\n flex-grow 0.2s ease,\n opacity 0.2s ease,\n width 0.2s ease,\n margin-left 0.2s ease,\n padding 0.2s ease;\n user-select: none;\n white-space: nowrap;\n\n background-color: rgba(0, 0, 0, 0.25);\n color: #fff;\n\n ${({ $isExpanded }) =>\n $isExpanded &&\n css`\n flex: 1 1 auto;\n min-width: 0;\n `}\n\n ${({ $isCollapsed }) =>\n $isCollapsed &&\n css`\n flex: 0 0 auto;\n padding: 0;\n width: 42px;\n `}\n\n ${({ $isPrimary, $isCollapsed }) =>\n $isPrimary &&\n !$isCollapsed &&\n css`\n flex: 1 1 auto;\n min-width: 0;\n `}\n\n ${({ $isShrunk }) =>\n $isShrunk &&\n css`\n flex: 0 0 auto;\n padding: 0;\n width: 42px;\n `}\n\n ${({ $isSecondary, $isExpanded }) =>\n $isSecondary &&\n !$isExpanded &&\n css`\n flex: 0 0 auto;\n padding: 0;\n width: 42px;\n `}\n\n ${({ $isSecondary }) =>\n $isSecondary &&\n css`\n margin-left: 2px;\n `}\n\n ${({ $isHidden }) =>\n $isHidden &&\n css`\n margin-left: 0;\n opacity: 0;\n pointer-events: none;\n width: 0;\n `}\n\n ${({ $isPrimary }) =>\n $isPrimary &&\n css`\n border-bottom-right-radius: 0;\n border-top-right-radius: 0;\n `}\n\n ${({ $isPrimary, $isCollapsed }) =>\n $isPrimary &&\n $isCollapsed &&\n css`\n border-bottom-right-radius: 21px;\n border-top-right-radius: 21px;\n `}\n\n ${({ $isSecondary }) =>\n $isSecondary &&\n css`\n border-bottom-left-radius: 0;\n border-top-left-radius: 0;\n `}\n\n ${({ $isSolo }) =>\n $isSolo &&\n css`\n border-radius: 21px;\n `}\n\n ${({ $isCollapsed }) =>\n $isCollapsed &&\n css`\n border-radius: 21px;\n `}\n\n ${({ $statusType, $pulseColor }) =>\n $statusType === MultiActionButtonStatusType.Pulse &&\n css`\n overflow: hidden;\n\n &::before {\n animation: ${pulse} 1.6s ease-in-out infinite;\n background: ${$pulseColor || 'rgba(255, 0, 0, 0.85)'};\n border-radius: 3px;\n content: '';\n inset: 0;\n opacity: 0.1;\n pointer-events: none;\n position: absolute;\n }\n `}\n\n &:disabled {\n cursor: default;\n opacity: 0.5;\n }\n\n &:hover:not(:disabled) {\n filter: brightness(1.05);\n }\n`;\n\nexport const StyledActionContent = styled.span`\n align-items: center;\n display: inline-flex;\n flex: 1 1 auto;\n min-width: 0;\n position: relative;\n z-index: 1;\n`;\n\nexport const StyledIconSlot = styled.span`\n align-items: center;\n display: inline-flex;\n flex: 0 0 auto;\n height: 42px;\n justify-content: center;\n width: 42px;\n`;\n\nexport const StyledSecondaryLabel = styled.span`\n display: block;\n flex: 1 1 auto;\n min-width: 0;\n max-width: 100%;\n overflow: hidden;\n padding-right: 12px;\n text-overflow: ellipsis;\n white-space: nowrap;\n`;\n\nexport const StyledPrimaryLabel = styled(StyledSecondaryLabel)``;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAF,OAAA;AAAwE,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,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ACjD,IAAAV,qBAAG;AACX;AACA;AACA;AACA,6BAA6BV,KAAK;AAClC,8BAA8BkB,WAAW,IAAI,uBAAuB;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMG,mBAAmB,GAAAlB,OAAA,CAAAkB,mBAAA,GAAGjB,yBAAM,CAACkB,IAAI;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,cAAc,GAAApB,OAAA,CAAAoB,cAAA,GAAGnB,yBAAM,CAACkB,IAAI;AACzC;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAME,oBAAoB,GAAArB,OAAA,CAAAqB,oBAAA,GAAGpB,yBAAM,CAACkB,IAAI;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMG,kBAAkB,GAAAtB,OAAA,CAAAsB,kBAAA,GAAG,IAAArB,yBAAM,EAACoB,oBAAoB,CAAC,EAAE","ignoreList":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MultiActionButtonStatusType = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Supported status types for the multi action button.
|
|
9
|
+
*/
|
|
10
|
+
let MultiActionButtonStatusType = exports.MultiActionButtonStatusType = /*#__PURE__*/function (MultiActionButtonStatusType) {
|
|
11
|
+
/**
|
|
12
|
+
* Pulsing background effect.
|
|
13
|
+
* @description Applies a subtle animated overlay on the action background to draw attention.
|
|
14
|
+
* This is intended for temporary states like recording or live activity indicators.
|
|
15
|
+
*/
|
|
16
|
+
MultiActionButtonStatusType["Pulse"] = "pulse";
|
|
17
|
+
return MultiActionButtonStatusType;
|
|
18
|
+
}({});
|
|
19
|
+
/**
|
|
20
|
+
* Minimal status configuration for an action.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Event payload emitted on action click.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for a single action.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Props for the MultiActionButton component.
|
|
30
|
+
*/
|
|
31
|
+
//# sourceMappingURL=MultiActionButton.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiActionButton.types.js","names":["MultiActionButtonStatusType","exports"],"sources":["../../../../src/components/multi-action-button/MultiActionButton.types.ts"],"sourcesContent":["import type { MouseEvent, ReactNode } from 'react';\nimport type { MotionValue } from 'motion/react';\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 * Minimal status configuration for an action.\n */\nexport type MultiActionButtonActionStatus = {\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 * Optional pulse color override.\n * @description Controls the overlay color used by the pulse animation. Provide a semi-transparent\n * color to avoid overpowering the action content.\n * @optional\n */\n pulseColor?: string;\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 * 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 * Original click event.\n * @description Useful to access modifier keys, prevent default, or stop propagation.\n */\n event: MouseEvent<HTMLButtonElement>;\n};\n\n/**\n * Configuration for a single action.\n */\nexport type MultiActionButtonAction = {\n /**\n * The icon for the action.\n * @description Can be a FontAwesome class string (e.g., 'fa fa-microphone') or a custom ReactNode.\n * The icon is always rendered inside a fixed-size slot to keep alignment stable.\n */\n icon: string | ReactNode;\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 * 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 * 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 * 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 * 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\n/**\n * Props for the MultiActionButton component.\n */\nexport type MultiActionButtonProps = {\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 * Whether the whole control is disabled.\n * @description Disables interactions for both actions, including hover expansion and clicks.\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 & { label: ReactNode };\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 * Auto-reset timeout for the extended state (ms).\n * @description Applies only when the secondary action is clicked (not when hovered). After the timeout,\n * the secondary action collapses automatically.\n * @default 2000\n * @optional\n */\n extendedTimeoutMs?: number;\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 button stretches to the full width of its parent.\n * @optional\n */\n width?: number | MotionValue<number>;\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 * @optional\n */\n isCollapsed?: boolean;\n};\n"],"mappings":";;;;;;AAGA;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;AAkBA;AACA;AACA;AA0BA;AACA;AACA;AA0CA;AACA;AACA","ignoreList":[]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -33,12 +33,6 @@ Object.defineProperty(exports, "AccordionItem", {
|
|
|
33
33
|
return _AccordionItem.default;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(exports, "ActionMenuButton", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _ActionMenuButton.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
36
|
Object.defineProperty(exports, "AmountControl", {
|
|
43
37
|
enumerable: true,
|
|
44
38
|
get: function () {
|
|
@@ -273,6 +267,12 @@ Object.defineProperty(exports, "MentionFinderPopupAlignment", {
|
|
|
273
267
|
return _mentionFinder.MentionFinderPopupAlignment;
|
|
274
268
|
}
|
|
275
269
|
});
|
|
270
|
+
Object.defineProperty(exports, "MultiActionButton", {
|
|
271
|
+
enumerable: true,
|
|
272
|
+
get: function () {
|
|
273
|
+
return _MultiActionButton.default;
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
276
|
Object.defineProperty(exports, "NumberInput", {
|
|
277
277
|
enumerable: true,
|
|
278
278
|
get: function () {
|
|
@@ -524,7 +524,6 @@ var _AccordionContent = _interopRequireDefault(require("./components/accordion/a
|
|
|
524
524
|
var _AccordionGroup = _interopRequireDefault(require("./components/accordion/accordion-group/AccordionGroup"));
|
|
525
525
|
var _AccordionIntro = _interopRequireDefault(require("./components/accordion/accordion-intro/AccordionIntro"));
|
|
526
526
|
var _AccordionItem = _interopRequireDefault(require("./components/accordion/accordion-item/AccordionItem"));
|
|
527
|
-
var _ActionMenuButton = _interopRequireDefault(require("./components/action-menu-button/ActionMenuButton"));
|
|
528
527
|
var _AmountControl = _interopRequireDefault(require("./components/amount-control/AmountControl"));
|
|
529
528
|
var _VerificationBadge = _interopRequireDefault(require("./components/verification-badge/VerificationBadge"));
|
|
530
529
|
var _AreaContextProvider = _interopRequireWildcard(require("./components/area-provider/AreaContextProvider"));
|
|
@@ -559,6 +558,7 @@ var _List = _interopRequireDefault(require("./components/list/List"));
|
|
|
559
558
|
var _ListItemContent = _interopRequireDefault(require("./components/list/list-item/list-item-content/ListItemContent"));
|
|
560
559
|
var _ListItem = _interopRequireDefault(require("./components/list/list-item/ListItem"));
|
|
561
560
|
var _MentionFinder = _interopRequireDefault(require("./components/mention-finder/MentionFinder"));
|
|
561
|
+
var _MultiActionButton = _interopRequireDefault(require("./components/multi-action-button/MultiActionButton"));
|
|
562
562
|
var _NumberInput = _interopRequireDefault(require("./components/number-input/NumberInput"));
|
|
563
563
|
var _PageProvider = _interopRequireDefault(require("./components/page-provider/PageProvider"));
|
|
564
564
|
var _Popup = _interopRequireDefault(require("./components/popup/Popup"));
|