@skatteetaten/ds-overlays 1.6.0 → 2.0.1
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 -27
- package/Modal/styles.css +1 -1
- package/PopoverContent.esm.js +3 -3
- package/PopoverTrigger/index.esm.js +3 -3
- package/RolePicker/index.esm.js +9 -8
- package/RolePickerBusinessList/index.esm.js +54 -18
- package/RolePickerFilterInput/index.esm.js +3 -3
- package/RolePickerPeopleList/index.esm.js +22 -14
- package/RolePickerRow/index.esm.js +1 -1
- package/index.esm.js +2 -3
- package/package.json +15 -14
- package/src/Modal/Modal.d.ts +5 -1
- package/src/Modal/Modal.types.d.ts +4 -9
- 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 +3 -0
- package/src/RolePicker/defaults.d.ts +1 -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 +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, getCommonClassNameDefault
|
|
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,20 +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
|
-
if (variant === 'important') {
|
|
124
|
-
console.warn('Modal: Varianten "important" er deprekert og vil bli fjernet i neste major versjon.');
|
|
125
|
-
}
|
|
126
134
|
return /*#__PURE__*/ jsx("dialog", {
|
|
127
135
|
ref: modalRef,
|
|
128
136
|
id: id,
|
|
129
|
-
className: `${styles.modal} ${
|
|
137
|
+
className: `${styles.modal} ${className} ${classNames?.container ?? ''}`.trim(),
|
|
130
138
|
lang: lang,
|
|
131
139
|
"data-testid": dataTestId,
|
|
132
140
|
"aria-labelledby": headingId,
|
|
141
|
+
"data-variant": variant,
|
|
133
142
|
autoFocus: true,
|
|
134
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(),
|
|
135
144
|
onKeyDown: (e)=>{
|
|
@@ -165,9 +174,6 @@ const Modal = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNameDefa
|
|
|
165
174
|
/*#__PURE__*/ jsxs("div", {
|
|
166
175
|
className: `${paddingClassName} ${noPaddingTop}`.trim(),
|
|
167
176
|
children: [
|
|
168
|
-
variant === 'important' && /*#__PURE__*/ jsx(SkatteetatenLogo, {
|
|
169
|
-
className: styles.modalLogo
|
|
170
|
-
}),
|
|
171
177
|
renderIcon && /*#__PURE__*/ jsx("div", {
|
|
172
178
|
children: renderIcon?.()
|
|
173
179
|
}),
|
|
@@ -181,12 +187,11 @@ const Modal = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNameDefa
|
|
|
181
187
|
}),
|
|
182
188
|
children
|
|
183
189
|
]
|
|
184
|
-
})
|
|
185
|
-
variant === 'important' && /*#__PURE__*/ jsx(Separator, {})
|
|
190
|
+
})
|
|
186
191
|
]
|
|
187
192
|
})
|
|
188
193
|
});
|
|
189
|
-
}
|
|
194
|
+
};
|
|
190
195
|
Modal.displayName = 'Modal';
|
|
191
196
|
|
|
192
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/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,8 +1,8 @@
|
|
|
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
8
|
import { Modal, getModalDismissOnOutsideClickDefault, getModalDismissOnEscDefault } from '../Modal/index.esm.js';
|
|
@@ -21,13 +21,14 @@ const getRolePickerHideCloseButtonDefault = ()=>false;
|
|
|
21
21
|
const getRolePickerShowSubunitsDefault = ()=>true;
|
|
22
22
|
const getRolePickerShowInactiveBusinessesDefault = ()=>false;
|
|
23
23
|
const getRolePickerShowDeceasedPeopleDefault = ()=>false;
|
|
24
|
+
const getRolePickerMinimumEntitiesForSearchDefault = ()=>11;
|
|
24
25
|
|
|
25
26
|
var styles = {
|
|
26
27
|
"rolePicker": "RolePicker-module_rolePicker__pTz4X",
|
|
27
28
|
"rolePickerFooter": "RolePicker-module_rolePickerFooter__64Pj-",
|
|
28
29
|
"container": "RolePicker-module_container__VtHRL"};
|
|
29
30
|
|
|
30
|
-
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 })=>{
|
|
31
32
|
const [filter, setFilter] = useState('');
|
|
32
33
|
const [loadingEntityId, setLoadingEntityId] = useState(undefined);
|
|
33
34
|
const [error, setError] = useState(undefined);
|
|
@@ -37,7 +38,7 @@ const RolePicker = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNam
|
|
|
37
38
|
const deferredFilter = useDeferredValue(filter);
|
|
38
39
|
const businessesCount = businesses ? businesses.total : 0;
|
|
39
40
|
const peopleCount = people ? people.total : 0;
|
|
40
|
-
const displaySearch = businessesCount + peopleCount
|
|
41
|
+
const displaySearch = businessesCount + peopleCount >= minimumEntitiesForSearch;
|
|
41
42
|
const modalRef = useRef(null);
|
|
42
43
|
useImperativeHandle(ref, ()=>modalRef.current);
|
|
43
44
|
const handleClose = ()=>{
|
|
@@ -115,7 +116,7 @@ const RolePicker = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNam
|
|
|
115
116
|
me ? /*#__PURE__*/ jsx(RolePickerRow, {
|
|
116
117
|
id: me.personId,
|
|
117
118
|
title: t('rolepicker.MeHeading'),
|
|
118
|
-
description: `${t('rolepicker.PeopleDescriptionPrefix')} ${me.personId}`,
|
|
119
|
+
description: `${t('rolepicker.PeopleDescriptionPrefix')} ${formatNationalIdentityNumber(me.personId)}`,
|
|
119
120
|
svgPath: FavoriteSVGpath,
|
|
120
121
|
titleAs: 'h2',
|
|
121
122
|
onClick: ()=>{
|
|
@@ -133,7 +134,7 @@ const RolePicker = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNam
|
|
|
133
134
|
}) : null,
|
|
134
135
|
getRepresentationText(),
|
|
135
136
|
displaySearch ? /*#__PURE__*/ jsx(RolePickerFilterInput, {
|
|
136
|
-
label:
|
|
137
|
+
label: t('rolepicker.SearchText'),
|
|
137
138
|
value: filter,
|
|
138
139
|
onChange: (e)=>setFilter(e.target.value),
|
|
139
140
|
onClear: ()=>setFilter('')
|
|
@@ -189,7 +190,7 @@ const RolePicker = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNam
|
|
|
189
190
|
})
|
|
190
191
|
})
|
|
191
192
|
});
|
|
192
|
-
}
|
|
193
|
+
};
|
|
193
194
|
RolePicker.displayName = 'RolePicker';
|
|
194
195
|
|
|
195
|
-
export { RolePicker, getRolePickerHideCloseButtonDefault, getRolePickerShowDeceasedPeopleDefault, 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
|
});
|
|
@@ -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 };
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
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
6
|
import { Checkbox } from '@skatteetaten/ds-forms';
|
|
7
7
|
import { PersonSVGpath } from '@skatteetaten/ds-icons';
|
|
8
8
|
import { Heading } from '@skatteetaten/ds-typography';
|
|
@@ -19,18 +19,22 @@ var styles = {
|
|
|
19
19
|
"showAllButtonWrapper": "RolePickerPeopleList-module_showAllButtonWrapper__-ErxO"
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const MAX_INITIAL_ITEMS = 5;
|
|
23
23
|
const RolePickerPeopleList = ({ people, filterQuery, showDeceasedPeople: showDeceasedPeopleExternal })=>{
|
|
24
24
|
const { t } = useTranslation('ds_overlays', {
|
|
25
25
|
i18n: dsI18n
|
|
26
26
|
});
|
|
27
|
-
const [
|
|
27
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
28
28
|
const [showDeceasedPeople, setShowDeceasedPeople] = useState(showDeceasedPeopleExternal);
|
|
29
29
|
const ctx = useContext(RolePickerContext);
|
|
30
30
|
const navRef = useRef(null);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
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();
|
|
34
38
|
};
|
|
35
39
|
const handleEntityClicked = async (entity)=>{
|
|
36
40
|
ctx?.setLoadingEntityId(entity.personId);
|
|
@@ -51,15 +55,15 @@ const RolePickerPeopleList = ({ people, filterQuery, showDeceasedPeople: showDec
|
|
|
51
55
|
if (filterQuery) {
|
|
52
56
|
return items.filter((f)=>f.name.toLowerCase().includes(filterQuery.toLowerCase()) || f.personId.includes(filterQuery.toLowerCase()));
|
|
53
57
|
}
|
|
54
|
-
if (
|
|
58
|
+
if (isExpanded) {
|
|
55
59
|
return items;
|
|
56
60
|
}
|
|
57
|
-
return items.slice(0,
|
|
61
|
+
return items.slice(0, MAX_INITIAL_ITEMS);
|
|
58
62
|
}, [
|
|
59
63
|
people.list,
|
|
60
64
|
showDeceasedPeople,
|
|
61
65
|
filterQuery,
|
|
62
|
-
|
|
66
|
+
isExpanded
|
|
63
67
|
]);
|
|
64
68
|
const getShowAllCount = useCallback(()=>{
|
|
65
69
|
return showDeceasedPeople ? people.total : people.list.filter((p)=>!p.isDeleted).length;
|
|
@@ -68,7 +72,7 @@ const RolePickerPeopleList = ({ people, filterQuery, showDeceasedPeople: showDec
|
|
|
68
72
|
people.total,
|
|
69
73
|
showDeceasedPeople
|
|
70
74
|
]);
|
|
71
|
-
const
|
|
75
|
+
const displayToggleAllButton = !filterQuery && people.total > MAX_INITIAL_ITEMS;
|
|
72
76
|
return /*#__PURE__*/ jsxs("div", {
|
|
73
77
|
children: [
|
|
74
78
|
/*#__PURE__*/ jsx(Heading, {
|
|
@@ -93,7 +97,7 @@ const RolePickerPeopleList = ({ people, filterQuery, showDeceasedPeople: showDec
|
|
|
93
97
|
children: /*#__PURE__*/ jsx(RolePickerRow, {
|
|
94
98
|
id: item.personId,
|
|
95
99
|
title: `${item.name}${item.isDeleted ? ` (${t('rolepicker.Deceased')})` : ''}`,
|
|
96
|
-
description: `${t('rolepicker.PeopleDescriptionPrefix')} ${item.personId}`,
|
|
100
|
+
description: `${t('rolepicker.PeopleDescriptionPrefix')} ${formatNationalIdentityNumber(item.personId)}`,
|
|
97
101
|
svgPath: PersonSVGpath,
|
|
98
102
|
onClick: ()=>handleEntityClicked(item)
|
|
99
103
|
})
|
|
@@ -101,11 +105,15 @@ const RolePickerPeopleList = ({ people, filterQuery, showDeceasedPeople: showDec
|
|
|
101
105
|
})
|
|
102
106
|
})
|
|
103
107
|
}),
|
|
104
|
-
|
|
108
|
+
displayToggleAllButton ? /*#__PURE__*/ jsx("div", {
|
|
105
109
|
className: styles.showAllButtonWrapper,
|
|
106
|
-
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, {
|
|
107
115
|
variant: 'tertiary',
|
|
108
|
-
onClick:
|
|
116
|
+
onClick: handleExpand,
|
|
109
117
|
children: `${t('rolepicker.ShowAll')} ${t('rolepicker.People')} (${getShowAllCount()})`
|
|
110
118
|
})
|
|
111
119
|
}) : null
|
|
@@ -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, getRolePickerShowDeceasedPeopleDefault, 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.1",
|
|
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": "
|
|
27
|
-
"date-fns": "^
|
|
28
|
-
"@floating-ui/react": "0.26.28"
|
|
16
|
+
"i18next": "^24",
|
|
17
|
+
"react": "^19 ",
|
|
18
|
+
"react-i18next": "^15",
|
|
19
|
+
"@skatteetaten/ds-core-utils": "2.0.1",
|
|
20
|
+
"@skatteetaten/ds-buttons": "2.0.1",
|
|
21
|
+
"@skatteetaten/ds-forms": "2.0.1",
|
|
22
|
+
"@skatteetaten/ds-icons": "2.0.1",
|
|
23
|
+
"@skatteetaten/ds-navigation": "2.0.1",
|
|
24
|
+
"@skatteetaten/ds-typography": "2.0.1",
|
|
25
|
+
"@skatteetaten/ds-progress": "2.0.1",
|
|
26
|
+
"@skatteetaten/ds-status": "2.0.1",
|
|
27
|
+
"date-fns": "^4",
|
|
28
|
+
"@floating-ui/react": "0.26.28",
|
|
29
|
+
"@skatteetaten/ds-content": "2.0.1"
|
|
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,11 +1,12 @@
|
|
|
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;
|
|
@@ -14,9 +15,6 @@ export interface ModalProps extends BaseProps {
|
|
|
14
15
|
children: ReactNode;
|
|
15
16
|
/**
|
|
16
17
|
* Definerer stilen til Modal.
|
|
17
|
-
*
|
|
18
|
-
* **Deprecated:** Variant 'important' skal fases ut i neste major versjon.
|
|
19
|
-
* Bruk 'outline' i stedet.
|
|
20
18
|
*/
|
|
21
19
|
variant?: ModalVariant;
|
|
22
20
|
/** Padding rundt Modal */
|
|
@@ -37,10 +35,7 @@ export interface ModalProps extends BaseProps {
|
|
|
37
35
|
imageSourceAltText?: string;
|
|
38
36
|
/** Icon-komponent som en funksjon som vises over overskriften */
|
|
39
37
|
renderIcon?: () => ReactElement<IconProps>;
|
|
40
|
-
/**
|
|
41
|
-
* Modal i shadowndom.
|
|
42
|
-
* @deprecated Prop skal fjernes ved lansering av neste major versjon.
|
|
43
|
-
*/
|
|
38
|
+
/** Modal i shadowndom. */
|
|
44
39
|
shadowRootNode?: Document | ShadowRoot;
|
|
45
40
|
/** Callback når modalen lukkes */
|
|
46
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,6 +32,8 @@ 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>;
|
|
35
|
+
/** Minimum antall personer/virksomheter som kreves for at søkefelt skal være synlig. Default: 11. */
|
|
36
|
+
minimumEntitiesForSearch?: number;
|
|
34
37
|
/** Om avviklede virksomheter skal vises som standard når rollevelger åpnes. */
|
|
35
38
|
showInactiveBusinesses?: boolean;
|
|
36
39
|
/** Om underenheter av virksomheter skal vises som standard når rollevelger åpnes. */
|
|
@@ -2,3 +2,4 @@ export declare const getRolePickerHideCloseButtonDefault: () => boolean;
|
|
|
2
2
|
export declare const getRolePickerShowSubunitsDefault: () => boolean;
|
|
3
3
|
export declare const getRolePickerShowInactiveBusinessesDefault: () => boolean;
|
|
4
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
|
+
};
|