@dnb/eufemia 9.25.0 → 9.26.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 (47) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/cjs/components/accordion/Accordion.d.ts +17 -4
  3. package/cjs/components/accordion/AccordionHeader.d.ts +11 -4
  4. package/cjs/components/accordion/AccordionHeader.js +17 -7
  5. package/cjs/components/accordion/AccordionPropTypes.js +5 -2
  6. package/cjs/components/accordion/AccordionProvider.d.ts +17 -2
  7. package/cjs/components/autocomplete/Autocomplete.d.ts +23 -0
  8. package/cjs/components/autocomplete/Autocomplete.js +8 -0
  9. package/cjs/components/help-button/HelpButtonInstance.js +7 -7
  10. package/cjs/fragments/drawer-list/DrawerListProvider.d.ts +1 -0
  11. package/cjs/fragments/drawer-list/DrawerListProvider.js +2 -0
  12. package/cjs/shared/Eufemia.js +1 -1
  13. package/components/accordion/Accordion.d.ts +17 -4
  14. package/components/accordion/AccordionHeader.d.ts +11 -4
  15. package/components/accordion/AccordionHeader.js +17 -7
  16. package/components/accordion/AccordionPropTypes.js +5 -2
  17. package/components/accordion/AccordionProvider.d.ts +17 -2
  18. package/components/autocomplete/Autocomplete.d.ts +23 -0
  19. package/components/autocomplete/Autocomplete.js +8 -0
  20. package/components/help-button/HelpButtonInstance.js +7 -7
  21. package/es/components/accordion/Accordion.d.ts +17 -4
  22. package/es/components/accordion/AccordionHeader.d.ts +11 -4
  23. package/es/components/accordion/AccordionHeader.js +18 -8
  24. package/es/components/accordion/AccordionPropTypes.js +5 -2
  25. package/es/components/accordion/AccordionProvider.d.ts +17 -2
  26. package/es/components/autocomplete/Autocomplete.d.ts +23 -0
  27. package/es/components/autocomplete/Autocomplete.js +8 -0
  28. package/es/components/help-button/HelpButtonInstance.js +7 -7
  29. package/es/fragments/drawer-list/DrawerListProvider.d.ts +1 -0
  30. package/es/fragments/drawer-list/DrawerListProvider.js +2 -0
  31. package/es/shared/Eufemia.js +1 -1
  32. package/esm/dnb-ui-basis.min.mjs +1 -1
  33. package/esm/dnb-ui-components.min.mjs +1 -1
  34. package/esm/dnb-ui-elements.min.mjs +1 -1
  35. package/esm/dnb-ui-extensions.min.mjs +1 -1
  36. package/esm/dnb-ui-lib.min.mjs +2 -2
  37. package/esm/dnb-ui-web-components.min.mjs +2 -2
  38. package/fragments/drawer-list/DrawerListProvider.d.ts +1 -0
  39. package/fragments/drawer-list/DrawerListProvider.js +2 -0
  40. package/package.json +1 -1
  41. package/shared/Eufemia.js +1 -1
  42. package/umd/dnb-ui-basis.min.js +1 -1
  43. package/umd/dnb-ui-components.min.js +1 -1
  44. package/umd/dnb-ui-elements.min.js +1 -1
  45. package/umd/dnb-ui-extensions.min.js +1 -1
  46. package/umd/dnb-ui-lib.min.js +2 -2
  47. package/umd/dnb-ui-web-components.min.js +2 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
3
3
  All notable changes to @dnb/eufemia will be documented in this file. See
4
4
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [9.26.0](https://github.com/dnbexperience/eufemia/compare/v9.25.0...v9.26.0) (2022-04-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **Autocomplete:** Missing properties in PropTypes ([#1383](https://github.com/dnbexperience/eufemia/issues/1383)) ([1256009](https://github.com/dnbexperience/eufemia/commit/125600991434f15b3c5d85b8c9ad28e1c2bfcc00))
12
+ * **HelpButton:** ensure Drawer/Dialog/Modal trigger button gets a label ([4b52c98](https://github.com/dnbexperience/eufemia/commit/4b52c988904433ae3819b12709985ea0602462fa))
13
+
14
+
15
+ ### Features
16
+
17
+ * add "plain" variant to Accordion ([#1398](https://github.com/dnbexperience/eufemia/issues/1398)) ([105d9ae](https://github.com/dnbexperience/eufemia/commit/105d9aed9e803aa0a3bd5d44686ccde4d64effb8))
18
+ * make Accordion support a separate icon for the expanded state ([58ac1d3](https://github.com/dnbexperience/eufemia/commit/58ac1d385fcd497313067422123173766a0d739a))
19
+
6
20
  # [9.25.0](https://github.com/dnbexperience/eufemia/compare/v9.24.0...v9.25.0) (2022-04-05)
7
21
 
8
22
 
@@ -11,12 +11,24 @@ export type AccordionPreventRerenderConditional = string | boolean;
11
11
  export type AccordionRememberState = string | boolean;
12
12
  export type AccordionFlushRememberedState = string | boolean;
13
13
  export type AccordionSingleContainer = string | boolean;
14
- export type AccordionVariant = 'default' | 'outlined' | 'filled';
14
+ export type AccordionVariant = 'plain' | 'default' | 'outlined' | 'filled';
15
15
  export type AccordionAllowCloseAll = string | boolean;
16
16
  export type AccordionDisabled = string | boolean;
17
17
  export type AccordionSkeleton = string | boolean;
18
18
  export type AccordionHeading = boolean | React.ReactNode;
19
19
  export type AccordionHeadingLevel = string | number;
20
+ export type AccordionIcon =
21
+ | React.ReactNode
22
+ | ((...args: any[]) => any)
23
+ | {
24
+ closed?: React.ReactNode | ((...args: any[]) => any);
25
+
26
+ /**
27
+ * If set to `true` the accordion will be expanded as its initial state.
28
+ */
29
+ expanded?: React.ReactNode | ((...args: any[]) => any);
30
+ };
31
+ export type AccordionClosed = React.ReactNode | ((...args: any[]) => any);
20
32
  export type AccordionIconPosition = 'left' | 'right';
21
33
  export type AccordionAttributes = string | Object;
22
34
  export type AccordionSpace =
@@ -104,7 +116,7 @@ export interface AccordionProps extends React.HTMLProps<HTMLElement> {
104
116
  single_container?: AccordionSingleContainer;
105
117
 
106
118
  /**
107
- * Defines the used styling. As of now, only `outlined` is available. It defaults to `outlined`.
119
+ * Defines the used styling. As of now, only `outlined` is available. Use `plain` for no styles. It defaults to `outlined`.
108
120
  */
109
121
  variant?: AccordionVariant;
110
122
 
@@ -146,9 +158,10 @@ export interface AccordionProps extends React.HTMLProps<HTMLElement> {
146
158
  heading_level?: AccordionHeadingLevel;
147
159
 
148
160
  /**
149
- * Will replace the `chevron` icon. The icon will still rotate (by CSS).
161
+ * Will replace the `chevron` icon. The icon will still rotate (by CSS). You can use an object to use two different icons, one for the closed state and one for the expanded state `{ closed, expanded }`.
150
162
  */
151
- icon?: React.ReactNode;
163
+ icon?: AccordionIcon;
164
+ closed?: AccordionClosed;
152
165
 
153
166
  /**
154
167
  * Will set the placement of the icon. Defaults to `left`.
@@ -81,9 +81,12 @@ export interface AccordionHeaderContainerProps {
81
81
  }
82
82
  declare const AccordionHeaderContainer: React.FC<AccordionHeaderContainerProps>;
83
83
  export type AccordionHeaderIconIcon =
84
- | string
85
84
  | React.ReactNode
86
- | ((...args: any[]) => any);
85
+ | ((...args: any[]) => any)
86
+ | {
87
+ closed?: React.ReactNode | ((...args: any[]) => any);
88
+ expanded?: React.ReactNode | ((...args: any[]) => any);
89
+ };
87
90
 
88
91
  /**
89
92
  * NB: Do not change the docs (comments) in here. The docs are updated during build time by "generateTypes.js" and "fetchPropertiesFromDocs.js".
@@ -91,6 +94,7 @@ export type AccordionHeaderIconIcon =
91
94
  export interface AccordionHeaderIconProps {
92
95
  icon?: AccordionHeaderIconIcon;
93
96
  size?: string;
97
+ expanded?: boolean;
94
98
  }
95
99
  declare const AccordionHeaderIcon: React.FC<AccordionHeaderIconProps>;
96
100
  export type AccordionHeaderTitle =
@@ -116,9 +120,12 @@ export type AccordionHeaderHeading =
116
120
  | ((...args: any[]) => any);
117
121
  export type AccordionHeaderHeadingLevel = string | number;
118
122
  export type AccordionHeaderIcon =
119
- | string
120
123
  | React.ReactNode
121
- | ((...args: any[]) => any);
124
+ | ((...args: any[]) => any)
125
+ | {
126
+ closed?: React.ReactNode | ((...args: any[]) => any);
127
+ expanded?: React.ReactNode | ((...args: any[]) => any);
128
+ };
122
129
  export type AccordionHeaderIconPosition = 'left' | 'right';
123
130
  export type AccordionHeaderDisabled = string | boolean;
124
131
  export type AccordionHeaderSkeleton = string | boolean;
@@ -66,7 +66,7 @@ var _SkeletonHelper = require("../skeleton/SkeletonHelper");
66
66
  var _excluded = ["children"],
67
67
  _excluded2 = ["children"],
68
68
  _excluded3 = ["children"],
69
- _excluded4 = ["icon"],
69
+ _excluded4 = ["icon", "expanded"],
70
70
  _excluded5 = ["children", "className", "left_component", "expanded", "title", "description", "icon", "icon_size", "disabled"];
71
71
 
72
72
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -153,23 +153,29 @@ AccordionHeaderContainer.defaultProps = {
153
153
 
154
154
  function AccordionHeaderIcon(_ref4) {
155
155
  var icon = _ref4.icon,
156
+ expanded = _ref4.expanded,
156
157
  rest = _objectWithoutProperties(_ref4, _excluded4);
157
158
 
158
159
  return _react.default.createElement("span", {
159
160
  className: "dnb-accordion__header__icon"
160
161
  }, _react.default.createElement(_IconPrimary.default, _extends({}, rest, {
161
- icon: icon || 'chevron-down',
162
+ icon: typeof (icon === null || icon === void 0 ? void 0 : icon.expanded) !== 'undefined' ? icon[expanded ? 'expanded' : 'closed'] : icon || 'chevron-down',
162
163
  "aria-hidden": true
163
164
  })));
164
165
  }
165
166
 
166
167
  process.env.NODE_ENV !== "production" ? AccordionHeaderIcon.propTypes = {
167
- icon: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node, _propTypes.default.func]),
168
- size: _propTypes.default.string
168
+ icon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func, _propTypes.default.shape({
169
+ closed: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
170
+ expanded: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func])
171
+ })]),
172
+ size: _propTypes.default.string,
173
+ expanded: _propTypes.default.bool
169
174
  } : void 0;
170
175
  AccordionHeaderIcon.defaultProps = {
171
176
  icon: null,
172
- size: 'medium'
177
+ size: 'medium',
178
+ expanded: null
173
179
  };
174
180
 
175
181
  var AccordionHeader = function (_React$PureComponent) {
@@ -279,7 +285,8 @@ var AccordionHeader = function (_React$PureComponent) {
279
285
  var defaultParts = [_react.default.createElement(AccordionHeaderIcon, {
280
286
  key: "icon",
281
287
  icon: icon,
282
- size: icon_size
288
+ size: icon_size,
289
+ expanded: this.context.expanded
283
290
  }), _react.default.createElement(AccordionHeaderContainer, {
284
291
  key: "container"
285
292
  }, left_component), _react.default.createElement(AccordionHeaderTitle, {
@@ -431,7 +438,10 @@ process.env.NODE_ENV !== "production" ? AccordionHeader.propTypes = _objectSprea
431
438
  element: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node, _propTypes.default.func]),
432
439
  heading: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string, _propTypes.default.node, _propTypes.default.func]),
433
440
  heading_level: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
434
- icon: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node, _propTypes.default.func]),
441
+ icon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func, _propTypes.default.shape({
442
+ closed: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
443
+ expanded: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func])
444
+ })]),
435
445
  icon_position: _propTypes.default.oneOf(['left', 'right']),
436
446
  icon_size: _propTypes.default.string,
437
447
  disabled: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
@@ -42,7 +42,7 @@ var accordionPropTypes = _objectSpread(_objectSpread({
42
42
  remember_state: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
43
43
  flush_remembered_state: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
44
44
  single_container: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
45
- variant: _propTypes.default.oneOf(['default', 'outlined', 'filled']),
45
+ variant: _propTypes.default.oneOf(['plain', 'default', 'outlined', 'filled']),
46
46
  left_component: _propTypes.default.node,
47
47
  allow_close_all: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
48
48
  disabled: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
@@ -52,7 +52,10 @@ var accordionPropTypes = _objectSpread(_objectSpread({
52
52
  element: _propTypes.default.node,
53
53
  heading: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.node]),
54
54
  heading_level: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
55
- icon: _propTypes.default.node,
55
+ icon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func, _propTypes.default.shape({
56
+ closed: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
57
+ expanded: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func])
58
+ })]),
56
59
  icon_position: _propTypes.default.oneOf(['left', 'right']),
57
60
  icon_size: _propTypes.default.string,
58
61
  attributes: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object]),
@@ -8,12 +8,26 @@ export type AccordionGroupPreventRerenderConditional = string | boolean;
8
8
  export type AccordionGroupRememberState = string | boolean;
9
9
  export type AccordionGroupFlushRememberedState = string | boolean;
10
10
  export type AccordionGroupSingleContainer = string | boolean;
11
- export type AccordionGroupVariant = 'default' | 'outlined' | 'filled';
11
+ export type AccordionGroupVariant =
12
+ | 'plain'
13
+ | 'default'
14
+ | 'outlined'
15
+ | 'filled';
12
16
  export type AccordionGroupAllowCloseAll = string | boolean;
13
17
  export type AccordionGroupDisabled = string | boolean;
14
18
  export type AccordionGroupSkeleton = string | boolean;
15
19
  export type AccordionGroupHeading = boolean | React.ReactNode;
16
20
  export type AccordionGroupHeadingLevel = string | number;
21
+ export type AccordionGroupIcon =
22
+ | React.ReactNode
23
+ | ((...args: any[]) => any)
24
+ | {
25
+ closed?: React.ReactNode | ((...args: any[]) => any);
26
+ expanded?: React.ReactNode | ((...args: any[]) => any);
27
+ };
28
+ export type AccordionGroupClosed =
29
+ | React.ReactNode
30
+ | ((...args: any[]) => any);
17
31
  export type AccordionGroupIconPosition = 'left' | 'right';
18
32
  export type AccordionGroupAttributes = string | Object;
19
33
  export type AccordionGroupSpace =
@@ -55,7 +69,8 @@ export interface AccordionGroupProps extends React.HTMLProps<HTMLElement> {
55
69
  element?: React.ReactNode;
56
70
  heading?: AccordionGroupHeading;
57
71
  heading_level?: AccordionGroupHeadingLevel;
58
- icon?: React.ReactNode;
72
+ icon?: AccordionGroupIcon;
73
+ closed?: AccordionGroupClosed;
59
74
  icon_position?: AccordionGroupIconPosition;
60
75
  icon_size?: string;
61
76
  attributes?: AccordionGroupAttributes;
@@ -129,6 +129,9 @@ export type AutocompleteOpened = string | boolean;
129
129
  export type AutocompleteDisabled = string | boolean;
130
130
  export type AutocompleteStretch = string | boolean;
131
131
  export type AutocompleteSkeleton = string | boolean;
132
+ export type AutocompletePageOffset = string | number;
133
+ export type AutocompleteObserverElement = string | React.ReactNode;
134
+ export type AutocompleteMinHeight = string | number;
132
135
  export type AutocompleteChildren =
133
136
  | string
134
137
  | ((...args: any[]) => any)
@@ -509,6 +512,26 @@ export interface AutocompleteProps extends React.HTMLProps<HTMLElement> {
509
512
  * Define a custom class for the internal drawer-list. This makes it possible more easily customize the drawer-list style with styled-components and the `css` style method. Defaults to `null`.
510
513
  */
511
514
  drawer_class?: string;
515
+
516
+ /**
517
+ * Defines if the available scrollable height. If scrolling not should change the height of the drawer-list, then set it to `0` (useful if the DrawerList is used in fixed positions on contrast to a scrollable page content). Defaults to `window.pageYOffset`.
518
+ */
519
+ page_offset?: AutocompletePageOffset;
520
+
521
+ /**
522
+ * Set a HTML element, either as a selector or a DOM element. Can be used to send in an element which will be used to make the <em>direction calculation</em> on.
523
+ */
524
+ observer_element?: AutocompleteObserverElement;
525
+
526
+ /**
527
+ * Defines if the minimum height (in `rem`) of the options list. Defaults to `10rem`.
528
+ */
529
+ min_height?: AutocompleteMinHeight;
530
+
531
+ /**
532
+ * If set to true, the HTML body will get locked from scrolling. Defaults to `false`.
533
+ */
534
+ enable_body_lock?: boolean;
512
535
  class?: string;
513
536
  className?: string;
514
537
 
@@ -263,6 +263,10 @@ _defineProperty(Autocomplete, "defaultProps", {
263
263
  skeleton: null,
264
264
  portal_class: null,
265
265
  drawer_class: null,
266
+ page_offset: null,
267
+ observer_element: null,
268
+ min_height: null,
269
+ enable_body_lock: false,
266
270
  class: null,
267
271
  className: null,
268
272
  children: null,
@@ -344,6 +348,10 @@ process.env.NODE_ENV !== "production" ? Autocomplete.propTypes = _objectSpread(_
344
348
  skeleton: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
345
349
  portal_class: _propTypes.default.string,
346
350
  drawer_class: _propTypes.default.string,
351
+ page_offset: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
352
+ observer_element: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
353
+ min_height: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
354
+ enable_body_lock: _propTypes.default.bool,
347
355
  class: _propTypes.default.string,
348
356
  className: _propTypes.default.string,
349
357
  children: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func, _propTypes.default.node, _propTypes.default.object, _propTypes.default.array]),
@@ -138,16 +138,16 @@ var HelpButtonInstance = function (_React$PureComponent) {
138
138
  if (!params['aria-roledescription']) {
139
139
  params['aria-roledescription'] = this.context.getTranslation(this.props).HelpButton.aria_role;
140
140
  }
141
+ }
141
142
 
142
- if (!params.text && !params['aria-label']) {
143
- var ariaLabel = (0, _componentHelper.convertJsxToString)(props.title || props.children);
144
-
145
- if (!ariaLabel) {
146
- ariaLabel = this.context.getTranslation(this.props).HelpButton.title;
147
- }
143
+ if (!params.text && !params['aria-label']) {
144
+ var ariaLabel = (0, _componentHelper.convertJsxToString)(props.title || props.children);
148
145
 
149
- params['aria-label'] = ariaLabel;
146
+ if (!ariaLabel) {
147
+ ariaLabel = this.context.getTranslation(this.props).HelpButton.title;
150
148
  }
149
+
150
+ params['aria-label'] = ariaLabel;
151
151
  }
152
152
 
153
153
  if (icon === 'information' && !size) {
@@ -137,6 +137,7 @@ export interface DrawerListProviderProps
137
137
  on_resize?: (...args: any[]) => any;
138
138
  on_select?: (...args: any[]) => any;
139
139
  on_state_update?: (...args: any[]) => any;
140
+ enable_body_lock?: boolean;
140
141
  use_drawer_on_mobile?: DrawerListProviderUseDrawerOnMobile;
141
142
  page_offset?: DrawerListProviderPageOffset;
142
143
  observer_element?: DrawerListProviderObserverElement;
@@ -1245,6 +1245,7 @@ exports.default = DrawerListProvider;
1245
1245
  _defineProperty(DrawerListProvider, "contextType", _Context.default);
1246
1246
 
1247
1247
  _defineProperty(DrawerListProvider, "defaultProps", _objectSpread(_objectSpread({}, _DrawerListHelpers.drawerListDefaultProps), {}, {
1248
+ enable_body_lock: false,
1248
1249
  use_drawer_on_mobile: null,
1249
1250
  page_offset: null,
1250
1251
  observer_element: null,
@@ -1254,6 +1255,7 @@ _defineProperty(DrawerListProvider, "defaultProps", _objectSpread(_objectSpread(
1254
1255
  _defineProperty(DrawerListProvider, "blurDelay", 201);
1255
1256
 
1256
1257
  process.env.NODE_ENV !== "production" ? DrawerListProvider.propTypes = _objectSpread(_objectSpread({}, _DrawerListHelpers.drawerListPropTypes), {}, {
1258
+ enable_body_lock: _propTypes.default.bool,
1257
1259
  use_drawer_on_mobile: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
1258
1260
  page_offset: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
1259
1261
  observer_element: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
@@ -21,7 +21,7 @@ function init() {
21
21
  _createClass(Eufemia, [{
22
22
  key: "version",
23
23
  get: function get() {
24
- return '9.25.0';
24
+ return '9.26.0';
25
25
  }
26
26
  }]);
27
27
 
@@ -11,12 +11,24 @@ export type AccordionPreventRerenderConditional = string | boolean;
11
11
  export type AccordionRememberState = string | boolean;
12
12
  export type AccordionFlushRememberedState = string | boolean;
13
13
  export type AccordionSingleContainer = string | boolean;
14
- export type AccordionVariant = 'default' | 'outlined' | 'filled';
14
+ export type AccordionVariant = 'plain' | 'default' | 'outlined' | 'filled';
15
15
  export type AccordionAllowCloseAll = string | boolean;
16
16
  export type AccordionDisabled = string | boolean;
17
17
  export type AccordionSkeleton = string | boolean;
18
18
  export type AccordionHeading = boolean | React.ReactNode;
19
19
  export type AccordionHeadingLevel = string | number;
20
+ export type AccordionIcon =
21
+ | React.ReactNode
22
+ | ((...args: any[]) => any)
23
+ | {
24
+ closed?: React.ReactNode | ((...args: any[]) => any);
25
+
26
+ /**
27
+ * If set to `true` the accordion will be expanded as its initial state.
28
+ */
29
+ expanded?: React.ReactNode | ((...args: any[]) => any);
30
+ };
31
+ export type AccordionClosed = React.ReactNode | ((...args: any[]) => any);
20
32
  export type AccordionIconPosition = 'left' | 'right';
21
33
  export type AccordionAttributes = string | Object;
22
34
  export type AccordionSpace =
@@ -104,7 +116,7 @@ export interface AccordionProps extends React.HTMLProps<HTMLElement> {
104
116
  single_container?: AccordionSingleContainer;
105
117
 
106
118
  /**
107
- * Defines the used styling. As of now, only `outlined` is available. It defaults to `outlined`.
119
+ * Defines the used styling. As of now, only `outlined` is available. Use `plain` for no styles. It defaults to `outlined`.
108
120
  */
109
121
  variant?: AccordionVariant;
110
122
 
@@ -146,9 +158,10 @@ export interface AccordionProps extends React.HTMLProps<HTMLElement> {
146
158
  heading_level?: AccordionHeadingLevel;
147
159
 
148
160
  /**
149
- * Will replace the `chevron` icon. The icon will still rotate (by CSS).
161
+ * Will replace the `chevron` icon. The icon will still rotate (by CSS). You can use an object to use two different icons, one for the closed state and one for the expanded state `{ closed, expanded }`.
150
162
  */
151
- icon?: React.ReactNode;
163
+ icon?: AccordionIcon;
164
+ closed?: AccordionClosed;
152
165
 
153
166
  /**
154
167
  * Will set the placement of the icon. Defaults to `left`.
@@ -81,9 +81,12 @@ export interface AccordionHeaderContainerProps {
81
81
  }
82
82
  declare const AccordionHeaderContainer: React.FC<AccordionHeaderContainerProps>;
83
83
  export type AccordionHeaderIconIcon =
84
- | string
85
84
  | React.ReactNode
86
- | ((...args: any[]) => any);
85
+ | ((...args: any[]) => any)
86
+ | {
87
+ closed?: React.ReactNode | ((...args: any[]) => any);
88
+ expanded?: React.ReactNode | ((...args: any[]) => any);
89
+ };
87
90
 
88
91
  /**
89
92
  * NB: Do not change the docs (comments) in here. The docs are updated during build time by "generateTypes.js" and "fetchPropertiesFromDocs.js".
@@ -91,6 +94,7 @@ export type AccordionHeaderIconIcon =
91
94
  export interface AccordionHeaderIconProps {
92
95
  icon?: AccordionHeaderIconIcon;
93
96
  size?: string;
97
+ expanded?: boolean;
94
98
  }
95
99
  declare const AccordionHeaderIcon: React.FC<AccordionHeaderIconProps>;
96
100
  export type AccordionHeaderTitle =
@@ -116,9 +120,12 @@ export type AccordionHeaderHeading =
116
120
  | ((...args: any[]) => any);
117
121
  export type AccordionHeaderHeadingLevel = string | number;
118
122
  export type AccordionHeaderIcon =
119
- | string
120
123
  | React.ReactNode
121
- | ((...args: any[]) => any);
124
+ | ((...args: any[]) => any)
125
+ | {
126
+ closed?: React.ReactNode | ((...args: any[]) => any);
127
+ expanded?: React.ReactNode | ((...args: any[]) => any);
128
+ };
122
129
  export type AccordionHeaderIconPosition = 'left' | 'right';
123
130
  export type AccordionHeaderDisabled = string | boolean;
124
131
  export type AccordionHeaderSkeleton = string | boolean;
@@ -14,7 +14,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
14
14
  var _excluded = ["children"],
15
15
  _excluded2 = ["children"],
16
16
  _excluded3 = ["children"],
17
- _excluded4 = ["icon"],
17
+ _excluded4 = ["icon", "expanded"],
18
18
  _excluded5 = ["children", "className", "left_component", "expanded", "title", "description", "icon", "icon_size", "disabled"];
19
19
  import "core-js/modules/es.symbol.js";
20
20
  import "core-js/modules/es.symbol.description.js";
@@ -93,23 +93,29 @@ AccordionHeaderContainer.defaultProps = {
93
93
 
94
94
  function AccordionHeaderIcon(_ref4) {
95
95
  var icon = _ref4.icon,
96
+ expanded = _ref4.expanded,
96
97
  rest = _objectWithoutProperties(_ref4, _excluded4);
97
98
 
98
99
  return React.createElement("span", {
99
100
  className: "dnb-accordion__header__icon"
100
101
  }, React.createElement(IconPrimary, _extends({}, rest, {
101
- icon: icon || 'chevron-down',
102
+ icon: typeof (icon === null || icon === void 0 ? void 0 : icon.expanded) !== 'undefined' ? icon[expanded ? 'expanded' : 'closed'] : icon || 'chevron-down',
102
103
  "aria-hidden": true
103
104
  })));
104
105
  }
105
106
 
106
107
  process.env.NODE_ENV !== "production" ? AccordionHeaderIcon.propTypes = {
107
- icon: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.func]),
108
- size: PropTypes.string
108
+ icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func, PropTypes.shape({
109
+ closed: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
110
+ expanded: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
111
+ })]),
112
+ size: PropTypes.string,
113
+ expanded: PropTypes.bool
109
114
  } : void 0;
110
115
  AccordionHeaderIcon.defaultProps = {
111
116
  icon: null,
112
- size: 'medium'
117
+ size: 'medium',
118
+ expanded: null
113
119
  };
114
120
 
115
121
  var AccordionHeader = function (_React$PureComponent) {
@@ -219,7 +225,8 @@ var AccordionHeader = function (_React$PureComponent) {
219
225
  var defaultParts = [React.createElement(AccordionHeaderIcon, {
220
226
  key: "icon",
221
227
  icon: icon,
222
- size: icon_size
228
+ size: icon_size,
229
+ expanded: this.context.expanded
223
230
  }), React.createElement(AccordionHeaderContainer, {
224
231
  key: "container"
225
232
  }, left_component), React.createElement(AccordionHeaderTitle, {
@@ -368,7 +375,10 @@ process.env.NODE_ENV !== "production" ? AccordionHeader.propTypes = _objectSprea
368
375
  element: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.func]),
369
376
  heading: PropTypes.oneOfType([PropTypes.bool, PropTypes.string, PropTypes.node, PropTypes.func]),
370
377
  heading_level: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
371
- icon: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.func]),
378
+ icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func, PropTypes.shape({
379
+ closed: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
380
+ expanded: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
381
+ })]),
372
382
  icon_position: PropTypes.oneOf(['left', 'right']),
373
383
  icon_size: PropTypes.string,
374
384
  disabled: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
@@ -24,7 +24,7 @@ export var accordionPropTypes = _objectSpread(_objectSpread({
24
24
  remember_state: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
25
25
  flush_remembered_state: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
26
26
  single_container: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
27
- variant: PropTypes.oneOf(['default', 'outlined', 'filled']),
27
+ variant: PropTypes.oneOf(['plain', 'default', 'outlined', 'filled']),
28
28
  left_component: PropTypes.node,
29
29
  allow_close_all: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
30
30
  disabled: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
@@ -34,7 +34,10 @@ export var accordionPropTypes = _objectSpread(_objectSpread({
34
34
  element: PropTypes.node,
35
35
  heading: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
36
36
  heading_level: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
37
- icon: PropTypes.node,
37
+ icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func, PropTypes.shape({
38
+ closed: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
39
+ expanded: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
40
+ })]),
38
41
  icon_position: PropTypes.oneOf(['left', 'right']),
39
42
  icon_size: PropTypes.string,
40
43
  attributes: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
@@ -8,12 +8,26 @@ export type AccordionGroupPreventRerenderConditional = string | boolean;
8
8
  export type AccordionGroupRememberState = string | boolean;
9
9
  export type AccordionGroupFlushRememberedState = string | boolean;
10
10
  export type AccordionGroupSingleContainer = string | boolean;
11
- export type AccordionGroupVariant = 'default' | 'outlined' | 'filled';
11
+ export type AccordionGroupVariant =
12
+ | 'plain'
13
+ | 'default'
14
+ | 'outlined'
15
+ | 'filled';
12
16
  export type AccordionGroupAllowCloseAll = string | boolean;
13
17
  export type AccordionGroupDisabled = string | boolean;
14
18
  export type AccordionGroupSkeleton = string | boolean;
15
19
  export type AccordionGroupHeading = boolean | React.ReactNode;
16
20
  export type AccordionGroupHeadingLevel = string | number;
21
+ export type AccordionGroupIcon =
22
+ | React.ReactNode
23
+ | ((...args: any[]) => any)
24
+ | {
25
+ closed?: React.ReactNode | ((...args: any[]) => any);
26
+ expanded?: React.ReactNode | ((...args: any[]) => any);
27
+ };
28
+ export type AccordionGroupClosed =
29
+ | React.ReactNode
30
+ | ((...args: any[]) => any);
17
31
  export type AccordionGroupIconPosition = 'left' | 'right';
18
32
  export type AccordionGroupAttributes = string | Object;
19
33
  export type AccordionGroupSpace =
@@ -55,7 +69,8 @@ export interface AccordionGroupProps extends React.HTMLProps<HTMLElement> {
55
69
  element?: React.ReactNode;
56
70
  heading?: AccordionGroupHeading;
57
71
  heading_level?: AccordionGroupHeadingLevel;
58
- icon?: React.ReactNode;
72
+ icon?: AccordionGroupIcon;
73
+ closed?: AccordionGroupClosed;
59
74
  icon_position?: AccordionGroupIconPosition;
60
75
  icon_size?: string;
61
76
  attributes?: AccordionGroupAttributes;
@@ -129,6 +129,9 @@ export type AutocompleteOpened = string | boolean;
129
129
  export type AutocompleteDisabled = string | boolean;
130
130
  export type AutocompleteStretch = string | boolean;
131
131
  export type AutocompleteSkeleton = string | boolean;
132
+ export type AutocompletePageOffset = string | number;
133
+ export type AutocompleteObserverElement = string | React.ReactNode;
134
+ export type AutocompleteMinHeight = string | number;
132
135
  export type AutocompleteChildren =
133
136
  | string
134
137
  | ((...args: any[]) => any)
@@ -509,6 +512,26 @@ export interface AutocompleteProps extends React.HTMLProps<HTMLElement> {
509
512
  * Define a custom class for the internal drawer-list. This makes it possible more easily customize the drawer-list style with styled-components and the `css` style method. Defaults to `null`.
510
513
  */
511
514
  drawer_class?: string;
515
+
516
+ /**
517
+ * Defines if the available scrollable height. If scrolling not should change the height of the drawer-list, then set it to `0` (useful if the DrawerList is used in fixed positions on contrast to a scrollable page content). Defaults to `window.pageYOffset`.
518
+ */
519
+ page_offset?: AutocompletePageOffset;
520
+
521
+ /**
522
+ * Set a HTML element, either as a selector or a DOM element. Can be used to send in an element which will be used to make the <em>direction calculation</em> on.
523
+ */
524
+ observer_element?: AutocompleteObserverElement;
525
+
526
+ /**
527
+ * Defines if the minimum height (in `rem`) of the options list. Defaults to `10rem`.
528
+ */
529
+ min_height?: AutocompleteMinHeight;
530
+
531
+ /**
532
+ * If set to true, the HTML body will get locked from scrolling. Defaults to `false`.
533
+ */
534
+ enable_body_lock?: boolean;
512
535
  class?: string;
513
536
  className?: string;
514
537
 
@@ -179,6 +179,10 @@ _defineProperty(Autocomplete, "defaultProps", {
179
179
  skeleton: null,
180
180
  portal_class: null,
181
181
  drawer_class: null,
182
+ page_offset: null,
183
+ observer_element: null,
184
+ min_height: null,
185
+ enable_body_lock: false,
182
186
  class: null,
183
187
  className: null,
184
188
  children: null,
@@ -261,6 +265,10 @@ process.env.NODE_ENV !== "production" ? Autocomplete.propTypes = _objectSpread(_
261
265
  skeleton: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
262
266
  portal_class: PropTypes.string,
263
267
  drawer_class: PropTypes.string,
268
+ page_offset: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
269
+ observer_element: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
270
+ min_height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
271
+ enable_body_lock: PropTypes.bool,
264
272
  class: PropTypes.string,
265
273
  className: PropTypes.string,
266
274
  children: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.node, PropTypes.object, PropTypes.array]),
@@ -74,16 +74,16 @@ var HelpButtonInstance = function (_React$PureComponent) {
74
74
  if (!params['aria-roledescription']) {
75
75
  params['aria-roledescription'] = this.context.getTranslation(this.props).HelpButton.aria_role;
76
76
  }
77
+ }
77
78
 
78
- if (!params.text && !params['aria-label']) {
79
- var ariaLabel = convertJsxToString(props.title || props.children);
80
-
81
- if (!ariaLabel) {
82
- ariaLabel = this.context.getTranslation(this.props).HelpButton.title;
83
- }
79
+ if (!params.text && !params['aria-label']) {
80
+ var ariaLabel = convertJsxToString(props.title || props.children);
84
81
 
85
- params['aria-label'] = ariaLabel;
82
+ if (!ariaLabel) {
83
+ ariaLabel = this.context.getTranslation(this.props).HelpButton.title;
86
84
  }
85
+
86
+ params['aria-label'] = ariaLabel;
87
87
  }
88
88
 
89
89
  if (icon === 'information' && !size) {