@atproto/oauth-provider-ui 0.0.2 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authorization-page-Cms-rcBA.js +3 -0
- package/dist/authorization-page-Cms-rcBA.js.map +1 -0
- package/dist/{assets/bundle-manifest.json → bundle-manifest.json} +197 -197
- package/dist/error-page-DC6Vc-cv.js +2 -0
- package/dist/error-page-DC6Vc-cv.js.map +1 -0
- package/dist/error-view-CRGNTAn2.css +1 -0
- package/dist/error-view-MVy7C9l0.js +59 -0
- package/dist/error-view-MVy7C9l0.js.map +1 -0
- package/dist/index-CHPoD7Rp.js +20 -0
- package/dist/index-CHPoD7Rp.js.map +1 -0
- package/dist/messages-B0mgsxS-.js +2 -0
- package/dist/messages-B0mgsxS-.js.map +1 -0
- package/dist/messages-B5g8Fkio.js +2 -0
- package/dist/messages-B5g8Fkio.js.map +1 -0
- package/dist/messages-BCMss-Kt.js +2 -0
- package/dist/messages-BCMss-Kt.js.map +1 -0
- package/dist/messages-BGUrKgyK.js +2 -0
- package/dist/messages-BGUrKgyK.js.map +1 -0
- package/dist/messages-BjxAnLDp.js +2 -0
- package/dist/messages-BjxAnLDp.js.map +1 -0
- package/dist/messages-Bjysz3rI.js +2 -0
- package/dist/messages-Bjysz3rI.js.map +1 -0
- package/dist/messages-BvvEr3UX.js +2 -0
- package/dist/messages-BvvEr3UX.js.map +1 -0
- package/dist/messages-Bz6JOhJf.js +2 -0
- package/dist/messages-Bz6JOhJf.js.map +1 -0
- package/dist/messages-BzL3D1EU.js +2 -0
- package/dist/messages-BzL3D1EU.js.map +1 -0
- package/dist/messages-CAvN5UoW.js +2 -0
- package/dist/messages-CAvN5UoW.js.map +1 -0
- package/dist/messages-CEmswT1Q.js +2 -0
- package/dist/messages-CEmswT1Q.js.map +1 -0
- package/dist/messages-CHYqz0q6.js +2 -0
- package/dist/messages-CHYqz0q6.js.map +1 -0
- package/dist/messages-CRmpdijj.js +2 -0
- package/dist/messages-CRmpdijj.js.map +1 -0
- package/dist/messages-Cdb79R6S.js +2 -0
- package/dist/messages-Cdb79R6S.js.map +1 -0
- package/dist/messages-ChkJ_0WT.js +2 -0
- package/dist/messages-ChkJ_0WT.js.map +1 -0
- package/dist/messages-CqiEX6JJ.js +2 -0
- package/dist/messages-CqiEX6JJ.js.map +1 -0
- package/dist/messages-CxkHjJSR.js +2 -0
- package/dist/messages-CxkHjJSR.js.map +1 -0
- package/dist/messages-D0-cWoJ9.js +2 -0
- package/dist/messages-D0-cWoJ9.js.map +1 -0
- package/dist/messages-D2MnAxYY.js +2 -0
- package/dist/messages-D2MnAxYY.js.map +1 -0
- package/dist/messages-D5TZVsui.js +2 -0
- package/dist/messages-D5TZVsui.js.map +1 -0
- package/dist/messages-DBdV4-iw.js +2 -0
- package/dist/messages-DBdV4-iw.js.map +1 -0
- package/dist/messages-DEK3zybC.js +2 -0
- package/dist/messages-DEK3zybC.js.map +1 -0
- package/dist/messages-DGSM5jkd.js +2 -0
- package/dist/messages-DGSM5jkd.js.map +1 -0
- package/dist/messages-DJgAnSTQ.js +2 -0
- package/dist/messages-DJgAnSTQ.js.map +1 -0
- package/dist/messages-DK7O7sb_.js +2 -0
- package/dist/messages-DK7O7sb_.js.map +1 -0
- package/dist/messages-DRp7qc3j.js +2 -0
- package/dist/messages-DRp7qc3j.js.map +1 -0
- package/dist/messages-DT6xRw0m.js +2 -0
- package/dist/messages-DT6xRw0m.js.map +1 -0
- package/dist/messages-LnzLtU0L.js +2 -0
- package/dist/messages-LnzLtU0L.js.map +1 -0
- package/dist/messages-_Nk2qNGw.js +2 -0
- package/dist/messages-_Nk2qNGw.js.map +1 -0
- package/dist/messages-eHH6nZyF.js +2 -0
- package/dist/messages-eHH6nZyF.js.map +1 -0
- package/dist/messages-iNw8zY2C.js +2 -0
- package/dist/messages-iNw8zY2C.js.map +1 -0
- package/dist/messages-ipc0L8yF.js +2 -0
- package/dist/messages-ipc0L8yF.js.map +1 -0
- package/dist/messages-j7LsWm2F.js +2 -0
- package/dist/messages-j7LsWm2F.js.map +1 -0
- package/dist/messages-mgE_5UEw.js +2 -0
- package/dist/messages-mgE_5UEw.js.map +1 -0
- package/dist/messages-oRd-J5--.js +2 -0
- package/dist/messages-oRd-J5--.js.map +1 -0
- package/hydration-data.d.ts +42 -0
- package/package.json +30 -37
- package/.linguirc +0 -57
- package/CHANGELOG.md +0 -7
- package/CONTRIBUTING.md +0 -6
- package/dist/assets/COdVzed-.css +0 -3
- package/dist/assets/COdVzed-.js +0 -100
- package/dist/assets/COdVzed-.js.map +0 -1
- package/dist/assets/Cqnfnbvc.js +0 -6
- package/dist/assets/Cqnfnbvc.js.map +0 -1
- package/dist/assets/error-view-Bu4y7Nd8.js +0 -208
- package/dist/assets/error-view-Bu4y7Nd8.js.map +0 -1
- package/dist/assets/index-DXlCRM6V.js +0 -36
- package/dist/assets/index-DXlCRM6V.js.map +0 -1
- package/dist/assets/messages-2GoTm2qL.js +0 -4
- package/dist/assets/messages-2GoTm2qL.js.map +0 -1
- package/dist/assets/messages-6Cn2Jbhw.js +0 -4
- package/dist/assets/messages-6Cn2Jbhw.js.map +0 -1
- package/dist/assets/messages-75hFgOK2.js +0 -4
- package/dist/assets/messages-75hFgOK2.js.map +0 -1
- package/dist/assets/messages-B3OK4k0O.js +0 -4
- package/dist/assets/messages-B3OK4k0O.js.map +0 -1
- package/dist/assets/messages-BNXlPzKV.js +0 -4
- package/dist/assets/messages-BNXlPzKV.js.map +0 -1
- package/dist/assets/messages-BUygB8mD.js +0 -4
- package/dist/assets/messages-BUygB8mD.js.map +0 -1
- package/dist/assets/messages-BVPPcwNr.js +0 -4
- package/dist/assets/messages-BVPPcwNr.js.map +0 -1
- package/dist/assets/messages-BbbWUQS8.js +0 -4
- package/dist/assets/messages-BbbWUQS8.js.map +0 -1
- package/dist/assets/messages-BibKCYyW.js +0 -4
- package/dist/assets/messages-BibKCYyW.js.map +0 -1
- package/dist/assets/messages-BlPrr9_7.js +0 -4
- package/dist/assets/messages-BlPrr9_7.js.map +0 -1
- package/dist/assets/messages-ByVCw40U.js +0 -4
- package/dist/assets/messages-ByVCw40U.js.map +0 -1
- package/dist/assets/messages-C5DU1neP.js +0 -4
- package/dist/assets/messages-C5DU1neP.js.map +0 -1
- package/dist/assets/messages-C6IgUtbX.js +0 -4
- package/dist/assets/messages-C6IgUtbX.js.map +0 -1
- package/dist/assets/messages-C92Zzt2o.js +0 -4
- package/dist/assets/messages-C92Zzt2o.js.map +0 -1
- package/dist/assets/messages-CGZqYT14.js +0 -4
- package/dist/assets/messages-CGZqYT14.js.map +0 -1
- package/dist/assets/messages-CGlsy4wt.js +0 -4
- package/dist/assets/messages-CGlsy4wt.js.map +0 -1
- package/dist/assets/messages-CPT1nd0u.js +0 -4
- package/dist/assets/messages-CPT1nd0u.js.map +0 -1
- package/dist/assets/messages-CTTdXyw_.js +0 -4
- package/dist/assets/messages-CTTdXyw_.js.map +0 -1
- package/dist/assets/messages-ChK_C_Pj.js +0 -4
- package/dist/assets/messages-ChK_C_Pj.js.map +0 -1
- package/dist/assets/messages-CjJbk7Uf.js +0 -4
- package/dist/assets/messages-CjJbk7Uf.js.map +0 -1
- package/dist/assets/messages-CoiLjLYO.js +0 -4
- package/dist/assets/messages-CoiLjLYO.js.map +0 -1
- package/dist/assets/messages-Cwx6B4Ti.js +0 -4
- package/dist/assets/messages-Cwx6B4Ti.js.map +0 -1
- package/dist/assets/messages-D0uXAp_H.js +0 -4
- package/dist/assets/messages-D0uXAp_H.js.map +0 -1
- package/dist/assets/messages-DG0_arU0.js +0 -4
- package/dist/assets/messages-DG0_arU0.js.map +0 -1
- package/dist/assets/messages-DOXFJh9K.js +0 -4
- package/dist/assets/messages-DOXFJh9K.js.map +0 -1
- package/dist/assets/messages-DPK7nOoC.js +0 -4
- package/dist/assets/messages-DPK7nOoC.js.map +0 -1
- package/dist/assets/messages-Duccgtu0.js +0 -4
- package/dist/assets/messages-Duccgtu0.js.map +0 -1
- package/dist/assets/messages-DxTqgsHq.js +0 -4
- package/dist/assets/messages-DxTqgsHq.js.map +0 -1
- package/dist/assets/messages-E5_lTg7A.js +0 -4
- package/dist/assets/messages-E5_lTg7A.js.map +0 -1
- package/dist/assets/messages-UhunAjh1.js +0 -4
- package/dist/assets/messages-UhunAjh1.js.map +0 -1
- package/dist/assets/messages-Xg_3YLGw.js +0 -4
- package/dist/assets/messages-Xg_3YLGw.js.map +0 -1
- package/dist/assets/messages-iliBQHY2.js +0 -4
- package/dist/assets/messages-iliBQHY2.js.map +0 -1
- package/dist/assets/messages-lRprpIl-.js +0 -4
- package/dist/assets/messages-lRprpIl-.js.map +0 -1
- package/dist/assets/messages-pbPHQbz1.js +0 -4
- package/dist/assets/messages-pbPHQbz1.js.map +0 -1
- package/dist/assets/messages-q-O7ZQGs.js +0 -4
- package/dist/assets/messages-q-O7ZQGs.js.map +0 -1
- package/dist/lib/index.d.ts +0 -19
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/index.js +0 -47
- package/dist/lib/index.js.map +0 -1
- package/dist/tsconfig.backend.tsbuildinfo +0 -1
- package/lib/index.ts +0 -72
- package/rollup.config.js +0 -102
- package/src/authorization-page.html +0 -183
- package/src/authorization-page.tsx +0 -55
- package/src/backend-data.ts +0 -35
- package/src/components/forms/button-toggle-visibility.tsx +0 -43
- package/src/components/forms/button.tsx +0 -60
- package/src/components/forms/fieldset.tsx +0 -55
- package/src/components/forms/form-card-async.tsx +0 -103
- package/src/components/forms/form-card.tsx +0 -49
- package/src/components/forms/input-checkbox.tsx +0 -78
- package/src/components/forms/input-container.tsx +0 -107
- package/src/components/forms/input-email-address.tsx +0 -65
- package/src/components/forms/input-new-password.tsx +0 -62
- package/src/components/forms/input-password.tsx +0 -87
- package/src/components/forms/input-text.tsx +0 -82
- package/src/components/forms/input-token.tsx +0 -94
- package/src/components/forms/wizard-card.tsx +0 -116
- package/src/components/layouts/layout-title-page.tsx +0 -77
- package/src/components/layouts/layout-welcome.tsx +0 -73
- package/src/components/utils/account-identifier.tsx +0 -23
- package/src/components/utils/account-image.tsx +0 -33
- package/src/components/utils/admonition.tsx +0 -52
- package/src/components/utils/client-name.tsx +0 -45
- package/src/components/utils/error-card.tsx +0 -93
- package/src/components/utils/error-message.tsx +0 -88
- package/src/components/utils/help-card.tsx +0 -46
- package/src/components/utils/icons.tsx +0 -88
- package/src/components/utils/link-anchor.tsx +0 -28
- package/src/components/utils/link-title.tsx +0 -26
- package/src/components/utils/multi-lang-string.tsx +0 -56
- package/src/components/utils/password-strength-label.tsx +0 -37
- package/src/components/utils/password-strength-meter.tsx +0 -58
- package/src/components/utils/url-viewer.tsx +0 -73
- package/src/cookies.ts +0 -11
- package/src/error-page.html +0 -125
- package/src/error-page.tsx +0 -29
- package/src/hooks/use-api.ts +0 -182
- package/src/hooks/use-async-action.ts +0 -120
- package/src/hooks/use-bound-dispatch.ts +0 -5
- package/src/hooks/use-browser-color-scheme.ts +0 -31
- package/src/hooks/use-csrf-token.ts +0 -5
- package/src/hooks/use-random-string.ts +0 -37
- package/src/hooks/use-stepper.ts +0 -87
- package/src/index.html +0 -13
- package/src/lib/api.ts +0 -234
- package/src/lib/backend-data.ts +0 -6
- package/src/lib/clsx.ts +0 -6
- package/src/lib/json-client.ts +0 -97
- package/src/lib/password.ts +0 -98
- package/src/lib/ref.ts +0 -17
- package/src/lib/util.ts +0 -13
- package/src/locales/an/messages.po +0 -487
- package/src/locales/ast/messages.po +0 -487
- package/src/locales/ca/messages.po +0 -487
- package/src/locales/da/messages.po +0 -487
- package/src/locales/de/messages.po +0 -487
- package/src/locales/el/messages.po +0 -487
- package/src/locales/en/messages.po +0 -487
- package/src/locales/en-GB/messages.po +0 -487
- package/src/locales/es/messages.po +0 -487
- package/src/locales/eu/messages.po +0 -487
- package/src/locales/fi/messages.po +0 -487
- package/src/locales/fr/messages.po +0 -487
- package/src/locales/ga/messages.po +0 -487
- package/src/locales/gl/messages.po +0 -487
- package/src/locales/hi/messages.po +0 -487
- package/src/locales/hu/messages.po +0 -487
- package/src/locales/ia/messages.po +0 -487
- package/src/locales/id/messages.po +0 -487
- package/src/locales/it/messages.po +0 -487
- package/src/locales/ja/messages.po +0 -487
- package/src/locales/km/messages.po +0 -487
- package/src/locales/ko/messages.po +0 -487
- package/src/locales/load.ts +0 -8
- package/src/locales/locale-context.ts +0 -19
- package/src/locales/locale-provider.tsx +0 -112
- package/src/locales/locale-selector.tsx +0 -58
- package/src/locales/locales.ts +0 -168
- package/src/locales/ne/messages.po +0 -487
- package/src/locales/nl/messages.po +0 -487
- package/src/locales/pl/messages.po +0 -487
- package/src/locales/pt-BR/messages.po +0 -487
- package/src/locales/ro/messages.po +0 -487
- package/src/locales/ru/messages.po +0 -487
- package/src/locales/sv/messages.po +0 -487
- package/src/locales/th/messages.po +0 -487
- package/src/locales/tr/messages.po +0 -487
- package/src/locales/uk/messages.po +0 -487
- package/src/locales/vi/messages.po +0 -487
- package/src/locales/zh-CN/messages.po +0 -487
- package/src/locales/zh-HK/messages.po +0 -487
- package/src/locales/zh-TW/messages.po +0 -487
- package/src/styles.css +0 -33
- package/src/views/authorize/accept/accept-form.tsx +0 -150
- package/src/views/authorize/accept/accept-view.tsx +0 -70
- package/src/views/authorize/authorize-view.tsx +0 -183
- package/src/views/authorize/reset-password/reset-password-confirm-form.tsx +0 -88
- package/src/views/authorize/reset-password/reset-password-request-form.tsx +0 -80
- package/src/views/authorize/reset-password/reset-password-view.tsx +0 -127
- package/src/views/authorize/sign-in/sign-in-form.tsx +0 -242
- package/src/views/authorize/sign-in/sign-in-picker.tsx +0 -116
- package/src/views/authorize/sign-in/sign-in-view.tsx +0 -145
- package/src/views/authorize/sign-up/sign-up-account-form.tsx +0 -142
- package/src/views/authorize/sign-up/sign-up-disclaimer.tsx +0 -51
- package/src/views/authorize/sign-up/sign-up-handle-form.tsx +0 -287
- package/src/views/authorize/sign-up/sign-up-hcaptcha-form.tsx +0 -108
- package/src/views/authorize/sign-up/sign-up-view.tsx +0 -158
- package/src/views/authorize/welcome/welcome-view.tsx +0 -56
- package/src/views/error/error-view.tsx +0 -31
- package/tailwind.config.js +0 -31
- package/tsconfig.backend.json +0 -8
- package/tsconfig.frontend.json +0 -10
- package/tsconfig.frontend.tsbuildinfo +0 -1
- package/tsconfig.json +0 -8
- package/tsconfig.tools.json +0 -8
- package/tsconfig.tools.tsbuildinfo +0 -1
- package/vite.config.mjs +0 -16
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Trans } from '@lingui/react/macro'
|
|
2
|
-
import { FormEvent, ReactNode, useCallback } from 'react'
|
|
3
|
-
import {
|
|
4
|
-
UseAsyncActionOptions,
|
|
5
|
-
useAsyncAction,
|
|
6
|
-
} from '../../hooks/use-async-action.ts'
|
|
7
|
-
import { Override } from '../../lib/util.ts'
|
|
8
|
-
import { ErrorCard } from '../utils/error-card.tsx'
|
|
9
|
-
import { Button } from './button.tsx'
|
|
10
|
-
import { FormCard, FormCardProps } from './form-card.tsx'
|
|
11
|
-
|
|
12
|
-
export type { AsyncActionController } from '../../hooks/use-async-action.ts'
|
|
13
|
-
|
|
14
|
-
export type ErrorRender = (data: { error: Error }) => ReactNode
|
|
15
|
-
export const errorRenderDefault: ErrorRender = ({ error }) => (
|
|
16
|
-
<ErrorCard error={error} />
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
export type FormCardAsyncProps = Override<
|
|
20
|
-
Override<
|
|
21
|
-
Omit<FormCardProps, 'cancel' | 'actions' | 'prepend'>,
|
|
22
|
-
Pick<UseAsyncActionOptions, 'ref' | 'onLoading' | 'onError'>
|
|
23
|
-
>,
|
|
24
|
-
{
|
|
25
|
-
invalid?: boolean
|
|
26
|
-
disabled?: boolean
|
|
27
|
-
|
|
28
|
-
onSubmit: (signal: AbortSignal) => void | PromiseLike<void>
|
|
29
|
-
submitLabel?: ReactNode
|
|
30
|
-
|
|
31
|
-
onCancel?: () => void
|
|
32
|
-
cancelLabel?: ReactNode
|
|
33
|
-
|
|
34
|
-
errorRender?: ErrorRender
|
|
35
|
-
}
|
|
36
|
-
>
|
|
37
|
-
|
|
38
|
-
export function FormCardAsync({
|
|
39
|
-
invalid,
|
|
40
|
-
disabled,
|
|
41
|
-
|
|
42
|
-
onSubmit,
|
|
43
|
-
submitLabel,
|
|
44
|
-
|
|
45
|
-
onCancel = undefined,
|
|
46
|
-
cancelLabel,
|
|
47
|
-
|
|
48
|
-
errorRender = errorRenderDefault,
|
|
49
|
-
|
|
50
|
-
// UseAsyncActionOptions
|
|
51
|
-
ref,
|
|
52
|
-
onLoading,
|
|
53
|
-
onError,
|
|
54
|
-
|
|
55
|
-
// FormCardProps
|
|
56
|
-
children,
|
|
57
|
-
...props
|
|
58
|
-
}: FormCardAsyncProps) {
|
|
59
|
-
const { run, loading, error } = useAsyncAction(onSubmit, {
|
|
60
|
-
ref,
|
|
61
|
-
onError,
|
|
62
|
-
onLoading,
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
const doSubmit = useCallback(
|
|
66
|
-
(event: FormEvent<HTMLFormElement>) => {
|
|
67
|
-
event.preventDefault()
|
|
68
|
-
|
|
69
|
-
if (!event.currentTarget.reportValidity()) return
|
|
70
|
-
|
|
71
|
-
if (!disabled && !invalid) void run()
|
|
72
|
-
},
|
|
73
|
-
[disabled, invalid, run],
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<FormCard
|
|
78
|
-
{...props}
|
|
79
|
-
onSubmit={doSubmit}
|
|
80
|
-
disabled={disabled || loading}
|
|
81
|
-
prepend={error != null ? errorRender({ error }) : undefined}
|
|
82
|
-
cancel={
|
|
83
|
-
onCancel && (
|
|
84
|
-
<Button onClick={onCancel}>
|
|
85
|
-
{cancelLabel || <Trans>Cancel</Trans>}
|
|
86
|
-
</Button>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
actions={
|
|
90
|
-
<Button
|
|
91
|
-
color="brand"
|
|
92
|
-
type="submit"
|
|
93
|
-
loading={loading}
|
|
94
|
-
disabled={disabled}
|
|
95
|
-
>
|
|
96
|
-
{submitLabel || <Trans>Submit</Trans>}
|
|
97
|
-
</Button>
|
|
98
|
-
}
|
|
99
|
-
>
|
|
100
|
-
{children}
|
|
101
|
-
</FormCard>
|
|
102
|
-
)
|
|
103
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { JSX, ReactNode } from 'react'
|
|
2
|
-
import { Override } from '../../lib/util.ts'
|
|
3
|
-
|
|
4
|
-
export type FormCardProps = Override<
|
|
5
|
-
JSX.IntrinsicElements['form'],
|
|
6
|
-
{
|
|
7
|
-
disabled?: boolean
|
|
8
|
-
append?: ReactNode
|
|
9
|
-
prepend?: ReactNode
|
|
10
|
-
cancel?: ReactNode
|
|
11
|
-
actions?: ReactNode
|
|
12
|
-
}
|
|
13
|
-
>
|
|
14
|
-
|
|
15
|
-
export function FormCard({
|
|
16
|
-
actions,
|
|
17
|
-
cancel,
|
|
18
|
-
append,
|
|
19
|
-
children,
|
|
20
|
-
prepend,
|
|
21
|
-
disabled,
|
|
22
|
-
|
|
23
|
-
// form
|
|
24
|
-
inert = disabled,
|
|
25
|
-
...props
|
|
26
|
-
}: FormCardProps) {
|
|
27
|
-
return (
|
|
28
|
-
<form {...props} inert={inert} className="flex flex-col space-y-4">
|
|
29
|
-
{prepend && <div key="prepend">{prepend}</div>}
|
|
30
|
-
|
|
31
|
-
<div key="children" className="space-y-4">
|
|
32
|
-
{children}
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
{append && <div key="append">{append}</div>}
|
|
36
|
-
|
|
37
|
-
{(actions || cancel) && (
|
|
38
|
-
<div
|
|
39
|
-
key="buttons"
|
|
40
|
-
className="flex flex-wrap flex-row-reverse items-center justify-end space-x-reverse space-x-2"
|
|
41
|
-
>
|
|
42
|
-
{actions}
|
|
43
|
-
<div className="flex-auto" />
|
|
44
|
-
{cancel}
|
|
45
|
-
</div>
|
|
46
|
-
)}
|
|
47
|
-
</form>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { JSX, ReactNode, useContext, useRef } from 'react'
|
|
2
|
-
import { useRandomString } from '../../hooks/use-random-string.ts'
|
|
3
|
-
import { clsx } from '../../lib/clsx.ts'
|
|
4
|
-
import { mergeRefs } from '../../lib/ref.ts'
|
|
5
|
-
import { Override } from '../../lib/util.ts'
|
|
6
|
-
import { FieldsetContext } from './fieldset.tsx'
|
|
7
|
-
import { InputContainer } from './input-container.tsx'
|
|
8
|
-
|
|
9
|
-
export type InputCheckboxProps = Override<
|
|
10
|
-
Omit<JSX.IntrinsicElements['input'], 'className' | 'type' | 'children'>,
|
|
11
|
-
{
|
|
12
|
-
className?: string
|
|
13
|
-
children?: ReactNode
|
|
14
|
-
}
|
|
15
|
-
>
|
|
16
|
-
|
|
17
|
-
export function InputCheckbox({
|
|
18
|
-
className,
|
|
19
|
-
children,
|
|
20
|
-
|
|
21
|
-
// input
|
|
22
|
-
id,
|
|
23
|
-
ref,
|
|
24
|
-
disabled,
|
|
25
|
-
title,
|
|
26
|
-
'aria-label': ariaLabel = title,
|
|
27
|
-
'aria-labelledby': ariaLabelledBy,
|
|
28
|
-
...props
|
|
29
|
-
}: InputCheckboxProps) {
|
|
30
|
-
const htmlFor = useRandomString('input-checkbox-')
|
|
31
|
-
const labelRef = useRef<HTMLLabelElement>(null)
|
|
32
|
-
const inputRef = useRef<HTMLInputElement>(null)
|
|
33
|
-
const ctx = useContext(FieldsetContext)
|
|
34
|
-
|
|
35
|
-
const inputId = id ?? htmlFor
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<InputContainer
|
|
39
|
-
className={clsx('cursor-pointer', className)}
|
|
40
|
-
icon={
|
|
41
|
-
<input
|
|
42
|
-
{...props}
|
|
43
|
-
disabled={disabled ?? ctx.disabled}
|
|
44
|
-
title={title}
|
|
45
|
-
aria-label={ariaLabel}
|
|
46
|
-
aria-labelledby={
|
|
47
|
-
children
|
|
48
|
-
? // Prefer the local "<label>" element (through "htmlFor") over the wrapping "<fieldset>" to describe the checkbox.
|
|
49
|
-
undefined
|
|
50
|
-
: ariaLabelledBy ?? ctx.labelId
|
|
51
|
-
}
|
|
52
|
-
ref={mergeRefs([ref, inputRef])}
|
|
53
|
-
id={inputId}
|
|
54
|
-
className="accent-brand outline-none"
|
|
55
|
-
type="checkbox"
|
|
56
|
-
/>
|
|
57
|
-
}
|
|
58
|
-
tabIndex={-1}
|
|
59
|
-
onClick={({ target }) => {
|
|
60
|
-
// Native behavior of clicking the label should toggle the checkbox.
|
|
61
|
-
if (target === labelRef.current) return
|
|
62
|
-
if (target === inputRef.current) return
|
|
63
|
-
|
|
64
|
-
inputRef.current?.click()
|
|
65
|
-
}}
|
|
66
|
-
>
|
|
67
|
-
{children && (
|
|
68
|
-
<label
|
|
69
|
-
ref={labelRef}
|
|
70
|
-
htmlFor={inputId}
|
|
71
|
-
className="block w-full leading-[1.6] select-none cursor-pointer"
|
|
72
|
-
>
|
|
73
|
-
{children}
|
|
74
|
-
</label>
|
|
75
|
-
)}
|
|
76
|
-
</InputContainer>
|
|
77
|
-
)
|
|
78
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { JSX, ReactNode, useState } from 'react'
|
|
2
|
-
import { clsx } from '../../lib/clsx.ts'
|
|
3
|
-
import { Override } from '../../lib/util.ts'
|
|
4
|
-
|
|
5
|
-
export type InputContainerProps = Override<
|
|
6
|
-
JSX.IntrinsicElements['div'],
|
|
7
|
-
{
|
|
8
|
-
icon: ReactNode
|
|
9
|
-
append?: ReactNode
|
|
10
|
-
bellow?: ReactNode
|
|
11
|
-
}
|
|
12
|
-
>
|
|
13
|
-
|
|
14
|
-
export function InputContainer({
|
|
15
|
-
icon,
|
|
16
|
-
append,
|
|
17
|
-
bellow,
|
|
18
|
-
|
|
19
|
-
// div
|
|
20
|
-
className,
|
|
21
|
-
children,
|
|
22
|
-
onFocus,
|
|
23
|
-
onBlur,
|
|
24
|
-
...props
|
|
25
|
-
}: InputContainerProps) {
|
|
26
|
-
const [hasFocus, setHasFocus] = useState(false)
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div
|
|
30
|
-
{...props}
|
|
31
|
-
onFocus={(event) => {
|
|
32
|
-
onFocus?.(event)
|
|
33
|
-
if (!event.defaultPrevented) setHasFocus(true)
|
|
34
|
-
}}
|
|
35
|
-
onBlur={(event) => {
|
|
36
|
-
onBlur?.(event)
|
|
37
|
-
if (!event.defaultPrevented) setHasFocus(false)
|
|
38
|
-
}}
|
|
39
|
-
className={clsx(
|
|
40
|
-
// Layout
|
|
41
|
-
'min-h-12',
|
|
42
|
-
'max-w-full',
|
|
43
|
-
'overflow-hidden',
|
|
44
|
-
// Border
|
|
45
|
-
'rounded-lg',
|
|
46
|
-
className,
|
|
47
|
-
)}
|
|
48
|
-
>
|
|
49
|
-
<div
|
|
50
|
-
className={clsx(
|
|
51
|
-
// Layout
|
|
52
|
-
'px-1',
|
|
53
|
-
'w-full min-h-12',
|
|
54
|
-
'flex items-center justify-stretch',
|
|
55
|
-
// Border
|
|
56
|
-
'rounded-lg',
|
|
57
|
-
bellow ? 'rounded-br-none rounded-bl-none' : undefined,
|
|
58
|
-
'outline-none',
|
|
59
|
-
'border-solid border-2 border-transparent',
|
|
60
|
-
'focus:border-brand has-[:focus]:border-brand',
|
|
61
|
-
'hover:border-gray-400 hover:focus:border-gray-400',
|
|
62
|
-
'dark:hover:border-gray-500 dark:hover:focus:border-gray-500',
|
|
63
|
-
// Background
|
|
64
|
-
'bg-gray-100 focus:bg-slate-200 has-[:focus]:bg-slate-200',
|
|
65
|
-
'dark:bg-slate-800 dark:focus:bg-slate-700 dark:has-[:focus]:bg-slate-700',
|
|
66
|
-
// Font
|
|
67
|
-
'text-slate-600 dark:text-slate-300',
|
|
68
|
-
'accent-brand',
|
|
69
|
-
)}
|
|
70
|
-
>
|
|
71
|
-
{icon && (
|
|
72
|
-
<div
|
|
73
|
-
className={clsx(
|
|
74
|
-
'shrink-0 grow-0',
|
|
75
|
-
'mx-1',
|
|
76
|
-
hasFocus ? 'text-brand' : 'text-slate-500',
|
|
77
|
-
)}
|
|
78
|
-
>
|
|
79
|
-
{icon}
|
|
80
|
-
</div>
|
|
81
|
-
)}
|
|
82
|
-
|
|
83
|
-
{children}
|
|
84
|
-
|
|
85
|
-
<div className="ml-1 grow-0 shrink-0 flex items-center">{append}</div>
|
|
86
|
-
</div>
|
|
87
|
-
{bellow && (
|
|
88
|
-
<div
|
|
89
|
-
className={clsx(
|
|
90
|
-
// Layout
|
|
91
|
-
'px-3 py-2 space-x-2',
|
|
92
|
-
'flex flex-row items-center gap-1',
|
|
93
|
-
// Border
|
|
94
|
-
'rounded-br-2 rounded-bl-2',
|
|
95
|
-
// Background
|
|
96
|
-
'bg-gray-200 dark:bg-slate-700',
|
|
97
|
-
// Font
|
|
98
|
-
'text-gray-700 dark:text-gray-300',
|
|
99
|
-
'text-sm italic',
|
|
100
|
-
)}
|
|
101
|
-
>
|
|
102
|
-
{bellow}
|
|
103
|
-
</div>
|
|
104
|
-
)}
|
|
105
|
-
</div>
|
|
106
|
-
)
|
|
107
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useLingui } from '@lingui/react/macro'
|
|
2
|
-
import { ChangeEvent, useCallback, useState } from 'react'
|
|
3
|
-
import { Override } from '../../lib/util.ts'
|
|
4
|
-
import { AtSymbolIcon } from '../utils/icons.tsx'
|
|
5
|
-
import { InputText, InputTextProps } from './input-text.tsx'
|
|
6
|
-
|
|
7
|
-
export type InputEmailAddressProps = Override<
|
|
8
|
-
Omit<InputTextProps, 'type'>,
|
|
9
|
-
{
|
|
10
|
-
onEmail?: (email: string | undefined) => void
|
|
11
|
-
}
|
|
12
|
-
>
|
|
13
|
-
|
|
14
|
-
export function InputEmailAddress({
|
|
15
|
-
onEmail,
|
|
16
|
-
|
|
17
|
-
// InputTextProps
|
|
18
|
-
autoCapitalize = 'none',
|
|
19
|
-
autoComplete = 'email',
|
|
20
|
-
autoCorrect = 'off',
|
|
21
|
-
dir = 'auto',
|
|
22
|
-
icon = <AtSymbolIcon className="w-5" />,
|
|
23
|
-
onBlur,
|
|
24
|
-
onChange,
|
|
25
|
-
pattern = '^[^@]+@[^@]+\\.[^@]+$',
|
|
26
|
-
spellCheck = 'false',
|
|
27
|
-
value,
|
|
28
|
-
defaultValue = value,
|
|
29
|
-
title,
|
|
30
|
-
...props
|
|
31
|
-
}: InputEmailAddressProps) {
|
|
32
|
-
const { t } = useLingui()
|
|
33
|
-
const [email, setEmail] = useState<string>(
|
|
34
|
-
typeof defaultValue === 'string' ? defaultValue : '',
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
const doChange = useCallback(
|
|
38
|
-
(event: ChangeEvent<HTMLInputElement>) => {
|
|
39
|
-
const email = event.target.value.toLowerCase()
|
|
40
|
-
|
|
41
|
-
setEmail(email)
|
|
42
|
-
onChange?.(event)
|
|
43
|
-
onEmail?.(event.target.validity.valid ? email : undefined)
|
|
44
|
-
},
|
|
45
|
-
[onChange, onEmail],
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<InputText
|
|
50
|
-
{...props}
|
|
51
|
-
title={title ?? t`Email address`}
|
|
52
|
-
type="email"
|
|
53
|
-
autoCapitalize={autoCapitalize}
|
|
54
|
-
autoCorrect={autoCorrect}
|
|
55
|
-
dir={dir}
|
|
56
|
-
spellCheck={spellCheck}
|
|
57
|
-
icon={icon}
|
|
58
|
-
pattern={pattern}
|
|
59
|
-
autoComplete={autoComplete}
|
|
60
|
-
value={email}
|
|
61
|
-
onChange={doChange}
|
|
62
|
-
onBlur={onBlur}
|
|
63
|
-
/>
|
|
64
|
-
)
|
|
65
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { useLingui } from '@lingui/react/macro'
|
|
2
|
-
import { ChangeEvent, useCallback, useState } from 'react'
|
|
3
|
-
import { MIN_PASSWORD_LENGTH } from '../../lib/password.ts'
|
|
4
|
-
import { Override } from '../../lib/util.ts'
|
|
5
|
-
import { PasswordStrengthLabel } from '../utils/password-strength-label.tsx'
|
|
6
|
-
import { PasswordStrengthMeter } from '../utils/password-strength-meter.tsx'
|
|
7
|
-
import { InputPassword, InputPasswordProps } from './input-password.tsx'
|
|
8
|
-
|
|
9
|
-
export type InputNewPasswordProps = Override<
|
|
10
|
-
Omit<InputPasswordProps, 'value' | 'defaultValue'>,
|
|
11
|
-
{
|
|
12
|
-
password?: string
|
|
13
|
-
onPassword?: (password: undefined | string) => void
|
|
14
|
-
}
|
|
15
|
-
>
|
|
16
|
-
|
|
17
|
-
export function InputNewPassword({
|
|
18
|
-
password: passwordInit = '',
|
|
19
|
-
onPassword,
|
|
20
|
-
|
|
21
|
-
// InputPasswordProps
|
|
22
|
-
onChange,
|
|
23
|
-
autoComplete = 'new-password',
|
|
24
|
-
minLength = MIN_PASSWORD_LENGTH,
|
|
25
|
-
...props
|
|
26
|
-
}: InputNewPasswordProps) {
|
|
27
|
-
const { t } = useLingui()
|
|
28
|
-
const [password, setPassword] = useState<string>(passwordInit)
|
|
29
|
-
|
|
30
|
-
const doChange = useCallback(
|
|
31
|
-
(event: ChangeEvent<HTMLInputElement>) => {
|
|
32
|
-
const { value } = event.target
|
|
33
|
-
onChange?.(event)
|
|
34
|
-
if (event.defaultPrevented) return
|
|
35
|
-
setPassword(value)
|
|
36
|
-
onPassword?.(event.target.validity.valid ? value : undefined)
|
|
37
|
-
},
|
|
38
|
-
[onChange, onPassword],
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<InputPassword
|
|
43
|
-
{...props}
|
|
44
|
-
placeholder={t`Enter a password`}
|
|
45
|
-
aria-label={t`Enter your new password`}
|
|
46
|
-
title={t`Password with at least ${MIN_PASSWORD_LENGTH} characters`}
|
|
47
|
-
minLength={minLength}
|
|
48
|
-
onChange={doChange}
|
|
49
|
-
value={password}
|
|
50
|
-
autoComplete={autoComplete}
|
|
51
|
-
bellow={
|
|
52
|
-
<>
|
|
53
|
-
<PasswordStrengthMeter password={password} />
|
|
54
|
-
<PasswordStrengthLabel
|
|
55
|
-
className="grow-1 min-w-max text-xs text-gray-500 dark:text-gray-400"
|
|
56
|
-
password={password}
|
|
57
|
-
/>
|
|
58
|
-
</>
|
|
59
|
-
}
|
|
60
|
-
/>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { useLingui } from '@lingui/react/macro'
|
|
2
|
-
import { ChangeEvent, useCallback, useRef, useState } from 'react'
|
|
3
|
-
import { mergeRefs } from '../../lib/ref.ts'
|
|
4
|
-
import { Override } from '../../lib/util.ts'
|
|
5
|
-
import { LockIcon } from '../utils/icons.tsx'
|
|
6
|
-
import { ButtonToggleVisibility } from './button-toggle-visibility.tsx'
|
|
7
|
-
import { InputText, InputTextProps } from './input-text.tsx'
|
|
8
|
-
|
|
9
|
-
export type InputPasswordProps = Override<
|
|
10
|
-
Omit<InputTextProps, 'type' | 'children'>,
|
|
11
|
-
{
|
|
12
|
-
autoHide?: boolean
|
|
13
|
-
}
|
|
14
|
-
>
|
|
15
|
-
|
|
16
|
-
export function InputPassword({
|
|
17
|
-
autoHide = true,
|
|
18
|
-
|
|
19
|
-
// InputTextProps
|
|
20
|
-
onBlur,
|
|
21
|
-
onChange,
|
|
22
|
-
append,
|
|
23
|
-
autoComplete = 'current-password',
|
|
24
|
-
icon = <LockIcon className="w-5" />,
|
|
25
|
-
value,
|
|
26
|
-
defaultValue = value,
|
|
27
|
-
ref,
|
|
28
|
-
title,
|
|
29
|
-
dir = 'auto',
|
|
30
|
-
autoCapitalize = 'none',
|
|
31
|
-
autoCorrect = 'off',
|
|
32
|
-
spellCheck = 'false',
|
|
33
|
-
...props
|
|
34
|
-
}: InputPasswordProps) {
|
|
35
|
-
const { t } = useLingui()
|
|
36
|
-
const inputRef = useRef<HTMLInputElement>(null)
|
|
37
|
-
const [visible, setVisible] = useState<boolean>(false)
|
|
38
|
-
const [password, setPassword] = useState<string>(
|
|
39
|
-
typeof defaultValue === 'string' ? defaultValue : '',
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
const doChange = useCallback(
|
|
43
|
-
(event: ChangeEvent<HTMLInputElement>) => {
|
|
44
|
-
onChange?.(event)
|
|
45
|
-
setPassword(event.target.value)
|
|
46
|
-
},
|
|
47
|
-
[onChange],
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<InputText
|
|
52
|
-
{...props}
|
|
53
|
-
title={title ?? t`Password`}
|
|
54
|
-
ref={mergeRefs([ref, inputRef])}
|
|
55
|
-
dir={dir}
|
|
56
|
-
autoCapitalize={autoCapitalize}
|
|
57
|
-
autoCorrect={autoCorrect}
|
|
58
|
-
spellCheck={spellCheck}
|
|
59
|
-
icon={icon}
|
|
60
|
-
onBlur={
|
|
61
|
-
autoHide
|
|
62
|
-
? (event) => {
|
|
63
|
-
onBlur?.(event)
|
|
64
|
-
if (!event.defaultPrevented) setVisible(false)
|
|
65
|
-
}
|
|
66
|
-
: onBlur
|
|
67
|
-
}
|
|
68
|
-
value={password}
|
|
69
|
-
onChange={doChange}
|
|
70
|
-
type={visible ? 'text' : 'password'}
|
|
71
|
-
autoComplete={autoComplete}
|
|
72
|
-
append={
|
|
73
|
-
<>
|
|
74
|
-
<ButtonToggleVisibility
|
|
75
|
-
className="m-1"
|
|
76
|
-
visible={visible}
|
|
77
|
-
toggleVisible={() => {
|
|
78
|
-
setVisible((prev) => !prev)
|
|
79
|
-
inputRef.current?.focus()
|
|
80
|
-
}}
|
|
81
|
-
/>
|
|
82
|
-
{append}
|
|
83
|
-
</>
|
|
84
|
-
}
|
|
85
|
-
/>
|
|
86
|
-
)
|
|
87
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { JSX, ReactNode, useContext, useRef } from 'react'
|
|
2
|
-
import { clsx } from '../../lib/clsx.ts'
|
|
3
|
-
import { mergeRefs } from '../../lib/ref.ts'
|
|
4
|
-
import { Override } from '../../lib/util.ts'
|
|
5
|
-
import { FieldsetContext } from './fieldset.tsx'
|
|
6
|
-
import { InputContainer } from './input-container.tsx'
|
|
7
|
-
|
|
8
|
-
export type InputTextProps = Override<
|
|
9
|
-
Omit<JSX.IntrinsicElements['input'], 'children'>,
|
|
10
|
-
{
|
|
11
|
-
icon?: ReactNode
|
|
12
|
-
append?: ReactNode
|
|
13
|
-
bellow?: ReactNode
|
|
14
|
-
className?: string
|
|
15
|
-
}
|
|
16
|
-
>
|
|
17
|
-
|
|
18
|
-
export function InputText({
|
|
19
|
-
icon,
|
|
20
|
-
append,
|
|
21
|
-
bellow,
|
|
22
|
-
className,
|
|
23
|
-
|
|
24
|
-
// input
|
|
25
|
-
onFocus,
|
|
26
|
-
onBlur,
|
|
27
|
-
ref,
|
|
28
|
-
disabled,
|
|
29
|
-
title,
|
|
30
|
-
'aria-label': ariaLabel = title,
|
|
31
|
-
'aria-labelledby': ariaLabelledBy,
|
|
32
|
-
placeholder = ariaLabel,
|
|
33
|
-
...props
|
|
34
|
-
}: InputTextProps) {
|
|
35
|
-
const ctx = useContext(FieldsetContext)
|
|
36
|
-
|
|
37
|
-
const inputRef = useRef<HTMLInputElement>(null)
|
|
38
|
-
const focusedRef = useRef(false) // ref instead of state to avoid re-renders
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<InputContainer
|
|
42
|
-
icon={icon}
|
|
43
|
-
append={append}
|
|
44
|
-
bellow={bellow}
|
|
45
|
-
className={clsx('cursor-text', className)}
|
|
46
|
-
tabIndex={-1}
|
|
47
|
-
onClick={(event) => {
|
|
48
|
-
if (inputRef.current !== event.target) {
|
|
49
|
-
event.preventDefault()
|
|
50
|
-
event.stopPropagation()
|
|
51
|
-
inputRef.current?.focus()
|
|
52
|
-
}
|
|
53
|
-
}}
|
|
54
|
-
onMouseDown={(event) => {
|
|
55
|
-
if (focusedRef.current && event.target !== inputRef.current) {
|
|
56
|
-
// Prevent "blur" event from firing when clicking outside the input
|
|
57
|
-
event.preventDefault()
|
|
58
|
-
event.stopPropagation()
|
|
59
|
-
}
|
|
60
|
-
}}
|
|
61
|
-
>
|
|
62
|
-
<input
|
|
63
|
-
{...props}
|
|
64
|
-
disabled={disabled ?? ctx.disabled}
|
|
65
|
-
title={title}
|
|
66
|
-
placeholder={placeholder}
|
|
67
|
-
aria-label={ariaLabel}
|
|
68
|
-
aria-labelledby={ariaLabelledBy ?? ctx.labelId}
|
|
69
|
-
ref={mergeRefs([ref, inputRef])}
|
|
70
|
-
className="w-full bg-transparent bg-clip-padding text-base text-inherit outline-none dark:placeholder-gray-500 text-ellipsis"
|
|
71
|
-
onFocus={(event) => {
|
|
72
|
-
onFocus?.(event)
|
|
73
|
-
if (!event.defaultPrevented) focusedRef.current = true
|
|
74
|
-
}}
|
|
75
|
-
onBlur={(event) => {
|
|
76
|
-
onBlur?.(event)
|
|
77
|
-
if (!event.defaultPrevented) focusedRef.current = false
|
|
78
|
-
}}
|
|
79
|
-
/>
|
|
80
|
-
</InputContainer>
|
|
81
|
-
)
|
|
82
|
-
}
|