@wix/editor-react-components 1.2439.0 → 1.2441.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.
- package/dist/site/components/Checkbox/component.js +1 -2
- package/dist/site/components/CheckboxGroup/CheckboxGroup.types.d.ts +2 -1
- package/dist/site/components/CheckboxGroup/component.js +67 -7
- package/dist/site/components/CheckboxGroup/constants.d.ts +3 -0
- package/dist/site/components/CheckboxGroup/css.css +22 -5
- package/dist/site/components/CheckboxGroup/manifest.js +16 -1
- package/dist/site/components/DatePicker/component.js +1 -2
- package/dist/site/components/Dropdown/component.js +1 -2
- package/dist/site/components/Lottie/component.js +9 -197
- package/dist/site/components/Lottie/constants.d.ts +0 -1
- package/dist/site/components/Lottie/hooks/useLottie.d.ts +1 -1
- package/dist/site/components/Lottie/manifest.js +1 -1
- package/dist/site/components/Lottie/types.d.ts +1 -0
- package/dist/site/components/RadioButtons/component.js +1 -2
- package/dist/site/components/Slideshow/component.js +11 -26
- package/dist/site/components/TextBox/component.js +1 -2
- package/dist/site/components/TextInput/component.js +1 -2
- package/dist/site/components/TimePicker/component.js +1 -2
- package/dist/site/components/chunks/RequiredIndicator.js +80 -2
- package/dist/site/components/chunks/constants28.js +3 -5
- package/dist/site/components/chunks/constants36.js +6 -2
- package/dist/site/components/chunks/manifest2.js +3 -1
- package/dist/site/components/chunks/useHasDisplayedElement.js +26 -0
- package/package.json +2 -2
- package/dist/site/components/chunks/useValidatedField.js +0 -80
|
@@ -6,8 +6,7 @@ import { useService } from "@wix/services-manager-react";
|
|
|
6
6
|
import { E as EnvironmentDefinition } from "../chunks/index2.js";
|
|
7
7
|
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
8
8
|
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
9
|
-
import { R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
10
|
-
import { u as useValidatedField } from "../chunks/useValidatedField.js";
|
|
9
|
+
import { u as useValidatedField, R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
11
10
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
12
11
|
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
13
12
|
import { d as defaultValues, V as VALUE_MISSING_MESSAGE, s as selectors, T as TestIds, a as semanticClassNames } from "../chunks/constants37.js";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { A11y, Direction } from '@wix/editor-react-types';
|
|
2
2
|
import { SdkFunctionFocusableProps } from '../../../utils/functions/sdkFunctionCallbackProps';
|
|
3
|
+
import { FieldValidationProps } from '../../../utils/validation/types';
|
|
3
4
|
import { CheckboxGroupOption } from './constants';
|
|
4
5
|
export type { CheckboxGroupOption } from './constants';
|
|
5
|
-
export type CheckboxGroupProps = SdkFunctionFocusableProps & {
|
|
6
|
+
export type CheckboxGroupProps = SdkFunctionFocusableProps & FieldValidationProps<Array<string>> & {
|
|
6
7
|
id: string;
|
|
7
8
|
className: string;
|
|
8
9
|
options: Array<CheckboxGroupOption>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef } from "react";
|
|
2
3
|
import { c as clsx } from "../chunks/clsx.js";
|
|
3
|
-
import { a as Fieldset, T as Tooltip, d as CheckboxGroup_CheckboxGroup_CheckboxGroup, e as Checkbox } from "../chunks/index11.js";
|
|
4
|
-
import "react";
|
|
4
|
+
import { a as Fieldset, T as Tooltip, d as CheckboxGroup_CheckboxGroup_CheckboxGroup, c as InfoCircle_default, e as Checkbox } from "../chunks/index11.js";
|
|
5
5
|
import { useService } from "@wix/services-manager-react";
|
|
6
6
|
import { E as EnvironmentDefinition } from "../chunks/index2.js";
|
|
7
7
|
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
8
8
|
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
9
|
-
import { R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
9
|
+
import { u as useValidatedField, R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
10
10
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
11
11
|
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
12
|
-
import { d as defaultValues, a as defaultOptions, s as selectors, T as TestIds, b as semanticClassNames } from "../chunks/constants36.js";
|
|
12
|
+
import { d as defaultValues, a as defaultOptions, V as VALUE_MISSING_MESSAGE, s as selectors, T as TestIds, b as semanticClassNames } from "../chunks/constants36.js";
|
|
13
13
|
import { I as InfoCircleSmall_default } from "../chunks/InfoCircleSmall.js";
|
|
14
14
|
const root = "root__raraS";
|
|
15
15
|
const fieldset = "fieldset__pDERL";
|
|
@@ -23,6 +23,7 @@ const control = "control__MMIkR";
|
|
|
23
23
|
const indicator = "indicator__mDg93";
|
|
24
24
|
const checkmark = "checkmark__YItvi";
|
|
25
25
|
const label = "label__aznPH";
|
|
26
|
+
const errorMessage = "errorMessage__tlSBa";
|
|
26
27
|
const styles = {
|
|
27
28
|
root,
|
|
28
29
|
fieldset,
|
|
@@ -35,10 +36,12 @@ const styles = {
|
|
|
35
36
|
control,
|
|
36
37
|
indicator,
|
|
37
38
|
checkmark,
|
|
38
|
-
label
|
|
39
|
+
label,
|
|
40
|
+
errorMessage
|
|
39
41
|
};
|
|
40
42
|
const noop = () => {
|
|
41
43
|
};
|
|
44
|
+
const arraysEqual = (a, b) => a.length === b.length && a.every((item, index) => item === b[index]);
|
|
42
45
|
const CheckmarkIcon = () => /* @__PURE__ */ jsx(
|
|
43
46
|
"svg",
|
|
44
47
|
{
|
|
@@ -68,6 +71,10 @@ function CheckboxGroupComponent(props) {
|
|
|
68
71
|
onChange = noop,
|
|
69
72
|
onFocus = noop,
|
|
70
73
|
onBlur = noop,
|
|
74
|
+
fieldValidity,
|
|
75
|
+
showValidityIndication,
|
|
76
|
+
onValidate,
|
|
77
|
+
onValidityChange,
|
|
71
78
|
wix
|
|
72
79
|
} = props;
|
|
73
80
|
const sourceOptions = Array.isArray(props.options) && props.options.length ? props.options : defaultOptions;
|
|
@@ -78,10 +85,46 @@ function CheckboxGroupComponent(props) {
|
|
|
78
85
|
const allValues = options.map((option2) => option2.value);
|
|
79
86
|
const keepKnownOptions = (values) => values.filter((optionValue) => allValues.includes(optionValue));
|
|
80
87
|
const defaultChecked = options.filter((option2) => option2.checked).map((option2) => option2.value);
|
|
81
|
-
const
|
|
88
|
+
const controlledValues = value !== void 0 ? keepKnownOptions(value) : void 0;
|
|
89
|
+
const isControlled = controlledValues !== void 0;
|
|
90
|
+
const valueProps = controlledValues !== void 0 ? { value: controlledValues } : { defaultValue: keepKnownOptions(defaultChecked) };
|
|
91
|
+
const [uncontrolledValues, setUncontrolledValues] = useState(
|
|
92
|
+
keepKnownOptions(defaultChecked)
|
|
93
|
+
);
|
|
94
|
+
const rawValues = controlledValues ?? uncontrolledValues;
|
|
95
|
+
const stableValuesRef = useRef(rawValues);
|
|
96
|
+
if (!arraysEqual(stableValuesRef.current, rawValues)) {
|
|
97
|
+
stableValuesRef.current = rawValues;
|
|
98
|
+
}
|
|
99
|
+
const currentValues = stableValuesRef.current;
|
|
82
100
|
const handleValueChange = (next) => {
|
|
101
|
+
if (!isControlled) {
|
|
102
|
+
setUncontrolledValues(next);
|
|
103
|
+
}
|
|
83
104
|
onChange(next);
|
|
84
105
|
};
|
|
106
|
+
const intrinsic = required && !disabled && !readOnly && currentValues.length === 0 ? { valid: false, validationMessage: VALUE_MISSING_MESSAGE } : { valid: true, validationMessage: "" };
|
|
107
|
+
const {
|
|
108
|
+
validity,
|
|
109
|
+
showValidityIndication: showIndication,
|
|
110
|
+
handleBlur: handleValidationBlur
|
|
111
|
+
} = useValidatedField({
|
|
112
|
+
value: currentValues,
|
|
113
|
+
intrinsic,
|
|
114
|
+
fieldValidity,
|
|
115
|
+
showValidityIndication,
|
|
116
|
+
onValidate,
|
|
117
|
+
onValidityChange
|
|
118
|
+
});
|
|
119
|
+
const isInvalid = showIndication && !validity.valid;
|
|
120
|
+
const showErrorMessage = isInvalid && !!validity.validationMessage;
|
|
121
|
+
const errorId = `${id}-error`;
|
|
122
|
+
const handleBlur = (event) => {
|
|
123
|
+
onBlur(event);
|
|
124
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
125
|
+
handleValidationBlur();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
85
128
|
const hasLegend = displayLabel && !!label2;
|
|
86
129
|
const showLabelRow = hasLegend || !!tooltip2;
|
|
87
130
|
const ariaLabel = !hasLegend ? (a11y == null ? void 0 : a11y.ariaLabel) || void 0 : void 0;
|
|
@@ -180,11 +223,13 @@ function CheckboxGroupComponent(props) {
|
|
|
180
223
|
allValues,
|
|
181
224
|
disabled,
|
|
182
225
|
"aria-required": required || void 0,
|
|
226
|
+
"aria-invalid": isInvalid || void 0,
|
|
227
|
+
"aria-describedby": showErrorMessage ? errorId : void 0,
|
|
183
228
|
"aria-label": ariaLabel,
|
|
184
229
|
className: styles.group,
|
|
185
230
|
"data-testid": TestIds.group,
|
|
186
231
|
onFocus,
|
|
187
|
-
onBlur,
|
|
232
|
+
onBlur: handleBlur,
|
|
188
233
|
children: [
|
|
189
234
|
selectAll && /* @__PURE__ */ jsxs(
|
|
190
235
|
"label",
|
|
@@ -241,6 +286,21 @@ function CheckboxGroupComponent(props) {
|
|
|
241
286
|
))
|
|
242
287
|
]
|
|
243
288
|
}
|
|
289
|
+
),
|
|
290
|
+
showErrorMessage && /* @__PURE__ */ jsxs(
|
|
291
|
+
"div",
|
|
292
|
+
{
|
|
293
|
+
id: errorId,
|
|
294
|
+
className: clsx(
|
|
295
|
+
styles.errorMessage,
|
|
296
|
+
formatClassNames(semanticClassNames.errorMessage)
|
|
297
|
+
),
|
|
298
|
+
"data-testid": TestIds.errorMessage,
|
|
299
|
+
children: [
|
|
300
|
+
/* @__PURE__ */ jsx(InfoCircle_default, { "aria-hidden": "true" }),
|
|
301
|
+
validity.validationMessage
|
|
302
|
+
]
|
|
303
|
+
}
|
|
244
304
|
)
|
|
245
305
|
] })
|
|
246
306
|
}
|
|
@@ -82,6 +82,7 @@ export declare const defaultValues: {
|
|
|
82
82
|
readonly disabled: false;
|
|
83
83
|
readonly selectAll: false;
|
|
84
84
|
};
|
|
85
|
+
export declare const VALUE_MISSING_MESSAGE = "This field is required";
|
|
85
86
|
export declare const TestIds: {
|
|
86
87
|
readonly root: "checkbox-group-root";
|
|
87
88
|
readonly group: "checkbox-group-group";
|
|
@@ -93,6 +94,7 @@ export declare const TestIds: {
|
|
|
93
94
|
readonly indicator: "checkbox-group-indicator";
|
|
94
95
|
readonly optionLabel: "checkbox-group-option-label";
|
|
95
96
|
readonly tooltipButton: "checkbox-group-tooltip-button";
|
|
97
|
+
readonly errorMessage: "checkbox-group-error-message";
|
|
96
98
|
};
|
|
97
99
|
export declare const selectors: {
|
|
98
100
|
readonly root: "checkbox-group";
|
|
@@ -108,4 +110,5 @@ export declare const semanticClassNames: {
|
|
|
108
110
|
readonly indicator: "checkbox-group__indicator";
|
|
109
111
|
readonly label: "checkbox-group__label";
|
|
110
112
|
readonly requiredIndicator: "checkbox-group__required-indicator";
|
|
113
|
+
readonly errorMessage: "checkbox-group__error-message";
|
|
111
114
|
};
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
.tooltip__xXd2k {
|
|
65
65
|
max-width: 220px;
|
|
66
66
|
padding: 6px 10px;
|
|
67
|
-
font:
|
|
68
|
-
color:
|
|
69
|
-
background:
|
|
67
|
+
font: normal normal normal 12px/1.4em madefor-text, sans-serif;
|
|
68
|
+
color: #fff;
|
|
69
|
+
background: #2b2b2b;
|
|
70
70
|
border-radius: 6px;
|
|
71
71
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
|
|
72
72
|
}
|
|
@@ -164,14 +164,17 @@
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
.control__MMIkR:not([data-checked]):not([data-indeterminate])[data-invalid] .indicator__mDg93,
|
|
167
|
-
.control__MMIkR:not([data-checked]):not([data-indeterminate]) .indicator__mDg93.checkbox-group__indicator--invalid
|
|
167
|
+
.control__MMIkR:not([data-checked]):not([data-indeterminate]) .indicator__mDg93.checkbox-group__indicator--invalid,
|
|
168
|
+
.group__5et8j[aria-invalid=true] .control__MMIkR:not([data-checked]):not([data-indeterminate]) .indicator__mDg93 {
|
|
168
169
|
--indicator-border: var(--uncheckedBorderColor, #e62214);
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
.control__MMIkR[data-checked][data-invalid] .indicator__mDg93,
|
|
172
173
|
.control__MMIkR[data-indeterminate][data-invalid] .indicator__mDg93,
|
|
173
174
|
.control__MMIkR[data-checked] .indicator__mDg93.checkbox-group__indicator--invalid,
|
|
174
|
-
.control__MMIkR[data-indeterminate] .indicator__mDg93.checkbox-group__indicator--invalid
|
|
175
|
+
.control__MMIkR[data-indeterminate] .indicator__mDg93.checkbox-group__indicator--invalid,
|
|
176
|
+
.group__5et8j[aria-invalid=true] .control__MMIkR[data-checked] .indicator__mDg93,
|
|
177
|
+
.group__5et8j[aria-invalid=true] .control__MMIkR[data-indeterminate] .indicator__mDg93 {
|
|
175
178
|
--indicator-border: var(--checkedBorderColor, #e62214);
|
|
176
179
|
}
|
|
177
180
|
|
|
@@ -207,6 +210,20 @@
|
|
|
207
210
|
.label__aznPH {
|
|
208
211
|
cursor: pointer;
|
|
209
212
|
margin-bottom: 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.errorMessage__tlSBa {
|
|
216
|
+
display: flex;
|
|
217
|
+
flex-direction: row;
|
|
218
|
+
align-items: center;
|
|
219
|
+
gap: 4px;
|
|
220
|
+
font: normal normal normal 12px/1.4em madefor-text, sans-serif;
|
|
221
|
+
color: var(--errorTextColor, #ff4040);
|
|
222
|
+
}
|
|
223
|
+
.errorMessage__tlSBa svg {
|
|
224
|
+
flex: none;
|
|
225
|
+
width: 18px;
|
|
226
|
+
height: 18px;
|
|
210
227
|
}.checkbox-group {
|
|
211
228
|
--checkboxesSpacing: 6px;
|
|
212
229
|
--labelSpacing: 16px;
|
|
@@ -3,6 +3,7 @@ import { D as DesignStates, c as DisplayNames, d as defaultValues, s as selector
|
|
|
3
3
|
import { w as withSpec, g as getSelector } from "../chunks/manifest.js";
|
|
4
4
|
import { I as IS_SUPPORT_DESIGN_STATE_SPEC } from "../chunks/specs.js";
|
|
5
5
|
import { m as manifestFocusable, a as manifestChangeable } from "../chunks/manifestSdkMixins.js";
|
|
6
|
+
import { m as manifestValidation } from "../chunks/manifest2.js";
|
|
6
7
|
const manifest = {
|
|
7
8
|
id: "aa224b85-e2af-462b-9a15-5de3a753bea8",
|
|
8
9
|
type: "wixEditorElements.CheckboxGroup__DEV__v3",
|
|
@@ -128,7 +129,21 @@ const manifest = {
|
|
|
128
129
|
dataType: DATA.DATA_TYPE.direction
|
|
129
130
|
},
|
|
130
131
|
...manifestChangeable(),
|
|
131
|
-
...manifestFocusable()
|
|
132
|
+
...manifestFocusable(),
|
|
133
|
+
// `item` is proto-correct for a function-param array but currently fails
|
|
134
|
+
// enrichment (SPI validates it with the data-field ArrayItems schema).
|
|
135
|
+
// Do NOT switch to `dataItem` — it is stripped in serialization and fails
|
|
136
|
+
// identically. Blocked on a component-protocol platform fix.
|
|
137
|
+
...manifestValidation({
|
|
138
|
+
valueParameter: {
|
|
139
|
+
dataType: DATA.DATA_TYPE.arrayItems,
|
|
140
|
+
[DATA.DATA_TYPE.arrayItems]: {
|
|
141
|
+
item: {
|
|
142
|
+
dataType: DATA.DATA_TYPE.text
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
})
|
|
132
147
|
},
|
|
133
148
|
displayGroups: {
|
|
134
149
|
optionsGroup: {
|
|
@@ -16,8 +16,7 @@ import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
|
16
16
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
17
17
|
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
18
18
|
import { E as EMPTY_VALUE, T as TestIds, s as selectors, D as DesignStates, A as ARIA_LABEL_NAMESPACE, d as defaultValues, S as SelectionModeValues, G as GranularityValues, V as VALUE_MISSING_MESSAGE, a as AriaLabels } from "../chunks/constants34.js";
|
|
19
|
-
import { u as useValidatedField } from "../chunks/
|
|
20
|
-
import { R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
19
|
+
import { R as RequiredIndicator, u as useValidatedField } from "../chunks/RequiredIndicator.js";
|
|
21
20
|
import { I as InfoCircleSmall_default } from "../chunks/InfoCircleSmall.js";
|
|
22
21
|
import { D as DismissSmall_default } from "../chunks/DismissSmall.js";
|
|
23
22
|
createContext(null);
|
|
@@ -8,11 +8,10 @@ import { E as EnvironmentDefinition } from "../chunks/index2.js";
|
|
|
8
8
|
import { T as TranslationsDefinition } from "../chunks/index6.js";
|
|
9
9
|
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
10
10
|
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
11
|
-
import { R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
11
|
+
import { u as useValidatedField, R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
12
12
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
13
13
|
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
14
14
|
import { A as ALL_VALUE, s as selectors, a as semanticClassNames, T as TestIds, d as defaultValues, b as TriggerModeValues, c as ARIA_LABEL_NAMESPACE, e as AriaLabels, V as VALUE_MISSING_MESSAGE } from "../chunks/constants33.js";
|
|
15
|
-
import { u as useValidatedField } from "../chunks/useValidatedField.js";
|
|
16
15
|
import { u as useResizeObserver } from "../chunks/useResizeObserver.js";
|
|
17
16
|
import { D as DismissSmall_default } from "../chunks/DismissSmall.js";
|
|
18
17
|
import { g as getDefaultExportFromCjs } from "../chunks/_commonjsHelpers.js";
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key2, value2) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key2] = value2;
|
|
3
|
-
var __publicField = (obj, key2, value2) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value2);
|
|
4
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
2
|
import { c as clsx } from "../chunks/clsx.js";
|
|
6
3
|
import { useService } from "@wix/services-manager-react";
|
|
@@ -8,11 +5,12 @@ import { T as TranslationsDefinition } from "../chunks/index6.js";
|
|
|
8
5
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
9
6
|
import { g as getTranslation } from "../chunks/getTranslation.js";
|
|
10
7
|
import { B as Button } from "../chunks/Button.js";
|
|
11
|
-
import {
|
|
8
|
+
import { r as rootDataDefaults, s as semanticSelectors, A as ARIA_LABEL_NAMESPACE, t as testIds, p as pauseIconSvg, a as playIconSvg, b as showButtonOnHoverDefaults, D as DefaultTranslations, T as TranslationKeys } from "../chunks/constants28.js";
|
|
12
9
|
import { g as getDefaultExportFromCjs } from "../chunks/_commonjsHelpers.js";
|
|
13
10
|
import React__default, { useEffect, useState, useRef, useMemo } from "react";
|
|
14
11
|
import { f as convertA11yKeysToHtmlFormat } from "../chunks/a11y.js";
|
|
15
12
|
import { E as EnvironmentDefinition } from "../chunks/index2.js";
|
|
13
|
+
import { u as useHasDisplayedElement } from "../chunks/useHasDisplayedElement.js";
|
|
16
14
|
var lottie$2 = { exports: {} };
|
|
17
15
|
var lottie$1 = lottie$2.exports;
|
|
18
16
|
var hasRequiredLottie;
|
|
@@ -16773,189 +16771,11 @@ const LottieAnimation = ({ a11y, animationData, ...playerProps }) => animationDa
|
|
|
16773
16771
|
...a11y && convertA11yKeysToHtmlFormat(a11y)
|
|
16774
16772
|
}
|
|
16775
16773
|
) : null;
|
|
16776
|
-
class StyleObserver {
|
|
16777
|
-
/**
|
|
16778
|
-
* Create a new (detached) instance of CSS variable observer.
|
|
16779
|
-
*
|
|
16780
|
-
* @param observedVariables list of CSS variables to observe
|
|
16781
|
-
* @param callback callback that will be invoked every time any of listed CSS variables change
|
|
16782
|
-
* @param options configuration options
|
|
16783
|
-
*/
|
|
16784
|
-
constructor(callback, config = { propertiesToObserve: [] }) {
|
|
16785
|
-
// List of elements that are being observed
|
|
16786
|
-
__publicField(this, "_observedElements", /* @__PURE__ */ new Set());
|
|
16787
|
-
// Value cache per observed element
|
|
16788
|
-
__publicField(this, "_cachedValues", /* @__PURE__ */ new WeakMap());
|
|
16789
|
-
/*
|
|
16790
|
-
* Observer CSS variables and their internal identifiers.
|
|
16791
|
-
*/
|
|
16792
|
-
__publicField(this, "_observedVariables");
|
|
16793
|
-
/*
|
|
16794
|
-
* User supplied callback that receives CSS variable values.
|
|
16795
|
-
*/
|
|
16796
|
-
__publicField(this, "_callback");
|
|
16797
|
-
/*
|
|
16798
|
-
* Event handler that is used to invoke callback.
|
|
16799
|
-
*/
|
|
16800
|
-
__publicField(this, "_eventHandler", this._handleUpdate.bind(this));
|
|
16801
|
-
/*
|
|
16802
|
-
* Mode to determine whether to observe all properties or only the changed ones
|
|
16803
|
-
*/
|
|
16804
|
-
__publicField(this, "_notificationMode");
|
|
16805
|
-
/*
|
|
16806
|
-
* Format to determine how to return the observed values
|
|
16807
|
-
*/
|
|
16808
|
-
__publicField(this, "_returnFormat");
|
|
16809
|
-
this._callback = callback;
|
|
16810
|
-
this._observedVariables = config.propertiesToObserve;
|
|
16811
|
-
this._notificationMode = config.notificationMode ?? "changed_only";
|
|
16812
|
-
this._returnFormat = config.returnFormat ?? "object";
|
|
16813
|
-
}
|
|
16814
|
-
setPropertiesToObserve(propertiesToObserve) {
|
|
16815
|
-
this._observedVariables = propertiesToObserve;
|
|
16816
|
-
}
|
|
16817
|
-
/**
|
|
16818
|
-
* Attach observer to target element. Callback will be invoked immediately with the current assigned values.
|
|
16819
|
-
*
|
|
16820
|
-
* @param targetElement target element
|
|
16821
|
-
*/
|
|
16822
|
-
observe(targetElement) {
|
|
16823
|
-
if (!this._observedElements.has(targetElement)) {
|
|
16824
|
-
this._observedElements.add(targetElement);
|
|
16825
|
-
this._cachedValues.set(targetElement, {});
|
|
16826
|
-
this._setTargetElementStyles(targetElement);
|
|
16827
|
-
targetElement.addEventListener("transitionrun", this._eventHandler);
|
|
16828
|
-
}
|
|
16829
|
-
}
|
|
16830
|
-
/**
|
|
16831
|
-
* Detach observer from given targetElement
|
|
16832
|
-
* If no argument is passed, then all are detached
|
|
16833
|
-
*/
|
|
16834
|
-
unobserve(targetElement) {
|
|
16835
|
-
let elementsToUnobserve;
|
|
16836
|
-
if (targetElement) {
|
|
16837
|
-
if (this._observedElements.has(targetElement)) {
|
|
16838
|
-
elementsToUnobserve = /* @__PURE__ */ new Set([targetElement]);
|
|
16839
|
-
} else {
|
|
16840
|
-
elementsToUnobserve = /* @__PURE__ */ new Set();
|
|
16841
|
-
}
|
|
16842
|
-
} else {
|
|
16843
|
-
elementsToUnobserve = this._observedElements;
|
|
16844
|
-
}
|
|
16845
|
-
if (!elementsToUnobserve.size) {
|
|
16846
|
-
return;
|
|
16847
|
-
}
|
|
16848
|
-
elementsToUnobserve.forEach((elementToUnobserve) => {
|
|
16849
|
-
this._unsetTargetElementStyles(elementToUnobserve);
|
|
16850
|
-
elementToUnobserve.removeEventListener(
|
|
16851
|
-
"transitionrun",
|
|
16852
|
-
this._eventHandler
|
|
16853
|
-
);
|
|
16854
|
-
this._observedElements.delete(elementToUnobserve);
|
|
16855
|
-
this._cachedValues.delete(elementToUnobserve);
|
|
16856
|
-
});
|
|
16857
|
-
}
|
|
16858
|
-
/**
|
|
16859
|
-
* Attach the styles necessary to track the changes to the given element
|
|
16860
|
-
*
|
|
16861
|
-
* @param targetElement The element to track
|
|
16862
|
-
*/
|
|
16863
|
-
_setTargetElementStyles(targetElement) {
|
|
16864
|
-
const cssTransitionValue = this._observedVariables.map((value2) => `${value2} 0.001ms step-start`).join(", ");
|
|
16865
|
-
targetElement.style.setProperty("transition", cssTransitionValue);
|
|
16866
|
-
targetElement.style.setProperty("transition-behavior", "allow-discrete");
|
|
16867
|
-
}
|
|
16868
|
-
/**
|
|
16869
|
-
* Remove the styles that track the property changes
|
|
16870
|
-
*
|
|
16871
|
-
* @param targetElement The element to track
|
|
16872
|
-
*/
|
|
16873
|
-
_unsetTargetElementStyles(targetElement) {
|
|
16874
|
-
targetElement.style.removeProperty("transition");
|
|
16875
|
-
targetElement.style.removeProperty("transition-behavior");
|
|
16876
|
-
}
|
|
16877
|
-
/**
|
|
16878
|
-
* Process the computed style and collect the changes
|
|
16879
|
-
*
|
|
16880
|
-
* @param computedStyle The computed style of the target element
|
|
16881
|
-
* @returns Collected changes
|
|
16882
|
-
*/
|
|
16883
|
-
_processComputedStyle(computedStyle, targetElement) {
|
|
16884
|
-
const changes = {};
|
|
16885
|
-
const cachedValuesForElement = this._cachedValues.get(targetElement) ?? {};
|
|
16886
|
-
this._observedVariables.forEach((propertyName) => {
|
|
16887
|
-
const currentValue = computedStyle.getPropertyValue(propertyName);
|
|
16888
|
-
const previousValue = cachedValuesForElement[propertyName];
|
|
16889
|
-
const hasChanged = currentValue !== previousValue;
|
|
16890
|
-
if (this._notificationMode === "all" || hasChanged) {
|
|
16891
|
-
changes[propertyName] = {
|
|
16892
|
-
value: currentValue,
|
|
16893
|
-
previousValue,
|
|
16894
|
-
changed: hasChanged,
|
|
16895
|
-
element: targetElement
|
|
16896
|
-
};
|
|
16897
|
-
cachedValuesForElement[propertyName] = currentValue;
|
|
16898
|
-
}
|
|
16899
|
-
});
|
|
16900
|
-
return changes;
|
|
16901
|
-
}
|
|
16902
|
-
/**
|
|
16903
|
-
* Returns the formatter to use
|
|
16904
|
-
*/
|
|
16905
|
-
_getFormatter(format) {
|
|
16906
|
-
switch (format) {
|
|
16907
|
-
case "object":
|
|
16908
|
-
return (changes) => {
|
|
16909
|
-
return changes;
|
|
16910
|
-
};
|
|
16911
|
-
case "value_only":
|
|
16912
|
-
default:
|
|
16913
|
-
return (changes) => {
|
|
16914
|
-
const formattedChanges = {};
|
|
16915
|
-
Object.keys(changes).forEach((key2) => {
|
|
16916
|
-
formattedChanges[key2] = changes[key2].value;
|
|
16917
|
-
});
|
|
16918
|
-
return formattedChanges;
|
|
16919
|
-
};
|
|
16920
|
-
}
|
|
16921
|
-
}
|
|
16922
|
-
/**
|
|
16923
|
-
* Collect CSS variable values and invoke callback.
|
|
16924
|
-
*/
|
|
16925
|
-
_handleUpdate(e) {
|
|
16926
|
-
const targetElement = e instanceof HTMLElement ? e : e.target;
|
|
16927
|
-
if (this._observedElements.has(targetElement)) {
|
|
16928
|
-
const computedStyle = getComputedStyle(targetElement);
|
|
16929
|
-
const changes = this._processComputedStyle(computedStyle, targetElement);
|
|
16930
|
-
if (Object.keys(changes).length === 0) {
|
|
16931
|
-
return;
|
|
16932
|
-
}
|
|
16933
|
-
const formatter = this._getFormatter(this._returnFormat);
|
|
16934
|
-
this._callback(formatter(changes));
|
|
16935
|
-
}
|
|
16936
|
-
}
|
|
16937
|
-
}
|
|
16938
|
-
function useStyleRefreshKey(element, propertiesToObserve = []) {
|
|
16939
|
-
const [refreshKey, setRefreshKey] = useState(0);
|
|
16940
|
-
const refreshComponent = () => setRefreshKey((oldRefreshKey) => oldRefreshKey + 1);
|
|
16941
|
-
const styleObserverRef = useRef(
|
|
16942
|
-
new StyleObserver(refreshComponent, { propertiesToObserve })
|
|
16943
|
-
);
|
|
16944
|
-
useEffect(() => {
|
|
16945
|
-
const styleObserver = styleObserverRef.current;
|
|
16946
|
-
styleObserver.setPropertiesToObserve(propertiesToObserve);
|
|
16947
|
-
if (!element) {
|
|
16948
|
-
return;
|
|
16949
|
-
}
|
|
16950
|
-
styleObserver.observe(element);
|
|
16951
|
-
return () => styleObserver.unobserve(element);
|
|
16952
|
-
}, [element, propertiesToObserve]);
|
|
16953
|
-
return refreshKey;
|
|
16954
|
-
}
|
|
16955
16774
|
function useLottie({
|
|
16956
16775
|
animationUrl,
|
|
16957
16776
|
autoplay = true,
|
|
16958
|
-
speed = rootDataDefaults.speed
|
|
16777
|
+
speed = rootDataDefaults.speed,
|
|
16778
|
+
allowClickToStop = rootDataDefaults.allowClickToStop
|
|
16959
16779
|
}) {
|
|
16960
16780
|
var _a;
|
|
16961
16781
|
const environment = useService(EnvironmentDefinition);
|
|
@@ -16967,19 +16787,11 @@ function useLottie({
|
|
|
16967
16787
|
[]
|
|
16968
16788
|
);
|
|
16969
16789
|
const containerRef = useRef(null);
|
|
16970
|
-
const
|
|
16971
|
-
|
|
16972
|
-
|
|
16973
|
-
|
|
16974
|
-
`.${semanticSelectors.playButton}`
|
|
16975
|
-
);
|
|
16976
|
-
setPlayButtonElement(el ?? null);
|
|
16977
|
-
}, []);
|
|
16978
|
-
useStyleRefreshKey(
|
|
16979
|
-
playButtonElement,
|
|
16980
|
-
displayPropertyToObserve
|
|
16790
|
+
const isPlayButtonHidden = !useHasDisplayedElement(
|
|
16791
|
+
containerRef,
|
|
16792
|
+
[`.${semanticSelectors.playButton}`],
|
|
16793
|
+
allowClickToStop
|
|
16981
16794
|
);
|
|
16982
|
-
const isPlayButtonHidden = !isSSR && playButtonElement ? window.getComputedStyle(playButtonElement).display === "none" : false;
|
|
16983
16795
|
const lottieRef = useRef(null);
|
|
16984
16796
|
const [animationData, setAnimationData] = useState(null);
|
|
16985
16797
|
const [isPlaying, setIsPlaying] = useState(
|
|
@@ -17127,7 +16939,7 @@ const Lottie = (props) => {
|
|
|
17127
16939
|
handleComplete,
|
|
17128
16940
|
handlePause,
|
|
17129
16941
|
handleResume
|
|
17130
|
-
} = useLottie({ animationUrl, autoplay, speed });
|
|
16942
|
+
} = useLottie({ animationUrl, autoplay, speed, allowClickToStop });
|
|
17131
16943
|
return /* @__PURE__ */ jsx(
|
|
17132
16944
|
"div",
|
|
17133
16945
|
{
|
|
@@ -47,7 +47,6 @@ export declare const editorOverrides: {
|
|
|
47
47
|
readonly showButtonOnHover: "always";
|
|
48
48
|
readonly allowClickToStop: false;
|
|
49
49
|
};
|
|
50
|
-
export declare const displayPropertyToObserve: string[];
|
|
51
50
|
export declare const testIds: {
|
|
52
51
|
readonly animationClickWrapper: "lottie-animation-click-wrapper";
|
|
53
52
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LottieRefCurrentProps } from 'lottie-react';
|
|
2
2
|
import { UseLottieParams } from '../types';
|
|
3
|
-
export declare function useLottie({ animationUrl, autoplay, speed, }: UseLottieParams): {
|
|
3
|
+
export declare function useLottie({ animationUrl, autoplay, speed, allowClickToStop, }: UseLottieParams): {
|
|
4
4
|
containerRef: import('react').RefObject<HTMLDivElement>;
|
|
5
5
|
lottieRef: import('react').MutableRefObject<LottieRefCurrentProps | null>;
|
|
6
6
|
animationData: unknown;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { b as DISPLAY_GROUPS, E as ELEMENTS, D as DATA, L as LAYOUT, A as Archetype } from "../chunks/chunk-V7QOLP3D.js";
|
|
2
2
|
import { g as getSelector } from "../chunks/manifest.js";
|
|
3
|
-
import { c as speedConstraints,
|
|
3
|
+
import { c as speedConstraints, d as playButtonDefaults, e as DisplayNames, r as rootDataDefaults, b as showButtonOnHoverDefaults, f as borderDefaultValue, i as initialSize, s as semanticSelectors } from "../chunks/constants28.js";
|
|
4
4
|
import { m as manifestFocusable, c as manifestMouseHover, d as manifestClickable } from "../chunks/manifestSdkMixins.js";
|
|
5
5
|
const manifest = {
|
|
6
6
|
id: "13165477-8205-4050-b078-424a1479159e",
|
|
@@ -29,6 +29,7 @@ export interface UseLottieParams {
|
|
|
29
29
|
animationUrl?: string;
|
|
30
30
|
autoplay?: boolean;
|
|
31
31
|
speed?: number;
|
|
32
|
+
allowClickToStop?: boolean;
|
|
32
33
|
}
|
|
33
34
|
export type LottiePlayerAnyRendererProps = Omit<LottieComponentProps, 'renderer' | 'rendererSettings'> & {
|
|
34
35
|
renderer?: RendererType;
|
|
@@ -6,8 +6,7 @@ import { useService } from "@wix/services-manager-react";
|
|
|
6
6
|
import { E as EnvironmentDefinition } from "../chunks/index2.js";
|
|
7
7
|
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
8
8
|
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
9
|
-
import { R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
10
|
-
import { u as useValidatedField } from "../chunks/useValidatedField.js";
|
|
9
|
+
import { u as useValidatedField, R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
11
10
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
12
11
|
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
13
12
|
import { d as defaultValues, a as defaultOptions, V as VALUE_MISSING_MESSAGE, s as selectors, T as TestIds, b as semanticClassNames } from "../chunks/constants24.js";
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState, useRef, useEffect, useCallback, useMemo } from "react";
|
|
3
3
|
import { c as clsx } from "../chunks/clsx.js";
|
|
4
4
|
import { M as MOVEMENT_DIRECTION, A as AUTOPLAY_STATE, s as slideshowDataDefaults, a as semanticClassNames, b as ARIA_LABEL_NAMESPACE, S as SLIDESHOW_SLIDE_LTR_DIRECTION_EXPERIMENT, D as DefaultTranslations, T as TranslationKeys } from "../chunks/Slideshow.semanticClassNames.js";
|
|
5
|
-
import { u as
|
|
5
|
+
import { u as useHasDisplayedElement } from "../chunks/useHasDisplayedElement.js";
|
|
6
6
|
import { B as Button } from "../chunks/Button.js";
|
|
7
7
|
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
8
8
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
@@ -515,7 +515,11 @@ const PauseButton = ({
|
|
|
515
515
|
}
|
|
516
516
|
);
|
|
517
517
|
};
|
|
518
|
-
const
|
|
518
|
+
const SLIDE_CHANGING_CONTROL_SELECTORS = [
|
|
519
|
+
".animated-icon",
|
|
520
|
+
".label",
|
|
521
|
+
`.${semanticClassNames.pagination}`
|
|
522
|
+
];
|
|
519
523
|
const Slideshow = (props) => {
|
|
520
524
|
var _a, _b;
|
|
521
525
|
const {
|
|
@@ -562,30 +566,11 @@ const Slideshow = (props) => {
|
|
|
562
566
|
const navigationButtonsProps = elementProps == null ? void 0 : elementProps.navigationButtons;
|
|
563
567
|
const slideIndicatorsProps = elementProps == null ? void 0 : elementProps.slideIndicators;
|
|
564
568
|
const controlsRef = useRef(null);
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
const icon = container.querySelector(".animated-icon");
|
|
573
|
-
const label = container.querySelector(".label");
|
|
574
|
-
const indicators = container.querySelector(
|
|
575
|
-
`.${semanticClassNames.pagination}`
|
|
576
|
-
);
|
|
577
|
-
setForcePauseButton(
|
|
578
|
-
!isDisplayed(icon) && !isDisplayed(label) && !isDisplayed(indicators)
|
|
579
|
-
);
|
|
580
|
-
}, [reducedMotion]);
|
|
581
|
-
useResizeObserver({
|
|
582
|
-
callback: evaluateSlideChangingControls,
|
|
583
|
-
ref: controlsRef,
|
|
584
|
-
enabled: reducedMotion
|
|
585
|
-
});
|
|
586
|
-
useEffect(() => {
|
|
587
|
-
evaluateSlideChangingControls();
|
|
588
|
-
}, [evaluateSlideChangingControls]);
|
|
569
|
+
const forcePauseButton = !useHasDisplayedElement(
|
|
570
|
+
controlsRef,
|
|
571
|
+
SLIDE_CHANGING_CONTROL_SELECTORS,
|
|
572
|
+
reducedMotion
|
|
573
|
+
);
|
|
589
574
|
const [autoplayState, setAutoplayState] = useState(
|
|
590
575
|
autoplay ? AUTOPLAY_STATE.RUNNING : AUTOPLAY_STATE.PAUSED
|
|
591
576
|
);
|
|
@@ -6,11 +6,10 @@ import { useService } from "@wix/services-manager-react";
|
|
|
6
6
|
import { E as EnvironmentDefinition } from "../chunks/index2.js";
|
|
7
7
|
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
8
8
|
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
9
|
-
import { R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
9
|
+
import { u as useValidatedField, R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
10
10
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
11
11
|
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
12
12
|
import { d as defaultValues, s as selectors, T as TestIds, V as VALIDATION_MESSAGES, a as semanticClassNames } from "../chunks/constants18.js";
|
|
13
|
-
import { u as useValidatedField } from "../chunks/useValidatedField.js";
|
|
14
13
|
import { I as InfoCircleSmall_default } from "../chunks/InfoCircleSmall.js";
|
|
15
14
|
const root = "root__dlp5n";
|
|
16
15
|
const field = "field__i7dfL";
|
|
@@ -5,8 +5,7 @@ import { c as clsx } from "../chunks/clsx.js";
|
|
|
5
5
|
import { E as EnvironmentDefinition } from "../chunks/index2.js";
|
|
6
6
|
import { b as getAccessibilityAttributes, H as HAS_CUSTOM_FOCUS_CLASSNAME } from "../chunks/a11y.js";
|
|
7
7
|
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
8
|
-
import { R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
9
|
-
import { u as useValidatedField } from "../chunks/useValidatedField.js";
|
|
8
|
+
import { u as useValidatedField, R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
10
9
|
import { s as selectors, T as TestIds, V as VALUE_MISSING_MESSAGE } from "../chunks/constants3.js";
|
|
11
10
|
import { useService } from "@wix/services-manager-react";
|
|
12
11
|
import { T as TranslationsDefinition } from "../chunks/index6.js";
|
|
@@ -13,8 +13,7 @@ import { g as getTranslation } from "../chunks/getTranslation.js";
|
|
|
13
13
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
14
14
|
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
15
15
|
import { E as EMPTY_VALUE, T as TestIds, s as selectors, a as TRANSLATIONS_NAMESPACE, d as defaultValues, V as VALUE_MISSING_MESSAGE, H as HourCycleValues, D as DefaultTranslations, b as TranslationKeys } from "../chunks/constants2.js";
|
|
16
|
-
import { u as useValidatedField } from "../chunks/
|
|
17
|
-
import { R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
16
|
+
import { u as useValidatedField, R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
18
17
|
import { D as DismissSmall_default } from "../chunks/DismissSmall.js";
|
|
19
18
|
import { I as InfoCircleSmall_default } from "../chunks/InfoCircleSmall.js";
|
|
20
19
|
const root = "root__dzkbY";
|
|
@@ -1,6 +1,83 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useState, useMemo, useRef, useEffect, useCallback } from "react";
|
|
1
3
|
import { jsx } from "react/jsx-runtime";
|
|
2
4
|
import { c as clsx } from "./clsx.js";
|
|
3
|
-
|
|
5
|
+
const sameValidity = (a, b) => a !== null && a.valid === b.valid && a.validationMessage === b.validationMessage;
|
|
6
|
+
function useValidatedField({
|
|
7
|
+
value,
|
|
8
|
+
valueKey,
|
|
9
|
+
intrinsic,
|
|
10
|
+
fieldValidity,
|
|
11
|
+
showValidityIndication,
|
|
12
|
+
onValidate,
|
|
13
|
+
onValidityChange
|
|
14
|
+
}) {
|
|
15
|
+
const isGateControlled = showValidityIndication !== void 0;
|
|
16
|
+
const [touched, setTouched] = useState(false);
|
|
17
|
+
const showIndication = isGateControlled ? Boolean(showValidityIndication) : touched;
|
|
18
|
+
const changeKey = valueKey === void 0 ? value : valueKey;
|
|
19
|
+
const customInvalid = (fieldValidity == null ? void 0 : fieldValidity.valid) === false;
|
|
20
|
+
const customMessage = (fieldValidity == null ? void 0 : fieldValidity.validationMessage) ?? "";
|
|
21
|
+
const validity = useMemo(() => {
|
|
22
|
+
const valid = intrinsic.valid && !customInvalid;
|
|
23
|
+
let validationMessage = "";
|
|
24
|
+
if (!intrinsic.valid) {
|
|
25
|
+
validationMessage = intrinsic.validationMessage;
|
|
26
|
+
} else if (customInvalid) {
|
|
27
|
+
validationMessage = customMessage;
|
|
28
|
+
}
|
|
29
|
+
return { valid, validationMessage };
|
|
30
|
+
}, [
|
|
31
|
+
intrinsic.valid,
|
|
32
|
+
intrinsic.validationMessage,
|
|
33
|
+
customInvalid,
|
|
34
|
+
customMessage
|
|
35
|
+
]);
|
|
36
|
+
const onValidateRef = useRef(onValidate);
|
|
37
|
+
onValidateRef.current = onValidate;
|
|
38
|
+
const onValidityChangeRef = useRef(onValidityChange);
|
|
39
|
+
onValidityChangeRef.current = onValidityChange;
|
|
40
|
+
const valueRef = useRef(value);
|
|
41
|
+
valueRef.current = value;
|
|
42
|
+
const lastEmittedRef = useRef(null);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
var _a;
|
|
45
|
+
if (sameValidity(lastEmittedRef.current, validity)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
lastEmittedRef.current = validity;
|
|
49
|
+
(_a = onValidityChangeRef.current) == null ? void 0 : _a.call(onValidityChangeRef, validity);
|
|
50
|
+
}, [validity]);
|
|
51
|
+
const mountedRef = useRef(false);
|
|
52
|
+
const prevKeyRef = useRef(changeKey);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
var _a;
|
|
55
|
+
(_a = onValidateRef.current) == null ? void 0 : _a.call(onValidateRef, valueRef.current, "mount");
|
|
56
|
+
mountedRef.current = true;
|
|
57
|
+
prevKeyRef.current = changeKey;
|
|
58
|
+
}, []);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
var _a;
|
|
61
|
+
if (!mountedRef.current) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (prevKeyRef.current === changeKey) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
prevKeyRef.current = changeKey;
|
|
68
|
+
if (showIndication) {
|
|
69
|
+
(_a = onValidateRef.current) == null ? void 0 : _a.call(onValidateRef, valueRef.current, "change");
|
|
70
|
+
}
|
|
71
|
+
}, [changeKey, showIndication]);
|
|
72
|
+
const handleBlur = useCallback(() => {
|
|
73
|
+
var _a;
|
|
74
|
+
if (!isGateControlled) {
|
|
75
|
+
setTouched(true);
|
|
76
|
+
}
|
|
77
|
+
(_a = onValidateRef.current) == null ? void 0 : _a.call(onValidateRef, valueRef.current, "blur");
|
|
78
|
+
}, [isGateControlled]);
|
|
79
|
+
return { validity, showValidityIndication: showIndication, handleBlur };
|
|
80
|
+
}
|
|
4
81
|
const Asterisk = ({ size, ...props }) => /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 7 7", fill: "currentColor", width: size || "7", height: size || "7", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M1.809 7 1 6.397 2.74 3.94 0 3.026l.31-.974L3 2.948V0h1v2.976l2.69-.924.31.975-2.719.934L6 6.397 5.19 7 3.503 4.609 1.809 7Z" }));
|
|
5
82
|
Asterisk.displayName = "Asterisk";
|
|
6
83
|
var Asterisk_default = Asterisk;
|
|
@@ -21,5 +98,6 @@ const RequiredIndicator = ({
|
|
|
21
98
|
}
|
|
22
99
|
);
|
|
23
100
|
export {
|
|
24
|
-
RequiredIndicator as R
|
|
101
|
+
RequiredIndicator as R,
|
|
102
|
+
useValidatedField as u
|
|
25
103
|
};
|
|
@@ -42,7 +42,6 @@ const showButtonOnHoverDefaults = {
|
|
|
42
42
|
displayName: "On hover"
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
const displayPropertyToObserve = ["display"];
|
|
46
45
|
const testIds = {
|
|
47
46
|
animationClickWrapper: "lottie-animation-click-wrapper"
|
|
48
47
|
};
|
|
@@ -83,10 +82,9 @@ export {
|
|
|
83
82
|
playIconSvg as a,
|
|
84
83
|
showButtonOnHoverDefaults as b,
|
|
85
84
|
speedConstraints as c,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
borderDefaultValue as g,
|
|
85
|
+
playButtonDefaults as d,
|
|
86
|
+
DisplayNames as e,
|
|
87
|
+
borderDefaultValue as f,
|
|
90
88
|
initialSize as i,
|
|
91
89
|
pauseIconSvg as p,
|
|
92
90
|
rootDataDefaults as r,
|
|
@@ -79,6 +79,7 @@ const defaultValues = {
|
|
|
79
79
|
disabled: false,
|
|
80
80
|
selectAll: false
|
|
81
81
|
};
|
|
82
|
+
const VALUE_MISSING_MESSAGE = "This field is required";
|
|
82
83
|
const TestIds = {
|
|
83
84
|
root: "checkbox-group-root",
|
|
84
85
|
group: "checkbox-group-group",
|
|
@@ -89,7 +90,8 @@ const TestIds = {
|
|
|
89
90
|
control: "checkbox-group-control",
|
|
90
91
|
indicator: "checkbox-group-indicator",
|
|
91
92
|
optionLabel: "checkbox-group-option-label",
|
|
92
|
-
tooltipButton: "checkbox-group-tooltip-button"
|
|
93
|
+
tooltipButton: "checkbox-group-tooltip-button",
|
|
94
|
+
errorMessage: "checkbox-group-error-message"
|
|
93
95
|
};
|
|
94
96
|
const selectors = {
|
|
95
97
|
root: "checkbox-group",
|
|
@@ -103,11 +105,13 @@ const semanticClassNames = {
|
|
|
103
105
|
control: "checkbox-group__control",
|
|
104
106
|
indicator: "checkbox-group__indicator",
|
|
105
107
|
label: "checkbox-group__label",
|
|
106
|
-
requiredIndicator: "checkbox-group__required-indicator"
|
|
108
|
+
requiredIndicator: "checkbox-group__required-indicator",
|
|
109
|
+
errorMessage: "checkbox-group__error-message"
|
|
107
110
|
};
|
|
108
111
|
export {
|
|
109
112
|
DesignStates as D,
|
|
110
113
|
TestIds as T,
|
|
114
|
+
VALUE_MISSING_MESSAGE as V,
|
|
111
115
|
defaultOptions as a,
|
|
112
116
|
semanticClassNames as b,
|
|
113
117
|
DisplayNames as c,
|
|
@@ -9,12 +9,14 @@ const MANIFEST_DEFAULT_VALIDATION_DISPLAY_NAMES = {
|
|
|
9
9
|
};
|
|
10
10
|
function manifestValidation({
|
|
11
11
|
valueDataType = DATA.DATA_TYPE.text,
|
|
12
|
+
valueParameter,
|
|
12
13
|
displayNames = {}
|
|
13
14
|
} = {}) {
|
|
14
15
|
const names = {
|
|
15
16
|
...MANIFEST_DEFAULT_VALIDATION_DISPLAY_NAMES,
|
|
16
17
|
...displayNames
|
|
17
18
|
};
|
|
19
|
+
const valueParam = valueParameter ?? { dataType: valueDataType };
|
|
18
20
|
const fieldValidityItems = {
|
|
19
21
|
valid: {
|
|
20
22
|
dataType: DATA.DATA_TYPE.booleanValue,
|
|
@@ -46,7 +48,7 @@ function manifestValidation({
|
|
|
46
48
|
displayName: names.onValidate,
|
|
47
49
|
[DATA.DATA_TYPE.function]: {
|
|
48
50
|
parameters: [
|
|
49
|
-
|
|
51
|
+
valueParam,
|
|
50
52
|
// value
|
|
51
53
|
{
|
|
52
54
|
// cause: 'mount' | 'change' | 'blur'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect } from "react";
|
|
2
|
+
import { u as useResizeObserver } from "./useResizeObserver.js";
|
|
3
|
+
const isDisplayed = (element) => getComputedStyle(element).display !== "none";
|
|
4
|
+
function useHasDisplayedElement(containerRef, selectors, enabled = true) {
|
|
5
|
+
const [hasDisplayedElement, setHasDisplayedElement] = useState(true);
|
|
6
|
+
const selectorList = selectors.join(", ");
|
|
7
|
+
const evaluate = useCallback(() => {
|
|
8
|
+
const container = containerRef.current;
|
|
9
|
+
if (!enabled || !container) {
|
|
10
|
+
setHasDisplayedElement(true);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const elements = Array.from(
|
|
14
|
+
container.querySelectorAll(selectorList)
|
|
15
|
+
);
|
|
16
|
+
setHasDisplayedElement(elements.some(isDisplayed));
|
|
17
|
+
}, [containerRef, selectorList, enabled]);
|
|
18
|
+
useResizeObserver({ callback: evaluate, ref: containerRef, enabled });
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
evaluate();
|
|
21
|
+
}, [evaluate]);
|
|
22
|
+
return hasDisplayedElement;
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
useHasDisplayedElement as u
|
|
26
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/editor-react-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2441.0",
|
|
4
4
|
"description": "React components for the Wix Editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -197,5 +197,5 @@
|
|
|
197
197
|
"registry": "https://registry.npmjs.org/",
|
|
198
198
|
"access": "public"
|
|
199
199
|
},
|
|
200
|
-
"falconPackageHash": "
|
|
200
|
+
"falconPackageHash": "46ae1fbe924e1d979e3e1f23fc20a16506c636ffa2f9b369b56f2aa3"
|
|
201
201
|
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { useState, useMemo, useRef, useEffect, useCallback } from "react";
|
|
2
|
-
const sameValidity = (a, b) => a !== null && a.valid === b.valid && a.validationMessage === b.validationMessage;
|
|
3
|
-
function useValidatedField({
|
|
4
|
-
value,
|
|
5
|
-
valueKey,
|
|
6
|
-
intrinsic,
|
|
7
|
-
fieldValidity,
|
|
8
|
-
showValidityIndication,
|
|
9
|
-
onValidate,
|
|
10
|
-
onValidityChange
|
|
11
|
-
}) {
|
|
12
|
-
const isGateControlled = showValidityIndication !== void 0;
|
|
13
|
-
const [touched, setTouched] = useState(false);
|
|
14
|
-
const showIndication = isGateControlled ? Boolean(showValidityIndication) : touched;
|
|
15
|
-
const changeKey = valueKey === void 0 ? value : valueKey;
|
|
16
|
-
const customInvalid = (fieldValidity == null ? void 0 : fieldValidity.valid) === false;
|
|
17
|
-
const customMessage = (fieldValidity == null ? void 0 : fieldValidity.validationMessage) ?? "";
|
|
18
|
-
const validity = useMemo(() => {
|
|
19
|
-
const valid = intrinsic.valid && !customInvalid;
|
|
20
|
-
let validationMessage = "";
|
|
21
|
-
if (!intrinsic.valid) {
|
|
22
|
-
validationMessage = intrinsic.validationMessage;
|
|
23
|
-
} else if (customInvalid) {
|
|
24
|
-
validationMessage = customMessage;
|
|
25
|
-
}
|
|
26
|
-
return { valid, validationMessage };
|
|
27
|
-
}, [
|
|
28
|
-
intrinsic.valid,
|
|
29
|
-
intrinsic.validationMessage,
|
|
30
|
-
customInvalid,
|
|
31
|
-
customMessage
|
|
32
|
-
]);
|
|
33
|
-
const onValidateRef = useRef(onValidate);
|
|
34
|
-
onValidateRef.current = onValidate;
|
|
35
|
-
const onValidityChangeRef = useRef(onValidityChange);
|
|
36
|
-
onValidityChangeRef.current = onValidityChange;
|
|
37
|
-
const valueRef = useRef(value);
|
|
38
|
-
valueRef.current = value;
|
|
39
|
-
const lastEmittedRef = useRef(null);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
var _a;
|
|
42
|
-
if (sameValidity(lastEmittedRef.current, validity)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
lastEmittedRef.current = validity;
|
|
46
|
-
(_a = onValidityChangeRef.current) == null ? void 0 : _a.call(onValidityChangeRef, validity);
|
|
47
|
-
}, [validity]);
|
|
48
|
-
const mountedRef = useRef(false);
|
|
49
|
-
const prevKeyRef = useRef(changeKey);
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
var _a;
|
|
52
|
-
(_a = onValidateRef.current) == null ? void 0 : _a.call(onValidateRef, valueRef.current, "mount");
|
|
53
|
-
mountedRef.current = true;
|
|
54
|
-
prevKeyRef.current = changeKey;
|
|
55
|
-
}, []);
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
var _a;
|
|
58
|
-
if (!mountedRef.current) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (prevKeyRef.current === changeKey) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
prevKeyRef.current = changeKey;
|
|
65
|
-
if (showIndication) {
|
|
66
|
-
(_a = onValidateRef.current) == null ? void 0 : _a.call(onValidateRef, valueRef.current, "change");
|
|
67
|
-
}
|
|
68
|
-
}, [changeKey, showIndication]);
|
|
69
|
-
const handleBlur = useCallback(() => {
|
|
70
|
-
var _a;
|
|
71
|
-
if (!isGateControlled) {
|
|
72
|
-
setTouched(true);
|
|
73
|
-
}
|
|
74
|
-
(_a = onValidateRef.current) == null ? void 0 : _a.call(onValidateRef, valueRef.current, "blur");
|
|
75
|
-
}, [isGateControlled]);
|
|
76
|
-
return { validity, showValidityIndication: showIndication, handleBlur };
|
|
77
|
-
}
|
|
78
|
-
export {
|
|
79
|
-
useValidatedField as u
|
|
80
|
-
};
|