@wix/form-public 0.512.0 → 0.514.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/index.cjs +63 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +64 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -43130,6 +43130,7 @@ var ForcedState = /* @__PURE__ */ (function(ForcedState2) {
|
|
|
43130
43130
|
ForcedState2["INPUT_FIELDS_HOVER"] = "INPUT_FIELDS_HOVER";
|
|
43131
43131
|
ForcedState2["INPUT_FIELDS_FOCUS"] = "INPUT_FIELDS_FOCUS";
|
|
43132
43132
|
ForcedState2["INPUT_FIELDS_ERROR"] = "INPUT_FIELDS_ERROR";
|
|
43133
|
+
ForcedState2["SUCCESS_MESSAGE"] = "SUCCESS_MESSAGE";
|
|
43133
43134
|
return ForcedState2;
|
|
43134
43135
|
})({});
|
|
43135
43136
|
var ForcedStateContext = React172.createContext([]);
|
|
@@ -55723,9 +55724,9 @@ function useFileUploadController({ valueSliderLimit, value, explanationText, tar
|
|
|
55723
55724
|
setFormStatus,
|
|
55724
55725
|
target
|
|
55725
55726
|
]);
|
|
55726
|
-
const
|
|
55727
|
+
const getStatusText = React172.useCallback(() => {
|
|
55727
55728
|
if (!files.length) {
|
|
55728
|
-
return
|
|
55729
|
+
return void 0;
|
|
55729
55730
|
}
|
|
55730
55731
|
const uploadingCount = files.filter((f) => f.state === "uploading").length;
|
|
55731
55732
|
if (uploadingCount) {
|
|
@@ -55735,14 +55736,27 @@ function useFileUploadController({ valueSliderLimit, value, explanationText, tar
|
|
|
55735
55736
|
count: Math.round(progress * 100)
|
|
55736
55737
|
});
|
|
55737
55738
|
}
|
|
55738
|
-
return
|
|
55739
|
+
return t(`form.file-upload.explanation-text`, {
|
|
55739
55740
|
count: files.length
|
|
55740
55741
|
});
|
|
55741
55742
|
}, [
|
|
55742
55743
|
files,
|
|
55743
|
-
explanationText,
|
|
55744
55744
|
t
|
|
55745
55745
|
]);
|
|
55746
|
+
const getExplanationText = React172.useCallback(() => {
|
|
55747
|
+
if (!files.length) {
|
|
55748
|
+
return explanationText;
|
|
55749
|
+
}
|
|
55750
|
+
const isUploading = files.some((f) => f.state === "uploading");
|
|
55751
|
+
if (isUploading) {
|
|
55752
|
+
return getStatusText();
|
|
55753
|
+
}
|
|
55754
|
+
return explanationText || getStatusText();
|
|
55755
|
+
}, [
|
|
55756
|
+
files,
|
|
55757
|
+
explanationText,
|
|
55758
|
+
getStatusText
|
|
55759
|
+
]);
|
|
55746
55760
|
const _uploadFiles = React172.useCallback(async (filesToUpload) => {
|
|
55747
55761
|
await uploadFiles(filesToUpload, ({ file, uploadedFile }) => {
|
|
55748
55762
|
setFiles((previousFiles) => previousFiles.map((f) => f.file === file ? {
|
|
@@ -55825,6 +55839,7 @@ function useFileUploadController({ valueSliderLimit, value, explanationText, tar
|
|
|
55825
55839
|
limitError,
|
|
55826
55840
|
hover,
|
|
55827
55841
|
getExplanationText,
|
|
55842
|
+
getStatusText,
|
|
55828
55843
|
handleChange,
|
|
55829
55844
|
handleDelete,
|
|
55830
55845
|
accept,
|
|
@@ -55862,7 +55877,10 @@ function useFileUploadContext() {
|
|
|
55862
55877
|
var DropZone = ({ children, className }) => {
|
|
55863
55878
|
const { ariaDescribedBy } = useFieldAttributes();
|
|
55864
55879
|
const { disabled, hasError } = useFieldPropsV2();
|
|
55865
|
-
const { handleFileChange } = useFileUploadContext();
|
|
55880
|
+
const { handleFileChange, limitReached } = useFileUploadContext();
|
|
55881
|
+
if (limitReached) {
|
|
55882
|
+
return null;
|
|
55883
|
+
}
|
|
55866
55884
|
const titleElement = findChildOfType(children, DropZone.Title);
|
|
55867
55885
|
const subtitleElement = findChildOfType(children, DropZone.Subtitle);
|
|
55868
55886
|
const buttonElement = findChildOfType(children, DropZone.Button);
|
|
@@ -55901,13 +55919,14 @@ var DropZoneTitle = ({ className, children }) => {
|
|
|
55901
55919
|
};
|
|
55902
55920
|
var DropZoneSubtitle = ({ className, children }) => {
|
|
55903
55921
|
const { limitReached } = useFileUploadContext();
|
|
55922
|
+
const { explanationText } = useFieldPropsV2();
|
|
55904
55923
|
return /* @__PURE__ */ React172__default.default.createElement("p", {
|
|
55905
55924
|
className
|
|
55906
|
-
}, children({
|
|
55925
|
+
}, explanationText || children({
|
|
55907
55926
|
limitReached
|
|
55908
55927
|
}));
|
|
55909
55928
|
};
|
|
55910
|
-
var DropZoneButton = ({ className, children, "aria-roledescription": roleDescription }) => {
|
|
55929
|
+
var DropZoneButton = ({ className, children, "aria-roledescription": roleDescription, onHoverStart, onHoverEnd }) => {
|
|
55911
55930
|
const { ariaDescribedBy, inputId, labelId, errorId } = useFieldAttributes();
|
|
55912
55931
|
const { disabled, required, onFocus, hasError, errorMessage } = useFieldPropsV2();
|
|
55913
55932
|
const { handleFileChange, accept, multiple, buttonRef, handleBlur, limitError, files } = useFileUploadContext();
|
|
@@ -55941,7 +55960,9 @@ var DropZoneButton = ({ className, children, "aria-roledescription": roleDescrip
|
|
|
55941
55960
|
isDisabled: disabled,
|
|
55942
55961
|
className,
|
|
55943
55962
|
onFocus,
|
|
55944
|
-
onBlur: handleBlur
|
|
55963
|
+
onBlur: handleBlur,
|
|
55964
|
+
onHoverStart,
|
|
55965
|
+
onHoverEnd
|
|
55945
55966
|
}, children));
|
|
55946
55967
|
};
|
|
55947
55968
|
var DropZoneButtonText = ({ className }) => {
|
|
@@ -56054,13 +56075,19 @@ Files.File = File2;
|
|
|
56054
56075
|
// ../form-fields/dist/esm/ui/file-upload/file-upload-headless/file-upload-headless.js
|
|
56055
56076
|
var fileKey = (f) => f.file.name;
|
|
56056
56077
|
var FileUpload = ({ children }) => {
|
|
56078
|
+
const { t } = useTranslation2();
|
|
56057
56079
|
const { id: id6, value, onChange, uploadFileFormats, valueSliderLimit, target, explanationText, onBlur, hasError, errorMessage, FieldLayout } = useFieldPropsV2();
|
|
56058
56080
|
const buttonRef = React172.useRef(null);
|
|
56059
56081
|
const fileRemoveButtonRefs = React172.useRef({});
|
|
56082
|
+
const pendingUploadButtonFocus = React172.useRef(false);
|
|
56060
56083
|
const handleFilesCleared = React172.useCallback(() => {
|
|
56061
|
-
buttonRef.current
|
|
56084
|
+
if (buttonRef.current) {
|
|
56085
|
+
buttonRef.current.focus();
|
|
56086
|
+
} else {
|
|
56087
|
+
pendingUploadButtonFocus.current = true;
|
|
56088
|
+
}
|
|
56062
56089
|
}, []);
|
|
56063
|
-
const { files, limitError, hover, getExplanationText, handleBlur, handleChange, handleDelete: _handleDelete, accept } = useFileUploadController({
|
|
56090
|
+
const { files, limitError, hover, getExplanationText, getStatusText, handleBlur, handleChange, handleDelete: _handleDelete, accept } = useFileUploadController({
|
|
56064
56091
|
valueSliderLimit,
|
|
56065
56092
|
value,
|
|
56066
56093
|
explanationText,
|
|
@@ -56082,6 +56109,14 @@ var FileUpload = ({ children }) => {
|
|
|
56082
56109
|
_handleDelete,
|
|
56083
56110
|
files
|
|
56084
56111
|
]);
|
|
56112
|
+
React172.useEffect(() => {
|
|
56113
|
+
if (pendingUploadButtonFocus.current && buttonRef.current) {
|
|
56114
|
+
pendingUploadButtonFocus.current = false;
|
|
56115
|
+
buttonRef.current.focus();
|
|
56116
|
+
}
|
|
56117
|
+
}, [
|
|
56118
|
+
files
|
|
56119
|
+
]);
|
|
56085
56120
|
const multiple = valueSliderLimit > 1;
|
|
56086
56121
|
const limitReached = files.length >= valueSliderLimit;
|
|
56087
56122
|
const contextValue = React172.useMemo(() => ({
|
|
@@ -56093,6 +56128,7 @@ var FileUpload = ({ children }) => {
|
|
|
56093
56128
|
limitReached,
|
|
56094
56129
|
multiple,
|
|
56095
56130
|
getExplanationText,
|
|
56131
|
+
getStatusText,
|
|
56096
56132
|
hover,
|
|
56097
56133
|
limitError,
|
|
56098
56134
|
buttonRef,
|
|
@@ -56106,6 +56142,7 @@ var FileUpload = ({ children }) => {
|
|
|
56106
56142
|
limitReached,
|
|
56107
56143
|
multiple,
|
|
56108
56144
|
getExplanationText,
|
|
56145
|
+
getStatusText,
|
|
56109
56146
|
hover,
|
|
56110
56147
|
limitError
|
|
56111
56148
|
]);
|
|
@@ -56117,7 +56154,11 @@ var FileUpload = ({ children }) => {
|
|
|
56117
56154
|
const descriptionElement = findChildOfType(children, FileUpload.Description);
|
|
56118
56155
|
const errorElement = findChildOfType(children, FileUpload.Error);
|
|
56119
56156
|
useFocusFieldEvent(() => {
|
|
56120
|
-
buttonRef.current
|
|
56157
|
+
if (buttonRef.current) {
|
|
56158
|
+
buttonRef.current.focus();
|
|
56159
|
+
return;
|
|
56160
|
+
}
|
|
56161
|
+
files.map((f) => fileRemoveButtonRefs.current[fileKey(f)]).find((ref) => ref?.current)?.current?.focus();
|
|
56121
56162
|
}, id6);
|
|
56122
56163
|
return /* @__PURE__ */ React172__default.default.createElement(FileUploadContext.Provider, {
|
|
56123
56164
|
value: contextValue
|
|
@@ -56128,13 +56169,19 @@ var FileUpload = ({ children }) => {
|
|
|
56128
56169
|
renderDescription: () => /* @__PURE__ */ React172__default.default.createElement(React172__default.default.Fragment, null, applyInternalProps(errorElement, {
|
|
56129
56170
|
hasError: Boolean(hasError || limitError),
|
|
56130
56171
|
errorMessage: limitError ?? errorMessage
|
|
56131
|
-
}),
|
|
56172
|
+
}), /* @__PURE__ */ React172__default.default.createElement(reactAriaComponents.VisuallyHidden, {
|
|
56173
|
+
role: "status",
|
|
56174
|
+
"aria-live": "polite",
|
|
56175
|
+
"aria-atomic": "true"
|
|
56176
|
+
}, t("form.file-upload.explanation-text", {
|
|
56177
|
+
count: files.length
|
|
56178
|
+
})), explanationElement, filesElement, descriptionElement)
|
|
56132
56179
|
}));
|
|
56133
56180
|
};
|
|
56134
|
-
var Explanation = ({ className }) => {
|
|
56135
|
-
const { getExplanationText } = useFileUploadContext();
|
|
56136
|
-
const displayText = getExplanationText();
|
|
56137
|
-
if (!displayText) {
|
|
56181
|
+
var Explanation = ({ className, showUploadStatusOnly }) => {
|
|
56182
|
+
const { files, getExplanationText, getStatusText } = useFileUploadContext();
|
|
56183
|
+
const displayText = showUploadStatusOnly ? getStatusText() : getExplanationText();
|
|
56184
|
+
if (files.length === 1 || !displayText) {
|
|
56138
56185
|
return null;
|
|
56139
56186
|
}
|
|
56140
56187
|
return /* @__PURE__ */ React172__default.default.createElement("p", {
|