@bbl-digital/snorre 4.0.21 → 4.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. package/dist/bundle.js +117 -31
  2. package/esm/core/BoxedTable/TableBody/index.js +10 -0
  3. package/esm/core/BoxedTable/TableBody/styles.js +16 -0
  4. package/esm/core/Button/Button.stories.js +51 -49
  5. package/esm/core/Card/index.js +4 -3
  6. package/esm/core/Checkbox/index.js +32 -9
  7. package/esm/core/CollapseList/Item.js +4 -3
  8. package/esm/core/CollapseList/index.js +4 -3
  9. package/esm/core/Datepicker/Datepicker.stories.js +7 -6
  10. package/esm/core/DatepickerRange/DatepickerRange.stories.js +4 -3
  11. package/esm/core/Dropdown/index.js +0 -1
  12. package/esm/core/DropdownMenu/DropdownMenu.stories.js +34 -26
  13. package/esm/core/DropdownMenu/DropdownMenuOption.js +2 -0
  14. package/esm/core/DropdownMenu/index.js +16 -0
  15. package/esm/core/Editor/Editor.stories.js +31 -30
  16. package/esm/core/FileInput/index.js +7 -1
  17. package/esm/core/GoogleButton/GoogleButton.stories.js +4 -4
  18. package/esm/core/Header/Header.stories.js +42 -45
  19. package/esm/core/HighlightText/HighlightText.stories.js +11 -11
  20. package/esm/core/Image/index.js +19 -4
  21. package/esm/core/ImagePicker/ImagePicker.stories.js +2 -1
  22. package/esm/core/ImagePicker/index.js +4 -0
  23. package/esm/core/ImageViewer/index.js +15 -5
  24. package/esm/core/InfoButton/InfoButton.stories.js +23 -22
  25. package/esm/core/InfoButton/index.js +4 -0
  26. package/esm/core/Input/index.js +4 -0
  27. package/esm/core/private/ButtonOrLink.js +4 -3
  28. package/lib/core/Autocomplete/styles.d.ts +39 -1
  29. package/lib/core/Autocomplete/styles.d.ts.map +1 -1
  30. package/lib/core/Box/styles.d.ts +39 -1
  31. package/lib/core/Box/styles.d.ts.map +1 -1
  32. package/lib/core/BoxedTable/TableBody/index.d.ts +7 -0
  33. package/lib/core/BoxedTable/TableBody/index.d.ts.map +1 -0
  34. package/lib/core/BoxedTable/TableBody/index.js +10 -0
  35. package/lib/core/BoxedTable/TableBody/styles.d.ts +6 -0
  36. package/lib/core/BoxedTable/TableBody/styles.d.ts.map +1 -0
  37. package/lib/core/BoxedTable/TableBody/styles.js +16 -0
  38. package/lib/core/Button/Button.stories.d.ts +20 -63
  39. package/lib/core/Button/Button.stories.d.ts.map +1 -1
  40. package/lib/core/Button/Button.stories.js +51 -49
  41. package/lib/core/Button/index.d.ts +54 -3
  42. package/lib/core/Button/index.d.ts.map +1 -1
  43. package/lib/core/Card/index.d.ts +14 -15
  44. package/lib/core/Card/index.d.ts.map +1 -1
  45. package/lib/core/Card/index.js +4 -3
  46. package/lib/core/Checkbox/index.d.ts +3 -3
  47. package/lib/core/Checkbox/index.d.ts.map +1 -1
  48. package/lib/core/Checkbox/index.js +32 -9
  49. package/lib/core/CollapseList/Item.d.ts +1 -1
  50. package/lib/core/CollapseList/Item.d.ts.map +1 -1
  51. package/lib/core/CollapseList/Item.js +4 -3
  52. package/lib/core/CollapseList/index.d.ts +1 -1
  53. package/lib/core/CollapseList/index.d.ts.map +1 -1
  54. package/lib/core/CollapseList/index.js +4 -3
  55. package/lib/core/CollapseList/styles.d.ts +39 -1
  56. package/lib/core/CollapseList/styles.d.ts.map +1 -1
  57. package/lib/core/Datepicker/Datepicker.stories.d.ts +6 -6
  58. package/lib/core/Datepicker/Datepicker.stories.d.ts.map +1 -1
  59. package/lib/core/Datepicker/Datepicker.stories.js +7 -6
  60. package/lib/core/DatepickerRange/DatepickerRange.stories.d.ts +6 -7
  61. package/lib/core/DatepickerRange/DatepickerRange.stories.d.ts.map +1 -1
  62. package/lib/core/DatepickerRange/DatepickerRange.stories.js +4 -3
  63. package/lib/core/Dropdown/index.d.ts.map +1 -1
  64. package/lib/core/Dropdown/index.js +0 -1
  65. package/lib/core/DropdownMenu/DropdownMenu.stories.d.ts +8 -15
  66. package/lib/core/DropdownMenu/DropdownMenu.stories.d.ts.map +1 -1
  67. package/lib/core/DropdownMenu/DropdownMenu.stories.js +34 -26
  68. package/lib/core/DropdownMenu/DropdownMenuOption.d.ts.map +1 -1
  69. package/lib/core/DropdownMenu/DropdownMenuOption.js +2 -0
  70. package/lib/core/DropdownMenu/index.d.ts.map +1 -1
  71. package/lib/core/DropdownMenu/index.js +16 -0
  72. package/lib/core/Editor/Editor.stories.d.ts +10 -23
  73. package/lib/core/Editor/Editor.stories.d.ts.map +1 -1
  74. package/lib/core/Editor/Editor.stories.js +31 -30
  75. package/lib/core/FileInput/index.d.ts +3 -1
  76. package/lib/core/FileInput/index.d.ts.map +1 -1
  77. package/lib/core/FileInput/index.js +7 -1
  78. package/lib/core/FileInput/styles.d.ts +39 -1
  79. package/lib/core/FileInput/styles.d.ts.map +1 -1
  80. package/lib/core/GoogleButton/GoogleButton.stories.d.ts +6 -7
  81. package/lib/core/GoogleButton/GoogleButton.stories.d.ts.map +1 -1
  82. package/lib/core/GoogleButton/GoogleButton.stories.js +4 -4
  83. package/lib/core/Header/Header.stories.d.ts +13 -35
  84. package/lib/core/Header/Header.stories.d.ts.map +1 -1
  85. package/lib/core/Header/Header.stories.js +42 -45
  86. package/lib/core/HighlightText/HighlightText.stories.d.ts +7 -11
  87. package/lib/core/HighlightText/HighlightText.stories.d.ts.map +1 -1
  88. package/lib/core/HighlightText/HighlightText.stories.js +11 -11
  89. package/lib/core/Image/index.d.ts +1 -0
  90. package/lib/core/Image/index.d.ts.map +1 -1
  91. package/lib/core/Image/index.js +19 -4
  92. package/lib/core/ImagePicker/ImagePicker.stories.d.ts +6 -17
  93. package/lib/core/ImagePicker/ImagePicker.stories.d.ts.map +1 -1
  94. package/lib/core/ImagePicker/ImagePicker.stories.js +2 -1
  95. package/lib/core/ImagePicker/index.d.ts.map +1 -1
  96. package/lib/core/ImagePicker/index.js +4 -0
  97. package/lib/core/ImageViewer/index.d.ts.map +1 -1
  98. package/lib/core/ImageViewer/index.js +15 -5
  99. package/lib/core/InfoButton/InfoButton.stories.d.ts +10 -23
  100. package/lib/core/InfoButton/InfoButton.stories.d.ts.map +1 -1
  101. package/lib/core/InfoButton/InfoButton.stories.js +23 -22
  102. package/lib/core/InfoButton/index.d.ts.map +1 -1
  103. package/lib/core/InfoButton/index.js +4 -0
  104. package/lib/core/InfoButton/styles.d.ts +39 -1
  105. package/lib/core/InfoButton/styles.d.ts.map +1 -1
  106. package/lib/core/Input/index.d.ts +1 -1
  107. package/lib/core/Input/index.d.ts.map +1 -1
  108. package/lib/core/Input/index.js +4 -0
  109. package/lib/core/private/ButtonOrLink.d.ts +46 -3
  110. package/lib/core/private/ButtonOrLink.d.ts.map +1 -1
  111. package/lib/core/private/ButtonOrLink.js +4 -3
  112. package/lib/layout/Footer/FooterButton/styles.d.ts +3 -3
  113. package/lib/layout/Footer/FooterLink/styles.d.ts +3 -3
  114. package/lib/layout/Menu/MenuTop/styles.d.ts +3 -3
  115. package/package.json +1 -1
  116. package/esm/core/Autocomplete/utils/useHandleOptionsHeight.js +0 -16
  117. package/esm/core/CheckboxController/index.js +0 -22
  118. package/esm/core/Datepicker/yearMonthForm.js +0 -56
  119. package/esm/core/EditorOld/config.js +0 -69
  120. package/esm/core/EditorOld/index.js +0 -147
  121. package/esm/core/EditorOld/styles.js +0 -65
  122. package/esm/core/ImageCarousel/index.js +0 -70
  123. package/esm/core/ImageCarousel/styles.js +0 -58
  124. package/esm/enums/ModifierKey.js +0 -13
  125. package/lib/core/Autocomplete/utils/useHandleOptionsHeight.d.ts +0 -7
  126. package/lib/core/Autocomplete/utils/useHandleOptionsHeight.d.ts.map +0 -1
  127. package/lib/core/Autocomplete/utils/useHandleOptionsHeight.js +0 -16
  128. package/lib/core/CheckboxController/index.d.ts +0 -1
  129. package/lib/core/CheckboxController/index.d.ts.map +0 -1
  130. package/lib/core/CheckboxController/index.js +0 -22
  131. package/lib/core/Datepicker/yearMonthForm.d.ts +0 -10
  132. package/lib/core/Datepicker/yearMonthForm.d.ts.map +0 -1
  133. package/lib/core/Datepicker/yearMonthForm.js +0 -56
  134. package/lib/core/EditorOld/config.d.ts +0 -56
  135. package/lib/core/EditorOld/config.d.ts.map +0 -1
  136. package/lib/core/EditorOld/config.js +0 -69
  137. package/lib/core/EditorOld/index.d.ts +0 -39
  138. package/lib/core/EditorOld/index.d.ts.map +0 -1
  139. package/lib/core/EditorOld/index.js +0 -147
  140. package/lib/core/EditorOld/styles.d.ts +0 -23
  141. package/lib/core/EditorOld/styles.d.ts.map +0 -1
  142. package/lib/core/EditorOld/styles.js +0 -65
  143. package/lib/core/ImageCarousel/index.d.ts +0 -11
  144. package/lib/core/ImageCarousel/index.d.ts.map +0 -1
  145. package/lib/core/ImageCarousel/index.js +0 -70
  146. package/lib/core/ImageCarousel/styles.d.ts +0 -26
  147. package/lib/core/ImageCarousel/styles.d.ts.map +0 -1
  148. package/lib/core/ImageCarousel/styles.js +0 -58
  149. package/lib/enums/ModifierKey.d.ts +0 -12
  150. package/lib/enums/ModifierKey.d.ts.map +0 -1
  151. package/lib/enums/ModifierKey.js +0 -13
@@ -62,12 +62,14 @@ const Input = /*#__PURE__*/React.forwardRef(({
62
62
  return _jsxs("div", {
63
63
  css: styles.relative,
64
64
  children: [_jsxs("label", {
65
+ htmlFor: props.id,
65
66
  css: theme => [styles.default(theme), props.highlight && styles.highligted(height), type === 'search' && styles.searchLabel(theme), (props.invalid || props.invalidMessage) && styles.invalid(theme), height && styles.height(height)],
66
67
  className: className,
67
68
  children: [props.label && _jsx("span", {
68
69
  css: info && styles.pr4,
69
70
  children: props.label
70
71
  }), _jsx("input", {
72
+ id: props.id,
71
73
  type: type,
72
74
  ...(type !== 'password' && {
73
75
  value
@@ -81,6 +83,7 @@ const Input = /*#__PURE__*/React.forwardRef(({
81
83
  maxLength: maxlength,
82
84
  ref: ref,
83
85
  name: props.name,
86
+ "aria-describedby": props.invalidMessage ? 'input-error-message' : undefined,
84
87
  css: theme => [type === 'text' && styles.text(theme), type === 'search' && styles.search(theme), type === 'password' && styles.password(theme), type === 'number' && styles.number(theme), props.disabled && styles.disabled(theme), cardInput && styles.cardInput(theme)],
85
88
  children: React.Children.map(props.children, child => {
86
89
  if (!child) {
@@ -91,6 +94,7 @@ const Input = /*#__PURE__*/React.forwardRef(({
91
94
  }), type === 'search' && _jsx(IconSearch, {}), props.invalidMessage && _jsx(IconErrorOutline, {
92
95
  size: "16px"
93
96
  }), props.invalidMessage && _jsx("span", {
97
+ id: "input-error-message",
94
98
  css: theme => [styles.errorMessage(theme), !props?.label && styles.errorMessageNoLabel],
95
99
  children: props.invalidMessage
96
100
  })]
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  export declare type ButtonOrLinkTypes = HTMLAnchorElement | HTMLButtonElement;
3
3
  export declare type Props = React.HTMLAttributes<ButtonOrLinkTypes> & {
4
- [prop: string]: unknown;
5
4
  /** Icon to display at the end the content. */
6
5
  afterIcon?: React.ReactNode;
7
6
  /** Icon to display at the start the content. */
@@ -19,10 +18,11 @@ export declare type Props = React.HTMLAttributes<ButtonOrLinkTypes> & {
19
18
  /** Callback fired when the element is released. */
20
19
  onMouseUp?: (event: React.MouseEvent<ButtonOrLinkTypes>) => void;
21
20
  /** Keypress handler, to handle any wanted eventlistener button clicks */
22
- onKeyPress?: {
21
+ onCustomKeyPress?: {
23
22
  key: string;
24
23
  action: (event: KeyboardEvent) => void;
25
24
  };
25
+ onKeyPress?: (event: KeyboardEvent) => void;
26
26
  /** Callback fired when the enter key is released. */
27
27
  onEnterKeyPress?: (event: KeyboardEvent) => void;
28
28
  /** Callback fired when the escape key is released. */
@@ -44,6 +44,49 @@ export declare type Props = React.HTMLAttributes<ButtonOrLinkTypes> & {
44
44
  /** Set tabindex */
45
45
  tabIndex?: number;
46
46
  };
47
- declare const ButtonOrLink: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<any>>;
47
+ declare const ButtonOrLink: React.ForwardRefExoticComponent<React.HTMLAttributes<ButtonOrLinkTypes> & {
48
+ /** Icon to display at the end the content. */
49
+ afterIcon?: React.ReactNode;
50
+ /** Icon to display at the start the content. */
51
+ beforeIcon?: React.ReactNode;
52
+ /** Content within the button or link. */
53
+ children: NonNullable<React.ReactNode>;
54
+ /** Whether the element is disabled. */
55
+ disabled?: boolean | undefined;
56
+ /** Render as an anchor link with a URL. */
57
+ href?: string | undefined;
58
+ /** Whether the element is loading. */
59
+ loading?: boolean | undefined;
60
+ /** Callback fired when the element is clicked. */
61
+ onClick?: ((event: React.MouseEvent<ButtonOrLinkTypes>) => void) | undefined;
62
+ /** Callback fired when the element is released. */
63
+ onMouseUp?: ((event: React.MouseEvent<ButtonOrLinkTypes>) => void) | undefined;
64
+ /** Keypress handler, to handle any wanted eventlistener button clicks */
65
+ onCustomKeyPress?: {
66
+ key: string;
67
+ action: (event: KeyboardEvent) => void;
68
+ } | undefined;
69
+ onKeyPress?: ((event: KeyboardEvent) => void) | undefined;
70
+ /** Callback fired when the enter key is released. */
71
+ onEnterKeyPress?: ((event: KeyboardEvent) => void) | undefined;
72
+ /** Callback fired when the escape key is released. */
73
+ onEscapeKeyPress?: ((event: KeyboardEvent) => void) | undefined;
74
+ /** When a link, open the target in a new window. */
75
+ openInNewWindow?: boolean | undefined;
76
+ /** Rel attribute override for if the component has an href */
77
+ rel?: string | undefined;
78
+ /** Add a data-tracking-event attribute. */
79
+ trackingEvent?: string | undefined;
80
+ /** Add a data-tracking-name attribute. */
81
+ trackingName?: string | undefined;
82
+ /** When a button, the type of button. */
83
+ type?: "button" | "submit" | "reset" | undefined;
84
+ /** Link target */
85
+ target?: string | undefined;
86
+ /** Specifies the link as a download link . */
87
+ download?: any;
88
+ /** Set tabindex */
89
+ tabIndex?: number | undefined;
90
+ } & React.RefAttributes<any>>;
48
91
  export default ButtonOrLink;
49
92
  //# sourceMappingURL=ButtonOrLink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonOrLink.d.ts","sourceRoot":"","sources":["../../../src/packages/core/private/ButtonOrLink.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAGxC,oBA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KAAK,IAAI;IACjD,oDAAoD;;IAEpD,8DAA8D;;IAE9D,2CAA2C;;IAE3C,0CAA0C;;IAE1C,yCAAyC;;IAEzC,kBAAkB;;IAElB,8CAA8C;eACnC,GAAG;IACd,mBAAmB;;6BAoHpB,CAAA;AAED,eAAe,YAAY,CAAA"}
@@ -7,7 +7,6 @@ const ButtonOrLink = /*#__PURE__*/React.forwardRef(({
7
7
  beforeIcon,
8
8
  children,
9
9
  disabled = false,
10
- flexAlign,
11
10
  href = '',
12
11
  loading = false,
13
12
  openInNewWindow = false,
@@ -22,6 +21,7 @@ const ButtonOrLink = /*#__PURE__*/React.forwardRef(({
22
21
  onMouseUp,
23
22
  onEnterKeyPress,
24
23
  onEscapeKeyPress,
24
+ onCustomKeyPress,
25
25
  onKeyPress,
26
26
  ...restProps
27
27
  }, ref) => {
@@ -44,10 +44,11 @@ const ButtonOrLink = /*#__PURE__*/React.forwardRef(({
44
44
  const handleKeyPress = event => {
45
45
  if (onEnterKeyPress && event.key === 'Enter') onEnterKeyPress(event);
46
46
  if (onEscapeKeyPress && event.key === 'Escape') onEscapeKeyPress(event);
47
- if (onKeyPress && event.key === onKeyPress.key) onKeyPress.action(event);
47
+ if (onCustomKeyPress && event.key === onCustomKeyPress.key) onCustomKeyPress.action(event);
48
+ if (onKeyPress) onKeyPress(event);
48
49
  };
49
50
  useEffect(() => {
50
- const hasKeyPressEvents = onEnterKeyPress || onEscapeKeyPress || onKeyPress;
51
+ const hasKeyPressEvents = onEnterKeyPress || onEscapeKeyPress || onKeyPress || onCustomKeyPress;
51
52
  if (!hasKeyPressEvents) return;
52
53
  window.addEventListener('keyup', handleKeyPress);
53
54
  return () => {
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  export declare const Wrapper: import("@emotion/styled").StyledComponent<import("react").HTMLAttributes<import("../../../core/private/ButtonOrLink").ButtonOrLinkTypes> & {
3
- [prop: string]: unknown;
4
3
  afterIcon?: import("react").ReactNode;
5
4
  beforeIcon?: import("react").ReactNode;
6
5
  children: string | number | boolean | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | import("react").ReactPortal;
@@ -9,17 +8,18 @@ export declare const Wrapper: import("@emotion/styled").StyledComponent<import("
9
8
  loading?: boolean | undefined;
10
9
  onClick?: ((event: import("react").MouseEvent<import("../../../core/private/ButtonOrLink").ButtonOrLinkTypes, MouseEvent>) => void) | undefined;
11
10
  onMouseUp?: ((event: import("react").MouseEvent<import("../../../core/private/ButtonOrLink").ButtonOrLinkTypes, MouseEvent>) => void) | undefined;
12
- onKeyPress?: {
11
+ onCustomKeyPress?: {
13
12
  key: string;
14
13
  action: (event: KeyboardEvent) => void;
15
14
  } | undefined;
15
+ onKeyPress?: ((event: KeyboardEvent) => void) | undefined;
16
16
  onEnterKeyPress?: ((event: KeyboardEvent) => void) | undefined;
17
17
  onEscapeKeyPress?: ((event: KeyboardEvent) => void) | undefined;
18
18
  openInNewWindow?: boolean | undefined;
19
19
  rel?: string | undefined;
20
20
  trackingEvent?: string | undefined;
21
21
  trackingName?: string | undefined;
22
- type?: "button" | "reset" | "submit" | undefined;
22
+ type?: "button" | "submit" | "reset" | undefined;
23
23
  target?: string | undefined;
24
24
  download?: any;
25
25
  tabIndex?: number | undefined;
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  export declare const Wrapper: import("@emotion/styled").StyledComponent<import("react").HTMLAttributes<import("../../../core/private/ButtonOrLink").ButtonOrLinkTypes> & {
3
- [prop: string]: unknown;
4
3
  afterIcon?: import("react").ReactNode;
5
4
  beforeIcon?: import("react").ReactNode;
6
5
  children: string | number | boolean | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | import("react").ReactPortal;
@@ -9,17 +8,18 @@ export declare const Wrapper: import("@emotion/styled").StyledComponent<import("
9
8
  loading?: boolean | undefined;
10
9
  onClick?: ((event: import("react").MouseEvent<import("../../../core/private/ButtonOrLink").ButtonOrLinkTypes, MouseEvent>) => void) | undefined;
11
10
  onMouseUp?: ((event: import("react").MouseEvent<import("../../../core/private/ButtonOrLink").ButtonOrLinkTypes, MouseEvent>) => void) | undefined;
12
- onKeyPress?: {
11
+ onCustomKeyPress?: {
13
12
  key: string;
14
13
  action: (event: KeyboardEvent) => void;
15
14
  } | undefined;
15
+ onKeyPress?: ((event: KeyboardEvent) => void) | undefined;
16
16
  onEnterKeyPress?: ((event: KeyboardEvent) => void) | undefined;
17
17
  onEscapeKeyPress?: ((event: KeyboardEvent) => void) | undefined;
18
18
  openInNewWindow?: boolean | undefined;
19
19
  rel?: string | undefined;
20
20
  trackingEvent?: string | undefined;
21
21
  trackingName?: string | undefined;
22
- type?: "button" | "reset" | "submit" | undefined;
22
+ type?: "button" | "submit" | "reset" | undefined;
23
23
  target?: string | undefined;
24
24
  download?: any;
25
25
  tabIndex?: number | undefined;
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  export declare const StyledLink: import("@emotion/styled").StyledComponent<import("react").HTMLAttributes<import("../../../core/private/ButtonOrLink").ButtonOrLinkTypes> & {
3
- [prop: string]: unknown;
4
3
  afterIcon?: import("react").ReactNode;
5
4
  beforeIcon?: import("react").ReactNode;
6
5
  children: string | number | boolean | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | import("react").ReactPortal;
@@ -9,17 +8,18 @@ export declare const StyledLink: import("@emotion/styled").StyledComponent<impor
9
8
  loading?: boolean | undefined;
10
9
  onClick?: ((event: import("react").MouseEvent<import("../../../core/private/ButtonOrLink").ButtonOrLinkTypes, MouseEvent>) => void) | undefined;
11
10
  onMouseUp?: ((event: import("react").MouseEvent<import("../../../core/private/ButtonOrLink").ButtonOrLinkTypes, MouseEvent>) => void) | undefined;
12
- onKeyPress?: {
11
+ onCustomKeyPress?: {
13
12
  key: string;
14
13
  action: (event: KeyboardEvent) => void;
15
14
  } | undefined;
15
+ onKeyPress?: ((event: KeyboardEvent) => void) | undefined;
16
16
  onEnterKeyPress?: ((event: KeyboardEvent) => void) | undefined;
17
17
  onEscapeKeyPress?: ((event: KeyboardEvent) => void) | undefined;
18
18
  openInNewWindow?: boolean | undefined;
19
19
  rel?: string | undefined;
20
20
  trackingEvent?: string | undefined;
21
21
  trackingName?: string | undefined;
22
- type?: "button" | "reset" | "submit" | undefined;
22
+ type?: "button" | "submit" | "reset" | undefined;
23
23
  target?: string | undefined;
24
24
  download?: any;
25
25
  tabIndex?: number | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbl-digital/snorre",
3
- "version": "4.0.21",
3
+ "version": "4.0.23",
4
4
  "description": "Design library for BBL Digital",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",
@@ -1,16 +0,0 @@
1
- import { createRef, useEffect, useState } from 'react';
2
-
3
- const useHandleOptionsHeight = () => {
4
- const [optionsHeight, setOptionsHeight] = useState(0);
5
- const optionsRef = /*#__PURE__*/createRef();
6
- useEffect(() => {
7
- const rect = optionsRef.current?.getBoundingClientRect();
8
- setOptionsHeight(rect?.height || 0); // eslint-disable-next-line react-hooks/exhaustive-deps
9
- }, [optionsRef.current]);
10
- return {
11
- optionsHeight,
12
- optionsRef
13
- };
14
- };
15
-
16
- export default useHandleOptionsHeight;
@@ -1,22 +0,0 @@
1
- // import React from 'react'
2
- // interface IProps {
3
- // /** Function children in which CheckBox components can be rendered. */
4
- // children: (component: React.ComponentType, values: string[], id: string) => void;
5
- // /** Unique name of the field. */
6
- // name: string,;
7
- // /** Callback that is triggered when a child CheckBox is clicked. */
8
- // onChange: (values: string[], event: React.ChangeEvent<HTMLInputElement>) => void;
9
- // /** Default checked values. */
10
- // value?: string,[];
11
- // }
12
- // const CheckboxController: React.FC<IProps> = props => {
13
- // const type: string = 'checkbox'
14
- // const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
15
- // if (props.onChange) {
16
- // props.onChange(e.target.checked)
17
- // }
18
- // }
19
- // return (
20
- // )
21
- // }
22
- // export default Checkbox
@@ -1,56 +0,0 @@
1
- import React from 'react';
2
- import { MONTHS } from '../../utils/dates';
3
- import { StyledSelect, Div } from './styles';
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- import { jsxs as _jsxs } from "react/jsx-runtime";
6
-
7
- const YearMonthForm = ({
8
- onChange,
9
- date,
10
- fromDate,
11
- toDate
12
- }) => {
13
- const months = MONTHS;
14
- const years = [];
15
-
16
- for (let i = fromDate.getFullYear(); i <= toDate.getFullYear(); i += 1) {
17
- years.push(i);
18
- }
19
-
20
- const changeMonth = e => {
21
- let newDate = date;
22
- newDate.setMonth(e.target.value);
23
- if (newDate > toDate) newDate = toDate;
24
- onChange(newDate);
25
- };
26
-
27
- const changeYear = e => {
28
- let newDate = date;
29
- newDate.setFullYear(e.target.value);
30
- if (newDate > toDate) newDate = toDate;
31
- onChange(newDate);
32
- };
33
-
34
- return /*#__PURE__*/_jsxs(Div, {
35
- className: "DayPicker-Caption",
36
- children: [/*#__PURE__*/_jsx(StyledSelect, {
37
- name: "month",
38
- onChange: changeMonth,
39
- value: date.getMonth(),
40
- children: months.map((month, i) => /*#__PURE__*/_jsx("option", {
41
- value: i,
42
- children: month
43
- }, month))
44
- }), /*#__PURE__*/_jsx(StyledSelect, {
45
- name: "year",
46
- onChange: changeYear,
47
- value: date.getFullYear(),
48
- children: years.map(year => /*#__PURE__*/_jsx("option", {
49
- value: year,
50
- children: year
51
- }, year))
52
- })]
53
- });
54
- };
55
-
56
- export default YearMonthForm;
@@ -1,69 +0,0 @@
1
- export const basicToolbar = {
2
- options: ['inline', 'list'],
3
- inline: {
4
- options: ['bold', 'italic', 'underline']
5
- }
6
- };
7
- export const richToolbar = {
8
- options: ['blockType', 'inline', 'list', 'textAlign', 'link'],
9
- inline: {
10
- options: ['bold', 'italic', 'underline']
11
- },
12
- textAlign: {
13
- options: ['left', 'center', 'right', 'justify']
14
- },
15
- blockType: {
16
- inDropdown: true,
17
- options: ['Normal', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6']
18
- },
19
- link: {
20
- showOpenOptionOnHover: true,
21
- defaultTargetOption: '_blank',
22
- options: ['link', 'unlink']
23
- }
24
- };
25
- export const htmlToEntity = (nodeName, node, createEntity) => {
26
- if (nodeName === 'a') {
27
- return createEntity('LINK', 'MUTABLE', {
28
- url: node.href
29
- });
30
- }
31
- };
32
- export const getStrippedHtml = html => {
33
- return html.replace(/<img[^>]*>/g, '');
34
- };
35
- export const editorLabels = {
36
- // Generic
37
- 'generic.add': 'Legg til',
38
- 'generic.cancel': 'Avbryt',
39
- // Inline
40
- 'components.controls.inline.bold': 'Fet',
41
- 'components.controls.inline.italic': 'Kursiv',
42
- 'components.controls.inline.underline': 'Understrek',
43
- // List
44
- 'components.controls.list.unordered': 'Punktliste',
45
- 'components.controls.list.ordered': 'Nummerliste',
46
- 'components.controls.list.indent': 'Innrykk',
47
- 'components.controls.list.outdent': 'Utrykk',
48
- // Text align
49
- 'components.controls.textAlign.left': 'Venstrejuster',
50
- 'components.controls.textAlign.center': 'Midtstill',
51
- 'components.controls.textAlign.right': 'Høyrejuster',
52
- 'components.controls.textAlign.justify': 'Blokkjuster',
53
- // Block type
54
- 'components.controls.blocktype.normal': 'Avsnitt',
55
- 'components.controls.blocktype.h1': 'Overskrift 1',
56
- 'components.controls.blocktype.h2': 'Overskrift 2',
57
- 'components.controls.blocktype.h3': 'Overskrift 3',
58
- 'components.controls.blocktype.h4': 'Overskrift 4',
59
- 'components.controls.blocktype.h5': 'Overskrift 5',
60
- 'components.controls.blocktype.h6': 'Overskrift 6',
61
- // Link
62
- 'components.controls.link.linkTitle': 'Tittel',
63
- 'components.controls.link.linkTarget': 'URL',
64
- 'components.controls.link.linkTargetOption': 'Åpne i ny fane',
65
- 'components.controls.link.link': 'Legg til lenke',
66
- 'components.controls.link.unlink': 'Fjern lenke',
67
- // Remove
68
- 'components.controls.remove.remove': 'Fjern'
69
- };
@@ -1,147 +0,0 @@
1
- /** @jsxImportSource @emotion/react */
2
- import React, { useState } from 'react';
3
- import { Editor as Wysiwyg } from 'react-draft-wysiwyg';
4
- import { convertToRaw, EditorState, Modifier } from 'draft-js';
5
- import { stateFromHTML } from 'draft-js-import-html';
6
- import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
7
- import { CounterWrapper, ErrorWrapper, Label, RelativeDiv, styles } from './styles';
8
- import { basicToolbar, editorLabels, getStrippedHtml, htmlToEntity, richToolbar } from './config';
9
- import { convertToHTML, convertFromHTML } from 'draft-convert';
10
- import Text from '../Text';
11
- import { useTheme } from '@emotion/react';
12
- import IconErrorOutline from '../../icons/General/IconErrorOutline';
13
- import draftToHtml from 'draftjs-to-html';
14
- import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
15
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
16
-
17
- /**
18
- *
19
- * TODO: REMOVE AND CLEANUP PACKAGES
20
- *
21
- */
22
- const EditorOld = ({
23
- initialValue,
24
- height = 300,
25
- maxHeight,
26
- maxlength,
27
- maxlengthType = 'plaintext',
28
- maxlengthText,
29
- withCounter,
30
- invalidMessage,
31
- label,
32
- customToolbar,
33
- type = 'basic',
34
- onChange,
35
- onBlur
36
- }) => {
37
- const theme = useTheme();
38
- const [maxlengthError, setMaxlengthError] = useState(null);
39
- const [charCount, setCharCount] = useState(0);
40
- const [editorState, setEditorState] = useState(initialValue ? EditorState.createWithContent(convertFromHTML({
41
- htmlToEntity
42
- })(initialValue)) : EditorState.createEmpty());
43
-
44
- const handleEditorChange = state => {
45
- handleValidity(state);
46
- setEditorState(state);
47
- const plainText = state.getCurrentContent().getPlainText();
48
- const html = draftToHtml(convertToRaw(state.getCurrentContent()));
49
- onChange(plainText.length > 0 ? html : ''); // return empty if no content
50
-
51
- if (withCounter && maxlength) {
52
- setCharCount(maxlengthType === 'html' ? html.length : plainText.length);
53
- }
54
- };
55
-
56
- const handleValidity = state => {
57
- if (!maxlength) {
58
- setMaxlengthError(null);
59
- return;
60
- }
61
-
62
- const plaintext = state.getCurrentContent().getPlainText();
63
- const html = convertToHTML(state.getCurrentContent());
64
-
65
- if (maxlengthType === 'html' && html.length > maxlength) {
66
- setMaxlengthError(maxlengthText ? maxlengthText : 'Text is too long');
67
- return;
68
- }
69
-
70
- if (maxlengthType === 'plaintext' && plaintext.length > maxlength) {
71
- setMaxlengthError(maxlengthText ? maxlengthText : 'Text is too long');
72
- return;
73
- }
74
-
75
- setMaxlengthError(null);
76
- };
77
-
78
- const Counter = _jsx(CounterWrapper, {
79
- children: _jsxs(Text, {
80
- children: [charCount, "/", maxlength]
81
- })
82
- });
83
-
84
- const handlePaste = (text, html, editorState, onChange) => {
85
- if (!html) return false;
86
- const strippedHtml = getStrippedHtml(html);
87
- const blockMap = stateFromHTML(strippedHtml).blockMap;
88
- const newState = Modifier.replaceWithFragment(editorState.getCurrentContent(), editorState.getSelection(), blockMap);
89
- onChange(EditorState.push(editorState, newState, 'insert-fragment'));
90
- return true;
91
- };
92
-
93
- const getToolbar = () => {
94
- switch (type) {
95
- case 'basic':
96
- return basicToolbar;
97
-
98
- case 'rich':
99
- return richToolbar;
100
-
101
- case 'custom':
102
- return customToolbar;
103
-
104
- default:
105
- return undefined;
106
- }
107
- };
108
-
109
- return _jsxs("div", {
110
- css: theme => [styles.default(theme, height), maxHeight && styles.maxHeight(maxHeight)],
111
- children: [label && _jsx(Label, {
112
- children: label
113
- }), _jsxs(RelativeDiv, {
114
- children: [_jsx(Wysiwyg, {
115
- editorState: editorState,
116
- toolbarClassName: "toolbar-wrapper",
117
- wrapperClassName: "editor-wrapper",
118
- editorClassName: "content-wrapper",
119
- onEditorStateChange: handleEditorChange,
120
- toolbar: getToolbar(),
121
- localization: {
122
- locale: 'nb_NO',
123
- translations: editorLabels
124
- },
125
- stripPastedStyles: type !== 'rich',
126
- onBlur: () => onBlur && onBlur(),
127
- handlePastedText: handlePaste
128
- }), maxlength && withCounter && Counter]
129
- }), (maxlengthError || invalidMessage) && _jsxs(ErrorWrapper, {
130
- children: [maxlengthError && _jsxs(Text, {
131
- color: theme.alert,
132
- children: [_jsx(IconErrorOutline, {
133
- size: "16px",
134
- color: theme.alert
135
- }), ' ', maxlengthError]
136
- }), invalidMessage && _jsxs(Text, {
137
- color: theme.alert,
138
- children: [_jsx(IconErrorOutline, {
139
- size: "16px",
140
- color: theme.alert
141
- }), ' ', invalidMessage]
142
- })]
143
- })]
144
- });
145
- };
146
-
147
- export default EditorOld;