@openzeppelin/ui-components 1.7.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -26,7 +26,7 @@ import { Toaster as Toaster$1, toast } from "sonner";
26
26
  import { useTheme } from "next-themes";
27
27
 
28
28
  //#region src/version.ts
29
- const VERSION = "1.7.0";
29
+ const VERSION = "2.0.0";
30
30
 
31
31
  //#endregion
32
32
  //#region src/components/ui/accordion.tsx
@@ -2662,13 +2662,13 @@ const MAX_SUGGESTIONS = 5;
2662
2662
  * 2. TransactionForm renders the overall form structure with React Hook Form
2663
2663
  * 3. DynamicFormField selects the appropriate field component (like AddressField) based on field type
2664
2664
  * 4. BaseField provides consistent layout and hook form integration
2665
- * 5. This component handles blockchain address-specific rendering and validation using the passed adapter
2665
+ * 5. This component handles blockchain address-specific rendering and validation using the passed addressing capability
2666
2666
  *
2667
2667
  * The component includes:
2668
2668
  * - Integration with React Hook Form
2669
- * - Blockchain address validation through adapter-provided custom validation
2669
+ * - Blockchain address validation through the provided addressing capability
2670
2670
  * - Automatic error handling and reporting
2671
- * - Chain-agnostic design (validation handled by adapters)
2671
+ * - Chain-agnostic design (validation handled by capabilities)
2672
2672
  * - Full accessibility support with ARIA attributes
2673
2673
  * - Keyboard navigation
2674
2674
  *
@@ -2683,7 +2683,7 @@ const MAX_SUGGESTIONS = 5;
2683
2683
  * The suggestion dropdown includes built-in debouncing, keyboard navigation (Arrow keys,
2684
2684
  * Enter, Escape), click-outside dismissal, and ARIA listbox semantics.
2685
2685
  */
2686
- function AddressField({ id, label, placeholder, helperText, control, name, width = "full", validation, adapter, readOnly, suggestions: suggestionsProp, onSuggestionSelect }) {
2686
+ function AddressField({ id, label, placeholder, helperText, control, name, width = "full", validation, addressing, readOnly, suggestions: suggestionsProp, onSuggestionSelect }) {
2687
2687
  const isRequired = !!validation?.required;
2688
2688
  const errorId = `${id}-error`;
2689
2689
  const descriptionId = `${id}-description`;
@@ -2766,8 +2766,8 @@ function AddressField({ id, label, placeholder, helperText, control, name, width
2766
2766
  if (value === void 0 || value === null || value === "") return validation?.required ? "This field is required" : true;
2767
2767
  const standardValidationResult = validateField(value, validation);
2768
2768
  if (standardValidationResult !== true) return standardValidationResult;
2769
- if (adapter && typeof value === "string") {
2770
- if (!adapter.isValidAddress(value)) return "Invalid address format for the selected chain";
2769
+ if (addressing && typeof value === "string") {
2770
+ if (!addressing.isValidAddress(value)) return "Invalid address format for the selected chain";
2771
2771
  }
2772
2772
  return true;
2773
2773
  } },
@@ -3323,7 +3323,7 @@ ArrayField.displayName = "ArrayField";
3323
3323
  * The component combines the functionality of ArrayField and ObjectField to handle
3324
3324
  * complex nested data structures commonly found in blockchain contracts.
3325
3325
  */
3326
- function ArrayObjectField({ id, label, helperText, control, name, width = "full", validation, components = [], minItems = 0, maxItems, renderProperty, collapsible = true, defaultCollapsed = false, readOnly, adapter, contractSchema }) {
3326
+ function ArrayObjectField({ id, label, helperText, control, name, width = "full", validation, components = [], minItems = 0, maxItems, renderProperty, collapsible = true, defaultCollapsed = false, readOnly, typeMapping, contractSchema }) {
3327
3327
  const isRequired = !!validation?.required;
3328
3328
  const errorId = `${id}-error`;
3329
3329
  const descriptionId = `${id}-description`;
@@ -3440,8 +3440,8 @@ function ArrayObjectField({ id, label, helperText, control, name, width = "full"
3440
3440
  }), !isCollapsed && /* @__PURE__ */ jsx("div", {
3441
3441
  className: "space-y-4 mt-4",
3442
3442
  children: components.map((component) => {
3443
- if (!adapter) throw new Error(`ArrayObjectField: No adapter provided for field generation. Cannot generate field for "${component.name}"`);
3444
- const generatedField = adapter.generateDefaultField(component, contractSchema);
3443
+ if (!typeMapping) throw new Error(`ArrayObjectField: No typeMapping capability provided for field generation. Cannot generate field for "${component.name}"`);
3444
+ const generatedField = typeMapping.generateDefaultField(component, contractSchema);
3445
3445
  const propertyField = {
3446
3446
  ...generatedField,
3447
3447
  id: `${id}-${index}-${component.name}`,
@@ -5154,7 +5154,7 @@ NumberField.displayName = "NumberField";
5154
5154
  * The component reuses existing field components for individual properties,
5155
5155
  * maintaining consistency across the form system while supporting complex nested structures.
5156
5156
  */
5157
- function ObjectField({ id, label, helperText, control, name, width = "full", validation, components = [], renderProperty, showCard = true, readOnly, adapter, contractSchema }) {
5157
+ function ObjectField({ id, label, helperText, control, name, width = "full", validation, components = [], renderProperty, showCard = true, readOnly, typeMapping, contractSchema }) {
5158
5158
  const isRequired = !!validation?.required;
5159
5159
  const errorId = `${id}-error`;
5160
5160
  const descriptionId = `${id}-description`;
@@ -5181,8 +5181,8 @@ function ObjectField({ id, label, helperText, control, name, width = "full", val
5181
5181
  className: "text-muted-foreground text-sm",
5182
5182
  children: "No properties defined for this object"
5183
5183
  }) : components.map((component) => {
5184
- if (!adapter) throw new Error(`ObjectField: No adapter provided for field generation. Cannot generate field for "${component.name}"`);
5185
- const generatedField = adapter.generateDefaultField(component, contractSchema);
5184
+ if (!typeMapping) throw new Error(`ObjectField: No typeMapping capability provided for field generation. Cannot generate field for "${component.name}"`);
5185
+ const generatedField = typeMapping.generateDefaultField(component, contractSchema);
5186
5186
  const propertyField = {
5187
5187
  ...generatedField,
5188
5188
  id: `${id}-${component.name}`,
@@ -6204,19 +6204,19 @@ function useNetworkErrors() {
6204
6204
  return context;
6205
6205
  }
6206
6206
  /**
6207
- * Hook for reporting network errors for a specific adapter
6207
+ * Hook for reporting network errors for a specific runtime-bound capability
6208
6208
  */
6209
- function useNetworkErrorReporter(adapter) {
6209
+ function useNetworkErrorReporter(capability) {
6210
6210
  const { reportNetworkError } = useNetworkErrors();
6211
6211
  return {
6212
6212
  reportRpcError: useCallback((message) => {
6213
- if (!adapter) return;
6214
- reportNetworkError("rpc", adapter.networkConfig.id, adapter.networkConfig.name, message);
6215
- }, [adapter, reportNetworkError]),
6213
+ if (!capability) return;
6214
+ reportNetworkError("rpc", capability.networkConfig.id, capability.networkConfig.name, message);
6215
+ }, [capability, reportNetworkError]),
6216
6216
  reportExplorerError: useCallback((message) => {
6217
- if (!adapter) return;
6218
- reportNetworkError("explorer", adapter.networkConfig.id, adapter.networkConfig.name, message);
6219
- }, [adapter, reportNetworkError])
6217
+ if (!capability) return;
6218
+ reportNetworkError("explorer", capability.networkConfig.id, capability.networkConfig.name, message);
6219
+ }, [capability, reportNetworkError])
6220
6220
  };
6221
6221
  }
6222
6222
 
@@ -6225,15 +6225,15 @@ function useNetworkErrorReporter(adapter) {
6225
6225
  /**
6226
6226
  * Creates an adapter proxy that intercepts and reports network errors
6227
6227
  */
6228
- function useNetworkErrorAwareAdapter(adapter) {
6228
+ function useNetworkErrorAwareAdapter(capability) {
6229
6229
  const { reportNetworkError } = useNetworkErrors();
6230
- const wrappedAdapterRef = useRef(null);
6230
+ const wrappedCapabilityRef = useRef(null);
6231
6231
  useEffect(() => {
6232
- if (!adapter) {
6233
- wrappedAdapterRef.current = null;
6232
+ if (!capability) {
6233
+ wrappedCapabilityRef.current = null;
6234
6234
  return;
6235
6235
  }
6236
- wrappedAdapterRef.current = new Proxy(adapter, { get(target, prop, receiver) {
6236
+ wrappedCapabilityRef.current = new Proxy(capability, { get(target, prop, receiver) {
6237
6237
  const value = Reflect.get(target, prop, receiver);
6238
6238
  if (typeof value === "function" && (prop === "queryViewFunction" || prop === "loadContract")) return async (...args) => {
6239
6239
  try {
@@ -6247,8 +6247,8 @@ function useNetworkErrorAwareAdapter(adapter) {
6247
6247
  };
6248
6248
  return value;
6249
6249
  } });
6250
- }, [adapter, reportNetworkError]);
6251
- return wrappedAdapterRef.current;
6250
+ }, [capability, reportNetworkError]);
6251
+ return wrappedCapabilityRef.current;
6252
6252
  }
6253
6253
 
6254
6254
  //#endregion