@openzeppelin/ui-components 2.2.0 → 2.3.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 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 = "2.2.0";
41
+ const VERSION = "2.3.1";
42
42
 
43
43
  //#endregion
44
44
  //#region src/components/ui/accordion.tsx
@@ -190,15 +190,19 @@ function usePrefersHover() {
190
190
  *
191
191
  * // Inline variant (no chip background) — useful inside wallet bars
192
192
  * <AddressDisplay address="0x742d35Cc..." variant="inline" showTooltip showCopyButton />
193
+ *
194
+ * // Truncate only when an alias/label is present (full address when unlabeled)
195
+ * <AddressDisplay address="G..." truncateWhenLabeled />
193
196
  * ```
194
197
  */
195
- function AddressDisplay({ address, truncate = true, untruncateOnHover = false, startChars = 6, endChars = 4, showCopyButton = false, showCopyButtonOnHover = false, explorerUrl, label: labelProp, onLabelEdit: onLabelEditProp, networkId, disableLabel = false, showTooltip = false, variant = "chip", className, onPointerEnter, onPointerLeave, onMouseEnter, onMouseLeave, onClick, ...props }) {
198
+ function AddressDisplay({ address, truncate: truncateProp, truncateWhenLabeled = false, untruncateOnHover = false, startChars = 6, endChars = 4, showCopyButton = false, showCopyButtonOnHover = false, explorerUrl, label: labelProp, onLabelEdit: onLabelEditProp, networkId, disableLabel = false, showTooltip = false, variant = "chip", className, onPointerEnter, onPointerLeave, onMouseEnter, onMouseLeave, onClick, ...props }) {
196
199
  const [copied, setCopied] = react.useState(false);
197
200
  const [isHovered, setIsHovered] = react.useState(false);
198
201
  const copyTimeoutRef = react.useRef(null);
199
202
  const prefersHover = usePrefersHover();
200
203
  const resolver = react.useContext(AddressLabelContext);
201
204
  const resolvedLabel = disableLabel ? void 0 : labelProp ?? resolver?.resolveLabel(address, networkId);
205
+ const effectiveTruncate = truncateProp !== void 0 ? truncateProp : truncateWhenLabeled ? Boolean(resolvedLabel) : true;
202
206
  const contextEditHandler = react.useCallback(() => {
203
207
  resolver?.onEditLabel?.(address, networkId);
204
208
  }, [
@@ -207,10 +211,10 @@ function AddressDisplay({ address, truncate = true, untruncateOnHover = false, s
207
211
  networkId
208
212
  ]);
209
213
  const editHandler = disableLabel ? void 0 : onLabelEditProp ?? (resolver?.onEditLabel ? contextEditHandler : void 0);
210
- const canUntruncate = untruncateOnHover && truncate && !showTooltip;
211
- const showFullAddress = !truncate || canUntruncate && isHovered;
214
+ const canUntruncate = untruncateOnHover && effectiveTruncate && !showTooltip;
215
+ const showFullAddress = !effectiveTruncate || canUntruncate && isHovered;
212
216
  const displayAddress = showFullAddress ? address : (0, _openzeppelin_ui_utils.truncateMiddle)(address, startChars, endChars);
213
- const addressTextClassName = (0, _openzeppelin_ui_utils.cn)(!showFullAddress && "truncate", (showFullAddress || !truncate) && "break-all");
217
+ const addressTextClassName = (0, _openzeppelin_ui_utils.cn)(!showFullAddress && "truncate", (showFullAddress || !effectiveTruncate) && "break-all");
214
218
  const expandInteractionClassName = canUntruncate && !prefersHover ? "cursor-pointer" : void 0;
215
219
  const handlePointerEnter = (e) => {
216
220
  if (canUntruncate && prefersHover) setIsHovered(true);
@@ -272,7 +276,7 @@ function AddressDisplay({ address, truncate = true, untruncateOnHover = false, s
272
276
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Pencil, { className: "h-3.5 w-3.5" })
273
277
  })
274
278
  ] });
275
- const shouldShowTooltip = showTooltip && truncate;
279
+ const shouldShowTooltip = showTooltip && effectiveTruncate;
276
280
  const wrapWithTooltip = (content) => {
277
281
  if (!shouldShowTooltip) return content;
278
282
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipProvider, {
@@ -2314,6 +2318,12 @@ function isScrollableNavigationKey(event) {
2314
2318
  function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepIndexProp, onStepChange, onComplete, onLastStepPrimary, onCancel, nextLabel, lastStepLabel, onLastStepSecondary, lastStepSecondaryLabel, lastStepSecondaryDisabled, hideLastStepPrimary, navActions, header, variant, className }) {
2315
2319
  const safeIndex = getSafeStepIndex(steps.length, currentStepIndex);
2316
2320
  const resolvedFurthestStepIndex = useFurthestStepIndex(safeIndex, furthestStepIndexProp);
2321
+ const stepBodyScrollRef = (0, react.useRef)(null);
2322
+ (0, react.useLayoutEffect)(() => {
2323
+ const el = stepBodyScrollRef.current;
2324
+ if (!el) return;
2325
+ el.scrollTop = 0;
2326
+ }, [safeIndex]);
2317
2327
  if (steps.length === 0) return null;
2318
2328
  const isFirstStep = safeIndex === 0;
2319
2329
  const isLastStep = safeIndex === steps.length - 1;
@@ -2367,6 +2377,7 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2367
2377
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2368
2378
  className: "flex min-w-0 flex-1 flex-col overflow-hidden",
2369
2379
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2380
+ ref: stepBodyScrollRef,
2370
2381
  className: "flex-1 overflow-y-auto p-8",
2371
2382
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2372
2383
  className: "mx-auto max-w-5xl",
@@ -2389,6 +2400,7 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2389
2400
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2390
2401
  className: "flex min-w-0 flex-1 flex-col overflow-hidden",
2391
2402
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2403
+ ref: stepBodyScrollRef,
2392
2404
  className: "flex-1 overflow-y-auto p-8",
2393
2405
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2394
2406
  className: "mx-auto max-w-5xl",