@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
@@ -34,6 +34,9 @@ export interface formatOptionParams {
34
34
  /** Should the number be cleaned */
35
35
  clean?: boolean;
36
36
 
37
+ /** shortens any number or currency including an abbreviation. You can combine `compact` with `currency`. It gives you zero decimal by default `decimals={0}`. Use either a boolean, or a string with "short" or "long" */
38
+ compact?: boolean | 'short' | 'long';
39
+
37
40
  /** How many decimals */
38
41
  decimals?: number;
39
42
 
@@ -53,13 +56,19 @@ export interface formatOptionParams {
53
56
  /** Currency code (ISO 4217) or `true` to use the default, `NOK`. */
54
57
  currency?: string | boolean;
55
58
 
56
- /** Intl.NumberFormat currency option – you can use false or empty string to hide the sign/name */
57
- currency_display?: string | boolean;
59
+ /** Intl.NumberFormat currency option – you can use false or empty string to hide the sign/name. Defaults to narrowSymbol when the locale is no else we default to code. */
60
+ currency_display?:
61
+ | boolean
62
+ | ''
63
+ | 'code'
64
+ | 'name'
65
+ | 'symbol'
66
+ | 'narrowSymbol';
58
67
  /** currency option */
59
68
  currency_position?: formatCurrencyPosition;
60
69
  /** hides the currency sign */
61
70
  omit_currency_sign?: boolean;
62
- /** will remove all extra signs,like a currency sign or percent sign for the cleanedValue return when returnAria is true */
71
+ /** will remove all extra signs, like a currency sign or percent sign for the cleanedValue return when returnAria is true */
63
72
  clean_copy_value?: boolean;
64
73
 
65
74
  /** Intl.NumberFormat options (NumberFormatOptions) */
@@ -31,6 +31,7 @@ import "core-js/modules/es.array.filter.js";
31
31
  import "core-js/modules/es.string.starts-with.js";
32
32
  import "core-js/modules/es.string.ends-with.js";
33
33
  import "core-js/modules/es.array.find.js";
34
+ import "core-js/modules/es.parse-int.js";
34
35
  import React from 'react';
35
36
  import Context from '../../shared/Context';
36
37
  import { LOCALE, CURRENCY, CURRENCY_DISPLAY } from '../../shared/defaults';
@@ -43,6 +44,8 @@ export var format = function format(value) {
43
44
  locale = _ref$locale === void 0 ? null : _ref$locale,
44
45
  _ref$clean = _ref.clean,
45
46
  clean = _ref$clean === void 0 ? false : _ref$clean,
47
+ _ref$compact = _ref.compact,
48
+ compact = _ref$compact === void 0 ? null : _ref$compact,
46
49
  _ref$phone = _ref.phone,
47
50
  phone = _ref$phone === void 0 ? null : _ref$phone,
48
51
  _ref$org = _ref.org,
@@ -94,7 +97,7 @@ export var format = function format(value) {
94
97
 
95
98
  if (parseFloat(decimals) >= 0) {
96
99
  value = formatDecimals(value, decimals, omit_rounding, opts);
97
- } else {
100
+ } else if (typeof opts.maximumFractionDigits === 'undefined') {
98
101
  opts.maximumFractionDigits = 20;
99
102
  }
100
103
 
@@ -152,6 +155,13 @@ export var format = function format(value) {
152
155
  } else if (isTrue(currency) || typeof currency === 'string') {
153
156
  type = 'currency';
154
157
  opts.currency = opts.currency || (isTrue(currency) ? CURRENCY : currency);
158
+ handleCompactBeforeDisplay({
159
+ value: value,
160
+ locale: locale,
161
+ compact: compact,
162
+ decimals: decimals,
163
+ opts: opts
164
+ });
155
165
 
156
166
  if (decimals === null) {
157
167
  decimals = 2;
@@ -165,7 +175,7 @@ export var format = function format(value) {
165
175
  }
166
176
 
167
177
  opts.style = 'currency';
168
- opts.currencyDisplay = getFallbackCurrencyDisplay(locale, opts.currency_display || currency_display);
178
+ opts.currencyDisplay = getFallbackCurrencyDisplay(locale, opts.currencyDisplay || currency_display);
169
179
 
170
180
  if (typeof opts.minimumFractionDigits === 'undefined' && String(value).indexOf('.') === -1 && cleanedNumber % 1 === 0) {
171
181
  opts.minimumFractionDigits = 0;
@@ -214,6 +224,11 @@ export var format = function format(value) {
214
224
  }
215
225
  }
216
226
 
227
+ handleCompactBeforeAria({
228
+ value: value,
229
+ compact: compact,
230
+ opts: opts
231
+ });
217
232
  aria = formatNumber(cleanedNumber, locale, _objectSpread(_objectSpread({
218
233
  minimumFractionDigits: 0,
219
234
  maximumFractionDigits: 2
@@ -229,12 +244,21 @@ export var format = function format(value) {
229
244
  aria = prepareMinus(aria, locale);
230
245
  }
231
246
  } else {
247
+ handleCompactBeforeDisplay({
248
+ value: value,
249
+ locale: locale,
250
+ compact: compact,
251
+ decimals: decimals,
252
+ opts: opts
253
+ });
232
254
  display = formatNumber(value, locale, opts);
233
255
  display = prepareMinus(display, locale);
234
- aria = formatNumber(value, locale, _objectSpread(_objectSpread({}, opts), {}, {
235
- minimumFractionDigits: 1,
236
- maximumFractionDigits: 20
237
- }));
256
+ handleCompactBeforeAria({
257
+ value: value,
258
+ compact: compact,
259
+ opts: opts
260
+ });
261
+ aria = formatNumber(value, locale, opts);
238
262
  aria = enhanceSR(value, aria, locale);
239
263
  }
240
264
 
@@ -261,7 +285,7 @@ export var format = function format(value) {
261
285
  });
262
286
  } else {
263
287
  var thousandsSeparator = getThousandsSeparator(locale);
264
- cleanedValue = display.replace(new RegExp("".concat(thousandsSeparator, "(?=\\d{3})"), 'g'), '');
288
+ cleanedValue = String(display).replace(new RegExp("".concat(thousandsSeparator, "(?=\\d{3})"), 'g'), '');
265
289
  }
266
290
 
267
291
  return {
@@ -878,4 +902,78 @@ function formatToParts(_ref9) {
878
902
  return [{
879
903
  value: number
880
904
  }];
905
+ }
906
+
907
+ function handleCompactBeforeDisplay() {
908
+ var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
909
+ value = _ref10.value,
910
+ locale = _ref10.locale,
911
+ compact = _ref10.compact,
912
+ _ref10$decimals = _ref10.decimals,
913
+ decimals = _ref10$decimals === void 0 ? 0 : _ref10$decimals,
914
+ opts = _ref10.opts;
915
+
916
+ if (!canHandleCompact({
917
+ value: value,
918
+ compact: compact
919
+ })) {
920
+ return;
921
+ }
922
+
923
+ value = parseInt(Math.abs(value));
924
+ opts.notation = 'compact';
925
+
926
+ if (isTrue(compact) && locale && /(no|nb|nn)$/i.test(locale)) {
927
+ opts.compactDisplay = Math.abs(value) < 1000000 ? 'long' : 'short';
928
+ } else {
929
+ opts.compactDisplay = !isTrue(compact) ? compact : 'short';
930
+ }
931
+
932
+ if (typeof opts.maximumSignificantDigits === 'undefined') {
933
+ if (isNaN(parseFloat(decimals))) {
934
+ decimals = 0;
935
+ } else {
936
+ decimals = parseFloat(decimals);
937
+ }
938
+
939
+ var ref = String(value).length % 3;
940
+
941
+ if (ref === 2) {
942
+ decimals += 1;
943
+ } else if (ref === 0) {
944
+ decimals += 2;
945
+ }
946
+
947
+ opts.maximumSignificantDigits = decimals + 1;
948
+ }
949
+ }
950
+
951
+ function handleCompactBeforeAria(_ref11) {
952
+ var value = _ref11.value,
953
+ compact = _ref11.compact,
954
+ opts = _ref11.opts;
955
+
956
+ if (!canHandleCompact({
957
+ value: value,
958
+ compact: compact
959
+ })) {
960
+ return;
961
+ }
962
+
963
+ opts.compactDisplay = 'long';
964
+ }
965
+
966
+ function canHandleCompact(_ref12) {
967
+ var value = _ref12.value,
968
+ compact = _ref12.compact;
969
+
970
+ if (IS_IE11) {
971
+ return false;
972
+ }
973
+
974
+ if (compact && Math.abs(value) >= 1000) {
975
+ return true;
976
+ }
977
+
978
+ return false;
881
979
  }
@@ -13,6 +13,11 @@ export interface TagProps {
13
13
  * Default: null
14
14
  */
15
15
  icon?: IconPrimaryIcon;
16
+ /**
17
+ * If a label is given, typical inside a table or dl (definition list), then you can disable Tag.Group as a dependent of Tag. Use `true` to omit the `Tag group required:` warning.
18
+ * Default: null
19
+ */
20
+ hasLabel?: boolean;
16
21
  /**
17
22
  * Custom className on the component root
18
23
  * Default: null
@@ -45,13 +50,7 @@ export interface TagProps {
45
50
  omitOnKeyUpDeleteEvent?: boolean;
46
51
  }
47
52
  export declare const defaultProps: {
48
- className: any;
49
53
  skeleton: boolean;
50
- text: any;
51
- children: any;
52
- icon: any;
53
- onClick: any;
54
- onDelete: any;
55
54
  omitOnKeyUpDeleteEvent: boolean;
56
55
  };
57
56
  declare const Tag: {
@@ -3,7 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
3
3
 
4
4
  var _IconPrimary;
5
5
 
6
- var _excluded = ["className", "skeleton", "children", "text", "onClick", "onDelete", "omitOnKeyUpDeleteEvent"];
6
+ var _excluded = ["className", "skeleton", "children", "text", "hasLabel", "onClick", "onDelete", "omitOnKeyUpDeleteEvent"];
7
7
  import React from 'react';
8
8
  import classnames from 'classnames';
9
9
  import IconPrimary from '../icon-primary/IconPrimary';
@@ -14,13 +14,7 @@ import { usePropsWithContext } from '../../shared/hooks';
14
14
  import TagGroup from './TagGroup';
15
15
  import { TagGroupContext } from './TagContext';
16
16
  export var defaultProps = {
17
- className: null,
18
17
  skeleton: false,
19
- text: null,
20
- children: null,
21
- icon: null,
22
- onClick: null,
23
- onDelete: null,
24
18
  omitOnKeyUpDeleteEvent: false
25
19
  };
26
20
 
@@ -35,6 +29,7 @@ var Tag = function Tag(localProps) {
35
29
  skeleton = _usePropsWithContext.skeleton,
36
30
  children = _usePropsWithContext.children,
37
31
  text = _usePropsWithContext.text,
32
+ hasLabel = _usePropsWithContext.hasLabel,
38
33
  onClick = _usePropsWithContext.onClick,
39
34
  onDelete = _usePropsWithContext.onDelete,
40
35
  omitOnKeyUpDeleteEvent = _usePropsWithContext.omitOnKeyUpDeleteEvent,
@@ -67,7 +62,7 @@ var Tag = function Tag(localProps) {
67
62
  buttonAttr.icon = getDeleteIcon();
68
63
  }
69
64
 
70
- if (!tagGroupContext) {
65
+ if (!tagGroupContext && !hasLabel) {
71
66
  warn("Tag group required: A Tag requires a Tag.Group with label description as a parent component. This is to ensure correct semantic and accessibility.");
72
67
  }
73
68
 
@@ -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;
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- const _excluded = ["alt", "className", "children", "size", "skeleton", "variant", "src", "imgProps"];
4
+ const _excluded = ["alt", "className", "children", "size", "skeleton", "variant", "src", "imgProps", "hasLabel"];
5
5
 
6
6
  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; }
7
7
 
@@ -17,14 +17,9 @@ import { warn } from '../../shared/component-helper';
17
17
  import { usePropsWithContext } from '../../shared/hooks';
18
18
  import AvatarGroup, { AvatarGroupContext } from './AvatarGroup';
19
19
  export const defaultProps = {
20
- alt: null,
21
- className: null,
22
20
  size: 'medium',
23
- src: null,
24
- imgProps: null,
25
21
  variant: 'primary',
26
- skeleton: false,
27
- children: null
22
+ skeleton: false
28
23
  };
29
24
 
30
25
  const Avatar = localProps => {
@@ -40,7 +35,8 @@ const Avatar = localProps => {
40
35
  skeleton,
41
36
  variant,
42
37
  src,
43
- imgProps
38
+ imgProps,
39
+ hasLabel
44
40
  } = _usePropsWithContext,
45
41
  props = _objectWithoutProperties(_usePropsWithContext, _excluded);
46
42
 
@@ -66,7 +62,7 @@ const Avatar = localProps => {
66
62
  children = childrenProp;
67
63
  }
68
64
 
69
- if (!avatarGroupContext) {
65
+ if (!avatarGroupContext && !hasLabel) {
70
66
  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.`);
71
67
  }
72
68
 
@@ -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: {
@@ -13,12 +13,7 @@ import { usePropsWithContext } from '../../shared/hooks';
13
13
  import BreadcrumbItem from './BreadcrumbItem';
14
14
  import { convertJsxToString } from '../../shared/component-helper';
15
15
  export const defaultProps = {
16
- className: null,
17
16
  skeleton: false,
18
- children: null,
19
- variant: null,
20
- onClick: null,
21
- href: null,
22
17
  navText: 'Back',
23
18
  goBackText: 'Back',
24
19
  homeText: 'Home',
@@ -26,7 +21,6 @@ export const defaultProps = {
26
21
  isCollapsed: true,
27
22
  styleType: 'transparent',
28
23
  collapsedStyleType: 'pistachio',
29
- data: null,
30
24
  spacing: false
31
25
  };
32
26
 
@@ -66,7 +60,7 @@ const Breadcrumb = localProps => {
66
60
  });
67
61
  let currentVariant = variant;
68
62
 
69
- if (variant === null) {
63
+ if (!variant) {
70
64
  if (childrenItems || data) {
71
65
  currentVariant = isSmallScreen ? 'collapse' : 'multiple';
72
66
  } 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({ id, rootId, contentId, focusSelector, labelledBy, directDomReturn, hideCloseButton, closeButtonAttributes, disabled, title, dialogTitle, closeTitle, spacing, noAnimation, noAnimationOnMobile, animationDuration, fullscreen, onOpen, onClose, onClosePrevent, openModal, closeModal, preventClose, openState, openDelay, trigger, triggerAttributes, overlayClass, contentClass, top, bottom, left, right, space, ...props }: DialogProps & DialogContentProps): JSX.Element;
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;
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- const _excluded = ["id", "rootId", "contentId", "focusSelector", "labelledBy", "directDomReturn", "hideCloseButton", "closeButtonAttributes", "disabled", "title", "dialogTitle", "closeTitle", "spacing", "noAnimation", "noAnimationOnMobile", "animationDuration", "fullscreen", "onOpen", "onClose", "onClosePrevent", "openModal", "closeModal", "preventClose", "openState", "openDelay", "trigger", "triggerAttributes", "overlayClass", "contentClass", "top", "bottom", "left", "right", "space"];
4
+ const _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"];
5
5
 
6
6
  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; }
7
7
 
@@ -15,27 +15,37 @@ import DialogHeader from './parts/DialogHeader';
15
15
  import DialogNavigation from './parts/DialogNavigation';
16
16
  import classnames from 'classnames';
17
17
  import Context from '../../shared/Context';
18
- import { removeUndefinedProps } from '../../shared/component-helper';
18
+ import DialogAction from './parts/DialogAction';
19
+ import { usePropsWithContext } from '../../shared/hooks';
20
+ const defaultProps = {
21
+ variant: 'information',
22
+ spacing: true
23
+ };
19
24
 
20
- function Dialog(_ref) {
21
- let {
25
+ function Dialog(localProps) {
26
+ const context = useContext(Context);
27
+ const propsWithContext = usePropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.Dialog);
28
+
29
+ const {
22
30
  id,
23
31
  rootId,
24
32
  contentId,
25
33
  focusSelector,
26
34
  labelledBy,
27
35
  directDomReturn,
28
- hideCloseButton,
29
36
  closeButtonAttributes,
30
37
  disabled,
38
+ variant,
31
39
  title,
32
40
  dialogTitle,
33
41
  closeTitle,
34
- spacing = true,
42
+ spacing,
35
43
  noAnimation,
36
44
  noAnimationOnMobile,
37
45
  animationDuration,
38
- fullscreen = 'auto',
46
+ triggerAttributes,
47
+ hideCloseButton,
48
+ fullscreen,
39
49
  onOpen,
40
50
  onClose,
41
51
  onClosePrevent,
@@ -45,7 +55,6 @@ function Dialog(_ref) {
45
55
  openState,
46
56
  openDelay,
47
57
  trigger,
48
- triggerAttributes,
49
58
  overlayClass,
50
59
  contentClass,
51
60
  top,
@@ -53,11 +62,25 @@ function Dialog(_ref) {
53
62
  left,
54
63
  right,
55
64
  space
56
- } = _ref,
57
- props = _objectWithoutProperties(_ref, _excluded);
65
+ } = propsWithContext,
66
+ props = _objectWithoutProperties(propsWithContext, _excluded);
58
67
 
59
- const context = useContext(Context);
60
- const modalProps = removeUndefinedProps({
68
+ let currentHideCloseButton = hideCloseButton;
69
+ let currentTriggerAttributes = triggerAttributes;
70
+ let currentFullscreen = fullscreen;
71
+
72
+ if (variant === 'confirmation') {
73
+ currentHideCloseButton = hideCloseButton !== undefined ? hideCloseButton : true;
74
+ currentTriggerAttributes = triggerAttributes || {
75
+ hidden: true
76
+ };
77
+ }
78
+
79
+ if (fullscreen === undefined) {
80
+ currentFullscreen = variant === 'information' ? 'auto' : false;
81
+ }
82
+
83
+ const modalProps = {
61
84
  title,
62
85
  id,
63
86
  focusSelector,
@@ -68,13 +91,13 @@ function Dialog(_ref) {
68
91
  contentId,
69
92
  dialogTitle,
70
93
  closeTitle,
71
- hideCloseButton,
94
+ hideCloseButton: currentHideCloseButton,
72
95
  closeButtonAttributes,
73
96
  preventClose,
74
97
  animationDuration,
75
98
  noAnimation,
76
99
  noAnimationOnMobile,
77
- fullscreen,
100
+ fullscreen: currentFullscreen,
78
101
  openState,
79
102
  directDomReturn,
80
103
  rootId,
@@ -84,27 +107,32 @@ function Dialog(_ref) {
84
107
  openModal,
85
108
  closeModal,
86
109
  trigger,
87
- triggerAttributes,
110
+ triggerAttributes: currentTriggerAttributes,
88
111
  overlayClass,
89
112
  top,
90
113
  bottom,
91
114
  left,
92
115
  right,
93
116
  space
94
- });
95
- const dialogProps = removeUndefinedProps(_objectSpread(_objectSpread({}, props), {}, {
117
+ };
118
+
119
+ const dialogProps = _objectSpread(_objectSpread({}, props), {}, {
96
120
  noAnimation,
97
121
  noAnimationOnMobile,
98
- fullscreen,
99
- spacing
100
- }));
101
- return React.createElement(Modal, _extends({}, context.Dialog, modalProps, {
122
+ fullscreen: currentFullscreen,
123
+ spacing,
124
+ variant
125
+ });
126
+
127
+ return React.createElement(Modal, _extends({}, modalProps, {
102
128
  mode: "custom",
129
+ dialogRole: variant == 'information' ? 'dialog' : 'alertdialog',
103
130
  contentClass: classnames('dnb-dialog__root', contentClass)
104
- }), React.createElement(DialogContent, _extends({}, context.Dialog, dialogProps)));
131
+ }), React.createElement(DialogContent, dialogProps));
105
132
  }
106
133
 
107
134
  Dialog.Body = DialogBody;
108
135
  Dialog.Header = DialogHeader;
109
136
  Dialog.Navigation = DialogNavigation;
137
+ Dialog.Action = DialogAction;
110
138
  export default Dialog;
@@ -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;
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- const _excluded = ["modalContent", "navContent", "headerContent", "alignContent", "className", "class", "preventCoreStyle", "spacing", "fullscreen", "noAnimation", "noAnimationOnMobile", "minWidth", "maxWidth"];
3
+ const _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
 
@@ -12,26 +12,37 @@ import { isTrue, findElementInChildren } from '../../shared/component-helper';
12
12
  import ScrollView from '../../fragments/scroll-view/ScrollView';
13
13
  import DialogHeader from './parts/DialogHeader';
14
14
  import DialogNavigation from './parts/DialogNavigation';
15
+ import DialogAction from './parts/DialogAction';
15
16
  import { getContent } from '../modal/helpers';
16
17
  import ModalContext from '../modal/ModalContext';
17
18
  import { checkMinMaxWidth } from '../drawer/helpers';
18
19
  import ModalHeaderBar from '../modal/parts/ModalHeaderBar';
19
20
  import ModalHeader from '../modal/parts/ModalHeader';
21
+ import IconPrimary from '../icon-primary/IconPrimary';
20
22
  export default function DialogContent(_ref) {
21
23
  let {
22
24
  modalContent = null,
23
25
  navContent = null,
24
26
  headerContent = null,
25
- alignContent = 'left',
27
+ alignContent = null,
26
28
  className = null,
27
29
  class: _className = null,
28
30
  preventCoreStyle = null,
29
31
  spacing = true,
30
- fullscreen = 'auto',
32
+ fullscreen,
31
33
  noAnimation = false,
32
34
  noAnimationOnMobile = false,
33
35
  minWidth: min_width = null,
34
- maxWidth: max_width = null
36
+ maxWidth: max_width = null,
37
+ variant = 'information',
38
+ confirmType = 'info',
39
+ icon = null,
40
+ description,
41
+ hideDecline,
42
+ onConfirm,
43
+ onDecline,
44
+ declineText,
45
+ confirmText
35
46
  } = _ref,
36
47
  rest = _objectWithoutProperties(_ref, _excluded);
37
48
 
@@ -44,8 +55,12 @@ export default function DialogContent(_ref) {
44
55
  close: context === null || context === void 0 ? void 0 : context.close
45
56
  })) : rest);
46
57
 
58
+ if (alignContent === null) {
59
+ alignContent = variant === 'information' ? 'left' : 'centered';
60
+ }
61
+
47
62
  const innerParams = _objectSpread({
48
- 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--${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`),
63
+ 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--${variant}`, isTrue(spacing) && 'dnb-dialog--spacing', alignContent && `dnb-dialog__align--${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`),
49
64
  style: (minWidth || maxWidth) && {
50
65
  minWidth,
51
66
  maxWidth
@@ -57,14 +72,31 @@ export default function DialogContent(_ref) {
57
72
 
58
73
  const navExists = findElementInChildren(content, cur => cur.type === DialogNavigation || cur.type === ModalHeaderBar);
59
74
  const headerExists = findElementInChildren(content, cur => cur.type === DialogHeader || cur.type === ModalHeader);
75
+ const actionExists = findElementInChildren(content, cur => cur.type === DialogAction);
76
+ const dialogActionProps = {
77
+ onConfirm,
78
+ onDecline,
79
+ declineText,
80
+ confirmText,
81
+ hideDecline
82
+ };
60
83
  return React.createElement(ScrollView, innerParams, React.createElement("div", {
61
84
  tabIndex: -1,
62
85
  className: "dnb-dialog__inner dnb-no-focus",
63
86
  ref: context === null || context === void 0 ? void 0 : context.contentRef
64
- }, !navExists && React.createElement(DialogNavigation, null, navContent), !headerExists && React.createElement(DialogHeader, {
65
- title: context === null || context === void 0 ? void 0 : context.title
87
+ }, !navExists && React.createElement(DialogNavigation, null, navContent), icon && React.createElement("div", {
88
+ className: "dnb-dialog__icon"
89
+ }, React.createElement(IconPrimary, {
90
+ border: true,
91
+ key: "dialog-icon",
92
+ icon: icon,
93
+ "aria-hidden": true,
94
+ className: classnames('dnb-dialog__icon__primary', 'dnb-dialog__icon--' + confirmType)
95
+ })), !headerExists && React.createElement(DialogHeader, {
96
+ title: context === null || context === void 0 ? void 0 : context.title,
97
+ size: variant === 'information' ? 'x-large' : 'large'
66
98
  }, headerContent), React.createElement("div", {
67
99
  id: (context === null || context === void 0 ? void 0 : context.contentId) + '-content',
68
100
  className: "dnb-dialog__content"
69
- }, content)));
101
+ }, description, content), variant === 'confirmation' && !actionExists && React.createElement(DialogAction, dialogActionProps)));
70
102
  }