@bbl-digital/snorre 4.0.22 → 4.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. package/dist/bundle.js +113 -27
  2. package/esm/core/Button/Button.stories.js +50 -48
  3. package/esm/core/Card/index.js +4 -3
  4. package/esm/core/Checkbox/index.js +32 -9
  5. package/esm/core/CollapseList/Item.js +4 -3
  6. package/esm/core/CollapseList/index.js +4 -3
  7. package/esm/core/Datepicker/Datepicker.stories.js +7 -6
  8. package/esm/core/DatepickerRange/DatepickerRange.stories.js +4 -3
  9. package/esm/core/DropdownMenu/DropdownMenu.stories.js +34 -26
  10. package/esm/core/DropdownMenu/DropdownMenuOption.js +2 -0
  11. package/esm/core/DropdownMenu/index.js +16 -0
  12. package/esm/core/Editor/Editor.stories.js +31 -30
  13. package/esm/core/FileInput/index.js +7 -1
  14. package/esm/core/GoogleButton/GoogleButton.stories.js +4 -4
  15. package/esm/core/Header/Header.stories.js +42 -45
  16. package/esm/core/HighlightText/HighlightText.stories.js +11 -11
  17. package/esm/core/Image/index.js +19 -4
  18. package/esm/core/ImagePicker/ImagePicker.stories.js +2 -1
  19. package/esm/core/ImagePicker/index.js +4 -0
  20. package/esm/core/ImageViewer/index.js +15 -5
  21. package/esm/core/InfoButton/InfoButton.stories.js +23 -22
  22. package/esm/core/InfoButton/index.js +4 -0
  23. package/esm/core/Input/index.js +4 -0
  24. package/lib/core/Button/Button.stories.d.ts +20 -63
  25. package/lib/core/Button/Button.stories.d.ts.map +1 -1
  26. package/lib/core/Button/Button.stories.js +50 -48
  27. package/lib/core/Card/index.d.ts +14 -15
  28. package/lib/core/Card/index.d.ts.map +1 -1
  29. package/lib/core/Card/index.js +4 -3
  30. package/lib/core/Checkbox/index.d.ts +3 -3
  31. package/lib/core/Checkbox/index.d.ts.map +1 -1
  32. package/lib/core/Checkbox/index.js +32 -9
  33. package/lib/core/CollapseList/Item.d.ts +1 -1
  34. package/lib/core/CollapseList/Item.d.ts.map +1 -1
  35. package/lib/core/CollapseList/Item.js +4 -3
  36. package/lib/core/CollapseList/index.d.ts +1 -1
  37. package/lib/core/CollapseList/index.d.ts.map +1 -1
  38. package/lib/core/CollapseList/index.js +4 -3
  39. package/lib/core/Datepicker/Datepicker.stories.d.ts +6 -6
  40. package/lib/core/Datepicker/Datepicker.stories.d.ts.map +1 -1
  41. package/lib/core/Datepicker/Datepicker.stories.js +7 -6
  42. package/lib/core/DatepickerRange/DatepickerRange.stories.d.ts +6 -7
  43. package/lib/core/DatepickerRange/DatepickerRange.stories.d.ts.map +1 -1
  44. package/lib/core/DatepickerRange/DatepickerRange.stories.js +4 -3
  45. package/lib/core/DropdownMenu/DropdownMenu.stories.d.ts +8 -15
  46. package/lib/core/DropdownMenu/DropdownMenu.stories.d.ts.map +1 -1
  47. package/lib/core/DropdownMenu/DropdownMenu.stories.js +34 -26
  48. package/lib/core/DropdownMenu/DropdownMenuOption.d.ts.map +1 -1
  49. package/lib/core/DropdownMenu/DropdownMenuOption.js +2 -0
  50. package/lib/core/DropdownMenu/index.d.ts.map +1 -1
  51. package/lib/core/DropdownMenu/index.js +16 -0
  52. package/lib/core/Editor/Editor.stories.d.ts +10 -23
  53. package/lib/core/Editor/Editor.stories.d.ts.map +1 -1
  54. package/lib/core/Editor/Editor.stories.js +31 -30
  55. package/lib/core/FileInput/index.d.ts +3 -1
  56. package/lib/core/FileInput/index.d.ts.map +1 -1
  57. package/lib/core/FileInput/index.js +7 -1
  58. package/lib/core/GoogleButton/GoogleButton.stories.d.ts +6 -7
  59. package/lib/core/GoogleButton/GoogleButton.stories.d.ts.map +1 -1
  60. package/lib/core/GoogleButton/GoogleButton.stories.js +4 -4
  61. package/lib/core/Header/Header.stories.d.ts +13 -35
  62. package/lib/core/Header/Header.stories.d.ts.map +1 -1
  63. package/lib/core/Header/Header.stories.js +42 -45
  64. package/lib/core/HighlightText/HighlightText.stories.d.ts +7 -11
  65. package/lib/core/HighlightText/HighlightText.stories.d.ts.map +1 -1
  66. package/lib/core/HighlightText/HighlightText.stories.js +11 -11
  67. package/lib/core/Image/index.d.ts +1 -0
  68. package/lib/core/Image/index.d.ts.map +1 -1
  69. package/lib/core/Image/index.js +19 -4
  70. package/lib/core/ImagePicker/ImagePicker.stories.d.ts +6 -17
  71. package/lib/core/ImagePicker/ImagePicker.stories.d.ts.map +1 -1
  72. package/lib/core/ImagePicker/ImagePicker.stories.js +2 -1
  73. package/lib/core/ImagePicker/index.d.ts.map +1 -1
  74. package/lib/core/ImagePicker/index.js +4 -0
  75. package/lib/core/ImageViewer/index.d.ts.map +1 -1
  76. package/lib/core/ImageViewer/index.js +15 -5
  77. package/lib/core/InfoButton/InfoButton.stories.d.ts +10 -23
  78. package/lib/core/InfoButton/InfoButton.stories.d.ts.map +1 -1
  79. package/lib/core/InfoButton/InfoButton.stories.js +23 -22
  80. package/lib/core/InfoButton/index.d.ts.map +1 -1
  81. package/lib/core/InfoButton/index.js +4 -0
  82. package/lib/core/Input/index.d.ts +1 -1
  83. package/lib/core/Input/index.d.ts.map +1 -1
  84. package/lib/core/Input/index.js +4 -0
  85. package/package.json +1 -1
@@ -3,8 +3,25 @@ import React, { useEffect, useState } from 'react';
3
3
  import { styles } from './styles';
4
4
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
5
5
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
6
- const Checkbox = props => {
6
+ const Checkbox = /*#__PURE__*/React.forwardRef(({
7
+ ...props
8
+ }, ref) => {
7
9
  const [value, setValue] = useState(props.checked ? true : false);
10
+ const {
11
+ checked,
12
+ disabled,
13
+ className,
14
+ disabledHoverState,
15
+ nomargin,
16
+ child,
17
+ type,
18
+ name,
19
+ onChange,
20
+ onClick,
21
+ id,
22
+ children,
23
+ ...restProps
24
+ } = props;
8
25
  useEffect(() => {
9
26
  setValue(props.checked ? true : false);
10
27
  }, [props.checked]);
@@ -15,18 +32,24 @@ const Checkbox = props => {
15
32
  };
16
33
  return _jsxs("label", {
17
34
  "aria-label": props['aria-label'],
18
- className: props.className,
19
- css: theme => [styles.default(theme), props.disabled && styles.disabled(theme, props.disabledHoverState), props.nomargin && styles.nomargin, props.child && styles.child, props.type === 'subtle' && styles.subtle(theme)],
35
+ htmlFor: id,
36
+ className: className,
37
+ css: theme => [styles.default(theme), disabled && styles.disabled(theme, disabledHoverState), nomargin && styles.nomargin, child && styles.child, type === 'subtle' && styles.subtle(theme)],
20
38
  onClick: e => e.stopPropagation(),
21
39
  children: [_jsx("input", {
40
+ ref: ref,
22
41
  type: "checkbox",
42
+ role: "checkbox",
43
+ "aria-checked": value,
23
44
  checked: value,
24
45
  value: props.value,
25
- name: props.name,
26
- disabled: props.disabled,
27
- onClick: props.onClick,
28
- onChange: handleChange
29
- }), _jsx("span", {}), props.children]
46
+ name: name,
47
+ id: id,
48
+ disabled: disabled,
49
+ onClick: onClick,
50
+ onChange: handleChange,
51
+ ...restProps
52
+ }), _jsx("span", {}), children]
30
53
  });
31
- };
54
+ });
32
55
  export default Checkbox;
@@ -4,12 +4,12 @@ import { IconChevronDown } from '../..';
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
5
  import { jsxs as _jsxs } from "react/jsx-runtime";
6
6
  const headerTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'Header'];
7
- const CollapseListItem = ({
7
+ const CollapseListItem = /*#__PURE__*/React.forwardRef(({
8
8
  header,
9
9
  content,
10
10
  initialOpen,
11
11
  ...restProps
12
- }) => {
12
+ }, ref) => {
13
13
  const [open, setOpen] = useState(initialOpen ? true : false);
14
14
  const contentRef = useRef(null);
15
15
  const contentId = `content-${Math.random().toString(36).substring(2, 9)}`;
@@ -34,6 +34,7 @@ const CollapseListItem = ({
34
34
  };
35
35
 
36
36
  return /*#__PURE__*/_jsxs("div", {
37
+ ref: ref,
37
38
  className: "item",
38
39
  ...restProps,
39
40
  role: restProps['role'] || 'listitem',
@@ -63,5 +64,5 @@ const CollapseListItem = ({
63
64
  children: content
64
65
  })]
65
66
  });
66
- };
67
+ });
67
68
  export default CollapseListItem;
@@ -2,14 +2,15 @@
2
2
  import React from 'react';
3
3
  import { styles } from './styles';
4
4
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
5
- const CollapseList = ({
5
+ const CollapseList = /*#__PURE__*/React.forwardRef(({
6
6
  children,
7
7
  ...restProps
8
- }) => {
8
+ }, ref) => {
9
9
  return _jsx("div", {
10
+ ref: ref,
10
11
  css: theme => [styles.default(theme)],
11
12
  ...restProps,
12
13
  children: children
13
14
  });
14
- };
15
+ });
15
16
  export default CollapseList;
@@ -1,16 +1,17 @@
1
1
  import Datepicker from '.';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- export default {
3
+ const meta = {
4
4
  title: 'Core/Datepicker',
5
5
  component: Datepicker
6
6
  };
7
- export const DatepickerDefault = {
8
- render: () => /*#__PURE__*/_jsx(Datepicker, {
7
+ export default meta;
8
+ export const Default = {
9
+ args: {
9
10
  onChange: e => console.log(e),
10
11
  onBlur: () => console.log('blur'),
11
- label: "Date"
12
- }),
13
- name: 'Datepicker'
12
+ label: 'Date'
13
+ },
14
+ name: 'Default'
14
15
  };
15
16
  export const WithError = {
16
17
  render: () => /*#__PURE__*/_jsx(Datepicker, {
@@ -1,10 +1,11 @@
1
1
  import DatepickerRange from '.';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- export default {
3
+ const meta = {
4
4
  title: 'Core/DatepickerRange',
5
5
  component: DatepickerRange
6
6
  };
7
- export const DatepickerRangeDefault = {
7
+ export default meta;
8
+ export const Default = {
8
9
  render: () => /*#__PURE__*/_jsx("div", {
9
10
  style: {
10
11
  height: '600px'
@@ -17,5 +18,5 @@ export const DatepickerRangeDefault = {
17
18
  }
18
19
  })
19
20
  }),
20
- name: 'DatepickerRange'
21
+ name: 'Default'
21
22
  };
@@ -2,46 +2,54 @@ import DropdownMenu from '.';
2
2
  import DropdownMenuOption from './DropdownMenuOption';
3
3
  import IconMail from '../../icons/General/IconMail';
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { Fragment as _Fragment } from "react/jsx-runtime";
5
6
  import { jsxs as _jsxs } from "react/jsx-runtime";
6
- export default {
7
+ const meta = {
7
8
  title: 'Core/DropdownMenu',
8
9
  component: DropdownMenu
9
10
  };
11
+ export default meta;
10
12
  export const Default = {
11
- render: () => /*#__PURE__*/_jsxs(DropdownMenu, {
13
+ args: {
12
14
  icon: /*#__PURE__*/_jsx(IconMail, {}),
13
- children: [/*#__PURE__*/_jsx(DropdownMenuOption, {
14
- onClick: () => console.log('Option 1 clicked'),
15
- children: "Option 1"
16
- }), /*#__PURE__*/_jsx(DropdownMenuOption, {
17
- onClick: () => console.log('Option 2 clicked'),
18
- children: "Option 2"
19
- })]
20
- }),
15
+ children: /*#__PURE__*/_jsxs(_Fragment, {
16
+ children: [/*#__PURE__*/_jsx(DropdownMenuOption, {
17
+ onClick: () => console.log('Option 1 clicked'),
18
+ children: "Option 1"
19
+ }), /*#__PURE__*/_jsx(DropdownMenuOption, {
20
+ onClick: () => console.log('Option 2 clicked'),
21
+ children: "Option 2"
22
+ })]
23
+ })
24
+ },
21
25
  name: 'Default'
22
26
  };
23
27
  export const WithCounterProp = {
24
- render: () => /*#__PURE__*/_jsxs(DropdownMenu, {
28
+ args: {
25
29
  icon: /*#__PURE__*/_jsx(IconMail, {}),
26
- children: [/*#__PURE__*/_jsx(DropdownMenuOption, {
27
- onClick: () => console.log('Option 1 clicked'),
28
- counter: 3,
29
- children: "With counter"
30
- }), /*#__PURE__*/_jsx(DropdownMenuOption, {
31
- onClick: () => console.log('Option 2 clicked'),
32
- children: "Option 2"
33
- })]
34
- }),
30
+ children: /*#__PURE__*/_jsxs(_Fragment, {
31
+ children: [/*#__PURE__*/_jsx(DropdownMenuOption, {
32
+ onClick: () => console.log('Option 1 clicked'),
33
+ counter: 3,
34
+ children: "With counter"
35
+ }), /*#__PURE__*/_jsx(DropdownMenuOption, {
36
+ onClick: () => console.log('Option 2 clicked'),
37
+ children: "Option 2"
38
+ })]
39
+ })
40
+ },
35
41
  name: 'With counter prop'
36
42
  };
37
43
  export const WithClassname = {
38
- render: () => /*#__PURE__*/_jsx(DropdownMenu, {
44
+ args: {
39
45
  icon: /*#__PURE__*/_jsx(IconMail, {}),
40
- className: "my-class",
41
- children: /*#__PURE__*/_jsx(DropdownMenuOption, {
42
- onClick: () => console.log('Option 1 clicked'),
43
- children: "This menu has a classname"
46
+ className: 'my-class',
47
+ children: /*#__PURE__*/_jsx(_Fragment, {
48
+ children: /*#__PURE__*/_jsx(DropdownMenuOption, {
49
+ onClick: () => console.log('Option 1 clicked'),
50
+ children: "This menu has a classname"
51
+ })
44
52
  })
45
- }),
53
+ },
46
54
  name: 'With classname'
47
55
  };
@@ -9,12 +9,14 @@ const DropdownMenuOption = ({
9
9
  children
10
10
  }) => {
11
11
  return _jsxs(Link, {
12
+ role: "menuitem",
12
13
  trackingName: "Topbar",
13
14
  trackingEvent: 'DropdownMenu click: ' + (children ? children : ''),
14
15
  css: theme => [dropdownMenuOption(theme)],
15
16
  onClick: onClick,
16
17
  removeUnderline: true,
17
18
  small: true,
19
+ "aria-label": children ? `Option: ${children}${counter ? `, ${counter} notifications` : ''}` : '',
18
20
  children: [children ? children : '', counter ? ` (${counter})` : '']
19
21
  });
20
22
  };
@@ -9,6 +9,7 @@ const DropdownMenu = ({
9
9
  children
10
10
  }) => {
11
11
  const [open, setOpen] = useState(false);
12
+ const dropdownRef = React.useRef(null);
12
13
  useEffect(() => {
13
14
  const handleClickOutside = e => {
14
15
  setTimeout(() => {
@@ -24,9 +25,22 @@ const DropdownMenu = ({
24
25
  document.removeEventListener('mousedown', handleClickOutside);
25
26
  };
26
27
  }, [open]);
28
+ useEffect(() => {
29
+ if (!dropdownRef?.current) return;
30
+ if (open) {
31
+ // Focus the first focusable element in the dropdown when it opens
32
+ const focusableElements = dropdownRef.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
33
+ if (focusableElements.length) {
34
+ const element = focusableElements[0];
35
+ element.focus();
36
+ }
37
+ }
38
+ }, [open]);
27
39
  return /*#__PURE__*/_jsxs(Wrapper, {
28
40
  className: className,
29
41
  children: [/*#__PURE__*/_jsx(Button, {
42
+ "aria-haspopup": true,
43
+ "aria-expanded": open,
30
44
  nostyle: true,
31
45
  focusable: true,
32
46
  onClick: () => setOpen(!open),
@@ -34,6 +48,8 @@ const DropdownMenu = ({
34
48
  trackingName: "Topbar",
35
49
  children: icon ? icon : ''
36
50
  }), open && /*#__PURE__*/_jsx(Content, {
51
+ ref: dropdownRef,
52
+ role: "menu",
37
53
  children: children
38
54
  })]
39
55
  });
@@ -1,54 +1,55 @@
1
1
  import Editor from '.';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- export default {
2
+ const meta = {
4
3
  title: 'Core/Editor',
5
4
  component: Editor
6
5
  };
6
+ export default meta;
7
7
  export const Default = {
8
- render: () => /*#__PURE__*/_jsx(Editor, {
9
- onChange: e => console.log(e),
10
- label: "Editor-label"
11
- }),
8
+ args: {
9
+ label: 'Editor-label',
10
+ onChange: e => console.log(e)
11
+ },
12
12
  name: 'Default'
13
13
  };
14
14
  export const Rich = {
15
- render: () => /*#__PURE__*/_jsx(Editor, {
15
+ args: {
16
+ label: 'Editor-label',
16
17
  onChange: e => console.log(e),
17
- label: "Editor-label",
18
- type: "rich",
18
+ type: 'rich',
19
19
  allowImages: true
20
- }),
20
+ },
21
21
  name: 'Rich'
22
22
  };
23
23
  export const ValidElements = {
24
- render: () => /*#__PURE__*/_jsx(Editor, {
24
+ args: {
25
+ label: 'Editor-label',
25
26
  onChange: e => console.log(e),
26
- validElements: "strong,p,span,em",
27
- type: "custom",
28
- customToolbar: "bold italic underline"
29
- }),
27
+ type: 'custom',
28
+ customToolbar: 'bold italic underline',
29
+ validElements: 'strong,p,span,em'
30
+ },
30
31
  name: 'Valid elements'
31
32
  };
32
33
  export const InvalidElements = {
33
- render: () => /*#__PURE__*/_jsx(Editor, {
34
+ args: {
35
+ label: 'Editor-label',
34
36
  onChange: e => console.log(e),
35
- pasteAsText: false,
36
- invalidElements: "button,a,h1,h2,h3,h4,h5,h6"
37
- }),
37
+ type: 'custom',
38
+ customToolbar: 'bold italic underline',
39
+ invalidElements: 'button,a,h1,h2,h3,h4,h5,h6'
40
+ },
38
41
  name: 'Invalid elements'
39
42
  };
40
43
  export const AllProps = {
41
- render: () => /*#__PURE__*/_jsx(Editor, {
42
- label: "Label",
43
- type: "rich",
44
- initialValue: '<p><img src="https://i.ytimg.com/vi/CZFKWt3S2Ys/maxresdefault.jpg" alt="testimage" width="444" height="250" /></p><br/><p>"wow" - Owen Wilson</p>',
44
+ args: {
45
+ label: 'Editor-label',
46
+ onChange: e => console.log(e),
47
+ type: 'rich',
45
48
  allowImages: true,
46
- invalidElements: "",
47
- invalidMessage: "Memes are not allowed",
49
+ invalidElements: 'button,a,h1,h2,h3,h4,h5,h6',
50
+ invalidMessage: 'Memes are not allowed',
48
51
  height: 400,
49
- maxHeight: 600,
50
- onChange: (e, length) => console.log(e, length),
51
- onBlur: () => console.log('blur')
52
- }),
53
- name: 'Props'
52
+ maxHeight: 600
53
+ },
54
+ name: 'All props'
54
55
  };
@@ -22,6 +22,7 @@ const FileInput = ({
22
22
  rotateIcon,
23
23
  isControlledState,
24
24
  controlledFiles,
25
+ id = 'file-input',
25
26
  onChange
26
27
  }) => {
27
28
  const [uncontrolledFiles, setUncontrolledFiles] = useState(initialFiles);
@@ -30,6 +31,7 @@ const FileInput = ({
30
31
  const files = isControlledState ? controlledFiles || [] : uncontrolledFiles;
31
32
  const hiddenFileInput = useRef(null);
32
33
  const handleClick = () => {
34
+ if (!hiddenFileInput.current) return;
33
35
  const node = hiddenFileInput.current;
34
36
  node.click();
35
37
  };
@@ -76,6 +78,7 @@ const FileInput = ({
76
78
  };
77
79
  return /*#__PURE__*/_jsxs(Wrapper, {
78
80
  children: [label && /*#__PURE__*/_jsx(Label, {
81
+ id: id,
79
82
  children: label
80
83
  }), /*#__PURE__*/_jsxs(FileWrapper, {
81
84
  children: [files.length > 0 && !hideFileList && /*#__PURE__*/_jsx(DocumentList, {
@@ -102,6 +105,7 @@ const FileInput = ({
102
105
  width: width,
103
106
  type: "button",
104
107
  nostyle: nostyle,
108
+ "aria-labelledby": "fileInputLabel",
105
109
  children: !nostyle ? /*#__PURE__*/_jsxs(ButtonContent, {
106
110
  children: [text, /*#__PURE__*/_jsx(Icon, {
107
111
  rotated: rotateIcon ? 1 : 0,
@@ -116,7 +120,8 @@ const FileInput = ({
116
120
  onChange: handleChange,
117
121
  multiple: multiple,
118
122
  accept: accept,
119
- ref: hiddenFileInput
123
+ ref: hiddenFileInput,
124
+ "aria-hidden": "true"
120
125
  })]
121
126
  })]
122
127
  }), invalidMessage && /*#__PURE__*/_jsx(ErrorMessage, {
@@ -124,6 +129,7 @@ const FileInput = ({
124
129
  }), sizeError && /*#__PURE__*/_jsxs(Alert, {
125
130
  danger: true,
126
131
  onClose: () => setSizeError(false),
132
+ "aria-live": "assertive",
127
133
  children: ["Fil kan ikke overstige ", formatBytes(fileMaxsixe)]
128
134
  })]
129
135
  });
@@ -1,12 +1,12 @@
1
1
  import GoogleButtonComponent from '.';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- export default {
2
+ const meta = {
4
3
  title: 'Core/GoogleButton',
5
4
  component: GoogleButtonComponent
6
5
  };
6
+ export default meta;
7
7
  export const GoogleButton = {
8
- render: () => /*#__PURE__*/_jsx(GoogleButtonComponent, {
8
+ args: {
9
9
  onClick: () => console.log('clicking button')
10
- }),
10
+ },
11
11
  name: 'Google button'
12
12
  };
@@ -1,65 +1,62 @@
1
1
  import Header from '.';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- export default {
2
+ const meta = {
4
3
  title: 'Core/Header',
5
4
  component: Header
6
5
  };
6
+ export default meta;
7
7
  export const Header1 = {
8
- render: () => /*#__PURE__*/_jsx(Header, {
9
- level: 1,
10
- children: "Header 1"
11
- }),
12
- name: 'Header 1'
8
+ args: {
9
+ children: 'Header',
10
+ level: 1
11
+ },
12
+ name: 'Header level 1'
13
13
  };
14
14
  export const Header2 = {
15
- render: () => /*#__PURE__*/_jsx(Header, {
16
- level: 2,
17
- children: "Header 2"
18
- }),
19
- name: 'Header 2'
15
+ args: {
16
+ children: 'Header 2',
17
+ level: 2
18
+ },
19
+ name: 'Header level 2'
20
20
  };
21
21
  export const Header3 = {
22
- render: () => /*#__PURE__*/_jsx(Header, {
23
- level: 3,
24
- children: "Header 3"
25
- }),
26
- name: 'Header 3'
22
+ args: {
23
+ children: 'Header 3',
24
+ level: 3
25
+ },
26
+ name: 'Header level 3'
27
27
  };
28
28
  export const Header4 = {
29
- render: () => /*#__PURE__*/_jsx(Header, {
30
- level: 4,
31
- children: "Header 4"
32
- }),
33
- name: 'Header 4'
29
+ args: {
30
+ children: 'Header 4',
31
+ level: 4
32
+ },
33
+ name: 'Header level 4'
34
34
  };
35
35
  export const Header5 = {
36
- render: () => /*#__PURE__*/_jsx(Header, {
37
- level: 5,
38
- children: "Header 5"
39
- }),
40
- name: 'Header 5'
36
+ args: {
37
+ children: 'Header 5',
38
+ level: 5
39
+ },
40
+ name: 'Header level 5'
41
41
  };
42
- export const HeaderCustomColor = {
43
- render: () => /*#__PURE__*/_jsx(Header, {
44
- level: 3,
45
- color: "green",
46
- children: "Header 3 custom color"
47
- }),
42
+ export const HeaderSecondaryColor = {
43
+ args: {
44
+ children: 'Header 3 custom color',
45
+ secondary: true
46
+ },
48
47
  name: 'Header custom color'
49
48
  };
50
49
  export const HeaderPrimaryColor = {
51
- render: () => /*#__PURE__*/_jsx(Header, {
52
- level: 3,
53
- primary: true,
54
- children: "Header 3 primary color"
55
- }),
50
+ args: {
51
+ children: 'Header 3 primary color',
52
+ primary: true
53
+ },
56
54
  name: 'Header primary color'
57
55
  };
58
- export const HeaderSecondaryColor = {
59
- render: () => /*#__PURE__*/_jsx(Header, {
60
- level: 3,
61
- secondary: true,
62
- children: "Header 3 secondary color"
63
- }),
64
- name: 'Header secondary color'
56
+ export const HeaderCustomColor = {
57
+ args: {
58
+ children: 'Header 3 custom color',
59
+ color: 'red'
60
+ },
61
+ name: 'Header custom color'
65
62
  };
@@ -1,22 +1,22 @@
1
1
  import HighlightText from '.';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- export default {
2
+ const meta = {
4
3
  title: 'Core/HighlightText',
5
4
  component: HighlightText
6
5
  };
6
+ export default meta;
7
7
  export const Highlight = {
8
- render: () => /*#__PURE__*/_jsx(HighlightText, {
9
- text: "This is a text with a highlighted part",
10
- highlight: "highlighted part"
11
- }),
8
+ args: {
9
+ text: 'This is a text with a highlighted part',
10
+ highlight: 'highlighted part'
11
+ },
12
12
  name: 'Highlight'
13
13
  };
14
14
  export const AllProps = {
15
- render: () => /*#__PURE__*/_jsx(HighlightText, {
16
- text: "This is a text with a highlighted part",
17
- highlight: "highlighted part",
18
- size: "14px",
15
+ args: {
16
+ text: 'This is a text with a highlighted part',
17
+ highlight: 'highlighted part',
18
+ size: '14px',
19
19
  semibold: true
20
- }),
20
+ },
21
21
  name: 'All props'
22
22
  };
@@ -1,6 +1,6 @@
1
1
  /** @jsxImportSource @emotion/react */
2
2
 
3
- import React, { useState } from 'react';
3
+ import React, { useMemo, useState } from 'react';
4
4
  import { convertBlobToObjectUrl } from '../../utils/image';
5
5
  import styles from './styles';
6
6
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
@@ -16,16 +16,31 @@ const Image = ({
16
16
  radius,
17
17
  withPlaceholder,
18
18
  fallbackUrl,
19
+ interactive,
19
20
  ...restProps
20
21
  }) => {
21
22
  const [imageLoaded, setImageLoaded] = useState(false);
22
23
  const [imageSrc, setImageSrc] = useState(src || blob && convertBlobToObjectUrl(blob) || undefined);
24
+ const altText = useMemo(() => {
25
+ if (!imageLoaded && withPlaceholder) return 'Laster bilde...';
26
+ if (!imageSrc) return 'Bilde ikke tilgjengelig';
27
+ return alt;
28
+ }, [imageLoaded, imageSrc, alt]);
29
+ const handleLoad = () => {
30
+ setImageLoaded(true);
31
+ };
32
+ const handleError = () => {
33
+ setImageSrc(fallbackUrl);
34
+ setImageLoaded(false);
35
+ };
23
36
  return _jsx("img", {
24
37
  src: imageSrc,
25
- alt: alt,
26
- onLoad: withPlaceholder ? () => setImageLoaded(true) : undefined,
27
- onError: fallbackUrl ? () => setImageSrc(fallbackUrl) : undefined,
38
+ alt: altText,
39
+ onLoad: withPlaceholder ? () => handleLoad() : undefined,
40
+ onError: fallbackUrl ? () => handleError() : undefined,
28
41
  css: theme => [height && styles.height(height), width && styles.width(width), responsive && styles.responsive, objectFit && styles.objectFit(objectFit), withPlaceholder && !imageLoaded && styles.placeholder(theme), radius && styles.radius(radius), css && css],
42
+ tabIndex: interactive ? 0 : undefined,
43
+ role: interactive ? 'button' : undefined,
29
44
  ...restProps
30
45
  });
31
46
  };
@@ -4,10 +4,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  const state = createState({
5
5
  images: []
6
6
  });
7
- export default {
7
+ const meta = {
8
8
  title: 'Core/ImagePicker',
9
9
  component: ImagePicker
10
10
  };
11
+ export default meta;
11
12
  export const Default = {
12
13
  render: () => /*#__PURE__*/_jsx("div", {
13
14
  style: {