dibk-design 7.7.0 → 8.0.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.
Files changed (136) hide show
  1. package/README.md +7 -0
  2. package/dist/dibk-design.css +1 -0
  3. package/dist/favicon.ico +0 -0
  4. package/dist/index.es.js +2386 -0
  5. package/dist/index.html +38 -0
  6. package/dist/index.umd.js +20 -0
  7. package/dist/manifest.json +15 -0
  8. package/dist/robots.txt +3 -0
  9. package/package.json +19 -27
  10. package/dist/assets/fonts/PPMori-Bold.otf +0 -0
  11. package/dist/assets/fonts/PPMori-Book.otf +0 -0
  12. package/dist/assets/fonts/PPMori-ExtraBold.otf +0 -0
  13. package/dist/assets/fonts/PPMori-Light.otf +0 -0
  14. package/dist/assets/fonts/PPMori-Medium.otf +0 -0
  15. package/dist/assets/fonts/PPMori-Regular.otf +0 -0
  16. package/dist/assets/fonts/PPMori-RegularItalic.otf +0 -0
  17. package/dist/assets/fonts/PPMori-SemiBold.otf +0 -0
  18. package/dist/assets/png/dibk-logo.png +0 -0
  19. package/dist/assets/svg/arbeidstilsynet-logo.svg +0 -1
  20. package/dist/assets/svg/asterisk.svg +0 -1
  21. package/dist/assets/svg/checkmark-symbol.svg +0 -8
  22. package/dist/assets/svg/dibk-logo-base64.js +0 -7
  23. package/dist/assets/svg/dibk-logo-mobile.svg +0 -91
  24. package/dist/assets/svg/dibk-logo.svg +0 -52
  25. package/dist/assets/svg/error-sign.svg +0 -15
  26. package/dist/assets/svg/info-sign.svg +0 -1
  27. package/dist/assets/svg/spinner.svg +0 -57
  28. package/dist/assets/svg/x-symbol.svg +0 -1
  29. package/dist/components/Accordion.js +0 -64
  30. package/dist/components/Accordion.module.scss +0 -190
  31. package/dist/components/Button.js +0 -118
  32. package/dist/components/Button.module.scss +0 -290
  33. package/dist/components/CheckBoxIcon.js +0 -42
  34. package/dist/components/CheckBoxIcon.module.scss +0 -69
  35. package/dist/components/CheckBoxInput.js +0 -70
  36. package/dist/components/CheckBoxInput.module.scss +0 -53
  37. package/dist/components/CheckBoxList.js +0 -55
  38. package/dist/components/CheckBoxList.module.scss +0 -25
  39. package/dist/components/CheckBoxListItem.js +0 -61
  40. package/dist/components/CheckBoxListItem.module.scss +0 -84
  41. package/dist/components/Container.js +0 -24
  42. package/dist/components/Container.module.scss +0 -15
  43. package/dist/components/ContentBox.js +0 -56
  44. package/dist/components/ContentBox.module.scss +0 -60
  45. package/dist/components/DescriptionDetails.js +0 -32
  46. package/dist/components/DescriptionDetails.module.scss +0 -22
  47. package/dist/components/DescriptionList.js +0 -47
  48. package/dist/components/DescriptionList.module.scss +0 -15
  49. package/dist/components/DescriptionTerm.js +0 -32
  50. package/dist/components/DescriptionTerm.module.scss +0 -30
  51. package/dist/components/Dialog.js +0 -86
  52. package/dist/components/Dialog.module.scss +0 -178
  53. package/dist/components/DragAndDropFileInput.js +0 -131
  54. package/dist/components/DragAndDropFileInput.module.scss +0 -38
  55. package/dist/components/ErrorBox.js +0 -33
  56. package/dist/components/ErrorBox.module.scss +0 -68
  57. package/dist/components/ErrorMessage.js +0 -37
  58. package/dist/components/ErrorMessage.module.scss +0 -30
  59. package/dist/components/Footer.js +0 -16
  60. package/dist/components/Footer.module.scss +0 -21
  61. package/dist/components/Header.js +0 -42
  62. package/dist/components/Header.module.scss +0 -79
  63. package/dist/components/InfoBox.js +0 -23
  64. package/dist/components/InfoBox.module.scss +0 -44
  65. package/dist/components/InputField.js +0 -137
  66. package/dist/components/InputField.module.scss +0 -88
  67. package/dist/components/Label.js +0 -40
  68. package/dist/components/Label.module.scss +0 -19
  69. package/dist/components/Lead.js +0 -31
  70. package/dist/components/Lead.module.scss +0 -13
  71. package/dist/components/List.js +0 -46
  72. package/dist/components/List.module.scss +0 -12
  73. package/dist/components/ListItem.js +0 -27
  74. package/dist/components/ListItem.module.scss +0 -10
  75. package/dist/components/LoadingAnimation.js +0 -26
  76. package/dist/components/LoadingAnimation.module.scss +0 -28
  77. package/dist/components/NavigationBar.js +0 -146
  78. package/dist/components/NavigationBar.module.scss +0 -474
  79. package/dist/components/NavigationBarListItem.js +0 -24
  80. package/dist/components/PDF.js +0 -14
  81. package/dist/components/PDF.scss +0 -765
  82. package/dist/components/Paper.js +0 -24
  83. package/dist/components/Paper.module.scss +0 -17
  84. package/dist/components/ProgressBar.js +0 -32
  85. package/dist/components/ProgressBar.module.scss +0 -30
  86. package/dist/components/RadioButtonIcon.js +0 -34
  87. package/dist/components/RadioButtonIcon.module.scss +0 -49
  88. package/dist/components/RadioButtonInput.js +0 -68
  89. package/dist/components/RadioButtonInput.module.scss +0 -53
  90. package/dist/components/RadioButtonList.js +0 -55
  91. package/dist/components/RadioButtonList.module.scss +0 -25
  92. package/dist/components/RadioButtonListItem.js +0 -59
  93. package/dist/components/RadioButtonListItem.module.scss +0 -84
  94. package/dist/components/Select.js +0 -224
  95. package/dist/components/Select.module.scss +0 -118
  96. package/dist/components/Table.js +0 -31
  97. package/dist/components/Table.module.scss +0 -65
  98. package/dist/components/Textarea.js +0 -105
  99. package/dist/components/Textarea.module.scss +0 -73
  100. package/dist/components/Theme.js +0 -138
  101. package/dist/components/Theme.module.scss +0 -103
  102. package/dist/components/ThemeProvider.js +0 -24
  103. package/dist/components/ThemeProvider.module.scss +0 -24
  104. package/dist/components/ToggleNavigationButton.js +0 -44
  105. package/dist/components/ToggleNavigationButton.module.scss +0 -34
  106. package/dist/components/WizardNavigation/Step.js +0 -66
  107. package/dist/components/WizardNavigation/Step.module.scss +0 -175
  108. package/dist/components/WizardNavigation.js +0 -56
  109. package/dist/components/WizardNavigation.module.scss +0 -25
  110. package/dist/functions/generators.js +0 -16
  111. package/dist/functions/helpers.js +0 -112
  112. package/dist/functions/theme.js +0 -18
  113. package/dist/index.js +0 -279
  114. package/dist/style/abstracts/mixins/_animation.scss +0 -6
  115. package/dist/style/abstracts/mixins/_appearance.scss +0 -5
  116. package/dist/style/abstracts/mixins/_border-radius.scss +0 -31
  117. package/dist/style/abstracts/mixins/_box-shadow.scss +0 -5
  118. package/dist/style/abstracts/mixins/_box-sizing.scss +0 -5
  119. package/dist/style/abstracts/mixins/_calc.scss +0 -5
  120. package/dist/style/abstracts/mixins/_keyframes.scss +0 -14
  121. package/dist/style/abstracts/mixins/_opacity.scss +0 -5
  122. package/dist/style/abstracts/mixins/_placeholder.scss +0 -17
  123. package/dist/style/abstracts/mixins/_scrollbar.scss +0 -26
  124. package/dist/style/abstracts/mixins/_transform.scss +0 -6
  125. package/dist/style/abstracts/mixins/_transition.scss +0 -34
  126. package/dist/style/abstracts/variables/_colors.scss +0 -33
  127. package/dist/style/abstracts/variables/_sizes.scss +0 -1
  128. package/dist/style/abstracts/variables/_transitions.scss +0 -2
  129. package/dist/style/abstracts/variables/_typography.scss +0 -1
  130. package/dist/style/abstracts/variables/_viewports.scss +0 -14
  131. package/dist/style/base/_fonts.scss +0 -57
  132. package/dist/style/base/_reset.scss +0 -15
  133. package/dist/style/base/_typography.scss +0 -10
  134. package/dist/style/layout/_containers.scss +0 -11
  135. package/dist/style/pdf.css +0 -637
  136. package/dist/style/pdf.css.map +0 -1
@@ -1,84 +0,0 @@
1
- // Mixins
2
- @use "../style/abstracts/mixins/border-radius";
3
- @use "../style/abstracts/mixins/box-sizing";
4
- @use "../style/abstracts/mixins/transition";
5
-
6
- // Variables
7
- @use "../style/abstracts/variables/colors";
8
- @use "../style/abstracts/variables/transitions";
9
- @use "../style/abstracts/variables/typography";
10
-
11
- .checkBoxListItem {
12
- @include box-sizing.box-sizing(content-box);
13
- @include border-radius.border-radius(0);
14
- @include transition.transition(all transitions.$default-transition);
15
- display: -webkit-box;
16
- display: -webkit-flex;
17
- display: -ms-flexbox;
18
- display: flex;
19
- -webkit-align-items: flex-start;
20
- -webkit-box-align: flex-start;
21
- -ms-flex-align: flex-start;
22
- align-items: flex-start;
23
- cursor: pointer;
24
- font-family: typography.$default-font;
25
- position: relative;
26
- font-size: 16px;
27
- line-height: 24px;
28
- color: #000;
29
-
30
- &:not(.contentOnly):not(.compact) {
31
- border: 1px solid var(--color-secondary-light, colors.$color-secondary-light);
32
- background: white;
33
- margin-bottom: 8px;
34
- label {
35
- padding: 20px;
36
- }
37
- }
38
-
39
- &.contentOnly {
40
- cursor: auto;
41
- label {
42
- cursor: auto;
43
- padding: 5px 10px;
44
- }
45
- }
46
-
47
- &.disabled {
48
- label {
49
- cursor: auto;
50
- }
51
- }
52
-
53
- &.checked:not(.contentOnly):not(.compact):not(.disabled) {
54
- background-color: var(--color-secondary-light, colors.$color-secondary-light);
55
- }
56
-
57
- &:not(.checked):not(.contentOnly):not(.compact):not(.disabled) {
58
- &:hover {
59
- background-color: var(--color-secondary-x-light, colors.$color-secondary-x-light);
60
- }
61
- &:focus-within {
62
- background-color: var(--color-secondary-x-light, colors.$color-secondary-x-light);
63
- }
64
- }
65
-
66
- label {
67
- width: 100%;
68
- padding: 10px;
69
- margin: 0;
70
- cursor: pointer;
71
- }
72
-
73
- &.compact {
74
- display: table;
75
- label {
76
- padding: 6px 4px;
77
- }
78
- }
79
-
80
- input[type="checkbox"] {
81
- opacity: 0;
82
- position: absolute;
83
- }
84
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _ContainerModule = _interopRequireDefault(require("./Container.module.scss"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const Container = props => {
12
- var _props$maxWidth;
13
- const styleProps = {
14
- "--max-width": (props === null || props === void 0 || (_props$maxWidth = props.maxWidth) === null || _props$maxWidth === void 0 ? void 0 : _props$maxWidth.length) && props.maxWidth
15
- };
16
- return _react.default.createElement("div", {
17
- className: _ContainerModule.default.container,
18
- style: styleProps
19
- }, props.children);
20
- };
21
- Container.propTypes = {
22
- maxWidth: _propTypes.default.string
23
- };
24
- var _default = exports.default = Container;
@@ -1,15 +0,0 @@
1
- // Variables
2
- @use "../style/abstracts/variables/sizes";
3
- @use "../style/abstracts/variables/viewports";
4
-
5
- .container {
6
- margin: auto;
7
- padding: 8px;
8
- @media (min-width: viewports.$screen-sm) {
9
- padding: 20px;
10
- max-width: sizes.$content-width;
11
- &[style*="--max-width"] {
12
- max-width: var(--max-width);
13
- }
14
- }
15
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _ContentBoxModule = _interopRequireDefault(require("./ContentBox.module.scss"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const ContentBox = props => {
12
- var _props$content;
13
- const renderTitle = () => {
14
- let className = _ContentBoxModule.default.title + " " + _ContentBoxModule.default[props.titleSize];
15
- if (props.title) {
16
- return _react.default.createElement("h2", {
17
- className: className
18
- }, props.title);
19
- } else {
20
- return;
21
- }
22
- };
23
- let colorClass = " " + _ContentBoxModule.default[props.color];
24
- let linkClass = props.href ? " " + _ContentBoxModule.default.link : "";
25
- let className = _ContentBoxModule.default.contentBox + colorClass + linkClass;
26
- const bodyContent = (_props$content = props.content) !== null && _props$content !== void 0 && _props$content.length ? props.content : props.children;
27
- if (props.href) {
28
- return _react.default.createElement("a", {
29
- href: props.href,
30
- className: className
31
- }, renderTitle(), _react.default.createElement("div", {
32
- className: _ContentBoxModule.default.content
33
- }, bodyContent));
34
- } else {
35
- return _react.default.createElement("div", {
36
- className: className
37
- }, renderTitle(), _react.default.createElement("div", {
38
- className: _ContentBoxModule.default.content
39
- }, bodyContent));
40
- }
41
- };
42
- ContentBox.propTypes = {
43
- title: _propTypes.default.string,
44
- titleSize: _propTypes.default.oneOf(["regular", "large"]),
45
- content: _propTypes.default.string,
46
- children: _propTypes.default.any,
47
- color: _propTypes.default.oneOf(["default", "secondary"])
48
- };
49
- ContentBox.defaultProps = {
50
- title: null,
51
- titleSize: "regular",
52
- href: null,
53
- content: "",
54
- color: "default"
55
- };
56
- var _default = exports.default = ContentBox;
@@ -1,60 +0,0 @@
1
- // Mixins
2
- @use "../style/abstracts/mixins/transition";
3
-
4
- // Variables
5
- @use "../style/abstracts/variables/colors";
6
- @use "../style/abstracts/variables/typography";
7
-
8
- .contentBox {
9
- font-family: typography.$default-font;
10
- text-decoration: none;
11
- padding: 20px;
12
- width: 100%;
13
- display: block;
14
- &.link {
15
- color: var(--color-primary, colors.$color-primary);
16
- @include transition.transition(filter 0.3s);
17
- &:hover,
18
- &:focus {
19
- filter: brightness(90%);
20
- }
21
- &:active {
22
- filter: brightness(85%);
23
- }
24
- }
25
- &.default {
26
- background-color: var(--color-default-background, colors.$color-default-background);
27
- .content,
28
- .title {
29
- color: colors.$color-default-text;
30
- }
31
- }
32
- &.secondary {
33
- background-color: var(--color-secondary-background, colors.$color-secondary-background);
34
- color: var(--color-default-text, colors.$color-default-text);
35
- .content,
36
- .title {
37
- color: var(--color-default-text, colors.$color-default-text);
38
- }
39
- }
40
-
41
- .title {
42
- &.regular {
43
- font-family: typography.$default-font;
44
- font-weight: bold;
45
- font-size: 21px;
46
- font-style: normal;
47
- line-height: 1.4;
48
- padding-bottom: 10px;
49
- border-bottom: 1px solid rgba(0, 0, 0, 0.075);
50
- }
51
- &.large {
52
- font-family: typography.$default-font;
53
- font-weight: normal;
54
- font-size: 24px;
55
- margin: 0;
56
- margin-bottom: 20px;
57
- font-style: normal;
58
- }
59
- }
60
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _helpers = require("../functions/helpers");
10
- var _DescriptionDetailsModule = _interopRequireDefault(require("./DescriptionDetails.module.scss"));
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- const DescriptionDetails = _ref => {
13
- let {
14
- compact,
15
- titleWidth,
16
- children
17
- } = _ref;
18
- return _react.default.createElement("dd", {
19
- className: (0, _helpers.classNameArrayToClassNameString)([_DescriptionDetailsModule.default.descriptionDetails, compact && _DescriptionDetailsModule.default.compact]),
20
- style: {
21
- "--title-width": titleWidth || null
22
- }
23
- }, children);
24
- };
25
- DescriptionDetails.propTypes = {
26
- compact: _propTypes.default.bool,
27
- titleWidth: _propTypes.default.string
28
- };
29
- DescriptionDetails.defaultProps = {
30
- compact: false
31
- };
32
- var _default = exports.default = DescriptionDetails;
@@ -1,22 +0,0 @@
1
- // Variables
2
- @use "../style/abstracts/variables/colors";
3
-
4
- .descriptionDetails {
5
- font-size: 16px;
6
- list-style: var(--listStyle);
7
- color: var(--color-primary, colors.$color-primary);
8
- margin: 0;
9
- &:not(.compact) {
10
- line-height: 1.6;
11
- }
12
- &.compact {
13
- line-height: 1.4;
14
- }
15
- &:not([style*="--title-width"]) {
16
- display: inline;
17
- }
18
- &[style*="--title-width"] {
19
- flex-basis: calc(100% - var(--title-width));
20
- flex-grow: 1;
21
- }
22
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _DescriptionListModule = _interopRequireDefault(require("./DescriptionList.module.scss"));
10
- var _helpers = require("../functions/helpers");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- const DescriptionList = _ref => {
13
- let {
14
- compact,
15
- titleWidth,
16
- children
17
- } = _ref;
18
- const renderChildElements = childElements => {
19
- const childElementsthroughFragments = (0, _helpers.cloneThroughFragments)(childElements);
20
- return childElementsthroughFragments.map((childElement, index) => {
21
- const childElementCopy = _react.default.cloneElement(childElement, {
22
- compact: compact,
23
- titleWidth: titleWidth,
24
- key: "descriptionListItem-".concat(index)
25
- });
26
- return childElementCopy;
27
- });
28
- };
29
- const renderList = children => {
30
- let listElement = _react.default.createElement("dl", {
31
- className: (0, _helpers.classNameArrayToClassNameString)([_DescriptionListModule.default.descriptionList, !!compact && _DescriptionListModule.default.compact]),
32
- style: {
33
- "--title-width": titleWidth || null
34
- }
35
- }, renderChildElements(_react.default.Children.toArray(children)));
36
- return listElement;
37
- };
38
- return renderList(children);
39
- };
40
- DescriptionList.propTypes = {
41
- compact: _propTypes.default.bool,
42
- titleWidth: _propTypes.default.string
43
- };
44
- DescriptionList.defaultProps = {
45
- compact: false
46
- };
47
- var _default = exports.default = DescriptionList;
@@ -1,15 +0,0 @@
1
- .descriptionList {
2
- margin: 0;
3
- padding: 0;
4
- margin-bottom: 20px;
5
- font-size: 16px;
6
- list-style: var(--listStyle);
7
- &[style*="--title-width"] {
8
- display: flex;
9
- flex-flow: row wrap;
10
- align-items: end;
11
- }
12
- &.compact {
13
- margin-left: 0px;
14
- }
15
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _helpers = require("../functions/helpers");
10
- var _DescriptionTermModule = _interopRequireDefault(require("./DescriptionTerm.module.scss"));
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- const DescriptionTerm = _ref => {
13
- let {
14
- compact,
15
- titleWidth,
16
- children
17
- } = _ref;
18
- return _react.default.createElement("dt", {
19
- className: (0, _helpers.classNameArrayToClassNameString)([_DescriptionTermModule.default.descriptionTerm, compact && _DescriptionTermModule.default.compact]),
20
- style: {
21
- "--title-width": titleWidth || null
22
- }
23
- }, children);
24
- };
25
- DescriptionTerm.propTypes = {
26
- compact: _propTypes.default.bool,
27
- titleWidth: _propTypes.default.string
28
- };
29
- DescriptionTerm.defaultProps = {
30
- compact: false
31
- };
32
- var _default = exports.default = DescriptionTerm;
@@ -1,30 +0,0 @@
1
- // Variables
2
- @use "../style/abstracts/variables/colors";
3
-
4
- .descriptionTerm {
5
- font-size: 16px;
6
- list-style: var(--listStyle);
7
- color: var(--color-primary, colors.$color-primary);
8
- margin: 0;
9
- font-weight: bold;
10
- &:not(.compact) {
11
- line-height: 1.6;
12
- }
13
- &.compact {
14
- line-height: 1.4;
15
- }
16
- &:not([style*="--title-width"]) {
17
- display: inline;
18
- &::before {
19
- display: block;
20
- content: "";
21
- }
22
- &::after {
23
- display: inline;
24
- content: " ";
25
- }
26
- }
27
- &[style*="--title-width"] {
28
- width: var(--title-width);
29
- }
30
- }
@@ -1,86 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _xSymbol = _interopRequireDefault(require("../assets/svg/x-symbol.svg?url"));
10
- var _DialogModule = _interopRequireDefault(require("./Dialog.module.scss"));
11
- var _helpers = require("../functions/helpers");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
- const Dialog = props => {
16
- var _props$attachTo, _props$maxWidth;
17
- const dialogRef = (0, _react.useRef)();
18
- const dialogContainerRef = (0, _react.useRef)();
19
- const dialogContentRef = (0, _react.useCallback)(element => {
20
- if (!!element) {
21
- (0, _helpers.addFocusTrapInsideElement)(element);
22
- }
23
- return element;
24
- }, []);
25
- (0, _react.useEffect)(() => {
26
- const keyDownFunction = event => {
27
- switch (event.keyCode) {
28
- case 27:
29
- if (props.onClickOutside) props.onClickOutside();
30
- break;
31
- default:
32
- return null;
33
- }
34
- };
35
- const handleClickOutside = event => {
36
- if (dialogContainerRef !== null && dialogContainerRef !== void 0 && dialogContainerRef.current && !dialogContainerRef.current.contains(event.target)) {
37
- props.onClickOutside();
38
- }
39
- };
40
- document.addEventListener("mousedown", handleClickOutside);
41
- document.addEventListener("keydown", keyDownFunction, false);
42
- }, [props, dialogContainerRef]);
43
- (0, _react.useEffect)(() => {
44
- dialogRef.current.close();
45
- if (!props.hidden) {
46
- props.modal ? dialogRef.current.showModal() : dialogRef.current.show();
47
- }
48
- }, [dialogRef, props.hidden, props.modal]);
49
- const sideBarClassNames = ((_props$attachTo = props.attachTo) === null || _props$attachTo === void 0 ? void 0 : _props$attachTo.length) && (0, _helpers.classNameArrayToClassNameString)([_DialogModule.default.isSidebar, _DialogModule.default[props.attachTo]]);
50
- const dialogContentStyleProps = {
51
- "--max-width": (props === null || props === void 0 || (_props$maxWidth = props.maxWidth) === null || _props$maxWidth === void 0 ? void 0 : _props$maxWidth.length) && props.maxWidth
52
- };
53
- return _react.default.createElement("dialog", {
54
- className: (0, _helpers.classNameArrayToClassNameString)([_DialogModule.default.dialog, sideBarClassNames]),
55
- ref: dialogRef
56
- }, _react.default.createElement("div", {
57
- ref: dialogContainerRef,
58
- className: _DialogModule.default.dialogContainer,
59
- style: dialogContentStyleProps
60
- }, _react.default.createElement("div", {
61
- ref: dialogContentRef,
62
- className: (0, _helpers.classNameArrayToClassNameString)([_DialogModule.default.dialogContent, props.noPadding && _DialogModule.default.noPadding])
63
- }, props.closeButton ? _react.default.createElement("button", {
64
- "aria-label": "Lukk dialog",
65
- onClick: props.onClickOutside,
66
- className: (0, _helpers.classNameArrayToClassNameString)([_DialogModule.default.closeButton, props.noPadding && _DialogModule.default.noPadding])
67
- }, _react.default.createElement("img", {
68
- src: _xSymbol.default,
69
- alt: ""
70
- })) : null, _react.default.createElement("div", {
71
- "aria-live": "assertive",
72
- role: "dialog"
73
- }, props.children))));
74
- };
75
- Dialog.propTypes = {
76
- maxWidth: _propTypes.default.string,
77
- noPadding: _propTypes.default.bool,
78
- closeButton: _propTypes.default.bool,
79
- onClickOutside: _propTypes.default.func.isRequired,
80
- modal: _propTypes.default.bool
81
- };
82
- Dialog.defaultProps = {
83
- maxWidth: "none",
84
- modal: false
85
- };
86
- var _default = exports.default = Dialog;
@@ -1,178 +0,0 @@
1
- // Mixins
2
- @use "../style/abstracts/mixins/calc";
3
-
4
- // Variables
5
- @use "../style/abstracts/variables/colors";
6
- @use "../style/abstracts/variables/viewports";
7
-
8
- @keyframes modalInVertical {
9
- 0% {
10
- opacity: 0;
11
- transform: translateY(2em);
12
- }
13
- }
14
-
15
- @keyframes modalInHorizontalRight {
16
- 0% {
17
- opacity: 0;
18
- transform: translateX(2em);
19
- }
20
- }
21
-
22
- @keyframes modalInHorizontalLeft {
23
- 0% {
24
- opacity: 0;
25
- transform: translateX(-2em);
26
- }
27
- }
28
-
29
- .dialog {
30
- &::backdrop {
31
- background: color-mix(in srgb, var(--color-primary, colors.$color-primary), transparent 60%);
32
- }
33
- &[open] {
34
- border: none;
35
- background: none;
36
- display: flex;
37
- max-height: none;
38
- max-width: none;
39
- top: 0;
40
- bottom: 0;
41
- left: 0;
42
- position: fixed;
43
- .dialogContainer {
44
- display: flex;
45
- flex-wrap: wrap;
46
- overflow: auto;
47
- .dialogContent {
48
- background-color: #fff;
49
- width: 100%;
50
- }
51
- .dialogContent {
52
- position: relative;
53
- }
54
- .closeButton {
55
- background: none;
56
- border: none;
57
- color: var(--color-primary, colors.$color-primary);
58
- display: inline-block;
59
- position: absolute;
60
- cursor: pointer;
61
- &:hover {
62
- text-decoration: none;
63
- }
64
- img {
65
- width: 17px;
66
- height: 17px;
67
- }
68
- }
69
- }
70
- &:not(.isSidebar) {
71
- align-items: center;
72
- justify-content: center;
73
- padding: 8px 28px;
74
- @media (min-width: viewports.$screen-md) {
75
- padding: 36px;
76
- }
77
- .dialogContainer {
78
- animation: 1000ms cubic-bezier(0.22, 1, 0.36, 1) 0s 1 normal none running modalInVertical;
79
- max-height: 90vh;
80
- .dialogContent {
81
- &:not(.noPadding) {
82
- padding: 30px 15px;
83
- @media only screen and (min-width: viewports.$screen-sm) {
84
- padding: 60px 40px;
85
- }
86
- }
87
- }
88
- }
89
- .closeButton {
90
- &:not(.noPadding) {
91
- right: 5px;
92
- top: 8px;
93
- @media only screen and (min-width: viewports.$screen-sm) {
94
- right: 10px;
95
- top: 13px;
96
- }
97
- }
98
- &.noPadding {
99
- right: 0;
100
- top: 0;
101
- }
102
- }
103
- }
104
- &.isSidebar {
105
- padding: 0;
106
- height: 100vh;
107
- .dialogContainer {
108
- height: 100%;
109
- width: var(--max-width, auto);
110
- max-width: 100vw;
111
- .dialogContent {
112
- &:not(.noPadding) {
113
- padding: 24px;
114
- }
115
- }
116
- }
117
- .closeButton {
118
- z-index: 2;
119
- right: 10px;
120
- top: 13px;
121
- }
122
- &.left {
123
- margin: 0 auto 0 0;
124
- .dialogContainer {
125
- justify-content: left;
126
- animation: 1000ms cubic-bezier(0.22, 1, 0.36, 1) 0s 1 normal none running modalInHorizontalLeft;
127
- }
128
- }
129
- &.right {
130
- margin: 0 0 0 auto;
131
- .dialogContainer {
132
- justify-content: right;
133
- animation: 1000ms cubic-bezier(0.22, 1, 0.36, 1) 0s 1 normal none running modalInHorizontalRight;
134
- }
135
- }
136
- }
137
- }
138
- }
139
-
140
- .dialogOverlay {
141
- width: 0;
142
- height: 0;
143
- border: none;
144
- position: absolute;
145
- padding: 0;
146
- overflow: hidden;
147
-
148
- &[open] {
149
- position: fixed;
150
- width: 100%;
151
- height: 100%;
152
- top: 0;
153
- left: 0;
154
- z-index: 2;
155
- }
156
-
157
- &:not(.isSidebar) {
158
- align-content: center;
159
- justify-content: center;
160
-
161
- .dialogContent {
162
- @include calc.calc("max-height", "100% - 128px");
163
- width: 100%;
164
- max-width: var(--max-width, 540px);
165
- }
166
- }
167
-
168
- .dialogContent {
169
- background-color: #fff;
170
- overflow: auto;
171
- position: relative;
172
-
173
- @media (min-width: viewports.$screen-md) {
174
- @include calc.calc("width", "100% - 128px");
175
- max-height: 100%;
176
- }
177
- }
178
- }