@inera/ids-react 6.2.0 → 7.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/components/accordion/accordion.d.ts +1 -1
- package/components/accordion/accordion.js +6 -7
- package/components/agent/agent.d.ts +1 -1
- package/components/agent/agent.js +2 -2
- package/components/alert/alert.d.ts +1 -1
- package/components/alert/alert.js +9 -2
- package/components/alert-global/alert-global.d.ts +2 -2
- package/components/alert-global/alert-global.js +6 -7
- package/components/badge/badge.d.ts +4 -3
- package/components/badge/badge.js +4 -3
- package/components/box-link/box-link.d.ts +11 -3
- package/components/box-link/box-link.js +9 -9
- package/components/breadcrumbs/breadcrumbs.d.ts +1 -1
- package/components/breadcrumbs/breadcrumbs.js +4 -2
- package/components/button/button.d.ts +23 -5
- package/components/button/button.js +95 -11
- package/components/button-group/button-group.d.ts +13 -3
- package/components/button-group/button-group.js +10 -9
- package/components/card/card.d.ts +4 -3
- package/components/card/card.js +16 -8
- package/components/carousel/carousel-item.d.ts +10 -0
- package/components/carousel/carousel-item.js +24 -0
- package/components/carousel/carousel.d.ts +11 -5
- package/components/carousel/carousel.js +167 -16
- package/components/date-label/date-label.d.ts +2 -2
- package/components/date-label/date-label.js +4 -40
- package/components/dialog/dialog.d.ts +23 -6
- package/components/dialog/dialog.js +75 -13
- package/components/dropdown/dropdown-content-link.d.ts +6 -0
- package/components/dropdown/dropdown-content-link.js +20 -0
- package/components/dropdown/dropdown.d.ts +16 -8
- package/components/dropdown/dropdown.js +72 -20
- package/components/footer-1177/footer-1177.d.ts +23 -3
- package/components/footer-1177/footer-1177.js +64 -9
- package/components/footer-1177-admin/footer-1177-admin.d.ts +21 -3
- package/components/footer-1177-admin/footer-1177-admin.js +63 -9
- package/components/footer-1177-pro/footer-1177-pro.d.ts +17 -3
- package/components/footer-1177-pro/footer-1177-pro.js +39 -9
- package/components/footer-inera/footer-inera.d.ts +23 -3
- package/components/footer-inera/footer-inera.js +64 -9
- package/components/footer-inera-admin/footer-inera-admin.d.ts +23 -3
- package/components/footer-inera-admin/footer-inera-admin.js +61 -9
- package/components/form/check-button/check-button.d.ts +7 -3
- package/components/form/check-button/check-button.js +12 -5
- package/components/form/checkbox/checkbox-group.d.ts +13 -3
- package/components/form/checkbox/checkbox-group.js +51 -9
- package/components/form/checkbox/checkbox.d.ts +17 -3
- package/components/form/checkbox/checkbox.js +52 -5
- package/components/form/error-message/error-message.d.ts +10 -0
- package/components/form/error-message/error-message.js +12 -0
- package/components/form/form-hooks/useAriaDescribedBy.d.ts +1 -0
- package/components/form/form-hooks/useAriaDescribedBy.js +26 -0
- package/components/form/form-hooks/useGroupValidity.d.ts +1 -0
- package/components/form/form-hooks/useGroupValidity.js +60 -0
- package/components/form/form-hooks/useInputValidity.d.ts +1 -0
- package/components/form/form-hooks/useInputValidity.js +27 -0
- package/components/form/input/input.d.ts +22 -3
- package/components/form/input/input.js +58 -8
- package/components/form/radio/radio-group.d.ts +13 -3
- package/components/form/radio/radio-group.js +28 -5
- package/components/form/radio/radio.d.ts +17 -3
- package/components/form/radio/radio.js +24 -8
- package/components/form/radio-button/radio-button-group.d.ts +9 -0
- package/components/form/radio-button/radio-button-group.js +22 -0
- package/components/form/radio-button/radio-button.d.ts +9 -0
- package/components/form/radio-button/radio-button.js +15 -0
- package/components/form/range/range.d.ts +16 -3
- package/components/form/range/range.js +30 -8
- package/components/form/select/select.d.ts +15 -3
- package/components/form/select/select.js +20 -8
- package/components/form/select-multiple/select-multiple.d.ts +18 -3
- package/components/form/select-multiple/select-multiple.js +60 -9
- package/components/form/spinner/spinner.d.ts +9 -3
- package/components/form/spinner/spinner.js +9 -9
- package/components/form/textarea/textarea.d.ts +18 -3
- package/components/form/textarea/textarea.js +27 -8
- package/components/form/time/time.d.ts +13 -3
- package/components/form/time/time.js +22 -8
- package/components/form/toggle/toggle.d.ts +8 -3
- package/components/form/toggle/toggle.js +11 -8
- package/components/grid/column.d.ts +16 -0
- package/components/grid/column.js +13 -0
- package/components/grid/container.d.ts +9 -0
- package/components/grid/container.js +24 -0
- package/components/grid/row.d.ts +9 -0
- package/components/grid/row.js +18 -0
- package/components/header-1177/header-1177-avatar.d.ts +10 -2
- package/components/header-1177/header-1177-avatar.js +30 -8
- package/components/header-1177/header-1177-item.d.ts +12 -2
- package/components/header-1177/header-1177-item.js +25 -8
- package/components/header-1177/header-1177-menu-mobile.d.ts +11 -0
- package/components/header-1177/header-1177-menu-mobile.js +42 -0
- package/components/header-1177/header-1177-nav-item-mobile.d.ts +11 -2
- package/components/header-1177/header-1177-nav-item-mobile.js +24 -8
- package/components/header-1177/header-1177-nav-item.d.ts +15 -2
- package/components/header-1177/header-1177-nav-item.js +22 -8
- package/components/header-1177/header-1177-nav.d.ts +8 -2
- package/components/header-1177/header-1177-nav.js +14 -8
- package/components/header-1177/header-1177.d.ts +22 -5
- package/components/header-1177/header-1177.js +41 -12
- package/components/header-1177-admin/header-1177-admin-avatar-mobile.d.ts +9 -2
- package/components/header-1177-admin/header-1177-admin-avatar-mobile.js +6 -8
- package/components/header-1177-admin/header-1177-admin-avatar.d.ts +10 -2
- package/components/header-1177-admin/header-1177-admin-avatar.js +31 -8
- package/components/header-1177-admin/header-1177-admin-item.d.ts +12 -2
- package/components/header-1177-admin/header-1177-admin-item.js +26 -8
- package/components/header-1177-admin/header-1177-admin-nav-item.d.ts +15 -2
- package/components/header-1177-admin/header-1177-admin-nav-item.js +24 -8
- package/components/header-1177-admin/header-1177-admin-nav.d.ts +7 -2
- package/components/header-1177-admin/header-1177-admin-nav.js +12 -8
- package/components/header-1177-admin/header-1177-admin.d.ts +22 -3
- package/components/header-1177-admin/header-1177-admin.js +26 -9
- package/components/header-1177-pro/header-1177-pro-avatar-mobile.d.ts +9 -2
- package/components/header-1177-pro/header-1177-pro-avatar-mobile.js +6 -8
- package/components/header-1177-pro/header-1177-pro-avatar.d.ts +10 -2
- package/components/header-1177-pro/header-1177-pro-avatar.js +31 -8
- package/components/header-1177-pro/header-1177-pro-item.d.ts +12 -2
- package/components/header-1177-pro/header-1177-pro-item.js +23 -8
- package/components/header-1177-pro/header-1177-pro-nav-item.d.ts +15 -2
- package/components/header-1177-pro/header-1177-pro-nav-item.js +33 -8
- package/components/header-1177-pro/header-1177-pro-nav-menu-mobile.d.ts +11 -5
- package/components/header-1177-pro/header-1177-pro-nav-menu-mobile.js +32 -12
- package/components/header-1177-pro/header-1177-pro-nav.d.ts +10 -2
- package/components/header-1177-pro/header-1177-pro-nav.js +27 -8
- package/components/header-1177-pro/header-1177-pro.d.ts +23 -5
- package/components/header-1177-pro/header-1177-pro.js +37 -12
- package/components/header-inera/header-inera-item.d.ts +13 -2
- package/components/header-inera/header-inera-item.js +24 -8
- package/components/header-inera/header-inera-nav-item.d.ts +15 -2
- package/components/header-inera/header-inera-nav-item.js +54 -8
- package/components/header-inera/header-inera-nav-mobile.d.ts +11 -5
- package/components/header-inera/header-inera-nav-mobile.js +44 -12
- package/components/header-inera/header-inera-nav.d.ts +7 -2
- package/components/header-inera/header-inera-nav.js +13 -8
- package/components/header-inera/header-inera.d.ts +16 -3
- package/components/header-inera/header-inera.js +16 -9
- package/components/header-inera-admin/header-inera-admin-avatar-mobile.d.ts +9 -2
- package/components/header-inera-admin/header-inera-admin-avatar-mobile.js +11 -8
- package/components/header-inera-admin/header-inera-admin-avatar.d.ts +12 -2
- package/components/header-inera-admin/header-inera-admin-avatar.js +32 -8
- package/components/header-inera-admin/header-inera-admin-item.d.ts +13 -2
- package/components/header-inera-admin/header-inera-admin-item.js +24 -8
- package/components/header-inera-admin/header-inera-admin-nav-item.d.ts +16 -2
- package/components/header-inera-admin/header-inera-admin-nav-item.js +54 -8
- package/components/header-inera-admin/header-inera-admin-nav-mobile.d.ts +12 -5
- package/components/header-inera-admin/header-inera-admin-nav-mobile.js +32 -12
- package/components/header-inera-admin/header-inera-admin-nav.d.ts +8 -2
- package/components/header-inera-admin/header-inera-admin-nav.js +13 -8
- package/components/header-inera-admin/header-inera-admin.d.ts +15 -3
- package/components/header-inera-admin/header-inera-admin.js +24 -9
- package/components/header-patient/header-patient.d.ts +13 -0
- package/components/header-patient/header-patient.js +21 -0
- package/components/link/link.d.ts +17 -3
- package/components/link/link.js +42 -9
- package/components/mobile/menu/item/mobile-item.d.ts +15 -4
- package/components/mobile/menu/item/mobile-item.js +58 -11
- package/components/mobile/menu/mobile-menu.d.ts +7 -3
- package/components/mobile/menu/mobile-menu.js +9 -9
- package/components/navigation/content/navigation-content.d.ts +7 -3
- package/components/navigation/content/navigation-content.js +18 -9
- package/components/navigation/local/navigation-local.d.ts +7 -3
- package/components/navigation/local/navigation-local.js +6 -9
- package/components/notification/badge/notification-badge.d.ts +4 -2
- package/components/notification/badge/notification-badge.js +4 -3
- package/components/pagination/data-pagination/data-pagination.d.ts +24 -3
- package/components/pagination/data-pagination/data-pagination.js +14 -9
- package/components/pagination/list-pagination/list-pagination.d.ts +19 -7
- package/components/pagination/list-pagination/list-pagination.js +51 -14
- package/components/popover/popover.d.ts +20 -5
- package/components/popover/popover.js +192 -16
- package/components/progressbar/progressbar.d.ts +1 -1
- package/components/progressbar/progressbar.js +4 -2
- package/components/puff-list/puff-list-item/puff-list-item-info.d.ts +7 -0
- package/components/puff-list/puff-list-item/puff-list-item-info.js +8 -0
- package/components/puff-list/puff-list-item/puff-list-item.d.ts +19 -3
- package/components/puff-list/puff-list-item/puff-list-item.js +56 -9
- package/components/puff-list/puff-list.d.ts +7 -3
- package/components/puff-list/puff-list.js +6 -9
- package/components/region-icon/region-icon.d.ts +12 -0
- package/components/region-icon/region-icon.js +25 -0
- package/components/side-menu/side-menu.d.ts +16 -6
- package/components/side-menu/side-menu.js +52 -13
- package/components/side-panel/side-panel.d.ts +21 -6
- package/components/side-panel/side-panel.js +74 -13
- package/components/stepper/step.d.ts +18 -0
- package/components/stepper/step.js +41 -0
- package/components/stepper/stepper.d.ts +9 -7
- package/components/stepper/stepper.js +21 -19
- package/components/tabs/tab-panel.d.ts +11 -0
- package/components/tabs/tab-panel.js +20 -0
- package/components/tabs/tab.d.ts +15 -0
- package/components/tabs/tab.js +19 -0
- package/components/tabs/tabs.d.ts +14 -9
- package/components/tabs/tabs.js +79 -25
- package/components/tag/tag.d.ts +5 -6
- package/components/tag/tag.js +9 -9
- package/components/tooltip/tooltip.d.ts +10 -3
- package/components/tooltip/tooltip.js +79 -9
- package/components/utils/contexts/HeaderContext.d.ts +9 -0
- package/components/utils/contexts/HeaderContext.js +7 -0
- package/components/utils/hooks/useElementId.d.ts +5 -0
- package/components/utils/hooks/useElementId.js +12 -0
- package/components/utils/hooks/useFocusTrap.d.ts +1 -0
- package/components/utils/hooks/useFocusTrap.js +44 -0
- package/components/utils/utils.d.ts +6 -0
- package/components/utils/utils.js +44 -0
- package/index.d.ts +15 -5
- package/index.js +20 -10
- package/package.json +2 -2
- package/components/form/errormessage/error-message.d.ts +0 -3
- package/components/form/errormessage/error-message.js +0 -12
- package/components/grid/grid.d.ts +0 -9
- package/components/grid/grid.js +0 -26
- package/components/header-1177/header-1177-nav-menu-mobile.d.ts +0 -5
- package/components/header-1177/header-1177-nav-menu-mobile.js +0 -15
- package/components/icon-region/icon-region.d.ts +0 -3
- package/components/icon-region/icon-region.js +0 -12
- package/components/puff-list/puff-list-item/puff-list-info/puff-list-item-info.d.ts +0 -3
- package/components/puff-list/puff-list-item/puff-list-info/puff-list-item-info.js +0 -12
|
@@ -1,15 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
|
+
import '@inera/ids-design/components/header-1177-pro/header-1177-pro-nav-menu-mobile.css';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
|
|
4
7
|
|
|
5
|
-
const IDSHeader1177ProNavMenuMobile =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const IDSHeader1177ProNavMenuMobile = ({ label = "", persistent = false, children, onExpanded, onClosed }) => {
|
|
9
|
+
const headerContext = useHeaderContext();
|
|
10
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
11
|
+
const menuRef = useRef(null);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!persistent && isExpanded) {
|
|
14
|
+
const handleClick = () => {
|
|
15
|
+
setIsExpanded(false);
|
|
16
|
+
onClosed?.();
|
|
17
|
+
};
|
|
18
|
+
const links = menuRef.current?.querySelectorAll("a") || [];
|
|
19
|
+
links.forEach(link => link.addEventListener("click", handleClick));
|
|
20
|
+
return () => {
|
|
21
|
+
links.forEach(link => link.removeEventListener("click", handleClick));
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}, [isExpanded, persistent, onClosed]);
|
|
25
|
+
const toggleExpansion = () => {
|
|
26
|
+
const newExpanded = !isExpanded;
|
|
27
|
+
setIsExpanded(newExpanded);
|
|
28
|
+
newExpanded ? onExpanded?.() : onClosed?.();
|
|
29
|
+
};
|
|
30
|
+
return (jsxs(Fragment, { children: [jsx("div", { className: clsx("ids-header-1177-pro__nav-mobile__item", {
|
|
31
|
+
"ids-header-1177-pro__nav-mobile__item--unresponsive": headerContext?.unresponsive
|
|
32
|
+
}), children: jsxs("button", { onClick: toggleExpansion, "aria-expanded": isExpanded, "aria-controls": "ids-header-1177-pro-nav-mobile-dropdown", className: "ids-header-1177-pro__nav-mobile__menu", children: [label, jsx("div", { className: "ids-hamburger", children: jsx("div", { className: "ids-hamburger__lines" }) })] }) }), isExpanded && (jsx("div", { id: "ids-header-1177-pro-nav-mobile-dropdown", className: "ids-header-1177-pro__nav-mobile__menu-items", ref: menuRef, children: children }))] }));
|
|
33
|
+
};
|
|
14
34
|
|
|
15
35
|
export { IDSHeader1177ProNavMenuMobile };
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import "@inera/ids-design/components/header-1177-pro/header-1177-pro-nav.css";
|
|
3
|
+
import "@inera/ids-design/components/header-1177-pro/header-1177-pro-region-picker.css";
|
|
4
|
+
interface IDSHeader1177ProNavProps {
|
|
5
|
+
regionIconMobile?: ReactNode;
|
|
6
|
+
mobileMenu?: ReactNode;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const IDSHeader1177ProNav: React.FC<IDSHeader1177ProNavProps>;
|
|
10
|
+
export {};
|
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import '@inera/ids-design/components/header-1177-pro/header-1177-pro-nav.css';
|
|
5
|
+
import '@inera/ids-design/components/header-1177-pro/header-1177-pro-region-picker.css';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
|
|
4
8
|
|
|
5
|
-
const IDSHeader1177ProNav =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const IDSHeader1177ProNav = ({ regionIconMobile, mobileMenu, children }) => {
|
|
10
|
+
const headerContext = useHeaderContext();
|
|
11
|
+
const [regionPickerExpanded, setRegionPickerExpanded] = useState(false);
|
|
12
|
+
const toggleRegion = () => {
|
|
13
|
+
setRegionPickerExpanded(prev => !prev);
|
|
14
|
+
};
|
|
15
|
+
const renderRegionPicker = () => {
|
|
16
|
+
if (headerContext?.hideRegionPicker)
|
|
17
|
+
return null;
|
|
18
|
+
return (jsx("button", { className: clsx("ids-header-1177-pro__region-picker-button--mobile", {
|
|
19
|
+
"ids-header-1177-pro__region-picker-button--mobile--expanded": regionPickerExpanded
|
|
20
|
+
}), "aria-label": headerContext?.regionPickerText, "aria-expanded": regionPickerExpanded, onClick: toggleRegion, children: regionIconMobile ? (regionIconMobile) : (jsxs("div", { className: "ids-header-1177-pro__region-picker__text", children: [jsx("span", { className: "ids-header-1177-pro__region-picker-icon" }), headerContext?.regionPickerText] })) }));
|
|
21
|
+
};
|
|
22
|
+
return (jsx("nav", { className: clsx("ids-header-1177-pro__nav", {
|
|
23
|
+
"ids-header-1177-pro__nav--fluid": headerContext?.fluid,
|
|
24
|
+
"ids-header-1177-pro__nav--unresponsive": headerContext?.unresponsive
|
|
25
|
+
}), children: jsxs("div", { className: clsx("ids-header-1177-pro__nav-inner", {
|
|
26
|
+
"ids-header-1177-pro__nav-inner--no-region-picker": headerContext?.hideRegionPicker
|
|
27
|
+
}), children: [renderRegionPicker(), children, mobileMenu] }) }));
|
|
28
|
+
};
|
|
10
29
|
|
|
11
30
|
export { IDSHeader1177ProNav };
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import React, { ReactNode, PropsWithChildren, AnchorHTMLAttributes } from "react";
|
|
2
|
+
import "@inera/ids-design/components/header-1177-pro/header-1177-pro.css";
|
|
3
|
+
import "@inera/ids-design/components/header-1177-pro/header-1177-pro-region-picker.css";
|
|
4
|
+
interface IDSHeader1177ProProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
regionPickerText?: string;
|
|
6
|
+
regionPickerExpanded?: boolean;
|
|
7
|
+
hideRegionPicker?: boolean;
|
|
8
|
+
fluid?: boolean;
|
|
9
|
+
unresponsive?: boolean;
|
|
10
|
+
logoText?: string;
|
|
11
|
+
srLogoLabel?: string;
|
|
12
|
+
logoHref?: string;
|
|
13
|
+
logoProps?: AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
14
|
+
onToggleRegion?: (isExpanded: boolean) => void;
|
|
15
|
+
avatar?: ReactNode;
|
|
16
|
+
logo?: ReactNode;
|
|
17
|
+
regionIcon?: ReactNode;
|
|
18
|
+
items?: ReactNode;
|
|
19
|
+
skipToContentLink?: ReactNode;
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
export declare const IDSHeader1177Pro: React.FC<PropsWithChildren<IDSHeader1177ProProps>>;
|
|
23
|
+
export {};
|
|
@@ -1,15 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import '@inera/ids-design/components/header-1177-pro/header-1177-pro.css';
|
|
6
|
+
import '@inera/ids-design/components/header-1177-pro/header-1177-pro-region-picker.css';
|
|
7
|
+
import { HeaderProvider } from '../utils/contexts/HeaderContext.js';
|
|
5
8
|
|
|
6
|
-
const IDSHeader1177Pro =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const IDSHeader1177Pro = ({ regionPickerText = "Välj region", hideRegionPicker: initialRegionPicker = false, regionPickerExpanded: initialExpanded = false, fluid = false, unresponsive = false, logoText = "för vårdpersonal", srLogoLabel = "Logotyp", logoHref = "", logoProps = {}, onToggleRegion, avatar, logo, regionIcon, items, skipToContentLink, className, children }) => {
|
|
10
|
+
const [isRegionExpanded, setIsRegionExpanded] = useState(initialExpanded);
|
|
11
|
+
const [hideRegionPicker, setHideRegionPicker] = useState(initialRegionPicker);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (avatar) {
|
|
14
|
+
// No region picker when avatar
|
|
15
|
+
setIsRegionExpanded(false);
|
|
16
|
+
setHideRegionPicker(true);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
setHideRegionPicker(initialRegionPicker);
|
|
20
|
+
}
|
|
21
|
+
}, [avatar]);
|
|
22
|
+
const toggleRegion = () => {
|
|
23
|
+
const newValue = !isRegionExpanded;
|
|
24
|
+
setIsRegionExpanded(newValue);
|
|
25
|
+
onToggleRegion?.(newValue);
|
|
26
|
+
};
|
|
27
|
+
return (jsx(HeaderProvider, { value: {
|
|
28
|
+
unresponsive,
|
|
29
|
+
fluid,
|
|
30
|
+
hideRegionPicker,
|
|
31
|
+
regionPickerText
|
|
32
|
+
}, children: jsxs("header", { className: clsx("ids-header-1177-pro", {
|
|
33
|
+
"ids-header-1177-pro--unresponsive": unresponsive,
|
|
34
|
+
"ids-header-1177-pro--fluid": fluid
|
|
35
|
+
}, className), children: [skipToContentLink && (jsx("div", { className: "ids-header-1177-pro__skip-to-content", children: skipToContentLink })), jsx("div", { className: "ids-header-1177-pro__container", children: jsxs("div", { className: "ids-header-1177-pro__inner", children: [jsxs("div", { className: "ids-header-1177-pro__logo-col", children: [jsx("div", { className: "ids-header-1177-pro__logo", children: logo ? (logo) : (jsx("a", { className: "ids-header-1177-pro__logo-link", href: logoHref, "aria-label": srLogoLabel, ...logoProps })) }), jsx("div", { className: "ids-header-1177-pro__logo-text", children: logoText }), !hideRegionPicker && !avatar && (jsx("button", { className: clsx("ids-header-1177-pro__region-picker-button", {
|
|
36
|
+
"ids-header-1177-pro__region-picker-button--expanded": isRegionExpanded
|
|
37
|
+
}), onClick: toggleRegion, "aria-label": regionPickerText, "aria-expanded": isRegionExpanded, children: regionIcon || regionPickerText }))] }), jsx("div", { className: "ids-header-1177-pro__items", children: jsxs("div", { className: "ids-header-1177-pro__items-inner", children: [items, " ", avatar] }) })] }) }), children] }) }));
|
|
38
|
+
};
|
|
14
39
|
|
|
15
40
|
export { IDSHeader1177Pro };
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import "@inera/ids-design/components/header-inera/header-inera-item.css";
|
|
3
|
+
interface IDSHeaderIneraItemProps {
|
|
4
|
+
mobile?: boolean;
|
|
5
|
+
separatorLeft?: boolean;
|
|
6
|
+
icon?: string;
|
|
7
|
+
text?: string;
|
|
8
|
+
href?: string;
|
|
9
|
+
link?: ReactNode;
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const IDSHeaderIneraItem: React.FC<IDSHeaderIneraItemProps>;
|
|
13
|
+
export {};
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { isValidElement, cloneElement } from 'react';
|
|
4
|
+
import '@inera/ids-design/components/header-inera/header-inera-item.css';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
|
|
4
7
|
|
|
5
|
-
const IDSHeaderIneraItem =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const IDSHeaderIneraItem = ({ mobile = false, separatorLeft = false, icon = "", text = "", href = "", link, onClick, ...props }) => {
|
|
9
|
+
const headerContext = useHeaderContext();
|
|
10
|
+
const classNames = clsx("ids-header-inera-item", {
|
|
11
|
+
"ids-header-inera-item--mobile": mobile,
|
|
12
|
+
"ids-header-inera-item__separator": separatorLeft,
|
|
13
|
+
"ids-header-inera-item--unresponsive": headerContext?.unresponsive
|
|
14
|
+
});
|
|
15
|
+
const renderContent = () => (jsxs(Fragment, { children: [jsx("div", { className: "ids-header-inera-item__icon", "aria-label": text, children: icon && jsx("span", { className: `ids-icon-${icon}` }) }), jsx("div", { className: "ids-header-inera-item__text", children: text })] }));
|
|
16
|
+
if (link && isValidElement(link)) {
|
|
17
|
+
return cloneElement(link, {
|
|
18
|
+
...props,
|
|
19
|
+
style: { textDecoration: "none" },
|
|
20
|
+
className: clsx(link.props.className, classNames),
|
|
21
|
+
children: renderContent()
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return onClick ? (jsx("button", { className: classNames, onClick: onClick, ...props, children: renderContent() })) : (jsx("a", { className: classNames, href: href, style: { textDecoration: "none" }, ...props, children: renderContent() }));
|
|
25
|
+
};
|
|
10
26
|
|
|
11
27
|
export { IDSHeaderIneraItem };
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import React, { ReactNode, ReactElement } from "react";
|
|
2
|
+
import "@inera/ids-design/components/header-inera/header-inera-nav-item.css";
|
|
3
|
+
import { IDSLinkProps } from "../link/link";
|
|
4
|
+
export interface IDSHeaderIneraNavItemProps {
|
|
5
|
+
label?: string;
|
|
6
|
+
active?: boolean;
|
|
7
|
+
expanded?: boolean;
|
|
8
|
+
notification?: ReactNode;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
col1?: ReactElement<IDSLinkProps>[];
|
|
11
|
+
col2?: ReactElement<IDSLinkProps>[];
|
|
12
|
+
col3?: ReactElement<IDSLinkProps>[];
|
|
13
|
+
col4?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare const IDSHeaderIneraNavItem: React.FC<IDSHeaderIneraNavItemProps>;
|
|
@@ -1,11 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React__default, { useState, useRef, useEffect } from 'react';
|
|
4
|
+
import '@inera/ids-design/components/header-inera/header-inera-nav-item.css';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
|
|
7
|
+
import { useElementId } from '../utils/hooks/useElementId.js';
|
|
4
8
|
|
|
5
|
-
const IDSHeaderIneraNavItem =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const IDSHeaderIneraNavItem = ({ label = "", active = false, expanded = false, notification, children, col1, col2, col3, col4 }) => {
|
|
10
|
+
const headerContext = useHeaderContext();
|
|
11
|
+
const [isExpanded, setIsExpanded] = useState(expanded);
|
|
12
|
+
const containerRef = useRef(null);
|
|
13
|
+
const contentId = useElementId();
|
|
14
|
+
const handleClickOutside = (event) => {
|
|
15
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
16
|
+
setIsExpanded(false);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setIsExpanded(expanded);
|
|
21
|
+
document.addEventListener("click", handleClickOutside);
|
|
22
|
+
return () => {
|
|
23
|
+
document.removeEventListener("click", handleClickOutside);
|
|
24
|
+
};
|
|
25
|
+
}, [expanded]);
|
|
26
|
+
const renderNavItem = () => {
|
|
27
|
+
if (label) {
|
|
28
|
+
return (jsxs("button", { "aria-controls": contentId, "aria-expanded": isExpanded, className: clsx("ids-header-inera-nav-item__button", {
|
|
29
|
+
"ids-header-inera-nav-item__button--expanded": isExpanded,
|
|
30
|
+
"ids-header-inera-nav-item__button--active": active
|
|
31
|
+
}), onClick: () => setIsExpanded(prev => !prev), children: [label, " ", notification] }));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return (jsxs("span", { className: clsx("ids-header-inera-nav-item__link", {
|
|
35
|
+
"ids-header-inera-nav-item__link--active": active
|
|
36
|
+
}), children: [children, " ", notification] }));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const renderLink = (link) => {
|
|
40
|
+
return React__default.isValidElement(link)
|
|
41
|
+
? React__default.cloneElement(link, { activeIcon: true, block: true, colorPreset: 2 })
|
|
42
|
+
: link;
|
|
43
|
+
};
|
|
44
|
+
const renderContent = () => {
|
|
45
|
+
if (!isExpanded)
|
|
46
|
+
return null;
|
|
47
|
+
return (jsx("div", { id: contentId, className: "ids-header-inera-nav-item__content", children: jsxs("div", { className: clsx("ids-header-inera-nav-item__content-inner", {
|
|
48
|
+
"ids-header-inera-nav-item__content-inner--fluid": headerContext?.fluid
|
|
49
|
+
}), children: [jsx("div", { className: "ids-header-inera-nav-item__content-col", children: col1?.map((link, idx) => (jsx("div", { className: "ids-header-inera-nav-item__wrapper", children: renderLink(link) }, idx))) }), jsx("div", { className: "ids-header-inera-nav-item__content-col", children: col2?.map((link, idx) => (jsx("div", { className: "ids-header-inera-nav-item__wrapper", children: renderLink(link) }, idx))) }), jsx("div", { className: "ids-header-inera-nav-item__content-col", children: col3?.map((link, idx) => (jsx("div", { className: "ids-header-inera-nav-item__wrapper", children: renderLink(link) }, idx))) }), jsx("div", { className: "ids-header-inera-nav-item__content-col", children: col4 })] }) }));
|
|
50
|
+
};
|
|
51
|
+
return (jsxs("div", { ref: containerRef, className: clsx("ids-header-inera-nav-item", {
|
|
52
|
+
"ids-header-inera-nav-item--fluid": headerContext?.fluid,
|
|
53
|
+
"ids-header-inera-nav-item--unresponsive": headerContext?.unresponsive
|
|
54
|
+
}), children: [renderNavItem(), renderContent()] }));
|
|
55
|
+
};
|
|
10
56
|
|
|
11
57
|
export { IDSHeaderIneraNavItem };
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import "@inera/ids-design/components/header-inera/header-inera-nav-mobile.css";
|
|
3
|
+
export interface IDSHeaderIneraNavMobileProps {
|
|
4
|
+
expanded?: boolean;
|
|
5
|
+
persistent?: boolean;
|
|
6
|
+
srLabel?: string;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
onExpanded?: () => void;
|
|
9
|
+
onClosed?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const IDSHeaderIneraNavMobile: React.FC<IDSHeaderIneraNavMobileProps>;
|
|
@@ -1,15 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
|
+
import '@inera/ids-design/components/header-inera/header-inera-nav-mobile.css';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
|
|
4
7
|
|
|
5
|
-
const IDSHeaderIneraNavMobile =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const IDSHeaderIneraNavMobile = ({ expanded = false, persistent = false, srLabel = "Meny", children, onExpanded, onClosed }) => {
|
|
9
|
+
const headerContext = useHeaderContext();
|
|
10
|
+
const [isExpanded, setIsExpanded] = useState(expanded);
|
|
11
|
+
const containerRef = useRef(null);
|
|
12
|
+
const menuRef = useRef(null);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!persistent) {
|
|
15
|
+
const links = menuRef.current?.querySelectorAll("a") || [];
|
|
16
|
+
links.forEach(link => {
|
|
17
|
+
link.addEventListener("click", handleCloseMenu);
|
|
18
|
+
});
|
|
19
|
+
return () => {
|
|
20
|
+
links.forEach(link => {
|
|
21
|
+
link.removeEventListener("click", handleCloseMenu);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}, [isExpanded, persistent]);
|
|
26
|
+
const handleCloseMenu = () => {
|
|
27
|
+
if (isExpanded) {
|
|
28
|
+
toggleExpanded();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const toggleExpanded = () => {
|
|
32
|
+
const newExpanded = !isExpanded;
|
|
33
|
+
setIsExpanded(newExpanded);
|
|
34
|
+
if (newExpanded) {
|
|
35
|
+
onExpanded?.();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
onClosed?.();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return (jsxs("div", { ref: containerRef, className: clsx("ids-header-inera-nav-mobile", {
|
|
42
|
+
"ids-header-inera-nav-mobile--expanded": isExpanded,
|
|
43
|
+
"ids-header-inera-nav-mobile--unresponsive": headerContext?.unresponsive
|
|
44
|
+
}), children: [jsx("button", { "aria-label": srLabel, "aria-expanded": isExpanded, onClick: toggleExpanded, className: "ids-header-inera-nav-mobile__button", children: jsx("div", { className: "ids-hamburger", children: jsx("div", { className: "ids-hamburger__lines" }) }) }), isExpanded && (jsx("nav", { className: "ids-header-inera-nav-mobile__menu-items", ref: menuRef, children: children }))] }));
|
|
45
|
+
};
|
|
14
46
|
|
|
15
47
|
export { IDSHeaderIneraNavMobile };
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "@inera/ids-design/components/header-inera/header-inera-nav.css";
|
|
3
|
+
export interface IDSHeaderIneraNavProps {
|
|
4
|
+
srText?: string;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const IDSHeaderIneraNav: React.FC<IDSHeaderIneraNavProps>;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import '@inera/ids-design/components/header-inera/header-inera-nav.css';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
|
|
4
6
|
|
|
5
|
-
const IDSHeaderIneraNav =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const IDSHeaderIneraNav = ({ srText = "Huvudmeny", children }) => {
|
|
8
|
+
const headerContext = useHeaderContext();
|
|
9
|
+
const className = clsx("ids-header-inera-nav", {
|
|
10
|
+
"ids-header-inera-nav--fluid": headerContext?.fluid,
|
|
11
|
+
"ids-header-inera-nav--unresponsive": headerContext?.unresponsive
|
|
12
|
+
});
|
|
13
|
+
return (jsx("nav", { className: className, "aria-label": srText, children: jsx("div", { className: "ids-header-inera-nav__nav-items", children: children }) }));
|
|
14
|
+
};
|
|
10
15
|
|
|
11
16
|
export { IDSHeaderIneraNav };
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import React, { ReactNode, PropsWithChildren, AnchorHTMLAttributes } from "react";
|
|
2
|
+
import "@inera/ids-design/components/header-inera/header-inera.css";
|
|
3
|
+
interface IDSHeaderIneraProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
logoHref?: string;
|
|
5
|
+
logoProps?: AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
6
|
+
srLogoLabel?: string;
|
|
7
|
+
fluid?: boolean;
|
|
8
|
+
unresponsive?: boolean;
|
|
9
|
+
items?: ReactNode;
|
|
10
|
+
mobileMenu?: ReactNode;
|
|
11
|
+
skipToContent?: ReactNode;
|
|
12
|
+
logo?: ReactNode;
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare const IDSHeaderInera: React.FC<PropsWithChildren<IDSHeaderIneraProps>>;
|
|
16
|
+
export {};
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import '@inera/ids-design/components/header-inera/header-inera.css';
|
|
5
|
+
import { HeaderProvider } from '../utils/contexts/HeaderContext.js';
|
|
5
6
|
|
|
6
|
-
const IDSHeaderInera =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const IDSHeaderInera = ({ logoHref = "", logoProps = {}, srLogoLabel = "Logotyp inera", fluid = false, unresponsive = false, items, mobileMenu, skipToContent, logo, className, children }) => {
|
|
8
|
+
return (jsx(HeaderProvider, { value: {
|
|
9
|
+
unresponsive,
|
|
10
|
+
fluid,
|
|
11
|
+
hideRegionPicker: true,
|
|
12
|
+
regionPickerText: ""
|
|
13
|
+
}, children: jsxs("header", { className: clsx("ids-header-inera", {
|
|
14
|
+
"ids-header-inera--unresponsive": unresponsive,
|
|
15
|
+
"ids-header-inera--fluid": fluid
|
|
16
|
+
}, className), children: [skipToContent && jsx("div", { className: "ids-header-inera__skip-to-content", children: skipToContent }), jsxs("div", { className: "ids-header-inera__inner", children: [logoHref ? (jsx("a", { href: logoHref, "aria-label": srLogoLabel, className: "ids-header-inera__logo", ...logoProps })) : logo ? (jsx("div", { className: "ids-header-inera__logo-custom", children: logo })) : (jsx("div", { className: "ids-header-inera__logo" })), jsxs("div", { className: "ids-header-inera__items", children: [items, " ", mobileMenu] })] }), children] }) }));
|
|
17
|
+
};
|
|
11
18
|
|
|
12
19
|
export { IDSHeaderInera };
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "@inera/ids-design/components/header-inera-admin/header-inera-admin-avatar-mobile.css";
|
|
3
|
+
interface IDSHeaderIneraAdminAvatarMobileProps {
|
|
4
|
+
username?: string;
|
|
5
|
+
unit?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const IDSHeaderIneraAdminAvatarMobile: React.FC<IDSHeaderIneraAdminAvatarMobileProps>;
|
|
9
|
+
export {};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import '@inera/ids-design/components/header-inera-admin/header-inera-admin-avatar-mobile.css';
|
|
4
|
+
import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
|
|
5
|
+
import clsx from 'clsx';
|
|
4
6
|
|
|
5
|
-
const IDSHeaderIneraAdminAvatarMobile =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
7
|
+
const IDSHeaderIneraAdminAvatarMobile = ({ username = "", unit = "", children }) => {
|
|
8
|
+
const headerContext = useHeaderContext();
|
|
9
|
+
return (jsxs("div", { className: clsx("ids-header-inera-admin-avatar-mobile", {
|
|
10
|
+
"ids-header-inera-admin-avatar-mobile--unresponsive": headerContext?.unresponsive
|
|
11
|
+
}), children: [username && (jsx(Fragment, { children: jsxs("div", { className: "ids-header-inera-admin-avatar-mobile__user-info", children: [jsx("div", { className: "ids-header-inera-admin-avatar-mobile__username", children: username }), jsx("div", { className: "ids-header-inera-admin-avatar-mobile__unit", children: unit })] }) })), jsx("div", { className: "ids-header-inera-admin-avatar-mobile__links", children: children })] }));
|
|
12
|
+
};
|
|
10
13
|
|
|
11
14
|
export { IDSHeaderIneraAdminAvatarMobile };
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import "@inera/ids-design/components/header-inera-admin/header-inera-admin-avatar.css";
|
|
3
|
+
interface IDSHeaderIneraAdminAvatarProps {
|
|
4
|
+
username?: string;
|
|
5
|
+
unit?: string;
|
|
6
|
+
maxwidth?: string;
|
|
7
|
+
onExpanded?: () => void;
|
|
8
|
+
onClosed?: () => void;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare const IDSHeaderIneraAdminAvatar: React.FC<IDSHeaderIneraAdminAvatarProps>;
|
|
12
|
+
export {};
|
|
@@ -1,11 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
|
+
import '@inera/ids-design/components/header-inera-admin/header-inera-admin-avatar.css';
|
|
5
|
+
import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
|
|
6
|
+
import clsx from 'clsx';
|
|
4
7
|
|
|
5
|
-
const IDSHeaderIneraAdminAvatar =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const IDSHeaderIneraAdminAvatar = ({ username = "", unit = "", maxwidth = "", onExpanded, onClosed, children }) => {
|
|
9
|
+
const headerContext = useHeaderContext();
|
|
10
|
+
const [expanded, setExpanded] = useState(false);
|
|
11
|
+
const ref = useRef(null);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const handleClickOutside = (event) => {
|
|
14
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
15
|
+
if (expanded)
|
|
16
|
+
toggleExpanded();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
document.addEventListener("click", handleClickOutside);
|
|
20
|
+
return () => document.removeEventListener("click", handleClickOutside);
|
|
21
|
+
}, [expanded]);
|
|
22
|
+
const toggleExpanded = () => {
|
|
23
|
+
const newExpanded = !expanded;
|
|
24
|
+
setExpanded(newExpanded);
|
|
25
|
+
newExpanded ? onExpanded?.() : onClosed?.();
|
|
26
|
+
};
|
|
27
|
+
return (jsx("div", { ref: ref, className: clsx("ids-header-inera-admin-avatar", {
|
|
28
|
+
"ids-header-inera-admin-avatar--fluid": headerContext?.fluid,
|
|
29
|
+
"ids-header-inera-admin-avatar--unresponsive": headerContext?.unresponsive
|
|
30
|
+
}), children: jsxs("div", { className: "ids-header-inera-admin-avatar__inner", children: [jsxs("button", { "aria-expanded": expanded, onClick: toggleExpanded, className: "ids-header-inera-admin-avatar__button", children: [jsxs("div", { className: "ids-header-inera-admin-avatar__button-main", children: [jsx("div", { className: "ids-header-inera-admin-avatar__username", style: maxwidth ? { maxWidth: maxwidth } : undefined, children: username }), jsx("div", { className: "ids-header-inera-admin-avatar__unit", style: maxwidth ? { maxWidth: maxwidth } : undefined, children: unit })] }), jsx("div", { className: clsx("ids-header-inera-admin-avatar__chevron", {
|
|
31
|
+
"ids-header-inera-admin-avatar__chevron--expanded": expanded
|
|
32
|
+
}) })] }), expanded && jsx("div", { className: "ids-header-inera-admin-avatar__menu", children: children })] }) }));
|
|
33
|
+
};
|
|
10
34
|
|
|
11
35
|
export { IDSHeaderIneraAdminAvatar };
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import "@inera/ids-design/components/header-inera-admin/header-inera-admin-item.css";
|
|
3
|
+
interface IDSHeaderIneraAdminItemProps {
|
|
4
|
+
mobile?: boolean;
|
|
5
|
+
separatorLeft?: boolean;
|
|
6
|
+
icon?: string;
|
|
7
|
+
text?: string;
|
|
8
|
+
href?: string;
|
|
9
|
+
link?: ReactNode;
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const IDSHeaderIneraAdminItem: React.FC<IDSHeaderIneraAdminItemProps>;
|
|
13
|
+
export {};
|