@uva-glass/component-library 3.52.6 → 3.52.7
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/dist/{client--GsCJ9Up.js → client-CFLMKOFW.js} +1 -37
- package/dist/{client--GsCJ9Up.js.map → client-CFLMKOFW.js.map} +1 -1
- package/dist/components/Accordion/Accordion.test.js +3 -3
- package/dist/components/AccordionCard/AccordionCard.test.js +3 -3
- package/dist/components/ActionList/ActionList.test.js +3 -3
- package/dist/components/AppStatusBar/AppStatusBar.test.js +2 -2
- package/dist/components/Attention/Attention.test.js +2 -2
- package/dist/components/Backdrop/Backdrop.test.js +2 -2
- package/dist/components/Buttons/Button.test.js +2 -2
- package/dist/components/Buttons/LinkButton.test.js +2 -2
- package/dist/components/Buttons/MenuButton.test.js +2 -2
- package/dist/components/Card/Card.test.js +2 -2
- package/dist/components/Checkbox/Checkbox.test.js +3 -3
- package/dist/components/CheckboxButtonBar/CheckboxButtonBar.test.js +2 -2
- package/dist/components/FeedbackBar/FeedbackBar.test.js +2 -2
- package/dist/components/Label/Label.test.js +2 -2
- package/dist/components/MetaDataBar/MetaDataBar.test.js +1 -1
- package/dist/components/MultiSelectBox/MultiSelectBox.test.js +2 -2
- package/dist/components/Notification/Notification.test.js +2 -2
- package/dist/components/RadioGroup/Radiogroup.test.js +2 -2
- package/dist/components/SearchField/SearchField.js +61 -51
- package/dist/components/SearchField/SearchField.js.map +1 -1
- package/dist/components/StatusBadge/StatusBadge.test.js +2 -2
- package/dist/components/TextArea/TextArea.test.js +2 -2
- package/dist/components/VarIndicator/VarIndicator.test.js +3 -3
- package/dist/{index-DYPpFe2R.js → index-ApPj4mI1.js} +1 -2
- package/dist/{index-DYPpFe2R.js.map → index-ApPj4mI1.js.map} +1 -1
- package/dist/{index-C_1Z-Fok.js → index-BKK3EWVW.js} +2 -2
- package/dist/{index-C_1Z-Fok.js.map → index-BKK3EWVW.js.map} +1 -1
- package/dist/{react-18-BHQltW8V.js → react-18-CJB15f47.js} +2 -2
- package/dist/{react-18-BHQltW8V.js.map → react-18-CJB15f47.js.map} +1 -1
- package/dist/{react.esm-DdELhthz.js → react.esm-BjO203QT.js} +3 -19
- package/dist/{react.esm-DdELhthz.js.map → react.esm-BjO203QT.js.map} +1 -1
- package/dist/setupTests.js +1 -1
- package/dist/storybook__react.d.js +2 -2
- package/dist/{test-utils-BP59mSnn.js → test-utils-BcpWLsLH.js} +1 -19
- package/dist/{test-utils-BP59mSnn.js.map → test-utils-BcpWLsLH.js.map} +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as n, s as a } from "../../react.esm-
|
|
4
|
-
import { u as e } from "../../index-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as n, s as a } from "../../react.esm-BjO203QT.js";
|
|
4
|
+
import { u as e } from "../../index-BKK3EWVW.js";
|
|
5
5
|
import { Accordion as i } from "./Accordion.js";
|
|
6
6
|
describe("Accordion", () => {
|
|
7
7
|
it("should render", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as c, s as e, f as s, w as d } from "../../react.esm-
|
|
4
|
-
import { u as r } from "../../index-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as c, s as e, f as s, w as d } from "../../react.esm-BjO203QT.js";
|
|
4
|
+
import { u as r } from "../../index-BKK3EWVW.js";
|
|
5
5
|
import { AccordionCard as a } from "./AccordionCard.js";
|
|
6
6
|
describe("AccordionCard", () => {
|
|
7
7
|
it("should render", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as n, s as t, w as a } from "../../react.esm-
|
|
4
|
-
import { u as l } from "../../index-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as n, s as t, w as a } from "../../react.esm-BjO203QT.js";
|
|
4
|
+
import { u as l } from "../../index-BKK3EWVW.js";
|
|
5
5
|
import { ActionList as o } from "./ActionList.js";
|
|
6
6
|
const T = jest.fn(), c = [
|
|
7
7
|
/* @__PURE__ */ i("button", { type: "button", onClick: T, children: "Test Action 1" }, "1"),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r, s as t } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r, s as t } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { AppStatusBar as s } from "./AppStatusBar.js";
|
|
5
5
|
describe("AppStatusBar", () => {
|
|
6
6
|
it("should render", () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as t, s as r } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as t, s as r } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { Attention as n } from "./Attention.js";
|
|
5
5
|
describe("Attention", () => {
|
|
6
6
|
it("should render (variant primary)", () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as e, s as o } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as e, s as o } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { Backdrop as t } from "./Backdrop.js";
|
|
5
5
|
describe("Backdrop", () => {
|
|
6
6
|
it("should render", () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as n, s as t, f as c } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as n, s as t, f as c } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { Button as o } from "./Button.js";
|
|
5
5
|
const s = jest.fn();
|
|
6
6
|
describe("Button", () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as s, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as n, s as t, f as c } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as n, s as t, f as c } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { BrowserRouter as u, Routes as a, Route as d } from "react-router";
|
|
5
5
|
import { LinkButton as o } from "./LinkButton.js";
|
|
6
6
|
const r = ({ children: i }) => /* @__PURE__ */ s(u, { children: [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as u, s as e, f as c } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as u, s as e, f as c } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { createRef as s } from "react";
|
|
5
5
|
import { MenuButton as r } from "./MenuButton.js";
|
|
6
6
|
const n = jest.fn();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r, s as d } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r, s as d } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { Card as o } from "./Card.js";
|
|
5
5
|
describe("Card", () => {
|
|
6
6
|
it("should render", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as o, s as t } from "../../react.esm-
|
|
4
|
-
import { u as s } from "../../index-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as o, s as t } from "../../react.esm-BjO203QT.js";
|
|
4
|
+
import { u as s } from "../../index-BKK3EWVW.js";
|
|
5
5
|
import { Checkbox as r } from "./Checkbox.js";
|
|
6
6
|
describe("Checkbox", () => {
|
|
7
7
|
it("should render", () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as c, s as t } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as c, s as t } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { CheckboxButtonBar as a } from "./CheckboxButtonBar.js";
|
|
5
5
|
const n = jest.fn(), d = [
|
|
6
6
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as s, s as e, f as r } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as s, s as e, f as r } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { FeedbackBar as c } from "./FeedbackBar.js";
|
|
5
5
|
describe("FeedbackBar", () => {
|
|
6
6
|
it("should render with children text", () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as t, s as l } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as t, s as l } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { Label as r } from "./Label.js";
|
|
5
5
|
describe("Label", () => {
|
|
6
6
|
it("should render", () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { r as n, s as e } from "../../react.esm-
|
|
2
|
+
import { r as n, s as e } from "../../react.esm-BjO203QT.js";
|
|
3
3
|
import { MetaDataBar as c } from "./MetaDataBar.js";
|
|
4
4
|
jest.mock("components/Icon", () => ({
|
|
5
5
|
Icon: ({ name: a }) => /* @__PURE__ */ t("span", { "data-testid": "icon", children: a })
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as o, jsxs as d, Fragment as r } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as n, s as t, f as a } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as n, s as t, f as a } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { MultiSelectBox as l } from "./MultiSelectBox.js";
|
|
5
5
|
const i = jest.fn(), c = [
|
|
6
6
|
{ label: "Option 1", value: "1" },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as i, s as t } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as i, s as t } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { Notification as n } from "./Notification.js";
|
|
5
5
|
describe("Notification", () => {
|
|
6
6
|
it("renders title and subtitle", () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as l, s as t, f as s } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as l, s as t, f as s } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { RadioGroup as a } from "./RadioGroup.js";
|
|
5
5
|
const i = [
|
|
6
6
|
{ id: "1", titleLabel: "Option 1", value: "option1" },
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { jsxs as x, jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as y, useState as k, useEffect as
|
|
3
|
-
import { c as
|
|
4
|
-
import { ResultOption as
|
|
5
|
-
import { s as
|
|
6
|
-
import { ResultOptionBox as
|
|
7
|
-
import { Icon as
|
|
8
|
-
import { useOnClickOutside as
|
|
9
|
-
const
|
|
10
|
-
id:
|
|
11
|
-
placeholder:
|
|
12
|
-
isLoading:
|
|
13
|
-
isCompact:
|
|
14
|
-
onChange:
|
|
2
|
+
import { useRef as y, useState as k, useEffect as h, Children as d, isValidElement as F, cloneElement as N } from "react";
|
|
3
|
+
import { c as O } from "../../clsx-OuTLNxxd.js";
|
|
4
|
+
import { ResultOption as S } from "./components/ResultsOption.js";
|
|
5
|
+
import { s as l } from "../../SearchField.module-CMUEgX7d.js";
|
|
6
|
+
import { ResultOptionBox as D } from "./components/ResultOptionBox.js";
|
|
7
|
+
import { Icon as g } from "../Icon/Icon.js";
|
|
8
|
+
import { useOnClickOutside as B } from "../hooks/useOnClickOutside.js";
|
|
9
|
+
const j = ({
|
|
10
|
+
id: _,
|
|
11
|
+
placeholder: m,
|
|
12
|
+
isLoading: v = !1,
|
|
13
|
+
isCompact: n,
|
|
14
|
+
onChange: u,
|
|
15
15
|
children: a,
|
|
16
|
-
resultCountRow:
|
|
16
|
+
resultCountRow: c
|
|
17
17
|
}) => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
},
|
|
18
|
+
const t = y(null), [f, p] = k(!1), b = y(null), w = () => {
|
|
19
|
+
t.current && (t.current.value = "", t.current.focus());
|
|
20
|
+
}, E = (e) => {
|
|
21
|
+
const r = e.target, o = r.value;
|
|
22
|
+
r.setSelectionRange(o.length, o.length), o && u(o);
|
|
23
|
+
}, R = (e) => {
|
|
24
24
|
switch (e.key) {
|
|
25
25
|
case "Escape":
|
|
26
|
-
e.preventDefault(),
|
|
26
|
+
e.preventDefault(), u(""), t.current && (t.current.value = ""), n && (p(!1), t.current?.blur());
|
|
27
27
|
break;
|
|
28
28
|
case "ArrowDown": {
|
|
29
29
|
e.preventDefault();
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
let i =
|
|
30
|
+
const o = b.current?.querySelector('li[role="option"]:not([tabindex="-1"])');
|
|
31
|
+
if (o) {
|
|
32
|
+
let i = o;
|
|
33
33
|
for (; i && i.getAttribute("tabindex") === "-1"; )
|
|
34
34
|
i = i.nextElementSibling;
|
|
35
35
|
i?.focus();
|
|
@@ -38,59 +38,69 @@ const A = ({
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
}, [a
|
|
44
|
-
|
|
41
|
+
return h(() => {
|
|
42
|
+
!d.count(a) && t.current?.value.length === 0 && n && c === null && p(!1);
|
|
43
|
+
}, [a, n, c]), h(() => {
|
|
44
|
+
if (t.current === null) return;
|
|
45
|
+
const e = () => {
|
|
46
|
+
n && !d.count(a) && p(!1);
|
|
47
|
+
}, r = t.current;
|
|
48
|
+
return r.addEventListener("blur", e), () => {
|
|
49
|
+
r.removeEventListener("blur", e);
|
|
50
|
+
};
|
|
51
|
+
}, [n, a]), h(() => {
|
|
52
|
+
n && f && t.current && t.current.focus();
|
|
53
|
+
}, [n, f]), B(b, u.bind(null, "")), /* @__PURE__ */ x("div", { className: l["search-field__input-wrapper"], children: [
|
|
54
|
+
n && /* @__PURE__ */ s(
|
|
45
55
|
"button",
|
|
46
56
|
{
|
|
47
57
|
type: "button",
|
|
48
|
-
className:
|
|
49
|
-
onClick: () =>
|
|
50
|
-
"aria-label":
|
|
51
|
-
children: /* @__PURE__ */ s(
|
|
58
|
+
className: l["search-field__compact-button"],
|
|
59
|
+
onClick: () => p(!0),
|
|
60
|
+
"aria-label": m,
|
|
61
|
+
children: /* @__PURE__ */ s(g, { name: "Magnify", className: l["search-field__compact-icon"], "aria-hidden": "true" })
|
|
52
62
|
}
|
|
53
63
|
),
|
|
54
64
|
/* @__PURE__ */ x(
|
|
55
65
|
"div",
|
|
56
66
|
{
|
|
57
|
-
className:
|
|
58
|
-
[
|
|
59
|
-
[
|
|
67
|
+
className: O(l["search-field__input-container"], {
|
|
68
|
+
[l["search-field__input-container--hidden"]]: n && !f,
|
|
69
|
+
[l["search-field__input-container--visible"]]: n && f
|
|
60
70
|
}),
|
|
61
71
|
children: [
|
|
62
|
-
/* @__PURE__ */ s(
|
|
72
|
+
/* @__PURE__ */ s(g, { name: "Magnify", className: l["search-field__icon"], "aria-hidden": "true" }),
|
|
63
73
|
/* @__PURE__ */ s(
|
|
64
74
|
"input",
|
|
65
75
|
{
|
|
66
76
|
type: "text",
|
|
67
|
-
className:
|
|
68
|
-
placeholder:
|
|
69
|
-
id:
|
|
70
|
-
onChange: (e) =>
|
|
71
|
-
onFocus:
|
|
72
|
-
onKeyDown:
|
|
77
|
+
className: l["search-field__input-field"],
|
|
78
|
+
placeholder: m,
|
|
79
|
+
id: _,
|
|
80
|
+
onChange: (e) => u(e.target.value),
|
|
81
|
+
onFocus: E,
|
|
82
|
+
onKeyDown: R,
|
|
73
83
|
role: "combobox",
|
|
74
|
-
"aria-expanded": !!
|
|
75
|
-
"aria-controls": `${
|
|
84
|
+
"aria-expanded": !!d.count(a) || v,
|
|
85
|
+
"aria-controls": `${_}-results`,
|
|
76
86
|
"aria-autocomplete": "list",
|
|
77
87
|
"aria-haspopup": "listbox",
|
|
78
|
-
"aria-label":
|
|
88
|
+
"aria-label": m,
|
|
79
89
|
autoComplete: "off",
|
|
80
|
-
ref:
|
|
90
|
+
ref: t
|
|
81
91
|
}
|
|
82
92
|
)
|
|
83
93
|
]
|
|
84
94
|
}
|
|
85
95
|
),
|
|
86
|
-
(a ||
|
|
87
|
-
key:
|
|
88
|
-
onReset:
|
|
96
|
+
(a || v) && /* @__PURE__ */ s(D, { resultCountRow: c || null, ref: b, children: d.map(a, (e, r) => F(e) ? N(e, {
|
|
97
|
+
key: r,
|
|
98
|
+
onReset: w
|
|
89
99
|
}) : e) })
|
|
90
100
|
] });
|
|
91
101
|
};
|
|
92
|
-
|
|
102
|
+
j.ResultOption = S;
|
|
93
103
|
export {
|
|
94
|
-
|
|
104
|
+
j as SearchField
|
|
95
105
|
};
|
|
96
106
|
//# sourceMappingURL=SearchField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchField.js","sources":["../../../src/components/SearchField/SearchField.tsx"],"sourcesContent":["import { Children, cloneElement, isValidElement, useEffect, useRef, useState } from 'react';\r\nimport { clsx } from 'clsx';\r\n\r\nimport type { KeyboardEvent, ReactNode, RefObject } from 'react';\r\nimport type { ResultOptionProps } from './components/ResultsOption';\r\n\r\nimport { ResultOption } from './components/ResultsOption';\r\nimport styles from './SearchField.module.css';\r\nimport { ResultOptionBox } from './components/ResultOptionBox';\r\n\r\nimport { Icon } from 'components/Icon';\r\nimport { useOnClickOutside } from 'components/hooks/useOnClickOutside';\r\n\r\nexport interface SearchFieldProps {\r\n /** Unique identifier for the search field. */\r\n id: string;\r\n /** Placeholder text for the search input. */\r\n placeholder: string;\r\n /** Indicates if the search field is in a loading state. */\r\n isLoading?: boolean;\r\n /** If true, the search field is displayed in a compact style. */\r\n isCompact?: boolean;\r\n /** Callback function triggered when the input value changes. */\r\n onChange: (query: string) => void;\r\n /** The children elements, typically ResultOption components. */\r\n children: ReactNode;\r\n /** Optional row to display the count of results. */\r\n resultCountRow?: ReactNode;\r\n}\r\n\r\nexport const SearchField = ({\r\n id,\r\n placeholder,\r\n isLoading = false,\r\n isCompact,\r\n onChange,\r\n children,\r\n resultCountRow,\r\n}: SearchFieldProps) => {\r\n const inputRef = useRef<HTMLInputElement>(null);\r\n const [showField, setShowField] = useState<boolean>(false);\r\n const optionListRef = useRef<HTMLDivElement>(null);\r\n\r\n const handleReset = () => {\r\n if (inputRef.current) {\r\n inputRef.current.value = '';\r\n inputRef.current.focus();\r\n }\r\n };\r\n\r\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\r\n const target = event.target;\r\n const value = target.value;\r\n target.setSelectionRange(value.length, value.length);\r\n if (value) {\r\n onChange(value);\r\n }\r\n };\r\n\r\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\r\n switch (event.key) {\r\n case 'Escape':\r\n event.preventDefault();\r\n onChange('');\r\n if (inputRef.current) {\r\n inputRef.current.value = '';\r\n }\r\n if (isCompact) {\r\n setShowField(false);\r\n inputRef.current?.blur();\r\n }\r\n break;\r\n case 'ArrowDown': {\r\n event.preventDefault();\r\n const container = optionListRef.current;\r\n const firstFocusable = container?.querySelector<HTMLElement>('li[role=\"option\"]:not([tabindex=\"-1\"])');\r\n if (firstFocusable) {\r\n let currentOption: HTMLElement | null = firstFocusable;\r\n while (currentOption && currentOption.getAttribute('tabindex') === '-1') {\r\n currentOption = currentOption.nextElementSibling as HTMLElement;\r\n }\r\n currentOption?.focus();\r\n }\r\n break;\r\n }\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n if (!Children.count(children)) {\r\n setShowField(false);\r\n }\r\n }, [children]);\r\n\r\n useOnClickOutside(optionListRef as RefObject<HTMLElement>, onChange.bind(null, ''));\r\n\r\n return (\r\n <div className={styles['search-field__input-wrapper']}>\r\n {isCompact && (\r\n <button\r\n type=\"button\"\r\n className={styles['search-field__compact-button']}\r\n onClick={() => setShowField(true)}\r\n aria-label={placeholder}\r\n >\r\n <Icon name=\"Magnify\" className={styles['search-field__compact-icon']} aria-hidden=\"true\" />\r\n </button>\r\n )}\r\n <div\r\n className={clsx(styles['search-field__input-container'], {\r\n [styles['search-field__input-container--hidden']]: isCompact && !showField,\r\n [styles['search-field__input-container--visible']]: isCompact && showField,\r\n })}\r\n >\r\n <Icon name=\"Magnify\" className={styles['search-field__icon']} aria-hidden=\"true\" />\r\n <input\r\n type=\"text\"\r\n className={styles['search-field__input-field']}\r\n placeholder={placeholder}\r\n id={id}\r\n onChange={(event) => onChange(event.target.value)}\r\n onFocus={handleFocus}\r\n onKeyDown={handleKeyDown}\r\n role=\"combobox\"\r\n aria-expanded={Boolean(Children.count(children)) || isLoading}\r\n aria-controls={`${id}-results`}\r\n aria-autocomplete=\"list\"\r\n aria-haspopup=\"listbox\"\r\n aria-label={placeholder}\r\n autoComplete=\"off\"\r\n ref={inputRef}\r\n />\r\n </div>\r\n {(children || isLoading) && (\r\n <ResultOptionBox resultCountRow={resultCountRow ? resultCountRow : null} ref={optionListRef}>\r\n {Children.map(children, (child, index) => {\r\n if (isValidElement<ResultOptionProps>(child)) {\r\n return cloneElement(child, {\r\n key: index,\r\n onReset: handleReset,\r\n });\r\n }\r\n return child;\r\n })}\r\n </ResultOptionBox>\r\n )}\r\n </div>\r\n );\r\n};\r\n\r\nSearchField.ResultOption = ResultOption;\r\n"],"names":["SearchField","id","placeholder","isLoading","isCompact","onChange","children","resultCountRow","inputRef","useRef","showField","setShowField","useState","optionListRef","handleReset","handleFocus","event","target","value","handleKeyDown","firstFocusable","currentOption","useEffect","Children","useOnClickOutside","jsxs","styles","jsx","Icon","clsx","ResultOptionBox","child","index","isValidElement","cloneElement","ResultOption"],"mappings":";;;;;;;;AA8BO,MAAMA,IAAc,CAAC;AAAA,EAC1B,IAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAAC;AACF,MAAwB;AACtB,QAAMC,IAAWC,EAAyB,IAAI,GACxC,CAACC,GAAWC,CAAY,IAAIC,EAAkB,EAAK,GACnDC,IAAgBJ,EAAuB,IAAI,GAE3CK,IAAc,MAAM;AACxB,IAAIN,EAAS,YACXA,EAAS,QAAQ,QAAQ,IACzBA,EAAS,QAAQ,MAAA;AAAA,EAErB,GAEMO,IAAc,CAACC,MAA8C;AACjE,UAAMC,IAASD,EAAM,QACfE,IAAQD,EAAO;AACrB,IAAAA,EAAO,kBAAkBC,EAAM,QAAQA,EAAM,MAAM,GAC/CA,KACFb,EAASa,CAAK;AAAA,EAElB,GAEMC,IAAgB,CAACH,MAA2C;AAChE,YAAQA,EAAM,KAAA;AAAA,MACZ,KAAK;AACH,QAAAA,EAAM,eAAA,GACNX,EAAS,EAAE,GACPG,EAAS,YACXA,EAAS,QAAQ,QAAQ,KAEvBJ,MACFO,EAAa,EAAK,GAClBH,EAAS,SAAS,KAAA;AAEpB;AAAA,MACF,KAAK,aAAa;AAChB,QAAAQ,EAAM,eAAA;AAEN,cAAMI,IADYP,EAAc,SACE,cAA2B,wCAAwC;AACrG,YAAIO,GAAgB;AAClB,cAAIC,IAAoCD;AACxC,iBAAOC,KAAiBA,EAAc,aAAa,UAAU,MAAM;AACjE,YAAAA,IAAgBA,EAAc;AAEhC,UAAAA,GAAe,MAAA;AAAA,QACjB;AACA;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAEA,SAAAC,EAAU,MAAM;AACd,
|
|
1
|
+
{"version":3,"file":"SearchField.js","sources":["../../../src/components/SearchField/SearchField.tsx"],"sourcesContent":["import { Children, cloneElement, isValidElement, useEffect, useRef, useState } from 'react';\r\nimport { clsx } from 'clsx';\r\n\r\nimport type { KeyboardEvent, ReactNode, RefObject } from 'react';\r\nimport type { ResultOptionProps } from './components/ResultsOption';\r\n\r\nimport { ResultOption } from './components/ResultsOption';\r\nimport styles from './SearchField.module.css';\r\nimport { ResultOptionBox } from './components/ResultOptionBox';\r\n\r\nimport { Icon } from 'components/Icon';\r\nimport { useOnClickOutside } from 'components/hooks/useOnClickOutside';\r\n\r\nexport interface SearchFieldProps {\r\n /** Unique identifier for the search field. */\r\n id: string;\r\n /** Placeholder text for the search input. */\r\n placeholder: string;\r\n /** Indicates if the search field is in a loading state. */\r\n isLoading?: boolean;\r\n /** If true, the search field is displayed in a compact style. */\r\n isCompact?: boolean;\r\n /** Callback function triggered when the input value changes. */\r\n onChange: (query: string) => void;\r\n /** The children elements, typically ResultOption components. */\r\n children: ReactNode;\r\n /** Optional row to display the count of results. */\r\n resultCountRow?: ReactNode;\r\n}\r\n\r\nexport const SearchField = ({\r\n id,\r\n placeholder,\r\n isLoading = false,\r\n isCompact,\r\n onChange,\r\n children,\r\n resultCountRow,\r\n}: SearchFieldProps) => {\r\n const inputRef = useRef<HTMLInputElement>(null);\r\n const [showField, setShowField] = useState<boolean>(false);\r\n const optionListRef = useRef<HTMLDivElement>(null);\r\n\r\n const handleReset = () => {\r\n if (inputRef.current) {\r\n inputRef.current.value = '';\r\n inputRef.current.focus();\r\n }\r\n };\r\n\r\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\r\n const target = event.target;\r\n const value = target.value;\r\n target.setSelectionRange(value.length, value.length);\r\n if (value) {\r\n onChange(value);\r\n }\r\n };\r\n\r\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\r\n switch (event.key) {\r\n case 'Escape':\r\n event.preventDefault();\r\n onChange('');\r\n if (inputRef.current) {\r\n inputRef.current.value = '';\r\n }\r\n if (isCompact) {\r\n setShowField(false);\r\n inputRef.current?.blur();\r\n }\r\n break;\r\n case 'ArrowDown': {\r\n event.preventDefault();\r\n const container = optionListRef.current;\r\n const firstFocusable = container?.querySelector<HTMLElement>('li[role=\"option\"]:not([tabindex=\"-1\"])');\r\n if (firstFocusable) {\r\n let currentOption: HTMLElement | null = firstFocusable;\r\n while (currentOption && currentOption.getAttribute('tabindex') === '-1') {\r\n currentOption = currentOption.nextElementSibling as HTMLElement;\r\n }\r\n currentOption?.focus();\r\n }\r\n break;\r\n }\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n if (!Children.count(children) && inputRef.current?.value.length === 0 && isCompact && resultCountRow === null) {\r\n setShowField(false);\r\n }\r\n }, [children, isCompact, resultCountRow]);\r\n\r\n useEffect(() => {\r\n if (inputRef.current === null) return;\r\n\r\n const handleBlur = () => {\r\n if (isCompact && !Children.count(children)) {\r\n setShowField(false);\r\n }\r\n };\r\n\r\n const currentInput = inputRef.current;\r\n currentInput.addEventListener('blur', handleBlur);\r\n\r\n return () => {\r\n currentInput.removeEventListener('blur', handleBlur);\r\n };\r\n }, [isCompact, children]);\r\n\r\n useEffect(() => {\r\n if (isCompact && showField && inputRef.current) {\r\n inputRef.current.focus();\r\n }\r\n }, [isCompact, showField]);\r\n\r\n useOnClickOutside(optionListRef as RefObject<HTMLElement>, onChange.bind(null, ''));\r\n\r\n return (\r\n <div className={styles['search-field__input-wrapper']}>\r\n {isCompact && (\r\n <button\r\n type=\"button\"\r\n className={styles['search-field__compact-button']}\r\n onClick={() => setShowField(true)}\r\n aria-label={placeholder}\r\n >\r\n <Icon name=\"Magnify\" className={styles['search-field__compact-icon']} aria-hidden=\"true\" />\r\n </button>\r\n )}\r\n <div\r\n className={clsx(styles['search-field__input-container'], {\r\n [styles['search-field__input-container--hidden']]: isCompact && !showField,\r\n [styles['search-field__input-container--visible']]: isCompact && showField,\r\n })}\r\n >\r\n <Icon name=\"Magnify\" className={styles['search-field__icon']} aria-hidden=\"true\" />\r\n <input\r\n type=\"text\"\r\n className={styles['search-field__input-field']}\r\n placeholder={placeholder}\r\n id={id}\r\n onChange={(event) => onChange(event.target.value)}\r\n onFocus={handleFocus}\r\n onKeyDown={handleKeyDown}\r\n role=\"combobox\"\r\n aria-expanded={Boolean(Children.count(children)) || isLoading}\r\n aria-controls={`${id}-results`}\r\n aria-autocomplete=\"list\"\r\n aria-haspopup=\"listbox\"\r\n aria-label={placeholder}\r\n autoComplete=\"off\"\r\n ref={inputRef}\r\n />\r\n </div>\r\n {(children || isLoading) && (\r\n <ResultOptionBox resultCountRow={resultCountRow ? resultCountRow : null} ref={optionListRef}>\r\n {Children.map(children, (child, index) => {\r\n if (isValidElement<ResultOptionProps>(child)) {\r\n return cloneElement(child, {\r\n key: index,\r\n onReset: handleReset,\r\n });\r\n }\r\n return child;\r\n })}\r\n </ResultOptionBox>\r\n )}\r\n </div>\r\n );\r\n};\r\n\r\nSearchField.ResultOption = ResultOption;\r\n"],"names":["SearchField","id","placeholder","isLoading","isCompact","onChange","children","resultCountRow","inputRef","useRef","showField","setShowField","useState","optionListRef","handleReset","handleFocus","event","target","value","handleKeyDown","firstFocusable","currentOption","useEffect","Children","handleBlur","currentInput","useOnClickOutside","jsxs","styles","jsx","Icon","clsx","ResultOptionBox","child","index","isValidElement","cloneElement","ResultOption"],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as t, s } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as t, s } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { StatusBadge as a } from "./StatusBage.js";
|
|
5
5
|
describe("StatusBadge", () => {
|
|
6
6
|
it("should render with message", () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as o, s as t, f as r } from "../../react.esm-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as o, s as t, f as r } from "../../react.esm-BjO203QT.js";
|
|
4
4
|
import { J as c } from "../../index-BJRrLdmi.js";
|
|
5
5
|
import { TextArea as n } from "./TextArea.js";
|
|
6
6
|
describe("TextArea", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { r as l, s as e, w as a } from "../../react.esm-
|
|
4
|
-
import { u as i } from "../../index-
|
|
2
|
+
import "../../index-ApPj4mI1.js";
|
|
3
|
+
import { r as l, s as e, w as a } from "../../react.esm-BjO203QT.js";
|
|
4
|
+
import { u as i } from "../../index-BKK3EWVW.js";
|
|
5
5
|
import { useState as s } from "react";
|
|
6
6
|
import { VarIndicator as n } from "./VarIndicator.js";
|
|
7
7
|
const o = {
|
|
@@ -1023,7 +1023,6 @@ function Hn() {
|
|
|
1023
1023
|
var Tn = /* @__PURE__ */ Hn();
|
|
1024
1024
|
const Dn = /* @__PURE__ */ de(Tn);
|
|
1025
1025
|
var z = { exports: {} };
|
|
1026
|
-
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
|
|
1027
1026
|
var Bn = z.exports, Oe;
|
|
1028
1027
|
function Pn() {
|
|
1029
1028
|
return Oe || (Oe = 1, (function(e, t) {
|
|
@@ -2361,4 +2360,4 @@ var kr = /* @__PURE__ */ Object.freeze({
|
|
|
2361
2360
|
toHaveValue: mt
|
|
2362
2361
|
});
|
|
2363
2362
|
expect.extend(kr);
|
|
2364
|
-
//# sourceMappingURL=index-
|
|
2363
|
+
//# sourceMappingURL=index-ApPj4mI1.js.map
|