@dnb/eufemia 9.19.0 → 9.20.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 (200) hide show
  1. package/CHANGELOG.md +20 -198
  2. package/cjs/components/avatar/Avatar.js +14 -12
  3. package/cjs/components/avatar/AvatarGroup.js +11 -11
  4. package/cjs/components/avatar/style/_avatar.scss +2 -0
  5. package/cjs/components/avatar/style/dnb-avatar.css +4 -1
  6. package/cjs/components/avatar/style/dnb-avatar.min.css +1 -1
  7. package/cjs/components/breadcrumb/Breadcrumb.js +27 -52
  8. package/cjs/components/breadcrumb/BreadcrumbItem.js +15 -29
  9. package/cjs/components/button/Button.d.ts +11 -7
  10. package/cjs/components/icon-primary/IconPrimary.d.ts +2 -1
  11. package/cjs/components/info-card/InfoCard.js +22 -22
  12. package/cjs/components/pagination/Pagination.d.ts +6 -6
  13. package/cjs/components/pagination/Pagination.js +2 -2
  14. package/cjs/components/skeleton/Skeleton.d.ts +1 -1
  15. package/cjs/components/skeleton/SkeletonHelper.d.ts +2 -1
  16. package/cjs/components/step-indicator/StepIndicatorTriggerButton.js +4 -4
  17. package/cjs/components/tag/Tag.js +17 -29
  18. package/cjs/components/tag/TagGroup.js +10 -24
  19. package/cjs/components/timeline/Timeline.js +24 -64
  20. package/cjs/components/timeline/TimelineItem.js +16 -29
  21. package/cjs/elements/Div.d.ts +1 -1
  22. package/cjs/elements/P.d.ts +2 -1
  23. package/cjs/shared/AnimateHeight.js +19 -13
  24. package/cjs/shared/helpers.js +16 -4
  25. package/cjs/shared/hooks/index.js +13 -0
  26. package/cjs/shared/hooks/usePropsWithContext.js +92 -0
  27. package/cjs/style/dnb-ui-components.css +4 -1
  28. package/cjs/style/dnb-ui-components.min.css +1 -1
  29. package/cjs/style/dnb-ui-elements.css +1 -3
  30. package/cjs/style/dnb-ui-elements.min.css +1 -1
  31. package/cjs/style/dnb-ui-tags.css +2 -6
  32. package/cjs/style/dnb-ui-tags.min.css +2 -2
  33. package/cjs/style/elements/code.scss +1 -3
  34. package/cjs/style/stylis.d.ts +38 -0
  35. package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.css +1 -3
  36. package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
  37. package/cjs/style/themes/theme-ui/dnb-theme-ui.css +1 -3
  38. package/cjs/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
  39. package/components/avatar/Avatar.js +14 -13
  40. package/components/avatar/Avatar.tsx +8 -9
  41. package/components/avatar/AvatarGroup.js +20 -20
  42. package/components/avatar/AvatarGroup.tsx +4 -8
  43. package/components/avatar/style/_avatar.scss +2 -0
  44. package/components/avatar/style/dnb-avatar.css +4 -1
  45. package/components/avatar/style/dnb-avatar.min.css +1 -1
  46. package/components/breadcrumb/Breadcrumb.js +22 -35
  47. package/components/breadcrumb/Breadcrumb.tsx +10 -10
  48. package/components/breadcrumb/BreadcrumbItem.js +14 -25
  49. package/components/breadcrumb/BreadcrumbItem.tsx +8 -11
  50. package/components/button/Button.d.ts +11 -7
  51. package/components/icon-primary/IconPrimary.d.ts +2 -1
  52. package/components/info-card/InfoCard.js +22 -22
  53. package/components/info-card/InfoCard.tsx +13 -12
  54. package/components/modal/Modal.tsx +1 -1
  55. package/components/modal/ModalContent.tsx +6 -2
  56. package/components/modal/components/ModalHeader.tsx +2 -2
  57. package/components/modal/types.ts +2 -2
  58. package/components/pagination/Pagination.d.ts +6 -6
  59. package/components/pagination/Pagination.js +2 -2
  60. package/components/skeleton/SkeletonHelper.d.ts +2 -1
  61. package/components/step-indicator/StepIndicatorTriggerButton.js +4 -4
  62. package/components/tag/Tag.js +17 -27
  63. package/components/tag/Tag.tsx +15 -13
  64. package/components/tag/TagGroup.js +9 -22
  65. package/components/tag/TagGroup.tsx +6 -10
  66. package/components/timeline/Timeline.js +23 -27
  67. package/components/timeline/Timeline.tsx +24 -20
  68. package/components/timeline/TimelineItem.js +15 -25
  69. package/components/timeline/TimelineItem.tsx +8 -10
  70. package/elements/P.d.ts +2 -1
  71. package/es/components/avatar/Avatar.js +7 -6
  72. package/es/components/avatar/Avatar.tsx +8 -9
  73. package/es/components/avatar/AvatarGroup.js +6 -6
  74. package/es/components/avatar/AvatarGroup.tsx +4 -8
  75. package/es/components/avatar/style/_avatar.scss +2 -0
  76. package/es/components/avatar/style/dnb-avatar.css +4 -1
  77. package/es/components/avatar/style/dnb-avatar.min.css +1 -1
  78. package/es/components/breadcrumb/Breadcrumb.js +8 -14
  79. package/es/components/breadcrumb/Breadcrumb.tsx +10 -10
  80. package/es/components/breadcrumb/BreadcrumbItem.js +9 -13
  81. package/es/components/breadcrumb/BreadcrumbItem.tsx +8 -11
  82. package/es/components/button/Button.d.ts +11 -7
  83. package/es/components/icon-primary/IconPrimary.d.ts +2 -1
  84. package/es/components/info-card/InfoCard.js +8 -8
  85. package/es/components/info-card/InfoCard.tsx +13 -12
  86. package/es/components/modal/Modal.tsx +1 -1
  87. package/es/components/modal/ModalContent.tsx +6 -2
  88. package/es/components/modal/components/ModalHeader.tsx +2 -2
  89. package/es/components/modal/types.ts +2 -2
  90. package/es/components/pagination/Pagination.d.ts +6 -6
  91. package/es/components/pagination/Pagination.js +2 -2
  92. package/es/components/skeleton/Skeleton.d.ts +1 -1
  93. package/es/components/skeleton/SkeletonHelper.d.ts +2 -1
  94. package/es/components/step-indicator/StepIndicatorTriggerButton.js +4 -4
  95. package/es/components/tag/Tag.js +11 -14
  96. package/es/components/tag/Tag.tsx +15 -13
  97. package/es/components/tag/TagGroup.js +7 -13
  98. package/es/components/tag/TagGroup.tsx +6 -10
  99. package/es/components/timeline/Timeline.js +21 -17
  100. package/es/components/timeline/Timeline.tsx +24 -20
  101. package/es/components/timeline/TimelineItem.js +9 -12
  102. package/es/components/timeline/TimelineItem.tsx +8 -10
  103. package/es/elements/Div.d.ts +1 -1
  104. package/es/elements/P.d.ts +2 -1
  105. package/es/shared/AnimateHeight.js +15 -13
  106. package/es/shared/helpers.js +9 -2
  107. package/es/shared/hooks/index.js +1 -0
  108. package/es/shared/hooks/index.ts +1 -0
  109. package/es/shared/hooks/usePropsWithContext.js +26 -0
  110. package/es/shared/hooks/usePropsWithContext.ts +45 -0
  111. package/es/shared/interfaces.tsx +0 -2
  112. package/es/style/dnb-ui-components.css +4 -1
  113. package/es/style/dnb-ui-components.min.css +1 -1
  114. package/es/style/dnb-ui-elements.css +1 -3
  115. package/es/style/dnb-ui-elements.min.css +1 -1
  116. package/es/style/dnb-ui-tags.css +2 -6
  117. package/es/style/dnb-ui-tags.min.css +2 -2
  118. package/es/style/elements/code.scss +1 -3
  119. package/es/style/stylis.d.ts +38 -0
  120. package/es/style/themes/theme-open-banking/dnb-theme-open-banking.css +1 -3
  121. package/es/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
  122. package/es/style/themes/theme-ui/dnb-theme-ui.css +1 -3
  123. package/es/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
  124. package/esm/components/avatar/Avatar.js +14 -13
  125. package/esm/components/avatar/Avatar.tsx +8 -9
  126. package/esm/components/avatar/AvatarGroup.js +20 -20
  127. package/esm/components/avatar/AvatarGroup.tsx +4 -8
  128. package/esm/components/avatar/style/_avatar.scss +2 -0
  129. package/esm/components/avatar/style/dnb-avatar.css +4 -1
  130. package/esm/components/avatar/style/dnb-avatar.min.css +1 -1
  131. package/esm/components/breadcrumb/Breadcrumb.js +22 -35
  132. package/esm/components/breadcrumb/Breadcrumb.tsx +10 -10
  133. package/esm/components/breadcrumb/BreadcrumbItem.js +14 -25
  134. package/esm/components/breadcrumb/BreadcrumbItem.tsx +8 -11
  135. package/esm/components/button/Button.d.ts +11 -7
  136. package/esm/components/icon-primary/IconPrimary.d.ts +2 -1
  137. package/esm/components/info-card/InfoCard.js +22 -22
  138. package/esm/components/info-card/InfoCard.tsx +13 -12
  139. package/esm/components/modal/Modal.tsx +1 -1
  140. package/esm/components/modal/ModalContent.tsx +6 -2
  141. package/esm/components/modal/components/ModalHeader.tsx +2 -2
  142. package/esm/components/modal/types.ts +2 -2
  143. package/esm/components/pagination/Pagination.d.ts +6 -6
  144. package/esm/components/pagination/Pagination.js +2 -2
  145. package/esm/components/skeleton/SkeletonHelper.d.ts +2 -1
  146. package/esm/components/step-indicator/StepIndicatorTriggerButton.js +4 -4
  147. package/esm/components/tag/Tag.js +17 -27
  148. package/esm/components/tag/Tag.tsx +15 -13
  149. package/esm/components/tag/TagGroup.js +9 -22
  150. package/esm/components/tag/TagGroup.tsx +6 -10
  151. package/esm/components/timeline/Timeline.js +23 -27
  152. package/esm/components/timeline/Timeline.tsx +24 -20
  153. package/esm/components/timeline/TimelineItem.js +15 -25
  154. package/esm/components/timeline/TimelineItem.tsx +8 -10
  155. package/esm/dnb-ui-components.min.mjs +3 -3
  156. package/esm/dnb-ui-lib.min.mjs +3 -3
  157. package/esm/dnb-ui-web-components.min.mjs +4 -4
  158. package/esm/elements/P.d.ts +2 -1
  159. package/esm/shared/AnimateHeight.js +19 -13
  160. package/esm/shared/helpers.js +15 -4
  161. package/esm/shared/hooks/index.js +1 -0
  162. package/esm/shared/hooks/index.ts +1 -0
  163. package/esm/shared/hooks/usePropsWithContext.js +47 -0
  164. package/esm/shared/hooks/usePropsWithContext.ts +45 -0
  165. package/esm/shared/interfaces.tsx +0 -2
  166. package/esm/style/dnb-ui-components.css +4 -1
  167. package/esm/style/dnb-ui-components.min.css +1 -1
  168. package/esm/style/dnb-ui-elements.css +1 -3
  169. package/esm/style/dnb-ui-elements.min.css +1 -1
  170. package/esm/style/dnb-ui-tags.css +2 -6
  171. package/esm/style/dnb-ui-tags.min.css +2 -2
  172. package/esm/style/elements/code.scss +1 -3
  173. package/esm/style/stylis.d.ts +38 -0
  174. package/esm/style/themes/theme-open-banking/dnb-theme-open-banking.css +1 -3
  175. package/esm/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
  176. package/esm/style/themes/theme-ui/dnb-theme-ui.css +1 -3
  177. package/esm/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
  178. package/package.json +1 -1
  179. package/shared/AnimateHeight.js +19 -13
  180. package/shared/helpers.js +15 -4
  181. package/shared/hooks/index.js +1 -0
  182. package/shared/hooks/index.ts +1 -0
  183. package/shared/hooks/usePropsWithContext.js +47 -0
  184. package/shared/hooks/usePropsWithContext.ts +45 -0
  185. package/shared/interfaces.tsx +0 -2
  186. package/style/dnb-ui-components.css +4 -1
  187. package/style/dnb-ui-components.min.css +1 -1
  188. package/style/dnb-ui-elements.css +1 -3
  189. package/style/dnb-ui-elements.min.css +1 -1
  190. package/style/dnb-ui-tags.css +2 -6
  191. package/style/dnb-ui-tags.min.css +2 -2
  192. package/style/elements/code.scss +1 -3
  193. package/style/stylis.d.ts +38 -0
  194. package/style/themes/theme-open-banking/dnb-theme-open-banking.css +1 -3
  195. package/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
  196. package/style/themes/theme-ui/dnb-theme-ui.css +1 -3
  197. package/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
  198. package/umd/dnb-ui-components.min.js +3 -3
  199. package/umd/dnb-ui-lib.min.js +4 -4
  200. package/umd/dnb-ui-web-components.min.js +3 -3
@@ -47,6 +47,10 @@ declare global {
47
47
  }
48
48
  }
49
49
 
50
+ interface CSSPropertiesWithVars extends React.CSSProperties {
51
+ '--modal-background-color': string
52
+ }
53
+
50
54
  export default class ModalContent extends React.PureComponent<
51
55
  ModalContentProps,
52
56
  ModalContentState
@@ -476,9 +480,9 @@ export default class ModalContent extends React.PureComponent<
476
480
  tabIndex={-1}
477
481
  className="dnb-modal__content__spacing dnb-no-focus"
478
482
  style={
479
- color
483
+ (color
480
484
  ? { '--modal-background-color': `var(--color-${color})` }
481
- : null
485
+ : null) as CSSPropertiesWithVars
482
486
  }
483
487
  ref={this._contentRef}
484
488
  >
@@ -21,7 +21,7 @@ interface ModalHeaderProps {
21
21
  /**
22
22
  * The modal/drawer title. Displays on the very top of the content.
23
23
  */
24
- title?: React.ReactNode | string
24
+ title?: React.ReactNode
25
25
 
26
26
  /**
27
27
  * Give the inner content wrapper a class name (maps to `dnb-modal__content__inner`).
@@ -30,7 +30,7 @@ interface ModalHeaderProps {
30
30
  }
31
31
 
32
32
  export default class ModalHeader extends React.PureComponent<
33
- ModalHeaderProps & SectionProps
33
+ ModalHeaderProps & Omit<SectionProps, 'title'>
34
34
  > {
35
35
  static contextType = ModalContext
36
36
  render() {
@@ -180,7 +180,7 @@ export interface ModalContentProps {
180
180
  /**
181
181
  * The modal/drawer title. Displays on the very top of the content.
182
182
  */
183
- title?: React.ReactNode | string
183
+ title?: React.ReactNode
184
184
 
185
185
  dialog_title?: string
186
186
 
@@ -255,7 +255,7 @@ export interface ModalContentProps {
255
255
  */
256
256
  overlay_class?: string
257
257
 
258
- closeModal: (...args: any[]) => any
258
+ closeModal?: (...args: any[]) => any
259
259
 
260
260
  /**
261
261
  * Give the inner content wrapper a class name (maps to `dnb-modal__content__inner`).
@@ -128,7 +128,7 @@ export interface PaginationProps extends React.HTMLProps<HTMLElement> {
128
128
  skeleton?: PaginationSkeleton;
129
129
 
130
130
  /**
131
- * If set to `infinity`, then the pagination bar will be now shown and but infinity scrolling will do the content presentation. Defaults to `pagination`.
131
+ * If set to `infinity`, then the pagination bar will be now shown and but infinity scrolling will do the content presentation. For more information, check out the <a href="https://eufemia.dnb.no/uilib/components/pagination/infinity-scroller">Infinity Scroller</a>. Defaults to `pagination`.
132
132
  */
133
133
  mode?: PaginationMode;
134
134
 
@@ -214,7 +214,7 @@ export interface PaginationProps extends React.HTMLProps<HTMLElement> {
214
214
  is_loading_text?: string;
215
215
 
216
216
  /**
217
- * Used during infinity mode. If `use_load_button` is set to true, then a button is show on the bottom. If the `startup_page` is higher than 1, . Defaults to `Vis mer innhold`.
217
+ * Used during infinity mode. If `use_load_button` is set to true, then a button is show on the bottom. If the `startup_page` is higher than 1. Defaults to `Vis mer innhold`.
218
218
  */
219
219
  load_button_text?: string;
220
220
 
@@ -406,7 +406,7 @@ export interface PaginationInstanceProps {
406
406
  skeleton?: PaginationInstanceSkeleton;
407
407
 
408
408
  /**
409
- * If set to `infinity`, then the pagination bar will be now shown and but infinity scrolling will do the content presentation. Defaults to `pagination`.
409
+ * If set to `infinity`, then the pagination bar will be now shown and but infinity scrolling will do the content presentation. For more information, check out the <a href="https://eufemia.dnb.no/uilib/components/pagination/infinity-scroller">Infinity Scroller</a>. Defaults to `pagination`.
410
410
  */
411
411
  mode?: PaginationInstanceMode;
412
412
 
@@ -492,7 +492,7 @@ export interface PaginationInstanceProps {
492
492
  is_loading_text?: string;
493
493
 
494
494
  /**
495
- * Used during infinity mode. If `use_load_button` is set to true, then a button is show on the bottom. If the `startup_page` is higher than 1, . Defaults to `Vis mer innhold`.
495
+ * Used during infinity mode. If `use_load_button` is set to true, then a button is show on the bottom. If the `startup_page` is higher than 1. Defaults to `Vis mer innhold`.
496
496
  */
497
497
  load_button_text?: string;
498
498
 
@@ -686,7 +686,7 @@ export interface InfinityMarkerProps {
686
686
  skeleton?: InfinityMarkerSkeleton;
687
687
 
688
688
  /**
689
- * If set to `infinity`, then the pagination bar will be now shown and but infinity scrolling will do the content presentation. Defaults to `pagination`.
689
+ * If set to `infinity`, then the pagination bar will be now shown and but infinity scrolling will do the content presentation. For more information, check out the <a href="https://eufemia.dnb.no/uilib/components/pagination/infinity-scroller">Infinity Scroller</a>. Defaults to `pagination`.
690
690
  */
691
691
  mode?: InfinityMarkerMode;
692
692
 
@@ -772,7 +772,7 @@ export interface InfinityMarkerProps {
772
772
  is_loading_text?: string;
773
773
 
774
774
  /**
775
- * Used during infinity mode. If `use_load_button` is set to true, then a button is show on the bottom. If the `startup_page` is higher than 1, . Defaults to `Vis mer innhold`.
775
+ * Used during infinity mode. If `use_load_button` is set to true, then a button is show on the bottom. If the `startup_page` is higher than 1. Defaults to `Vis mer innhold`.
776
776
  */
777
777
  load_button_text?: string;
778
778
 
@@ -205,13 +205,13 @@ var PaginationInstance = function (_React$PureComponent2) {
205
205
  var pageNumber = _ref.pageNumber;
206
206
  return pageNumber === currentPage;
207
207
  })) === null || _items$find === void 0 ? void 0 : _items$find.content;
208
- return React.createElement(React.Fragment, null, this.context.pagination.mode === 'infinity' && typeof children !== 'function' && children, React.createElement("div", mainParams, React.createElement(PaginationBar, {
208
+ return React.createElement("div", mainParams, React.createElement(PaginationBar, {
209
209
  contentRef: this._contentRef
210
210
  }, children), items.length > 0 && React.createElement(PaginationContent, {
211
211
  ref: this._contentRef
212
212
  }, content || React.createElement(PaginationIndicator, {
213
213
  indicator_element: indicator_element || fallback_element
214
- }))));
214
+ })));
215
215
  }
216
216
 
217
217
  return _InfinityScroller || (_InfinityScroller = React.createElement(InfinityScroller, null));
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { SkeletonShow } from './Skeleton';
2
3
  export interface AutoSizeProps {
3
4
  __element?: React.ReactNode;
4
5
  children?: React.ReactNode;
@@ -20,7 +21,7 @@ export interface SkeletonContextProps {
20
21
  }
21
22
  export const createSkeletonClass: (
22
23
  method: 'shape' | 'font',
23
- skeleton: boolean,
24
+ skeleton: SkeletonShow,
24
25
  context?: SkeletonContextProps
25
26
  ) => React.HTMLProps<HTMLElement>;
26
27
  export interface skeletonDOMAttributesContext {
@@ -64,6 +64,8 @@ var StepIndicatorTriggerButton = function (_React$PureComponent) {
64
64
  key: "componentDidMount",
65
65
  value: function componentDidMount() {
66
66
  this._heightAnim.setElement(this._buttonRef.current);
67
+
68
+ this._prevStep = this.context.activeStep;
67
69
  }
68
70
  }, {
69
71
  key: "componentWillUnmount",
@@ -76,12 +78,10 @@ var StepIndicatorTriggerButton = function (_React$PureComponent) {
76
78
  if (this._prevStep !== this.context.activeStep) {
77
79
  var toHeight = this._heightAnim.getUnknownHeight();
78
80
 
79
- this._heightAnim.adjustFrom(height);
80
-
81
81
  this._heightAnim.adjustTo(height, toHeight);
82
- }
83
82
 
84
- this._prevStep = this.context.activeStep;
83
+ this._prevStep = this.context.activeStep;
84
+ }
85
85
  }
86
86
  }, {
87
87
  key: "render",
@@ -1,28 +1,16 @@
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
1
  import _extends from "@babel/runtime/helpers/esm/extends";
9
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
11
3
 
12
4
  var _IconPrimary;
13
5
 
14
6
  var _excluded = ["className", "skeleton", "children", "text", "onClick", "onDelete", "omitOnKeyUpDeleteEvent"];
15
-
16
- 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; }
17
-
18
- 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; }
19
-
20
7
  import React from 'react';
21
8
  import classnames from 'classnames';
22
9
  import IconPrimary from '../icon-primary/IconPrimary';
23
10
  import Button from '../button/Button';
24
11
  import Context from '../../shared/Context';
25
- import { warn, extendPropsWithContext } from '../../shared/component-helper';
12
+ import { warn } from '../../shared/component-helper';
13
+ import { usePropsWithContext } from '../../shared/hooks';
26
14
  import TagGroup from './TagGroup';
27
15
  import { TagGroupContext } from './TagContext';
28
16
  export var defaultProps = {
@@ -42,15 +30,15 @@ var Tag = function Tag(localProps) {
42
30
  var context = React.useContext(Context);
43
31
  var tagGroupContext = React.useContext(TagGroupContext);
44
32
 
45
- var _extendPropsWithConte = extendPropsWithContext(_objectSpread(_objectSpread({}, defaultProps), localProps), defaultProps, context === null || context === void 0 ? void 0 : (_context$translation = context.translation) === null || _context$translation === void 0 ? void 0 : _context$translation.Tag, context === null || context === void 0 ? void 0 : context.Tag, tagGroupContext),
46
- className = _extendPropsWithConte.className,
47
- skeleton = _extendPropsWithConte.skeleton,
48
- children = _extendPropsWithConte.children,
49
- text = _extendPropsWithConte.text,
50
- onClick = _extendPropsWithConte.onClick,
51
- onDelete = _extendPropsWithConte.onDelete,
52
- omitOnKeyUpDeleteEvent = _extendPropsWithConte.omitOnKeyUpDeleteEvent,
53
- props = _objectWithoutProperties(_extendPropsWithConte, _excluded);
33
+ var _usePropsWithContext = usePropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : (_context$translation = context.translation) === null || _context$translation === void 0 ? void 0 : _context$translation.Tag, context === null || context === void 0 ? void 0 : context.Tag, tagGroupContext),
34
+ className = _usePropsWithContext.className,
35
+ skeleton = _usePropsWithContext.skeleton,
36
+ children = _usePropsWithContext.children,
37
+ text = _usePropsWithContext.text,
38
+ onClick = _usePropsWithContext.onClick,
39
+ onDelete = _usePropsWithContext.onDelete,
40
+ omitOnKeyUpDeleteEvent = _usePropsWithContext.omitOnKeyUpDeleteEvent,
41
+ props = _objectWithoutProperties(_usePropsWithContext, _excluded);
54
42
 
55
43
  var content = text || children;
56
44
  var isClickable = !!onClick;
@@ -68,13 +56,15 @@ var Tag = function Tag(localProps) {
68
56
  }
69
57
  };
70
58
 
59
+ var buttonAttr = props;
60
+
71
61
  if (!isInteractive) {
72
- props.element = 'span';
73
- props.type = '';
62
+ buttonAttr.element = 'span';
63
+ buttonAttr.type = '';
74
64
  }
75
65
 
76
66
  if (isRemovable) {
77
- props.icon = getDeleteIcon();
67
+ buttonAttr.icon = getDeleteIcon();
78
68
  }
79
69
 
80
70
  if (!tagGroupContext) {
@@ -93,7 +83,7 @@ var Tag = function Tag(localProps) {
93
83
  onKeyUp: isRemovable && !omitOnKeyUpDeleteEvent ? function (e) {
94
84
  return handleKeyUp(e);
95
85
  } : undefined
96
- }, props));
86
+ }, buttonAttr));
97
87
 
98
88
  function getDeleteIcon() {
99
89
  return _IconPrimary || (_IconPrimary = React.createElement(IconPrimary, {
@@ -3,15 +3,14 @@ import classnames from 'classnames'
3
3
 
4
4
  // Components
5
5
  import IconPrimary, { IconPrimaryIcon } from '../icon-primary/IconPrimary'
6
- import Button from '../button/Button'
6
+ import Button, { ButtonProps } from '../button/Button'
7
7
 
8
8
  // Shared
9
9
  import Context from '../../shared/Context'
10
- import { ISpacingProps, SkeletonTypes } from '../../shared/interfaces'
11
- import {
12
- warn,
13
- extendPropsWithContext,
14
- } from '../../shared/component-helper'
10
+ import { ISpacingProps } from '../../shared/interfaces'
11
+ import { SkeletonShow } from '../skeleton/Skeleton'
12
+ import { warn } from '../../shared/component-helper'
13
+ import { usePropsWithContext } from '../../shared/hooks'
15
14
 
16
15
  // Internal
17
16
  import TagGroup from './TagGroup'
@@ -40,7 +39,7 @@ export interface TagProps {
40
39
  * Skeleton should be applied when loading content
41
40
  * Default: null
42
41
  */
43
- skeleton?: SkeletonTypes
42
+ skeleton?: SkeletonShow
44
43
 
45
44
  /**
46
45
  * The content of the tag element, can be a string or a React Element. Will be overwritten by text prop
@@ -93,8 +92,8 @@ const Tag = (localProps: TagProps & ISpacingProps) => {
93
92
  onDelete,
94
93
  omitOnKeyUpDeleteEvent,
95
94
  ...props
96
- } = extendPropsWithContext(
97
- { ...defaultProps, ...localProps },
95
+ } = usePropsWithContext(
96
+ localProps,
98
97
  defaultProps,
99
98
  context?.translation?.Tag,
100
99
  context?.Tag,
@@ -125,13 +124,16 @@ const Tag = (localProps: TagProps & ISpacingProps) => {
125
124
  }
126
125
  }
127
126
 
127
+ const buttonAttr: typeof props & Pick<ButtonProps, 'element' | 'type'> =
128
+ props
129
+
128
130
  if (!isInteractive) {
129
- props.element = 'span'
130
- props.type = ''
131
+ buttonAttr.element = 'span'
132
+ buttonAttr.type = ''
131
133
  }
132
134
 
133
135
  if (isRemovable) {
134
- props.icon = getDeleteIcon()
136
+ buttonAttr.icon = getDeleteIcon()
135
137
  }
136
138
 
137
139
  if (!tagGroupContext) {
@@ -155,7 +157,7 @@ const Tag = (localProps: TagProps & ISpacingProps) => {
155
157
  ? (e) => handleKeyUp(e)
156
158
  : undefined
157
159
  }
158
- {...props}
160
+ {...buttonAttr}
159
161
  />
160
162
  )
161
163
 
@@ -1,26 +1,13 @@
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
1
  import _extends from "@babel/runtime/helpers/esm/extends";
9
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
10
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
12
4
  var _excluded = ["label", "className", "children"];
13
5
  import "core-js/modules/es.array.map.js";
14
-
15
- 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; }
16
-
17
- 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; }
18
-
19
6
  import React from 'react';
20
7
  import classnames from 'classnames';
21
8
  import { createSpacingClasses } from '../space/SpacingHelper';
22
9
  import Context from '../../shared/Context';
23
- import { extendPropsWithContext } from '../../shared/component-helper';
10
+ import { usePropsWithContext } from '../../shared/hooks';
24
11
  import { TagGroupContext } from './TagContext';
25
12
  export var defaultProps = {
26
13
  label: null,
@@ -28,14 +15,14 @@ export var defaultProps = {
28
15
  children: null
29
16
  };
30
17
 
31
- function TagGroup(localProps) {
18
+ var TagGroup = function TagGroup(localProps) {
32
19
  var context = React.useContext(Context);
33
20
 
34
- var _extendPropsWithConte = extendPropsWithContext(_objectSpread(_objectSpread({}, defaultProps), localProps), defaultProps, context === null || context === void 0 ? void 0 : context.TagGroup),
35
- label = _extendPropsWithConte.label,
36
- className = _extendPropsWithConte.className,
37
- childrenProp = _extendPropsWithConte.children,
38
- props = _objectWithoutProperties(_extendPropsWithConte, _excluded);
21
+ var _usePropsWithContext = usePropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.TagGroup),
22
+ label = _usePropsWithContext.label,
23
+ className = _usePropsWithContext.className,
24
+ childrenProp = _usePropsWithContext.children,
25
+ props = _objectWithoutProperties(_usePropsWithContext, _excluded);
39
26
 
40
27
  var children = childrenProp;
41
28
 
@@ -48,13 +35,13 @@ function TagGroup(localProps) {
48
35
  var spacingClasses = createSpacingClasses(props);
49
36
  return React.createElement(TagGroupContext.Provider, {
50
37
  value: props
51
- }, React.createElement("div", _extends({
38
+ }, React.createElement("span", _extends({
52
39
  className: classnames('dnb-tag__group', spacingClasses, className),
53
40
  "data-testid": "tag-group"
54
41
  }, props), React.createElement("span", {
55
42
  "data-testid": "tag-group-label",
56
43
  className: "dnb-sr-only"
57
44
  }, label), children));
58
- }
45
+ };
59
46
 
60
47
  export default TagGroup;
@@ -7,7 +7,7 @@ import { createSpacingClasses } from '../space/SpacingHelper'
7
7
  // Shared
8
8
  import Context from '../../shared/Context'
9
9
  import { ISpacingProps } from '../../shared/interfaces'
10
- import { extendPropsWithContext } from '../../shared/component-helper'
10
+ import { usePropsWithContext } from '../../shared/hooks'
11
11
  import { TagGroupContext } from './TagContext'
12
12
 
13
13
  export interface TagGroupProps {
@@ -15,7 +15,7 @@ export interface TagGroupProps {
15
15
  * Aria label to describe the tag group
16
16
  * Default: null
17
17
  */
18
- label: string
18
+ label: React.ReactNode
19
19
 
20
20
  /**
21
21
  * Custom className on the component root
@@ -36,7 +36,7 @@ export const defaultProps = {
36
36
  children: null,
37
37
  }
38
38
 
39
- function TagGroup(localProps: TagGroupProps & ISpacingProps) {
39
+ const TagGroup = (localProps: TagGroupProps & ISpacingProps) => {
40
40
  // Every component should have a context
41
41
  const context = React.useContext(Context)
42
42
  // Extract additional props from global context
@@ -45,11 +45,7 @@ function TagGroup(localProps: TagGroupProps & ISpacingProps) {
45
45
  className,
46
46
  children: childrenProp,
47
47
  ...props
48
- } = extendPropsWithContext(
49
- { ...defaultProps, ...localProps },
50
- defaultProps,
51
- context?.TagGroup
52
- )
48
+ } = usePropsWithContext(localProps, defaultProps, context?.TagGroup)
53
49
 
54
50
  let children = childrenProp
55
51
 
@@ -63,7 +59,7 @@ function TagGroup(localProps: TagGroupProps & ISpacingProps) {
63
59
 
64
60
  return (
65
61
  <TagGroupContext.Provider value={props}>
66
- <div
62
+ <span
67
63
  className={classnames('dnb-tag__group', spacingClasses, className)}
68
64
  data-testid="tag-group"
69
65
  {...props}
@@ -72,7 +68,7 @@ function TagGroup(localProps: TagGroupProps & ISpacingProps) {
72
68
  {label}
73
69
  </span>
74
70
  {children}
75
- </div>
71
+ </span>
76
72
  </TagGroupContext.Provider>
77
73
  )
78
74
  }
@@ -1,28 +1,13 @@
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
1
  import _extends from "@babel/runtime/helpers/esm/extends";
9
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
11
3
  var _excluded = ["className", "skeleton", "data", "children"];
12
4
  import "core-js/modules/es.array.map.js";
13
- import "core-js/modules/es.function.name.js";
14
-
15
- 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; }
16
-
17
- 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; }
18
-
19
5
  import React from 'react';
20
6
  import classnames from 'classnames';
21
7
  import { createSpacingClasses } from '../space/SpacingHelper';
22
8
  import Context from '../../shared/Context';
23
- import { extendPropsWithContext } from '../../shared/component-helper';
9
+ import { usePropsWithContext } from '../../shared/hooks';
24
10
  import TimelineItem from './TimelineItem';
25
- export * from './TimelineItem';
26
11
  export var defaultProps = {
27
12
  className: null,
28
13
  skeleton: false,
@@ -30,27 +15,38 @@ export var defaultProps = {
30
15
  children: null
31
16
  };
32
17
 
33
- function Timeline(localProps) {
18
+ var Timeline = function Timeline(localProps) {
34
19
  var context = React.useContext(Context);
35
20
 
36
- var _extendPropsWithConte = extendPropsWithContext(_objectSpread(_objectSpread({}, defaultProps), localProps), defaultProps, context === null || context === void 0 ? void 0 : context.Timeline),
37
- className = _extendPropsWithConte.className,
38
- skeleton = _extendPropsWithConte.skeleton,
39
- data = _extendPropsWithConte.data,
40
- childrenItems = _extendPropsWithConte.children,
41
- props = _objectWithoutProperties(_extendPropsWithConte, _excluded);
21
+ var _usePropsWithContext = usePropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.Timeline),
22
+ className = _usePropsWithContext.className,
23
+ skeleton = _usePropsWithContext.skeleton,
24
+ data = _usePropsWithContext.data,
25
+ childrenProp = _usePropsWithContext.children,
26
+ props = _objectWithoutProperties(_usePropsWithContext, _excluded);
42
27
 
43
28
  var spacingClasses = createSpacingClasses(props);
29
+ var children = childrenProp;
30
+
31
+ if (Array.isArray(childrenProp)) {
32
+ children = childrenProp.map(function (child, i) {
33
+ return React.cloneElement(child, {
34
+ skeleton: skeleton,
35
+ key: i
36
+ });
37
+ });
38
+ }
39
+
44
40
  return React.createElement("div", _extends({
45
41
  className: classnames('dnb-timeline', spacingClasses, className),
46
42
  "data-testid": "timeline"
47
- }, props), data === null || data === void 0 ? void 0 : data.map(function (timelineItem) {
43
+ }, props), data === null || data === void 0 ? void 0 : data.map(function (timelineItem, i) {
48
44
  return React.createElement(TimelineItem, _extends({
49
- key: timelineItem.name,
45
+ key: i,
50
46
  skeleton: skeleton
51
47
  }, timelineItem));
52
- }), childrenItems);
53
- }
48
+ }), children);
49
+ };
54
50
 
55
51
  Timeline.Item = TimelineItem;
56
52
  export { TimelineItem };
@@ -6,14 +6,13 @@ import { createSpacingClasses } from '../space/SpacingHelper'
6
6
 
7
7
  // Shared
8
8
  import Context from '../../shared/Context'
9
- import { ISpacingProps, SkeletonTypes } from '../../shared/interfaces'
10
- import { extendPropsWithContext } from '../../shared/component-helper'
9
+ import { ISpacingProps } from '../../shared/interfaces'
10
+ import { SkeletonShow } from '../skeleton/Skeleton'
11
+ import { usePropsWithContext } from '../../shared/hooks'
11
12
 
12
13
  // Internal
13
14
  import TimelineItem, { TimelineItemProps } from './TimelineItem'
14
15
 
15
- export * from './TimelineItem'
16
-
17
16
  export interface TimelineProps {
18
17
  /**
19
18
  * Custom className on the component root
@@ -25,7 +24,7 @@ export interface TimelineProps {
25
24
  * Skeleton should be applied when loading content
26
25
  * Default: null
27
26
  */
28
- skeleton?: SkeletonTypes
27
+ skeleton?: SkeletonShow
29
28
 
30
29
  /**
31
30
  * Pass in a list of your events as objects of timelineitem, to render them as timelineitems.
@@ -37,7 +36,9 @@ export interface TimelineProps {
37
36
  * The content of the component. Can be used instead of prop "data".
38
37
  * Default: null
39
38
  */
40
- children?: TimelineItemProps[]
39
+ children?:
40
+ | React.ReactElement<TimelineItemProps>[]
41
+ | React.ReactElement<TimelineItemProps>
41
42
  }
42
43
 
43
44
  export const defaultProps = {
@@ -47,7 +48,7 @@ export const defaultProps = {
47
48
  children: null,
48
49
  }
49
50
 
50
- function Timeline(localProps: TimelineProps & ISpacingProps) {
51
+ const Timeline = (localProps: TimelineProps & ISpacingProps) => {
51
52
  // Every component should have a context
52
53
  const context = React.useContext(Context)
53
54
  // Extract additional props from global context
@@ -55,31 +56,34 @@ function Timeline(localProps: TimelineProps & ISpacingProps) {
55
56
  className,
56
57
  skeleton,
57
58
  data,
58
- children: childrenItems,
59
+ children: childrenProp,
59
60
  ...props
60
- } = extendPropsWithContext(
61
- { ...defaultProps, ...localProps },
62
- defaultProps,
63
- context?.Timeline
64
- )
61
+ } = usePropsWithContext(localProps, defaultProps, context?.Timeline)
65
62
 
66
63
  const spacingClasses = createSpacingClasses(props)
67
64
 
65
+ let children = childrenProp
66
+
67
+ if (Array.isArray(childrenProp)) {
68
+ children = childrenProp.map((child, i) => {
69
+ return React.cloneElement(child, {
70
+ skeleton: skeleton,
71
+ key: i,
72
+ })
73
+ })
74
+ }
75
+
68
76
  return (
69
77
  <div
70
78
  className={classnames('dnb-timeline', spacingClasses, className)}
71
79
  data-testid="timeline"
72
80
  {...props}
73
81
  >
74
- {data?.map((timelineItem: TimelineItemProps) => (
75
- <TimelineItem
76
- key={timelineItem.name}
77
- skeleton={skeleton}
78
- {...timelineItem}
79
- />
82
+ {data?.map((timelineItem, i) => (
83
+ <TimelineItem key={i} skeleton={skeleton} {...timelineItem} />
80
84
  ))}
81
85
 
82
- {childrenItems}
86
+ {children}
83
87
  </div>
84
88
  )
85
89
  }