@aarhus-university/au-lib-react-components 12.6.2 → 12.6.3
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 +35 -35
- package/.storybook/main.js +34 -34
- package/.storybook/preview.js +17 -17
- package/README.md +19 -19
- package/__tests__/jest/AUButtonComponent.test.tsx +165 -165
- package/__tests__/jest/AUDynamicContentComponent.test.tsx +386 -386
- package/__tests__/jest/AUErrorComponent.test.tsx +142 -142
- package/__tests__/jest/AUModalComponent.test.tsx +186 -186
- package/__tests__/jest/AUNotificationComponent.test.tsx +115 -115
- package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -57
- package/__tests__/jest/AUToolbarComponent.test.tsx +46 -46
- package/__tests__/jest/context.test.ts +25 -25
- package/__tests__/jest/helpers.test.ts +15 -15
- package/__tests__/jest/setupTests.ts +2 -2
- package/babel.config.js +8 -8
- package/build/umd/all.css +2 -2
- package/build/umd/all.js +1 -1
- package/build/umd/alphabox.js +1 -1
- package/build/umd/databox.js +1 -1
- package/build/umd/diagramme.js +1 -1
- package/build/umd/flowbox.js +1 -1
- package/build/umd/flowbox.js.map +1 -1
- package/build/umd/universe.js +1 -1
- package/build-storybook.log +386 -386
- package/esbuild.mjs +22 -22
- package/package.json +107 -107
- package/src/components/AUAlertComponent.tsx +128 -128
- package/src/components/AUAutoSuggestComponent.js +148 -148
- package/src/components/AUButtonComponent.tsx +99 -99
- package/src/components/AUCalendarComponent.tsx +497 -497
- package/src/components/AUCharacterCountComponent.tsx +56 -56
- package/src/components/AUComboBoxComponent.tsx +195 -195
- package/src/components/AUContentToggleComponent.tsx +50 -50
- package/src/components/AUDatepickerComponent.tsx +124 -124
- package/src/components/AUDialogModalComponent.tsx +124 -124
- package/src/components/AUDynamicContentComponent.tsx +137 -137
- package/src/components/AUEditorComponent.tsx +126 -126
- package/src/components/AUErrorComponent.tsx +73 -73
- package/src/components/AUMobilePrefixComponent.tsx +20 -20
- package/src/components/AUModalComponent.tsx +72 -72
- package/src/components/AUNotificationComponent.tsx +44 -44
- package/src/components/AUReceiptComponent.tsx +34 -34
- package/src/components/AUSpinnerComponent.tsx +40 -40
- package/src/components/AUStepComponent.tsx +75 -75
- package/src/components/AUSubNavComponent.tsx +57 -57
- package/src/components/AUSubmitButtonContainerComponent.tsx +38 -38
- package/src/components/AUTabbedContentComponent.tsx +154 -154
- package/src/components/AUTableComponent.tsx +29 -29
- package/src/components/AUToastComponent.tsx +104 -104
- package/src/components/AUToolbarComponent.tsx +108 -108
- package/src/components/AUTruncatorComponent.tsx +141 -141
- package/src/components/wrapping/AUEmbedComponent.js +47 -47
- package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +142 -142
- package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
- package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
- package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
- package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
- package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
- package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
- package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
- package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
- package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
- package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
- package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
- package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
- package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
- package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
- package/src/layout-2016/lib/all.js +3 -3
- package/src/layout-2016/lib/au-alphabox.js +99 -99
- package/src/layout-2016/lib/au-databox.js +399 -399
- package/src/layout-2016/lib/au-diagramme.js +85 -85
- package/src/layout-2016/lib/au-flowbox.js +116 -119
- package/src/lib/context.tsx +59 -59
- package/src/lib/dates.ts +52 -52
- package/src/lib/helpers.ts +208 -208
- package/src/lib/hooks.ts +157 -157
- package/src/lib/i18n.ts +600 -600
- package/src/lib/portals.tsx +150 -150
- package/src/lib/tinymce.ts +84 -84
- package/src/lib/wrapping.ts +21 -21
- package/src/styles/_settings.scss +10 -10
- package/src/styles/alphabox.scss +222 -222
- package/src/styles/app.scss +7 -7
- package/src/styles/autosuggest.scss +57 -57
- package/src/styles/databox.scss +563 -563
- package/src/styles/diagramme.scss +119 -119
- package/src/styles/flowbox.scss +72 -72
- package/src/styles/maps.scss +395 -395
- package/stories/AUAlertComponent.stories.tsx +133 -133
- package/stories/AUAutoSuggestComponent.stories.tsx +95 -95
- package/stories/AUButtonComponent.stories.tsx +139 -139
- package/stories/AUCharacterCountComponent.stories.tsx +121 -121
- package/stories/AUComboBoxComponent.stories.tsx +101 -101
- package/stories/AUContentToggleComponent.stories.tsx +87 -87
- package/stories/AUDialogModalComponent.stories.tsx +75 -75
- package/stories/AUDynamicContentComponent.stories.tsx +119 -119
- package/stories/AUEditorComponent.stories.tsx +66 -66
- package/stories/AUErrorComponent.stories.tsx +132 -132
- package/stories/AUModalComponent.stories.tsx +160 -160
- package/stories/AUNotificationComponent.stories.tsx +151 -151
- package/stories/AUSpinnerComponent.stories.tsx +44 -44
- package/stories/AUStepComponent.stories.tsx +91 -91
- package/stories/AUToolbarComponent.stories.tsx +389 -389
- package/stories/AUTruncatorComponent.stories.tsx +123 -123
- package/stories/lib/helpers.tsx +146 -146
- package/tsconfig.json +46 -46
- package/webpack.config.js +88 -88
- package/.claude/settings.local.json +0 -12
- package/.vscode/settings.json +0 -22
package/esbuild.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import * as esbuild from 'esbuild';
|
|
4
|
-
import { sassPlugin } from 'esbuild-sass-plugin';
|
|
5
|
-
|
|
6
|
-
await esbuild.build({
|
|
7
|
-
entryPoints: {
|
|
8
|
-
'./umd/all': './src/layout-2016/lib/all',
|
|
9
|
-
'./umd/alphabox': './src/layout-2016/lib/au-alphabox',
|
|
10
|
-
'./umd/databox': './src/layout-2016/lib/au-databox',
|
|
11
|
-
'./umd/diagramme': './src/layout-2016/lib/au-diagramme',
|
|
12
|
-
'./umd/flowbox': './src/layout-2016/lib/au-flowbox',
|
|
13
|
-
},
|
|
14
|
-
bundle: true,
|
|
15
|
-
minify: true,
|
|
16
|
-
sourcemap: true,
|
|
17
|
-
outdir: 'build',
|
|
18
|
-
plugins: [sassPlugin()],
|
|
19
|
-
loader: {
|
|
20
|
-
'.js': 'jsx',
|
|
21
|
-
},
|
|
22
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as esbuild from 'esbuild';
|
|
4
|
+
import { sassPlugin } from 'esbuild-sass-plugin';
|
|
5
|
+
|
|
6
|
+
await esbuild.build({
|
|
7
|
+
entryPoints: {
|
|
8
|
+
'./umd/all': './src/layout-2016/lib/all',
|
|
9
|
+
'./umd/alphabox': './src/layout-2016/lib/au-alphabox',
|
|
10
|
+
'./umd/databox': './src/layout-2016/lib/au-databox',
|
|
11
|
+
'./umd/diagramme': './src/layout-2016/lib/au-diagramme',
|
|
12
|
+
'./umd/flowbox': './src/layout-2016/lib/au-flowbox',
|
|
13
|
+
},
|
|
14
|
+
bundle: true,
|
|
15
|
+
minify: true,
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
outdir: 'build',
|
|
18
|
+
plugins: [sassPlugin()],
|
|
19
|
+
loader: {
|
|
20
|
+
'.js': 'jsx',
|
|
21
|
+
},
|
|
22
|
+
});
|
package/package.json
CHANGED
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
{
|
|
2
|
-
"sideEffects": true,
|
|
3
|
-
"name": "@aarhus-university/au-lib-react-components",
|
|
4
|
-
"version": "12.6.
|
|
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.6.15",
|
|
32
|
-
"@storybook/addon-essentials": "^8.6.15",
|
|
33
|
-
"@storybook/addon-interactions": "^8.6.15",
|
|
34
|
-
"@storybook/addon-links": "^8.6.15",
|
|
35
|
-
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
|
|
36
|
-
"@storybook/react": "^8.6.15",
|
|
37
|
-
"@testing-library/jest-dom": "^5.16.5",
|
|
38
|
-
"@testing-library/react": "^16.3.2",
|
|
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
|
-
"jest-environment-jsdom": "^30.2.0",
|
|
58
|
-
"mini-css-extract-plugin": "^2.7.6",
|
|
59
|
-
"react-dom": "18.3.1",
|
|
60
|
-
"sass": "^1.63.6",
|
|
61
|
-
"sass-loader": "^13.3.2",
|
|
62
|
-
"storybook": "^8.2.1",
|
|
63
|
-
"ts-jest": "^29.1.1",
|
|
64
|
-
"typescript": "^5.1.6",
|
|
65
|
-
"webpack-cli": "^6.0.1",
|
|
66
|
-
"wicg-inert": "^3.1.2"
|
|
67
|
-
},
|
|
68
|
-
"dependencies": {
|
|
69
|
-
"@aarhus-university/au-designsystem-delphinus": "^1.12.2",
|
|
70
|
-
"@aarhus-university/types": "^
|
|
71
|
-
"@reduxjs/toolkit": "^1.9.5",
|
|
72
|
-
"@storybook/react-webpack5": "^8.6.15",
|
|
73
|
-
"@tinymce/tinymce-react": "^5.1.1",
|
|
74
|
-
"@types/react": "^18.3.27",
|
|
75
|
-
"@types/react-dom": "^18.3.7",
|
|
76
|
-
"@types/react-router-dom": "^5.3.3",
|
|
77
|
-
"dayjs": "^1.11.9",
|
|
78
|
-
"esbuild": "^0.19.4",
|
|
79
|
-
"esbuild-sass-plugin": "^2.10.0",
|
|
80
|
-
"lodash.debounce": "^4.0.8",
|
|
81
|
-
"prop-types": "^15.8.1",
|
|
82
|
-
"query-string": "^8.1.0",
|
|
83
|
-
"react": "^18.3.1",
|
|
84
|
-
"react-autosuggest": "^10.1.0",
|
|
85
|
-
"react-router-dom": "^6.14.1",
|
|
86
|
-
"regenerator-runtime": "^0.13.11",
|
|
87
|
-
"webpack": "^5.88.1",
|
|
88
|
-
"whatwg-fetch": "^3.6.2"
|
|
89
|
-
},
|
|
90
|
-
"jest": {
|
|
91
|
-
"rootDir": "__tests__/jest",
|
|
92
|
-
"setupFilesAfterEnv": [
|
|
93
|
-
"./setupTests.ts"
|
|
94
|
-
],
|
|
95
|
-
"transform": {
|
|
96
|
-
"^.+\\.(ts|tsx|js|jsx)$": "ts-jest"
|
|
97
|
-
},
|
|
98
|
-
"testEnvironment": "jsdom",
|
|
99
|
-
"transformIgnorePatterns": [
|
|
100
|
-
"node_modules/(?!(@aarhus-university/au-lib-react-components|@aarhus-university/au-designsystem-delphinus|node-fetch|data-uri-to-buffer|fetch-blob|formdata-polyfill)/)"
|
|
101
|
-
],
|
|
102
|
-
"testPathIgnorePatterns": [
|
|
103
|
-
"factory.ts",
|
|
104
|
-
"setupTests.ts"
|
|
105
|
-
]
|
|
106
|
-
}
|
|
107
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"sideEffects": true,
|
|
3
|
+
"name": "@aarhus-university/au-lib-react-components",
|
|
4
|
+
"version": "12.6.3",
|
|
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.6.15",
|
|
32
|
+
"@storybook/addon-essentials": "^8.6.15",
|
|
33
|
+
"@storybook/addon-interactions": "^8.6.15",
|
|
34
|
+
"@storybook/addon-links": "^8.6.15",
|
|
35
|
+
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
|
|
36
|
+
"@storybook/react": "^8.6.15",
|
|
37
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
38
|
+
"@testing-library/react": "^16.3.2",
|
|
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
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
58
|
+
"mini-css-extract-plugin": "^2.7.6",
|
|
59
|
+
"react-dom": "18.3.1",
|
|
60
|
+
"sass": "^1.63.6",
|
|
61
|
+
"sass-loader": "^13.3.2",
|
|
62
|
+
"storybook": "^8.2.1",
|
|
63
|
+
"ts-jest": "^29.1.1",
|
|
64
|
+
"typescript": "^5.1.6",
|
|
65
|
+
"webpack-cli": "^6.0.1",
|
|
66
|
+
"wicg-inert": "^3.1.2"
|
|
67
|
+
},
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"@aarhus-university/au-designsystem-delphinus": "^1.12.2",
|
|
70
|
+
"@aarhus-university/types": "^2.1.3",
|
|
71
|
+
"@reduxjs/toolkit": "^1.9.5",
|
|
72
|
+
"@storybook/react-webpack5": "^8.6.15",
|
|
73
|
+
"@tinymce/tinymce-react": "^5.1.1",
|
|
74
|
+
"@types/react": "^18.3.27",
|
|
75
|
+
"@types/react-dom": "^18.3.7",
|
|
76
|
+
"@types/react-router-dom": "^5.3.3",
|
|
77
|
+
"dayjs": "^1.11.9",
|
|
78
|
+
"esbuild": "^0.19.4",
|
|
79
|
+
"esbuild-sass-plugin": "^2.10.0",
|
|
80
|
+
"lodash.debounce": "^4.0.8",
|
|
81
|
+
"prop-types": "^15.8.1",
|
|
82
|
+
"query-string": "^8.1.0",
|
|
83
|
+
"react": "^18.3.1",
|
|
84
|
+
"react-autosuggest": "^10.1.0",
|
|
85
|
+
"react-router-dom": "^6.14.1",
|
|
86
|
+
"regenerator-runtime": "^0.13.11",
|
|
87
|
+
"webpack": "^5.88.1",
|
|
88
|
+
"whatwg-fetch": "^3.6.2"
|
|
89
|
+
},
|
|
90
|
+
"jest": {
|
|
91
|
+
"rootDir": "__tests__/jest",
|
|
92
|
+
"setupFilesAfterEnv": [
|
|
93
|
+
"./setupTests.ts"
|
|
94
|
+
],
|
|
95
|
+
"transform": {
|
|
96
|
+
"^.+\\.(ts|tsx|js|jsx)$": "ts-jest"
|
|
97
|
+
},
|
|
98
|
+
"testEnvironment": "jsdom",
|
|
99
|
+
"transformIgnorePatterns": [
|
|
100
|
+
"node_modules/(?!(@aarhus-university/au-lib-react-components|@aarhus-university/au-designsystem-delphinus|node-fetch|data-uri-to-buffer|fetch-blob|formdata-polyfill)/)"
|
|
101
|
+
],
|
|
102
|
+
"testPathIgnorePatterns": [
|
|
103
|
+
"factory.ts",
|
|
104
|
+
"setupTests.ts"
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
3
|
-
/* eslint-env browser */
|
|
4
|
-
import React, {
|
|
5
|
-
FC, useState, useRef, useEffect,
|
|
6
|
-
} from 'react';
|
|
7
|
-
import { hideModal } from '@aarhus-university/au-designsystem-delphinus/source/js/components/modal-view';
|
|
8
|
-
import AUButtonComponent, { Props as ButtonProps } from './AUButtonComponent';
|
|
9
|
-
import AUModalComponent from './AUModalComponent';
|
|
10
|
-
|
|
11
|
-
type Props = ButtonProps & {
|
|
12
|
-
modalId: string;
|
|
13
|
-
confirm: boolean;
|
|
14
|
-
processing: boolean;
|
|
15
|
-
done: boolean;
|
|
16
|
-
header: string;
|
|
17
|
-
message: string;
|
|
18
|
-
okButtonText: string;
|
|
19
|
-
cancelButtonText: string;
|
|
20
|
-
okMode: ButtonProps['mode'];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const AUAlertComponent: FC<Props> = ({
|
|
24
|
-
modalId,
|
|
25
|
-
confirm,
|
|
26
|
-
processing,
|
|
27
|
-
done,
|
|
28
|
-
header,
|
|
29
|
-
message,
|
|
30
|
-
okButtonText,
|
|
31
|
-
cancelButtonText,
|
|
32
|
-
label,
|
|
33
|
-
size,
|
|
34
|
-
type,
|
|
35
|
-
icon,
|
|
36
|
-
iconPosition,
|
|
37
|
-
hideLabel,
|
|
38
|
-
mode,
|
|
39
|
-
okMode,
|
|
40
|
-
classNames,
|
|
41
|
-
asSubmit,
|
|
42
|
-
onClick,
|
|
43
|
-
}) => {
|
|
44
|
-
const [alert, setAlert] = useState<boolean>(false);
|
|
45
|
-
const btnRef = useRef<HTMLButtonElement>(null);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (done) {
|
|
48
|
-
hideModal(modalId, btnRef.current as HTMLButtonElement, () => setAlert(false));
|
|
49
|
-
}
|
|
50
|
-
}, [done]);
|
|
51
|
-
|
|
52
|
-
let okBtnMode = okMode;
|
|
53
|
-
if (processing) {
|
|
54
|
-
if (mode === 'confirmable-action') {
|
|
55
|
-
okBtnMode = 'confirmable-action processing';
|
|
56
|
-
} else if (mode === 'ireversable-action') {
|
|
57
|
-
okBtnMode = 'ireversable-action processing';
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<>
|
|
63
|
-
<AUModalComponent
|
|
64
|
-
domId={modalId}
|
|
65
|
-
show={alert}
|
|
66
|
-
sender={btnRef.current}
|
|
67
|
-
onClose={() => setAlert(false)}
|
|
68
|
-
closeButtonDisabled={processing}
|
|
69
|
-
>
|
|
70
|
-
<>
|
|
71
|
-
<h2 className="modal-view__header">{header}</h2>
|
|
72
|
-
<div className="modal-view__content">
|
|
73
|
-
<div className="content-container" dangerouslySetInnerHTML={{ __html: message }} />
|
|
74
|
-
<div className="button-container vertical-spacing-top">
|
|
75
|
-
<AUButtonComponent
|
|
76
|
-
label={okButtonText}
|
|
77
|
-
disabled={processing}
|
|
78
|
-
mode={okBtnMode}
|
|
79
|
-
onClick={(event) => {
|
|
80
|
-
if (typeof onClick === 'function') {
|
|
81
|
-
onClick(event, btnRef);
|
|
82
|
-
}
|
|
83
|
-
}}
|
|
84
|
-
/>
|
|
85
|
-
{
|
|
86
|
-
confirm && (
|
|
87
|
-
<AUButtonComponent
|
|
88
|
-
label={cancelButtonText}
|
|
89
|
-
disabled={processing}
|
|
90
|
-
type="text"
|
|
91
|
-
onClick={() => {
|
|
92
|
-
hideModal(modalId, btnRef.current as HTMLButtonElement, () => setAlert(false));
|
|
93
|
-
}}
|
|
94
|
-
/>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
99
|
-
</>
|
|
100
|
-
</AUModalComponent>
|
|
101
|
-
<AUButtonComponent
|
|
102
|
-
label={label}
|
|
103
|
-
disabled={alert}
|
|
104
|
-
size={size}
|
|
105
|
-
type={type}
|
|
106
|
-
icon={icon}
|
|
107
|
-
iconPosition={iconPosition}
|
|
108
|
-
hideLabel={hideLabel}
|
|
109
|
-
mode={mode}
|
|
110
|
-
btnRef={btnRef}
|
|
111
|
-
classNames={classNames}
|
|
112
|
-
ariaExpanded={alert}
|
|
113
|
-
ariaHasPopup
|
|
114
|
-
asSubmit={asSubmit}
|
|
115
|
-
onClick={() => {
|
|
116
|
-
setAlert(true);
|
|
117
|
-
}}
|
|
118
|
-
/>
|
|
119
|
-
</>
|
|
120
|
-
);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
AUAlertComponent.displayName = 'AUAlertComponent';
|
|
124
|
-
export default AUAlertComponent;
|
|
125
|
-
|
|
126
|
-
export {
|
|
127
|
-
Props,
|
|
128
|
-
};
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
3
|
+
/* eslint-env browser */
|
|
4
|
+
import React, {
|
|
5
|
+
FC, useState, useRef, useEffect,
|
|
6
|
+
} from 'react';
|
|
7
|
+
import { hideModal } from '@aarhus-university/au-designsystem-delphinus/source/js/components/modal-view';
|
|
8
|
+
import AUButtonComponent, { Props as ButtonProps } from './AUButtonComponent';
|
|
9
|
+
import AUModalComponent from './AUModalComponent';
|
|
10
|
+
|
|
11
|
+
type Props = ButtonProps & {
|
|
12
|
+
modalId: string;
|
|
13
|
+
confirm: boolean;
|
|
14
|
+
processing: boolean;
|
|
15
|
+
done: boolean;
|
|
16
|
+
header: string;
|
|
17
|
+
message: string;
|
|
18
|
+
okButtonText: string;
|
|
19
|
+
cancelButtonText: string;
|
|
20
|
+
okMode: ButtonProps['mode'];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const AUAlertComponent: FC<Props> = ({
|
|
24
|
+
modalId,
|
|
25
|
+
confirm,
|
|
26
|
+
processing,
|
|
27
|
+
done,
|
|
28
|
+
header,
|
|
29
|
+
message,
|
|
30
|
+
okButtonText,
|
|
31
|
+
cancelButtonText,
|
|
32
|
+
label,
|
|
33
|
+
size,
|
|
34
|
+
type,
|
|
35
|
+
icon,
|
|
36
|
+
iconPosition,
|
|
37
|
+
hideLabel,
|
|
38
|
+
mode,
|
|
39
|
+
okMode,
|
|
40
|
+
classNames,
|
|
41
|
+
asSubmit,
|
|
42
|
+
onClick,
|
|
43
|
+
}) => {
|
|
44
|
+
const [alert, setAlert] = useState<boolean>(false);
|
|
45
|
+
const btnRef = useRef<HTMLButtonElement>(null);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (done) {
|
|
48
|
+
hideModal(modalId, btnRef.current as HTMLButtonElement, () => setAlert(false));
|
|
49
|
+
}
|
|
50
|
+
}, [done]);
|
|
51
|
+
|
|
52
|
+
let okBtnMode = okMode;
|
|
53
|
+
if (processing) {
|
|
54
|
+
if (mode === 'confirmable-action') {
|
|
55
|
+
okBtnMode = 'confirmable-action processing';
|
|
56
|
+
} else if (mode === 'ireversable-action') {
|
|
57
|
+
okBtnMode = 'ireversable-action processing';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
<AUModalComponent
|
|
64
|
+
domId={modalId}
|
|
65
|
+
show={alert}
|
|
66
|
+
sender={btnRef.current}
|
|
67
|
+
onClose={() => setAlert(false)}
|
|
68
|
+
closeButtonDisabled={processing}
|
|
69
|
+
>
|
|
70
|
+
<>
|
|
71
|
+
<h2 className="modal-view__header">{header}</h2>
|
|
72
|
+
<div className="modal-view__content">
|
|
73
|
+
<div className="content-container" dangerouslySetInnerHTML={{ __html: message }} />
|
|
74
|
+
<div className="button-container vertical-spacing-top">
|
|
75
|
+
<AUButtonComponent
|
|
76
|
+
label={okButtonText}
|
|
77
|
+
disabled={processing}
|
|
78
|
+
mode={okBtnMode}
|
|
79
|
+
onClick={(event) => {
|
|
80
|
+
if (typeof onClick === 'function') {
|
|
81
|
+
onClick(event, btnRef);
|
|
82
|
+
}
|
|
83
|
+
}}
|
|
84
|
+
/>
|
|
85
|
+
{
|
|
86
|
+
confirm && (
|
|
87
|
+
<AUButtonComponent
|
|
88
|
+
label={cancelButtonText}
|
|
89
|
+
disabled={processing}
|
|
90
|
+
type="text"
|
|
91
|
+
onClick={() => {
|
|
92
|
+
hideModal(modalId, btnRef.current as HTMLButtonElement, () => setAlert(false));
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</>
|
|
100
|
+
</AUModalComponent>
|
|
101
|
+
<AUButtonComponent
|
|
102
|
+
label={label}
|
|
103
|
+
disabled={alert}
|
|
104
|
+
size={size}
|
|
105
|
+
type={type}
|
|
106
|
+
icon={icon}
|
|
107
|
+
iconPosition={iconPosition}
|
|
108
|
+
hideLabel={hideLabel}
|
|
109
|
+
mode={mode}
|
|
110
|
+
btnRef={btnRef}
|
|
111
|
+
classNames={classNames}
|
|
112
|
+
ariaExpanded={alert}
|
|
113
|
+
ariaHasPopup
|
|
114
|
+
asSubmit={asSubmit}
|
|
115
|
+
onClick={() => {
|
|
116
|
+
setAlert(true);
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
</>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
AUAlertComponent.displayName = 'AUAlertComponent';
|
|
124
|
+
export default AUAlertComponent;
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
Props,
|
|
128
|
+
};
|