@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,149 @@
|
|
|
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/Pagination/Pagination.tsx
|
|
21
|
+
var Pagination_exports = {};
|
|
22
|
+
__export(Pagination_exports, {
|
|
23
|
+
Pagination: () => Pagination
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(Pagination_exports);
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
+
var Pagination = ({
|
|
28
|
+
currentPage,
|
|
29
|
+
totalPages,
|
|
30
|
+
onPageChange,
|
|
31
|
+
ariaLabel = "Pagination",
|
|
32
|
+
className = ""
|
|
33
|
+
}) => {
|
|
34
|
+
if (totalPages <= 1) return null;
|
|
35
|
+
const getPageNumbers = () => {
|
|
36
|
+
const pages2 = [];
|
|
37
|
+
pages2.push(1);
|
|
38
|
+
const start = Math.max(2, currentPage - 1);
|
|
39
|
+
const end = Math.min(totalPages - 1, currentPage + 1);
|
|
40
|
+
if (start > 2) pages2.push("...");
|
|
41
|
+
for (let i = start; i <= end; i++) {
|
|
42
|
+
pages2.push(i);
|
|
43
|
+
}
|
|
44
|
+
if (end < totalPages - 1) pages2.push("...");
|
|
45
|
+
if (totalPages > 1) {
|
|
46
|
+
pages2.push(totalPages);
|
|
47
|
+
}
|
|
48
|
+
return Array.from(new Set(pages2));
|
|
49
|
+
};
|
|
50
|
+
const pages = getPageNumbers();
|
|
51
|
+
const styles = {
|
|
52
|
+
nav: {
|
|
53
|
+
display: "flex",
|
|
54
|
+
justifyContent: "center",
|
|
55
|
+
marginTop: "1.5rem",
|
|
56
|
+
marginBottom: "1.5rem",
|
|
57
|
+
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
58
|
+
},
|
|
59
|
+
list: {
|
|
60
|
+
display: "flex",
|
|
61
|
+
listStyle: "none",
|
|
62
|
+
padding: 0,
|
|
63
|
+
margin: 0,
|
|
64
|
+
gap: "0.5rem",
|
|
65
|
+
alignItems: "center"
|
|
66
|
+
},
|
|
67
|
+
button: {
|
|
68
|
+
minWidth: "2.5rem",
|
|
69
|
+
height: "2.5rem",
|
|
70
|
+
display: "flex",
|
|
71
|
+
alignItems: "center",
|
|
72
|
+
justifyContent: "center",
|
|
73
|
+
border: "1px solid #cbd5e1",
|
|
74
|
+
backgroundColor: "white",
|
|
75
|
+
borderRadius: "0.375rem",
|
|
76
|
+
cursor: "pointer",
|
|
77
|
+
fontSize: "1rem",
|
|
78
|
+
color: "#1e293b",
|
|
79
|
+
padding: "0 0.75rem",
|
|
80
|
+
transition: "all 0.2s"
|
|
81
|
+
},
|
|
82
|
+
activeButton: {
|
|
83
|
+
backgroundColor: "#2563eb",
|
|
84
|
+
// Blue-600
|
|
85
|
+
color: "white",
|
|
86
|
+
borderColor: "#2563eb",
|
|
87
|
+
fontWeight: "bold"
|
|
88
|
+
},
|
|
89
|
+
disabledButton: {
|
|
90
|
+
opacity: 0.5,
|
|
91
|
+
cursor: "not-allowed",
|
|
92
|
+
backgroundColor: "#f1f5f9"
|
|
93
|
+
},
|
|
94
|
+
ellipsis: {
|
|
95
|
+
color: "#64748b",
|
|
96
|
+
padding: "0 0.5rem"
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { "aria-label": ariaLabel, className, style: styles.nav, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ul", { style: styles.list, children: [
|
|
100
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
101
|
+
"button",
|
|
102
|
+
{
|
|
103
|
+
type: "button",
|
|
104
|
+
onClick: () => onPageChange(currentPage - 1),
|
|
105
|
+
disabled: currentPage === 1,
|
|
106
|
+
"aria-disabled": currentPage === 1,
|
|
107
|
+
"aria-label": "Previous page",
|
|
108
|
+
style: {
|
|
109
|
+
...styles.button,
|
|
110
|
+
...currentPage === 1 ? styles.disabledButton : {}
|
|
111
|
+
},
|
|
112
|
+
children: "\u2190"
|
|
113
|
+
}
|
|
114
|
+
) }),
|
|
115
|
+
pages.map((page, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: page === "..." ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: styles.ellipsis, children: "\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
116
|
+
"button",
|
|
117
|
+
{
|
|
118
|
+
type: "button",
|
|
119
|
+
onClick: () => onPageChange(page),
|
|
120
|
+
"aria-current": currentPage === page ? "page" : void 0,
|
|
121
|
+
"aria-label": `Page ${page}`,
|
|
122
|
+
style: {
|
|
123
|
+
...styles.button,
|
|
124
|
+
...currentPage === page ? styles.activeButton : {}
|
|
125
|
+
},
|
|
126
|
+
children: page
|
|
127
|
+
}
|
|
128
|
+
) }, `${page}-${index}`)),
|
|
129
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
130
|
+
"button",
|
|
131
|
+
{
|
|
132
|
+
type: "button",
|
|
133
|
+
onClick: () => onPageChange(currentPage + 1),
|
|
134
|
+
disabled: currentPage === totalPages,
|
|
135
|
+
"aria-disabled": currentPage === totalPages,
|
|
136
|
+
"aria-label": "Next page",
|
|
137
|
+
style: {
|
|
138
|
+
...styles.button,
|
|
139
|
+
...currentPage === totalPages ? styles.disabledButton : {}
|
|
140
|
+
},
|
|
141
|
+
children: "\u2192"
|
|
142
|
+
}
|
|
143
|
+
) })
|
|
144
|
+
] }) });
|
|
145
|
+
};
|
|
146
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
+
0 && (module.exports = {
|
|
148
|
+
Pagination
|
|
149
|
+
});
|
|
@@ -8,7 +8,7 @@ interface TooltipProps {
|
|
|
8
8
|
children: React__default.ReactNode;
|
|
9
9
|
}
|
|
10
10
|
declare const Tooltip: ({ children }: TooltipProps) => react_jsx_runtime.JSX.Element;
|
|
11
|
-
declare const TooltipTrigger: ({ children, asChild, ...props }: React__default.HTMLAttributes<HTMLElement> & {
|
|
11
|
+
declare const TooltipTrigger: ({ children, asChild: _asChild, ...props }: React__default.HTMLAttributes<HTMLElement> & {
|
|
12
12
|
asChild?: boolean;
|
|
13
13
|
}) => react_jsx_runtime.JSX.Element;
|
|
14
14
|
declare const TooltipContent: ({ children, className }: {
|
|
@@ -8,7 +8,7 @@ interface TooltipProps {
|
|
|
8
8
|
children: React__default.ReactNode;
|
|
9
9
|
}
|
|
10
10
|
declare const Tooltip: ({ children }: TooltipProps) => react_jsx_runtime.JSX.Element;
|
|
11
|
-
declare const TooltipTrigger: ({ children, asChild, ...props }: React__default.HTMLAttributes<HTMLElement> & {
|
|
11
|
+
declare const TooltipTrigger: ({ children, asChild: _asChild, ...props }: React__default.HTMLAttributes<HTMLElement> & {
|
|
12
12
|
asChild?: boolean;
|
|
13
13
|
}) => react_jsx_runtime.JSX.Element;
|
|
14
14
|
declare const TooltipContent: ({ children, className }: {
|
package/dist/Tooltip/Tooltip.js
CHANGED
|
@@ -47,7 +47,7 @@ var Tooltip = ({ children }) => {
|
|
|
47
47
|
const id = (0, import_react.useRef)(`tooltip-${Math.random().toString(36).substr(2, 9)}`).current;
|
|
48
48
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContext.Provider, { value: { open, setOpen, id }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative inline-block group", onMouseLeave: () => setOpen(false), children }) });
|
|
49
49
|
};
|
|
50
|
-
var TooltipTrigger = ({ children, asChild = false, ...props }) => {
|
|
50
|
+
var TooltipTrigger = ({ children, asChild: _asChild = false, ...props }) => {
|
|
51
51
|
const context = (0, import_react.useContext)(TooltipContext);
|
|
52
52
|
if (!context) throw new Error("TooltipTrigger must be used within Tooltip");
|
|
53
53
|
const { setOpen, id } = context;
|
package/dist/Tooltip/Tooltip.mjs
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface TreeNode {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
children?: TreeNode[];
|
|
7
|
+
}
|
|
8
|
+
interface TreeViewProps {
|
|
9
|
+
data: TreeNode[];
|
|
10
|
+
ariaLabel?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
onSelect?: (node: TreeNode) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const TreeView: React__default.FC<TreeViewProps>;
|
|
15
|
+
|
|
16
|
+
export { type TreeNode, TreeView, type TreeViewProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface TreeNode {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
children?: TreeNode[];
|
|
7
|
+
}
|
|
8
|
+
interface TreeViewProps {
|
|
9
|
+
data: TreeNode[];
|
|
10
|
+
ariaLabel?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
onSelect?: (node: TreeNode) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const TreeView: React__default.FC<TreeViewProps>;
|
|
15
|
+
|
|
16
|
+
export { type TreeNode, TreeView, type TreeViewProps };
|
|
@@ -0,0 +1,250 @@
|
|
|
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/TreeView/TreeView.tsx
|
|
21
|
+
var TreeView_exports = {};
|
|
22
|
+
__export(TreeView_exports, {
|
|
23
|
+
TreeView: () => TreeView
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(TreeView_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var TreeView = ({
|
|
29
|
+
data,
|
|
30
|
+
ariaLabel = "Tree View",
|
|
31
|
+
className = "",
|
|
32
|
+
onSelect
|
|
33
|
+
}) => {
|
|
34
|
+
const [expandedIds, setExpandedIds] = (0, import_react.useState)(/* @__PURE__ */ new Set());
|
|
35
|
+
const [selectedId, setSelectedId] = (0, import_react.useState)(null);
|
|
36
|
+
const [focusedId, setFocusedId] = (0, import_react.useState)(data.length > 0 ? data[0].id : null);
|
|
37
|
+
const nodeRefs = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
38
|
+
const toggleExpand = (nodeId) => {
|
|
39
|
+
const newExpanded = new Set(expandedIds);
|
|
40
|
+
if (newExpanded.has(nodeId)) {
|
|
41
|
+
newExpanded.delete(nodeId);
|
|
42
|
+
} else {
|
|
43
|
+
newExpanded.add(nodeId);
|
|
44
|
+
}
|
|
45
|
+
setExpandedIds(newExpanded);
|
|
46
|
+
};
|
|
47
|
+
const getVisibleNodes = (nodes) => {
|
|
48
|
+
let visible = [];
|
|
49
|
+
for (const node of nodes) {
|
|
50
|
+
visible.push(node);
|
|
51
|
+
if (node.children && expandedIds.has(node.id)) {
|
|
52
|
+
visible = visible.concat(getVisibleNodes(node.children));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return visible;
|
|
56
|
+
};
|
|
57
|
+
const handleKeyDown = (e, node) => {
|
|
58
|
+
const visibleNodes = getVisibleNodes(data);
|
|
59
|
+
const currentIndex = visibleNodes.findIndex((n) => n.id === node.id);
|
|
60
|
+
switch (e.key) {
|
|
61
|
+
case "ArrowDown": {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
if (currentIndex < visibleNodes.length - 1) {
|
|
64
|
+
const nextNode = visibleNodes[currentIndex + 1];
|
|
65
|
+
setFocusedId(nextNode.id);
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
case "ArrowUp": {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
if (currentIndex > 0) {
|
|
72
|
+
const prevNode = visibleNodes[currentIndex - 1];
|
|
73
|
+
setFocusedId(prevNode.id);
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case "ArrowRight": {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
if (node.children && !expandedIds.has(node.id)) {
|
|
80
|
+
toggleExpand(node.id);
|
|
81
|
+
} else if (node.children && expandedIds.has(node.id)) {
|
|
82
|
+
if (currentIndex < visibleNodes.length - 1) {
|
|
83
|
+
setFocusedId(visibleNodes[currentIndex + 1].id);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "ArrowLeft": {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
if (node.children && expandedIds.has(node.id)) {
|
|
91
|
+
toggleExpand(node.id);
|
|
92
|
+
} else {
|
|
93
|
+
const parent = findParent(data, node.id);
|
|
94
|
+
if (parent) {
|
|
95
|
+
setFocusedId(parent.id);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case "Home": {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
if (visibleNodes.length > 0) {
|
|
103
|
+
setFocusedId(visibleNodes[0].id);
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case "End": {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
if (visibleNodes.length > 0) {
|
|
110
|
+
setFocusedId(visibleNodes[visibleNodes.length - 1].id);
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case "Enter":
|
|
115
|
+
case " ": {
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
if (onSelect) onSelect(node);
|
|
118
|
+
setSelectedId(node.id);
|
|
119
|
+
if (node.children) {
|
|
120
|
+
toggleExpand(node.id);
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const findParent = (nodes, childId, parent = null) => {
|
|
127
|
+
for (const node of nodes) {
|
|
128
|
+
if (node.id === childId) return parent;
|
|
129
|
+
if (node.children) {
|
|
130
|
+
const found = findParent(node.children, childId, node);
|
|
131
|
+
if (found) return found;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
};
|
|
136
|
+
(0, import_react.useEffect)(() => {
|
|
137
|
+
if (focusedId) {
|
|
138
|
+
const el = nodeRefs.current.get(focusedId);
|
|
139
|
+
if (el) el.focus();
|
|
140
|
+
}
|
|
141
|
+
}, [focusedId]);
|
|
142
|
+
const renderTree = (nodes, level = 1) => {
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { role: "group", style: { paddingLeft: level > 1 ? "1.5rem" : 0, listStyle: "none", margin: 0 }, children: nodes.map((node) => {
|
|
144
|
+
const isExpanded = expandedIds.has(node.id);
|
|
145
|
+
const hasChildren = node.children && node.children.length > 0;
|
|
146
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { role: "none", children: [
|
|
147
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
ref: (el) => {
|
|
151
|
+
if (el) nodeRefs.current.set(node.id, el);
|
|
152
|
+
else nodeRefs.current.delete(node.id);
|
|
153
|
+
},
|
|
154
|
+
role: "treeitem",
|
|
155
|
+
"aria-expanded": hasChildren ? isExpanded : void 0,
|
|
156
|
+
"aria-selected": selectedId === node.id,
|
|
157
|
+
"aria-level": level,
|
|
158
|
+
tabIndex: focusedId === node.id ? 0 : -1,
|
|
159
|
+
onClick: () => {
|
|
160
|
+
setFocusedId(node.id);
|
|
161
|
+
setSelectedId(node.id);
|
|
162
|
+
if (hasChildren) toggleExpand(node.id);
|
|
163
|
+
if (onSelect) onSelect(node);
|
|
164
|
+
},
|
|
165
|
+
onKeyDown: (e) => handleKeyDown(e, node),
|
|
166
|
+
style: {
|
|
167
|
+
cursor: "pointer",
|
|
168
|
+
padding: "0.25rem 0.5rem",
|
|
169
|
+
borderRadius: "0.25rem",
|
|
170
|
+
outline: "none",
|
|
171
|
+
backgroundColor: selectedId === node.id ? "#e0f2fe" : "transparent",
|
|
172
|
+
// Sky-100
|
|
173
|
+
color: selectedId === node.id ? "#0369a1" : "inherit",
|
|
174
|
+
// Sky-700
|
|
175
|
+
border: focusedId === node.id ? "1px solid #0ea5e9" : "1px solid transparent",
|
|
176
|
+
// Sky-500
|
|
177
|
+
display: "flex",
|
|
178
|
+
alignItems: "center",
|
|
179
|
+
gap: "0.5rem"
|
|
180
|
+
},
|
|
181
|
+
children: [
|
|
182
|
+
hasChildren && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontSize: "0.75rem", color: "#94a3b8" }, children: isExpanded ? "\u25BC" : "\u25B6" }),
|
|
183
|
+
!hasChildren && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { width: "0.75rem" } }),
|
|
184
|
+
node.label
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
hasChildren && isExpanded && renderTree(node.children, level + 1)
|
|
189
|
+
] }, node.id);
|
|
190
|
+
}) });
|
|
191
|
+
};
|
|
192
|
+
const styles = {
|
|
193
|
+
container: {
|
|
194
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
195
|
+
border: "1px solid #cbd5e1",
|
|
196
|
+
borderRadius: "0.375rem",
|
|
197
|
+
padding: "1rem",
|
|
198
|
+
backgroundColor: "white"
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, style: styles.container, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { role: "tree", "aria-label": ariaLabel, style: { listStyle: "none", padding: 0, margin: 0 }, children: data.map((node) => {
|
|
202
|
+
const isExpanded = expandedIds.has(node.id);
|
|
203
|
+
const hasChildren = node.children && node.children.length > 0;
|
|
204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { role: "none", children: [
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
ref: (el) => {
|
|
209
|
+
if (el) nodeRefs.current.set(node.id, el);
|
|
210
|
+
else nodeRefs.current.delete(node.id);
|
|
211
|
+
},
|
|
212
|
+
role: "treeitem",
|
|
213
|
+
"aria-expanded": hasChildren ? isExpanded : void 0,
|
|
214
|
+
"aria-selected": selectedId === node.id,
|
|
215
|
+
"aria-level": 1,
|
|
216
|
+
tabIndex: focusedId === node.id ? 0 : -1,
|
|
217
|
+
onClick: () => {
|
|
218
|
+
setFocusedId(node.id);
|
|
219
|
+
setSelectedId(node.id);
|
|
220
|
+
if (hasChildren) toggleExpand(node.id);
|
|
221
|
+
if (onSelect) onSelect(node);
|
|
222
|
+
},
|
|
223
|
+
onKeyDown: (e) => handleKeyDown(e, node),
|
|
224
|
+
style: {
|
|
225
|
+
cursor: "pointer",
|
|
226
|
+
padding: "0.25rem 0.5rem",
|
|
227
|
+
borderRadius: "0.25rem",
|
|
228
|
+
outline: "none",
|
|
229
|
+
backgroundColor: selectedId === node.id ? "#e0f2fe" : "transparent",
|
|
230
|
+
color: selectedId === node.id ? "#0369a1" : "inherit",
|
|
231
|
+
border: focusedId === node.id ? "1px solid #0ea5e9" : "1px solid transparent",
|
|
232
|
+
display: "flex",
|
|
233
|
+
alignItems: "center",
|
|
234
|
+
gap: "0.5rem"
|
|
235
|
+
},
|
|
236
|
+
children: [
|
|
237
|
+
hasChildren && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontSize: "0.75rem", color: "#94a3b8" }, children: isExpanded ? "\u25BC" : "\u25B6" }),
|
|
238
|
+
!hasChildren && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { width: "0.75rem" } }),
|
|
239
|
+
node.label
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
),
|
|
243
|
+
hasChildren && isExpanded && renderTree(node.children, 2)
|
|
244
|
+
] }, node.id);
|
|
245
|
+
}) }) });
|
|
246
|
+
};
|
|
247
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
248
|
+
0 && (module.exports = {
|
|
249
|
+
TreeView
|
|
250
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/LiveRegion/LiveRegion.tsx
|
|
2
|
+
import { useEffect, useState, useRef } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var LiveRegion = ({
|
|
5
|
+
message,
|
|
6
|
+
ariaLive = "polite",
|
|
7
|
+
clearAfter
|
|
8
|
+
}) => {
|
|
9
|
+
const [announcement, setAnnouncement] = useState("");
|
|
10
|
+
const timeoutRef = useRef();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (message) {
|
|
13
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
14
|
+
setAnnouncement(message);
|
|
15
|
+
if (clearAfter) {
|
|
16
|
+
timeoutRef.current = setTimeout(() => {
|
|
17
|
+
setAnnouncement("");
|
|
18
|
+
}, clearAfter);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}, [message, clearAfter]);
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
"aria-live": ariaLive,
|
|
26
|
+
"aria-atomic": "true",
|
|
27
|
+
style: {
|
|
28
|
+
position: "absolute",
|
|
29
|
+
width: 1,
|
|
30
|
+
height: 1,
|
|
31
|
+
padding: 0,
|
|
32
|
+
margin: -1,
|
|
33
|
+
overflow: "hidden",
|
|
34
|
+
clip: "rect(0, 0, 0, 0)",
|
|
35
|
+
whiteSpace: "nowrap",
|
|
36
|
+
border: 0
|
|
37
|
+
},
|
|
38
|
+
children: announcement
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
LiveRegion
|
|
45
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// src/DatePicker/DatePicker.tsx
|
|
2
|
+
import { useId, forwardRef } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var DatePicker = forwardRef(({
|
|
5
|
+
label,
|
|
6
|
+
description,
|
|
7
|
+
error,
|
|
8
|
+
className = "",
|
|
9
|
+
style,
|
|
10
|
+
id: providedId,
|
|
11
|
+
...props
|
|
12
|
+
}, ref) => {
|
|
13
|
+
const generatedId = useId();
|
|
14
|
+
const id = providedId || generatedId;
|
|
15
|
+
const descriptionId = `${id}-description`;
|
|
16
|
+
const errorId = `${id}-error`;
|
|
17
|
+
const styles = {
|
|
18
|
+
container: {
|
|
19
|
+
marginBottom: "1rem",
|
|
20
|
+
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
21
|
+
},
|
|
22
|
+
label: {
|
|
23
|
+
display: "block",
|
|
24
|
+
fontWeight: 600,
|
|
25
|
+
marginBottom: "0.25rem",
|
|
26
|
+
color: "#1e293b"
|
|
27
|
+
},
|
|
28
|
+
description: {
|
|
29
|
+
fontSize: "0.875rem",
|
|
30
|
+
color: "#64748b",
|
|
31
|
+
marginBottom: "0.5rem"
|
|
32
|
+
},
|
|
33
|
+
error: {
|
|
34
|
+
fontSize: "0.875rem",
|
|
35
|
+
color: "#dc2626",
|
|
36
|
+
marginTop: "0.25rem"
|
|
37
|
+
},
|
|
38
|
+
input: {
|
|
39
|
+
display: "block",
|
|
40
|
+
width: "100%",
|
|
41
|
+
padding: "0.5rem 0.75rem",
|
|
42
|
+
fontSize: "1rem",
|
|
43
|
+
lineHeight: 1.5,
|
|
44
|
+
color: "#0f172a",
|
|
45
|
+
backgroundColor: "#ffffff",
|
|
46
|
+
border: `1px solid ${error ? "#dc2626" : "#cbd5e1"}`,
|
|
47
|
+
borderRadius: "0.375rem",
|
|
48
|
+
outline: "none",
|
|
49
|
+
boxSizing: "border-box",
|
|
50
|
+
minHeight: "2.5rem"
|
|
51
|
+
// Ensure touch target size
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return /* @__PURE__ */ jsxs("div", { className, style: { ...styles.container, ...style }, children: [
|
|
55
|
+
/* @__PURE__ */ jsx(
|
|
56
|
+
"label",
|
|
57
|
+
{
|
|
58
|
+
htmlFor: id,
|
|
59
|
+
style: styles.label,
|
|
60
|
+
children: label
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
description && /* @__PURE__ */ jsx("div", { id: descriptionId, style: styles.description, children: description }),
|
|
64
|
+
/* @__PURE__ */ jsx(
|
|
65
|
+
"input",
|
|
66
|
+
{
|
|
67
|
+
ref,
|
|
68
|
+
id,
|
|
69
|
+
type: "date",
|
|
70
|
+
"aria-invalid": !!error,
|
|
71
|
+
"aria-describedby": [
|
|
72
|
+
description ? descriptionId : null,
|
|
73
|
+
error ? errorId : null
|
|
74
|
+
].filter(Boolean).join(" ") || void 0,
|
|
75
|
+
style: styles.input,
|
|
76
|
+
...props
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
error && /* @__PURE__ */ jsx("div", { id: errorId, style: styles.error, role: "alert", children: error })
|
|
80
|
+
] });
|
|
81
|
+
});
|
|
82
|
+
DatePicker.displayName = "DatePicker";
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
DatePicker
|
|
86
|
+
};
|