@bbl-digital/snorre 4.0.10 → 4.0.11
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +118 -38
- package/esm/core/Alert/index.js +1 -1
- package/esm/core/AppLoader/index.js +1 -1
- package/esm/core/Banner/Banner.stories.js +17 -0
- package/esm/core/Banner/index.js +1 -1
- package/esm/core/Box/Box.stories.js +32 -31
- package/esm/core/Box/index.js +10 -3
- package/esm/core/Button/index.js +3 -2
- package/esm/core/Card/Card.stories.js +8 -7
- package/esm/core/Card/index.js +1 -0
- package/esm/core/Checkbox/Checkbox.stories.js +22 -22
- package/esm/core/CollapseList/CollapseList.stories.js +36 -28
- package/esm/core/CollapseList/Item.js +36 -3
- package/esm/core/CollapseList/index.js +3 -1
- package/esm/core/CommentsTimeline/CommentLine/index.js +13 -4
- package/esm/core/CommentsTimeline/CommentsTimeline.stories.js +67 -62
- package/esm/core/CommentsTimeline/index.js +2 -0
- package/esm/core/CustomText/CustomText.stories.js +12 -12
- package/esm/core/CustomText/index.js +4 -1
- package/esm/core/Dropdown/Dropdown.stories.js +16 -15
- package/esm/core/Dropdown/index.js +18 -0
- package/esm/core/Header/index.js +2 -1
- package/esm/core/Header/styles.js +7 -7
- package/esm/core/Modal/index.js +1 -1
- package/esm/core/Modal/styles.js +9 -9
- package/esm/core/Text/index.js +3 -1
- package/esm/core/private/ButtonOrLink.js +5 -4
- package/lib/core/Alert/index.d.ts +1 -2
- package/lib/core/Alert/index.d.ts.map +1 -1
- package/lib/core/Alert/index.js +1 -1
- package/lib/core/AppLoader/index.d.ts +1 -2
- package/lib/core/AppLoader/index.d.ts.map +1 -1
- package/lib/core/AppLoader/index.js +1 -1
- package/lib/core/Autocomplete/styles.d.ts +1 -39
- package/lib/core/Autocomplete/styles.d.ts.map +1 -1
- package/lib/core/Banner/Banner.stories.d.ts +1 -0
- package/lib/core/Banner/Banner.stories.d.ts.map +1 -1
- package/lib/core/Banner/Banner.stories.js +17 -0
- package/lib/core/Banner/index.d.ts +1 -2
- package/lib/core/Banner/index.d.ts.map +1 -1
- package/lib/core/Banner/index.js +1 -1
- package/lib/core/Box/Box.stories.d.ts +14 -39
- package/lib/core/Box/Box.stories.d.ts.map +1 -1
- package/lib/core/Box/Box.stories.js +32 -31
- package/lib/core/Box/index.d.ts +1 -1
- package/lib/core/Box/index.d.ts.map +1 -1
- package/lib/core/Box/index.js +10 -3
- package/lib/core/Box/styles.d.ts +1 -39
- package/lib/core/Box/styles.d.ts.map +1 -1
- package/lib/core/Button/index.d.ts +3 -4
- package/lib/core/Button/index.d.ts.map +1 -1
- package/lib/core/Button/index.js +3 -2
- package/lib/core/Card/Card.stories.d.ts +10 -24
- package/lib/core/Card/Card.stories.d.ts.map +1 -1
- package/lib/core/Card/Card.stories.js +8 -7
- package/lib/core/Card/index.d.ts +1 -1
- package/lib/core/Card/index.d.ts.map +1 -1
- package/lib/core/Card/index.js +1 -0
- package/lib/core/Checkbox/Checkbox.stories.d.ts +10 -23
- package/lib/core/Checkbox/Checkbox.stories.d.ts.map +1 -1
- package/lib/core/Checkbox/Checkbox.stories.js +22 -22
- package/lib/core/CollapseList/CollapseList.stories.d.ts +7 -11
- package/lib/core/CollapseList/CollapseList.stories.d.ts.map +1 -1
- package/lib/core/CollapseList/CollapseList.stories.js +36 -28
- package/lib/core/CollapseList/Item.d.ts +4 -4
- package/lib/core/CollapseList/Item.d.ts.map +1 -1
- package/lib/core/CollapseList/Item.js +36 -3
- package/lib/core/CollapseList/index.d.ts +1 -1
- package/lib/core/CollapseList/index.d.ts.map +1 -1
- package/lib/core/CollapseList/index.js +3 -1
- package/lib/core/CollapseList/styles.d.ts +1 -39
- package/lib/core/CollapseList/styles.d.ts.map +1 -1
- package/lib/core/CommentsTimeline/CommentLine/index.d.ts +1 -1
- package/lib/core/CommentsTimeline/CommentLine/index.d.ts.map +1 -1
- package/lib/core/CommentsTimeline/CommentLine/index.js +13 -4
- package/lib/core/CommentsTimeline/CommentsTimeline.stories.d.ts +7 -11
- package/lib/core/CommentsTimeline/CommentsTimeline.stories.d.ts.map +1 -1
- package/lib/core/CommentsTimeline/CommentsTimeline.stories.js +67 -62
- package/lib/core/CommentsTimeline/index.d.ts.map +1 -1
- package/lib/core/CommentsTimeline/index.js +2 -0
- package/lib/core/CustomText/CustomText.stories.d.ts +9 -19
- package/lib/core/CustomText/CustomText.stories.d.ts.map +1 -1
- package/lib/core/CustomText/CustomText.stories.js +12 -12
- package/lib/core/CustomText/index.d.ts.map +1 -1
- package/lib/core/CustomText/index.js +4 -1
- package/lib/core/Dropdown/Dropdown.stories.d.ts +10 -23
- package/lib/core/Dropdown/Dropdown.stories.d.ts.map +1 -1
- package/lib/core/Dropdown/Dropdown.stories.js +16 -15
- package/lib/core/Dropdown/index.d.ts +1 -1
- package/lib/core/Dropdown/index.d.ts.map +1 -1
- package/lib/core/Dropdown/index.js +18 -0
- package/lib/core/FileInput/styles.d.ts +1 -39
- package/lib/core/FileInput/styles.d.ts.map +1 -1
- package/lib/core/Header/index.d.ts +3 -1
- package/lib/core/Header/index.d.ts.map +1 -1
- package/lib/core/Header/index.js +2 -1
- package/lib/core/Header/styles.d.ts +1 -1
- package/lib/core/Header/styles.d.ts.map +1 -1
- package/lib/core/Header/styles.js +7 -7
- package/lib/core/InfoButton/styles.d.ts +1 -39
- package/lib/core/InfoButton/styles.d.ts.map +1 -1
- package/lib/core/Modal/index.d.ts +1 -2
- package/lib/core/Modal/index.d.ts.map +1 -1
- package/lib/core/Modal/index.js +1 -1
- package/lib/core/Modal/styles.d.ts +1 -1
- package/lib/core/Modal/styles.d.ts.map +1 -1
- package/lib/core/Modal/styles.js +9 -9
- package/lib/core/Text/index.d.ts +2 -1
- package/lib/core/Text/index.d.ts.map +1 -1
- package/lib/core/Text/index.js +3 -1
- package/lib/core/private/ButtonOrLink.d.ts +2 -3
- package/lib/core/private/ButtonOrLink.d.ts.map +1 -1
- package/lib/core/private/ButtonOrLink.js +5 -4
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/layout/Footer/FooterButton/styles.d.ts +1 -1
- package/lib/layout/Footer/FooterLink/styles.d.ts +1 -1
- package/lib/layout/Menu/MenuTop/styles.d.ts +1 -1
- package/package.json +1 -1
- package/esm/core/Autocomplete/utils/useHandleOptionsHeight.js +0 -16
- package/esm/core/CheckboxController/index.js +0 -22
- package/esm/core/Datepicker/yearMonthForm.js +0 -56
- package/esm/core/EditorOld/config.js +0 -69
- package/esm/core/EditorOld/index.js +0 -147
- package/esm/core/EditorOld/styles.js +0 -65
- package/esm/core/ImageCarousel/index.js +0 -70
- package/esm/core/ImageCarousel/styles.js +0 -58
- package/esm/enums/ModifierKey.js +0 -13
- package/lib/core/Autocomplete/utils/useHandleOptionsHeight.d.ts +0 -7
- package/lib/core/Autocomplete/utils/useHandleOptionsHeight.d.ts.map +0 -1
- package/lib/core/Autocomplete/utils/useHandleOptionsHeight.js +0 -16
- package/lib/core/CheckboxController/index.d.ts +0 -1
- package/lib/core/CheckboxController/index.d.ts.map +0 -1
- package/lib/core/CheckboxController/index.js +0 -22
- package/lib/core/Datepicker/yearMonthForm.d.ts +0 -10
- package/lib/core/Datepicker/yearMonthForm.d.ts.map +0 -1
- package/lib/core/Datepicker/yearMonthForm.js +0 -56
- package/lib/core/EditorOld/config.d.ts +0 -56
- package/lib/core/EditorOld/config.d.ts.map +0 -1
- package/lib/core/EditorOld/config.js +0 -69
- package/lib/core/EditorOld/index.d.ts +0 -39
- package/lib/core/EditorOld/index.d.ts.map +0 -1
- package/lib/core/EditorOld/index.js +0 -147
- package/lib/core/EditorOld/styles.d.ts +0 -23
- package/lib/core/EditorOld/styles.d.ts.map +0 -1
- package/lib/core/EditorOld/styles.js +0 -65
- package/lib/core/ImageCarousel/index.d.ts +0 -11
- package/lib/core/ImageCarousel/index.d.ts.map +0 -1
- package/lib/core/ImageCarousel/index.js +0 -70
- package/lib/core/ImageCarousel/styles.d.ts +0 -26
- package/lib/core/ImageCarousel/styles.d.ts.map +0 -1
- package/lib/core/ImageCarousel/styles.js +0 -58
- package/lib/enums/ModifierKey.d.ts +0 -12
- package/lib/enums/ModifierKey.d.ts.map +0 -1
- package/lib/enums/ModifierKey.js +0 -13
package/esm/core/Alert/index.js
CHANGED
@@ -33,7 +33,6 @@ const Alert = ({
|
|
33
33
|
return 'Informasjon';
|
34
34
|
};
|
35
35
|
const accessibilityProps = {
|
36
|
-
role: restProps['role'] || 'alert',
|
37
36
|
'aria-live': ariaLivePolicy,
|
38
37
|
'aria-atomic': restProps['aria-atomic'] || true,
|
39
38
|
'aria-label': restProps['aria-label'] || getDefaultAriaLabel(),
|
@@ -41,6 +40,7 @@ const Alert = ({
|
|
41
40
|
'aria-describedby': descriptionId.current
|
42
41
|
};
|
43
42
|
return _jsxs("div", {
|
43
|
+
role: "alert",
|
44
44
|
css: theme => [styles.default(theme), success && styles.success(theme), info && styles.info(theme), danger && styles.danger(theme), rounded && styles.rounded, primary && styles.primary(theme), css && css],
|
45
45
|
className: className,
|
46
46
|
...restProps,
|
@@ -8,11 +8,11 @@ const AppLoader = ({
|
|
8
8
|
...restProps
|
9
9
|
}) => {
|
10
10
|
const accessibilityProps = {
|
11
|
-
role: restProps['role'] || 'status',
|
12
11
|
'aria-live': restProps['aria-live'] || 'polite',
|
13
12
|
'aria-label': restProps['aria-label'] || 'Laster innhold'
|
14
13
|
};
|
15
14
|
return _jsxs("div", {
|
15
|
+
role: "status",
|
16
16
|
css: theme => [styles.default(theme, color)],
|
17
17
|
...restProps,
|
18
18
|
...accessibilityProps,
|
@@ -73,4 +73,21 @@ export const WithoutChildren = {
|
|
73
73
|
})
|
74
74
|
},
|
75
75
|
name: 'Without children'
|
76
|
+
};
|
77
|
+
export const WithAriaLabel = {
|
78
|
+
args: {
|
79
|
+
header: /*#__PURE__*/_jsx(Header, {
|
80
|
+
level: 4,
|
81
|
+
children: "Title"
|
82
|
+
}),
|
83
|
+
'aria-label': 'Title. Some content.',
|
84
|
+
children: /*#__PURE__*/_jsx("p", {
|
85
|
+
children: "Some content"
|
86
|
+
}),
|
87
|
+
actionButton: /*#__PURE__*/_jsx(Button, {
|
88
|
+
onClick: () => console.log('Hello'),
|
89
|
+
children: "Hello I am button"
|
90
|
+
})
|
91
|
+
},
|
92
|
+
name: 'With aria-label'
|
76
93
|
};
|
package/esm/core/Banner/index.js
CHANGED
@@ -1,89 +1,90 @@
|
|
1
1
|
import Header from '../Header';
|
2
2
|
import Box from '.';
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
4
|
-
|
4
|
+
const meta = {
|
5
5
|
title: 'Core/Box',
|
6
6
|
component: Box
|
7
7
|
};
|
8
|
+
export default meta;
|
8
9
|
export const Default = {
|
9
|
-
|
10
|
-
children:
|
11
|
-
}
|
10
|
+
args: {
|
11
|
+
children: 'Stuff'
|
12
|
+
},
|
12
13
|
name: 'Default'
|
13
14
|
};
|
14
15
|
export const Collapsable = {
|
15
|
-
|
16
|
+
args: {
|
16
17
|
header: /*#__PURE__*/_jsx(Header, {
|
17
18
|
level: 3,
|
18
19
|
children: "Header"
|
19
20
|
}),
|
20
21
|
collapsable: true,
|
21
|
-
children:
|
22
|
-
}
|
22
|
+
children: 'Stuff'
|
23
|
+
},
|
23
24
|
name: 'Collapsable'
|
24
25
|
};
|
25
26
|
export const Rounded = {
|
26
|
-
|
27
|
-
type:
|
28
|
-
children:
|
29
|
-
}
|
27
|
+
args: {
|
28
|
+
type: 'mysite',
|
29
|
+
children: 'Stuff'
|
30
|
+
},
|
30
31
|
name: 'Rounded'
|
31
32
|
};
|
32
33
|
export const WithHeader = {
|
33
|
-
|
34
|
+
args: {
|
34
35
|
header: /*#__PURE__*/_jsx(Header, {
|
35
36
|
level: 3,
|
36
37
|
children: "Header"
|
37
38
|
}),
|
38
|
-
children:
|
39
|
-
}
|
39
|
+
children: 'Stuff'
|
40
|
+
},
|
40
41
|
name: 'With header'
|
41
42
|
};
|
42
43
|
export const WithHeaderAndCollapse = {
|
43
|
-
|
44
|
+
args: {
|
44
45
|
header: /*#__PURE__*/_jsx(Header, {
|
45
46
|
level: 3,
|
46
47
|
children: "Header"
|
47
48
|
}),
|
48
49
|
collapsable: true,
|
49
|
-
children:
|
50
|
-
}
|
50
|
+
children: 'Stuff'
|
51
|
+
},
|
51
52
|
name: 'With header and collapse'
|
52
53
|
};
|
53
54
|
export const CollapsableMysite = {
|
54
|
-
|
55
|
+
args: {
|
55
56
|
header: /*#__PURE__*/_jsx(Header, {
|
56
57
|
level: 3,
|
57
58
|
children: "Header"
|
58
59
|
}),
|
59
60
|
collapsable: true,
|
60
|
-
type:
|
61
|
-
children:
|
62
|
-
}
|
61
|
+
type: 'mysite',
|
62
|
+
children: 'Stuff'
|
63
|
+
},
|
63
64
|
name: 'Collapsable mysite'
|
64
65
|
};
|
65
66
|
export const Noshadow = {
|
66
|
-
|
67
|
+
args: {
|
67
68
|
noshadow: true,
|
68
|
-
children:
|
69
|
-
}
|
69
|
+
children: 'Stuff'
|
70
|
+
},
|
70
71
|
name: 'Noshadow'
|
71
72
|
};
|
72
73
|
export const Background = {
|
73
|
-
|
74
|
-
background:
|
75
|
-
children:
|
76
|
-
}
|
74
|
+
args: {
|
75
|
+
background: '#ececec',
|
76
|
+
children: 'Stuff'
|
77
|
+
},
|
77
78
|
name: 'Background'
|
78
79
|
};
|
79
80
|
export const HideContent = {
|
80
|
-
|
81
|
+
args: {
|
81
82
|
header: /*#__PURE__*/_jsx(Header, {
|
82
83
|
level: 3,
|
83
84
|
children: "Header"
|
84
85
|
}),
|
85
86
|
hideContent: true,
|
86
|
-
children:
|
87
|
-
}
|
87
|
+
children: 'Stuff'
|
88
|
+
},
|
88
89
|
name: 'Hide content'
|
89
90
|
};
|
package/esm/core/Box/index.js
CHANGED
@@ -28,12 +28,18 @@ const Box = ({
|
|
28
28
|
const onCollapseIconClicked = e => {
|
29
29
|
setIsOpen(!isOpen);
|
30
30
|
};
|
31
|
-
const icon = collapseIcon === 'plus/minus' ? isOpen ? _jsx(IconMinus, {
|
31
|
+
const icon = collapseIcon === 'plus/minus' ? isOpen ? _jsx(IconMinus, {
|
32
|
+
"aria-hidden": "true"
|
33
|
+
}) : _jsx(IconPlus, {
|
34
|
+
"aria-hidden": "true"
|
35
|
+
}) : _jsx(IconChevronDown, {
|
32
36
|
flipVertical: isOpen,
|
33
|
-
size: "14px"
|
37
|
+
size: "14px",
|
38
|
+
"aria-hidden": "true"
|
34
39
|
});
|
35
40
|
const headerWrapper = collapsable ? _jsx(CollapseButton, {
|
36
|
-
"aria-label":
|
41
|
+
"aria-label": `Toggle box ${isOpen ? 'closed' : 'open'}`,
|
42
|
+
"aria-expanded": isOpen,
|
37
43
|
onClick: onCollapseIconClicked,
|
38
44
|
nostyle: true,
|
39
45
|
children: _jsxs(HeaderWrapper, {
|
@@ -45,6 +51,7 @@ const Box = ({
|
|
45
51
|
children: header
|
46
52
|
});
|
47
53
|
return _jsxs("div", {
|
54
|
+
role: "group",
|
48
55
|
css: theme => [styles.default(theme), css && css, type === 'mysite' && styles.mysite(theme), noshadow && styles.noshadow, background && styles.background(background)],
|
49
56
|
className: className,
|
50
57
|
...restProps,
|
package/esm/core/Button/index.js
CHANGED
@@ -6,7 +6,7 @@ import AppLoader from '../AppLoader';
|
|
6
6
|
import { useTheme } from '@emotion/react';
|
7
7
|
import IconChevronLeft from '../../icons/General/IconChevronLeft';
|
8
8
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
9
|
-
const Button = props => {
|
9
|
+
const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
10
10
|
const {
|
11
11
|
danger,
|
12
12
|
success,
|
@@ -49,6 +49,7 @@ const Button = props => {
|
|
49
49
|
tabIndex: tabIndex,
|
50
50
|
disabled: disabled,
|
51
51
|
loading: loading,
|
52
|
+
ref: ref,
|
52
53
|
css: theme => [styles.default(theme), outline && styles.outline(theme), danger && styles.danger(theme), success && styles.success(theme), highlight && styles.highlighted, disabled && styles.disabled(theme), (beforeIcon || afterIcon) && styles.icon(theme), beforeIcon && styles.beforeIcon, afterIcon && styles.afterIcon, border && styles.border(border), nostyle && styles.nostyle, loading && styles.loading(theme), back && styles.back(theme), css && css, small && styles.small, danger && outline && styles.dangerOutline(theme), success && outline && styles.successOutline(theme), transparentBg && styles.transparentBg, focusable && styles.focusable],
|
53
54
|
afterIcon: afterIcon,
|
54
55
|
beforeIcon: back ? _jsx(IconChevronLeft, {
|
@@ -60,5 +61,5 @@ const Button = props => {
|
|
60
61
|
color: getLoaderColor()
|
61
62
|
}) : props.children
|
62
63
|
});
|
63
|
-
};
|
64
|
+
});
|
64
65
|
export default Button;
|
@@ -2,21 +2,22 @@ import Card from '.';
|
|
2
2
|
import Dropdown from '../Dropdown';
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
4
4
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
5
|
-
|
5
|
+
const meta = {
|
6
6
|
title: 'Core/Card',
|
7
7
|
component: Card
|
8
8
|
};
|
9
|
+
export default meta;
|
9
10
|
export const Default = {
|
10
|
-
|
11
|
-
children:
|
12
|
-
}
|
11
|
+
args: {
|
12
|
+
children: 'Stuff'
|
13
|
+
},
|
13
14
|
name: 'Default'
|
14
15
|
};
|
15
16
|
export const WithHover = {
|
16
|
-
|
17
|
+
args: {
|
17
18
|
withhover: true,
|
18
|
-
children:
|
19
|
-
}
|
19
|
+
children: 'Hover me!'
|
20
|
+
},
|
20
21
|
name: 'With hover'
|
21
22
|
};
|
22
23
|
export const WithShadow = {
|
package/esm/core/Card/index.js
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
import Checkbox from '.';
|
2
|
-
|
3
|
-
export default {
|
2
|
+
const meta = {
|
4
3
|
title: 'Core/Checkbox',
|
5
4
|
component: Checkbox
|
6
5
|
};
|
6
|
+
export default meta;
|
7
7
|
export const Default = {
|
8
|
-
|
9
|
-
value:
|
10
|
-
children:
|
11
|
-
}
|
8
|
+
args: {
|
9
|
+
value: 'value1',
|
10
|
+
children: 'Option'
|
11
|
+
},
|
12
12
|
name: 'Default'
|
13
13
|
};
|
14
14
|
export const WithoutLabel = {
|
15
|
-
|
16
|
-
value:
|
17
|
-
}
|
15
|
+
args: {
|
16
|
+
value: 'value1'
|
17
|
+
},
|
18
18
|
name: 'Without label'
|
19
19
|
};
|
20
20
|
export const Subtle = {
|
21
|
-
|
22
|
-
value:
|
23
|
-
type:
|
24
|
-
children:
|
25
|
-
}
|
21
|
+
args: {
|
22
|
+
value: 'value1',
|
23
|
+
type: 'subtle',
|
24
|
+
children: 'Option'
|
25
|
+
},
|
26
26
|
name: 'Subtle'
|
27
27
|
};
|
28
28
|
export const Checked = {
|
29
|
-
|
30
|
-
value:
|
29
|
+
args: {
|
30
|
+
value: 'value1',
|
31
31
|
checked: true,
|
32
|
-
children:
|
33
|
-
}
|
32
|
+
children: 'Option'
|
33
|
+
},
|
34
34
|
name: 'Checked'
|
35
35
|
};
|
36
36
|
export const Disabled = {
|
37
|
-
|
38
|
-
value:
|
37
|
+
args: {
|
38
|
+
value: 'value1',
|
39
39
|
disabled: true,
|
40
|
-
children:
|
41
|
-
}
|
40
|
+
children: 'Disabled option'
|
41
|
+
},
|
42
42
|
name: 'Disabled'
|
43
43
|
};
|
@@ -1,43 +1,51 @@
|
|
1
1
|
import CollapseList from '.';
|
2
2
|
import CollapseListItem from './Item';
|
3
3
|
import Text from '../Text';
|
4
|
+
import Header from '../Header';
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
5
6
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
6
|
-
|
7
|
+
const meta = {
|
7
8
|
title: 'Core/CollapseList',
|
8
9
|
component: CollapseList
|
9
10
|
};
|
11
|
+
export default meta;
|
10
12
|
export const Default = {
|
11
|
-
|
12
|
-
children:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
13
|
+
args: {
|
14
|
+
children: /*#__PURE__*/_jsxs(CollapseList, {
|
15
|
+
children: [/*#__PURE__*/_jsx(CollapseListItem, {
|
16
|
+
header: /*#__PURE__*/_jsx(Header, {
|
17
|
+
level: 5,
|
18
|
+
children: "Header"
|
19
|
+
}),
|
20
|
+
content: /*#__PURE__*/_jsx(Text, {
|
21
|
+
children: "Content"
|
22
|
+
})
|
23
|
+
}), /*#__PURE__*/_jsx(CollapseListItem, {
|
24
|
+
header: /*#__PURE__*/_jsx(Header, {
|
25
|
+
level: 5,
|
26
|
+
children: "Item 2"
|
27
|
+
}),
|
28
|
+
content: /*#__PURE__*/_jsx(Text, {
|
29
|
+
children: "Content"
|
30
|
+
})
|
31
|
+
})]
|
32
|
+
})
|
33
|
+
},
|
28
34
|
name: 'Default'
|
29
35
|
};
|
30
36
|
export const InitialOpen = {
|
31
|
-
|
32
|
-
children: /*#__PURE__*/_jsx(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
args: {
|
38
|
+
children: /*#__PURE__*/_jsx(CollapseList, {
|
39
|
+
children: /*#__PURE__*/_jsx(CollapseListItem, {
|
40
|
+
header: /*#__PURE__*/_jsx(Text, {
|
41
|
+
children: "Header"
|
42
|
+
}),
|
43
|
+
content: /*#__PURE__*/_jsx(Text, {
|
44
|
+
children: "Content"
|
45
|
+
}),
|
46
|
+
initialOpen: true
|
47
|
+
})
|
40
48
|
})
|
41
|
-
}
|
49
|
+
},
|
42
50
|
name: 'initialOpen'
|
43
51
|
};
|
@@ -1,32 +1,65 @@
|
|
1
|
-
import React, { useState } from 'react';
|
1
|
+
import React, { useMemo, useRef, useState } from 'react';
|
2
2
|
import { CollapseButton } from './styles';
|
3
3
|
import { IconChevronDown } from '../..';
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
5
5
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
6
|
+
const headerTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'Header'];
|
6
7
|
const CollapseListItem = ({
|
7
8
|
header,
|
8
9
|
content,
|
9
|
-
initialOpen
|
10
|
+
initialOpen,
|
11
|
+
...restProps
|
10
12
|
}) => {
|
11
13
|
const [open, setOpen] = useState(initialOpen ? true : false);
|
14
|
+
const contentRef = useRef(null);
|
15
|
+
const contentId = `content-${Math.random().toString(36).substring(2, 9)}`;
|
16
|
+
const tag = useMemo(() => getHtmlTag(header), [header]);
|
17
|
+
const isHeadingOrHTMLHeading = headerTags.includes(tag || '');
|
18
|
+
function getHtmlTag(node) {
|
19
|
+
if ( /*#__PURE__*/React.isValidElement(node)) {
|
20
|
+
const element = node;
|
21
|
+
if (typeof element.type === 'function') {
|
22
|
+
return element.type.name;
|
23
|
+
} else if (typeof element.type === 'string') {
|
24
|
+
return element.type;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
return null;
|
28
|
+
}
|
12
29
|
const toggleOpen = () => {
|
13
30
|
setOpen(!open);
|
31
|
+
if (!open && contentRef.current) {
|
32
|
+
contentRef.current.focus(); // Optional focus management.
|
33
|
+
}
|
14
34
|
};
|
35
|
+
|
15
36
|
return /*#__PURE__*/_jsxs("div", {
|
16
37
|
className: "item",
|
38
|
+
...restProps,
|
39
|
+
role: restProps['role'] || 'listitem',
|
17
40
|
children: [/*#__PURE__*/_jsx(CollapseButton, {
|
18
41
|
onClick: toggleOpen,
|
19
42
|
nostyle: true,
|
43
|
+
"aria-expanded": open,
|
44
|
+
"aria-controls": contentId,
|
45
|
+
"aria-label": typeof header === 'string' ? `Toggle ${header}` : undefined,
|
20
46
|
children: /*#__PURE__*/_jsxs("div", {
|
21
47
|
className: "header",
|
48
|
+
role: !isHeadingOrHTMLHeading ? 'heading' : undefined,
|
22
49
|
children: [header, /*#__PURE__*/_jsx(IconChevronDown, {
|
23
50
|
primary: true,
|
24
51
|
flipVertical: open,
|
25
52
|
size: '14px'
|
26
53
|
})]
|
27
54
|
})
|
28
|
-
}), open && /*#__PURE__*/_jsx("
|
55
|
+
}), open && /*#__PURE__*/_jsx("section", {
|
56
|
+
role: "region",
|
29
57
|
className: "content",
|
58
|
+
id: contentId,
|
59
|
+
"aria-hidden": !open,
|
60
|
+
ref: contentRef,
|
61
|
+
tabIndex: -1,
|
62
|
+
"aria-live": "polite",
|
30
63
|
children: content
|
31
64
|
})]
|
32
65
|
});
|
@@ -3,10 +3,12 @@ import React from 'react';
|
|
3
3
|
import { styles } from './styles';
|
4
4
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
5
5
|
const CollapseList = ({
|
6
|
-
children
|
6
|
+
children,
|
7
|
+
...restProps
|
7
8
|
}) => {
|
8
9
|
return _jsx("div", {
|
9
10
|
css: theme => [styles.default(theme)],
|
11
|
+
...restProps,
|
10
12
|
children: children
|
11
13
|
});
|
12
14
|
};
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import { DateWrapper, IconWrapper, TextWrapper, Wrapper } from './styles';
|
3
3
|
import { useTheme } from '@emotion/react';
|
4
4
|
import Text from '../../Text';
|
5
|
-
import { useIsMobile } from '../../..';
|
5
|
+
import { Header, useIsMobile } from '../../..';
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
7
7
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
8
8
|
const CommentLine = ({
|
@@ -14,13 +14,18 @@ const CommentLine = ({
|
|
14
14
|
italic,
|
15
15
|
commentInfo,
|
16
16
|
subtle,
|
17
|
-
customContent
|
17
|
+
customContent,
|
18
|
+
...restProps
|
18
19
|
}) => {
|
19
20
|
const theme = useTheme();
|
20
21
|
const isMobile = useIsMobile();
|
22
|
+
const ariaLabel = `kommentar ${date} klokken ${time}`;
|
21
23
|
return /*#__PURE__*/_jsxs(Wrapper, {
|
22
24
|
theme: theme,
|
23
25
|
"data-testid": "comment-line",
|
26
|
+
role: "article",
|
27
|
+
"aria-label": ariaLabel,
|
28
|
+
...restProps,
|
24
29
|
children: [/*#__PURE__*/_jsxs(DateWrapper, {
|
25
30
|
children: [/*#__PURE__*/_jsx(Text, {
|
26
31
|
subtle: true,
|
@@ -31,15 +36,19 @@ const CommentLine = ({
|
|
31
36
|
children: date
|
32
37
|
})]
|
33
38
|
}), /*#__PURE__*/_jsx(IconWrapper, {
|
39
|
+
"aria-hidden": true,
|
34
40
|
children: icon
|
35
41
|
}), /*#__PURE__*/_jsxs(TextWrapper, {
|
36
|
-
|
37
|
-
|
42
|
+
tabIndex: 0,
|
43
|
+
children: [/*#__PURE__*/_jsx(Header, {
|
44
|
+
level: 5,
|
45
|
+
size: "16px",
|
38
46
|
children: header
|
39
47
|
}), /*#__PURE__*/_jsx(Text, {
|
40
48
|
italic: italic,
|
41
49
|
subtle: subtle,
|
42
50
|
size: "14px",
|
51
|
+
paragraph: true,
|
43
52
|
children: comment
|
44
53
|
}), commentInfo && /*#__PURE__*/_jsx(Text, {
|
45
54
|
italic: true,
|