@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.
- package/CHANGELOG.md +20 -198
- package/cjs/components/avatar/Avatar.js +14 -12
- package/cjs/components/avatar/AvatarGroup.js +11 -11
- package/cjs/components/avatar/style/_avatar.scss +2 -0
- package/cjs/components/avatar/style/dnb-avatar.css +4 -1
- package/cjs/components/avatar/style/dnb-avatar.min.css +1 -1
- package/cjs/components/breadcrumb/Breadcrumb.js +27 -52
- package/cjs/components/breadcrumb/BreadcrumbItem.js +15 -29
- package/cjs/components/button/Button.d.ts +11 -7
- package/cjs/components/icon-primary/IconPrimary.d.ts +2 -1
- package/cjs/components/info-card/InfoCard.js +22 -22
- package/cjs/components/pagination/Pagination.d.ts +6 -6
- package/cjs/components/pagination/Pagination.js +2 -2
- package/cjs/components/skeleton/Skeleton.d.ts +1 -1
- package/cjs/components/skeleton/SkeletonHelper.d.ts +2 -1
- package/cjs/components/step-indicator/StepIndicatorTriggerButton.js +4 -4
- package/cjs/components/tag/Tag.js +17 -29
- package/cjs/components/tag/TagGroup.js +10 -24
- package/cjs/components/timeline/Timeline.js +24 -64
- package/cjs/components/timeline/TimelineItem.js +16 -29
- package/cjs/elements/Div.d.ts +1 -1
- package/cjs/elements/P.d.ts +2 -1
- package/cjs/shared/AnimateHeight.js +19 -13
- package/cjs/shared/helpers.js +16 -4
- package/cjs/shared/hooks/index.js +13 -0
- package/cjs/shared/hooks/usePropsWithContext.js +92 -0
- package/cjs/style/dnb-ui-components.css +4 -1
- package/cjs/style/dnb-ui-components.min.css +1 -1
- package/cjs/style/dnb-ui-elements.css +1 -3
- package/cjs/style/dnb-ui-elements.min.css +1 -1
- package/cjs/style/dnb-ui-tags.css +2 -6
- package/cjs/style/dnb-ui-tags.min.css +2 -2
- package/cjs/style/elements/code.scss +1 -3
- package/cjs/style/stylis.d.ts +38 -0
- package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.css +1 -3
- package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/cjs/style/themes/theme-ui/dnb-theme-ui.css +1 -3
- package/cjs/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- package/components/avatar/Avatar.js +14 -13
- package/components/avatar/Avatar.tsx +8 -9
- package/components/avatar/AvatarGroup.js +20 -20
- package/components/avatar/AvatarGroup.tsx +4 -8
- package/components/avatar/style/_avatar.scss +2 -0
- package/components/avatar/style/dnb-avatar.css +4 -1
- package/components/avatar/style/dnb-avatar.min.css +1 -1
- package/components/breadcrumb/Breadcrumb.js +22 -35
- package/components/breadcrumb/Breadcrumb.tsx +10 -10
- package/components/breadcrumb/BreadcrumbItem.js +14 -25
- package/components/breadcrumb/BreadcrumbItem.tsx +8 -11
- package/components/button/Button.d.ts +11 -7
- package/components/icon-primary/IconPrimary.d.ts +2 -1
- package/components/info-card/InfoCard.js +22 -22
- package/components/info-card/InfoCard.tsx +13 -12
- package/components/modal/Modal.tsx +1 -1
- package/components/modal/ModalContent.tsx +6 -2
- package/components/modal/components/ModalHeader.tsx +2 -2
- package/components/modal/types.ts +2 -2
- package/components/pagination/Pagination.d.ts +6 -6
- package/components/pagination/Pagination.js +2 -2
- package/components/skeleton/SkeletonHelper.d.ts +2 -1
- package/components/step-indicator/StepIndicatorTriggerButton.js +4 -4
- package/components/tag/Tag.js +17 -27
- package/components/tag/Tag.tsx +15 -13
- package/components/tag/TagGroup.js +9 -22
- package/components/tag/TagGroup.tsx +6 -10
- package/components/timeline/Timeline.js +23 -27
- package/components/timeline/Timeline.tsx +24 -20
- package/components/timeline/TimelineItem.js +15 -25
- package/components/timeline/TimelineItem.tsx +8 -10
- package/elements/P.d.ts +2 -1
- package/es/components/avatar/Avatar.js +7 -6
- package/es/components/avatar/Avatar.tsx +8 -9
- package/es/components/avatar/AvatarGroup.js +6 -6
- package/es/components/avatar/AvatarGroup.tsx +4 -8
- package/es/components/avatar/style/_avatar.scss +2 -0
- package/es/components/avatar/style/dnb-avatar.css +4 -1
- package/es/components/avatar/style/dnb-avatar.min.css +1 -1
- package/es/components/breadcrumb/Breadcrumb.js +8 -14
- package/es/components/breadcrumb/Breadcrumb.tsx +10 -10
- package/es/components/breadcrumb/BreadcrumbItem.js +9 -13
- package/es/components/breadcrumb/BreadcrumbItem.tsx +8 -11
- package/es/components/button/Button.d.ts +11 -7
- package/es/components/icon-primary/IconPrimary.d.ts +2 -1
- package/es/components/info-card/InfoCard.js +8 -8
- package/es/components/info-card/InfoCard.tsx +13 -12
- package/es/components/modal/Modal.tsx +1 -1
- package/es/components/modal/ModalContent.tsx +6 -2
- package/es/components/modal/components/ModalHeader.tsx +2 -2
- package/es/components/modal/types.ts +2 -2
- package/es/components/pagination/Pagination.d.ts +6 -6
- package/es/components/pagination/Pagination.js +2 -2
- package/es/components/skeleton/Skeleton.d.ts +1 -1
- package/es/components/skeleton/SkeletonHelper.d.ts +2 -1
- package/es/components/step-indicator/StepIndicatorTriggerButton.js +4 -4
- package/es/components/tag/Tag.js +11 -14
- package/es/components/tag/Tag.tsx +15 -13
- package/es/components/tag/TagGroup.js +7 -13
- package/es/components/tag/TagGroup.tsx +6 -10
- package/es/components/timeline/Timeline.js +21 -17
- package/es/components/timeline/Timeline.tsx +24 -20
- package/es/components/timeline/TimelineItem.js +9 -12
- package/es/components/timeline/TimelineItem.tsx +8 -10
- package/es/elements/Div.d.ts +1 -1
- package/es/elements/P.d.ts +2 -1
- package/es/shared/AnimateHeight.js +15 -13
- package/es/shared/helpers.js +9 -2
- package/es/shared/hooks/index.js +1 -0
- package/es/shared/hooks/index.ts +1 -0
- package/es/shared/hooks/usePropsWithContext.js +26 -0
- package/es/shared/hooks/usePropsWithContext.ts +45 -0
- package/es/shared/interfaces.tsx +0 -2
- package/es/style/dnb-ui-components.css +4 -1
- package/es/style/dnb-ui-components.min.css +1 -1
- package/es/style/dnb-ui-elements.css +1 -3
- package/es/style/dnb-ui-elements.min.css +1 -1
- package/es/style/dnb-ui-tags.css +2 -6
- package/es/style/dnb-ui-tags.min.css +2 -2
- package/es/style/elements/code.scss +1 -3
- package/es/style/stylis.d.ts +38 -0
- package/es/style/themes/theme-open-banking/dnb-theme-open-banking.css +1 -3
- package/es/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/es/style/themes/theme-ui/dnb-theme-ui.css +1 -3
- package/es/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- package/esm/components/avatar/Avatar.js +14 -13
- package/esm/components/avatar/Avatar.tsx +8 -9
- package/esm/components/avatar/AvatarGroup.js +20 -20
- package/esm/components/avatar/AvatarGroup.tsx +4 -8
- package/esm/components/avatar/style/_avatar.scss +2 -0
- package/esm/components/avatar/style/dnb-avatar.css +4 -1
- package/esm/components/avatar/style/dnb-avatar.min.css +1 -1
- package/esm/components/breadcrumb/Breadcrumb.js +22 -35
- package/esm/components/breadcrumb/Breadcrumb.tsx +10 -10
- package/esm/components/breadcrumb/BreadcrumbItem.js +14 -25
- package/esm/components/breadcrumb/BreadcrumbItem.tsx +8 -11
- package/esm/components/button/Button.d.ts +11 -7
- package/esm/components/icon-primary/IconPrimary.d.ts +2 -1
- package/esm/components/info-card/InfoCard.js +22 -22
- package/esm/components/info-card/InfoCard.tsx +13 -12
- package/esm/components/modal/Modal.tsx +1 -1
- package/esm/components/modal/ModalContent.tsx +6 -2
- package/esm/components/modal/components/ModalHeader.tsx +2 -2
- package/esm/components/modal/types.ts +2 -2
- package/esm/components/pagination/Pagination.d.ts +6 -6
- package/esm/components/pagination/Pagination.js +2 -2
- package/esm/components/skeleton/SkeletonHelper.d.ts +2 -1
- package/esm/components/step-indicator/StepIndicatorTriggerButton.js +4 -4
- package/esm/components/tag/Tag.js +17 -27
- package/esm/components/tag/Tag.tsx +15 -13
- package/esm/components/tag/TagGroup.js +9 -22
- package/esm/components/tag/TagGroup.tsx +6 -10
- package/esm/components/timeline/Timeline.js +23 -27
- package/esm/components/timeline/Timeline.tsx +24 -20
- package/esm/components/timeline/TimelineItem.js +15 -25
- package/esm/components/timeline/TimelineItem.tsx +8 -10
- package/esm/dnb-ui-components.min.mjs +3 -3
- package/esm/dnb-ui-lib.min.mjs +3 -3
- package/esm/dnb-ui-web-components.min.mjs +4 -4
- package/esm/elements/P.d.ts +2 -1
- package/esm/shared/AnimateHeight.js +19 -13
- package/esm/shared/helpers.js +15 -4
- package/esm/shared/hooks/index.js +1 -0
- package/esm/shared/hooks/index.ts +1 -0
- package/esm/shared/hooks/usePropsWithContext.js +47 -0
- package/esm/shared/hooks/usePropsWithContext.ts +45 -0
- package/esm/shared/interfaces.tsx +0 -2
- package/esm/style/dnb-ui-components.css +4 -1
- package/esm/style/dnb-ui-components.min.css +1 -1
- package/esm/style/dnb-ui-elements.css +1 -3
- package/esm/style/dnb-ui-elements.min.css +1 -1
- package/esm/style/dnb-ui-tags.css +2 -6
- package/esm/style/dnb-ui-tags.min.css +2 -2
- package/esm/style/elements/code.scss +1 -3
- package/esm/style/stylis.d.ts +38 -0
- package/esm/style/themes/theme-open-banking/dnb-theme-open-banking.css +1 -3
- package/esm/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/esm/style/themes/theme-ui/dnb-theme-ui.css +1 -3
- package/esm/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- package/package.json +1 -1
- package/shared/AnimateHeight.js +19 -13
- package/shared/helpers.js +15 -4
- package/shared/hooks/index.js +1 -0
- package/shared/hooks/index.ts +1 -0
- package/shared/hooks/usePropsWithContext.js +47 -0
- package/shared/hooks/usePropsWithContext.ts +45 -0
- package/shared/interfaces.tsx +0 -2
- package/style/dnb-ui-components.css +4 -1
- package/style/dnb-ui-components.min.css +1 -1
- package/style/dnb-ui-elements.css +1 -3
- package/style/dnb-ui-elements.min.css +1 -1
- package/style/dnb-ui-tags.css +2 -6
- package/style/dnb-ui-tags.min.css +2 -2
- package/style/elements/code.scss +1 -3
- package/style/stylis.d.ts +38 -0
- package/style/themes/theme-open-banking/dnb-theme-open-banking.css +1 -3
- package/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/style/themes/theme-ui/dnb-theme-ui.css +1 -3
- package/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- package/umd/dnb-ui-components.min.js +3 -3
- package/umd/dnb-ui-lib.min.js +4 -4
- package/umd/dnb-ui-web-components.min.js +3 -3
|
@@ -1,23 +1,10 @@
|
|
|
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 _span;
|
|
13
5
|
|
|
14
6
|
var _excluded = ["icon", "iconAlt", "name", "date", "infoMessage", "state", "skeleton"];
|
|
15
7
|
import "core-js/modules/es.function.name.js";
|
|
16
|
-
|
|
17
|
-
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; }
|
|
18
|
-
|
|
19
|
-
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; }
|
|
20
|
-
|
|
21
8
|
import React from 'react';
|
|
22
9
|
import classnames from 'classnames';
|
|
23
10
|
import FormStatus from '../form-status/FormStatus';
|
|
@@ -27,7 +14,7 @@ import checkIcon from '../../icons/check';
|
|
|
27
14
|
import calendarIcon from '../../icons/calendar';
|
|
28
15
|
import pinIcon from '../../icons/pin';
|
|
29
16
|
import Context from '../../shared/Context';
|
|
30
|
-
import {
|
|
17
|
+
import { usePropsWithContext } from '../../shared/hooks';
|
|
31
18
|
var defaultProps = {
|
|
32
19
|
icon: null,
|
|
33
20
|
iconAlt: null,
|
|
@@ -37,7 +24,8 @@ var defaultProps = {
|
|
|
37
24
|
state: null,
|
|
38
25
|
skeleton: false
|
|
39
26
|
};
|
|
40
|
-
|
|
27
|
+
|
|
28
|
+
var TimelineItem = function TimelineItem(localProps) {
|
|
41
29
|
var _span2, _span3, _span4, _FormStatus;
|
|
42
30
|
|
|
43
31
|
var context = React.useContext(Context);
|
|
@@ -46,15 +34,15 @@ export default function TimelineItem(localProps) {
|
|
|
46
34
|
alt_label_current = _context$translation$.alt_label_current,
|
|
47
35
|
alt_label_upcoming = _context$translation$.alt_label_upcoming;
|
|
48
36
|
|
|
49
|
-
var
|
|
50
|
-
icon =
|
|
51
|
-
iconAlt =
|
|
52
|
-
name =
|
|
53
|
-
date =
|
|
54
|
-
infoMessage =
|
|
55
|
-
state =
|
|
56
|
-
skeleton =
|
|
57
|
-
props = _objectWithoutProperties(
|
|
37
|
+
var _usePropsWithContext = usePropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.TimelineItem),
|
|
38
|
+
icon = _usePropsWithContext.icon,
|
|
39
|
+
iconAlt = _usePropsWithContext.iconAlt,
|
|
40
|
+
name = _usePropsWithContext.name,
|
|
41
|
+
date = _usePropsWithContext.date,
|
|
42
|
+
infoMessage = _usePropsWithContext.infoMessage,
|
|
43
|
+
state = _usePropsWithContext.state,
|
|
44
|
+
skeleton = _usePropsWithContext.skeleton,
|
|
45
|
+
props = _objectWithoutProperties(_usePropsWithContext, _excluded);
|
|
58
46
|
|
|
59
47
|
var stateIsCompleted = state === 'completed';
|
|
60
48
|
var stateIsCurrent = state === 'current';
|
|
@@ -109,4 +97,6 @@ export default function TimelineItem(localProps) {
|
|
|
109
97
|
"data-testid": "timeline-item",
|
|
110
98
|
"aria-current": stateIsCurrent ? 'step' : undefined
|
|
111
99
|
}, props), React.createElement(TimelineItemLabel, null), React.createElement(TimelineItemContent, null));
|
|
112
|
-
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default TimelineItem;
|
|
@@ -13,8 +13,8 @@ import pinIcon from '../../icons/pin'
|
|
|
13
13
|
|
|
14
14
|
// Shared
|
|
15
15
|
import Context from '../../shared/Context'
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { SkeletonShow } from '../skeleton/Skeleton'
|
|
17
|
+
import { usePropsWithContext } from '../../shared/hooks'
|
|
18
18
|
|
|
19
19
|
export interface TimelineItemProps {
|
|
20
20
|
/**
|
|
@@ -32,7 +32,7 @@ export interface TimelineItemProps {
|
|
|
32
32
|
/**
|
|
33
33
|
* Text displaying the name of the timeline item.
|
|
34
34
|
*/
|
|
35
|
-
name: React.ReactNode
|
|
35
|
+
name: React.ReactNode & string
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Text displaying the date of the timeline item.
|
|
@@ -54,7 +54,7 @@ export interface TimelineItemProps {
|
|
|
54
54
|
* Skeleton should be applied when loading content
|
|
55
55
|
* Default: null
|
|
56
56
|
*/
|
|
57
|
-
skeleton?:
|
|
57
|
+
skeleton?: SkeletonShow
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const defaultProps = {
|
|
@@ -67,7 +67,7 @@ const defaultProps = {
|
|
|
67
67
|
skeleton: false,
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
const TimelineItem = (localProps: TimelineItemProps) => {
|
|
71
71
|
// Every component should have a context
|
|
72
72
|
const context = React.useContext(Context)
|
|
73
73
|
const {
|
|
@@ -90,11 +90,7 @@ export default function TimelineItem(localProps: TimelineItemProps) {
|
|
|
90
90
|
state,
|
|
91
91
|
skeleton,
|
|
92
92
|
...props
|
|
93
|
-
} =
|
|
94
|
-
{ ...defaultProps, ...localProps },
|
|
95
|
-
defaultProps,
|
|
96
|
-
context?.TimelineItem
|
|
97
|
-
)
|
|
93
|
+
} = usePropsWithContext(localProps, defaultProps, context?.TimelineItem)
|
|
98
94
|
|
|
99
95
|
const stateIsCompleted = state === 'completed'
|
|
100
96
|
const stateIsCurrent = state === 'current'
|
|
@@ -191,3 +187,5 @@ export default function TimelineItem(localProps: TimelineItemProps) {
|
|
|
191
187
|
</div>
|
|
192
188
|
)
|
|
193
189
|
}
|
|
190
|
+
|
|
191
|
+
export default TimelineItem
|
package/elements/P.d.ts
CHANGED
|
@@ -25,7 +25,8 @@ export type PSize =
|
|
|
25
25
|
/**
|
|
26
26
|
* NB: Do not change the docs (comments) in here. The docs are updated during build time by "generateTypes.js" and "fetchPropertiesFromDocs.js".
|
|
27
27
|
*/
|
|
28
|
-
export interface PProps
|
|
28
|
+
export interface PProps
|
|
29
|
+
extends Omit<React.HTMLProps<HTMLElement>, 'size'> {
|
|
29
30
|
space?: PSpace;
|
|
30
31
|
top?: PTop;
|
|
31
32
|
right?: PRight;
|
|
@@ -13,7 +13,8 @@ import { createSpacingClasses } from '../space/SpacingHelper';
|
|
|
13
13
|
import { createSkeletonClass } from '../skeleton/SkeletonHelper';
|
|
14
14
|
import Img from '../../elements/Img';
|
|
15
15
|
import Context from '../../shared/Context';
|
|
16
|
-
import {
|
|
16
|
+
import { warn } from '../../shared/component-helper';
|
|
17
|
+
import { usePropsWithContext } from '../../shared/hooks';
|
|
17
18
|
import AvatarGroup, { AvatarGroupContext } from './AvatarGroup';
|
|
18
19
|
export const defaultProps = {
|
|
19
20
|
alt: null,
|
|
@@ -26,11 +27,11 @@ export const defaultProps = {
|
|
|
26
27
|
children: null
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
const Avatar = localProps => {
|
|
30
31
|
const context = React.useContext(Context);
|
|
31
32
|
const avatarGroupContext = React.useContext(AvatarGroupContext);
|
|
32
33
|
|
|
33
|
-
const
|
|
34
|
+
const _usePropsWithContext = usePropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.Avatar, avatarGroupContext),
|
|
34
35
|
{
|
|
35
36
|
alt,
|
|
36
37
|
className,
|
|
@@ -40,8 +41,8 @@ function Avatar(localProps) {
|
|
|
40
41
|
variant,
|
|
41
42
|
src,
|
|
42
43
|
imgProps
|
|
43
|
-
} =
|
|
44
|
-
props = _objectWithoutProperties(
|
|
44
|
+
} = _usePropsWithContext,
|
|
45
|
+
props = _objectWithoutProperties(_usePropsWithContext, _excluded);
|
|
45
46
|
|
|
46
47
|
let children = null;
|
|
47
48
|
const skeletonClasses = createSkeletonClass('shape', skeleton, context);
|
|
@@ -76,7 +77,7 @@ function Avatar(localProps) {
|
|
|
76
77
|
"data-testid": "avatar-label",
|
|
77
78
|
className: "dnb-sr-only"
|
|
78
79
|
}, childrenProp), children);
|
|
79
|
-
}
|
|
80
|
+
};
|
|
80
81
|
|
|
81
82
|
Avatar.Group = AvatarGroup;
|
|
82
83
|
export { AvatarGroup };
|
|
@@ -10,11 +10,10 @@ import Img, { ImgProps } from '../../elements/Img'
|
|
|
10
10
|
|
|
11
11
|
// Shared
|
|
12
12
|
import Context from '../../shared/Context'
|
|
13
|
-
import { ISpacingProps
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from '../../shared/component-helper'
|
|
13
|
+
import { ISpacingProps } from '../../shared/interfaces'
|
|
14
|
+
import { SkeletonShow } from '../skeleton/Skeleton'
|
|
15
|
+
import { warn } from '../../shared/component-helper'
|
|
16
|
+
import { usePropsWithContext } from '../../shared/hooks'
|
|
18
17
|
|
|
19
18
|
// Internal
|
|
20
19
|
import AvatarGroup, { AvatarGroupContext } from './AvatarGroup'
|
|
@@ -39,7 +38,7 @@ export interface AvatarProps {
|
|
|
39
38
|
* Skeleton should be applied when loading content
|
|
40
39
|
* Default: null
|
|
41
40
|
*/
|
|
42
|
-
skeleton?:
|
|
41
|
+
skeleton?: SkeletonShow
|
|
43
42
|
|
|
44
43
|
/**
|
|
45
44
|
* The content of the component. Can be used instead of prop "data".
|
|
@@ -83,7 +82,7 @@ export const defaultProps = {
|
|
|
83
82
|
children: null,
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
|
|
85
|
+
const Avatar = (localProps: AvatarProps & ISpacingProps) => {
|
|
87
86
|
// Every component should have a context
|
|
88
87
|
const context = React.useContext(Context)
|
|
89
88
|
const avatarGroupContext = React.useContext(AvatarGroupContext)
|
|
@@ -99,8 +98,8 @@ function Avatar(localProps: AvatarProps & ISpacingProps) {
|
|
|
99
98
|
src,
|
|
100
99
|
imgProps,
|
|
101
100
|
...props
|
|
102
|
-
} =
|
|
103
|
-
|
|
101
|
+
} = usePropsWithContext(
|
|
102
|
+
localProps,
|
|
104
103
|
defaultProps,
|
|
105
104
|
context?.Avatar,
|
|
106
105
|
avatarGroupContext
|
|
@@ -11,7 +11,7 @@ import React from 'react';
|
|
|
11
11
|
import classnames from 'classnames';
|
|
12
12
|
import { createSpacingClasses } from '../space/SpacingHelper';
|
|
13
13
|
import Context from '../../shared/Context';
|
|
14
|
-
import {
|
|
14
|
+
import { usePropsWithContext } from '../../shared/hooks';
|
|
15
15
|
export const defaultProps = {
|
|
16
16
|
label: null,
|
|
17
17
|
className: null,
|
|
@@ -22,10 +22,10 @@ export const defaultProps = {
|
|
|
22
22
|
};
|
|
23
23
|
export const AvatarGroupContext = React.createContext(null);
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const AvatarGroup = localProps => {
|
|
26
26
|
const context = React.useContext(Context);
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const _usePropsWithContext = usePropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.AvatarGroup),
|
|
29
29
|
{
|
|
30
30
|
label,
|
|
31
31
|
className,
|
|
@@ -33,8 +33,8 @@ function AvatarGroup(localProps) {
|
|
|
33
33
|
size,
|
|
34
34
|
maxElements: maxElementsProp,
|
|
35
35
|
variant
|
|
36
|
-
} =
|
|
37
|
-
props = _objectWithoutProperties(
|
|
36
|
+
} = _usePropsWithContext,
|
|
37
|
+
props = _objectWithoutProperties(_usePropsWithContext, _excluded);
|
|
38
38
|
|
|
39
39
|
const maxElements = maxElementsProp && maxElementsProp > 0 ? maxElementsProp : 4;
|
|
40
40
|
let children = childrenProp;
|
|
@@ -73,7 +73,7 @@ function AvatarGroup(localProps) {
|
|
|
73
73
|
}, label), children, numOfHiddenAvatars ? React.createElement(ElementsHidden, {
|
|
74
74
|
size: size
|
|
75
75
|
}, "+", numOfHiddenAvatars) : null));
|
|
76
|
-
}
|
|
76
|
+
};
|
|
77
77
|
|
|
78
78
|
function ElementsHidden(props) {
|
|
79
79
|
const {
|
|
@@ -8,14 +8,14 @@ import { AvatarSizes, AvatarVariants } from './Avatar'
|
|
|
8
8
|
// Shared
|
|
9
9
|
import Context from '../../shared/Context'
|
|
10
10
|
import { ISpacingProps } from '../../shared/interfaces'
|
|
11
|
-
import {
|
|
11
|
+
import { usePropsWithContext } from '../../shared/hooks'
|
|
12
12
|
|
|
13
13
|
export interface AvatarGroupProps {
|
|
14
14
|
/**
|
|
15
15
|
* Label to describe the avatar group
|
|
16
16
|
* Default: null
|
|
17
17
|
*/
|
|
18
|
-
label:
|
|
18
|
+
label: React.ReactNode
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Custom className on the component root
|
|
@@ -59,7 +59,7 @@ export const defaultProps = {
|
|
|
59
59
|
|
|
60
60
|
export const AvatarGroupContext = React.createContext(null)
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
const AvatarGroup = (localProps: AvatarGroupProps & ISpacingProps) => {
|
|
63
63
|
// Every component should have a context
|
|
64
64
|
const context = React.useContext(Context)
|
|
65
65
|
// Extract additional props from global context
|
|
@@ -71,11 +71,7 @@ function AvatarGroup(localProps: AvatarGroupProps & ISpacingProps) {
|
|
|
71
71
|
maxElements: maxElementsProp,
|
|
72
72
|
variant,
|
|
73
73
|
...props
|
|
74
|
-
} =
|
|
75
|
-
{ ...defaultProps, ...localProps },
|
|
76
|
-
defaultProps,
|
|
77
|
-
context?.AvatarGroup
|
|
78
|
-
)
|
|
74
|
+
} = usePropsWithContext(localProps, defaultProps, context?.AvatarGroup)
|
|
79
75
|
|
|
80
76
|
const maxElements =
|
|
81
77
|
maxElementsProp && maxElementsProp > 0 ? maxElementsProp : 4
|
|
@@ -112,6 +112,7 @@
|
|
|
112
112
|
|
|
113
113
|
&:nth-of-type(2) {
|
|
114
114
|
margin-left: 0;
|
|
115
|
+
border-left: none;
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -119,6 +120,7 @@
|
|
|
119
120
|
display: inline-flex;
|
|
120
121
|
align-items: center;
|
|
121
122
|
justify-content: center;
|
|
123
|
+
flex-shrink: 0;
|
|
122
124
|
color: var(--color-black-55);
|
|
123
125
|
|
|
124
126
|
&--size-small {
|
|
@@ -185,7 +185,8 @@
|
|
|
185
185
|
.dnb-avatar__group .dnb-avatar--size-x-large {
|
|
186
186
|
margin-left: -1.5rem; }
|
|
187
187
|
.dnb-avatar__group .dnb-avatar:nth-of-type(2) {
|
|
188
|
-
margin-left: 0;
|
|
188
|
+
margin-left: 0;
|
|
189
|
+
border-left: none; }
|
|
189
190
|
.dnb-avatar__group--elements-left {
|
|
190
191
|
display: -webkit-inline-box;
|
|
191
192
|
display: -ms-inline-flexbox;
|
|
@@ -196,6 +197,8 @@
|
|
|
196
197
|
-webkit-box-pack: center;
|
|
197
198
|
-ms-flex-pack: center;
|
|
198
199
|
justify-content: center;
|
|
200
|
+
-ms-flex-negative: 0;
|
|
201
|
+
flex-shrink: 0;
|
|
199
202
|
color: #737373;
|
|
200
203
|
color: var(--color-black-55); }
|
|
201
204
|
.dnb-avatar__group--elements-left--size-small {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.dnb-avatar{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:rgba(0,0,0,0);-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;color:#333;color:var(--color-black-80,#333);font-family:DNB,sans-serif;font-family:var(--font-family-default);font-size:1rem;font-size:var(--font-size-small);font-style:normal;font-weight:400;font-weight:var(--font-weight-basis);line-height:1.5rem;line-height:var(--line-height-basis);margin:0;padding:0;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-break:break-word}.dnb-avatar *,.dnb-avatar :after,.dnb-avatar :before{background-repeat:no-repeat;-webkit-box-sizing:border-box;box-sizing:border-box}.dnb-avatar :after,.dnb-avatar :before{text-decoration:inherit;vertical-align:inherit}:root{--avatar-font-size--small:var(--font-size-x-small);--avatar-font-size--medium:var(--font-size-basis);--avatar-font-size--large:var(--font-size-x-large);--avatar-font-size--x-large:var(--font-size-x-large);--avatar-line-height--small:var(--line-height-x-small);--avatar-line-height--medium:var(--line-height-basis);--avatar-line-height--large:var(--line-height-large);--avatar-line-height--x-large:var(--line-height-large);--avatar-width--small:1.5rem;--avatar-height--small:1.5rem;--avatar-width--medium:2rem;--avatar-height--medium:2rem;--avatar-width--large:4rem;--avatar-height--large:4rem;--avatar-width--x-large:5rem;--avatar-height--x-large:5rem}.dnb-avatar{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;-ms-flex-negative:0;align-items:center;border-radius:50%;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;flex-shrink:0;font-weight:500;font-weight:var(--font-weight-medium);justify-content:center;line-height:1;overflow:hidden;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.dnb-avatar,.dnb-core-style .dnb-avatar{line-height:2.5rem;line-height:var(--button-height)}.dnb-avatar--size-small{font-size:.875rem;font-size:var(--avatar-font-size--small);height:1.5rem;height:var(--avatar-height--small);width:1.5rem;width:var(--avatar-width--small)}.dnb-avatar--size-small,.dnb-core-style .dnb-avatar--size-small{line-height:1.125rem;line-height:var(--avatar-line-height--small)}.dnb-avatar--size-medium{font-size:1.125rem;font-size:var(--avatar-font-size--medium);height:2rem;height:var(--avatar-height--medium);width:2rem;width:var(--avatar-width--medium)}.dnb-avatar--size-medium,.dnb-core-style .dnb-avatar--size-medium{line-height:1.5rem;line-height:var(--avatar-line-height--medium)}.dnb-avatar--size-large{font-size:2.125rem;font-size:var(--avatar-font-size--large);height:4rem;height:var(--avatar-height--large);width:4rem;width:var(--avatar-width--large)}.dnb-avatar--size-large,.dnb-core-style .dnb-avatar--size-large{line-height:2.5rem;line-height:var(--avatar-line-height--large)}.dnb-avatar--size-x-large{font-size:2.125rem;font-size:var(--avatar-font-size--x-large);height:5rem;height:var(--avatar-height--x-large);width:5rem;width:var(--avatar-width--x-large)}.dnb-avatar--size-x-large,.dnb-core-style .dnb-avatar--size-x-large{line-height:2.5rem;line-height:var(--avatar-line-height--x-large)}.dnb-avatar__group{-webkit-box-pack:flex;-ms-flex-pack:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:row;flex-direction:row;justify-content:flex}.dnb-avatar__group .dnb-avatar{border:.125rem solid #f8f8f8;border:.125rem solid var(--color-black-3);-webkit-box-sizing:content-box;box-sizing:content-box}.dnb-avatar__group .dnb-avatar--size-small{margin-left:-.5rem}.dnb-avatar__group .dnb-avatar--size-medium{margin-left:-.75rem}.dnb-avatar__group .dnb-avatar--size-large{margin-left:-1rem}.dnb-avatar__group .dnb-avatar--size-x-large{margin-left:-1.5rem}.dnb-avatar__group .dnb-avatar:nth-of-type(2){margin-left:0}.dnb-avatar__group--elements-left{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;color:#737373;color:var(--color-black-55);display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;justify-content:center}.dnb-avatar__group--elements-left--size-small{font-size:.875rem;font-size:var(--font-size-x-small);margin-left:.125rem}.dnb-avatar__group--elements-left--size-medium{font-size:1rem;font-size:var(--font-size-small);margin-left:.125rem}.dnb-avatar__group--elements-left--size-large,.dnb-avatar__group--elements-left--size-x-large{font-size:1.625rem;font-size:var(--font-size-large);margin-left:.25rem;margin-left:var(--spacing-xx-small)}
|
|
1
|
+
.dnb-avatar{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:rgba(0,0,0,0);-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;color:#333;color:var(--color-black-80,#333);font-family:DNB,sans-serif;font-family:var(--font-family-default);font-size:1rem;font-size:var(--font-size-small);font-style:normal;font-weight:400;font-weight:var(--font-weight-basis);line-height:1.5rem;line-height:var(--line-height-basis);margin:0;padding:0;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-break:break-word}.dnb-avatar *,.dnb-avatar :after,.dnb-avatar :before{background-repeat:no-repeat;-webkit-box-sizing:border-box;box-sizing:border-box}.dnb-avatar :after,.dnb-avatar :before{text-decoration:inherit;vertical-align:inherit}:root{--avatar-font-size--small:var(--font-size-x-small);--avatar-font-size--medium:var(--font-size-basis);--avatar-font-size--large:var(--font-size-x-large);--avatar-font-size--x-large:var(--font-size-x-large);--avatar-line-height--small:var(--line-height-x-small);--avatar-line-height--medium:var(--line-height-basis);--avatar-line-height--large:var(--line-height-large);--avatar-line-height--x-large:var(--line-height-large);--avatar-width--small:1.5rem;--avatar-height--small:1.5rem;--avatar-width--medium:2rem;--avatar-height--medium:2rem;--avatar-width--large:4rem;--avatar-height--large:4rem;--avatar-width--x-large:5rem;--avatar-height--x-large:5rem}.dnb-avatar{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;-ms-flex-negative:0;align-items:center;border-radius:50%;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;flex-shrink:0;font-weight:500;font-weight:var(--font-weight-medium);justify-content:center;line-height:1;overflow:hidden;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.dnb-avatar,.dnb-core-style .dnb-avatar{line-height:2.5rem;line-height:var(--button-height)}.dnb-avatar--size-small{font-size:.875rem;font-size:var(--avatar-font-size--small);height:1.5rem;height:var(--avatar-height--small);width:1.5rem;width:var(--avatar-width--small)}.dnb-avatar--size-small,.dnb-core-style .dnb-avatar--size-small{line-height:1.125rem;line-height:var(--avatar-line-height--small)}.dnb-avatar--size-medium{font-size:1.125rem;font-size:var(--avatar-font-size--medium);height:2rem;height:var(--avatar-height--medium);width:2rem;width:var(--avatar-width--medium)}.dnb-avatar--size-medium,.dnb-core-style .dnb-avatar--size-medium{line-height:1.5rem;line-height:var(--avatar-line-height--medium)}.dnb-avatar--size-large{font-size:2.125rem;font-size:var(--avatar-font-size--large);height:4rem;height:var(--avatar-height--large);width:4rem;width:var(--avatar-width--large)}.dnb-avatar--size-large,.dnb-core-style .dnb-avatar--size-large{line-height:2.5rem;line-height:var(--avatar-line-height--large)}.dnb-avatar--size-x-large{font-size:2.125rem;font-size:var(--avatar-font-size--x-large);height:5rem;height:var(--avatar-height--x-large);width:5rem;width:var(--avatar-width--x-large)}.dnb-avatar--size-x-large,.dnb-core-style .dnb-avatar--size-x-large{line-height:2.5rem;line-height:var(--avatar-line-height--x-large)}.dnb-avatar__group{-webkit-box-pack:flex;-ms-flex-pack:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:row;flex-direction:row;justify-content:flex}.dnb-avatar__group .dnb-avatar{border:.125rem solid #f8f8f8;border:.125rem solid var(--color-black-3);-webkit-box-sizing:content-box;box-sizing:content-box}.dnb-avatar__group .dnb-avatar--size-small{margin-left:-.5rem}.dnb-avatar__group .dnb-avatar--size-medium{margin-left:-.75rem}.dnb-avatar__group .dnb-avatar--size-large{margin-left:-1rem}.dnb-avatar__group .dnb-avatar--size-x-large{margin-left:-1.5rem}.dnb-avatar__group .dnb-avatar:nth-of-type(2){border-left:none;margin-left:0}.dnb-avatar__group--elements-left{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;-ms-flex-negative:0;align-items:center;color:#737373;color:var(--color-black-55);display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;flex-shrink:0;justify-content:center}.dnb-avatar__group--elements-left--size-small{font-size:.875rem;font-size:var(--font-size-x-small);margin-left:.125rem}.dnb-avatar__group--elements-left--size-medium{font-size:1rem;font-size:var(--font-size-small);margin-left:.125rem}.dnb-avatar__group--elements-left--size-large,.dnb-avatar__group--elements-left--size-x-large{font-size:1.625rem;font-size:var(--font-size-large);margin-left:.25rem;margin-left:var(--spacing-xx-small)}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
3
|
const _excluded = ["className", "skeleton", "children", "variant", "onClick", "navText", "goBackText", "homeText", "backToText", "styleType", "collapsedStyleType", "isCollapsed", "spacing", "data", "href"];
|
|
5
|
-
|
|
6
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
-
|
|
8
|
-
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; }
|
|
9
|
-
|
|
10
4
|
import React, { useEffect, useState } from 'react';
|
|
11
5
|
import classnames from 'classnames';
|
|
12
6
|
import { createSkeletonClass } from '../skeleton/SkeletonHelper';
|
|
@@ -15,9 +9,9 @@ import Section from '../section/Section';
|
|
|
15
9
|
import Button from '../button/Button';
|
|
16
10
|
import { useMediaQuery } from '../../shared';
|
|
17
11
|
import Context from '../../shared/Context';
|
|
18
|
-
import {
|
|
12
|
+
import { usePropsWithContext } from '../../shared/hooks';
|
|
19
13
|
import BreadcrumbItem from './BreadcrumbItem';
|
|
20
|
-
|
|
14
|
+
import { convertJsxToString } from '../../shared/component-helper';
|
|
21
15
|
export const defaultProps = {
|
|
22
16
|
className: null,
|
|
23
17
|
skeleton: false,
|
|
@@ -36,12 +30,12 @@ export const defaultProps = {
|
|
|
36
30
|
spacing: false
|
|
37
31
|
};
|
|
38
32
|
|
|
39
|
-
|
|
33
|
+
const Breadcrumb = localProps => {
|
|
40
34
|
var _context$translation;
|
|
41
35
|
|
|
42
36
|
const context = React.useContext(Context);
|
|
43
37
|
|
|
44
|
-
const
|
|
38
|
+
const _usePropsWithContext = usePropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : (_context$translation = context.translation) === null || _context$translation === void 0 ? void 0 : _context$translation.Breadcrumb, context === null || context === void 0 ? void 0 : context.Breadcrumb),
|
|
45
39
|
{
|
|
46
40
|
className,
|
|
47
41
|
skeleton,
|
|
@@ -58,8 +52,8 @@ function Breadcrumb(localProps) {
|
|
|
58
52
|
spacing,
|
|
59
53
|
data,
|
|
60
54
|
href
|
|
61
|
-
} =
|
|
62
|
-
props = _objectWithoutProperties(
|
|
55
|
+
} = _usePropsWithContext,
|
|
56
|
+
props = _objectWithoutProperties(_usePropsWithContext, _excluded);
|
|
63
57
|
|
|
64
58
|
const skeletonClasses = createSkeletonClass('font', skeleton, context);
|
|
65
59
|
const spacingClasses = createSpacingClasses(props);
|
|
@@ -92,7 +86,7 @@ function Breadcrumb(localProps) {
|
|
|
92
86
|
}, breadcrumbItem))), childrenItems);
|
|
93
87
|
|
|
94
88
|
return React.createElement("nav", _extends({
|
|
95
|
-
"aria-label": navText,
|
|
89
|
+
"aria-label": convertJsxToString(navText),
|
|
96
90
|
className: classnames('dnb-breadcrumb', skeletonClasses, spacingClasses, className, spacing && 'dnb-breadcrumb--spacing'),
|
|
97
91
|
"data-testid": "breadcrumb-nav"
|
|
98
92
|
}, props), React.createElement(Section, {
|
|
@@ -119,7 +113,7 @@ function Breadcrumb(localProps) {
|
|
|
119
113
|
className: "dnb-breadcrumb__collapse",
|
|
120
114
|
"data-testid": "breadcrumb-collapse"
|
|
121
115
|
}, React.createElement(MultipleCrumbs, null)));
|
|
122
|
-
}
|
|
116
|
+
};
|
|
123
117
|
|
|
124
118
|
Breadcrumb.Item = BreadcrumbItem;
|
|
125
119
|
export { BreadcrumbItem };
|
|
@@ -10,13 +10,13 @@ import Button from '../button/Button'
|
|
|
10
10
|
// Shared
|
|
11
11
|
import { useMediaQuery } from '../../shared'
|
|
12
12
|
import Context from '../../shared/Context'
|
|
13
|
-
import { ISpacingProps
|
|
14
|
-
import {
|
|
13
|
+
import { ISpacingProps } from '../../shared/interfaces'
|
|
14
|
+
import { SkeletonShow } from '../skeleton/Skeleton'
|
|
15
|
+
import { usePropsWithContext } from '../../shared/hooks'
|
|
15
16
|
|
|
16
17
|
// Internal
|
|
17
18
|
import BreadcrumbItem, { BreadcrumbItemProps } from './BreadcrumbItem'
|
|
18
|
-
|
|
19
|
-
export * from './BreadcrumbItem'
|
|
19
|
+
import { convertJsxToString } from '../../shared/component-helper'
|
|
20
20
|
|
|
21
21
|
export interface BreadcrumbProps {
|
|
22
22
|
/**
|
|
@@ -29,7 +29,7 @@ export interface BreadcrumbProps {
|
|
|
29
29
|
* Skeleton should be applied when loading content
|
|
30
30
|
* Default: null
|
|
31
31
|
*/
|
|
32
|
-
skeleton?:
|
|
32
|
+
skeleton?: SkeletonShow
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Pass in a list of your pages as objects of breadcrumbitem to render them as breadcrumbitems.
|
|
@@ -89,7 +89,7 @@ export interface BreadcrumbProps {
|
|
|
89
89
|
* If variant='collapse', you can override isCollapsed for the collapsed content by updating this value.
|
|
90
90
|
* Default: null
|
|
91
91
|
*/
|
|
92
|
-
isCollapsed?: boolean
|
|
92
|
+
isCollapsed?: boolean
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* Use one of the Section component style types (style_type)
|
|
@@ -128,7 +128,7 @@ export const defaultProps = {
|
|
|
128
128
|
spacing: false,
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
const Breadcrumb = (localProps: BreadcrumbProps & ISpacingProps) => {
|
|
132
132
|
// Every component should have a context
|
|
133
133
|
const context = React.useContext(Context)
|
|
134
134
|
// Extract additional props from global context
|
|
@@ -149,8 +149,8 @@ function Breadcrumb(localProps: BreadcrumbProps & ISpacingProps) {
|
|
|
149
149
|
data,
|
|
150
150
|
href,
|
|
151
151
|
...props
|
|
152
|
-
} =
|
|
153
|
-
|
|
152
|
+
} = usePropsWithContext(
|
|
153
|
+
localProps,
|
|
154
154
|
defaultProps,
|
|
155
155
|
context?.translation?.Breadcrumb,
|
|
156
156
|
context?.Breadcrumb
|
|
@@ -197,7 +197,7 @@ function Breadcrumb(localProps: BreadcrumbProps & ISpacingProps) {
|
|
|
197
197
|
|
|
198
198
|
return (
|
|
199
199
|
<nav
|
|
200
|
-
aria-label={navText}
|
|
200
|
+
aria-label={convertJsxToString(navText)}
|
|
201
201
|
className={classnames(
|
|
202
202
|
'dnb-breadcrumb',
|
|
203
203
|
skeletonClasses,
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
3
|
const _excluded = ["text", "href", "icon", "onClick", "variant", "skeleton"];
|
|
5
|
-
|
|
6
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
-
|
|
8
|
-
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; }
|
|
9
|
-
|
|
10
4
|
import React from 'react';
|
|
11
5
|
import Button from '../button/Button';
|
|
12
6
|
import IconPrimary from '../icon-primary/IconPrimary';
|
|
13
7
|
import P from '../../elements/P';
|
|
14
8
|
import homeIcon from '../../icons/home';
|
|
15
9
|
import Context from '../../shared/Context';
|
|
16
|
-
import {
|
|
10
|
+
import { usePropsWithContext } from '../../shared/hooks';
|
|
17
11
|
const defaultProps = {
|
|
18
12
|
text: null,
|
|
19
13
|
href: null,
|
|
@@ -22,7 +16,8 @@ const defaultProps = {
|
|
|
22
16
|
variant: null,
|
|
23
17
|
skeleton: null
|
|
24
18
|
};
|
|
25
|
-
|
|
19
|
+
|
|
20
|
+
const BreadcrumbItem = localProps => {
|
|
26
21
|
const context = React.useContext(Context);
|
|
27
22
|
const {
|
|
28
23
|
translation: {
|
|
@@ -32,7 +27,7 @@ export default function BreadcrumbItem(localProps) {
|
|
|
32
27
|
}
|
|
33
28
|
} = context;
|
|
34
29
|
|
|
35
|
-
const
|
|
30
|
+
const _usePropsWithContext = usePropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.BreadcrumbItem),
|
|
36
31
|
{
|
|
37
32
|
text,
|
|
38
33
|
href,
|
|
@@ -40,8 +35,8 @@ export default function BreadcrumbItem(localProps) {
|
|
|
40
35
|
onClick,
|
|
41
36
|
variant,
|
|
42
37
|
skeleton
|
|
43
|
-
} =
|
|
44
|
-
props = _objectWithoutProperties(
|
|
38
|
+
} = _usePropsWithContext,
|
|
39
|
+
props = _objectWithoutProperties(_usePropsWithContext, _excluded);
|
|
45
40
|
|
|
46
41
|
const currentIcon = icon || variant === 'home' && homeIcon || 'chevron_left';
|
|
47
42
|
const currentText = text || variant === 'home' && homeText || '';
|
|
@@ -55,7 +50,6 @@ export default function BreadcrumbItem(localProps) {
|
|
|
55
50
|
href: href,
|
|
56
51
|
icon: currentIcon,
|
|
57
52
|
icon_position: "left",
|
|
58
|
-
icon_: currentIcon,
|
|
59
53
|
on_click: onClick,
|
|
60
54
|
text: currentText,
|
|
61
55
|
skeleton: skeleton
|
|
@@ -68,4 +62,6 @@ export default function BreadcrumbItem(localProps) {
|
|
|
68
62
|
left: "0",
|
|
69
63
|
"data-testid": "breadcrumb-item-text"
|
|
70
64
|
}, currentText)));
|
|
71
|
-
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default BreadcrumbItem;
|
|
@@ -12,8 +12,8 @@ import homeIcon from '../../icons/home'
|
|
|
12
12
|
|
|
13
13
|
// Shared
|
|
14
14
|
import Context from '../../shared/Context'
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { SkeletonShow } from '../skeleton/Skeleton'
|
|
16
|
+
import { usePropsWithContext } from '../../shared/hooks'
|
|
17
17
|
|
|
18
18
|
export interface BreadcrumbItemProps {
|
|
19
19
|
/**
|
|
@@ -50,7 +50,7 @@ export interface BreadcrumbItemProps {
|
|
|
50
50
|
* Skeleton should be applied when loading content
|
|
51
51
|
* Default: null
|
|
52
52
|
*/
|
|
53
|
-
skeleton?:
|
|
53
|
+
skeleton?: SkeletonShow
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const defaultProps = {
|
|
@@ -62,7 +62,7 @@ const defaultProps = {
|
|
|
62
62
|
skeleton: null,
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
const BreadcrumbItem = (localProps: BreadcrumbItemProps) => {
|
|
66
66
|
// Every component should have a context
|
|
67
67
|
const context = React.useContext(Context)
|
|
68
68
|
const {
|
|
@@ -73,13 +73,9 @@ export default function BreadcrumbItem(localProps: BreadcrumbItemProps) {
|
|
|
73
73
|
|
|
74
74
|
// Extract additional props from global context
|
|
75
75
|
const { text, href, icon, onClick, variant, skeleton, ...props } =
|
|
76
|
-
|
|
77
|
-
{ ...defaultProps, ...localProps },
|
|
78
|
-
defaultProps,
|
|
79
|
-
context?.BreadcrumbItem
|
|
80
|
-
)
|
|
76
|
+
usePropsWithContext(localProps, defaultProps, context?.BreadcrumbItem)
|
|
81
77
|
|
|
82
|
-
const currentIcon =
|
|
78
|
+
const currentIcon: IconPrimaryIcon =
|
|
83
79
|
icon || (variant === 'home' && homeIcon) || 'chevron_left'
|
|
84
80
|
const currentText = text || (variant === 'home' && homeText) || ''
|
|
85
81
|
const isInteractive = (href || onClick) && variant !== 'current'
|
|
@@ -96,7 +92,6 @@ export default function BreadcrumbItem(localProps: BreadcrumbItemProps) {
|
|
|
96
92
|
href={href}
|
|
97
93
|
icon={currentIcon}
|
|
98
94
|
icon_position="left"
|
|
99
|
-
icon_={currentIcon} // what does this do?
|
|
100
95
|
on_click={onClick}
|
|
101
96
|
text={currentText}
|
|
102
97
|
skeleton={skeleton}
|
|
@@ -116,3 +111,5 @@ export default function BreadcrumbItem(localProps: BreadcrumbItemProps) {
|
|
|
116
111
|
</li>
|
|
117
112
|
)
|
|
118
113
|
}
|
|
114
|
+
|
|
115
|
+
export default BreadcrumbItem
|