@openzeppelin/ui-components 1.0.0 → 1.0.2
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-D4BAP8iw.cjs +281 -0
- package/dist/ErrorMessage-D4BAP8iw.cjs.map +1 -0
- package/dist/ErrorMessage-DyO9ZWWz.js +170 -0
- package/dist/ErrorMessage-DyO9ZWWz.js.map +1 -0
- package/dist/code-editor-BKEEXGxt.d.cts +122 -0
- package/dist/code-editor-BKEEXGxt.d.cts.map +1 -0
- package/dist/code-editor-CxxSe1o8.d.ts +122 -0
- package/dist/code-editor-CxxSe1o8.d.ts.map +1 -0
- package/dist/code-editor.cjs +132 -0
- package/dist/code-editor.cjs.map +1 -0
- package/dist/code-editor.d.cts +122 -0
- package/dist/code-editor.d.ts +122 -0
- package/dist/code-editor.js +129 -0
- package/dist/code-editor.js.map +1 -0
- package/dist/{index-CrEkH28U.d.cts → index-DDdy06qO.d.ts} +8 -124
- package/dist/index-DDdy06qO.d.ts.map +1 -0
- package/dist/{index-CYn57Ffl.d.ts → index-DfQJGBqH.d.cts} +13 -129
- package/dist/index-DfQJGBqH.d.cts.map +1 -0
- package/dist/index.cjs +268 -584
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -121
- package/dist/index.d.ts +11 -127
- package/dist/index.js +196 -482
- package/dist/index.js.map +1 -1
- package/package.json +8 -3
- package/dist/index-CYn57Ffl.d.ts.map +0 -1
- package/dist/index-CrEkH28U.d.cts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,70 +1,229 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
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");
|
|
28
6
|
let _radix_ui_react_accordion = require("@radix-ui/react-accordion");
|
|
29
|
-
_radix_ui_react_accordion = __toESM(_radix_ui_react_accordion);
|
|
7
|
+
_radix_ui_react_accordion = require_ErrorMessage.__toESM(_radix_ui_react_accordion);
|
|
30
8
|
let class_variance_authority = require("class-variance-authority");
|
|
31
9
|
let lucide_react = require("lucide-react");
|
|
32
|
-
let react = require("react");
|
|
33
|
-
react = __toESM(react);
|
|
34
10
|
let _openzeppelin_ui_utils = require("@openzeppelin/ui-utils");
|
|
35
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
36
11
|
let _radix_ui_react_slot = require("@radix-ui/react-slot");
|
|
37
12
|
let react_day_picker = require("react-day-picker");
|
|
38
13
|
let _radix_ui_react_checkbox = require("@radix-ui/react-checkbox");
|
|
39
|
-
_radix_ui_react_checkbox = __toESM(_radix_ui_react_checkbox);
|
|
14
|
+
_radix_ui_react_checkbox = require_ErrorMessage.__toESM(_radix_ui_react_checkbox);
|
|
40
15
|
let date_fns = require("date-fns");
|
|
41
16
|
let _radix_ui_react_popover = require("@radix-ui/react-popover");
|
|
42
|
-
_radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
17
|
+
_radix_ui_react_popover = require_ErrorMessage.__toESM(_radix_ui_react_popover);
|
|
43
18
|
let _radix_ui_react_dialog = require("@radix-ui/react-dialog");
|
|
44
|
-
_radix_ui_react_dialog = __toESM(_radix_ui_react_dialog);
|
|
19
|
+
_radix_ui_react_dialog = require_ErrorMessage.__toESM(_radix_ui_react_dialog);
|
|
45
20
|
let _radix_ui_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
|
|
46
|
-
_radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
47
|
-
let react_hook_form = require("react-hook-form");
|
|
21
|
+
_radix_ui_react_dropdown_menu = require_ErrorMessage.__toESM(_radix_ui_react_dropdown_menu);
|
|
48
22
|
let _radix_ui_react_label = require("@radix-ui/react-label");
|
|
49
|
-
_radix_ui_react_label = __toESM(_radix_ui_react_label);
|
|
23
|
+
_radix_ui_react_label = require_ErrorMessage.__toESM(_radix_ui_react_label);
|
|
50
24
|
let _radix_ui_react_progress = require("@radix-ui/react-progress");
|
|
51
|
-
_radix_ui_react_progress = __toESM(_radix_ui_react_progress);
|
|
25
|
+
_radix_ui_react_progress = require_ErrorMessage.__toESM(_radix_ui_react_progress);
|
|
52
26
|
let _radix_ui_react_radio_group = require("@radix-ui/react-radio-group");
|
|
53
|
-
_radix_ui_react_radio_group = __toESM(_radix_ui_react_radio_group);
|
|
27
|
+
_radix_ui_react_radio_group = require_ErrorMessage.__toESM(_radix_ui_react_radio_group);
|
|
54
28
|
let _radix_ui_react_select = require("@radix-ui/react-select");
|
|
55
|
-
_radix_ui_react_select = __toESM(_radix_ui_react_select);
|
|
29
|
+
_radix_ui_react_select = require_ErrorMessage.__toESM(_radix_ui_react_select);
|
|
56
30
|
let _radix_ui_react_tabs = require("@radix-ui/react-tabs");
|
|
57
|
-
_radix_ui_react_tabs = __toESM(_radix_ui_react_tabs);
|
|
31
|
+
_radix_ui_react_tabs = require_ErrorMessage.__toESM(_radix_ui_react_tabs);
|
|
58
32
|
let _radix_ui_react_tooltip = require("@radix-ui/react-tooltip");
|
|
59
|
-
_radix_ui_react_tooltip = __toESM(_radix_ui_react_tooltip);
|
|
60
|
-
let _uiw_react_textarea_code_editor = require("@uiw/react-textarea-code-editor");
|
|
61
|
-
_uiw_react_textarea_code_editor = __toESM(_uiw_react_textarea_code_editor);
|
|
62
|
-
let _uiw_react_textarea_code_editor_nohighlight = require("@uiw/react-textarea-code-editor/nohighlight");
|
|
63
|
-
_uiw_react_textarea_code_editor_nohighlight = __toESM(_uiw_react_textarea_code_editor_nohighlight);
|
|
33
|
+
_radix_ui_react_tooltip = require_ErrorMessage.__toESM(_radix_ui_react_tooltip);
|
|
64
34
|
let _openzeppelin_ui_types = require("@openzeppelin/ui-types");
|
|
65
35
|
let sonner = require("sonner");
|
|
66
36
|
let next_themes = require("next-themes");
|
|
67
37
|
|
|
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
|
|
68
227
|
//#region src/components/ui/accordion.tsx
|
|
69
228
|
const accordionItemVariants = (0, class_variance_authority.cva)("", {
|
|
70
229
|
variants: { variant: {
|
|
@@ -342,7 +501,7 @@ Button.displayName = "Button";
|
|
|
342
501
|
function Calendar({ className, classNames, showOutsideDays = true, ...props }) {
|
|
343
502
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_day_picker.DayPicker, {
|
|
344
503
|
showOutsideDays,
|
|
345
|
-
className: (0, _openzeppelin_ui_utils.cn)("p-3", className),
|
|
504
|
+
className: (0, _openzeppelin_ui_utils.cn)("relative p-3", className),
|
|
346
505
|
classNames: {
|
|
347
506
|
months: "flex flex-col sm:flex-row gap-2 px-5",
|
|
348
507
|
month: "flex flex-col gap-4",
|
|
@@ -1504,360 +1663,6 @@ function ViewContractStateButton({ contractAddress, onToggle }) {
|
|
|
1504
1663
|
});
|
|
1505
1664
|
}
|
|
1506
1665
|
|
|
1507
|
-
//#endregion
|
|
1508
|
-
//#region src/components/fields/utils/accessibility.ts
|
|
1509
|
-
/**
|
|
1510
|
-
* Accessibility utilities for form field components
|
|
1511
|
-
*/
|
|
1512
|
-
/**
|
|
1513
|
-
* Default aria-describedby ID generator based on field ID
|
|
1514
|
-
*/
|
|
1515
|
-
function getDescribedById(id, type = "error") {
|
|
1516
|
-
return `${id}-${type}`;
|
|
1517
|
-
}
|
|
1518
|
-
/**
|
|
1519
|
-
* Generates accessibility attributes for form fields
|
|
1520
|
-
*/
|
|
1521
|
-
function getAccessibilityProps({ id, hasError = false, isRequired = false, isDisabled = false, isReadOnly = false, hasHelperText = false, hasCharacterCounter = false }) {
|
|
1522
|
-
const describedByIds = [];
|
|
1523
|
-
if (hasError) describedByIds.push(getDescribedById(id, "error"));
|
|
1524
|
-
if (hasHelperText) describedByIds.push(getDescribedById(id, "description"));
|
|
1525
|
-
if (hasCharacterCounter) describedByIds.push(getDescribedById(id, "counter"));
|
|
1526
|
-
return {
|
|
1527
|
-
"aria-invalid": hasError,
|
|
1528
|
-
"aria-required": isRequired,
|
|
1529
|
-
"aria-describedby": describedByIds.length > 0 ? describedByIds.join(" ") : void 0,
|
|
1530
|
-
"aria-errormessage": hasError ? getDescribedById(id, "error") : void 0,
|
|
1531
|
-
required: isRequired,
|
|
1532
|
-
disabled: isDisabled,
|
|
1533
|
-
readOnly: isReadOnly,
|
|
1534
|
-
tabIndex: isDisabled ? -1 : 0
|
|
1535
|
-
};
|
|
1536
|
-
}
|
|
1537
|
-
/**
|
|
1538
|
-
* Utility function to handle keyboard events for interactive elements
|
|
1539
|
-
* Helps ensure keyboard users can interact with form controls
|
|
1540
|
-
*/
|
|
1541
|
-
function handleKeyboardEvent(event, handlers) {
|
|
1542
|
-
switch (event.key) {
|
|
1543
|
-
case "Enter":
|
|
1544
|
-
if (handlers.onEnter) {
|
|
1545
|
-
event.preventDefault();
|
|
1546
|
-
handlers.onEnter();
|
|
1547
|
-
}
|
|
1548
|
-
break;
|
|
1549
|
-
case " ":
|
|
1550
|
-
if (handlers.onSpace) {
|
|
1551
|
-
event.preventDefault();
|
|
1552
|
-
handlers.onSpace();
|
|
1553
|
-
}
|
|
1554
|
-
break;
|
|
1555
|
-
case "Escape":
|
|
1556
|
-
if (handlers.onEscape) {
|
|
1557
|
-
event.preventDefault();
|
|
1558
|
-
handlers.onEscape();
|
|
1559
|
-
}
|
|
1560
|
-
break;
|
|
1561
|
-
case "ArrowUp":
|
|
1562
|
-
if (handlers.onArrowUp) {
|
|
1563
|
-
event.preventDefault();
|
|
1564
|
-
handlers.onArrowUp();
|
|
1565
|
-
}
|
|
1566
|
-
break;
|
|
1567
|
-
case "ArrowDown":
|
|
1568
|
-
if (handlers.onArrowDown) {
|
|
1569
|
-
event.preventDefault();
|
|
1570
|
-
handlers.onArrowDown();
|
|
1571
|
-
}
|
|
1572
|
-
break;
|
|
1573
|
-
case "ArrowLeft":
|
|
1574
|
-
if (handlers.onArrowLeft) {
|
|
1575
|
-
event.preventDefault();
|
|
1576
|
-
handlers.onArrowLeft();
|
|
1577
|
-
}
|
|
1578
|
-
break;
|
|
1579
|
-
case "ArrowRight":
|
|
1580
|
-
if (handlers.onArrowRight) {
|
|
1581
|
-
event.preventDefault();
|
|
1582
|
-
handlers.onArrowRight();
|
|
1583
|
-
}
|
|
1584
|
-
break;
|
|
1585
|
-
case "Tab":
|
|
1586
|
-
if (handlers.onTab) {
|
|
1587
|
-
event.preventDefault();
|
|
1588
|
-
handlers.onTab();
|
|
1589
|
-
}
|
|
1590
|
-
break;
|
|
1591
|
-
default: break;
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
/**
|
|
1595
|
-
* Field focus management utility
|
|
1596
|
-
* For managing focus within a field group or complex form component
|
|
1597
|
-
*/
|
|
1598
|
-
function createFocusManager() {
|
|
1599
|
-
return {
|
|
1600
|
-
focusFirstElement(container) {
|
|
1601
|
-
if (!container) return;
|
|
1602
|
-
const focusable = container.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])");
|
|
1603
|
-
if (focusable.length > 0) focusable[0].focus();
|
|
1604
|
-
},
|
|
1605
|
-
focusElementById(id) {
|
|
1606
|
-
const element = document.getElementById(id);
|
|
1607
|
-
if (element) element.focus();
|
|
1608
|
-
},
|
|
1609
|
-
trapFocus(event, container) {
|
|
1610
|
-
if (!container || event.key !== "Tab") return;
|
|
1611
|
-
const focusable = Array.from(container.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])"));
|
|
1612
|
-
if (focusable.length === 0) return;
|
|
1613
|
-
const firstElement = focusable[0];
|
|
1614
|
-
const lastElement = focusable[focusable.length - 1];
|
|
1615
|
-
if (event.shiftKey && document.activeElement === firstElement) {
|
|
1616
|
-
event.preventDefault();
|
|
1617
|
-
lastElement.focus();
|
|
1618
|
-
} else if (!event.shiftKey && document.activeElement === lastElement) {
|
|
1619
|
-
event.preventDefault();
|
|
1620
|
-
firstElement.focus();
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
};
|
|
1624
|
-
}
|
|
1625
|
-
/**
|
|
1626
|
-
* Provides a handler for Escape key to clear input fields
|
|
1627
|
-
*
|
|
1628
|
-
* @param onChange - Function to call when value changes
|
|
1629
|
-
* @param value - Current value of the input
|
|
1630
|
-
* @returns A function to handle the Escape key press
|
|
1631
|
-
*/
|
|
1632
|
-
function handleEscapeKey(onChange, value) {
|
|
1633
|
-
return (e) => {
|
|
1634
|
-
if (e.key === "Escape") {
|
|
1635
|
-
e.preventDefault();
|
|
1636
|
-
if (value) onChange("");
|
|
1637
|
-
else e.target.blur();
|
|
1638
|
-
}
|
|
1639
|
-
};
|
|
1640
|
-
}
|
|
1641
|
-
/**
|
|
1642
|
-
* Provides a handler for Space/Enter keys for toggle components (checkboxes, switches)
|
|
1643
|
-
*
|
|
1644
|
-
* @param onChange - Function to call when value changes
|
|
1645
|
-
* @param value - Current value of the input
|
|
1646
|
-
* @returns A function to handle the Space/Enter key press
|
|
1647
|
-
*/
|
|
1648
|
-
function handleToggleKeys(onChange, value) {
|
|
1649
|
-
return (e) => {
|
|
1650
|
-
if (e.key === " " || e.key === "Enter") {
|
|
1651
|
-
e.preventDefault();
|
|
1652
|
-
onChange(!value);
|
|
1653
|
-
}
|
|
1654
|
-
};
|
|
1655
|
-
}
|
|
1656
|
-
/**
|
|
1657
|
-
* Provides a handler for arrow keys for numeric inputs
|
|
1658
|
-
*
|
|
1659
|
-
* @param onChange - Function to call when value changes
|
|
1660
|
-
* @param value - Current numeric value
|
|
1661
|
-
* @param step - Step amount for increments/decrements
|
|
1662
|
-
* @param min - Minimum allowed value (optional)
|
|
1663
|
-
* @param max - Maximum allowed value (optional)
|
|
1664
|
-
* @returns A function to handle arrow key presses
|
|
1665
|
-
*/
|
|
1666
|
-
function handleNumericKeys(onChange, value, step = 1, min, max) {
|
|
1667
|
-
return (e) => {
|
|
1668
|
-
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
1669
|
-
e.preventDefault();
|
|
1670
|
-
const direction = e.key === "ArrowUp" ? 1 : -1;
|
|
1671
|
-
let newValue = typeof value === "number" ? value + step * direction : 0;
|
|
1672
|
-
if (typeof min === "number") newValue = Math.max(min, newValue);
|
|
1673
|
-
if (typeof max === "number") newValue = Math.min(max, newValue);
|
|
1674
|
-
onChange(newValue);
|
|
1675
|
-
}
|
|
1676
|
-
};
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
//#endregion
|
|
1680
|
-
//#region src/components/fields/utils/integerValidation.ts
|
|
1681
|
-
/**
|
|
1682
|
-
* Shared integer validation patterns for BigInt fields and validation utilities.
|
|
1683
|
-
*
|
|
1684
|
-
* These patterns ensure consistent validation across the application.
|
|
1685
|
-
*/
|
|
1686
|
-
/**
|
|
1687
|
-
* Integer validation pattern - requires at least one digit
|
|
1688
|
-
* Used for validation to ensure complete integers are entered
|
|
1689
|
-
* Matches: -123, 0, 456
|
|
1690
|
-
* Does not match: -, abc, 12.3
|
|
1691
|
-
*/
|
|
1692
|
-
const INTEGER_PATTERN = /^-?\d+$/;
|
|
1693
|
-
/**
|
|
1694
|
-
* Integer input pattern - allows partial input during typing
|
|
1695
|
-
* Used during input to allow users to type minus sign first
|
|
1696
|
-
* Matches: -, -1, 123, (empty string)
|
|
1697
|
-
* Does not match: abc, 12.3
|
|
1698
|
-
*/
|
|
1699
|
-
const INTEGER_INPUT_PATTERN = /^-?\d*$/;
|
|
1700
|
-
/**
|
|
1701
|
-
* HTML pattern attribute for integer inputs
|
|
1702
|
-
* Must use [0-9] instead of \d for HTML5 pattern attribute
|
|
1703
|
-
*/
|
|
1704
|
-
const INTEGER_HTML_PATTERN = "-?[0-9]*";
|
|
1705
|
-
|
|
1706
|
-
//#endregion
|
|
1707
|
-
//#region src/components/fields/utils/validation.ts
|
|
1708
|
-
/**
|
|
1709
|
-
* Determines if a field has an error
|
|
1710
|
-
*/
|
|
1711
|
-
function hasFieldError(error) {
|
|
1712
|
-
return !!error;
|
|
1713
|
-
}
|
|
1714
|
-
/**
|
|
1715
|
-
* Gets appropriate error message from field error
|
|
1716
|
-
*/
|
|
1717
|
-
function getErrorMessage(error) {
|
|
1718
|
-
if (!error) return void 0;
|
|
1719
|
-
return error.message || "This field is invalid";
|
|
1720
|
-
}
|
|
1721
|
-
/**
|
|
1722
|
-
* Formats validation error messages for display
|
|
1723
|
-
*/
|
|
1724
|
-
function formatValidationError(error, fieldName) {
|
|
1725
|
-
if (!error) return void 0;
|
|
1726
|
-
const defaultMessage = fieldName ? `${fieldName} is invalid` : "This field is invalid";
|
|
1727
|
-
return error.message || defaultMessage;
|
|
1728
|
-
}
|
|
1729
|
-
/**
|
|
1730
|
-
* Generates common CSS classes for field validation states
|
|
1731
|
-
*/
|
|
1732
|
-
function getValidationStateClasses(error, touched) {
|
|
1733
|
-
if (error) return "border-destructive focus:border-destructive focus:ring-destructive/30";
|
|
1734
|
-
if (touched) return "border-success focus:border-success focus:ring-success/30";
|
|
1735
|
-
return "";
|
|
1736
|
-
}
|
|
1737
|
-
/**
|
|
1738
|
-
* Helper for handling form validation errors with React Hook Form
|
|
1739
|
-
*/
|
|
1740
|
-
function handleValidationError(error, id) {
|
|
1741
|
-
const hasError = hasFieldError(error);
|
|
1742
|
-
const errorMessage = getErrorMessage(error);
|
|
1743
|
-
return {
|
|
1744
|
-
errorId: `${id}-error`,
|
|
1745
|
-
errorMessage,
|
|
1746
|
-
hasError,
|
|
1747
|
-
validationClasses: getValidationStateClasses(error)
|
|
1748
|
-
};
|
|
1749
|
-
}
|
|
1750
|
-
/**
|
|
1751
|
-
* Creates a validation result object for field components
|
|
1752
|
-
*/
|
|
1753
|
-
function createValidationResult(id, error, touched) {
|
|
1754
|
-
const hasError = hasFieldError(error);
|
|
1755
|
-
const errorMessage = getErrorMessage(error);
|
|
1756
|
-
const errorId = `${id}-error`;
|
|
1757
|
-
return {
|
|
1758
|
-
hasError,
|
|
1759
|
-
errorMessage,
|
|
1760
|
-
errorId,
|
|
1761
|
-
validationClasses: getValidationStateClasses(error, touched),
|
|
1762
|
-
"aria-invalid": hasError,
|
|
1763
|
-
"aria-errormessage": hasError ? errorId : void 0
|
|
1764
|
-
};
|
|
1765
|
-
}
|
|
1766
|
-
/**
|
|
1767
|
-
* Generic field validation function that can be used to validate any field type
|
|
1768
|
-
* based on common validation criteria
|
|
1769
|
-
*/
|
|
1770
|
-
function validateField(value, validation) {
|
|
1771
|
-
if (!validation) return true;
|
|
1772
|
-
if (validation.required && (value === void 0 || value === null || value === "")) return typeof validation.required === "boolean" ? "This field is required" : "This field is required";
|
|
1773
|
-
if (value === void 0 || value === null || value === "") return true;
|
|
1774
|
-
if (typeof value === "string") {
|
|
1775
|
-
if (validation.minLength && value.length < validation.minLength) return `Minimum length is ${validation.minLength} characters`;
|
|
1776
|
-
if (validation.maxLength && value.length > validation.maxLength) return `Maximum length is ${validation.maxLength} characters`;
|
|
1777
|
-
if (validation.pattern) {
|
|
1778
|
-
if (!(typeof validation.pattern === "string" ? new RegExp(validation.pattern) : validation.pattern).test(value)) {
|
|
1779
|
-
if (!INTEGER_PATTERN.test(value) && /\d/.test(value)) return "Value must be a valid integer (no decimals)";
|
|
1780
|
-
return "Value does not match the required pattern";
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
if (typeof value === "number" || typeof value === "string" && !isNaN(Number(value))) {
|
|
1785
|
-
const numValue = typeof value === "number" ? value : Number(value);
|
|
1786
|
-
if (validation.min !== void 0 && numValue < validation.min) return `Minimum value is ${validation.min}`;
|
|
1787
|
-
if (validation.max !== void 0 && numValue > validation.max) return `Maximum value is ${validation.max}`;
|
|
1788
|
-
}
|
|
1789
|
-
if (validation.conditions && validation.conditions.length > 0) {}
|
|
1790
|
-
return true;
|
|
1791
|
-
}
|
|
1792
|
-
/**
|
|
1793
|
-
* Map validation utilities
|
|
1794
|
-
*/
|
|
1795
|
-
/**
|
|
1796
|
-
* Checks if a map entry at the given index has a duplicate key
|
|
1797
|
-
* @param entries - Array of map entries
|
|
1798
|
-
* @param currentIndex - Index of the entry to check
|
|
1799
|
-
* @returns true if the key at currentIndex is duplicated elsewhere in the array
|
|
1800
|
-
*/
|
|
1801
|
-
function isDuplicateMapKey(entries, currentIndex) {
|
|
1802
|
-
if (!Array.isArray(entries) || entries.length <= 1) return false;
|
|
1803
|
-
const currentKeyValue = entries[currentIndex]?.key;
|
|
1804
|
-
if (!currentKeyValue || currentKeyValue === "") return false;
|
|
1805
|
-
return entries.some((entry, i) => {
|
|
1806
|
-
if (i === currentIndex) return false;
|
|
1807
|
-
const key = entry?.key;
|
|
1808
|
-
if (key === "") return false;
|
|
1809
|
-
if (typeof key === "string" && typeof currentKeyValue === "string") return key === currentKeyValue;
|
|
1810
|
-
if (typeof key === "number" && typeof currentKeyValue === "number") return Number.isNaN(key) ? Number.isNaN(currentKeyValue) : key === currentKeyValue;
|
|
1811
|
-
if (typeof key === "boolean" && typeof currentKeyValue === "boolean") return key === currentKeyValue;
|
|
1812
|
-
if (typeof key === "object" && key !== null && typeof currentKeyValue === "object" && currentKeyValue !== null) return key === currentKeyValue;
|
|
1813
|
-
return false;
|
|
1814
|
-
});
|
|
1815
|
-
}
|
|
1816
|
-
/**
|
|
1817
|
-
* Validates an array of map entries for duplicate keys
|
|
1818
|
-
* @param entries - Array of map entries to validate
|
|
1819
|
-
* @returns Validation error message if duplicates found, otherwise undefined
|
|
1820
|
-
*/
|
|
1821
|
-
function validateMapEntries(entries) {
|
|
1822
|
-
if (!Array.isArray(entries) || entries.length <= 1) return;
|
|
1823
|
-
const keyStrings = entries.map((entry) => entry?.key).filter((key) => key !== void 0 && key !== null && key !== "").map((key) => String(key));
|
|
1824
|
-
const uniqueKeyStrings = new Set(keyStrings);
|
|
1825
|
-
if (keyStrings.length !== uniqueKeyStrings.size) return "Duplicate keys are not allowed";
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
|
-
//#endregion
|
|
1829
|
-
//#region src/components/fields/utils/ErrorMessage.tsx
|
|
1830
|
-
/**
|
|
1831
|
-
* Displays validation error messages for form fields
|
|
1832
|
-
*/
|
|
1833
|
-
function ErrorMessage({ error, id, message, className = "" }) {
|
|
1834
|
-
const errorMessage = message || getErrorMessage(error);
|
|
1835
|
-
if (!errorMessage) return null;
|
|
1836
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1837
|
-
id,
|
|
1838
|
-
className: `text-destructive mt-1 text-sm ${className}`,
|
|
1839
|
-
role: "alert",
|
|
1840
|
-
children: errorMessage
|
|
1841
|
-
});
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
|
-
//#endregion
|
|
1845
|
-
//#region src/components/fields/utils/layout.ts
|
|
1846
|
-
/**
|
|
1847
|
-
* Layout utility functions for form components
|
|
1848
|
-
*/
|
|
1849
|
-
/**
|
|
1850
|
-
* Helper function to get width classes based on the field width
|
|
1851
|
-
*/
|
|
1852
|
-
function getWidthClasses(width) {
|
|
1853
|
-
switch (width) {
|
|
1854
|
-
case "half": return "form-field-half";
|
|
1855
|
-
case "third": return "form-field-third";
|
|
1856
|
-
case "full":
|
|
1857
|
-
default: return "form-field-full";
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1861
1666
|
//#endregion
|
|
1862
1667
|
//#region src/components/fields/AddressField.tsx
|
|
1863
1668
|
/**
|
|
@@ -1899,7 +1704,7 @@ function AddressField({ id, label, placeholder, helperText, control, name, width
|
|
|
1899
1704
|
name,
|
|
1900
1705
|
rules: { validate: (value) => {
|
|
1901
1706
|
if (value === void 0 || value === null || value === "") return validation?.required ? "This field is required" : true;
|
|
1902
|
-
const standardValidationResult = validateField(value, validation);
|
|
1707
|
+
const standardValidationResult = require_ErrorMessage.validateField(value, validation);
|
|
1903
1708
|
if (standardValidationResult !== true) return standardValidationResult;
|
|
1904
1709
|
if (adapter && typeof value === "string") {
|
|
1905
1710
|
if (!adapter.isValidAddress(value)) return "Invalid address format for the selected chain";
|
|
@@ -1910,7 +1715,7 @@ function AddressField({ id, label, placeholder, helperText, control, name, width
|
|
|
1910
1715
|
render: ({ fieldState: { error, isTouched }, field }) => {
|
|
1911
1716
|
const hasError = !!error;
|
|
1912
1717
|
const shouldShowError = hasError && isTouched;
|
|
1913
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
1718
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
1914
1719
|
const patternErrorMessage = validation?.pattern && typeof validation.pattern === "object" && "message" in validation.pattern ? validation.pattern.message : void 0;
|
|
1915
1720
|
const handleInputChange = (e) => {
|
|
1916
1721
|
const value = e.target.value;
|
|
@@ -1944,7 +1749,7 @@ function AddressField({ id, label, placeholder, helperText, control, name, width
|
|
|
1944
1749
|
className: "text-muted-foreground text-sm",
|
|
1945
1750
|
children: helperText
|
|
1946
1751
|
}),
|
|
1947
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
1752
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
1948
1753
|
error,
|
|
1949
1754
|
id: errorId,
|
|
1950
1755
|
message: shouldShowError ? error?.message || patternErrorMessage : void 0
|
|
@@ -2020,7 +1825,7 @@ function AmountField({ id, label, placeholder, helperText, control, name, width
|
|
|
2020
1825
|
render: ({ field, fieldState: { error, isTouched } }) => {
|
|
2021
1826
|
const hasError = !!error?.message;
|
|
2022
1827
|
const shouldShowError = hasError && isTouched;
|
|
2023
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
1828
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
2024
1829
|
const accessibilityProps = getAccessibilityProps({
|
|
2025
1830
|
id,
|
|
2026
1831
|
hasError,
|
|
@@ -2081,7 +1886,7 @@ function AmountField({ id, label, placeholder, helperText, control, name, width
|
|
|
2081
1886
|
className: "text-muted-foreground text-sm",
|
|
2082
1887
|
children: helperText
|
|
2083
1888
|
}),
|
|
2084
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
1889
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
2085
1890
|
error,
|
|
2086
1891
|
id: errorId,
|
|
2087
1892
|
message: shouldShowError ? error?.message : void 0
|
|
@@ -2293,7 +2098,7 @@ function ArrayField({ id, label, helperText, control, name, width = "full", vali
|
|
|
2293
2098
|
className: "text-muted-foreground text-sm",
|
|
2294
2099
|
children: helperText
|
|
2295
2100
|
}),
|
|
2296
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
2101
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
2297
2102
|
error,
|
|
2298
2103
|
id: errorId
|
|
2299
2104
|
})
|
|
@@ -2479,7 +2284,7 @@ function ArrayObjectField({ id, label, helperText, control, name, width = "full"
|
|
|
2479
2284
|
className: "text-muted-foreground text-sm",
|
|
2480
2285
|
children: helperText
|
|
2481
2286
|
}),
|
|
2482
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
2287
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
2483
2288
|
error,
|
|
2484
2289
|
id: errorId
|
|
2485
2290
|
})
|
|
@@ -2607,10 +2412,10 @@ function BigIntField({ id, label, placeholder, helperText, control, name, width
|
|
|
2607
2412
|
const descriptionId = `${id}-description`;
|
|
2608
2413
|
const enhancedValidation = {
|
|
2609
2414
|
...validation,
|
|
2610
|
-
pattern: validation?.pattern || INTEGER_PATTERN
|
|
2415
|
+
pattern: validation?.pattern || require_ErrorMessage.INTEGER_PATTERN
|
|
2611
2416
|
};
|
|
2612
2417
|
const validateBigIntValue = (value) => {
|
|
2613
|
-
const standardValidation = validateField(value, enhancedValidation);
|
|
2418
|
+
const standardValidation = require_ErrorMessage.validateField(value, enhancedValidation);
|
|
2614
2419
|
if (standardValidation !== true) return standardValidation;
|
|
2615
2420
|
if (validateBigInt) {
|
|
2616
2421
|
const customValidation = validateBigInt(value);
|
|
@@ -2644,7 +2449,7 @@ function BigIntField({ id, label, placeholder, helperText, control, name, width
|
|
|
2644
2449
|
render: ({ field, fieldState: { error, isTouched } }) => {
|
|
2645
2450
|
const hasError = !!error;
|
|
2646
2451
|
const shouldShowError = hasError && isTouched;
|
|
2647
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
2452
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
2648
2453
|
const handleInputChange = (e) => {
|
|
2649
2454
|
const rawValue = e.target.value;
|
|
2650
2455
|
if (rawValue === "") {
|
|
@@ -2655,7 +2460,7 @@ function BigIntField({ id, label, placeholder, helperText, control, name, width
|
|
|
2655
2460
|
field.onChange(rawValue);
|
|
2656
2461
|
return;
|
|
2657
2462
|
}
|
|
2658
|
-
if (INTEGER_INPUT_PATTERN.test(rawValue)) field.onChange(rawValue);
|
|
2463
|
+
if (require_ErrorMessage.INTEGER_INPUT_PATTERN.test(rawValue)) field.onChange(rawValue);
|
|
2659
2464
|
};
|
|
2660
2465
|
const handleKeyDown = (e) => {
|
|
2661
2466
|
const allowedKeys = [
|
|
@@ -2711,7 +2516,7 @@ function BigIntField({ id, label, placeholder, helperText, control, name, width
|
|
|
2711
2516
|
"data-slot": "input",
|
|
2712
2517
|
onChange: handleInputChange,
|
|
2713
2518
|
inputMode: "numeric",
|
|
2714
|
-
pattern: INTEGER_HTML_PATTERN,
|
|
2519
|
+
pattern: require_ErrorMessage.INTEGER_HTML_PATTERN,
|
|
2715
2520
|
...accessibilityProps,
|
|
2716
2521
|
"aria-describedby": `${helperText ? descriptionId : ""} ${hasError ? errorId : ""}`,
|
|
2717
2522
|
disabled: readOnly
|
|
@@ -2721,7 +2526,7 @@ function BigIntField({ id, label, placeholder, helperText, control, name, width
|
|
|
2721
2526
|
className: "text-muted-foreground text-sm",
|
|
2722
2527
|
children: helperText
|
|
2723
2528
|
}),
|
|
2724
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
2529
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
2725
2530
|
error,
|
|
2726
2531
|
id: errorId,
|
|
2727
2532
|
message: shouldShowError ? error?.message : void 0
|
|
@@ -2758,7 +2563,7 @@ function BooleanField({ id, label, helperText, control, name, width = "full", va
|
|
|
2758
2563
|
const errorId = `${id}-error`;
|
|
2759
2564
|
const descriptionId = `${id}-description`;
|
|
2760
2565
|
const validateBooleanValue = (value) => {
|
|
2761
|
-
const standardValidation = validateField(value, validation);
|
|
2566
|
+
const standardValidation = require_ErrorMessage.validateField(value, validation);
|
|
2762
2567
|
if (standardValidation !== true) return standardValidation;
|
|
2763
2568
|
if (validateBoolean) {
|
|
2764
2569
|
const customValidation = validateBoolean(value);
|
|
@@ -2780,7 +2585,7 @@ function BooleanField({ id, label, helperText, control, name, width = "full", va
|
|
|
2780
2585
|
disabled: readOnly,
|
|
2781
2586
|
render: ({ field, fieldState: { error, isTouched } }) => {
|
|
2782
2587
|
const hasError = !!error;
|
|
2783
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
2588
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
2784
2589
|
const handleCheckedChange = (checked) => {
|
|
2785
2590
|
const value = checked === true;
|
|
2786
2591
|
field.onChange(value);
|
|
@@ -2829,7 +2634,7 @@ function BooleanField({ id, label, helperText, control, name, width = "full", va
|
|
|
2829
2634
|
className: "text-muted-foreground pl-6 text-sm",
|
|
2830
2635
|
children: helperText
|
|
2831
2636
|
}),
|
|
2832
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
2637
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
2833
2638
|
error,
|
|
2834
2639
|
id: errorId,
|
|
2835
2640
|
className: "pl-6"
|
|
@@ -2912,7 +2717,7 @@ function BytesField({ id, label, helperText, control, name, width = "full", vali
|
|
|
2912
2717
|
render: ({ field, fieldState: { error, isTouched } }) => {
|
|
2913
2718
|
const hasError = !!error;
|
|
2914
2719
|
const shouldShowError = hasError && (isTouched || validation?.required);
|
|
2915
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
2720
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
2916
2721
|
const accessibilityProps = getAccessibilityProps({
|
|
2917
2722
|
id,
|
|
2918
2723
|
hasError,
|
|
@@ -2955,7 +2760,7 @@ function BytesField({ id, label, helperText, control, name, width = "full", vali
|
|
|
2955
2760
|
]
|
|
2956
2761
|
})]
|
|
2957
2762
|
}),
|
|
2958
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
2763
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
2959
2764
|
error,
|
|
2960
2765
|
id: errorId,
|
|
2961
2766
|
message: shouldShowError ? error?.message : void 0
|
|
@@ -2967,126 +2772,6 @@ function BytesField({ id, label, helperText, control, name, width = "full", vali
|
|
|
2967
2772
|
}
|
|
2968
2773
|
BytesField.displayName = "BytesField";
|
|
2969
2774
|
|
|
2970
|
-
//#endregion
|
|
2971
|
-
//#region src/components/fields/CodeEditorField.tsx
|
|
2972
|
-
/**
|
|
2973
|
-
* CodeEditorField provides syntax-highlighted code editing with form integration.
|
|
2974
|
-
*
|
|
2975
|
-
* Features:
|
|
2976
|
-
* - Syntax highlighting via @uiw/react-textarea-code-editor
|
|
2977
|
-
* - React Hook Form integration with Controller
|
|
2978
|
-
* - Configurable language support (JSON, TypeScript, etc.)
|
|
2979
|
-
* - Performance optimizations with smart highlighting
|
|
2980
|
-
* - Constrained height with automatic scrolling
|
|
2981
|
-
* - Design system styling integration
|
|
2982
|
-
*
|
|
2983
|
-
* @example
|
|
2984
|
-
* ```tsx
|
|
2985
|
-
* <CodeEditorField
|
|
2986
|
-
* id="contractAbi"
|
|
2987
|
-
* name="contractSchema"
|
|
2988
|
-
* control={control}
|
|
2989
|
-
* label="Contract ABI"
|
|
2990
|
-
* language="json"
|
|
2991
|
-
* placeholder="Paste your ABI JSON here..."
|
|
2992
|
-
* />
|
|
2993
|
-
* ```
|
|
2994
|
-
*/
|
|
2995
|
-
function CodeEditorField({ id, name, control, label, helperText, placeholder = "", language = "json", theme = "light", height = "200px", maxHeight = "400px", performanceThreshold = 5e3, required = false, disabled = false, readOnly = false, validateCode, className }) {
|
|
2996
|
-
function extractPixelValue(val, fallback) {
|
|
2997
|
-
if (typeof val === "number") return val;
|
|
2998
|
-
const match = typeof val === "string" ? val.match(/^(\d+)\s*px$/) : null;
|
|
2999
|
-
if (match) return parseInt(match[1], 10);
|
|
3000
|
-
return fallback;
|
|
3001
|
-
}
|
|
3002
|
-
const minHeightNum = extractPixelValue(height, 200);
|
|
3003
|
-
const maxHeightNum = extractPixelValue(maxHeight, 400);
|
|
3004
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3005
|
-
className,
|
|
3006
|
-
children: [label && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3007
|
-
htmlFor: id,
|
|
3008
|
-
className: "block text-sm font-medium text-foreground mb-2",
|
|
3009
|
-
children: [label, required && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3010
|
-
className: "text-destructive ml-1",
|
|
3011
|
-
children: "*"
|
|
3012
|
-
})]
|
|
3013
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_hook_form.Controller, {
|
|
3014
|
-
name,
|
|
3015
|
-
control,
|
|
3016
|
-
rules: {
|
|
3017
|
-
required: required ? "This field is required" : false,
|
|
3018
|
-
validate: { validCode: (value) => {
|
|
3019
|
-
if (!validateCode || !value) return true;
|
|
3020
|
-
const validation = validateCode(value);
|
|
3021
|
-
if (typeof validation === "string") return validation;
|
|
3022
|
-
if (validation === false) return "Invalid code format";
|
|
3023
|
-
return true;
|
|
3024
|
-
} }
|
|
3025
|
-
},
|
|
3026
|
-
render: ({ field: { onChange, onBlur, value }, fieldState: { error } }) => {
|
|
3027
|
-
const shouldDisableHighlighting = (value || "").length > performanceThreshold;
|
|
3028
|
-
const EditorComponent = shouldDisableHighlighting ? _uiw_react_textarea_code_editor_nohighlight.default : _uiw_react_textarea_code_editor.default;
|
|
3029
|
-
const handleChange = (event) => {
|
|
3030
|
-
onChange(event.target.value);
|
|
3031
|
-
};
|
|
3032
|
-
const handleBlur = () => {
|
|
3033
|
-
onBlur();
|
|
3034
|
-
};
|
|
3035
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3036
|
-
className: "space-y-2",
|
|
3037
|
-
children: [
|
|
3038
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3039
|
-
className: "w-full rounded-md border border-input bg-background ring-offset-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 disabled:cursor-not-allowed resize-y",
|
|
3040
|
-
style: {
|
|
3041
|
-
maxHeight: `${maxHeightNum}px`,
|
|
3042
|
-
overflow: "auto",
|
|
3043
|
-
overflowX: "hidden",
|
|
3044
|
-
minHeight: `${minHeightNum}px`,
|
|
3045
|
-
resize: "vertical"
|
|
3046
|
-
},
|
|
3047
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditorComponent, {
|
|
3048
|
-
id,
|
|
3049
|
-
value: value || "",
|
|
3050
|
-
language,
|
|
3051
|
-
placeholder,
|
|
3052
|
-
onChange: handleChange,
|
|
3053
|
-
onBlur: handleBlur,
|
|
3054
|
-
padding: 12,
|
|
3055
|
-
minHeight: minHeightNum,
|
|
3056
|
-
"data-color-mode": theme,
|
|
3057
|
-
disabled,
|
|
3058
|
-
readOnly,
|
|
3059
|
-
"data-testid": `${id}-code-editor${shouldDisableHighlighting ? "-no-highlight" : ""}`,
|
|
3060
|
-
className: "text-sm placeholder:text-muted-foreground",
|
|
3061
|
-
style: {
|
|
3062
|
-
fontFamily: "ui-monospace, SFMono-Regular, \"SF Mono\", Consolas, \"Liberation Mono\", Menlo, monospace",
|
|
3063
|
-
fontSize: "14px",
|
|
3064
|
-
border: "none",
|
|
3065
|
-
backgroundColor: "transparent",
|
|
3066
|
-
width: "100%",
|
|
3067
|
-
wordWrap: "break-word",
|
|
3068
|
-
whiteSpace: "pre-wrap",
|
|
3069
|
-
overflowWrap: "break-word"
|
|
3070
|
-
}
|
|
3071
|
-
})
|
|
3072
|
-
}),
|
|
3073
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
3074
|
-
error,
|
|
3075
|
-
id: `${id}-error`
|
|
3076
|
-
}),
|
|
3077
|
-
helperText && !error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3078
|
-
className: "text-sm text-muted-foreground",
|
|
3079
|
-
id: `${id}-helper`,
|
|
3080
|
-
children: helperText
|
|
3081
|
-
})
|
|
3082
|
-
]
|
|
3083
|
-
});
|
|
3084
|
-
}
|
|
3085
|
-
})]
|
|
3086
|
-
});
|
|
3087
|
-
}
|
|
3088
|
-
CodeEditorField.displayName = "CodeEditorField";
|
|
3089
|
-
|
|
3090
2775
|
//#endregion
|
|
3091
2776
|
//#region src/components/fields/DateTimeField.tsx
|
|
3092
2777
|
/**
|
|
@@ -3117,7 +2802,7 @@ function DateTimeField({ id, label, placeholder, helperText, control, name, widt
|
|
|
3117
2802
|
const errorId = `${id}-error`;
|
|
3118
2803
|
const descriptionId = `${id}-description`;
|
|
3119
2804
|
const validateDateValue = (value) => {
|
|
3120
|
-
const validationResult = validateField(value, validation);
|
|
2805
|
+
const validationResult = require_ErrorMessage.validateField(value, validation);
|
|
3121
2806
|
return validationResult === true ? true : validationResult;
|
|
3122
2807
|
};
|
|
3123
2808
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -3144,7 +2829,7 @@ function DateTimeField({ id, label, placeholder, helperText, control, name, widt
|
|
|
3144
2829
|
render: ({ field, fieldState: { error, isTouched } }) => {
|
|
3145
2830
|
const hasError = !!error;
|
|
3146
2831
|
const shouldShowError = hasError && isTouched;
|
|
3147
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
2832
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
3148
2833
|
const handleChange = (e) => {
|
|
3149
2834
|
const raw = e.target.value;
|
|
3150
2835
|
if (!raw) {
|
|
@@ -3202,7 +2887,7 @@ function DateTimeField({ id, label, placeholder, helperText, control, name, widt
|
|
|
3202
2887
|
className: "text-muted-foreground text-sm",
|
|
3203
2888
|
children: helperText
|
|
3204
2889
|
}),
|
|
3205
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
2890
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
3206
2891
|
error,
|
|
3207
2892
|
id: errorId,
|
|
3208
2893
|
message: shouldShowError ? error?.message : void 0
|
|
@@ -3249,7 +2934,7 @@ function EnumField({ id, label, placeholder = "Select variant", helperText, cont
|
|
|
3249
2934
|
name,
|
|
3250
2935
|
disabled: readOnly,
|
|
3251
2936
|
rules: { validate: (value) => {
|
|
3252
|
-
const standardValidation = validateField(value, validation);
|
|
2937
|
+
const standardValidation = require_ErrorMessage.validateField(value, validation);
|
|
3253
2938
|
if (standardValidation !== true) return standardValidation;
|
|
3254
2939
|
if (typeof value === "string") try {
|
|
3255
2940
|
if (!JSON.parse(value).tag) return "JSON must have a \"tag\" property specifying the enum variant";
|
|
@@ -3263,7 +2948,7 @@ function EnumField({ id, label, placeholder = "Select variant", helperText, cont
|
|
|
3263
2948
|
} },
|
|
3264
2949
|
render: ({ field, fieldState: { error, isTouched } }) => {
|
|
3265
2950
|
const hasError = !!error;
|
|
3266
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
2951
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
3267
2952
|
const accessibilityProps = getAccessibilityProps({
|
|
3268
2953
|
id,
|
|
3269
2954
|
hasError,
|
|
@@ -3311,7 +2996,7 @@ function EnumField({ id, label, placeholder = "Select variant", helperText, cont
|
|
|
3311
2996
|
className: "text-muted-foreground text-sm",
|
|
3312
2997
|
children: helperText
|
|
3313
2998
|
}),
|
|
3314
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
2999
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
3315
3000
|
error,
|
|
3316
3001
|
id: errorId
|
|
3317
3002
|
})
|
|
@@ -3336,7 +3021,7 @@ function EnumField({ id, label, placeholder = "Select variant", helperText, cont
|
|
|
3336
3021
|
name,
|
|
3337
3022
|
disabled: readOnly,
|
|
3338
3023
|
rules: { validate: (value) => {
|
|
3339
|
-
const standardValidation = validateField(value, validation);
|
|
3024
|
+
const standardValidation = require_ErrorMessage.validateField(value, validation);
|
|
3340
3025
|
if (standardValidation !== true) return standardValidation;
|
|
3341
3026
|
if (!value || !value.tag) return validation?.required ? "This field is required" : true;
|
|
3342
3027
|
if (validateEnum && value) {
|
|
@@ -3456,7 +3141,7 @@ function EnumField({ id, label, placeholder = "Select variant", helperText, cont
|
|
|
3456
3141
|
className: "text-muted-foreground text-sm",
|
|
3457
3142
|
children: helperText
|
|
3458
3143
|
}),
|
|
3459
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
3144
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
3460
3145
|
error,
|
|
3461
3146
|
id: errorId
|
|
3462
3147
|
})
|
|
@@ -3597,9 +3282,9 @@ function FileUploadField({ id, label, placeholder = "Drop your file here or clic
|
|
|
3597
3282
|
control,
|
|
3598
3283
|
name,
|
|
3599
3284
|
rules: { validate: (value) => {
|
|
3600
|
-
if (!value) return validateField(value, validation);
|
|
3285
|
+
if (!value) return require_ErrorMessage.validateField(value, validation);
|
|
3601
3286
|
if (maxSize && value && typeof value === "object" && "size" in value && value.size > maxSize) return `File size must be less than ${(maxSize / (1024 * 1024)).toFixed(2)} MB`;
|
|
3602
|
-
return validateField(value, validation);
|
|
3287
|
+
return require_ErrorMessage.validateField(value, validation);
|
|
3603
3288
|
} },
|
|
3604
3289
|
disabled: readOnly,
|
|
3605
3290
|
render: ({ field: { onChange, onBlur }, fieldState: { error } }) => {
|
|
@@ -3721,7 +3406,7 @@ function FileUploadField({ id, label, placeholder = "Drop your file here or clic
|
|
|
3721
3406
|
})]
|
|
3722
3407
|
})
|
|
3723
3408
|
}),
|
|
3724
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
3409
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
3725
3410
|
error,
|
|
3726
3411
|
id: errorId
|
|
3727
3412
|
})
|
|
@@ -3944,7 +3629,7 @@ function MapField({ id, label, helperText, control, name, width = "full", valida
|
|
|
3944
3629
|
className: "text-muted-foreground text-sm",
|
|
3945
3630
|
children: helperText
|
|
3946
3631
|
}),
|
|
3947
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
3632
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
3948
3633
|
message: shouldShowError ? error?.message : void 0,
|
|
3949
3634
|
error,
|
|
3950
3635
|
id: errorId
|
|
@@ -4061,7 +3746,7 @@ function validateMapStructure({ value, required, minItems }) {
|
|
|
4061
3746
|
return true;
|
|
4062
3747
|
}
|
|
4063
3748
|
const mapArray = value;
|
|
4064
|
-
const duplicateError = validateMapEntries(mapArray);
|
|
3749
|
+
const duplicateError = require_ErrorMessage.validateMapEntries(mapArray);
|
|
4065
3750
|
if (duplicateError) return duplicateError;
|
|
4066
3751
|
if (mapArray.some((entry) => {
|
|
4067
3752
|
const key = entry.key;
|
|
@@ -4114,7 +3799,7 @@ function NumberField({ id, label, placeholder, helperText, control, name, width
|
|
|
4114
3799
|
COMPLETE_NUMBER: /^-?\d+\.?\d*$/
|
|
4115
3800
|
};
|
|
4116
3801
|
const validateNumericValue = (value) => {
|
|
4117
|
-
const standardValidation = validateField(value, mergedValidation);
|
|
3802
|
+
const standardValidation = require_ErrorMessage.validateField(value, mergedValidation);
|
|
4118
3803
|
if (standardValidation !== true) return standardValidation;
|
|
4119
3804
|
if (validateNumber) {
|
|
4120
3805
|
const customValidation = validateNumber(value);
|
|
@@ -4153,7 +3838,7 @@ function NumberField({ id, label, placeholder, helperText, control, name, width
|
|
|
4153
3838
|
render: ({ field, fieldState: { error, isTouched } }) => {
|
|
4154
3839
|
const hasError = !!error;
|
|
4155
3840
|
const shouldShowError = hasError && isTouched;
|
|
4156
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
3841
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
4157
3842
|
const handleInputChange = (e) => {
|
|
4158
3843
|
const rawValue = e.target.value;
|
|
4159
3844
|
if (!NUMBER_REGEX.VALID_FORMAT.test(rawValue) && rawValue !== "") return;
|
|
@@ -4242,7 +3927,7 @@ function NumberField({ id, label, placeholder, helperText, control, name, width
|
|
|
4242
3927
|
className: "text-muted-foreground text-sm",
|
|
4243
3928
|
children: helperText
|
|
4244
3929
|
}),
|
|
4245
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
3930
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
4246
3931
|
error,
|
|
4247
3932
|
id: errorId,
|
|
4248
3933
|
message: shouldShowError ? error?.message : void 0
|
|
@@ -4327,7 +4012,7 @@ function ObjectField({ id, label, helperText, control, name, width = "full", val
|
|
|
4327
4012
|
className: "text-muted-foreground text-sm mt-2",
|
|
4328
4013
|
children: helperText
|
|
4329
4014
|
}),
|
|
4330
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
4015
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
4331
4016
|
error,
|
|
4332
4017
|
id: errorId
|
|
4333
4018
|
})
|
|
@@ -4383,7 +4068,7 @@ function PasswordField({ id, label, placeholder, helperText, control, name, widt
|
|
|
4383
4068
|
const errorId = `${id}-error`;
|
|
4384
4069
|
const descriptionId = `${id}-description`;
|
|
4385
4070
|
const validatePasswordValue = (value) => {
|
|
4386
|
-
const validationResult = validateField(value, validation);
|
|
4071
|
+
const validationResult = require_ErrorMessage.validateField(value, validation);
|
|
4387
4072
|
return validationResult === true ? true : validationResult;
|
|
4388
4073
|
};
|
|
4389
4074
|
const togglePasswordVisibility = () => {
|
|
@@ -4413,7 +4098,7 @@ function PasswordField({ id, label, placeholder, helperText, control, name, widt
|
|
|
4413
4098
|
render: ({ field, fieldState: { error, isTouched } }) => {
|
|
4414
4099
|
const hasError = !!error;
|
|
4415
4100
|
const shouldShowError = hasError && isTouched;
|
|
4416
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
4101
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
4417
4102
|
const handleInputChange = (e) => {
|
|
4418
4103
|
const value = e.target.value;
|
|
4419
4104
|
field.onChange(value);
|
|
@@ -4462,7 +4147,7 @@ function PasswordField({ id, label, placeholder, helperText, control, name, widt
|
|
|
4462
4147
|
className: "text-muted-foreground text-sm",
|
|
4463
4148
|
children: helperText
|
|
4464
4149
|
}),
|
|
4465
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
4150
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
4466
4151
|
error,
|
|
4467
4152
|
id: errorId,
|
|
4468
4153
|
message: shouldShowError ? error?.message : void 0
|
|
@@ -4574,7 +4259,7 @@ function RadioField({ id, label, helperText, control, name, width = "full", vali
|
|
|
4574
4259
|
className: "text-sm text-muted-foreground",
|
|
4575
4260
|
children: helperText
|
|
4576
4261
|
}),
|
|
4577
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
4262
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
4578
4263
|
error,
|
|
4579
4264
|
id: errorId
|
|
4580
4265
|
})
|
|
@@ -4674,7 +4359,7 @@ function SelectField({ id, label, placeholder = "Select an option", helperText,
|
|
|
4674
4359
|
className: "text-muted-foreground text-sm",
|
|
4675
4360
|
children: helperText
|
|
4676
4361
|
}),
|
|
4677
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
4362
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
4678
4363
|
error,
|
|
4679
4364
|
id: errorId
|
|
4680
4365
|
})
|
|
@@ -4771,7 +4456,7 @@ function SelectGroupedField({ id, label, placeholder = "Select an option", helpe
|
|
|
4771
4456
|
className: "text-muted-foreground text-sm",
|
|
4772
4457
|
children: helperText
|
|
4773
4458
|
}),
|
|
4774
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
4459
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
4775
4460
|
error,
|
|
4776
4461
|
id: errorId
|
|
4777
4462
|
})
|
|
@@ -4834,7 +4519,7 @@ function TextAreaField({ id, label, placeholder, helperText, control, name, widt
|
|
|
4834
4519
|
render: ({ field, fieldState: { error, isTouched } }) => {
|
|
4835
4520
|
const hasError = !!error;
|
|
4836
4521
|
const shouldShowError = hasError && isTouched;
|
|
4837
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
4522
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
4838
4523
|
const accessibilityProps = getAccessibilityProps({
|
|
4839
4524
|
id,
|
|
4840
4525
|
hasError,
|
|
@@ -4869,7 +4554,7 @@ function TextAreaField({ id, label, placeholder, helperText, control, name, widt
|
|
|
4869
4554
|
className: "text-muted-foreground text-sm",
|
|
4870
4555
|
children: helperText
|
|
4871
4556
|
}),
|
|
4872
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
4557
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
4873
4558
|
error,
|
|
4874
4559
|
id: errorId,
|
|
4875
4560
|
message: shouldShowError ? error?.message : void 0
|
|
@@ -4906,7 +4591,7 @@ function TextField({ id, label, placeholder, helperText, control, name, width =
|
|
|
4906
4591
|
const errorId = `${id}-error`;
|
|
4907
4592
|
const descriptionId = `${id}-description`;
|
|
4908
4593
|
const validateTextValue = (value) => {
|
|
4909
|
-
const validationResult = validateField(value, validation);
|
|
4594
|
+
const validationResult = require_ErrorMessage.validateField(value, validation);
|
|
4910
4595
|
return validationResult === true ? true : validationResult;
|
|
4911
4596
|
};
|
|
4912
4597
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -4933,7 +4618,7 @@ function TextField({ id, label, placeholder, helperText, control, name, width =
|
|
|
4933
4618
|
render: ({ field, fieldState: { error, isTouched } }) => {
|
|
4934
4619
|
const hasError = !!error;
|
|
4935
4620
|
const shouldShowError = hasError && isTouched;
|
|
4936
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
4621
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
4937
4622
|
const handleInputChange = (e) => {
|
|
4938
4623
|
const value = e.target.value;
|
|
4939
4624
|
field.onChange(value);
|
|
@@ -4966,7 +4651,7 @@ function TextField({ id, label, placeholder, helperText, control, name, width =
|
|
|
4966
4651
|
className: "text-muted-foreground text-sm",
|
|
4967
4652
|
children: helperText
|
|
4968
4653
|
}),
|
|
4969
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
4654
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
4970
4655
|
error,
|
|
4971
4656
|
id: errorId,
|
|
4972
4657
|
message: shouldShowError ? error?.message : void 0
|
|
@@ -5004,7 +4689,7 @@ function UrlField({ id, label, placeholder, helperText, control, name, width = "
|
|
|
5004
4689
|
name,
|
|
5005
4690
|
rules: { validate: (value) => {
|
|
5006
4691
|
if (value === void 0 || value === null || value === "") return validation?.required ? "This field is required" : true;
|
|
5007
|
-
const standardValidationResult = validateField(value, validation);
|
|
4692
|
+
const standardValidationResult = require_ErrorMessage.validateField(value, validation);
|
|
5008
4693
|
if (standardValidationResult !== true) return standardValidationResult;
|
|
5009
4694
|
if (typeof value === "string" && value && !(0, _openzeppelin_ui_utils.isValidUrl)(value)) return (0, _openzeppelin_ui_utils.getInvalidUrlMessage)();
|
|
5010
4695
|
return true;
|
|
@@ -5013,7 +4698,7 @@ function UrlField({ id, label, placeholder, helperText, control, name, width = "
|
|
|
5013
4698
|
render: ({ field, fieldState: { error, isTouched } }) => {
|
|
5014
4699
|
const hasError = !!error;
|
|
5015
4700
|
const shouldShowError = hasError && isTouched;
|
|
5016
|
-
const validationClasses = getValidationStateClasses(error, isTouched);
|
|
4701
|
+
const validationClasses = require_ErrorMessage.getValidationStateClasses(error, isTouched);
|
|
5017
4702
|
const handleInputChange = (e) => {
|
|
5018
4703
|
const value = e.target.value;
|
|
5019
4704
|
field.onChange(value);
|
|
@@ -5051,7 +4736,7 @@ function UrlField({ id, label, placeholder, helperText, control, name, width = "
|
|
|
5051
4736
|
className: "text-muted-foreground text-sm",
|
|
5052
4737
|
children: helperText
|
|
5053
4738
|
}),
|
|
5054
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
4739
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ErrorMessage.ErrorMessage, {
|
|
5055
4740
|
error,
|
|
5056
4741
|
id: errorId,
|
|
5057
4742
|
message: shouldShowError ? error?.message : void 0
|
|
@@ -5410,7 +5095,6 @@ exports.CardFooter = CardFooter;
|
|
|
5410
5095
|
exports.CardHeader = CardHeader;
|
|
5411
5096
|
exports.CardTitle = CardTitle;
|
|
5412
5097
|
exports.Checkbox = Checkbox;
|
|
5413
|
-
exports.CodeEditorField = CodeEditorField;
|
|
5414
5098
|
exports.DateRangePicker = DateRangePicker;
|
|
5415
5099
|
exports.DateTimeField = DateTimeField;
|
|
5416
5100
|
exports.Dialog = Dialog;
|
|
@@ -5440,7 +5124,7 @@ exports.DropdownMenuSubTrigger = DropdownMenuSubTrigger;
|
|
|
5440
5124
|
exports.DropdownMenuTrigger = DropdownMenuTrigger;
|
|
5441
5125
|
exports.EmptyState = EmptyState;
|
|
5442
5126
|
exports.EnumField = EnumField;
|
|
5443
|
-
exports.ErrorMessage = ErrorMessage;
|
|
5127
|
+
exports.ErrorMessage = require_ErrorMessage.ErrorMessage;
|
|
5444
5128
|
exports.ExternalLink = ExternalLink;
|
|
5445
5129
|
exports.FileUploadField = FileUploadField;
|
|
5446
5130
|
exports.Footer = Footer;
|
|
@@ -5452,9 +5136,9 @@ exports.FormItem = FormItem;
|
|
|
5452
5136
|
exports.FormLabel = FormLabel;
|
|
5453
5137
|
exports.FormMessage = FormMessage;
|
|
5454
5138
|
exports.Header = Header;
|
|
5455
|
-
exports.INTEGER_HTML_PATTERN = INTEGER_HTML_PATTERN;
|
|
5456
|
-
exports.INTEGER_INPUT_PATTERN = INTEGER_INPUT_PATTERN;
|
|
5457
|
-
exports.INTEGER_PATTERN = INTEGER_PATTERN;
|
|
5139
|
+
exports.INTEGER_HTML_PATTERN = require_ErrorMessage.INTEGER_HTML_PATTERN;
|
|
5140
|
+
exports.INTEGER_INPUT_PATTERN = require_ErrorMessage.INTEGER_INPUT_PATTERN;
|
|
5141
|
+
exports.INTEGER_PATTERN = require_ErrorMessage.INTEGER_PATTERN;
|
|
5458
5142
|
exports.Input = Input;
|
|
5459
5143
|
exports.Label = Label;
|
|
5460
5144
|
exports.LoadingButton = LoadingButton;
|
|
@@ -5509,26 +5193,26 @@ exports.ViewContractStateButton = ViewContractStateButton;
|
|
|
5509
5193
|
exports.buttonVariants = buttonVariants;
|
|
5510
5194
|
exports.computeChildTouched = computeChildTouched;
|
|
5511
5195
|
exports.createFocusManager = createFocusManager;
|
|
5512
|
-
exports.createValidationResult = createValidationResult;
|
|
5513
|
-
exports.formatValidationError = formatValidationError;
|
|
5196
|
+
exports.createValidationResult = require_ErrorMessage.createValidationResult;
|
|
5197
|
+
exports.formatValidationError = require_ErrorMessage.formatValidationError;
|
|
5514
5198
|
exports.getAccessibilityProps = getAccessibilityProps;
|
|
5515
5199
|
exports.getDescribedById = getDescribedById;
|
|
5516
|
-
exports.getErrorMessage = getErrorMessage;
|
|
5517
|
-
exports.getValidationStateClasses = getValidationStateClasses;
|
|
5200
|
+
exports.getErrorMessage = require_ErrorMessage.getErrorMessage;
|
|
5201
|
+
exports.getValidationStateClasses = require_ErrorMessage.getValidationStateClasses;
|
|
5518
5202
|
exports.getWidthClasses = getWidthClasses;
|
|
5519
5203
|
exports.handleEscapeKey = handleEscapeKey;
|
|
5520
5204
|
exports.handleKeyboardEvent = handleKeyboardEvent;
|
|
5521
5205
|
exports.handleNumericKeys = handleNumericKeys;
|
|
5522
5206
|
exports.handleToggleKeys = handleToggleKeys;
|
|
5523
|
-
exports.handleValidationError = handleValidationError;
|
|
5524
|
-
exports.hasFieldError = hasFieldError;
|
|
5525
|
-
exports.isDuplicateMapKey = isDuplicateMapKey;
|
|
5207
|
+
exports.handleValidationError = require_ErrorMessage.handleValidationError;
|
|
5208
|
+
exports.hasFieldError = require_ErrorMessage.hasFieldError;
|
|
5209
|
+
exports.isDuplicateMapKey = require_ErrorMessage.isDuplicateMapKey;
|
|
5526
5210
|
exports.useDuplicateKeyIndexes = useDuplicateKeyIndexes;
|
|
5527
5211
|
exports.useMapFieldSync = useMapFieldSync;
|
|
5528
5212
|
exports.useNetworkErrorAwareAdapter = useNetworkErrorAwareAdapter;
|
|
5529
5213
|
exports.useNetworkErrorReporter = useNetworkErrorReporter;
|
|
5530
5214
|
exports.useNetworkErrors = useNetworkErrors;
|
|
5531
|
-
exports.validateField = validateField;
|
|
5532
|
-
exports.validateMapEntries = validateMapEntries;
|
|
5215
|
+
exports.validateField = require_ErrorMessage.validateField;
|
|
5216
|
+
exports.validateMapEntries = require_ErrorMessage.validateMapEntries;
|
|
5533
5217
|
exports.validateMapStructure = validateMapStructure;
|
|
5534
5218
|
//# sourceMappingURL=index.cjs.map
|