@telus-uds/components-base 1.92.0 → 1.94.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/CHANGELOG.md +21 -2
- package/lib/A11yText/index.js +7 -2
- package/lib/Button/ButtonGroup.js +17 -1
- package/lib/Card/Card.js +12 -0
- package/lib/Card/CardBase.js +37 -2
- package/lib/Carousel/Carousel.js +55 -13
- package/lib/Carousel/CarouselItem/CarouselItem.js +86 -12
- package/lib/Fieldset/FieldsetContainer.js +7 -2
- package/lib/Fieldset/FieldsetContainer.native.js +4 -1
- package/lib/FileUpload/FileUpload.js +336 -0
- package/lib/FileUpload/NotificationContent.js +60 -0
- package/lib/FileUpload/dictionary.js +47 -0
- package/lib/FileUpload/index.js +10 -0
- package/lib/Link/TextButton.js +7 -17
- package/lib/Modal/ModalContent.js +12 -6
- package/lib/MultiSelectFilter/ModalOverlay.js +49 -30
- package/lib/MultiSelectFilter/MultiSelectFilter.js +170 -131
- package/lib/Notification/Notification.js +11 -2
- package/lib/Status/Status.js +9 -4
- package/lib/index.js +8 -0
- package/lib/utils/convertFromMegaByteToByte.js +16 -0
- package/lib/utils/formatImageSource.js +34 -0
- package/lib/utils/index.js +17 -1
- package/lib-module/A11yText/index.js +7 -2
- package/lib-module/Button/ButtonGroup.js +17 -1
- package/lib-module/Card/Card.js +13 -1
- package/lib-module/Card/CardBase.js +38 -3
- package/lib-module/Carousel/Carousel.js +55 -13
- package/lib-module/Carousel/CarouselItem/CarouselItem.js +86 -12
- package/lib-module/Fieldset/FieldsetContainer.js +7 -2
- package/lib-module/Fieldset/FieldsetContainer.native.js +4 -1
- package/lib-module/FileUpload/FileUpload.js +329 -0
- package/lib-module/FileUpload/NotificationContent.js +55 -0
- package/lib-module/FileUpload/dictionary.js +40 -0
- package/lib-module/FileUpload/index.js +2 -0
- package/lib-module/Link/TextButton.js +7 -17
- package/lib-module/Modal/ModalContent.js +12 -6
- package/lib-module/MultiSelectFilter/ModalOverlay.js +49 -30
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +171 -132
- package/lib-module/Notification/Notification.js +11 -2
- package/lib-module/Status/Status.js +9 -4
- package/lib-module/index.js +1 -0
- package/lib-module/utils/convertFromMegaByteToByte.js +10 -0
- package/lib-module/utils/formatImageSource.js +27 -0
- package/lib-module/utils/index.js +3 -1
- package/package.json +4 -3
- package/src/A11yText/index.jsx +7 -3
- package/src/Button/ButtonGroup.jsx +9 -1
- package/src/Card/Card.jsx +18 -2
- package/src/Card/CardBase.jsx +47 -12
- package/src/Carousel/Carousel.jsx +59 -13
- package/src/Carousel/CarouselItem/CarouselItem.jsx +94 -9
- package/src/Fieldset/FieldsetContainer.jsx +4 -3
- package/src/Fieldset/FieldsetContainer.native.jsx +9 -6
- package/src/FileUpload/FileUpload.jsx +396 -0
- package/src/FileUpload/NotificationContent.jsx +44 -0
- package/src/FileUpload/dictionary.js +40 -0
- package/src/FileUpload/index.js +3 -0
- package/src/Link/TextButton.jsx +10 -17
- package/src/Modal/ModalContent.jsx +8 -3
- package/src/MultiSelectFilter/ModalOverlay.jsx +44 -18
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +188 -126
- package/src/Notification/Notification.jsx +12 -4
- package/src/Status/Status.jsx +15 -4
- package/src/index.js +1 -0
- package/src/utils/convertFromMegaByteToByte.js +11 -0
- package/src/utils/formatImageSource.js +29 -0
- package/src/utils/index.js +2 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
9
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
12
|
+
var _utils = require("../utils");
|
|
13
|
+
var _InputLabel = _interopRequireDefault(require("../InputLabel"));
|
|
14
|
+
var _Button = require("../Button");
|
|
15
|
+
var _Notification = _interopRequireDefault(require("../Notification"));
|
|
16
|
+
var _Spacer = _interopRequireDefault(require("../Spacer"));
|
|
17
|
+
var _StackView = _interopRequireDefault(require("../StackView"));
|
|
18
|
+
var _NotificationContent = _interopRequireDefault(require("./NotificationContent"));
|
|
19
|
+
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
23
|
+
const getHintFromFileTypes = fileTypes => {
|
|
24
|
+
const acceptedFileTypes = fileTypes.map(type => type.toUpperCase());
|
|
25
|
+
return acceptedFileTypes.reduce((acc, curr, index) => {
|
|
26
|
+
if (index === 0) {
|
|
27
|
+
return `${curr}`;
|
|
28
|
+
}
|
|
29
|
+
return `${acc}, ${curr}`;
|
|
30
|
+
}, '');
|
|
31
|
+
};
|
|
32
|
+
const stringifyFileTypesList = (fileTypes, getCopy) => {
|
|
33
|
+
const acceptedFileTypes = fileTypes.map(type => `.${type.toUpperCase()}`);
|
|
34
|
+
return acceptedFileTypes.reduce((acc, curr, index) => {
|
|
35
|
+
if (index === 0) {
|
|
36
|
+
return curr;
|
|
37
|
+
}
|
|
38
|
+
if (index === acceptedFileTypes.length - 1) {
|
|
39
|
+
return `${acc} ${getCopy('or')} ${curr}`;
|
|
40
|
+
}
|
|
41
|
+
return `${acc}, ${curr}`;
|
|
42
|
+
}, '');
|
|
43
|
+
};
|
|
44
|
+
const selectComponentTokens = (tokens, componentIdentifier) => {
|
|
45
|
+
return Object.entries(tokens).reduce((acc, _ref) => {
|
|
46
|
+
let [key, value] = _ref;
|
|
47
|
+
if (key.startsWith(componentIdentifier) && value !== null) {
|
|
48
|
+
const newKey = key.replace(componentIdentifier, '').replace('Text', '').charAt(0).toLowerCase() + key.replace(componentIdentifier, '').replace('Text', '').slice(1);
|
|
49
|
+
acc[newKey] = value;
|
|
50
|
+
}
|
|
51
|
+
return acc;
|
|
52
|
+
}, {});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* FileUpload component for uploading files.
|
|
57
|
+
*
|
|
58
|
+
* @component
|
|
59
|
+
* @example
|
|
60
|
+
* // Usage:
|
|
61
|
+
* <FileUpload
|
|
62
|
+
* tokens={tokens}
|
|
63
|
+
* variant={variant}
|
|
64
|
+
* copy={copy}
|
|
65
|
+
* fileTypes={fileTypes}
|
|
66
|
+
* allowMultipleFiles={allowMultipleFiles}
|
|
67
|
+
* maxFileSize={maxFileSize}
|
|
68
|
+
* maxFilesCount={maxFilesCount}
|
|
69
|
+
* onUpload={onUpload}
|
|
70
|
+
* onDelete={onDelete}
|
|
71
|
+
* documentPicker={documentPicker}
|
|
72
|
+
* {...rest}
|
|
73
|
+
* />
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} props - The component props.
|
|
76
|
+
* @param {Object} props.tokens - The tokens for styling the component.
|
|
77
|
+
* @param {string} props.variant - The variant of the component.
|
|
78
|
+
* @param {string} props.copy - The copy for the component.
|
|
79
|
+
* @param {string[]} props.fileTypes - The allowed file types for upload.
|
|
80
|
+
* @param {boolean} props.allowMultipleFiles - Whether multiple files can be uploaded.
|
|
81
|
+
* @param {number} props.maxFileSize - The maximum file size in megabytes.
|
|
82
|
+
* @param {number} props.maxFilesCount - The maximum number of files that can be uploaded.
|
|
83
|
+
* @param {Function} props.onUpload - The callback function for file upload.
|
|
84
|
+
* @param {Function} props.onDelete - The callback function for file deletion.
|
|
85
|
+
* @param {Object} props.documentPicker - The document picker object.
|
|
86
|
+
* @param {any} props.rest - Additional props to be spread to the component.
|
|
87
|
+
* @returns {JSX.Element} The rendered FileUpload component.
|
|
88
|
+
*/
|
|
89
|
+
const FileUpload = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
90
|
+
let {
|
|
91
|
+
tokens,
|
|
92
|
+
variant,
|
|
93
|
+
copy = 'en',
|
|
94
|
+
fileTypes,
|
|
95
|
+
allowMultipleFiles = false,
|
|
96
|
+
maxFileSize,
|
|
97
|
+
maxFilesCount = 1,
|
|
98
|
+
onUpload,
|
|
99
|
+
onDelete,
|
|
100
|
+
documentPicker,
|
|
101
|
+
...rest
|
|
102
|
+
} = _ref2;
|
|
103
|
+
const themeTokens = (0, _ThemeProvider.useThemeTokens)('FileUpload', tokens, variant);
|
|
104
|
+
const getCopy = (0, _utils.useCopy)({
|
|
105
|
+
dictionary: _dictionary.default,
|
|
106
|
+
copy
|
|
107
|
+
});
|
|
108
|
+
const inputFileRef = _react.default.useRef(null);
|
|
109
|
+
const [filesStatus, setFilesStatus] = _react.default.useState([]);
|
|
110
|
+
const [renderTrigger, setRenderTrigger] = _react.default.useState(0);
|
|
111
|
+
_react.default.useEffect(() => {
|
|
112
|
+
setRenderTrigger(prev => prev + 1);
|
|
113
|
+
}, [filesStatus]);
|
|
114
|
+
const areFileTypesExtensionsValid = files => files.some(file => {
|
|
115
|
+
const fileExtension = file.name.split('.').pop().toLowerCase();
|
|
116
|
+
if (!fileTypes.includes(fileExtension)) {
|
|
117
|
+
setFilesStatus([{
|
|
118
|
+
description: getCopy('wrongFileType').replace('%{fileType}', stringifyFileTypesList(fileTypes, getCopy)),
|
|
119
|
+
style: 'error'
|
|
120
|
+
}]);
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
});
|
|
125
|
+
const areFileSizesWithinLimit = files => files.some(file => {
|
|
126
|
+
if (file.size > (0, _utils.convertFromMegaByteToByte)(maxFileSize)) {
|
|
127
|
+
setFilesStatus([{
|
|
128
|
+
description: getCopy('fileTooBig').replace('%{size}', maxFileSize),
|
|
129
|
+
style: 'error'
|
|
130
|
+
}]);
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
});
|
|
135
|
+
const areMoreFilesUploadedThanAllowed = files => {
|
|
136
|
+
if (files.length > maxFilesCount) {
|
|
137
|
+
setFilesStatus([{
|
|
138
|
+
description: getCopy('tooManyFiles').replace('%{maxFilesCount}', maxFilesCount),
|
|
139
|
+
style: 'error'
|
|
140
|
+
}]);
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
};
|
|
145
|
+
const handleFilesUpload = async files => {
|
|
146
|
+
try {
|
|
147
|
+
const results = await onUpload(files);
|
|
148
|
+
const currentFilesStatus = files.map((file, index) => {
|
|
149
|
+
if (results[index].error) {
|
|
150
|
+
return {
|
|
151
|
+
description: /*#__PURE__*/(0, _jsxRuntime.jsx)(_NotificationContent.default, {
|
|
152
|
+
file: file,
|
|
153
|
+
color: selectComponentTokens(themeTokens, 'notification').color,
|
|
154
|
+
children: ` ${getCopy('uploadError')} ${results[index].error}.`
|
|
155
|
+
}),
|
|
156
|
+
style: 'error'
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
description: /*#__PURE__*/(0, _jsxRuntime.jsx)(_NotificationContent.default, {
|
|
161
|
+
file: file,
|
|
162
|
+
color: selectComponentTokens(themeTokens, 'notification').color,
|
|
163
|
+
children: ` ${getCopy('uploadSuccess')}`
|
|
164
|
+
}),
|
|
165
|
+
style: 'success',
|
|
166
|
+
file,
|
|
167
|
+
onDismiss: () => handleFileDeletion(file)
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
setFilesStatus(currentFilesStatus);
|
|
171
|
+
} catch (error) {
|
|
172
|
+
setFilesStatus([{
|
|
173
|
+
description: allowMultipleFiles ? getCopy('problemUploadingMultipleFiles') : getCopy('problemUploading'),
|
|
174
|
+
style: 'error'
|
|
175
|
+
}]);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const handleFileDeletion = async file => {
|
|
179
|
+
const copyFile = {
|
|
180
|
+
...file
|
|
181
|
+
};
|
|
182
|
+
try {
|
|
183
|
+
const result = await onDelete(copyFile);
|
|
184
|
+
setFilesStatus(prevStatus => {
|
|
185
|
+
const filteredFilesStatus = prevStatus.filter(f => f.file && f.file.name !== file.name);
|
|
186
|
+
return result.error ? [...filteredFilesStatus, {
|
|
187
|
+
description: /*#__PURE__*/(0, _jsxRuntime.jsx)(_NotificationContent.default, {
|
|
188
|
+
file: file,
|
|
189
|
+
color: selectComponentTokens(themeTokens, 'notification').color,
|
|
190
|
+
children: ` ${getCopy('uploadSuccess')}`
|
|
191
|
+
}),
|
|
192
|
+
style: 'success',
|
|
193
|
+
file,
|
|
194
|
+
onDismiss: () => handleFileDeletion(file)
|
|
195
|
+
}, {
|
|
196
|
+
description: /*#__PURE__*/(0, _jsxRuntime.jsx)(_NotificationContent.default, {
|
|
197
|
+
file: file,
|
|
198
|
+
color: selectComponentTokens(themeTokens, 'notification').color,
|
|
199
|
+
children: ` ${getCopy('deleteProblem')} ${result.error}.`
|
|
200
|
+
}),
|
|
201
|
+
style: 'error',
|
|
202
|
+
file
|
|
203
|
+
}] : filteredFilesStatus;
|
|
204
|
+
});
|
|
205
|
+
} catch (error) {
|
|
206
|
+
setFilesStatus([{
|
|
207
|
+
description: /*#__PURE__*/(0, _jsxRuntime.jsx)(_NotificationContent.default, {
|
|
208
|
+
file: file,
|
|
209
|
+
color: selectComponentTokens(themeTokens, 'notification').color,
|
|
210
|
+
children: ` ${getCopy('problemDeleting')}`
|
|
211
|
+
}),
|
|
212
|
+
style: 'error'
|
|
213
|
+
}]);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const handleOnChange = async event => {
|
|
217
|
+
const targetFiles = event.target.files;
|
|
218
|
+
const files = Array.from(targetFiles);
|
|
219
|
+
if (files.length === 0) return;
|
|
220
|
+
if (fileTypes && !areFileTypesExtensionsValid(files)) return;
|
|
221
|
+
if (maxFileSize && !areFileSizesWithinLimit(files)) return;
|
|
222
|
+
if (maxFilesCount && areMoreFilesUploadedThanAllowed(files)) return;
|
|
223
|
+
await handleFilesUpload(files);
|
|
224
|
+
if (inputFileRef.current) inputFileRef.current.value = '';
|
|
225
|
+
};
|
|
226
|
+
const onFileUploadButtonClick = async () => {
|
|
227
|
+
if (_Platform.default.OS === 'web') {
|
|
228
|
+
inputFileRef.current.click();
|
|
229
|
+
} else {
|
|
230
|
+
try {
|
|
231
|
+
const result = await documentPicker.getDocumentAsync({
|
|
232
|
+
multiple: allowMultipleFiles
|
|
233
|
+
});
|
|
234
|
+
if (result) {
|
|
235
|
+
const files = Array.isArray(result) ? result : [result];
|
|
236
|
+
if (files.find(file => file.type === 'cancel')) return;
|
|
237
|
+
const event = {
|
|
238
|
+
target: {
|
|
239
|
+
files
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
await handleOnChange(event);
|
|
243
|
+
}
|
|
244
|
+
} catch (_) {
|
|
245
|
+
setFilesStatus([{
|
|
246
|
+
description: allowMultipleFiles ? getCopy('problemUploadingFiles') : getCopy('problemUploading'),
|
|
247
|
+
style: 'error'
|
|
248
|
+
}]);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
253
|
+
ref: ref,
|
|
254
|
+
...selectProps(rest),
|
|
255
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_InputLabel.default, {
|
|
256
|
+
label: getCopy('label'),
|
|
257
|
+
hint: fileTypes && getCopy('allowedFileTypes').replace('%{fileTypes}', getHintFromFileTypes(fileTypes)),
|
|
258
|
+
hintPosition: "below"
|
|
259
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spacer.default, {
|
|
260
|
+
space: 4
|
|
261
|
+
}), _Platform.default.OS === 'web' && /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
262
|
+
type: "file",
|
|
263
|
+
multiple: allowMultipleFiles,
|
|
264
|
+
ref: inputFileRef,
|
|
265
|
+
hidden: true,
|
|
266
|
+
accept: fileTypes && fileTypes.map(type => `.${type}`).join(', '),
|
|
267
|
+
onChange: handleOnChange
|
|
268
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
|
|
269
|
+
onClick: onFileUploadButtonClick,
|
|
270
|
+
tokens: selectComponentTokens(themeTokens, 'button'),
|
|
271
|
+
children: getCopy('buttonLabel')
|
|
272
|
+
}), filesStatus.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
273
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Spacer.default, {
|
|
274
|
+
space: 4
|
|
275
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.default, {
|
|
276
|
+
space: 4,
|
|
277
|
+
children: filesStatus.map((_ref3, index) => {
|
|
278
|
+
let {
|
|
279
|
+
description,
|
|
280
|
+
style,
|
|
281
|
+
onDismiss
|
|
282
|
+
} = _ref3;
|
|
283
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Notification.default, {
|
|
284
|
+
variant: {
|
|
285
|
+
style
|
|
286
|
+
},
|
|
287
|
+
dismissible: !!onDismiss,
|
|
288
|
+
onDismiss: onDismiss,
|
|
289
|
+
tokens: selectComponentTokens(themeTokens, 'notification'),
|
|
290
|
+
children: description
|
|
291
|
+
}, `${index.toString()}-${renderTrigger}`);
|
|
292
|
+
})
|
|
293
|
+
})]
|
|
294
|
+
})]
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
FileUpload.displayName = 'FileUpload';
|
|
298
|
+
FileUpload.propTypes = {
|
|
299
|
+
...selectedSystemPropTypes,
|
|
300
|
+
tokens: (0, _utils.getTokensPropType)('FileUpload'),
|
|
301
|
+
variant: _utils.variantProp.propType,
|
|
302
|
+
/**
|
|
303
|
+
* To define the locale of the copy
|
|
304
|
+
*/
|
|
305
|
+
copy: _utils.copyPropTypes,
|
|
306
|
+
/**
|
|
307
|
+
* The file types allowed for upload. Example: fileTypes={['pdf', 'docx']}.
|
|
308
|
+
*/
|
|
309
|
+
fileTypes: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
310
|
+
/**
|
|
311
|
+
* Whether to allow multiple files to be uploaded.
|
|
312
|
+
*/
|
|
313
|
+
allowMultipleFiles: _propTypes.default.bool,
|
|
314
|
+
/**
|
|
315
|
+
* The maximum file size allowed for upload in MB.
|
|
316
|
+
*/
|
|
317
|
+
maxFileSize: _propTypes.default.number,
|
|
318
|
+
/**
|
|
319
|
+
* The maximum number of files allowed for upload.
|
|
320
|
+
*/
|
|
321
|
+
maxFilesCount: _propTypes.default.number,
|
|
322
|
+
/**
|
|
323
|
+
* Callback function called when a file is uploaded.
|
|
324
|
+
*/
|
|
325
|
+
onUpload: _propTypes.default.func,
|
|
326
|
+
/**
|
|
327
|
+
* Callback function called when a file is deleted
|
|
328
|
+
*/
|
|
329
|
+
onDelete: _propTypes.default.func,
|
|
330
|
+
/**
|
|
331
|
+
* The document picker to use for mobile
|
|
332
|
+
*/
|
|
333
|
+
documentPicker: _propTypes.default.object
|
|
334
|
+
};
|
|
335
|
+
var _default = FileUpload;
|
|
336
|
+
exports.default = _default;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _Typography = _interopRequireDefault(require("../Typography"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
/**
|
|
13
|
+
* Renders the content of a notification for a file upload.
|
|
14
|
+
*
|
|
15
|
+
* @component
|
|
16
|
+
* @param {Object} props - The component props.
|
|
17
|
+
* @param {Object} props.file - The file object.
|
|
18
|
+
* @param {string} props.children - The content to be displayed.
|
|
19
|
+
* @param {string} props.color - The color of the typography.
|
|
20
|
+
* @param {React.Ref} ref - The ref to be forwarded to the Typography component.
|
|
21
|
+
* @returns {JSX.Element} The rendered NotificationContent component.
|
|
22
|
+
*/const NotificationContent = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
23
|
+
let {
|
|
24
|
+
file,
|
|
25
|
+
color,
|
|
26
|
+
children
|
|
27
|
+
} = _ref;
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
29
|
+
tokens: {
|
|
30
|
+
color
|
|
31
|
+
},
|
|
32
|
+
ref: ref,
|
|
33
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
34
|
+
variant: {
|
|
35
|
+
bold: true
|
|
36
|
+
},
|
|
37
|
+
tokens: {
|
|
38
|
+
color
|
|
39
|
+
},
|
|
40
|
+
children: file.name
|
|
41
|
+
}), children]
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
NotificationContent.displayName = 'NotificationContent';
|
|
45
|
+
NotificationContent.propTypes = {
|
|
46
|
+
/**
|
|
47
|
+
* The file object.
|
|
48
|
+
*/
|
|
49
|
+
file: _propTypes.default.object,
|
|
50
|
+
/**
|
|
51
|
+
* The content to be displayed.
|
|
52
|
+
*/
|
|
53
|
+
children: _propTypes.default.string,
|
|
54
|
+
/**
|
|
55
|
+
* The color of the typography.
|
|
56
|
+
*/
|
|
57
|
+
color: _propTypes.default.string
|
|
58
|
+
};
|
|
59
|
+
var _default = NotificationContent;
|
|
60
|
+
exports.default = _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
en: {
|
|
9
|
+
label: 'Upload files',
|
|
10
|
+
buttonLabel: 'Choose files',
|
|
11
|
+
dismissButtonLabel: 'Remove file',
|
|
12
|
+
wrongFileType: 'The selected file must be a %{fileType}.',
|
|
13
|
+
allowedFileTypes: 'Allowed file types: %{fileTypes}.',
|
|
14
|
+
fileTooBig: 'The selected file must be smaller than %{size}MB.',
|
|
15
|
+
fileIsEmpty: 'The selected file is empty.',
|
|
16
|
+
problemUploading: 'The selected file could not be uploaded. Try again.',
|
|
17
|
+
problemDeleting: 'The selected file could not be deleted. Try again.',
|
|
18
|
+
problemUploadingMultipleFiles: 'The selected files could not be uploaded. Try again.',
|
|
19
|
+
only: 'only',
|
|
20
|
+
and: 'and',
|
|
21
|
+
or: 'or',
|
|
22
|
+
uploadSuccess: 'uploaded successfully.',
|
|
23
|
+
uploadError: 'was not uploaded due to',
|
|
24
|
+
deleteProblem: 'was not deleted due to',
|
|
25
|
+
tooManyFiles: 'You can only select up to %{maxFilesCount} files at the same time.'
|
|
26
|
+
},
|
|
27
|
+
fr: {
|
|
28
|
+
label: 'Téléverser les fichiers"',
|
|
29
|
+
buttonLabel: 'Choisir les fichiers',
|
|
30
|
+
dismissButtonLabel: 'Supprimer le fichier',
|
|
31
|
+
wrongFileType: 'Le fichier sélectionné doit être au format %{fileType}.',
|
|
32
|
+
allowedFileTypes: 'Formats de fichiers autorisés : %{fileTypes}.',
|
|
33
|
+
fileTooBig: 'Le fichier sélectionné doit être inférieur à %{size}Mo.',
|
|
34
|
+
fileIsEmpty: 'Le fichier sélectionné est vide.',
|
|
35
|
+
problemUploading: 'Impossible de téléverser le fichier sélectionné. Veuillez réessayer.',
|
|
36
|
+
problemDeleting: `Le fichier sélectionné n'a pas pu être supprimé. Réessayez.`,
|
|
37
|
+
problemUploadingMultipleFiles: `Les fichiers sélectionnés n'ont pas pu être téléchargés. Veuillez réessayer.`,
|
|
38
|
+
only: 'uniquement',
|
|
39
|
+
and: 'et',
|
|
40
|
+
or: 'ou',
|
|
41
|
+
uploadSuccess: 'téléchargé avec succès.',
|
|
42
|
+
uploadError: `n'a pas été téléchargé en raison de`,
|
|
43
|
+
deleteProblem: `n'a pas été supprimé en raison de`,
|
|
44
|
+
tooManyFiles: `Vous ne pouvez sélectionner que jusqu'à %{maxFilesCount} fichiers en même temps.`
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.default = _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _FileUpload = _interopRequireDefault(require("./FileUpload"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var _default = _FileUpload.default;
|
|
10
|
+
exports.default = _default;
|
package/lib/Link/TextButton.js
CHANGED
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
10
|
-
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
9
|
var _ThemeProvider = require("../ThemeProvider");
|
|
12
10
|
var _LinkBase = _interopRequireDefault(require("./LinkBase"));
|
|
13
11
|
var _utils = require("../utils");
|
|
@@ -27,23 +25,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
27
25
|
...linkProps
|
|
28
26
|
} = _ref;
|
|
29
27
|
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('Link', tokens, variant);
|
|
30
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
...linkProps,
|
|
38
|
-
children: children
|
|
39
|
-
})
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LinkBase.default, {
|
|
29
|
+
onPress: onPress,
|
|
30
|
+
accessibilityRole: accessibilityRole,
|
|
31
|
+
tokens: getTokens,
|
|
32
|
+
ref: ref,
|
|
33
|
+
...linkProps,
|
|
34
|
+
children: children
|
|
40
35
|
});
|
|
41
36
|
});
|
|
42
|
-
const styles = _StyleSheet.default.create({
|
|
43
|
-
textButton: {
|
|
44
|
-
flex: 1
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
37
|
TextButton.displayName = 'TextButton';
|
|
48
38
|
TextButton.propTypes = {
|
|
49
39
|
..._LinkBase.default.propTypes,
|
|
@@ -141,12 +141,15 @@ const ModalContent = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
141
141
|
},
|
|
142
142
|
onPress: onConfirm,
|
|
143
143
|
children: confirmButtonText
|
|
144
|
-
}), hasCancelButton ? /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
}), hasCancelButton ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
145
|
+
style: styles.cancelButton,
|
|
146
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CancelButton, {
|
|
147
|
+
tokens: {
|
|
148
|
+
color: cancelButtonColor
|
|
149
|
+
},
|
|
150
|
+
onPress: onCancel,
|
|
151
|
+
children: cancelButtonText
|
|
152
|
+
})
|
|
150
153
|
}) : null]
|
|
151
154
|
})]
|
|
152
155
|
});
|
|
@@ -157,6 +160,9 @@ const styles = _StyleSheet.default.create({
|
|
|
157
160
|
flex: 1,
|
|
158
161
|
flexDirection: 'column',
|
|
159
162
|
minHeight: _Platform.default.OS === 'web' ? '100%' : 'auto'
|
|
163
|
+
},
|
|
164
|
+
cancelButton: {
|
|
165
|
+
flex: 1
|
|
160
166
|
}
|
|
161
167
|
});
|
|
162
168
|
ModalContent.propTypes = {
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
10
10
|
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
12
|
var _portal = require("@gorhom/portal");
|
|
12
13
|
var _utils = require("../utils");
|
|
13
14
|
var _ViewportProvider = require("../ViewportProvider");
|
|
@@ -21,10 +22,32 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
21
22
|
positioner: {
|
|
22
23
|
flex: 1,
|
|
23
24
|
// Grow to maxWidth when possible, shrink when not possible
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
zIndex: 10000,
|
|
26
|
+
// Position on top of all the other overlays, including backdrops and modals,
|
|
27
|
+
elevation: 10000,
|
|
28
|
+
// Position on top of all the other overlays, including backdrops and modals,
|
|
29
|
+
borderRadius: 4,
|
|
30
|
+
..._Platform.default.select({
|
|
31
|
+
web: {
|
|
32
|
+
boxShadow: 'rgba(0, 0, 0, 0.1) 0px 4px 8px 0px'
|
|
33
|
+
},
|
|
34
|
+
default: {
|
|
35
|
+
shadowColor: 'rgba(0, 0, 0, 0.1)',
|
|
36
|
+
shadowOffset: {
|
|
37
|
+
width: 0,
|
|
38
|
+
height: 4
|
|
39
|
+
},
|
|
40
|
+
shadowOpacity: 1,
|
|
41
|
+
shadowRadius: 8
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
},
|
|
45
|
+
card: {
|
|
46
|
+
paddingLeft: 0,
|
|
47
|
+
paddingRight: 0,
|
|
48
|
+
paddingTop: 0,
|
|
49
|
+
paddingBottom: 0
|
|
26
50
|
},
|
|
27
|
-
|
|
28
51
|
closeButtonContainer: {
|
|
29
52
|
position: 'absolute',
|
|
30
53
|
top: 0,
|
|
@@ -37,6 +60,17 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
37
60
|
opacity: 0
|
|
38
61
|
}
|
|
39
62
|
});
|
|
63
|
+
const selectContainerStyle = (enableFullscreen, themeTokens) => ({
|
|
64
|
+
borderColor: themeTokens.borderColor,
|
|
65
|
+
..._Platform.default.select({
|
|
66
|
+
web: {
|
|
67
|
+
position: enableFullscreen ? 'fixed' : 'absolute'
|
|
68
|
+
},
|
|
69
|
+
default: {
|
|
70
|
+
position: 'absolute'
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
});
|
|
40
74
|
const selectCloseButtonContainerStyles = _ref => {
|
|
41
75
|
let {
|
|
42
76
|
paddingRight,
|
|
@@ -47,20 +81,7 @@ const selectCloseButtonContainerStyles = _ref => {
|
|
|
47
81
|
paddingTop
|
|
48
82
|
};
|
|
49
83
|
};
|
|
50
|
-
const
|
|
51
|
-
let {
|
|
52
|
-
paddingTop,
|
|
53
|
-
paddingLeft,
|
|
54
|
-
paddingRight
|
|
55
|
-
} = _ref2;
|
|
56
|
-
return {
|
|
57
|
-
paddingBottom: 35,
|
|
58
|
-
paddingTop,
|
|
59
|
-
paddingLeft,
|
|
60
|
-
paddingRight
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
const ModalOverlay = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
84
|
+
const ModalOverlay = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
64
85
|
let {
|
|
65
86
|
children,
|
|
66
87
|
isReady = false,
|
|
@@ -74,22 +95,19 @@ const ModalOverlay = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
74
95
|
variant,
|
|
75
96
|
tokens,
|
|
76
97
|
copy,
|
|
77
|
-
onClose
|
|
78
|
-
|
|
98
|
+
onClose,
|
|
99
|
+
enableFullscreen = false
|
|
100
|
+
} = _ref2;
|
|
79
101
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
80
102
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Modal', tokens, variant, {
|
|
81
103
|
viewport,
|
|
82
104
|
maxWidth: false
|
|
83
105
|
});
|
|
84
106
|
const containerWidthHeight = {
|
|
85
|
-
minWidth,
|
|
86
|
-
minHeight,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}),
|
|
90
|
-
...(maxHeight && maxHeightSize && {
|
|
91
|
-
maxHeight: maxHeightSize
|
|
92
|
-
})
|
|
107
|
+
minWidth: tokens.maxWidth ? maxWidthSize : minWidth,
|
|
108
|
+
minHeight: maxHeight ? maxHeightSize : minHeight,
|
|
109
|
+
maxWidth: maxWidthSize,
|
|
110
|
+
maxHeight: maxHeightSize
|
|
93
111
|
};
|
|
94
112
|
const {
|
|
95
113
|
closeIcon: CloseIconComponent
|
|
@@ -103,9 +121,9 @@ const ModalOverlay = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
103
121
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
104
122
|
ref: ref,
|
|
105
123
|
onLayout: onLayout,
|
|
106
|
-
style: [overlaidPosition, containerWidthHeight, staticStyles.positioner, !isReady && staticStyles.hidden],
|
|
124
|
+
style: [overlaidPosition, containerWidthHeight, staticStyles.positioner, !isReady && staticStyles.hidden, selectContainerStyle(enableFullscreen, themeTokens)],
|
|
107
125
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Card.default, {
|
|
108
|
-
tokens:
|
|
126
|
+
tokens: staticStyles.card,
|
|
109
127
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
110
128
|
style: [staticStyles.closeButtonContainer, selectCloseButtonContainerStyles(themeTokens)],
|
|
111
129
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
@@ -138,7 +156,8 @@ ModalOverlay.propTypes = {
|
|
|
138
156
|
variant: _utils.variantProp.propType,
|
|
139
157
|
tokens: (0, _utils.getTokensPropType)('Modal'),
|
|
140
158
|
copy: _utils.copyPropTypes,
|
|
141
|
-
onClose: _propTypes.default.func
|
|
159
|
+
onClose: _propTypes.default.func,
|
|
160
|
+
enableFullscreen: _propTypes.default.bool
|
|
142
161
|
};
|
|
143
162
|
var _default = ModalOverlay;
|
|
144
163
|
exports.default = _default;
|