@openzeppelin/ui-components 1.7.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -2
- package/dist/index.cjs +55 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -15
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +21 -21
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +55 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -137,11 +137,29 @@ components/
|
|
|
137
137
|
|
|
138
138
|
Components are styled using Tailwind CSS. The necessary Tailwind configuration is expected to be present in the consuming application. The UI package itself does not bundle CSS but provides the class names and structure.
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
Important: a bare Tailwind import is not enough for OpenZeppelin packages. Tailwind v4 must be told to scan the relevant `@openzeppelin/*` sources, or some component classes will be omitted from the final CSS.
|
|
141
|
+
|
|
142
|
+
For consumer apps that use `@openzeppelin/ui-dev-cli`, the recommended workflow is:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
pnpm exec oz-ui-dev tailwind doctor --project "$PWD"
|
|
146
|
+
pnpm exec oz-ui-dev tailwind fix --project "$PWD"
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
That creates a managed `oz-tailwind.generated.css` file and keeps the `@source` wiring in sync with your installed dependencies.
|
|
150
|
+
|
|
151
|
+
If you need to configure Tailwind manually, import the shared styles and register the OpenZeppelin package sources explicitly:
|
|
141
152
|
|
|
142
153
|
```css
|
|
154
|
+
@layer base, components, utilities;
|
|
155
|
+
|
|
156
|
+
@import 'tailwindcss' source(none);
|
|
157
|
+
@source "../node_modules/@openzeppelin/ui-components";
|
|
158
|
+
@source "../node_modules/@openzeppelin/ui-react";
|
|
159
|
+
@source "../node_modules/@openzeppelin/ui-renderer";
|
|
160
|
+
@source "../node_modules/@openzeppelin/ui-styles";
|
|
161
|
+
@source "../node_modules/@openzeppelin/ui-utils";
|
|
143
162
|
@import '@openzeppelin/ui-styles/global.css';
|
|
144
|
-
@import 'tailwindcss';
|
|
145
163
|
```
|
|
146
164
|
|
|
147
165
|
## Development
|
package/dist/index.cjs
CHANGED
|
@@ -38,7 +38,7 @@ let sonner = require("sonner");
|
|
|
38
38
|
let next_themes = require("next-themes");
|
|
39
39
|
|
|
40
40
|
//#region src/version.ts
|
|
41
|
-
const VERSION = "
|
|
41
|
+
const VERSION = "2.0.1";
|
|
42
42
|
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/components/ui/accordion.tsx
|
|
@@ -126,7 +126,7 @@ const TooltipTrigger = _radix_ui_react_tooltip.Trigger;
|
|
|
126
126
|
const TooltipContent = react.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tooltip.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tooltip.Content, {
|
|
127
127
|
ref,
|
|
128
128
|
sideOffset,
|
|
129
|
-
className: (0, _openzeppelin_ui_utils.cn)("bg-
|
|
129
|
+
className: (0, _openzeppelin_ui_utils.cn)("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 overflow-hidden rounded-md px-3 py-1.5 text-xs", className),
|
|
130
130
|
...props
|
|
131
131
|
}) }));
|
|
132
132
|
TooltipContent.displayName = _radix_ui_react_tooltip.Content.displayName;
|
|
@@ -573,15 +573,15 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }) {
|
|
|
573
573
|
weekdays: "flex",
|
|
574
574
|
weekday: "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
|
|
575
575
|
week: "flex w-full mt-2",
|
|
576
|
-
day: (0, _openzeppelin_ui_utils.cn)("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-
|
|
576
|
+
day: (0, _openzeppelin_ui_utils.cn)("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-selected/15 [&:has([aria-selected].day-outside)]:bg-selected/10 [&:has([aria-selected].day-range-end)]:rounded-r-md", props.mode === "range" ? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md" : "[&:has([aria-selected])]:rounded-md"),
|
|
577
577
|
day_button: (0, _openzeppelin_ui_utils.cn)(buttonVariants({ variant: "ghost" }), "h-9 w-9 p-0 font-normal aria-selected:opacity-100 rounded-none hover:rounded-none"),
|
|
578
578
|
range_start: "day-range-start rounded-l-md",
|
|
579
579
|
range_end: "day-range-end rounded-r-md",
|
|
580
|
-
selected: "bg-
|
|
580
|
+
selected: "bg-selected text-selected-foreground hover:bg-selected hover:text-selected-foreground focus:bg-selected focus:text-selected-foreground",
|
|
581
581
|
today: "bg-accent text-accent-foreground",
|
|
582
|
-
outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-
|
|
582
|
+
outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-selected/10 aria-selected:text-muted-foreground aria-selected:opacity-30",
|
|
583
583
|
disabled: "text-muted-foreground opacity-50",
|
|
584
|
-
range_middle: "aria-selected:bg-
|
|
584
|
+
range_middle: "aria-selected:bg-selected/15 aria-selected:text-foreground",
|
|
585
585
|
hidden: "invisible",
|
|
586
586
|
...classNames
|
|
587
587
|
},
|
|
@@ -650,7 +650,7 @@ function CardFooter({ className, ...props }) {
|
|
|
650
650
|
function Checkbox({ className, ...props }) {
|
|
651
651
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_checkbox.Root, {
|
|
652
652
|
"data-slot": "checkbox",
|
|
653
|
-
className: (0, _openzeppelin_ui_utils.cn)("border-input data-[state=checked]:bg-
|
|
653
|
+
className: (0, _openzeppelin_ui_utils.cn)("border-input data-[state=checked]:bg-selected data-[state=checked]:text-selected-foreground data-[state=checked]:border-selected focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
654
654
|
...props,
|
|
655
655
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_checkbox.Indicator, {
|
|
656
656
|
"data-slot": "checkbox-indicator",
|
|
@@ -1244,7 +1244,7 @@ const Header = ({ title, onOpenSidebar, rightContent }) => {
|
|
|
1244
1244
|
type: "button",
|
|
1245
1245
|
"aria-label": "Open menu",
|
|
1246
1246
|
onClick: onOpenSidebar,
|
|
1247
|
-
className: "mr-2 sm:mr-3 inline-flex items-center justify-center rounded-md p-2 text-
|
|
1247
|
+
className: "mr-2 sm:mr-3 inline-flex items-center justify-center rounded-md p-2 text-foreground hover:bg-muted focus:outline-none focus:ring-2 focus:ring-primary xl:hidden",
|
|
1248
1248
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Menu, { className: "size-5" })
|
|
1249
1249
|
}),
|
|
1250
1250
|
title && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1491,7 +1491,7 @@ function NetworkSelector({ networks, getNetworkLabel, getNetworkIcon, getNetwork
|
|
|
1491
1491
|
className: "gap-2",
|
|
1492
1492
|
children: [
|
|
1493
1493
|
isMultiple ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1494
|
-
className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-
|
|
1494
|
+
className: (0, _openzeppelin_ui_utils.cn)("flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border transition-colors", isSelected(network) ? "border-selected bg-selected text-selected-foreground" : "border-input bg-background"),
|
|
1495
1495
|
children: isSelected(network) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "h-3 w-3" })
|
|
1496
1496
|
}) : null,
|
|
1497
1497
|
getNetworkIcon?.(network),
|
|
@@ -1505,7 +1505,7 @@ function NetworkSelector({ networks, getNetworkLabel, getNetworkIcon, getNetwork
|
|
|
1505
1505
|
children: getNetworkType(network)
|
|
1506
1506
|
})]
|
|
1507
1507
|
}),
|
|
1508
|
-
!isMultiple && isSelected(network) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "h-4 w-4 opacity-100" })
|
|
1508
|
+
!isMultiple && isSelected(network) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "h-4 w-4 text-selected opacity-100" })
|
|
1509
1509
|
]
|
|
1510
1510
|
}, getNetworkId(network))) }),
|
|
1511
1511
|
index < Object.keys(groupedNetworks).length - 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuSeparator, {})
|
|
@@ -1595,7 +1595,7 @@ RadioGroup.displayName = _radix_ui_react_radio_group.Root.displayName;
|
|
|
1595
1595
|
const RadioGroupItem = react.forwardRef(({ className, ...props }, ref) => {
|
|
1596
1596
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_radio_group.Item, {
|
|
1597
1597
|
ref,
|
|
1598
|
-
className: (0, _openzeppelin_ui_utils.cn)("border-input bg-background text-
|
|
1598
|
+
className: (0, _openzeppelin_ui_utils.cn)("border-input bg-background text-selected h-4 w-4 rounded-full border shadow-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
1599
1599
|
...props,
|
|
1600
1600
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_radio_group.Indicator, {
|
|
1601
1601
|
className: "flex items-center justify-center",
|
|
@@ -1687,7 +1687,7 @@ SelectSeparator.displayName = _radix_ui_react_select.Separator.displayName;
|
|
|
1687
1687
|
* Can render as a button or anchor element depending on whether href is provided.
|
|
1688
1688
|
*/
|
|
1689
1689
|
function SidebarButton({ icon, children, onClick, size = "default", badge, disabled = false, isSelected = false, href, target, rel, className }) {
|
|
1690
|
-
const commonClass = (0, _openzeppelin_ui_utils.cn)("group relative flex flex-wrap items-center gap-x-2 gap-y-0.5 px-3 py-2 rounded-lg font-semibold text-sm transition-colors", badge ? "justify-between" : "justify-start", disabled ? "text-
|
|
1690
|
+
const commonClass = (0, _openzeppelin_ui_utils.cn)("group relative flex flex-wrap items-center gap-x-2 gap-y-0.5 px-3 py-2 rounded-lg font-semibold text-sm transition-colors", badge ? "justify-between" : "justify-start", disabled ? "text-muted-foreground/60 cursor-not-allowed" : isSelected ? "text-selected bg-selected/10" : "text-muted-foreground hover:text-foreground cursor-pointer hover:before:content-[\"\"] hover:before:absolute hover:before:inset-x-0 hover:before:top-1 hover:before:bottom-1 hover:before:bg-muted/80 hover:before:rounded-lg hover:before:-z-10", size === "small" ? "min-h-10" : "min-h-11", className);
|
|
1691
1691
|
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1692
1692
|
className: "flex items-center gap-2",
|
|
1693
1693
|
children: [icon, children]
|
|
@@ -1865,7 +1865,7 @@ function TabsList({ className, ...props }) {
|
|
|
1865
1865
|
function TabsTrigger({ className, ...props }) {
|
|
1866
1866
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tabs.Trigger, {
|
|
1867
1867
|
"data-slot": "tabs-trigger",
|
|
1868
|
-
className: (0, _openzeppelin_ui_utils.cn)("data-[state=active]:bg-background data-[state=active]:text-
|
|
1868
|
+
className: (0, _openzeppelin_ui_utils.cn)("data-[state=active]:bg-background data-[state=active]:text-selected focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring inline-flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
1869
1869
|
...props
|
|
1870
1870
|
});
|
|
1871
1871
|
}
|
|
@@ -1940,7 +1940,7 @@ function canClick(state, freeNavigation = false) {
|
|
|
1940
1940
|
}
|
|
1941
1941
|
function StepCircle({ state, index }) {
|
|
1942
1942
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1943
|
-
className: (0, _openzeppelin_ui_utils.cn)("flex size-6 shrink-0 items-center justify-center rounded-full text-xs font-semibold transition-all", state === "completed" && "bg-
|
|
1943
|
+
className: (0, _openzeppelin_ui_utils.cn)("flex size-6 shrink-0 items-center justify-center rounded-full text-xs font-semibold transition-all", state === "completed" && "bg-selected text-selected-foreground", state === "current" && "bg-selected text-selected-foreground ring-2 ring-selected/30", state === "visited" && "bg-selected/10 text-selected ring-1 ring-selected/40", state === "invalid" && "bg-destructive/10 text-destructive ring-1 ring-destructive/40", state === "upcoming" && "bg-muted text-muted-foreground"),
|
|
1944
1944
|
children: state === "completed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "size-3.5" }) : state === "visited" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Pencil, { className: "size-3" }) : state === "invalid" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.AlertCircle, { className: "size-3.5" }) : index + 1
|
|
1945
1945
|
});
|
|
1946
1946
|
}
|
|
@@ -1948,10 +1948,10 @@ function StepLabel({ title, state, isSkipped }) {
|
|
|
1948
1948
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1949
1949
|
className: "min-w-0 flex-1",
|
|
1950
1950
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1951
|
-
className: (0, _openzeppelin_ui_utils.cn)("text-sm font-medium transition-colors", state === "current" && "text-
|
|
1951
|
+
className: (0, _openzeppelin_ui_utils.cn)("text-sm font-medium transition-colors", state === "current" && "text-selected", state === "completed" && "text-foreground", state === "visited" && "text-selected", state === "invalid" && "text-destructive", state === "upcoming" && "text-muted-foreground"),
|
|
1952
1952
|
children: title
|
|
1953
1953
|
}), isSkipped && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1954
|
-
className: "mt-0.5 block text-[11px] text-
|
|
1954
|
+
className: "mt-0.5 block text-[11px] text-muted-foreground",
|
|
1955
1955
|
children: "Skipped"
|
|
1956
1956
|
})]
|
|
1957
1957
|
});
|
|
@@ -1959,7 +1959,7 @@ function StepLabel({ title, state, isSkipped }) {
|
|
|
1959
1959
|
function VerticalStepper({ steps, currentStepIndex, furthestStepIndex = currentStepIndex, onStepClick, freeNavigation, className }) {
|
|
1960
1960
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
|
|
1961
1961
|
"aria-label": "Wizard steps",
|
|
1962
|
-
className: (0, _openzeppelin_ui_utils.cn)("rounded-2xl border border-
|
|
1962
|
+
className: (0, _openzeppelin_ui_utils.cn)("rounded-2xl border border-border bg-card p-6", className),
|
|
1963
1963
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1964
1964
|
className: "flex flex-col gap-1",
|
|
1965
1965
|
children: steps.map((step, index) => {
|
|
@@ -1969,7 +1969,7 @@ function VerticalStepper({ steps, currentStepIndex, furthestStepIndex = currentS
|
|
|
1969
1969
|
type: "button",
|
|
1970
1970
|
onClick: () => clickable && onStepClick?.(index),
|
|
1971
1971
|
disabled: !clickable,
|
|
1972
|
-
className: (0, _openzeppelin_ui_utils.cn)("flex items-center gap-3 rounded-xl border border-transparent px-3 py-3 text-left transition-all duration-150", clickable ? "cursor-pointer" : "cursor-not-allowed opacity-50", state === "current" && "border-
|
|
1972
|
+
className: (0, _openzeppelin_ui_utils.cn)("flex items-center gap-3 rounded-xl border border-transparent px-3 py-3 text-left transition-all duration-150", clickable ? "cursor-pointer" : "cursor-not-allowed opacity-50", state === "current" && "border-selected/40 bg-selected/5", state === "completed" && "bg-card hover:bg-muted/40", state === "visited" && "bg-card hover:bg-selected/5", state === "invalid" && "border-destructive/40 bg-destructive/5 hover:bg-destructive/10", state === "upcoming" && "bg-card"),
|
|
1973
1973
|
"aria-current": state === "current" ? "step" : void 0,
|
|
1974
1974
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StepCircle, {
|
|
1975
1975
|
state,
|
|
@@ -1987,7 +1987,7 @@ function VerticalStepper({ steps, currentStepIndex, furthestStepIndex = currentS
|
|
|
1987
1987
|
function HorizontalStepper({ steps, currentStepIndex, furthestStepIndex = currentStepIndex, onStepClick, freeNavigation, className }) {
|
|
1988
1988
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
|
|
1989
1989
|
"aria-label": "Wizard steps",
|
|
1990
|
-
className: (0, _openzeppelin_ui_utils.cn)("rounded-2xl border border-
|
|
1990
|
+
className: (0, _openzeppelin_ui_utils.cn)("rounded-2xl border border-border bg-card p-6", className),
|
|
1991
1991
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1992
1992
|
className: "flex w-full items-center",
|
|
1993
1993
|
children: steps.map((step, index) => {
|
|
@@ -1998,7 +1998,7 @@ function HorizontalStepper({ steps, currentStepIndex, furthestStepIndex = curren
|
|
|
1998
1998
|
type: "button",
|
|
1999
1999
|
onClick: () => clickable && onStepClick?.(index),
|
|
2000
2000
|
disabled: !clickable,
|
|
2001
|
-
className: (0, _openzeppelin_ui_utils.cn)("flex items-center gap-2 rounded-xl border border-transparent px-3 py-2 text-left transition-all duration-150", clickable ? "cursor-pointer" : "cursor-not-allowed opacity-50", state === "current" && "border-
|
|
2001
|
+
className: (0, _openzeppelin_ui_utils.cn)("flex items-center gap-2 rounded-xl border border-transparent px-3 py-2 text-left transition-all duration-150", clickable ? "cursor-pointer" : "cursor-not-allowed opacity-50", state === "current" && "border-selected/40 bg-selected/5", state === "completed" && "bg-card hover:bg-muted/40", state === "visited" && "bg-card hover:bg-selected/5", state === "invalid" && "border-destructive/40 bg-destructive/5 hover:bg-destructive/10", state === "upcoming" && "bg-card"),
|
|
2002
2002
|
"aria-current": state === "current" ? "step" : void 0,
|
|
2003
2003
|
"aria-label": `Step ${index + 1}: ${step.title}`,
|
|
2004
2004
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StepCircle, {
|
|
@@ -2012,7 +2012,7 @@ function HorizontalStepper({ steps, currentStepIndex, furthestStepIndex = curren
|
|
|
2012
2012
|
isSkipped: step.status === "skipped"
|
|
2013
2013
|
})
|
|
2014
2014
|
})]
|
|
2015
|
-
}), !isLast && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: (0, _openzeppelin_ui_utils.cn)("mx-1 h-px flex-1 transition-colors sm:mx-2", index < currentStepIndex ? "bg-
|
|
2015
|
+
}), !isLast && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: (0, _openzeppelin_ui_utils.cn)("mx-1 h-px flex-1 transition-colors sm:mx-2", index < currentStepIndex ? "bg-selected" : "bg-border") })] }, step.id);
|
|
2016
2016
|
})
|
|
2017
2017
|
})
|
|
2018
2018
|
});
|
|
@@ -2674,13 +2674,13 @@ const MAX_SUGGESTIONS = 5;
|
|
|
2674
2674
|
* 2. TransactionForm renders the overall form structure with React Hook Form
|
|
2675
2675
|
* 3. DynamicFormField selects the appropriate field component (like AddressField) based on field type
|
|
2676
2676
|
* 4. BaseField provides consistent layout and hook form integration
|
|
2677
|
-
* 5. This component handles blockchain address-specific rendering and validation using the passed
|
|
2677
|
+
* 5. This component handles blockchain address-specific rendering and validation using the passed addressing capability
|
|
2678
2678
|
*
|
|
2679
2679
|
* The component includes:
|
|
2680
2680
|
* - Integration with React Hook Form
|
|
2681
|
-
* - Blockchain address validation through
|
|
2681
|
+
* - Blockchain address validation through the provided addressing capability
|
|
2682
2682
|
* - Automatic error handling and reporting
|
|
2683
|
-
* - Chain-agnostic design (validation handled by
|
|
2683
|
+
* - Chain-agnostic design (validation handled by capabilities)
|
|
2684
2684
|
* - Full accessibility support with ARIA attributes
|
|
2685
2685
|
* - Keyboard navigation
|
|
2686
2686
|
*
|
|
@@ -2695,7 +2695,7 @@ const MAX_SUGGESTIONS = 5;
|
|
|
2695
2695
|
* The suggestion dropdown includes built-in debouncing, keyboard navigation (Arrow keys,
|
|
2696
2696
|
* Enter, Escape), click-outside dismissal, and ARIA listbox semantics.
|
|
2697
2697
|
*/
|
|
2698
|
-
function AddressField({ id, label, placeholder, helperText, control, name, width = "full", validation,
|
|
2698
|
+
function AddressField({ id, label, placeholder, helperText, control, name, width = "full", validation, addressing, readOnly, suggestions: suggestionsProp, onSuggestionSelect }) {
|
|
2699
2699
|
const isRequired = !!validation?.required;
|
|
2700
2700
|
const errorId = `${id}-error`;
|
|
2701
2701
|
const descriptionId = `${id}-description`;
|
|
@@ -2778,8 +2778,8 @@ function AddressField({ id, label, placeholder, helperText, control, name, width
|
|
|
2778
2778
|
if (value === void 0 || value === null || value === "") return validation?.required ? "This field is required" : true;
|
|
2779
2779
|
const standardValidationResult = require_ErrorMessage.validateField(value, validation);
|
|
2780
2780
|
if (standardValidationResult !== true) return standardValidationResult;
|
|
2781
|
-
if (
|
|
2782
|
-
if (!
|
|
2781
|
+
if (addressing && typeof value === "string") {
|
|
2782
|
+
if (!addressing.isValidAddress(value)) return "Invalid address format for the selected chain";
|
|
2783
2783
|
}
|
|
2784
2784
|
return true;
|
|
2785
2785
|
} },
|
|
@@ -2855,7 +2855,7 @@ function AddressField({ id, label, placeholder, helperText, control, name, width
|
|
|
2855
2855
|
type: "button",
|
|
2856
2856
|
role: "option",
|
|
2857
2857
|
"aria-selected": i === highlightedIndex,
|
|
2858
|
-
className: (0, _openzeppelin_ui_utils.cn)("flex w-full flex-col px-3 py-2 text-left text-sm", "hover:bg-
|
|
2858
|
+
className: (0, _openzeppelin_ui_utils.cn)("flex w-full flex-col px-3 py-2 text-left text-sm", "hover:bg-selected/10", i === highlightedIndex && "bg-selected/10"),
|
|
2859
2859
|
onMouseDown: (e) => {
|
|
2860
2860
|
e.preventDefault();
|
|
2861
2861
|
applySuggestion(s);
|
|
@@ -3335,7 +3335,7 @@ ArrayField.displayName = "ArrayField";
|
|
|
3335
3335
|
* The component combines the functionality of ArrayField and ObjectField to handle
|
|
3336
3336
|
* complex nested data structures commonly found in blockchain contracts.
|
|
3337
3337
|
*/
|
|
3338
|
-
function ArrayObjectField({ id, label, helperText, control, name, width = "full", validation, components = [], minItems = 0, maxItems, renderProperty, collapsible = true, defaultCollapsed = false, readOnly,
|
|
3338
|
+
function ArrayObjectField({ id, label, helperText, control, name, width = "full", validation, components = [], minItems = 0, maxItems, renderProperty, collapsible = true, defaultCollapsed = false, readOnly, typeMapping, contractSchema }) {
|
|
3339
3339
|
const isRequired = !!validation?.required;
|
|
3340
3340
|
const errorId = `${id}-error`;
|
|
3341
3341
|
const descriptionId = `${id}-description`;
|
|
@@ -3452,8 +3452,8 @@ function ArrayObjectField({ id, label, helperText, control, name, width = "full"
|
|
|
3452
3452
|
}), !isCollapsed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3453
3453
|
className: "space-y-4 mt-4",
|
|
3454
3454
|
children: components.map((component) => {
|
|
3455
|
-
if (!
|
|
3456
|
-
const generatedField =
|
|
3455
|
+
if (!typeMapping) throw new Error(`ArrayObjectField: No typeMapping capability provided for field generation. Cannot generate field for "${component.name}"`);
|
|
3456
|
+
const generatedField = typeMapping.generateDefaultField(component, contractSchema);
|
|
3457
3457
|
const propertyField = {
|
|
3458
3458
|
...generatedField,
|
|
3459
3459
|
id: `${id}-${index}-${component.name}`,
|
|
@@ -4549,15 +4549,15 @@ function FileUploadField({ id, label, placeholder = "Drop your file here or clic
|
|
|
4549
4549
|
},
|
|
4550
4550
|
className: `
|
|
4551
4551
|
relative rounded-lg border-2 border-dashed transition-all duration-200
|
|
4552
|
-
${isDragOver ? "border-
|
|
4552
|
+
${isDragOver ? "border-selected bg-selected/5" : hasError ? "border-destructive bg-destructive/5" : fileName ? "border-border bg-muted/30" : "border-border bg-background hover:border-selected/50 hover:bg-muted/50"}
|
|
4553
4553
|
${readOnly || isProcessing ? "cursor-not-allowed opacity-60" : fileName ? "cursor-default" : "cursor-pointer"}
|
|
4554
4554
|
p-6
|
|
4555
4555
|
`,
|
|
4556
4556
|
children: !fileName ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4557
4557
|
className: "flex flex-col items-center justify-center gap-3 text-center",
|
|
4558
4558
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4559
|
-
className: `rounded-full p-3 transition-colors ${isDragOver ? "bg-
|
|
4560
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Upload, { className: `h-8 w-8 transition-colors ${isDragOver ? "text-
|
|
4559
|
+
className: `rounded-full p-3 transition-colors ${isDragOver ? "bg-selected/10" : "bg-muted"}`,
|
|
4560
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Upload, { className: `h-8 w-8 transition-colors ${isDragOver ? "text-selected" : "text-muted-foreground"}` })
|
|
4561
4561
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4562
4562
|
className: "space-y-1",
|
|
4563
4563
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
@@ -5166,7 +5166,7 @@ NumberField.displayName = "NumberField";
|
|
|
5166
5166
|
* The component reuses existing field components for individual properties,
|
|
5167
5167
|
* maintaining consistency across the form system while supporting complex nested structures.
|
|
5168
5168
|
*/
|
|
5169
|
-
function ObjectField({ id, label, helperText, control, name, width = "full", validation, components = [], renderProperty, showCard = true, readOnly,
|
|
5169
|
+
function ObjectField({ id, label, helperText, control, name, width = "full", validation, components = [], renderProperty, showCard = true, readOnly, typeMapping, contractSchema }) {
|
|
5170
5170
|
const isRequired = !!validation?.required;
|
|
5171
5171
|
const errorId = `${id}-error`;
|
|
5172
5172
|
const descriptionId = `${id}-description`;
|
|
@@ -5193,8 +5193,8 @@ function ObjectField({ id, label, helperText, control, name, width = "full", val
|
|
|
5193
5193
|
className: "text-muted-foreground text-sm",
|
|
5194
5194
|
children: "No properties defined for this object"
|
|
5195
5195
|
}) : components.map((component) => {
|
|
5196
|
-
if (!
|
|
5197
|
-
const generatedField =
|
|
5196
|
+
if (!typeMapping) throw new Error(`ObjectField: No typeMapping capability provided for field generation. Cannot generate field for "${component.name}"`);
|
|
5197
|
+
const generatedField = typeMapping.generateDefaultField(component, contractSchema);
|
|
5198
5198
|
const propertyField = {
|
|
5199
5199
|
...generatedField,
|
|
5200
5200
|
id: `${id}-${component.name}`,
|
|
@@ -5442,7 +5442,7 @@ function RadioField({ id, label, helperText, control, name, width = "full", vali
|
|
|
5442
5442
|
const isDisabled = option.disabled;
|
|
5443
5443
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
5444
5444
|
htmlFor: optionId,
|
|
5445
|
-
className: `group relative flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-all duration-150 ${isDisabled ? "cursor-not-allowed opacity-50" : "hover:bg-muted/50"} ${isSelected && !hasError ? "bg-
|
|
5445
|
+
className: `group relative flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-all duration-150 ${isDisabled ? "cursor-not-allowed opacity-50" : "hover:bg-muted/50"} ${isSelected && !hasError ? "bg-selected/5" : ""}`,
|
|
5446
5446
|
children: [
|
|
5447
5447
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
5448
5448
|
type: "radio",
|
|
@@ -5456,13 +5456,13 @@ function RadioField({ id, label, helperText, control, name, width = "full", vali
|
|
|
5456
5456
|
}),
|
|
5457
5457
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5458
5458
|
className: "relative flex size-4 items-center justify-center",
|
|
5459
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `absolute size-4 rounded-full border-2 transition-all duration-150 ${isSelected ? hasError ? "border-destructive bg-destructive/10" : "border-
|
|
5459
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `absolute size-4 rounded-full border-2 transition-all duration-150 ${isSelected ? hasError ? "border-destructive bg-destructive/10" : "border-selected bg-selected/10" : hasError ? "border-destructive/50" : "border-muted-foreground/40 group-hover:border-muted-foreground/60"} ${!isDisabled && "group-hover:scale-105"}` }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `absolute size-1.5 rounded-full transition-all duration-150 ${isSelected ? hasError ? "bg-destructive scale-100 opacity-100" : "bg-selected scale-100 opacity-100" : "scale-0 opacity-0"}` })]
|
|
5460
5460
|
}),
|
|
5461
5461
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
5462
5462
|
className: `text-sm transition-colors duration-150 ${isDisabled ? "text-muted-foreground" : isSelected ? hasError ? "text-destructive font-medium" : "text-foreground font-medium" : "text-foreground"}`,
|
|
5463
5463
|
children: option.label
|
|
5464
5464
|
}),
|
|
5465
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `absolute -inset-1 rounded-lg ring-2 ring-
|
|
5465
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `absolute -inset-1 rounded-lg ring-2 ring-selected ring-offset-2 ring-offset-background transition-opacity duration-150 ${isSelected && !isDisabled ? "opacity-0 focus-within:opacity-100" : "opacity-0"}` })
|
|
5466
5466
|
]
|
|
5467
5467
|
}, option.value);
|
|
5468
5468
|
})
|
|
@@ -6216,19 +6216,19 @@ function useNetworkErrors() {
|
|
|
6216
6216
|
return context;
|
|
6217
6217
|
}
|
|
6218
6218
|
/**
|
|
6219
|
-
* Hook for reporting network errors for a specific
|
|
6219
|
+
* Hook for reporting network errors for a specific runtime-bound capability
|
|
6220
6220
|
*/
|
|
6221
|
-
function useNetworkErrorReporter(
|
|
6221
|
+
function useNetworkErrorReporter(capability) {
|
|
6222
6222
|
const { reportNetworkError } = useNetworkErrors();
|
|
6223
6223
|
return {
|
|
6224
6224
|
reportRpcError: (0, react.useCallback)((message) => {
|
|
6225
|
-
if (!
|
|
6226
|
-
reportNetworkError("rpc",
|
|
6227
|
-
}, [
|
|
6225
|
+
if (!capability) return;
|
|
6226
|
+
reportNetworkError("rpc", capability.networkConfig.id, capability.networkConfig.name, message);
|
|
6227
|
+
}, [capability, reportNetworkError]),
|
|
6228
6228
|
reportExplorerError: (0, react.useCallback)((message) => {
|
|
6229
|
-
if (!
|
|
6230
|
-
reportNetworkError("explorer",
|
|
6231
|
-
}, [
|
|
6229
|
+
if (!capability) return;
|
|
6230
|
+
reportNetworkError("explorer", capability.networkConfig.id, capability.networkConfig.name, message);
|
|
6231
|
+
}, [capability, reportNetworkError])
|
|
6232
6232
|
};
|
|
6233
6233
|
}
|
|
6234
6234
|
|
|
@@ -6237,15 +6237,15 @@ function useNetworkErrorReporter(adapter) {
|
|
|
6237
6237
|
/**
|
|
6238
6238
|
* Creates an adapter proxy that intercepts and reports network errors
|
|
6239
6239
|
*/
|
|
6240
|
-
function useNetworkErrorAwareAdapter(
|
|
6240
|
+
function useNetworkErrorAwareAdapter(capability) {
|
|
6241
6241
|
const { reportNetworkError } = useNetworkErrors();
|
|
6242
|
-
const
|
|
6242
|
+
const wrappedCapabilityRef = (0, react.useRef)(null);
|
|
6243
6243
|
(0, react.useEffect)(() => {
|
|
6244
|
-
if (!
|
|
6245
|
-
|
|
6244
|
+
if (!capability) {
|
|
6245
|
+
wrappedCapabilityRef.current = null;
|
|
6246
6246
|
return;
|
|
6247
6247
|
}
|
|
6248
|
-
|
|
6248
|
+
wrappedCapabilityRef.current = new Proxy(capability, { get(target, prop, receiver) {
|
|
6249
6249
|
const value = Reflect.get(target, prop, receiver);
|
|
6250
6250
|
if (typeof value === "function" && (prop === "queryViewFunction" || prop === "loadContract")) return async (...args) => {
|
|
6251
6251
|
try {
|
|
@@ -6259,8 +6259,8 @@ function useNetworkErrorAwareAdapter(adapter) {
|
|
|
6259
6259
|
};
|
|
6260
6260
|
return value;
|
|
6261
6261
|
} });
|
|
6262
|
-
}, [
|
|
6263
|
-
return
|
|
6262
|
+
}, [capability, reportNetworkError]);
|
|
6263
|
+
return wrappedCapabilityRef.current;
|
|
6264
6264
|
}
|
|
6265
6265
|
|
|
6266
6266
|
//#endregion
|