@openzeppelin/ui-components 2.1.0 → 2.2.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.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.1.0";
41
+ const VERSION = "2.2.0";
42
42
 
43
43
  //#endregion
44
44
  //#region src/components/ui/accordion.tsx
@@ -2042,8 +2042,9 @@ function WizardStepper(props) {
2042
2042
  * @param props - The props for the WizardNavigation component.
2043
2043
  * @returns A React node representing the navigation component.
2044
2044
  */
2045
- function WizardNavigation({ isFirstStep, isLastStep, canProceed = true, onPrevious, onNext, onCancel, extraActions, nextLabel = "Next", lastStepLabel = "Finish", showLastStepPrimary = true, className }) {
2045
+ function WizardNavigation({ isFirstStep, isLastStep, canProceed = true, onPrevious, onNext, onCancel, extraActions, nextLabel = "Next", lastStepLabel = "Finish", onLastStepSecondary, lastStepSecondaryLabel, lastStepSecondaryDisabled, showLastStepPrimary = true, className }) {
2046
2046
  const showPrimary = !isLastStep || showLastStepPrimary;
2047
+ const showSecondary = isLastStep && lastStepSecondaryLabel != null && lastStepSecondaryLabel !== "" && onLastStepSecondary != null;
2047
2048
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2048
2049
  className: (0, _openzeppelin_ui_utils.cn)("flex items-center justify-between", className),
2049
2050
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -2063,13 +2064,24 @@ function WizardNavigation({ isFirstStep, isLastStep, canProceed = true, onPrevio
2063
2064
  })]
2064
2065
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2065
2066
  className: "flex gap-2",
2066
- children: [extraActions, showPrimary && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Button, {
2067
- type: "button",
2068
- onClick: onNext,
2069
- disabled: !canProceed,
2070
- className: "gap-2",
2071
- children: [isLastStep ? lastStepLabel : nextLabel, !isLastStep && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "size-4" })]
2072
- })]
2067
+ children: [
2068
+ extraActions,
2069
+ showSecondary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2070
+ type: "button",
2071
+ variant: "outline",
2072
+ onClick: onLastStepSecondary,
2073
+ disabled: lastStepSecondaryDisabled ?? false,
2074
+ className: "gap-2",
2075
+ children: lastStepSecondaryLabel
2076
+ }),
2077
+ showPrimary && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Button, {
2078
+ type: "button",
2079
+ onClick: onNext,
2080
+ disabled: !canProceed,
2081
+ className: "gap-2",
2082
+ children: [isLastStep ? lastStepLabel : nextLabel, !isLastStep && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "size-4" })]
2083
+ })
2084
+ ]
2073
2085
  })]
2074
2086
  });
2075
2087
  }
@@ -2299,7 +2311,7 @@ function isScrollableNavigationKey(event) {
2299
2311
 
2300
2312
  //#endregion
2301
2313
  //#region src/components/ui/wizard/WizardLayout.tsx
2302
- function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepIndexProp, onStepChange, onComplete, onLastStepPrimary, onCancel, nextLabel, lastStepLabel, hideLastStepPrimary, navActions, header, variant, className }) {
2314
+ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepIndexProp, onStepChange, onComplete, onLastStepPrimary, onCancel, nextLabel, lastStepLabel, onLastStepSecondary, lastStepSecondaryLabel, lastStepSecondaryDisabled, hideLastStepPrimary, navActions, header, variant, className }) {
2303
2315
  const safeIndex = getSafeStepIndex(steps.length, currentStepIndex);
2304
2316
  const resolvedFurthestStepIndex = useFurthestStepIndex(safeIndex, furthestStepIndexProp);
2305
2317
  if (steps.length === 0) return null;
@@ -2333,6 +2345,9 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2333
2345
  extraActions: navActions,
2334
2346
  nextLabel,
2335
2347
  lastStepLabel,
2348
+ onLastStepSecondary,
2349
+ lastStepSecondaryLabel,
2350
+ lastStepSecondaryDisabled,
2336
2351
  showLastStepPrimary: !hideLastStepPrimary
2337
2352
  })
2338
2353
  })
@@ -2383,7 +2398,7 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2383
2398
  })]
2384
2399
  });
2385
2400
  }
2386
- function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onComplete, hideScrollableCompleteButton, scrollableCompleteLabel, scrollPadding, className }) {
2401
+ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onComplete, hideScrollableCompleteButton, scrollableCompleteLabel, onScrollableSecondary, scrollableSecondaryLabel, scrollableSecondaryDisabled, scrollPadding, className }) {
2387
2402
  const instanceId = (0, react.useId)();
2388
2403
  const scrollRef = (0, react.useRef)(null);
2389
2404
  const sectionId = (0, react.useCallback)((stepId) => `wizard-section-${instanceId}-${stepId}`, [instanceId]);
@@ -2397,6 +2412,9 @@ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onCom
2397
2412
  });
2398
2413
  if (steps.length === 0) return null;
2399
2414
  const stepDefs = toStepDefs(steps, activeIndex);
2415
+ const showScrollableSecondary = onScrollableSecondary != null && scrollableSecondaryLabel != null && scrollableSecondaryLabel !== "";
2416
+ const showScrollablePrimary = onComplete != null && !hideScrollableCompleteButton;
2417
+ const showScrollableFooter = showScrollableSecondary || showScrollablePrimary;
2400
2418
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2401
2419
  className: (0, _openzeppelin_ui_utils.cn)("flex h-full gap-6", className),
2402
2420
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -2422,13 +2440,19 @@ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onCom
2422
2440
  children: step.component
2423
2441
  }, step.id))
2424
2442
  }),
2425
- onComplete && !hideScrollableCompleteButton && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2426
- className: "flex justify-end pt-8",
2427
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2443
+ showScrollableFooter && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2444
+ className: "flex justify-end gap-2 pt-8",
2445
+ children: [showScrollableSecondary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2446
+ type: "button",
2447
+ variant: "outline",
2448
+ onClick: onScrollableSecondary,
2449
+ disabled: scrollableSecondaryDisabled ?? false,
2450
+ children: scrollableSecondaryLabel
2451
+ }), showScrollablePrimary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2428
2452
  type: "button",
2429
2453
  onClick: onComplete,
2430
2454
  children: scrollableCompleteLabel ?? "Finish"
2431
- })
2455
+ })]
2432
2456
  })
2433
2457
  ]
2434
2458
  })]
@@ -2462,6 +2486,9 @@ function WizardLayout(props) {
2462
2486
  onComplete: rest.onComplete,
2463
2487
  hideScrollableCompleteButton: rest.hideScrollableCompleteButton,
2464
2488
  scrollableCompleteLabel: rest.scrollableCompleteLabel,
2489
+ onScrollableSecondary: rest.onScrollableSecondary,
2490
+ scrollableSecondaryLabel: rest.scrollableSecondaryLabel,
2491
+ scrollableSecondaryDisabled: rest.scrollableSecondaryDisabled,
2465
2492
  scrollPadding: rest.scrollPadding,
2466
2493
  className: rest.className
2467
2494
  });