@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.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.0.1";
41
+ const VERSION = "2.2.0";
42
42
 
43
43
  //#endregion
44
44
  //#region src/components/ui/accordion.tsx
@@ -2042,7 +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", className }) {
2045
+ function WizardNavigation({ isFirstStep, isLastStep, canProceed = true, onPrevious, onNext, onCancel, extraActions, nextLabel = "Next", lastStepLabel = "Finish", onLastStepSecondary, lastStepSecondaryLabel, lastStepSecondaryDisabled, showLastStepPrimary = true, className }) {
2046
+ const showPrimary = !isLastStep || showLastStepPrimary;
2047
+ const showSecondary = isLastStep && lastStepSecondaryLabel != null && lastStepSecondaryLabel !== "" && onLastStepSecondary != null;
2046
2048
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2047
2049
  className: (0, _openzeppelin_ui_utils.cn)("flex items-center justify-between", className),
2048
2050
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -2062,13 +2064,24 @@ function WizardNavigation({ isFirstStep, isLastStep, canProceed = true, onPrevio
2062
2064
  })]
2063
2065
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2064
2066
  className: "flex gap-2",
2065
- children: [extraActions, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Button, {
2066
- type: "button",
2067
- onClick: onNext,
2068
- disabled: !canProceed,
2069
- className: "gap-2",
2070
- children: [isLastStep ? lastStepLabel : nextLabel, !isLastStep && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "size-4" })]
2071
- })]
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
+ ]
2072
2085
  })]
2073
2086
  });
2074
2087
  }
@@ -2298,7 +2311,7 @@ function isScrollableNavigationKey(event) {
2298
2311
 
2299
2312
  //#endregion
2300
2313
  //#region src/components/ui/wizard/WizardLayout.tsx
2301
- function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepIndexProp, onStepChange, onComplete, onCancel, 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 }) {
2302
2315
  const safeIndex = getSafeStepIndex(steps.length, currentStepIndex);
2303
2316
  const resolvedFurthestStepIndex = useFurthestStepIndex(safeIndex, furthestStepIndexProp);
2304
2317
  if (steps.length === 0) return null;
@@ -2308,7 +2321,8 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2308
2321
  const canProceed = currentStep?.isValid !== false;
2309
2322
  const handleNext = () => {
2310
2323
  if (isLastStep) {
2311
- onComplete?.();
2324
+ if (onLastStepPrimary) onLastStepPrimary();
2325
+ else onComplete?.();
2312
2326
  return;
2313
2327
  }
2314
2328
  onStepChange(safeIndex + 1);
@@ -2328,7 +2342,13 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2328
2342
  onPrevious: handlePrevious,
2329
2343
  onNext: handleNext,
2330
2344
  onCancel,
2331
- extraActions: navActions
2345
+ extraActions: navActions,
2346
+ nextLabel,
2347
+ lastStepLabel,
2348
+ onLastStepSecondary,
2349
+ lastStepSecondaryLabel,
2350
+ lastStepSecondaryDisabled,
2351
+ showLastStepPrimary: !hideLastStepPrimary
2332
2352
  })
2333
2353
  })
2334
2354
  });
@@ -2378,7 +2398,7 @@ function PagedLayout({ steps, currentStepIndex, furthestStepIndex: furthestStepI
2378
2398
  })]
2379
2399
  });
2380
2400
  }
2381
- function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onComplete, scrollPadding, className }) {
2401
+ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onComplete, hideScrollableCompleteButton, scrollableCompleteLabel, onScrollableSecondary, scrollableSecondaryLabel, scrollableSecondaryDisabled, scrollPadding, className }) {
2382
2402
  const instanceId = (0, react.useId)();
2383
2403
  const scrollRef = (0, react.useRef)(null);
2384
2404
  const sectionId = (0, react.useCallback)((stepId) => `wizard-section-${instanceId}-${stepId}`, [instanceId]);
@@ -2392,6 +2412,9 @@ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onCom
2392
2412
  });
2393
2413
  if (steps.length === 0) return null;
2394
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;
2395
2418
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2396
2419
  className: (0, _openzeppelin_ui_utils.cn)("flex h-full gap-6", className),
2397
2420
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -2417,13 +2440,19 @@ function ScrollableLayout({ steps, currentStepIndex, onStepChange, header, onCom
2417
2440
  children: step.component
2418
2441
  }, step.id))
2419
2442
  }),
2420
- onComplete && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2421
- className: "flex justify-end pt-8",
2422
- 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, {
2423
2452
  type: "button",
2424
2453
  onClick: onComplete,
2425
- children: "Finish"
2426
- })
2454
+ children: scrollableCompleteLabel ?? "Finish"
2455
+ })]
2427
2456
  })
2428
2457
  ]
2429
2458
  })]
@@ -2455,6 +2484,11 @@ function WizardLayout(props) {
2455
2484
  onStepChange: rest.onStepChange,
2456
2485
  header: rest.header,
2457
2486
  onComplete: rest.onComplete,
2487
+ hideScrollableCompleteButton: rest.hideScrollableCompleteButton,
2488
+ scrollableCompleteLabel: rest.scrollableCompleteLabel,
2489
+ onScrollableSecondary: rest.onScrollableSecondary,
2490
+ scrollableSecondaryLabel: rest.scrollableSecondaryLabel,
2491
+ scrollableSecondaryDisabled: rest.scrollableSecondaryDisabled,
2458
2492
  scrollPadding: rest.scrollPadding,
2459
2493
  className: rest.className
2460
2494
  });