@wix/editor-react-components 1.2440.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/RadioButtons/component.js +1 -2
- 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/constants36.js +6 -2
- package/dist/site/components/chunks/manifest2.js +3 -1
- 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";
|
|
@@ -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";
|
|
@@ -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
|
};
|
|
@@ -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'
|
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
|
-
};
|