@navikt/ds-react 0.15.2 → 0.15.3
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.
|
@@ -42,13 +42,13 @@ const HelpText = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
42
42
|
var { className, children, placement = "top", strategy = "absolute", title = "hjelp" } = _a, rest = __rest(_a, ["className", "children", "placement", "strategy", "title"]);
|
|
43
43
|
const buttonRef = (0, react_1.useRef)(null);
|
|
44
44
|
const mergedRef = (0, react_merge_refs_1.default)([buttonRef, ref]);
|
|
45
|
-
const popoverRef = (0, react_1.
|
|
45
|
+
const [popoverRef, setPopoverRef] = (0, react_1.useState)(null);
|
|
46
46
|
const wrapperRef = (0, react_1.useRef)(null);
|
|
47
47
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
48
48
|
(0, react_1.useEffect)(() => {
|
|
49
49
|
var _a;
|
|
50
|
-
open && ((_a = popoverRef.
|
|
51
|
-
}, [open]);
|
|
50
|
+
open && ((_a = popoverRef === null || popoverRef === void 0 ? void 0 : popoverRef.focus) === null || _a === void 0 ? void 0 : _a.call(popoverRef));
|
|
51
|
+
}, [open, popoverRef]);
|
|
52
52
|
const handleClick = (e) => {
|
|
53
53
|
setOpen((x) => !x);
|
|
54
54
|
rest.onClick && rest.onClick(e);
|
|
@@ -57,7 +57,7 @@ const HelpText = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
57
57
|
react_1.default.createElement("button", Object.assign({}, rest, { ref: mergedRef, onClick: (e) => handleClick(e), className: (0, classnames_1.default)(className, "navds-help-text__button"), type: "button", "aria-expanded": open, "aria-haspopup": "dialog", title: title }),
|
|
58
58
|
react_1.default.createElement(ds_icons_1.Helptext, { className: "navds-help-text__icon" }),
|
|
59
59
|
react_1.default.createElement("span", { className: "navds-sr-only" }, title)),
|
|
60
|
-
react_1.default.createElement(__1.Popover, { ref:
|
|
60
|
+
react_1.default.createElement(__1.Popover, { ref: setPopoverRef, onClose: () => setOpen(false), className: "navds-help-text__popover", open: open, role: "tooltip", anchorEl: buttonRef.current, placement: placement, strategy: strategy },
|
|
61
61
|
react_1.default.createElement(__1.Popover.Content, null, children))));
|
|
62
62
|
});
|
|
63
63
|
exports.default = HelpText;
|
|
@@ -18,13 +18,13 @@ const HelpText = forwardRef((_a, ref) => {
|
|
|
18
18
|
var { className, children, placement = "top", strategy = "absolute", title = "hjelp" } = _a, rest = __rest(_a, ["className", "children", "placement", "strategy", "title"]);
|
|
19
19
|
const buttonRef = useRef(null);
|
|
20
20
|
const mergedRef = mergeRefs([buttonRef, ref]);
|
|
21
|
-
const popoverRef =
|
|
21
|
+
const [popoverRef, setPopoverRef] = useState(null);
|
|
22
22
|
const wrapperRef = useRef(null);
|
|
23
23
|
const [open, setOpen] = useState(false);
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
var _a;
|
|
26
|
-
open && ((_a = popoverRef.
|
|
27
|
-
}, [open]);
|
|
26
|
+
open && ((_a = popoverRef === null || popoverRef === void 0 ? void 0 : popoverRef.focus) === null || _a === void 0 ? void 0 : _a.call(popoverRef));
|
|
27
|
+
}, [open, popoverRef]);
|
|
28
28
|
const handleClick = (e) => {
|
|
29
29
|
setOpen((x) => !x);
|
|
30
30
|
rest.onClick && rest.onClick(e);
|
|
@@ -33,7 +33,7 @@ const HelpText = forwardRef((_a, ref) => {
|
|
|
33
33
|
React.createElement("button", Object.assign({}, rest, { ref: mergedRef, onClick: (e) => handleClick(e), className: cl(className, "navds-help-text__button"), type: "button", "aria-expanded": open, "aria-haspopup": "dialog", title: title }),
|
|
34
34
|
React.createElement(HelpTextIcon, { className: "navds-help-text__icon" }),
|
|
35
35
|
React.createElement("span", { className: "navds-sr-only" }, title)),
|
|
36
|
-
React.createElement(Popover, { ref:
|
|
36
|
+
React.createElement(Popover, { ref: setPopoverRef, onClose: () => setOpen(false), className: "navds-help-text__popover", open: open, role: "tooltip", anchorEl: buttonRef.current, placement: placement, strategy: strategy },
|
|
37
37
|
React.createElement(Popover.Content, null, children))));
|
|
38
38
|
});
|
|
39
39
|
export default HelpText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelpText.js","sourceRoot":"","sources":["../../src/help-text/HelpText.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAgB,MAAM,IAAI,CAAC;AAW3C,MAAM,QAAQ,GAAG,UAAU,CACzB,CACE,EAOC,EACD,GAAG,EACH,EAAE;QATF,EACE,SAAS,EACT,QAAQ,EACR,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,UAAU,EACrB,KAAK,GAAG,OAAO,OAEhB,EADI,IAAI,cANT,2DAOC,CADQ;IAIT,MAAM,SAAS,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAC;IACzD,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"HelpText.js","sourceRoot":"","sources":["../../src/help-text/HelpText.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAgB,MAAM,IAAI,CAAC;AAW3C,MAAM,QAAQ,GAAG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AAK,EAAE,KAAK;YAEZ,oBAAC,YAAY,IAAC,SAAS,EAAC,uBAAuB,GAAG;YAClD,8BAAM,SAAS,EAAC,eAAe,IAAE,KAAK,CAAQ,CACvC;QACT,oBAAC,OAAO,IACN,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAC7B,SAAS,EAAC,0BAA0B,EACpC,IAAI,EAAE,IAAI,EACV,IAAI,EAAC,SAAS,EACd,QAAQ,EAAE,SAAS,CAAC,OAAO,EAC3B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ;YAElB,oBAAC,OAAO,CAAC,OAAO,QAAE,QAAQ,CAAmB,CACrC,CACN,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NAV designsystem react components",
|
|
6
6
|
"author": "NAV Designsystem team",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"@types/react": "^17.0.30",
|
|
65
65
|
"react": "^17.0.0"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "d002c03647f18abf543b112cba0a977e00e3a912"
|
|
68
68
|
}
|
|
@@ -27,14 +27,14 @@ const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(
|
|
|
27
27
|
) => {
|
|
28
28
|
const buttonRef = useRef<HTMLButtonElement | null>(null);
|
|
29
29
|
const mergedRef = mergeRefs([buttonRef, ref]);
|
|
30
|
-
const popoverRef =
|
|
30
|
+
const [popoverRef, setPopoverRef] = useState<HTMLDivElement | null>(null);
|
|
31
31
|
const wrapperRef = useRef<HTMLDivElement | null>(null);
|
|
32
32
|
|
|
33
33
|
const [open, setOpen] = useState(false);
|
|
34
34
|
|
|
35
35
|
useEffect(() => {
|
|
36
|
-
open && popoverRef
|
|
37
|
-
}, [open]);
|
|
36
|
+
open && popoverRef?.focus?.();
|
|
37
|
+
}, [open, popoverRef]);
|
|
38
38
|
|
|
39
39
|
const handleClick = (
|
|
40
40
|
e: React.MouseEvent<HTMLButtonElement, MouseEvent>
|
|
@@ -42,7 +42,6 @@ const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(
|
|
|
42
42
|
setOpen((x) => !x);
|
|
43
43
|
rest.onClick && rest.onClick(e);
|
|
44
44
|
};
|
|
45
|
-
|
|
46
45
|
return (
|
|
47
46
|
<div className="navds-help-text" ref={wrapperRef}>
|
|
48
47
|
<button
|
|
@@ -59,7 +58,7 @@ const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(
|
|
|
59
58
|
<span className="navds-sr-only">{title}</span>
|
|
60
59
|
</button>
|
|
61
60
|
<Popover
|
|
62
|
-
ref={
|
|
61
|
+
ref={setPopoverRef}
|
|
63
62
|
onClose={() => setOpen(false)}
|
|
64
63
|
className="navds-help-text__popover"
|
|
65
64
|
open={open}
|