@openzeppelin/ui-utils 1.0.0 → 1.1.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/dist/index.cjs +159 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +114 -26
- package/dist/index.d.cts.map +1 -0
- package/dist/{index-DNIN-Squ.d.cts → index.d.mts} +114 -26
- package/dist/index.d.mts.map +1 -0
- package/dist/{index.js → index.mjs} +157 -3
- package/dist/index.mjs.map +1 -0
- package/package.json +10 -8
- package/dist/index-DNIN-Squ.d.cts.map +0 -1
- package/dist/index-qy1AQMhr.d.ts +0 -1205
- package/dist/index-qy1AQMhr.d.ts.map +0 -1
- package/dist/index.d.ts +0 -1205
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -216,7 +216,7 @@ const logger = Logger.getInstance();
|
|
|
216
216
|
* Determine whether logging should be enabled by default.
|
|
217
217
|
*
|
|
218
218
|
* - In Vite/browser contexts, use `import.meta.env.DEV`.
|
|
219
|
-
* - In Node/
|
|
219
|
+
* - In Node/tsdown contexts, use `process.env.NODE_ENV`.
|
|
220
220
|
*
|
|
221
221
|
* Defaults to disabled outside development to avoid runtime overhead and noise.
|
|
222
222
|
*/
|
|
@@ -2102,6 +2102,160 @@ function formatAccessControlError(error) {
|
|
|
2102
2102
|
return message;
|
|
2103
2103
|
}
|
|
2104
2104
|
|
|
2105
|
+
//#endregion
|
|
2106
|
+
//#region src/walletComponentSizing.ts
|
|
2107
|
+
/**
|
|
2108
|
+
* Maps WalletComponentSize to Button component props and styling.
|
|
2109
|
+
* Used for ConnectButton and similar button-based wallet components.
|
|
2110
|
+
*
|
|
2111
|
+
* @param walletSize - The wallet component size ('sm' | 'default' | 'lg' | 'xl')
|
|
2112
|
+
* @returns Button size props including component size, className overrides, and icon size
|
|
2113
|
+
*
|
|
2114
|
+
* @example
|
|
2115
|
+
* ```tsx
|
|
2116
|
+
* const sizeProps = getWalletButtonSizeProps(size);
|
|
2117
|
+
* <Button size={sizeProps.size} className={sizeProps.className}>
|
|
2118
|
+
* <Icon className={sizeProps.iconSize} />
|
|
2119
|
+
* </Button>
|
|
2120
|
+
* ```
|
|
2121
|
+
*/
|
|
2122
|
+
function getWalletButtonSizeProps(walletSize) {
|
|
2123
|
+
switch (walletSize) {
|
|
2124
|
+
case "sm": return {
|
|
2125
|
+
size: "sm",
|
|
2126
|
+
className: "h-7 px-2 text-[11px]",
|
|
2127
|
+
iconSize: "size-3"
|
|
2128
|
+
};
|
|
2129
|
+
case "lg": return {
|
|
2130
|
+
size: "lg",
|
|
2131
|
+
className: "h-11 px-5",
|
|
2132
|
+
iconSize: "size-5"
|
|
2133
|
+
};
|
|
2134
|
+
case "xl": return {
|
|
2135
|
+
size: "lg",
|
|
2136
|
+
className: "h-12 px-6 text-base",
|
|
2137
|
+
iconSize: "size-5"
|
|
2138
|
+
};
|
|
2139
|
+
case "default":
|
|
2140
|
+
default: return {
|
|
2141
|
+
size: "default",
|
|
2142
|
+
className: "h-9 px-4 text-sm",
|
|
2143
|
+
iconSize: "size-4"
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
/**
|
|
2148
|
+
* Maps WalletComponentSize to AccountDisplay component styling.
|
|
2149
|
+
* Provides text sizes and icon button dimensions for account info display.
|
|
2150
|
+
*
|
|
2151
|
+
* @param walletSize - The wallet component size ('sm' | 'default' | 'lg' | 'xl')
|
|
2152
|
+
* @returns Account display size props for text, subtitle, and disconnect button
|
|
2153
|
+
*
|
|
2154
|
+
* @example
|
|
2155
|
+
* ```tsx
|
|
2156
|
+
* const sizeProps = getWalletAccountDisplaySizeProps(size);
|
|
2157
|
+
* <span className={sizeProps.textSize}>{address}</span>
|
|
2158
|
+
* <Button className={sizeProps.iconButtonSize}>
|
|
2159
|
+
* <LogOut className={sizeProps.iconSize} />
|
|
2160
|
+
* </Button>
|
|
2161
|
+
* ```
|
|
2162
|
+
*/
|
|
2163
|
+
function getWalletAccountDisplaySizeProps(walletSize) {
|
|
2164
|
+
switch (walletSize) {
|
|
2165
|
+
case "sm": return {
|
|
2166
|
+
textSize: "text-[11px]",
|
|
2167
|
+
subTextSize: "text-[8px]",
|
|
2168
|
+
iconButtonSize: "size-5",
|
|
2169
|
+
iconSize: "size-3"
|
|
2170
|
+
};
|
|
2171
|
+
case "lg": return {
|
|
2172
|
+
textSize: "text-base",
|
|
2173
|
+
subTextSize: "text-xs",
|
|
2174
|
+
iconButtonSize: "size-8",
|
|
2175
|
+
iconSize: "size-4"
|
|
2176
|
+
};
|
|
2177
|
+
case "xl": return {
|
|
2178
|
+
textSize: "text-lg",
|
|
2179
|
+
subTextSize: "text-sm",
|
|
2180
|
+
iconButtonSize: "size-10",
|
|
2181
|
+
iconSize: "size-5"
|
|
2182
|
+
};
|
|
2183
|
+
case "default":
|
|
2184
|
+
default: return {
|
|
2185
|
+
textSize: "text-xs",
|
|
2186
|
+
subTextSize: "text-[9px]",
|
|
2187
|
+
iconButtonSize: "size-6",
|
|
2188
|
+
iconSize: "size-3.5"
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
/**
|
|
2193
|
+
* Maps WalletComponentSize to NetworkSwitcher component styling.
|
|
2194
|
+
* Provides sizing for select trigger, items, and loading indicator.
|
|
2195
|
+
*
|
|
2196
|
+
* @param walletSize - The wallet component size ('sm' | 'default' | 'lg' | 'xl')
|
|
2197
|
+
* @returns Network switcher size props for select components
|
|
2198
|
+
*
|
|
2199
|
+
* @example
|
|
2200
|
+
* ```tsx
|
|
2201
|
+
* const sizeProps = getWalletNetworkSwitcherSizeProps(size);
|
|
2202
|
+
* <SelectTrigger className={sizeProps.triggerClassName}>
|
|
2203
|
+
* ...
|
|
2204
|
+
* </SelectTrigger>
|
|
2205
|
+
* <Loader2 className={sizeProps.loaderSize} />
|
|
2206
|
+
* ```
|
|
2207
|
+
*/
|
|
2208
|
+
function getWalletNetworkSwitcherSizeProps(walletSize) {
|
|
2209
|
+
switch (walletSize) {
|
|
2210
|
+
case "sm": return {
|
|
2211
|
+
triggerClassName: "h-8 text-xs px-2 min-w-[90px] max-w-[120px]",
|
|
2212
|
+
itemClassName: "text-xs py-1.5",
|
|
2213
|
+
loaderSize: "h-3 w-3"
|
|
2214
|
+
};
|
|
2215
|
+
case "lg": return {
|
|
2216
|
+
triggerClassName: "h-10 text-sm px-3 min-w-[120px] max-w-[180px]",
|
|
2217
|
+
itemClassName: "text-sm py-2",
|
|
2218
|
+
loaderSize: "h-4 w-4"
|
|
2219
|
+
};
|
|
2220
|
+
case "xl": return {
|
|
2221
|
+
triggerClassName: "h-12 text-base px-4 min-w-[140px] max-w-[200px]",
|
|
2222
|
+
itemClassName: "text-base py-2.5",
|
|
2223
|
+
loaderSize: "h-5 w-5"
|
|
2224
|
+
};
|
|
2225
|
+
case "default":
|
|
2226
|
+
default: return {
|
|
2227
|
+
triggerClassName: "h-9 text-sm px-3 min-w-[100px] max-w-[150px]",
|
|
2228
|
+
itemClassName: "text-sm py-1.5",
|
|
2229
|
+
loaderSize: "h-3.5 w-3.5"
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
/**
|
|
2234
|
+
* Maps WalletComponentVariant to NetworkSwitcher SelectTrigger styling.
|
|
2235
|
+
* Since Select components don't have a native variant prop like Button,
|
|
2236
|
+
* this maps variants to appropriate Tailwind CSS classes.
|
|
2237
|
+
*
|
|
2238
|
+
* @param variant - The wallet component variant ('default' | 'outline' | 'ghost' | 'secondary')
|
|
2239
|
+
* @returns CSS class string for the SelectTrigger
|
|
2240
|
+
*
|
|
2241
|
+
* @example
|
|
2242
|
+
* ```tsx
|
|
2243
|
+
* const variantClassName = getWalletNetworkSwitcherVariantClassName(variant);
|
|
2244
|
+
* <SelectTrigger className={cn(sizeProps.triggerClassName, variantClassName)}>
|
|
2245
|
+
* ...
|
|
2246
|
+
* </SelectTrigger>
|
|
2247
|
+
* ```
|
|
2248
|
+
*/
|
|
2249
|
+
function getWalletNetworkSwitcherVariantClassName(variant) {
|
|
2250
|
+
switch (variant) {
|
|
2251
|
+
case "ghost": return "border-transparent bg-transparent hover:bg-accent";
|
|
2252
|
+
case "secondary": return "border-secondary bg-secondary/10 hover:bg-secondary/20";
|
|
2253
|
+
case "outline": return "border-input bg-transparent hover:bg-accent";
|
|
2254
|
+
case "default":
|
|
2255
|
+
default: return "";
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2105
2259
|
//#endregion
|
|
2106
2260
|
exports.AnalyticsService = AnalyticsService;
|
|
2107
2261
|
exports.AppConfigService = AppConfigService;
|
|
@@ -2134,6 +2288,10 @@ exports.getForcedService = getForcedService;
|
|
|
2134
2288
|
exports.getInvalidUrlMessage = getInvalidUrlMessage;
|
|
2135
2289
|
exports.getMissingRequiredContractInputs = getMissingRequiredContractInputs;
|
|
2136
2290
|
exports.getTotalMemberCount = getTotalMemberCount;
|
|
2291
|
+
exports.getWalletAccountDisplaySizeProps = getWalletAccountDisplaySizeProps;
|
|
2292
|
+
exports.getWalletButtonSizeProps = getWalletButtonSizeProps;
|
|
2293
|
+
exports.getWalletNetworkSwitcherSizeProps = getWalletNetworkSwitcherSizeProps;
|
|
2294
|
+
exports.getWalletNetworkSwitcherVariantClassName = getWalletNetworkSwitcherVariantClassName;
|
|
2137
2295
|
exports.hasMissingRequiredContractInputs = hasMissingRequiredContractInputs;
|
|
2138
2296
|
exports.hasOwnership = hasOwnership;
|
|
2139
2297
|
exports.hasRoles = hasRoles;
|