@holmdigital/components 1.2.4 → 2.0.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.
Files changed (66) hide show
  1. package/README.md +137 -60
  2. package/dist/AccessibilityStatement/AccessibilityStatement.d.mts +29 -0
  3. package/dist/AccessibilityStatement/AccessibilityStatement.d.ts +29 -0
  4. package/dist/AccessibilityStatement/AccessibilityStatement.js +551 -0
  5. package/dist/AccessibilityStatement/AccessibilityStatement.mjs +6 -0
  6. package/dist/Button/Button.js +1 -1
  7. package/dist/Button/Button.mjs +1 -1
  8. package/dist/Card/Card.d.mts +12 -0
  9. package/dist/Card/Card.d.ts +12 -0
  10. package/dist/Card/Card.js +81 -0
  11. package/dist/Card/Card.mjs +6 -0
  12. package/dist/Combobox/Combobox.d.mts +19 -0
  13. package/dist/Combobox/Combobox.d.ts +19 -0
  14. package/dist/Combobox/Combobox.js +271 -0
  15. package/dist/Combobox/Combobox.mjs +6 -0
  16. package/dist/DataTable/DataTable.d.mts +18 -0
  17. package/dist/DataTable/DataTable.d.ts +18 -0
  18. package/dist/DataTable/DataTable.js +125 -0
  19. package/dist/DataTable/DataTable.mjs +6 -0
  20. package/dist/DatePicker/DatePicker.d.mts +11 -0
  21. package/dist/DatePicker/DatePicker.d.ts +11 -0
  22. package/dist/DatePicker/DatePicker.js +110 -0
  23. package/dist/DatePicker/DatePicker.mjs +6 -0
  24. package/dist/ErrorSummary/ErrorSummary.d.mts +14 -0
  25. package/dist/ErrorSummary/ErrorSummary.d.ts +14 -0
  26. package/dist/ErrorSummary/ErrorSummary.js +119 -0
  27. package/dist/ErrorSummary/ErrorSummary.mjs +6 -0
  28. package/dist/LiveRegion/LiveRegion.d.mts +10 -0
  29. package/dist/LiveRegion/LiveRegion.d.ts +10 -0
  30. package/dist/LiveRegion/LiveRegion.js +69 -0
  31. package/dist/LiveRegion/LiveRegion.mjs +6 -0
  32. package/dist/Modal/Modal.d.mts +1 -2
  33. package/dist/Modal/Modal.d.ts +1 -2
  34. package/dist/MultiSelect/MultiSelect.d.mts +19 -0
  35. package/dist/MultiSelect/MultiSelect.d.ts +19 -0
  36. package/dist/MultiSelect/MultiSelect.js +263 -0
  37. package/dist/MultiSelect/MultiSelect.mjs +6 -0
  38. package/dist/Pagination/Pagination.d.mts +12 -0
  39. package/dist/Pagination/Pagination.d.ts +12 -0
  40. package/dist/Pagination/Pagination.js +149 -0
  41. package/dist/Pagination/Pagination.mjs +6 -0
  42. package/dist/Tooltip/Tooltip.d.mts +1 -1
  43. package/dist/Tooltip/Tooltip.d.ts +1 -1
  44. package/dist/Tooltip/Tooltip.js +1 -1
  45. package/dist/Tooltip/Tooltip.mjs +1 -1
  46. package/dist/TreeView/TreeView.d.mts +16 -0
  47. package/dist/TreeView/TreeView.d.ts +16 -0
  48. package/dist/TreeView/TreeView.js +250 -0
  49. package/dist/TreeView/TreeView.mjs +6 -0
  50. package/dist/chunk-4UONERC6.mjs +45 -0
  51. package/dist/chunk-57NZTQBX.mjs +86 -0
  52. package/dist/chunk-6REI7HHO.mjs +226 -0
  53. package/dist/chunk-EVNHLNS5.mjs +125 -0
  54. package/dist/chunk-FKSBWEX3.mjs +529 -0
  55. package/dist/chunk-HSUDZAQ6.mjs +101 -0
  56. package/dist/{chunk-C5M6C7KT.mjs → chunk-MCEJNWZT.mjs} +1 -1
  57. package/dist/{chunk-7V2LETZ6.mjs → chunk-MYXIUDCP.mjs} +1 -1
  58. package/dist/chunk-NECEXNCF.mjs +57 -0
  59. package/dist/chunk-OMSIXECN.mjs +247 -0
  60. package/dist/chunk-P2IXX552.mjs +95 -0
  61. package/dist/chunk-VM3O36W4.mjs +239 -0
  62. package/dist/index.d.mts +42 -1
  63. package/dist/index.d.ts +42 -1
  64. package/dist/index.js +1941 -2
  65. package/dist/index.mjs +244 -6
  66. package/package.json +48 -6
@@ -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
- export { Accordion, AccordionContent, type AccordionContentProps, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, BreadcrumbItem, type BreadcrumbItemProps, Breadcrumbs, type BreadcrumbsProps, TabTrigger, type TabTriggerProps, Tabs, TabsContent, type TabsContentProps, TabsList, type TabsListProps, type TabsProps };
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
- export { Accordion, AccordionContent, type AccordionContentProps, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, BreadcrumbItem, type BreadcrumbItemProps, Breadcrumbs, type BreadcrumbsProps, TabTrigger, type TabTriggerProps, Tabs, TabsContent, type TabsContentProps, TabsList, type TabsListProps, type TabsProps };
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 };