@openzeppelin/ui-components 1.0.4 → 1.2.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/dist/{ErrorMessage-DyO9ZWWz.js → ErrorMessage-BqOEJm84.mjs} +1 -1
- package/dist/ErrorMessage-BqOEJm84.mjs.map +1 -0
- package/dist/code-editor.cjs +4 -4
- package/dist/code-editor.d.cts +1 -2
- package/dist/code-editor.d.cts.map +1 -0
- package/dist/{code-editor-CxxSe1o8.d.ts → code-editor.d.mts} +1 -2
- package/dist/code-editor.d.mts.map +1 -0
- package/dist/{code-editor.js → code-editor.mjs} +5 -5
- package/dist/code-editor.mjs.map +1 -0
- package/dist/index.cjs +297 -193
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -45
- package/dist/index.d.cts.map +1 -0
- package/dist/{index-B4RKqEg8.d.ts → index.d.mts} +80 -48
- package/dist/index.d.mts.map +1 -0
- package/dist/{index.js → index.mjs} +298 -197
- package/dist/index.mjs.map +1 -0
- package/package.json +20 -14
- package/dist/ErrorMessage-DyO9ZWWz.js.map +0 -1
- package/dist/code-editor-BKEEXGxt.d.cts +0 -122
- package/dist/code-editor-BKEEXGxt.d.cts.map +0 -1
- package/dist/code-editor-CxxSe1o8.d.ts.map +0 -1
- package/dist/code-editor.d.ts +0 -122
- package/dist/code-editor.js.map +0 -1
- package/dist/index-B4RKqEg8.d.ts.map +0 -1
- package/dist/index-mhkE-hOZ.d.cts +0 -2412
- package/dist/index-mhkE-hOZ.d.cts.map +0 -1
- package/dist/index.d.ts +0 -2412
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const require_ErrorMessage = require('./ErrorMessage-D4BAP8iw.cjs');
|
|
2
|
-
let react = require("react");
|
|
3
|
-
react = require_ErrorMessage.__toESM(react);
|
|
4
|
-
let react_hook_form = require("react-hook-form");
|
|
5
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
2
|
let _radix_ui_react_accordion = require("@radix-ui/react-accordion");
|
|
7
3
|
_radix_ui_react_accordion = require_ErrorMessage.__toESM(_radix_ui_react_accordion);
|
|
8
4
|
let class_variance_authority = require("class-variance-authority");
|
|
9
5
|
let lucide_react = require("lucide-react");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
react = require_ErrorMessage.__toESM(react);
|
|
10
8
|
let _openzeppelin_ui_utils = require("@openzeppelin/ui-utils");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
10
|
let _radix_ui_react_slot = require("@radix-ui/react-slot");
|
|
12
11
|
let react_day_picker = require("react-day-picker");
|
|
13
12
|
let _radix_ui_react_checkbox = require("@radix-ui/react-checkbox");
|
|
@@ -19,6 +18,7 @@ let _radix_ui_react_dialog = require("@radix-ui/react-dialog");
|
|
|
19
18
|
_radix_ui_react_dialog = require_ErrorMessage.__toESM(_radix_ui_react_dialog);
|
|
20
19
|
let _radix_ui_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
|
|
21
20
|
_radix_ui_react_dropdown_menu = require_ErrorMessage.__toESM(_radix_ui_react_dropdown_menu);
|
|
21
|
+
let react_hook_form = require("react-hook-form");
|
|
22
22
|
let _radix_ui_react_label = require("@radix-ui/react-label");
|
|
23
23
|
_radix_ui_react_label = require_ErrorMessage.__toESM(_radix_ui_react_label);
|
|
24
24
|
let _radix_ui_react_progress = require("@radix-ui/react-progress");
|
|
@@ -27,6 +27,8 @@ let _radix_ui_react_radio_group = require("@radix-ui/react-radio-group");
|
|
|
27
27
|
_radix_ui_react_radio_group = require_ErrorMessage.__toESM(_radix_ui_react_radio_group);
|
|
28
28
|
let _radix_ui_react_select = require("@radix-ui/react-select");
|
|
29
29
|
_radix_ui_react_select = require_ErrorMessage.__toESM(_radix_ui_react_select);
|
|
30
|
+
let _radix_ui_react_collapsible = require("@radix-ui/react-collapsible");
|
|
31
|
+
_radix_ui_react_collapsible = require_ErrorMessage.__toESM(_radix_ui_react_collapsible);
|
|
30
32
|
let _radix_ui_react_tabs = require("@radix-ui/react-tabs");
|
|
31
33
|
_radix_ui_react_tabs = require_ErrorMessage.__toESM(_radix_ui_react_tabs);
|
|
32
34
|
let _radix_ui_react_tooltip = require("@radix-ui/react-tooltip");
|
|
@@ -35,195 +37,6 @@ let _openzeppelin_ui_types = require("@openzeppelin/ui-types");
|
|
|
35
37
|
let sonner = require("sonner");
|
|
36
38
|
let next_themes = require("next-themes");
|
|
37
39
|
|
|
38
|
-
//#region src/components/fields/utils/accessibility.ts
|
|
39
|
-
/**
|
|
40
|
-
* Accessibility utilities for form field components
|
|
41
|
-
*/
|
|
42
|
-
/**
|
|
43
|
-
* Default aria-describedby ID generator based on field ID
|
|
44
|
-
*/
|
|
45
|
-
function getDescribedById(id, type = "error") {
|
|
46
|
-
return `${id}-${type}`;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Generates accessibility attributes for form fields
|
|
50
|
-
*/
|
|
51
|
-
function getAccessibilityProps({ id, hasError = false, isRequired = false, isDisabled = false, isReadOnly = false, hasHelperText = false, hasCharacterCounter = false }) {
|
|
52
|
-
const describedByIds = [];
|
|
53
|
-
if (hasError) describedByIds.push(getDescribedById(id, "error"));
|
|
54
|
-
if (hasHelperText) describedByIds.push(getDescribedById(id, "description"));
|
|
55
|
-
if (hasCharacterCounter) describedByIds.push(getDescribedById(id, "counter"));
|
|
56
|
-
return {
|
|
57
|
-
"aria-invalid": hasError,
|
|
58
|
-
"aria-required": isRequired,
|
|
59
|
-
"aria-describedby": describedByIds.length > 0 ? describedByIds.join(" ") : void 0,
|
|
60
|
-
"aria-errormessage": hasError ? getDescribedById(id, "error") : void 0,
|
|
61
|
-
required: isRequired,
|
|
62
|
-
disabled: isDisabled,
|
|
63
|
-
readOnly: isReadOnly,
|
|
64
|
-
tabIndex: isDisabled ? -1 : 0
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Utility function to handle keyboard events for interactive elements
|
|
69
|
-
* Helps ensure keyboard users can interact with form controls
|
|
70
|
-
*/
|
|
71
|
-
function handleKeyboardEvent(event, handlers) {
|
|
72
|
-
switch (event.key) {
|
|
73
|
-
case "Enter":
|
|
74
|
-
if (handlers.onEnter) {
|
|
75
|
-
event.preventDefault();
|
|
76
|
-
handlers.onEnter();
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
case " ":
|
|
80
|
-
if (handlers.onSpace) {
|
|
81
|
-
event.preventDefault();
|
|
82
|
-
handlers.onSpace();
|
|
83
|
-
}
|
|
84
|
-
break;
|
|
85
|
-
case "Escape":
|
|
86
|
-
if (handlers.onEscape) {
|
|
87
|
-
event.preventDefault();
|
|
88
|
-
handlers.onEscape();
|
|
89
|
-
}
|
|
90
|
-
break;
|
|
91
|
-
case "ArrowUp":
|
|
92
|
-
if (handlers.onArrowUp) {
|
|
93
|
-
event.preventDefault();
|
|
94
|
-
handlers.onArrowUp();
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
case "ArrowDown":
|
|
98
|
-
if (handlers.onArrowDown) {
|
|
99
|
-
event.preventDefault();
|
|
100
|
-
handlers.onArrowDown();
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
case "ArrowLeft":
|
|
104
|
-
if (handlers.onArrowLeft) {
|
|
105
|
-
event.preventDefault();
|
|
106
|
-
handlers.onArrowLeft();
|
|
107
|
-
}
|
|
108
|
-
break;
|
|
109
|
-
case "ArrowRight":
|
|
110
|
-
if (handlers.onArrowRight) {
|
|
111
|
-
event.preventDefault();
|
|
112
|
-
handlers.onArrowRight();
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
115
|
-
case "Tab":
|
|
116
|
-
if (handlers.onTab) {
|
|
117
|
-
event.preventDefault();
|
|
118
|
-
handlers.onTab();
|
|
119
|
-
}
|
|
120
|
-
break;
|
|
121
|
-
default: break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Field focus management utility
|
|
126
|
-
* For managing focus within a field group or complex form component
|
|
127
|
-
*/
|
|
128
|
-
function createFocusManager() {
|
|
129
|
-
return {
|
|
130
|
-
focusFirstElement(container) {
|
|
131
|
-
if (!container) return;
|
|
132
|
-
const focusable = container.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])");
|
|
133
|
-
if (focusable.length > 0) focusable[0].focus();
|
|
134
|
-
},
|
|
135
|
-
focusElementById(id) {
|
|
136
|
-
const element = document.getElementById(id);
|
|
137
|
-
if (element) element.focus();
|
|
138
|
-
},
|
|
139
|
-
trapFocus(event, container) {
|
|
140
|
-
if (!container || event.key !== "Tab") return;
|
|
141
|
-
const focusable = Array.from(container.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])"));
|
|
142
|
-
if (focusable.length === 0) return;
|
|
143
|
-
const firstElement = focusable[0];
|
|
144
|
-
const lastElement = focusable[focusable.length - 1];
|
|
145
|
-
if (event.shiftKey && document.activeElement === firstElement) {
|
|
146
|
-
event.preventDefault();
|
|
147
|
-
lastElement.focus();
|
|
148
|
-
} else if (!event.shiftKey && document.activeElement === lastElement) {
|
|
149
|
-
event.preventDefault();
|
|
150
|
-
firstElement.focus();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Provides a handler for Escape key to clear input fields
|
|
157
|
-
*
|
|
158
|
-
* @param onChange - Function to call when value changes
|
|
159
|
-
* @param value - Current value of the input
|
|
160
|
-
* @returns A function to handle the Escape key press
|
|
161
|
-
*/
|
|
162
|
-
function handleEscapeKey(onChange, value) {
|
|
163
|
-
return (e) => {
|
|
164
|
-
if (e.key === "Escape") {
|
|
165
|
-
e.preventDefault();
|
|
166
|
-
if (value) onChange("");
|
|
167
|
-
else e.target.blur();
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Provides a handler for Space/Enter keys for toggle components (checkboxes, switches)
|
|
173
|
-
*
|
|
174
|
-
* @param onChange - Function to call when value changes
|
|
175
|
-
* @param value - Current value of the input
|
|
176
|
-
* @returns A function to handle the Space/Enter key press
|
|
177
|
-
*/
|
|
178
|
-
function handleToggleKeys(onChange, value) {
|
|
179
|
-
return (e) => {
|
|
180
|
-
if (e.key === " " || e.key === "Enter") {
|
|
181
|
-
e.preventDefault();
|
|
182
|
-
onChange(!value);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Provides a handler for arrow keys for numeric inputs
|
|
188
|
-
*
|
|
189
|
-
* @param onChange - Function to call when value changes
|
|
190
|
-
* @param value - Current numeric value
|
|
191
|
-
* @param step - Step amount for increments/decrements
|
|
192
|
-
* @param min - Minimum allowed value (optional)
|
|
193
|
-
* @param max - Maximum allowed value (optional)
|
|
194
|
-
* @returns A function to handle arrow key presses
|
|
195
|
-
*/
|
|
196
|
-
function handleNumericKeys(onChange, value, step = 1, min, max) {
|
|
197
|
-
return (e) => {
|
|
198
|
-
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
199
|
-
e.preventDefault();
|
|
200
|
-
const direction = e.key === "ArrowUp" ? 1 : -1;
|
|
201
|
-
let newValue = typeof value === "number" ? value + step * direction : 0;
|
|
202
|
-
if (typeof min === "number") newValue = Math.max(min, newValue);
|
|
203
|
-
if (typeof max === "number") newValue = Math.min(max, newValue);
|
|
204
|
-
onChange(newValue);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
//#endregion
|
|
210
|
-
//#region src/components/fields/utils/layout.ts
|
|
211
|
-
/**
|
|
212
|
-
* Layout utility functions for form components
|
|
213
|
-
*/
|
|
214
|
-
/**
|
|
215
|
-
* Helper function to get width classes based on the field width
|
|
216
|
-
*/
|
|
217
|
-
function getWidthClasses(width) {
|
|
218
|
-
switch (width) {
|
|
219
|
-
case "half": return "form-field-half";
|
|
220
|
-
case "third": return "form-field-third";
|
|
221
|
-
case "full":
|
|
222
|
-
default: return "form-field-full";
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
//#endregion
|
|
227
40
|
//#region src/components/ui/accordion.tsx
|
|
228
41
|
const accordionItemVariants = (0, class_variance_authority.cva)("", {
|
|
229
42
|
variants: { variant: {
|
|
@@ -1478,6 +1291,47 @@ function SidebarButton({ icon, children, onClick, size = "default", badge, disab
|
|
|
1478
1291
|
});
|
|
1479
1292
|
}
|
|
1480
1293
|
|
|
1294
|
+
//#endregion
|
|
1295
|
+
//#region src/components/ui/sidebar/SidebarGroup.tsx
|
|
1296
|
+
/**
|
|
1297
|
+
* A collapsible group component for organizing sidebar navigation items.
|
|
1298
|
+
* Supports both controlled and uncontrolled modes.
|
|
1299
|
+
*/
|
|
1300
|
+
function SidebarGroup({ title, icon, children, defaultOpen = false, open: controlledOpen, onOpenChange, className, triggerClassName, contentClassName }) {
|
|
1301
|
+
const [uncontrolledOpen, setUncontrolledOpen] = (0, react.useState)(defaultOpen);
|
|
1302
|
+
const isControlled = controlledOpen !== void 0;
|
|
1303
|
+
const isOpen = isControlled ? controlledOpen : uncontrolledOpen;
|
|
1304
|
+
const handleOpenChange = (nextOpen) => {
|
|
1305
|
+
if (!isControlled) setUncontrolledOpen(nextOpen);
|
|
1306
|
+
onOpenChange?.(nextOpen);
|
|
1307
|
+
};
|
|
1308
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_collapsible.Root, {
|
|
1309
|
+
open: isOpen,
|
|
1310
|
+
onOpenChange: handleOpenChange,
|
|
1311
|
+
className: (0, _openzeppelin_ui_utils.cn)("w-full", className),
|
|
1312
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_collapsible.Trigger, {
|
|
1313
|
+
className: (0, _openzeppelin_ui_utils.cn)("group flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm font-semibold", "text-muted-foreground transition-colors hover:text-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", triggerClassName),
|
|
1314
|
+
children: [
|
|
1315
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: (0, _openzeppelin_ui_utils.cn)("size-4 shrink-0 transition-transform duration-200", isOpen && "rotate-90") }),
|
|
1316
|
+
icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1317
|
+
className: "shrink-0",
|
|
1318
|
+
children: icon
|
|
1319
|
+
}),
|
|
1320
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1321
|
+
className: "flex-1 text-left",
|
|
1322
|
+
children: title
|
|
1323
|
+
})
|
|
1324
|
+
]
|
|
1325
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_collapsible.Content, {
|
|
1326
|
+
className: (0, _openzeppelin_ui_utils.cn)("overflow-hidden transition-all duration-200 ease-in-out", "data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down", contentClassName),
|
|
1327
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1328
|
+
className: "py-1 pl-4",
|
|
1329
|
+
children
|
|
1330
|
+
})
|
|
1331
|
+
})]
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1481
1335
|
//#endregion
|
|
1482
1336
|
//#region src/components/ui/sidebar/SidebarLayout.tsx
|
|
1483
1337
|
/**
|
|
@@ -1663,6 +1517,195 @@ function ViewContractStateButton({ contractAddress, onToggle }) {
|
|
|
1663
1517
|
});
|
|
1664
1518
|
}
|
|
1665
1519
|
|
|
1520
|
+
//#endregion
|
|
1521
|
+
//#region src/components/fields/utils/accessibility.ts
|
|
1522
|
+
/**
|
|
1523
|
+
* Accessibility utilities for form field components
|
|
1524
|
+
*/
|
|
1525
|
+
/**
|
|
1526
|
+
* Default aria-describedby ID generator based on field ID
|
|
1527
|
+
*/
|
|
1528
|
+
function getDescribedById(id, type = "error") {
|
|
1529
|
+
return `${id}-${type}`;
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Generates accessibility attributes for form fields
|
|
1533
|
+
*/
|
|
1534
|
+
function getAccessibilityProps({ id, hasError = false, isRequired = false, isDisabled = false, isReadOnly = false, hasHelperText = false, hasCharacterCounter = false }) {
|
|
1535
|
+
const describedByIds = [];
|
|
1536
|
+
if (hasError) describedByIds.push(getDescribedById(id, "error"));
|
|
1537
|
+
if (hasHelperText) describedByIds.push(getDescribedById(id, "description"));
|
|
1538
|
+
if (hasCharacterCounter) describedByIds.push(getDescribedById(id, "counter"));
|
|
1539
|
+
return {
|
|
1540
|
+
"aria-invalid": hasError,
|
|
1541
|
+
"aria-required": isRequired,
|
|
1542
|
+
"aria-describedby": describedByIds.length > 0 ? describedByIds.join(" ") : void 0,
|
|
1543
|
+
"aria-errormessage": hasError ? getDescribedById(id, "error") : void 0,
|
|
1544
|
+
required: isRequired,
|
|
1545
|
+
disabled: isDisabled,
|
|
1546
|
+
readOnly: isReadOnly,
|
|
1547
|
+
tabIndex: isDisabled ? -1 : 0
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1550
|
+
/**
|
|
1551
|
+
* Utility function to handle keyboard events for interactive elements
|
|
1552
|
+
* Helps ensure keyboard users can interact with form controls
|
|
1553
|
+
*/
|
|
1554
|
+
function handleKeyboardEvent(event, handlers) {
|
|
1555
|
+
switch (event.key) {
|
|
1556
|
+
case "Enter":
|
|
1557
|
+
if (handlers.onEnter) {
|
|
1558
|
+
event.preventDefault();
|
|
1559
|
+
handlers.onEnter();
|
|
1560
|
+
}
|
|
1561
|
+
break;
|
|
1562
|
+
case " ":
|
|
1563
|
+
if (handlers.onSpace) {
|
|
1564
|
+
event.preventDefault();
|
|
1565
|
+
handlers.onSpace();
|
|
1566
|
+
}
|
|
1567
|
+
break;
|
|
1568
|
+
case "Escape":
|
|
1569
|
+
if (handlers.onEscape) {
|
|
1570
|
+
event.preventDefault();
|
|
1571
|
+
handlers.onEscape();
|
|
1572
|
+
}
|
|
1573
|
+
break;
|
|
1574
|
+
case "ArrowUp":
|
|
1575
|
+
if (handlers.onArrowUp) {
|
|
1576
|
+
event.preventDefault();
|
|
1577
|
+
handlers.onArrowUp();
|
|
1578
|
+
}
|
|
1579
|
+
break;
|
|
1580
|
+
case "ArrowDown":
|
|
1581
|
+
if (handlers.onArrowDown) {
|
|
1582
|
+
event.preventDefault();
|
|
1583
|
+
handlers.onArrowDown();
|
|
1584
|
+
}
|
|
1585
|
+
break;
|
|
1586
|
+
case "ArrowLeft":
|
|
1587
|
+
if (handlers.onArrowLeft) {
|
|
1588
|
+
event.preventDefault();
|
|
1589
|
+
handlers.onArrowLeft();
|
|
1590
|
+
}
|
|
1591
|
+
break;
|
|
1592
|
+
case "ArrowRight":
|
|
1593
|
+
if (handlers.onArrowRight) {
|
|
1594
|
+
event.preventDefault();
|
|
1595
|
+
handlers.onArrowRight();
|
|
1596
|
+
}
|
|
1597
|
+
break;
|
|
1598
|
+
case "Tab":
|
|
1599
|
+
if (handlers.onTab) {
|
|
1600
|
+
event.preventDefault();
|
|
1601
|
+
handlers.onTab();
|
|
1602
|
+
}
|
|
1603
|
+
break;
|
|
1604
|
+
default: break;
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
/**
|
|
1608
|
+
* Field focus management utility
|
|
1609
|
+
* For managing focus within a field group or complex form component
|
|
1610
|
+
*/
|
|
1611
|
+
function createFocusManager() {
|
|
1612
|
+
return {
|
|
1613
|
+
focusFirstElement(container) {
|
|
1614
|
+
if (!container) return;
|
|
1615
|
+
const focusable = container.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])");
|
|
1616
|
+
if (focusable.length > 0) focusable[0].focus();
|
|
1617
|
+
},
|
|
1618
|
+
focusElementById(id) {
|
|
1619
|
+
const element = document.getElementById(id);
|
|
1620
|
+
if (element) element.focus();
|
|
1621
|
+
},
|
|
1622
|
+
trapFocus(event, container) {
|
|
1623
|
+
if (!container || event.key !== "Tab") return;
|
|
1624
|
+
const focusable = Array.from(container.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])"));
|
|
1625
|
+
if (focusable.length === 0) return;
|
|
1626
|
+
const firstElement = focusable[0];
|
|
1627
|
+
const lastElement = focusable[focusable.length - 1];
|
|
1628
|
+
if (event.shiftKey && document.activeElement === firstElement) {
|
|
1629
|
+
event.preventDefault();
|
|
1630
|
+
lastElement.focus();
|
|
1631
|
+
} else if (!event.shiftKey && document.activeElement === lastElement) {
|
|
1632
|
+
event.preventDefault();
|
|
1633
|
+
firstElement.focus();
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Provides a handler for Escape key to clear input fields
|
|
1640
|
+
*
|
|
1641
|
+
* @param onChange - Function to call when value changes
|
|
1642
|
+
* @param value - Current value of the input
|
|
1643
|
+
* @returns A function to handle the Escape key press
|
|
1644
|
+
*/
|
|
1645
|
+
function handleEscapeKey(onChange, value) {
|
|
1646
|
+
return (e) => {
|
|
1647
|
+
if (e.key === "Escape") {
|
|
1648
|
+
e.preventDefault();
|
|
1649
|
+
if (value) onChange("");
|
|
1650
|
+
else e.target.blur();
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Provides a handler for Space/Enter keys for toggle components (checkboxes, switches)
|
|
1656
|
+
*
|
|
1657
|
+
* @param onChange - Function to call when value changes
|
|
1658
|
+
* @param value - Current value of the input
|
|
1659
|
+
* @returns A function to handle the Space/Enter key press
|
|
1660
|
+
*/
|
|
1661
|
+
function handleToggleKeys(onChange, value) {
|
|
1662
|
+
return (e) => {
|
|
1663
|
+
if (e.key === " " || e.key === "Enter") {
|
|
1664
|
+
e.preventDefault();
|
|
1665
|
+
onChange(!value);
|
|
1666
|
+
}
|
|
1667
|
+
};
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
* Provides a handler for arrow keys for numeric inputs
|
|
1671
|
+
*
|
|
1672
|
+
* @param onChange - Function to call when value changes
|
|
1673
|
+
* @param value - Current numeric value
|
|
1674
|
+
* @param step - Step amount for increments/decrements
|
|
1675
|
+
* @param min - Minimum allowed value (optional)
|
|
1676
|
+
* @param max - Maximum allowed value (optional)
|
|
1677
|
+
* @returns A function to handle arrow key presses
|
|
1678
|
+
*/
|
|
1679
|
+
function handleNumericKeys(onChange, value, step = 1, min, max) {
|
|
1680
|
+
return (e) => {
|
|
1681
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
1682
|
+
e.preventDefault();
|
|
1683
|
+
const direction = e.key === "ArrowUp" ? 1 : -1;
|
|
1684
|
+
let newValue = typeof value === "number" ? value + step * direction : 0;
|
|
1685
|
+
if (typeof min === "number") newValue = Math.max(min, newValue);
|
|
1686
|
+
if (typeof max === "number") newValue = Math.min(max, newValue);
|
|
1687
|
+
onChange(newValue);
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
//#endregion
|
|
1693
|
+
//#region src/components/fields/utils/layout.ts
|
|
1694
|
+
/**
|
|
1695
|
+
* Layout utility functions for form components
|
|
1696
|
+
*/
|
|
1697
|
+
/**
|
|
1698
|
+
* Helper function to get width classes based on the field width
|
|
1699
|
+
*/
|
|
1700
|
+
function getWidthClasses(width) {
|
|
1701
|
+
switch (width) {
|
|
1702
|
+
case "half": return "form-field-half";
|
|
1703
|
+
case "third": return "form-field-third";
|
|
1704
|
+
case "full":
|
|
1705
|
+
default: return "form-field-full";
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1666
1709
|
//#endregion
|
|
1667
1710
|
//#region src/components/fields/AddressField.tsx
|
|
1668
1711
|
/**
|
|
@@ -5050,6 +5093,65 @@ function useNetworkErrorAwareAdapter(adapter) {
|
|
|
5050
5093
|
return wrappedAdapterRef.current;
|
|
5051
5094
|
}
|
|
5052
5095
|
|
|
5096
|
+
//#endregion
|
|
5097
|
+
//#region src/components/network-errors/NetworkServiceErrorBanner.tsx
|
|
5098
|
+
/**
|
|
5099
|
+
* User-friendly banner displayed when a network service connection fails.
|
|
5100
|
+
* Works with any service type (RPC, Explorer, Indexer, etc.) and provides
|
|
5101
|
+
* a clear explanation of the issue with a call-to-action to open the
|
|
5102
|
+
* network settings dialog where users can configure an alternative endpoint.
|
|
5103
|
+
*
|
|
5104
|
+
* This component can be used with or without the NetworkErrorNotificationProvider:
|
|
5105
|
+
* - With provider: The settings handler is obtained from context
|
|
5106
|
+
* - Without provider: Pass onOpenNetworkSettings prop directly, or the button won't render
|
|
5107
|
+
*/
|
|
5108
|
+
function NetworkServiceErrorBanner({ networkConfig, serviceType, errorMessage, title, description, onOpenNetworkSettings: onOpenNetworkSettingsProp }) {
|
|
5109
|
+
const context = (0, react.useContext)(NetworkErrorContext);
|
|
5110
|
+
const onOpenNetworkSettings = onOpenNetworkSettingsProp ?? context?.onOpenNetworkSettings;
|
|
5111
|
+
const handleOpenSettings = () => {
|
|
5112
|
+
onOpenNetworkSettings?.(networkConfig.id);
|
|
5113
|
+
};
|
|
5114
|
+
const serviceName = (0, _openzeppelin_ui_utils.getServiceDisplayName)(serviceType);
|
|
5115
|
+
const defaultTitle = `Unable to Connect to ${networkConfig.name}`;
|
|
5116
|
+
const defaultDescription = onOpenNetworkSettings ? `This could be due to network congestion, rate limiting, or the service being temporarily down. You can configure a custom ${serviceName.toLowerCase()} endpoint in the network settings.` : `This could be due to network congestion, rate limiting, or the service being temporarily down.`;
|
|
5117
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Alert, {
|
|
5118
|
+
variant: "destructive",
|
|
5119
|
+
className: "border-red-500/50 bg-red-50 dark:bg-red-950/20",
|
|
5120
|
+
children: [
|
|
5121
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CloudOff, { className: "h-4 w-4 text-red-600 dark:text-red-400" }),
|
|
5122
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(AlertTitle, {
|
|
5123
|
+
className: "text-red-900 dark:text-red-100",
|
|
5124
|
+
children: title || defaultTitle
|
|
5125
|
+
}),
|
|
5126
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(AlertDescription, {
|
|
5127
|
+
className: "text-red-800 dark:text-red-200",
|
|
5128
|
+
children: [
|
|
5129
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
5130
|
+
className: "mb-2",
|
|
5131
|
+
children: errorMessage || `The ${serviceName.toLowerCase()} for ${networkConfig.name} is currently unavailable or not responding.`
|
|
5132
|
+
}),
|
|
5133
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
5134
|
+
className: "text-sm mb-3",
|
|
5135
|
+
children: description || defaultDescription
|
|
5136
|
+
}),
|
|
5137
|
+
onOpenNetworkSettings && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Button, {
|
|
5138
|
+
onClick: handleOpenSettings,
|
|
5139
|
+
variant: "default",
|
|
5140
|
+
size: "sm",
|
|
5141
|
+
className: "bg-red-600 hover:bg-red-700 text-white dark:bg-red-500 dark:hover:bg-red-600",
|
|
5142
|
+
children: [
|
|
5143
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Settings, { className: "mr-2 h-4 w-4" }),
|
|
5144
|
+
"Configure ",
|
|
5145
|
+
serviceName,
|
|
5146
|
+
" Settings"
|
|
5147
|
+
]
|
|
5148
|
+
})
|
|
5149
|
+
]
|
|
5150
|
+
})
|
|
5151
|
+
]
|
|
5152
|
+
});
|
|
5153
|
+
}
|
|
5154
|
+
|
|
5053
5155
|
//#endregion
|
|
5054
5156
|
//#region src/components/ui/sonner.tsx
|
|
5055
5157
|
const Toaster = ({ ...props }) => {
|
|
@@ -5148,6 +5250,7 @@ exports.MidnightIcon = MidnightIcon;
|
|
|
5148
5250
|
exports.NetworkErrorNotificationProvider = NetworkErrorNotificationProvider;
|
|
5149
5251
|
exports.NetworkIcon = NetworkIcon;
|
|
5150
5252
|
exports.NetworkSelector = NetworkSelector;
|
|
5253
|
+
exports.NetworkServiceErrorBanner = NetworkServiceErrorBanner;
|
|
5151
5254
|
exports.NetworkStatusBadge = NetworkStatusBadge;
|
|
5152
5255
|
exports.NumberField = NumberField;
|
|
5153
5256
|
exports.ObjectField = ObjectField;
|
|
@@ -5174,6 +5277,7 @@ exports.SelectSeparator = SelectSeparator;
|
|
|
5174
5277
|
exports.SelectTrigger = SelectTrigger;
|
|
5175
5278
|
exports.SelectValue = SelectValue;
|
|
5176
5279
|
exports.SidebarButton = SidebarButton;
|
|
5280
|
+
exports.SidebarGroup = SidebarGroup;
|
|
5177
5281
|
exports.SidebarLayout = SidebarLayout;
|
|
5178
5282
|
exports.SidebarSection = SidebarSection;
|
|
5179
5283
|
exports.Tabs = Tabs;
|