@holmdigital/components 1.2.4 → 2.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/README.md +135 -60
- package/dist/AccessibilityStatement/AccessibilityStatement.d.mts +29 -0
- package/dist/AccessibilityStatement/AccessibilityStatement.d.ts +29 -0
- package/dist/AccessibilityStatement/AccessibilityStatement.js +483 -0
- package/dist/AccessibilityStatement/AccessibilityStatement.mjs +6 -0
- package/dist/Button/Button.js +1 -1
- package/dist/Button/Button.mjs +1 -1
- package/dist/Card/Card.d.mts +12 -0
- package/dist/Card/Card.d.ts +12 -0
- package/dist/Card/Card.js +81 -0
- package/dist/Card/Card.mjs +6 -0
- package/dist/Combobox/Combobox.d.mts +19 -0
- package/dist/Combobox/Combobox.d.ts +19 -0
- package/dist/Combobox/Combobox.js +271 -0
- package/dist/Combobox/Combobox.mjs +6 -0
- package/dist/DataTable/DataTable.d.mts +18 -0
- package/dist/DataTable/DataTable.d.ts +18 -0
- package/dist/DataTable/DataTable.js +125 -0
- package/dist/DataTable/DataTable.mjs +6 -0
- package/dist/DatePicker/DatePicker.d.mts +11 -0
- package/dist/DatePicker/DatePicker.d.ts +11 -0
- package/dist/DatePicker/DatePicker.js +110 -0
- package/dist/DatePicker/DatePicker.mjs +6 -0
- package/dist/ErrorSummary/ErrorSummary.d.mts +14 -0
- package/dist/ErrorSummary/ErrorSummary.d.ts +14 -0
- package/dist/ErrorSummary/ErrorSummary.js +119 -0
- package/dist/ErrorSummary/ErrorSummary.mjs +6 -0
- package/dist/LiveRegion/LiveRegion.d.mts +10 -0
- package/dist/LiveRegion/LiveRegion.d.ts +10 -0
- package/dist/LiveRegion/LiveRegion.js +69 -0
- package/dist/LiveRegion/LiveRegion.mjs +6 -0
- package/dist/Modal/Modal.d.mts +1 -2
- package/dist/Modal/Modal.d.ts +1 -2
- package/dist/MultiSelect/MultiSelect.d.mts +19 -0
- package/dist/MultiSelect/MultiSelect.d.ts +19 -0
- package/dist/MultiSelect/MultiSelect.js +263 -0
- package/dist/MultiSelect/MultiSelect.mjs +6 -0
- package/dist/Pagination/Pagination.d.mts +12 -0
- package/dist/Pagination/Pagination.d.ts +12 -0
- package/dist/Pagination/Pagination.js +149 -0
- package/dist/Pagination/Pagination.mjs +6 -0
- package/dist/Tooltip/Tooltip.d.mts +1 -1
- package/dist/Tooltip/Tooltip.d.ts +1 -1
- package/dist/Tooltip/Tooltip.js +1 -1
- package/dist/Tooltip/Tooltip.mjs +1 -1
- package/dist/TreeView/TreeView.d.mts +16 -0
- package/dist/TreeView/TreeView.d.ts +16 -0
- package/dist/TreeView/TreeView.js +250 -0
- package/dist/TreeView/TreeView.mjs +6 -0
- package/dist/chunk-4UONERC6.mjs +45 -0
- package/dist/chunk-57NZTQBX.mjs +86 -0
- package/dist/chunk-6REI7HHO.mjs +226 -0
- package/dist/chunk-EVNHLNS5.mjs +125 -0
- package/dist/chunk-HSUDZAQ6.mjs +101 -0
- package/dist/{chunk-C5M6C7KT.mjs → chunk-MCEJNWZT.mjs} +1 -1
- package/dist/{chunk-7V2LETZ6.mjs → chunk-MYXIUDCP.mjs} +1 -1
- package/dist/chunk-NECEXNCF.mjs +57 -0
- package/dist/chunk-OFTOD72G.mjs +462 -0
- package/dist/chunk-OMSIXECN.mjs +247 -0
- package/dist/chunk-P2IXX552.mjs +95 -0
- package/dist/chunk-VM3O36W4.mjs +239 -0
- package/dist/index.d.mts +42 -1
- package/dist/index.d.ts +42 -1
- package/dist/index.js +1873 -2
- package/dist/index.mjs +244 -6
- package/package.json +48 -6
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// src/Combobox/Combobox.tsx
|
|
2
|
+
import { useState, useRef, useEffect, useId } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var Combobox = ({
|
|
5
|
+
label,
|
|
6
|
+
description,
|
|
7
|
+
error,
|
|
8
|
+
options,
|
|
9
|
+
onChange,
|
|
10
|
+
value,
|
|
11
|
+
placeholder = "Type to search...",
|
|
12
|
+
className = ""
|
|
13
|
+
}) => {
|
|
14
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
15
|
+
const [inputValue, setInputValue] = useState("");
|
|
16
|
+
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
17
|
+
const inputRef = useRef(null);
|
|
18
|
+
const listboxRef = useRef(null);
|
|
19
|
+
const containerRef = useRef(null);
|
|
20
|
+
const id = useId();
|
|
21
|
+
const listboxId = `${id}-listbox`;
|
|
22
|
+
const labelId = `${id}-label`;
|
|
23
|
+
const descriptionId = `${id}-description`;
|
|
24
|
+
const errorId = `${id}-error`;
|
|
25
|
+
const filteredOptions = options.filter(
|
|
26
|
+
(option) => option.label.toLowerCase().includes(inputValue.toLowerCase())
|
|
27
|
+
);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (value) {
|
|
30
|
+
const selectedOption = options.find((o) => o.value === value);
|
|
31
|
+
if (selectedOption) {
|
|
32
|
+
setInputValue(selectedOption.label);
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
setInputValue("");
|
|
36
|
+
}
|
|
37
|
+
}, [value, options]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const handleClickOutside = (event) => {
|
|
40
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
41
|
+
setIsOpen(false);
|
|
42
|
+
setFocusedIndex(-1);
|
|
43
|
+
if (value) {
|
|
44
|
+
const selectedOption = options.find((o) => o.value === value);
|
|
45
|
+
if (selectedOption) setInputValue(selectedOption.label);
|
|
46
|
+
} else {
|
|
47
|
+
setInputValue("");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
52
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
53
|
+
}, [value, options]);
|
|
54
|
+
const handleInputChange = (e) => {
|
|
55
|
+
setInputValue(e.target.value);
|
|
56
|
+
setIsOpen(true);
|
|
57
|
+
setFocusedIndex(-1);
|
|
58
|
+
if (e.target.value === "") {
|
|
59
|
+
onChange(null);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const handleOptionSelect = (option) => {
|
|
63
|
+
onChange(option.value);
|
|
64
|
+
setInputValue(option.label);
|
|
65
|
+
setIsOpen(false);
|
|
66
|
+
setFocusedIndex(-1);
|
|
67
|
+
};
|
|
68
|
+
const handleKeyDown = (e) => {
|
|
69
|
+
if (!isOpen && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
|
|
70
|
+
setIsOpen(true);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
switch (e.key) {
|
|
74
|
+
case "ArrowDown":
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
setFocusedIndex(
|
|
77
|
+
(prev) => prev < filteredOptions.length - 1 ? prev + 1 : 0
|
|
78
|
+
);
|
|
79
|
+
break;
|
|
80
|
+
case "ArrowUp":
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
setFocusedIndex(
|
|
83
|
+
(prev) => prev > 0 ? prev - 1 : filteredOptions.length - 1
|
|
84
|
+
);
|
|
85
|
+
break;
|
|
86
|
+
case "Enter":
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
if (isOpen && focusedIndex >= 0) {
|
|
89
|
+
handleOptionSelect(filteredOptions[focusedIndex]);
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
case "Escape":
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
setIsOpen(false);
|
|
95
|
+
setFocusedIndex(-1);
|
|
96
|
+
if (value) {
|
|
97
|
+
const selectedOption = options.find((o) => o.value === value);
|
|
98
|
+
if (selectedOption) setInputValue(selectedOption.label);
|
|
99
|
+
} else {
|
|
100
|
+
setInputValue("");
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
case "Tab":
|
|
104
|
+
setIsOpen(false);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const styles = {
|
|
109
|
+
container: {
|
|
110
|
+
position: "relative",
|
|
111
|
+
marginBottom: "1rem",
|
|
112
|
+
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
113
|
+
},
|
|
114
|
+
label: {
|
|
115
|
+
display: "block",
|
|
116
|
+
fontWeight: 600,
|
|
117
|
+
marginBottom: "0.25rem",
|
|
118
|
+
color: "#1e293b"
|
|
119
|
+
},
|
|
120
|
+
description: {
|
|
121
|
+
fontSize: "0.875rem",
|
|
122
|
+
color: "#64748b",
|
|
123
|
+
marginBottom: "0.5rem"
|
|
124
|
+
},
|
|
125
|
+
error: {
|
|
126
|
+
fontSize: "0.875rem",
|
|
127
|
+
color: "#dc2626",
|
|
128
|
+
marginTop: "0.25rem"
|
|
129
|
+
},
|
|
130
|
+
input: {
|
|
131
|
+
width: "100%",
|
|
132
|
+
padding: "0.5rem 0.75rem",
|
|
133
|
+
fontSize: "1rem",
|
|
134
|
+
border: `1px solid ${error ? "#dc2626" : "#cbd5e1"}`,
|
|
135
|
+
borderRadius: "0.375rem",
|
|
136
|
+
outline: "none",
|
|
137
|
+
boxSizing: "border-box"
|
|
138
|
+
},
|
|
139
|
+
listbox: {
|
|
140
|
+
position: "absolute",
|
|
141
|
+
top: "100%",
|
|
142
|
+
left: 0,
|
|
143
|
+
right: 0,
|
|
144
|
+
maxHeight: "200px",
|
|
145
|
+
overflowY: "auto",
|
|
146
|
+
border: "1px solid #cbd5e1",
|
|
147
|
+
borderRadius: "0.375rem",
|
|
148
|
+
backgroundColor: "white",
|
|
149
|
+
zIndex: 10,
|
|
150
|
+
marginTop: "0.25rem",
|
|
151
|
+
padding: 0,
|
|
152
|
+
listStyle: "none",
|
|
153
|
+
boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1)"
|
|
154
|
+
},
|
|
155
|
+
option: {
|
|
156
|
+
padding: "0.5rem 0.75rem",
|
|
157
|
+
cursor: "pointer"
|
|
158
|
+
},
|
|
159
|
+
activeOption: {
|
|
160
|
+
backgroundColor: "#e2e8f0",
|
|
161
|
+
color: "#0f172a"
|
|
162
|
+
},
|
|
163
|
+
noResults: {
|
|
164
|
+
padding: "0.5rem 0.75rem",
|
|
165
|
+
color: "#64748b",
|
|
166
|
+
fontStyle: "italic"
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
return /* @__PURE__ */ jsxs("div", { ref: containerRef, className, style: styles.container, children: [
|
|
170
|
+
/* @__PURE__ */ jsx(
|
|
171
|
+
"label",
|
|
172
|
+
{
|
|
173
|
+
id: labelId,
|
|
174
|
+
htmlFor: id,
|
|
175
|
+
style: styles.label,
|
|
176
|
+
children: label
|
|
177
|
+
}
|
|
178
|
+
),
|
|
179
|
+
description && /* @__PURE__ */ jsx("div", { id: descriptionId, style: styles.description, children: description }),
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
"input",
|
|
182
|
+
{
|
|
183
|
+
ref: inputRef,
|
|
184
|
+
id,
|
|
185
|
+
type: "text",
|
|
186
|
+
role: "combobox",
|
|
187
|
+
"aria-autocomplete": "list",
|
|
188
|
+
"aria-expanded": isOpen,
|
|
189
|
+
"aria-haspopup": "listbox",
|
|
190
|
+
"aria-controls": listboxId,
|
|
191
|
+
"aria-activedescendant": focusedIndex >= 0 ? `${id}-option-${focusedIndex}` : void 0,
|
|
192
|
+
"aria-invalid": !!error,
|
|
193
|
+
"aria-describedby": [
|
|
194
|
+
description ? descriptionId : null,
|
|
195
|
+
error ? errorId : null
|
|
196
|
+
].filter(Boolean).join(" ") || void 0,
|
|
197
|
+
value: inputValue,
|
|
198
|
+
onChange: handleInputChange,
|
|
199
|
+
onKeyDown: handleKeyDown,
|
|
200
|
+
placeholder,
|
|
201
|
+
style: {
|
|
202
|
+
...styles.input,
|
|
203
|
+
...isOpen ? { borderColor: "#3b82f6", ring: "2px solid #93c5fd" } : {}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
),
|
|
207
|
+
error && /* @__PURE__ */ jsx("div", { id: errorId, style: styles.error, role: "alert", children: error }),
|
|
208
|
+
isOpen && /* @__PURE__ */ jsx(
|
|
209
|
+
"ul",
|
|
210
|
+
{
|
|
211
|
+
ref: listboxRef,
|
|
212
|
+
id: listboxId,
|
|
213
|
+
role: "listbox",
|
|
214
|
+
"aria-label": label,
|
|
215
|
+
style: styles.listbox,
|
|
216
|
+
children: filteredOptions.length > 0 ? filteredOptions.map((option, index) => {
|
|
217
|
+
const isSelected = value === option.value;
|
|
218
|
+
const isFocused = focusedIndex === index;
|
|
219
|
+
return /* @__PURE__ */ jsxs(
|
|
220
|
+
"li",
|
|
221
|
+
{
|
|
222
|
+
id: `${id}-option-${index}`,
|
|
223
|
+
role: "option",
|
|
224
|
+
"aria-selected": isSelected,
|
|
225
|
+
onClick: () => handleOptionSelect(option),
|
|
226
|
+
onMouseEnter: () => setFocusedIndex(index),
|
|
227
|
+
style: {
|
|
228
|
+
...styles.option,
|
|
229
|
+
...isFocused ? styles.activeOption : {},
|
|
230
|
+
...isSelected ? { fontWeight: "bold" } : {}
|
|
231
|
+
},
|
|
232
|
+
children: [
|
|
233
|
+
option.label,
|
|
234
|
+
isSelected && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { float: "right" }, children: "\u2713" })
|
|
235
|
+
]
|
|
236
|
+
},
|
|
237
|
+
option.value
|
|
238
|
+
);
|
|
239
|
+
}) : /* @__PURE__ */ jsx("li", { style: styles.noResults, children: "No results found" })
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
] });
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export {
|
|
246
|
+
Combobox
|
|
247
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// src/ErrorSummary/ErrorSummary.tsx
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var ErrorSummary = ({
|
|
5
|
+
errors,
|
|
6
|
+
title = "There is a problem",
|
|
7
|
+
focusOnMount = true,
|
|
8
|
+
className = ""
|
|
9
|
+
}) => {
|
|
10
|
+
const headingRef = useRef(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (focusOnMount && errors.length > 0 && headingRef.current) {
|
|
13
|
+
headingRef.current.focus();
|
|
14
|
+
}
|
|
15
|
+
}, [focusOnMount, errors]);
|
|
16
|
+
if (errors.length === 0) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const styles = {
|
|
20
|
+
container: {
|
|
21
|
+
border: "2px solid #dc2626",
|
|
22
|
+
// Red-600
|
|
23
|
+
borderRadius: "0.375rem",
|
|
24
|
+
padding: "1rem",
|
|
25
|
+
marginBottom: "1.5rem",
|
|
26
|
+
backgroundColor: "#fef2f2"
|
|
27
|
+
// Red-50
|
|
28
|
+
},
|
|
29
|
+
heading: {
|
|
30
|
+
color: "#991b1b",
|
|
31
|
+
// Red-800
|
|
32
|
+
fontWeight: "bold",
|
|
33
|
+
fontSize: "1.125rem",
|
|
34
|
+
marginBottom: "0.5rem",
|
|
35
|
+
outline: "none"
|
|
36
|
+
// Managed focus usually visually indicated by browser, but we can style if needed
|
|
37
|
+
},
|
|
38
|
+
list: {
|
|
39
|
+
listStyleType: "disc",
|
|
40
|
+
paddingLeft: "1.25rem",
|
|
41
|
+
margin: 0,
|
|
42
|
+
color: "#dc2626"
|
|
43
|
+
// Red-600
|
|
44
|
+
},
|
|
45
|
+
link: {
|
|
46
|
+
color: "#b91c1c",
|
|
47
|
+
// Red-700
|
|
48
|
+
textDecoration: "underline",
|
|
49
|
+
cursor: "pointer",
|
|
50
|
+
fontWeight: 500
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return /* @__PURE__ */ jsxs(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
className: `a11y-error-summary ${className}`,
|
|
57
|
+
role: "alert",
|
|
58
|
+
"aria-labelledby": "error-summary-title",
|
|
59
|
+
style: styles.container,
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
"h2",
|
|
63
|
+
{
|
|
64
|
+
id: "error-summary-title",
|
|
65
|
+
ref: headingRef,
|
|
66
|
+
tabIndex: -1,
|
|
67
|
+
style: styles.heading,
|
|
68
|
+
children: title
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
/* @__PURE__ */ jsx("ul", { style: styles.list, children: errors.map((error, index) => /* @__PURE__ */ jsx("li", { style: { marginBottom: "0.25rem" }, children: /* @__PURE__ */ jsx(
|
|
72
|
+
"a",
|
|
73
|
+
{
|
|
74
|
+
href: `#${error.id}`,
|
|
75
|
+
style: styles.link,
|
|
76
|
+
onClick: (e) => {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
const element = document.getElementById(error.id);
|
|
79
|
+
if (element) {
|
|
80
|
+
element.focus();
|
|
81
|
+
element.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
children: error.message
|
|
85
|
+
}
|
|
86
|
+
) }, index)) })
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
ErrorSummary.displayName = "ErrorSummary";
|
|
92
|
+
|
|
93
|
+
export {
|
|
94
|
+
ErrorSummary
|
|
95
|
+
};
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// src/MultiSelect/MultiSelect.tsx
|
|
2
|
+
import { useState, useRef, useId } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var MultiSelect = ({
|
|
5
|
+
label,
|
|
6
|
+
description,
|
|
7
|
+
error,
|
|
8
|
+
options,
|
|
9
|
+
selected,
|
|
10
|
+
onChange,
|
|
11
|
+
placeholder = "Select items...",
|
|
12
|
+
className = ""
|
|
13
|
+
}) => {
|
|
14
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
15
|
+
const [inputValue, setInputValue] = useState("");
|
|
16
|
+
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
17
|
+
const [activeTokenIndex] = useState(-1);
|
|
18
|
+
const inputRef = useRef(null);
|
|
19
|
+
const containerRef = useRef(null);
|
|
20
|
+
const id = useId();
|
|
21
|
+
const listboxId = `${id}-listbox`;
|
|
22
|
+
const labelId = `${id}-label`;
|
|
23
|
+
const descriptionId = `${id}-description`;
|
|
24
|
+
const errorId = `${id}-error`;
|
|
25
|
+
const availableOptions = options.filter(
|
|
26
|
+
(option) => !selected.includes(option.value) && option.label.toLowerCase().includes(inputValue.toLowerCase())
|
|
27
|
+
);
|
|
28
|
+
const handleSelect = (value) => {
|
|
29
|
+
onChange([...selected, value]);
|
|
30
|
+
setInputValue("");
|
|
31
|
+
setIsOpen(false);
|
|
32
|
+
setFocusedIndex(-1);
|
|
33
|
+
inputRef.current?.focus();
|
|
34
|
+
};
|
|
35
|
+
const handleRemove = (value) => {
|
|
36
|
+
onChange(selected.filter((v) => v !== value));
|
|
37
|
+
inputRef.current?.focus();
|
|
38
|
+
};
|
|
39
|
+
const handleKeyDown = (e) => {
|
|
40
|
+
if (activeTokenIndex !== -1) {
|
|
41
|
+
handleTokenNavigation(e);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
switch (e.key) {
|
|
45
|
+
case "ArrowDown":
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
setIsOpen(true);
|
|
48
|
+
setFocusedIndex((prev) => prev < availableOptions.length - 1 ? prev + 1 : 0);
|
|
49
|
+
break;
|
|
50
|
+
case "ArrowUp":
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
setIsOpen(true);
|
|
53
|
+
setFocusedIndex((prev) => prev > 0 ? prev - 1 : availableOptions.length - 1);
|
|
54
|
+
break;
|
|
55
|
+
case "Enter":
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
if (isOpen && focusedIndex >= 0) {
|
|
58
|
+
handleSelect(availableOptions[focusedIndex].value);
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case "Escape":
|
|
62
|
+
setIsOpen(false);
|
|
63
|
+
break;
|
|
64
|
+
case "Backspace":
|
|
65
|
+
if (inputValue === "" && selected.length > 0) {
|
|
66
|
+
handleRemove(selected[selected.length - 1]);
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case "ArrowLeft":
|
|
70
|
+
if (inputValue === "" && selected.length > 0) {
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const handleTokenNavigation = (_e) => {
|
|
76
|
+
};
|
|
77
|
+
const styles = {
|
|
78
|
+
container: {
|
|
79
|
+
position: "relative",
|
|
80
|
+
marginBottom: "1rem",
|
|
81
|
+
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
82
|
+
},
|
|
83
|
+
label: {
|
|
84
|
+
display: "block",
|
|
85
|
+
fontWeight: 600,
|
|
86
|
+
marginBottom: "0.25rem",
|
|
87
|
+
color: "#1e293b"
|
|
88
|
+
},
|
|
89
|
+
description: {
|
|
90
|
+
fontSize: "0.875rem",
|
|
91
|
+
color: "#64748b",
|
|
92
|
+
marginBottom: "0.5rem"
|
|
93
|
+
},
|
|
94
|
+
error: {
|
|
95
|
+
fontSize: "0.875rem",
|
|
96
|
+
color: "#dc2626",
|
|
97
|
+
marginTop: "0.25rem"
|
|
98
|
+
},
|
|
99
|
+
inputWrapper: {
|
|
100
|
+
display: "flex",
|
|
101
|
+
flexWrap: "wrap",
|
|
102
|
+
gap: "0.5rem",
|
|
103
|
+
padding: "0.375rem",
|
|
104
|
+
border: `1px solid ${error ? "#dc2626" : "#cbd5e1"}`,
|
|
105
|
+
borderRadius: "0.375rem",
|
|
106
|
+
backgroundColor: "white",
|
|
107
|
+
minHeight: "2.5rem"
|
|
108
|
+
},
|
|
109
|
+
input: {
|
|
110
|
+
flex: 1,
|
|
111
|
+
minWidth: "120px",
|
|
112
|
+
border: "none",
|
|
113
|
+
outline: "none",
|
|
114
|
+
padding: "0.25rem",
|
|
115
|
+
fontSize: "1rem"
|
|
116
|
+
},
|
|
117
|
+
token: {
|
|
118
|
+
display: "inline-flex",
|
|
119
|
+
alignItems: "center",
|
|
120
|
+
backgroundColor: "#e2e8f0",
|
|
121
|
+
border: "1px solid #cbd5e1",
|
|
122
|
+
borderRadius: "0.25rem",
|
|
123
|
+
padding: "0.125rem 0.5rem",
|
|
124
|
+
fontSize: "0.875rem",
|
|
125
|
+
color: "#0f172a"
|
|
126
|
+
},
|
|
127
|
+
removeButton: {
|
|
128
|
+
marginLeft: "0.25rem",
|
|
129
|
+
border: "none",
|
|
130
|
+
background: "none",
|
|
131
|
+
cursor: "pointer",
|
|
132
|
+
padding: "0 0.125rem",
|
|
133
|
+
fontSize: "1rem",
|
|
134
|
+
lineHeight: 1,
|
|
135
|
+
color: "#64748b"
|
|
136
|
+
},
|
|
137
|
+
listbox: {
|
|
138
|
+
position: "absolute",
|
|
139
|
+
top: "100%",
|
|
140
|
+
left: 0,
|
|
141
|
+
right: 0,
|
|
142
|
+
maxHeight: "200px",
|
|
143
|
+
overflowY: "auto",
|
|
144
|
+
border: "1px solid #cbd5e1",
|
|
145
|
+
borderRadius: "0.375rem",
|
|
146
|
+
backgroundColor: "white",
|
|
147
|
+
zIndex: 10,
|
|
148
|
+
marginTop: "0.25rem",
|
|
149
|
+
padding: 0,
|
|
150
|
+
listStyle: "none",
|
|
151
|
+
boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1)"
|
|
152
|
+
},
|
|
153
|
+
option: {
|
|
154
|
+
padding: "0.5rem 0.75rem",
|
|
155
|
+
cursor: "pointer"
|
|
156
|
+
},
|
|
157
|
+
activeOption: {
|
|
158
|
+
backgroundColor: "#e2e8f0",
|
|
159
|
+
color: "#0f172a"
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
return /* @__PURE__ */ jsxs("div", { ref: containerRef, className, style: styles.container, children: [
|
|
163
|
+
/* @__PURE__ */ jsx("label", { id: labelId, htmlFor: id, style: styles.label, children: label }),
|
|
164
|
+
description && /* @__PURE__ */ jsx("div", { id: descriptionId, style: styles.description, children: description }),
|
|
165
|
+
/* @__PURE__ */ jsxs("div", { style: styles.inputWrapper, children: [
|
|
166
|
+
selected.map((value) => {
|
|
167
|
+
const option = options.find((o) => o.value === value);
|
|
168
|
+
return /* @__PURE__ */ jsxs("span", { style: styles.token, children: [
|
|
169
|
+
option?.label || value,
|
|
170
|
+
/* @__PURE__ */ jsx(
|
|
171
|
+
"button",
|
|
172
|
+
{
|
|
173
|
+
type: "button",
|
|
174
|
+
style: styles.removeButton,
|
|
175
|
+
onClick: () => handleRemove(value),
|
|
176
|
+
"aria-label": `Remove ${option?.label || value}`,
|
|
177
|
+
children: "\xD7"
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] }, value);
|
|
181
|
+
}),
|
|
182
|
+
/* @__PURE__ */ jsx(
|
|
183
|
+
"input",
|
|
184
|
+
{
|
|
185
|
+
ref: inputRef,
|
|
186
|
+
id,
|
|
187
|
+
type: "text",
|
|
188
|
+
role: "combobox",
|
|
189
|
+
"aria-autocomplete": "list",
|
|
190
|
+
"aria-expanded": isOpen,
|
|
191
|
+
"aria-haspopup": "listbox",
|
|
192
|
+
"aria-controls": listboxId,
|
|
193
|
+
"aria-activedescendant": focusedIndex >= 0 ? `${id}-option-${focusedIndex}` : void 0,
|
|
194
|
+
"aria-invalid": !!error,
|
|
195
|
+
value: inputValue,
|
|
196
|
+
onChange: (e) => {
|
|
197
|
+
setInputValue(e.target.value);
|
|
198
|
+
setIsOpen(true);
|
|
199
|
+
setFocusedIndex(-1);
|
|
200
|
+
},
|
|
201
|
+
onKeyDown: handleKeyDown,
|
|
202
|
+
onFocus: () => setIsOpen(true),
|
|
203
|
+
placeholder: selected.length === 0 ? placeholder : "",
|
|
204
|
+
style: styles.input
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
] }),
|
|
208
|
+
error && /* @__PURE__ */ jsx("div", { id: errorId, style: styles.error, role: "alert", children: error }),
|
|
209
|
+
isOpen && availableOptions.length > 0 && /* @__PURE__ */ jsx(
|
|
210
|
+
"ul",
|
|
211
|
+
{
|
|
212
|
+
id: listboxId,
|
|
213
|
+
role: "listbox",
|
|
214
|
+
"aria-label": label,
|
|
215
|
+
style: styles.listbox,
|
|
216
|
+
children: availableOptions.map((option, index) => /* @__PURE__ */ jsx(
|
|
217
|
+
"li",
|
|
218
|
+
{
|
|
219
|
+
id: `${id}-option-${index}`,
|
|
220
|
+
role: "option",
|
|
221
|
+
"aria-selected": false,
|
|
222
|
+
onClick: () => handleSelect(option.value),
|
|
223
|
+
onMouseEnter: () => setFocusedIndex(index),
|
|
224
|
+
style: {
|
|
225
|
+
...styles.option,
|
|
226
|
+
...focusedIndex === index ? styles.activeOption : {}
|
|
227
|
+
},
|
|
228
|
+
children: option.label
|
|
229
|
+
},
|
|
230
|
+
option.value
|
|
231
|
+
))
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
] });
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export {
|
|
238
|
+
MultiSelect
|
|
239
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -13,6 +13,17 @@ export { Switch } from './Switch/Switch.mjs';
|
|
|
13
13
|
export { Toast, ToastProvider, ToastType, useToast } from './Toast/Toast.mjs';
|
|
14
14
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './Tooltip/Tooltip.mjs';
|
|
15
15
|
export { Heading, HeadingProps } from './Heading/Heading.mjs';
|
|
16
|
+
export { AccessibilityStatement, AccessibilityStatementProps } from './AccessibilityStatement/AccessibilityStatement.mjs';
|
|
17
|
+
export { ErrorSummary, ErrorSummaryProps } from './ErrorSummary/ErrorSummary.mjs';
|
|
18
|
+
export { Combobox, ComboboxOption, ComboboxProps } from './Combobox/Combobox.mjs';
|
|
19
|
+
export { DatePicker, DatePickerProps } from './DatePicker/DatePicker.mjs';
|
|
20
|
+
export { MultiSelect, MultiSelectOption, MultiSelectProps } from './MultiSelect/MultiSelect.mjs';
|
|
21
|
+
export { Column, DataTable, DataTableProps } from './DataTable/DataTable.mjs';
|
|
22
|
+
export { Pagination, PaginationProps } from './Pagination/Pagination.mjs';
|
|
23
|
+
export { Card, CardProps } from './Card/Card.mjs';
|
|
24
|
+
export { TreeNode, TreeView, TreeViewProps } from './TreeView/TreeView.mjs';
|
|
25
|
+
export { LiveRegion, LiveRegionProps } from './LiveRegion/LiveRegion.mjs';
|
|
26
|
+
import '@holmdigital/standards';
|
|
16
27
|
|
|
17
28
|
interface BreadcrumbsProps extends React__default.HTMLAttributes<HTMLElement> {
|
|
18
29
|
separator?: ReactNode;
|
|
@@ -81,4 +92,34 @@ interface TabsContentProps {
|
|
|
81
92
|
}
|
|
82
93
|
declare const TabsContent: ({ value, children, className }: TabsContentProps) => react_jsx_runtime.JSX.Element | null;
|
|
83
94
|
|
|
84
|
-
|
|
95
|
+
interface ProgressBarProps {
|
|
96
|
+
value: number;
|
|
97
|
+
min?: number;
|
|
98
|
+
max?: number;
|
|
99
|
+
label: string;
|
|
100
|
+
showValueLabel?: boolean;
|
|
101
|
+
valueText?: string;
|
|
102
|
+
variant?: 'primary' | 'success' | 'warning' | 'danger';
|
|
103
|
+
className?: string;
|
|
104
|
+
}
|
|
105
|
+
declare const ProgressBar: React__default.FC<ProgressBarProps>;
|
|
106
|
+
|
|
107
|
+
interface SkeletonProps {
|
|
108
|
+
variant?: 'text' | 'circular' | 'rectangular';
|
|
109
|
+
width?: string | number;
|
|
110
|
+
height?: string | number;
|
|
111
|
+
animation?: 'pulse' | 'wave' | 'none';
|
|
112
|
+
className?: string;
|
|
113
|
+
}
|
|
114
|
+
declare const Skeleton: React__default.FC<SkeletonProps>;
|
|
115
|
+
|
|
116
|
+
interface HelpTextProps {
|
|
117
|
+
id: string;
|
|
118
|
+
children: React__default.ReactNode;
|
|
119
|
+
variant?: 'default' | 'error' | 'valid';
|
|
120
|
+
showIcon?: boolean;
|
|
121
|
+
className?: string;
|
|
122
|
+
}
|
|
123
|
+
declare const HelpText: React__default.FC<HelpTextProps>;
|
|
124
|
+
|
|
125
|
+
export { Accordion, AccordionContent, type AccordionContentProps, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, BreadcrumbItem, type BreadcrumbItemProps, Breadcrumbs, type BreadcrumbsProps, HelpText, type HelpTextProps, ProgressBar, type ProgressBarProps, Skeleton, type SkeletonProps, TabTrigger, type TabTriggerProps, Tabs, TabsContent, type TabsContentProps, TabsList, type TabsListProps, type TabsProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,17 @@ export { Switch } from './Switch/Switch.js';
|
|
|
13
13
|
export { Toast, ToastProvider, ToastType, useToast } from './Toast/Toast.js';
|
|
14
14
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './Tooltip/Tooltip.js';
|
|
15
15
|
export { Heading, HeadingProps } from './Heading/Heading.js';
|
|
16
|
+
export { AccessibilityStatement, AccessibilityStatementProps } from './AccessibilityStatement/AccessibilityStatement.js';
|
|
17
|
+
export { ErrorSummary, ErrorSummaryProps } from './ErrorSummary/ErrorSummary.js';
|
|
18
|
+
export { Combobox, ComboboxOption, ComboboxProps } from './Combobox/Combobox.js';
|
|
19
|
+
export { DatePicker, DatePickerProps } from './DatePicker/DatePicker.js';
|
|
20
|
+
export { MultiSelect, MultiSelectOption, MultiSelectProps } from './MultiSelect/MultiSelect.js';
|
|
21
|
+
export { Column, DataTable, DataTableProps } from './DataTable/DataTable.js';
|
|
22
|
+
export { Pagination, PaginationProps } from './Pagination/Pagination.js';
|
|
23
|
+
export { Card, CardProps } from './Card/Card.js';
|
|
24
|
+
export { TreeNode, TreeView, TreeViewProps } from './TreeView/TreeView.js';
|
|
25
|
+
export { LiveRegion, LiveRegionProps } from './LiveRegion/LiveRegion.js';
|
|
26
|
+
import '@holmdigital/standards';
|
|
16
27
|
|
|
17
28
|
interface BreadcrumbsProps extends React__default.HTMLAttributes<HTMLElement> {
|
|
18
29
|
separator?: ReactNode;
|
|
@@ -81,4 +92,34 @@ interface TabsContentProps {
|
|
|
81
92
|
}
|
|
82
93
|
declare const TabsContent: ({ value, children, className }: TabsContentProps) => react_jsx_runtime.JSX.Element | null;
|
|
83
94
|
|
|
84
|
-
|
|
95
|
+
interface ProgressBarProps {
|
|
96
|
+
value: number;
|
|
97
|
+
min?: number;
|
|
98
|
+
max?: number;
|
|
99
|
+
label: string;
|
|
100
|
+
showValueLabel?: boolean;
|
|
101
|
+
valueText?: string;
|
|
102
|
+
variant?: 'primary' | 'success' | 'warning' | 'danger';
|
|
103
|
+
className?: string;
|
|
104
|
+
}
|
|
105
|
+
declare const ProgressBar: React__default.FC<ProgressBarProps>;
|
|
106
|
+
|
|
107
|
+
interface SkeletonProps {
|
|
108
|
+
variant?: 'text' | 'circular' | 'rectangular';
|
|
109
|
+
width?: string | number;
|
|
110
|
+
height?: string | number;
|
|
111
|
+
animation?: 'pulse' | 'wave' | 'none';
|
|
112
|
+
className?: string;
|
|
113
|
+
}
|
|
114
|
+
declare const Skeleton: React__default.FC<SkeletonProps>;
|
|
115
|
+
|
|
116
|
+
interface HelpTextProps {
|
|
117
|
+
id: string;
|
|
118
|
+
children: React__default.ReactNode;
|
|
119
|
+
variant?: 'default' | 'error' | 'valid';
|
|
120
|
+
showIcon?: boolean;
|
|
121
|
+
className?: string;
|
|
122
|
+
}
|
|
123
|
+
declare const HelpText: React__default.FC<HelpTextProps>;
|
|
124
|
+
|
|
125
|
+
export { Accordion, AccordionContent, type AccordionContentProps, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, BreadcrumbItem, type BreadcrumbItemProps, Breadcrumbs, type BreadcrumbsProps, HelpText, type HelpTextProps, ProgressBar, type ProgressBarProps, Skeleton, type SkeletonProps, TabTrigger, type TabTriggerProps, Tabs, TabsContent, type TabsContentProps, TabsList, type TabsListProps, type TabsProps };
|