@tc96/cli 0.0.0-stage → 0.28.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/LICENSE +21 -0
- package/README.md +213 -2
- package/cli.js +1450 -0
- package/package.json +35 -4
- package/registry/agenda-1.json +1297 -0
- package/registry/aggregate.json +4 -0
- package/registry/ai-chat-1.json +91 -0
- package/registry/app-shell-1.json +81 -0
- package/registry/app-shell-2.json +89 -0
- package/registry/app-shell-3.json +109 -0
- package/registry/app-shell-4.json +104 -0
- package/registry/card-1.json +104 -0
- package/registry/card-2.json +97 -0
- package/registry/card-3.json +104 -0
- package/registry/card-4.json +98 -0
- package/registry/card-5.json +85 -0
- package/registry/card-6.json +98 -0
- package/registry/card-7.json +104 -0
- package/registry/card-8.json +106 -0
- package/registry/card-9.json +92 -0
- package/registry/charts.json +30 -0
- package/registry/chat-assistant.json +110 -0
- package/registry/chats-panel.json +97 -0
- package/registry/checklist.json +321 -0
- package/registry/collection.json +1104 -0
- package/registry/crm-1.json +1317 -0
- package/registry/crm-2.json +1400 -0
- package/registry/dashboard-1.json +160 -0
- package/registry/dashboard-2.json +153 -0
- package/registry/dashboard-3.json +154 -0
- package/registry/dashboard-4.json +168 -0
- package/registry/dashboard-5.json +167 -0
- package/registry/dashboard-6.json +143 -0
- package/registry/dashboard-7.json +188 -0
- package/registry/documents-1.json +1322 -0
- package/registry/editable.json +36 -0
- package/registry/empty-state-1.json +40 -0
- package/registry/empty-state-2.json +39 -0
- package/registry/empty-state-3.json +61 -0
- package/registry/empty-state-4.json +39 -0
- package/registry/empty-state-5.json +47 -0
- package/registry/empty-state-6.json +40 -0
- package/registry/finance-1.json +845 -0
- package/registry/finance-2.json +973 -0
- package/registry/finance-3.json +1436 -0
- package/registry/flow-1.json +460 -0
- package/registry/flow-2.json +503 -0
- package/registry/flow-3.json +198 -0
- package/registry/flow-4.json +75 -0
- package/registry/flow-canvas.json +198 -0
- package/registry/flow-inspector.json +151 -0
- package/registry/flow-step-library.json +112 -0
- package/registry/forgot-password-1.json +73 -0
- package/registry/forgot-password-2.json +73 -0
- package/registry/inbox-1.json +1184 -0
- package/registry/inventory-1.json +828 -0
- package/registry/inventory-2.json +956 -0
- package/registry/legal-1.json +1345 -0
- package/registry/legal-2.json +1279 -0
- package/registry/legal-3.json +1273 -0
- package/registry/legal-4.json +1273 -0
- package/registry/legal-5.json +1393 -0
- package/registry/legal-6.json +1309 -0
- package/registry/legal-7.json +1315 -0
- package/registry/legal-8.json +1358 -0
- package/registry/legal-9.json +1381 -0
- package/registry/list-1.json +129 -0
- package/registry/list-2.json +117 -0
- package/registry/list-3.json +129 -0
- package/registry/list-4.json +105 -0
- package/registry/list-5.json +98 -0
- package/registry/list-6.json +92 -0
- package/registry/list.json +52 -0
- package/registry/login-1.json +89 -0
- package/registry/login-10.json +88 -0
- package/registry/login-2.json +81 -0
- package/registry/login-3.json +90 -0
- package/registry/login-4.json +81 -0
- package/registry/login-5.json +82 -0
- package/registry/login-6.json +88 -0
- package/registry/login-7.json +83 -0
- package/registry/login-8.json +81 -0
- package/registry/login-9.json +88 -0
- package/registry/magic-link-6.json +79 -0
- package/registry/marketing-1.json +833 -0
- package/registry/marketing-2.json +961 -0
- package/registry/navbar-1.json +66 -0
- package/registry/navbar-10.json +50 -0
- package/registry/navbar-11.json +48 -0
- package/registry/navbar-12.json +48 -0
- package/registry/navbar-2.json +48 -0
- package/registry/navbar-3.json +50 -0
- package/registry/navbar-4.json +39 -0
- package/registry/navbar-5.json +50 -0
- package/registry/navbar-6.json +48 -0
- package/registry/navbar-7.json +72 -0
- package/registry/navbar-8.json +50 -0
- package/registry/navbar-9.json +54 -0
- package/registry/onboarding-1.json +114 -0
- package/registry/onboarding-2.json +78 -0
- package/registry/onboarding-3.json +71 -0
- package/registry/otp-1.json +73 -0
- package/registry/projects-1.json +865 -0
- package/registry/projects-2.json +993 -0
- package/registry/projects-3.json +1346 -0
- package/registry/properties.json +530 -0
- package/registry/record-dialog.json +88 -0
- package/registry/record-group.json +194 -0
- package/registry/record-preview.json +70 -0
- package/registry/record-status-list.json +70 -0
- package/registry/reset-password-1.json +92 -0
- package/registry/reset-password-2.json +98 -0
- package/registry/reset-password-6.json +91 -0
- package/registry/revenue-1.json +834 -0
- package/registry/revenue-2.json +968 -0
- package/registry/revenue-3.json +821 -0
- package/registry/revenue-4.json +949 -0
- package/registry/rich-text-editor-1.json +172 -0
- package/registry/rich-text-editor-2.json +158 -0
- package/registry/rich-text-editor-3.json +198 -0
- package/registry/rich-text-editor-4.json +200 -0
- package/registry/rich-text-editor-5.json +237 -0
- package/registry/rich-text-editor.json +113 -0
- package/registry/settings-account-1.json +119 -0
- package/registry/settings-account-2.json +118 -0
- package/registry/settings-catalog-1.json +128 -0
- package/registry/settings-catalog-10.json +129 -0
- package/registry/settings-catalog-2.json +116 -0
- package/registry/settings-catalog-3.json +118 -0
- package/registry/settings-catalog-4.json +227 -0
- package/registry/settings-catalog-5.json +129 -0
- package/registry/settings-catalog-6.json +130 -0
- package/registry/settings-catalog-7.json +130 -0
- package/registry/settings-catalog-8.json +183 -0
- package/registry/settings-catalog-9.json +159 -0
- package/registry/settings-integration-1.json +125 -0
- package/registry/settings-integration-2.json +122 -0
- package/registry/settings-integration-3.json +118 -0
- package/registry/settings-integration-4.json +129 -0
- package/registry/settings-integration-5.json +122 -0
- package/registry/settings-integration-6.json +92 -0
- package/registry/settings-integration-7.json +122 -0
- package/registry/settings-integration-8.json +593 -0
- package/registry/settings-notification-channel-1.json +112 -0
- package/registry/settings-preference-1.json +123 -0
- package/registry/settings-preference-2.json +123 -0
- package/registry/settings-preference-3.json +116 -0
- package/registry/settings-role-permission-1.json +117 -0
- package/registry/settings-security-1.json +117 -0
- package/registry/settings-workspace-1.json +119 -0
- package/registry/settings-workspace-2.json +125 -0
- package/registry/settings.json +82 -0
- package/registry/signup-1.json +100 -0
- package/registry/signup-2.json +93 -0
- package/registry/signup-3.json +83 -0
- package/registry/signup-6.json +99 -0
- package/registry/state-surface.json +58 -0
- package/registry/stats-1.json +116 -0
- package/registry/stats-2.json +115 -0
- package/registry/stats-3.json +97 -0
- package/registry/stats-4.json +92 -0
- package/registry/stats-5.json +103 -0
- package/registry/stats-6.json +105 -0
- package/registry/stats-7.json +103 -0
- package/registry/stats.json +64 -0
- package/registry/support-1.json +853 -0
- package/registry/support-2.json +981 -0
- package/registry/support-3.json +762 -0
- package/registry/support-4.json +538 -0
- package/registry/team-1.json +829 -0
- package/registry/team-2.json +957 -0
- package/registry/timeline-1.json +97 -0
- package/registry/timeline-2.json +102 -0
- package/registry/timeline-3.json +68 -0
- package/registry/timeline-4.json +86 -0
- package/registry/ui/accordion.json +15 -0
- package/registry/ui/alert-dialog.json +14 -0
- package/registry/ui/alert.json +50 -0
- package/registry/ui/autocomplete.json +18 -0
- package/registry/ui/avatar.json +14 -0
- package/registry/ui/badge.json +51 -0
- package/registry/ui/breadcrumb.json +15 -0
- package/registry/ui/button.json +25 -0
- package/registry/ui/calendar.json +15 -0
- package/registry/ui/card.json +14 -0
- package/registry/ui/chat.json +115 -0
- package/registry/ui/checkbox-group.json +14 -0
- package/registry/ui/checkbox.json +14 -0
- package/registry/ui/collapsible.json +14 -0
- package/registry/ui/combobox.json +18 -0
- package/registry/ui/command.json +17 -0
- package/registry/ui/composer-clipboard.json +14 -0
- package/registry/ui/composer-document.json +14 -0
- package/registry/ui/composer-editor.json +16 -0
- package/registry/ui/composer-query.json +12 -0
- package/registry/ui/composer.json +17 -0
- package/registry/ui/context-menu.json +23 -0
- package/registry/ui/dialog.json +18 -0
- package/registry/ui/drawer.json +18 -0
- package/registry/ui/empty.json +14 -0
- package/registry/ui/field.json +22 -0
- package/registry/ui/fieldset.json +14 -0
- package/registry/ui/form.json +14 -0
- package/registry/ui/frame.json +12 -0
- package/registry/ui/gauge.json +31 -0
- package/registry/ui/group.json +17 -0
- package/registry/ui/icon-frame.json +31 -0
- package/registry/ui/input-group.json +17 -0
- package/registry/ui/input.json +14 -0
- package/registry/ui/kbd.json +12 -0
- package/registry/ui/label.json +14 -0
- package/registry/ui/menu.json +39 -0
- package/registry/ui/meter.json +14 -0
- package/registry/ui/number-field.json +17 -0
- package/registry/ui/otp-field.json +31 -0
- package/registry/ui/pagination.json +17 -0
- package/registry/ui/popover.json +14 -0
- package/registry/ui/preview-card.json +14 -0
- package/registry/ui/progress.json +14 -0
- package/registry/ui/property-meta.json +16 -0
- package/registry/ui/property-tone.json +12 -0
- package/registry/ui/radio-group.json +14 -0
- package/registry/ui/render-anchor.json +12 -0
- package/registry/ui/scroll-area.json +14 -0
- package/registry/ui/segmented-control.json +14 -0
- package/registry/ui/select.json +16 -0
- package/registry/ui/separator.json +14 -0
- package/registry/ui/sheet.json +18 -0
- package/registry/ui/sidebar.json +25 -0
- package/registry/ui/skeleton.json +24 -0
- package/registry/ui/slider.json +14 -0
- package/registry/ui/spinner.json +14 -0
- package/registry/ui/switch.json +14 -0
- package/registry/ui/table.json +14 -0
- package/registry/ui/tabs.json +16 -0
- package/registry/ui/text.json +31 -0
- package/registry/ui/textarea.json +14 -0
- package/registry/ui/toast.json +89 -0
- package/registry/ui/toggle-group.json +18 -0
- package/registry/ui/toggle.json +15 -0
- package/registry/ui/toolbar.json +14 -0
- package/registry/ui/tooltip.json +14 -0
- package/registry/ui/use-composer-editor.json +17 -0
- package/registry/ui/use-copy-to-clipboard.json +12 -0
- package/registry/ui/use-media-query.json +12 -0
- package/registry/view.json +1104 -0
- package/registry/widgets.json +319 -0
- package/registry/wizard.json +89 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "signup-2",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "blocks/application/auth/shared/auth-card.tsx",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"content": "'use client'\n\nimport { Alert, AlertDescription, AlertTitle } from '@tc96/ui/alert'\nimport {\n Card,\n CardDescription,\n CardHeader,\n CardPanel,\n CardTitle,\n} from '@tc96/ui/card'\nimport type { ReactElement, ReactNode, Ref } from 'react'\n\nexport interface AuthCardProps {\n alertRef?: Ref<HTMLDivElement>\n children?: ReactNode\n description?: ReactNode\n error?: string\n errorTitle: string\n footer?: ReactNode\n logo?: ReactNode\n notice?: ReactNode\n title: ReactNode\n titleRef?: Ref<HTMLDivElement>\n}\n\nexport function AuthCard({\n alertRef,\n children,\n description,\n error,\n errorTitle,\n footer,\n logo,\n notice,\n title,\n titleRef,\n}: Readonly<AuthCardProps>): ReactElement {\n return (\n <main className=\"flex min-h-svh items-center justify-center p-4 sm:p-6\">\n <div className=\"flex w-full max-w-sm flex-col gap-6\">\n <Card>\n <CardHeader className=\"justify-items-center text-center\">\n {logo ? (\n <div className=\"mb-2 flex justify-center\">{logo}</div>\n ) : null}\n <CardTitle\n ref={titleRef}\n render={(props) => <h1 {...props} />}\n tabIndex={titleRef ? -1 : undefined}\n >\n {title}\n </CardTitle>\n {description ? (\n <CardDescription>{description}</CardDescription>\n ) : null}\n </CardHeader>\n <CardPanel className=\"flex flex-col gap-4\">\n {error ? (\n <Alert ref={alertRef} tabIndex={-1} variant=\"error\">\n <AlertTitle>{errorTitle}</AlertTitle>\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n ) : null}\n {children}\n </CardPanel>\n </Card>\n {footer ? (\n <div\n className=\"flex flex-wrap items-center justify-center gap-1 text-muted-foreground text-sm\"\n data-slot=\"auth-footer\"\n >\n {footer}\n </div>\n ) : null}\n {notice}\n </div>\n </main>\n )\n}\n",
|
|
9
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/auth-card.tsx"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "blocks/application/auth/shared/auth-password-feedback.tsx",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"content": "'use client'\n\nimport { CheckIcon, CircleIcon } from '@phosphor-icons/react'\nimport { FieldDescription } from '@tc96/ui/field'\nimport { type ReactElement, useState } from 'react'\nimport { getPasswordSuggestions } from './password-suggestions'\nimport type { AuthNewPasswordLabels, AuthPasswordSuggestion } from './types'\n\nconst suggestionLabelKeys = {\n lowercase: 'suggestionLowercase',\n number: 'suggestionNumber',\n symbol: 'suggestionSymbol',\n uppercase: 'suggestionUppercase',\n} as const satisfies Record<AuthPasswordSuggestion, keyof AuthNewPasswordLabels>\n\nexport interface AuthPasswordFeedbackProps {\n labels: AuthNewPasswordLabels\n password: string\n suggestions: readonly AuthPasswordSuggestion[]\n}\n\ninterface FeedbackState {\n announcement: string\n met: readonly AuthPasswordSuggestion[]\n}\n\nexport function AuthPasswordFeedback({\n labels,\n password,\n suggestions,\n}: Readonly<AuthPasswordFeedbackProps>): ReactElement {\n const met = getPasswordSuggestions(password, suggestions)\n const [state, setState] = useState<FeedbackState>({\n announcement: '',\n met,\n })\n if (state.met.join() !== met.join()) {\n const messages: string[] = []\n for (const suggestion of suggestions) {\n const wasMet = state.met.includes(suggestion)\n const isMet = met.includes(suggestion)\n if (wasMet !== isMet)\n messages.push(\n `${labels[suggestionLabelKeys[suggestion]]}: ${isMet ? labels.suggestionMet : labels.suggestionMissing}`,\n )\n }\n setState({ announcement: messages.join('. '), met })\n }\n return (\n <>\n <FieldDescription className=\"flex flex-col gap-1.5\" render={<div />}>\n {suggestions.length ? (\n <ul className=\"flex gap-x-3 whitespace-nowrap text-xs\">\n {suggestions.map((suggestion) => {\n const isMet = met.includes(suggestion)\n return (\n <li\n className=\"flex items-center gap-1 transition-colors data-met:font-medium data-met:text-success-foreground\"\n data-met={isMet ? '' : undefined}\n key={suggestion}\n >\n {isMet ? (\n <CheckIcon aria-hidden className=\"size-3\" />\n ) : (\n <CircleIcon aria-hidden className=\"size-3\" />\n )}\n {labels[suggestionLabelKeys[suggestion]]}\n <span className=\"sr-only\">\n {` ${isMet ? labels.suggestionMet : labels.suggestionMissing}`}\n </span>\n </li>\n )\n })}\n </ul>\n ) : null}\n </FieldDescription>\n <div aria-live=\"polite\" className=\"sr-only\">\n {state.announcement}\n </div>\n </>\n )\n}\n",
|
|
15
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/auth-password-feedback.tsx"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "blocks/application/auth/shared/auth-password-field.tsx",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "'use client'\n\nimport { EyeIcon, EyeSlashIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport { Field, FieldError, FieldLabel } from '@tc96/ui/field'\nimport {\n InputGroup,\n InputGroupAddon,\n InputGroupInput,\n} from '@tc96/ui/input-group'\nimport { type ReactElement, type ReactNode, useState } from 'react'\n\nexport interface AuthPasswordFieldProps {\n autoComplete: 'current-password' | 'new-password'\n children?: ReactNode\n hideLabel: string\n label: string\n labelAction?: ReactNode\n minLength?: number\n name: string\n onValueChange?: (value: string) => void\n required?: boolean\n showLabel: string\n}\n\nexport function AuthPasswordField({\n autoComplete,\n children,\n hideLabel,\n label,\n labelAction,\n minLength,\n name,\n onValueChange,\n required = true,\n showLabel,\n}: Readonly<AuthPasswordFieldProps>): ReactElement {\n const [visible, setVisible] = useState(false)\n const toggleLabel = visible ? hideLabel : showLabel\n return (\n <Field name={name}>\n {labelAction ? (\n <div className=\"flex w-full items-center justify-between gap-2\">\n <FieldLabel>{label}</FieldLabel>\n {labelAction}\n </div>\n ) : (\n <FieldLabel>{label}</FieldLabel>\n )}\n <InputGroup>\n <InputGroupInput\n autoComplete={autoComplete}\n minLength={minLength}\n onValueChange={onValueChange}\n required={required}\n type={visible ? 'text' : 'password'}\n />\n <InputGroupAddon align=\"inline-end\">\n <Button\n aria-label={toggleLabel}\n onClick={() => setVisible((current) => !current)}\n size=\"sm\"\n title={toggleLabel}\n type=\"button\"\n variant=\"ghost\"\n >\n {visible ? <EyeSlashIcon aria-hidden /> : <EyeIcon aria-hidden />}\n </Button>\n </InputGroupAddon>\n </InputGroup>\n <FieldError />\n {children}\n </Field>\n )\n}\n",
|
|
21
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/auth-password-field.tsx"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "blocks/application/auth/shared/labels.ts",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "import type { AuthCommonLabels, AuthNewPasswordLabels } from './types'\n\nexport const defaultAuthCommonLabels: AuthCommonLabels = {\n email: 'E-mail',\n errorTitle: 'Não foi possível continuar',\n hidePassword: 'Ocultar senha',\n password: 'Senha',\n providerContinue: (label) => `Continuar com ${label}`,\n providersGroup: 'Entrar com outro serviço',\n providersSeparator: 'ou continue com e-mail',\n showPassword: 'Mostrar senha',\n}\n\nexport const defaultAuthNewPasswordLabels: AuthNewPasswordLabels = {\n confirmPassword: 'Confirmar senha',\n passwordMismatch: 'As senhas não coincidem.',\n suggestionLowercase: 'minúscula',\n suggestionMet: 'atendida',\n suggestionMissing: 'faltando',\n suggestionNumber: 'número',\n suggestionSymbol: 'símbolo',\n suggestionUppercase: 'maiúscula',\n}\n\nexport function resolveAuthLabels<TLabels>(\n defaults: TLabels,\n labels?: Partial<TLabels>,\n): TLabels {\n return { ...defaults, ...labels }\n}\n",
|
|
27
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/labels.ts"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "blocks/application/auth/shared/password-suggestions.ts",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "import type { AuthPasswordSuggestion } from './types'\n\nconst suggestionPatterns: Record<AuthPasswordSuggestion, RegExp> = {\n lowercase: /\\p{Ll}/u,\n number: /\\p{Nd}/u,\n symbol: /[^\\p{L}\\p{N}\\s]/u,\n uppercase: /\\p{Lu}/u,\n}\n\nexport const defaultPasswordSuggestions: AuthPasswordSuggestion[] = [\n 'lowercase',\n 'uppercase',\n 'number',\n 'symbol',\n]\n\nexport function getPasswordSuggestions(\n password: string,\n suggestions: readonly AuthPasswordSuggestion[],\n): AuthPasswordSuggestion[] {\n return suggestions.filter((suggestion) =>\n suggestionPatterns[suggestion].test(password),\n )\n}\n",
|
|
33
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/password-suggestions.ts"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "blocks/application/auth/shared/to-form-errors.ts",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"content": "export function toFormErrors(\n fieldErrors?: Readonly<Partial<Record<string, string>>>,\n): Record<string, string> {\n const errors: Record<string, string> = {}\n for (const [name, message] of Object.entries(fieldErrors ?? {}))\n if (message) errors[name] = message\n return errors\n}\n",
|
|
39
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/to-form-errors.ts"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "blocks/application/auth/shared/types.ts",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"content": "import type { RenderLink } from '@tc96/ui/render-anchor'\nimport type { ReactNode } from 'react'\n\nexport type AuthRenderLink = RenderLink\n\nexport interface AuthProvider {\n icon?: ReactNode\n id: string\n label: string\n}\n\nexport type AuthFieldErrors<TValues> = Partial<Record<keyof TValues, string>>\n\nexport type AuthPasswordSuggestion =\n | 'lowercase'\n | 'uppercase'\n | 'number'\n | 'symbol'\n\nexport interface AuthCommonLabels {\n email: string\n errorTitle: string\n hidePassword: string\n password: string\n providerContinue: (label: string) => string\n providersGroup: string\n providersSeparator: string\n showPassword: string\n}\n\nexport interface AuthNewPasswordLabels {\n confirmPassword: string\n passwordMismatch: string\n suggestionLowercase: string\n suggestionMet: string\n suggestionMissing: string\n suggestionNumber: string\n suggestionSymbol: string\n suggestionUppercase: string\n}\n\nexport interface AuthBaseProps<TLabels> {\n error?: string\n labels?: Partial<TLabels>\n logo?: ReactNode\n pending?: boolean\n renderLink?: AuthRenderLink\n}\n",
|
|
45
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/types.ts"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "blocks/application/auth/shared/use-focus-first-invalid.ts",
|
|
49
|
+
"type": "registry:file",
|
|
50
|
+
"content": "'use client'\n\nimport { type RefObject, useEffect, useRef } from 'react'\nimport { toFormErrors } from './to-form-errors'\n\nexport interface UseFocusFirstInvalidOptions {\n alertRef: RefObject<HTMLElement | null>\n error?: string\n fieldErrors?: Readonly<Partial<Record<string, string>>>\n formRef: RefObject<HTMLFormElement | null>\n}\n\nfunction findFirstNamedControl(\n form: HTMLFormElement | null,\n names: readonly string[],\n): HTMLElement | undefined {\n return Array.from(form?.elements ?? []).find(\n (element): element is HTMLElement =>\n element instanceof HTMLElement &&\n !(element instanceof HTMLInputElement && element.type === 'hidden') &&\n names.includes(element.getAttribute('name') ?? ''),\n )\n}\n\nexport function useFocusFirstInvalid({\n alertRef,\n error,\n fieldErrors,\n formRef,\n}: UseFocusFirstInvalidOptions): void {\n const invalidNames = Object.keys(toFormErrors(fieldErrors)).join('\\n')\n const hasError = Boolean(error)\n const previous = useRef({ hasError, invalidNames })\n\n useEffect(() => {\n const before = previous.current\n previous.current = { hasError, invalidNames }\n const hasFieldErrors = invalidNames !== ''\n const filled =\n (hasFieldErrors && before.invalidNames === '') ||\n (hasError && !before.hasError)\n if (!filled) return\n const field = hasFieldErrors\n ? findFirstNamedControl(formRef.current, invalidNames.split('\\n'))\n : undefined\n if (field) field.focus()\n else if (hasError) alertRef.current?.focus()\n }, [alertRef, formRef, hasError, invalidNames])\n}\n",
|
|
51
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/use-focus-first-invalid.ts"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "blocks/application/auth/signup-2/index.ts",
|
|
55
|
+
"type": "registry:file",
|
|
56
|
+
"content": "export type {\n AuthFieldErrors,\n AuthNewPasswordLabels,\n AuthPasswordSuggestion,\n} from '../shared/types'\nexport { Signup2 } from './signup-2'\nexport type { Signup2Labels, Signup2Props, Signup2Values } from './types'\n",
|
|
57
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-2/index.ts"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "blocks/application/auth/signup-2/labels.ts",
|
|
61
|
+
"type": "registry:file",
|
|
62
|
+
"content": "import {\n defaultAuthCommonLabels,\n defaultAuthNewPasswordLabels,\n} from '../shared/labels'\nimport type { Signup2Labels } from './types'\n\nexport const defaultSignup2Labels: Signup2Labels = {\n ...defaultAuthNewPasswordLabels,\n description: 'Preencha os dados para começar.',\n email: defaultAuthCommonLabels.email,\n errorTitle: defaultAuthCommonLabels.errorTitle,\n hidePassword: defaultAuthCommonLabels.hidePassword,\n name: 'Nome',\n password: defaultAuthCommonLabels.password,\n showPassword: defaultAuthCommonLabels.showPassword,\n submit: 'Criar conta',\n title: 'Criar conta',\n}\n",
|
|
63
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-2/labels.ts"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"path": "blocks/application/auth/signup-2/signup-2.tsx",
|
|
67
|
+
"type": "registry:file",
|
|
68
|
+
"content": "'use client'\n\nimport { Button } from '@tc96/ui/button'\nimport { Field, FieldError, FieldLabel } from '@tc96/ui/field'\nimport { Form } from '@tc96/ui/form'\nimport { Input } from '@tc96/ui/input'\nimport { type ReactElement, useMemo, useRef, useState } from 'react'\nimport { AuthCard } from '../shared/auth-card'\nimport { AuthPasswordFeedback } from '../shared/auth-password-feedback'\nimport { AuthPasswordField } from '../shared/auth-password-field'\nimport { resolveAuthLabels } from '../shared/labels'\nimport { defaultPasswordSuggestions } from '../shared/password-suggestions'\nimport { toFormErrors } from '../shared/to-form-errors'\nimport { useFocusFirstInvalid } from '../shared/use-focus-first-invalid'\nimport { defaultSignup2Labels } from './labels'\nimport type { Signup2Props, Signup2Values } from './types'\n\nfunction toSignup2Values(\n values: Readonly<Record<string, unknown>>,\n): Signup2Values {\n return {\n email: String(values.email ?? ''),\n name: String(values.name ?? ''),\n password: String(values.password ?? ''),\n }\n}\n\nexport function Signup2({\n error,\n fieldErrors,\n labels: labelsProp,\n onSubmit,\n passwordMinLength = 8,\n passwordSuggestions = defaultPasswordSuggestions,\n pending = false,\n}: Readonly<Signup2Props>): ReactElement {\n const labels = resolveAuthLabels(defaultSignup2Labels, labelsProp)\n const formRef = useRef<HTMLFormElement>(null)\n const alertRef = useRef<HTMLDivElement>(null)\n const [password, setPassword] = useState('')\n const [mismatch, setMismatch] = useState(false)\n const errors = useMemo(\n () => ({\n ...toFormErrors(fieldErrors),\n ...(mismatch ? { confirmPassword: labels.passwordMismatch } : undefined),\n }),\n [fieldErrors, labels.passwordMismatch, mismatch],\n )\n\n useFocusFirstInvalid({ alertRef, error, fieldErrors, formRef })\n\n return (\n <AuthCard\n alertRef={alertRef}\n description={labels.description}\n error={error}\n errorTitle={labels.errorTitle}\n title={labels.title}\n >\n <Form\n aria-busy={pending}\n className=\"flex flex-col gap-4\"\n errors={errors}\n onFormSubmit={(values) => {\n if (pending) return\n if (values.password !== values.confirmPassword) {\n setMismatch(true)\n return\n }\n onSubmit(toSignup2Values(values))\n }}\n ref={formRef}\n >\n <Field name=\"name\">\n <FieldLabel>{labels.name}</FieldLabel>\n <Input autoComplete=\"name\" required />\n <FieldError />\n </Field>\n <Field name=\"email\">\n <FieldLabel>{labels.email}</FieldLabel>\n <Input autoComplete=\"email\" required type=\"email\" />\n <FieldError />\n </Field>\n <AuthPasswordField\n autoComplete=\"new-password\"\n hideLabel={labels.hidePassword}\n label={labels.password}\n minLength={passwordMinLength}\n name=\"password\"\n onValueChange={(value) => {\n setPassword(value)\n setMismatch(false)\n }}\n showLabel={labels.showPassword}\n >\n <AuthPasswordFeedback\n labels={labels}\n password={password}\n suggestions={passwordSuggestions}\n />\n </AuthPasswordField>\n <AuthPasswordField\n autoComplete=\"new-password\"\n hideLabel={labels.hidePassword}\n label={labels.confirmPassword}\n name=\"confirmPassword\"\n onValueChange={() => setMismatch(false)}\n showLabel={labels.showPassword}\n />\n <Button className=\"w-full\" loading={pending} type=\"submit\">\n {labels.submit}\n </Button>\n </Form>\n </AuthCard>\n )\n}\n",
|
|
69
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-2/signup-2.tsx"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"path": "blocks/application/auth/signup-2/types.ts",
|
|
73
|
+
"type": "registry:file",
|
|
74
|
+
"content": "import type {\n AuthCommonLabels,\n AuthFieldErrors,\n AuthNewPasswordLabels,\n AuthPasswordSuggestion,\n} from '../shared/types'\n\nexport interface Signup2Values {\n name: string\n email: string\n password: string\n}\n\nexport interface Signup2Labels\n extends Pick<\n AuthCommonLabels,\n 'email' | 'errorTitle' | 'hidePassword' | 'password' | 'showPassword'\n >,\n AuthNewPasswordLabels {\n description: string\n name: string\n submit: string\n title: string\n}\n\nexport interface Signup2Props {\n error?: string\n fieldErrors?: AuthFieldErrors<Signup2Values>\n labels?: Partial<Signup2Labels>\n onSubmit: (values: Signup2Values) => void\n passwordMinLength?: number\n passwordSuggestions?: AuthPasswordSuggestion[]\n pending?: boolean\n}\n",
|
|
75
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-2/types.ts"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"dependencies": [
|
|
79
|
+
"@phosphor-icons/react@2.1.10",
|
|
80
|
+
"react@19.1.1"
|
|
81
|
+
],
|
|
82
|
+
"registryDependencies": [
|
|
83
|
+
"@ui/alert",
|
|
84
|
+
"@ui/button",
|
|
85
|
+
"@ui/card",
|
|
86
|
+
"@ui/field",
|
|
87
|
+
"@ui/form",
|
|
88
|
+
"@ui/input",
|
|
89
|
+
"@ui/input-group",
|
|
90
|
+
"@ui/render-anchor"
|
|
91
|
+
],
|
|
92
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
93
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "signup-3",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "blocks/application/auth/shared/labels.ts",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"content": "import type { AuthCommonLabels, AuthNewPasswordLabels } from './types'\n\nexport const defaultAuthCommonLabels: AuthCommonLabels = {\n email: 'E-mail',\n errorTitle: 'Não foi possível continuar',\n hidePassword: 'Ocultar senha',\n password: 'Senha',\n providerContinue: (label) => `Continuar com ${label}`,\n providersGroup: 'Entrar com outro serviço',\n providersSeparator: 'ou continue com e-mail',\n showPassword: 'Mostrar senha',\n}\n\nexport const defaultAuthNewPasswordLabels: AuthNewPasswordLabels = {\n confirmPassword: 'Confirmar senha',\n passwordMismatch: 'As senhas não coincidem.',\n suggestionLowercase: 'minúscula',\n suggestionMet: 'atendida',\n suggestionMissing: 'faltando',\n suggestionNumber: 'número',\n suggestionSymbol: 'símbolo',\n suggestionUppercase: 'maiúscula',\n}\n\nexport function resolveAuthLabels<TLabels>(\n defaults: TLabels,\n labels?: Partial<TLabels>,\n): TLabels {\n return { ...defaults, ...labels }\n}\n",
|
|
9
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/labels.ts"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "blocks/application/auth/shared/to-form-errors.ts",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"content": "export function toFormErrors(\n fieldErrors?: Readonly<Partial<Record<string, string>>>,\n): Record<string, string> {\n const errors: Record<string, string> = {}\n for (const [name, message] of Object.entries(fieldErrors ?? {}))\n if (message) errors[name] = message\n return errors\n}\n",
|
|
15
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/to-form-errors.ts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "blocks/application/auth/shared/types.ts",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "import type { RenderLink } from '@tc96/ui/render-anchor'\nimport type { ReactNode } from 'react'\n\nexport type AuthRenderLink = RenderLink\n\nexport interface AuthProvider {\n icon?: ReactNode\n id: string\n label: string\n}\n\nexport type AuthFieldErrors<TValues> = Partial<Record<keyof TValues, string>>\n\nexport type AuthPasswordSuggestion =\n | 'lowercase'\n | 'uppercase'\n | 'number'\n | 'symbol'\n\nexport interface AuthCommonLabels {\n email: string\n errorTitle: string\n hidePassword: string\n password: string\n providerContinue: (label: string) => string\n providersGroup: string\n providersSeparator: string\n showPassword: string\n}\n\nexport interface AuthNewPasswordLabels {\n confirmPassword: string\n passwordMismatch: string\n suggestionLowercase: string\n suggestionMet: string\n suggestionMissing: string\n suggestionNumber: string\n suggestionSymbol: string\n suggestionUppercase: string\n}\n\nexport interface AuthBaseProps<TLabels> {\n error?: string\n labels?: Partial<TLabels>\n logo?: ReactNode\n pending?: boolean\n renderLink?: AuthRenderLink\n}\n",
|
|
21
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/types.ts"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "blocks/application/auth/shared/use-focus-first-invalid.ts",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "'use client'\n\nimport { type RefObject, useEffect, useRef } from 'react'\nimport { toFormErrors } from './to-form-errors'\n\nexport interface UseFocusFirstInvalidOptions {\n alertRef: RefObject<HTMLElement | null>\n error?: string\n fieldErrors?: Readonly<Partial<Record<string, string>>>\n formRef: RefObject<HTMLFormElement | null>\n}\n\nfunction findFirstNamedControl(\n form: HTMLFormElement | null,\n names: readonly string[],\n): HTMLElement | undefined {\n return Array.from(form?.elements ?? []).find(\n (element): element is HTMLElement =>\n element instanceof HTMLElement &&\n !(element instanceof HTMLInputElement && element.type === 'hidden') &&\n names.includes(element.getAttribute('name') ?? ''),\n )\n}\n\nexport function useFocusFirstInvalid({\n alertRef,\n error,\n fieldErrors,\n formRef,\n}: UseFocusFirstInvalidOptions): void {\n const invalidNames = Object.keys(toFormErrors(fieldErrors)).join('\\n')\n const hasError = Boolean(error)\n const previous = useRef({ hasError, invalidNames })\n\n useEffect(() => {\n const before = previous.current\n previous.current = { hasError, invalidNames }\n const hasFieldErrors = invalidNames !== ''\n const filled =\n (hasFieldErrors && before.invalidNames === '') ||\n (hasError && !before.hasError)\n if (!filled) return\n const field = hasFieldErrors\n ? findFirstNamedControl(formRef.current, invalidNames.split('\\n'))\n : undefined\n if (field) field.focus()\n else if (hasError) alertRef.current?.focus()\n }, [alertRef, formRef, hasError, invalidNames])\n}\n",
|
|
27
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/use-focus-first-invalid.ts"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "blocks/application/auth/signup-3/index.ts",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "export type {\n AuthBaseProps,\n AuthCommonLabels,\n AuthFieldErrors,\n AuthProvider,\n AuthRenderLink,\n} from '../shared/types'\nexport { Signup3 } from './signup-3'\nexport type { Signup3Labels, Signup3Props, Signup3Values } from './types'\n",
|
|
33
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-3/index.ts"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "blocks/application/auth/signup-3/labels.ts",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"content": "import { defaultAuthCommonLabels } from '../shared/labels'\nimport type { Signup3Labels } from './types'\n\nexport const defaultSignup3Labels: Signup3Labels = {\n ...defaultAuthCommonLabels,\n brandsGroup: 'Empresas que usam o produto',\n description: 'Sem cartão de crédito. Cancele quando quiser.',\n email: 'E-mail de trabalho',\n hasAccount: 'Já tem uma conta?',\n heading: 'Tudo o que seu time precisa para vender mais',\n login: 'Entrar',\n passwordPlaceholder: 'Mínimo de 8 caracteres',\n pitch:\n 'Centralize clientes, negócios e conversas e acompanhe cada etapa do funil.',\n privacy: 'Política de Privacidade',\n providersGroup: 'Criar conta com outro serviço',\n providersSeparator: 'OU',\n submit: 'Começar teste grátis',\n terms: 'Termos de Uso',\n termsAnd: 'e a',\n termsLead: 'Ao criar a conta você concorda com os',\n title: 'Comece seu teste de 14 dias',\n}\n",
|
|
39
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-3/labels.ts"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "blocks/application/auth/signup-3/signup-3-password-field.tsx",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"content": "'use client'\n\nimport { EyeIcon, EyeSlashIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport { Field, FieldError, FieldLabel } from '@tc96/ui/field'\nimport {\n InputGroup,\n InputGroupAddon,\n InputGroupInput,\n} from '@tc96/ui/input-group'\nimport { type ReactElement, useState } from 'react'\n\nexport interface Signup3PasswordFieldProps {\n hideLabel: string\n label: string\n minLength?: number\n name: string\n placeholder?: string\n showLabel: string\n}\n\nexport function Signup3PasswordField({\n hideLabel,\n label,\n minLength,\n name,\n placeholder,\n showLabel,\n}: Readonly<Signup3PasswordFieldProps>): ReactElement {\n const [visible, setVisible] = useState(false)\n const toggleLabel = visible ? hideLabel : showLabel\n return (\n <Field name={name}>\n <FieldLabel>{label}</FieldLabel>\n <InputGroup>\n <InputGroupInput\n autoComplete=\"new-password\"\n minLength={minLength}\n placeholder={placeholder}\n required\n type={visible ? 'text' : 'password'}\n />\n <InputGroupAddon align=\"inline-end\">\n <Button\n aria-label={toggleLabel}\n onClick={() => setVisible((current) => !current)}\n size=\"sm\"\n title={toggleLabel}\n type=\"button\"\n variant=\"ghost\"\n >\n {visible ? <EyeSlashIcon aria-hidden /> : <EyeIcon aria-hidden />}\n </Button>\n </InputGroupAddon>\n </InputGroup>\n <FieldError />\n </Field>\n )\n}\n",
|
|
45
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-3/signup-3-password-field.tsx"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "blocks/application/auth/signup-3/signup-3-providers.tsx",
|
|
49
|
+
"type": "registry:file",
|
|
50
|
+
"content": "'use client'\n\nimport { Button } from '@tc96/ui/button'\nimport { Separator } from '@tc96/ui/separator'\nimport type { ReactElement } from 'react'\nimport type { AuthCommonLabels, AuthProvider } from '../shared/types'\n\nexport interface Signup3ProvidersProps {\n labels: Pick<\n AuthCommonLabels,\n 'providerContinue' | 'providersGroup' | 'providersSeparator'\n >\n onSelect?: (id: string) => void\n pending?: boolean\n providers?: readonly AuthProvider[]\n}\n\nexport function Signup3Providers({\n labels,\n onSelect,\n pending = false,\n providers,\n}: Readonly<Signup3ProvidersProps>): ReactElement | null {\n if (!providers?.length) return null\n return (\n <div className=\"flex flex-col gap-4\">\n <fieldset className=\"grid min-w-0 gap-2\">\n <legend className=\"sr-only\">{labels.providersGroup}</legend>\n {providers.map((provider) => (\n <Button\n className=\"w-full\"\n disabled={pending}\n key={provider.id}\n onClick={() => {\n if (!pending) onSelect?.(provider.id)\n }}\n type=\"button\"\n variant=\"secondary\"\n >\n {provider.icon}\n {labels.providerContinue(provider.label)}\n </Button>\n ))}\n </fieldset>\n <div\n aria-hidden=\"true\"\n className=\"flex items-center gap-3 text-muted-foreground text-xs\"\n >\n <div className=\"flex-1\">\n <Separator />\n </div>\n <span>{labels.providersSeparator}</span>\n <div className=\"flex-1\">\n <Separator />\n </div>\n </div>\n </div>\n )\n}\n",
|
|
51
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-3/signup-3-providers.tsx"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "blocks/application/auth/signup-3/signup-3.tsx",
|
|
55
|
+
"type": "registry:file",
|
|
56
|
+
"content": "'use client'\n\nimport { ArrowRightIcon } from '@phosphor-icons/react'\nimport { Alert, AlertDescription, AlertTitle } from '@tc96/ui/alert'\nimport { Badge } from '@tc96/ui/badge'\nimport { Button } from '@tc96/ui/button'\nimport {\n Card,\n CardDescription,\n CardHeader,\n CardPanel,\n CardTitle,\n} from '@tc96/ui/card'\nimport { Field, FieldError, FieldLabel } from '@tc96/ui/field'\nimport { Form } from '@tc96/ui/form'\nimport { Input } from '@tc96/ui/input'\nimport { renderAnchor } from '@tc96/ui/render-anchor'\nimport { Fragment, type ReactElement, useMemo, useRef } from 'react'\nimport { resolveAuthLabels } from '../shared/labels'\nimport { toFormErrors } from '../shared/to-form-errors'\nimport { useFocusFirstInvalid } from '../shared/use-focus-first-invalid'\nimport { defaultSignup3Labels } from './labels'\nimport { Signup3PasswordField } from './signup-3-password-field'\nimport { Signup3Providers } from './signup-3-providers'\nimport type { Signup3Props, Signup3Values } from './types'\n\nfunction toSignup3Values(\n values: Readonly<Record<string, unknown>>,\n): Signup3Values {\n return {\n email: String(values.email ?? ''),\n password: String(values.password ?? ''),\n }\n}\n\nexport function Signup3({\n badge,\n brands,\n brandsLabel,\n error,\n fieldErrors,\n labels: labelsProp,\n loginHref,\n logo,\n onProviderSelect,\n onSubmit,\n passwordMinLength = 8,\n pending = false,\n privacyHref,\n providers,\n renderLink = renderAnchor,\n termsHref,\n}: Readonly<Signup3Props>): ReactElement {\n const labels = resolveAuthLabels(defaultSignup3Labels, labelsProp)\n const formRef = useRef<HTMLFormElement>(null)\n const alertRef = useRef<HTMLDivElement>(null)\n const errors = useMemo(() => toFormErrors(fieldErrors), [fieldErrors])\n\n useFocusFirstInvalid({ alertRef, error, fieldErrors, formRef })\n\n const legalLinks: { href: string; label: string }[] = []\n if (termsHref) legalLinks.push({ href: termsHref, label: labels.terms })\n if (privacyHref) legalLinks.push({ href: privacyHref, label: labels.privacy })\n\n return (\n <div className=\"flex min-h-svh flex-col\">\n {logo || loginHref ? (\n <header className=\"flex items-center justify-between gap-4 px-4 py-4 sm:px-6 lg:px-10\">\n <div className=\"flex\">{logo}</div>\n {loginHref ? (\n <div className=\"flex flex-wrap items-center gap-1 text-muted-foreground text-sm\">\n <span>{labels.hasAccount}</span>\n <Button\n className=\"underline\"\n render={renderLink(loginHref)}\n size=\"sm\"\n variant=\"link\"\n >\n {labels.login}\n </Button>\n </div>\n ) : null}\n </header>\n ) : null}\n <main className=\"flex flex-1 flex-col justify-center gap-12 px-4 py-8 sm:px-6 lg:px-10\">\n <div className=\"mx-auto grid w-full max-w-6xl items-center gap-10 lg:grid-cols-2\">\n <div className=\"flex flex-col items-start gap-5\">\n {badge ? <Badge variant=\"outline\">{badge}</Badge> : null}\n <h1 className=\"font-semibold text-4xl tracking-tight sm:text-5xl\">\n {labels.heading}\n </h1>\n <p className=\"max-w-lg text-lg text-muted-foreground\">\n {labels.pitch}\n </p>\n </div>\n <Card className=\"w-full max-w-md lg:justify-self-end\">\n <CardHeader className=\"gap-1\">\n <CardTitle render={(props) => <h2 {...props} />}>\n {labels.title}\n </CardTitle>\n <CardDescription>{labels.description}</CardDescription>\n </CardHeader>\n <CardPanel className=\"flex flex-col gap-4\">\n {error ? (\n <Alert ref={alertRef} tabIndex={-1} variant=\"error\">\n <AlertTitle>{labels.errorTitle}</AlertTitle>\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n ) : null}\n <Signup3Providers\n labels={labels}\n onSelect={onProviderSelect}\n pending={pending}\n providers={providers}\n />\n <Form\n aria-busy={pending}\n className=\"flex flex-col gap-4\"\n errors={errors}\n onFormSubmit={(values) => {\n if (pending) return\n onSubmit(toSignup3Values(values))\n }}\n ref={formRef}\n >\n <Field name=\"email\">\n <FieldLabel>{labels.email}</FieldLabel>\n <Input autoComplete=\"email\" required type=\"email\" />\n <FieldError />\n </Field>\n <Signup3PasswordField\n hideLabel={labels.hidePassword}\n label={labels.password}\n minLength={passwordMinLength}\n name=\"password\"\n placeholder={labels.passwordPlaceholder}\n showLabel={labels.showPassword}\n />\n <Button className=\"w-full\" loading={pending} type=\"submit\">\n {labels.submit}\n <ArrowRightIcon aria-hidden />\n </Button>\n </Form>\n {legalLinks.length ? (\n <p className=\"flex flex-wrap items-center gap-x-1 text-muted-foreground text-xs\">\n <span>{labels.termsLead}</span>\n {legalLinks.map((link, index) => (\n <Fragment key={link.href}>\n {index > 0 ? <span>{labels.termsAnd}</span> : null}\n <Button\n className=\"px-0 underline\"\n render={renderLink(link.href)}\n size=\"sm\"\n variant=\"link\"\n >\n {link.label}\n </Button>\n </Fragment>\n ))}\n </p>\n ) : null}\n </CardPanel>\n </Card>\n </div>\n {brands ? (\n <section\n aria-label={brandsLabel ?? labels.brandsGroup}\n className=\"mx-auto flex w-full max-w-6xl flex-col items-center gap-4\"\n >\n {brandsLabel ? (\n <p className=\"text-muted-foreground text-sm\">{brandsLabel}</p>\n ) : null}\n <div className=\"flex flex-wrap items-center justify-center gap-x-10 gap-y-4 text-muted-foreground\">\n {brands}\n </div>\n </section>\n ) : null}\n </main>\n </div>\n )\n}\n",
|
|
57
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-3/signup-3.tsx"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "blocks/application/auth/signup-3/types.ts",
|
|
61
|
+
"type": "registry:file",
|
|
62
|
+
"content": "import type { ReactNode } from 'react'\nimport type {\n AuthBaseProps,\n AuthCommonLabels,\n AuthFieldErrors,\n AuthProvider,\n} from '../shared/types'\n\nexport interface Signup3Values {\n email: string\n password: string\n}\n\nexport interface Signup3Labels extends AuthCommonLabels {\n brandsGroup: string\n description: string\n hasAccount: string\n heading: ReactNode\n login: string\n passwordPlaceholder: string\n pitch: string\n privacy: string\n submit: string\n terms: string\n termsAnd: string\n termsLead: string\n title: string\n}\n\nexport interface Signup3Props extends AuthBaseProps<Signup3Labels> {\n badge?: string\n brands?: ReactNode\n brandsLabel?: string\n fieldErrors?: AuthFieldErrors<Signup3Values>\n loginHref?: string\n onProviderSelect?: (id: string) => void\n onSubmit: (values: Signup3Values) => void\n passwordMinLength?: number\n privacyHref?: string\n providers?: AuthProvider[]\n termsHref?: string\n}\n",
|
|
63
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-3/types.ts"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"dependencies": [
|
|
67
|
+
"@phosphor-icons/react@2.1.10",
|
|
68
|
+
"react@19.1.1"
|
|
69
|
+
],
|
|
70
|
+
"registryDependencies": [
|
|
71
|
+
"@ui/alert",
|
|
72
|
+
"@ui/badge",
|
|
73
|
+
"@ui/button",
|
|
74
|
+
"@ui/card",
|
|
75
|
+
"@ui/field",
|
|
76
|
+
"@ui/form",
|
|
77
|
+
"@ui/input",
|
|
78
|
+
"@ui/input-group",
|
|
79
|
+
"@ui/render-anchor",
|
|
80
|
+
"@ui/separator"
|
|
81
|
+
],
|
|
82
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
83
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "signup-6",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "blocks/application/auth/shared/auth-password-feedback.tsx",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"content": "'use client'\n\nimport { CheckIcon, CircleIcon } from '@phosphor-icons/react'\nimport { FieldDescription } from '@tc96/ui/field'\nimport { type ReactElement, useState } from 'react'\nimport { getPasswordSuggestions } from './password-suggestions'\nimport type { AuthNewPasswordLabels, AuthPasswordSuggestion } from './types'\n\nconst suggestionLabelKeys = {\n lowercase: 'suggestionLowercase',\n number: 'suggestionNumber',\n symbol: 'suggestionSymbol',\n uppercase: 'suggestionUppercase',\n} as const satisfies Record<AuthPasswordSuggestion, keyof AuthNewPasswordLabels>\n\nexport interface AuthPasswordFeedbackProps {\n labels: AuthNewPasswordLabels\n password: string\n suggestions: readonly AuthPasswordSuggestion[]\n}\n\ninterface FeedbackState {\n announcement: string\n met: readonly AuthPasswordSuggestion[]\n}\n\nexport function AuthPasswordFeedback({\n labels,\n password,\n suggestions,\n}: Readonly<AuthPasswordFeedbackProps>): ReactElement {\n const met = getPasswordSuggestions(password, suggestions)\n const [state, setState] = useState<FeedbackState>({\n announcement: '',\n met,\n })\n if (state.met.join() !== met.join()) {\n const messages: string[] = []\n for (const suggestion of suggestions) {\n const wasMet = state.met.includes(suggestion)\n const isMet = met.includes(suggestion)\n if (wasMet !== isMet)\n messages.push(\n `${labels[suggestionLabelKeys[suggestion]]}: ${isMet ? labels.suggestionMet : labels.suggestionMissing}`,\n )\n }\n setState({ announcement: messages.join('. '), met })\n }\n return (\n <>\n <FieldDescription className=\"flex flex-col gap-1.5\" render={<div />}>\n {suggestions.length ? (\n <ul className=\"flex gap-x-3 whitespace-nowrap text-xs\">\n {suggestions.map((suggestion) => {\n const isMet = met.includes(suggestion)\n return (\n <li\n className=\"flex items-center gap-1 transition-colors data-met:font-medium data-met:text-success-foreground\"\n data-met={isMet ? '' : undefined}\n key={suggestion}\n >\n {isMet ? (\n <CheckIcon aria-hidden className=\"size-3\" />\n ) : (\n <CircleIcon aria-hidden className=\"size-3\" />\n )}\n {labels[suggestionLabelKeys[suggestion]]}\n <span className=\"sr-only\">\n {` ${isMet ? labels.suggestionMet : labels.suggestionMissing}`}\n </span>\n </li>\n )\n })}\n </ul>\n ) : null}\n </FieldDescription>\n <div aria-live=\"polite\" className=\"sr-only\">\n {state.announcement}\n </div>\n </>\n )\n}\n",
|
|
9
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/auth-password-feedback.tsx"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "blocks/application/auth/shared/auth-password-field.tsx",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"content": "'use client'\n\nimport { EyeIcon, EyeSlashIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport { Field, FieldError, FieldLabel } from '@tc96/ui/field'\nimport {\n InputGroup,\n InputGroupAddon,\n InputGroupInput,\n} from '@tc96/ui/input-group'\nimport { type ReactElement, type ReactNode, useState } from 'react'\n\nexport interface AuthPasswordFieldProps {\n autoComplete: 'current-password' | 'new-password'\n children?: ReactNode\n hideLabel: string\n label: string\n labelAction?: ReactNode\n minLength?: number\n name: string\n onValueChange?: (value: string) => void\n required?: boolean\n showLabel: string\n}\n\nexport function AuthPasswordField({\n autoComplete,\n children,\n hideLabel,\n label,\n labelAction,\n minLength,\n name,\n onValueChange,\n required = true,\n showLabel,\n}: Readonly<AuthPasswordFieldProps>): ReactElement {\n const [visible, setVisible] = useState(false)\n const toggleLabel = visible ? hideLabel : showLabel\n return (\n <Field name={name}>\n {labelAction ? (\n <div className=\"flex w-full items-center justify-between gap-2\">\n <FieldLabel>{label}</FieldLabel>\n {labelAction}\n </div>\n ) : (\n <FieldLabel>{label}</FieldLabel>\n )}\n <InputGroup>\n <InputGroupInput\n autoComplete={autoComplete}\n minLength={minLength}\n onValueChange={onValueChange}\n required={required}\n type={visible ? 'text' : 'password'}\n />\n <InputGroupAddon align=\"inline-end\">\n <Button\n aria-label={toggleLabel}\n onClick={() => setVisible((current) => !current)}\n size=\"sm\"\n title={toggleLabel}\n type=\"button\"\n variant=\"ghost\"\n >\n {visible ? <EyeSlashIcon aria-hidden /> : <EyeIcon aria-hidden />}\n </Button>\n </InputGroupAddon>\n </InputGroup>\n <FieldError />\n {children}\n </Field>\n )\n}\n",
|
|
15
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/auth-password-field.tsx"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "blocks/application/auth/shared/auth-split-layout.tsx",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "'use client'\n\nimport { Alert, AlertDescription, AlertTitle } from '@tc96/ui/alert'\nimport type { ReactElement, ReactNode, Ref } from 'react'\n\nexport interface AuthSplitLayoutProps {\n alertRef?: Ref<HTMLDivElement>\n children: ReactNode\n description?: ReactNode\n error?: string\n errorTitle: string\n footer?: ReactNode\n logo?: ReactNode\n media?: ReactNode\n mediaLabel: string\n title: ReactNode\n titleRef?: Ref<HTMLHeadingElement>\n}\n\nexport function AuthSplitLayout({\n alertRef,\n children,\n description,\n error,\n errorTitle,\n footer,\n logo,\n media,\n mediaLabel,\n title,\n titleRef,\n}: Readonly<AuthSplitLayoutProps>): ReactElement {\n return (\n <div className=\"grid min-h-svh md:grid-cols-2\">\n <main className=\"flex flex-col gap-6 p-6 md:p-10\">\n {logo ? <div className=\"flex\">{logo}</div> : null}\n <div className=\"flex flex-1 items-center justify-center\">\n <div className=\"flex w-full max-w-sm flex-col gap-6\">\n <div className=\"flex flex-col gap-1\">\n <h1\n className=\"font-semibold text-2xl outline-none\"\n ref={titleRef}\n tabIndex={titleRef ? -1 : undefined}\n >\n {title}\n </h1>\n {description ? (\n <p className=\"text-muted-foreground text-sm\">{description}</p>\n ) : null}\n </div>\n {error ? (\n <Alert ref={alertRef} tabIndex={-1} variant=\"error\">\n <AlertTitle>{errorTitle}</AlertTitle>\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n ) : null}\n {children}\n {footer ? (\n <div\n className=\"mt-6 flex flex-wrap items-center gap-1 text-muted-foreground text-sm\"\n data-slot=\"auth-footer\"\n >\n {footer}\n </div>\n ) : null}\n </div>\n </div>\n </main>\n {media ? (\n <aside\n aria-label={mediaLabel}\n className=\"hidden p-4 md:flex md:flex-col\"\n >\n <div className=\"flex-1 overflow-hidden rounded-xl border\">\n {media}\n </div>\n </aside>\n ) : null}\n </div>\n )\n}\n",
|
|
21
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/auth-split-layout.tsx"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "blocks/application/auth/shared/auth-split-providers.tsx",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "'use client'\n\nimport { Button } from '@tc96/ui/button'\nimport { Separator } from '@tc96/ui/separator'\nimport type { ReactElement } from 'react'\nimport type { AuthCommonLabels, AuthProvider } from './types'\n\nexport interface AuthSplitProvidersProps {\n labels: Pick<\n AuthCommonLabels,\n 'providerContinue' | 'providersGroup' | 'providersSeparator'\n >\n onSelect?: (id: string) => void\n pending?: boolean\n providers?: readonly AuthProvider[]\n}\n\nexport function AuthSplitProviders({\n labels,\n onSelect,\n pending = false,\n providers,\n}: Readonly<AuthSplitProvidersProps>): ReactElement | null {\n if (!providers?.length) return null\n return (\n <div className=\"flex flex-col gap-4\">\n <div\n aria-hidden=\"true\"\n className=\"flex items-center gap-3 text-muted-foreground text-xs\"\n >\n <div className=\"flex-1\">\n <Separator />\n </div>\n <span>{labels.providersSeparator}</span>\n <div className=\"flex-1\">\n <Separator />\n </div>\n </div>\n <fieldset\n className={\n providers.length > 1\n ? 'grid min-w-0 grid-cols-2 gap-2'\n : 'grid min-w-0 gap-2'\n }\n >\n <legend className=\"sr-only\">{labels.providersGroup}</legend>\n {providers.map((provider) => (\n <Button\n aria-label={labels.providerContinue(provider.label)}\n className=\"w-full\"\n disabled={pending}\n key={provider.id}\n onClick={() => {\n if (!pending) onSelect?.(provider.id)\n }}\n type=\"button\"\n variant=\"secondary\"\n >\n {provider.icon}\n {provider.label}\n </Button>\n ))}\n </fieldset>\n </div>\n )\n}\n",
|
|
27
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/auth-split-providers.tsx"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "blocks/application/auth/shared/labels.ts",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "import type { AuthCommonLabels, AuthNewPasswordLabels } from './types'\n\nexport const defaultAuthCommonLabels: AuthCommonLabels = {\n email: 'E-mail',\n errorTitle: 'Não foi possível continuar',\n hidePassword: 'Ocultar senha',\n password: 'Senha',\n providerContinue: (label) => `Continuar com ${label}`,\n providersGroup: 'Entrar com outro serviço',\n providersSeparator: 'ou continue com e-mail',\n showPassword: 'Mostrar senha',\n}\n\nexport const defaultAuthNewPasswordLabels: AuthNewPasswordLabels = {\n confirmPassword: 'Confirmar senha',\n passwordMismatch: 'As senhas não coincidem.',\n suggestionLowercase: 'minúscula',\n suggestionMet: 'atendida',\n suggestionMissing: 'faltando',\n suggestionNumber: 'número',\n suggestionSymbol: 'símbolo',\n suggestionUppercase: 'maiúscula',\n}\n\nexport function resolveAuthLabels<TLabels>(\n defaults: TLabels,\n labels?: Partial<TLabels>,\n): TLabels {\n return { ...defaults, ...labels }\n}\n",
|
|
33
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/labels.ts"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "blocks/application/auth/shared/password-suggestions.ts",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"content": "import type { AuthPasswordSuggestion } from './types'\n\nconst suggestionPatterns: Record<AuthPasswordSuggestion, RegExp> = {\n lowercase: /\\p{Ll}/u,\n number: /\\p{Nd}/u,\n symbol: /[^\\p{L}\\p{N}\\s]/u,\n uppercase: /\\p{Lu}/u,\n}\n\nexport const defaultPasswordSuggestions: AuthPasswordSuggestion[] = [\n 'lowercase',\n 'uppercase',\n 'number',\n 'symbol',\n]\n\nexport function getPasswordSuggestions(\n password: string,\n suggestions: readonly AuthPasswordSuggestion[],\n): AuthPasswordSuggestion[] {\n return suggestions.filter((suggestion) =>\n suggestionPatterns[suggestion].test(password),\n )\n}\n",
|
|
39
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/password-suggestions.ts"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "blocks/application/auth/shared/to-form-errors.ts",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"content": "export function toFormErrors(\n fieldErrors?: Readonly<Partial<Record<string, string>>>,\n): Record<string, string> {\n const errors: Record<string, string> = {}\n for (const [name, message] of Object.entries(fieldErrors ?? {}))\n if (message) errors[name] = message\n return errors\n}\n",
|
|
45
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/to-form-errors.ts"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "blocks/application/auth/shared/types.ts",
|
|
49
|
+
"type": "registry:file",
|
|
50
|
+
"content": "import type { RenderLink } from '@tc96/ui/render-anchor'\nimport type { ReactNode } from 'react'\n\nexport type AuthRenderLink = RenderLink\n\nexport interface AuthProvider {\n icon?: ReactNode\n id: string\n label: string\n}\n\nexport type AuthFieldErrors<TValues> = Partial<Record<keyof TValues, string>>\n\nexport type AuthPasswordSuggestion =\n | 'lowercase'\n | 'uppercase'\n | 'number'\n | 'symbol'\n\nexport interface AuthCommonLabels {\n email: string\n errorTitle: string\n hidePassword: string\n password: string\n providerContinue: (label: string) => string\n providersGroup: string\n providersSeparator: string\n showPassword: string\n}\n\nexport interface AuthNewPasswordLabels {\n confirmPassword: string\n passwordMismatch: string\n suggestionLowercase: string\n suggestionMet: string\n suggestionMissing: string\n suggestionNumber: string\n suggestionSymbol: string\n suggestionUppercase: string\n}\n\nexport interface AuthBaseProps<TLabels> {\n error?: string\n labels?: Partial<TLabels>\n logo?: ReactNode\n pending?: boolean\n renderLink?: AuthRenderLink\n}\n",
|
|
51
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/types.ts"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "blocks/application/auth/shared/use-focus-first-invalid.ts",
|
|
55
|
+
"type": "registry:file",
|
|
56
|
+
"content": "'use client'\n\nimport { type RefObject, useEffect, useRef } from 'react'\nimport { toFormErrors } from './to-form-errors'\n\nexport interface UseFocusFirstInvalidOptions {\n alertRef: RefObject<HTMLElement | null>\n error?: string\n fieldErrors?: Readonly<Partial<Record<string, string>>>\n formRef: RefObject<HTMLFormElement | null>\n}\n\nfunction findFirstNamedControl(\n form: HTMLFormElement | null,\n names: readonly string[],\n): HTMLElement | undefined {\n return Array.from(form?.elements ?? []).find(\n (element): element is HTMLElement =>\n element instanceof HTMLElement &&\n !(element instanceof HTMLInputElement && element.type === 'hidden') &&\n names.includes(element.getAttribute('name') ?? ''),\n )\n}\n\nexport function useFocusFirstInvalid({\n alertRef,\n error,\n fieldErrors,\n formRef,\n}: UseFocusFirstInvalidOptions): void {\n const invalidNames = Object.keys(toFormErrors(fieldErrors)).join('\\n')\n const hasError = Boolean(error)\n const previous = useRef({ hasError, invalidNames })\n\n useEffect(() => {\n const before = previous.current\n previous.current = { hasError, invalidNames }\n const hasFieldErrors = invalidNames !== ''\n const filled =\n (hasFieldErrors && before.invalidNames === '') ||\n (hasError && !before.hasError)\n if (!filled) return\n const field = hasFieldErrors\n ? findFirstNamedControl(formRef.current, invalidNames.split('\\n'))\n : undefined\n if (field) field.focus()\n else if (hasError) alertRef.current?.focus()\n }, [alertRef, formRef, hasError, invalidNames])\n}\n",
|
|
57
|
+
"target": "~/packages/ui/src/blocks/application/auth/shared/use-focus-first-invalid.ts"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "blocks/application/auth/signup-6/index.ts",
|
|
61
|
+
"type": "registry:file",
|
|
62
|
+
"content": "export type {\n AuthBaseProps,\n AuthCommonLabels,\n AuthFieldErrors,\n AuthNewPasswordLabels,\n AuthPasswordSuggestion,\n AuthProvider,\n AuthRenderLink,\n} from '../shared/types'\nexport { Signup6 } from './signup-6'\nexport type { Signup6Labels, Signup6Props, Signup6Values } from './types'\n",
|
|
63
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-6/index.ts"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"path": "blocks/application/auth/signup-6/labels.ts",
|
|
67
|
+
"type": "registry:file",
|
|
68
|
+
"content": "import {\n defaultAuthCommonLabels,\n defaultAuthNewPasswordLabels,\n} from '../shared/labels'\nimport type { Signup6Labels } from './types'\n\nexport const defaultSignup6Labels: Signup6Labels = {\n ...defaultAuthCommonLabels,\n ...defaultAuthNewPasswordLabels,\n description: 'Preencha os dados para criar a sua conta.',\n hasAccount: 'Já tem uma conta?',\n login: 'Entrar',\n mediaLabel: 'Apresentação do produto',\n name: 'Nome',\n privacy: 'Política de Privacidade',\n providersSeparator: 'ou continue com',\n submit: 'Criar conta',\n terms: 'Termos de Uso',\n termsAnd: 'e a',\n termsLead: 'Ao criar a conta você concorda com os',\n title: 'Criar conta',\n}\n",
|
|
69
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-6/labels.ts"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"path": "blocks/application/auth/signup-6/signup-6.tsx",
|
|
73
|
+
"type": "registry:file",
|
|
74
|
+
"content": "'use client'\n\nimport { Button } from '@tc96/ui/button'\nimport { Field, FieldError, FieldLabel } from '@tc96/ui/field'\nimport { Form } from '@tc96/ui/form'\nimport { Input } from '@tc96/ui/input'\nimport { renderAnchor } from '@tc96/ui/render-anchor'\nimport { Fragment, type ReactElement, useMemo, useRef, useState } from 'react'\nimport { AuthPasswordFeedback } from '../shared/auth-password-feedback'\nimport { AuthPasswordField } from '../shared/auth-password-field'\nimport { AuthSplitLayout } from '../shared/auth-split-layout'\nimport { AuthSplitProviders } from '../shared/auth-split-providers'\nimport { resolveAuthLabels } from '../shared/labels'\nimport { defaultPasswordSuggestions } from '../shared/password-suggestions'\nimport { toFormErrors } from '../shared/to-form-errors'\nimport { useFocusFirstInvalid } from '../shared/use-focus-first-invalid'\nimport { defaultSignup6Labels } from './labels'\nimport type { Signup6Props, Signup6Values } from './types'\n\nfunction toSignup6Values(\n values: Readonly<Record<string, unknown>>,\n): Signup6Values {\n return {\n email: String(values.email ?? ''),\n name: String(values.name ?? ''),\n password: String(values.password ?? ''),\n }\n}\n\nexport function Signup6({\n error,\n fieldErrors,\n labels: labelsProp,\n loginHref,\n logo,\n media,\n onProviderSelect,\n onSubmit,\n passwordMinLength = 8,\n passwordSuggestions = defaultPasswordSuggestions,\n pending = false,\n privacyHref,\n providers,\n renderLink = renderAnchor,\n showProviders = true,\n termsHref,\n}: Readonly<Signup6Props>): ReactElement {\n const labels = resolveAuthLabels(defaultSignup6Labels, labelsProp)\n const formRef = useRef<HTMLFormElement>(null)\n const alertRef = useRef<HTMLDivElement>(null)\n const [password, setPassword] = useState('')\n const [mismatch, setMismatch] = useState(false)\n const errors = useMemo(\n () => ({\n ...toFormErrors(fieldErrors),\n ...(mismatch ? { confirmPassword: labels.passwordMismatch } : undefined),\n }),\n [fieldErrors, labels.passwordMismatch, mismatch],\n )\n\n useFocusFirstInvalid({ alertRef, error, fieldErrors, formRef })\n\n const legalLinks: { href: string; label: string }[] = []\n if (termsHref) legalLinks.push({ href: termsHref, label: labels.terms })\n if (privacyHref) legalLinks.push({ href: privacyHref, label: labels.privacy })\n\n return (\n <AuthSplitLayout\n alertRef={alertRef}\n description={labels.description}\n error={error}\n errorTitle={labels.errorTitle}\n footer={\n loginHref ? (\n <>\n <span>{labels.hasAccount}</span>\n <Button\n className=\"underline\"\n render={renderLink(loginHref)}\n size=\"sm\"\n variant=\"link\"\n >\n {labels.login}\n </Button>\n </>\n ) : undefined\n }\n logo={logo}\n media={media}\n mediaLabel={labels.mediaLabel}\n title={labels.title}\n >\n <Form\n aria-busy={pending}\n className=\"flex flex-col gap-4\"\n errors={errors}\n onFormSubmit={(values) => {\n if (pending) return\n if (values.password !== values.confirmPassword) {\n setMismatch(true)\n return\n }\n onSubmit(toSignup6Values(values))\n }}\n ref={formRef}\n >\n <Field name=\"name\">\n <FieldLabel>{labels.name}</FieldLabel>\n <Input autoComplete=\"name\" required />\n <FieldError />\n </Field>\n <Field name=\"email\">\n <FieldLabel>{labels.email}</FieldLabel>\n <Input autoComplete=\"email\" required type=\"email\" />\n <FieldError />\n </Field>\n <AuthPasswordField\n autoComplete=\"new-password\"\n hideLabel={labels.hidePassword}\n label={labels.password}\n minLength={passwordMinLength}\n name=\"password\"\n onValueChange={(value) => {\n setPassword(value)\n setMismatch(false)\n }}\n showLabel={labels.showPassword}\n >\n <AuthPasswordFeedback\n labels={labels}\n password={password}\n suggestions={passwordSuggestions}\n />\n </AuthPasswordField>\n <AuthPasswordField\n autoComplete=\"new-password\"\n hideLabel={labels.hidePassword}\n label={labels.confirmPassword}\n name=\"confirmPassword\"\n onValueChange={() => setMismatch(false)}\n showLabel={labels.showPassword}\n />\n <Button className=\"w-full\" loading={pending} type=\"submit\">\n {labels.submit}\n </Button>\n </Form>\n <AuthSplitProviders\n labels={labels}\n onSelect={onProviderSelect}\n pending={pending}\n providers={showProviders ? providers : undefined}\n />\n {legalLinks.length ? (\n <p className=\"flex flex-wrap items-center gap-x-1 text-muted-foreground text-xs\">\n <span>{labels.termsLead}</span>\n {legalLinks.map((link, index) => (\n <Fragment key={link.href}>\n {index > 0 ? <span>{labels.termsAnd}</span> : null}\n <Button\n className=\"px-0 underline\"\n render={renderLink(link.href)}\n size=\"sm\"\n variant=\"link\"\n >\n {link.label}\n </Button>\n </Fragment>\n ))}\n </p>\n ) : null}\n </AuthSplitLayout>\n )\n}\n",
|
|
75
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-6/signup-6.tsx"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"path": "blocks/application/auth/signup-6/types.ts",
|
|
79
|
+
"type": "registry:file",
|
|
80
|
+
"content": "import type { ReactNode } from 'react'\nimport type {\n AuthBaseProps,\n AuthCommonLabels,\n AuthFieldErrors,\n AuthNewPasswordLabels,\n AuthPasswordSuggestion,\n AuthProvider,\n} from '../shared/types'\n\nexport interface Signup6Values {\n name: string\n email: string\n password: string\n}\n\nexport interface Signup6Labels extends AuthCommonLabels, AuthNewPasswordLabels {\n description: string\n hasAccount: string\n login: string\n mediaLabel: string\n name: string\n privacy: string\n submit: string\n terms: string\n termsAnd: string\n termsLead: string\n title: string\n}\n\nexport interface Signup6Props extends AuthBaseProps<Signup6Labels> {\n fieldErrors?: AuthFieldErrors<Signup6Values>\n loginHref?: string\n media?: ReactNode\n onProviderSelect?: (id: string) => void\n onSubmit: (values: Signup6Values) => void\n passwordMinLength?: number\n passwordSuggestions?: AuthPasswordSuggestion[]\n privacyHref?: string\n providers?: AuthProvider[]\n showProviders?: boolean\n termsHref?: string\n}\n",
|
|
81
|
+
"target": "~/packages/ui/src/blocks/application/auth/signup-6/types.ts"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"dependencies": [
|
|
85
|
+
"@phosphor-icons/react@2.1.10",
|
|
86
|
+
"react@19.1.1"
|
|
87
|
+
],
|
|
88
|
+
"registryDependencies": [
|
|
89
|
+
"@ui/alert",
|
|
90
|
+
"@ui/button",
|
|
91
|
+
"@ui/field",
|
|
92
|
+
"@ui/form",
|
|
93
|
+
"@ui/input",
|
|
94
|
+
"@ui/input-group",
|
|
95
|
+
"@ui/render-anchor",
|
|
96
|
+
"@ui/separator"
|
|
97
|
+
],
|
|
98
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
99
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "state-surface",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "patterns/surfaces/state/composition/index.ts",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"content": "export * from './state-guard/index'\nexport * from './state-surface/index'\n",
|
|
9
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/composition/index.ts"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "patterns/surfaces/state/composition/state-guard/index.ts",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"content": "export { StateGuard } from './state-guard'\n",
|
|
15
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/composition/state-guard/index.ts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "patterns/surfaces/state/composition/state-guard/state-guard.tsx",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "import { Spinner } from '@tc96/ui/spinner'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport type { StateGuardProps } from '../../core'\nimport { StateSurface } from '../state-surface/index'\n\nexport function StateGuard(props: StateGuardProps): ReactNode {\n if (props.state === 'data') {\n return props.children\n }\n\n if (props.state === 'loading') {\n const { className, description, title } = props.surface\n\n return (\n <output\n className={cn(\n 'flex flex-col items-center justify-center gap-2 p-8 text-center',\n className,\n )}\n data-slot=\"state-guard-loading\"\n >\n <span className=\"text-muted-foreground\">\n <Spinner aria-hidden=\"true\" className=\"size-5\" />\n </span>\n <p className=\"font-medium text-sm\">{title}</p>\n {description ? (\n <p className=\"max-w-md text-muted-foreground text-sm\">\n {description}\n </p>\n ) : null}\n </output>\n )\n }\n\n return <StateSurface kind={props.state} {...props.surface} />\n}\n",
|
|
21
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/composition/state-guard/state-guard.tsx"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "patterns/surfaces/state/composition/state-surface/index.ts",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "export { StateSurface } from './state-surface'\n",
|
|
27
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/composition/state-surface/index.ts"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "patterns/surfaces/state/composition/state-surface/state-surface.tsx",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "import {\n FileMagnifyingGlassIcon,\n LockIcon,\n MagnifyingGlassIcon,\n TrayIcon,\n WarningIcon,\n} from '@phosphor-icons/react'\nimport {\n Empty,\n EmptyContent,\n EmptyDescription,\n EmptyHeader,\n EmptyMedia,\n EmptyTitle,\n} from '@tc96/ui/empty'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport {\n STATE_SURFACE_ICON_COLORS,\n STATE_SURFACE_ROLES,\n type StateSurfaceKind,\n type StateSurfaceProps,\n} from '../../core'\n\nconst KIND_ICONS = {\n empty: TrayIcon,\n error: WarningIcon,\n 'no-result': MagnifyingGlassIcon,\n 'not-found': FileMagnifyingGlassIcon,\n permission: LockIcon,\n} as const satisfies Record<StateSurfaceKind, typeof TrayIcon>\n\nexport function StateSurface({\n actions,\n className,\n description,\n icon,\n kind,\n title,\n}: StateSurfaceProps): ReactNode {\n const Icon = KIND_ICONS[kind]\n const iconColor = STATE_SURFACE_ICON_COLORS[kind]\n\n return (\n <Empty\n className={className}\n data-kind={kind}\n role={STATE_SURFACE_ROLES[kind]}\n >\n <EmptyHeader>\n {icon === null ? null : (\n <EmptyMedia>\n <IconFrame\n className={cn(!iconColor && 'bg-muted/60')}\n color={iconColor}\n shape=\"rounded\"\n size=\"xl\"\n >\n {icon === undefined ? <Icon aria-hidden=\"true\" /> : icon}\n </IconFrame>\n </EmptyMedia>\n )}\n <EmptyTitle>{title}</EmptyTitle>\n <EmptyDescription>{description}</EmptyDescription>\n </EmptyHeader>\n {actions ? (\n <EmptyContent className=\"flex-row flex-wrap justify-center gap-2\">\n {actions}\n </EmptyContent>\n ) : null}\n </Empty>\n )\n}\n",
|
|
33
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/composition/state-surface/state-surface.tsx"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "patterns/surfaces/state/core.ts",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"content": "import type { ReactNode } from 'react'\n\nexport const STATE_SURFACE_KINDS = [\n 'empty',\n 'no-result',\n 'error',\n 'permission',\n 'not-found',\n] as const\n\nexport type StateSurfaceKind = (typeof STATE_SURFACE_KINDS)[number]\n\nexport type StateGuardState = 'data' | 'loading' | StateSurfaceKind\n\nexport type StateSurfaceRole = 'alert' | 'status'\n\nexport const STATE_SURFACE_ROLES = {\n empty: 'status',\n error: 'alert',\n 'no-result': 'status',\n 'not-found': 'status',\n permission: 'alert',\n} as const satisfies Record<StateSurfaceKind, StateSurfaceRole>\n\nexport const STATE_SURFACE_ICON_COLORS: Partial<\n Record<StateSurfaceKind, string>\n> = {\n error: 'var(--destructive)',\n permission: 'var(--destructive)',\n}\n\nexport interface StateSurfaceProps {\n actions?: ReactNode\n className?: string\n description: ReactNode\n icon?: ReactNode\n kind: StateSurfaceKind\n title: ReactNode\n}\n\nexport type StateGuardProps = {\n children: ReactNode\n} & (\n | { state: 'data'; surface?: Omit<StateSurfaceProps, 'kind'> }\n | {\n state: 'loading'\n surface: Pick<StateSurfaceProps, 'className' | 'title'> & {\n description?: ReactNode\n }\n }\n | { state: StateSurfaceKind; surface: Omit<StateSurfaceProps, 'kind'> }\n)\n",
|
|
39
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/core.ts"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "patterns/surfaces/state/index.ts",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"content": "export * from './composition/index'\nexport type {\n StateGuardProps,\n StateGuardState,\n StateSurfaceKind,\n StateSurfaceProps,\n} from './core'\n",
|
|
45
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/index.ts"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"dependencies": [
|
|
49
|
+
"@phosphor-icons/react@2.1.10",
|
|
50
|
+
"react@19.1.1"
|
|
51
|
+
],
|
|
52
|
+
"registryDependencies": [
|
|
53
|
+
"@ui/empty",
|
|
54
|
+
"@ui/icon-frame",
|
|
55
|
+
"@ui/spinner"
|
|
56
|
+
],
|
|
57
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
58
|
+
}
|