@pingux/astro 1.0.0-alpha.3 → 1.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/lib/cjs/components/FileInputField/FileInputField.js +324 -0
  3. package/lib/cjs/components/FileInputField/FileInputField.stories.js +250 -0
  4. package/lib/cjs/components/FileInputField/FileInputField.test.js +227 -0
  5. package/lib/cjs/components/FileInputField/FileItem.js +125 -0
  6. package/lib/cjs/components/FileInputField/FileSelect.js +48 -0
  7. package/lib/cjs/components/FileInputField/index.js +18 -0
  8. package/lib/cjs/components/Tab/Tab.js +10 -3
  9. package/lib/cjs/components/Tabs/Tabs.js +4 -1
  10. package/lib/cjs/components/Tabs/Tabs.stories.js +57 -2
  11. package/lib/cjs/components/Tabs/Tabs.test.js +34 -0
  12. package/lib/cjs/index.js +10 -0
  13. package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +146 -0
  14. package/lib/cjs/styles/forms/input.js +11 -0
  15. package/lib/cjs/styles/variants/boxes.js +23 -0
  16. package/lib/cjs/styles/variants/buttons.js +20 -0
  17. package/lib/cjs/styles/variants/tabs.js +1 -0
  18. package/lib/components/FileInputField/FileInputField.js +280 -0
  19. package/lib/components/FileInputField/FileInputField.stories.js +206 -0
  20. package/lib/components/FileInputField/FileInputField.test.js +187 -0
  21. package/lib/components/FileInputField/FileItem.js +100 -0
  22. package/lib/components/FileInputField/FileSelect.js +31 -0
  23. package/lib/components/FileInputField/index.js +1 -0
  24. package/lib/components/Tab/Tab.js +10 -3
  25. package/lib/components/Tabs/Tabs.js +4 -1
  26. package/lib/components/Tabs/Tabs.stories.js +53 -0
  27. package/lib/components/Tabs/Tabs.test.js +38 -0
  28. package/lib/index.js +1 -0
  29. package/lib/recipes/RadioButtonsWithLinks.stories.js +120 -0
  30. package/lib/styles/forms/input.js +11 -0
  31. package/lib/styles/variants/boxes.js +23 -0
  32. package/lib/styles/variants/buttons.js +20 -0
  33. package/lib/styles/variants/tabs.js +1 -0
  34. package/package.json +3 -2
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
+
7
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
8
+
9
+ _Object$defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+
13
+ exports.Default = exports["default"] = void 0;
14
+
15
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
16
+
17
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
18
+
19
+ var _react = _interopRequireWildcard(require("react"));
20
+
21
+ var _CloseIcon = _interopRequireDefault(require("mdi-react/CloseIcon"));
22
+
23
+ var _index = require("../index");
24
+
25
+ var _RadioField = _interopRequireDefault(require("../components/RadioField"));
26
+
27
+ var _RadioGroupField = _interopRequireDefault(require("../components/RadioGroupField"));
28
+
29
+ var _react2 = require("@emotion/react");
30
+
31
+ var _default = {
32
+ title: 'Recipes/RadioButtonsWithLinks'
33
+ };
34
+ exports["default"] = _default;
35
+
36
+ var Default = function Default() {
37
+ var roles = [{
38
+ name: 'Client Application Developer'
39
+ }, {
40
+ name: 'Environment Admin',
41
+ isDisabled: true
42
+ }, {
43
+ name: 'Identity Data Admin',
44
+ isDisabled: true
45
+ }, {
46
+ name: 'Organization Admin'
47
+ }];
48
+ var titleSx = {
49
+ fontSize: 'md',
50
+ color: 'neutral.20',
51
+ fontWeight: 2
52
+ };
53
+ var subtitleSx = {
54
+ fontSize: 'md',
55
+ color: 'neutral.10'
56
+ };
57
+
58
+ var RadioFieldWithButton = function RadioFieldWithButton(_ref) {
59
+ var fieldName = _ref.fieldName,
60
+ isDisabled = _ref.isDisabled;
61
+
62
+ var _useState = (0, _react.useState)(false),
63
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
64
+ isOpen = _useState2[0],
65
+ setIsOpen = _useState2[1];
66
+
67
+ return (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Box, {
68
+ isRow: true,
69
+ alignItems: "center"
70
+ }, (0, _react2.jsx)(_RadioField["default"], {
71
+ value: fieldName,
72
+ label: fieldName,
73
+ isDisabled: isDisabled
74
+ }), (0, _react2.jsx)(_index.Button, {
75
+ variant: "text",
76
+ mb: "xs",
77
+ ml: "md",
78
+ onPress: function onPress() {
79
+ return setIsOpen(function (prev) {
80
+ return !prev;
81
+ });
82
+ },
83
+ isDisabled: isDisabled
84
+ }, "".concat(isOpen ? 'Hide' : 'Show', " Permissions"))), isOpen && (0, _react2.jsx)(PermissionsList, {
85
+ onPress: function onPress() {
86
+ return setIsOpen(false);
87
+ }
88
+ }));
89
+ };
90
+
91
+ var PermissionsList = function PermissionsList(_ref2) {
92
+ var onPress = _ref2.onPress;
93
+ return (0, _react2.jsx)(_index.Box, {
94
+ p: "md",
95
+ bg: "neutral.95"
96
+ }, (0, _react2.jsx)(_index.Box, {
97
+ isRow: true,
98
+ justifyContent: "space-between",
99
+ mb: "sm"
100
+ }, (0, _react2.jsx)(_index.Text, {
101
+ sx: {
102
+ fontWeight: 2
103
+ }
104
+ }, "Permissions"), (0, _react2.jsx)(_index.IconButton, {
105
+ onPress: onPress
106
+ }, (0, _react2.jsx)(_index.Icon, {
107
+ icon: _CloseIcon["default"]
108
+ }))), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Text, {
109
+ sx: titleSx,
110
+ mb: "xs"
111
+ }, "Resource"), (0, _react2.jsx)(_index.Text, {
112
+ sx: subtitleSx,
113
+ mb: "sm"
114
+ }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), (0, _react2.jsx)(_index.Text, {
115
+ sx: titleSx,
116
+ mb: "xs"
117
+ }, "Push Credentials"), (0, _react2.jsx)(_index.Text, {
118
+ sx: subtitleSx,
119
+ mb: "sm"
120
+ }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod"), (0, _react2.jsx)(_index.Text, {
121
+ sx: titleSx,
122
+ mb: "xs"
123
+ }, "Organization"), (0, _react2.jsx)(_index.Text, {
124
+ sx: subtitleSx,
125
+ mb: "sm"
126
+ }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco"), (0, _react2.jsx)(_index.Text, {
127
+ sx: titleSx,
128
+ mb: "xs"
129
+ }, "Image"), (0, _react2.jsx)(_index.Text, {
130
+ sx: subtitleSx,
131
+ mb: "sm"
132
+ }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod")));
133
+ };
134
+
135
+ return (0, _react2.jsx)(_RadioGroupField["default"], null, (0, _map["default"])(roles).call(roles, function (_ref3) {
136
+ var name = _ref3.name,
137
+ isDisabled = _ref3.isDisabled;
138
+ return (0, _react2.jsx)(RadioFieldWithButton, {
139
+ fieldName: name,
140
+ isDisabled: isDisabled,
141
+ key: name
142
+ });
143
+ }));
144
+ };
145
+
146
+ exports.Default = Default;
@@ -71,6 +71,17 @@ var input = _objectSpread(_objectSpread({}, _text.text.inputValue), {}, {
71
71
  '&::placeholder': _text.text.placeholder,
72
72
  '&::-ms-expand': {
73
73
  display: 'none'
74
+ },
75
+ '&::-webkit-contacts-auto-fill-button, &::-webkit-credentials-auto-fill-button': {
76
+ visibility: 'hidden',
77
+ display: 'none !important',
78
+ pointerEvents: 'none',
79
+ height: 0,
80
+ width: 0,
81
+ margin: 0
82
+ },
83
+ '&::-ms-reveal, &::-ms-clear': {
84
+ display: 'none'
74
85
  }
75
86
  }); // Example variant input
76
87
 
@@ -250,6 +250,28 @@ var datePicker = {
250
250
  }
251
251
  }
252
252
  };
253
+ var fileInputFieldWrapper = {
254
+ display: 'flex',
255
+ border: '1px dashed',
256
+ borderColor: 'active',
257
+ padding: '10px 0',
258
+ '&.is-drag-active': {
259
+ backgroundColor: 'accent.95'
260
+ },
261
+ '&.is-error': {
262
+ borderColor: 'critical.dark'
263
+ },
264
+ '&.is-success': {
265
+ borderColor: 'success.dark'
266
+ },
267
+ '&.is-warning': {
268
+ borderColor: 'warning.dark'
269
+ },
270
+ '&.is-loading': {
271
+ justifyContent: 'center',
272
+ alignItems: 'center'
273
+ }
274
+ };
253
275
  var _default = {
254
276
  base: base,
255
277
  card: card,
@@ -258,6 +280,7 @@ var _default = {
258
280
  datePicker: datePicker,
259
281
  expandableRow: expandableRow,
260
282
  inputInContainerSlot: inputInContainerSlot,
283
+ fileInputFieldWrapper: fileInputFieldWrapper,
261
284
  listItem: listItem,
262
285
  listBoxSectionTitle: listBoxSectionTitle,
263
286
  listViewItem: listViewItem,
@@ -473,6 +473,25 @@ var expandableRow = {
473
473
  }
474
474
  }
475
475
  };
476
+ var fileInputField = {
477
+ background: 'none',
478
+ cursor: 'pointer',
479
+ '& span': {
480
+ textAlign: 'initial'
481
+ },
482
+ '&:focus-visible': {
483
+ outline: 'none'
484
+ },
485
+ '&.is-hovered, &.is-pressed': {
486
+ cursor: 'pointer',
487
+ '& span': {
488
+ textDecoration: 'underline'
489
+ }
490
+ },
491
+ '&.is-focused': {
492
+ boxShadow: 'focus'
493
+ }
494
+ };
476
495
  var _default = {
477
496
  accordionHeader: accordionHeader,
478
497
  chipDeleteButton: chipDeleteButton,
@@ -491,6 +510,7 @@ var _default = {
491
510
  '&.is-focused': _objectSpread({}, defaultFocus)
492
511
  }),
493
512
  expandableRow: expandableRow,
513
+ fileInputField: fileInputField,
494
514
  iconButton: iconButton,
495
515
  icon: icon,
496
516
  imageUpload: imageUpload,
@@ -14,6 +14,7 @@ var tab = {
14
14
  display: 'inline-flex',
15
15
  outline: 'none',
16
16
  transform: 'translateY(1px)',
17
+ width: '100%',
17
18
  '&.is-focused': {
18
19
  boxShadow: 'focus'
19
20
  },
@@ -0,0 +1,280 @@
1
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
2
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
3
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
4
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
5
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
6
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
7
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
8
+ import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
9
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
11
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
12
+ import _URL from "@babel/runtime-corejs3/core-js-stable/url";
13
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
14
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
15
+ import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
16
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
17
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
18
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source), true)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
23
+
24
+ import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState } from 'react';
25
+ import { useVisuallyHidden } from '@react-aria/visually-hidden';
26
+ import { useDropzone } from 'react-dropzone';
27
+ import PropTypes from 'prop-types';
28
+ import { mergeProps } from '@react-aria/utils';
29
+ import { v4 as uuidv4 } from 'uuid';
30
+ import { Box, Input, FieldHelperText, Label, Loader } from '../../index';
31
+ import FileItem from './FileItem';
32
+ import FileSelect from './FileSelect';
33
+ import useStatusClasses from '../../hooks/useStatusClasses';
34
+ import useField from '../../hooks/useField';
35
+ import statuses from '../../utils/devUtils/constants/statuses';
36
+ /**
37
+ * The FileInputField component allows users to upload one or more files by
38
+ * clicking the button or via drag and drop.
39
+ *
40
+ * We utilize [react-dropzone](https://react-dropzone.js.org/) for the drag and drop functionality.
41
+ * */
42
+
43
+ import { jsx as ___EmotionJSX } from "@emotion/react";
44
+ var FileInputField = /*#__PURE__*/forwardRef(function (props, ref) {
45
+ var defaultButtonText = props.defaultButtonText,
46
+ defaultFileList = props.defaultFileList,
47
+ uploadedFilesImperative = props.fileList,
48
+ helperText = props.helperText,
49
+ isDisabled = props.isDisabled,
50
+ isLoading = props.isLoading,
51
+ isMultiple = props.isMultiple,
52
+ onFileSelect = props.onFileSelect,
53
+ onRemove = props.onRemove,
54
+ status = props.status,
55
+ textProps = props.textProps,
56
+ others = _objectWithoutProperties(props, ["defaultButtonText", "defaultFileList", "fileList", "helperText", "isDisabled", "isLoading", "isMultiple", "onFileSelect", "onRemove", "status", "textProps"]);
57
+
58
+ var _useState = useState(defaultFileList || []),
59
+ _useState2 = _slicedToArray(_useState, 2),
60
+ uploadedFiles = _useState2[0],
61
+ setUploadedFiles = _useState2[1];
62
+
63
+ var inputRef = useRef();
64
+ /* istanbul ignore next */
65
+
66
+ useImperativeHandle(ref, function () {
67
+ return inputRef.current;
68
+ });
69
+
70
+ var _useField = useField(_objectSpread({
71
+ status: status,
72
+ isDisabled: isDisabled
73
+ }, others)),
74
+ fieldContainerProps = _useField.fieldContainerProps,
75
+ fieldControlProps = _useField.fieldControlProps,
76
+ fieldLabelProps = _useField.fieldLabelProps;
77
+
78
+ var _useVisuallyHidden = useVisuallyHidden(),
79
+ visuallyHiddenProps = _useVisuallyHidden.visuallyHiddenProps;
80
+
81
+ var handleFileSelect = useCallback(function () {
82
+ inputRef.current.value = null;
83
+ inputRef.current.click();
84
+ }, [inputRef]);
85
+ var handleFileUpload = useCallback(function (event, newFiles) {
86
+ if (onFileSelect) {
87
+ onFileSelect(event, newFiles);
88
+ }
89
+
90
+ var arrayWithNewFiles = _Array$from(newFiles);
91
+
92
+ if (!isMultiple) {
93
+ arrayWithNewFiles = _sliceInstanceProperty(arrayWithNewFiles).call(arrayWithNewFiles, 0, 1);
94
+ }
95
+
96
+ var newFilesWithIdAndLink = _mapInstanceProperty(arrayWithNewFiles).call(arrayWithNewFiles, function (newFile) {
97
+ return {
98
+ fileObj: newFile,
99
+ name: newFile.name,
100
+ id: uuidv4(),
101
+ downloadLink: _URL.createObjectURL(newFile),
102
+ status: statuses.DEFAULT
103
+ };
104
+ });
105
+
106
+ if (isMultiple) {
107
+ setUploadedFiles(function (prevFiles) {
108
+ var _context;
109
+
110
+ return _concatInstanceProperty(_context = []).call(_context, prevFiles, newFilesWithIdAndLink);
111
+ });
112
+ } else {
113
+ setUploadedFiles(newFilesWithIdAndLink);
114
+ }
115
+ }, [isMultiple, onFileSelect]);
116
+ var onDrop = useCallback(function (acceptedFiles, fileRejections, event) {
117
+ handleFileUpload(event, acceptedFiles);
118
+ }, [handleFileUpload]);
119
+
120
+ var _useDropzone = useDropzone({
121
+ onDrop: onDrop,
122
+ noKeyboard: true,
123
+ disabled: isDisabled || isLoading
124
+ }),
125
+ getRootProps = _useDropzone.getRootProps,
126
+ getInputProps = _useDropzone.getInputProps,
127
+ isDragActive = _useDropzone.isDragActive;
128
+
129
+ var handleOnChange = useCallback(function (event) {
130
+ handleFileUpload(event, event.target.files);
131
+ }, [handleFileUpload]);
132
+ var handleFileDelete = useCallback(function (e, fileId) {
133
+ if (onRemove) {
134
+ onRemove(e, fileId);
135
+ }
136
+
137
+ setUploadedFiles(function (prevFiles) {
138
+ return _filterInstanceProperty(prevFiles).call(prevFiles, function (_ref) {
139
+ var id = _ref.id;
140
+ return id !== fileId;
141
+ });
142
+ });
143
+ }, [onRemove]);
144
+ var filesListNode = useMemo(function () {
145
+ var filesToRender = uploadedFilesImperative || uploadedFiles;
146
+
147
+ if (!(filesToRender === null || filesToRender === void 0 ? void 0 : filesToRender.length)) {
148
+ return null;
149
+ }
150
+
151
+ return _mapInstanceProperty(filesToRender).call(filesToRender, function (fileProps) {
152
+ return ___EmotionJSX(FileItem, _extends({
153
+ handleFileDelete: handleFileDelete,
154
+ isDisabled: isDisabled || isLoading,
155
+ key: fileProps.id,
156
+ textProps: textProps
157
+ }, fileProps));
158
+ });
159
+ }, [uploadedFilesImperative, uploadedFiles, handleFileDelete, isDisabled, isLoading, textProps]);
160
+
161
+ var _useStatusClasses = useStatusClasses('fileInputFieldWrapper', _defineProperty({
162
+ isDragActive: isDragActive,
163
+ isLoading: isLoading
164
+ }, "is-".concat(status), true)),
165
+ classNames = _useStatusClasses.classNames;
166
+
167
+ var shouldFileSelectRender = useCallback(function () {
168
+ var isFileUploaded;
169
+
170
+ if (uploadedFilesImperative) {
171
+ isFileUploaded = Boolean(uploadedFilesImperative === null || uploadedFilesImperative === void 0 ? void 0 : uploadedFilesImperative.length);
172
+ } else {
173
+ isFileUploaded = Boolean(uploadedFiles === null || uploadedFiles === void 0 ? void 0 : uploadedFiles.length);
174
+ }
175
+
176
+ return isMultiple || !isFileUploaded;
177
+ }, [uploadedFiles, uploadedFilesImperative, isMultiple]);
178
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Label, fieldLabelProps), ___EmotionJSX(Box, _extends({
179
+ variant: "boxes.fileInputFieldWrapper"
180
+ }, mergeProps(fieldContainerProps, others), {
181
+ className: classNames
182
+ }, getRootProps()), ___EmotionJSX(Input, _extends({}, mergeProps(visuallyHiddenProps, fieldControlProps, getInputProps()), {
183
+ "aria-label": "File Input",
184
+ multiple: isMultiple,
185
+ onChange: handleOnChange,
186
+ ref: inputRef,
187
+ type: "file"
188
+ })), filesListNode, shouldFileSelectRender() && ___EmotionJSX(FileSelect, {
189
+ buttonText: defaultButtonText,
190
+ handleFileSelect: handleFileSelect,
191
+ isDisabled: isDisabled || isLoading,
192
+ textProps: textProps
193
+ }), isLoading && ___EmotionJSX(Loader, {
194
+ color: "active",
195
+ sx: {
196
+ position: 'absolute'
197
+ },
198
+ "data-testid": "file-input-field__loader"
199
+ })), helperText && ___EmotionJSX(FieldHelperText, {
200
+ status: status
201
+ }, helperText));
202
+ });
203
+ FileInputField.displayName = 'FileInputField';
204
+ FileInputField.propTypes = {
205
+ /** The rendered label for the field. */
206
+ label: PropTypes.node,
207
+
208
+ /** Text rendered below the input. */
209
+ helperText: PropTypes.node,
210
+
211
+ /** Determines the component border status color indicator and helper text styling. */
212
+ status: PropTypes.oneOf(_Object$values(statuses)),
213
+
214
+ /** Default button text that will be changed on the file name once file is uploaded */
215
+ defaultButtonText: PropTypes.string,
216
+
217
+ /** Defines whether input can accept multiple files or not */
218
+ isMultiple: PropTypes.bool,
219
+
220
+ /** Determines whether the loading indicator is shown. */
221
+ isLoading: PropTypes.bool,
222
+
223
+ /** Whether the field is disabled. */
224
+ isDisabled: PropTypes.bool,
225
+
226
+ /** Array of objects for uploaded files.
227
+ * Objects should have the following structure:
228
+ *
229
+ * {
230
+ *
231
+ * fileObj: File object (optional),
232
+ *
233
+ * id: file id (required - will be returned on delete),
234
+ *
235
+ * name: file name that will be displayed (required - will be displayed),
236
+ *
237
+ * downloadLink: link for the file download (optional),
238
+ *
239
+ * status: file status (if error - icon of the
240
+ * component will be red icon and warning sign)(optional),
241
+ *
242
+ * }
243
+ * */
244
+ fileList: PropTypes.arrayOf(PropTypes.shape({
245
+ fileObj: PropTypes.shape({}),
246
+ id: PropTypes.string.required,
247
+ name: PropTypes.string.required,
248
+ downloadLink: PropTypes.string,
249
+ status: PropTypes.oneOf(_Object$values(statuses))
250
+ })),
251
+
252
+ /** Default array of objects for uploaded files. */
253
+ defaultFileList: PropTypes.arrayOf(PropTypes.shape({
254
+ fileObj: PropTypes.shape({}),
255
+ id: PropTypes.string.required,
256
+ name: PropTypes.string.required,
257
+ downloadLink: PropTypes.string,
258
+ status: PropTypes.oneOf(_Object$values(statuses))
259
+ })),
260
+
261
+ /** The handler that is called when the input files is uploaded.
262
+ *
263
+ * `(event, files) => void`
264
+ * */
265
+ onFileSelect: PropTypes.func,
266
+
267
+ /** The handler that is called when an uploaded file got removed.
268
+ *
269
+ * `(fileId) => void`
270
+ * */
271
+ onRemove: PropTypes.func,
272
+
273
+ /** These props will be spread to the field text component. */
274
+ textProps: PropTypes.shape({})
275
+ };
276
+ FileInputField.defaultProps = {
277
+ defaultButtonText: 'Select a file',
278
+ status: statuses.DEFAULT
279
+ };
280
+ export default FileInputField;