@wix/editor-react-components 1.2775.0 → 1.2776.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 (37) hide show
  1. package/dist/site/components/AudioPlayer/component.js +5 -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/Checkbox/component.js +1 -1
  5. package/dist/site/components/CheckboxGroup/component.js +1 -1
  6. package/dist/site/components/CollapsibleText/component.js +1 -1
  7. package/dist/site/components/DatePicker/component.js +622 -7
  8. package/dist/site/components/Lottie/component.js +1 -1
  9. package/dist/site/components/Menu/component.js +1 -1
  10. package/dist/site/components/RadioButtons/component.js +1 -1
  11. package/dist/site/components/Slideshow/component.js +1 -1
  12. package/dist/site/components/TextBox/component.js +1 -1
  13. package/dist/site/components/TextInput/component.js +3 -2
  14. package/dist/site/components/TextMarquee/component.js +6 -6
  15. package/dist/site/components/TimePicker/TimePicker.types.d.ts +14 -39
  16. package/dist/site/components/TimePicker/component.js +81 -547
  17. package/dist/site/components/TimePicker/component.preview.d.ts +7 -2
  18. package/dist/site/components/TimePicker/components/TimePickerField.d.ts +1 -2
  19. package/dist/site/components/TimePicker/constants.d.ts +35 -68
  20. package/dist/site/components/TimePicker/css.css +17 -169
  21. package/dist/site/components/TimePicker/hooks/useTimePickerValue.d.ts +3 -5
  22. package/dist/site/components/TimePicker/manifest.js +246 -152
  23. package/dist/site/components/TimePicker/timePickerUtils.d.ts +8 -8
  24. package/dist/site/components/chunks/Button.js +466 -1055
  25. package/dist/site/components/chunks/Button2.js +284 -471
  26. package/dist/site/components/chunks/DateField.js +51 -673
  27. package/dist/site/components/chunks/Group.js +46 -160
  28. package/dist/site/components/chunks/I18nProvider.js +1 -1
  29. package/dist/site/components/chunks/Input.js +2 -2
  30. package/dist/site/components/chunks/constants2.js +40 -70
  31. package/dist/site/components/chunks/filterDOMProps.js +13 -13
  32. package/dist/site/components/chunks/useFocusable.js +70 -0
  33. package/dist/site/components/chunks/usePress.js +825 -0
  34. package/package.json +2 -2
  35. package/dist/site/components/TimePicker/hooks/useTimeConstraints.d.ts +0 -8
  36. package/dist/site/components/chunks/VisuallyHidden.js +0 -47
  37. package/dist/site/components/chunks/{RequiredIndicator.js → useValidatedField.js} +19 -19
@@ -1,486 +1,299 @@
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, D as DesignStates, S as SEMANTIC_CLASS_NAMES, a as TestIds, C as COMPONENT_TYPE } from "./constants21.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
- import { d as defineStaticService } from "./staticService.js";
14
- import { d as defineService } from "./index10.js";
15
- import { E as EnvironmentDefinition } from "./index2.js";
16
- import { useService } from "@wix/services-manager-react";
17
- const root = "root__IB9QF";
18
- const active = "active__lpoVO";
19
- const label = "label__EtLji";
20
- const hasTransitions = "hasTransitions__sv08Z";
21
- const link = "link__0rDnC";
22
- const icon = "icon__ZzsS5";
23
- const button = "button__i8gkO";
24
- const styles = {
25
- root,
26
- active,
27
- label,
28
- hasTransitions,
29
- link,
30
- icon,
31
- button
32
- };
33
- const AnimatedButtonIcon = forwardRef(
34
- ({ svg, duration, className }, ref) => /* @__PURE__ */ jsx(
35
- AnimatedIconWithReducedMotion,
36
- {
37
- id: "animated-icon",
38
- duration,
39
- svg,
40
- className: clsx("animated-icon", styles.icon, className),
41
- ref
42
- }
43
- )
44
- );
45
- function useIconAnimation(isDisabled) {
46
- const iconAnimatedRef = useRef(null);
47
- const onAnimationForward = useCallback(() => {
48
- var _a;
49
- !isDisabled && ((_a = iconAnimatedRef.current) == null ? void 0 : _a.runAnimationForward());
50
- }, [isDisabled]);
51
- const onAnimationBackward = useCallback(() => {
52
- var _a;
53
- !isDisabled && ((_a = iconAnimatedRef.current) == null ? void 0 : _a.runAnimationBackward());
54
- }, [isDisabled]);
55
- return { iconAnimatedRef, onAnimationForward, onAnimationBackward };
1
+ import { d 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);
56
16
  }
57
- function useButtonInteractionState(iconAnimationTriggers, onAnimationForward, onAnimationBackward, propsOnMouseEnter, propsOnMouseLeave) {
58
- const [active2, setActive] = useState(false);
59
- const animationTimeoutRef = useRef(
60
- null
61
- );
62
- const isForwardRef = useRef(false);
63
- const hasHoverTrigger = iconAnimationTriggers.includes(
64
- IconAnimationTriggers.HOVER
65
- );
66
- const hasClickTrigger = iconAnimationTriggers.includes(
67
- IconAnimationTriggers.CLICK
68
- );
69
- useEffect(() => {
70
- isForwardRef.current = false;
71
- }, [hasClickTrigger, hasHoverTrigger]);
72
- useEffect(() => {
73
- return () => {
74
- if (animationTimeoutRef.current) {
75
- clearTimeout(animationTimeoutRef.current);
76
- }
77
- };
78
- }, []);
79
- const onMouseEnter = useCallback(
80
- (event) => {
81
- if (animationTimeoutRef.current) {
82
- clearTimeout(animationTimeoutRef.current);
83
- animationTimeoutRef.current = null;
84
- }
85
- setActive(true);
86
- if (hasHoverTrigger) {
87
- onAnimationForward();
88
- }
89
- propsOnMouseEnter == null ? void 0 : propsOnMouseEnter(event);
90
- },
91
- [hasHoverTrigger, onAnimationForward, propsOnMouseEnter]
92
- );
93
- const onMouseLeave = useCallback(
94
- (event) => {
95
- animationTimeoutRef.current = setTimeout(() => {
96
- setActive(false);
97
- }, TRANSITION_DURATION);
98
- if (hasHoverTrigger) {
99
- onAnimationBackward();
100
- }
101
- propsOnMouseLeave == null ? void 0 : propsOnMouseLeave(event);
102
- },
103
- [hasHoverTrigger, onAnimationBackward, propsOnMouseLeave]
104
- );
105
- const onIconAnimationClick = useCallback(() => {
106
- if (!hasClickTrigger) {
107
- return;
108
- }
109
- if (isForwardRef.current) {
110
- onAnimationBackward();
111
- } else {
112
- onAnimationForward();
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);
113
77
  }
114
- isForwardRef.current = !isForwardRef.current;
115
- }, [hasClickTrigger, onAnimationBackward, onAnimationForward]);
78
+ }
79
+ }
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
+ }));
116
120
  return {
117
- active: active2,
118
- onMouseEnter,
119
- onMouseLeave,
120
- onIconAnimationClick: hasClickTrigger ? onIconAnimationClick : void 0
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
+ })
121
130
  };
122
131
  }
123
- const useAnalyticsReportClicks = ({
124
- reportBiOnClick,
125
- onClick: propsOnClick
126
- }) => {
127
- return useCallback(
128
- (event) => {
129
- reportBiOnClick == null ? void 0 : reportBiOnClick(event);
130
- propsOnClick == null ? void 0 : propsOnClick(event);
131
- },
132
- [reportBiOnClick, propsOnClick]
133
- );
134
- };
135
- function useButtonEventHandlers({
136
- isDisabled,
137
- link: link2,
138
- propsOnClick,
139
- preventLinkNavigation,
140
- reportBiOnClick,
141
- onMouseEnter,
142
- onMouseLeave,
143
- onIconAnimationClick,
144
- onDblClick,
145
- onFocus,
146
- onBlur
147
- }) {
148
- const isLink = isValidLink(link2);
149
- const shouldPreventLinkNavigation = preventLinkNavigation && isLink;
150
- const shouldHaveOnClick = !isDisabled && propsOnClick || shouldPreventLinkNavigation;
151
- const onClick = useAnalyticsReportClicks({
152
- reportBiOnClick,
153
- onClick: shouldHaveOnClick || onIconAnimationClick ? (event) => {
154
- onIconAnimationClick == null ? void 0 : onIconAnimationClick(event);
155
- if (shouldHaveOnClick) {
156
- shouldPreventLinkNavigation && event.preventDefault();
157
- !isDisabled && (propsOnClick == null ? void 0 : propsOnClick());
158
- }
159
- } : void 0
160
- });
161
- const eventHandlers = useMemo(
162
- () => ({
163
- onClick,
164
- onMouseEnter,
165
- onMouseLeave,
166
- onKeyDown: isLink ? activateByEnterButton : activateBySpaceOrEnterButton,
167
- onDoubleClick: !isDisabled && onDblClick ? onDblClick : void 0,
168
- onFocus: !isDisabled && onFocus ? onFocus : void 0,
169
- onBlur: !isDisabled && onBlur ? onBlur : void 0
170
- }),
171
- [
172
- onClick,
173
- onMouseEnter,
174
- onMouseLeave,
175
- isLink,
176
- isDisabled,
177
- onDblClick,
178
- onFocus,
179
- onBlur
180
- ]
181
- );
182
- return { isLink, eventHandlers };
132
+ function $240e9101ba2842f5$export$7d15b64cf5a3a4c4(value, min = -Infinity, max = Infinity) {
133
+ let newValue = Math.min(Math.max(value, min), max);
134
+ return newValue;
183
135
  }
184
- function useButtonA11y({
185
- propsA11y,
186
- ariaAttributes,
187
- lang
188
- }) {
189
- const normalizedA11y = useMemo(() => {
190
- const {
191
- lang: manifestLang,
192
- tabIndex: manifestTabindex,
193
- ...manifestAriaAttributes
194
- } = propsA11y ?? {};
195
- return {
196
- lang: manifestLang,
197
- tabIndex: manifestTabindex,
198
- ariaAttributes: removeAriaPrefix(manifestAriaAttributes)
199
- };
200
- }, [propsA11y]);
201
- const a11yAttr = useMemo(
202
- () => {
203
- var _a;
204
- return getAccessibilityAttributesSpread({
205
- ariaAttributes: {
206
- ...ariaAttributes,
207
- ...normalizedA11y.ariaAttributes,
208
- label: (ariaAttributes == null ? void 0 : ariaAttributes.label) ?? normalizedA11y.ariaAttributes.label
209
- },
210
- tabIndex: normalizedA11y.tabIndex,
211
- lang: ((lang == null ? void 0 : lang.trim()) ?? ((_a = normalizedA11y.lang) == null ? void 0 : _a.trim())) || void 0
212
- });
213
- },
214
- [normalizedA11y, ariaAttributes, lang]
215
- );
216
- return a11yAttr;
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;
217
163
  }
218
- const BusinessLoggerDefinition = defineStaticService("@wix/site-service-business-logger");
219
- const ConfigurationDefinition = defineService("@wix/site-service-configuration");
220
- const CLICK_ANALYTICS_SRC = 76;
221
- const CLICK_ANALYTICS_EVID = 1113;
222
- const CLICK_ANALYTICS_ENDPOINT = "pa";
223
- const ClickAnalyticsGroups = {
224
- Button: "Button"
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"
225
175
  };
226
- const buildClickAnalyticsEvent = ({
227
- link: link2,
228
- details,
229
- elementId,
230
- elementType,
231
- elementGroup,
232
- elementTitle,
233
- language
234
- }) => ({
235
- src: CLICK_ANALYTICS_SRC,
236
- evid: CLICK_ANALYTICS_EVID,
237
- bl: navigator.language,
238
- url: window.location.href,
239
- element_id: elementId,
240
- elementType,
241
- elementGroup,
242
- elementTitle,
243
- language,
244
- value: link2 == null ? void 0 : link2.href,
245
- details: details ? JSON.stringify(details) : void 0
246
- });
247
- const useClickAnalyticsReporter = (params) => {
248
- var _a;
249
- const businessLogger = useService(
250
- BusinessLoggerDefinition
251
- );
252
- const environment = useService(EnvironmentDefinition);
253
- const configuration = useService(
254
- ConfigurationDefinition
255
- );
256
- const isPreview = (_a = environment == null ? void 0 : environment.getPreviewMode) == null ? void 0 : _a.call(environment);
257
- const reportBi = businessLogger == null ? void 0 : businessLogger.reportBi;
258
- const language = params.language ?? (environment == null ? void 0 : environment.language);
259
- const trackClicksAnalytics = configuration == null ? void 0 : configuration.trackClicksAnalytics;
260
- const isEnabled = !isPreview && trackClicksAnalytics && typeof reportBi === "function";
261
- const paramsRef = useRef(params);
262
- paramsRef.current = params;
263
- return useMemo(() => {
264
- if (!isEnabled) {
265
- return void 0;
266
- }
267
- return (event) => {
268
- const { elementId, ...restParams } = paramsRef.current;
269
- try {
270
- void Promise.resolve(
271
- reportBi(
272
- buildClickAnalyticsEvent({
273
- ...restParams,
274
- language,
275
- elementId: elementId || event.currentTarget.id
276
- }),
277
- { endpoint: CLICK_ANALYTICS_ENDPOINT }
278
- )
279
- ).catch(() => {
280
- });
281
- } catch {
282
- }
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)
182
+ });
183
+ let combinedStyles = useMemo(() => {
184
+ if (isFocused) return style;
185
+ else if (style) return {
186
+ ...$ea3928288112382f$var$styles,
187
+ ...style
283
188
  };
284
- }, [isEnabled, reportBi, language]);
285
- };
286
- const Button = (props) => {
287
- var _a;
288
- const {
289
- id,
290
- link: link2,
291
- type = "button",
292
- label: label2 = "",
293
- labelContent,
294
- disabled: isDisabled = false,
295
- onClick: propsOnClick,
296
- className,
297
- corvid,
298
- a11y: propsA11y,
299
- direction,
300
- elementProps,
301
- compPreviewState,
302
- isQaMode,
303
- fullNameCompType,
304
- lang,
305
- ariaAttributes,
306
- onDblClick,
307
- onFocus,
308
- onBlur,
309
- reportBiOnClick,
310
- preventLinkNavigation,
311
- onMouseEnter,
312
- onMouseLeave,
313
- onMouseIn,
314
- onMouseOut,
315
- wix,
316
- hasTransitions: hasTransitions2 = true
317
- } = props;
318
- const propsOnMouseEnter = useCallback(
319
- (event) => {
320
- onMouseIn == null ? void 0 : onMouseIn(event);
321
- onMouseEnter == null ? void 0 : onMouseEnter(event);
322
- },
323
- [onMouseIn, onMouseEnter]
324
- );
325
- const propsOnMouseLeave = useCallback(
326
- (event) => {
327
- onMouseOut == null ? void 0 : onMouseOut(event);
328
- onMouseLeave == null ? void 0 : onMouseLeave(event);
329
- },
330
- [onMouseOut, onMouseLeave]
331
- );
332
- const presetsWrapperProps = (wix == null ? void 0 : wix.presetsWrapperProps) || {};
333
- const animatedIconProps = elementProps == null ? void 0 : elementProps.animatedIcon;
334
- const corvidIconAnimationTriggers = (corvid == null ? void 0 : corvid.iconAnimationTriggers) ?? [];
335
- const defaultTrigger = (animatedIconProps == null ? void 0 : animatedIconProps.trigger) === IconAnimationTriggers.CLICK ? IconAnimationTriggers.CLICK : IconAnimationTriggers.HOVER;
336
- const iconAnimationTriggers = corvidIconAnimationTriggers.length > 0 ? corvidIconAnimationTriggers : [defaultTrigger];
337
- const { iconAnimatedRef, onAnimationForward, onAnimationBackward } = useIconAnimation(isDisabled);
338
- const {
339
- active: active2,
340
- onMouseEnter: handleMouseEnter,
341
- onMouseLeave: handleMouseLeave,
342
- onIconAnimationClick
343
- } = useButtonInteractionState(
344
- iconAnimationTriggers,
345
- onAnimationForward,
346
- onAnimationBackward,
347
- propsOnMouseEnter,
348
- propsOnMouseLeave
349
- );
350
- const buttonOrLinkRef = useRef(null);
351
- const semanticClassNames = SEMANTIC_CLASS_NAMES;
352
- const rootClassName = clsx(
353
- styles.root,
354
- className,
355
- styles.button,
356
- "button",
357
- !direction && directionStyles.fallbackDirection,
358
- formatClassNames(semanticClassNames.root),
359
- {
360
- disabled: isDisabled,
361
- [DesignStates.root.disabled.className]: isDisabled,
362
- [styles.active]: active2,
363
- [styles.hasTransitions]: hasTransitions2
189
+ else return $ea3928288112382f$var$styles;
190
+ }, [
191
+ isFocused
192
+ ]);
193
+ return {
194
+ visuallyHiddenProps: {
195
+ ...focusWithinProps,
196
+ style: combinedStyles
364
197
  }
365
- );
366
- const labelClassName = clsx(
367
- "label",
368
- styles.label,
369
- formatClassNames(semanticClassNames.buttonLabel),
370
- (_a = elementProps == null ? void 0 : elementProps.label) == null ? void 0 : _a.className,
371
- isDisabled && DesignStates.label.disabled.className
372
- );
373
- const linkClassName = styles.link;
374
- const reportClickAnalytics = useClickAnalyticsReporter({
375
- link: link2,
376
- elementId: id,
377
- elementType: COMPONENT_TYPE,
378
- elementGroup: ClickAnalyticsGroups.Button,
379
- elementTitle: label2,
380
- details: { isDisabled }
381
- });
382
- const { isLink, eventHandlers } = useButtonEventHandlers({
383
- isDisabled,
384
- link: link2,
385
- propsOnClick,
386
- preventLinkNavigation,
387
- reportBiOnClick: reportBiOnClick ?? reportClickAnalytics,
388
- onMouseEnter: handleMouseEnter,
389
- onMouseLeave: handleMouseLeave,
390
- onIconAnimationClick,
391
- onDblClick,
392
- onFocus,
393
- onBlur
394
- });
395
- const a11yAttr = useButtonA11y({ propsA11y, ariaAttributes, lang });
396
- const renderedLabel = labelContent ?? label2;
397
- const wrapperAttributes = {
398
- id,
399
- ...getDataAttributes(props),
400
- ...getQaDataAttributes(isQaMode, fullNameCompType),
401
- "data-semantic-classname": semanticClassNames.root,
402
- ...direction && { dir: direction }
403
198
  };
404
- const renderButtonContent = () => /* @__PURE__ */ jsxs(Fragment, { children: [
405
- renderedLabel && /* @__PURE__ */ jsx("span", { className: labelClassName, "data-testid": TestIds.buttonLabel, children: renderedLabel }),
406
- /* @__PURE__ */ jsx(
407
- AnimatedButtonIcon,
408
- {
409
- ref: iconAnimatedRef,
410
- svg: animatedIconProps == null ? void 0 : animatedIconProps.svg,
411
- duration: animatedIconProps == null ? void 0 : animatedIconProps.duration,
412
- className: animatedIconProps == null ? void 0 : animatedIconProps.className
413
- }
414
- )
415
- ] });
416
- const renderButton = () => /* @__PURE__ */ jsx(
417
- "button",
418
- {
419
- type,
420
- disabled: isDisabled,
421
- className: rootClassName,
422
- "data-testid": TestIds.buttonContent,
423
- ...wrapperAttributes,
424
- ...a11yAttr,
425
- ...eventHandlers,
426
- ref: buttonOrLinkRef,
427
- "data-preview": compPreviewState,
428
- children: renderButtonContent()
429
- }
430
- );
431
- const renderLinkedButton = () => {
432
- const linkHref = isDisabled ? void 0 : link2.href;
433
- const linkRel = link2.rel;
434
- const linkTarget = link2.target;
435
- const linkPopupId = link2.linkPopupId;
436
- const anchorDataId = link2.anchorDataId;
437
- const anchorCompId = link2.anchorCompId;
438
- return /* @__PURE__ */ jsx(
439
- "a",
440
- {
441
- href: linkHref,
442
- rel: linkRel,
443
- target: linkTarget,
444
- "data-popupid": linkPopupId,
445
- "data-anchor": anchorDataId,
446
- "data-anchor-comp-id": anchorCompId,
447
- className: clsx(linkClassName, rootClassName),
448
- "data-testid": TestIds.buttonContent,
449
- ...wrapperAttributes,
450
- ...a11yAttr,
451
- ...eventHandlers,
452
- role: a11yAttr.role,
453
- tabIndex: a11yAttr.tabIndex,
454
- ref: buttonOrLinkRef,
455
- "data-preview": compPreviewState,
456
- children: renderButtonContent()
457
- }
458
- );
199
+ }
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);
204
+ }
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
217
+ });
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
459
225
  };
460
- const renderDisabledLinkAsButton = () => /* @__PURE__ */ jsx(
461
- "button",
462
- {
463
- type,
464
- disabled: isDisabled,
465
- className: clsx(rootClassName),
466
- "data-testid": TestIds.buttonContent,
467
- ...wrapperAttributes,
468
- ...a11yAttr,
469
- ...eventHandlers,
470
- role: "link",
471
- ref: buttonOrLinkRef,
472
- "data-preview": compPreviewState,
473
- children: renderButtonContent()
474
- }
475
- );
476
- const renderContent = () => {
477
- if (isDisabled && isLink) {
478
- return renderDisabledLinkAsButton();
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
479
275
  }
480
- return isLink ? renderLinkedButton() : renderButton();
481
- };
482
- return /* @__PURE__ */ jsx("div", { className: presetWrapperStyles.presetWrapper, ...presetsWrapperProps, children: renderContent() });
483
- };
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
+ }
484
292
  export {
485
- Button as B
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
486
299
  };