@wealthx/shadcn 1.5.28 → 1.5.30
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/.turbo/turbo-build.log +134 -134
- package/CHANGELOG.md +12 -0
- package/dist/{chunk-DWJHPNFL.mjs → chunk-4UT3RZ2D.mjs} +32 -16
- package/dist/{chunk-CE2WONIY.mjs → chunk-AE4JKISB.mjs} +27 -31
- package/dist/chunk-BZWQU52U.mjs +1025 -0
- package/dist/{chunk-RNLIZRAK.mjs → chunk-C6R42PCL.mjs} +1 -1
- package/dist/{chunk-EVUY67CY.mjs → chunk-FTQ2AKZ2.mjs} +1 -1
- package/dist/{chunk-7T4TYUO3.mjs → chunk-H5ZD63NT.mjs} +31 -16
- package/dist/{chunk-SO4RB3XB.mjs → chunk-IEQX4UVP.mjs} +2 -2
- package/dist/chunk-IKVF4XE2.mjs +94 -0
- package/dist/{chunk-KPGARKFC.mjs → chunk-MS3GNXMB.mjs} +1 -1
- package/dist/{chunk-M32QNCD3.mjs → chunk-OSSS56CB.mjs} +1 -1
- package/dist/{chunk-36IN7YRM.mjs → chunk-SCGCGVDN.mjs} +1 -1
- package/dist/{chunk-KJQ3BVTB.mjs → chunk-X2NIDXFB.mjs} +1 -1
- package/dist/components/ui/ai-builder/index.js +993 -12
- package/dist/components/ui/ai-builder/index.mjs +27 -3
- package/dist/components/ui/ai-conversations/index.js +27 -31
- package/dist/components/ui/ai-conversations/index.mjs +1 -1
- package/dist/components/ui/backoffice-signup-steps.js +98 -48
- package/dist/components/ui/backoffice-signup-steps.mjs +4 -4
- package/dist/components/ui/bank-statement-generate-dialog.mjs +2 -2
- package/dist/components/ui/chat-widget.js +1 -1
- package/dist/components/ui/chat-widget.mjs +2 -2
- package/dist/components/ui/contact-alert-dialog/index.mjs +2 -2
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/field.mjs +1 -1
- package/dist/components/ui/frontend-signup-steps.js +166 -90
- package/dist/components/ui/frontend-signup-steps.mjs +4 -5
- package/dist/components/ui/password-strength-tooltip.js +81 -107
- package/dist/components/ui/password-strength-tooltip.mjs +3 -2
- package/dist/components/ui/property-report-dialog.mjs +2 -2
- package/dist/components/ui/signup-form-primitives.js +117 -114
- package/dist/components/ui/signup-form-primitives.mjs +3 -4
- package/dist/components/ui/two-fa-setup-form.js +31 -16
- package/dist/components/ui/two-fa-setup-form.mjs +2 -2
- package/dist/index.js +5061 -4992
- package/dist/index.mjs +12 -12
- package/dist/styles.css +1 -1
- package/package.json +4 -1
- package/src/components/index.tsx +0 -2
- package/src/components/ui/ai-builder/agent-card.tsx +7 -5
- package/src/components/ui/ai-builder/agent-settings.tsx +709 -0
- package/src/components/ui/ai-builder/index.tsx +27 -2
- package/src/components/ui/ai-builder/service-config-modal.tsx +11 -11
- package/src/components/ui/ai-builder/types.ts +27 -15
- package/src/components/ui/ai-conversations/thread.tsx +9 -11
- package/src/components/ui/field.tsx +12 -12
- package/src/components/ui/password-strength-tooltip.tsx +89 -47
- package/src/components/ui/signup-form-primitives.tsx +34 -16
- package/src/components/ui/two-fa-setup-form.tsx +41 -31
- package/src/styles/styles-css.ts +1 -1
- package/dist/chunk-T5PGVLMR.mjs +0 -479
- package/dist/chunk-WHIW6KOB.mjs +0 -57
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export type {
|
|
2
2
|
AiBuilderAgentItem,
|
|
3
3
|
AiBuilderEmailCategories,
|
|
4
|
-
AiBuilderEmailFilterCategory,
|
|
5
|
-
AiBuilderEmailFilters,
|
|
6
4
|
AiBuilderServiceData,
|
|
7
5
|
AiBuilderServiceType,
|
|
6
|
+
AiBuilderAgentTone,
|
|
7
|
+
AiBuilderAgentLanguage,
|
|
8
|
+
AiBuilderAgentConfig,
|
|
9
|
+
AiBuilderAgentGeneralSettings,
|
|
10
|
+
AiBuilderResponseTemplate,
|
|
11
|
+
AiBuilderRuleItem,
|
|
8
12
|
} from "./types";
|
|
9
13
|
|
|
10
14
|
export { AgentCard, AgentMenuModal } from "./agent-card";
|
|
@@ -21,3 +25,24 @@ export type {
|
|
|
21
25
|
|
|
22
26
|
export { ServiceConfigurationModal } from "./service-config-modal";
|
|
23
27
|
export type { ServiceConfigurationModalProps } from "./service-config-modal";
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
SettingRow,
|
|
31
|
+
SettingCard,
|
|
32
|
+
AgentConfigForm,
|
|
33
|
+
ResponseTemplateEditModal,
|
|
34
|
+
RuleOrderBadge,
|
|
35
|
+
RuleSetSection,
|
|
36
|
+
SectionHeader,
|
|
37
|
+
AddEditRuleModal,
|
|
38
|
+
} from "./agent-settings";
|
|
39
|
+
export type {
|
|
40
|
+
SettingRowProps,
|
|
41
|
+
SettingCardProps,
|
|
42
|
+
AgentConfigFormProps,
|
|
43
|
+
ResponseTemplateEditModalProps,
|
|
44
|
+
RuleOrderBadgeProps,
|
|
45
|
+
RuleSetSectionProps,
|
|
46
|
+
SectionHeaderProps,
|
|
47
|
+
AddEditRuleModalProps,
|
|
48
|
+
} from "./agent-settings";
|
|
@@ -50,7 +50,7 @@ export function ServiceConfigurationModal({
|
|
|
50
50
|
}: ServiceConfigurationModalProps) {
|
|
51
51
|
return (
|
|
52
52
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
53
|
-
<DialogContent className="max-w-md">
|
|
53
|
+
<DialogContent className="flex max-h-[90vh] flex-col max-w-md">
|
|
54
54
|
{isConnected ? (
|
|
55
55
|
<>
|
|
56
56
|
<DialogHeader>
|
|
@@ -60,7 +60,7 @@ export function ServiceConfigurationModal({
|
|
|
60
60
|
</DialogDescription>
|
|
61
61
|
</DialogHeader>
|
|
62
62
|
|
|
63
|
-
<div className="flex flex-col gap-4 py-2">
|
|
63
|
+
<div className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto py-2">
|
|
64
64
|
<div className="flex items-center gap-2 px-3 py-2 text-xs font-medium bg-success/10 text-success">
|
|
65
65
|
<CheckCircle2 className="h-3.5 w-3.5 shrink-0" />
|
|
66
66
|
Active — integration is running
|
|
@@ -158,13 +158,13 @@ export function ServiceConfigurationModal({
|
|
|
158
158
|
</p>
|
|
159
159
|
</div>
|
|
160
160
|
<Card className="py-0">
|
|
161
|
-
<CardContent className="flex flex-col gap-3 p-3
|
|
161
|
+
<CardContent className="flex flex-col gap-3 p-3">
|
|
162
162
|
{serviceData.emailCategories.available.map(
|
|
163
163
|
(category) => {
|
|
164
164
|
const checked =
|
|
165
|
-
serviceData.emailCategories!.selected.
|
|
166
|
-
category
|
|
167
|
-
)
|
|
165
|
+
serviceData.emailCategories!.selected.includes(
|
|
166
|
+
category
|
|
167
|
+
);
|
|
168
168
|
return (
|
|
169
169
|
<div
|
|
170
170
|
key={category}
|
|
@@ -181,10 +181,10 @@ export function ServiceConfigurationModal({
|
|
|
181
181
|
category,
|
|
182
182
|
]
|
|
183
183
|
: serviceData.emailCategories!.selected.filter(
|
|
184
|
-
(c) => c !== category
|
|
184
|
+
(c) => c !== category
|
|
185
185
|
);
|
|
186
186
|
serviceData.emailCategories!.onChange(
|
|
187
|
-
next
|
|
187
|
+
next
|
|
188
188
|
);
|
|
189
189
|
}}
|
|
190
190
|
/>
|
|
@@ -196,7 +196,7 @@ export function ServiceConfigurationModal({
|
|
|
196
196
|
</label>
|
|
197
197
|
</div>
|
|
198
198
|
);
|
|
199
|
-
}
|
|
199
|
+
}
|
|
200
200
|
)}
|
|
201
201
|
</CardContent>
|
|
202
202
|
</Card>
|
|
@@ -227,7 +227,7 @@ export function ServiceConfigurationModal({
|
|
|
227
227
|
onCheckedChange={(v) =>
|
|
228
228
|
serviceData.emailFilters!.onFilterChange(
|
|
229
229
|
category.id,
|
|
230
|
-
!!v
|
|
230
|
+
!!v
|
|
231
231
|
)
|
|
232
232
|
}
|
|
233
233
|
/>
|
|
@@ -238,7 +238,7 @@ export function ServiceConfigurationModal({
|
|
|
238
238
|
{category.label}
|
|
239
239
|
</label>
|
|
240
240
|
</div>
|
|
241
|
-
)
|
|
241
|
+
)
|
|
242
242
|
)}
|
|
243
243
|
</CardContent>
|
|
244
244
|
</Card>
|
|
@@ -19,18 +19,6 @@ export type AiBuilderEmailCategories = {
|
|
|
19
19
|
onChange: (categories: string[]) => void;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export type AiBuilderEmailFilterCategory = {
|
|
23
|
-
id: string;
|
|
24
|
-
label: string;
|
|
25
|
-
enabled: boolean;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type AiBuilderEmailFilters = {
|
|
29
|
-
description: string;
|
|
30
|
-
categories: AiBuilderEmailFilterCategory[];
|
|
31
|
-
onFilterChange: (categoryId: string, enabled: boolean) => void;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
22
|
export type AiBuilderServiceData = {
|
|
35
23
|
accountIdentifier: string;
|
|
36
24
|
accountIdentifierLabel: string;
|
|
@@ -41,8 +29,32 @@ export type AiBuilderServiceData = {
|
|
|
41
29
|
syncDescription: string;
|
|
42
30
|
syncEnabled: boolean;
|
|
43
31
|
onSyncToggle: (enabled: boolean) => void;
|
|
44
|
-
/** When set, renders an "Email
|
|
32
|
+
/** When set, renders an "Email Filters" section with per-category checkboxes. */
|
|
45
33
|
emailCategories?: AiBuilderEmailCategories;
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type AiBuilderAgentTone = "Professional" | "Friendly" | "Enthusiastic";
|
|
37
|
+
export type AiBuilderAgentLanguage = "American English" | "Australian English";
|
|
38
|
+
|
|
39
|
+
export type AiBuilderAgentConfig = {
|
|
40
|
+
name: string;
|
|
41
|
+
businessDescription: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type AiBuilderAgentGeneralSettings = {
|
|
45
|
+
autoResponse: boolean;
|
|
46
|
+
tone: AiBuilderAgentTone;
|
|
47
|
+
language: AiBuilderAgentLanguage;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type AiBuilderResponseTemplate = {
|
|
51
|
+
channel: "email" | "chat";
|
|
52
|
+
isEnabled: boolean;
|
|
53
|
+
content: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type AiBuilderRuleItem = {
|
|
57
|
+
id: string;
|
|
58
|
+
text: string;
|
|
59
|
+
isEnabled: boolean;
|
|
48
60
|
};
|
|
@@ -367,6 +367,7 @@ export function ChatComposer({
|
|
|
367
367
|
}: ChatComposerProps) {
|
|
368
368
|
// Semi-controlled: owns channel state for uncontrolled usage, notifies parent on change.
|
|
369
369
|
// Force chat when email isn't integrated so the panel never lands on a hidden tab.
|
|
370
|
+
const initialChannelRef = React.useRef(channelProp);
|
|
370
371
|
const [channel, setChannel] = React.useState<AiConvChannel>(
|
|
371
372
|
isEmailIntegrated ? channelProp : "chat",
|
|
372
373
|
);
|
|
@@ -558,12 +559,6 @@ export function ChatComposer({
|
|
|
558
559
|
<ComposerToolbarButton label="Attach file" icon={Paperclip} />
|
|
559
560
|
</div>
|
|
560
561
|
<div className="flex items-center gap-2">
|
|
561
|
-
{onLetAiHandle && (
|
|
562
|
-
<Button variant="outline" size="sm" onClick={onLetAiHandle}>
|
|
563
|
-
<Bot className="mr-1.5 size-3.5" />
|
|
564
|
-
Let AI Handle
|
|
565
|
-
</Button>
|
|
566
|
-
)}
|
|
567
562
|
<Button
|
|
568
563
|
size="sm"
|
|
569
564
|
onClick={() => {
|
|
@@ -596,12 +591,15 @@ export function ChatComposer({
|
|
|
596
591
|
className="min-h-0 flex-1 resize-none text-base"
|
|
597
592
|
/>
|
|
598
593
|
<div className="flex items-center justify-between">
|
|
599
|
-
|
|
600
|
-
<
|
|
601
|
-
|
|
602
|
-
|
|
594
|
+
{initialChannelRef.current !== "email" && (
|
|
595
|
+
<Button variant="outline" size="sm" onClick={onLetAiHandle}>
|
|
596
|
+
<Bot className="mr-1.5 size-3.5" />
|
|
597
|
+
Let AI Handle
|
|
598
|
+
</Button>
|
|
599
|
+
)}
|
|
603
600
|
<Button
|
|
604
601
|
size="sm"
|
|
602
|
+
className="ml-auto"
|
|
605
603
|
onClick={() => onSend?.(inputValue)}
|
|
606
604
|
disabled={!inputValue.trim()}
|
|
607
605
|
>
|
|
@@ -793,7 +791,7 @@ export function ChatThread({
|
|
|
793
791
|
Take Over
|
|
794
792
|
</Button>
|
|
795
793
|
)}
|
|
796
|
-
{!isClosed && !aiIsHandling && (
|
|
794
|
+
{!isClosed && !aiIsHandling && channel !== "email" && (
|
|
797
795
|
<Button variant="outline" size="sm" onClick={onLetAiHandle}>
|
|
798
796
|
<Bot className="mr-1.5 size-3.5" />
|
|
799
797
|
Let AI Handle
|
|
@@ -22,7 +22,7 @@ function FieldSet({ className, ...props }: FieldSetProps): ReactElement {
|
|
|
22
22
|
className={cn(
|
|
23
23
|
"flex flex-col gap-6",
|
|
24
24
|
"has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
|
|
25
|
-
className
|
|
25
|
+
className
|
|
26
26
|
)}
|
|
27
27
|
data-slot="field-set"
|
|
28
28
|
{...props}
|
|
@@ -45,7 +45,7 @@ function FieldLegend({
|
|
|
45
45
|
"mb-3",
|
|
46
46
|
"data-[variant=legend]:text-label-large",
|
|
47
47
|
"data-[variant=label]:text-label-medium",
|
|
48
|
-
className
|
|
48
|
+
className
|
|
49
49
|
)}
|
|
50
50
|
data-slot="field-legend"
|
|
51
51
|
data-variant={variant}
|
|
@@ -61,7 +61,7 @@ function FieldGroup({ className, ...props }: FieldGroupProps): ReactElement {
|
|
|
61
61
|
<div
|
|
62
62
|
className={cn(
|
|
63
63
|
"group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
|
|
64
|
-
className
|
|
64
|
+
className
|
|
65
65
|
)}
|
|
66
66
|
data-slot="field-group"
|
|
67
67
|
{...props}
|
|
@@ -90,7 +90,7 @@ const fieldVariants = cva(
|
|
|
90
90
|
defaultVariants: {
|
|
91
91
|
orientation: "vertical",
|
|
92
92
|
},
|
|
93
|
-
}
|
|
93
|
+
}
|
|
94
94
|
);
|
|
95
95
|
|
|
96
96
|
export type FieldProps = React.ComponentProps<"div"> &
|
|
@@ -122,7 +122,7 @@ function FieldContent({
|
|
|
122
122
|
<div
|
|
123
123
|
className={cn(
|
|
124
124
|
"group/field-content flex flex-1 flex-col gap-1.5 leading-snug",
|
|
125
|
-
className
|
|
125
|
+
className
|
|
126
126
|
)}
|
|
127
127
|
data-slot="field-content"
|
|
128
128
|
{...props}
|
|
@@ -139,7 +139,7 @@ function FieldLabel({ className, ...props }: FieldLabelProps): ReactElement {
|
|
|
139
139
|
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",
|
|
140
140
|
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4",
|
|
141
141
|
"has-data-checked:border-primary has-data-checked:bg-primary/5 dark:has-data-checked:bg-primary/10",
|
|
142
|
-
className
|
|
142
|
+
className
|
|
143
143
|
)}
|
|
144
144
|
data-slot="field-label"
|
|
145
145
|
{...props}
|
|
@@ -154,7 +154,7 @@ function FieldTitle({ className, ...props }: FieldTitleProps): ReactElement {
|
|
|
154
154
|
<div
|
|
155
155
|
className={cn(
|
|
156
156
|
"flex w-fit items-center gap-2 text-label-medium leading-snug group-data-[disabled=true]/field:opacity-50",
|
|
157
|
-
className
|
|
157
|
+
className
|
|
158
158
|
)}
|
|
159
159
|
data-slot="field-label"
|
|
160
160
|
{...props}
|
|
@@ -174,7 +174,7 @@ function FieldDescription({
|
|
|
174
174
|
"text-caption leading-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance",
|
|
175
175
|
"last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",
|
|
176
176
|
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
|
|
177
|
-
className
|
|
177
|
+
className
|
|
178
178
|
)}
|
|
179
179
|
data-slot="field-description"
|
|
180
180
|
{...props}
|
|
@@ -195,7 +195,7 @@ function FieldSeparator({
|
|
|
195
195
|
<div
|
|
196
196
|
className={cn(
|
|
197
197
|
"relative -my-2 h-5 text-body-small group-data-[variant=outline]/field-group:-mb-2",
|
|
198
|
-
className
|
|
198
|
+
className
|
|
199
199
|
)}
|
|
200
200
|
data-content={Boolean(children)}
|
|
201
201
|
data-slot="field-separator"
|
|
@@ -234,7 +234,7 @@ function FieldError({
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
const uniqueErrors = Array.from(
|
|
237
|
-
new Map(errors.map((error) => [error?.message, error])).values()
|
|
237
|
+
new Map(errors.map((error) => [error?.message, error])).values()
|
|
238
238
|
);
|
|
239
239
|
|
|
240
240
|
if (uniqueErrors.length === 1) {
|
|
@@ -245,7 +245,7 @@ function FieldError({
|
|
|
245
245
|
<ul className="ml-4 flex list-disc flex-col gap-1">
|
|
246
246
|
{uniqueErrors.map(
|
|
247
247
|
(error) =>
|
|
248
|
-
error?.message && <li key={error.message}>{error.message}</li
|
|
248
|
+
error?.message && <li key={error.message}>{error.message}</li>
|
|
249
249
|
)}
|
|
250
250
|
</ul>
|
|
251
251
|
);
|
|
@@ -257,7 +257,7 @@ function FieldError({
|
|
|
257
257
|
|
|
258
258
|
return (
|
|
259
259
|
<div
|
|
260
|
-
className={cn("text-caption text-destructive", className)}
|
|
260
|
+
className={cn("text-left text-caption text-destructive", className)}
|
|
261
261
|
data-slot="field-error"
|
|
262
262
|
role="alert"
|
|
263
263
|
{...props}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Check, X } from "lucide-react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
PopoverTrigger,
|
|
7
|
-
} from "@/components/ui/popover";
|
|
3
|
+
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
import { useThemeVars } from "@/lib/theme-provider";
|
|
8
6
|
|
|
9
|
-
type
|
|
7
|
+
export type PasswordStrengthRule = {
|
|
8
|
+
label: string;
|
|
9
|
+
test: (p: string) => boolean;
|
|
10
|
+
};
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
+
export const PASSWORD_STRENGTH_RULES: PasswordStrengthRule[] = [
|
|
12
13
|
{ label: "Minimum 8 characters", test: (p) => p.length >= 8 },
|
|
13
14
|
{ label: "At least one uppercase letter", test: (p) => /[A-Z]/.test(p) },
|
|
14
15
|
{ label: "At least one lowercase letter", test: (p) => /[a-z]/.test(p) },
|
|
@@ -24,47 +25,88 @@ export type PasswordStrengthTooltipProps = {
|
|
|
24
25
|
password: string;
|
|
25
26
|
children: React.ReactNode;
|
|
26
27
|
side?: "top" | "right" | "bottom" | "left";
|
|
28
|
+
onRequestClose?: () => void;
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
side = "right",
|
|
34
|
-
|
|
31
|
+
export const PasswordStrengthTooltip = React.forwardRef<
|
|
32
|
+
HTMLDivElement,
|
|
33
|
+
PasswordStrengthTooltipProps
|
|
34
|
+
>(function PasswordStrengthTooltip(
|
|
35
|
+
{ open = false, password, children, side = "right" },
|
|
36
|
+
forwardedRef
|
|
37
|
+
) {
|
|
38
|
+
const themeVars = useThemeVars();
|
|
39
|
+
// anchorRef is used by Positioner for popup placement.
|
|
40
|
+
// forwardedRef (fieldRef from consumer) is used for contains() checks in dismiss logic.
|
|
41
|
+
const anchorRef = React.useRef<HTMLDivElement>(null);
|
|
42
|
+
|
|
43
|
+
const composedRef = React.useCallback(
|
|
44
|
+
(node: HTMLDivElement | null) => {
|
|
45
|
+
(anchorRef as React.MutableRefObject<HTMLDivElement | null>).current =
|
|
46
|
+
node;
|
|
47
|
+
if (typeof forwardedRef === "function") {
|
|
48
|
+
forwardedRef(node);
|
|
49
|
+
} else if (forwardedRef) {
|
|
50
|
+
(
|
|
51
|
+
forwardedRef as React.MutableRefObject<HTMLDivElement | null>
|
|
52
|
+
).current = node;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
+
[forwardedRef]
|
|
57
|
+
);
|
|
58
|
+
|
|
35
59
|
return (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
// PopoverPrimitive.Root with no Trigger — popup is fully controlled via `open` prop.
|
|
61
|
+
// The wrapper div has no trigger behaviors injected, so clicking the input inside
|
|
62
|
+
// works on the first click without interference.
|
|
63
|
+
<PopoverPrimitive.Root open={open}>
|
|
64
|
+
<div ref={composedRef}>{children}</div>
|
|
65
|
+
<PopoverPrimitive.Portal>
|
|
66
|
+
<PopoverPrimitive.Positioner
|
|
67
|
+
anchor={anchorRef}
|
|
68
|
+
side={side}
|
|
69
|
+
align="start"
|
|
70
|
+
sideOffset={8}
|
|
71
|
+
className="z-[200]"
|
|
72
|
+
>
|
|
73
|
+
<PopoverPrimitive.Popup
|
|
74
|
+
initialFocus={false}
|
|
75
|
+
finalFocus={false}
|
|
76
|
+
className={cn(
|
|
77
|
+
"border border-border bg-popover shadow-md outline-hidden",
|
|
78
|
+
"w-auto max-w-[280px] p-3 font-sans",
|
|
79
|
+
"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2",
|
|
80
|
+
"data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
81
|
+
"data-ending-style:animate-out data-ending-style:fade-out-0 data-ending-style:zoom-out-95 data-ending-style:fill-mode-forwards",
|
|
82
|
+
"data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95"
|
|
83
|
+
)}
|
|
84
|
+
style={themeVars as React.CSSProperties}
|
|
85
|
+
>
|
|
86
|
+
<div className="flex flex-col gap-1.5">
|
|
87
|
+
{PASSWORD_STRENGTH_RULES.map((rule) => {
|
|
88
|
+
const valid = password ? rule.test(password) : false;
|
|
89
|
+
return (
|
|
90
|
+
<div
|
|
91
|
+
key={rule.label}
|
|
92
|
+
className={cn(
|
|
93
|
+
"flex items-center gap-1.5 text-[13px] leading-[18px]",
|
|
94
|
+
valid ? "text-success" : "text-destructive"
|
|
95
|
+
)}
|
|
96
|
+
>
|
|
97
|
+
{valid ? (
|
|
98
|
+
<Check size={14} className="shrink-0" />
|
|
99
|
+
) : (
|
|
100
|
+
<X size={14} className="shrink-0" />
|
|
101
|
+
)}
|
|
102
|
+
<span>{rule.label}</span>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
})}
|
|
106
|
+
</div>
|
|
107
|
+
</PopoverPrimitive.Popup>
|
|
108
|
+
</PopoverPrimitive.Positioner>
|
|
109
|
+
</PopoverPrimitive.Portal>
|
|
110
|
+
</PopoverPrimitive.Root>
|
|
69
111
|
);
|
|
70
|
-
}
|
|
112
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
2
|
import { EyeIcon, EyeOffIcon, Trash2Icon } from "lucide-react";
|
|
3
3
|
import { Button } from "./button";
|
|
4
4
|
import { Field, FieldError, FieldLabel } from "./field";
|
|
@@ -10,7 +10,10 @@ import {
|
|
|
10
10
|
SelectTrigger,
|
|
11
11
|
SelectValue,
|
|
12
12
|
} from "./select";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
PASSWORD_STRENGTH_RULES,
|
|
15
|
+
PasswordStrengthTooltip,
|
|
16
|
+
} from "./password-strength-tooltip";
|
|
14
17
|
|
|
15
18
|
// ---------------------------------------------------------------------------
|
|
16
19
|
// SectionHeading
|
|
@@ -52,14 +55,6 @@ export function FormField({ label, required, children }: FormFieldProps) {
|
|
|
52
55
|
// PasswordField — input with show/hide toggle + optional strength popover
|
|
53
56
|
// ---------------------------------------------------------------------------
|
|
54
57
|
|
|
55
|
-
const STRENGTH_RULES = [
|
|
56
|
-
{ test: (p: string) => p.length >= 8 },
|
|
57
|
-
{ test: (p: string) => /[A-Z]/.test(p) },
|
|
58
|
-
{ test: (p: string) => /[a-z]/.test(p) },
|
|
59
|
-
{ test: (p: string) => /\d/.test(p) },
|
|
60
|
-
{ test: (p: string) => /[^A-Za-z0-9]/.test(p) },
|
|
61
|
-
];
|
|
62
|
-
|
|
63
58
|
export interface PasswordFieldProps {
|
|
64
59
|
label: string;
|
|
65
60
|
placeholder: string;
|
|
@@ -79,16 +74,30 @@ export function PasswordField({
|
|
|
79
74
|
const [error, setError] = useState("");
|
|
80
75
|
const [touched, setTouched] = useState(false);
|
|
81
76
|
const [value, setValue] = useState("");
|
|
82
|
-
const [
|
|
77
|
+
const [dismissed, setDismissed] = useState(false);
|
|
78
|
+
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
83
79
|
|
|
84
|
-
const allRulesPass =
|
|
85
|
-
const isPopoverOpen =
|
|
80
|
+
const allRulesPass = PASSWORD_STRENGTH_RULES.every((r) => r.test(value));
|
|
81
|
+
const isPopoverOpen =
|
|
82
|
+
!!showStrengthPopover && !dismissed && value.length > 0 && !allRulesPass;
|
|
86
83
|
|
|
87
84
|
const validate = (v: string) => {
|
|
88
|
-
if (v
|
|
85
|
+
if (!v) return "";
|
|
86
|
+
if (v.length < 8) return "Min. 8 characters required";
|
|
87
|
+
if (!PASSWORD_STRENGTH_RULES.every((r) => r.test(v)))
|
|
88
|
+
return "Password doesn't meet all requirements";
|
|
89
89
|
return "";
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!isPopoverOpen) return;
|
|
94
|
+
const onMouseDown = (e: MouseEvent) => {
|
|
95
|
+
if (!wrapperRef.current?.contains(e.target as Node)) setDismissed(true);
|
|
96
|
+
};
|
|
97
|
+
document.addEventListener("mousedown", onMouseDown, true);
|
|
98
|
+
return () => document.removeEventListener("mousedown", onMouseDown, true);
|
|
99
|
+
}, [isPopoverOpen]);
|
|
100
|
+
|
|
92
101
|
const inputEl = (
|
|
93
102
|
<div className="relative">
|
|
94
103
|
<Input
|
|
@@ -100,8 +109,16 @@ export function PasswordField({
|
|
|
100
109
|
const v = e.target.value;
|
|
101
110
|
setValue(v);
|
|
102
111
|
onValueChange?.(v);
|
|
103
|
-
if (!typingStarted && v.length > 0) setTypingStarted(true);
|
|
104
112
|
if (touched) setError(validate(v));
|
|
113
|
+
setDismissed(false);
|
|
114
|
+
}}
|
|
115
|
+
onFocus={() => setDismissed(false)}
|
|
116
|
+
onKeyDown={(e: React.KeyboardEvent) => {
|
|
117
|
+
if (e.key === "Tab") {
|
|
118
|
+
setTouched(true);
|
|
119
|
+
setError(validate(value));
|
|
120
|
+
setDismissed(true);
|
|
121
|
+
}
|
|
105
122
|
}}
|
|
106
123
|
onBlur={() => {
|
|
107
124
|
setTouched(true);
|
|
@@ -131,6 +148,7 @@ export function PasswordField({
|
|
|
131
148
|
</FieldLabel>
|
|
132
149
|
{showStrengthPopover ? (
|
|
133
150
|
<PasswordStrengthTooltip
|
|
151
|
+
ref={wrapperRef}
|
|
134
152
|
open={isPopoverOpen}
|
|
135
153
|
password={value}
|
|
136
154
|
side="right"
|
|
@@ -141,7 +159,7 @@ export function PasswordField({
|
|
|
141
159
|
inputEl
|
|
142
160
|
)}
|
|
143
161
|
<div className="min-h-5">
|
|
144
|
-
{touched && error && <FieldError>{error}</FieldError>}
|
|
162
|
+
{touched && error && !isPopoverOpen && <FieldError>{error}</FieldError>}
|
|
145
163
|
</div>
|
|
146
164
|
</Field>
|
|
147
165
|
);
|