@pingux/astro 2.220.0 → 2.221.1-alpha.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/lib/cjs/components/AIComponents/PromptInput/PromptInput.js +4 -1
- package/lib/cjs/components/FileInputField/FileInputField.d.ts +8 -0
- package/lib/cjs/components/FileInputField/FileInputField.js +19 -77
- package/lib/cjs/components/FileInputField/FileInputField.stories.js +7 -10
- package/lib/cjs/components/FileInputField/FileInputField.styles.d.ts +47 -0
- package/lib/cjs/components/FileInputField/FileInputField.test.js +3 -2
- package/lib/cjs/components/FileInputField/FileItem.d.ts +4 -0
- package/lib/cjs/components/FileInputField/FileItem.js +8 -16
- package/lib/cjs/components/FileInputField/FileSelect.d.ts +4 -0
- package/lib/cjs/components/FileInputField/FileSelect.js +1 -18
- package/lib/cjs/components/FileInputField/index.d.ts +1 -0
- package/lib/cjs/components/PhoneNumberField/PhoneNumberField.js +17 -7
- package/lib/cjs/components/PhoneNumberField/PhoneNumberField.test.js +111 -0
- package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +5 -1
- package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +5 -1
- package/lib/cjs/styles/themes/next-gen/variants/variants.js +5 -1
- package/lib/cjs/types/fileInputField.d.ts +106 -0
- package/lib/cjs/types/fileInputField.js +6 -0
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +60 -49
- package/lib/cjs/types/input.d.ts +4 -3
- package/lib/components/AIComponents/PromptInput/PromptInput.js +4 -1
- package/lib/components/FileInputField/FileInputField.js +20 -78
- package/lib/components/FileInputField/FileInputField.stories.js +7 -10
- package/lib/components/FileInputField/FileInputField.test.js +3 -2
- package/lib/components/FileInputField/FileItem.js +8 -16
- package/lib/components/FileInputField/FileSelect.js +2 -20
- package/lib/components/PhoneNumberField/PhoneNumberField.js +17 -7
- package/lib/components/PhoneNumberField/PhoneNumberField.test.js +112 -1
- package/lib/styles/themes/next-gen/variants/variants.js +5 -1
- package/lib/types/fileInputField.js +1 -0
- package/lib/types/index.js +1 -0
- package/package.json +2 -2
|
@@ -93,6 +93,9 @@ var PromptInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
93
93
|
return _file.id !== id;
|
|
94
94
|
}));
|
|
95
95
|
};
|
|
96
|
+
var handleFileRemoveFromField = function handleFileRemoveFromField(_e, id) {
|
|
97
|
+
handleFileRemove(id);
|
|
98
|
+
};
|
|
96
99
|
var onEnterPress = function onEnterPress(e) {
|
|
97
100
|
if (onSubmit && !isLoading) {
|
|
98
101
|
onSubmit(e, value);
|
|
@@ -162,7 +165,7 @@ var PromptInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
162
165
|
ml: ".75rem"
|
|
163
166
|
}, (0, _react2.jsx)(_index.FileInputField, (0, _extends2["default"])({
|
|
164
167
|
onFileSelect: handleFileSelect,
|
|
165
|
-
onRemove:
|
|
168
|
+
onRemove: handleFileRemoveFromField,
|
|
166
169
|
fileList: [],
|
|
167
170
|
isIconButton: true,
|
|
168
171
|
buttonProps: {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FileInputFieldProps } from '../../types';
|
|
3
|
+
export declare const filterFileTypes: ({ arrayWithNewFiles, fileTypes }: {
|
|
4
|
+
arrayWithNewFiles: File[];
|
|
5
|
+
fileTypes?: string[];
|
|
6
|
+
}) => File[];
|
|
7
|
+
declare const FileInputField: React.ForwardRefExoticComponent<FileInputFieldProps & React.RefAttributes<HTMLInputElement>>;
|
|
8
|
+
export default FileInputField;
|
|
@@ -31,7 +31,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
31
31
|
var _reactAria = require("react-aria");
|
|
32
32
|
var _reactDropzone = require("react-dropzone");
|
|
33
33
|
var _pluralize = _interopRequireDefault(require("pluralize"));
|
|
34
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
35
34
|
var _uuid = require("uuid");
|
|
36
35
|
var _ = require("../..");
|
|
37
36
|
var _useField2 = _interopRequireDefault(require("../../hooks/useField"));
|
|
@@ -39,8 +38,6 @@ var _useStatusClasses3 = _interopRequireDefault(require("../../hooks/useStatusCl
|
|
|
39
38
|
var _pendoID = require("../../utils/devUtils/constants/pendoID");
|
|
40
39
|
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
|
41
40
|
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
|
42
|
-
var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
|
43
|
-
var _statusProp = require("../../utils/docUtils/statusProp");
|
|
44
41
|
var _FileItem = _interopRequireDefault(require("./FileItem"));
|
|
45
42
|
var _FileSelect = _interopRequireDefault(require("./FileSelect"));
|
|
46
43
|
var _FileSelectIcon = _interopRequireDefault(require("./FileSelectIcon"));
|
|
@@ -69,7 +66,8 @@ var filterFileTypes = exports.filterFileTypes = function filterFileTypes(_ref) {
|
|
|
69
66
|
};
|
|
70
67
|
var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
71
68
|
var buttonProps = props.buttonProps,
|
|
72
|
-
|
|
69
|
+
_props$defaultButtonT = props.defaultButtonText,
|
|
70
|
+
defaultButtonText = _props$defaultButtonT === void 0 ? 'Select a file' : _props$defaultButtonT,
|
|
73
71
|
defaultFileList = props.defaultFileList,
|
|
74
72
|
uploadedFilesImperative = props.fileList,
|
|
75
73
|
helperText = props.helperText,
|
|
@@ -82,7 +80,8 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
82
80
|
label = props.label,
|
|
83
81
|
onFileSelect = props.onFileSelect,
|
|
84
82
|
onRemove = props.onRemove,
|
|
85
|
-
status = props.status,
|
|
83
|
+
_props$status = props.status,
|
|
84
|
+
status = _props$status === void 0 ? 'default' : _props$status,
|
|
86
85
|
textProps = props.textProps,
|
|
87
86
|
fileTypes = props.fileTypes,
|
|
88
87
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
@@ -98,7 +97,7 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
98
97
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
99
98
|
fileChangeMessage = _useState6[0],
|
|
100
99
|
setFileChangeMessage = _useState6[1];
|
|
101
|
-
var inputRef = (0, _react.useRef)();
|
|
100
|
+
var inputRef = (0, _react.useRef)(null);
|
|
102
101
|
/* istanbul ignore next */
|
|
103
102
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
104
103
|
return inputRef.current;
|
|
@@ -115,11 +114,14 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
115
114
|
fieldControlInputProps = _useField.fieldControlInputProps,
|
|
116
115
|
fieldControlWrapperProps = _useField.fieldControlWrapperProps,
|
|
117
116
|
fieldLabelProps = _useField.fieldLabelProps;
|
|
118
|
-
var helperTextId = (0,
|
|
117
|
+
var helperTextId = (0, _react.useMemo)(function () {
|
|
118
|
+
return (0, _uuid.v4)();
|
|
119
|
+
}, []);
|
|
119
120
|
var _useVisuallyHidden = (0, _reactAria.useVisuallyHidden)(),
|
|
120
121
|
visuallyHiddenProps = _useVisuallyHidden.visuallyHiddenProps;
|
|
121
122
|
var handleFileSelect = (0, _react.useCallback)(function () {
|
|
122
|
-
inputRef.current
|
|
123
|
+
if (!inputRef.current) return;
|
|
124
|
+
inputRef.current.value = '';
|
|
123
125
|
inputRef.current.click();
|
|
124
126
|
}, [inputRef]);
|
|
125
127
|
(0, _react.useEffect)(function () {
|
|
@@ -127,7 +129,7 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
127
129
|
// update/delete file status update on Safari
|
|
128
130
|
|
|
129
131
|
if (status === _statuses["default"].ERROR) {
|
|
130
|
-
setFileChangeMessage(helperText);
|
|
132
|
+
setFileChangeMessage(typeof helperText === 'string' ? helperText : '');
|
|
131
133
|
} else if (fileChangeStatus) {
|
|
132
134
|
var _context;
|
|
133
135
|
setFileChangeMessage((0, _concat["default"])(_context = "".concat((0, _pluralize["default"])('file', fileChangeStatus.fileCount, true), " ")).call(_context, fileChangeStatus.status, " successfully"));
|
|
@@ -185,6 +187,7 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
185
187
|
var handleOnChange = function handleOnChange(event) {
|
|
186
188
|
handleFileUpload(event, event.target.files);
|
|
187
189
|
};
|
|
190
|
+
var mergedInputProps = (0, _reactAria.mergeProps)(visuallyHiddenProps, fieldControlInputProps, getInputProps());
|
|
188
191
|
var filesListNode = (0, _react.useMemo)(function () {
|
|
189
192
|
var handleFileDelete = function handleFileDelete(e, fileId) {
|
|
190
193
|
setFileChangeMessage('');
|
|
@@ -239,7 +242,7 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
239
242
|
}, getRootProps(), {
|
|
240
243
|
// to pass accessibility test, this removes focusable dependents
|
|
241
244
|
role: "none"
|
|
242
|
-
}), (0, _react2.jsx)(_.Input, (0, _extends2["default"])({},
|
|
245
|
+
}), (0, _react2.jsx)(_.Input, (0, _extends2["default"])({}, mergedInputProps, {
|
|
243
246
|
multiple: isMultiple,
|
|
244
247
|
onChange: handleOnChange,
|
|
245
248
|
ref: inputRef,
|
|
@@ -247,10 +250,11 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
247
250
|
accept: fileTypes ? fileTypes === null || fileTypes === void 0 ? void 0 : fileTypes.join(',') : '*'
|
|
248
251
|
})), filesListNode, shouldFileSelectRender() && (isIconButton ? (0, _react2.jsx)(_FileSelectIcon["default"], (0, _extends2["default"])({
|
|
249
252
|
handleFileSelect: handleFileSelect,
|
|
250
|
-
iconContainerProps: iconContainerProps,
|
|
251
|
-
buttonProps: buttonProps,
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
iconContainerProps: iconContainerProps !== null && iconContainerProps !== void 0 ? iconContainerProps : {},
|
|
254
|
+
buttonProps: _objectSpread(_objectSpread({}, buttonProps), {}, {
|
|
255
|
+
isDisabled: isDisabled || isLoading
|
|
256
|
+
}),
|
|
257
|
+
iconProps: iconProps !== null && iconProps !== void 0 ? iconProps : {}
|
|
254
258
|
}, ariaProps)) : (0, _react2.jsx)(_FileSelect["default"], (0, _extends2["default"])({
|
|
255
259
|
buttonText: defaultButtonText,
|
|
256
260
|
handleFileSelect: handleFileSelect,
|
|
@@ -263,7 +267,7 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
263
267
|
},
|
|
264
268
|
"data-testid": "file-input-field__loader"
|
|
265
269
|
})), helperText && (0, _react2.jsx)(_.Box, {
|
|
266
|
-
"aria-label": helperText,
|
|
270
|
+
"aria-label": typeof helperText === 'string' ? helperText : undefined,
|
|
267
271
|
role: "marquee"
|
|
268
272
|
}, (0, _react2.jsx)(_.FieldHelperText, {
|
|
269
273
|
status: status,
|
|
@@ -275,66 +279,4 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
275
279
|
}, (0, _react2.jsx)(_reactAria.VisuallyHidden, null, (0, _react2.jsx)("h1", null, fileChangeMessage))));
|
|
276
280
|
});
|
|
277
281
|
FileInputField.displayName = displayName;
|
|
278
|
-
FileInputField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|
|
279
|
-
/** The rendered label for the field. */
|
|
280
|
-
label: _propTypes["default"].node,
|
|
281
|
-
/** Text rendered below the input. */
|
|
282
|
-
helperText: _propTypes["default"].node,
|
|
283
|
-
/** Default button text that will be changed on the file name once file is uploaded */
|
|
284
|
-
defaultButtonText: _propTypes["default"].string,
|
|
285
|
-
/** Defines whether input can accept multiple files or not */
|
|
286
|
-
isMultiple: _propTypes["default"].bool,
|
|
287
|
-
/** Determines whether the loading indicator is shown. */
|
|
288
|
-
isLoading: _propTypes["default"].bool,
|
|
289
|
-
/** Whether the field is disabled. */
|
|
290
|
-
isDisabled: _propTypes["default"].bool,
|
|
291
|
-
/** Array of objects for uploaded files.
|
|
292
|
-
* Objects should have the following structure:
|
|
293
|
-
*
|
|
294
|
-
* {
|
|
295
|
-
*
|
|
296
|
-
* fileObj: File object (optional),
|
|
297
|
-
*
|
|
298
|
-
* id: file id (required - will be returned on delete),
|
|
299
|
-
*
|
|
300
|
-
* name: file name that will be displayed (required - will be displayed),
|
|
301
|
-
*
|
|
302
|
-
* downloadLink: link for the file download (optional),
|
|
303
|
-
*
|
|
304
|
-
* status: file status (if error - icon of the
|
|
305
|
-
* component will be red icon and warning sign)(optional),
|
|
306
|
-
*
|
|
307
|
-
* }
|
|
308
|
-
* */
|
|
309
|
-
fileList: _propTypes["default"].arrayOf(_propTypes["default"].shape(_objectSpread({
|
|
310
|
-
fileObj: _propTypes["default"].shape({}),
|
|
311
|
-
id: _propTypes["default"].string.isRequired,
|
|
312
|
-
name: _propTypes["default"].string.isRequired,
|
|
313
|
-
downloadLink: _propTypes["default"].string
|
|
314
|
-
}, _statusProp.statusPropTypes))),
|
|
315
|
-
/** Default array of objects for uploaded files. */
|
|
316
|
-
defaultFileList: _propTypes["default"].arrayOf(_propTypes["default"].shape(_objectSpread({
|
|
317
|
-
fileObj: _propTypes["default"].shape({}),
|
|
318
|
-
id: _propTypes["default"].string.isRequired,
|
|
319
|
-
name: _propTypes["default"].string.isRequired,
|
|
320
|
-
downloadLink: _propTypes["default"].string
|
|
321
|
-
}, _statusProp.statusPropTypes))),
|
|
322
|
-
/** The handler that is called when the input files is uploaded.
|
|
323
|
-
*
|
|
324
|
-
* `(event, files) => void`
|
|
325
|
-
* */
|
|
326
|
-
onFileSelect: _propTypes["default"].func,
|
|
327
|
-
/** The handler that is called when an uploaded file got removed.
|
|
328
|
-
*
|
|
329
|
-
* `(fileId) => void`
|
|
330
|
-
* */
|
|
331
|
-
onRemove: _propTypes["default"].func,
|
|
332
|
-
/** These props will be spread to the field text component. */
|
|
333
|
-
textProps: _propTypes["default"].shape({}),
|
|
334
|
-
/** Props object that is spread directly into the helphint element. */
|
|
335
|
-
helpHintProps: _propTypes["default"].shape({})
|
|
336
|
-
}, _statusProp.statusPropTypes), _ariaAttributes.ariaAttributesBasePropTypes), _fieldAttributes.inputFieldAttributesBasePropTypes);
|
|
337
|
-
FileInputField.defaultProps = _objectSpread({
|
|
338
|
-
defaultButtonText: 'Select a file'
|
|
339
|
-
}, _statusProp.statusDefaultProp);
|
|
340
282
|
var _default = exports["default"] = FileInputField;
|
|
@@ -113,7 +113,6 @@ var ControlledState = exports.ControlledState = function ControlledState(args) {
|
|
|
113
113
|
error = _useState4[0],
|
|
114
114
|
setError = _useState4[1];
|
|
115
115
|
var handleFileSelect = function handleFileSelect(event, files) {
|
|
116
|
-
// this is approximate conversion just for an example
|
|
117
116
|
var uploadedFileSizeMb = files[0].size / 1e6;
|
|
118
117
|
if (uploadedFileSizeMb > 2) {
|
|
119
118
|
setError('Only files under 2 MB can be uploaded.');
|
|
@@ -123,14 +122,12 @@ var ControlledState = exports.ControlledState = function ControlledState(args) {
|
|
|
123
122
|
name: files[0].name,
|
|
124
123
|
downloadLink: 'link for testing purposes'
|
|
125
124
|
}]);
|
|
126
|
-
setError(
|
|
125
|
+
setError(undefined);
|
|
127
126
|
}
|
|
128
127
|
};
|
|
129
|
-
|
|
130
|
-
// you would want to handle this differently in case you have multiple files
|
|
131
128
|
var handleFileRemove = function handleFileRemove() {
|
|
132
129
|
setUserFiles([]);
|
|
133
|
-
setError(
|
|
130
|
+
setError(undefined);
|
|
134
131
|
};
|
|
135
132
|
return (0, _react2.jsx)(_index.FileInputField, (0, _extends2["default"])({}, args, {
|
|
136
133
|
label: "Controlled State With limit on file size upload below 2 mb",
|
|
@@ -138,7 +135,7 @@ var ControlledState = exports.ControlledState = function ControlledState(args) {
|
|
|
138
135
|
onRemove: handleFileRemove,
|
|
139
136
|
fileList: userFiles,
|
|
140
137
|
sx: fitContentWidthSx,
|
|
141
|
-
status: error
|
|
138
|
+
status: error ? _statuses["default"].ERROR : undefined,
|
|
142
139
|
helperText: error,
|
|
143
140
|
isMultiple: true
|
|
144
141
|
}));
|
|
@@ -223,13 +220,13 @@ var WithFileTypePdfAndImage = exports.WithFileTypePdfAndImage = function WithFil
|
|
|
223
220
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
224
221
|
error = _useState6[0],
|
|
225
222
|
setError = _useState6[1];
|
|
226
|
-
var handleFileSelect = function handleFileSelect(
|
|
223
|
+
var handleFileSelect = function handleFileSelect(_event, files) {
|
|
227
224
|
var uploadedFileType = files[0].type;
|
|
228
225
|
var isValidFileType = (0, _some["default"])(fileTypes).call(fileTypes, function (fileType) {
|
|
229
226
|
return uploadedFileType.search(fileType) !== -1;
|
|
230
227
|
});
|
|
231
228
|
if (isValidFileType) {
|
|
232
|
-
setError(
|
|
229
|
+
setError(undefined);
|
|
233
230
|
} else {
|
|
234
231
|
setError('Not a valid File Type. Only PDF and Image files are allowed.');
|
|
235
232
|
}
|
|
@@ -240,9 +237,9 @@ var WithFileTypePdfAndImage = exports.WithFileTypePdfAndImage = function WithFil
|
|
|
240
237
|
fileTypes: fileTypes,
|
|
241
238
|
onFileSelect: handleFileSelect,
|
|
242
239
|
onRemove: function onRemove() {
|
|
243
|
-
return setError(
|
|
240
|
+
return setError(undefined);
|
|
244
241
|
},
|
|
245
|
-
status: error
|
|
242
|
+
status: error ? _statuses["default"].ERROR : undefined,
|
|
246
243
|
helperText: error
|
|
247
244
|
});
|
|
248
245
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
wrapper: {
|
|
3
|
+
display: string;
|
|
4
|
+
border: string;
|
|
5
|
+
borderColor: string;
|
|
6
|
+
padding: string;
|
|
7
|
+
'&.is-drag-active': {
|
|
8
|
+
backgroundColor: string;
|
|
9
|
+
};
|
|
10
|
+
'&.is-error': {
|
|
11
|
+
borderColor: string;
|
|
12
|
+
};
|
|
13
|
+
'&.is-success': {
|
|
14
|
+
borderColor: string;
|
|
15
|
+
};
|
|
16
|
+
'&.is-warning': {
|
|
17
|
+
borderColor: string;
|
|
18
|
+
};
|
|
19
|
+
'&.is-loading': {
|
|
20
|
+
justifyContent: string;
|
|
21
|
+
alignItems: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
button: {
|
|
25
|
+
background: string;
|
|
26
|
+
cursor: string;
|
|
27
|
+
'& span': {
|
|
28
|
+
textAlign: string;
|
|
29
|
+
};
|
|
30
|
+
'&:focus-visible': {
|
|
31
|
+
outline: string;
|
|
32
|
+
};
|
|
33
|
+
'&.is-hovered, &.is-pressed': {
|
|
34
|
+
cursor: string;
|
|
35
|
+
'& span': {
|
|
36
|
+
textDecoration: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
'&.is-focused': {
|
|
40
|
+
boxShadow: string;
|
|
41
|
+
outline: string;
|
|
42
|
+
outlineColor: string;
|
|
43
|
+
outlineOffset: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export default _default;
|
|
@@ -84,7 +84,8 @@ beforeAll(function () {
|
|
|
84
84
|
afterAll(function () {
|
|
85
85
|
_url["default"].createObjectURL = originalValue;
|
|
86
86
|
});
|
|
87
|
-
var getComponent = function getComponent(
|
|
87
|
+
var getComponent = function getComponent() {
|
|
88
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
88
89
|
return (0, _react2.render)((0, _react3.jsx)(_FileInputField["default"], (0, _extends2["default"])({}, defaultProps, props)));
|
|
89
90
|
};
|
|
90
91
|
|
|
@@ -316,7 +317,7 @@ test('File upload should allow only image', /*#__PURE__*/(0, _asyncToGenerator2[
|
|
|
316
317
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
317
318
|
while (1) switch (_context7.prev = _context7.next) {
|
|
318
319
|
case 0:
|
|
319
|
-
setStateMock = jest.fn();
|
|
320
|
+
setStateMock = jest.fn(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
320
321
|
jest.spyOn(_react["default"], 'useState').mockImplementation(function (initialState) {
|
|
321
322
|
return [initialState, setStateMock];
|
|
322
323
|
});
|
|
@@ -15,17 +15,15 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
exports["default"] = void 0;
|
|
18
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
19
18
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
19
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
21
21
|
var _reactAria = require("react-aria");
|
|
22
22
|
var _AlertCircleIcon = _interopRequireDefault(require("@pingux/mdi-react/AlertCircleIcon"));
|
|
23
23
|
var _DeleteIcon = _interopRequireDefault(require("@pingux/mdi-react/DeleteIcon"));
|
|
24
24
|
var _InsertDriveFileIcon = _interopRequireDefault(require("@pingux/mdi-react/InsertDriveFileIcon"));
|
|
25
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
26
25
|
var _index = require("../../index");
|
|
27
26
|
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
|
28
|
-
var _statusProp = require("../../utils/docUtils/statusProp");
|
|
29
27
|
var _react2 = require("@emotion/react");
|
|
30
28
|
function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
31
29
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -43,7 +41,7 @@ var FileItem = function FileItem(props) {
|
|
|
43
41
|
}, [id, handleFileDelete]);
|
|
44
42
|
var _useVisuallyHidden = (0, _reactAria.useVisuallyHidden)(),
|
|
45
43
|
visuallyHiddenProps = _useVisuallyHidden.visuallyHiddenProps;
|
|
46
|
-
var downloadRef = (0, _react.useRef)();
|
|
44
|
+
var downloadRef = (0, _react.useRef)(null);
|
|
47
45
|
var getFileIconProps = (0, _react.useCallback)(function () {
|
|
48
46
|
switch (status) {
|
|
49
47
|
case _statuses["default"].ERROR:
|
|
@@ -66,7 +64,9 @@ var FileItem = function FileItem(props) {
|
|
|
66
64
|
}
|
|
67
65
|
}, [status]);
|
|
68
66
|
var handleDownloadPress = function handleDownloadPress() {
|
|
69
|
-
downloadRef.current
|
|
67
|
+
if (downloadRef.current) {
|
|
68
|
+
downloadRef.current.click();
|
|
69
|
+
}
|
|
70
70
|
};
|
|
71
71
|
return (0, _react2.jsx)(_index.Box, {
|
|
72
72
|
isRow: true,
|
|
@@ -76,9 +76,9 @@ var FileItem = function FileItem(props) {
|
|
|
76
76
|
}, (0, _react2.jsx)(_index.Icon, (0, _extends2["default"])({
|
|
77
77
|
size: 15,
|
|
78
78
|
"data-testid": "file-uploaded__file-icon"
|
|
79
|
-
}, getFileIconProps(), {
|
|
79
|
+
}, _objectSpread(_objectSpread({}, getFileIconProps()), {}, {
|
|
80
80
|
isDisabled: isDisabled
|
|
81
|
-
})), (0, _react2.jsx)(_index.Button, {
|
|
81
|
+
}))), (0, _react2.jsx)(_index.Button, {
|
|
82
82
|
variant: "forms.fileInputField.button",
|
|
83
83
|
mx: 5,
|
|
84
84
|
isDisabled: isDisabled,
|
|
@@ -115,12 +115,4 @@ var FileItem = function FileItem(props) {
|
|
|
115
115
|
id: "file-uploaded__download-link-".concat(id)
|
|
116
116
|
})));
|
|
117
117
|
};
|
|
118
|
-
var _default = exports["default"] = FileItem;
|
|
119
|
-
FileItem.propTypes = _objectSpread({
|
|
120
|
-
downloadLink: _propTypes["default"].string,
|
|
121
|
-
handleFileDelete: _propTypes["default"].func,
|
|
122
|
-
id: _propTypes["default"].string,
|
|
123
|
-
isDisabled: _propTypes["default"].bool,
|
|
124
|
-
name: _propTypes["default"].string,
|
|
125
|
-
textProps: _propTypes["default"].shape({})
|
|
126
|
-
}, _statusProp.statusPropTypes);
|
|
118
|
+
var _default = exports["default"] = FileItem;
|
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
|
4
|
-
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
|
5
|
-
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
|
6
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
7
|
-
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
|
8
|
-
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
|
9
|
-
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
|
10
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
11
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
12
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
13
6
|
value: true
|
|
14
7
|
});
|
|
15
8
|
exports["default"] = void 0;
|
|
16
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
17
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
18
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
|
19
11
|
var _react = _interopRequireDefault(require("react"));
|
|
20
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
21
12
|
var _ = require("../..");
|
|
22
13
|
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
|
23
14
|
var _react2 = require("@emotion/react");
|
|
24
15
|
var _excluded = ["buttonText", "handleFileSelect", "isDisabled", "textProps"];
|
|
25
|
-
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
27
16
|
var FileSelect = function FileSelect(_ref) {
|
|
28
17
|
var buttonText = _ref.buttonText,
|
|
29
18
|
handleFileSelect = _ref.handleFileSelect,
|
|
@@ -44,10 +33,4 @@ var FileSelect = function FileSelect(_ref) {
|
|
|
44
33
|
color: "active"
|
|
45
34
|
}, textProps), buttonText));
|
|
46
35
|
};
|
|
47
|
-
var _default = exports["default"] = FileSelect;
|
|
48
|
-
FileSelect.propTypes = _objectSpread({
|
|
49
|
-
buttonText: _propTypes["default"].string,
|
|
50
|
-
handleFileSelect: _propTypes["default"].func,
|
|
51
|
-
isDisabled: _propTypes["default"].bool,
|
|
52
|
-
textProps: _propTypes["default"].shape({})
|
|
53
|
-
}, _ariaAttributes.ariaAttributesBasePropTypes);
|
|
36
|
+
var _default = exports["default"] = FileSelect;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './FileInputField';
|
|
@@ -78,6 +78,7 @@ var parsePaste = function parsePaste(raw) {
|
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
80
|
var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
81
|
+
var _fieldControlInputPro;
|
|
81
82
|
var countryValue = props.countryValue,
|
|
82
83
|
defaultCountryValue = props.defaultCountryValue,
|
|
83
84
|
helperText = props.helperText,
|
|
@@ -240,6 +241,14 @@ var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
240
241
|
borderBottomRightRadius: '0 !important'
|
|
241
242
|
}
|
|
242
243
|
});
|
|
244
|
+
var countryPickerScrollBoxSx = {
|
|
245
|
+
minWidth: 0,
|
|
246
|
+
'@media screen and (max-width: 500px)': {
|
|
247
|
+
width: '100%',
|
|
248
|
+
maxWidth: '100%',
|
|
249
|
+
overflowX: 'hidden'
|
|
250
|
+
}
|
|
251
|
+
};
|
|
243
252
|
var countryLabel = function countryLabel(c) {
|
|
244
253
|
var _context4, _context5;
|
|
245
254
|
return (0, _concat["default"])(_context4 = (0, _concat["default"])(_context5 = "".concat(c.name)).call(_context5, c.name !== c["native"] ? " (".concat(c["native"], ")") : '', " +")).call(_context4, c.phone.split(',')[0]);
|
|
@@ -275,9 +284,7 @@ var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
275
284
|
},
|
|
276
285
|
scrollBoxProps: {
|
|
277
286
|
maxHeight: '215px',
|
|
278
|
-
sx:
|
|
279
|
-
minWidth: '280px'
|
|
280
|
-
}
|
|
287
|
+
sx: countryPickerScrollBoxSx
|
|
281
288
|
},
|
|
282
289
|
items: fieldState.items,
|
|
283
290
|
inputValue: currentCountryInputValue,
|
|
@@ -292,14 +299,17 @@ var PhoneNumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
292
299
|
textValue: "+".concat(item[1].phone.split(',')[0])
|
|
293
300
|
}, countryLabel(item[1]));
|
|
294
301
|
}), (0, _react2.jsx)(_.Box, {
|
|
302
|
+
className: (_fieldControlInputPro = fieldControlInputProps.className) !== null && _fieldControlInputPro !== void 0 && (0, _includes["default"])(_fieldControlInputPro).call(_fieldControlInputPro, 'is-focused') ? 'phone-number-field__input-focused' : undefined,
|
|
295
303
|
sx: {
|
|
296
|
-
ml: '
|
|
297
|
-
width: 'calc(100% -
|
|
304
|
+
ml: '109px',
|
|
305
|
+
width: 'calc(100% - 109px)',
|
|
298
306
|
visibility: fieldState.isOpen ? 'hidden' : undefined,
|
|
307
|
+
'&.phone-number-field__input-focused': {
|
|
308
|
+
ml: '111px'
|
|
309
|
+
},
|
|
299
310
|
'& input': {
|
|
300
311
|
borderTopLeftRadius: '0 !important',
|
|
301
|
-
borderBottomLeftRadius: '0 !important'
|
|
302
|
-
borderLeft: 0
|
|
312
|
+
borderBottomLeftRadius: '0 !important'
|
|
303
313
|
}
|
|
304
314
|
}
|
|
305
315
|
}, (0, _react2.jsx)(_.Input, (0, _extends2["default"])({
|