@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.
Files changed (179) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/cjs/components/avatar/Avatar.d.ts +6 -5
  3. package/cjs/components/avatar/Avatar.js +4 -8
  4. package/cjs/components/breadcrumb/Breadcrumb.d.ts +0 -6
  5. package/cjs/components/breadcrumb/Breadcrumb.js +1 -7
  6. package/cjs/components/dialog/Dialog.d.ts +2 -1
  7. package/cjs/components/dialog/Dialog.js +79 -51
  8. package/cjs/components/dialog/DialogContent.d.ts +1 -1
  9. package/cjs/components/dialog/DialogContent.js +50 -12
  10. package/cjs/components/dialog/parts/DialogAction.d.ts +34 -0
  11. package/cjs/components/dialog/parts/DialogAction.js +136 -0
  12. package/cjs/components/dialog/style/_dialog.scss +152 -72
  13. package/cjs/components/dialog/style/dnb-dialog.css +352 -199
  14. package/cjs/components/dialog/style/dnb-dialog.min.css +1 -1
  15. package/cjs/components/dialog/types.d.ts +20 -2
  16. package/cjs/components/drawer/style/dnb-drawer.css +177 -100
  17. package/cjs/components/drawer/style/dnb-drawer.min.css +1 -1
  18. package/cjs/components/form-status/FormStatus.d.ts +19 -2
  19. package/cjs/components/form-status/FormStatus.js +27 -3
  20. package/cjs/components/form-status/style/themes/dnb-form-status-theme-ui.css +16 -0
  21. package/cjs/components/form-status/style/themes/dnb-form-status-theme-ui.min.css +1 -1
  22. package/cjs/components/form-status/style/themes/dnb-form-status-theme-ui.scss +7 -0
  23. package/cjs/components/info-card/InfoCard.d.ts +0 -9
  24. package/cjs/components/info-card/InfoCard.js +0 -9
  25. package/cjs/components/modal/Modal.d.ts +1 -0
  26. package/cjs/components/modal/Modal.js +1 -1
  27. package/cjs/components/modal/ModalContent.js +13 -5
  28. package/cjs/components/modal/parts/CloseButton.d.ts +1 -0
  29. package/cjs/components/modal/style/_modal.scss +1 -0
  30. package/cjs/components/modal/style/dnb-modal.css +177 -100
  31. package/cjs/components/modal/style/dnb-modal.min.css +1 -1
  32. package/cjs/components/modal/types.d.ts +9 -1
  33. package/cjs/components/number-format/NumberFormat.d.ts +7 -1
  34. package/cjs/components/number-format/NumberFormat.js +5 -1
  35. package/cjs/components/number-format/NumberUtils.d.ts +12 -3
  36. package/cjs/components/number-format/NumberUtils.js +106 -7
  37. package/cjs/components/tag/Tag.d.ts +5 -6
  38. package/cjs/components/tag/Tag.js +3 -8
  39. package/cjs/fragments/drawer-list/DrawerList.js +1 -1
  40. package/cjs/fragments/drawer-list/DrawerListHelpers.js +3 -1
  41. package/cjs/shared/Context.d.ts +2 -0
  42. package/cjs/shared/Context.js +1 -0
  43. package/cjs/shared/Eufemia.js +1 -1
  44. package/cjs/shared/locales/en-GB.d.ts +4 -0
  45. package/cjs/shared/locales/en-GB.js +4 -0
  46. package/cjs/shared/locales/en-US.d.ts +4 -0
  47. package/cjs/shared/locales/index.d.ts +8 -0
  48. package/cjs/shared/locales/nb-NO.d.ts +4 -0
  49. package/cjs/shared/locales/nb-NO.js +4 -0
  50. package/cjs/shared/useTranslation.d.ts +1 -0
  51. package/cjs/style/dnb-ui-components.css +177 -100
  52. package/cjs/style/dnb-ui-components.min.css +2 -2
  53. package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.css +16 -0
  54. package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
  55. package/cjs/style/themes/theme-ui/dnb-theme-ui.css +16 -0
  56. package/cjs/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
  57. package/components/avatar/Avatar.d.ts +6 -5
  58. package/components/avatar/Avatar.js +4 -8
  59. package/components/breadcrumb/Breadcrumb.d.ts +0 -6
  60. package/components/breadcrumb/Breadcrumb.js +1 -7
  61. package/components/dialog/Dialog.d.ts +2 -1
  62. package/components/dialog/Dialog.js +78 -52
  63. package/components/dialog/DialogContent.d.ts +1 -1
  64. package/components/dialog/DialogContent.js +46 -9
  65. package/components/dialog/parts/DialogAction.d.ts +34 -0
  66. package/components/dialog/parts/DialogAction.js +96 -0
  67. package/components/dialog/style/_dialog.scss +152 -72
  68. package/components/dialog/style/dnb-dialog.css +352 -199
  69. package/components/dialog/style/dnb-dialog.min.css +1 -1
  70. package/components/dialog/types.d.ts +20 -2
  71. package/components/drawer/style/dnb-drawer.css +177 -100
  72. package/components/drawer/style/dnb-drawer.min.css +1 -1
  73. package/components/form-status/FormStatus.d.ts +19 -2
  74. package/components/form-status/FormStatus.js +23 -2
  75. package/components/form-status/style/themes/dnb-form-status-theme-ui.css +16 -0
  76. package/components/form-status/style/themes/dnb-form-status-theme-ui.min.css +1 -1
  77. package/components/form-status/style/themes/dnb-form-status-theme-ui.scss +7 -0
  78. package/components/info-card/InfoCard.d.ts +0 -9
  79. package/components/info-card/InfoCard.js +0 -9
  80. package/components/modal/Modal.d.ts +1 -0
  81. package/components/modal/Modal.js +1 -1
  82. package/components/modal/ModalContent.js +13 -5
  83. package/components/modal/parts/CloseButton.d.ts +1 -0
  84. package/components/modal/style/_modal.scss +1 -0
  85. package/components/modal/style/dnb-modal.css +177 -100
  86. package/components/modal/style/dnb-modal.min.css +1 -1
  87. package/components/modal/types.d.ts +9 -1
  88. package/components/number-format/NumberFormat.d.ts +7 -1
  89. package/components/number-format/NumberFormat.js +5 -1
  90. package/components/number-format/NumberUtils.d.ts +12 -3
  91. package/components/number-format/NumberUtils.js +105 -7
  92. package/components/tag/Tag.d.ts +5 -6
  93. package/components/tag/Tag.js +3 -8
  94. package/es/components/avatar/Avatar.d.ts +6 -5
  95. package/es/components/avatar/Avatar.js +5 -9
  96. package/es/components/breadcrumb/Breadcrumb.d.ts +0 -6
  97. package/es/components/breadcrumb/Breadcrumb.js +1 -7
  98. package/es/components/dialog/Dialog.d.ts +2 -1
  99. package/es/components/dialog/Dialog.js +50 -22
  100. package/es/components/dialog/DialogContent.d.ts +1 -1
  101. package/es/components/dialog/DialogContent.js +40 -8
  102. package/es/components/dialog/parts/DialogAction.d.ts +34 -0
  103. package/es/components/dialog/parts/DialogAction.js +82 -0
  104. package/es/components/dialog/style/_dialog.scss +152 -72
  105. package/es/components/dialog/style/dnb-dialog.css +352 -199
  106. package/es/components/dialog/style/dnb-dialog.min.css +1 -1
  107. package/es/components/dialog/types.d.ts +20 -2
  108. package/es/components/drawer/style/dnb-drawer.css +177 -100
  109. package/es/components/drawer/style/dnb-drawer.min.css +1 -1
  110. package/es/components/form-status/FormStatus.d.ts +19 -2
  111. package/es/components/form-status/FormStatus.js +21 -2
  112. package/es/components/form-status/style/themes/dnb-form-status-theme-ui.css +16 -0
  113. package/es/components/form-status/style/themes/dnb-form-status-theme-ui.min.css +1 -1
  114. package/es/components/form-status/style/themes/dnb-form-status-theme-ui.scss +7 -0
  115. package/es/components/info-card/InfoCard.d.ts +0 -9
  116. package/es/components/info-card/InfoCard.js +0 -9
  117. package/es/components/modal/Modal.d.ts +1 -0
  118. package/es/components/modal/Modal.js +1 -1
  119. package/es/components/modal/ModalContent.js +13 -6
  120. package/es/components/modal/parts/CloseButton.d.ts +1 -0
  121. package/es/components/modal/style/_modal.scss +1 -0
  122. package/es/components/modal/style/dnb-modal.css +177 -100
  123. package/es/components/modal/style/dnb-modal.min.css +1 -1
  124. package/es/components/modal/types.d.ts +9 -1
  125. package/es/components/number-format/NumberFormat.d.ts +7 -1
  126. package/es/components/number-format/NumberFormat.js +5 -1
  127. package/es/components/number-format/NumberUtils.d.ts +12 -3
  128. package/es/components/number-format/NumberUtils.js +101 -7
  129. package/es/components/tag/Tag.d.ts +5 -6
  130. package/es/components/tag/Tag.js +3 -8
  131. package/es/fragments/drawer-list/DrawerList.js +1 -1
  132. package/es/fragments/drawer-list/DrawerListHelpers.js +3 -1
  133. package/es/shared/Context.d.ts +2 -0
  134. package/es/shared/Context.js +1 -0
  135. package/es/shared/Eufemia.js +1 -1
  136. package/es/shared/locales/en-GB.d.ts +4 -0
  137. package/es/shared/locales/en-GB.js +4 -0
  138. package/es/shared/locales/en-US.d.ts +4 -0
  139. package/es/shared/locales/index.d.ts +8 -0
  140. package/es/shared/locales/nb-NO.d.ts +4 -0
  141. package/es/shared/locales/nb-NO.js +4 -0
  142. package/es/shared/useTranslation.d.ts +1 -0
  143. package/es/style/dnb-ui-components.css +177 -100
  144. package/es/style/dnb-ui-components.min.css +2 -2
  145. package/es/style/themes/theme-open-banking/dnb-theme-open-banking.css +16 -0
  146. package/es/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
  147. package/es/style/themes/theme-ui/dnb-theme-ui.css +16 -0
  148. package/es/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
  149. package/esm/dnb-ui-basis.min.mjs +1 -1
  150. package/esm/dnb-ui-components.min.mjs +1 -1
  151. package/esm/dnb-ui-elements.min.mjs +1 -1
  152. package/esm/dnb-ui-extensions.min.mjs +3 -3
  153. package/esm/dnb-ui-lib.min.mjs +3 -3
  154. package/esm/dnb-ui-web-components.min.mjs +2 -2
  155. package/fragments/drawer-list/DrawerList.js +1 -1
  156. package/fragments/drawer-list/DrawerListHelpers.js +3 -1
  157. package/package.json +1 -1
  158. package/shared/Context.d.ts +2 -0
  159. package/shared/Context.js +1 -0
  160. package/shared/Eufemia.js +1 -1
  161. package/shared/locales/en-GB.d.ts +4 -0
  162. package/shared/locales/en-GB.js +4 -0
  163. package/shared/locales/en-US.d.ts +4 -0
  164. package/shared/locales/index.d.ts +8 -0
  165. package/shared/locales/nb-NO.d.ts +4 -0
  166. package/shared/locales/nb-NO.js +4 -0
  167. package/shared/useTranslation.d.ts +1 -0
  168. package/style/dnb-ui-components.css +177 -100
  169. package/style/dnb-ui-components.min.css +2 -2
  170. package/style/themes/theme-open-banking/dnb-theme-open-banking.css +16 -0
  171. package/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
  172. package/style/themes/theme-ui/dnb-theme-ui.css +16 -0
  173. package/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
  174. package/umd/dnb-ui-basis.min.js +1 -1
  175. package/umd/dnb-ui-components.min.js +1 -1
  176. package/umd/dnb-ui-elements.min.js +1 -1
  177. package/umd/dnb-ui-extensions.min.js +2 -2
  178. package/umd/dnb-ui-lib.min.js +4 -4
  179. package/umd/dnb-ui-web-components.min.js +2 -2
@@ -1,14 +1,15 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["modalContent", "navContent", "headerContent", "alignContent", "className", "class", "preventCoreStyle", "spacing", "fullscreen", "noAnimation", "noAnimationOnMobile", "minWidth", "maxWidth"];
3
+ var _excluded = ["modalContent", "navContent", "headerContent", "alignContent", "className", "class", "preventCoreStyle", "spacing", "fullscreen", "noAnimation", "noAnimationOnMobile", "minWidth", "maxWidth", "variant", "confirmType", "icon", "description", "hideDecline", "onConfirm", "onDecline", "declineText", "confirmText"];
4
4
 
5
5
  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; }
6
6
 
7
7
  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; }
8
8
 
9
+ import "core-js/modules/es.symbol.js";
10
+ import "core-js/modules/es.symbol.description.js";
9
11
  import "core-js/modules/es.object.freeze.js";
10
12
  import "core-js/modules/es.object.keys.js";
11
- import "core-js/modules/es.symbol.js";
12
13
  import "core-js/modules/es.array.filter.js";
13
14
  import "core-js/modules/es.object.to-string.js";
14
15
  import "core-js/modules/es.object.get-own-property-descriptor.js";
@@ -20,11 +21,13 @@ import { isTrue, findElementInChildren } from '../../shared/component-helper';
20
21
  import ScrollView from '../../fragments/scroll-view/ScrollView';
21
22
  import DialogHeader from './parts/DialogHeader';
22
23
  import DialogNavigation from './parts/DialogNavigation';
24
+ import DialogAction from './parts/DialogAction';
23
25
  import { getContent } from '../modal/helpers';
24
26
  import ModalContext from '../modal/ModalContext';
25
27
  import { checkMinMaxWidth } from '../drawer/helpers';
26
28
  import ModalHeaderBar from '../modal/parts/ModalHeaderBar';
27
29
  import ModalHeader from '../modal/parts/ModalHeader';
30
+ import IconPrimary from '../icon-primary/IconPrimary';
28
31
  export default function DialogContent(_ref) {
29
32
  var _ref$modalContent = _ref.modalContent,
30
33
  modalContent = _ref$modalContent === void 0 ? null : _ref$modalContent,
@@ -33,7 +36,7 @@ export default function DialogContent(_ref) {
33
36
  _ref$headerContent = _ref.headerContent,
34
37
  headerContent = _ref$headerContent === void 0 ? null : _ref$headerContent,
35
38
  _ref$alignContent = _ref.alignContent,
36
- alignContent = _ref$alignContent === void 0 ? 'left' : _ref$alignContent,
39
+ alignContent = _ref$alignContent === void 0 ? null : _ref$alignContent,
37
40
  _ref$className = _ref.className,
38
41
  className = _ref$className === void 0 ? null : _ref$className,
39
42
  _ref$class = _ref.class,
@@ -42,8 +45,7 @@ export default function DialogContent(_ref) {
42
45
  preventCoreStyle = _ref$preventCoreStyle === void 0 ? null : _ref$preventCoreStyle,
43
46
  _ref$spacing = _ref.spacing,
44
47
  spacing = _ref$spacing === void 0 ? true : _ref$spacing,
45
- _ref$fullscreen = _ref.fullscreen,
46
- fullscreen = _ref$fullscreen === void 0 ? 'auto' : _ref$fullscreen,
48
+ fullscreen = _ref.fullscreen,
47
49
  _ref$noAnimation = _ref.noAnimation,
48
50
  noAnimation = _ref$noAnimation === void 0 ? false : _ref$noAnimation,
49
51
  _ref$noAnimationOnMob = _ref.noAnimationOnMobile,
@@ -52,6 +54,18 @@ export default function DialogContent(_ref) {
52
54
  min_width = _ref$minWidth === void 0 ? null : _ref$minWidth,
53
55
  _ref$maxWidth = _ref.maxWidth,
54
56
  max_width = _ref$maxWidth === void 0 ? null : _ref$maxWidth,
57
+ _ref$variant = _ref.variant,
58
+ variant = _ref$variant === void 0 ? 'information' : _ref$variant,
59
+ _ref$confirmType = _ref.confirmType,
60
+ confirmType = _ref$confirmType === void 0 ? 'info' : _ref$confirmType,
61
+ _ref$icon = _ref.icon,
62
+ icon = _ref$icon === void 0 ? null : _ref$icon,
63
+ description = _ref.description,
64
+ hideDecline = _ref.hideDecline,
65
+ onConfirm = _ref.onConfirm,
66
+ onDecline = _ref.onDecline,
67
+ declineText = _ref.declineText,
68
+ confirmText = _ref.confirmText,
55
69
  rest = _objectWithoutProperties(_ref, _excluded);
56
70
 
57
71
  var context = useContext(ModalContext);
@@ -64,8 +78,12 @@ export default function DialogContent(_ref) {
64
78
  close: context === null || context === void 0 ? void 0 : context.close
65
79
  })) : rest);
66
80
 
81
+ if (alignContent === null) {
82
+ alignContent = variant === 'information' ? 'left' : 'centered';
83
+ }
84
+
67
85
  var innerParams = _objectSpread({
68
- className: classnames('dnb-dialog', isTrue(fullscreen) ? "dnb-dialog--fullscreen" : fullscreen === 'auto' && "dnb-dialog--auto-fullscreen", className, _className, !isTrue(preventCoreStyle) && 'dnb-core-style', isTrue(spacing) && 'dnb-dialog--spacing', alignContent && "dnb-dialog__align--".concat(alignContent), isTrue(context === null || context === void 0 ? void 0 : context.hide) && "dnb-dialog--hide", isTrue(noAnimation) && "dnb-dialog--no-animation", isTrue(noAnimationOnMobile) && "dnb-dialog--no-animation-on-mobile"),
86
+ className: classnames('dnb-dialog', isTrue(fullscreen) ? "dnb-dialog--fullscreen" : fullscreen === 'auto' && "dnb-dialog--auto-fullscreen", className, _className, !isTrue(preventCoreStyle) && 'dnb-core-style', variant && "dnb-dialog--".concat(variant), isTrue(spacing) && 'dnb-dialog--spacing', alignContent && "dnb-dialog__align--".concat(alignContent), isTrue(context === null || context === void 0 ? void 0 : context.hide) && "dnb-dialog--hide", isTrue(noAnimation) && "dnb-dialog--no-animation", isTrue(noAnimationOnMobile) && "dnb-dialog--no-animation-on-mobile"),
69
87
  style: (minWidth || maxWidth) && {
70
88
  minWidth: minWidth,
71
89
  maxWidth: maxWidth
@@ -81,14 +99,33 @@ export default function DialogContent(_ref) {
81
99
  var headerExists = findElementInChildren(content, function (cur) {
82
100
  return cur.type === DialogHeader || cur.type === ModalHeader;
83
101
  });
102
+ var actionExists = findElementInChildren(content, function (cur) {
103
+ return cur.type === DialogAction;
104
+ });
105
+ var dialogActionProps = {
106
+ onConfirm: onConfirm,
107
+ onDecline: onDecline,
108
+ declineText: declineText,
109
+ confirmText: confirmText,
110
+ hideDecline: hideDecline
111
+ };
84
112
  return React.createElement(ScrollView, innerParams, React.createElement("div", {
85
113
  tabIndex: -1,
86
114
  className: "dnb-dialog__inner dnb-no-focus",
87
115
  ref: context === null || context === void 0 ? void 0 : context.contentRef
88
- }, !navExists && React.createElement(DialogNavigation, null, navContent), !headerExists && React.createElement(DialogHeader, {
89
- title: context === null || context === void 0 ? void 0 : context.title
116
+ }, !navExists && React.createElement(DialogNavigation, null, navContent), icon && React.createElement("div", {
117
+ className: "dnb-dialog__icon"
118
+ }, React.createElement(IconPrimary, {
119
+ border: true,
120
+ key: "dialog-icon",
121
+ icon: icon,
122
+ "aria-hidden": true,
123
+ className: classnames('dnb-dialog__icon__primary', 'dnb-dialog__icon--' + confirmType)
124
+ })), !headerExists && React.createElement(DialogHeader, {
125
+ title: context === null || context === void 0 ? void 0 : context.title,
126
+ size: variant === 'information' ? 'x-large' : 'large'
90
127
  }, headerContent), React.createElement("div", {
91
128
  id: (context === null || context === void 0 ? void 0 : context.contentId) + '-content',
92
129
  className: "dnb-dialog__content"
93
- }, content)));
130
+ }, description, content), variant === 'confirmation' && !actionExists && React.createElement(DialogAction, dialogActionProps)));
94
131
  }
@@ -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,96 @@
1
+ import "core-js/modules/es.object.keys.js";
2
+ import "core-js/modules/es.symbol.js";
3
+ import "core-js/modules/es.array.filter.js";
4
+ import "core-js/modules/es.object.to-string.js";
5
+ import "core-js/modules/es.object.get-own-property-descriptor.js";
6
+ import "core-js/modules/web.dom-collections.for-each.js";
7
+ import "core-js/modules/es.object.get-own-property-descriptors.js";
8
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
+
10
+ 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; }
11
+
12
+ 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; }
13
+
14
+ import "core-js/modules/es.array.map.js";
15
+ import React, { useContext } from 'react';
16
+ import Button from '../../button/Button';
17
+ import { Context } from '../../../shared';
18
+ import ModalContext from '../../modal/ModalContext';
19
+ import { dispatchCustomElementEvent } from '../../../shared/component-helper';
20
+
21
+ var fallbackCloseAction = function fallbackCloseAction(_ref) {
22
+ var close = _ref.close;
23
+ return close();
24
+ };
25
+
26
+ var DialogAction = function DialogAction(_ref2) {
27
+ var _translation$Dialog, _translation$Dialog2;
28
+
29
+ var _ref2$declineText = _ref2.declineText,
30
+ declineText = _ref2$declineText === void 0 ? null : _ref2$declineText,
31
+ _ref2$confirmText = _ref2.confirmText,
32
+ confirmText = _ref2$confirmText === void 0 ? null : _ref2$confirmText,
33
+ _ref2$hideDecline = _ref2.hideDecline,
34
+ hideDecline = _ref2$hideDecline === void 0 ? false : _ref2$hideDecline,
35
+ _ref2$onConfirm = _ref2.onConfirm,
36
+ onConfirm = _ref2$onConfirm === void 0 ? fallbackCloseAction : _ref2$onConfirm,
37
+ _ref2$onDecline = _ref2.onDecline,
38
+ onDecline = _ref2$onDecline === void 0 ? fallbackCloseAction : _ref2$onDecline,
39
+ children = _ref2.children;
40
+
41
+ var _useContext = useContext(Context),
42
+ translation = _useContext.translation,
43
+ ButtonContext = _useContext.Button;
44
+
45
+ var _useContext2 = useContext(ModalContext),
46
+ close = _useContext2.close;
47
+
48
+ var childrenWithCloseFunc;
49
+
50
+ if (children) {
51
+ childrenWithCloseFunc = React.Children.map(children, function (child) {
52
+ if (child.type === Button) {
53
+ return React.cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
54
+ on_click: function on_click(event) {
55
+ dispatchCustomElementEvent(child.props, 'on_click', {
56
+ event: event,
57
+ close: close
58
+ });
59
+ }
60
+ }), child.props.children);
61
+ } else {
62
+ return child;
63
+ }
64
+ });
65
+ }
66
+
67
+ return React.createElement("div", {
68
+ className: "dnb-dialog__actions"
69
+ }, childrenWithCloseFunc, !children && !hideDecline && React.createElement(Button, {
70
+ text: declineText || (translation === null || translation === void 0 ? void 0 : (_translation$Dialog = translation.Dialog) === null || _translation$Dialog === void 0 ? void 0 : _translation$Dialog.declineText),
71
+ variant: "secondary",
72
+ onClick: function onClick(event) {
73
+ dispatchCustomElementEvent({
74
+ onDecline: onDecline
75
+ }, 'onDecline', {
76
+ event: event,
77
+ close: close
78
+ });
79
+ },
80
+ size: (ButtonContext === null || ButtonContext === void 0 ? void 0 : ButtonContext.size) || 'large'
81
+ }), !children && React.createElement(Button, {
82
+ text: confirmText || (translation === null || translation === void 0 ? void 0 : (_translation$Dialog2 = translation.Dialog) === null || _translation$Dialog2 === void 0 ? void 0 : _translation$Dialog2.confirmText),
83
+ variant: "primary",
84
+ onClick: function onClick(event) {
85
+ dispatchCustomElementEvent({
86
+ onConfirm: onConfirm
87
+ }, 'onConfirm', {
88
+ event: event,
89
+ close: close
90
+ });
91
+ },
92
+ size: (ButtonContext === null || ButtonContext === void 0 ? void 0 : ButtonContext.size) || 'large'
93
+ }));
94
+ };
95
+
96
+ export default DialogAction;
@@ -9,28 +9,34 @@
9
9
  // we do this because SCSS fails by using min(100vw, 50rem) = "Incompatible units: 'rem' and 'vw'"
10
10
  --dialog-min-width: 320px; // use px, so larger font-size don't enlarge the min, has to be under 20rem, because of spacing and later mobile fullscreen
11
11
  --dialog-avg-width: 60vw; // content defines the size
12
- --dialog-max-width: 60rem; // because of our default width --layout-large
12
+ --dialog-max-width: 49rem; // because of our default width --layout-large
13
+ --dialog-confirm-max-width: 40rem;
13
14
  --dialog-spacing: 2rem; // should reflect --spacing-large
14
15
  --dialog-spacing-minus: -2rem; // should reflect --spacing-large
15
16
  }
16
17
 
17
18
  .dnb-dialog {
18
19
  position: relative;
19
-
20
- width: var(--dialog-avg-width);
21
- min-width: var(--dialog-min-width);
22
- max-width: var(--dialog-max-width);
23
20
  max-height: 100vh;
24
-
25
- @include defaultDropShadow();
26
21
  border-radius: 0.5rem;
22
+ @include defaultDropShadow();
27
23
 
28
24
  user-select: text;
29
25
  -webkit-user-select: text; // Safari / Touch fix
30
26
  border: none;
31
-
32
27
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
33
28
 
29
+ &--information {
30
+ min-width: var(--dialog-min-width);
31
+ width: var(--dialog-avg-width);
32
+ max-width: var(--dialog-max-width);
33
+ }
34
+
35
+ &--confirmation {
36
+ max-width: var(--dialog-confirm-max-width);
37
+ margin: 0 1rem;
38
+ }
39
+
34
40
  &--auto-fullscreen {
35
41
  @include allBelow(small) {
36
42
  @include modalFullscreen();
@@ -39,14 +45,43 @@
39
45
  &--fullscreen {
40
46
  @include modalFullscreen();
41
47
  }
48
+ &--spacing#{&}--information &__content {
49
+ padding-bottom: calc(var(--dialog-spacing) * 2);
42
50
 
43
- @include IS_SAFARI_MOBILE() {
44
- // iOS on iPhone fix
45
- // Because Safari includes the navigation bar on the height
46
- @media (max-height: 40em) and (orientation: landscape) {
47
- &:not(#{&}--fullscreen) {
48
- max-height: 80vh;
49
- }
51
+ @include IS_SAFARI_MOBILE {
52
+ padding-bottom: calc(var(--dialog-spacing) * 8);
53
+ }
54
+ }
55
+
56
+ &--spacing#{&}--information &__inner {
57
+ padding-left: calc(var(--dialog-spacing) * 1.75); // 3.5rem (56px)
58
+ padding-right: calc(var(--dialog-spacing) * 1.75); // 3.5rem (56px)
59
+
60
+ @include allBelow(large) {
61
+ padding-left: calc(var(--dialog-spacing)); // 2rem (32px)
62
+ padding-right: calc(var(--dialog-spacing)); // 2rem (32px)
63
+ }
64
+
65
+ @include allBelow(small) {
66
+ padding-left: calc(var(--dialog-spacing) / 2); // 1rem (16px)
67
+ padding-right: calc(var(--dialog-spacing) / 2); // 1rem (16px)
68
+ }
69
+ }
70
+
71
+ &--spacing#{&}--information &__navigation.dnb-section {
72
+ margin-top: calc(var(--dialog-spacing)); // 2rem (32px)
73
+ margin-bottom: calc(var(--dialog-spacing) / 2); // 1rem (16px)
74
+
75
+ @include allBelow(medium) {
76
+ margin-top: calc(var(--dialog-spacing) / 2); // 1rem (16px)
77
+ }
78
+ }
79
+
80
+ &--spacing#{&}--confirmation &__inner {
81
+ padding: calc(var(--dialog-spacing)); // 2rem (32px)
82
+
83
+ @include IS_SAFARI_MOBILE {
84
+ padding-bottom: calc(var(--dialog-spacing) * 8);
50
85
  }
51
86
  }
52
87
 
@@ -70,25 +105,98 @@
70
105
  }
71
106
  }
72
107
 
73
- // Padding right and left based on screen size
74
- &--spacing &__inner {
75
- // FOR DIALOG STYLES
76
- padding: 0 var(--dialog-spacing) 0;
108
+ &__align--centered &__inner {
109
+ align-items: center;
110
+ justify-content: center;
111
+ }
112
+ &__align--centered &__title,
113
+ &__align--centered#{&}--confirmation &__content {
114
+ text-align: center;
115
+ }
116
+
117
+ &__content {
118
+ position: relative;
119
+ z-index: 1;
120
+ }
121
+
122
+ &__actions {
123
+ padding-top: 1.5rem;
77
124
 
78
- @include allAbove(x-large) {
79
- padding: 0 calc(var(--dialog-spacing) * 1.75) 0; // 3.5rem (56px)
125
+ display: flex;
126
+ justify-content: center;
127
+ width: 100%;
128
+
129
+ > :not(:last-child) {
130
+ margin-right: 1rem;
80
131
  }
132
+ }
133
+
134
+ &__align--center &__content {
135
+ align-items: center;
136
+ text-align: center;
137
+ }
138
+
139
+ &__align--right &__content {
140
+ align-items: flex-end;
141
+ text-align: right;
142
+ }
143
+
144
+ &__title ~ &__content {
145
+ padding-top: calc(var(--dialog-spacing) / 2);
146
+ }
147
+
148
+ &__title {
81
149
  @include allBelow(medium) {
82
- padding: 0 calc(var(--dialog-spacing) / 1.333333) 0; // 2rem (32px)
150
+ font-size: var(--font-size-large) !important;
151
+ line-height: var(--line-height-medium) !important;
83
152
  }
84
153
  @include allBelow(small) {
85
- padding: 0 calc(var(--dialog-spacing) / 2) 0; // 1rem (16px)
154
+ font-size: var(--font-size-medium) !important;
155
+ line-height: calc(var(--line-height-medium) - 0.25rem) !important;
86
156
  }
87
157
  }
88
158
 
89
- &__align--centered &__inner {
90
- align-items: center;
91
- justify-content: center;
159
+ &--information &__title {
160
+ margin-bottom: var(--spacing-small) !important;
161
+ }
162
+
163
+ &--confirmation &__title {
164
+ margin-bottom: var(--spacing-x-small) !important;
165
+ }
166
+
167
+ &__navigation.dnb-section {
168
+ display: flex;
169
+ flex-direction: row;
170
+ justify-content: space-between;
171
+ }
172
+
173
+ &__icon {
174
+ // Modify the border prop from the icon component
175
+ &__primary.dnb-icon--border::after {
176
+ left: -50%;
177
+ right: -50%;
178
+ top: -50%;
179
+ bottom: -50%;
180
+
181
+ border: none;
182
+ background-color: currentColor;
183
+ opacity: 0.1;
184
+ }
185
+
186
+ &__primary#{&}--warning {
187
+ color: var(--color-fire-red);
188
+
189
+ ::after {
190
+ background-color: var(--color-fire-red-8);
191
+ }
192
+ }
193
+ &__primary#{&}--info {
194
+ color: var(--color-emerald-green);
195
+
196
+ ::after {
197
+ background-color: var(--color-pistachio);
198
+ }
199
+ }
92
200
  }
93
201
 
94
202
  // Animation in
@@ -110,35 +218,20 @@
110
218
  }
111
219
  }
112
220
 
113
- &__content {
114
- position: relative;
115
- z-index: 1;
116
- }
117
-
118
- &--spacing &__content {
221
+ &__body {
119
222
  padding-bottom: calc(var(--dialog-spacing) * 2);
120
-
121
- @include IS_SAFARI_MOBILE {
122
- padding-bottom: calc(var(--dialog-spacing) * 8);
123
- }
124
- }
125
-
126
- &__align--center &__content {
127
- align-items: center;
128
- text-align: center;
129
- }
130
-
131
- &__align--right &__content {
132
- align-items: flex-end;
133
- text-align: right;
223
+ margin-bottom: calc(var(--dialog-spacing-minus) * 2);
134
224
  }
135
225
 
136
- &__title ~ &__content {
137
- padding-top: calc(var(--dialog-spacing) / 2);
226
+ &__header {
227
+ &::after {
228
+ top: -500%;
229
+ height: 600%;
230
+ }
138
231
  }
139
232
 
140
- & &__header [class*='dnb-h--'],
141
- & &__header .dnb-modal__title {
233
+ &__header [class*='dnb-h--'],
234
+ &__header .dnb-modal__title {
142
235
  padding: 0;
143
236
  &:not([class*='__top']) {
144
237
  margin-top: 0;
@@ -148,36 +241,23 @@
148
241
  }
149
242
  }
150
243
 
151
- & &__header {
152
- &::after {
153
- top: -500%;
154
- height: 600%;
155
- }
156
- }
157
-
158
244
  &--spacing &__header {
159
245
  .dnb-tabs {
160
246
  margin-top: 3.5rem;
161
247
  }
162
248
  }
163
249
 
164
- &__body {
165
- padding-bottom: calc(var(--dialog-spacing) * 2);
166
- margin-bottom: calc(var(--dialog-spacing-minus) * 2);
167
- }
168
-
169
- &__navigation.dnb-section {
170
- display: flex;
171
- flex-direction: row;
172
- justify-content: space-between;
250
+ &__icon ~ &__header {
251
+ margin-top: 1.5rem;
173
252
  }
174
253
 
175
- &--spacing &__navigation.dnb-section {
176
- // on large screens
177
- margin-top: calc(var(--dialog-spacing) * 1.75);
178
- margin-bottom: calc(var(--dialog-spacing) / 2);
179
- @include allBelow(medium) {
180
- margin-top: calc(var(--dialog-spacing) / 2);
254
+ @include IS_SAFARI_MOBILE() {
255
+ // iOS on iPhone fix
256
+ // Because Safari includes the navigation bar on the height
257
+ @media (max-height: 40em) and (orientation: landscape) {
258
+ &:not(#{&}--fullscreen) {
259
+ max-height: 80vh;
260
+ }
181
261
  }
182
262
  }
183
263
  }