@dnb/eufemia 9.34.3 → 9.36.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 +33 -0
- package/cjs/components/breadcrumb/style/dnb-breadcrumb.css +6 -0
- package/cjs/components/breadcrumb/style/dnb-breadcrumb.min.css +1 -1
- package/cjs/components/global-status/style/dnb-global-status.css +6 -0
- package/cjs/components/global-status/style/dnb-global-status.min.css +1 -1
- package/cjs/components/section/Section.d.ts +2 -2
- package/cjs/components/section/style/_section.scss +8 -0
- package/cjs/components/section/style/dnb-section.css +6 -0
- package/cjs/components/section/style/dnb-section.min.css +1 -1
- package/cjs/components/space/Space.d.ts +0 -2
- package/cjs/components/space/Space.js +18 -12
- package/cjs/components/space/SpacingUtils.d.ts +14 -9
- package/cjs/components/space/SpacingUtils.js +59 -45
- package/cjs/components/step-indicator/StepIndicatorSidebar.js +5 -1
- package/cjs/components/tabs/Tabs.d.ts +2 -2
- package/cjs/components/tabs/Tabs.js +6 -11
- package/cjs/components/tabs/TabsContentWrapper.d.ts +1 -1
- package/cjs/components/tabs/TabsContentWrapper.js +6 -4
- package/cjs/components/tabs/style/_tabs.scss +15 -2
- package/cjs/components/tabs/style/dnb-tabs.css +14 -2
- package/cjs/components/tabs/style/dnb-tabs.min.css +1 -1
- package/cjs/components/tabs/style/themes/dnb-tabs-theme-eiendom.css +3 -3
- package/cjs/components/tabs/style/themes/dnb-tabs-theme-eiendom.min.css +1 -1
- package/cjs/components/tabs/style/themes/dnb-tabs-theme-ui.css +3 -3
- package/cjs/components/tabs/style/themes/dnb-tabs-theme-ui.min.css +1 -1
- package/cjs/components/tabs/style/themes/dnb-tabs-theme-ui.scss +4 -1
- package/cjs/components/upload/Upload.js +14 -17
- package/cjs/components/upload/UploadFileInput.js +17 -22
- package/cjs/components/upload/UploadFileList.js +1 -0
- package/cjs/components/upload/UploadFileListCell.d.ts +2 -1
- package/cjs/components/upload/UploadFileListCell.js +65 -7
- package/cjs/components/upload/UploadVerify.d.ts +4 -1
- package/cjs/components/upload/UploadVerify.js +67 -1
- package/cjs/components/upload/style/themes/dnb-upload-theme-ui.css +16 -3
- package/cjs/components/upload/style/themes/dnb-upload-theme-ui.min.css +1 -1
- package/cjs/components/upload/style/themes/dnb-upload-theme-ui.scss +9 -0
- package/cjs/components/upload/types.d.ts +3 -1
- package/cjs/components/upload/useUpload.d.ts +1 -2
- package/cjs/components/upload/useUpload.js +19 -3
- package/cjs/elements/Element.d.ts +1 -1
- package/cjs/shared/Eufemia.js +1 -1
- package/cjs/shared/MediaQueryUtils.d.ts +1 -5
- package/cjs/shared/MediaQueryUtils.js +1 -7
- package/cjs/shared/SpacingHelper.d.ts +6 -1
- package/cjs/shared/useMedia.js +1 -2
- package/cjs/shared/useMediaQuery.js +4 -2
- package/cjs/style/dnb-ui-components.css +20 -2
- package/cjs/style/dnb-ui-components.min.css +2 -2
- package/cjs/style/themes/theme-eiendom/dnb-theme-eiendom.css +22 -9
- package/cjs/style/themes/theme-eiendom/dnb-theme-eiendom.min.css +2 -2
- package/cjs/style/themes/theme-ui/dnb-theme-ui.css +19 -6
- package/cjs/style/themes/theme-ui/dnb-theme-ui.min.css +2 -2
- package/components/breadcrumb/style/dnb-breadcrumb.css +6 -0
- package/components/breadcrumb/style/dnb-breadcrumb.min.css +1 -1
- package/components/global-status/style/dnb-global-status.css +6 -0
- package/components/global-status/style/dnb-global-status.min.css +1 -1
- package/components/section/Section.d.ts +2 -2
- package/components/section/style/_section.scss +8 -0
- package/components/section/style/dnb-section.css +6 -0
- package/components/section/style/dnb-section.min.css +1 -1
- package/components/space/Space.d.ts +0 -2
- package/components/space/Space.js +17 -11
- package/components/space/SpacingUtils.d.ts +14 -9
- package/components/space/SpacingUtils.js +57 -44
- package/components/step-indicator/StepIndicatorSidebar.js +3 -1
- package/components/tabs/Tabs.d.ts +2 -2
- package/components/tabs/Tabs.js +6 -11
- package/components/tabs/TabsContentWrapper.d.ts +1 -1
- package/components/tabs/TabsContentWrapper.js +5 -4
- package/components/tabs/style/_tabs.scss +15 -2
- package/components/tabs/style/dnb-tabs.css +14 -2
- package/components/tabs/style/dnb-tabs.min.css +1 -1
- package/components/tabs/style/themes/dnb-tabs-theme-eiendom.css +3 -3
- package/components/tabs/style/themes/dnb-tabs-theme-eiendom.min.css +1 -1
- package/components/tabs/style/themes/dnb-tabs-theme-ui.css +3 -3
- package/components/tabs/style/themes/dnb-tabs-theme-ui.min.css +1 -1
- package/components/tabs/style/themes/dnb-tabs-theme-ui.scss +4 -1
- package/components/upload/Upload.js +11 -15
- package/components/upload/UploadFileInput.js +16 -21
- package/components/upload/UploadFileList.js +1 -0
- package/components/upload/UploadFileListCell.d.ts +2 -1
- package/components/upload/UploadFileListCell.js +44 -3
- package/components/upload/UploadVerify.d.ts +4 -1
- package/components/upload/UploadVerify.js +27 -1
- package/components/upload/style/themes/dnb-upload-theme-ui.css +16 -3
- package/components/upload/style/themes/dnb-upload-theme-ui.min.css +1 -1
- package/components/upload/style/themes/dnb-upload-theme-ui.scss +9 -0
- package/components/upload/types.d.ts +3 -1
- package/components/upload/useUpload.d.ts +1 -2
- package/components/upload/useUpload.js +17 -3
- package/elements/Element.d.ts +1 -1
- package/es/components/breadcrumb/style/dnb-breadcrumb.css +6 -0
- package/es/components/breadcrumb/style/dnb-breadcrumb.min.css +1 -1
- package/es/components/global-status/style/dnb-global-status.css +6 -0
- package/es/components/global-status/style/dnb-global-status.min.css +1 -1
- package/es/components/section/Section.d.ts +2 -2
- package/es/components/section/style/_section.scss +8 -0
- package/es/components/section/style/dnb-section.css +6 -0
- package/es/components/section/style/dnb-section.min.css +1 -1
- package/es/components/space/Space.d.ts +0 -2
- package/es/components/space/Space.js +17 -11
- package/es/components/space/SpacingUtils.d.ts +14 -9
- package/es/components/space/SpacingUtils.js +44 -36
- package/es/components/step-indicator/StepIndicatorSidebar.js +3 -1
- package/es/components/tabs/Tabs.d.ts +2 -2
- package/es/components/tabs/Tabs.js +6 -11
- package/es/components/tabs/TabsContentWrapper.d.ts +1 -1
- package/es/components/tabs/TabsContentWrapper.js +5 -4
- package/es/components/tabs/style/_tabs.scss +15 -2
- package/es/components/tabs/style/dnb-tabs.css +14 -2
- package/es/components/tabs/style/dnb-tabs.min.css +1 -1
- package/es/components/tabs/style/themes/dnb-tabs-theme-eiendom.css +3 -3
- package/es/components/tabs/style/themes/dnb-tabs-theme-eiendom.min.css +1 -1
- package/es/components/tabs/style/themes/dnb-tabs-theme-ui.css +3 -3
- package/es/components/tabs/style/themes/dnb-tabs-theme-ui.min.css +1 -1
- package/es/components/tabs/style/themes/dnb-tabs-theme-ui.scss +4 -1
- package/es/components/upload/Upload.js +11 -13
- package/es/components/upload/UploadFileInput.js +13 -17
- package/es/components/upload/UploadFileList.js +1 -0
- package/es/components/upload/UploadFileListCell.d.ts +2 -1
- package/es/components/upload/UploadFileListCell.js +36 -2
- package/es/components/upload/UploadVerify.d.ts +4 -1
- package/es/components/upload/UploadVerify.js +12 -1
- package/es/components/upload/style/themes/dnb-upload-theme-ui.css +16 -3
- package/es/components/upload/style/themes/dnb-upload-theme-ui.min.css +1 -1
- package/es/components/upload/style/themes/dnb-upload-theme-ui.scss +9 -0
- package/es/components/upload/types.d.ts +3 -1
- package/es/components/upload/useUpload.d.ts +1 -2
- package/es/components/upload/useUpload.js +15 -3
- package/es/elements/Element.d.ts +1 -1
- package/es/shared/Eufemia.js +1 -1
- package/es/shared/MediaQueryUtils.d.ts +1 -5
- package/es/shared/MediaQueryUtils.js +1 -6
- package/es/shared/SpacingHelper.d.ts +6 -1
- package/es/shared/useMedia.js +1 -2
- package/es/shared/useMediaQuery.js +4 -2
- package/es/style/dnb-ui-components.css +20 -2
- package/es/style/dnb-ui-components.min.css +2 -2
- package/es/style/themes/theme-eiendom/dnb-theme-eiendom.css +22 -9
- package/es/style/themes/theme-eiendom/dnb-theme-eiendom.min.css +2 -2
- package/es/style/themes/theme-ui/dnb-theme-ui.css +19 -6
- package/es/style/themes/theme-ui/dnb-theme-ui.min.css +2 -2
- package/esm/dnb-ui-basis.min.mjs +1 -1
- package/esm/dnb-ui-components.min.mjs +1 -1
- package/esm/dnb-ui-elements.min.mjs +3 -3
- package/esm/dnb-ui-extensions.min.mjs +4 -4
- package/esm/dnb-ui-lib.min.mjs +2 -2
- package/esm/dnb-ui-web-components.min.mjs +2 -2
- package/package.json +1 -1
- package/shared/Eufemia.js +1 -1
- package/shared/MediaQueryUtils.d.ts +1 -5
- package/shared/MediaQueryUtils.js +1 -7
- package/shared/SpacingHelper.d.ts +6 -1
- package/shared/useMedia.js +1 -2
- package/shared/useMediaQuery.js +4 -2
- package/style/dnb-ui-components.css +20 -2
- package/style/dnb-ui-components.min.css +2 -2
- package/style/themes/theme-eiendom/dnb-theme-eiendom.css +22 -9
- package/style/themes/theme-eiendom/dnb-theme-eiendom.min.css +2 -2
- package/style/themes/theme-ui/dnb-theme-ui.css +19 -6
- package/style/themes/theme-ui/dnb-theme-ui.min.css +2 -2
- package/umd/dnb-ui-basis.min.js +1 -1
- package/umd/dnb-ui-components.min.js +1 -1
- package/umd/dnb-ui-elements.min.js +4 -4
- package/umd/dnb-ui-extensions.min.js +3 -3
- package/umd/dnb-ui-lib.min.js +3 -3
- package/umd/dnb-ui-web-components.min.js +4 -4
|
@@ -4,6 +4,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
4
4
|
|
|
5
5
|
require("core-js/modules/es.array.iterator.js");
|
|
6
6
|
|
|
7
|
+
require("core-js/modules/es.object.to-string.js");
|
|
8
|
+
|
|
7
9
|
require("core-js/modules/es.weak-map.js");
|
|
8
10
|
|
|
9
11
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
@@ -21,11 +23,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
21
23
|
});
|
|
22
24
|
exports.default = void 0;
|
|
23
25
|
|
|
24
|
-
require("core-js/modules/es.array.
|
|
25
|
-
|
|
26
|
-
require("core-js/modules/es.object.to-string.js");
|
|
27
|
-
|
|
28
|
-
require("core-js/modules/es.array.concat.js");
|
|
26
|
+
require("core-js/modules/es.array.join.js");
|
|
29
27
|
|
|
30
28
|
require("core-js/modules/es.array.map.js");
|
|
31
29
|
|
|
@@ -45,7 +43,7 @@ var _UploadContext = require("./UploadContext");
|
|
|
45
43
|
|
|
46
44
|
var _UploadStatus2 = _interopRequireDefault(require("./UploadStatus"));
|
|
47
45
|
|
|
48
|
-
var
|
|
46
|
+
var _UploadVerify = require("./UploadVerify");
|
|
49
47
|
|
|
50
48
|
var _UploadStatus;
|
|
51
49
|
|
|
@@ -66,18 +64,6 @@ var UploadFileInput = function UploadFileInput() {
|
|
|
66
64
|
onInputUpload = context.onInputUpload,
|
|
67
65
|
filesAmountLimit = context.filesAmountLimit;
|
|
68
66
|
|
|
69
|
-
var _useUpload = (0, _useUpload2.default)(id),
|
|
70
|
-
internalFiles = _useUpload.internalFiles;
|
|
71
|
-
|
|
72
|
-
var accept = acceptedFileTypes.reduce(function (accept, format, index) {
|
|
73
|
-
var previus = index === 0 ? '' : "".concat(accept, ",");
|
|
74
|
-
return "".concat(previus, " .").concat(format);
|
|
75
|
-
}, '');
|
|
76
|
-
(0, _react.useEffect)(function () {
|
|
77
|
-
fileInput.current.value = null;
|
|
78
|
-
fileInput.current.accept = accept;
|
|
79
|
-
}, []);
|
|
80
|
-
|
|
81
67
|
var openFileDialog = function openFileDialog() {
|
|
82
68
|
var _fileInput$current;
|
|
83
69
|
|
|
@@ -85,6 +71,9 @@ var UploadFileInput = function UploadFileInput() {
|
|
|
85
71
|
};
|
|
86
72
|
|
|
87
73
|
var sharedId = id || (0, _componentHelper.makeUniqueId)();
|
|
74
|
+
var accept = (0, _UploadVerify.extendWithAbbreviation)(acceptedFileTypes).map(function (type) {
|
|
75
|
+
return ".".concat(type);
|
|
76
|
+
}).join(',');
|
|
88
77
|
return _react.default.createElement("div", {
|
|
89
78
|
"data-testid": "upload-file-input"
|
|
90
79
|
}, _react.default.createElement(_Button.default, {
|
|
@@ -96,19 +85,20 @@ var UploadFileInput = function UploadFileInput() {
|
|
|
96
85
|
icon_position: "left",
|
|
97
86
|
variant: "secondary",
|
|
98
87
|
wrap: true,
|
|
99
|
-
onClick: openFileDialog
|
|
100
|
-
disabled: internalFiles.length > filesAmountLimit
|
|
88
|
+
onClick: openFileDialog
|
|
101
89
|
}, buttonText), _UploadStatus || (_UploadStatus = _react.default.createElement(_UploadStatus2.default, null)), _react.default.createElement("input", {
|
|
102
90
|
"aria-labelledby": "".concat(sharedId, "-input"),
|
|
103
91
|
"data-testid": "upload-file-input-input",
|
|
104
92
|
ref: fileInput,
|
|
93
|
+
accept: accept,
|
|
105
94
|
className: "dnb-upload__file-input",
|
|
106
95
|
type: "file",
|
|
107
|
-
onChange:
|
|
96
|
+
onChange: onChangeHandler,
|
|
97
|
+
onClick: onClickHandler,
|
|
108
98
|
multiple: filesAmountLimit > 1
|
|
109
99
|
}));
|
|
110
100
|
|
|
111
|
-
function
|
|
101
|
+
function onChangeHandler(event) {
|
|
112
102
|
var target = event.target;
|
|
113
103
|
var files = target.files;
|
|
114
104
|
onInputUpload(Array.from(files).map(function (file) {
|
|
@@ -117,6 +107,11 @@ var UploadFileInput = function UploadFileInput() {
|
|
|
117
107
|
};
|
|
118
108
|
}));
|
|
119
109
|
}
|
|
110
|
+
|
|
111
|
+
function onClickHandler(event) {
|
|
112
|
+
var target = event.target;
|
|
113
|
+
target.value = null;
|
|
114
|
+
}
|
|
120
115
|
};
|
|
121
116
|
|
|
122
117
|
var _default = UploadFileInput;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UploadFile } from './types';
|
|
3
3
|
export declare type UploadFileListCellProps = {
|
|
4
|
+
id: string;
|
|
4
5
|
/**
|
|
5
6
|
* Uploaded file
|
|
6
7
|
*/
|
|
@@ -15,5 +16,5 @@ export declare type UploadFileListCellProps = {
|
|
|
15
16
|
loadingText: React.ReactNode;
|
|
16
17
|
deleteButtonText: React.ReactNode;
|
|
17
18
|
};
|
|
18
|
-
declare const UploadFileListCell: ({ uploadFile, onDelete, loadingText, deleteButtonText, }: UploadFileListCellProps) => JSX.Element;
|
|
19
|
+
declare const UploadFileListCell: ({ id, uploadFile, onDelete, loadingText, deleteButtonText, }: UploadFileListCellProps) => JSX.Element;
|
|
19
20
|
export default UploadFileListCell;
|
|
@@ -2,16 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
4
|
|
|
5
|
-
require("core-js/modules/es.weak-map.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
8
|
-
|
|
9
5
|
require("core-js/modules/es.symbol.js");
|
|
10
6
|
|
|
11
7
|
require("core-js/modules/es.symbol.description.js");
|
|
12
8
|
|
|
13
9
|
require("core-js/modules/es.symbol.iterator.js");
|
|
14
10
|
|
|
11
|
+
require("core-js/modules/es.array.slice.js");
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/es.array.from.js");
|
|
14
|
+
|
|
15
|
+
require("core-js/modules/es.weak-map.js");
|
|
16
|
+
|
|
17
|
+
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
18
|
+
|
|
15
19
|
Object.defineProperty(exports, "__esModule", {
|
|
16
20
|
value: true
|
|
17
21
|
});
|
|
@@ -37,6 +41,8 @@ require("core-js/modules/web.url-search-params.js");
|
|
|
37
41
|
|
|
38
42
|
var _react = _interopRequireWildcard(require("react"));
|
|
39
43
|
|
|
44
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
45
|
+
|
|
40
46
|
var _Button = _interopRequireDefault(require("../button/Button"));
|
|
41
47
|
|
|
42
48
|
var _Icon2 = _interopRequireDefault(require("../../components/Icon"));
|
|
@@ -51,6 +57,8 @@ var _icons = require("../../icons");
|
|
|
51
57
|
|
|
52
58
|
var _componentHelper = require("../../shared/component-helper");
|
|
53
59
|
|
|
60
|
+
var _useUpload2 = _interopRequireDefault(require("./useUpload"));
|
|
61
|
+
|
|
54
62
|
var _ProgressIndicator, _Icon;
|
|
55
63
|
|
|
56
64
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -59,6 +67,18 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
59
67
|
|
|
60
68
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
61
69
|
|
|
70
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
71
|
+
|
|
72
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
73
|
+
|
|
74
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
75
|
+
|
|
76
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
77
|
+
|
|
78
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
79
|
+
|
|
80
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
81
|
+
|
|
62
82
|
var images = {
|
|
63
83
|
pdf: _icons.file_pdf_medium,
|
|
64
84
|
xls: _icons.file_xls_medium,
|
|
@@ -72,7 +92,8 @@ var images = {
|
|
|
72
92
|
var UploadFileListCell = function UploadFileListCell(_ref) {
|
|
73
93
|
var _div, _a, _FormStatus;
|
|
74
94
|
|
|
75
|
-
var
|
|
95
|
+
var id = _ref.id,
|
|
96
|
+
uploadFile = _ref.uploadFile,
|
|
76
97
|
onDelete = _ref.onDelete,
|
|
77
98
|
loadingText = _ref.loadingText,
|
|
78
99
|
deleteButtonText = _ref.deleteButtonText;
|
|
@@ -85,6 +106,7 @@ var UploadFileListCell = function UploadFileListCell(_ref) {
|
|
|
85
106
|
var hasWarning = errorMessage != null;
|
|
86
107
|
var imageUrl = URL.createObjectURL(file);
|
|
87
108
|
var cellRef = (0, _react.useRef)();
|
|
109
|
+
var exists = useExistsHighlight(id, file);
|
|
88
110
|
|
|
89
111
|
var handleDisappearFocus = function handleDisappearFocus() {
|
|
90
112
|
try {
|
|
@@ -103,7 +125,7 @@ var UploadFileListCell = function UploadFileListCell(_ref) {
|
|
|
103
125
|
|
|
104
126
|
return _react.default.createElement("li", {
|
|
105
127
|
"data-testid": "upload-file-list-cell",
|
|
106
|
-
className: 'dnb-upload__file-cell'
|
|
128
|
+
className: (0, _classnames.default)('dnb-upload__file-cell', hasWarning && 'dnb-upload__file-cell--warning', exists && 'dnb-upload__file-cell--highlight'),
|
|
107
129
|
ref: cellRef
|
|
108
130
|
}, _react.default.createElement("div", {
|
|
109
131
|
className: "dnb-upload__file-cell__content"
|
|
@@ -168,4 +190,40 @@ var UploadFileListCell = function UploadFileListCell(_ref) {
|
|
|
168
190
|
};
|
|
169
191
|
|
|
170
192
|
var _default = UploadFileListCell;
|
|
171
|
-
exports.default = _default;
|
|
193
|
+
exports.default = _default;
|
|
194
|
+
|
|
195
|
+
function useExistsHighlight(id, file) {
|
|
196
|
+
var _useUpload = (0, _useUpload2.default)(id),
|
|
197
|
+
internalFiles = _useUpload.internalFiles;
|
|
198
|
+
|
|
199
|
+
var _React$useState = _react.default.useState(false),
|
|
200
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
201
|
+
exists = _React$useState2[0],
|
|
202
|
+
updateExists = _React$useState2[1];
|
|
203
|
+
|
|
204
|
+
var timerRef = _react.default.useRef();
|
|
205
|
+
|
|
206
|
+
var clearTimers = function clearTimers() {
|
|
207
|
+
clearTimeout(timerRef.current);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
_react.default.useEffect(function () {
|
|
211
|
+
var exists = internalFiles.some(function (_ref2) {
|
|
212
|
+
var exists = _ref2.exists,
|
|
213
|
+
f = _ref2.file;
|
|
214
|
+
return exists && f.name === file.name && f.size === file.size;
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
if (exists) {
|
|
218
|
+
updateExists(true);
|
|
219
|
+
clearTimers();
|
|
220
|
+
timerRef.current = setTimeout(function () {
|
|
221
|
+
return updateExists(false);
|
|
222
|
+
}, 1500);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return clearTimers;
|
|
226
|
+
}, [file, internalFiles]);
|
|
227
|
+
|
|
228
|
+
return exists;
|
|
229
|
+
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import { UploadContextProps,
|
|
1
|
+
import { UploadFile, UploadContextProps, UploadAcceptedFileTypes } from './types';
|
|
2
2
|
export declare function verifyFiles(files: UploadFile[], context: Pick<UploadContextProps, 'errorUnsupportedFile' | 'errorLargeFile' | 'acceptedFileTypes' | 'fileMaxSize'>): UploadFile[];
|
|
3
|
+
export declare function extendWithAbbreviation(acceptedFileTypes: UploadAcceptedFileTypes, abbreviations?: {
|
|
4
|
+
jpg: string;
|
|
5
|
+
}): string[];
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.symbol.js");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.symbol.description.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.symbol.iterator.js");
|
|
8
|
+
|
|
9
|
+
require("core-js/modules/es.array.iterator.js");
|
|
10
|
+
|
|
11
|
+
require("core-js/modules/es.string.iterator.js");
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
14
|
+
|
|
15
|
+
require("core-js/modules/es.array.from.js");
|
|
16
|
+
|
|
17
|
+
require("core-js/modules/es.array.slice.js");
|
|
18
|
+
|
|
19
|
+
require("core-js/modules/es.function.name.js");
|
|
20
|
+
|
|
3
21
|
Object.defineProperty(exports, "__esModule", {
|
|
4
22
|
value: true
|
|
5
23
|
});
|
|
24
|
+
exports.extendWithAbbreviation = extendWithAbbreviation;
|
|
6
25
|
exports.verifyFiles = verifyFiles;
|
|
7
26
|
|
|
8
27
|
require("core-js/modules/es.regexp.exec.js");
|
|
@@ -19,8 +38,32 @@ require("core-js/modules/es.string.includes.js");
|
|
|
19
38
|
|
|
20
39
|
require("core-js/modules/es.array.map.js");
|
|
21
40
|
|
|
41
|
+
require("core-js/modules/web.dom-collections.for-each.js");
|
|
42
|
+
|
|
43
|
+
require("core-js/modules/es.object.entries.js");
|
|
44
|
+
|
|
22
45
|
var _NumberUtils = require("../number-format/NumberUtils");
|
|
23
46
|
|
|
47
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
48
|
+
|
|
49
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
50
|
+
|
|
51
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
52
|
+
|
|
53
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
54
|
+
|
|
55
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
56
|
+
|
|
57
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
58
|
+
|
|
59
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
60
|
+
|
|
61
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
62
|
+
|
|
63
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
64
|
+
|
|
65
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
66
|
+
|
|
24
67
|
var BYTES_IN_A_MEGA_BYTE = 1048576;
|
|
25
68
|
|
|
26
69
|
function verifyFiles(files, context) {
|
|
@@ -38,7 +81,7 @@ function verifyFiles(files, context) {
|
|
|
38
81
|
return false;
|
|
39
82
|
}
|
|
40
83
|
|
|
41
|
-
var foundType = acceptedFileTypes.some(function (type) {
|
|
84
|
+
var foundType = extendWithAbbreviation(acceptedFileTypes).some(function (type) {
|
|
42
85
|
return file.type.includes(type);
|
|
43
86
|
});
|
|
44
87
|
return !foundType ? errorUnsupportedFile : null;
|
|
@@ -55,4 +98,27 @@ function verifyFiles(files, context) {
|
|
|
55
98
|
return item;
|
|
56
99
|
});
|
|
57
100
|
return cleanedFiles;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function extendWithAbbreviation(acceptedFileTypes) {
|
|
104
|
+
var abbreviations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
105
|
+
jpg: 'jpeg'
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
var list = _toConsumableArray(acceptedFileTypes);
|
|
109
|
+
|
|
110
|
+
Object.entries(abbreviations).forEach(function (_ref) {
|
|
111
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
112
|
+
type = _ref2[0],
|
|
113
|
+
abbr = _ref2[1];
|
|
114
|
+
|
|
115
|
+
if (list.some(function (t) {
|
|
116
|
+
return t === type;
|
|
117
|
+
}) && !list.some(function (t) {
|
|
118
|
+
return t === abbr;
|
|
119
|
+
})) {
|
|
120
|
+
list.push(abbr);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return list;
|
|
58
124
|
}
|
|
@@ -27,9 +27,22 @@
|
|
|
27
27
|
.dnb-upload--active {
|
|
28
28
|
background-color: #f2f4ec;
|
|
29
29
|
background-color: var(--color-pistachio); }
|
|
30
|
-
.dnb-upload__file-cell
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
.dnb-upload__file-cell {
|
|
31
|
+
/** Highlight Animation */
|
|
32
|
+
-webkit-transition: background-color;
|
|
33
|
+
transition: background-color;
|
|
34
|
+
-webkit-transition-duration: 1.5s;
|
|
35
|
+
transition-duration: 1.5s;
|
|
36
|
+
-webkit-transition-timing-function: cubic-bezier(0.42, 0, 0, 1);
|
|
37
|
+
transition-timing-function: cubic-bezier(0.42, 0, 0, 1);
|
|
38
|
+
-webkit-transition-timing-function: var(--easing-default);
|
|
39
|
+
transition-timing-function: var(--easing-default); }
|
|
40
|
+
.dnb-upload__file-cell--warning .dnb-upload__file-cell__content__left .dnb-icon {
|
|
41
|
+
color: #dc2a2a;
|
|
42
|
+
color: var(--color-fire-red); }
|
|
43
|
+
.dnb-upload__file-cell--highlight {
|
|
44
|
+
background-color: #fbf6ec;
|
|
45
|
+
background-color: var(--color-sand-yellow); }
|
|
33
46
|
.dnb-upload__text.dnb-p {
|
|
34
47
|
color: #737373;
|
|
35
48
|
color: var(--color-black-55); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.dnb-upload{background-color:#fff;background-color:var(--color-white);border-radius:.5rem}.dnb-upload__outline{stroke:#007272;stroke:var(--color-sea-green);stroke-width:.1875rem;border-radius:.5rem}.dnb-upload--active .dnb-upload__outline{stroke:#14555a;stroke:var(--color-emerald-green);bottom:-1px;height:calc(100% + 2px);inset:-1px;left:-1px;right:-1px;top:-1px;width:calc(100% + 2px)}.dnb-upload--active .dnb-upload__outline rect{stroke-width:.25rem;stroke-dasharray:0}.dnb-upload--active{background-color:#f2f4ec;background-color:var(--color-pistachio)}.dnb-upload__file-cell--warning .dnb-upload__file-cell__content__left .dnb-icon{color:#dc2a2a;color:var(--color-fire-red)}.dnb-upload__subtitle.dnb-p,.dnb-upload__text.dnb-p{color:#737373;color:var(--color-black-55)}
|
|
1
|
+
.dnb-upload{background-color:#fff;background-color:var(--color-white);border-radius:.5rem}.dnb-upload__outline{stroke:#007272;stroke:var(--color-sea-green);stroke-width:.1875rem;border-radius:.5rem}.dnb-upload--active .dnb-upload__outline{stroke:#14555a;stroke:var(--color-emerald-green);bottom:-1px;height:calc(100% + 2px);inset:-1px;left:-1px;right:-1px;top:-1px;width:calc(100% + 2px)}.dnb-upload--active .dnb-upload__outline rect{stroke-width:.25rem;stroke-dasharray:0}.dnb-upload--active{background-color:#f2f4ec;background-color:var(--color-pistachio)}.dnb-upload__file-cell{-webkit-transition:background-color;transition:background-color;-webkit-transition-duration:1.5s;transition-duration:1.5s;-webkit-transition-timing-function:cubic-bezier(.42,0,0,1);transition-timing-function:cubic-bezier(.42,0,0,1);-webkit-transition-timing-function:var(--easing-default);transition-timing-function:var(--easing-default)}.dnb-upload__file-cell--warning .dnb-upload__file-cell__content__left .dnb-icon{color:#dc2a2a;color:var(--color-fire-red)}.dnb-upload__file-cell--highlight{background-color:#fbf6ec;background-color:var(--color-sand-yellow)}.dnb-upload__subtitle.dnb-p,.dnb-upload__text.dnb-p{color:#737373;color:var(--color-black-55)}
|
|
@@ -35,6 +35,15 @@
|
|
|
35
35
|
&--warning &__content__left .dnb-icon {
|
|
36
36
|
color: var(--color-fire-red);
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
/** Highlight Animation */
|
|
40
|
+
transition: background-color;
|
|
41
|
+
transition-duration: 1.5s;
|
|
42
|
+
transition-timing-function: var(--easing-default);
|
|
43
|
+
|
|
44
|
+
&--highlight {
|
|
45
|
+
background-color: var(--color-sand-yellow);
|
|
46
|
+
}
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
&__text.dnb-p {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SkeletonShow } from '../skeleton/Skeleton';
|
|
3
3
|
import { LocaleProps, SpacingProps } from '../../shared/types';
|
|
4
|
+
export declare type UploadAcceptedFileTypes = string[];
|
|
4
5
|
export declare type UploadProps = {
|
|
5
6
|
/**
|
|
6
7
|
* unique id used with the useUpload hook to manage the files
|
|
@@ -9,7 +10,7 @@ export declare type UploadProps = {
|
|
|
9
10
|
/**
|
|
10
11
|
* list of accepted file types.
|
|
11
12
|
*/
|
|
12
|
-
acceptedFileTypes:
|
|
13
|
+
acceptedFileTypes: UploadAcceptedFileTypes;
|
|
13
14
|
/**
|
|
14
15
|
* Skeleton should be applied when loading content
|
|
15
16
|
* Default: null
|
|
@@ -63,5 +64,6 @@ export declare type UploadFile = {
|
|
|
63
64
|
file: File;
|
|
64
65
|
errorMessage?: React.ReactNode;
|
|
65
66
|
isLoading?: boolean;
|
|
67
|
+
exists?: boolean;
|
|
66
68
|
id?: string;
|
|
67
69
|
};
|
|
@@ -4,11 +4,10 @@ export declare type useUploadReturn = {
|
|
|
4
4
|
setFiles: (files: UploadFile[]) => void;
|
|
5
5
|
internalFiles: UploadFile[];
|
|
6
6
|
setInternalFiles: (files: UploadFile[]) => void;
|
|
7
|
+
existsInFiles: (file: File, fileItems?: UploadFile[]) => boolean;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
10
|
* Use together with Upload with the same id to manage the files from outside the component.
|
|
10
|
-
* @param id string, must match the id of the Upload component
|
|
11
|
-
* @returns { files: UploadFile[], setFiles: (file: UploadFile[]) => void }
|
|
12
11
|
*/
|
|
13
12
|
declare function useUpload(id: string): useUploadReturn;
|
|
14
13
|
export default useUpload;
|
|
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
require("core-js/modules/es.object.to-string.js");
|
|
9
|
+
|
|
10
|
+
require("core-js/modules/es.function.name.js");
|
|
11
|
+
|
|
8
12
|
var _componentHelper = require("../../shared/component-helper");
|
|
9
13
|
|
|
10
14
|
function useUpload(id) {
|
|
@@ -24,11 +28,23 @@ function useUpload(id) {
|
|
|
24
28
|
});
|
|
25
29
|
};
|
|
26
30
|
|
|
31
|
+
var files = (data === null || data === void 0 ? void 0 : data.files) || [];
|
|
32
|
+
var internalFiles = (data === null || data === void 0 ? void 0 : data.internalFiles) || [];
|
|
33
|
+
|
|
34
|
+
var existsInFiles = function existsInFiles(file) {
|
|
35
|
+
var fileItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : files;
|
|
36
|
+
return fileItems.some(function (_ref) {
|
|
37
|
+
var f = _ref.file;
|
|
38
|
+
return f.name === file.name && f.size === file.size && f.lastModified === file.lastModified;
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
27
42
|
return {
|
|
28
|
-
files:
|
|
43
|
+
files: files,
|
|
29
44
|
setFiles: setFiles,
|
|
30
|
-
internalFiles:
|
|
31
|
-
setInternalFiles: setInternalFiles
|
|
45
|
+
internalFiles: internalFiles,
|
|
46
|
+
setInternalFiles: setInternalFiles,
|
|
47
|
+
existsInFiles: existsInFiles
|
|
32
48
|
};
|
|
33
49
|
}
|
|
34
50
|
|
|
@@ -49,5 +49,5 @@ declare const Element: React.ForwardRefExoticComponent<Pick<{
|
|
|
49
49
|
skeleton_method?: SkeletonMethods;
|
|
50
50
|
} & import("../shared/types").SpacingElementProps & {
|
|
51
51
|
space?: import("../shared/types").SpaceTypes | import("../shared/types").SpacingElementProps;
|
|
52
|
-
} & ElementInternalProps & React.HTMLProps<HTMLElement>, "aria-hidden" | "cite" | "data" | "dir" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "accessKey" | "key" | "value" | "top" | "right" | "bottom" | "left" | "width" | "height" | "size" | "children" | "className" | "skeleton" | "
|
|
52
|
+
} & ElementInternalProps & React.HTMLProps<HTMLElement>, "aria-hidden" | "cite" | "data" | "dir" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "accessKey" | "key" | "value" | "top" | "right" | "bottom" | "left" | "space" | "width" | "height" | "size" | "children" | "className" | "skeleton" | "alt" | "src" | "shape" | "list" | "step" | "content" | "inner_ref" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "as" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "crossOrigin" | "dateTime" | "default" | "defer" | "disabled" | "download" | "encType" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "name" | "nonce" | "noValidate" | "open" | "optimum" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "sizes" | "srcDoc" | "srcLang" | "srcSet" | "start" | "target" | "type" | "useMap" | "wmode" | "wrap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "id" | "lang" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "class" | "innerRef" | "skeletonMethod" | "internalClass" | "css" | "skeleton_method"> & React.RefAttributes<unknown>>;
|
|
53
53
|
export default Element;
|
package/cjs/shared/Eufemia.js
CHANGED
|
@@ -32,10 +32,6 @@ export declare type MediaQueryProperties = {
|
|
|
32
32
|
* If set to true, no MediaQuery will be used.
|
|
33
33
|
*/
|
|
34
34
|
disabled?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* If set to true, no Eufemia warning will be shown when window.matchMedia is undefined
|
|
37
|
-
*/
|
|
38
|
-
dismissWarning?: boolean;
|
|
39
35
|
/**
|
|
40
36
|
* For debugging
|
|
41
37
|
*/
|
|
@@ -84,7 +80,7 @@ export declare const isMatchMediaSupported: () => boolean;
|
|
|
84
80
|
* @property {boolean} log - print used query to console
|
|
85
81
|
* @returns MediaQueryList type
|
|
86
82
|
*/
|
|
87
|
-
export declare function makeMediaQueryList({ query, when, not, log, disabled,
|
|
83
|
+
export declare function makeMediaQueryList({ query, when, not, log, disabled, }?: MediaQueryProperties, breakpoints?: MediaQueryBreakpoints): MediaQueryList;
|
|
88
84
|
/**
|
|
89
85
|
* Adds a listener to the window.matchMedia Browser API
|
|
90
86
|
*
|
|
@@ -136,18 +136,12 @@ function makeMediaQueryList() {
|
|
|
136
136
|
_ref2$log = _ref2.log,
|
|
137
137
|
log = _ref2$log === void 0 ? false : _ref2$log,
|
|
138
138
|
_ref2$disabled = _ref2.disabled,
|
|
139
|
-
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled
|
|
140
|
-
_ref2$dismissWarning = _ref2.dismissWarning,
|
|
141
|
-
dismissWarning = _ref2$dismissWarning === void 0 ? false : _ref2$dismissWarning;
|
|
139
|
+
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled;
|
|
142
140
|
|
|
143
141
|
var breakpoints = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
144
142
|
var isSupported = isMatchMediaSupported();
|
|
145
143
|
|
|
146
144
|
if (disabled || !isSupported) {
|
|
147
|
-
if (!dismissWarning && !isSupported) {
|
|
148
|
-
(0, _helpers.warn)('window.matchMedia is "undefined"');
|
|
149
|
-
}
|
|
150
|
-
|
|
151
145
|
return null;
|
|
152
146
|
}
|
|
153
147
|
|
package/cjs/shared/useMedia.js
CHANGED
|
@@ -131,8 +131,7 @@ function useMedia() {
|
|
|
131
131
|
var mediaQueryList = (0, _MediaQueryUtils.makeMediaQueryList)({
|
|
132
132
|
when: when,
|
|
133
133
|
disabled: disabled,
|
|
134
|
-
log: log
|
|
135
|
-
dismissWarning: true
|
|
134
|
+
log: log
|
|
136
135
|
}, context.breakpoints);
|
|
137
136
|
var event = (0, _MediaQueryUtils.createMediaQueryListener)(mediaQueryList, function (match) {
|
|
138
137
|
if (!disabledRef.current && match) {
|
|
@@ -87,9 +87,11 @@ function useMediaQuery(props) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
if (typeof listenerRef.current === 'function') {
|
|
90
|
+
var _mediaQueryList$curre2;
|
|
91
|
+
|
|
90
92
|
listenerRef.current();
|
|
91
93
|
mediaQueryList.current = (0, _MediaQueryUtils.makeMediaQueryList)(props, context.breakpoints);
|
|
92
|
-
matchUpdate(mediaQueryList.current.matches);
|
|
94
|
+
matchUpdate((_mediaQueryList$curre2 = mediaQueryList.current) === null || _mediaQueryList$curre2 === void 0 ? void 0 : _mediaQueryList$curre2.matches);
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
listenerRef.current = (0, _MediaQueryUtils.createMediaQueryListener)(mediaQueryList.current, function (match) {
|
|
@@ -98,5 +100,5 @@ function useMediaQuery(props) {
|
|
|
98
100
|
return listenerRef.current;
|
|
99
101
|
}, [query, when, not, disabled]);
|
|
100
102
|
|
|
101
|
-
return match;
|
|
103
|
+
return Boolean(match);
|
|
102
104
|
}
|