@facter/ds-core 1.2.0 → 1.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.d.mts +376 -3
- package/dist/index.d.ts +376 -3
- package/dist/index.js +666 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +659 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -67,7 +67,7 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
67
67
|
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
68
68
|
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
69
69
|
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
70
|
-
secondary: "bg-
|
|
70
|
+
secondary: "bg-primary/15 text-primary hover:bg-primary/25",
|
|
71
71
|
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
72
72
|
link: "text-primary underline-offset-4 hover:underline"
|
|
73
73
|
},
|
|
@@ -6341,6 +6341,660 @@ var Kanban = {
|
|
|
6341
6341
|
Column: KanbanColumn,
|
|
6342
6342
|
Card: KanbanCard
|
|
6343
6343
|
};
|
|
6344
|
+
var WizardContext = React48.createContext(void 0);
|
|
6345
|
+
function useWizardContext() {
|
|
6346
|
+
const context = React48.useContext(WizardContext);
|
|
6347
|
+
if (context === void 0) {
|
|
6348
|
+
throw new Error("useWizardContext must be used within a Wizard component");
|
|
6349
|
+
}
|
|
6350
|
+
return context;
|
|
6351
|
+
}
|
|
6352
|
+
function useWizardContextOptional() {
|
|
6353
|
+
return React48.useContext(WizardContext);
|
|
6354
|
+
}
|
|
6355
|
+
function WizardProvider({
|
|
6356
|
+
children,
|
|
6357
|
+
form,
|
|
6358
|
+
steps,
|
|
6359
|
+
initialStep = 0,
|
|
6360
|
+
onStepChange,
|
|
6361
|
+
validateOnNext = true,
|
|
6362
|
+
allowJumpToStep = false
|
|
6363
|
+
}) {
|
|
6364
|
+
const [completedSteps, setCompletedSteps] = React48.useState(/* @__PURE__ */ new Set());
|
|
6365
|
+
const activeSteps = React48.useMemo(() => {
|
|
6366
|
+
const formValues = form.getValues();
|
|
6367
|
+
return steps.filter((step) => {
|
|
6368
|
+
if (typeof step.isHidden === "function") {
|
|
6369
|
+
return !step.isHidden(formValues);
|
|
6370
|
+
}
|
|
6371
|
+
return !step.isHidden;
|
|
6372
|
+
});
|
|
6373
|
+
}, [steps, form]);
|
|
6374
|
+
const [currentStep, setCurrentStep] = React48.useState(() => {
|
|
6375
|
+
return Math.min(Math.max(0, initialStep), activeSteps.length - 1);
|
|
6376
|
+
});
|
|
6377
|
+
const totalSteps = activeSteps.length;
|
|
6378
|
+
const isFirstStep = currentStep === 0;
|
|
6379
|
+
const isLastStep = currentStep === totalSteps - 1;
|
|
6380
|
+
const progress = totalSteps > 0 ? Math.round((currentStep + 1) / totalSteps * 100) : 0;
|
|
6381
|
+
const currentStepConfig = activeSteps[currentStep];
|
|
6382
|
+
const getStepConfig = React48.useCallback(
|
|
6383
|
+
(index) => activeSteps[index],
|
|
6384
|
+
[activeSteps]
|
|
6385
|
+
);
|
|
6386
|
+
const getStepByName = React48.useCallback(
|
|
6387
|
+
(name) => activeSteps.find((step) => step.name === name || step.id === name),
|
|
6388
|
+
[activeSteps]
|
|
6389
|
+
);
|
|
6390
|
+
const getStepIndexByName = React48.useCallback(
|
|
6391
|
+
(name) => activeSteps.findIndex((step) => step.name === name || step.id === name),
|
|
6392
|
+
[activeSteps]
|
|
6393
|
+
);
|
|
6394
|
+
const isStepCompleted = React48.useCallback(
|
|
6395
|
+
(index) => completedSteps.has(index),
|
|
6396
|
+
[completedSteps]
|
|
6397
|
+
);
|
|
6398
|
+
const hasStepErrors = React48.useCallback(
|
|
6399
|
+
(index) => {
|
|
6400
|
+
const stepConfig = activeSteps[index];
|
|
6401
|
+
if (!stepConfig?.fields) return false;
|
|
6402
|
+
const errors = form.formState.errors;
|
|
6403
|
+
return stepConfig.fields.some((field) => {
|
|
6404
|
+
const fieldPath = field;
|
|
6405
|
+
return fieldPath in errors;
|
|
6406
|
+
});
|
|
6407
|
+
},
|
|
6408
|
+
[activeSteps, form.formState.errors]
|
|
6409
|
+
);
|
|
6410
|
+
const validateCurrentStep = React48.useCallback(async () => {
|
|
6411
|
+
const stepConfig = currentStepConfig;
|
|
6412
|
+
if (!stepConfig?.validationSchema) {
|
|
6413
|
+
return true;
|
|
6414
|
+
}
|
|
6415
|
+
const formValues = form.getValues();
|
|
6416
|
+
const result = await stepConfig.validationSchema.safeParseAsync(formValues);
|
|
6417
|
+
if (!result.success) {
|
|
6418
|
+
if (stepConfig.fields) {
|
|
6419
|
+
await Promise.all(
|
|
6420
|
+
stepConfig.fields.map((field) => form.trigger(field))
|
|
6421
|
+
);
|
|
6422
|
+
}
|
|
6423
|
+
return false;
|
|
6424
|
+
}
|
|
6425
|
+
if (stepConfig.fields) {
|
|
6426
|
+
stepConfig.fields.forEach((field) => {
|
|
6427
|
+
form.clearErrors(field);
|
|
6428
|
+
});
|
|
6429
|
+
}
|
|
6430
|
+
return true;
|
|
6431
|
+
}, [currentStepConfig, form]);
|
|
6432
|
+
const goToNextStep = React48.useCallback(async () => {
|
|
6433
|
+
if (isLastStep) {
|
|
6434
|
+
return false;
|
|
6435
|
+
}
|
|
6436
|
+
if (validateOnNext) {
|
|
6437
|
+
const isValid = await validateCurrentStep();
|
|
6438
|
+
if (!isValid) {
|
|
6439
|
+
return false;
|
|
6440
|
+
}
|
|
6441
|
+
}
|
|
6442
|
+
setCompletedSteps((prev) => /* @__PURE__ */ new Set([...prev, currentStep]));
|
|
6443
|
+
const nextStep = currentStep + 1;
|
|
6444
|
+
setCurrentStep(nextStep);
|
|
6445
|
+
onStepChange?.(nextStep, "next");
|
|
6446
|
+
return true;
|
|
6447
|
+
}, [isLastStep, validateOnNext, validateCurrentStep, currentStep, onStepChange]);
|
|
6448
|
+
const goToPrevStep = React48.useCallback(() => {
|
|
6449
|
+
if (isFirstStep) {
|
|
6450
|
+
return;
|
|
6451
|
+
}
|
|
6452
|
+
const prevStep = currentStep - 1;
|
|
6453
|
+
setCurrentStep(prevStep);
|
|
6454
|
+
onStepChange?.(prevStep, "prev");
|
|
6455
|
+
}, [isFirstStep, currentStep, onStepChange]);
|
|
6456
|
+
const goToStep = React48.useCallback(
|
|
6457
|
+
async (targetStep) => {
|
|
6458
|
+
if (targetStep < 0 || targetStep >= totalSteps) {
|
|
6459
|
+
return false;
|
|
6460
|
+
}
|
|
6461
|
+
if (!allowJumpToStep && targetStep > currentStep) {
|
|
6462
|
+
for (let i = currentStep; i < targetStep; i++) {
|
|
6463
|
+
if (!completedSteps.has(i)) {
|
|
6464
|
+
return false;
|
|
6465
|
+
}
|
|
6466
|
+
}
|
|
6467
|
+
}
|
|
6468
|
+
if (targetStep < currentStep) {
|
|
6469
|
+
setCurrentStep(targetStep);
|
|
6470
|
+
onStepChange?.(targetStep, "jump");
|
|
6471
|
+
return true;
|
|
6472
|
+
}
|
|
6473
|
+
if (validateOnNext && targetStep > currentStep) {
|
|
6474
|
+
const isValid = await validateCurrentStep();
|
|
6475
|
+
if (!isValid) {
|
|
6476
|
+
return false;
|
|
6477
|
+
}
|
|
6478
|
+
setCompletedSteps((prev) => /* @__PURE__ */ new Set([...prev, currentStep]));
|
|
6479
|
+
}
|
|
6480
|
+
setCurrentStep(targetStep);
|
|
6481
|
+
onStepChange?.(targetStep, "jump");
|
|
6482
|
+
return true;
|
|
6483
|
+
},
|
|
6484
|
+
[totalSteps, allowJumpToStep, currentStep, completedSteps, validateOnNext, validateCurrentStep, onStepChange]
|
|
6485
|
+
);
|
|
6486
|
+
const reset = React48.useCallback(() => {
|
|
6487
|
+
setCurrentStep(Math.min(Math.max(0, initialStep), activeSteps.length - 1));
|
|
6488
|
+
setCompletedSteps(/* @__PURE__ */ new Set());
|
|
6489
|
+
form.reset();
|
|
6490
|
+
}, [initialStep, activeSteps.length, form]);
|
|
6491
|
+
const contextValue = React48.useMemo(
|
|
6492
|
+
() => ({
|
|
6493
|
+
// State
|
|
6494
|
+
currentStep,
|
|
6495
|
+
totalSteps,
|
|
6496
|
+
activeSteps,
|
|
6497
|
+
allSteps: steps,
|
|
6498
|
+
// Computed
|
|
6499
|
+
isFirstStep,
|
|
6500
|
+
isLastStep,
|
|
6501
|
+
progress,
|
|
6502
|
+
// Navigation
|
|
6503
|
+
goToNextStep,
|
|
6504
|
+
goToPrevStep,
|
|
6505
|
+
goToStep,
|
|
6506
|
+
reset,
|
|
6507
|
+
// Validation
|
|
6508
|
+
validateCurrentStep,
|
|
6509
|
+
isStepCompleted,
|
|
6510
|
+
hasStepErrors,
|
|
6511
|
+
// Form
|
|
6512
|
+
form,
|
|
6513
|
+
// Step info
|
|
6514
|
+
currentStepConfig,
|
|
6515
|
+
getStepConfig,
|
|
6516
|
+
getStepByName,
|
|
6517
|
+
getStepIndexByName,
|
|
6518
|
+
// Settings
|
|
6519
|
+
allowJumpToStep
|
|
6520
|
+
}),
|
|
6521
|
+
[
|
|
6522
|
+
currentStep,
|
|
6523
|
+
totalSteps,
|
|
6524
|
+
activeSteps,
|
|
6525
|
+
steps,
|
|
6526
|
+
isFirstStep,
|
|
6527
|
+
isLastStep,
|
|
6528
|
+
progress,
|
|
6529
|
+
goToNextStep,
|
|
6530
|
+
goToPrevStep,
|
|
6531
|
+
goToStep,
|
|
6532
|
+
reset,
|
|
6533
|
+
validateCurrentStep,
|
|
6534
|
+
isStepCompleted,
|
|
6535
|
+
hasStepErrors,
|
|
6536
|
+
form,
|
|
6537
|
+
currentStepConfig,
|
|
6538
|
+
getStepConfig,
|
|
6539
|
+
getStepByName,
|
|
6540
|
+
getStepIndexByName,
|
|
6541
|
+
allowJumpToStep
|
|
6542
|
+
]
|
|
6543
|
+
);
|
|
6544
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WizardContext.Provider, { value: contextValue, children });
|
|
6545
|
+
}
|
|
6546
|
+
var sizeConfig = {
|
|
6547
|
+
sm: {
|
|
6548
|
+
circle: "h-7 w-7 text-xs",
|
|
6549
|
+
icon: "h-3.5 w-3.5",
|
|
6550
|
+
label: "text-xs",
|
|
6551
|
+
description: "text-xs",
|
|
6552
|
+
gap: "gap-1.5"
|
|
6553
|
+
},
|
|
6554
|
+
md: {
|
|
6555
|
+
circle: "h-9 w-9 text-sm",
|
|
6556
|
+
icon: "h-4 w-4",
|
|
6557
|
+
label: "text-sm",
|
|
6558
|
+
description: "text-xs",
|
|
6559
|
+
gap: "gap-2"
|
|
6560
|
+
},
|
|
6561
|
+
lg: {
|
|
6562
|
+
circle: "h-11 w-11 text-base",
|
|
6563
|
+
icon: "h-5 w-5",
|
|
6564
|
+
label: "text-base",
|
|
6565
|
+
description: "text-sm",
|
|
6566
|
+
gap: "gap-2.5"
|
|
6567
|
+
}
|
|
6568
|
+
};
|
|
6569
|
+
var stateStyles = {
|
|
6570
|
+
completed: {
|
|
6571
|
+
circle: "bg-green-500 text-white border-green-500",
|
|
6572
|
+
label: "text-green-600 dark:text-green-400",
|
|
6573
|
+
description: "text-muted-foreground"
|
|
6574
|
+
},
|
|
6575
|
+
current: {
|
|
6576
|
+
circle: "bg-primary text-primary-foreground border-primary ring-4 ring-primary/20",
|
|
6577
|
+
label: "text-primary font-semibold",
|
|
6578
|
+
description: "text-muted-foreground"
|
|
6579
|
+
},
|
|
6580
|
+
pending: {
|
|
6581
|
+
circle: "bg-background text-muted-foreground border-muted-foreground/30",
|
|
6582
|
+
label: "text-muted-foreground",
|
|
6583
|
+
description: "text-muted-foreground/60"
|
|
6584
|
+
},
|
|
6585
|
+
error: {
|
|
6586
|
+
circle: "bg-destructive text-destructive-foreground border-destructive",
|
|
6587
|
+
label: "text-destructive",
|
|
6588
|
+
description: "text-destructive/60"
|
|
6589
|
+
},
|
|
6590
|
+
disabled: {
|
|
6591
|
+
circle: "bg-muted text-muted-foreground/50 border-muted cursor-not-allowed",
|
|
6592
|
+
label: "text-muted-foreground/50",
|
|
6593
|
+
description: "text-muted-foreground/30"
|
|
6594
|
+
}
|
|
6595
|
+
};
|
|
6596
|
+
function WizardStepIndicator({
|
|
6597
|
+
step,
|
|
6598
|
+
index,
|
|
6599
|
+
state,
|
|
6600
|
+
showNumber = false,
|
|
6601
|
+
showDescription = false,
|
|
6602
|
+
size = "md",
|
|
6603
|
+
isClickable = false,
|
|
6604
|
+
onClick
|
|
6605
|
+
}) {
|
|
6606
|
+
const config = sizeConfig[size];
|
|
6607
|
+
const styles = stateStyles[state];
|
|
6608
|
+
const Icon2 = step.icon;
|
|
6609
|
+
const renderCircleContent = () => {
|
|
6610
|
+
if (state === "completed") {
|
|
6611
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: config.icon, strokeWidth: 3 });
|
|
6612
|
+
}
|
|
6613
|
+
if (state === "error") {
|
|
6614
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: config.icon });
|
|
6615
|
+
}
|
|
6616
|
+
if (Icon2 && !showNumber) {
|
|
6617
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Icon2, { className: config.icon });
|
|
6618
|
+
}
|
|
6619
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { children: index + 1 });
|
|
6620
|
+
};
|
|
6621
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6622
|
+
"div",
|
|
6623
|
+
{
|
|
6624
|
+
className: cn(
|
|
6625
|
+
"flex flex-col items-center",
|
|
6626
|
+
config.gap,
|
|
6627
|
+
isClickable && "cursor-pointer group"
|
|
6628
|
+
),
|
|
6629
|
+
onClick: isClickable ? onClick : void 0,
|
|
6630
|
+
role: isClickable ? "button" : void 0,
|
|
6631
|
+
tabIndex: isClickable ? 0 : void 0,
|
|
6632
|
+
onKeyDown: isClickable ? (e) => {
|
|
6633
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
6634
|
+
e.preventDefault();
|
|
6635
|
+
onClick?.();
|
|
6636
|
+
}
|
|
6637
|
+
} : void 0,
|
|
6638
|
+
"aria-current": state === "current" ? "step" : void 0,
|
|
6639
|
+
children: [
|
|
6640
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6641
|
+
"div",
|
|
6642
|
+
{
|
|
6643
|
+
className: cn(
|
|
6644
|
+
"flex items-center justify-center rounded-full border-2 transition-all duration-200",
|
|
6645
|
+
config.circle,
|
|
6646
|
+
styles.circle,
|
|
6647
|
+
isClickable && "group-hover:ring-4 group-hover:ring-primary/10"
|
|
6648
|
+
),
|
|
6649
|
+
children: renderCircleContent()
|
|
6650
|
+
}
|
|
6651
|
+
),
|
|
6652
|
+
(step.label || showDescription) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center text-center max-w-[120px]", children: [
|
|
6653
|
+
step.label && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6654
|
+
"span",
|
|
6655
|
+
{
|
|
6656
|
+
className: cn(
|
|
6657
|
+
"leading-tight transition-colors duration-200",
|
|
6658
|
+
config.label,
|
|
6659
|
+
styles.label
|
|
6660
|
+
),
|
|
6661
|
+
children: step.label
|
|
6662
|
+
}
|
|
6663
|
+
),
|
|
6664
|
+
showDescription && step.description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6665
|
+
"span",
|
|
6666
|
+
{
|
|
6667
|
+
className: cn(
|
|
6668
|
+
"leading-tight mt-0.5",
|
|
6669
|
+
config.description,
|
|
6670
|
+
styles.description
|
|
6671
|
+
),
|
|
6672
|
+
children: step.description
|
|
6673
|
+
}
|
|
6674
|
+
)
|
|
6675
|
+
] })
|
|
6676
|
+
]
|
|
6677
|
+
}
|
|
6678
|
+
);
|
|
6679
|
+
}
|
|
6680
|
+
function WizardStepConnector({
|
|
6681
|
+
isCompleted = false,
|
|
6682
|
+
variant = "horizontal",
|
|
6683
|
+
className
|
|
6684
|
+
}) {
|
|
6685
|
+
const isHorizontal = variant === "horizontal";
|
|
6686
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6687
|
+
"div",
|
|
6688
|
+
{
|
|
6689
|
+
className: cn(
|
|
6690
|
+
"transition-colors duration-300",
|
|
6691
|
+
isHorizontal ? "flex-1 h-0.5 min-w-[24px] mx-2" : "w-0.5 min-h-[24px] my-2 ml-[18px]",
|
|
6692
|
+
isCompleted ? "bg-green-500" : "bg-muted-foreground/20",
|
|
6693
|
+
className
|
|
6694
|
+
),
|
|
6695
|
+
"aria-hidden": "true"
|
|
6696
|
+
}
|
|
6697
|
+
);
|
|
6698
|
+
}
|
|
6699
|
+
function WizardSteps({
|
|
6700
|
+
variant = "horizontal",
|
|
6701
|
+
showDescription = false,
|
|
6702
|
+
showNumbers = false,
|
|
6703
|
+
size = "md",
|
|
6704
|
+
className
|
|
6705
|
+
}) {
|
|
6706
|
+
const {
|
|
6707
|
+
activeSteps,
|
|
6708
|
+
currentStep,
|
|
6709
|
+
isStepCompleted,
|
|
6710
|
+
hasStepErrors,
|
|
6711
|
+
goToStep,
|
|
6712
|
+
allowJumpToStep
|
|
6713
|
+
} = useWizardContext();
|
|
6714
|
+
const getStepState = (index) => {
|
|
6715
|
+
const step = activeSteps[index];
|
|
6716
|
+
if (step.isDisabled) {
|
|
6717
|
+
return "disabled";
|
|
6718
|
+
}
|
|
6719
|
+
if (index === currentStep) {
|
|
6720
|
+
return hasStepErrors(index) ? "error" : "current";
|
|
6721
|
+
}
|
|
6722
|
+
if (isStepCompleted(index)) {
|
|
6723
|
+
return hasStepErrors(index) ? "error" : "completed";
|
|
6724
|
+
}
|
|
6725
|
+
return "pending";
|
|
6726
|
+
};
|
|
6727
|
+
const isStepClickable = (index) => {
|
|
6728
|
+
if (index === currentStep) return false;
|
|
6729
|
+
const step = activeSteps[index];
|
|
6730
|
+
if (step.isDisabled) return false;
|
|
6731
|
+
if (index < currentStep) return true;
|
|
6732
|
+
if (allowJumpToStep && index > currentStep) {
|
|
6733
|
+
for (let i = currentStep; i < index; i++) {
|
|
6734
|
+
if (!isStepCompleted(i)) return false;
|
|
6735
|
+
}
|
|
6736
|
+
return true;
|
|
6737
|
+
}
|
|
6738
|
+
return false;
|
|
6739
|
+
};
|
|
6740
|
+
const handleStepClick = async (index) => {
|
|
6741
|
+
if (isStepClickable(index)) {
|
|
6742
|
+
await goToStep(index);
|
|
6743
|
+
}
|
|
6744
|
+
};
|
|
6745
|
+
const isHorizontal = variant === "horizontal";
|
|
6746
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6747
|
+
"nav",
|
|
6748
|
+
{
|
|
6749
|
+
"aria-label": "Progresso do formul\xE1rio",
|
|
6750
|
+
className: cn(
|
|
6751
|
+
"flex",
|
|
6752
|
+
isHorizontal ? "flex-row items-center justify-center" : "flex-col items-start",
|
|
6753
|
+
className
|
|
6754
|
+
),
|
|
6755
|
+
children: activeSteps.map((step, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6756
|
+
"div",
|
|
6757
|
+
{
|
|
6758
|
+
className: cn(
|
|
6759
|
+
"flex",
|
|
6760
|
+
isHorizontal ? "flex-row items-center" : "flex-col",
|
|
6761
|
+
index !== activeSteps.length - 1 && isHorizontal && "flex-1"
|
|
6762
|
+
),
|
|
6763
|
+
children: [
|
|
6764
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6765
|
+
WizardStepIndicator,
|
|
6766
|
+
{
|
|
6767
|
+
step,
|
|
6768
|
+
index,
|
|
6769
|
+
state: getStepState(index),
|
|
6770
|
+
showNumber: showNumbers,
|
|
6771
|
+
showDescription,
|
|
6772
|
+
size,
|
|
6773
|
+
isClickable: isStepClickable(index),
|
|
6774
|
+
onClick: () => handleStepClick(index)
|
|
6775
|
+
}
|
|
6776
|
+
),
|
|
6777
|
+
index !== activeSteps.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6778
|
+
WizardStepConnector,
|
|
6779
|
+
{
|
|
6780
|
+
isCompleted: isStepCompleted(index),
|
|
6781
|
+
variant
|
|
6782
|
+
}
|
|
6783
|
+
)
|
|
6784
|
+
]
|
|
6785
|
+
},
|
|
6786
|
+
step.id
|
|
6787
|
+
))
|
|
6788
|
+
}
|
|
6789
|
+
);
|
|
6790
|
+
}
|
|
6791
|
+
function WizardContent({ children, className }) {
|
|
6792
|
+
const { currentStepConfig } = useWizardContext();
|
|
6793
|
+
let activePanel = null;
|
|
6794
|
+
React48.Children.forEach(children, (child) => {
|
|
6795
|
+
if (!React48.isValidElement(child)) return;
|
|
6796
|
+
const panelProps = child.props;
|
|
6797
|
+
if (panelProps.name === currentStepConfig?.name || panelProps.name === currentStepConfig?.id) {
|
|
6798
|
+
activePanel = child;
|
|
6799
|
+
}
|
|
6800
|
+
});
|
|
6801
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6802
|
+
"div",
|
|
6803
|
+
{
|
|
6804
|
+
className: cn("flex-1", className),
|
|
6805
|
+
role: "tabpanel",
|
|
6806
|
+
"aria-label": currentStepConfig?.label || currentStepConfig?.name,
|
|
6807
|
+
children: activePanel
|
|
6808
|
+
}
|
|
6809
|
+
);
|
|
6810
|
+
}
|
|
6811
|
+
function WizardPanel({ name, children, className }) {
|
|
6812
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("w-full", className), "data-wizard-panel": name, children });
|
|
6813
|
+
}
|
|
6814
|
+
function WizardNavigation({
|
|
6815
|
+
cancelLabel = "Cancelar",
|
|
6816
|
+
prevLabel = "Voltar",
|
|
6817
|
+
nextLabel = "Continuar",
|
|
6818
|
+
submitLabel = "Finalizar",
|
|
6819
|
+
loadingLabel = "Processando...",
|
|
6820
|
+
onCancel,
|
|
6821
|
+
showCancel,
|
|
6822
|
+
submitDisabled = false,
|
|
6823
|
+
className
|
|
6824
|
+
}) {
|
|
6825
|
+
const {
|
|
6826
|
+
isFirstStep,
|
|
6827
|
+
isLastStep,
|
|
6828
|
+
goToNextStep,
|
|
6829
|
+
goToPrevStep,
|
|
6830
|
+
form
|
|
6831
|
+
} = useWizardContext();
|
|
6832
|
+
const isSubmitting = form.formState.isSubmitting;
|
|
6833
|
+
const shouldShowCancel = showCancel ?? isFirstStep;
|
|
6834
|
+
const handleNext = React48.useCallback(async () => {
|
|
6835
|
+
await goToNextStep();
|
|
6836
|
+
}, [goToNextStep]);
|
|
6837
|
+
const handlePrev = React48.useCallback(() => {
|
|
6838
|
+
goToPrevStep();
|
|
6839
|
+
}, [goToPrevStep]);
|
|
6840
|
+
const handleCancel = React48.useCallback(() => {
|
|
6841
|
+
onCancel?.();
|
|
6842
|
+
}, [onCancel]);
|
|
6843
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6844
|
+
"div",
|
|
6845
|
+
{
|
|
6846
|
+
className: cn(
|
|
6847
|
+
"flex items-center justify-between gap-3 pt-4 border-t border-border",
|
|
6848
|
+
className
|
|
6849
|
+
),
|
|
6850
|
+
children: [
|
|
6851
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", children: shouldShowCancel && onCancel ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6852
|
+
Button,
|
|
6853
|
+
{
|
|
6854
|
+
type: "button",
|
|
6855
|
+
variant: "outline",
|
|
6856
|
+
onClick: handleCancel,
|
|
6857
|
+
disabled: isSubmitting,
|
|
6858
|
+
className: "w-full sm:w-auto",
|
|
6859
|
+
children: cancelLabel
|
|
6860
|
+
}
|
|
6861
|
+
) : !isFirstStep ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6862
|
+
Button,
|
|
6863
|
+
{
|
|
6864
|
+
type: "button",
|
|
6865
|
+
variant: "outline",
|
|
6866
|
+
onClick: handlePrev,
|
|
6867
|
+
disabled: isSubmitting,
|
|
6868
|
+
className: "w-full sm:w-auto",
|
|
6869
|
+
children: prevLabel
|
|
6870
|
+
}
|
|
6871
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", {}) }),
|
|
6872
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
6873
|
+
!isFirstStep && shouldShowCancel && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6874
|
+
Button,
|
|
6875
|
+
{
|
|
6876
|
+
type: "button",
|
|
6877
|
+
variant: "outline",
|
|
6878
|
+
onClick: handlePrev,
|
|
6879
|
+
disabled: isSubmitting,
|
|
6880
|
+
children: prevLabel
|
|
6881
|
+
}
|
|
6882
|
+
),
|
|
6883
|
+
isLastStep ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6884
|
+
Button,
|
|
6885
|
+
{
|
|
6886
|
+
type: "submit",
|
|
6887
|
+
disabled: submitDisabled || isSubmitting,
|
|
6888
|
+
className: "min-w-[120px]",
|
|
6889
|
+
children: isSubmitting ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
|
|
6890
|
+
/* @__PURE__ */ jsxRuntime.jsx(Loader, { variant: "spinner" }),
|
|
6891
|
+
loadingLabel
|
|
6892
|
+
] }) : submitLabel
|
|
6893
|
+
}
|
|
6894
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
6895
|
+
Button,
|
|
6896
|
+
{
|
|
6897
|
+
type: "button",
|
|
6898
|
+
onClick: handleNext,
|
|
6899
|
+
disabled: isSubmitting,
|
|
6900
|
+
className: "min-w-[120px]",
|
|
6901
|
+
children: nextLabel
|
|
6902
|
+
}
|
|
6903
|
+
)
|
|
6904
|
+
] })
|
|
6905
|
+
]
|
|
6906
|
+
}
|
|
6907
|
+
);
|
|
6908
|
+
}
|
|
6909
|
+
function WizardProgress({
|
|
6910
|
+
showPercentage = false,
|
|
6911
|
+
showStepCount = false,
|
|
6912
|
+
className
|
|
6913
|
+
}) {
|
|
6914
|
+
const { progress, currentStep, totalSteps } = useWizardContext();
|
|
6915
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full", className), children: [
|
|
6916
|
+
(showPercentage || showStepCount) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2 text-sm text-muted-foreground", children: [
|
|
6917
|
+
showStepCount && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
6918
|
+
"Etapa ",
|
|
6919
|
+
currentStep + 1,
|
|
6920
|
+
" de ",
|
|
6921
|
+
totalSteps
|
|
6922
|
+
] }),
|
|
6923
|
+
showPercentage && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: !showStepCount ? "ml-auto" : "", children: [
|
|
6924
|
+
progress,
|
|
6925
|
+
"%"
|
|
6926
|
+
] })
|
|
6927
|
+
] }),
|
|
6928
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6929
|
+
"div",
|
|
6930
|
+
{
|
|
6931
|
+
className: "h-2 w-full bg-muted rounded-full overflow-hidden",
|
|
6932
|
+
role: "progressbar",
|
|
6933
|
+
"aria-valuenow": progress,
|
|
6934
|
+
"aria-valuemin": 0,
|
|
6935
|
+
"aria-valuemax": 100,
|
|
6936
|
+
"aria-label": `Progresso: ${progress}%`,
|
|
6937
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6938
|
+
"div",
|
|
6939
|
+
{
|
|
6940
|
+
className: "h-full bg-primary transition-all duration-300 ease-out rounded-full",
|
|
6941
|
+
style: { width: `${progress}%` }
|
|
6942
|
+
}
|
|
6943
|
+
)
|
|
6944
|
+
}
|
|
6945
|
+
)
|
|
6946
|
+
] });
|
|
6947
|
+
}
|
|
6948
|
+
function WizardRoot({
|
|
6949
|
+
children,
|
|
6950
|
+
form,
|
|
6951
|
+
steps,
|
|
6952
|
+
initialStep,
|
|
6953
|
+
onStepChange,
|
|
6954
|
+
onComplete,
|
|
6955
|
+
validateOnNext = true,
|
|
6956
|
+
allowJumpToStep = false,
|
|
6957
|
+
className
|
|
6958
|
+
}) {
|
|
6959
|
+
const handleSubmit = async (data) => {
|
|
6960
|
+
if (onComplete) {
|
|
6961
|
+
await onComplete(data);
|
|
6962
|
+
}
|
|
6963
|
+
};
|
|
6964
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6965
|
+
WizardProvider,
|
|
6966
|
+
{
|
|
6967
|
+
form,
|
|
6968
|
+
steps,
|
|
6969
|
+
initialStep,
|
|
6970
|
+
onStepChange,
|
|
6971
|
+
onComplete,
|
|
6972
|
+
validateOnNext,
|
|
6973
|
+
allowJumpToStep,
|
|
6974
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6975
|
+
"form",
|
|
6976
|
+
{
|
|
6977
|
+
onSubmit: form.handleSubmit(handleSubmit),
|
|
6978
|
+
className: cn("flex flex-col", className),
|
|
6979
|
+
noValidate: true,
|
|
6980
|
+
children
|
|
6981
|
+
}
|
|
6982
|
+
) })
|
|
6983
|
+
}
|
|
6984
|
+
);
|
|
6985
|
+
}
|
|
6986
|
+
var Wizard = Object.assign(WizardRoot, {
|
|
6987
|
+
/** Visual step indicators */
|
|
6988
|
+
Steps: WizardSteps,
|
|
6989
|
+
/** Container for step panels */
|
|
6990
|
+
Content: WizardContent,
|
|
6991
|
+
/** Individual step content panel */
|
|
6992
|
+
Panel: WizardPanel,
|
|
6993
|
+
/** Navigation buttons (prev, next, submit) */
|
|
6994
|
+
Navigation: WizardNavigation,
|
|
6995
|
+
/** Progress bar indicator */
|
|
6996
|
+
Progress: WizardProgress
|
|
6997
|
+
});
|
|
6344
6998
|
function Logo({
|
|
6345
6999
|
width = 100,
|
|
6346
7000
|
color = "currentColor",
|
|
@@ -6609,6 +7263,15 @@ exports.Textarea = Textarea;
|
|
|
6609
7263
|
exports.ThemeProvider = ThemeProvider;
|
|
6610
7264
|
exports.ThemeToggle = ThemeToggle;
|
|
6611
7265
|
exports.Toaster = Toaster;
|
|
7266
|
+
exports.Wizard = Wizard;
|
|
7267
|
+
exports.WizardContent = WizardContent;
|
|
7268
|
+
exports.WizardNavigation = WizardNavigation;
|
|
7269
|
+
exports.WizardPanel = WizardPanel;
|
|
7270
|
+
exports.WizardProgress = WizardProgress;
|
|
7271
|
+
exports.WizardProvider = WizardProvider;
|
|
7272
|
+
exports.WizardStepConnector = WizardStepConnector;
|
|
7273
|
+
exports.WizardStepIndicator = WizardStepIndicator;
|
|
7274
|
+
exports.WizardSteps = WizardSteps;
|
|
6612
7275
|
exports.cn = cn;
|
|
6613
7276
|
exports.loader = loader;
|
|
6614
7277
|
exports.toast = toast;
|
|
@@ -6635,5 +7298,7 @@ exports.useMediaQuery = useMediaQuery2;
|
|
|
6635
7298
|
exports.useSidebar = useSidebar;
|
|
6636
7299
|
exports.useSidebarOptional = useSidebarOptional;
|
|
6637
7300
|
exports.useTheme = useTheme;
|
|
7301
|
+
exports.useWizardContext = useWizardContext;
|
|
7302
|
+
exports.useWizardContextOptional = useWizardContextOptional;
|
|
6638
7303
|
//# sourceMappingURL=index.js.map
|
|
6639
7304
|
//# sourceMappingURL=index.js.map
|