@openzeppelin/ui-renderer 1.0.2 → 1.0.4

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/package.json CHANGED
@@ -1,22 +1,25 @@
1
1
  {
2
2
  "name": "@openzeppelin/ui-renderer",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "private": false,
5
5
  "description": "A specialized library for rendering customizable transaction forms for blockchain applications.",
6
6
  "type": "module",
7
7
  "main": "dist/index.cjs",
8
- "module": "dist/index.js",
9
- "types": "dist/index.d.ts",
8
+ "module": "dist/index.mjs",
9
+ "types": "dist/index.d.mts",
10
10
  "exports": {
11
11
  ".": {
12
- "types": "./dist/index.d.ts",
13
- "import": "./dist/index.js",
12
+ "types": {
13
+ "import": "./dist/index.d.mts",
14
+ "require": "./dist/index.d.cts"
15
+ },
16
+ "import": "./dist/index.mjs",
14
17
  "require": "./dist/index.cjs"
15
18
  },
16
19
  "./index.css": "./dist/index.css",
17
20
  "./types/*": {
18
- "types": "./dist/types/*.d.ts",
19
- "import": "./dist/types/*.js",
21
+ "types": "./dist/types/*.d.mts",
22
+ "import": "./dist/types/*.mjs",
20
23
  "require": "./dist/types/*.cjs"
21
24
  },
22
25
  "./package.json": "./package.json"
@@ -58,20 +61,19 @@
58
61
  "lucide-react": "^0.503.0",
59
62
  "react": "^19.2.1",
60
63
  "react-dom": "^19.2.1",
61
- "react-hook-form": "^7.62.0",
64
+ "react-hook-form": "^7.71.1",
62
65
  "tailwind-merge": "^3.3.1",
63
- "@openzeppelin/ui-types": "^1.0.0",
64
- "@openzeppelin/ui-components": "^1.0.1",
65
- "@openzeppelin/ui-utils": "^1.0.0",
66
- "@openzeppelin/ui-react": "^1.0.0"
66
+ "@openzeppelin/ui-types": "^1.10.0",
67
+ "@openzeppelin/ui-components": "^1.3.0",
68
+ "@openzeppelin/ui-utils": "^1.3.0",
69
+ "@openzeppelin/ui-react": "^1.1.0"
67
70
  },
68
71
  "devDependencies": {
69
- "tsdown": "^0.12.5",
70
72
  "@testing-library/jest-dom": "^6.6.4",
71
73
  "@testing-library/react": "^16.3.0",
72
74
  "@testing-library/user-event": "^14.6.1",
73
- "@types/node": "^22.15.32",
74
- "@types/react": "^19.1.9",
75
+ "@types/node": "^22.19.7",
76
+ "@types/react": "^19.2.8",
75
77
  "@types/react-dom": "^19.1.7",
76
78
  "@vitejs/plugin-react": "^4.7.0",
77
79
  "jsdom": "^26.1.0",
@@ -79,8 +81,7 @@
79
81
  "vitest": "^3.2.4"
80
82
  },
81
83
  "scripts": {
82
- "build": "tsdown && pnpm build:dts-fix",
83
- "build:dts-fix": "cd dist && for f in index-*.d.ts; do [ -f \"$f\" ] && cp \"$f\" index.d.ts; done && for f in index-*.d.cts; do [ -f \"$f\" ] && cp \"$f\" index.d.cts; done || true",
84
+ "build": "tsdown",
84
85
  "clean": "rm -rf dist tsconfig.tsbuildinfo",
85
86
  "typecheck": "tsc --noEmit",
86
87
  "test": "vitest run",
@@ -1,353 +0,0 @@
1
- import { ContractAdapter, ContractFunction, ContractSchema, ExecutionConfig, FieldTransforms, FieldType, FormFieldType, FormValues, FullContractAdapter, NetworkConfig, TransactionFormProps } from "@openzeppelin/ui-types";
2
- import React$1, { JSX } from "react";
3
- import { Control } from "react-hook-form";
4
- import { ButtonProps } from "@openzeppelin/ui-components";
5
-
6
- //#region src/types/RendererConfig.d.ts
7
-
8
- /**
9
- * Types related to renderer configuration
10
- */
11
- /**
12
- * Configuration for the renderer package
13
- * This interface defines dependencies and settings for the renderer
14
- * that will be used when exporting form projects.
15
- */
16
- interface RendererConfig {
17
- /**
18
- * Core dependencies required for all renderer projects
19
- */
20
- coreDependencies: Record<string, string>;
21
- /**
22
- * Field-specific dependencies required for different field types
23
- */
24
- fieldDependencies: Record<string, {
25
- /**
26
- * Runtime dependencies needed for the field type
27
- */
28
- runtimeDependencies: Record<string, string>;
29
- /**
30
- * Development dependencies needed for the field type
31
- */
32
- devDependencies?: Record<string, string>;
33
- }>;
34
- }
35
- /**
36
- * Dependencies for a specific field type
37
- */
38
- //#endregion
39
- //#region src/config.d.ts
40
- /**
41
- * Configuration for the renderer package
42
- * Used by the export system to determine dependencies for exported forms
43
- */
44
- declare const rendererConfig: RendererConfig;
45
- //# sourceMappingURL=config.d.ts.map
46
-
47
- //#endregion
48
- //#region src/components/TransactionForm.d.ts
49
- /**
50
- * Transaction Form Component
51
- *
52
- * This is the main entry point for the app rendering system. It represents the top level of
53
- * the app rendering architecture:
54
- *
55
- * 1. TransactionForm receives a schema and adapter from the transaction builder app
56
- * 2. It sets up React Hook Form for state management and validation
57
- * 3. It renders fields dynamically using the DynamicFormField component
58
- * 4. Provides wallet connection UI (demo implementation)
59
- * 5. On submission, it processes data through the adapter before passing to handlers
60
- *
61
- * Note: The previewMode prop is currently used only for demo purposes and does not affect
62
- * the visibility of wallet connection or transaction execution UI. In the future, it will be used
63
- * to enable/disable actual blockchain interactions without changing the UI structure.
64
- *
65
- * @returns The rendered form component
66
- */
67
- declare function TransactionForm({
68
- schema,
69
- contractSchema,
70
- adapter,
71
- isWalletConnected,
72
- executionConfig
73
- }: TransactionFormProps): React.ReactElement;
74
- //# sourceMappingURL=TransactionForm.d.ts.map
75
- //#endregion
76
- //#region src/utils/formUtils.d.ts
77
- /**
78
- * Parameter constraints for validation and default value generation
79
- */
80
- interface ParameterConstraints {
81
- required?: boolean;
82
- min?: number;
83
- max?: number;
84
- minLength?: number;
85
- maxLength?: number;
86
- pattern?: string;
87
- }
88
- /**
89
- * Validate a field value against validation rules
90
- */
91
- declare function validateField(value: unknown, validation?: {
92
- required?: boolean;
93
- min?: number;
94
- max?: number;
95
- pattern?: string;
96
- }): string | null;
97
- /**
98
- * Creates a transform for address fields
99
- *
100
- * @param adapter The blockchain adapter to use for validation
101
- * @returns Transform functions for address fields
102
- */
103
- declare function createAddressTransform(adapter: ContractAdapter): FieldTransforms<string>;
104
- /**
105
- * Creates a transform for number fields
106
- *
107
- * @returns Transform functions for number fields
108
- */
109
- declare function createNumberTransform(): FieldTransforms<number>;
110
- /**
111
- * Creates a transform for bigint fields (large integers beyond JS Number precision)
112
- *
113
- * @returns Transform functions for bigint fields
114
- */
115
- declare function createBigIntTransform(): FieldTransforms<string>;
116
- /**
117
- * Creates a transform for boolean fields
118
- *
119
- * @returns Transform functions for boolean fields
120
- */
121
- declare function createBooleanTransform(): FieldTransforms<boolean>;
122
- /**
123
- * Creates a transform for complex type fields (arrays, objects, etc.)
124
- *
125
- * @returns Transform functions for complex fields
126
- */
127
- declare function createComplexTypeTransform(): FieldTransforms<unknown>;
128
- /**
129
- * Creates a transform for text fields
130
- *
131
- * @returns Transform functions for text-based fields
132
- */
133
- declare function createTextTransform(): FieldTransforms<string>;
134
- /**
135
- * Creates a transform function based on field type
136
- *
137
- * @param fieldType The type of field to create transforms for
138
- * @param adapter Optional adapter for address validation
139
- * @returns Transform functions for the field type
140
- */
141
- declare function createTransformForFieldType(fieldType: FieldType, adapter?: ContractAdapter): FieldTransforms<unknown>;
142
- /**
143
- * Generate a default value for a given field type based on parameter constraints
144
- */
145
- declare function generateDefaultValue(parameterType: string, constraints?: Partial<ParameterConstraints>): unknown;
146
- /**
147
- * Returns the appropriate default value based on field type
148
- */
149
- declare function getDefaultValueByFieldType(fieldType: FieldType): string | boolean | number;
150
- /**
151
- * Creates a complete default values object for form initialization
152
- * Ensures all fields have appropriate default values to avoid React controlled/uncontrolled input warnings
153
- *
154
- * @param fields The form field definitions
155
- * @param existingDefaults Any existing default values to preserve
156
- * @returns A complete form values object with no undefined values
157
- */
158
- declare function createDefaultFormValues(fields: FormFieldType[] | undefined, existingDefaults?: Record<string, unknown>): FormValues;
159
- /**
160
- * Creates a transform for array fields
161
- *
162
- * @returns Transform functions for array fields
163
- */
164
- declare function createArrayTransform(): FieldTransforms<unknown[]>;
165
- /**
166
- * Creates a transform for object fields
167
- *
168
- * @returns Transform functions for object fields
169
- */
170
- declare function createObjectTransform(): FieldTransforms<Record<string, unknown>>;
171
- /**
172
- * Creates a transform for array-object fields
173
- *
174
- * @returns Transform functions for array-object fields
175
- */
176
- declare function createArrayObjectTransform(): FieldTransforms<Record<string, unknown>[]>;
177
- //# sourceMappingURL=formUtils.d.ts.map
178
- //#endregion
179
- //#region src/components/DynamicFormField.d.ts
180
- /**
181
- * Props for the DynamicFormField component
182
- */
183
- interface DynamicFormFieldProps {
184
- /**
185
- * The field configuration to render
186
- */
187
- field: FormFieldType;
188
- /**
189
- * The React Hook Form control
190
- */
191
- control: Control<FormValues>;
192
- /**
193
- * The adapter for chain-specific validation and formatting
194
- */
195
- adapter: ContractAdapter;
196
- /**
197
- * Optional contract schema for nested metadata lookups
198
- */
199
- contractSchema?: ContractSchema;
200
- /**
201
- * The field error message, if any (Kept for potential direct use, though RHF handles it)
202
- */
203
- error?: string;
204
- }
205
- /**
206
- * Dynamic Form Field Component
207
- *
208
- * Renders the appropriate field component based on the field type defined in the form schema.
209
- * This component is part of the app rendering system architecture where:
210
- * 1. Form schemas are generated from contract functions using adapters
211
- * 2. The schemas are rendered using the TransactionForm component
212
- * 3. TransactionForm uses DynamicFormField to render appropriate field components based on the schema
213
- *
214
- * The field components (TextField, NumberField, AddressField, etc.) are specifically designed
215
- * for React Hook Form integration and should not be used as standalone components.
216
- *
217
- * @returns The rendered form field component or null if the field should not be visible
218
- */
219
- declare function DynamicFormField({
220
- field,
221
- control,
222
- adapter,
223
- contractSchema
224
- }: DynamicFormFieldProps): React$1.ReactElement | null;
225
- //#endregion
226
- //#region src/components/transaction/TransactionExecuteButton.d.ts
227
- interface TransactionExecuteButtonProps {
228
- /**
229
- * Whether the wallet is connected
230
- */
231
- isWalletConnected: boolean;
232
- /**
233
- * Whether a transaction is currently being submitted
234
- */
235
- isSubmitting: boolean;
236
- /**
237
- * Whether the form is valid
238
- */
239
- isFormValid: boolean;
240
- /**
241
- * Button variant
242
- */
243
- variant?: ButtonProps['variant'];
244
- /**
245
- * Optional function details to determine if local execution is possible
246
- * Functions with stateMutability === 'pure' can execute locally without wallet
247
- */
248
- functionDetails?: ContractFunction;
249
- /**
250
- * Whether this function can execute locally without wallet connection
251
- * If true, the wallet connection check is bypassed
252
- */
253
- canExecuteLocally?: boolean;
254
- }
255
- /**
256
- * TransactionExecuteButton Component
257
- *
258
- * Displays a button for executing a transaction, which is disabled if the wallet is not connected,
259
- * the form is invalid, or a transaction is currently being submitted.
260
- *
261
- * @param props The component props
262
- * @returns A React component
263
- */
264
- declare function TransactionExecuteButton({
265
- isWalletConnected,
266
- isSubmitting,
267
- isFormValid,
268
- variant,
269
- functionDetails,
270
- canExecuteLocally
271
- }: TransactionExecuteButtonProps): React.ReactElement;
272
- //# sourceMappingURL=TransactionExecuteButton.d.ts.map
273
- //#endregion
274
- //#region src/components/ContractStateWidget/ContractStateWidget.d.ts
275
- interface ContractStateWidgetProps {
276
- contractSchema: ContractSchema | null;
277
- contractAddress: string | null;
278
- adapter: FullContractAdapter;
279
- isVisible?: boolean;
280
- onToggle?: () => void;
281
- className?: string;
282
- error?: Error | null;
283
- }
284
- /**
285
- * ContractStateWidget - Compact widget for displaying contract state
286
- * Shows contract state by allowing users to query simple view functions (no parameters)
287
- */
288
- declare function ContractStateWidget({
289
- contractSchema,
290
- contractAddress,
291
- adapter,
292
- isVisible,
293
- onToggle,
294
- className,
295
- error
296
- }: ContractStateWidgetProps): JSX.Element | null;
297
- //#endregion
298
- //#region src/components/ContractActionBar/ContractActionBar.d.ts
299
- interface ContractActionBarProps {
300
- networkConfig: NetworkConfig | null;
301
- contractAddress?: string | null;
302
- onToggleContractState?: () => void;
303
- isWidgetExpanded?: boolean;
304
- children?: React$1.ReactNode;
305
- className?: string;
306
- }
307
- /**
308
- * ContractActionBar - A composable action bar for contract forms
309
- * Displays network information and contract state toggle button
310
- * Can be extended with additional actions via children
311
- */
312
- declare function ContractActionBar({
313
- networkConfig,
314
- contractAddress,
315
- onToggleContractState,
316
- isWidgetExpanded,
317
- children,
318
- className
319
- }: ContractActionBarProps): React$1.ReactElement | null;
320
- //#endregion
321
- //#region src/components/ExecutionConfigDisplay/ExecutionConfigDisplay.d.ts
322
- interface ExecutionConfigDisplayProps {
323
- executionConfig: ExecutionConfig;
324
- adapter?: ContractAdapter;
325
- error?: string | null;
326
- connectedWalletAddress?: string;
327
- onRuntimeApiKeyChange?: (apiKey: string) => void;
328
- }
329
- declare const ExecutionConfigDisplay: React$1.FC<ExecutionConfigDisplayProps>;
330
- //#endregion
331
- //#region src/components/network/NetworkSettingsDialog.d.ts
332
- interface Props {
333
- isOpen: boolean;
334
- onOpenChange: (open: boolean) => void;
335
- networkConfig: {
336
- id: string;
337
- name: string;
338
- } | null;
339
- adapter: ContractAdapter | null;
340
- }
341
- declare const NetworkSettingsDialog: React$1.FC<Props>;
342
- //#endregion
343
- //#region src/components/WalletConnectionWithSettings.d.ts
344
- /**
345
- * Enhanced wallet connection header with network settings menu.
346
- * Used in exported apps to provide access to RPC and Explorer configuration.
347
- */
348
- declare const WalletConnectionWithSettings: React$1.FC;
349
- //# sourceMappingURL=WalletConnectionWithSettings.d.ts.map
350
-
351
- //#endregion
352
- export { ContractActionBar, ContractStateWidget, DynamicFormField, ExecutionConfigDisplay, NetworkSettingsDialog, ParameterConstraints, type RendererConfig, TransactionExecuteButton, TransactionForm, WalletConnectionWithSettings, createAddressTransform, createArrayObjectTransform, createArrayTransform, createBigIntTransform, createBooleanTransform, createComplexTypeTransform, createDefaultFormValues, createNumberTransform, createObjectTransform, createTextTransform, createTransformForFieldType, generateDefaultValue, getDefaultValueByFieldType, rendererConfig, validateField };
353
- //# sourceMappingURL=index-f9GrUqL8.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-f9GrUqL8.d.cts","names":[],"sources":["../src/types/RendererConfig.ts","../src/config.ts","../src/components/TransactionForm.tsx","../src/utils/formUtils.ts","../src/components/DynamicFormField.tsx","../src/components/transaction/TransactionExecuteButton.tsx","../src/components/ContractStateWidget/ContractStateWidget.tsx","../src/components/ContractActionBar/ContractActionBar.tsx","../src/components/ExecutionConfigDisplay/ExecutionConfigDisplay.tsx","../src/components/network/NetworkSettingsDialog.tsx","../src/components/WalletConnectionWithSettings.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AASA;;AAIoB,UAJH,cAAA,CAIG;;;;EAKO,gBAAA,EALP,MAKO,CAAA,MAAA,EAAA,MAAA,CAAA;;;;ECJd,iBA4EZ,EDxEoB,MCwEpB,CAAA,MA5E4B,EAAA;;;;IC6Bb,mBAAe,EFnBJ,MEmBI,CAAA,MAAA,EAAA,MAAA,CAAA;IAAA;;;IAG7B,eAAA,CAAA,EFjBsB,MEiBtB,CAAA,MAAA,EAAA,MAAA,CAAA;;;;;;;;;;;;cDhCW,gBAAgB;;;;;;;;;;ADL7B;;;;;;;;;;ACKA;;;iBC6BgB,eAAA;;;;;;GAMb,uBAAuB,KAAA,CAAM;AANhC;;;;;;AFzBqB,UGLJ,oBAAA,CHKI;EAAM,QAAA,CAAA,EAAA,OAAA;;;;ECJd,SAAA,CAAA,EAAA,MA4EZ;;;;AC/CD;;AACE,iBCnBc,aAAA,CDmBd,KAAA,EAAA,OAAA,EAAA,WAAA,EAAA;UACA,CAAA,EAAA,OAAA;KACA,CAAA,EAAA,MAAA;KACA,CAAA,EAAA,MAAA;SACA,CAAA,EAAA,MAAA;UACC,GAAA,IAAA;;;;;;ACpCH;AAYgB,iBAiCA,sBAAA,CAjCa,OAAA,EAiCmB,eAjCnB,CAAA,EAiCqC,eAjCrC,CAAA,MAAA,CAAA;AAiC7B;;;;;AAqBgB,iBAAA,qBAAA,CAAA,CAAyB,EAAA,eAAe,CAAA,MAAA,CAAA;AAkBxD;AAuBA;AAuBA;AA6BA;AAuBA;AAA2C,iBAlG3B,qBAAA,CAAA,CAkG2B,EAlGF,eAkGE,CAAA,MAAA,CAAA;;;;;AA+C3C;AAAoC,iBA1HpB,sBAAA,CAAA,CA0HoB,EA1HM,eA0HN,CAAA,OAAA,CAAA;;;;AAuBpC;AAmBA;AAAuC,iBA7IvB,0BA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