@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,19 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface ComboboxOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
interface ComboboxProps {
|
|
8
|
+
label: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
options: ComboboxOption[];
|
|
12
|
+
onChange: (value: string | null) => void;
|
|
13
|
+
value?: string | null;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const Combobox: React__default.FC<ComboboxProps>;
|
|
18
|
+
|
|
19
|
+
export { Combobox, type ComboboxOption, type ComboboxProps };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface ComboboxOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
interface ComboboxProps {
|
|
8
|
+
label: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
options: ComboboxOption[];
|
|
12
|
+
onChange: (value: string | null) => void;
|
|
13
|
+
value?: string | null;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const Combobox: React__default.FC<ComboboxProps>;
|
|
18
|
+
|
|
19
|
+
export { Combobox, type ComboboxOption, type ComboboxProps };
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/Combobox/Combobox.tsx
|
|
21
|
+
var Combobox_exports = {};
|
|
22
|
+
__export(Combobox_exports, {
|
|
23
|
+
Combobox: () => Combobox
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(Combobox_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var Combobox = ({
|
|
29
|
+
label,
|
|
30
|
+
description,
|
|
31
|
+
error,
|
|
32
|
+
options,
|
|
33
|
+
onChange,
|
|
34
|
+
value,
|
|
35
|
+
placeholder = "Type to search...",
|
|
36
|
+
className = ""
|
|
37
|
+
}) => {
|
|
38
|
+
const [isOpen, setIsOpen] = (0, import_react.useState)(false);
|
|
39
|
+
const [inputValue, setInputValue] = (0, import_react.useState)("");
|
|
40
|
+
const [focusedIndex, setFocusedIndex] = (0, import_react.useState)(-1);
|
|
41
|
+
const inputRef = (0, import_react.useRef)(null);
|
|
42
|
+
const listboxRef = (0, import_react.useRef)(null);
|
|
43
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
44
|
+
const id = (0, import_react.useId)();
|
|
45
|
+
const listboxId = `${id}-listbox`;
|
|
46
|
+
const labelId = `${id}-label`;
|
|
47
|
+
const descriptionId = `${id}-description`;
|
|
48
|
+
const errorId = `${id}-error`;
|
|
49
|
+
const filteredOptions = options.filter(
|
|
50
|
+
(option) => option.label.toLowerCase().includes(inputValue.toLowerCase())
|
|
51
|
+
);
|
|
52
|
+
(0, import_react.useEffect)(() => {
|
|
53
|
+
if (value) {
|
|
54
|
+
const selectedOption = options.find((o) => o.value === value);
|
|
55
|
+
if (selectedOption) {
|
|
56
|
+
setInputValue(selectedOption.label);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
setInputValue("");
|
|
60
|
+
}
|
|
61
|
+
}, [value, options]);
|
|
62
|
+
(0, import_react.useEffect)(() => {
|
|
63
|
+
const handleClickOutside = (event) => {
|
|
64
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
65
|
+
setIsOpen(false);
|
|
66
|
+
setFocusedIndex(-1);
|
|
67
|
+
if (value) {
|
|
68
|
+
const selectedOption = options.find((o) => o.value === value);
|
|
69
|
+
if (selectedOption) setInputValue(selectedOption.label);
|
|
70
|
+
} else {
|
|
71
|
+
setInputValue("");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
76
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
77
|
+
}, [value, options]);
|
|
78
|
+
const handleInputChange = (e) => {
|
|
79
|
+
setInputValue(e.target.value);
|
|
80
|
+
setIsOpen(true);
|
|
81
|
+
setFocusedIndex(-1);
|
|
82
|
+
if (e.target.value === "") {
|
|
83
|
+
onChange(null);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const handleOptionSelect = (option) => {
|
|
87
|
+
onChange(option.value);
|
|
88
|
+
setInputValue(option.label);
|
|
89
|
+
setIsOpen(false);
|
|
90
|
+
setFocusedIndex(-1);
|
|
91
|
+
};
|
|
92
|
+
const handleKeyDown = (e) => {
|
|
93
|
+
if (!isOpen && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
|
|
94
|
+
setIsOpen(true);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
switch (e.key) {
|
|
98
|
+
case "ArrowDown":
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
setFocusedIndex(
|
|
101
|
+
(prev) => prev < filteredOptions.length - 1 ? prev + 1 : 0
|
|
102
|
+
);
|
|
103
|
+
break;
|
|
104
|
+
case "ArrowUp":
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
setFocusedIndex(
|
|
107
|
+
(prev) => prev > 0 ? prev - 1 : filteredOptions.length - 1
|
|
108
|
+
);
|
|
109
|
+
break;
|
|
110
|
+
case "Enter":
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
if (isOpen && focusedIndex >= 0) {
|
|
113
|
+
handleOptionSelect(filteredOptions[focusedIndex]);
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
case "Escape":
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
setIsOpen(false);
|
|
119
|
+
setFocusedIndex(-1);
|
|
120
|
+
if (value) {
|
|
121
|
+
const selectedOption = options.find((o) => o.value === value);
|
|
122
|
+
if (selectedOption) setInputValue(selectedOption.label);
|
|
123
|
+
} else {
|
|
124
|
+
setInputValue("");
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
case "Tab":
|
|
128
|
+
setIsOpen(false);
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const styles = {
|
|
133
|
+
container: {
|
|
134
|
+
position: "relative",
|
|
135
|
+
marginBottom: "1rem",
|
|
136
|
+
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
137
|
+
},
|
|
138
|
+
label: {
|
|
139
|
+
display: "block",
|
|
140
|
+
fontWeight: 600,
|
|
141
|
+
marginBottom: "0.25rem",
|
|
142
|
+
color: "#1e293b"
|
|
143
|
+
},
|
|
144
|
+
description: {
|
|
145
|
+
fontSize: "0.875rem",
|
|
146
|
+
color: "#64748b",
|
|
147
|
+
marginBottom: "0.5rem"
|
|
148
|
+
},
|
|
149
|
+
error: {
|
|
150
|
+
fontSize: "0.875rem",
|
|
151
|
+
color: "#dc2626",
|
|
152
|
+
marginTop: "0.25rem"
|
|
153
|
+
},
|
|
154
|
+
input: {
|
|
155
|
+
width: "100%",
|
|
156
|
+
padding: "0.5rem 0.75rem",
|
|
157
|
+
fontSize: "1rem",
|
|
158
|
+
border: `1px solid ${error ? "#dc2626" : "#cbd5e1"}`,
|
|
159
|
+
borderRadius: "0.375rem",
|
|
160
|
+
outline: "none",
|
|
161
|
+
boxSizing: "border-box"
|
|
162
|
+
},
|
|
163
|
+
listbox: {
|
|
164
|
+
position: "absolute",
|
|
165
|
+
top: "100%",
|
|
166
|
+
left: 0,
|
|
167
|
+
right: 0,
|
|
168
|
+
maxHeight: "200px",
|
|
169
|
+
overflowY: "auto",
|
|
170
|
+
border: "1px solid #cbd5e1",
|
|
171
|
+
borderRadius: "0.375rem",
|
|
172
|
+
backgroundColor: "white",
|
|
173
|
+
zIndex: 10,
|
|
174
|
+
marginTop: "0.25rem",
|
|
175
|
+
padding: 0,
|
|
176
|
+
listStyle: "none",
|
|
177
|
+
boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1)"
|
|
178
|
+
},
|
|
179
|
+
option: {
|
|
180
|
+
padding: "0.5rem 0.75rem",
|
|
181
|
+
cursor: "pointer"
|
|
182
|
+
},
|
|
183
|
+
activeOption: {
|
|
184
|
+
backgroundColor: "#e2e8f0",
|
|
185
|
+
color: "#0f172a"
|
|
186
|
+
},
|
|
187
|
+
noResults: {
|
|
188
|
+
padding: "0.5rem 0.75rem",
|
|
189
|
+
color: "#64748b",
|
|
190
|
+
fontStyle: "italic"
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: containerRef, className, style: styles.container, children: [
|
|
194
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
195
|
+
"label",
|
|
196
|
+
{
|
|
197
|
+
id: labelId,
|
|
198
|
+
htmlFor: id,
|
|
199
|
+
style: styles.label,
|
|
200
|
+
children: label
|
|
201
|
+
}
|
|
202
|
+
),
|
|
203
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: descriptionId, style: styles.description, children: description }),
|
|
204
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
205
|
+
"input",
|
|
206
|
+
{
|
|
207
|
+
ref: inputRef,
|
|
208
|
+
id,
|
|
209
|
+
type: "text",
|
|
210
|
+
role: "combobox",
|
|
211
|
+
"aria-autocomplete": "list",
|
|
212
|
+
"aria-expanded": isOpen,
|
|
213
|
+
"aria-haspopup": "listbox",
|
|
214
|
+
"aria-controls": listboxId,
|
|
215
|
+
"aria-activedescendant": focusedIndex >= 0 ? `${id}-option-${focusedIndex}` : void 0,
|
|
216
|
+
"aria-invalid": !!error,
|
|
217
|
+
"aria-describedby": [
|
|
218
|
+
description ? descriptionId : null,
|
|
219
|
+
error ? errorId : null
|
|
220
|
+
].filter(Boolean).join(" ") || void 0,
|
|
221
|
+
value: inputValue,
|
|
222
|
+
onChange: handleInputChange,
|
|
223
|
+
onKeyDown: handleKeyDown,
|
|
224
|
+
placeholder,
|
|
225
|
+
style: {
|
|
226
|
+
...styles.input,
|
|
227
|
+
...isOpen ? { borderColor: "#3b82f6", ring: "2px solid #93c5fd" } : {}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
),
|
|
231
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: errorId, style: styles.error, role: "alert", children: error }),
|
|
232
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
233
|
+
"ul",
|
|
234
|
+
{
|
|
235
|
+
ref: listboxRef,
|
|
236
|
+
id: listboxId,
|
|
237
|
+
role: "listbox",
|
|
238
|
+
"aria-label": label,
|
|
239
|
+
style: styles.listbox,
|
|
240
|
+
children: filteredOptions.length > 0 ? filteredOptions.map((option, index) => {
|
|
241
|
+
const isSelected = value === option.value;
|
|
242
|
+
const isFocused = focusedIndex === index;
|
|
243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
244
|
+
"li",
|
|
245
|
+
{
|
|
246
|
+
id: `${id}-option-${index}`,
|
|
247
|
+
role: "option",
|
|
248
|
+
"aria-selected": isSelected,
|
|
249
|
+
onClick: () => handleOptionSelect(option),
|
|
250
|
+
onMouseEnter: () => setFocusedIndex(index),
|
|
251
|
+
style: {
|
|
252
|
+
...styles.option,
|
|
253
|
+
...isFocused ? styles.activeOption : {},
|
|
254
|
+
...isSelected ? { fontWeight: "bold" } : {}
|
|
255
|
+
},
|
|
256
|
+
children: [
|
|
257
|
+
option.label,
|
|
258
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", style: { float: "right" }, children: "\u2713" })
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
option.value
|
|
262
|
+
);
|
|
263
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { style: styles.noResults, children: "No results found" })
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
] });
|
|
267
|
+
};
|
|
268
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
269
|
+
0 && (module.exports = {
|
|
270
|
+
Combobox
|
|
271
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
interface Column<T> {
|
|
5
|
+
header: string;
|
|
6
|
+
accessor: keyof T;
|
|
7
|
+
sortable?: boolean;
|
|
8
|
+
render?: (item: T) => React__default.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
interface DataTableProps<T> {
|
|
11
|
+
data: T[];
|
|
12
|
+
columns: Column<T>[];
|
|
13
|
+
caption: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function DataTable<T>({ data, columns, caption, className }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { type Column, DataTable, type DataTableProps };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
interface Column<T> {
|
|
5
|
+
header: string;
|
|
6
|
+
accessor: keyof T;
|
|
7
|
+
sortable?: boolean;
|
|
8
|
+
render?: (item: T) => React__default.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
interface DataTableProps<T> {
|
|
11
|
+
data: T[];
|
|
12
|
+
columns: Column<T>[];
|
|
13
|
+
caption: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function DataTable<T>({ data, columns, caption, className }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { type Column, DataTable, type DataTableProps };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/DataTable/DataTable.tsx
|
|
21
|
+
var DataTable_exports = {};
|
|
22
|
+
__export(DataTable_exports, {
|
|
23
|
+
DataTable: () => DataTable
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(DataTable_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
function DataTable({
|
|
29
|
+
data,
|
|
30
|
+
columns,
|
|
31
|
+
caption,
|
|
32
|
+
className = ""
|
|
33
|
+
}) {
|
|
34
|
+
const [sortConfig, setSortConfig] = (0, import_react.useState)({ key: null, direction: "ascending" });
|
|
35
|
+
const handleSort = (key) => {
|
|
36
|
+
let direction = "ascending";
|
|
37
|
+
if (sortConfig.key === key && sortConfig.direction === "ascending") {
|
|
38
|
+
direction = "descending";
|
|
39
|
+
}
|
|
40
|
+
setSortConfig({ key, direction });
|
|
41
|
+
};
|
|
42
|
+
const sortedData = (0, import_react.useMemo)(() => {
|
|
43
|
+
if (!sortConfig.key) return data;
|
|
44
|
+
return [...data].sort((a, b) => {
|
|
45
|
+
const aValue = a[sortConfig.key];
|
|
46
|
+
const bValue = b[sortConfig.key];
|
|
47
|
+
if (aValue < bValue) {
|
|
48
|
+
return sortConfig.direction === "ascending" ? -1 : 1;
|
|
49
|
+
}
|
|
50
|
+
if (aValue > bValue) {
|
|
51
|
+
return sortConfig.direction === "ascending" ? 1 : -1;
|
|
52
|
+
}
|
|
53
|
+
return 0;
|
|
54
|
+
});
|
|
55
|
+
}, [data, sortConfig]);
|
|
56
|
+
const styles = {
|
|
57
|
+
table: {
|
|
58
|
+
width: "100%",
|
|
59
|
+
borderCollapse: "collapse",
|
|
60
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
61
|
+
marginBottom: "1rem"
|
|
62
|
+
},
|
|
63
|
+
caption: {
|
|
64
|
+
textAlign: "left",
|
|
65
|
+
fontWeight: "bold",
|
|
66
|
+
fontSize: "1.25rem",
|
|
67
|
+
marginBottom: "0.75rem",
|
|
68
|
+
color: "#1e293b"
|
|
69
|
+
},
|
|
70
|
+
th: {
|
|
71
|
+
textAlign: "left",
|
|
72
|
+
borderBottom: "2px solid #e2e8f0",
|
|
73
|
+
padding: "0.75rem",
|
|
74
|
+
fontWeight: 600,
|
|
75
|
+
color: "#475569",
|
|
76
|
+
backgroundColor: "#f8fafc"
|
|
77
|
+
},
|
|
78
|
+
td: {
|
|
79
|
+
padding: "0.75rem",
|
|
80
|
+
borderBottom: "1px solid #e2e8f0",
|
|
81
|
+
color: "#334155"
|
|
82
|
+
},
|
|
83
|
+
sortButton: {
|
|
84
|
+
background: "none",
|
|
85
|
+
border: "none",
|
|
86
|
+
font: "inherit",
|
|
87
|
+
fontWeight: 600,
|
|
88
|
+
cursor: "pointer",
|
|
89
|
+
padding: 0,
|
|
90
|
+
display: "inline-flex",
|
|
91
|
+
alignItems: "center",
|
|
92
|
+
gap: "0.5rem",
|
|
93
|
+
color: "inherit"
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, style: { overflowX: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { style: styles.table, children: [
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("caption", { style: styles.caption, children: caption }),
|
|
98
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
|
+
"th",
|
|
100
|
+
{
|
|
101
|
+
scope: "col",
|
|
102
|
+
"aria-sort": sortConfig.key === column.accessor ? sortConfig.direction : void 0,
|
|
103
|
+
style: styles.th,
|
|
104
|
+
children: column.sortable ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
105
|
+
"button",
|
|
106
|
+
{
|
|
107
|
+
type: "button",
|
|
108
|
+
onClick: () => handleSort(column.accessor),
|
|
109
|
+
style: styles.sortButton,
|
|
110
|
+
children: [
|
|
111
|
+
column.header,
|
|
112
|
+
sortConfig.key === column.accessor ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", children: sortConfig.direction === "ascending" ? "\u25B2" : "\u25BC" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", style: { opacity: 0.3 }, children: "\u2195" })
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
) : column.header
|
|
116
|
+
},
|
|
117
|
+
index
|
|
118
|
+
)) }) }),
|
|
119
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: sortedData.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: columns.map((column, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { style: styles.td, children: column.render ? column.render(row) : String(row[column.accessor]) }, colIndex)) }, rowIndex)) })
|
|
120
|
+
] }) });
|
|
121
|
+
}
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {
|
|
124
|
+
DataTable
|
|
125
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface DatePickerProps extends React__default.InputHTMLAttributes<HTMLInputElement> {
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const DatePicker: React__default.ForwardRefExoticComponent<DatePickerProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
10
|
+
|
|
11
|
+
export { DatePicker, type DatePickerProps };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface DatePickerProps extends React__default.InputHTMLAttributes<HTMLInputElement> {
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const DatePicker: React__default.ForwardRefExoticComponent<DatePickerProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
10
|
+
|
|
11
|
+
export { DatePicker, type DatePickerProps };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/DatePicker/DatePicker.tsx
|
|
21
|
+
var DatePicker_exports = {};
|
|
22
|
+
__export(DatePicker_exports, {
|
|
23
|
+
DatePicker: () => DatePicker
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(DatePicker_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var DatePicker = (0, import_react.forwardRef)(({
|
|
29
|
+
label,
|
|
30
|
+
description,
|
|
31
|
+
error,
|
|
32
|
+
className = "",
|
|
33
|
+
style,
|
|
34
|
+
id: providedId,
|
|
35
|
+
...props
|
|
36
|
+
}, ref) => {
|
|
37
|
+
const generatedId = (0, import_react.useId)();
|
|
38
|
+
const id = providedId || generatedId;
|
|
39
|
+
const descriptionId = `${id}-description`;
|
|
40
|
+
const errorId = `${id}-error`;
|
|
41
|
+
const styles = {
|
|
42
|
+
container: {
|
|
43
|
+
marginBottom: "1rem",
|
|
44
|
+
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
45
|
+
},
|
|
46
|
+
label: {
|
|
47
|
+
display: "block",
|
|
48
|
+
fontWeight: 600,
|
|
49
|
+
marginBottom: "0.25rem",
|
|
50
|
+
color: "#1e293b"
|
|
51
|
+
},
|
|
52
|
+
description: {
|
|
53
|
+
fontSize: "0.875rem",
|
|
54
|
+
color: "#64748b",
|
|
55
|
+
marginBottom: "0.5rem"
|
|
56
|
+
},
|
|
57
|
+
error: {
|
|
58
|
+
fontSize: "0.875rem",
|
|
59
|
+
color: "#dc2626",
|
|
60
|
+
marginTop: "0.25rem"
|
|
61
|
+
},
|
|
62
|
+
input: {
|
|
63
|
+
display: "block",
|
|
64
|
+
width: "100%",
|
|
65
|
+
padding: "0.5rem 0.75rem",
|
|
66
|
+
fontSize: "1rem",
|
|
67
|
+
lineHeight: 1.5,
|
|
68
|
+
color: "#0f172a",
|
|
69
|
+
backgroundColor: "#ffffff",
|
|
70
|
+
border: `1px solid ${error ? "#dc2626" : "#cbd5e1"}`,
|
|
71
|
+
borderRadius: "0.375rem",
|
|
72
|
+
outline: "none",
|
|
73
|
+
boxSizing: "border-box",
|
|
74
|
+
minHeight: "2.5rem"
|
|
75
|
+
// Ensure touch target size
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className, style: { ...styles.container, ...style }, children: [
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
80
|
+
"label",
|
|
81
|
+
{
|
|
82
|
+
htmlFor: id,
|
|
83
|
+
style: styles.label,
|
|
84
|
+
children: label
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: descriptionId, style: styles.description, children: description }),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
89
|
+
"input",
|
|
90
|
+
{
|
|
91
|
+
ref,
|
|
92
|
+
id,
|
|
93
|
+
type: "date",
|
|
94
|
+
"aria-invalid": !!error,
|
|
95
|
+
"aria-describedby": [
|
|
96
|
+
description ? descriptionId : null,
|
|
97
|
+
error ? errorId : null
|
|
98
|
+
].filter(Boolean).join(" ") || void 0,
|
|
99
|
+
style: styles.input,
|
|
100
|
+
...props
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: errorId, style: styles.error, role: "alert", children: error })
|
|
104
|
+
] });
|
|
105
|
+
});
|
|
106
|
+
DatePicker.displayName = "DatePicker";
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
DatePicker
|
|
110
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface ErrorSummaryProps {
|
|
4
|
+
errors: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}>;
|
|
8
|
+
title?: string;
|
|
9
|
+
focusOnMount?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const ErrorSummary: React__default.FC<ErrorSummaryProps>;
|
|
13
|
+
|
|
14
|
+
export { ErrorSummary, type ErrorSummaryProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface ErrorSummaryProps {
|
|
4
|
+
errors: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}>;
|
|
8
|
+
title?: string;
|
|
9
|
+
focusOnMount?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const ErrorSummary: React__default.FC<ErrorSummaryProps>;
|
|
13
|
+
|
|
14
|
+
export { ErrorSummary, type ErrorSummaryProps };
|