@inera/ids-react 9.0.4 → 9.1.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/components/alert/alert.js +1 -1
- package/components/breadcrumbs/breadcrumbs.js +1 -1
- package/components/card/card.d.ts +2 -2
- package/components/card/card.js +4 -15
- package/components/data-pagination/data-pagination.d.ts +6 -6
- package/components/data-pagination/data-pagination.js +1 -1
- package/components/dialog/dialog-base.js +1 -1
- package/components/dialog/dialog.js +12 -13
- package/components/dropdown/dropdown-base.js +2 -2
- package/components/dropdown/dropdown.js +1 -0
- package/components/footer-1177-pro/footer-1177-pro.d.ts +2 -1
- package/components/footer-1177-pro/footer-1177-pro.js +2 -2
- package/components/form/checkbox/checkbox-group-base.d.ts +2 -1
- package/components/form/checkbox/checkbox-group-base.js +4 -2
- package/components/form/checkbox/checkbox-group.d.ts +1 -0
- package/components/form/checkbox/checkbox-group.js +4 -3
- package/components/form/datepicker/datepicker.d.ts +2 -1
- package/components/form/datepicker/datepicker.js +60 -37
- package/components/form/input/input-base.d.ts +2 -1
- package/components/form/input/input-base.js +10 -10
- package/components/form/input/input.d.ts +1 -0
- package/components/form/radio/radio-group-base.d.ts +2 -1
- package/components/form/radio/radio-group-base.js +4 -2
- package/components/form/radio/radio-group.d.ts +1 -0
- package/components/form/radio-button/radio-button-group-base.js +1 -1
- package/components/form/select/select.d.ts +1 -1
- package/components/form/select/select.js +2 -2
- package/components/form/select-multiple/select-multiple-base.d.ts +3 -3
- package/components/form/select-multiple/select-multiple-base.js +5 -6
- package/components/form/select-multiple/select-multiple.d.ts +1 -1
- package/components/form/select-multiple/select-multiple.js +10 -23
- package/components/form/textarea/textarea.d.ts +1 -1
- package/components/form/textarea/textarea.js +2 -2
- package/components/form/time/time.d.ts +1 -1
- package/components/form/time/time.js +2 -2
- package/components/{alert → global-alert}/global-alert.d.ts +1 -1
- package/components/{alert → global-alert}/global-alert.js +2 -2
- package/components/header-1177/header-1177-avatar-base.d.ts +2 -1
- package/components/header-1177/header-1177-avatar-base.js +2 -2
- package/components/header-1177/header-1177-avatar.js +11 -24
- package/components/header-1177/header-1177-menu-mobile-base.d.ts +2 -1
- package/components/header-1177/header-1177-menu-mobile-base.js +2 -2
- package/components/header-1177/header-1177-menu-mobile.js +9 -14
- package/components/header-1177/header-1177-nav-item-base.d.ts +2 -1
- package/components/header-1177/header-1177-nav-item-base.js +2 -2
- package/components/header-1177/header-1177-nav-item.js +8 -14
- package/components/header-1177-admin/header-1177-admin-avatar-base.d.ts +2 -1
- package/components/header-1177-admin/header-1177-admin-avatar-base.js +2 -2
- package/components/header-1177-admin/header-1177-admin-avatar-mobile-base.d.ts +2 -1
- package/components/header-1177-admin/header-1177-admin-avatar-mobile-base.js +2 -2
- package/components/header-1177-admin/header-1177-admin-avatar-mobile.js +12 -24
- package/components/header-1177-admin/header-1177-admin-avatar.js +11 -14
- package/components/header-1177-admin/header-1177-admin-menu-mobile-base.d.ts +2 -1
- package/components/header-1177-admin/header-1177-admin-menu-mobile-base.js +2 -2
- package/components/header-1177-admin/header-1177-admin-menu-mobile.js +9 -14
- package/components/header-1177-admin/header-1177-admin-nav-item-base.d.ts +2 -1
- package/components/header-1177-admin/header-1177-admin-nav-item-base.js +2 -2
- package/components/header-1177-admin/header-1177-admin-nav-item.js +8 -14
- package/components/header-1177-pro/header-1177-pro-avatar-base.d.ts +2 -1
- package/components/header-1177-pro/header-1177-pro-avatar-base.js +2 -2
- package/components/header-1177-pro/header-1177-pro-avatar-mobile-base.d.ts +2 -1
- package/components/header-1177-pro/header-1177-pro-avatar-mobile-base.js +2 -2
- package/components/header-1177-pro/header-1177-pro-avatar-mobile.js +12 -24
- package/components/header-1177-pro/header-1177-pro-avatar.js +11 -14
- package/components/header-1177-pro/header-1177-pro-menu-mobile-base.d.ts +2 -1
- package/components/header-1177-pro/header-1177-pro-menu-mobile-base.js +2 -2
- package/components/header-1177-pro/header-1177-pro-menu-mobile.js +9 -14
- package/components/header-1177-pro/header-1177-pro-nav-item-base.d.ts +2 -1
- package/components/header-1177-pro/header-1177-pro-nav-item-base.js +2 -2
- package/components/header-1177-pro/header-1177-pro-nav-item.js +8 -14
- package/components/header-inera/header-inera-menu-mobile-base.d.ts +2 -1
- package/components/header-inera/header-inera-menu-mobile-base.js +2 -2
- package/components/header-inera/header-inera-menu-mobile.js +9 -14
- package/components/header-inera/header-inera-nav-item-base.d.ts +2 -1
- package/components/header-inera/header-inera-nav-item-base.js +2 -2
- package/components/header-inera/header-inera-nav-item.js +8 -14
- package/components/header-inera-admin/header-inera-admin-avatar-base.d.ts +2 -1
- package/components/header-inera-admin/header-inera-admin-avatar-base.js +2 -2
- package/components/header-inera-admin/header-inera-admin-avatar-mobile-base.d.ts +2 -1
- package/components/header-inera-admin/header-inera-admin-avatar-mobile-base.js +2 -2
- package/components/header-inera-admin/header-inera-admin-avatar-mobile.js +12 -24
- package/components/header-inera-admin/header-inera-admin-avatar.js +12 -16
- package/components/header-inera-admin/header-inera-admin-menu-mobile-base.d.ts +2 -1
- package/components/header-inera-admin/header-inera-admin-menu-mobile-base.js +2 -2
- package/components/header-inera-admin/header-inera-admin-menu-mobile.js +9 -14
- package/components/header-inera-admin/header-inera-admin-nav-item-base.d.ts +2 -1
- package/components/header-inera-admin/header-inera-admin-nav-item-base.js +2 -2
- package/components/header-inera-admin/header-inera-admin-nav-item.js +8 -14
- package/components/popover/popover-content.js +1 -1
- package/components/popover/popover.js +1 -1
- package/components/puff-list/puff-list-item-header.js +1 -1
- package/components/puff-list/puff-list-item.js +1 -1
- package/components/side-panel/side-panel-base.js +6 -2
- package/components/side-panel/side-panel.js +50 -41
- package/components/stepper/step-base.js +1 -1
- package/components/stepper/step.js +12 -10
- package/components/tabs/tab-panel.js +1 -1
- package/components/tabs/tab.js +1 -1
- package/components/tabs/tabs.d.ts +1 -1
- package/components/tabs/tabs.js +8 -4
- package/components/utils/hooks/useClickOutside.d.ts +10 -0
- package/components/utils/hooks/useClickOutside.js +31 -0
- package/components/utils/hooks/useEsc.d.ts +10 -0
- package/components/utils/hooks/useEsc.js +27 -0
- package/components/utils/hooks/useHasFocusableChildren.d.ts +2 -0
- package/components/utils/hooks/useHasFocusableChildren.js +25 -0
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +2 -2
- /package/components/{alert → global-alert}/global-alert-base.d.ts +0 -0
- /package/components/{alert → global-alert}/global-alert-base.js +0 -0
|
@@ -9,4 +9,4 @@ export interface IDSTabsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
9
9
|
breakpoint?: "m" | "s";
|
|
10
10
|
selectLabel?: string;
|
|
11
11
|
}
|
|
12
|
-
export declare function IDSTabs({ tabs, selectLabel, light, compact, breakpoint, children, onTabChange, ...props }: IDSTabsProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function IDSTabs({ tabs, selectLabel, light, compact, breakpoint, children, className, onTabChange, ...props }: IDSTabsProps): import("react/jsx-runtime").JSX.Element;
|
package/components/tabs/tabs.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import React, { useId, useState } from 'react';
|
|
3
|
+
import React, { useId, useState, useRef } from 'react';
|
|
4
4
|
import { IDSTabsBase } from './tabs-base.js';
|
|
5
5
|
import { IDSSelect } from '../form/select/select.js';
|
|
6
|
+
import { useHasFocusableChildren } from '../utils/hooks/useHasFocusableChildren.js';
|
|
6
7
|
|
|
7
|
-
function IDSTabs({ tabs = [], selectLabel, light, compact, breakpoint, children, onTabChange, ...props }) {
|
|
8
|
+
function IDSTabs({ tabs = [], selectLabel, light, compact, breakpoint, children, className, onTabChange, ...props }) {
|
|
8
9
|
const reactId = useId();
|
|
9
10
|
const getTabId = (index) => `tab-${reactId}-${index}`;
|
|
10
11
|
const getTabPanelId = (index) => `tab-panel-${reactId}-${index}`;
|
|
@@ -57,7 +58,7 @@ function IDSTabs({ tabs = [], selectLabel, light, compact, breakpoint, children,
|
|
|
57
58
|
id: getTabId?.(idx),
|
|
58
59
|
panelId: getTabPanelId?.(idx),
|
|
59
60
|
index: `${idx}`,
|
|
60
|
-
label: tab.props.label,
|
|
61
|
+
label: tab.props.label || "Välj flik",
|
|
61
62
|
selected: activeTab === idx,
|
|
62
63
|
onTabClick: () => handleTabChange?.(idx),
|
|
63
64
|
onKeyDown: (e) => handleKeydown(e, idx)
|
|
@@ -66,6 +67,7 @@ function IDSTabs({ tabs = [], selectLabel, light, compact, breakpoint, children,
|
|
|
66
67
|
const enhancedTabPanels = React.Children.map(children, (panel, idx) => {
|
|
67
68
|
if (!React.isValidElement(panel))
|
|
68
69
|
return panel;
|
|
70
|
+
const panelRef = useRef(null);
|
|
69
71
|
return React.cloneElement(panel, {
|
|
70
72
|
key: `tab-panel-key-${idx}`,
|
|
71
73
|
id: getTabPanelId?.(idx),
|
|
@@ -73,10 +75,12 @@ function IDSTabs({ tabs = [], selectLabel, light, compact, breakpoint, children,
|
|
|
73
75
|
role: "tabpanel",
|
|
74
76
|
hidden: activeTab !== idx,
|
|
75
77
|
selected: activeTab === idx,
|
|
78
|
+
ref: panelRef,
|
|
79
|
+
noFocus: panel.props.noFocus || useHasFocusableChildren(panelRef),
|
|
76
80
|
compact
|
|
77
81
|
});
|
|
78
82
|
});
|
|
79
|
-
return (jsx(IDSTabsBase, { ...props, tabs: enhancedTabs, breakpoint: breakpoint, select: jsx(IDSSelect, { label: selectLabel, onChange: tabChangedFromSelect, value: activeTab, light: light, children: renderTabOptions() }), children: enhancedTabPanels }));
|
|
83
|
+
return (jsx(IDSTabsBase, { ...props, tabs: enhancedTabs, breakpoint: breakpoint, className: className, select: jsx(IDSSelect, { label: selectLabel, onChange: tabChangedFromSelect, value: activeTab, light: light, children: renderTabOptions() }), children: enhancedTabPanels }));
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
export { IDSTabs };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* useClickOutside
|
|
4
|
+
* Calls handler when a click occurs outside the provided ref(s)
|
|
5
|
+
*
|
|
6
|
+
* @param refs - one or more refs to consider "inside"
|
|
7
|
+
* @param handler - callback when a click outside occurs
|
|
8
|
+
* @param enabled - optional, defaults to true; disable the listener when false
|
|
9
|
+
*/
|
|
10
|
+
export declare function useClickOutside(refs: RefObject<HTMLElement> | RefObject<HTMLElement>[], handler: (event: MouseEvent | TouchEvent) => void, enabled?: boolean): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* useClickOutside
|
|
5
|
+
* Calls handler when a click occurs outside the provided ref(s)
|
|
6
|
+
*
|
|
7
|
+
* @param refs - one or more refs to consider "inside"
|
|
8
|
+
* @param handler - callback when a click outside occurs
|
|
9
|
+
* @param enabled - optional, defaults to true; disable the listener when false
|
|
10
|
+
*/
|
|
11
|
+
function useClickOutside(refs, handler, enabled = true) {
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!enabled)
|
|
14
|
+
return;
|
|
15
|
+
const elements = Array.isArray(refs) ? refs.map(r => r.current) : [refs.current];
|
|
16
|
+
const listener = (event) => {
|
|
17
|
+
// If any element contains the click, do nothing
|
|
18
|
+
if (elements.some(el => el && el.contains(event.target)))
|
|
19
|
+
return;
|
|
20
|
+
handler(event);
|
|
21
|
+
};
|
|
22
|
+
document.addEventListener("mousedown", listener);
|
|
23
|
+
document.addEventListener("touchstart", listener);
|
|
24
|
+
return () => {
|
|
25
|
+
document.removeEventListener("mousedown", listener);
|
|
26
|
+
document.removeEventListener("touchstart", listener);
|
|
27
|
+
};
|
|
28
|
+
}, [refs, handler, enabled]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { useClickOutside };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* useEsc
|
|
4
|
+
* Calls the provided callback when Escape is pressed and optionally focuses a ref
|
|
5
|
+
*
|
|
6
|
+
* @param callback - function to call when Escape is pressed
|
|
7
|
+
* @param focusRef - optional ref to focus when Escape is pressed
|
|
8
|
+
* @param enabled - optional, defaults to true; disables listener when false
|
|
9
|
+
*/
|
|
10
|
+
export declare function useEsc(callback: () => void, focusRef?: RefObject<HTMLElement>, enabled?: boolean): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* useEsc
|
|
5
|
+
* Calls the provided callback when Escape is pressed and optionally focuses a ref
|
|
6
|
+
*
|
|
7
|
+
* @param callback - function to call when Escape is pressed
|
|
8
|
+
* @param focusRef - optional ref to focus when Escape is pressed
|
|
9
|
+
* @param enabled - optional, defaults to true; disables listener when false
|
|
10
|
+
*/
|
|
11
|
+
function useEsc(callback, focusRef, enabled = true) {
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!enabled)
|
|
14
|
+
return;
|
|
15
|
+
const handleKeyDown = (event) => {
|
|
16
|
+
if (event.key === "Escape") {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
callback();
|
|
19
|
+
focusRef?.current?.focus();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
23
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
24
|
+
}, [callback, focusRef, enabled]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { useEsc };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const FOCUSABLE_SELECTORS = [
|
|
4
|
+
"a[href]",
|
|
5
|
+
"button:not([disabled])",
|
|
6
|
+
"input:not([disabled])",
|
|
7
|
+
"select:not([disabled])",
|
|
8
|
+
"textarea:not([disabled])",
|
|
9
|
+
"[tabindex]:not([tabindex='-1'])",
|
|
10
|
+
];
|
|
11
|
+
function useHasFocusableChildren(ref) {
|
|
12
|
+
const [hasFocusable, setHasFocusable] = useState(false);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!ref.current) {
|
|
15
|
+
setHasFocusable(false);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// Query for any focusable elements inside the ref
|
|
19
|
+
const focusable = ref.current.querySelectorAll(FOCUSABLE_SELECTORS.join(","));
|
|
20
|
+
setHasFocusable(focusable.length > 0);
|
|
21
|
+
}, [ref.current]);
|
|
22
|
+
return hasFocusable;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { useHasFocusableChildren };
|
package/index.d.ts
CHANGED
|
@@ -39,8 +39,8 @@ export * from "./components/accordion/accordion-base";
|
|
|
39
39
|
export * from "./components/link/action-link";
|
|
40
40
|
export * from "./components/alert/alert";
|
|
41
41
|
export * from "./components/alert/alert-base";
|
|
42
|
-
export * from "./components/alert/global-alert";
|
|
43
|
-
export * from "./components/alert/global-alert-base";
|
|
42
|
+
export * from "./components/global-alert/global-alert";
|
|
43
|
+
export * from "./components/global-alert/global-alert-base";
|
|
44
44
|
export * from "./components/mobile-menu/mobile-item";
|
|
45
45
|
export * from "./components/mobile-menu/mobile-item-base";
|
|
46
46
|
export * from "./components/mobile-menu/mobile-menu";
|
package/index.js
CHANGED
|
@@ -39,8 +39,8 @@ export { IDSAccordionBase } from './components/accordion/accordion-base.js';
|
|
|
39
39
|
export { IDSActionLink } from './components/link/action-link.js';
|
|
40
40
|
export { IDSAlert } from './components/alert/alert.js';
|
|
41
41
|
export { IDSAlertBase } from './components/alert/alert-base.js';
|
|
42
|
-
export { IDSGlobalAlert } from './components/alert/global-alert.js';
|
|
43
|
-
export { IDSGlobalAlertBase } from './components/alert/global-alert-base.js';
|
|
42
|
+
export { IDSGlobalAlert } from './components/global-alert/global-alert.js';
|
|
43
|
+
export { IDSGlobalAlertBase } from './components/global-alert/global-alert-base.js';
|
|
44
44
|
export { IDSMobileMenuItem } from './components/mobile-menu/mobile-item.js';
|
|
45
45
|
export { IDSMobileMenuItemBase } from './components/mobile-menu/mobile-item-base.js';
|
|
46
46
|
export { IDSMobileMenu } from './components/mobile-menu/mobile-menu.js';
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inera/ids-react",
|
|
3
|
-
"version": "9.0
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"react": "*",
|
|
7
7
|
"react-day-picker": "^9.11.3"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@inera/ids-design": "9.
|
|
10
|
+
"@inera/ids-design": "9.1.x",
|
|
11
11
|
"clsx": "*"
|
|
12
12
|
},
|
|
13
13
|
"types": "index.d.ts",
|
|
File without changes
|
|
File without changes
|