@openzeppelin/ui-components 2.0.1 → 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.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.0.1";
29
+ const VERSION = "2.2.0";
30
30
 
31
31
  //#endregion
32
32
  //#region src/components/ui/accordion.tsx
@@ -2030,7 +2030,9 @@ function WizardStepper(props) {
2030
2030
  * @param props - The props for the WizardNavigation component.
2031
2031
  * @returns A React node representing the navigation component.
2032
2032
  */
2033
- function WizardNavigation({ isFirstStep, isLastStep, canProceed = true, onPrevious, onNext, onCancel, extraActions, nextLabel = "Next", lastStepLabel = "Finish", className }) {
2033
+ function WizardNavigation({ isFirstStep, isLastStep, canProceed = true, onPrevious, onNext, onCancel, extraActions, nextLabel = "Next", lastStepLabel = "Finish", onLastStepSecondary, lastStepSecondaryLabel, lastStepSecondaryDisabled, showLastStepPrimary = true, className }) {
2034
+ const showPrimary = !isLastStep || showLastStepPrimary;
2035
+ const showSecondary = isLastStep && lastStepSecondaryLabel != null && lastStepSecondaryLabel !== "" && onLastStepSecondary != null;
2034
2036
  return /* @__PURE__ */ jsxs("div", {
2035
2037
  className: cn("flex items-center justify-between", className),
2036
2038
  children: [/* @__PURE__ */ jsxs("div", {
@@ -2050,13 +2052,24 @@ function WizardNavigation({ isFirstStep, isLastStep, canProceed = true, onPrevio
2050
2052
  })]
2051
2053
  }), /* @__PURE__ */ jsxs("div", {
2052
2054
  className: "flex gap-2",
2053
- children: [extraActions, /* @__PURE__ */ jsxs(Button, {
2054
- type: "button",
2055
- onClick: onNext,
2056
- disabled: !canProceed,
2057
- className: "gap-2",
2058
- children: [isLastStep ? lastStepLabel : nextLabel, !isLastStep && /* @__PURE__ */ jsx(ChevronRight, { className: "size-4" })]
2059
- })]
2055
+ children: [
2056
+ extraActions,
2057
+ showSecondary && /* @__PURE__ */ jsx(Button, {
2058
+ type: "button",
2059
+ variant: "outline",
2060
+ onClick: onLastStepSecondary,
2061
+ disabled: lastStepSecondaryDisabled ?? false,
2062
+ className: "gap-2",
2063
+ children: lastStepSecondaryLabel
2064
+ }),
2065
+ showPrimary && /* @__PURE__ */ jsxs(Button, {
2066
+ type: "button",
2067
+ onClick: onNext,
2068
+ disabled: !canProceed,
2069
+ className: "gap-2",
2070
+ children: [isLastStep ? lastStepLabel : nextLabel, !isLastStep && /* @__PURE__ */ jsx(ChevronRight, { className: "size-4" })]
2071
+ })
2072
+ ]
2060
2073
  })]
2061
2074
  });
2062
2075
  }
@@ -2286,7 +2299,7 @@ function isScrollableNavigationKey(event) {
2286
2299
 
2287
2300
  //#endregion
2288
2301
  //#region src/components/ui/wizard/WizardLayout.tsx
2289
- function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepIndexProp, onStepChange, onComplete, onCancel, navActions, header, variant, className }) {
2302
+ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepIndexProp, onStepChange, onComplete, onLastStepPrimary, onCancel, nextLabel, lastStepLabel, onLastStepSecondary, lastStepSecondaryLabel, lastStepSecondaryDisabled, hideLastStepPrimary, navActions, header, variant, className }) {
2290
2303
  const safeIndex = getSafeStepIndex(steps.length, currentStepIndex);
2291
2304
  const resolvedFurthestStepIndex = useFurthestStepIndex(safeIndex, furthestStepIndexProp);
2292
2305
  if (steps.length === 0) return null;
@@ -2296,7 +2309,8 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2296
2309
  const canProceed = currentStep?.isValid !== false;
2297
2310
  const handleNext = () => {
2298
2311
  if (isLastStep) {
2299
- onComplete?.();
2312
+ if (onLastStepPrimary) onLastStepPrimary();
2313
+ else onComplete?.();
2300
2314
  return;
2301
2315
  }
2302
2316
  onStepChange(safeIndex + 1);
@@ -2316,7 +2330,13 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2316
2330
  onPrevious: handlePrevious,
2317
2331
  onNext: handleNext,
2318
2332
  onCancel,
2319
- extraActions: navActions
2333
+ extraActions: navActions,
2334
+ nextLabel,
2335
+ lastStepLabel,
2336
+ onLastStepSecondary,
2337
+ lastStepSecondaryLabel,
2338
+ lastStepSecondaryDisabled,
2339
+ showLastStepPrimary: !hideLastStepPrimary
2320
2340
  })
2321
2341
  })
2322
2342
  });
@@ -2366,7 +2386,7 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2366
2386
  })]
2367
2387
  });
2368
2388
  }
2369
- function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onComplete, scrollPadding, className }) {
2389
+ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onComplete, hideScrollableCompleteButton, scrollableCompleteLabel, onScrollableSecondary, scrollableSecondaryLabel, scrollableSecondaryDisabled, scrollPadding, className }) {
2370
2390
  const instanceId = useId();
2371
2391
  const scrollRef = useRef(null);
2372
2392
  const sectionId = useCallback((stepId) => `wizard-section-${instanceId}-${stepId}`, [instanceId]);
@@ -2380,6 +2400,9 @@ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onCom
2380
2400
  });
2381
2401
  if (steps.length === 0) return null;
2382
2402
  const stepDefs = toStepDefs(steps, activeIndex);
2403
+ const showScrollableSecondary = onScrollableSecondary != null && scrollableSecondaryLabel != null && scrollableSecondaryLabel !== "";
2404
+ const showScrollablePrimary = onComplete != null && !hideScrollableCompleteButton;
2405
+ const showScrollableFooter = showScrollableSecondary || showScrollablePrimary;
2383
2406
  return /* @__PURE__ */ jsxs("div", {
2384
2407
  className: cn("flex h-full gap-6", className),
2385
2408
  children: [/* @__PURE__ */ jsx("div", {
@@ -2405,13 +2428,19 @@ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onCom
2405
2428
  children: step.component
2406
2429
  }, step.id))
2407
2430
  }),
2408
- onComplete && /* @__PURE__ */ jsx("div", {
2409
- className: "flex justify-end pt-8",
2410
- children: /* @__PURE__ */ jsx(Button, {
2431
+ showScrollableFooter && /* @__PURE__ */ jsxs("div", {
2432
+ className: "flex justify-end gap-2 pt-8",
2433
+ children: [showScrollableSecondary && /* @__PURE__ */ jsx(Button, {
2434
+ type: "button",
2435
+ variant: "outline",
2436
+ onClick: onScrollableSecondary,
2437
+ disabled: scrollableSecondaryDisabled ?? false,
2438
+ children: scrollableSecondaryLabel
2439
+ }), showScrollablePrimary && /* @__PURE__ */ jsx(Button, {
2411
2440
  type: "button",
2412
2441
  onClick: onComplete,
2413
- children: "Finish"
2414
- })
2442
+ children: scrollableCompleteLabel ?? "Finish"
2443
+ })]
2415
2444
  })
2416
2445
  ]
2417
2446
  })]
@@ -2443,6 +2472,11 @@ function WizardLayout(props) {
2443
2472
  onStepChange: rest.onStepChange,
2444
2473
  header: rest.header,
2445
2474
  onComplete: rest.onComplete,
2475
+ hideScrollableCompleteButton: rest.hideScrollableCompleteButton,
2476
+ scrollableCompleteLabel: rest.scrollableCompleteLabel,
2477
+ onScrollableSecondary: rest.onScrollableSecondary,
2478
+ scrollableSecondaryLabel: rest.scrollableSecondaryLabel,
2479
+ scrollableSecondaryDisabled: rest.scrollableSecondaryDisabled,
2446
2480
  scrollPadding: rest.scrollPadding,
2447
2481
  className: rest.className
2448
2482
  });