@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,226 @@
|
|
|
1
|
+
// src/TreeView/TreeView.tsx
|
|
2
|
+
import { useState, useRef, useEffect } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var TreeView = ({
|
|
5
|
+
data,
|
|
6
|
+
ariaLabel = "Tree View",
|
|
7
|
+
className = "",
|
|
8
|
+
onSelect
|
|
9
|
+
}) => {
|
|
10
|
+
const [expandedIds, setExpandedIds] = useState(/* @__PURE__ */ new Set());
|
|
11
|
+
const [selectedId, setSelectedId] = useState(null);
|
|
12
|
+
const [focusedId, setFocusedId] = useState(data.length > 0 ? data[0].id : null);
|
|
13
|
+
const nodeRefs = useRef(/* @__PURE__ */ new Map());
|
|
14
|
+
const toggleExpand = (nodeId) => {
|
|
15
|
+
const newExpanded = new Set(expandedIds);
|
|
16
|
+
if (newExpanded.has(nodeId)) {
|
|
17
|
+
newExpanded.delete(nodeId);
|
|
18
|
+
} else {
|
|
19
|
+
newExpanded.add(nodeId);
|
|
20
|
+
}
|
|
21
|
+
setExpandedIds(newExpanded);
|
|
22
|
+
};
|
|
23
|
+
const getVisibleNodes = (nodes) => {
|
|
24
|
+
let visible = [];
|
|
25
|
+
for (const node of nodes) {
|
|
26
|
+
visible.push(node);
|
|
27
|
+
if (node.children && expandedIds.has(node.id)) {
|
|
28
|
+
visible = visible.concat(getVisibleNodes(node.children));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return visible;
|
|
32
|
+
};
|
|
33
|
+
const handleKeyDown = (e, node) => {
|
|
34
|
+
const visibleNodes = getVisibleNodes(data);
|
|
35
|
+
const currentIndex = visibleNodes.findIndex((n) => n.id === node.id);
|
|
36
|
+
switch (e.key) {
|
|
37
|
+
case "ArrowDown": {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
if (currentIndex < visibleNodes.length - 1) {
|
|
40
|
+
const nextNode = visibleNodes[currentIndex + 1];
|
|
41
|
+
setFocusedId(nextNode.id);
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case "ArrowUp": {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
if (currentIndex > 0) {
|
|
48
|
+
const prevNode = visibleNodes[currentIndex - 1];
|
|
49
|
+
setFocusedId(prevNode.id);
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case "ArrowRight": {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
if (node.children && !expandedIds.has(node.id)) {
|
|
56
|
+
toggleExpand(node.id);
|
|
57
|
+
} else if (node.children && expandedIds.has(node.id)) {
|
|
58
|
+
if (currentIndex < visibleNodes.length - 1) {
|
|
59
|
+
setFocusedId(visibleNodes[currentIndex + 1].id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case "ArrowLeft": {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
if (node.children && expandedIds.has(node.id)) {
|
|
67
|
+
toggleExpand(node.id);
|
|
68
|
+
} else {
|
|
69
|
+
const parent = findParent(data, node.id);
|
|
70
|
+
if (parent) {
|
|
71
|
+
setFocusedId(parent.id);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case "Home": {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
if (visibleNodes.length > 0) {
|
|
79
|
+
setFocusedId(visibleNodes[0].id);
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case "End": {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
if (visibleNodes.length > 0) {
|
|
86
|
+
setFocusedId(visibleNodes[visibleNodes.length - 1].id);
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case "Enter":
|
|
91
|
+
case " ": {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
if (onSelect) onSelect(node);
|
|
94
|
+
setSelectedId(node.id);
|
|
95
|
+
if (node.children) {
|
|
96
|
+
toggleExpand(node.id);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const findParent = (nodes, childId, parent = null) => {
|
|
103
|
+
for (const node of nodes) {
|
|
104
|
+
if (node.id === childId) return parent;
|
|
105
|
+
if (node.children) {
|
|
106
|
+
const found = findParent(node.children, childId, node);
|
|
107
|
+
if (found) return found;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
};
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (focusedId) {
|
|
114
|
+
const el = nodeRefs.current.get(focusedId);
|
|
115
|
+
if (el) el.focus();
|
|
116
|
+
}
|
|
117
|
+
}, [focusedId]);
|
|
118
|
+
const renderTree = (nodes, level = 1) => {
|
|
119
|
+
return /* @__PURE__ */ jsx("ul", { role: "group", style: { paddingLeft: level > 1 ? "1.5rem" : 0, listStyle: "none", margin: 0 }, children: nodes.map((node) => {
|
|
120
|
+
const isExpanded = expandedIds.has(node.id);
|
|
121
|
+
const hasChildren = node.children && node.children.length > 0;
|
|
122
|
+
return /* @__PURE__ */ jsxs("li", { role: "none", children: [
|
|
123
|
+
/* @__PURE__ */ jsxs(
|
|
124
|
+
"div",
|
|
125
|
+
{
|
|
126
|
+
ref: (el) => {
|
|
127
|
+
if (el) nodeRefs.current.set(node.id, el);
|
|
128
|
+
else nodeRefs.current.delete(node.id);
|
|
129
|
+
},
|
|
130
|
+
role: "treeitem",
|
|
131
|
+
"aria-expanded": hasChildren ? isExpanded : void 0,
|
|
132
|
+
"aria-selected": selectedId === node.id,
|
|
133
|
+
"aria-level": level,
|
|
134
|
+
tabIndex: focusedId === node.id ? 0 : -1,
|
|
135
|
+
onClick: () => {
|
|
136
|
+
setFocusedId(node.id);
|
|
137
|
+
setSelectedId(node.id);
|
|
138
|
+
if (hasChildren) toggleExpand(node.id);
|
|
139
|
+
if (onSelect) onSelect(node);
|
|
140
|
+
},
|
|
141
|
+
onKeyDown: (e) => handleKeyDown(e, node),
|
|
142
|
+
style: {
|
|
143
|
+
cursor: "pointer",
|
|
144
|
+
padding: "0.25rem 0.5rem",
|
|
145
|
+
borderRadius: "0.25rem",
|
|
146
|
+
outline: "none",
|
|
147
|
+
backgroundColor: selectedId === node.id ? "#e0f2fe" : "transparent",
|
|
148
|
+
// Sky-100
|
|
149
|
+
color: selectedId === node.id ? "#0369a1" : "inherit",
|
|
150
|
+
// Sky-700
|
|
151
|
+
border: focusedId === node.id ? "1px solid #0ea5e9" : "1px solid transparent",
|
|
152
|
+
// Sky-500
|
|
153
|
+
display: "flex",
|
|
154
|
+
alignItems: "center",
|
|
155
|
+
gap: "0.5rem"
|
|
156
|
+
},
|
|
157
|
+
children: [
|
|
158
|
+
hasChildren && /* @__PURE__ */ jsx("span", { style: { fontSize: "0.75rem", color: "#94a3b8" }, children: isExpanded ? "\u25BC" : "\u25B6" }),
|
|
159
|
+
!hasChildren && /* @__PURE__ */ jsx("span", { style: { width: "0.75rem" } }),
|
|
160
|
+
node.label
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
hasChildren && isExpanded && renderTree(node.children, level + 1)
|
|
165
|
+
] }, node.id);
|
|
166
|
+
}) });
|
|
167
|
+
};
|
|
168
|
+
const styles = {
|
|
169
|
+
container: {
|
|
170
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
171
|
+
border: "1px solid #cbd5e1",
|
|
172
|
+
borderRadius: "0.375rem",
|
|
173
|
+
padding: "1rem",
|
|
174
|
+
backgroundColor: "white"
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
return /* @__PURE__ */ jsx("div", { className, style: styles.container, children: /* @__PURE__ */ jsx("ul", { role: "tree", "aria-label": ariaLabel, style: { listStyle: "none", padding: 0, margin: 0 }, children: data.map((node) => {
|
|
178
|
+
const isExpanded = expandedIds.has(node.id);
|
|
179
|
+
const hasChildren = node.children && node.children.length > 0;
|
|
180
|
+
return /* @__PURE__ */ jsxs("li", { role: "none", children: [
|
|
181
|
+
/* @__PURE__ */ jsxs(
|
|
182
|
+
"div",
|
|
183
|
+
{
|
|
184
|
+
ref: (el) => {
|
|
185
|
+
if (el) nodeRefs.current.set(node.id, el);
|
|
186
|
+
else nodeRefs.current.delete(node.id);
|
|
187
|
+
},
|
|
188
|
+
role: "treeitem",
|
|
189
|
+
"aria-expanded": hasChildren ? isExpanded : void 0,
|
|
190
|
+
"aria-selected": selectedId === node.id,
|
|
191
|
+
"aria-level": 1,
|
|
192
|
+
tabIndex: focusedId === node.id ? 0 : -1,
|
|
193
|
+
onClick: () => {
|
|
194
|
+
setFocusedId(node.id);
|
|
195
|
+
setSelectedId(node.id);
|
|
196
|
+
if (hasChildren) toggleExpand(node.id);
|
|
197
|
+
if (onSelect) onSelect(node);
|
|
198
|
+
},
|
|
199
|
+
onKeyDown: (e) => handleKeyDown(e, node),
|
|
200
|
+
style: {
|
|
201
|
+
cursor: "pointer",
|
|
202
|
+
padding: "0.25rem 0.5rem",
|
|
203
|
+
borderRadius: "0.25rem",
|
|
204
|
+
outline: "none",
|
|
205
|
+
backgroundColor: selectedId === node.id ? "#e0f2fe" : "transparent",
|
|
206
|
+
color: selectedId === node.id ? "#0369a1" : "inherit",
|
|
207
|
+
border: focusedId === node.id ? "1px solid #0ea5e9" : "1px solid transparent",
|
|
208
|
+
display: "flex",
|
|
209
|
+
alignItems: "center",
|
|
210
|
+
gap: "0.5rem"
|
|
211
|
+
},
|
|
212
|
+
children: [
|
|
213
|
+
hasChildren && /* @__PURE__ */ jsx("span", { style: { fontSize: "0.75rem", color: "#94a3b8" }, children: isExpanded ? "\u25BC" : "\u25B6" }),
|
|
214
|
+
!hasChildren && /* @__PURE__ */ jsx("span", { style: { width: "0.75rem" } }),
|
|
215
|
+
node.label
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
hasChildren && isExpanded && renderTree(node.children, 2)
|
|
220
|
+
] }, node.id);
|
|
221
|
+
}) }) });
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export {
|
|
225
|
+
TreeView
|
|
226
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// src/Pagination/Pagination.tsx
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
var Pagination = ({
|
|
4
|
+
currentPage,
|
|
5
|
+
totalPages,
|
|
6
|
+
onPageChange,
|
|
7
|
+
ariaLabel = "Pagination",
|
|
8
|
+
className = ""
|
|
9
|
+
}) => {
|
|
10
|
+
if (totalPages <= 1) return null;
|
|
11
|
+
const getPageNumbers = () => {
|
|
12
|
+
const pages2 = [];
|
|
13
|
+
pages2.push(1);
|
|
14
|
+
const start = Math.max(2, currentPage - 1);
|
|
15
|
+
const end = Math.min(totalPages - 1, currentPage + 1);
|
|
16
|
+
if (start > 2) pages2.push("...");
|
|
17
|
+
for (let i = start; i <= end; i++) {
|
|
18
|
+
pages2.push(i);
|
|
19
|
+
}
|
|
20
|
+
if (end < totalPages - 1) pages2.push("...");
|
|
21
|
+
if (totalPages > 1) {
|
|
22
|
+
pages2.push(totalPages);
|
|
23
|
+
}
|
|
24
|
+
return Array.from(new Set(pages2));
|
|
25
|
+
};
|
|
26
|
+
const pages = getPageNumbers();
|
|
27
|
+
const styles = {
|
|
28
|
+
nav: {
|
|
29
|
+
display: "flex",
|
|
30
|
+
justifyContent: "center",
|
|
31
|
+
marginTop: "1.5rem",
|
|
32
|
+
marginBottom: "1.5rem",
|
|
33
|
+
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
34
|
+
},
|
|
35
|
+
list: {
|
|
36
|
+
display: "flex",
|
|
37
|
+
listStyle: "none",
|
|
38
|
+
padding: 0,
|
|
39
|
+
margin: 0,
|
|
40
|
+
gap: "0.5rem",
|
|
41
|
+
alignItems: "center"
|
|
42
|
+
},
|
|
43
|
+
button: {
|
|
44
|
+
minWidth: "2.5rem",
|
|
45
|
+
height: "2.5rem",
|
|
46
|
+
display: "flex",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
justifyContent: "center",
|
|
49
|
+
border: "1px solid #cbd5e1",
|
|
50
|
+
backgroundColor: "white",
|
|
51
|
+
borderRadius: "0.375rem",
|
|
52
|
+
cursor: "pointer",
|
|
53
|
+
fontSize: "1rem",
|
|
54
|
+
color: "#1e293b",
|
|
55
|
+
padding: "0 0.75rem",
|
|
56
|
+
transition: "all 0.2s"
|
|
57
|
+
},
|
|
58
|
+
activeButton: {
|
|
59
|
+
backgroundColor: "#2563eb",
|
|
60
|
+
// Blue-600
|
|
61
|
+
color: "white",
|
|
62
|
+
borderColor: "#2563eb",
|
|
63
|
+
fontWeight: "bold"
|
|
64
|
+
},
|
|
65
|
+
disabledButton: {
|
|
66
|
+
opacity: 0.5,
|
|
67
|
+
cursor: "not-allowed",
|
|
68
|
+
backgroundColor: "#f1f5f9"
|
|
69
|
+
},
|
|
70
|
+
ellipsis: {
|
|
71
|
+
color: "#64748b",
|
|
72
|
+
padding: "0 0.5rem"
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return /* @__PURE__ */ jsx("nav", { "aria-label": ariaLabel, className, style: styles.nav, children: /* @__PURE__ */ jsxs("ul", { style: styles.list, children: [
|
|
76
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
77
|
+
"button",
|
|
78
|
+
{
|
|
79
|
+
type: "button",
|
|
80
|
+
onClick: () => onPageChange(currentPage - 1),
|
|
81
|
+
disabled: currentPage === 1,
|
|
82
|
+
"aria-disabled": currentPage === 1,
|
|
83
|
+
"aria-label": "Previous page",
|
|
84
|
+
style: {
|
|
85
|
+
...styles.button,
|
|
86
|
+
...currentPage === 1 ? styles.disabledButton : {}
|
|
87
|
+
},
|
|
88
|
+
children: "\u2190"
|
|
89
|
+
}
|
|
90
|
+
) }),
|
|
91
|
+
pages.map((page, index) => /* @__PURE__ */ jsx("li", { children: page === "..." ? /* @__PURE__ */ jsx("span", { style: styles.ellipsis, children: "\u2026" }) : /* @__PURE__ */ jsx(
|
|
92
|
+
"button",
|
|
93
|
+
{
|
|
94
|
+
type: "button",
|
|
95
|
+
onClick: () => onPageChange(page),
|
|
96
|
+
"aria-current": currentPage === page ? "page" : void 0,
|
|
97
|
+
"aria-label": `Page ${page}`,
|
|
98
|
+
style: {
|
|
99
|
+
...styles.button,
|
|
100
|
+
...currentPage === page ? styles.activeButton : {}
|
|
101
|
+
},
|
|
102
|
+
children: page
|
|
103
|
+
}
|
|
104
|
+
) }, `${page}-${index}`)),
|
|
105
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
106
|
+
"button",
|
|
107
|
+
{
|
|
108
|
+
type: "button",
|
|
109
|
+
onClick: () => onPageChange(currentPage + 1),
|
|
110
|
+
disabled: currentPage === totalPages,
|
|
111
|
+
"aria-disabled": currentPage === totalPages,
|
|
112
|
+
"aria-label": "Next page",
|
|
113
|
+
style: {
|
|
114
|
+
...styles.button,
|
|
115
|
+
...currentPage === totalPages ? styles.disabledButton : {}
|
|
116
|
+
},
|
|
117
|
+
children: "\u2192"
|
|
118
|
+
}
|
|
119
|
+
) })
|
|
120
|
+
] }) });
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export {
|
|
124
|
+
Pagination
|
|
125
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// src/DataTable/DataTable.tsx
|
|
2
|
+
import { useState, useMemo } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
function DataTable({
|
|
5
|
+
data,
|
|
6
|
+
columns,
|
|
7
|
+
caption,
|
|
8
|
+
className = ""
|
|
9
|
+
}) {
|
|
10
|
+
const [sortConfig, setSortConfig] = useState({ key: null, direction: "ascending" });
|
|
11
|
+
const handleSort = (key) => {
|
|
12
|
+
let direction = "ascending";
|
|
13
|
+
if (sortConfig.key === key && sortConfig.direction === "ascending") {
|
|
14
|
+
direction = "descending";
|
|
15
|
+
}
|
|
16
|
+
setSortConfig({ key, direction });
|
|
17
|
+
};
|
|
18
|
+
const sortedData = useMemo(() => {
|
|
19
|
+
if (!sortConfig.key) return data;
|
|
20
|
+
return [...data].sort((a, b) => {
|
|
21
|
+
const aValue = a[sortConfig.key];
|
|
22
|
+
const bValue = b[sortConfig.key];
|
|
23
|
+
if (aValue < bValue) {
|
|
24
|
+
return sortConfig.direction === "ascending" ? -1 : 1;
|
|
25
|
+
}
|
|
26
|
+
if (aValue > bValue) {
|
|
27
|
+
return sortConfig.direction === "ascending" ? 1 : -1;
|
|
28
|
+
}
|
|
29
|
+
return 0;
|
|
30
|
+
});
|
|
31
|
+
}, [data, sortConfig]);
|
|
32
|
+
const styles = {
|
|
33
|
+
table: {
|
|
34
|
+
width: "100%",
|
|
35
|
+
borderCollapse: "collapse",
|
|
36
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
37
|
+
marginBottom: "1rem"
|
|
38
|
+
},
|
|
39
|
+
caption: {
|
|
40
|
+
textAlign: "left",
|
|
41
|
+
fontWeight: "bold",
|
|
42
|
+
fontSize: "1.25rem",
|
|
43
|
+
marginBottom: "0.75rem",
|
|
44
|
+
color: "#1e293b"
|
|
45
|
+
},
|
|
46
|
+
th: {
|
|
47
|
+
textAlign: "left",
|
|
48
|
+
borderBottom: "2px solid #e2e8f0",
|
|
49
|
+
padding: "0.75rem",
|
|
50
|
+
fontWeight: 600,
|
|
51
|
+
color: "#475569",
|
|
52
|
+
backgroundColor: "#f8fafc"
|
|
53
|
+
},
|
|
54
|
+
td: {
|
|
55
|
+
padding: "0.75rem",
|
|
56
|
+
borderBottom: "1px solid #e2e8f0",
|
|
57
|
+
color: "#334155"
|
|
58
|
+
},
|
|
59
|
+
sortButton: {
|
|
60
|
+
background: "none",
|
|
61
|
+
border: "none",
|
|
62
|
+
font: "inherit",
|
|
63
|
+
fontWeight: 600,
|
|
64
|
+
cursor: "pointer",
|
|
65
|
+
padding: 0,
|
|
66
|
+
display: "inline-flex",
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
gap: "0.5rem",
|
|
69
|
+
color: "inherit"
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return /* @__PURE__ */ jsx("div", { className, style: { overflowX: "auto" }, children: /* @__PURE__ */ jsxs("table", { style: styles.table, children: [
|
|
73
|
+
/* @__PURE__ */ jsx("caption", { style: styles.caption, children: caption }),
|
|
74
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((column, index) => /* @__PURE__ */ jsx(
|
|
75
|
+
"th",
|
|
76
|
+
{
|
|
77
|
+
scope: "col",
|
|
78
|
+
"aria-sort": sortConfig.key === column.accessor ? sortConfig.direction : void 0,
|
|
79
|
+
style: styles.th,
|
|
80
|
+
children: column.sortable ? /* @__PURE__ */ jsxs(
|
|
81
|
+
"button",
|
|
82
|
+
{
|
|
83
|
+
type: "button",
|
|
84
|
+
onClick: () => handleSort(column.accessor),
|
|
85
|
+
style: styles.sortButton,
|
|
86
|
+
children: [
|
|
87
|
+
column.header,
|
|
88
|
+
sortConfig.key === column.accessor ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: sortConfig.direction === "ascending" ? "\u25B2" : "\u25BC" }) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { opacity: 0.3 }, children: "\u2195" })
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
) : column.header
|
|
92
|
+
},
|
|
93
|
+
index
|
|
94
|
+
)) }) }),
|
|
95
|
+
/* @__PURE__ */ jsx("tbody", { children: sortedData.map((row, rowIndex) => /* @__PURE__ */ jsx("tr", { children: columns.map((column, colIndex) => /* @__PURE__ */ jsx("td", { style: styles.td, children: column.render ? column.render(row) : String(row[column.accessor]) }, colIndex)) }, rowIndex)) })
|
|
96
|
+
] }) });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
DataTable
|
|
101
|
+
};
|
|
@@ -10,7 +10,7 @@ var Tooltip = ({ children }) => {
|
|
|
10
10
|
const id = useRef(`tooltip-${Math.random().toString(36).substr(2, 9)}`).current;
|
|
11
11
|
return /* @__PURE__ */ jsx(TooltipContext.Provider, { value: { open, setOpen, id }, children: /* @__PURE__ */ jsx("div", { className: "relative inline-block group", onMouseLeave: () => setOpen(false), children }) });
|
|
12
12
|
};
|
|
13
|
-
var TooltipTrigger = ({ children, asChild = false, ...props }) => {
|
|
13
|
+
var TooltipTrigger = ({ children, asChild: _asChild = false, ...props }) => {
|
|
14
14
|
const context = useContext(TooltipContext);
|
|
15
15
|
if (!context) throw new Error("TooltipTrigger must be used within Tooltip");
|
|
16
16
|
const { setOpen, id } = context;
|
|
@@ -77,7 +77,7 @@ var Button = forwardRef(
|
|
|
77
77
|
disabled: disabled || isLoading,
|
|
78
78
|
"aria-busy": isLoading,
|
|
79
79
|
tabIndex: props.tabIndex,
|
|
80
|
-
|
|
80
|
+
className,
|
|
81
81
|
children: [
|
|
82
82
|
isLoading ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { marginRight: "8px" }, children: "\u23F3" }) : null,
|
|
83
83
|
children
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/Card/Card.tsx
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
var Card = ({
|
|
4
|
+
title,
|
|
5
|
+
href,
|
|
6
|
+
children,
|
|
7
|
+
className = "",
|
|
8
|
+
as: Component = "div"
|
|
9
|
+
}) => {
|
|
10
|
+
const styles = {
|
|
11
|
+
card: {
|
|
12
|
+
position: "relative",
|
|
13
|
+
border: "1px solid #cbd5e1",
|
|
14
|
+
borderRadius: "0.5rem",
|
|
15
|
+
padding: "1.5rem",
|
|
16
|
+
backgroundColor: "white",
|
|
17
|
+
boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
|
|
18
|
+
transition: "box-shadow 0.2s, transform 0.2s",
|
|
19
|
+
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
20
|
+
},
|
|
21
|
+
title: {
|
|
22
|
+
marginTop: 0,
|
|
23
|
+
marginBottom: "0.75rem",
|
|
24
|
+
fontSize: "1.25rem",
|
|
25
|
+
fontWeight: 600,
|
|
26
|
+
color: "#1e293b"
|
|
27
|
+
},
|
|
28
|
+
link: {
|
|
29
|
+
textDecoration: "none",
|
|
30
|
+
color: "inherit"
|
|
31
|
+
},
|
|
32
|
+
stretchedLink: {
|
|
33
|
+
position: "absolute",
|
|
34
|
+
top: 0,
|
|
35
|
+
right: 0,
|
|
36
|
+
bottom: 0,
|
|
37
|
+
left: 0,
|
|
38
|
+
zIndex: 1,
|
|
39
|
+
content: "''"
|
|
40
|
+
},
|
|
41
|
+
content: {
|
|
42
|
+
color: "#475569",
|
|
43
|
+
lineHeight: 1.5
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ jsxs(Component, { className, style: styles.card, children: [
|
|
47
|
+
title && /* @__PURE__ */ jsx("h3", { style: styles.title, children: href ? /* @__PURE__ */ jsxs("a", { href, style: styles.link, children: [
|
|
48
|
+
/* @__PURE__ */ jsx("span", { style: styles.stretchedLink, "aria-hidden": "true" }),
|
|
49
|
+
title
|
|
50
|
+
] }) : title }),
|
|
51
|
+
/* @__PURE__ */ jsx("div", { style: styles.content, children })
|
|
52
|
+
] });
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
Card
|
|
57
|
+
};
|