@telus-uds/components-base 1.93.0 → 1.95.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +32 -3
  2. package/lib/Autocomplete/Autocomplete.js +2 -1
  3. package/lib/Button/ButtonGroup.js +17 -1
  4. package/lib/Card/Card.js +12 -0
  5. package/lib/Card/CardBase.js +37 -2
  6. package/lib/Carousel/Carousel.js +55 -13
  7. package/lib/Carousel/CarouselItem/CarouselItem.js +86 -12
  8. package/lib/DownloadApp/DownloadApp.js +168 -0
  9. package/lib/DownloadApp/dictionary.js +17 -0
  10. package/lib/DownloadApp/index.js +10 -0
  11. package/lib/Fieldset/FieldsetContainer.js +7 -2
  12. package/lib/Fieldset/FieldsetContainer.native.js +4 -1
  13. package/lib/FileUpload/FileUpload.js +336 -0
  14. package/lib/FileUpload/NotificationContent.js +60 -0
  15. package/lib/FileUpload/dictionary.js +47 -0
  16. package/lib/FileUpload/index.js +10 -0
  17. package/lib/Icon/IconText.js +19 -2
  18. package/lib/Link/LinkBase.js +2 -2
  19. package/lib/Link/TextButton.js +7 -17
  20. package/lib/Modal/Modal.js +1 -1
  21. package/lib/Modal/ModalContent.js +12 -6
  22. package/lib/MultiSelectFilter/ModalOverlay.js +49 -30
  23. package/lib/MultiSelectFilter/MultiSelectFilter.js +170 -131
  24. package/lib/Notification/Notification.js +11 -2
  25. package/lib/Status/Status.js +9 -4
  26. package/lib/TabBar/TabBar.js +133 -0
  27. package/lib/TabBar/TabBarItem.js +184 -0
  28. package/lib/TabBar/index.js +10 -0
  29. package/lib/TextInput/TextInputBase.js +2 -1
  30. package/lib/Tooltip/getTooltipPosition.js +8 -9
  31. package/lib/index.js +24 -0
  32. package/lib/utils/convertFromMegaByteToByte.js +16 -0
  33. package/lib/utils/formatImageSource.js +34 -0
  34. package/lib/utils/index.js +17 -1
  35. package/lib-module/Autocomplete/Autocomplete.js +2 -1
  36. package/lib-module/Button/ButtonGroup.js +17 -1
  37. package/lib-module/Card/Card.js +13 -1
  38. package/lib-module/Card/CardBase.js +38 -3
  39. package/lib-module/Carousel/Carousel.js +55 -13
  40. package/lib-module/Carousel/CarouselItem/CarouselItem.js +86 -12
  41. package/lib-module/DownloadApp/DownloadApp.js +160 -0
  42. package/lib-module/DownloadApp/dictionary.js +10 -0
  43. package/lib-module/DownloadApp/index.js +2 -0
  44. package/lib-module/Fieldset/FieldsetContainer.js +7 -2
  45. package/lib-module/Fieldset/FieldsetContainer.native.js +4 -1
  46. package/lib-module/FileUpload/FileUpload.js +329 -0
  47. package/lib-module/FileUpload/NotificationContent.js +55 -0
  48. package/lib-module/FileUpload/dictionary.js +40 -0
  49. package/lib-module/FileUpload/index.js +2 -0
  50. package/lib-module/Icon/IconText.js +19 -2
  51. package/lib-module/Link/LinkBase.js +2 -2
  52. package/lib-module/Link/TextButton.js +7 -17
  53. package/lib-module/Modal/Modal.js +1 -1
  54. package/lib-module/Modal/ModalContent.js +12 -6
  55. package/lib-module/MultiSelectFilter/ModalOverlay.js +49 -30
  56. package/lib-module/MultiSelectFilter/MultiSelectFilter.js +171 -132
  57. package/lib-module/Notification/Notification.js +11 -2
  58. package/lib-module/Status/Status.js +9 -4
  59. package/lib-module/TabBar/TabBar.js +125 -0
  60. package/lib-module/TabBar/TabBarItem.js +177 -0
  61. package/lib-module/TabBar/index.js +2 -0
  62. package/lib-module/TextInput/TextInputBase.js +2 -1
  63. package/lib-module/Tooltip/getTooltipPosition.js +8 -9
  64. package/lib-module/index.js +3 -0
  65. package/lib-module/utils/convertFromMegaByteToByte.js +10 -0
  66. package/lib-module/utils/formatImageSource.js +27 -0
  67. package/lib-module/utils/index.js +3 -1
  68. package/package.json +4 -3
  69. package/src/Autocomplete/Autocomplete.jsx +2 -1
  70. package/src/Button/ButtonGroup.jsx +9 -1
  71. package/src/Card/Card.jsx +18 -2
  72. package/src/Card/CardBase.jsx +47 -12
  73. package/src/Carousel/Carousel.jsx +59 -13
  74. package/src/Carousel/CarouselItem/CarouselItem.jsx +94 -9
  75. package/src/DownloadApp/DownloadApp.jsx +165 -0
  76. package/src/DownloadApp/dictionary.js +10 -0
  77. package/src/DownloadApp/index.js +3 -0
  78. package/src/Fieldset/FieldsetContainer.jsx +4 -3
  79. package/src/Fieldset/FieldsetContainer.native.jsx +9 -6
  80. package/src/FileUpload/FileUpload.jsx +396 -0
  81. package/src/FileUpload/NotificationContent.jsx +44 -0
  82. package/src/FileUpload/dictionary.js +40 -0
  83. package/src/FileUpload/index.js +3 -0
  84. package/src/Icon/IconText.jsx +21 -4
  85. package/src/Link/LinkBase.jsx +2 -2
  86. package/src/Link/TextButton.jsx +10 -17
  87. package/src/Modal/Modal.jsx +1 -1
  88. package/src/Modal/ModalContent.jsx +8 -3
  89. package/src/MultiSelectFilter/ModalOverlay.jsx +44 -18
  90. package/src/MultiSelectFilter/MultiSelectFilter.jsx +188 -126
  91. package/src/Notification/Notification.jsx +12 -4
  92. package/src/Status/Status.jsx +15 -4
  93. package/src/TabBar/TabBar.jsx +123 -0
  94. package/src/TabBar/TabBarItem.jsx +149 -0
  95. package/src/TabBar/index.js +3 -0
  96. package/src/TextInput/TextInputBase.jsx +1 -1
  97. package/src/Tooltip/getTooltipPosition.js +11 -12
  98. package/src/index.js +3 -0
  99. package/src/utils/convertFromMegaByteToByte.js +11 -0
  100. package/src/utils/formatImageSource.js +29 -0
  101. package/src/utils/index.js +2 -0
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _DownloadApp = _interopRequireDefault(require("./DownloadApp"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var _default = _DownloadApp.default;
10
+ exports.default = _default;
@@ -23,6 +23,7 @@ const FieldsetContainer = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
23
23
  name: fieldsetName,
24
24
  showBorderStyle = false,
25
25
  borderStyle,
26
+ style,
26
27
  ...rest
27
28
  } = _ref;
28
29
  // If needs border for error design or reset the component style
@@ -30,7 +31,10 @@ const FieldsetContainer = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
30
31
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("fieldset", {
31
32
  ref: ref,
32
33
  disabled: inactive,
33
- style: styleContainer,
34
+ style: {
35
+ ...styleContainer,
36
+ ...style
37
+ },
34
38
  role: accessibilityRole,
35
39
  name: fieldsetName,
36
40
  ...selectProps(rest),
@@ -45,7 +49,8 @@ FieldsetContainer.propTypes = {
45
49
  inactive: _propTypes.default.bool,
46
50
  name: _propTypes.default.string,
47
51
  showBorderStyle: _propTypes.default.bool,
48
- borderStyle: _propTypes.default.object
52
+ borderStyle: _propTypes.default.object,
53
+ style: _propTypes.default.object
49
54
  };
50
55
  var _default = FieldsetContainer;
51
56
  exports.default = _default;
@@ -18,12 +18,14 @@ const FieldsetContainer = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
18
18
  let {
19
19
  children,
20
20
  accessibilityRole,
21
+ style,
21
22
  ...rest
22
23
  } = _ref;
23
24
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
24
25
  ref: ref,
25
26
  accessibilityRole: accessibilityRole,
26
27
  ...selectProps(rest),
28
+ style: style,
27
29
  children: children
28
30
  });
29
31
  });
@@ -31,7 +33,8 @@ FieldsetContainer.displayName = 'FieldsetContainer';
31
33
  FieldsetContainer.propTypes = {
32
34
  ...selectedSystemPropTypes,
33
35
  children: _propTypes.default.node,
34
- accessibilityRole: _propTypes.default.string
36
+ accessibilityRole: _propTypes.default.string,
37
+ style: _propTypes.default.object
35
38
  };
36
39
  var _default = FieldsetContainer;
37
40
  exports.default = _default;
@@ -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;
@@ -8,6 +8,8 @@ var _react = _interopRequireDefault(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
10
10
  var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
11
+ var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
12
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
11
13
  var _Icon = _interopRequireWildcard(require("./Icon"));
12
14
  var _StackView = require("../StackView");
13
15
  var _utils = require("../utils");
@@ -66,6 +68,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
66
68
  });
67
69
  const mobile = _Platform.default.OS === 'android' ? iconAdjustedAndroid : iconAdjustedIOS;
68
70
  const adjustedContainer = _Platform.default.OS === 'web' ? iconContent : mobile;
71
+ const adjustedContainerWithPosition = /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
72
+ style: staticStyles.adjustedContainer,
73
+ children: adjustedContainer
74
+ });
75
+ if (iconPosition === 'inline') {
76
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Text.default, {
77
+ children: [children, " ", adjustedContainerWithPosition]
78
+ });
79
+ }
69
80
  return (0, _StackView.getStackedContent)(iconPosition === 'left' ? [adjustedContainer, children] : [children, adjustedContainer], {
70
81
  space,
71
82
  direction: 'row'
@@ -80,9 +91,9 @@ IconText.propTypes = {
80
91
  */
81
92
  space: _utils.spacingProps.types.spacingValue,
82
93
  /**
83
- * Whether the icon should be to the left of the content or the right of the content.
94
+ * Whether the icon should be to the left of the content, the right of the content or inline with the content.
84
95
  */
85
- iconPosition: _propTypes.default.oneOf(['left', 'right']),
96
+ iconPosition: _propTypes.default.oneOf(['left', 'right', 'inline']),
86
97
  /**
87
98
  * A valid UDS icon component imported from a UDS palette.
88
99
  */
@@ -100,5 +111,11 @@ IconText.propTypes = {
100
111
  children: _propTypes.default.node
101
112
  /* eslint-enable react/no-unused-prop-types */
102
113
  };
114
+
115
+ const staticStyles = _StyleSheet.default.create({
116
+ adjustedContainer: {
117
+ position: 'absolute'
118
+ }
119
+ });
103
120
  var _default = IconText;
104
121
  exports.default = _default;
@@ -245,9 +245,9 @@ LinkBase.propTypes = {
245
245
  */
246
246
  icon: _propTypes.default.elementType,
247
247
  /**
248
- * When `icon` is provided, use `iconPosition` to place the Icon to the left or right side of Link.
248
+ * When `icon` is provided, use `iconPosition` to place the Icon to the left, right or inline with Link.
249
249
  */
250
- iconPosition: _propTypes.default.oneOf(['left', 'right']),
250
+ iconPosition: _propTypes.default.oneOf(['left', 'right', 'inline']),
251
251
  /**
252
252
  * On Web if href is passed, React Native Web maps this object's props to
253
253
  * `rel`, `target` and `download` attrs.
@@ -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)(_View.default, {
31
- style: styles.textButton,
32
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LinkBase.default, {
33
- onPress: onPress,
34
- accessibilityRole: accessibilityRole,
35
- tokens: getTokens,
36
- ref: ref,
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,
@@ -158,7 +158,7 @@ const Modal = /*#__PURE__*/_react.default.forwardRef((_ref5, ref) => {
158
158
  if (_Platform.default.OS === 'web') {
159
159
  const handleFocus = () => {
160
160
  // If the focus is on the last item of the web modal container, move it to the close button
161
- if (document.activeElement === focusTrapRef.current) {
161
+ if (document.activeElement === focusTrapRef.current && closeButtonRef.current) {
162
162
  closeButtonRef.current.focus();
163
163
  }
164
164
  return undefined;
@@ -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)(CancelButton, {
145
- tokens: {
146
- color: cancelButtonColor
147
- },
148
- onPress: onCancel,
149
- children: cancelButtonText
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 = {