@dnb/eufemia 9.23.1 → 9.24.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 +17 -0
- package/cjs/components/avatar/Avatar.d.ts +6 -5
- package/cjs/components/avatar/Avatar.js +4 -8
- package/cjs/components/breadcrumb/Breadcrumb.d.ts +0 -6
- package/cjs/components/breadcrumb/Breadcrumb.js +1 -7
- package/cjs/components/dialog/Dialog.d.ts +2 -1
- package/cjs/components/dialog/Dialog.js +79 -51
- package/cjs/components/dialog/DialogContent.d.ts +1 -1
- package/cjs/components/dialog/DialogContent.js +50 -12
- package/cjs/components/dialog/parts/DialogAction.d.ts +34 -0
- package/cjs/components/dialog/parts/DialogAction.js +136 -0
- package/cjs/components/dialog/style/_dialog.scss +152 -72
- package/cjs/components/dialog/style/dnb-dialog.css +352 -199
- package/cjs/components/dialog/style/dnb-dialog.min.css +1 -1
- package/cjs/components/dialog/types.d.ts +20 -2
- package/cjs/components/drawer/style/dnb-drawer.css +177 -100
- package/cjs/components/drawer/style/dnb-drawer.min.css +1 -1
- package/cjs/components/form-status/FormStatus.d.ts +19 -2
- package/cjs/components/form-status/FormStatus.js +27 -3
- package/cjs/components/form-status/style/themes/dnb-form-status-theme-ui.css +16 -0
- package/cjs/components/form-status/style/themes/dnb-form-status-theme-ui.min.css +1 -1
- package/cjs/components/form-status/style/themes/dnb-form-status-theme-ui.scss +7 -0
- package/cjs/components/info-card/InfoCard.d.ts +0 -9
- package/cjs/components/info-card/InfoCard.js +0 -9
- package/cjs/components/modal/Modal.d.ts +1 -0
- package/cjs/components/modal/Modal.js +1 -1
- package/cjs/components/modal/ModalContent.js +13 -5
- package/cjs/components/modal/parts/CloseButton.d.ts +1 -0
- package/cjs/components/modal/style/_modal.scss +1 -0
- package/cjs/components/modal/style/dnb-modal.css +177 -100
- package/cjs/components/modal/style/dnb-modal.min.css +1 -1
- package/cjs/components/modal/types.d.ts +9 -1
- package/cjs/components/number-format/NumberFormat.d.ts +7 -1
- package/cjs/components/number-format/NumberFormat.js +5 -1
- package/cjs/components/number-format/NumberUtils.d.ts +12 -3
- package/cjs/components/number-format/NumberUtils.js +106 -7
- package/cjs/components/tag/Tag.d.ts +5 -6
- package/cjs/components/tag/Tag.js +3 -8
- package/cjs/fragments/drawer-list/DrawerList.js +1 -1
- package/cjs/fragments/drawer-list/DrawerListHelpers.js +3 -1
- package/cjs/shared/Context.d.ts +2 -0
- package/cjs/shared/Context.js +1 -0
- package/cjs/shared/Eufemia.js +1 -1
- package/cjs/shared/locales/en-GB.d.ts +4 -0
- package/cjs/shared/locales/en-GB.js +4 -0
- package/cjs/shared/locales/en-US.d.ts +4 -0
- package/cjs/shared/locales/index.d.ts +8 -0
- package/cjs/shared/locales/nb-NO.d.ts +4 -0
- package/cjs/shared/locales/nb-NO.js +4 -0
- package/cjs/shared/useTranslation.d.ts +1 -0
- package/cjs/style/dnb-ui-components.css +177 -100
- package/cjs/style/dnb-ui-components.min.css +2 -2
- package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.css +16 -0
- package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/cjs/style/themes/theme-ui/dnb-theme-ui.css +16 -0
- package/cjs/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- package/components/avatar/Avatar.d.ts +6 -5
- package/components/avatar/Avatar.js +4 -8
- package/components/breadcrumb/Breadcrumb.d.ts +0 -6
- package/components/breadcrumb/Breadcrumb.js +1 -7
- package/components/dialog/Dialog.d.ts +2 -1
- package/components/dialog/Dialog.js +78 -52
- package/components/dialog/DialogContent.d.ts +1 -1
- package/components/dialog/DialogContent.js +46 -9
- package/components/dialog/parts/DialogAction.d.ts +34 -0
- package/components/dialog/parts/DialogAction.js +96 -0
- package/components/dialog/style/_dialog.scss +152 -72
- package/components/dialog/style/dnb-dialog.css +352 -199
- package/components/dialog/style/dnb-dialog.min.css +1 -1
- package/components/dialog/types.d.ts +20 -2
- package/components/drawer/style/dnb-drawer.css +177 -100
- package/components/drawer/style/dnb-drawer.min.css +1 -1
- package/components/form-status/FormStatus.d.ts +19 -2
- package/components/form-status/FormStatus.js +23 -2
- package/components/form-status/style/themes/dnb-form-status-theme-ui.css +16 -0
- package/components/form-status/style/themes/dnb-form-status-theme-ui.min.css +1 -1
- package/components/form-status/style/themes/dnb-form-status-theme-ui.scss +7 -0
- package/components/info-card/InfoCard.d.ts +0 -9
- package/components/info-card/InfoCard.js +0 -9
- package/components/modal/Modal.d.ts +1 -0
- package/components/modal/Modal.js +1 -1
- package/components/modal/ModalContent.js +13 -5
- package/components/modal/parts/CloseButton.d.ts +1 -0
- package/components/modal/style/_modal.scss +1 -0
- package/components/modal/style/dnb-modal.css +177 -100
- package/components/modal/style/dnb-modal.min.css +1 -1
- package/components/modal/types.d.ts +9 -1
- package/components/number-format/NumberFormat.d.ts +7 -1
- package/components/number-format/NumberFormat.js +5 -1
- package/components/number-format/NumberUtils.d.ts +12 -3
- package/components/number-format/NumberUtils.js +105 -7
- package/components/tag/Tag.d.ts +5 -6
- package/components/tag/Tag.js +3 -8
- package/es/components/avatar/Avatar.d.ts +6 -5
- package/es/components/avatar/Avatar.js +5 -9
- package/es/components/breadcrumb/Breadcrumb.d.ts +0 -6
- package/es/components/breadcrumb/Breadcrumb.js +1 -7
- package/es/components/dialog/Dialog.d.ts +2 -1
- package/es/components/dialog/Dialog.js +50 -22
- package/es/components/dialog/DialogContent.d.ts +1 -1
- package/es/components/dialog/DialogContent.js +40 -8
- package/es/components/dialog/parts/DialogAction.d.ts +34 -0
- package/es/components/dialog/parts/DialogAction.js +82 -0
- package/es/components/dialog/style/_dialog.scss +152 -72
- package/es/components/dialog/style/dnb-dialog.css +352 -199
- package/es/components/dialog/style/dnb-dialog.min.css +1 -1
- package/es/components/dialog/types.d.ts +20 -2
- package/es/components/drawer/style/dnb-drawer.css +177 -100
- package/es/components/drawer/style/dnb-drawer.min.css +1 -1
- package/es/components/form-status/FormStatus.d.ts +19 -2
- package/es/components/form-status/FormStatus.js +21 -2
- package/es/components/form-status/style/themes/dnb-form-status-theme-ui.css +16 -0
- package/es/components/form-status/style/themes/dnb-form-status-theme-ui.min.css +1 -1
- package/es/components/form-status/style/themes/dnb-form-status-theme-ui.scss +7 -0
- package/es/components/info-card/InfoCard.d.ts +0 -9
- package/es/components/info-card/InfoCard.js +0 -9
- package/es/components/modal/Modal.d.ts +1 -0
- package/es/components/modal/Modal.js +1 -1
- package/es/components/modal/ModalContent.js +13 -6
- package/es/components/modal/parts/CloseButton.d.ts +1 -0
- package/es/components/modal/style/_modal.scss +1 -0
- package/es/components/modal/style/dnb-modal.css +177 -100
- package/es/components/modal/style/dnb-modal.min.css +1 -1
- package/es/components/modal/types.d.ts +9 -1
- package/es/components/number-format/NumberFormat.d.ts +7 -1
- package/es/components/number-format/NumberFormat.js +5 -1
- package/es/components/number-format/NumberUtils.d.ts +12 -3
- package/es/components/number-format/NumberUtils.js +101 -7
- package/es/components/tag/Tag.d.ts +5 -6
- package/es/components/tag/Tag.js +3 -8
- package/es/fragments/drawer-list/DrawerList.js +1 -1
- package/es/fragments/drawer-list/DrawerListHelpers.js +3 -1
- package/es/shared/Context.d.ts +2 -0
- package/es/shared/Context.js +1 -0
- package/es/shared/Eufemia.js +1 -1
- package/es/shared/locales/en-GB.d.ts +4 -0
- package/es/shared/locales/en-GB.js +4 -0
- package/es/shared/locales/en-US.d.ts +4 -0
- package/es/shared/locales/index.d.ts +8 -0
- package/es/shared/locales/nb-NO.d.ts +4 -0
- package/es/shared/locales/nb-NO.js +4 -0
- package/es/shared/useTranslation.d.ts +1 -0
- package/es/style/dnb-ui-components.css +177 -100
- package/es/style/dnb-ui-components.min.css +2 -2
- package/es/style/themes/theme-open-banking/dnb-theme-open-banking.css +16 -0
- package/es/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/es/style/themes/theme-ui/dnb-theme-ui.css +16 -0
- package/es/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- 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 +1 -1
- package/esm/dnb-ui-extensions.min.mjs +3 -3
- package/esm/dnb-ui-lib.min.mjs +3 -3
- package/esm/dnb-ui-web-components.min.mjs +2 -2
- package/fragments/drawer-list/DrawerList.js +1 -1
- package/fragments/drawer-list/DrawerListHelpers.js +3 -1
- package/package.json +1 -1
- package/shared/Context.d.ts +2 -0
- package/shared/Context.js +1 -0
- package/shared/Eufemia.js +1 -1
- package/shared/locales/en-GB.d.ts +4 -0
- package/shared/locales/en-GB.js +4 -0
- package/shared/locales/en-US.d.ts +4 -0
- package/shared/locales/index.d.ts +8 -0
- package/shared/locales/nb-NO.d.ts +4 -0
- package/shared/locales/nb-NO.js +4 -0
- package/shared/useTranslation.d.ts +1 -0
- package/style/dnb-ui-components.css +177 -100
- package/style/dnb-ui-components.min.css +2 -2
- package/style/themes/theme-open-banking/dnb-theme-open-banking.css +16 -0
- package/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/style/themes/theme-ui/dnb-theme-ui.css +16 -0
- package/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- 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 +1 -1
- package/umd/dnb-ui-extensions.min.js +2 -2
- package/umd/dnb-ui-lib.min.js +4 -4
- package/umd/dnb-ui-web-components.min.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
All notable changes to @dnb/eufemia will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [9.24.0](https://github.com/dnbexperience/eufemia/compare/v9.23.1...v9.24.0) (2022-03-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **Dialog:** set role alertdialog for confirmation variant ([8ec99af](https://github.com/dnbexperience/eufemia/commit/8ec99afb5f8ea385aae45e25880c6a71e04e6579))
|
|
12
|
+
* **Dropdown:** fix empty data entry handling ([4e4762b](https://github.com/dnbexperience/eufemia/commit/4e4762be4c6c4f1ebdc1c122922d44ef620bb3dc))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **Avatar:** add hasLabel to omit group warning ([#1318](https://github.com/dnbexperience/eufemia/issues/1318)) ([ed43481](https://github.com/dnbexperience/eufemia/commit/ed434810ae0cefdb6ae943a2b463fee90756dc55))
|
|
18
|
+
* **Dialog:** add new variant confirmation ([#1302](https://github.com/dnbexperience/eufemia/issues/1302)) ([bdb7bb4](https://github.com/dnbexperience/eufemia/commit/bdb7bb4275f2c6f95e8448f85219be3637f2fa7b))
|
|
19
|
+
* **FormStatus:** add new marketing state/status ([#1317](https://github.com/dnbexperience/eufemia/issues/1317)) ([f5e63a9](https://github.com/dnbexperience/eufemia/commit/f5e63a9897cbc62f035ede523a99b3198eecd501))
|
|
20
|
+
* **NumberFormat:** add "compact" property – format a number compact with an abbreviation ([0e26449](https://github.com/dnbexperience/eufemia/commit/0e26449fee5c1f4fdf02b619d5a46080829a64be))
|
|
21
|
+
* **Tag:** omit non-existing group warning with new prop: hasLabel ([079cdcd](https://github.com/dnbexperience/eufemia/commit/079cdcd2cca2185620cf07a49c581f55fdf4d204))
|
|
22
|
+
|
|
6
23
|
## [9.23.1](https://github.com/dnbexperience/eufemia/compare/v9.23.0...v9.23.1) (2022-02-23)
|
|
7
24
|
|
|
8
25
|
|
|
@@ -46,16 +46,17 @@ export interface AvatarProps {
|
|
|
46
46
|
* Default: primary.
|
|
47
47
|
*/
|
|
48
48
|
variant?: AvatarVariants;
|
|
49
|
+
/**
|
|
50
|
+
* If an avatar is hidden from the screen reader (by setting aria-hidden="true") or if label is given, typical inside a table or dl (definition list), then you can disable Avatar.Group as a dependent of Avatar.
|
|
51
|
+
* Use `true` to omit the `Avatar group required:` warning.
|
|
52
|
+
* Default: null
|
|
53
|
+
*/
|
|
54
|
+
hasLabel?: boolean;
|
|
49
55
|
}
|
|
50
56
|
export declare const defaultProps: {
|
|
51
|
-
alt: any;
|
|
52
|
-
className: any;
|
|
53
57
|
size: string;
|
|
54
|
-
src: any;
|
|
55
|
-
imgProps: any;
|
|
56
58
|
variant: string;
|
|
57
59
|
skeleton: boolean;
|
|
58
|
-
children: any;
|
|
59
60
|
};
|
|
60
61
|
declare const Avatar: {
|
|
61
62
|
(localProps: AvatarProps & ISpacingProps): JSX.Element;
|
|
@@ -63,7 +63,7 @@ var _hooks = require("../../shared/hooks");
|
|
|
63
63
|
|
|
64
64
|
var _AvatarGroup = _interopRequireWildcard(require("./AvatarGroup"));
|
|
65
65
|
|
|
66
|
-
var _excluded = ["alt", "className", "children", "size", "skeleton", "variant", "src", "imgProps"];
|
|
66
|
+
var _excluded = ["alt", "className", "children", "size", "skeleton", "variant", "src", "imgProps", "hasLabel"];
|
|
67
67
|
|
|
68
68
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
69
69
|
|
|
@@ -84,14 +84,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
84
84
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
85
85
|
|
|
86
86
|
var defaultProps = {
|
|
87
|
-
alt: null,
|
|
88
|
-
className: null,
|
|
89
87
|
size: 'medium',
|
|
90
|
-
src: null,
|
|
91
|
-
imgProps: null,
|
|
92
88
|
variant: 'primary',
|
|
93
|
-
skeleton: false
|
|
94
|
-
children: null
|
|
89
|
+
skeleton: false
|
|
95
90
|
};
|
|
96
91
|
exports.defaultProps = defaultProps;
|
|
97
92
|
|
|
@@ -109,6 +104,7 @@ var Avatar = function Avatar(localProps) {
|
|
|
109
104
|
variant = _usePropsWithContext.variant,
|
|
110
105
|
src = _usePropsWithContext.src,
|
|
111
106
|
imgProps = _usePropsWithContext.imgProps,
|
|
107
|
+
hasLabel = _usePropsWithContext.hasLabel,
|
|
112
108
|
props = _objectWithoutProperties(_usePropsWithContext, _excluded);
|
|
113
109
|
|
|
114
110
|
var children = null;
|
|
@@ -133,7 +129,7 @@ var Avatar = function Avatar(localProps) {
|
|
|
133
129
|
children = childrenProp;
|
|
134
130
|
}
|
|
135
131
|
|
|
136
|
-
if (!avatarGroupContext) {
|
|
132
|
+
if (!avatarGroupContext && !hasLabel) {
|
|
137
133
|
(0, _componentHelper.warn)("Avatar group required: An Avatar requires an Avatar.Group with label description as a parent component. This is to ensure correct semantic and accessibility.");
|
|
138
134
|
}
|
|
139
135
|
|
|
@@ -80,12 +80,7 @@ export interface BreadcrumbProps {
|
|
|
80
80
|
spacing?: boolean;
|
|
81
81
|
}
|
|
82
82
|
export declare const defaultProps: {
|
|
83
|
-
className: any;
|
|
84
83
|
skeleton: boolean;
|
|
85
|
-
children: any;
|
|
86
|
-
variant: any;
|
|
87
|
-
onClick: any;
|
|
88
|
-
href: any;
|
|
89
84
|
navText: string;
|
|
90
85
|
goBackText: string;
|
|
91
86
|
homeText: string;
|
|
@@ -93,7 +88,6 @@ export declare const defaultProps: {
|
|
|
93
88
|
isCollapsed: boolean;
|
|
94
89
|
styleType: string;
|
|
95
90
|
collapsedStyleType: string;
|
|
96
|
-
data: any;
|
|
97
91
|
spacing: boolean;
|
|
98
92
|
};
|
|
99
93
|
declare const Breadcrumb: {
|
|
@@ -96,12 +96,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
96
96
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
97
97
|
|
|
98
98
|
var defaultProps = {
|
|
99
|
-
className: null,
|
|
100
99
|
skeleton: false,
|
|
101
|
-
children: null,
|
|
102
|
-
variant: null,
|
|
103
|
-
onClick: null,
|
|
104
|
-
href: null,
|
|
105
100
|
navText: 'Back',
|
|
106
101
|
goBackText: 'Back',
|
|
107
102
|
homeText: 'Home',
|
|
@@ -109,7 +104,6 @@ var defaultProps = {
|
|
|
109
104
|
isCollapsed: true,
|
|
110
105
|
styleType: 'transparent',
|
|
111
106
|
collapsedStyleType: 'pistachio',
|
|
112
|
-
data: null,
|
|
113
107
|
spacing: false
|
|
114
108
|
};
|
|
115
109
|
exports.defaultProps = defaultProps;
|
|
@@ -153,7 +147,7 @@ var Breadcrumb = function Breadcrumb(localProps) {
|
|
|
153
147
|
});
|
|
154
148
|
var currentVariant = variant;
|
|
155
149
|
|
|
156
|
-
if (variant
|
|
150
|
+
if (!variant) {
|
|
157
151
|
if (childrenItems || data) {
|
|
158
152
|
currentVariant = isSmallScreen ? 'collapse' : 'multiple';
|
|
159
153
|
} else {
|
|
@@ -3,10 +3,11 @@ import DialogBody from './parts/DialogBody';
|
|
|
3
3
|
import DialogHeader from './parts/DialogHeader';
|
|
4
4
|
import DialogNavigation from './parts/DialogNavigation';
|
|
5
5
|
import { DialogProps, DialogContentProps } from './types';
|
|
6
|
-
declare function Dialog(
|
|
6
|
+
declare function Dialog(localProps: DialogProps & DialogContentProps): JSX.Element;
|
|
7
7
|
declare namespace Dialog {
|
|
8
8
|
var Body: typeof DialogBody;
|
|
9
9
|
var Header: typeof DialogHeader;
|
|
10
10
|
var Navigation: typeof DialogNavigation;
|
|
11
|
+
var Action: ({ declineText, confirmText, hideDecline, onConfirm, onDecline, children, }: import("./parts/DialogAction").DialogActionProps) => JSX.Element;
|
|
11
12
|
}
|
|
12
13
|
export default Dialog;
|
|
@@ -53,9 +53,11 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
53
53
|
|
|
54
54
|
var _Context = _interopRequireDefault(require("../../shared/Context"));
|
|
55
55
|
|
|
56
|
-
var
|
|
56
|
+
var _DialogAction = _interopRequireDefault(require("./parts/DialogAction"));
|
|
57
57
|
|
|
58
|
-
var
|
|
58
|
+
var _hooks = require("../../shared/hooks");
|
|
59
|
+
|
|
60
|
+
var _excluded = ["id", "rootId", "contentId", "focusSelector", "labelledBy", "directDomReturn", "closeButtonAttributes", "disabled", "variant", "title", "dialogTitle", "closeTitle", "spacing", "noAnimation", "noAnimationOnMobile", "animationDuration", "triggerAttributes", "hideCloseButton", "fullscreen", "onOpen", "onClose", "onClosePrevent", "openModal", "closeModal", "preventClose", "openState", "openDelay", "trigger", "overlayClass", "contentClass", "top", "bottom", "left", "right", "space"];
|
|
59
61
|
|
|
60
62
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
61
63
|
|
|
@@ -75,47 +77,68 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
75
77
|
|
|
76
78
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
focusSelector = _ref.focusSelector,
|
|
83
|
-
labelledBy = _ref.labelledBy,
|
|
84
|
-
directDomReturn = _ref.directDomReturn,
|
|
85
|
-
hideCloseButton = _ref.hideCloseButton,
|
|
86
|
-
closeButtonAttributes = _ref.closeButtonAttributes,
|
|
87
|
-
disabled = _ref.disabled,
|
|
88
|
-
title = _ref.title,
|
|
89
|
-
dialogTitle = _ref.dialogTitle,
|
|
90
|
-
closeTitle = _ref.closeTitle,
|
|
91
|
-
_ref$spacing = _ref.spacing,
|
|
92
|
-
spacing = _ref$spacing === void 0 ? true : _ref$spacing,
|
|
93
|
-
noAnimation = _ref.noAnimation,
|
|
94
|
-
noAnimationOnMobile = _ref.noAnimationOnMobile,
|
|
95
|
-
animationDuration = _ref.animationDuration,
|
|
96
|
-
_ref$fullscreen = _ref.fullscreen,
|
|
97
|
-
fullscreen = _ref$fullscreen === void 0 ? 'auto' : _ref$fullscreen,
|
|
98
|
-
onOpen = _ref.onOpen,
|
|
99
|
-
onClose = _ref.onClose,
|
|
100
|
-
onClosePrevent = _ref.onClosePrevent,
|
|
101
|
-
openModal = _ref.openModal,
|
|
102
|
-
closeModal = _ref.closeModal,
|
|
103
|
-
preventClose = _ref.preventClose,
|
|
104
|
-
openState = _ref.openState,
|
|
105
|
-
openDelay = _ref.openDelay,
|
|
106
|
-
trigger = _ref.trigger,
|
|
107
|
-
triggerAttributes = _ref.triggerAttributes,
|
|
108
|
-
overlayClass = _ref.overlayClass,
|
|
109
|
-
contentClass = _ref.contentClass,
|
|
110
|
-
top = _ref.top,
|
|
111
|
-
bottom = _ref.bottom,
|
|
112
|
-
left = _ref.left,
|
|
113
|
-
right = _ref.right,
|
|
114
|
-
space = _ref.space,
|
|
115
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
80
|
+
var defaultProps = {
|
|
81
|
+
variant: 'information',
|
|
82
|
+
spacing: true
|
|
83
|
+
};
|
|
116
84
|
|
|
85
|
+
function Dialog(localProps) {
|
|
117
86
|
var context = (0, _react.useContext)(_Context.default);
|
|
118
|
-
var
|
|
87
|
+
var propsWithContext = (0, _hooks.usePropsWithContext)(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.Dialog);
|
|
88
|
+
|
|
89
|
+
var id = propsWithContext.id,
|
|
90
|
+
rootId = propsWithContext.rootId,
|
|
91
|
+
contentId = propsWithContext.contentId,
|
|
92
|
+
focusSelector = propsWithContext.focusSelector,
|
|
93
|
+
labelledBy = propsWithContext.labelledBy,
|
|
94
|
+
directDomReturn = propsWithContext.directDomReturn,
|
|
95
|
+
closeButtonAttributes = propsWithContext.closeButtonAttributes,
|
|
96
|
+
disabled = propsWithContext.disabled,
|
|
97
|
+
variant = propsWithContext.variant,
|
|
98
|
+
title = propsWithContext.title,
|
|
99
|
+
dialogTitle = propsWithContext.dialogTitle,
|
|
100
|
+
closeTitle = propsWithContext.closeTitle,
|
|
101
|
+
spacing = propsWithContext.spacing,
|
|
102
|
+
noAnimation = propsWithContext.noAnimation,
|
|
103
|
+
noAnimationOnMobile = propsWithContext.noAnimationOnMobile,
|
|
104
|
+
animationDuration = propsWithContext.animationDuration,
|
|
105
|
+
triggerAttributes = propsWithContext.triggerAttributes,
|
|
106
|
+
hideCloseButton = propsWithContext.hideCloseButton,
|
|
107
|
+
fullscreen = propsWithContext.fullscreen,
|
|
108
|
+
onOpen = propsWithContext.onOpen,
|
|
109
|
+
onClose = propsWithContext.onClose,
|
|
110
|
+
onClosePrevent = propsWithContext.onClosePrevent,
|
|
111
|
+
openModal = propsWithContext.openModal,
|
|
112
|
+
closeModal = propsWithContext.closeModal,
|
|
113
|
+
preventClose = propsWithContext.preventClose,
|
|
114
|
+
openState = propsWithContext.openState,
|
|
115
|
+
openDelay = propsWithContext.openDelay,
|
|
116
|
+
trigger = propsWithContext.trigger,
|
|
117
|
+
overlayClass = propsWithContext.overlayClass,
|
|
118
|
+
contentClass = propsWithContext.contentClass,
|
|
119
|
+
top = propsWithContext.top,
|
|
120
|
+
bottom = propsWithContext.bottom,
|
|
121
|
+
left = propsWithContext.left,
|
|
122
|
+
right = propsWithContext.right,
|
|
123
|
+
space = propsWithContext.space,
|
|
124
|
+
props = _objectWithoutProperties(propsWithContext, _excluded);
|
|
125
|
+
|
|
126
|
+
var currentHideCloseButton = hideCloseButton;
|
|
127
|
+
var currentTriggerAttributes = triggerAttributes;
|
|
128
|
+
var currentFullscreen = fullscreen;
|
|
129
|
+
|
|
130
|
+
if (variant === 'confirmation') {
|
|
131
|
+
currentHideCloseButton = hideCloseButton !== undefined ? hideCloseButton : true;
|
|
132
|
+
currentTriggerAttributes = triggerAttributes || {
|
|
133
|
+
hidden: true
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (fullscreen === undefined) {
|
|
138
|
+
currentFullscreen = variant === 'information' ? 'auto' : false;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
var modalProps = {
|
|
119
142
|
title: title,
|
|
120
143
|
id: id,
|
|
121
144
|
focusSelector: focusSelector,
|
|
@@ -126,13 +149,13 @@ function Dialog(_ref) {
|
|
|
126
149
|
contentId: contentId,
|
|
127
150
|
dialogTitle: dialogTitle,
|
|
128
151
|
closeTitle: closeTitle,
|
|
129
|
-
hideCloseButton:
|
|
152
|
+
hideCloseButton: currentHideCloseButton,
|
|
130
153
|
closeButtonAttributes: closeButtonAttributes,
|
|
131
154
|
preventClose: preventClose,
|
|
132
155
|
animationDuration: animationDuration,
|
|
133
156
|
noAnimation: noAnimation,
|
|
134
157
|
noAnimationOnMobile: noAnimationOnMobile,
|
|
135
|
-
fullscreen:
|
|
158
|
+
fullscreen: currentFullscreen,
|
|
136
159
|
openState: openState,
|
|
137
160
|
directDomReturn: directDomReturn,
|
|
138
161
|
rootId: rootId,
|
|
@@ -142,28 +165,33 @@ function Dialog(_ref) {
|
|
|
142
165
|
openModal: openModal,
|
|
143
166
|
closeModal: closeModal,
|
|
144
167
|
trigger: trigger,
|
|
145
|
-
triggerAttributes:
|
|
168
|
+
triggerAttributes: currentTriggerAttributes,
|
|
146
169
|
overlayClass: overlayClass,
|
|
147
170
|
top: top,
|
|
148
171
|
bottom: bottom,
|
|
149
172
|
left: left,
|
|
150
173
|
right: right,
|
|
151
174
|
space: space
|
|
152
|
-
}
|
|
153
|
-
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
var dialogProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
154
178
|
noAnimation: noAnimation,
|
|
155
179
|
noAnimationOnMobile: noAnimationOnMobile,
|
|
156
|
-
fullscreen:
|
|
157
|
-
spacing: spacing
|
|
158
|
-
|
|
159
|
-
|
|
180
|
+
fullscreen: currentFullscreen,
|
|
181
|
+
spacing: spacing,
|
|
182
|
+
variant: variant
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
return _react.default.createElement(_Modal.default, _extends({}, modalProps, {
|
|
160
186
|
mode: "custom",
|
|
187
|
+
dialogRole: variant == 'information' ? 'dialog' : 'alertdialog',
|
|
161
188
|
contentClass: (0, _classnames.default)('dnb-dialog__root', contentClass)
|
|
162
|
-
}), _react.default.createElement(_DialogContent.default,
|
|
189
|
+
}), _react.default.createElement(_DialogContent.default, dialogProps));
|
|
163
190
|
}
|
|
164
191
|
|
|
165
192
|
Dialog.Body = _DialogBody.default;
|
|
166
193
|
Dialog.Header = _DialogHeader.default;
|
|
167
194
|
Dialog.Navigation = _DialogNavigation.default;
|
|
195
|
+
Dialog.Action = _DialogAction.default;
|
|
168
196
|
var _default = Dialog;
|
|
169
197
|
exports.default = _default;
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/// <reference types="react" />
|
|
6
6
|
import { DialogContentProps } from './types';
|
|
7
|
-
export default function DialogContent({ modalContent, navContent, headerContent, alignContent, className, class: _className, preventCoreStyle, spacing, fullscreen, noAnimation, noAnimationOnMobile, minWidth: min_width, maxWidth: max_width, ...rest }: DialogContentProps): JSX.Element;
|
|
7
|
+
export default function DialogContent({ modalContent, navContent, headerContent, alignContent, className, class: _className, preventCoreStyle, spacing, fullscreen, noAnimation, noAnimationOnMobile, minWidth: min_width, maxWidth: max_width, variant, confirmType, icon, description, hideDecline, onConfirm, onDecline, declineText, confirmText, ...rest }: DialogContentProps): JSX.Element;
|
|
@@ -6,8 +6,6 @@ require("core-js/modules/es.object.keys.js");
|
|
|
6
6
|
|
|
7
7
|
require("core-js/modules/es.array.index-of.js");
|
|
8
8
|
|
|
9
|
-
require("core-js/modules/es.symbol.js");
|
|
10
|
-
|
|
11
9
|
require("core-js/modules/es.array.filter.js");
|
|
12
10
|
|
|
13
11
|
require("core-js/modules/es.object.to-string.js");
|
|
@@ -26,8 +24,6 @@ require("core-js/modules/es.weak-map.js");
|
|
|
26
24
|
|
|
27
25
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
28
26
|
|
|
29
|
-
require("core-js/modules/es.symbol.description.js");
|
|
30
|
-
|
|
31
27
|
require("core-js/modules/es.symbol.iterator.js");
|
|
32
28
|
|
|
33
29
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -35,6 +31,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
35
31
|
});
|
|
36
32
|
exports.default = DialogContent;
|
|
37
33
|
|
|
34
|
+
require("core-js/modules/es.symbol.js");
|
|
35
|
+
|
|
36
|
+
require("core-js/modules/es.symbol.description.js");
|
|
37
|
+
|
|
38
38
|
require("core-js/modules/es.object.freeze.js");
|
|
39
39
|
|
|
40
40
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -49,6 +49,8 @@ var _DialogHeader = _interopRequireDefault(require("./parts/DialogHeader"));
|
|
|
49
49
|
|
|
50
50
|
var _DialogNavigation = _interopRequireDefault(require("./parts/DialogNavigation"));
|
|
51
51
|
|
|
52
|
+
var _DialogAction = _interopRequireDefault(require("./parts/DialogAction"));
|
|
53
|
+
|
|
52
54
|
var _helpers = require("../modal/helpers");
|
|
53
55
|
|
|
54
56
|
var _ModalContext = _interopRequireDefault(require("../modal/ModalContext"));
|
|
@@ -59,7 +61,9 @@ var _ModalHeaderBar = _interopRequireDefault(require("../modal/parts/ModalHeader
|
|
|
59
61
|
|
|
60
62
|
var _ModalHeader = _interopRequireDefault(require("../modal/parts/ModalHeader"));
|
|
61
63
|
|
|
62
|
-
var
|
|
64
|
+
var _IconPrimary = _interopRequireDefault(require("../icon-primary/IconPrimary"));
|
|
65
|
+
|
|
66
|
+
var _excluded = ["modalContent", "navContent", "headerContent", "alignContent", "className", "class", "preventCoreStyle", "spacing", "fullscreen", "noAnimation", "noAnimationOnMobile", "minWidth", "maxWidth", "variant", "confirmType", "icon", "description", "hideDecline", "onConfirm", "onDecline", "declineText", "confirmText"];
|
|
63
67
|
|
|
64
68
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
65
69
|
|
|
@@ -85,7 +89,7 @@ function DialogContent(_ref) {
|
|
|
85
89
|
_ref$headerContent = _ref.headerContent,
|
|
86
90
|
headerContent = _ref$headerContent === void 0 ? null : _ref$headerContent,
|
|
87
91
|
_ref$alignContent = _ref.alignContent,
|
|
88
|
-
alignContent = _ref$alignContent === void 0 ?
|
|
92
|
+
alignContent = _ref$alignContent === void 0 ? null : _ref$alignContent,
|
|
89
93
|
_ref$className = _ref.className,
|
|
90
94
|
className = _ref$className === void 0 ? null : _ref$className,
|
|
91
95
|
_ref$class = _ref.class,
|
|
@@ -94,8 +98,7 @@ function DialogContent(_ref) {
|
|
|
94
98
|
preventCoreStyle = _ref$preventCoreStyle === void 0 ? null : _ref$preventCoreStyle,
|
|
95
99
|
_ref$spacing = _ref.spacing,
|
|
96
100
|
spacing = _ref$spacing === void 0 ? true : _ref$spacing,
|
|
97
|
-
|
|
98
|
-
fullscreen = _ref$fullscreen === void 0 ? 'auto' : _ref$fullscreen,
|
|
101
|
+
fullscreen = _ref.fullscreen,
|
|
99
102
|
_ref$noAnimation = _ref.noAnimation,
|
|
100
103
|
noAnimation = _ref$noAnimation === void 0 ? false : _ref$noAnimation,
|
|
101
104
|
_ref$noAnimationOnMob = _ref.noAnimationOnMobile,
|
|
@@ -104,6 +107,18 @@ function DialogContent(_ref) {
|
|
|
104
107
|
min_width = _ref$minWidth === void 0 ? null : _ref$minWidth,
|
|
105
108
|
_ref$maxWidth = _ref.maxWidth,
|
|
106
109
|
max_width = _ref$maxWidth === void 0 ? null : _ref$maxWidth,
|
|
110
|
+
_ref$variant = _ref.variant,
|
|
111
|
+
variant = _ref$variant === void 0 ? 'information' : _ref$variant,
|
|
112
|
+
_ref$confirmType = _ref.confirmType,
|
|
113
|
+
confirmType = _ref$confirmType === void 0 ? 'info' : _ref$confirmType,
|
|
114
|
+
_ref$icon = _ref.icon,
|
|
115
|
+
icon = _ref$icon === void 0 ? null : _ref$icon,
|
|
116
|
+
description = _ref.description,
|
|
117
|
+
hideDecline = _ref.hideDecline,
|
|
118
|
+
onConfirm = _ref.onConfirm,
|
|
119
|
+
onDecline = _ref.onDecline,
|
|
120
|
+
declineText = _ref.declineText,
|
|
121
|
+
confirmText = _ref.confirmText,
|
|
107
122
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
108
123
|
|
|
109
124
|
var context = (0, _react.useContext)(_ModalContext.default);
|
|
@@ -116,8 +131,12 @@ function DialogContent(_ref) {
|
|
|
116
131
|
close: context === null || context === void 0 ? void 0 : context.close
|
|
117
132
|
})) : rest);
|
|
118
133
|
|
|
134
|
+
if (alignContent === null) {
|
|
135
|
+
alignContent = variant === 'information' ? 'left' : 'centered';
|
|
136
|
+
}
|
|
137
|
+
|
|
119
138
|
var innerParams = _objectSpread({
|
|
120
|
-
className: (0, _classnames.default)('dnb-dialog', (0, _componentHelper.isTrue)(fullscreen) ? "dnb-dialog--fullscreen" : fullscreen === 'auto' && "dnb-dialog--auto-fullscreen", className, _className, !(0, _componentHelper.isTrue)(preventCoreStyle) && 'dnb-core-style', (0, _componentHelper.isTrue)(spacing) && 'dnb-dialog--spacing', alignContent && "dnb-dialog__align--".concat(alignContent), (0, _componentHelper.isTrue)(context === null || context === void 0 ? void 0 : context.hide) && "dnb-dialog--hide", (0, _componentHelper.isTrue)(noAnimation) && "dnb-dialog--no-animation", (0, _componentHelper.isTrue)(noAnimationOnMobile) && "dnb-dialog--no-animation-on-mobile"),
|
|
139
|
+
className: (0, _classnames.default)('dnb-dialog', (0, _componentHelper.isTrue)(fullscreen) ? "dnb-dialog--fullscreen" : fullscreen === 'auto' && "dnb-dialog--auto-fullscreen", className, _className, !(0, _componentHelper.isTrue)(preventCoreStyle) && 'dnb-core-style', variant && "dnb-dialog--".concat(variant), (0, _componentHelper.isTrue)(spacing) && 'dnb-dialog--spacing', alignContent && "dnb-dialog__align--".concat(alignContent), (0, _componentHelper.isTrue)(context === null || context === void 0 ? void 0 : context.hide) && "dnb-dialog--hide", (0, _componentHelper.isTrue)(noAnimation) && "dnb-dialog--no-animation", (0, _componentHelper.isTrue)(noAnimationOnMobile) && "dnb-dialog--no-animation-on-mobile"),
|
|
121
140
|
style: (minWidth || maxWidth) && {
|
|
122
141
|
minWidth: minWidth,
|
|
123
142
|
maxWidth: maxWidth
|
|
@@ -133,14 +152,33 @@ function DialogContent(_ref) {
|
|
|
133
152
|
var headerExists = (0, _componentHelper.findElementInChildren)(content, function (cur) {
|
|
134
153
|
return cur.type === _DialogHeader.default || cur.type === _ModalHeader.default;
|
|
135
154
|
});
|
|
155
|
+
var actionExists = (0, _componentHelper.findElementInChildren)(content, function (cur) {
|
|
156
|
+
return cur.type === _DialogAction.default;
|
|
157
|
+
});
|
|
158
|
+
var dialogActionProps = {
|
|
159
|
+
onConfirm: onConfirm,
|
|
160
|
+
onDecline: onDecline,
|
|
161
|
+
declineText: declineText,
|
|
162
|
+
confirmText: confirmText,
|
|
163
|
+
hideDecline: hideDecline
|
|
164
|
+
};
|
|
136
165
|
return _react.default.createElement(_ScrollView.default, innerParams, _react.default.createElement("div", {
|
|
137
166
|
tabIndex: -1,
|
|
138
167
|
className: "dnb-dialog__inner dnb-no-focus",
|
|
139
168
|
ref: context === null || context === void 0 ? void 0 : context.contentRef
|
|
140
|
-
}, !navExists && _react.default.createElement(_DialogNavigation.default, null, navContent),
|
|
141
|
-
|
|
169
|
+
}, !navExists && _react.default.createElement(_DialogNavigation.default, null, navContent), icon && _react.default.createElement("div", {
|
|
170
|
+
className: "dnb-dialog__icon"
|
|
171
|
+
}, _react.default.createElement(_IconPrimary.default, {
|
|
172
|
+
border: true,
|
|
173
|
+
key: "dialog-icon",
|
|
174
|
+
icon: icon,
|
|
175
|
+
"aria-hidden": true,
|
|
176
|
+
className: (0, _classnames.default)('dnb-dialog__icon__primary', 'dnb-dialog__icon--' + confirmType)
|
|
177
|
+
})), !headerExists && _react.default.createElement(_DialogHeader.default, {
|
|
178
|
+
title: context === null || context === void 0 ? void 0 : context.title,
|
|
179
|
+
size: variant === 'information' ? 'x-large' : 'large'
|
|
142
180
|
}, headerContent), _react.default.createElement("div", {
|
|
143
181
|
id: (context === null || context === void 0 ? void 0 : context.contentId) + '-content',
|
|
144
182
|
className: "dnb-dialog__content"
|
|
145
|
-
}, content)));
|
|
183
|
+
}, description, content), variant === 'confirmation' && !actionExists && _react.default.createElement(_DialogAction.default, dialogActionProps)));
|
|
146
184
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type extendedMouseEvent = {
|
|
3
|
+
event: React.MouseEvent<HTMLElement>;
|
|
4
|
+
close: () => void;
|
|
5
|
+
};
|
|
6
|
+
interface DialogActionProps {
|
|
7
|
+
/**
|
|
8
|
+
* For dialog actions, give a custom text for the decline button.
|
|
9
|
+
*/
|
|
10
|
+
declineText?: string;
|
|
11
|
+
/**
|
|
12
|
+
* For dialog actions, give a custom text for the confirm button.
|
|
13
|
+
*/
|
|
14
|
+
confirmText?: string;
|
|
15
|
+
/**
|
|
16
|
+
* For variant confirmation, handle the confirm action click.
|
|
17
|
+
*/
|
|
18
|
+
onConfirm?: (event: extendedMouseEvent) => void;
|
|
19
|
+
/**
|
|
20
|
+
* For variant confirmation, handle the decline action click.
|
|
21
|
+
*/
|
|
22
|
+
onDecline?: (event: extendedMouseEvent) => void;
|
|
23
|
+
/**
|
|
24
|
+
* For variant confirmation, hide the default decline button and only show the confirm button.
|
|
25
|
+
*/
|
|
26
|
+
hideDecline?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Pass in custom confirm/decline buttons for action handling. Every child of type Button will be provided with a `close` function attribute.
|
|
29
|
+
*/
|
|
30
|
+
children?: React.ReactElement | Array<React.ReactElement>;
|
|
31
|
+
}
|
|
32
|
+
declare const DialogAction: ({ declineText, confirmText, hideDecline, onConfirm, onDecline, children, }: DialogActionProps) => JSX.Element;
|
|
33
|
+
export default DialogAction;
|
|
34
|
+
export type { DialogActionProps };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
require("core-js/modules/es.object.keys.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.symbol.js");
|
|
8
|
+
|
|
9
|
+
require("core-js/modules/es.array.filter.js");
|
|
10
|
+
|
|
11
|
+
require("core-js/modules/es.object.to-string.js");
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
14
|
+
|
|
15
|
+
require("core-js/modules/web.dom-collections.for-each.js");
|
|
16
|
+
|
|
17
|
+
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
18
|
+
|
|
19
|
+
require("core-js/modules/es.array.iterator.js");
|
|
20
|
+
|
|
21
|
+
require("core-js/modules/es.string.iterator.js");
|
|
22
|
+
|
|
23
|
+
require("core-js/modules/es.weak-map.js");
|
|
24
|
+
|
|
25
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
26
|
+
|
|
27
|
+
require("core-js/modules/es.symbol.description.js");
|
|
28
|
+
|
|
29
|
+
require("core-js/modules/es.symbol.iterator.js");
|
|
30
|
+
|
|
31
|
+
Object.defineProperty(exports, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
});
|
|
34
|
+
exports.default = void 0;
|
|
35
|
+
|
|
36
|
+
require("core-js/modules/es.array.map.js");
|
|
37
|
+
|
|
38
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
39
|
+
|
|
40
|
+
var _Button = _interopRequireDefault(require("../../button/Button"));
|
|
41
|
+
|
|
42
|
+
var _shared = require("../../../shared");
|
|
43
|
+
|
|
44
|
+
var _ModalContext = _interopRequireDefault(require("../../modal/ModalContext"));
|
|
45
|
+
|
|
46
|
+
var _componentHelper = require("../../../shared/component-helper");
|
|
47
|
+
|
|
48
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
49
|
+
|
|
50
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
51
|
+
|
|
52
|
+
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; }
|
|
53
|
+
|
|
54
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
55
|
+
|
|
56
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
57
|
+
|
|
58
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
59
|
+
|
|
60
|
+
var fallbackCloseAction = function fallbackCloseAction(_ref) {
|
|
61
|
+
var close = _ref.close;
|
|
62
|
+
return close();
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
var DialogAction = function DialogAction(_ref2) {
|
|
66
|
+
var _translation$Dialog, _translation$Dialog2;
|
|
67
|
+
|
|
68
|
+
var _ref2$declineText = _ref2.declineText,
|
|
69
|
+
declineText = _ref2$declineText === void 0 ? null : _ref2$declineText,
|
|
70
|
+
_ref2$confirmText = _ref2.confirmText,
|
|
71
|
+
confirmText = _ref2$confirmText === void 0 ? null : _ref2$confirmText,
|
|
72
|
+
_ref2$hideDecline = _ref2.hideDecline,
|
|
73
|
+
hideDecline = _ref2$hideDecline === void 0 ? false : _ref2$hideDecline,
|
|
74
|
+
_ref2$onConfirm = _ref2.onConfirm,
|
|
75
|
+
onConfirm = _ref2$onConfirm === void 0 ? fallbackCloseAction : _ref2$onConfirm,
|
|
76
|
+
_ref2$onDecline = _ref2.onDecline,
|
|
77
|
+
onDecline = _ref2$onDecline === void 0 ? fallbackCloseAction : _ref2$onDecline,
|
|
78
|
+
children = _ref2.children;
|
|
79
|
+
|
|
80
|
+
var _useContext = (0, _react.useContext)(_shared.Context),
|
|
81
|
+
translation = _useContext.translation,
|
|
82
|
+
ButtonContext = _useContext.Button;
|
|
83
|
+
|
|
84
|
+
var _useContext2 = (0, _react.useContext)(_ModalContext.default),
|
|
85
|
+
close = _useContext2.close;
|
|
86
|
+
|
|
87
|
+
var childrenWithCloseFunc;
|
|
88
|
+
|
|
89
|
+
if (children) {
|
|
90
|
+
childrenWithCloseFunc = _react.default.Children.map(children, function (child) {
|
|
91
|
+
if (child.type === _Button.default) {
|
|
92
|
+
return _react.default.cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
|
|
93
|
+
on_click: function on_click(event) {
|
|
94
|
+
(0, _componentHelper.dispatchCustomElementEvent)(child.props, 'on_click', {
|
|
95
|
+
event: event,
|
|
96
|
+
close: close
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}), child.props.children);
|
|
100
|
+
} else {
|
|
101
|
+
return child;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return _react.default.createElement("div", {
|
|
107
|
+
className: "dnb-dialog__actions"
|
|
108
|
+
}, childrenWithCloseFunc, !children && !hideDecline && _react.default.createElement(_Button.default, {
|
|
109
|
+
text: declineText || (translation === null || translation === void 0 ? void 0 : (_translation$Dialog = translation.Dialog) === null || _translation$Dialog === void 0 ? void 0 : _translation$Dialog.declineText),
|
|
110
|
+
variant: "secondary",
|
|
111
|
+
onClick: function onClick(event) {
|
|
112
|
+
(0, _componentHelper.dispatchCustomElementEvent)({
|
|
113
|
+
onDecline: onDecline
|
|
114
|
+
}, 'onDecline', {
|
|
115
|
+
event: event,
|
|
116
|
+
close: close
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
size: (ButtonContext === null || ButtonContext === void 0 ? void 0 : ButtonContext.size) || 'large'
|
|
120
|
+
}), !children && _react.default.createElement(_Button.default, {
|
|
121
|
+
text: confirmText || (translation === null || translation === void 0 ? void 0 : (_translation$Dialog2 = translation.Dialog) === null || _translation$Dialog2 === void 0 ? void 0 : _translation$Dialog2.confirmText),
|
|
122
|
+
variant: "primary",
|
|
123
|
+
onClick: function onClick(event) {
|
|
124
|
+
(0, _componentHelper.dispatchCustomElementEvent)({
|
|
125
|
+
onConfirm: onConfirm
|
|
126
|
+
}, 'onConfirm', {
|
|
127
|
+
event: event,
|
|
128
|
+
close: close
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
size: (ButtonContext === null || ButtonContext === void 0 ? void 0 : ButtonContext.size) || 'large'
|
|
132
|
+
}));
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
var _default = DialogAction;
|
|
136
|
+
exports.default = _default;
|