@openzeppelin/ui-renderer 1.1.1 → 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/README.md +69 -28
- package/dist/index.cjs +179 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -25
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +45 -25
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +177 -105
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -81,11 +81,11 @@ Renders form fields dynamically based on field type configuration.
|
|
|
81
81
|
|
|
82
82
|
## Type System
|
|
83
83
|
|
|
84
|
-
This package uses type definitions from `@openzeppelin/ui-types
|
|
84
|
+
This package uses type definitions from `@openzeppelin/ui-types`. Form and state widgets take **capability intersections** (for example `TransactionFormCapabilities`, `QueryCapability` + `SchemaCapability`) rather than a single monolithic adapter type:
|
|
85
85
|
|
|
86
86
|
```tsx
|
|
87
87
|
import { TransactionForm } from '@openzeppelin/ui-renderer';
|
|
88
|
-
import type {
|
|
88
|
+
import type { FormValues, RenderFormSchema, TransactionFormCapabilities } from '@openzeppelin/ui-types';
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
## Component Styling
|
|
@@ -95,21 +95,41 @@ This package renders forms using UI components from `@openzeppelin/ui-components
|
|
|
95
95
|
Styling relies on the consuming application to:
|
|
96
96
|
|
|
97
97
|
1. **Include Tailwind CSS** in its build process.
|
|
98
|
-
2. **Configure Tailwind** to scan the
|
|
98
|
+
2. **Configure Tailwind** to scan the OpenZeppelin UI and adapter packages that provide class names.
|
|
99
99
|
3. **Import the shared theme** from `@openzeppelin/ui-styles`.
|
|
100
100
|
|
|
101
|
+
For consumer apps that use `@openzeppelin/ui-dev-cli`, the recommended workflow is:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
pnpm exec oz-ui-dev tailwind doctor --project "$PWD"
|
|
105
|
+
pnpm exec oz-ui-dev tailwind fix --project "$PWD"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
That generates a managed `oz-tailwind.generated.css` file so Tailwind v4 always sees the required `@source` entries.
|
|
109
|
+
|
|
110
|
+
If you need to wire Tailwind manually, use explicit `@source` directives instead of a bare import:
|
|
111
|
+
|
|
101
112
|
```css
|
|
113
|
+
@layer base, components, utilities;
|
|
114
|
+
|
|
115
|
+
@import 'tailwindcss' source(none);
|
|
116
|
+
@source "../node_modules/@openzeppelin/ui-components";
|
|
117
|
+
@source "../node_modules/@openzeppelin/ui-react";
|
|
118
|
+
@source "../node_modules/@openzeppelin/ui-renderer";
|
|
119
|
+
@source "../node_modules/@openzeppelin/ui-styles";
|
|
120
|
+
@source "../node_modules/@openzeppelin/ui-utils";
|
|
102
121
|
@import '@openzeppelin/ui-styles/global.css';
|
|
103
|
-
@import 'tailwindcss';
|
|
104
122
|
```
|
|
105
123
|
|
|
106
124
|
## Usage
|
|
107
125
|
|
|
108
126
|
### Transaction Form
|
|
109
127
|
|
|
128
|
+
`TransactionForm` expects an `adapter` prop typed as **`TransactionFormCapabilities`** (execution, schema, type mapping, wallet-related pieces, etc., depending on profile). Derive it from your active `EcosystemRuntime` (for example by intersecting the capabilities your app uses) or pass the object your ecosystem exposes for transaction authoring.
|
|
129
|
+
|
|
110
130
|
```tsx
|
|
111
131
|
import { TransactionForm } from '@openzeppelin/ui-renderer';
|
|
112
|
-
import type {
|
|
132
|
+
import type { RenderFormSchema, TransactionFormCapabilities } from '@openzeppelin/ui-types';
|
|
113
133
|
|
|
114
134
|
const schema: RenderFormSchema = {
|
|
115
135
|
id: 'transfer-form',
|
|
@@ -122,13 +142,19 @@ const schema: RenderFormSchema = {
|
|
|
122
142
|
submitButton: { text: 'Transfer', loadingText: 'Transferring...' },
|
|
123
143
|
};
|
|
124
144
|
|
|
125
|
-
function App(
|
|
145
|
+
function App({
|
|
146
|
+
adapter,
|
|
147
|
+
contractSchema,
|
|
148
|
+
}: {
|
|
149
|
+
adapter: TransactionFormCapabilities;
|
|
150
|
+
contractSchema: import('@openzeppelin/ui-types').ContractSchema;
|
|
151
|
+
}) {
|
|
126
152
|
return (
|
|
127
153
|
<TransactionForm
|
|
128
154
|
schema={schema}
|
|
155
|
+
contractSchema={contractSchema}
|
|
129
156
|
adapter={adapter}
|
|
130
|
-
|
|
131
|
-
onSubmit={handleSubmit}
|
|
157
|
+
onTransactionSuccess={handleTransactionSuccess}
|
|
132
158
|
/>
|
|
133
159
|
);
|
|
134
160
|
}
|
|
@@ -136,15 +162,24 @@ function App() {
|
|
|
136
162
|
|
|
137
163
|
### Contract State Widget
|
|
138
164
|
|
|
165
|
+
`ContractStateWidget` extends **`ContractStateCapabilityProps`**: pass `query` and `schema` capabilities (from the active runtime) so view calls use the same network and schema pipeline as the rest of the app.
|
|
166
|
+
|
|
139
167
|
```tsx
|
|
140
168
|
import { ContractStateWidget } from '@openzeppelin/ui-renderer';
|
|
141
169
|
|
|
142
|
-
function ContractView(
|
|
170
|
+
function ContractView({
|
|
171
|
+
query,
|
|
172
|
+
schema,
|
|
173
|
+
}: {
|
|
174
|
+
query: import('@openzeppelin/ui-types').QueryCapability;
|
|
175
|
+
schema: import('@openzeppelin/ui-types').SchemaCapability;
|
|
176
|
+
}) {
|
|
143
177
|
return (
|
|
144
178
|
<ContractStateWidget
|
|
145
|
-
contractSchema={
|
|
179
|
+
contractSchema={contractSchema}
|
|
146
180
|
contractAddress="0x..."
|
|
147
|
-
|
|
181
|
+
query={query}
|
|
182
|
+
schema={schema}
|
|
148
183
|
isVisible={true}
|
|
149
184
|
/>
|
|
150
185
|
);
|
|
@@ -171,26 +206,32 @@ function FormHeader() {
|
|
|
171
206
|
|
|
172
207
|
### `<TransactionForm>`
|
|
173
208
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
|
177
|
-
|
|
|
178
|
-
| `
|
|
179
|
-
| `
|
|
180
|
-
| `
|
|
181
|
-
| `
|
|
182
|
-
| `
|
|
183
|
-
| `
|
|
209
|
+
See **`TransactionFormProps`** in `@openzeppelin/ui-types` for the full contract. Important props:
|
|
210
|
+
|
|
211
|
+
| Prop | Type | Description |
|
|
212
|
+
| --------------------- | ---------------------------- | -------------------------------------------------- |
|
|
213
|
+
| `schema` | `RenderFormSchema` | Form layout and fields |
|
|
214
|
+
| `contractSchema` | `ContractSchema` (optional)| ABI / function metadata for the target call |
|
|
215
|
+
| `adapter` | `TransactionFormCapabilities`| Capability bundle for signing, mapping, execution |
|
|
216
|
+
| `executionConfig` | `ExecutionConfig` (optional) | EOA vs relayer and related options |
|
|
217
|
+
| `onTransactionSuccess`| callback (optional) | Fires after a successful transaction lifecycle |
|
|
218
|
+
| `isWalletConnected` | `boolean` (optional) | Whether a wallet session is present |
|
|
219
|
+
|
|
220
|
+
Network configuration is taken from **`adapter.networkConfig`** (see `RuntimeCapability`).
|
|
184
221
|
|
|
185
222
|
### `<ContractStateWidget>`
|
|
186
223
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
|
190
|
-
|
|
|
191
|
-
| `
|
|
192
|
-
| `
|
|
193
|
-
| `
|
|
224
|
+
Implements **`ContractStateCapabilityProps`** plus display props:
|
|
225
|
+
|
|
226
|
+
| Prop | Type | Description |
|
|
227
|
+
| ----------------- | ------------------------ | ------------------------------------------------ |
|
|
228
|
+
| `contractSchema` | `ContractSchema \| null` | Contract schema with view functions |
|
|
229
|
+
| `contractAddress` | `string \| null` | Deployed contract address |
|
|
230
|
+
| `query` | `QueryCapability` | View/query capability (includes `networkConfig`) |
|
|
231
|
+
| `schema` | `SchemaCapability` | Schema capability for the active network |
|
|
232
|
+
| `isVisible` | `boolean` | (Optional) Controls widget visibility |
|
|
233
|
+
| `onToggle` | `() => void` | (Optional) Toggle callback |
|
|
234
|
+
| `error` | `Error \| null` | (Optional) External error to surface |
|
|
194
235
|
|
|
195
236
|
### `<ContractActionBar>`
|
|
196
237
|
|