@aarhus-university/au-lib-react-components 12.2.2 → 12.4.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/.eslintrc.js CHANGED
@@ -17,6 +17,7 @@ module.exports = {
17
17
  unnamedComponents: 'arrow-function',
18
18
  }],
19
19
  'react-hooks/rules-of-hooks': 'error',
20
+ 'react/require-default-props': [0],
20
21
  },
21
22
  settings: {
22
23
  react: {
@@ -1,11 +1,20 @@
1
1
  const path = require('path');
2
2
  module.exports = {
3
3
  'stories': ['../**/*.stories.mdx', '../**/*.stories.@(js|jsx|ts|tsx)'],
4
- 'addons': ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions', '@storybook/addon-a11y'],
4
+ 'addons': [
5
+ '@storybook/addon-links',
6
+ '@storybook/addon-essentials',
7
+ '@storybook/addon-interactions',
8
+ '@storybook/addon-a11y',
9
+ '@storybook/addon-webpack5-compiler-babel',
10
+ '@chromatic-com/storybook'
11
+ ],
12
+
5
13
  'framework': {
6
14
  name: '@storybook/react-webpack5',
7
15
  options: {}
8
16
  },
17
+
9
18
  webpackFinal: async config => {
10
19
  config.module.rules.push({
11
20
  test: /\.(ts|js)x?$/,
@@ -17,7 +26,10 @@ module.exports = {
17
26
  return config;
18
27
  // return { ...config, module: { ...config.module, rules: custom.module.rules } };
19
28
  },
20
- docs: {
21
- autodocs: true
29
+
30
+ docs: {},
31
+
32
+ typescript: {
33
+ reactDocgen: 'react-docgen-typescript'
22
34
  }
23
35
  };
@@ -2,7 +2,6 @@ import '@aarhus-university/au-designsystem-delphinus/public/style.css';
2
2
  import { globalTheme, globalLang } from '../stories/lib/helpers';
3
3
 
4
4
  export const parameters = {
5
- actions: { argTypesRegex: "^on[A-Z].*" },
6
5
  controls: {
7
6
  matchers: {
8
7
  color: /(background|color)$/i,
@@ -15,3 +14,4 @@ export const globalTypes = {
15
14
  theme: globalTheme.theme,
16
15
  lang: globalLang().lang,
17
16
  };
17
+ export const tags = ['autodocs'];
package/package.json CHANGED
@@ -1,120 +1,105 @@
1
- {
2
- "sideEffects": true,
3
- "name": "@aarhus-university/au-lib-react-components",
4
- "version": "12.2.2",
5
- "description": "Library for shared React components for various applications on au.dk",
6
- "scripts": {
7
- "test": "jest",
8
- "build": "jest && webpack --config ./webpack.config.js",
9
- "storybook": "storybook dev -p 6006 -h 127.0.0.1",
10
- "build-storybook": "storybook build",
11
- "chromatic": "npx chromatic --project-token=0be71d94786b",
12
- "build-js": "./esbuild.mjs"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "https://gitlab.au.dk/au-web-og-digital/au-lib-react-components"
17
- },
18
- "author": {
19
- "name": "Thomas Riis Hansen",
20
- "email": "trh@au.dk"
21
- },
22
- "devDependencies": {
23
- "@babel/core": "^7.22.5",
24
- "@babel/eslint-parser": "^7.22.5",
25
- "@babel/plugin-proposal-class-properties": "^7.18.6",
26
- "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
27
- "@babel/plugin-proposal-optional-chaining": "^7.21.0",
28
- "@babel/preset-env": "^7.22.5",
29
- "@babel/preset-react": "^7.22.5",
30
- "@babel/preset-typescript": "^7.22.5",
31
- "@mdx-js/react": "^2.3.0",
32
- "@storybook/addon-a11y": "^7.6.7",
33
- "@storybook/addon-actions": "^7.6.7",
34
- "@storybook/addon-essentials": "^7.6.7",
35
- "@storybook/addon-interactions": "^7.6.7",
36
- "@storybook/addon-links": "^7.6.7",
37
- "@storybook/jest": "^0.2.3",
38
- "@storybook/react": "^7.6.7",
39
- "@storybook/react-webpack5": "^7.6.7",
40
- "@storybook/testing-library": "^0.2.2",
41
- "@testing-library/jest-dom": "^5.16.5",
42
- "@testing-library/react": "^14.0.0",
43
- "@testing-library/user-event": "^14.4.3",
44
- "@types/jest": "^29.5.2",
45
- "@types/testing-library__jest-dom": "^5.14.6",
46
- "@typescript-eslint/eslint-plugin": "^5.60.1",
47
- "@typescript-eslint/parser": "^5.60.1",
48
- "babel-jest": "^29.5.0",
49
- "babel-loader": "^9.1.2",
50
- "chromatic": "^6.19.9",
51
- "css-loader": "^6.8.1",
52
- "eslint": "^8.44.0",
53
- "eslint-config-airbnb": "^19.0.4",
54
- "eslint-import-resolver-typescript": "^3.5.5",
55
- "eslint-plugin-import": "^2.27.5",
56
- "eslint-plugin-jsx-a11y": "^6.7.1",
57
- "eslint-plugin-react": "^7.32.2",
58
- "eslint-plugin-react-hooks": "^4.6.0",
59
- "eslint-plugin-storybook": "^0.6.15",
60
- "eslint-webpack-plugin": "^4.0.1",
61
- "fork-ts-checker-webpack-plugin": "^8.0.0",
62
- "jest": "^29.5.0",
63
- "jest-environment-jsdom": "^29.5.0",
64
- "mini-css-extract-plugin": "^2.7.6",
65
- "react-dom": "^18.2.0",
66
- "react-test-renderer": "^18.2.0",
67
- "sass": "^1.63.6",
68
- "sass-loader": "^13.3.2",
69
- "storybook": "^7.6.7",
70
- "style-loader": "^3.3.3",
71
- "ts-jest": "^29.1.1",
72
- "ts-loader": "^9.4.4",
73
- "typescript": "^5.1.6",
74
- "webpack-cli": "^5.1.4"
75
- },
76
- "dependencies": {
77
- "@aarhus-university/au-designsystem-delphinus": "1.3.3",
78
- "@aarhus-university/au-designsystem-delphinus-dev": "0.7.0",
79
- "@aarhus-university/types": "1.1.0",
80
- "@reduxjs/toolkit": "^1.9.5",
81
- "@tinymce/tinymce-react": "^4.3.2",
82
- "@types/google.analytics": "^0.0.42",
83
- "@types/react": "^18.2.14",
84
- "@types/react-dom": "^18.2.6",
85
- "@types/react-router-dom": "^5.3.3",
86
- "dayjs": "^1.11.9",
87
- "esbuild": "^0.18.11",
88
- "esbuild-sass-plugin": "^2.10.0",
89
- "lodash.debounce": "^4.0.8",
90
- "prop-types": "^15.8.1",
91
- "query-string": "^8.1.0",
92
- "react": "18.2.0",
93
- "react-autosuggest": "^10.1.0",
94
- "react-router-dom": "^6.14.1",
95
- "regenerator-runtime": "^0.13.11",
96
- "webpack": "^5.88.1",
97
- "whatwg-fetch": "^3.6.2"
98
- },
99
- "peerDependencies": {
100
- "react": "18.2.0",
101
- "react-dom": "18.2.0"
102
- },
103
- "jest": {
104
- "rootDir": "__tests__/jest",
105
- "setupFilesAfterEnv": [
106
- "./setupTests.ts"
107
- ],
108
- "transform": {
109
- "^.+\\.(ts|tsx|js|jsx)$": "ts-jest"
110
- },
111
- "testEnvironment": "jsdom",
112
- "transformIgnorePatterns": [
113
- "node_modules/(?!(@aarhus-university/au-lib-react-components|@aarhus-university/au-designsystem-delphinus|node-fetch|data-uri-to-buffer|fetch-blob|formdata-polyfill)/)"
114
- ],
115
- "testPathIgnorePatterns": [
116
- "factory.ts",
117
- "setupTests.ts"
118
- ]
119
- }
120
- }
1
+ {
2
+ "sideEffects": true,
3
+ "name": "@aarhus-university/au-lib-react-components",
4
+ "version": "12.4.0",
5
+ "description": "Library for shared React components for various applications on au.dk",
6
+ "scripts": {
7
+ "test": "jest",
8
+ "build": "jest && webpack --config ./webpack.config.js",
9
+ "storybook": "storybook dev -p 6006 -h 127.0.0.1",
10
+ "build-storybook": "storybook build",
11
+ "chromatic": "npx chromatic --project-token=0be71d94786b",
12
+ "build-js": "./esbuild.mjs"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://gitlab.au.dk/au-web-og-digital/au-lib-react-components"
17
+ },
18
+ "author": {
19
+ "name": "Thomas Riis Hansen",
20
+ "email": "trh@au.dk"
21
+ },
22
+ "devDependencies": {
23
+ "@babel/core": "^7.22.5",
24
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
25
+ "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
26
+ "@babel/plugin-proposal-optional-chaining": "^7.21.0",
27
+ "@babel/preset-env": "^7.22.5",
28
+ "@babel/preset-react": "^7.22.5",
29
+ "@babel/preset-typescript": "^7.22.5",
30
+ "@chromatic-com/storybook": "^1.6.1",
31
+ "@storybook/addon-a11y": "^8.2.1",
32
+ "@storybook/addon-essentials": "^8.2.1",
33
+ "@storybook/addon-interactions": "^8.2.1",
34
+ "@storybook/addon-links": "^8.2.1",
35
+ "@storybook/addon-webpack5-compiler-babel": "^3.0.3",
36
+ "@storybook/react": "^8.2.1",
37
+ "@testing-library/jest-dom": "^5.16.5",
38
+ "@testing-library/react": "^14.0.0",
39
+ "@types/testing-library__jest-dom": "^5.14.6",
40
+ "@typescript-eslint/eslint-plugin": "^5.60.1",
41
+ "@typescript-eslint/parser": "^5.60.1",
42
+ "babel-jest": "^29.5.0",
43
+ "babel-loader": "^9.1.2",
44
+ "chromatic": "^6.19.9",
45
+ "css-loader": "^6.8.1",
46
+ "eslint": "^8.44.0",
47
+ "eslint-config-airbnb": "^19.0.4",
48
+ "eslint-import-resolver-typescript": "^3.5.5",
49
+ "eslint-plugin-import": "^2.27.5",
50
+ "eslint-plugin-jsx-a11y": "^6.7.1",
51
+ "eslint-plugin-react": "^7.32.2",
52
+ "eslint-plugin-react-hooks": "^4.6.0",
53
+ "eslint-plugin-storybook": "^0.8.0",
54
+ "eslint-webpack-plugin": "^4.0.1",
55
+ "fork-ts-checker-webpack-plugin": "^8.0.0",
56
+ "jest": "^29.5.0",
57
+ "mini-css-extract-plugin": "^2.7.6",
58
+ "react-dom": "18.3.1",
59
+ "sass": "^1.63.6",
60
+ "sass-loader": "^13.3.2",
61
+ "storybook": "^8.2.1",
62
+ "ts-jest": "^29.1.1",
63
+ "typescript": "^5.1.6",
64
+ "wicg-inert": "^3.1.2"
65
+ },
66
+ "dependencies": {
67
+ "@aarhus-university/au-designsystem-delphinus": "^1.7.8",
68
+ "@aarhus-university/types": "^1.1.0",
69
+ "@reduxjs/toolkit": "^1.9.5",
70
+ "@storybook/react-webpack5": "^8.2.1",
71
+ "@tinymce/tinymce-react": "^5.1.1",
72
+ "@types/react": "^18.2.14",
73
+ "@types/react-dom": "^18.2.6",
74
+ "@types/react-router-dom": "^5.3.3",
75
+ "dayjs": "^1.11.9",
76
+ "esbuild": "^0.18.11",
77
+ "esbuild-sass-plugin": "^2.10.0",
78
+ "lodash.debounce": "^4.0.8",
79
+ "prop-types": "^15.8.1",
80
+ "query-string": "^8.1.0",
81
+ "react": "^18.3.1",
82
+ "react-autosuggest": "^10.1.0",
83
+ "react-router-dom": "^6.14.1",
84
+ "regenerator-runtime": "^0.13.11",
85
+ "webpack": "^5.88.1",
86
+ "whatwg-fetch": "^3.6.2"
87
+ },
88
+ "jest": {
89
+ "rootDir": "__tests__/jest",
90
+ "setupFilesAfterEnv": [
91
+ "./setupTests.ts"
92
+ ],
93
+ "transform": {
94
+ "^.+\\.(ts|tsx|js|jsx)$": "ts-jest"
95
+ },
96
+ "testEnvironment": "jsdom",
97
+ "transformIgnorePatterns": [
98
+ "node_modules/(?!(@aarhus-university/au-lib-react-components|@aarhus-university/au-designsystem-delphinus|node-fetch|data-uri-to-buffer|fetch-blob|formdata-polyfill)/)"
99
+ ],
100
+ "testPathIgnorePatterns": [
101
+ "factory.ts",
102
+ "setupTests.ts"
103
+ ]
104
+ }
105
+ }
@@ -24,19 +24,25 @@ type Props = {
24
24
 
25
25
  const AUButtonComponent: FC<Props> = ({
26
26
  label,
27
- disabled,
28
- size,
29
- type,
30
- icon,
31
- iconPosition,
32
- hideLabel,
33
- mode,
27
+ disabled = false,
28
+ size = 'default',
29
+ type = 'default',
30
+ icon = '',
31
+ iconPosition = 'left',
32
+ hideLabel = false,
33
+ mode = 'none',
34
34
  btnRef,
35
- classNames,
36
- ariaExpanded,
37
- ariaHasPopup,
38
- asSubmit,
39
- onClick,
35
+ classNames = [],
36
+ ariaExpanded = false,
37
+ ariaHasPopup = undefined,
38
+ asSubmit = false,
39
+ onClick = (
40
+ event: MouseEvent<HTMLButtonElement>,
41
+ ref: RefObject<HTMLButtonElement> | undefined,
42
+ ) => {
43
+ // eslint-disable-next-line no-console
44
+ console.log(event, ref);
45
+ },
40
46
  }) => {
41
47
  const sizeClass = size === 'default' ? '' : `button--${size}`;
42
48
  const typeClass = type === 'default' ? '' : `button--${type}`;
@@ -83,27 +89,6 @@ const AUButtonComponent: FC<Props> = ({
83
89
  );
84
90
  };
85
91
 
86
- AUButtonComponent.defaultProps = {
87
- disabled: false,
88
- size: 'default',
89
- type: 'default',
90
- icon: '',
91
- iconPosition: 'left',
92
- hideLabel: false,
93
- mode: 'none',
94
- classNames: [],
95
- ariaExpanded: false,
96
- ariaHasPopup: undefined,
97
- asSubmit: false,
98
- // eslint-disable-next-line no-console
99
- onClick: (
100
- event: MouseEvent<HTMLButtonElement>,
101
- ref: RefObject<HTMLButtonElement> | undefined,
102
- // eslint-disable-next-line no-console
103
- ) => console.log(event, ref),
104
- btnRef: undefined,
105
- };
106
-
107
92
  AUButtonComponent.displayName = 'AUButtonComponent';
108
93
  export default AUButtonComponent;
109
94
 
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
1
2
  import React, { useState, FC } from 'react';
2
3
  import dayjs from 'dayjs';
3
4
  import 'dayjs/locale/da';
@@ -109,24 +110,24 @@ type Props = {
109
110
  };
110
111
 
111
112
  const AUCalendarComponent: FC<Props> = ({
112
- lang,
113
+ lang = 'da',
113
114
  day,
114
115
  month,
115
116
  year,
116
117
  hour,
117
118
  minute,
118
- selected,
119
+ selected = new Date(),
119
120
  onSelected,
120
- highlightWeekend,
121
- highlightHolidays,
122
- yearSpanMinus,
123
- yearSpanPlus,
124
- minuteInterval,
125
- showTime,
126
- closeable,
127
- onClose,
128
- limitStart,
129
- limitEnd,
121
+ highlightWeekend = true,
122
+ highlightHolidays = true,
123
+ yearSpanMinus = 5,
124
+ yearSpanPlus = 5,
125
+ minuteInterval = 5,
126
+ showTime = true,
127
+ closeable = false,
128
+ onClose = () => { },
129
+ limitStart = null,
130
+ limitEnd = null,
130
131
  controls,
131
132
  }) => {
132
133
  dayjs.locale(lang);
@@ -492,22 +493,5 @@ const AUCalendarComponent: FC<Props> = ({
492
493
  );
493
494
  };
494
495
 
495
- AUCalendarComponent.defaultProps = {
496
- lang: 'da',
497
- selected: new Date(),
498
- // eslint-disable-next-line no-console
499
- highlightWeekend: true,
500
- highlightHolidays: true,
501
- yearSpanMinus: 5,
502
- yearSpanPlus: 5,
503
- minuteInterval: 5,
504
- showTime: true,
505
- closeable: false,
506
- // eslint-disable-next-line @typescript-eslint/no-empty-function
507
- onClose: () => { },
508
- limitStart: null,
509
- limitEnd: null,
510
- };
511
-
512
496
  AUCalendarComponent.displayName = 'AUCalendarComponent';
513
497
  export default AUCalendarComponent;
@@ -44,7 +44,7 @@ const AUComboBoxComponent: FC<Props> = ({
44
44
  resultsText,
45
45
  noResultsText,
46
46
  noResultsTextSecondary,
47
- clearOnSelect,
47
+ clearOnSelect = false,
48
48
  onItemSelect,
49
49
  }) => {
50
50
  const comboBoxRef = useRef<HTMLDivElement>(null);
@@ -191,9 +191,5 @@ const AUComboBoxComponent: FC<Props> = ({
191
191
  );
192
192
  };
193
193
 
194
- AUComboBoxComponent.defaultProps = {
195
- clearOnSelect: false,
196
- };
197
-
198
194
  AUComboBoxComponent.displayName = 'AUComboBoxComponent';
199
195
  export default AUComboBoxComponent;
@@ -7,20 +7,20 @@ import { setContentToggle } from '@aarhus-university/au-designsystem-delphinus/s
7
7
 
8
8
  type Props = {
9
9
  toggled: boolean;
10
- classNames?: string | undefined;
10
+ classNames?: string;
11
11
  children: JSX.Element;
12
- onClick?: ((content: HTMLElement, button: HTMLButtonElement) => void) | undefined;
13
- beforeCallback?: ((content: HTMLElement, button: HTMLButtonElement) => void) | undefined;
14
- afterCallback?: ((content: HTMLElement, button: HTMLButtonElement) => void) | undefined;
12
+ onClick?: ((content: HTMLElement, button: HTMLButtonElement) => void);
13
+ beforeCallback?: ((content: HTMLElement, button: HTMLButtonElement) => void);
14
+ afterCallback?: ((content: HTMLElement, button: HTMLButtonElement) => void);
15
15
  };
16
16
 
17
17
  const AUContentToggleComponent: FC<Props> = ({
18
18
  toggled,
19
- classNames,
19
+ classNames = undefined,
20
20
  children,
21
- onClick,
22
- beforeCallback,
23
- afterCallback,
21
+ onClick = undefined,
22
+ beforeCallback = undefined,
23
+ afterCallback = undefined,
24
24
  }) => {
25
25
  const toggleContainer = useRef<HTMLDivElement>(null);
26
26
  useEffect(() => {
@@ -46,12 +46,5 @@ const AUContentToggleComponent: FC<Props> = ({
46
46
  );
47
47
  };
48
48
 
49
- AUContentToggleComponent.defaultProps = {
50
- classNames: undefined,
51
- beforeCallback: undefined,
52
- afterCallback: undefined,
53
- onClick: undefined,
54
- };
55
-
56
49
  AUContentToggleComponent.displayName = 'AUContentToggleComponent';
57
50
  export default AUContentToggleComponent;
@@ -25,22 +25,22 @@ type Props = {
25
25
 
26
26
  const AUDatepickerComponent: FC<Props> = ({
27
27
  id,
28
- lang,
29
- date,
28
+ lang = 'da',
29
+ date = new Date(),
30
30
  onDateChange,
31
31
  onHide,
32
- format,
33
- showTime,
34
- showLabel,
35
- labelInline,
36
- labelText,
37
- fullWidth,
38
- yearSpanMinus,
39
- yearSpanPlus,
40
- limitStart,
41
- limitEnd,
42
- disabled,
43
- sideBySideGrowth,
32
+ format = 'YYYY-MM-DD HH:mm',
33
+ showTime = true,
34
+ showLabel = false,
35
+ labelInline = false,
36
+ labelText = 'Vælg dato:',
37
+ fullWidth = true,
38
+ yearSpanMinus = 5,
39
+ yearSpanPlus = 5,
40
+ limitStart = null,
41
+ limitEnd = null,
42
+ disabled = false,
43
+ sideBySideGrowth = 0,
44
44
  }) => {
45
45
  const [showCalendar, setShowCalendar] = useState(false);
46
46
  const [sDate, setDate] = useState<Date>(date as Date);
@@ -120,22 +120,5 @@ const AUDatepickerComponent: FC<Props> = ({
120
120
  );
121
121
  };
122
122
 
123
- AUDatepickerComponent.defaultProps = {
124
- date: new Date(),
125
- format: 'YYYY-MM-DD HH:mm',
126
- showTime: true,
127
- lang: 'da',
128
- showLabel: false,
129
- labelInline: false,
130
- labelText: 'Vælg dato:',
131
- fullWidth: true,
132
- yearSpanMinus: 5,
133
- yearSpanPlus: 5,
134
- limitStart: null,
135
- limitEnd: null,
136
- disabled: false,
137
- sideBySideGrowth: 0,
138
- };
139
-
140
123
  AUDatepickerComponent.displayName = 'AUDatepickerComponent';
141
124
  export default AUDatepickerComponent;
@@ -55,9 +55,9 @@ const AUEditorComponent: FC<Props> = ({
55
55
  id,
56
56
  initialValue,
57
57
  textareaName,
58
- showCounter,
59
- counterType,
60
- maxChars,
58
+ showCounter = false,
59
+ counterType = 'recommended',
60
+ maxChars = 0,
61
61
  translations,
62
62
  onEditorChange,
63
63
  }) => {
@@ -113,11 +113,5 @@ const AUEditorComponent: FC<Props> = ({
113
113
  );
114
114
  };
115
115
 
116
- AUEditorComponent.defaultProps = {
117
- showCounter: false,
118
- counterType: 'recommended',
119
- maxChars: 0,
120
- };
121
-
122
116
  AUEditorComponent.displayName = 'AUEditorComponent';
123
117
  export default AUEditorComponent;
@@ -11,10 +11,10 @@ type Props = {
11
11
  };
12
12
 
13
13
  const AUErrorComponent: FC<Props> = ({
14
- error: auError,
15
- fetchError,
16
- serializedError,
17
- withStatus,
14
+ error: auError = undefined,
15
+ fetchError = undefined,
16
+ serializedError = undefined,
17
+ withStatus = false,
18
18
  }) => {
19
19
  if (auError) {
20
20
  const { status, header, message } = auError;
@@ -67,14 +67,5 @@ const AUErrorComponent: FC<Props> = ({
67
67
  return null;
68
68
  };
69
69
 
70
- AUErrorComponent.defaultProps = {
71
- // eslint-disable-next-line react/default-props-match-prop-types
72
- error: undefined,
73
- fetchError: undefined,
74
- serializedError: undefined,
75
- // eslint-disable-next-line react/default-props-match-prop-types
76
- withStatus: false,
77
- };
78
-
79
70
  AUErrorComponent.displayName = 'AUErrorComponent';
80
71
  export default AUErrorComponent;
@@ -20,11 +20,11 @@ type Props = {
20
20
  };
21
21
 
22
22
  const AUModalComponent: FC<Props> = ({
23
- lang,
24
- domId,
25
- className,
23
+ lang = 'da',
24
+ domId = 'modal-view1',
25
+ className = 'modal-view',
26
26
  children,
27
- closeButton,
27
+ closeButton = true,
28
28
  closeButtonDisabled,
29
29
  sender,
30
30
  show,
@@ -68,12 +68,5 @@ const AUModalComponent: FC<Props> = ({
68
68
  );
69
69
  };
70
70
 
71
- AUModalComponent.defaultProps = {
72
- domId: 'modal-view1',
73
- closeButton: true,
74
- lang: 'da',
75
- className: 'modal-view',
76
- };
77
-
78
71
  AUModalComponent.displayName = 'AUModalComponent';
79
72
  export default AUModalComponent;
@@ -10,11 +10,11 @@ type Props = {
10
10
  };
11
11
 
12
12
  const AUNotificationComponent: FC<Props> = ({
13
- header,
13
+ header = null,
14
14
  content,
15
- actions,
16
- type,
17
- classNames,
15
+ actions = [],
16
+ type = 'information',
17
+ classNames = [],
18
18
  }) => {
19
19
  const typeClass = type === 'information' ? '' : `notification--${type}`;
20
20
  return (
@@ -40,12 +40,5 @@ const AUNotificationComponent: FC<Props> = ({
40
40
  );
41
41
  };
42
42
 
43
- AUNotificationComponent.defaultProps = {
44
- header: null,
45
- actions: [],
46
- type: 'information',
47
- classNames: [],
48
- };
49
-
50
43
  AUNotificationComponent.displayName = 'AUNotificationComponent';
51
44
  export default AUNotificationComponent;
@@ -9,9 +9,9 @@ type Props = {
9
9
 
10
10
  const AUReceiptComponent: FC<Props> = ({
11
11
  receiptText,
12
- helpText,
13
- showGoTo,
14
- buttons,
12
+ helpText = null,
13
+ showGoTo = true,
14
+ buttons = [],
15
15
  }) => {
16
16
  const renderButtons = (buttons || []).map((btn) => <a key={btn.gotoLink} href={btn.gotoLink} className="button">{btn.gotoText}</a>);
17
17
  return (
@@ -30,11 +30,5 @@ const AUReceiptComponent: FC<Props> = ({
30
30
  );
31
31
  };
32
32
 
33
- AUReceiptComponent.defaultProps = {
34
- showGoTo: true,
35
- helpText: null,
36
- buttons: [],
37
- };
38
-
39
33
  AUReceiptComponent.displayName = 'AUReceiptComponent';
40
34
  export default AUReceiptComponent;
@@ -12,9 +12,9 @@ type Props = {
12
12
 
13
13
  const AUSpinnerComponent: FC<Props> = ({
14
14
  loaded,
15
- init,
16
- height,
17
- className,
15
+ init = '',
16
+ height = 'auto',
17
+ className = '',
18
18
  children,
19
19
  }) => {
20
20
  let classNames = 'processing-state';
@@ -36,11 +36,5 @@ const AUSpinnerComponent: FC<Props> = ({
36
36
  return children;
37
37
  };
38
38
 
39
- AUSpinnerComponent.defaultProps = {
40
- className: '',
41
- height: 'auto',
42
- init: '',
43
- };
44
-
45
39
  AUSpinnerComponent.displayName = 'AUSpinnerComponent';
46
40
  export default AUSpinnerComponent;
@@ -21,8 +21,8 @@ type Props = {
21
21
  step: number;
22
22
  children: JSX.Element[];
23
23
  stepHeadlines: string[];
24
- introElement?: JSX.Element | undefined;
25
- outroElement?: JSX.Element | undefined;
24
+ introElement?: JSX.Element;
25
+ outroElement?: JSX.Element;
26
26
  showFinal?: boolean;
27
27
  finalIcon?: string;
28
28
  title: string;
@@ -34,11 +34,11 @@ const AUStepComponent: FC<Props> = ({
34
34
  step,
35
35
  children,
36
36
  stepHeadlines,
37
- introElement,
38
- outroElement,
39
- showFinal,
40
- finalIcon,
41
- showSteps,
37
+ introElement = undefined,
38
+ outroElement = undefined,
39
+ showFinal = false,
40
+ finalIcon = '',
41
+ showSteps = true,
42
42
  }) => (
43
43
  <div className="stepper">
44
44
  <h1 className="stepper__step-title">{title}</h1>
@@ -71,13 +71,5 @@ const AUStepComponent: FC<Props> = ({
71
71
  </div>
72
72
  );
73
73
 
74
- AUStepComponent.defaultProps = {
75
- introElement: undefined,
76
- outroElement: undefined,
77
- showFinal: false,
78
- showSteps: true,
79
- finalIcon: '',
80
- };
81
-
82
74
  AUStepComponent.displayName = 'AUStepComponent';
83
75
  export default AUStepComponent;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
1
2
  /* eslint-env browser */
2
3
  /* eslint-disable max-len */
3
4
  import React, { useEffect, useRef, FC } from 'react';
@@ -48,16 +49,16 @@ type Props = {
48
49
  };
49
50
 
50
51
  const AUTabbedContentComponent: FC<Props> = ({
51
- tabKey,
52
+ tabKey = 0,
52
53
  tabs,
53
- tabContent,
54
- children,
55
- focus,
56
- initial,
57
- lang,
58
- callback,
59
- withRouter,
60
- classNames,
54
+ tabContent = null,
55
+ children = null,
56
+ focus = true,
57
+ initial = 0,
58
+ lang = 'da',
59
+ callback = () => { },
60
+ withRouter = false,
61
+ classNames = 'tabbed-content',
61
62
  }) => {
62
63
  const tabsElement = useRef<HTMLDivElement>(null);
63
64
 
@@ -147,18 +148,5 @@ const AUTabbedContentComponent: FC<Props> = ({
147
148
  );
148
149
  };
149
150
 
150
- AUTabbedContentComponent.defaultProps = {
151
- tabKey: 0,
152
- children: null,
153
- tabContent: null,
154
- focus: true,
155
- initial: 0,
156
- lang: 'da',
157
- // eslint-disable-next-line @typescript-eslint/no-empty-function
158
- callback: () => { },
159
- withRouter: false,
160
- classNames: 'tabbed-content',
161
- };
162
-
163
151
  AUTabbedContentComponent.displayName = 'AUTabbedContentComponent';
164
152
  export default AUTabbedContentComponent;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
1
2
  /* eslint-env browser */
2
3
  import React, {
3
4
  useEffect, useLayoutEffect, useRef, FC,
@@ -16,9 +17,9 @@ type Props = {
16
17
 
17
18
  const AUToastComponent: FC<Props> = ({
18
19
  message: pMessage,
19
- buttonText,
20
- dismiss,
21
- onOpen,
20
+ buttonText = 'OK',
21
+ dismiss = () => { },
22
+ onOpen = () => { },
22
23
  }) => {
23
24
  const { type, message, header } = pMessage;
24
25
  const toastRef = useRef<HTMLDivElement>(null);
@@ -99,13 +100,5 @@ const AUToastComponent: FC<Props> = ({
99
100
  );
100
101
  };
101
102
 
102
- AUToastComponent.defaultProps = {
103
- buttonText: 'OK',
104
- // eslint-disable-next-line @typescript-eslint/no-empty-function
105
- dismiss: () => { },
106
- // eslint-disable-next-line @typescript-eslint/no-empty-function
107
- onOpen: () => { },
108
- };
109
-
110
103
  AUToastComponent.displayName = 'AUToastComponent';
111
104
  export default AUToastComponent;
@@ -19,12 +19,12 @@ type Props = {
19
19
  const AUToolbarComponent: FC<Props> = ({
20
20
  lang,
21
21
  elements,
22
- noCollapse,
23
- center,
24
- title,
25
- buttonClass,
26
- buttonElements,
27
- onCloseContentToggles,
22
+ noCollapse = false,
23
+ center = false,
24
+ title = undefined,
25
+ buttonClass = 'toolbar__toggle',
26
+ buttonElements = [],
27
+ onCloseContentToggles = undefined,
28
28
  }) => {
29
29
  const toolbarRef = useRef<HTMLDivElement>(null);
30
30
  useEffect(() => {
@@ -104,14 +104,5 @@ const AUToolbarComponent: FC<Props> = ({
104
104
  );
105
105
  };
106
106
 
107
- AUToolbarComponent.defaultProps = {
108
- noCollapse: false,
109
- center: false,
110
- title: undefined,
111
- buttonClass: 'toolbar__toggle',
112
- buttonElements: [],
113
- onCloseContentToggles: undefined,
114
- };
115
-
116
107
  AUToolbarComponent.displayName = 'AUToolbarComponent';
117
108
  export default AUToolbarComponent;
@@ -8,19 +8,19 @@ const getMaxLinesStyle = (maxLines: number): React.CSSProperties => ({ '--max-li
8
8
 
9
9
  type Props = {
10
10
  maxLines: number;
11
- header?: string | undefined;
11
+ header?: string;
12
12
  headerLevel?: number;
13
- children: string | JSX.Element | JSX.Element[] | undefined;
14
- classNames?: string | undefined;
13
+ children: string | JSX.Element | JSX.Element[];
14
+ classNames?: string;
15
15
  buttonChild: JSX.Element;
16
16
  };
17
17
 
18
18
  const AUTruncatorComponent: FC<Props> = ({
19
19
  maxLines,
20
- header,
21
- headerLevel,
20
+ header = undefined,
21
+ headerLevel = 2,
22
22
  children,
23
- classNames,
23
+ classNames = 'truncator',
24
24
  buttonChild,
25
25
  }) => {
26
26
  const expandRef = useRef<HTMLButtonElement>(null);
@@ -123,11 +123,5 @@ const AUTruncatorComponent: FC<Props> = ({
123
123
  );
124
124
  };
125
125
 
126
- AUTruncatorComponent.defaultProps = {
127
- header: undefined,
128
- headerLevel: 2,
129
- classNames: 'truncator',
130
- };
131
-
132
126
  AUTruncatorComponent.displayName = 'AUTruncatorComponent';
133
127
  export default AUTruncatorComponent;
@@ -1,32 +1,7 @@
1
1
  import React from 'react';
2
2
  import { StoryObj, Meta } from '@storybook/react';
3
3
  import AUCharacterCountComponent from '../src/components/AUCharacterCountComponent';
4
- import { ThemeWrapper } from './lib/helpers';
5
-
6
- export const translations = {
7
- character_count: {
8
- overflow: {
9
- message: {
10
- recommended: 'Vi anbefaler, at du maksimalt skriver {{maxchars}} tegn.',
11
- allowed: 'Du må maks. skrive {{maxchars}} tegn.'
12
- },
13
- count: {
14
- recommended: {
15
- one: 'Du har skrevet 1 tegn mere end anbefalet.',
16
- other: 'Du har skrevet {{overflow}} tegn mere end anbefalet.'
17
- },
18
- allowed: {
19
- one: 'Du har skrevet 1 tegn for meget.',
20
- other: 'Du har skrevet {{overflow}} tegn for meget.'
21
- }
22
- }
23
- },
24
- count_down: {
25
- one: 'Du har 1 tegn tilbage',
26
- other: 'Du har {{remaining}} tegn tilbage'
27
- }
28
- },
29
- };
4
+ import { ThemeWrapper, translations } from './lib/helpers';
30
5
 
31
6
  export default {
32
7
  title: 'Delphinus/Character Count',
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import { StoryObj, Meta } from '@storybook/react';
3
3
  import AUEditorComponent from '../src/components/AUEditorComponent';
4
- import { ThemeWrapper } from './lib/helpers';
5
- import { translations } from './AUCharacterCountComponent.stories';
4
+ import { ThemeWrapper, translations } from './lib/helpers';
6
5
 
7
6
  export default {
8
7
  title: 'Delphinus/Editor',
@@ -29,7 +29,7 @@ const globalLang = (items = ['da', 'en'], defaultValue = 'da') => ({
29
29
  },
30
30
  });
31
31
 
32
- const ThemeWrapper = ({ theme, children, withPageContentBlock }) => {
32
+ const ThemeWrapper = ({ theme, children, withPageContentBlock = true }) => {
33
33
  useEffect(() => {
34
34
  const body = document.querySelector('body');
35
35
  if (body) {
@@ -64,10 +64,6 @@ const ThemeWrapper = ({ theme, children, withPageContentBlock }) => {
64
64
  );
65
65
  }
66
66
 
67
- ThemeWrapper.defaultProps = {
68
- withPageContentBlock: true,
69
- };
70
-
71
67
  const ThemeLanguageWrapper = ({
72
68
  theme,
73
69
  children,
@@ -75,7 +71,7 @@ const ThemeLanguageWrapper = ({
75
71
  importPromises,
76
72
  translationContext,
77
73
  lang,
78
- withPageContentBlock,
74
+ withPageContentBlock = true,
79
75
  }) => {
80
76
  const translations = useTranslation<typeof defaultLabels>(defaultLabels, importPromises, lang);
81
77
  useEffect(() => {
@@ -116,8 +112,29 @@ const ThemeLanguageWrapper = ({
116
112
  );
117
113
  }
118
114
 
119
- ThemeLanguageWrapper.defaultProps = {
120
- withPageContentBlock: true,
115
+ const translations = {
116
+ character_count: {
117
+ overflow: {
118
+ message: {
119
+ recommended: 'Vi anbefaler, at du maksimalt skriver {{maxchars}} tegn.',
120
+ allowed: 'Du må maks. skrive {{maxchars}} tegn.'
121
+ },
122
+ count: {
123
+ recommended: {
124
+ one: 'Du har skrevet 1 tegn mere end anbefalet.',
125
+ other: 'Du har skrevet {{overflow}} tegn mere end anbefalet.'
126
+ },
127
+ allowed: {
128
+ one: 'Du har skrevet 1 tegn for meget.',
129
+ other: 'Du har skrevet {{overflow}} tegn for meget.'
130
+ }
131
+ }
132
+ },
133
+ count_down: {
134
+ one: 'Du har 1 tegn tilbage',
135
+ other: 'Du har {{remaining}} tegn tilbage'
136
+ }
137
+ },
121
138
  };
122
139
 
123
140
  export {
@@ -125,4 +142,5 @@ export {
125
142
  globalLang,
126
143
  ThemeWrapper,
127
144
  ThemeLanguageWrapper,
145
+ translations,
128
146
  };