@muraldevkit/ui-toolkit 4.75.0 → 4.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/file-upload/MrlFileUpload/MrlFileUpload.js +404 -0
- package/dist/cjs/components/file-upload/MrlFileUpload/MrlFileUpload.js.map +1 -0
- package/dist/cjs/components/file-upload/MrlFileUpload/MrlFileUpload.module.scss.js +8 -0
- package/dist/cjs/components/file-upload/MrlFileUpload/MrlFileUpload.module.scss.js.map +1 -0
- package/dist/cjs/components/file-upload/constants.js +48 -0
- package/dist/cjs/components/file-upload/constants.js.map +1 -0
- package/dist/cjs/components/file-upload/helpers.js +67 -0
- package/dist/cjs/components/file-upload/helpers.js.map +1 -0
- package/dist/cjs/index.js +37 -31
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/components/file-upload/MrlFileUpload/MrlFileUpload.d.ts +154 -0
- package/dist/components/file-upload/MrlFileUpload/index.d.ts +1 -0
- package/dist/components/file-upload/constants.d.ts +35 -0
- package/dist/components/file-upload/helpers.d.ts +35 -0
- package/dist/components/file-upload/index.d.ts +2 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/esm/components/file-upload/MrlFileUpload/MrlFileUpload.js +379 -0
- package/dist/esm/components/file-upload/MrlFileUpload/MrlFileUpload.js.map +1 -0
- package/dist/esm/components/file-upload/MrlFileUpload/MrlFileUpload.module.scss.js +4 -0
- package/dist/esm/components/file-upload/MrlFileUpload/MrlFileUpload.module.scss.js.map +1 -0
- package/dist/esm/components/file-upload/constants.js +44 -0
- package/dist/esm/components/file-upload/constants.js.map +1 -0
- package/dist/esm/components/file-upload/helpers.js +62 -0
- package/dist/esm/components/file-upload/helpers.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/styles/MrlFileUpload/module.scss +136 -0
- package/dist/styles/file-upload/variables.scss +13 -0
- package/dist/styles.css +1 -0
- package/dist/types/components/file-upload/MrlFileUpload/MrlFileUpload.d.ts +154 -0
- package/dist/types/components/file-upload/MrlFileUpload/index.d.ts +1 -0
- package/dist/types/components/file-upload/constants.d.ts +35 -0
- package/dist/types/components/file-upload/helpers.d.ts +35 -0
- package/dist/types/components/file-upload/index.d.ts +2 -0
- package/dist/types/components/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../../src/components/file-upload/helpers.ts"],"sourcesContent":["/**\n * Matches a file against an `accept` string (extensions and/or MIME types).\n *\n * The native `accept` attribute only filters the file picker; a dropped file\n * bypasses it entirely, so the same rules have to be applied in code.\n *\n * @param file - the file to test\n * @param accept - native `accept` syntax, e.g. '.png,image/*'\n * @returns whether the file matches the accept rules\n */\nexport function isAccepted(file: File, accept: string): boolean {\n\tconst rules = accept\n\t\t.split(',')\n\t\t.map((rule) => rule.trim().toLowerCase())\n\t\t.filter(Boolean);\n\n\tif (rules.length === 0) return true;\n\n\tconst name = file.name.toLowerCase();\n\tconst type = file.type.toLowerCase();\n\n\treturn rules.some((rule) => {\n\t\tif (rule.startsWith('.')) return name.endsWith(rule);\n\t\tif (rule.endsWith('/*')) return type.startsWith(rule.slice(0, -1));\n\t\treturn type === rule;\n\t});\n}\n\n/**\n * Formats a byte count for display in a validation message.\n *\n * @param bytes - the size in bytes\n * @returns a short human-readable size, e.g. '2.5 MB'\n */\nexport function formatBytes(bytes: number): string {\n\tif (bytes < 1024) return `${bytes} B`;\n\tif (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n\treturn `${Math.round((bytes / (1024 * 1024)) * 10) / 10} MB`;\n}\n\n/**\n * Lists the file types an `accept` string permits, for display.\n *\n * @param accept - native `accept` syntax, e.g. '.png,image/*'\n * @returns a comma-separated list, or an empty string if nothing is restricted\n */\nexport function formatAcceptList(accept: string): string {\n\treturn accept\n\t\t.split(',')\n\t\t.map((rule) => rule.trim())\n\t\t.filter(Boolean)\n\t\t.join(', ');\n}\n\n/**\n * Describes the constraints the component actually enforces, for use as helper\n * text. Deriving the sentence from `accept` and `maxSizeBytes` is what keeps it\n * from contradicting what validation rejects.\n *\n * @param accept - native `accept` syntax, e.g. '.png,image/*'\n * @param maxSizeBytes - the size limit in bytes, if there is one\n * @returns a sentence describing what may be uploaded, or an empty string\n */\nexport function describeConstraints(accept: string, maxSizeBytes?: number): string {\n\tconst types = formatAcceptList(accept);\n\tconst limit = maxSizeBytes !== undefined ? `up to ${formatBytes(maxSizeBytes)}` : '';\n\n\tif (!types) return limit ? `Accepts any file ${limit}` : '';\n\n\treturn limit ? `Accepts ${types} ${limit}` : `Accepts ${types}`;\n}\n"],"names":["isAccepted","file","accept","rules","split","map","rule","trim","toLowerCase","filter","Boolean","length","name","type","some","startsWith","endsWith","slice","formatBytes","bytes","concat","Math","round","formatAcceptList","join","describeConstraints","maxSizeBytes","types","limit","undefined"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,UAAUA,CAACC,IAAU,EAAEC,MAAc,EAAW;EAC/D,IAAMC,KAAK,GAAGD,MAAM,CAClBE,KAAK,CAAC,GAAG,CAAC,CACVC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,IAAI,EAAE,CAACC,WAAW,EAAE,CAAC,CACxCC,MAAM,CAACC,OAAO,CAAC;AAEjB,EAAA,IAAIP,KAAK,CAACQ,MAAM,KAAK,CAAC,EAAE,OAAO,IAAI;EAEnC,IAAMC,IAAI,GAAGX,IAAI,CAACW,IAAI,CAACJ,WAAW,EAAE;EACpC,IAAMK,IAAI,GAAGZ,IAAI,CAACY,IAAI,CAACL,WAAW,EAAE;AAEpC,EAAA,OAAOL,KAAK,CAACW,IAAI,CAAER,IAAI,IAAK;AAC3B,IAAA,IAAIA,IAAI,CAACS,UAAU,CAAC,GAAG,CAAC,EAAE,OAAOH,IAAI,CAACI,QAAQ,CAACV,IAAI,CAAC;IACpD,IAAIA,IAAI,CAACU,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAOH,IAAI,CAACE,UAAU,CAACT,IAAI,CAACW,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClE,OAAOJ,IAAI,KAAKP,IAAI;AACrB,EAAA,CAAC,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASY,WAAWA,CAACC,KAAa,EAAU;AAClD,EAAA,IAAIA,KAAK,GAAG,IAAI,EAAE,OAAA,EAAA,CAAAC,MAAA,CAAUD,KAAK,EAAA,IAAA,CAAA;AACjC,EAAA,IAAIA,KAAK,GAAG,IAAI,GAAG,IAAI,EAAE,OAAA,EAAA,CAAAC,MAAA,CAAUC,IAAI,CAACC,KAAK,CAACH,KAAK,GAAG,IAAI,CAAC,EAAA,KAAA,CAAA;AAC3D,EAAA,OAAA,EAAA,CAAAC,MAAA,CAAUC,IAAI,CAACC,KAAK,CAAEH,KAAK,IAAI,IAAI,GAAG,IAAI,CAAC,GAAI,EAAE,CAAC,GAAG,EAAE,EAAA,KAAA,CAAA;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,gBAAgBA,CAACrB,MAAc,EAAU;EACxD,OAAOA,MAAM,CACXE,KAAK,CAAC,GAAG,CAAC,CACVC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,IAAI,EAAE,CAAC,CAC1BE,MAAM,CAACC,OAAO,CAAC,CACfc,IAAI,CAAC,IAAI,CAAC;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,mBAAmBA,CAACvB,MAAc,EAAEwB,YAAqB,EAAU;AAClF,EAAA,IAAMC,KAAK,GAAGJ,gBAAgB,CAACrB,MAAM,CAAC;AACtC,EAAA,IAAM0B,KAAK,GAAGF,YAAY,KAAKG,SAAS,GAAA,QAAA,CAAAT,MAAA,CAAYF,WAAW,CAACQ,YAAY,CAAC,IAAK,EAAE;EAEpF,IAAI,CAACC,KAAK,EAAE,OAAOC,KAAK,uBAAAR,MAAA,CAAuBQ,KAAK,CAAA,GAAK,EAAE;AAE3D,EAAA,OAAOA,KAAK,GAAA,UAAA,CAAAR,MAAA,CAAcO,KAAK,EAAA,GAAA,CAAA,CAAAP,MAAA,CAAIQ,KAAK,CAAA,GAAA,UAAA,CAAAR,MAAA,CAAgBO,KAAK,CAAE;AAChE;;;;;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var MrlCreatableSelect = require('./components/form/select/MrlCreatableSelect/MrlCreatableSelect.js');
|
|
4
|
+
var constants = require('./components/file-upload/constants.js');
|
|
4
5
|
var MrlProcessingButton = require('./components/button/MrlProcessingButton/MrlProcessingButton.js');
|
|
5
6
|
var index = require('./utils/trapFocus/index.js');
|
|
6
7
|
var MrlPortal = require('./components/portal/MrlPortal.js');
|
|
@@ -33,6 +34,7 @@ var MrlEmptyLarge = require('./components/empty/large/MrlEmptyLarge.js');
|
|
|
33
34
|
var MrlErrorBoundary = require('./components/error-boundary/MrlErrorBoundary.js');
|
|
34
35
|
var MrlErrorPage = require('./components/layout/error-page/MrlErrorPage/MrlErrorPage.js');
|
|
35
36
|
var MrlFieldset = require('./components/form/fieldset/MrlFieldset/MrlFieldset.js');
|
|
37
|
+
var MrlFileUpload = require('./components/file-upload/MrlFileUpload/MrlFileUpload.js');
|
|
36
38
|
var MrlFilter = require('./components/filter/MrlFilter/MrlFilter.js');
|
|
37
39
|
var MrlFilterContext = require('./components/filter/MrlFilterContext/MrlFilterContext.js');
|
|
38
40
|
var MrlFilterItem = require('./components/filter/MrlFilterItem/MrlFilterItem.js');
|
|
@@ -87,7 +89,7 @@ var MrlSidebarNavItem = require('./components/navigation-sidebar/MrlSidebarNavIt
|
|
|
87
89
|
var MrlSkeleton = require('./components/skeleton/MrlSkeleton/MrlSkeleton.js');
|
|
88
90
|
var MrlSkeletonText = require('./components/skeleton/MrlSkeletonText/MrlSkeletonText.js');
|
|
89
91
|
var MrlSmartTable = require('./components/table/MrlSmartTable/MrlSmartTable.js');
|
|
90
|
-
var constants = require('./components/table/constants.js');
|
|
92
|
+
var constants$1 = require('./components/table/constants.js');
|
|
91
93
|
var MrlSpinner = require('./components/loader/MrlSpinner/MrlSpinner.js');
|
|
92
94
|
var MrlSvg = require('./components/svg/MrlSvg/MrlSvg.js');
|
|
93
95
|
var MrlSvgAnimate = require('./components/svg/MrlSvgAnimate/MrlSvgAnimate.js');
|
|
@@ -115,12 +117,12 @@ var MrlToolbar = require('./components/toolbar/MrlToolbar/MrlToolbar.js');
|
|
|
115
117
|
var MrlToolbarButton = require('./components/toolbar/MrlToolbarButton/MrlToolbarButton.js');
|
|
116
118
|
var MrlToolbarItem = require('./components/toolbar/MrlToolbarItem/MrlToolbarItem.js');
|
|
117
119
|
var MrlTooltip = require('./components/tooltip/MrlTooltip/MrlTooltip.js');
|
|
118
|
-
var constants$
|
|
120
|
+
var constants$2 = require('./components/tooltip/constants.js');
|
|
119
121
|
var MrlTopbar = require('./components/layout/MrlTopbar/MrlTopbar.js');
|
|
120
122
|
var index$3 = require('./utils/layers/index.js');
|
|
121
|
-
var constants$
|
|
122
|
-
var constants$
|
|
123
|
-
var constants$
|
|
123
|
+
var constants$3 = require('./components/modal/constants.js');
|
|
124
|
+
var constants$4 = require('./components/svg/constants.js');
|
|
125
|
+
var constants$5 = require('./components/form/constants.js');
|
|
124
126
|
var closeMenuOnScroll = require('./components/form/select/utils/closeMenuOnScroll.js');
|
|
125
127
|
var findAdjacentInteractiveElement = require('./utils/findAdjacentInteractiveElement/findAdjacentInteractiveElement.js');
|
|
126
128
|
var flipPosition = require('./components/menu/utilities/flip-position.js');
|
|
@@ -139,7 +141,7 @@ var index$6 = require('./utils/isImageUri/index.js');
|
|
|
139
141
|
var isObject = require('./utils/isObject/isObject.js');
|
|
140
142
|
var index$7 = require('./utils/noop/index.js');
|
|
141
143
|
var preventDefault = require('./utils/preventDefault/preventDefault.js');
|
|
142
|
-
var constants$
|
|
144
|
+
var constants$6 = require('./components/loader/constants.js');
|
|
143
145
|
var index$8 = require('./hooks/useBreakpoint/index.js');
|
|
144
146
|
var index$9 = require('./hooks/useCoordinate/index.js');
|
|
145
147
|
var index$a = require('./hooks/useElementDimensions/index.js');
|
|
@@ -152,6 +154,9 @@ var index$c = require('./hooks/useScrollbarInfo/index.js');
|
|
|
152
154
|
exports.CREATABLE_SELECT_CLASS_NAME_PREFIX = MrlCreatableSelect.CREATABLE_SELECT_CLASS_NAME_PREFIX;
|
|
153
155
|
exports.CREATABLE_SELECT_MENU_LIST_CLASS_NAME = MrlCreatableSelect.CREATABLE_SELECT_MENU_LIST_CLASS_NAME;
|
|
154
156
|
exports.MrlCreatableSelect = MrlCreatableSelect.MrlCreatableSelect;
|
|
157
|
+
exports.DEFAULT_ERROR_MESSAGE = constants.DEFAULT_ERROR_MESSAGE;
|
|
158
|
+
exports.allowedFileUploadValues = constants.allowedFileUploadValues;
|
|
159
|
+
exports.fileUploadDefaults = constants.fileUploadDefaults;
|
|
155
160
|
exports.DEFAULT_FEEDBACK_TIME = MrlProcessingButton.DEFAULT_FEEDBACK_TIME;
|
|
156
161
|
exports.DEFAULT_RESET_TIME = MrlProcessingButton.DEFAULT_RESET_TIME;
|
|
157
162
|
exports.MrlProcessingButton = MrlProcessingButton.MrlProcessingButton;
|
|
@@ -197,6 +202,7 @@ exports.MrlEmptyLarge = MrlEmptyLarge.MrlEmptyLarge;
|
|
|
197
202
|
exports.MrlErrorBoundary = MrlErrorBoundary.MrlErrorBoundary;
|
|
198
203
|
exports.MrlErrorPage = MrlErrorPage.MrlErrorPage;
|
|
199
204
|
exports.MrlFieldset = MrlFieldset.MrlFieldset;
|
|
205
|
+
exports.MrlFileUpload = MrlFileUpload.MrlFileUpload;
|
|
200
206
|
exports.MrlFilter = MrlFilter.MrlFilter;
|
|
201
207
|
exports.MrlFilterContextProvider = MrlFilterContext.MrlFilterContextProvider;
|
|
202
208
|
exports.useMrlFilterContext = MrlFilterContext.useMrlFilterContext;
|
|
@@ -255,7 +261,7 @@ exports.MrlSidebarNavItem = MrlSidebarNavItem.MrlSidebarNavItem;
|
|
|
255
261
|
exports.MrlSkeleton = MrlSkeleton.MrlSkeleton;
|
|
256
262
|
exports.MrlSkeletonText = MrlSkeletonText.MrlSkeletonText;
|
|
257
263
|
exports.MrlSmartTable = MrlSmartTable.MrlSmartTable;
|
|
258
|
-
exports.MrlSortDirection = constants.MrlSortDirection;
|
|
264
|
+
exports.MrlSortDirection = constants$1.MrlSortDirection;
|
|
259
265
|
exports.MrlSpinner = MrlSpinner.MrlSpinner;
|
|
260
266
|
exports.MrlSvg = MrlSvg.MrlSvg;
|
|
261
267
|
exports.MrlSvgAnimate = MrlSvgAnimate.MrlSvgAnimate;
|
|
@@ -284,31 +290,31 @@ exports.MrlToolbar = MrlToolbar.MrlToolbar;
|
|
|
284
290
|
exports.MrlToolbarButton = MrlToolbarButton.MrlToolbarButton;
|
|
285
291
|
exports.MrlToolbarItem = MrlToolbarItem.MrlToolbarItem;
|
|
286
292
|
exports.MrlTooltip = MrlTooltip.MrlTooltip;
|
|
287
|
-
exports.MrlTooltipDefaults = constants$
|
|
288
|
-
exports.allowedMrlTooltipValues = constants$
|
|
293
|
+
exports.MrlTooltipDefaults = constants$2.MrlTooltipDefaults;
|
|
294
|
+
exports.allowedMrlTooltipValues = constants$2.allowedMrlTooltipValues;
|
|
289
295
|
exports.MrlTopbar = MrlTopbar.MrlTopbar;
|
|
290
296
|
exports.PORTAL_LAYERS = index$3.PORTAL_LAYERS;
|
|
291
297
|
exports.getCurrentPortalLayer = index$3.getCurrentPortalLayer;
|
|
292
|
-
exports.TransitionDuration = constants$
|
|
293
|
-
exports.allowedValues = constants$
|
|
294
|
-
exports.defaults = constants$
|
|
295
|
-
exports.allowedAnimatedValues = constants$
|
|
296
|
-
exports.allowedSvgValues = constants$
|
|
297
|
-
exports.animatedDefaults = constants$
|
|
298
|
-
exports.baseLottieConfig = constants$
|
|
299
|
-
exports.svgDefaults = constants$
|
|
300
|
-
exports.allowedCheckboxValues = constants$
|
|
301
|
-
exports.allowedLabelValues = constants$
|
|
302
|
-
exports.allowedSelectItemValues = constants$
|
|
303
|
-
exports.allowedSelectMenuValues = constants$
|
|
304
|
-
exports.allowedSelectValues = constants$
|
|
305
|
-
exports.checkboxDefaults = constants$
|
|
306
|
-
exports.fieldsetDefault = constants$
|
|
307
|
-
exports.labelDefaults = constants$
|
|
308
|
-
exports.selectDefaults = constants$
|
|
309
|
-
exports.selectItemDefaults = constants$
|
|
310
|
-
exports.selectMenuDefaults = constants$
|
|
311
|
-
exports.textareaDefaults = constants$
|
|
298
|
+
exports.TransitionDuration = constants$3.TransitionDuration;
|
|
299
|
+
exports.allowedValues = constants$3.allowedValues;
|
|
300
|
+
exports.defaults = constants$3.defaults;
|
|
301
|
+
exports.allowedAnimatedValues = constants$4.allowedAnimatedValues;
|
|
302
|
+
exports.allowedSvgValues = constants$4.allowedSvgValues;
|
|
303
|
+
exports.animatedDefaults = constants$4.animatedDefaults;
|
|
304
|
+
exports.baseLottieConfig = constants$4.baseLottieConfig;
|
|
305
|
+
exports.svgDefaults = constants$4.svgDefaults;
|
|
306
|
+
exports.allowedCheckboxValues = constants$5.allowedCheckboxValues;
|
|
307
|
+
exports.allowedLabelValues = constants$5.allowedLabelValues;
|
|
308
|
+
exports.allowedSelectItemValues = constants$5.allowedSelectItemValues;
|
|
309
|
+
exports.allowedSelectMenuValues = constants$5.allowedSelectMenuValues;
|
|
310
|
+
exports.allowedSelectValues = constants$5.allowedSelectValues;
|
|
311
|
+
exports.checkboxDefaults = constants$5.checkboxDefaults;
|
|
312
|
+
exports.fieldsetDefault = constants$5.fieldsetDefault;
|
|
313
|
+
exports.labelDefaults = constants$5.labelDefaults;
|
|
314
|
+
exports.selectDefaults = constants$5.selectDefaults;
|
|
315
|
+
exports.selectItemDefaults = constants$5.selectItemDefaults;
|
|
316
|
+
exports.selectMenuDefaults = constants$5.selectMenuDefaults;
|
|
317
|
+
exports.textareaDefaults = constants$5.textareaDefaults;
|
|
312
318
|
exports.closeMenuOnScroll = closeMenuOnScroll.closeMenuOnScroll;
|
|
313
319
|
exports.findAdjacentInteractiveElement = findAdjacentInteractiveElement.findAdjacentInteractiveElement;
|
|
314
320
|
exports.flipPosition = flipPosition.flipPosition;
|
|
@@ -329,8 +335,8 @@ exports.isImageUri = index$6.isImageUri;
|
|
|
329
335
|
exports.isObject = isObject.isObject;
|
|
330
336
|
exports.noop = index$7.noop;
|
|
331
337
|
exports.preventDefault = preventDefault.preventDefault;
|
|
332
|
-
exports.progressBarDefaults = constants$
|
|
333
|
-
exports.spinnerDefaults = constants$
|
|
338
|
+
exports.progressBarDefaults = constants$6.progressBarDefaults;
|
|
339
|
+
exports.spinnerDefaults = constants$6.spinnerDefaults;
|
|
334
340
|
exports.useBreakpoint = index$8.useBreakpoint;
|
|
335
341
|
exports.useCoordinate = index$9.useCoordinate;
|
|
336
342
|
exports.useElementDimensions = index$a.useElementDimensions;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.76.0\";"],"names":["TOOLKIT_VERSION"],"mappings":";;AAAO,IAAMA,eAAe,GAAG;;;;"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ProgressRange } from '../../loader/constants';
|
|
3
|
+
import { DataQa } from '../../../utils/dataQa';
|
|
4
|
+
import { MrlFileUploadState } from '../constants';
|
|
5
|
+
/**
|
|
6
|
+
* The resting half of the state contract: anything but a reported failure.
|
|
7
|
+
*/
|
|
8
|
+
type MrlFileUploadRestingProps = {
|
|
9
|
+
/**
|
|
10
|
+
* Message for a failure the consumer is not currently reporting — kept across
|
|
11
|
+
* a retry, for instance. Rendered only in the error state.
|
|
12
|
+
*/
|
|
13
|
+
errorMessage?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The visual state of the zone, owned by the consumer. The component tracks
|
|
16
|
+
* drag state and local validation itself, but never starts, advances or
|
|
17
|
+
* completes an upload — pass 'uploading' with a `percent`, then 'complete'.
|
|
18
|
+
* Reporting 'error' requires an `errorMessage`, so it lives in the other half
|
|
19
|
+
* of this union.
|
|
20
|
+
*
|
|
21
|
+
* 'disabled' blocks all interaction: drag, drop and click handlers return
|
|
22
|
+
* early rather than relying on `pointer-events` alone. Because it is a value
|
|
23
|
+
* of this union rather than a separate flag, it replaces the lifecycle state
|
|
24
|
+
* rather than composing with it — a zone cannot be disabled *and* report
|
|
25
|
+
* progress at the same time.
|
|
26
|
+
*/
|
|
27
|
+
state?: Exclude<MrlFileUploadState, 'error'>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The failure half: reporting an error means saying what went wrong.
|
|
31
|
+
*/
|
|
32
|
+
type MrlFileUploadErrorProps = {
|
|
33
|
+
/**
|
|
34
|
+
* Why the upload failed. Required alongside `state="error"`: the failure has
|
|
35
|
+
* to reach people who cannot see the border colour.
|
|
36
|
+
*
|
|
37
|
+
* A retry that fails with the identical message is announced only once — a
|
|
38
|
+
* live region re-set to the text it already holds says nothing, and the
|
|
39
|
+
* component cannot tell a retry from a re-render. Pass through a non-error
|
|
40
|
+
* state between attempts (back to 'idle', or 'uploading' while the retry is
|
|
41
|
+
* in flight) so the second failure is a genuine change.
|
|
42
|
+
*/
|
|
43
|
+
errorMessage: string;
|
|
44
|
+
/**
|
|
45
|
+
* Reports a failed upload. A local validation failure supplies its own
|
|
46
|
+
* message and takes precedence over `errorMessage`.
|
|
47
|
+
*/
|
|
48
|
+
state: 'error';
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The zone's state and, when it reports a failure, the message that explains it.
|
|
52
|
+
*
|
|
53
|
+
* The two are a union rather than two independent props so that `state="error"`
|
|
54
|
+
* without an `errorMessage` does not compile. An errored zone with no text is
|
|
55
|
+
* signalled by border colour alone, which reaches neither assistive technology
|
|
56
|
+
* nor anyone who cannot distinguish the error hue. A consumer holding the state
|
|
57
|
+
* in a variable typed as the whole union has to narrow it before rendering —
|
|
58
|
+
* that is the point, not an accident.
|
|
59
|
+
*/
|
|
60
|
+
export type MrlFileUploadStateProps = MrlFileUploadRestingProps | MrlFileUploadErrorProps;
|
|
61
|
+
export type MrlFileUploadProps = {
|
|
62
|
+
/**
|
|
63
|
+
* Accepted file types, in the same format as the native `accept` attribute
|
|
64
|
+
* (e.g. '.gif,.jpg,.jpeg,.png' or 'image/*'). Also enforced on drop, which
|
|
65
|
+
* the native attribute does not cover.
|
|
66
|
+
*/
|
|
67
|
+
accept?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Name of the file being uploaded, shown in the progress and completed copy
|
|
70
|
+
* and announced to assistive technology. Falls back to the name of the file
|
|
71
|
+
* the user last selected.
|
|
72
|
+
*/
|
|
73
|
+
fileName?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Headline inside the drop zone.
|
|
76
|
+
*/
|
|
77
|
+
heading?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Supporting line describing what is accepted.
|
|
80
|
+
*/
|
|
81
|
+
helperText?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Field label rendered above the drop zone, and the zone's accessible name.
|
|
84
|
+
*/
|
|
85
|
+
label?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Maximum accepted file size in bytes. Omit for no limit.
|
|
88
|
+
*/
|
|
89
|
+
maxSizeBytes?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Fired when the user cancels an upload in progress. The consumer owns the
|
|
92
|
+
* abort — the component only returns itself to its resting state.
|
|
93
|
+
*/
|
|
94
|
+
onCancel?: () => void;
|
|
95
|
+
/**
|
|
96
|
+
* Fired when a file fails local validation, with the message shown to the
|
|
97
|
+
* user. Transport failures are reported by the consumer through
|
|
98
|
+
* `state="error"` instead.
|
|
99
|
+
*/
|
|
100
|
+
onError?: (message: string, file: File) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Fired when a file passes validation and is ready to upload. The consumer
|
|
103
|
+
* performs the upload and drives `state` and `percent` from its result.
|
|
104
|
+
*/
|
|
105
|
+
onFilesSelected?: (file: File) => void;
|
|
106
|
+
/**
|
|
107
|
+
* Fired when the user removes a completed upload.
|
|
108
|
+
*/
|
|
109
|
+
onRemove?: () => void;
|
|
110
|
+
/**
|
|
111
|
+
* Upload progress, 0–100. Only read while `state` is 'uploading'.
|
|
112
|
+
*/
|
|
113
|
+
percent?: ProgressRange;
|
|
114
|
+
/**
|
|
115
|
+
* Shows `helperText` inside the drop zone.
|
|
116
|
+
*/
|
|
117
|
+
showHelperText?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Repeats `helperText` as an inline message below the drop zone. Off by
|
|
120
|
+
* default — with `showHelperText` on, enabling both prints the same sentence
|
|
121
|
+
* twice. A validation or upload error always renders below the zone
|
|
122
|
+
* regardless of this flag.
|
|
123
|
+
*/
|
|
124
|
+
showInlineAlert?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Additional validation, run after the built-in `accept` and `maxSizeBytes`
|
|
127
|
+
* checks and only if those pass. Return a message to reject the file — it is
|
|
128
|
+
* shown and reported exactly like a built-in failure — or `null` to accept it.
|
|
129
|
+
*/
|
|
130
|
+
validate?: (file: File) => string | null;
|
|
131
|
+
/**
|
|
132
|
+
* Enables interaction tracking for this upload control. Provide a stable,
|
|
133
|
+
* non-PII id (e.g. 'workspace-logo-upload'). When omitted, the component
|
|
134
|
+
* emits no analytics.
|
|
135
|
+
*
|
|
136
|
+
* Note: file names, sizes and types are never emitted — only the fact of a
|
|
137
|
+
* selection and whether it was accepted.
|
|
138
|
+
*/
|
|
139
|
+
eventId?: string;
|
|
140
|
+
} & MrlFileUploadStateProps & Omit<React.ComponentPropsWithoutRef<'div'>, 'onError'> & DataQa;
|
|
141
|
+
/**
|
|
142
|
+
* A drag-and-drop file upload zone with a keyboard-accessible browse button.
|
|
143
|
+
*
|
|
144
|
+
* The component owns presentation, drag tracking and local validation
|
|
145
|
+
* (`accept`, `maxSizeBytes`); the consumer owns the upload itself and drives
|
|
146
|
+
* `state` and `percent`. Drag and drop is pointer-only by nature, so the
|
|
147
|
+
* button inside the zone is the equivalent path for everyone else and is the
|
|
148
|
+
* affordance exposed to the accessibility tree.
|
|
149
|
+
*
|
|
150
|
+
* @param props - The component props.
|
|
151
|
+
* @returns The MrlFileUpload component.
|
|
152
|
+
*/
|
|
153
|
+
export declare function MrlFileUpload(props: MrlFileUploadProps): React.ReactElement;
|
|
154
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MrlFileUpload, type MrlFileUploadProps } from './MrlFileUpload';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const allowedFileUploadValues: {
|
|
2
|
+
states: readonly ["idle", "uploading", "complete", "error", "disabled"];
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* The visual state of the drop zone, owned by the consumer.
|
|
6
|
+
*
|
|
7
|
+
* `dragging` is deliberately absent — a drag is transient pointer state the
|
|
8
|
+
* component tracks internally, not a state a consumer can meaningfully set.
|
|
9
|
+
*/
|
|
10
|
+
export type MrlFileUploadState = (typeof allowedFileUploadValues.states)[number];
|
|
11
|
+
export interface FileUploadDefaults {
|
|
12
|
+
accept: string;
|
|
13
|
+
heading: string;
|
|
14
|
+
showHelperText: boolean;
|
|
15
|
+
showInlineAlert: boolean;
|
|
16
|
+
state: MrlFileUploadState;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Default values for props on the MrlFileUpload component;
|
|
20
|
+
* shared between the component and Storybook.
|
|
21
|
+
*
|
|
22
|
+
* `helperText` is absent on purpose: with no value from the consumer it is
|
|
23
|
+
* derived from the constraints actually enforced, so the copy cannot drift from
|
|
24
|
+
* what `accept` and `maxSizeBytes` reject.
|
|
25
|
+
*/
|
|
26
|
+
export declare const fileUploadDefaults: FileUploadDefaults;
|
|
27
|
+
/**
|
|
28
|
+
* Shown when a consumer reports `state="error"` without an `errorMessage`.
|
|
29
|
+
*
|
|
30
|
+
* The types make that combination impossible, but a JavaScript consumer can
|
|
31
|
+
* still reach it — and an errored zone with no text is signalled by border
|
|
32
|
+
* colour alone, which reaches neither assistive technology nor anyone who
|
|
33
|
+
* cannot distinguish the error hue.
|
|
34
|
+
*/
|
|
35
|
+
export declare const DEFAULT_ERROR_MESSAGE = "Upload failed";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matches a file against an `accept` string (extensions and/or MIME types).
|
|
3
|
+
*
|
|
4
|
+
* The native `accept` attribute only filters the file picker; a dropped file
|
|
5
|
+
* bypasses it entirely, so the same rules have to be applied in code.
|
|
6
|
+
*
|
|
7
|
+
* @param file - the file to test
|
|
8
|
+
* @param accept - native `accept` syntax, e.g. '.png,image/*'
|
|
9
|
+
* @returns whether the file matches the accept rules
|
|
10
|
+
*/
|
|
11
|
+
export declare function isAccepted(file: File, accept: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Formats a byte count for display in a validation message.
|
|
14
|
+
*
|
|
15
|
+
* @param bytes - the size in bytes
|
|
16
|
+
* @returns a short human-readable size, e.g. '2.5 MB'
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatBytes(bytes: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* Lists the file types an `accept` string permits, for display.
|
|
21
|
+
*
|
|
22
|
+
* @param accept - native `accept` syntax, e.g. '.png,image/*'
|
|
23
|
+
* @returns a comma-separated list, or an empty string if nothing is restricted
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatAcceptList(accept: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Describes the constraints the component actually enforces, for use as helper
|
|
28
|
+
* text. Deriving the sentence from `accept` and `maxSizeBytes` is what keeps it
|
|
29
|
+
* from contradicting what validation rejects.
|
|
30
|
+
*
|
|
31
|
+
* @param accept - native `accept` syntax, e.g. '.png,image/*'
|
|
32
|
+
* @param maxSizeBytes - the size limit in bytes, if there is one
|
|
33
|
+
* @returns a sentence describing what may be uploaded, or an empty string
|
|
34
|
+
*/
|
|
35
|
+
export declare function describeConstraints(accept: string, maxSizeBytes?: number): string;
|