@skatteetaten/ds-overlays 1.5.1 → 2.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.
- package/Modal/index.esm.js +32 -24
- package/Modal/styles.css +1 -1
- package/Popover/index.esm.js +2 -2
- package/PopoverContent.esm.js +3 -3
- package/PopoverTrigger/index.esm.js +3 -3
- package/RolePicker/index.esm.js +15 -15
- package/RolePickerBusinessList/index.esm.js +54 -18
- package/RolePickerFilterInput/index.esm.js +6 -6
- package/RolePickerPeopleList/index.esm.js +49 -21
- package/RolePickerPeopleList/styles.css +1 -1
- package/RolePickerRow/index.esm.js +1 -1
- package/index.esm.js +2 -3
- package/package.json +14 -13
- package/src/Modal/Modal.d.ts +5 -1
- package/src/Modal/Modal.types.d.ts +7 -7
- package/src/PopoverContent/PopoverContent.d.ts +5 -1
- package/src/PopoverContent/PopoverContent.types.d.ts +2 -1
- package/src/PopoverTrigger/PopoverTrigger.d.ts +5 -1
- package/src/PopoverTrigger/PopoverTrigger.types.d.ts +5 -1
- package/src/RolePicker/RolePicker.d.ts +7 -3
- package/src/RolePicker/RolePicker.types.d.ts +7 -2
- package/src/RolePicker/defaults.d.ts +2 -0
- package/src/RolePickerBusinessList/RolePickerBusinessList.d.ts +1 -0
- package/src/RolePickerBusinessList/utils.d.ts +2 -0
- package/src/RolePickerFilterInput/RolePickerFilterInput.d.ts +5 -1
- package/src/RolePickerPeopleList/RolePickerPeopleList.d.ts +2 -1
- package/src/RolePickerPeopleList/RolePickerPeopleList.types.d.ts +1 -0
package/Modal/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useId, useRef, useImperativeHandle, useState, useEffect } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { IconButton } from '@skatteetaten/ds-buttons';
|
|
5
|
-
import { dsI18n,
|
|
5
|
+
import { dsI18n, getCommonClassNameDefault } from '@skatteetaten/ds-core-utils';
|
|
6
6
|
import { CancelSVGpath } from '@skatteetaten/ds-icons';
|
|
7
7
|
import { Heading } from '@skatteetaten/ds-typography';
|
|
8
8
|
import './styles.css';
|
|
@@ -16,11 +16,9 @@ const getModalDismissOnEscDefault = ()=>true;
|
|
|
16
16
|
var styles = {
|
|
17
17
|
"modal": "Modal-module_modal__Kyr-Y",
|
|
18
18
|
"modalContainer": "Modal-module_modalContainer__muf75",
|
|
19
|
-
"modalLogo": "Modal-module_modalLogo__Vaf6E",
|
|
20
19
|
"modalHeading": "Modal-module_modalHeading__uwT1R",
|
|
21
20
|
"modalHeadingNoPadding": "Modal-module_modalHeadingNoPadding__t2hkH",
|
|
22
21
|
"modalIllustration": "Modal-module_modalIllustration__jbA32",
|
|
23
|
-
"modalNoBorder": "Modal-module_modalNoBorder__ReNVP",
|
|
24
22
|
"modalPaddingNONE": "Modal-module_modalPaddingNONE__02HaX",
|
|
25
23
|
"modalPaddingS": "Modal-module_modalPaddingS__O93ax",
|
|
26
24
|
"modalPaddingM": "Modal-module_modalPaddingM__c5Wi2",
|
|
@@ -31,13 +29,15 @@ var styles = {
|
|
|
31
29
|
"srOnly": "Modal-module_srOnly__W8dQv"
|
|
32
30
|
};
|
|
33
31
|
|
|
34
|
-
const Modal =
|
|
32
|
+
const Modal = ({ ref, id, className = getCommonClassNameDefault(), classNames, lang, 'data-testid': dataTestId, dismissOnEsc = getModalDismissOnEscDefault(), dismissOnOutsideClick = getModalDismissOnOutsideClickDefault(), hideCloseButton, hideTitle, imageSource, imageSourceAltText, padding = getModalPaddingDefault(), title, variant = getModalVariantDefault(), shadowRootNode, onClose, renderIcon, children })=>{
|
|
35
33
|
const headingId = `modalHeadingId-${useId()}`;
|
|
36
34
|
const { t } = useTranslation('ds_overlays', {
|
|
37
35
|
i18n: dsI18n
|
|
38
36
|
});
|
|
39
37
|
const statusFlagRef = useRef({
|
|
40
|
-
mouseDownCaptured: false
|
|
38
|
+
mouseDownCaptured: false,
|
|
39
|
+
hasUserInteractionBeforeOpen: false,
|
|
40
|
+
isOpenedAtLeastOnce: false
|
|
41
41
|
});
|
|
42
42
|
const modalRef = useRef(null);
|
|
43
43
|
useImperativeHandle(ref, ()=>modalRef?.current);
|
|
@@ -47,21 +47,32 @@ const Modal = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNameDefa
|
|
|
47
47
|
if (dialog) {
|
|
48
48
|
const originalMethod = dialog.showModal;
|
|
49
49
|
dialog.showModal = function showModal(...args) {
|
|
50
|
-
|
|
50
|
+
statusFlagRef.current.isOpenedAtLeastOnce = true;
|
|
51
|
+
setIsAutoOpened(!statusFlagRef.current.hasUserInteractionBeforeOpen);
|
|
51
52
|
originalMethod.apply(dialog, args);
|
|
52
53
|
};
|
|
53
54
|
}
|
|
55
|
+
const handleUserInteraction = ()=>{
|
|
56
|
+
if (!statusFlagRef.current.isOpenedAtLeastOnce) {
|
|
57
|
+
statusFlagRef.current.hasUserInteractionBeforeOpen = true;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
document.addEventListener('mousedown', handleUserInteraction);
|
|
61
|
+
document.addEventListener('keydown', handleUserInteraction);
|
|
62
|
+
return ()=>{
|
|
63
|
+
document.removeEventListener('mousedown', handleUserInteraction);
|
|
64
|
+
document.removeEventListener('keydown', handleUserInteraction);
|
|
65
|
+
};
|
|
54
66
|
}, []);
|
|
55
67
|
useEffect(()=>{
|
|
56
68
|
const dialog = modalRef.current;
|
|
57
69
|
const handleClose = ()=>{
|
|
58
70
|
if (isAutoOpened) {
|
|
59
71
|
setIsAutoOpened(false);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
skipLink?.focus();
|
|
72
|
+
statusFlagRef.current.hasUserInteractionBeforeOpen = true;
|
|
73
|
+
const elementToFocus = shadowRootNode ? shadowRootNode.querySelector('#topbanner-focus-target') : document.querySelector('#topbanner-focus-target');
|
|
74
|
+
if (elementToFocus) {
|
|
75
|
+
elementToFocus?.focus();
|
|
65
76
|
} else {
|
|
66
77
|
const prevTabIndex = document.body.tabIndex;
|
|
67
78
|
document.body.tabIndex = -1;
|
|
@@ -79,13 +90,14 @@ const Modal = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNameDefa
|
|
|
79
90
|
}
|
|
80
91
|
};
|
|
81
92
|
}, [
|
|
82
|
-
isAutoOpened
|
|
93
|
+
isAutoOpened,
|
|
94
|
+
shadowRootNode
|
|
83
95
|
]);
|
|
84
96
|
useEffect(()=>{
|
|
85
97
|
/**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
* Hvis konsument endrer children i en åpen modal, vil fokus settes til body og dismissOnEsc vil slutte å fungere.
|
|
99
|
+
* Setter derfor fokus tilbake til modalen.
|
|
100
|
+
*/ if (!dismissOnEsc && modalRef.current?.open && document.activeElement?.nodeName === 'BODY') {
|
|
89
101
|
modalRef.current.focus();
|
|
90
102
|
}
|
|
91
103
|
}, [
|
|
@@ -116,17 +128,17 @@ const Modal = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNameDefa
|
|
|
116
128
|
}
|
|
117
129
|
};
|
|
118
130
|
const hideTitleClassName = hideTitle ? styles.srOnly : '';
|
|
119
|
-
const hideOutlineClassName = variant === 'plain' || variant === 'important' ? styles.modalNoBorder : '';
|
|
120
131
|
const paddingClassName = styles[`modalPadding${padding.toUpperCase()}`];
|
|
121
132
|
const noPaddingTop = imageSource ? styles.modalNoPaddingTop : '';
|
|
122
133
|
const headingNoPaddingClassName = padding === 'mega' ? styles.modalHeadingNoPadding : '';
|
|
123
134
|
return /*#__PURE__*/ jsx("dialog", {
|
|
124
135
|
ref: modalRef,
|
|
125
136
|
id: id,
|
|
126
|
-
className: `${styles.modal} ${
|
|
137
|
+
className: `${styles.modal} ${className} ${classNames?.container ?? ''}`.trim(),
|
|
127
138
|
lang: lang,
|
|
128
139
|
"data-testid": dataTestId,
|
|
129
140
|
"aria-labelledby": headingId,
|
|
141
|
+
"data-variant": variant,
|
|
130
142
|
autoFocus: true,
|
|
131
143
|
/* Må bruke onCancel i kombinasjon med onKeyDown siden to trykk på esc lukker modalen i chrome (https://issues.chromium.org/issues/41491338) */ onCancel: (e)=>!dismissOnEsc && e.preventDefault(),
|
|
132
144
|
onKeyDown: (e)=>{
|
|
@@ -162,9 +174,6 @@ const Modal = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNameDefa
|
|
|
162
174
|
/*#__PURE__*/ jsxs("div", {
|
|
163
175
|
className: `${paddingClassName} ${noPaddingTop}`.trim(),
|
|
164
176
|
children: [
|
|
165
|
-
variant === 'important' && /*#__PURE__*/ jsx(SkatteetatenLogo, {
|
|
166
|
-
className: styles.modalLogo
|
|
167
|
-
}),
|
|
168
177
|
renderIcon && /*#__PURE__*/ jsx("div", {
|
|
169
178
|
children: renderIcon?.()
|
|
170
179
|
}),
|
|
@@ -178,12 +187,11 @@ const Modal = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNameDefa
|
|
|
178
187
|
}),
|
|
179
188
|
children
|
|
180
189
|
]
|
|
181
|
-
})
|
|
182
|
-
variant === 'important' && /*#__PURE__*/ jsx(Separator, {})
|
|
190
|
+
})
|
|
183
191
|
]
|
|
184
192
|
})
|
|
185
193
|
});
|
|
186
|
-
}
|
|
194
|
+
};
|
|
187
195
|
Modal.displayName = 'Modal';
|
|
188
196
|
|
|
189
197
|
export { Modal, getModalDismissOnEscDefault, getModalDismissOnOutsideClickDefault, getModalPaddingDefault, getModalVariantDefault };
|
package/Modal/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
html:has(dialog[open]){overflow:hidden}.Modal-module_modal__Kyr-Y{background-color:var(--palette-graphite-0);border:.25rem solid var(--theme-primary);box-shadow:0 0 8px 2px rgba(0,0,0,.16),0 2px 4px -4px rgba(0,0,0,.16);box-sizing:border-box;font-size:var(--font-size-m);font-weight:var(--font-weight-regular);line-height:var(--semantic-line-height-article);max-height:calc(100vh - var(--spacing-m)*2);max-width:calc(var(--semantic-responsive-article) - var(--spacing-m)*2);min-width:calc(300px - var(--spacing-m)*2);overflow-y:auto;padding:0;position:fixed}.Modal-module_modal__Kyr-Y::backdrop{background:hsla(0,0%,100%,.8)}.Modal-module_modalContainer__muf75{outline:none}.Modal-
|
|
1
|
+
html:has(dialog[open]){overflow:hidden}.Modal-module_modal__Kyr-Y{background-color:var(--palette-graphite-0);border:.25rem solid var(--theme-primary);box-shadow:0 0 8px 2px rgba(0,0,0,.16),0 2px 4px -4px rgba(0,0,0,.16);box-sizing:border-box;font-size:var(--font-size-m);font-weight:var(--font-weight-regular);line-height:var(--semantic-line-height-article);max-height:calc(100vh - var(--spacing-m)*2);max-width:calc(var(--semantic-responsive-article) - var(--spacing-m)*2);min-width:calc(300px - var(--spacing-m)*2);overflow-y:auto;padding:0;position:fixed}.Modal-module_modal__Kyr-Y::backdrop{background:hsla(0,0%,100%,.8)}.Modal-module_modalContainer__muf75{outline:none}.Modal-module_modalHeading__uwT1R{padding-right:var(--spacing-xl)}.Modal-module_modalHeadingNoPadding__t2hkH{padding-right:0}.Modal-module_modalIllustration__jbA32{margin-bottom:var(--spacing-m);width:100%}.Modal-module_modal__Kyr-Y[data-variant=plain]{border:none}.Modal-module_modalPaddingNONE__02HaX{padding:0}.Modal-module_modalPaddingS__O93ax{padding:calc(var(--spacing-s) - .25rem)}.Modal-module_modalPaddingM__c5Wi2{padding:calc(var(--spacing-m) - .25rem)}.Modal-module_modalPaddingL__IbVyg{padding:calc(var(--spacing-l) - .25rem)}.Modal-module_modalPaddingMEGA__wWHwS{padding:calc(var(--spacing-mega) - .25rem)}.Modal-module_modalNoPaddingTop__REBWr{padding-top:0}.Modal-module_closeButton__jgbDq{margin:var(--spacing-s);position:absolute;right:0;top:0}.Modal-module_closeButton__jgbDq:not(:active)>svg{fill:var(--palette-graphite-100)}.Modal-module_srOnly__W8dQv{clip:rect(0,0,0,0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}
|
package/Popover/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useRef, useState, useEffect, useMemo } from 'react';
|
|
3
|
-
import { useFloating,
|
|
3
|
+
import { useFloating, offset, flip, shift, arrow, autoUpdate, useDismiss, useInteractions } from '@floating-ui/react';
|
|
4
4
|
import { useMediaQuery } from '@skatteetaten/ds-core-utils';
|
|
5
|
-
import {
|
|
5
|
+
import { a as getPopoverPositionDefault, P as PopoverContent } from '../PopoverContent.esm.js';
|
|
6
6
|
export { g as getPopoverColorDefault, b as getPopoverRestoreFocusDefault } from '../PopoverContent.esm.js';
|
|
7
7
|
import { PopoverContext } from '../PopoverContext/index.esm.js';
|
|
8
8
|
import { PopoverTrigger } from '../PopoverTrigger/index.esm.js';
|
package/PopoverContent.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useContext } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { useMergeRefs } from '@floating-ui/react';
|
|
5
5
|
import { IconButton } from '@skatteetaten/ds-buttons';
|
|
@@ -28,7 +28,7 @@ var styles = {
|
|
|
28
28
|
"popoverArrow_right": "PopoverContent-module_popoverArrow_right__MPxU2"
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
/* eslint-disable react/forbid-dom-props */ const PopoverContent =
|
|
31
|
+
/* eslint-disable react/forbid-dom-props */ const PopoverContent = ({ ref, id, className = getCommonClassNameDefault(), lang, 'data-testid': dataTestId, children })=>{
|
|
32
32
|
const { floatingData, interactions, arrowRef, isOpen, setIsOpen, color = getPopoverColorDefault(), shouldRestoreFocus = getPopoverRestoreFocusDefault(), onClose } = useContext(PopoverContext);
|
|
33
33
|
const { refs, floatingStyles, placement, middlewareData } = floatingData;
|
|
34
34
|
const { getFloatingProps } = interactions;
|
|
@@ -94,7 +94,7 @@ var styles = {
|
|
|
94
94
|
})
|
|
95
95
|
]
|
|
96
96
|
});
|
|
97
|
-
}
|
|
97
|
+
};
|
|
98
98
|
PopoverContent.displayName = 'PopoverContent';
|
|
99
99
|
|
|
100
100
|
export { PopoverContent as P, getPopoverPositionDefault as a, getPopoverRestoreFocusDefault as b, getPopoverColorDefault as g };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useContext } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { useMergeRefs } from '@floating-ui/react';
|
|
5
5
|
import { IconButton } from '@skatteetaten/ds-buttons';
|
|
@@ -7,7 +7,7 @@ import { dsI18n } from '@skatteetaten/ds-core-utils';
|
|
|
7
7
|
import { HelpSimpleSVGpath } from '@skatteetaten/ds-icons';
|
|
8
8
|
import { PopoverContext } from '../PopoverContext/index.esm.js';
|
|
9
9
|
|
|
10
|
-
const PopoverTrigger =
|
|
10
|
+
const PopoverTrigger = ({ ref, id, className, lang, 'data-testid': dataTestId, title, ariaDescribedby, size, svgPath, onClick, onBlur, onFocus })=>{
|
|
11
11
|
const { t } = useTranslation('Shared', {
|
|
12
12
|
i18n: dsI18n
|
|
13
13
|
});
|
|
@@ -37,7 +37,7 @@ const PopoverTrigger = /*#__PURE__*/ forwardRef(({ id, className, lang, 'data-te
|
|
|
37
37
|
onBlur: onBlur,
|
|
38
38
|
onFocus: onFocus
|
|
39
39
|
});
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
PopoverTrigger.displayName = 'PopoverTrigger';
|
|
42
42
|
|
|
43
43
|
export { PopoverTrigger };
|
package/RolePicker/index.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useState, useDeferredValue, useRef, useImperativeHandle, useMemo } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { Button } from '@skatteetaten/ds-buttons';
|
|
5
|
-
import { dsI18n, getCommonClassNameDefault } from '@skatteetaten/ds-core-utils';
|
|
5
|
+
import { dsI18n, getCommonClassNameDefault, formatNationalIdentityNumber } from '@skatteetaten/ds-core-utils';
|
|
6
6
|
import { FavoriteSVGpath, LogOutSVGpath } from '@skatteetaten/ds-icons';
|
|
7
7
|
import { Paragraph } from '@skatteetaten/ds-typography';
|
|
8
|
-
import { Modal,
|
|
8
|
+
import { Modal, getModalDismissOnOutsideClickDefault, getModalDismissOnEscDefault } from '../Modal/index.esm.js';
|
|
9
9
|
import { RolePickerBusinessList } from '../RolePickerBusinessList/index.esm.js';
|
|
10
10
|
import { RolePickerContext } from '../RolePickerContext/index.esm.js';
|
|
11
11
|
import { RolePickerFilterInput } from '../RolePickerFilterInput/index.esm.js';
|
|
@@ -20,16 +20,15 @@ import './styles.css';
|
|
|
20
20
|
const getRolePickerHideCloseButtonDefault = ()=>false;
|
|
21
21
|
const getRolePickerShowSubunitsDefault = ()=>true;
|
|
22
22
|
const getRolePickerShowInactiveBusinessesDefault = ()=>false;
|
|
23
|
+
const getRolePickerShowDeceasedPeopleDefault = ()=>false;
|
|
24
|
+
const getRolePickerMinimumEntitiesForSearchDefault = ()=>11;
|
|
23
25
|
|
|
24
26
|
var styles = {
|
|
25
27
|
"rolePicker": "RolePicker-module_rolePicker__pTz4X",
|
|
26
28
|
"rolePickerFooter": "RolePicker-module_rolePickerFooter__64Pj-",
|
|
27
|
-
"container": "RolePicker-module_container__VtHRL"
|
|
28
|
-
"showMoreButton": "RolePicker-module_showMoreButton__rY5m5",
|
|
29
|
-
"srOnly": "RolePicker-module_srOnly__ePXta"
|
|
30
|
-
};
|
|
29
|
+
"container": "RolePicker-module_container__VtHRL"};
|
|
31
30
|
|
|
32
|
-
const RolePicker =
|
|
31
|
+
const RolePicker = ({ ref, id, className = getCommonClassNameDefault(), lang, 'data-testid': dataTestId, me, businesses, people, title, dismissOnEsc = getModalDismissOnEscDefault(), dismissOnOutsideClick = getModalDismissOnOutsideClickDefault(), hideCloseButton = getRolePickerHideCloseButtonDefault(), minimumEntitiesForSearch = getRolePickerMinimumEntitiesForSearchDefault(), showInactiveBusinesses = getRolePickerShowInactiveBusinessesDefault(), showSubunits = getRolePickerShowSubunitsDefault(), showDeceasedPeople = getRolePickerShowDeceasedPeopleDefault(), onClose, onEntitySelect, onLogout, children })=>{
|
|
33
32
|
const [filter, setFilter] = useState('');
|
|
34
33
|
const [loadingEntityId, setLoadingEntityId] = useState(undefined);
|
|
35
34
|
const [error, setError] = useState(undefined);
|
|
@@ -39,7 +38,7 @@ const RolePicker = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNam
|
|
|
39
38
|
const deferredFilter = useDeferredValue(filter);
|
|
40
39
|
const businessesCount = businesses ? businesses.total : 0;
|
|
41
40
|
const peopleCount = people ? people.total : 0;
|
|
42
|
-
const displaySearch = businessesCount + peopleCount
|
|
41
|
+
const displaySearch = businessesCount + peopleCount >= minimumEntitiesForSearch;
|
|
43
42
|
const modalRef = useRef(null);
|
|
44
43
|
useImperativeHandle(ref, ()=>modalRef.current);
|
|
45
44
|
const handleClose = ()=>{
|
|
@@ -80,7 +79,7 @@ const RolePicker = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNam
|
|
|
80
79
|
}
|
|
81
80
|
};
|
|
82
81
|
const concatenatedClassName = `${styles.container} ${className}`.trim();
|
|
83
|
-
const noValidBusinesses = !me && !people &&
|
|
82
|
+
const noValidBusinesses = !me && !people && businesses && businesses.total === 0;
|
|
84
83
|
let internalTitle = title ? title : t('rolepicker.Heading');
|
|
85
84
|
if (noValidBusinesses) {
|
|
86
85
|
internalTitle = t('rolepicker.NoBusinessesErrorTitle');
|
|
@@ -117,7 +116,7 @@ const RolePicker = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNam
|
|
|
117
116
|
me ? /*#__PURE__*/ jsx(RolePickerRow, {
|
|
118
117
|
id: me.personId,
|
|
119
118
|
title: t('rolepicker.MeHeading'),
|
|
120
|
-
description: `${t('rolepicker.PeopleDescriptionPrefix')} ${me.personId}`,
|
|
119
|
+
description: `${t('rolepicker.PeopleDescriptionPrefix')} ${formatNationalIdentityNumber(me.personId)}`,
|
|
121
120
|
svgPath: FavoriteSVGpath,
|
|
122
121
|
titleAs: 'h2',
|
|
123
122
|
onClick: ()=>{
|
|
@@ -135,14 +134,15 @@ const RolePicker = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNam
|
|
|
135
134
|
}) : null,
|
|
136
135
|
getRepresentationText(),
|
|
137
136
|
displaySearch ? /*#__PURE__*/ jsx(RolePickerFilterInput, {
|
|
138
|
-
label:
|
|
137
|
+
label: t('rolepicker.SearchText'),
|
|
139
138
|
value: filter,
|
|
140
139
|
onChange: (e)=>setFilter(e.target.value),
|
|
141
140
|
onClear: ()=>setFilter('')
|
|
142
141
|
}) : null,
|
|
143
142
|
people && people?.total > 0 ? /*#__PURE__*/ jsx(RolePickerPeopleList, {
|
|
144
143
|
people: people,
|
|
145
|
-
filterQuery: deferredFilter
|
|
144
|
+
filterQuery: deferredFilter,
|
|
145
|
+
showDeceasedPeople: showDeceasedPeople
|
|
146
146
|
}) : null,
|
|
147
147
|
businesses && businesses.total > 0 ? /*#__PURE__*/ jsx(RolePickerBusinessList, {
|
|
148
148
|
businesses: businesses,
|
|
@@ -190,7 +190,7 @@ const RolePicker = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNam
|
|
|
190
190
|
})
|
|
191
191
|
})
|
|
192
192
|
});
|
|
193
|
-
}
|
|
193
|
+
};
|
|
194
194
|
RolePicker.displayName = 'RolePicker';
|
|
195
195
|
|
|
196
|
-
export { RolePicker, getRolePickerHideCloseButtonDefault, getRolePickerShowInactiveBusinessesDefault, getRolePickerShowSubunitsDefault };
|
|
196
|
+
export { RolePicker, getRolePickerHideCloseButtonDefault, getRolePickerMinimumEntitiesForSearchDefault, getRolePickerShowDeceasedPeopleDefault, getRolePickerShowInactiveBusinessesDefault, getRolePickerShowSubunitsDefault };
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useContext, useState, useRef, useMemo, useCallback } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { Button } from '@skatteetaten/ds-buttons';
|
|
5
|
-
import { dsI18n } from '@skatteetaten/ds-core-utils';
|
|
5
|
+
import { dsI18n, formatOrganisationNumber } from '@skatteetaten/ds-core-utils';
|
|
6
6
|
import { Checkbox } from '@skatteetaten/ds-forms';
|
|
7
7
|
import { BriefcaseOffSVGpath, BriefcaseMultipleSVGpath, BriefcaseSVGpath } from '@skatteetaten/ds-icons';
|
|
8
8
|
import { Heading } from '@skatteetaten/ds-typography';
|
|
@@ -13,6 +13,34 @@ import '@skatteetaten/ds-status';
|
|
|
13
13
|
import './styles.css';
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
const unitTypesToHide = [
|
|
17
|
+
'AS',
|
|
18
|
+
'DA',
|
|
19
|
+
'ANS',
|
|
20
|
+
'ASA',
|
|
21
|
+
'SE',
|
|
22
|
+
'BA',
|
|
23
|
+
'SA',
|
|
24
|
+
'SCE',
|
|
25
|
+
'STI',
|
|
26
|
+
'IKS',
|
|
27
|
+
'KF',
|
|
28
|
+
'FKF',
|
|
29
|
+
'RHF',
|
|
30
|
+
'HF',
|
|
31
|
+
'NUF'
|
|
32
|
+
];
|
|
33
|
+
const getBusinessTitle = (business)=>{
|
|
34
|
+
let title = business.name;
|
|
35
|
+
if (!unitTypesToHide.includes(business.unitType)) {
|
|
36
|
+
title += ` ${business.unitType}`;
|
|
37
|
+
}
|
|
38
|
+
if (business.isDeleted) {
|
|
39
|
+
title += ` (${dsI18n.t('ds_overlays:rolepicker.Deleted')})`;
|
|
40
|
+
}
|
|
41
|
+
return title;
|
|
42
|
+
};
|
|
43
|
+
|
|
16
44
|
var styles = {
|
|
17
45
|
"businessList": "RolePickerBusinessList-module_businessList__15fne",
|
|
18
46
|
"checkboxGroup": "RolePickerBusinessList-module_checkboxGroup__cdE2w",
|
|
@@ -27,15 +55,19 @@ const RolePickerBusinessList = ({ businesses, filterQuery, showInactiveBusinesse
|
|
|
27
55
|
i18n: dsI18n
|
|
28
56
|
});
|
|
29
57
|
const ctx = useContext(RolePickerContext);
|
|
30
|
-
const [
|
|
58
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
31
59
|
const [showInactiveBusinesses, setShowInactiveBusinesses] = useState(externalShowInactiveBusinesses);
|
|
32
60
|
const [showSubUnits, setShowSubUnits] = useState(externalShowSubUnits);
|
|
33
61
|
const navRef = useRef(null);
|
|
34
|
-
const
|
|
62
|
+
const handleExpand = ()=>{
|
|
35
63
|
const visibleLinks = navRef.current?.querySelectorAll('a').length ?? 1;
|
|
36
|
-
|
|
64
|
+
setIsExpanded(true);
|
|
37
65
|
navRef.current?.querySelectorAll('a')[visibleLinks - 1].focus();
|
|
38
66
|
};
|
|
67
|
+
const handleCollapse = ()=>{
|
|
68
|
+
setIsExpanded(false);
|
|
69
|
+
navRef.current?.querySelectorAll('a')[0].focus();
|
|
70
|
+
};
|
|
39
71
|
const handleEntityClicked = async (entity)=>{
|
|
40
72
|
ctx?.setLoadingEntityId(entity.organizationNumber);
|
|
41
73
|
ctx?.onEntitySelect?.(entity).then((res)=>{
|
|
@@ -69,15 +101,15 @@ const RolePickerBusinessList = ({ businesses, filterQuery, showInactiveBusinesse
|
|
|
69
101
|
return false;
|
|
70
102
|
});
|
|
71
103
|
} else {
|
|
72
|
-
items =
|
|
104
|
+
items = isExpanded ? items : items.slice(0, MAX_INITIAL_ITEMS);
|
|
73
105
|
}
|
|
74
106
|
return items;
|
|
75
107
|
}, [
|
|
76
|
-
filterQuery,
|
|
77
108
|
businesses.list,
|
|
78
|
-
showAll,
|
|
79
109
|
showInactiveBusinesses,
|
|
80
|
-
|
|
110
|
+
filterQuery,
|
|
111
|
+
showSubUnits,
|
|
112
|
+
isExpanded
|
|
81
113
|
]);
|
|
82
114
|
const hasInactiveItems = businesses.list.some((business)=>business.isDeleted || business.subunits?.some((sub)=>sub.isDeleted));
|
|
83
115
|
const hasItemsWithSubOranizations = businesses.list.some((business)=>business.subunits);
|
|
@@ -101,7 +133,7 @@ const RolePickerBusinessList = ({ businesses, filterQuery, showInactiveBusinesse
|
|
|
101
133
|
showInactiveBusinesses,
|
|
102
134
|
showSubUnits
|
|
103
135
|
]);
|
|
104
|
-
const
|
|
136
|
+
const displayExpandCollapseButton = !filterQuery && businesses.list?.length > MAX_INITIAL_ITEMS;
|
|
105
137
|
return /*#__PURE__*/ jsxs("div", {
|
|
106
138
|
children: [
|
|
107
139
|
/*#__PURE__*/ jsx(Heading, {
|
|
@@ -137,12 +169,12 @@ const RolePickerBusinessList = ({ businesses, filterQuery, showInactiveBusinesse
|
|
|
137
169
|
children: [
|
|
138
170
|
/*#__PURE__*/ jsx(RolePickerRow, {
|
|
139
171
|
id: item.organizationNumber,
|
|
140
|
-
title:
|
|
172
|
+
title: getBusinessTitle(item),
|
|
141
173
|
description: /*#__PURE__*/ jsxs(Fragment, {
|
|
142
174
|
children: [
|
|
143
175
|
t('rolepicker.BusinessDescriptionPrefix'),
|
|
144
176
|
' ',
|
|
145
|
-
item.organizationNumber,
|
|
177
|
+
formatOrganisationNumber(item.organizationNumber),
|
|
146
178
|
' ',
|
|
147
179
|
/*#__PURE__*/ jsxs("em", {
|
|
148
180
|
children: [
|
|
@@ -165,13 +197,13 @@ const RolePickerBusinessList = ({ businesses, filterQuery, showInactiveBusinesse
|
|
|
165
197
|
className: styles.subUnit,
|
|
166
198
|
children: /*#__PURE__*/ jsx(RolePickerRow, {
|
|
167
199
|
id: sub.organizationNumber,
|
|
168
|
-
title:
|
|
200
|
+
title: getBusinessTitle(sub),
|
|
169
201
|
titleAs: 'h4',
|
|
170
202
|
description: /*#__PURE__*/ jsxs(Fragment, {
|
|
171
203
|
children: [
|
|
172
204
|
t('rolepicker.BusinessDescriptionPrefix'),
|
|
173
205
|
' ',
|
|
174
|
-
sub.organizationNumber,
|
|
206
|
+
formatOrganisationNumber(sub.organizationNumber),
|
|
175
207
|
' ',
|
|
176
208
|
/*#__PURE__*/ jsxs("em", {
|
|
177
209
|
children: [
|
|
@@ -197,8 +229,8 @@ const RolePickerBusinessList = ({ businesses, filterQuery, showInactiveBusinesse
|
|
|
197
229
|
return /*#__PURE__*/ jsx("li", {
|
|
198
230
|
children: /*#__PURE__*/ jsx(RolePickerRow, {
|
|
199
231
|
id: item.organizationNumber,
|
|
200
|
-
title:
|
|
201
|
-
description: `${t('rolepicker.BusinessDescriptionPrefix')} ${item.organizationNumber}`,
|
|
232
|
+
title: getBusinessTitle(item),
|
|
233
|
+
description: `${t('rolepicker.BusinessDescriptionPrefix')} ${formatOrganisationNumber(item.organizationNumber)}`,
|
|
202
234
|
svgPath: item.isDeleted ? BriefcaseOffSVGpath : svgPath,
|
|
203
235
|
onClick: ()=>{
|
|
204
236
|
handleEntityClicked(item);
|
|
@@ -209,11 +241,15 @@ const RolePickerBusinessList = ({ businesses, filterQuery, showInactiveBusinesse
|
|
|
209
241
|
})
|
|
210
242
|
})
|
|
211
243
|
}),
|
|
212
|
-
|
|
244
|
+
displayExpandCollapseButton ? /*#__PURE__*/ jsx("div", {
|
|
213
245
|
className: styles.showAllButtonWrapper,
|
|
214
|
-
children: /*#__PURE__*/ jsx(Button, {
|
|
246
|
+
children: isExpanded ? /*#__PURE__*/ jsx(Button, {
|
|
247
|
+
variant: 'tertiary',
|
|
248
|
+
onClick: handleCollapse,
|
|
249
|
+
children: t('rolepicker.ShowLess')
|
|
250
|
+
}) : /*#__PURE__*/ jsx(Button, {
|
|
215
251
|
variant: 'tertiary',
|
|
216
|
-
onClick:
|
|
252
|
+
onClick: handleExpand,
|
|
217
253
|
children: `${t('rolepicker.ShowAll')} ${t('rolepicker.Businesses')} (${getShowAllCount()})`
|
|
218
254
|
})
|
|
219
255
|
}) : null
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useRef, useState, useEffect } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { IconButton } from '@skatteetaten/ds-buttons';
|
|
5
5
|
import { dsI18n } from '@skatteetaten/ds-core-utils';
|
|
@@ -18,7 +18,7 @@ var styles = {
|
|
|
18
18
|
"srOnly": "RolePickerFilterInput-module_srOnly__CFhaY"
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const RolePickerFilterInput =
|
|
21
|
+
const RolePickerFilterInput = ({ label, value, onChange, onClear })=>{
|
|
22
22
|
const { t: formsT } = useTranslation('ds_forms', {
|
|
23
23
|
i18n: dsI18n
|
|
24
24
|
});
|
|
@@ -49,16 +49,16 @@ const RolePickerFilterInput = /*#__PURE__*/ forwardRef(({ label, value, onChange
|
|
|
49
49
|
htmlFor: 'filterInputId',
|
|
50
50
|
children: label
|
|
51
51
|
}),
|
|
52
|
-
/*#__PURE__*/ jsx("
|
|
52
|
+
/*#__PURE__*/ jsx("div", {
|
|
53
53
|
className: styles.srOnly,
|
|
54
54
|
id: 'liveSearchId',
|
|
55
55
|
children: t('rolepicker.SearchResultDescription')
|
|
56
56
|
}),
|
|
57
|
-
/*#__PURE__*/ jsx("
|
|
57
|
+
/*#__PURE__*/ jsx("div", {
|
|
58
58
|
className: styles.srOnly,
|
|
59
59
|
"aria-live": 'assertive',
|
|
60
60
|
"aria-atomic": 'true',
|
|
61
|
-
children: value ? /*#__PURE__*/ jsx("
|
|
61
|
+
children: value ? /*#__PURE__*/ jsx("div", {
|
|
62
62
|
children: liveRegionContent
|
|
63
63
|
}) : null
|
|
64
64
|
}),
|
|
@@ -103,7 +103,7 @@ const RolePickerFilterInput = /*#__PURE__*/ forwardRef(({ label, value, onChange
|
|
|
103
103
|
]
|
|
104
104
|
})
|
|
105
105
|
});
|
|
106
|
-
}
|
|
106
|
+
};
|
|
107
107
|
RolePickerFilterInput.displayName = 'RolePickerFilterInput';
|
|
108
108
|
|
|
109
109
|
export { RolePickerFilterInput };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useContext, useRef, useMemo } from 'react';
|
|
2
|
+
import { useState, useContext, useRef, useMemo, useCallback } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { Button } from '@skatteetaten/ds-buttons';
|
|
5
|
-
import { dsI18n } from '@skatteetaten/ds-core-utils';
|
|
5
|
+
import { dsI18n, formatNationalIdentityNumber } from '@skatteetaten/ds-core-utils';
|
|
6
|
+
import { Checkbox } from '@skatteetaten/ds-forms';
|
|
6
7
|
import { PersonSVGpath } from '@skatteetaten/ds-icons';
|
|
7
8
|
import { Heading } from '@skatteetaten/ds-typography';
|
|
8
9
|
import { RolePickerContext } from '../RolePickerContext/index.esm.js';
|
|
@@ -14,20 +15,26 @@ import './styles.css';
|
|
|
14
15
|
|
|
15
16
|
var styles = {
|
|
16
17
|
"peopleList": "RolePickerPeopleList-module_peopleList__dEumR",
|
|
18
|
+
"showDeceasedChecbox": "RolePickerPeopleList-module_showDeceasedChecbox__4SCg3",
|
|
17
19
|
"showAllButtonWrapper": "RolePickerPeopleList-module_showAllButtonWrapper__-ErxO"
|
|
18
20
|
};
|
|
19
21
|
|
|
20
|
-
const
|
|
21
|
-
const RolePickerPeopleList = ({ people, filterQuery })=>{
|
|
22
|
+
const MAX_INITIAL_ITEMS = 5;
|
|
23
|
+
const RolePickerPeopleList = ({ people, filterQuery, showDeceasedPeople: showDeceasedPeopleExternal })=>{
|
|
22
24
|
const { t } = useTranslation('ds_overlays', {
|
|
23
25
|
i18n: dsI18n
|
|
24
26
|
});
|
|
25
|
-
const [
|
|
27
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
28
|
+
const [showDeceasedPeople, setShowDeceasedPeople] = useState(showDeceasedPeopleExternal);
|
|
26
29
|
const ctx = useContext(RolePickerContext);
|
|
27
30
|
const navRef = useRef(null);
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
navRef.current?.querySelectorAll('a')[
|
|
31
|
+
const handleExpand = ()=>{
|
|
32
|
+
setIsExpanded(true);
|
|
33
|
+
navRef.current?.querySelectorAll('a')[MAX_INITIAL_ITEMS - 1].focus();
|
|
34
|
+
};
|
|
35
|
+
const handleCollapse = ()=>{
|
|
36
|
+
setIsExpanded(false);
|
|
37
|
+
navRef.current?.querySelectorAll('a')[0].focus();
|
|
31
38
|
};
|
|
32
39
|
const handleEntityClicked = async (entity)=>{
|
|
33
40
|
ctx?.setLoadingEntityId(entity.personId);
|
|
@@ -42,19 +49,30 @@ const RolePickerPeopleList = ({ people, filterQuery })=>{
|
|
|
42
49
|
});
|
|
43
50
|
};
|
|
44
51
|
const visibleItems = useMemo(()=>{
|
|
52
|
+
// lager en dyp kopiering av person-listen for å unngå mutasjon
|
|
53
|
+
let items = JSON.parse(JSON.stringify(people.list));
|
|
54
|
+
items = !showDeceasedPeople ? items.filter((p)=>!p.isDeleted) : items;
|
|
45
55
|
if (filterQuery) {
|
|
46
|
-
return
|
|
56
|
+
return items.filter((f)=>f.name.toLowerCase().includes(filterQuery.toLowerCase()) || f.personId.includes(filterQuery.toLowerCase()));
|
|
47
57
|
}
|
|
48
|
-
if (
|
|
49
|
-
return
|
|
58
|
+
if (isExpanded) {
|
|
59
|
+
return items;
|
|
50
60
|
}
|
|
51
|
-
return
|
|
61
|
+
return items.slice(0, MAX_INITIAL_ITEMS);
|
|
52
62
|
}, [
|
|
63
|
+
people.list,
|
|
64
|
+
showDeceasedPeople,
|
|
53
65
|
filterQuery,
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
isExpanded
|
|
67
|
+
]);
|
|
68
|
+
const getShowAllCount = useCallback(()=>{
|
|
69
|
+
return showDeceasedPeople ? people.total : people.list.filter((p)=>!p.isDeleted).length;
|
|
70
|
+
}, [
|
|
71
|
+
people.list,
|
|
72
|
+
people.total,
|
|
73
|
+
showDeceasedPeople
|
|
56
74
|
]);
|
|
57
|
-
const
|
|
75
|
+
const displayToggleAllButton = !filterQuery && people.total > MAX_INITIAL_ITEMS;
|
|
58
76
|
return /*#__PURE__*/ jsxs("div", {
|
|
59
77
|
children: [
|
|
60
78
|
/*#__PURE__*/ jsx(Heading, {
|
|
@@ -63,6 +81,12 @@ const RolePickerPeopleList = ({ people, filterQuery })=>{
|
|
|
63
81
|
id: 'otherPeopleHeadingId',
|
|
64
82
|
children: filterQuery ? `${visibleItems.length} ${t('rolepicker.PeopleHits')}` : t('rolepicker.PeopleHeading')
|
|
65
83
|
}),
|
|
84
|
+
people.list.some((person)=>person.isDeleted) ? /*#__PURE__*/ jsx(Checkbox, {
|
|
85
|
+
className: styles.showDeceasedChecbox,
|
|
86
|
+
checked: showDeceasedPeople,
|
|
87
|
+
onChange: (e)=>setShowDeceasedPeople(e.target.checked),
|
|
88
|
+
children: t('rolepicker.ShowDeceasedPersons')
|
|
89
|
+
}) : null,
|
|
66
90
|
/*#__PURE__*/ jsx("nav", {
|
|
67
91
|
ref: navRef,
|
|
68
92
|
"aria-labelledby": 'otherPeopleHeadingId',
|
|
@@ -72,8 +96,8 @@ const RolePickerPeopleList = ({ people, filterQuery })=>{
|
|
|
72
96
|
return /*#__PURE__*/ jsx("li", {
|
|
73
97
|
children: /*#__PURE__*/ jsx(RolePickerRow, {
|
|
74
98
|
id: item.personId,
|
|
75
|
-
title: item.name
|
|
76
|
-
description: `${t('rolepicker.PeopleDescriptionPrefix')} ${item.personId}`,
|
|
99
|
+
title: `${item.name}${item.isDeleted ? ` (${t('rolepicker.Deceased')})` : ''}`,
|
|
100
|
+
description: `${t('rolepicker.PeopleDescriptionPrefix')} ${formatNationalIdentityNumber(item.personId)}`,
|
|
77
101
|
svgPath: PersonSVGpath,
|
|
78
102
|
onClick: ()=>handleEntityClicked(item)
|
|
79
103
|
})
|
|
@@ -81,12 +105,16 @@ const RolePickerPeopleList = ({ people, filterQuery })=>{
|
|
|
81
105
|
})
|
|
82
106
|
})
|
|
83
107
|
}),
|
|
84
|
-
|
|
108
|
+
displayToggleAllButton ? /*#__PURE__*/ jsx("div", {
|
|
85
109
|
className: styles.showAllButtonWrapper,
|
|
86
|
-
children: /*#__PURE__*/ jsx(Button, {
|
|
110
|
+
children: isExpanded ? /*#__PURE__*/ jsx(Button, {
|
|
111
|
+
variant: 'tertiary',
|
|
112
|
+
onClick: handleCollapse,
|
|
113
|
+
children: t('rolepicker.ShowLess')
|
|
114
|
+
}) : /*#__PURE__*/ jsx(Button, {
|
|
87
115
|
variant: 'tertiary',
|
|
88
|
-
onClick:
|
|
89
|
-
children: `${t('rolepicker.ShowAll')} ${t('rolepicker.People')} (${
|
|
116
|
+
onClick: handleExpand,
|
|
117
|
+
children: `${t('rolepicker.ShowAll')} ${t('rolepicker.People')} (${getShowAllCount()})`
|
|
90
118
|
})
|
|
91
119
|
}) : null
|
|
92
120
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.RolePickerPeopleList-module_peopleList__dEumR{display:flex;flex-direction:column;gap:var(--spacing-s);list-style-type:none;padding:0}.RolePickerPeopleList-module_showAllButtonWrapper__-ErxO{margin-top:var(--spacing-xs);text-align:right}
|
|
1
|
+
.RolePickerPeopleList-module_peopleList__dEumR{display:flex;flex-direction:column;gap:var(--spacing-s);list-style-type:none;padding:0}.RolePickerPeopleList-module_showDeceasedChecbox__4SCg3{margin-top:var(--spacing-s)}.RolePickerPeopleList-module_showAllButtonWrapper__-ErxO{margin-top:var(--spacing-xs);text-align:right}
|
|
@@ -30,7 +30,7 @@ function RolePickerRow({ id, title, description, svgPath, titleAs, onClick }) {
|
|
|
30
30
|
}
|
|
31
31
|
}),
|
|
32
32
|
/*#__PURE__*/ jsx(Alert, {
|
|
33
|
-
variant: '
|
|
33
|
+
variant: 'warning',
|
|
34
34
|
showAlert: hasError,
|
|
35
35
|
onClose: ()=>ctx?.setError(undefined),
|
|
36
36
|
children: ctx?.error?.message
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Modal, getModalDismissOnEscDefault, getModalDismissOnOutsideClickDefault, getModalPaddingDefault, getModalVariantDefault } from './Modal/index.esm.js';
|
|
2
2
|
export { Popover } from './Popover/index.esm.js';
|
|
3
3
|
import { colorNamesArr } from '@skatteetaten/ds-core-utils';
|
|
4
|
-
export { RolePicker, getRolePickerHideCloseButtonDefault, getRolePickerShowInactiveBusinessesDefault, getRolePickerShowSubunitsDefault } from './RolePicker/index.esm.js';
|
|
4
|
+
export { RolePicker, getRolePickerHideCloseButtonDefault, getRolePickerMinimumEntitiesForSearchDefault, getRolePickerShowDeceasedPeopleDefault, getRolePickerShowInactiveBusinessesDefault, getRolePickerShowSubunitsDefault } from './RolePicker/index.esm.js';
|
|
5
5
|
export { g as getPopoverColorDefault, a as getPopoverPositionDefault, b as getPopoverRestoreFocusDefault } from './PopoverContent.esm.js';
|
|
6
6
|
import 'react/jsx-runtime';
|
|
7
7
|
import 'react';
|
|
@@ -30,8 +30,7 @@ const modalPaddingArr = [
|
|
|
30
30
|
];
|
|
31
31
|
const modalVariantArr = [
|
|
32
32
|
'outline',
|
|
33
|
-
'plain'
|
|
34
|
-
'important'
|
|
33
|
+
'plain'
|
|
35
34
|
];
|
|
36
35
|
|
|
37
36
|
const popoverColorArr = [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skatteetaten/ds-overlays",
|
|
3
3
|
"groupId": "no.skatteetaten.aurora",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"main": "./index.esm.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"module": "./index.esm.js",
|
|
@@ -13,19 +13,20 @@
|
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"homepage": "https://www.skatteetaten.no/stilogtone/designsystemet/",
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"i18next": "^
|
|
17
|
-
"react": "^
|
|
18
|
-
"react-i18next": "^
|
|
19
|
-
"@skatteetaten/ds-core-utils": "
|
|
20
|
-
"@skatteetaten/ds-buttons": "
|
|
21
|
-
"@skatteetaten/ds-forms": "
|
|
22
|
-
"@skatteetaten/ds-icons": "
|
|
23
|
-
"@skatteetaten/ds-navigation": "
|
|
24
|
-
"@skatteetaten/ds-typography": "
|
|
25
|
-
"@skatteetaten/ds-progress": "
|
|
26
|
-
"@skatteetaten/ds-status": "
|
|
16
|
+
"i18next": "^24",
|
|
17
|
+
"react": "^19 ",
|
|
18
|
+
"react-i18next": "^15",
|
|
19
|
+
"@skatteetaten/ds-core-utils": "2.0.0",
|
|
20
|
+
"@skatteetaten/ds-buttons": "2.0.0",
|
|
21
|
+
"@skatteetaten/ds-forms": "2.0.0",
|
|
22
|
+
"@skatteetaten/ds-icons": "2.0.0",
|
|
23
|
+
"@skatteetaten/ds-navigation": "2.0.0",
|
|
24
|
+
"@skatteetaten/ds-typography": "2.0.0",
|
|
25
|
+
"@skatteetaten/ds-progress": "2.0.0",
|
|
26
|
+
"@skatteetaten/ds-status": "2.0.0",
|
|
27
|
+
"date-fns": "^4",
|
|
27
28
|
"@floating-ui/react": "0.26.28",
|
|
28
|
-
"
|
|
29
|
+
"@skatteetaten/ds-content": "2.0.0"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {},
|
|
31
32
|
"scripts": {}
|
package/src/Modal/Modal.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
1
2
|
import { getModalDismissOnEscDefault, getModalDismissOnOutsideClickDefault, getModalPaddingDefault, getModalVariantDefault } from './defaults';
|
|
2
3
|
import { ModalProps } from './Modal.types';
|
|
3
|
-
export declare const Modal:
|
|
4
|
+
export declare const Modal: {
|
|
5
|
+
({ ref, id, className, classNames, lang, "data-testid": dataTestId, dismissOnEsc, dismissOnOutsideClick, hideCloseButton, hideTitle, imageSource, imageSourceAltText, padding, title, variant, shadowRootNode, onClose, renderIcon, children, }: ModalProps): JSX.Element;
|
|
6
|
+
displayName: string;
|
|
7
|
+
};
|
|
4
8
|
export { getModalPaddingDefault, getModalVariantDefault, getModalDismissOnOutsideClickDefault, getModalDismissOnEscDefault, };
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from 'react';
|
|
1
|
+
import { ReactElement, ReactNode, Ref } from 'react';
|
|
2
2
|
import { BaseProps } from '@skatteetaten/ds-core-utils';
|
|
3
3
|
import { IconProps } from '@skatteetaten/ds-icons';
|
|
4
4
|
export declare const modalPaddingArr: readonly ["none", "s", "m", "l", "mega"];
|
|
5
5
|
export type ModalPadding = (typeof modalPaddingArr)[number];
|
|
6
|
-
export declare const modalVariantArr: readonly ["outline", "plain"
|
|
6
|
+
export declare const modalVariantArr: readonly ["outline", "plain"];
|
|
7
7
|
export type ModalVariant = (typeof modalVariantArr)[number];
|
|
8
8
|
export interface ModalProps extends BaseProps {
|
|
9
|
+
ref?: Ref<HTMLDialogElement>;
|
|
9
10
|
classNames?: {
|
|
10
11
|
container?: string;
|
|
11
12
|
image?: string;
|
|
12
13
|
};
|
|
13
14
|
/** Innhold */
|
|
14
15
|
children: ReactNode;
|
|
15
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Definerer stilen til Modal.
|
|
18
|
+
*/
|
|
16
19
|
variant?: ModalVariant;
|
|
17
20
|
/** Padding rundt Modal */
|
|
18
21
|
padding?: ModalPadding;
|
|
@@ -32,10 +35,7 @@ export interface ModalProps extends BaseProps {
|
|
|
32
35
|
imageSourceAltText?: string;
|
|
33
36
|
/** Icon-komponent som en funksjon som vises over overskriften */
|
|
34
37
|
renderIcon?: () => ReactElement<IconProps>;
|
|
35
|
-
/**
|
|
36
|
-
* Modal i shadowndom.
|
|
37
|
-
* Deprecated: Prop skal fjernes ved lansering av neste major versjon.
|
|
38
|
-
*/
|
|
38
|
+
/** Modal i shadowndom. */
|
|
39
39
|
shadowRootNode?: Document | ShadowRoot;
|
|
40
40
|
/** Callback når modalen lukkes */
|
|
41
41
|
onClose?: () => void;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
1
2
|
import { PopoverContentProps } from './PopoverContent.types';
|
|
2
|
-
export declare const PopoverContent:
|
|
3
|
+
export declare const PopoverContent: {
|
|
4
|
+
({ ref, id, className, lang, "data-testid": dataTestId, children, }: PopoverContentProps): JSX.Element | null;
|
|
5
|
+
displayName: string;
|
|
6
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ReactNode, Ref } from 'react';
|
|
2
2
|
import { BaseProps } from '@skatteetaten/ds-core-utils';
|
|
3
3
|
export declare const popoverPositionArr: readonly ["top-start", "top-end", "bottom-start", "bottom-end"];
|
|
4
4
|
export type PopoverPosition = (typeof popoverPositionArr)[number];
|
|
5
5
|
export declare const popoverColorArr: readonly ["forest", "ochre", "white"];
|
|
6
6
|
export type PopoverColor = (typeof popoverColorArr)[number];
|
|
7
7
|
export interface PopoverContentProps extends BaseProps {
|
|
8
|
+
ref?: Ref<HTMLDivElement>;
|
|
8
9
|
/** Tekst */
|
|
9
10
|
children: ReactNode;
|
|
10
11
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
1
2
|
import { PopoverTriggerProps } from './PopoverTrigger.types';
|
|
2
|
-
export declare const PopoverTrigger:
|
|
3
|
+
export declare const PopoverTrigger: {
|
|
4
|
+
({ ref, id, className, lang, "data-testid": dataTestId, title, ariaDescribedby, size, svgPath, onClick, onBlur, onFocus, }: PopoverTriggerProps): JSX.Element;
|
|
5
|
+
displayName: string;
|
|
6
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
1
2
|
import { IconButtonProps } from '@skatteetaten/ds-buttons';
|
|
2
3
|
import { BaseProps } from '@skatteetaten/ds-core-utils';
|
|
3
4
|
type PropsFromIconButton = Pick<IconButtonProps, 'size' | 'svgPath' | 'title' | 'ariaDescribedby' | 'onClick' | 'onBlur' | 'onFocus'>;
|
|
4
|
-
|
|
5
|
+
type PopoverTriggerCommonProps = BaseProps & {
|
|
6
|
+
ref?: Ref<HTMLButtonElement>;
|
|
7
|
+
};
|
|
8
|
+
export interface PopoverTriggerProps extends PopoverTriggerCommonProps, Partial<PropsFromIconButton> {
|
|
5
9
|
}
|
|
6
10
|
export {};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { getRolePickerHideCloseButtonDefault, getRolePickerMinimumEntitiesForSearchDefault, getRolePickerShowDeceasedPeopleDefault, getRolePickerShowInactiveBusinessesDefault, getRolePickerShowSubunitsDefault } from './defaults';
|
|
2
3
|
import { RolePickerProps } from './RolePicker.types';
|
|
3
|
-
export declare const RolePicker:
|
|
4
|
-
|
|
4
|
+
export declare const RolePicker: {
|
|
5
|
+
({ ref, id, className, lang, "data-testid": dataTestId, me, businesses, people, title, dismissOnEsc, dismissOnOutsideClick, hideCloseButton, minimumEntitiesForSearch, showInactiveBusinesses, showSubunits, showDeceasedPeople, onClose, onEntitySelect, onLogout, children, }: RolePickerProps): JSX.Element;
|
|
6
|
+
displayName: string;
|
|
7
|
+
};
|
|
8
|
+
export { getRolePickerHideCloseButtonDefault, getRolePickerShowInactiveBusinessesDefault, getRolePickerShowSubunitsDefault, getRolePickerShowDeceasedPeopleDefault, getRolePickerMinimumEntitiesForSearchDefault, };
|
|
@@ -23,6 +23,7 @@ export type OnEntitySelectHandler = (entity: Entity) => Promise<{
|
|
|
23
23
|
error: string;
|
|
24
24
|
} | void>;
|
|
25
25
|
export interface RolePickerProps extends BaseProps, Partial<Pick<ModalProps, 'dismissOnEsc' | 'dismissOnOutsideClick' | 'hideCloseButton' | 'onClose'>> {
|
|
26
|
+
ref?: React.Ref<HTMLDialogElement>;
|
|
26
27
|
/** Egendefinert tittel på modal. */
|
|
27
28
|
title?: string;
|
|
28
29
|
/** Den nåværende brukeren representert som et Person-objekt. */
|
|
@@ -31,10 +32,14 @@ export interface RolePickerProps extends BaseProps, Partial<Pick<ModalProps, 'di
|
|
|
31
32
|
people?: Paginated<Person>;
|
|
32
33
|
/** En paginert liste over virksomheter. */
|
|
33
34
|
businesses?: Paginated<Business>;
|
|
34
|
-
/**
|
|
35
|
+
/** Minimum antall personer/virksomheter som kreves for at søkefelt skal være synlig. Default: 11. */
|
|
36
|
+
minimumEntitiesForSearch?: number;
|
|
37
|
+
/** Om avviklede virksomheter skal vises som standard når rollevelger åpnes. */
|
|
35
38
|
showInactiveBusinesses?: boolean;
|
|
36
|
-
/** Om underenheter av virksomheter skal vises. */
|
|
39
|
+
/** Om underenheter av virksomheter skal vises som standard når rollevelger åpnes. */
|
|
37
40
|
showSubunits?: boolean;
|
|
41
|
+
/** Om avdøde personer skal vises som standard når rollevelger åpnes. */
|
|
42
|
+
showDeceasedPeople?: boolean;
|
|
38
43
|
/** Tilbakekallingsfunksjon for å håndtere valg av virksomhet/person. */
|
|
39
44
|
onEntitySelect?: OnEntitySelectHandler;
|
|
40
45
|
/** Tilbakekallingsfunksjon for å håndtere utlogging. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const getRolePickerHideCloseButtonDefault: () => boolean;
|
|
2
2
|
export declare const getRolePickerShowSubunitsDefault: () => boolean;
|
|
3
3
|
export declare const getRolePickerShowInactiveBusinessesDefault: () => boolean;
|
|
4
|
+
export declare const getRolePickerShowDeceasedPeopleDefault: () => boolean;
|
|
5
|
+
export declare const getRolePickerMinimumEntitiesForSearchDefault: () => number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
1
2
|
import { RolePickerBusinessListProps } from './RolePickerBusinessList.types';
|
|
2
3
|
export declare const RolePickerBusinessList: {
|
|
3
4
|
({ businesses, filterQuery, showInactiveBusinesses: externalShowInactiveBusinesses, showSubunits: externalShowSubUnits, }: RolePickerBusinessListProps): JSX.Element | null;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
1
2
|
import { RolePickerFilterInputProps } from './RolePickerFilterInput.types';
|
|
2
|
-
export declare const RolePickerFilterInput:
|
|
3
|
+
export declare const RolePickerFilterInput: {
|
|
4
|
+
({ label, value, onChange, onClear, }: RolePickerFilterInputProps): JSX.Element;
|
|
5
|
+
displayName: string;
|
|
6
|
+
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
1
2
|
import { RolePickerPeopleListProps } from './RolePickerPeopleList.types';
|
|
2
|
-
export declare const RolePickerPeopleList: ({ people, filterQuery, }: RolePickerPeopleListProps) => JSX.Element | null;
|
|
3
|
+
export declare const RolePickerPeopleList: ({ people, filterQuery, showDeceasedPeople: showDeceasedPeopleExternal, }: RolePickerPeopleListProps) => JSX.Element | null;
|