@openzeppelin/ui-components 2.1.0 → 2.3.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 = "2.1.0";
29
+ const VERSION = "2.3.0";
30
30
 
31
31
  //#endregion
32
32
  //#region src/components/ui/accordion.tsx
@@ -178,15 +178,19 @@ function usePrefersHover() {
178
178
  *
179
179
  * // Inline variant (no chip background) — useful inside wallet bars
180
180
  * <AddressDisplay address="0x742d35Cc..." variant="inline" showTooltip showCopyButton />
181
+ *
182
+ * // Truncate only when an alias/label is present (full address when unlabeled)
183
+ * <AddressDisplay address="G..." truncateWhenLabeled />
181
184
  * ```
182
185
  */
183
- 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 }) {
186
+ 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 }) {
184
187
  const [copied, setCopied] = React$1.useState(false);
185
188
  const [isHovered, setIsHovered] = React$1.useState(false);
186
189
  const copyTimeoutRef = React$1.useRef(null);
187
190
  const prefersHover = usePrefersHover();
188
191
  const resolver = React$1.useContext(AddressLabelContext);
189
192
  const resolvedLabel = disableLabel ? void 0 : labelProp ?? resolver?.resolveLabel(address, networkId);
193
+ const effectiveTruncate = truncateProp !== void 0 ? truncateProp : truncateWhenLabeled ? Boolean(resolvedLabel) : true;
190
194
  const contextEditHandler = React$1.useCallback(() => {
191
195
  resolver?.onEditLabel?.(address, networkId);
192
196
  }, [
@@ -195,10 +199,10 @@ function AddressDisplay({ address, truncate = true, untruncateOnHover = false, s
195
199
  networkId
196
200
  ]);
197
201
  const editHandler = disableLabel ? void 0 : onLabelEditProp ?? (resolver?.onEditLabel ? contextEditHandler : void 0);
198
- const canUntruncate = untruncateOnHover && truncate && !showTooltip;
199
- const showFullAddress = !truncate || canUntruncate && isHovered;
202
+ const canUntruncate = untruncateOnHover && effectiveTruncate && !showTooltip;
203
+ const showFullAddress = !effectiveTruncate || canUntruncate && isHovered;
200
204
  const displayAddress = showFullAddress ? address : truncateMiddle(address, startChars, endChars);
201
- const addressTextClassName = cn(!showFullAddress && "truncate", (showFullAddress || !truncate) && "break-all");
205
+ const addressTextClassName = cn(!showFullAddress && "truncate", (showFullAddress || !effectiveTruncate) && "break-all");
202
206
  const expandInteractionClassName = canUntruncate && !prefersHover ? "cursor-pointer" : void 0;
203
207
  const handlePointerEnter = (e) => {
204
208
  if (canUntruncate && prefersHover) setIsHovered(true);
@@ -260,7 +264,7 @@ function AddressDisplay({ address, truncate = true, untruncateOnHover = false, s
260
264
  children: /* @__PURE__ */ jsx(Pencil, { className: "h-3.5 w-3.5" })
261
265
  })
262
266
  ] });
263
- const shouldShowTooltip = showTooltip && truncate;
267
+ const shouldShowTooltip = showTooltip && effectiveTruncate;
264
268
  const wrapWithTooltip = (content) => {
265
269
  if (!shouldShowTooltip) return content;
266
270
  return /* @__PURE__ */ jsx(TooltipProvider, {
@@ -2030,8 +2034,9 @@ function WizardStepper(props) {
2030
2034
  * @param props - The props for the WizardNavigation component.
2031
2035
  * @returns A React node representing the navigation component.
2032
2036
  */
2033
- function WizardNavigation({ isFirstStep, isLastStep, canProceed = true, onPrevious, onNext, onCancel, extraActions, nextLabel = "Next", lastStepLabel = "Finish", showLastStepPrimary = true, className }) {
2037
+ function WizardNavigation({ isFirstStep, isLastStep, canProceed = true, onPrevious, onNext, onCancel, extraActions, nextLabel = "Next", lastStepLabel = "Finish", onLastStepSecondary, lastStepSecondaryLabel, lastStepSecondaryDisabled, showLastStepPrimary = true, className }) {
2034
2038
  const showPrimary = !isLastStep || showLastStepPrimary;
2039
+ const showSecondary = isLastStep && lastStepSecondaryLabel != null && lastStepSecondaryLabel !== "" && onLastStepSecondary != null;
2035
2040
  return /* @__PURE__ */ jsxs("div", {
2036
2041
  className: cn("flex items-center justify-between", className),
2037
2042
  children: [/* @__PURE__ */ jsxs("div", {
@@ -2051,13 +2056,24 @@ function WizardNavigation({ isFirstStep, isLastStep, canProceed = true, onPrevio
2051
2056
  })]
2052
2057
  }), /* @__PURE__ */ jsxs("div", {
2053
2058
  className: "flex gap-2",
2054
- children: [extraActions, showPrimary && /* @__PURE__ */ jsxs(Button, {
2055
- type: "button",
2056
- onClick: onNext,
2057
- disabled: !canProceed,
2058
- className: "gap-2",
2059
- children: [isLastStep ? lastStepLabel : nextLabel, !isLastStep && /* @__PURE__ */ jsx(ChevronRight, { className: "size-4" })]
2060
- })]
2059
+ children: [
2060
+ extraActions,
2061
+ showSecondary && /* @__PURE__ */ jsx(Button, {
2062
+ type: "button",
2063
+ variant: "outline",
2064
+ onClick: onLastStepSecondary,
2065
+ disabled: lastStepSecondaryDisabled ?? false,
2066
+ className: "gap-2",
2067
+ children: lastStepSecondaryLabel
2068
+ }),
2069
+ showPrimary && /* @__PURE__ */ jsxs(Button, {
2070
+ type: "button",
2071
+ onClick: onNext,
2072
+ disabled: !canProceed,
2073
+ className: "gap-2",
2074
+ children: [isLastStep ? lastStepLabel : nextLabel, !isLastStep && /* @__PURE__ */ jsx(ChevronRight, { className: "size-4" })]
2075
+ })
2076
+ ]
2061
2077
  })]
2062
2078
  });
2063
2079
  }
@@ -2287,7 +2303,7 @@ function isScrollableNavigationKey(event) {
2287
2303
 
2288
2304
  //#endregion
2289
2305
  //#region src/components/ui/wizard/WizardLayout.tsx
2290
- function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepIndexProp, onStepChange, onComplete, onLastStepPrimary, onCancel, nextLabel, lastStepLabel, hideLastStepPrimary, navActions, header, variant, className }) {
2306
+ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepIndexProp, onStepChange, onComplete, onLastStepPrimary, onCancel, nextLabel, lastStepLabel, onLastStepSecondary, lastStepSecondaryLabel, lastStepSecondaryDisabled, hideLastStepPrimary, navActions, header, variant, className }) {
2291
2307
  const safeIndex = getSafeStepIndex(steps.length, currentStepIndex);
2292
2308
  const resolvedFurthestStepIndex = useFurthestStepIndex(safeIndex, furthestStepIndexProp);
2293
2309
  if (steps.length === 0) return null;
@@ -2321,6 +2337,9 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2321
2337
  extraActions: navActions,
2322
2338
  nextLabel,
2323
2339
  lastStepLabel,
2340
+ onLastStepSecondary,
2341
+ lastStepSecondaryLabel,
2342
+ lastStepSecondaryDisabled,
2324
2343
  showLastStepPrimary: !hideLastStepPrimary
2325
2344
  })
2326
2345
  })
@@ -2371,7 +2390,7 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2371
2390
  })]
2372
2391
  });
2373
2392
  }
2374
- function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onComplete, hideScrollableCompleteButton, scrollableCompleteLabel, scrollPadding, className }) {
2393
+ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onComplete, hideScrollableCompleteButton, scrollableCompleteLabel, onScrollableSecondary, scrollableSecondaryLabel, scrollableSecondaryDisabled, scrollPadding, className }) {
2375
2394
  const instanceId = useId();
2376
2395
  const scrollRef = useRef(null);
2377
2396
  const sectionId = useCallback((stepId) => `wizard-section-${instanceId}-${stepId}`, [instanceId]);
@@ -2385,6 +2404,9 @@ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onCom
2385
2404
  });
2386
2405
  if (steps.length === 0) return null;
2387
2406
  const stepDefs = toStepDefs(steps, activeIndex);
2407
+ const showScrollableSecondary = onScrollableSecondary != null && scrollableSecondaryLabel != null && scrollableSecondaryLabel !== "";
2408
+ const showScrollablePrimary = onComplete != null && !hideScrollableCompleteButton;
2409
+ const showScrollableFooter = showScrollableSecondary || showScrollablePrimary;
2388
2410
  return /* @__PURE__ */ jsxs("div", {
2389
2411
  className: cn("flex h-full gap-6", className),
2390
2412
  children: [/* @__PURE__ */ jsx("div", {
@@ -2410,13 +2432,19 @@ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onCom
2410
2432
  children: step.component
2411
2433
  }, step.id))
2412
2434
  }),
2413
- onComplete && !hideScrollableCompleteButton && /* @__PURE__ */ jsx("div", {
2414
- className: "flex justify-end pt-8",
2415
- children: /* @__PURE__ */ jsx(Button, {
2435
+ showScrollableFooter && /* @__PURE__ */ jsxs("div", {
2436
+ className: "flex justify-end gap-2 pt-8",
2437
+ children: [showScrollableSecondary && /* @__PURE__ */ jsx(Button, {
2438
+ type: "button",
2439
+ variant: "outline",
2440
+ onClick: onScrollableSecondary,
2441
+ disabled: scrollableSecondaryDisabled ?? false,
2442
+ children: scrollableSecondaryLabel
2443
+ }), showScrollablePrimary && /* @__PURE__ */ jsx(Button, {
2416
2444
  type: "button",
2417
2445
  onClick: onComplete,
2418
2446
  children: scrollableCompleteLabel ?? "Finish"
2419
- })
2447
+ })]
2420
2448
  })
2421
2449
  ]
2422
2450
  })]
@@ -2450,6 +2478,9 @@ function WizardLayout(props) {
2450
2478
  onComplete: rest.onComplete,
2451
2479
  hideScrollableCompleteButton: rest.hideScrollableCompleteButton,
2452
2480
  scrollableCompleteLabel: rest.scrollableCompleteLabel,
2481
+ onScrollableSecondary: rest.onScrollableSecondary,
2482
+ scrollableSecondaryLabel: rest.scrollableSecondaryLabel,
2483
+ scrollableSecondaryDisabled: rest.scrollableSecondaryDisabled,
2453
2484
  scrollPadding: rest.scrollPadding,
2454
2485
  className: rest.className
2455
2486
  });