@dnb/eufemia 10.0.0-beta.5 → 10.0.0-beta.7

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 (78) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/cjs/components/accordion/Accordion.d.ts +3 -2
  3. package/cjs/components/accordion/AccordionHeader.d.ts +1 -1
  4. package/cjs/components/autocomplete/Autocomplete.d.ts +2 -2
  5. package/cjs/components/button/Button.d.ts +2 -1
  6. package/cjs/components/dialog/parts/DialogHeader.d.ts +2 -1
  7. package/cjs/components/dropdown/Dropdown.d.ts +1 -1
  8. package/cjs/components/help-button/HelpButton.d.ts +1 -1
  9. package/cjs/components/input/Input.d.ts +1 -1
  10. package/cjs/components/input-masked/InputMasked.d.ts +1 -1
  11. package/cjs/components/modal/ModalContent.d.ts +1 -0
  12. package/cjs/components/modal/ModalContent.js +10 -2
  13. package/cjs/components/modal/parts/CloseButton.d.ts +1 -1
  14. package/cjs/components/modal/types.d.ts +3 -3
  15. package/cjs/components/pagination/Pagination.d.ts +33 -33
  16. package/cjs/components/toggle-button/ToggleButton.d.ts +1 -1
  17. package/cjs/components/tooltip/TooltipPortal.js +20 -6
  18. package/cjs/elements/div/Div.d.ts +2 -0
  19. package/cjs/fragments/drawer-list/DrawerList.js +5 -1
  20. package/cjs/shared/Eufemia.js +1 -1
  21. package/cjs/shared/Theme.d.ts +9 -1
  22. package/cjs/shared/Theme.js +55 -30
  23. package/cjs/shared/VisibilityByTheme.js +10 -1
  24. package/components/accordion/Accordion.d.ts +3 -2
  25. package/components/accordion/AccordionHeader.d.ts +1 -1
  26. package/components/autocomplete/Autocomplete.d.ts +2 -2
  27. package/components/button/Button.d.ts +2 -1
  28. package/components/dialog/parts/DialogHeader.d.ts +2 -1
  29. package/components/dropdown/Dropdown.d.ts +1 -1
  30. package/components/help-button/HelpButton.d.ts +1 -1
  31. package/components/input/Input.d.ts +1 -1
  32. package/components/input-masked/InputMasked.d.ts +1 -1
  33. package/components/modal/ModalContent.d.ts +1 -0
  34. package/components/modal/ModalContent.js +8 -2
  35. package/components/modal/parts/CloseButton.d.ts +1 -1
  36. package/components/modal/types.d.ts +3 -3
  37. package/components/pagination/Pagination.d.ts +33 -33
  38. package/components/toggle-button/ToggleButton.d.ts +1 -1
  39. package/components/tooltip/TooltipPortal.js +18 -6
  40. package/elements/div/Div.d.ts +2 -0
  41. package/es/components/accordion/Accordion.d.ts +3 -2
  42. package/es/components/accordion/AccordionHeader.d.ts +1 -1
  43. package/es/components/autocomplete/Autocomplete.d.ts +2 -2
  44. package/es/components/button/Button.d.ts +2 -1
  45. package/es/components/dialog/parts/DialogHeader.d.ts +2 -1
  46. package/es/components/dropdown/Dropdown.d.ts +1 -1
  47. package/es/components/help-button/HelpButton.d.ts +1 -1
  48. package/es/components/input/Input.d.ts +1 -1
  49. package/es/components/input-masked/InputMasked.d.ts +1 -1
  50. package/es/components/modal/ModalContent.d.ts +1 -0
  51. package/es/components/modal/ModalContent.js +8 -2
  52. package/es/components/modal/parts/CloseButton.d.ts +1 -1
  53. package/es/components/modal/types.d.ts +3 -3
  54. package/es/components/pagination/Pagination.d.ts +33 -33
  55. package/es/components/toggle-button/ToggleButton.d.ts +1 -1
  56. package/es/components/tooltip/TooltipPortal.js +17 -5
  57. package/es/elements/div/Div.d.ts +2 -0
  58. package/es/fragments/drawer-list/DrawerList.js +4 -1
  59. package/es/shared/Eufemia.js +1 -1
  60. package/es/shared/Theme.d.ts +9 -1
  61. package/es/shared/Theme.js +52 -31
  62. package/es/shared/VisibilityByTheme.js +6 -1
  63. package/esm/dnb-ui-basis.min.mjs +1 -1
  64. package/esm/dnb-ui-components.min.mjs +1 -1
  65. package/esm/dnb-ui-elements.min.mjs +1 -1
  66. package/esm/dnb-ui-extensions.min.mjs +1 -1
  67. package/esm/dnb-ui-lib.min.mjs +1 -1
  68. package/fragments/drawer-list/DrawerList.js +4 -1
  69. package/package.json +1 -1
  70. package/shared/Eufemia.js +1 -1
  71. package/shared/Theme.d.ts +9 -1
  72. package/shared/Theme.js +52 -31
  73. package/shared/VisibilityByTheme.js +6 -1
  74. package/umd/dnb-ui-basis.min.js +1 -1
  75. package/umd/dnb-ui-components.min.js +1 -1
  76. package/umd/dnb-ui-elements.min.js +1 -1
  77. package/umd/dnb-ui-extensions.min.js +1 -1
  78. package/umd/dnb-ui-lib.min.js +1 -1
@@ -3,7 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.ThemeWrapper = ThemeWrapper;
6
7
  exports.default = Theme;
8
+ exports.getThemeClasses = getThemeClasses;
7
9
 
8
10
  var _react = _interopRequireDefault(require("react"));
9
11
 
@@ -13,19 +15,15 @@ var _Context = _interopRequireDefault(require("./Context"));
13
15
 
14
16
  var _Provider = _interopRequireDefault(require("./Provider"));
15
17
 
16
- const _excluded = ["children", "element"],
17
- _excluded2 = ["name", "variant", "size", "colorMapping"];
18
+ var _componentHelper = require("./component-helper");
19
+
20
+ const _excluded = ["children", "element", "name", "variant", "size", "colorMapping"],
21
+ _excluded2 = ["children", "theme", "element", "className"];
18
22
 
19
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
24
 
21
25
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
22
26
 
23
- 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; }
24
-
25
- 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; }
26
-
27
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
28
-
29
27
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
30
28
 
31
29
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -35,45 +33,72 @@ function Theme(themeProps) {
35
33
 
36
34
  const {
37
35
  children,
38
- element
36
+ element,
37
+ name,
38
+ variant,
39
+ size,
40
+ colorMapping
39
41
  } = themeProps,
40
- theme = _objectWithoutProperties(themeProps, _excluded);
41
-
42
- const currentTheme = _objectSpread(_objectSpread({}, context === null || context === void 0 ? void 0 : context.theme), theme);
42
+ restProps = _objectWithoutProperties(themeProps, _excluded);
43
43
 
44
+ const theme = (0, _componentHelper.extendPropsWithContext)({
45
+ name,
46
+ variant,
47
+ size,
48
+ colorMapping
49
+ }, null, context === null || context === void 0 ? void 0 : context.theme);
44
50
  return _react.default.createElement(_Provider.default, {
45
- theme: currentTheme
46
- }, _react.default.createElement(ThemeWrapper, {
51
+ theme: theme
52
+ }, _react.default.createElement(ThemeWrapper, _extends({
47
53
  element: element,
48
- currentTheme: currentTheme
49
- }, children));
54
+ theme: theme
55
+ }, restProps), children));
50
56
  }
51
57
 
52
58
  function ThemeWrapper(_ref) {
53
59
  let {
54
60
  children,
55
- element,
56
- currentTheme
57
- } = _ref;
58
-
59
- const {
60
- name,
61
- variant,
62
- size,
63
- colorMapping
64
- } = currentTheme,
65
- rest = _objectWithoutProperties(currentTheme, _excluded2);
61
+ theme,
62
+ element = null,
63
+ className = null
64
+ } = _ref,
65
+ rest = _objectWithoutProperties(_ref, _excluded2);
66
66
 
67
- const Wrapper = element || 'div';
67
+ const Wrapper = element === false ? _react.default.Fragment : element || 'div';
68
68
 
69
69
  const ref = _react.default.useRef(null);
70
70
 
71
+ if (Wrapper === _react.default.Fragment) {
72
+ return children;
73
+ }
74
+
71
75
  rest['ref'] = ref;
72
- const className = (0, _classnames.default)('eufemia-theme', name && `eufemia-theme__${name}` + (variant ? ` eufemia-theme__${name}--${variant}` : ""), colorMapping && `eufemia-theme__color-mapping--${colorMapping}`, size && `eufemia-theme__size--${size}`);
76
+ const classNames = getThemeClasses(theme, className);
77
+ const {
78
+ name,
79
+ variant,
80
+ size
81
+ } = theme;
73
82
  return _react.default.createElement(Wrapper, _extends({
74
83
  "data-name": name,
75
84
  "data-variant": variant,
76
85
  "data-size": size,
77
- className: className
86
+ className: classNames
78
87
  }, rest), children);
88
+ }
89
+
90
+ function getThemeClasses(theme) {
91
+ let className = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
92
+
93
+ if (!theme) {
94
+ return className;
95
+ }
96
+
97
+ const {
98
+ name,
99
+ variant,
100
+ size,
101
+ colorMapping
102
+ } = theme;
103
+ return (0, _classnames.default)(className, 'eufemia-theme', name && `eufemia-theme__${name}` + (variant ? ` eufemia-theme__${name}--${variant}` : ""), colorMapping && `eufemia-theme__color-mapping--${colorMapping}`, size && `eufemia-theme__size--${size}`);
79
104
  }
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = VisibilityByTheme;
7
7
 
8
+ var _react = _interopRequireDefault(require("react"));
9
+
8
10
  var _useTheme = _interopRequireDefault(require("./useTheme"));
9
11
 
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -15,7 +17,14 @@ function VisibilityByTheme(_ref) {
15
17
  visible,
16
18
  hidden
17
19
  } = _ref;
18
- const theme = (0, _useTheme.default)();
20
+ const themeOrig = (0, _useTheme.default)();
21
+
22
+ const [theme, refresh] = _react.default.useState({});
23
+
24
+ _react.default.useLayoutEffect(() => {
25
+ refresh(themeOrig);
26
+ }, [themeOrig]);
27
+
19
28
  const visibleList = Array.isArray(visible) ? visible : [visible];
20
29
  const hiddenList = Array.isArray(hidden) ? hidden : [hidden];
21
30
 
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { ButtonIconPosition } from '../button';
2
+ import type { ButtonIconPosition } from '../Button';
3
3
  import type { HeadingLevel } from '../Heading';
4
4
  import type { IconIcon, IconSize } from '../Icon';
5
5
  import type { SkeletonShow } from '../Skeleton';
@@ -21,6 +21,7 @@ export type AccordionIcon =
21
21
  expanded?: React.ReactNode | ((...args: any[]) => any);
22
22
  };
23
23
  export type AccordionAttributes = string | Record<string, unknown>;
24
+ export type AccordionIconPosition = ButtonIconPosition;
24
25
  export interface AccordionProps
25
26
  extends Omit<React.HTMLProps<HTMLElement>, 'ref'>,
26
27
  SpacingProps {
@@ -129,7 +130,7 @@ export interface AccordionProps
129
130
  /**
130
131
  * Will set the placement of the icon. Defaults to `left`.
131
132
  */
132
- icon_position?: ButtonIconPosition;
133
+ icon_position?: AccordionIconPosition;
133
134
 
134
135
  /**
135
136
  * Define a different icon size. Defaults to `medium` (1.5rem).
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { ButtonIconPosition } from '../button';
2
+ import type { ButtonIconPosition } from '../Button';
3
3
  import type { HeadingLevel } from '../Heading';
4
4
  import type { IconSize } from '../Icon';
5
5
  import type { SkeletonShow } from '../Skeleton';
@@ -4,7 +4,7 @@ import type {
4
4
  DrawerListData,
5
5
  DrawerListOptionsRender
6
6
  } from '../../fragments/DrawerList';
7
- import type { ButtonIconPosition } from '../button';
7
+ import type { ButtonIconPosition } from '../Button';
8
8
  import type { FormLabelLabelDirection, FormLabelText } from '../FormLabel';
9
9
  import type {
10
10
  FormStatusProps,
@@ -29,7 +29,7 @@ type AutocompleteSubmitButtonIcon =
29
29
  | ((...args: any[]) => any);
30
30
  type AutocompleteInputRef =
31
31
  | ((...args: any[]) => any)
32
- | Record<string, unknown>;
32
+ | React.MutableRefObject<HTMLInputElement | undefined>;
33
33
  type AutocompleteInputIcon =
34
34
  | string
35
35
  | React.ReactNode
@@ -15,6 +15,7 @@ export type ButtonVariant =
15
15
  | 'signal'
16
16
  | 'unstyled';
17
17
  export type ButtonSize = 'default' | 'small' | 'medium' | 'large';
18
+ export type ButtonIcon = IconIcon;
18
19
  export type ButtonIconPositionTertiary = 'top';
19
20
  export type ButtonIconPosition = 'left' | 'right';
20
21
  export type ButtonIconPositionAll =
@@ -65,7 +66,7 @@ export type ButtonProps = {
65
66
  /**
66
67
  * To be included in the button. <a href="/icons/primary">Primary Icons</a> can be set as a string (e.g. `icon="chevron_right"`), other icons should be set as React elements.
67
68
  */
68
- icon?: IconIcon;
69
+ icon?: ButtonIcon;
69
70
 
70
71
  /**
71
72
  * Position of icon inside the button. Set to `left` or `right`. Tertiary button variant also supports `top`. Defaults to `right` if not set.
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ModalHeaderProps } from '../../modal/parts/ModalHeader';
3
- interface DialogHeaderProps extends ModalHeaderProps {
3
+ import type { SpacingProps } from '../../space/types';
4
+ interface DialogHeaderProps extends ModalHeaderProps, SpacingProps {
4
5
  titleClass?: string;
5
6
  }
6
7
  export default function DialogHeader({ className, titleClass, size, ref, // eslint-disable-line
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { FormLabelLabelDirection, FormLabelText } from '../FormLabel';
3
- import type { ButtonIconPosition, ButtonVariant } from '../button';
3
+ import type { ButtonIconPosition, ButtonVariant } from '../Button';
4
4
  import type {
5
5
  FormStatusProps,
6
6
  FormStatusState,
@@ -3,7 +3,7 @@
3
3
  *
4
4
  */
5
5
  import React from 'react';
6
- import { ButtonProps } from '../button/Button';
6
+ import type { ButtonProps } from '../button/Button';
7
7
  import { ModalProps } from '../modal/types';
8
8
  export declare type HelpButtonProps = {
9
9
  modal_content?: React.ReactNode;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { ButtonIconPosition, ButtonVariant } from '../button';
2
+ import type { ButtonIconPosition, ButtonVariant } from '../Button';
3
3
  import type {
4
4
  FormStatusProps,
5
5
  FormStatusState,
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { Locale } from '../../shared/Context';
3
- import type { ButtonIconPosition } from '../button';
3
+ import type { ButtonIconPosition } from '../Button';
4
4
  import type { FormLabelLabelDirection, FormLabelText } from '../FormLabel';
5
5
  import type {
6
6
  FormStatusProps,
@@ -33,6 +33,7 @@ export default class ModalContent extends React.PureComponent<ModalContentProps,
33
33
  _androidFocusTimeout: NodeJS.Timeout;
34
34
  _ii: InteractionInvalidation;
35
35
  _iiLocal: InteractionInvalidation;
36
+ static contextType: React.Context<import("../../shared/Context").ContextProps>;
36
37
  constructor(props: ModalContentProps);
37
38
  componentDidMount(): void;
38
39
  componentWillUnmount(): void;
@@ -16,6 +16,8 @@ import { warn, isTrue, makeUniqueId, InteractionInvalidation, combineLabelledBy,
16
16
  import ModalContext from './ModalContext';
17
17
  import { IS_IOS, IS_SAFARI, IS_MAC, isAndroid } from '../../shared/helpers';
18
18
  import { getListOfModalRoots, getModalRoot, addToIndex, removeFromIndex } from './helpers';
19
+ import { getThemeClasses } from '../../shared/Theme';
20
+ import { Context } from '../../shared';
19
21
  export default class ModalContent extends React.PureComponent {
20
22
  constructor(props) {
21
23
  super(props);
@@ -295,6 +297,8 @@ export default class ModalContent extends React.PureComponent {
295
297
  }
296
298
 
297
299
  render() {
300
+ var _this$context;
301
+
298
302
  const _this$props2 = this.props,
299
303
  {
300
304
  hide,
@@ -335,7 +339,7 @@ export default class ModalContent extends React.PureComponent {
335
339
  'aria-labelledby': combineLabelledBy(this.props, title ? contentId + '-title' : null, labelled_by),
336
340
  'aria-describedby': combineDescribedBy(this.props, contentId + '-content'),
337
341
  'aria-label': !title && !labelled_by ? dialog_title : undefined,
338
- className: classnames('dnb-modal__content', isTrue(fullscreen) ? 'dnb-modal__content--fullscreen' : fullscreen === 'auto' && 'dnb-modal__content--auto-fullscreen', content_class, container_placement && `dnb-modal__content--${container_placement || 'right'}`),
342
+ className: classnames('dnb-modal__content', isTrue(fullscreen) ? 'dnb-modal__content--fullscreen' : fullscreen === 'auto' && 'dnb-modal__content--auto-fullscreen', getThemeClasses((_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.theme), content_class, container_placement && `dnb-modal__content--${container_placement || 'right'}`),
339
343
  onMouseDown: this.onContentMouseDownHandler,
340
344
  onClick: this.onContentClickHandler
341
345
  };
@@ -370,4 +374,6 @@ export default class ModalContent extends React.PureComponent {
370
374
  }));
371
375
  }
372
376
 
373
- }
377
+ }
378
+
379
+ _defineProperty(ModalContent, "contextType", Context);
@@ -3,7 +3,7 @@
3
3
  *
4
4
  */
5
5
  import React from 'react';
6
- import { ButtonProps } from '../../button';
6
+ import type { ButtonProps } from '../../button/Button';
7
7
  export declare type CloseButtonProps = {
8
8
  /**
9
9
  * The title of the close button. Defaults to <em>Close</em> or <em>Lukk</em>.
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- import { CloseButtonProps } from './parts/CloseButton';
3
- import { ButtonProps } from '../button/Button';
4
- import { ModalRootProps } from './ModalRoot';
2
+ import type { CloseButtonProps } from './parts/CloseButton';
3
+ import type { ButtonProps } from '../button/Button';
4
+ import type { ModalRootProps } from './ModalRoot';
5
5
  export declare type ReactChildType = React.ReactNode | ((...args: any[]) => any);
6
6
  export declare type ModalFullscreen = 'auto' | boolean;
7
7
  export declare type ModalAlignContent = 'left' | 'center' | 'centered' | 'right';
@@ -34,170 +34,170 @@ type PaginationIndicatorElement =
34
34
  | ((...args: any[]) => any)
35
35
  | string;
36
36
  type PaginationChildren = React.ReactNode | ((...args: any[]) => any);
37
- interface PaginationProps
37
+ export interface PaginationProps
38
38
  extends React.HTMLProps<HTMLElement>,
39
39
  SpacingProps {
40
40
  /**
41
41
  * The page shown in the very beginning. If `current_page` is set, then it may not make too much sense to set this as well.
42
42
  */
43
43
  startup_page?: PaginationStartupPage;
44
+
44
45
  /**
45
46
  * The page shown at the moment the component renders. Defaults to `1`.
46
47
  */
47
-
48
48
  current_page?: PaginationCurrentPage;
49
+
49
50
  /**
50
51
  * The total pages count. Defaults to `1`.
51
52
  */
52
-
53
53
  page_count?: PaginationPageCount;
54
+
54
55
  /**
55
56
  * Defines how many `infinity` pages should be loaded / shown on the first render. Defaults to `1`.
56
57
  */
57
-
58
58
  startup_count?: PaginationStartupCount;
59
+
59
60
  /**
60
61
  * Defines how many `infinity` pages should be loaded / shown once the user scrolls down. Defaults to `1`.
61
62
  */
62
-
63
63
  parallel_load_count?: PaginationParallelLoadCount;
64
+
64
65
  /**
65
66
  * If set to `true`, the infinity marker will be placed before the content (on top off). This could potentially have negative side effects. But it depends really on the content if this would make more sense to use instead. Defaults to `false`.
66
67
  */
67
-
68
68
  place_maker_before_content?: boolean;
69
+
69
70
  /**
70
71
  * The minimum time to wait, if the infinity scroll was invoked under that time threshold. This prevents not intentional infinity scroll loop calls. Defaults to `400` milliseconds.
71
72
  */
72
-
73
73
  min_wait_time?: PaginationMinWaitTime;
74
+
74
75
  /**
75
76
  * If set to `true`, all pagination bar buttons are disabled.
76
77
  */
77
-
78
78
  disabled?: boolean;
79
+
79
80
  /**
80
81
  * If set to `true`, an overlaying skeleton with animation will be shown.
81
82
  */
82
-
83
83
  skeleton?: SkeletonShow;
84
+
84
85
  /**
85
86
  * 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`.
86
87
  */
87
-
88
88
  mode?: PaginationMode;
89
+
89
90
  /**
90
91
  * If set to `true` it will disable the automated infinity scrolling, but shows a load more button at the of the content instead.
91
92
  */
92
-
93
93
  use_load_button?: boolean;
94
94
  items?: PaginationItems;
95
+
95
96
  /**
96
97
  * If set to `true` no indicator will be shown.
97
98
  */
98
-
99
99
  hide_progress_indicator?: boolean;
100
+
100
101
  /**
101
102
  * Callback function to get the `setContent` handler from the current pagination instance. e.g. `set_content_handler={fn => (...)}`. Use this handler to insert content during infinity mode.
102
103
  */
103
-
104
104
  set_content_handler?: PaginationSetContentHandler;
105
+
105
106
  /**
106
107
  * Callback function to get the `resetContent` handler from the current pagination instance. e.g. `reset_content_handler={fn => (...)}`. Use this handler to reset all the content. You can set it to `true`, to programmatically reset the content.
107
108
  */
108
-
109
109
  reset_content_handler?: PaginationResetContentHandler;
110
+
110
111
  /**
111
112
  * Callback function to get the `resetInfinity` handler from the current pagination instance. e.g. `reset_pagination_handler={fn => (...)}`. Use this handler to reset all the internal states. You can set it to `true`, to programmatically reset the states.
112
113
  */
113
-
114
114
  reset_pagination_handler?: PaginationResetPaginationHandler;
115
+
115
116
  /**
116
117
  * Callback function to get the `endInfinity` handler from the current pagination instance. e.g. `end_infinity_handler={fn => (...)}`. Use this handler to end the infinity scrolling procedure, in case the `page_count` is unknown.
117
118
  */
118
-
119
119
  end_infinity_handler?: PaginationEndInfinityHandler;
120
+
120
121
  /**
121
122
  * By default a `<div>` is used. Set it to any element you have to use. Adds also a class: `dnb-pagination__page` shown.
122
123
  */
123
-
124
124
  page_element?: PaginationPageElement;
125
+
125
126
  /**
126
127
  * (infinity mode) is used by the <em>indicator</em>, <em>load more</em> bar as well as by the marker. Defaults to a `div`.
127
128
  */
128
-
129
129
  fallback_element?: PaginationFallbackElement;
130
+
130
131
  /**
131
132
  * (infinity mode) is used by the internal marker. Falls back to `fallback_element` if not defined.
132
133
  */
133
-
134
134
  marker_element?: PaginationMarkerElement;
135
+
135
136
  /**
136
137
  * (infinity mode) is used by the <em>indicator</em>. Falls back to `fallback_element` if not defined.
137
138
  */
138
-
139
139
  indicator_element?: PaginationIndicatorElement;
140
+
140
141
  /**
141
142
  * Define the alignment of the pagination button bar. Can be `center`, `left` or `right`. Defaults to `left`.
142
143
  */
143
-
144
144
  align?: string;
145
+
145
146
  /**
146
147
  * The title used in every button shown in the bar. Defaults to `Side %s`.
147
148
  */
148
-
149
149
  button_title?: string;
150
+
150
151
  /**
151
152
  * The title used in the previous page button. Defaults to `Forrige side`.
152
153
  */
153
-
154
154
  prev_title?: string;
155
+
155
156
  /**
156
157
  * The title used in the next page button. Defaults to `Neste side`.
157
158
  */
158
-
159
159
  next_title?: string;
160
+
160
161
  /**
161
162
  * The title used in the dots. Relevant for screen-readers. Defaults to `%s flere sider`.
162
163
  */
163
-
164
164
  more_pages?: string;
165
+
165
166
  /**
166
167
  * Shown until new content is inserted in to the page. Defaults to `Laster nytt innhold`.
167
168
  */
168
-
169
169
  is_loading_text?: string;
170
+
170
171
  /**
171
- * 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`.
172
+ * 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`.
172
173
  */
173
-
174
174
  load_button_text?: string;
175
175
  class?: string;
176
176
  className?: string;
177
+
177
178
  /**
178
179
  * The given content can be either a function or a React node, depending on your needs. A function contains several helper functions. More details down below and have a look at the examples in the demos section.
179
180
  */
180
-
181
181
  children?: PaginationChildren;
182
+
182
183
  /**
183
184
  * Will be called for every page change, regardless if the mode is `mode="infinity"` or not. Returns an object with number of useful properties and methods. See below for more details.
184
185
  */
185
-
186
186
  on_change?: (...args: any[]) => any;
187
+
187
188
  /**
188
189
  * Only on "infinity" mode. Will be called once the component is ready for interaction. Returns an object with number of useful properties and methods. See below for more details. "NB:" Will be called again as soon as we reset the content by calling `resetContent()`.
189
190
  */
190
-
191
191
  on_startup?: (...args: any[]) => any;
192
+
192
193
  /**
193
194
  * Only on "infinity" mode. Will be called on every page interaction, also on the very first interaction. Returns an object with number of useful properties and methods. See below for more details.
194
195
  */
195
-
196
196
  on_load?: (...args: any[]) => any;
197
+
197
198
  /**
198
199
  * Only on "infinity" mode. Will be called once `page_count` is reached or `endInfinity` was called.
199
200
  */
200
-
201
201
  on_end?: (...args: any[]) => any;
202
202
  }
203
203
  export default class Pagination extends React.Component<
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { ButtonIconPosition } from '../button';
2
+ import type { ButtonIconPosition } from '../Button';
3
3
  import type { FormLabelLabelDirection, FormLabelText } from '../FormLabel';
4
4
  import type {
5
5
  FormStatusProps,
@@ -3,6 +3,8 @@ import React from 'react';
3
3
  import ReactDOM from 'react-dom';
4
4
  import { makeUniqueId, warn } from '../../shared/component-helper';
5
5
  import TooltipContainer from './TooltipContainer';
6
+ import { useTheme } from '../../shared';
7
+ import { getThemeClasses } from '../../shared/Theme';
6
8
  let tooltipPortal;
7
9
 
8
10
  if (typeof globalThis !== 'undefined') {
@@ -26,12 +28,13 @@ function TooltipPortal(props) {
26
28
  const [id] = React.useState(() => props.group || makeUniqueId());
27
29
  const isInDOM = React.useRef(false);
28
30
  const hasGroup = props.group;
31
+ const theme = useTheme();
29
32
 
30
33
  const makePortal = () => {
31
34
  if (!tooltipPortal[id]) {
32
35
  tooltipPortal[id] = {
33
36
  count: 0,
34
- node: hasGroup ? createGroupElement(id) : createRootElement()
37
+ node: hasGroup ? createGroupElement(theme, id) : createRootElement(theme)
35
38
  };
36
39
  }
37
40
  };
@@ -56,7 +59,7 @@ function TooltipPortal(props) {
56
59
  if (ref.count <= 0) {
57
60
  if (hasGroup) {
58
61
  ReactDOM.unmountComponentAtNode(ref.node);
59
- createRootElement().removeChild(ref.node);
62
+ createRootElement(theme).removeChild(ref.node);
60
63
  }
61
64
 
62
65
  delete tooltipPortal[id];
@@ -147,20 +150,24 @@ function TooltipPortal(props) {
147
150
 
148
151
  export default TooltipPortal;
149
152
 
150
- const createGroupElement = id => {
153
+ const createGroupElement = (theme, id) => {
151
154
  try {
152
155
  const elem = document.createElement('div');
153
156
  elem.classList.add('dnb-tooltip__group');
154
157
  elem.setAttribute('id', id);
155
- createRootElement().appendChild(elem);
158
+ createRootElement(theme).appendChild(elem);
156
159
  return elem;
157
160
  } catch (e) {
158
161
  warn(e);
159
162
  }
160
163
  };
161
164
 
162
- const createRootElement = function () {
163
- let className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'dnb-tooltip__portal';
165
+ const createRootElement = function (theme) {
166
+ let className = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
167
+
168
+ if (!className) {
169
+ className = 'dnb-tooltip__portal';
170
+ }
164
171
 
165
172
  try {
166
173
  const element = document.querySelector(`.${className}`);
@@ -172,6 +179,11 @@ const createRootElement = function () {
172
179
  const elem = document.createElement('div');
173
180
  elem.classList.add(className);
174
181
  elem.classList.add('dnb-core-style');
182
+
183
+ if (theme) {
184
+ elem.classList.add.call(elem.classList, ...getThemeClasses(theme).split(' '));
185
+ }
186
+
175
187
  document.body.appendChild(elem);
176
188
  return elem;
177
189
  } catch (e) {
@@ -3,6 +3,8 @@
3
3
  *
4
4
  */
5
5
  import React from 'react';
6
+ import { SpacingProps } from '../../components/space/types';
7
+ export declare type DivProps = SpacingProps & React.HTMLAttributes<HTMLElement>;
6
8
  declare const Div: React.ForwardRefExoticComponent<import("../../components/space/types").SpacingElementProps & {
7
9
  space?: import("../../components/space/types").SpaceType | import("../../components/space/types").SpacingElementProps;
8
10
  } & React.HTMLAttributes<HTMLElement> & React.RefAttributes<unknown>>;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { ButtonIconPosition } from '../button';
2
+ import type { ButtonIconPosition } from '../Button';
3
3
  import type { HeadingLevel } from '../Heading';
4
4
  import type { IconIcon, IconSize } from '../Icon';
5
5
  import type { SkeletonShow } from '../Skeleton';
@@ -21,6 +21,7 @@ export type AccordionIcon =
21
21
  expanded?: React.ReactNode | ((...args: any[]) => any);
22
22
  };
23
23
  export type AccordionAttributes = string | Record<string, unknown>;
24
+ export type AccordionIconPosition = ButtonIconPosition;
24
25
  export interface AccordionProps
25
26
  extends Omit<React.HTMLProps<HTMLElement>, 'ref'>,
26
27
  SpacingProps {
@@ -129,7 +130,7 @@ export interface AccordionProps
129
130
  /**
130
131
  * Will set the placement of the icon. Defaults to `left`.
131
132
  */
132
- icon_position?: ButtonIconPosition;
133
+ icon_position?: AccordionIconPosition;
133
134
 
134
135
  /**
135
136
  * Define a different icon size. Defaults to `medium` (1.5rem).
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { ButtonIconPosition } from '../button';
2
+ import type { ButtonIconPosition } from '../Button';
3
3
  import type { HeadingLevel } from '../Heading';
4
4
  import type { IconSize } from '../Icon';
5
5
  import type { SkeletonShow } from '../Skeleton';