@wix/editor-react-components 1.2310.0 → 1.2312.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/site/components/AudioPlayer/component.js +3 -4
  2. package/dist/site/components/Breadcrumbs/component.js +1 -1
  3. package/dist/site/components/Button/component.js +1 -1
  4. package/dist/site/components/CollapsibleText/component.js +1 -1
  5. package/dist/site/components/DatePicker/component.js +8 -965
  6. package/dist/site/components/Lottie/component.js +1 -1
  7. package/dist/site/components/Menu/component.js +1 -1
  8. package/dist/site/components/Slideshow/component.js +1 -1
  9. package/dist/site/components/TextInput/component.js +2 -3
  10. package/dist/site/components/TextMarquee/component.js +6 -6
  11. package/dist/site/components/TimePicker/TimePicker.types.d.ts +31 -0
  12. package/dist/site/components/TimePicker/component.js +119 -17
  13. package/dist/site/components/TimePicker/constants.d.ts +63 -1
  14. package/dist/site/components/TimePicker/css.css +126 -0
  15. package/dist/site/components/TimePicker/hooks/useTimeConstraints.d.ts +8 -0
  16. package/dist/site/components/TimePicker/hooks/useTimePickerValue.d.ts +2 -1
  17. package/dist/site/components/TimePicker/manifest.js +142 -3
  18. package/dist/site/components/TimePicker/timePickerUtils.d.ts +2 -0
  19. package/dist/site/components/chunks/Button.js +1057 -347
  20. package/dist/site/components/chunks/Button2.js +351 -285
  21. package/dist/site/components/chunks/Group.js +160 -47
  22. package/dist/site/components/chunks/Input.js +14 -14
  23. package/dist/site/components/chunks/{DateField.js → Tooltip.js} +1017 -52
  24. package/dist/site/components/chunks/VisuallyHidden.js +47 -0
  25. package/dist/site/components/chunks/constants2.js +62 -4
  26. package/dist/site/components/chunks/filterDOMProps.js +3 -3
  27. package/package.json +6 -3
  28. package/dist/site/components/chunks/useFocusable.js +0 -118
  29. package/dist/site/components/chunks/usePress.js +0 -825
@@ -1,299 +1,365 @@
1
- import { c as $bbaa08b3cd72f041$export$9d1611c77c2fe928, w as $2c9edc598a03d523$export$420e68273165f4ec, A as $0c4a58759813079a$export$4e328f61c538687f, B as $e969f22b6713ca4a$export$ae780daf29e6d456, x as $390e54f620492c70$export$f680877a34711e37 } from "./Group.js";
2
- import React__default, { useState, useMemo, createContext, useRef, useEffect } from "react";
3
- import { $ as $8e9d2fae0ecb9001$export$457c3d6518dd4c6f, a as $f39a9eba43920ace$export$86427a43e3e48ebb, b as $64fa3d84918910a7$export$29f1550f4b0d4415, f as $64fa3d84918910a7$export$4d86445c2cf5e3, g as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "./filterDOMProps.js";
4
- import { $ as $d1116acdf220c2da$export$4c014de7c8940b4c } from "./useFocusable.js";
5
- import { a as $d27d541f9569d26d$export$45712eceda6fad21 } from "./usePress.js";
6
- const $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY = 7e3;
7
- let $319e236875307eab$var$liveAnnouncer = null;
8
- function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
9
- if (!$319e236875307eab$var$liveAnnouncer) {
10
- $319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer();
11
- if (!(typeof IS_REACT_ACT_ENVIRONMENT === "boolean" ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== "undefined")) setTimeout(() => {
12
- if ($319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.isAttached()) $319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
13
- }, 100);
14
- else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
15
- } else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
16
- }
17
- class $319e236875307eab$var$LiveAnnouncer {
18
- isAttached() {
19
- var _this_node;
20
- return (_this_node = this.node) === null || _this_node === void 0 ? void 0 : _this_node.isConnected;
21
- }
22
- createLog(ariaLive) {
23
- let node = document.createElement("div");
24
- node.setAttribute("role", "log");
25
- node.setAttribute("aria-live", ariaLive);
26
- node.setAttribute("aria-relevant", "additions");
27
- return node;
28
- }
29
- destroy() {
30
- if (!this.node) return;
31
- document.body.removeChild(this.node);
32
- this.node = null;
33
- }
34
- announce(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
35
- var _this_assertiveLog, _this_politeLog;
36
- if (!this.node) return;
37
- let node = document.createElement("div");
38
- if (typeof message === "object") {
39
- node.setAttribute("role", "img");
40
- node.setAttribute("aria-labelledby", message["aria-labelledby"]);
41
- } else node.textContent = message;
42
- if (assertiveness === "assertive") (_this_assertiveLog = this.assertiveLog) === null || _this_assertiveLog === void 0 ? void 0 : _this_assertiveLog.appendChild(node);
43
- else (_this_politeLog = this.politeLog) === null || _this_politeLog === void 0 ? void 0 : _this_politeLog.appendChild(node);
44
- if (message !== "") setTimeout(() => {
45
- node.remove();
46
- }, timeout);
47
- }
48
- clear(assertiveness) {
49
- if (!this.node) return;
50
- if ((!assertiveness || assertiveness === "assertive") && this.assertiveLog) this.assertiveLog.innerHTML = "";
51
- if ((!assertiveness || assertiveness === "polite") && this.politeLog) this.politeLog.innerHTML = "";
52
- }
53
- constructor() {
54
- this.node = null;
55
- this.assertiveLog = null;
56
- this.politeLog = null;
57
- if (typeof document !== "undefined") {
58
- this.node = document.createElement("div");
59
- this.node.dataset.liveAnnouncer = "true";
60
- Object.assign(this.node.style, {
61
- border: 0,
62
- clip: "rect(0 0 0 0)",
63
- clipPath: "inset(50%)",
64
- height: "1px",
65
- margin: "-1px",
66
- overflow: "hidden",
67
- padding: 0,
68
- position: "absolute",
69
- width: "1px",
70
- whiteSpace: "nowrap"
71
- });
72
- this.assertiveLog = this.createLog("assertive");
73
- this.node.appendChild(this.assertiveLog);
74
- this.politeLog = this.createLog("polite");
75
- this.node.appendChild(this.politeLog);
76
- document.body.prepend(this.node);
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { forwardRef, useRef, useCallback, useState, useEffect, useMemo } from "react";
3
+ import { c as clsx } from "./clsx.js";
4
+ import { d as directionStyles } from "./direction.module.js";
5
+ import { p as presetWrapperStyles } from "./presetWrapper.module.js";
6
+ import { a as getDataAttributes, g as getQaDataAttributes } from "./dataUtils.js";
7
+ import { f as formatClassNames } from "./classNames.js";
8
+ import { I as IconAnimationTriggers } from "./Button.types.js";
9
+ import AnimatedIconWithReducedMotion from "../AnimatedIcon/component.js";
10
+ import { T as TRANSITION_DURATION, S as SEMANTIC_CLASS_NAMES, a as TestIds } from "./constants20.js";
11
+ import { d as activateByEnterButton, a as activateBySpaceOrEnterButton, r as removeAriaPrefix, g as getAccessibilityAttributesSpread } from "./a11y.js";
12
+ import { i as isValidLink } from "./Link.js";
13
+ const root = "root__IB9QF";
14
+ const active = "active__lpoVO";
15
+ const label = "label__EtLji";
16
+ const link = "link__0rDnC";
17
+ const icon = "icon__ZzsS5";
18
+ const button = "button__i8gkO";
19
+ const styles = {
20
+ root,
21
+ active,
22
+ label,
23
+ link,
24
+ icon,
25
+ button
26
+ };
27
+ const AnimatedButtonIcon = forwardRef(
28
+ ({ svg, duration }, ref) => /* @__PURE__ */ jsx(
29
+ AnimatedIconWithReducedMotion,
30
+ {
31
+ id: "animated-icon",
32
+ duration,
33
+ svg,
34
+ className: clsx("animated-icon", styles.icon),
35
+ ref
77
36
  }
78
- }
37
+ )
38
+ );
39
+ function useIconAnimation(isDisabled) {
40
+ const iconAnimatedRef = useRef(null);
41
+ const onAnimationForward = useCallback(() => {
42
+ var _a;
43
+ !isDisabled && ((_a = iconAnimatedRef.current) == null ? void 0 : _a.runAnimationForward());
44
+ }, [isDisabled]);
45
+ const onAnimationBackward = useCallback(() => {
46
+ var _a;
47
+ !isDisabled && ((_a = iconAnimatedRef.current) == null ? void 0 : _a.runAnimationBackward());
48
+ }, [isDisabled]);
49
+ return { iconAnimatedRef, onAnimationForward, onAnimationBackward };
79
50
  }
80
- function $ac4318a9c075bb9f$export$ea18c227d4417cc3(props, ref) {
81
- let { elementType = "button", isDisabled, onPress, onPressStart, onPressEnd, onPressUp, onPressChange, preventFocusOnPress, allowFocusWhenDisabled, onClick, href, target, rel, type = "button" } = props;
82
- let additionalProps;
83
- if (elementType === "button") additionalProps = {
84
- type,
85
- disabled: isDisabled,
86
- form: props.form,
87
- formAction: props.formAction,
88
- formEncType: props.formEncType,
89
- formMethod: props.formMethod,
90
- formNoValidate: props.formNoValidate,
91
- formTarget: props.formTarget,
92
- name: props.name,
93
- value: props.value
94
- };
95
- else additionalProps = {
96
- role: "button",
97
- href: elementType === "a" && !isDisabled ? href : void 0,
98
- target: elementType === "a" ? target : void 0,
99
- type: elementType === "input" ? type : void 0,
100
- disabled: elementType === "input" ? isDisabled : void 0,
101
- "aria-disabled": !isDisabled || elementType === "input" ? void 0 : isDisabled,
102
- rel: elementType === "a" ? rel : void 0
103
- };
104
- let { pressProps, isPressed } = $d27d541f9569d26d$export$45712eceda6fad21({
105
- onPressStart,
106
- onPressEnd,
107
- onPressChange,
108
- onPress,
109
- onPressUp,
110
- onClick,
111
- isDisabled,
112
- preventFocusOnPress,
113
- ref
114
- });
115
- let { focusableProps } = $d1116acdf220c2da$export$4c014de7c8940b4c(props, ref);
116
- if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
117
- let buttonProps = $bbaa08b3cd72f041$export$9d1611c77c2fe928(focusableProps, pressProps, $8e9d2fae0ecb9001$export$457c3d6518dd4c6f(props, {
118
- labelable: true
119
- }));
51
+ function useButtonInteractionState(iconAnimationTriggers, onAnimationForward, onAnimationBackward, propsOnMouseEnter, propsOnMouseLeave) {
52
+ const [active2, setActive] = useState(false);
53
+ const animationTimeoutRef = useRef(
54
+ null
55
+ );
56
+ const isForwardRef = useRef(false);
57
+ const hasHoverTrigger = iconAnimationTriggers.includes(
58
+ IconAnimationTriggers.HOVER
59
+ );
60
+ const hasClickTrigger = iconAnimationTriggers.includes(
61
+ IconAnimationTriggers.CLICK
62
+ );
63
+ useEffect(() => {
64
+ isForwardRef.current = false;
65
+ }, [hasClickTrigger, hasHoverTrigger]);
66
+ useEffect(() => {
67
+ return () => {
68
+ if (animationTimeoutRef.current) {
69
+ clearTimeout(animationTimeoutRef.current);
70
+ }
71
+ };
72
+ }, []);
73
+ const onMouseEnter = useCallback(
74
+ (event) => {
75
+ if (animationTimeoutRef.current) {
76
+ clearTimeout(animationTimeoutRef.current);
77
+ animationTimeoutRef.current = null;
78
+ }
79
+ setActive(true);
80
+ if (hasHoverTrigger) {
81
+ onAnimationForward();
82
+ }
83
+ propsOnMouseEnter == null ? void 0 : propsOnMouseEnter(event);
84
+ },
85
+ [hasHoverTrigger, onAnimationForward, propsOnMouseEnter]
86
+ );
87
+ const onMouseLeave = useCallback(
88
+ (event) => {
89
+ animationTimeoutRef.current = setTimeout(() => {
90
+ setActive(false);
91
+ }, TRANSITION_DURATION);
92
+ if (hasHoverTrigger) {
93
+ onAnimationBackward();
94
+ }
95
+ propsOnMouseLeave == null ? void 0 : propsOnMouseLeave(event);
96
+ },
97
+ [hasHoverTrigger, onAnimationBackward, propsOnMouseLeave]
98
+ );
99
+ const onIconAnimationClick = useCallback(() => {
100
+ if (!hasClickTrigger) {
101
+ return;
102
+ }
103
+ if (isForwardRef.current) {
104
+ onAnimationBackward();
105
+ } else {
106
+ onAnimationForward();
107
+ }
108
+ isForwardRef.current = !isForwardRef.current;
109
+ }, [hasClickTrigger, onAnimationBackward, onAnimationForward]);
120
110
  return {
121
- isPressed,
122
- buttonProps: $bbaa08b3cd72f041$export$9d1611c77c2fe928(additionalProps, buttonProps, {
123
- "aria-haspopup": props["aria-haspopup"],
124
- "aria-expanded": props["aria-expanded"],
125
- "aria-controls": props["aria-controls"],
126
- "aria-pressed": props["aria-pressed"],
127
- "aria-current": props["aria-current"],
128
- "aria-disabled": props["aria-disabled"]
129
- })
111
+ active: active2,
112
+ onMouseEnter,
113
+ onMouseLeave,
114
+ onIconAnimationClick: hasClickTrigger ? onIconAnimationClick : void 0
130
115
  };
131
116
  }
132
- function $240e9101ba2842f5$export$7d15b64cf5a3a4c4(value, min = -Infinity, max = Infinity) {
133
- let newValue = Math.min(Math.max(value, min), max);
134
- return newValue;
135
- }
136
- function $240e9101ba2842f5$export$e1a7b8e69ef6c52f(value, step) {
137
- let roundedValue = value;
138
- let precision = 0;
139
- let stepString = step.toString();
140
- let eIndex = stepString.toLowerCase().indexOf("e-");
141
- if (eIndex > 0) precision = Math.abs(Math.floor(Math.log10(Math.abs(step)))) + eIndex;
142
- else {
143
- let pointIndex = stepString.indexOf(".");
144
- if (pointIndex >= 0) precision = stepString.length - pointIndex;
145
- }
146
- if (precision > 0) {
147
- let pow = Math.pow(10, precision);
148
- roundedValue = Math.round(roundedValue * pow) / pow;
149
- }
150
- return roundedValue;
151
- }
152
- function $240e9101ba2842f5$export$cb6e0bb50bc19463(value, min, max, step) {
153
- min = Number(min);
154
- max = Number(max);
155
- let remainder = (value - (isNaN(min) ? 0 : min)) % step;
156
- let snappedValue = $240e9101ba2842f5$export$e1a7b8e69ef6c52f(Math.abs(remainder) * 2 >= step ? value + Math.sign(remainder) * (step - Math.abs(remainder)) : value - remainder, step);
157
- if (!isNaN(min)) {
158
- if (snappedValue < min) snappedValue = min;
159
- else if (!isNaN(max) && snappedValue > max) snappedValue = min + Math.floor($240e9101ba2842f5$export$e1a7b8e69ef6c52f((max - min) / step, step)) * step;
160
- } else if (!isNaN(max) && snappedValue > max) snappedValue = Math.floor($240e9101ba2842f5$export$e1a7b8e69ef6c52f(max / step, step)) * step;
161
- snappedValue = $240e9101ba2842f5$export$e1a7b8e69ef6c52f(snappedValue, step);
162
- return snappedValue;
163
- }
164
- const $ea3928288112382f$var$styles = {
165
- border: 0,
166
- clip: "rect(0 0 0 0)",
167
- clipPath: "inset(50%)",
168
- height: "1px",
169
- margin: "-1px",
170
- overflow: "hidden",
171
- padding: 0,
172
- position: "absolute",
173
- width: "1px",
174
- whiteSpace: "nowrap"
117
+ const useAnalyticsReportClicks = ({
118
+ reportBiOnClick,
119
+ onClick: propsOnClick
120
+ }) => {
121
+ return useCallback(
122
+ (event) => {
123
+ reportBiOnClick == null ? void 0 : reportBiOnClick(event);
124
+ propsOnClick == null ? void 0 : propsOnClick(event);
125
+ },
126
+ [reportBiOnClick, propsOnClick]
127
+ );
175
128
  };
176
- function $ea3928288112382f$export$a966af930f325cab(props = {}) {
177
- let { style, isFocusable } = props;
178
- let [isFocused, setFocused] = useState(false);
179
- let { focusWithinProps } = $2c9edc598a03d523$export$420e68273165f4ec({
180
- isDisabled: !isFocusable,
181
- onFocusWithinChange: (val) => setFocused(val)
129
+ function useButtonEventHandlers({
130
+ isDisabled,
131
+ link: link2,
132
+ propsOnClick,
133
+ preventLinkNavigation,
134
+ reportBiOnClick,
135
+ onMouseEnter,
136
+ onMouseLeave,
137
+ onIconAnimationClick,
138
+ onDblClick,
139
+ onFocus,
140
+ onBlur
141
+ }) {
142
+ const isLink = isValidLink(link2);
143
+ const shouldPreventLinkNavigation = preventLinkNavigation && isLink;
144
+ const shouldHaveOnClick = !isDisabled && propsOnClick || shouldPreventLinkNavigation;
145
+ const onClick = useAnalyticsReportClicks({
146
+ reportBiOnClick,
147
+ onClick: shouldHaveOnClick || onIconAnimationClick ? (event) => {
148
+ onIconAnimationClick == null ? void 0 : onIconAnimationClick(event);
149
+ if (shouldHaveOnClick) {
150
+ shouldPreventLinkNavigation && event.preventDefault();
151
+ !isDisabled && (propsOnClick == null ? void 0 : propsOnClick());
152
+ }
153
+ } : void 0
182
154
  });
183
- let combinedStyles = useMemo(() => {
184
- if (isFocused) return style;
185
- else if (style) return {
186
- ...$ea3928288112382f$var$styles,
187
- ...style
188
- };
189
- else return $ea3928288112382f$var$styles;
190
- }, [
191
- isFocused
192
- ]);
193
- return {
194
- visuallyHiddenProps: {
195
- ...focusWithinProps,
196
- style: combinedStyles
197
- }
198
- };
155
+ const eventHandlers = useMemo(
156
+ () => ({
157
+ onClick,
158
+ onMouseEnter,
159
+ onMouseLeave,
160
+ onKeyDown: isLink ? activateByEnterButton : activateBySpaceOrEnterButton,
161
+ onDoubleClick: !isDisabled && onDblClick ? onDblClick : void 0,
162
+ onFocus: !isDisabled && onFocus ? onFocus : void 0,
163
+ onBlur: !isDisabled && onBlur ? onBlur : void 0
164
+ }),
165
+ [
166
+ onClick,
167
+ onMouseEnter,
168
+ onMouseLeave,
169
+ isLink,
170
+ isDisabled,
171
+ onDblClick,
172
+ onFocus,
173
+ onBlur
174
+ ]
175
+ );
176
+ return { isLink, eventHandlers };
199
177
  }
200
- function $ea3928288112382f$export$439d29a4e110a164(props) {
201
- let { children, elementType: Element = "div", isFocusable, style, ...otherProps } = props;
202
- let { visuallyHiddenProps } = $ea3928288112382f$export$a966af930f325cab(props);
203
- return /* @__PURE__ */ React__default.createElement(Element, $bbaa08b3cd72f041$export$9d1611c77c2fe928(otherProps, visuallyHiddenProps), children);
178
+ function useButtonA11y({
179
+ propsA11y,
180
+ ariaAttributes,
181
+ label: label2
182
+ }) {
183
+ const normalizedA11y = useMemo(
184
+ () => removeAriaPrefix(propsA11y ?? {}),
185
+ [propsA11y]
186
+ );
187
+ const a11yAttr = useMemo(
188
+ () => getAccessibilityAttributesSpread({
189
+ ariaAttributes: {
190
+ ...ariaAttributes,
191
+ ...normalizedA11y,
192
+ label: (ariaAttributes == null ? void 0 : ariaAttributes.label) ?? (normalizedA11y.label || label2)
193
+ },
194
+ tabindex: normalizedA11y == null ? void 0 : normalizedA11y.tabindex
195
+ }),
196
+ [normalizedA11y, label2, ariaAttributes]
197
+ );
198
+ return a11yAttr;
204
199
  }
205
- const $0393f8ab869a0f1a$export$e9f3bf65a26ce129 = /* @__PURE__ */ createContext(null);
206
- const $d2b4bc8c273e7be6$export$24d547caef80ccd1 = /* @__PURE__ */ createContext({});
207
- const $d2b4bc8c273e7be6$export$353f5b6fc5456de1 = /* @__PURE__ */ $f39a9eba43920ace$export$86427a43e3e48ebb(function Button(props, ref) {
208
- [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $d2b4bc8c273e7be6$export$24d547caef80ccd1);
209
- props = $d2b4bc8c273e7be6$var$disablePendingProps(props);
210
- let ctx = props;
211
- let { isPending } = ctx;
212
- let { buttonProps, isPressed } = $ac4318a9c075bb9f$export$ea18c227d4417cc3(props, ref);
213
- let { focusProps, isFocused, isFocusVisible } = $0c4a58759813079a$export$4e328f61c538687f(props);
214
- let { hoverProps, isHovered } = $e969f22b6713ca4a$export$ae780daf29e6d456({
215
- ...props,
216
- isDisabled: props.isDisabled || isPending
200
+ const Button = (props) => {
201
+ const {
202
+ id,
203
+ link: link2,
204
+ type = "button",
205
+ label: label2 = "",
206
+ labelContent,
207
+ disabled: isDisabled = false,
208
+ onClick: propsOnClick,
209
+ className,
210
+ corvid,
211
+ a11y: propsA11y,
212
+ direction,
213
+ elementProps,
214
+ compPreviewState,
215
+ isQaMode,
216
+ fullNameCompType,
217
+ lang,
218
+ ariaAttributes,
219
+ onDblClick,
220
+ onFocus,
221
+ onBlur,
222
+ reportBiOnClick,
223
+ preventLinkNavigation,
224
+ onMouseEnter: propsOnMouseEnter,
225
+ onMouseLeave: propsOnMouseLeave,
226
+ wix
227
+ } = props;
228
+ const presetsWrapperProps = (wix == null ? void 0 : wix.presetsWrapperProps) || {};
229
+ const animatedIconProps = elementProps == null ? void 0 : elementProps.animatedIcon;
230
+ const corvidIconAnimationTriggers = (corvid == null ? void 0 : corvid.iconAnimationTriggers) ?? [];
231
+ const defaultTrigger = (animatedIconProps == null ? void 0 : animatedIconProps.trigger) === IconAnimationTriggers.CLICK ? IconAnimationTriggers.CLICK : IconAnimationTriggers.HOVER;
232
+ const iconAnimationTriggers = corvidIconAnimationTriggers.length > 0 ? corvidIconAnimationTriggers : [defaultTrigger];
233
+ const { iconAnimatedRef, onAnimationForward, onAnimationBackward } = useIconAnimation(isDisabled);
234
+ const { active: active2, onMouseEnter, onMouseLeave, onIconAnimationClick } = useButtonInteractionState(
235
+ iconAnimationTriggers,
236
+ onAnimationForward,
237
+ onAnimationBackward,
238
+ propsOnMouseEnter,
239
+ propsOnMouseLeave
240
+ );
241
+ const buttonOrLinkRef = useRef(null);
242
+ const semanticClassNames = SEMANTIC_CLASS_NAMES;
243
+ const rootClassName = clsx(
244
+ styles.root,
245
+ className,
246
+ styles.button,
247
+ "button",
248
+ !direction && directionStyles.fallbackDirection,
249
+ formatClassNames(semanticClassNames.root),
250
+ {
251
+ disabled: isDisabled,
252
+ [styles.active]: active2
253
+ }
254
+ );
255
+ const labelClassName = clsx(
256
+ "label",
257
+ styles.label,
258
+ formatClassNames(semanticClassNames.buttonLabel)
259
+ );
260
+ const linkClassName = styles.link;
261
+ const { isLink, eventHandlers } = useButtonEventHandlers({
262
+ isDisabled,
263
+ link: link2,
264
+ propsOnClick,
265
+ preventLinkNavigation,
266
+ reportBiOnClick,
267
+ onMouseEnter,
268
+ onMouseLeave,
269
+ onIconAnimationClick,
270
+ onDblClick,
271
+ onFocus,
272
+ onBlur
217
273
  });
218
- let renderValues = {
219
- isHovered,
220
- isPressed: (ctx.isPressed || isPressed) && !isPending,
221
- isFocused,
222
- isFocusVisible,
223
- isDisabled: props.isDisabled || false,
224
- isPending: isPending !== null && isPending !== void 0 ? isPending : false
274
+ const a11yAttr = useButtonA11y({ propsA11y, ariaAttributes, label: label2 });
275
+ const renderedLabel = labelContent ?? label2;
276
+ const wrapperAttributes = {
277
+ id,
278
+ ...getDataAttributes(props),
279
+ ...getQaDataAttributes(isQaMode, fullNameCompType),
280
+ "data-semantic-classname": semanticClassNames.root,
281
+ lang,
282
+ ...direction && { dir: direction }
225
283
  };
226
- let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
227
- ...props,
228
- values: renderValues,
229
- defaultClassName: "react-aria-Button"
230
- });
231
- let buttonId = $390e54f620492c70$export$f680877a34711e37(buttonProps.id);
232
- let progressId = $390e54f620492c70$export$f680877a34711e37();
233
- let ariaLabelledby = buttonProps["aria-labelledby"];
234
- if (isPending) {
235
- if (ariaLabelledby) ariaLabelledby = `${ariaLabelledby} ${progressId}`;
236
- else if (buttonProps["aria-label"]) ariaLabelledby = `${buttonId} ${progressId}`;
237
- }
238
- let wasPending = useRef(isPending);
239
- useEffect(() => {
240
- let message = {
241
- "aria-labelledby": ariaLabelledby || buttonId
242
- };
243
- if (!wasPending.current && isFocused && isPending) $319e236875307eab$export$a9b970dcc4ae71a9(message, "assertive");
244
- else if (wasPending.current && isFocused && !isPending) $319e236875307eab$export$a9b970dcc4ae71a9(message, "assertive");
245
- wasPending.current = isPending;
246
- }, [
247
- isPending,
248
- isFocused,
249
- ariaLabelledby,
250
- buttonId
251
- ]);
252
- let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
253
- global: true
254
- });
255
- delete DOMProps.onClick;
256
- return /* @__PURE__ */ React__default.createElement("button", {
257
- ...$bbaa08b3cd72f041$export$9d1611c77c2fe928(DOMProps, renderProps, buttonProps, focusProps, hoverProps),
258
- // When the button is in a pending state, we want to stop implicit form submission (ie. when the user presses enter on a text input).
259
- // We do this by changing the button's type to button.
260
- type: buttonProps.type === "submit" && isPending ? "button" : buttonProps.type,
261
- id: buttonId,
262
- ref,
263
- "aria-labelledby": ariaLabelledby,
264
- slot: props.slot || void 0,
265
- "aria-disabled": isPending ? "true" : buttonProps["aria-disabled"],
266
- "data-disabled": props.isDisabled || void 0,
267
- "data-pressed": renderValues.isPressed || void 0,
268
- "data-hovered": isHovered || void 0,
269
- "data-focused": isFocused || void 0,
270
- "data-pending": isPending || void 0,
271
- "data-focus-visible": isFocusVisible || void 0
272
- }, /* @__PURE__ */ React__default.createElement($0393f8ab869a0f1a$export$e9f3bf65a26ce129.Provider, {
273
- value: {
274
- id: progressId
284
+ const renderButtonContent = () => /* @__PURE__ */ jsxs(Fragment, { children: [
285
+ renderedLabel && /* @__PURE__ */ jsx("span", { className: labelClassName, "data-testid": TestIds.buttonLabel, children: renderedLabel }),
286
+ /* @__PURE__ */ jsx(
287
+ AnimatedButtonIcon,
288
+ {
289
+ ref: iconAnimatedRef,
290
+ svg: animatedIconProps == null ? void 0 : animatedIconProps.svg,
291
+ duration: animatedIconProps == null ? void 0 : animatedIconProps.duration
292
+ }
293
+ )
294
+ ] });
295
+ const renderButton = () => /* @__PURE__ */ jsx(
296
+ "button",
297
+ {
298
+ type,
299
+ disabled: isDisabled,
300
+ className: rootClassName,
301
+ "data-testid": TestIds.buttonContent,
302
+ ...wrapperAttributes,
303
+ ...a11yAttr,
304
+ ...eventHandlers,
305
+ ref: buttonOrLinkRef,
306
+ "data-preview": compPreviewState,
307
+ children: renderButtonContent()
275
308
  }
276
- }, renderProps.children));
277
- });
278
- function $d2b4bc8c273e7be6$var$disablePendingProps(props) {
279
- if (props.isPending) {
280
- props.onPress = void 0;
281
- props.onPressStart = void 0;
282
- props.onPressEnd = void 0;
283
- props.onPressChange = void 0;
284
- props.onPressUp = void 0;
285
- props.onKeyDown = void 0;
286
- props.onKeyUp = void 0;
287
- props.onClick = void 0;
288
- props.href = void 0;
289
- }
290
- return props;
291
- }
309
+ );
310
+ const renderLinkedButton = () => {
311
+ const linkHref = isDisabled ? void 0 : link2.href;
312
+ const linkRel = link2.rel;
313
+ const linkTarget = link2.target;
314
+ const linkPopupId = link2.linkPopupId;
315
+ const anchorDataId = link2.anchorDataId;
316
+ const anchorCompId = link2.anchorCompId;
317
+ return /* @__PURE__ */ jsx(
318
+ "a",
319
+ {
320
+ href: linkHref,
321
+ rel: linkRel,
322
+ target: linkTarget,
323
+ "data-popupid": linkPopupId,
324
+ "data-anchor": anchorDataId,
325
+ "data-anchor-comp-id": anchorCompId,
326
+ className: clsx(linkClassName, rootClassName),
327
+ "data-testid": TestIds.buttonContent,
328
+ ...wrapperAttributes,
329
+ ...a11yAttr,
330
+ ...eventHandlers,
331
+ role: a11yAttr.role,
332
+ tabIndex: a11yAttr.tabIndex,
333
+ ref: buttonOrLinkRef,
334
+ "data-preview": compPreviewState,
335
+ children: renderButtonContent()
336
+ }
337
+ );
338
+ };
339
+ const renderDisabledLinkAsButton = () => /* @__PURE__ */ jsx(
340
+ "button",
341
+ {
342
+ type,
343
+ disabled: isDisabled,
344
+ className: clsx(rootClassName),
345
+ "data-testid": TestIds.buttonContent,
346
+ ...wrapperAttributes,
347
+ ...a11yAttr,
348
+ ...eventHandlers,
349
+ role: "link",
350
+ ref: buttonOrLinkRef,
351
+ "data-preview": compPreviewState,
352
+ children: renderButtonContent()
353
+ }
354
+ );
355
+ const renderContent = () => {
356
+ if (isDisabled && isLink) {
357
+ return renderDisabledLinkAsButton();
358
+ }
359
+ return isLink ? renderLinkedButton() : renderButton();
360
+ };
361
+ return /* @__PURE__ */ jsx("div", { className: presetWrapperStyles.presetWrapper, ...presetsWrapperProps, children: renderContent() });
362
+ };
292
363
  export {
293
- $ea3928288112382f$export$439d29a4e110a164 as $,
294
- $240e9101ba2842f5$export$7d15b64cf5a3a4c4 as a,
295
- $d2b4bc8c273e7be6$export$24d547caef80ccd1 as b,
296
- $ea3928288112382f$export$a966af930f325cab as c,
297
- $d2b4bc8c273e7be6$export$353f5b6fc5456de1 as d,
298
- $240e9101ba2842f5$export$cb6e0bb50bc19463 as e
364
+ Button as B
299
365
  };