@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.
Files changed (109) hide show
  1. package/.eslintrc.js +35 -35
  2. package/.storybook/main.js +34 -34
  3. package/.storybook/preview.js +17 -17
  4. package/README.md +19 -19
  5. package/__tests__/jest/AUButtonComponent.test.tsx +165 -165
  6. package/__tests__/jest/AUDynamicContentComponent.test.tsx +386 -386
  7. package/__tests__/jest/AUErrorComponent.test.tsx +142 -142
  8. package/__tests__/jest/AUModalComponent.test.tsx +186 -186
  9. package/__tests__/jest/AUNotificationComponent.test.tsx +115 -115
  10. package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -57
  11. package/__tests__/jest/AUToolbarComponent.test.tsx +46 -46
  12. package/__tests__/jest/context.test.ts +25 -25
  13. package/__tests__/jest/helpers.test.ts +15 -15
  14. package/__tests__/jest/setupTests.ts +2 -2
  15. package/babel.config.js +8 -8
  16. package/build/umd/all.css +2 -2
  17. package/build/umd/all.js +1 -1
  18. package/build/umd/alphabox.js +1 -1
  19. package/build/umd/databox.js +1 -1
  20. package/build/umd/diagramme.js +1 -1
  21. package/build/umd/flowbox.js +1 -1
  22. package/build/umd/flowbox.js.map +1 -1
  23. package/build/umd/universe.js +1 -1
  24. package/build-storybook.log +386 -386
  25. package/esbuild.mjs +22 -22
  26. package/package.json +107 -107
  27. package/src/components/AUAlertComponent.tsx +128 -128
  28. package/src/components/AUAutoSuggestComponent.js +148 -148
  29. package/src/components/AUButtonComponent.tsx +99 -99
  30. package/src/components/AUCalendarComponent.tsx +497 -497
  31. package/src/components/AUCharacterCountComponent.tsx +56 -56
  32. package/src/components/AUComboBoxComponent.tsx +195 -195
  33. package/src/components/AUContentToggleComponent.tsx +50 -50
  34. package/src/components/AUDatepickerComponent.tsx +124 -124
  35. package/src/components/AUDialogModalComponent.tsx +124 -124
  36. package/src/components/AUDynamicContentComponent.tsx +137 -137
  37. package/src/components/AUEditorComponent.tsx +126 -126
  38. package/src/components/AUErrorComponent.tsx +73 -73
  39. package/src/components/AUMobilePrefixComponent.tsx +20 -20
  40. package/src/components/AUModalComponent.tsx +72 -72
  41. package/src/components/AUNotificationComponent.tsx +44 -44
  42. package/src/components/AUReceiptComponent.tsx +34 -34
  43. package/src/components/AUSpinnerComponent.tsx +40 -40
  44. package/src/components/AUStepComponent.tsx +75 -75
  45. package/src/components/AUSubNavComponent.tsx +57 -57
  46. package/src/components/AUSubmitButtonContainerComponent.tsx +38 -38
  47. package/src/components/AUTabbedContentComponent.tsx +154 -154
  48. package/src/components/AUTableComponent.tsx +29 -29
  49. package/src/components/AUToastComponent.tsx +104 -104
  50. package/src/components/AUToolbarComponent.tsx +108 -108
  51. package/src/components/AUTruncatorComponent.tsx +141 -141
  52. package/src/components/wrapping/AUEmbedComponent.js +47 -47
  53. package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +142 -142
  54. package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
  55. package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
  56. package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
  57. package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
  58. package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
  59. package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
  60. package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
  61. package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
  62. package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
  63. package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
  64. package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
  65. package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
  66. package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
  67. package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
  68. package/src/layout-2016/lib/all.js +3 -3
  69. package/src/layout-2016/lib/au-alphabox.js +99 -99
  70. package/src/layout-2016/lib/au-databox.js +399 -399
  71. package/src/layout-2016/lib/au-diagramme.js +85 -85
  72. package/src/layout-2016/lib/au-flowbox.js +116 -119
  73. package/src/lib/context.tsx +59 -59
  74. package/src/lib/dates.ts +52 -52
  75. package/src/lib/helpers.ts +208 -208
  76. package/src/lib/hooks.ts +157 -157
  77. package/src/lib/i18n.ts +600 -600
  78. package/src/lib/portals.tsx +150 -150
  79. package/src/lib/tinymce.ts +84 -84
  80. package/src/lib/wrapping.ts +21 -21
  81. package/src/styles/_settings.scss +10 -10
  82. package/src/styles/alphabox.scss +222 -222
  83. package/src/styles/app.scss +7 -7
  84. package/src/styles/autosuggest.scss +57 -57
  85. package/src/styles/databox.scss +563 -563
  86. package/src/styles/diagramme.scss +119 -119
  87. package/src/styles/flowbox.scss +72 -72
  88. package/src/styles/maps.scss +395 -395
  89. package/stories/AUAlertComponent.stories.tsx +133 -133
  90. package/stories/AUAutoSuggestComponent.stories.tsx +95 -95
  91. package/stories/AUButtonComponent.stories.tsx +139 -139
  92. package/stories/AUCharacterCountComponent.stories.tsx +121 -121
  93. package/stories/AUComboBoxComponent.stories.tsx +101 -101
  94. package/stories/AUContentToggleComponent.stories.tsx +87 -87
  95. package/stories/AUDialogModalComponent.stories.tsx +75 -75
  96. package/stories/AUDynamicContentComponent.stories.tsx +119 -119
  97. package/stories/AUEditorComponent.stories.tsx +66 -66
  98. package/stories/AUErrorComponent.stories.tsx +132 -132
  99. package/stories/AUModalComponent.stories.tsx +160 -160
  100. package/stories/AUNotificationComponent.stories.tsx +151 -151
  101. package/stories/AUSpinnerComponent.stories.tsx +44 -44
  102. package/stories/AUStepComponent.stories.tsx +91 -91
  103. package/stories/AUToolbarComponent.stories.tsx +389 -389
  104. package/stories/AUTruncatorComponent.stories.tsx +123 -123
  105. package/stories/lib/helpers.tsx +146 -146
  106. package/tsconfig.json +46 -46
  107. package/webpack.config.js +88 -88
  108. package/.claude/settings.local.json +0 -12
  109. 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.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/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": "^1.1.0",
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
+ };