@jcsoftdev/ui 0.3.0 → 0.5.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/CHANGELOG.md +200 -1
- package/README.md +56 -3
- package/bin/ui-theme.mjs +13 -2
- package/dist/atoms/button/button.d.ts +8 -1
- package/dist/atoms/button/button.js +10 -3
- package/dist/atoms/checkbox/checkbox.js +3 -1
- package/dist/atoms/chip/chip.d.ts +11 -3
- package/dist/atoms/chip/chip.js +8 -1
- package/dist/atoms/chip/index.d.ts +1 -1
- package/dist/atoms/chip/index.js +2 -0
- package/dist/atoms/divider/divider.d.ts +15 -0
- package/dist/atoms/divider/divider.js +27 -0
- package/dist/atoms/divider/index.d.ts +1 -0
- package/dist/atoms/divider/index.js +1 -0
- package/dist/atoms/due-chip/due-chip.d.ts +31 -0
- package/dist/atoms/due-chip/due-chip.js +41 -0
- package/dist/atoms/due-chip/index.d.ts +2 -0
- package/dist/atoms/due-chip/index.js +6 -0
- package/dist/atoms/due-chip/model.d.ts +25 -0
- package/dist/atoms/due-chip/model.js +44 -0
- package/dist/atoms/icon-button/icon-button.d.ts +22 -0
- package/dist/atoms/icon-button/icon-button.js +38 -0
- package/dist/atoms/icon-button/index.d.ts +1 -0
- package/dist/atoms/icon-button/index.js +8 -0
- package/dist/atoms/index.d.ts +6 -0
- package/dist/atoms/index.js +6 -0
- package/dist/atoms/internal/hit-area.d.ts +6 -0
- package/dist/atoms/internal/hit-area.js +4 -0
- package/dist/atoms/kbd/index.d.ts +1 -0
- package/dist/atoms/kbd/index.js +4 -0
- package/dist/atoms/kbd/kbd.d.ts +7 -0
- package/dist/atoms/kbd/kbd.js +17 -0
- package/dist/atoms/radio-group/radio-group.js +6 -2
- package/dist/atoms/seal/index.d.ts +1 -0
- package/dist/atoms/seal/index.js +4 -0
- package/dist/atoms/seal/seal.d.ts +30 -0
- package/dist/atoms/seal/seal.js +71 -0
- package/dist/atoms/spinner/index.d.ts +1 -0
- package/dist/atoms/spinner/index.js +5 -0
- package/dist/atoms/spinner/spinner.d.ts +19 -0
- package/dist/atoms/spinner/spinner.js +31 -0
- package/dist/atoms/switch/switch.js +3 -1
- package/dist/auth/auth-illustration/auth-illustration.d.ts +35 -0
- package/dist/auth/auth-illustration/auth-illustration.js +72 -0
- package/dist/auth/auth-illustration/index.d.ts +3 -0
- package/dist/auth/auth-illustration/index.js +11 -0
- package/dist/auth/auth-illustration/look.d.ts +30 -0
- package/dist/auth/auth-illustration/look.js +0 -0
- package/dist/auth/auth-illustration/model.d.ts +133 -0
- package/dist/auth/auth-illustration/model.js +202 -0
- package/dist/auth/auth-illustration/use-art-pointer.d.ts +9 -0
- package/dist/auth/auth-illustration/use-art-pointer.js +69 -0
- package/dist/auth/auth-layout/auth-layout.d.ts +80 -0
- package/dist/auth/auth-layout/auth-layout.js +190 -0
- package/dist/auth/auth-layout/index.d.ts +1 -0
- package/dist/auth/auth-layout/index.js +1 -0
- package/dist/auth/character/character.d.ts +12 -0
- package/dist/auth/character/character.js +333 -0
- package/dist/auth/character/index.d.ts +1 -0
- package/dist/auth/character/index.js +1 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.js +4 -0
- package/dist/auth/internal/auth-context.d.ts +17 -0
- package/dist/auth/internal/auth-context.js +10 -0
- package/dist/auth/internal/auth-styles.d.ts +1 -0
- package/dist/auth/internal/auth-styles.js +29 -0
- package/dist/auth/internal/portal-glyphs.d.ts +6 -0
- package/dist/auth/internal/portal-glyphs.js +39 -0
- package/dist/auth/login-form/context.d.ts +51 -0
- package/dist/auth/login-form/context.js +12 -0
- package/dist/auth/login-form/index.d.ts +2 -0
- package/dist/auth/login-form/index.js +23 -0
- package/dist/auth/login-form/login-form.d.ts +66 -0
- package/dist/auth/login-form/login-form.js +233 -0
- package/dist/auth/login-form/parts.d.ts +71 -0
- package/dist/auth/login-form/parts.js +371 -0
- package/dist/auth/looks/auth-illustration-any.d.ts +16 -0
- package/dist/auth/looks/auth-illustration-any.js +24 -0
- package/dist/auth/looks/index.d.ts +1 -0
- package/dist/auth/looks/index.js +1 -0
- package/dist/auth/mosaic/index.d.ts +1 -0
- package/dist/auth/mosaic/index.js +1 -0
- package/dist/auth/mosaic/mosaic.d.ts +11 -0
- package/dist/auth/mosaic/mosaic.js +195 -0
- package/dist/auth/slabs/index.d.ts +1 -0
- package/dist/auth/slabs/index.js +1 -0
- package/dist/auth/slabs/slabs.d.ts +13 -0
- package/dist/auth/slabs/slabs.js +136 -0
- package/dist/auth/stack/index.d.ts +1 -0
- package/dist/auth/stack/index.js +1 -0
- package/dist/auth/stack/stack.d.ts +6 -0
- package/dist/auth/stack/stack.js +222 -0
- package/dist/auth/statement/index.d.ts +1 -0
- package/dist/auth/statement/index.js +1 -0
- package/dist/auth/statement/statement.d.ts +13 -0
- package/dist/auth/statement/statement.js +99 -0
- package/dist/calendar/date-calendar/date-calendar.d.ts +32 -0
- package/dist/calendar/date-calendar/date-calendar.js +189 -0
- package/dist/calendar/date-calendar/index.d.ts +1 -0
- package/dist/calendar/date-calendar/index.js +6 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +1 -0
- package/dist/calendar/internal/date-utils.d.ts +26 -0
- package/dist/calendar/internal/date-utils.js +95 -1
- package/dist/containers/aside/aside.d.ts +14 -0
- package/dist/containers/aside/aside.js +25 -0
- package/dist/containers/aside/index.d.ts +1 -0
- package/dist/containers/aside/index.js +5 -0
- package/dist/containers/banner/banner.d.ts +4 -1
- package/dist/containers/banner/banner.js +9 -1
- package/dist/containers/description-list/description-list.d.ts +29 -6
- package/dist/containers/description-list/description-list.js +47 -6
- package/dist/containers/feed/feed.d.ts +23 -0
- package/dist/containers/feed/feed.js +77 -0
- package/dist/containers/feed/index.d.ts +2 -0
- package/dist/containers/feed/index.js +10 -0
- package/dist/containers/feed/model.d.ts +19 -0
- package/dist/containers/feed/model.js +38 -0
- package/dist/containers/index.d.ts +6 -0
- package/dist/containers/index.js +6 -0
- package/dist/containers/kpi/kpi.d.ts +50 -8
- package/dist/containers/kpi/kpi.js +91 -39
- package/dist/containers/list-detail/index.d.ts +1 -0
- package/dist/containers/list-detail/index.js +20 -0
- package/dist/containers/list-detail/list-detail.d.ts +55 -0
- package/dist/containers/list-detail/list-detail.js +221 -0
- package/dist/containers/note/index.d.ts +1 -0
- package/dist/containers/note/index.js +4 -0
- package/dist/containers/note/note.d.ts +13 -0
- package/dist/containers/note/note.js +27 -0
- package/dist/containers/section/index.d.ts +1 -0
- package/dist/containers/section/index.js +6 -0
- package/dist/containers/section/section.d.ts +68 -0
- package/dist/containers/section/section.js +198 -0
- package/dist/containers/shortcuts/index.d.ts +1 -0
- package/dist/containers/shortcuts/index.js +8 -0
- package/dist/containers/shortcuts/shortcuts.d.ts +18 -0
- package/dist/containers/shortcuts/shortcuts.js +50 -0
- package/dist/containers/table/selection.d.ts +9 -0
- package/dist/containers/table/selection.js +20 -0
- package/dist/containers/table/table.d.ts +66 -4
- package/dist/containers/table/table.js +128 -7
- package/dist/containers/timeline/index.d.ts +1 -1
- package/dist/containers/timeline/index.js +4 -2
- package/dist/containers/timeline/timeline.d.ts +32 -5
- package/dist/containers/timeline/timeline.js +154 -90
- package/dist/forms/chip-group/chip-group.d.ts +54 -0
- package/dist/forms/chip-group/chip-group.js +114 -0
- package/dist/forms/chip-group/index.d.ts +1 -0
- package/dist/forms/chip-group/index.js +6 -0
- package/dist/forms/combobox/combobox.d.ts +60 -0
- package/dist/forms/combobox/combobox.js +281 -0
- package/dist/forms/combobox/index.d.ts +1 -0
- package/dist/forms/combobox/index.js +6 -0
- package/dist/forms/date-picker/date-picker.d.ts +40 -0
- package/dist/forms/date-picker/date-picker.js +183 -0
- package/dist/forms/date-picker/date-time-picker.d.ts +43 -0
- package/dist/forms/date-picker/date-time-picker.js +121 -0
- package/dist/forms/date-picker/index.d.ts +2 -0
- package/dist/forms/date-picker/index.js +10 -0
- package/dist/forms/date-picker/model.d.ts +35 -0
- package/dist/forms/date-picker/model.js +83 -0
- package/dist/forms/dropzone/dropzone.d.ts +30 -2
- package/dist/forms/dropzone/dropzone.js +153 -23
- package/dist/forms/field/field.d.ts +16 -10
- package/dist/forms/field/field.js +41 -5
- package/dist/forms/index.d.ts +5 -0
- package/dist/forms/index.js +5 -0
- package/dist/forms/input/index.d.ts +1 -1
- package/dist/forms/input/index.js +4 -1
- package/dist/forms/input/input.d.ts +21 -5
- package/dist/forms/input/input.js +75 -9
- package/dist/forms/input-icon/input-icon.d.ts +1 -1
- package/dist/forms/internal/listbox-items.d.ts +18 -0
- package/dist/forms/internal/listbox-items.js +88 -0
- package/dist/forms/internal/listbox.d.ts +44 -0
- package/dist/forms/internal/listbox.js +74 -0
- package/dist/forms/number-stepper/model.d.ts +16 -0
- package/dist/forms/number-stepper/model.js +23 -0
- package/dist/forms/number-stepper/number-stepper.d.ts +36 -6
- package/dist/forms/number-stepper/number-stepper.js +86 -37
- package/dist/forms/password-input/index.d.ts +1 -0
- package/dist/forms/password-input/index.js +1 -0
- package/dist/forms/password-input/password-input.d.ts +16 -0
- package/dist/forms/password-input/password-input.js +45 -0
- package/dist/forms/select-menu/index.d.ts +1 -0
- package/dist/forms/select-menu/index.js +6 -0
- package/dist/forms/select-menu/select-menu.d.ts +35 -0
- package/dist/forms/select-menu/select-menu.js +230 -0
- package/dist/i18n/strings.d.ts +153 -0
- package/dist/i18n/strings.js +86 -2
- package/dist/i18n/ui-strings-provider.d.ts +1 -1
- package/dist/i18n/ui-strings-provider.js +6 -2
- package/dist/icons/eye.d.ts +2 -0
- package/dist/icons/eye.js +11 -0
- package/dist/icons/graduation-cap.d.ts +2 -0
- package/dist/icons/graduation-cap.js +12 -0
- package/dist/icons/house.d.ts +2 -0
- package/dist/icons/house.js +11 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +8 -0
- package/dist/icons/mail.d.ts +2 -0
- package/dist/icons/mail.js +11 -0
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/stepper/index.d.ts +1 -1
- package/dist/navigation/stepper/index.js +3 -1
- package/dist/navigation/stepper/stepper.d.ts +8 -0
- package/dist/navigation/stepper/stepper.js +68 -45
- package/dist/navigation/tabs/index.d.ts +1 -0
- package/dist/navigation/tabs/index.js +6 -0
- package/dist/navigation/tabs/tabs-nav.d.ts +37 -0
- package/dist/navigation/tabs/tabs-nav.js +57 -0
- package/dist/navigation/wizard/index.d.ts +1 -0
- package/dist/navigation/wizard/index.js +6 -0
- package/dist/navigation/wizard/model.d.ts +33 -0
- package/dist/navigation/wizard/model.js +34 -0
- package/dist/navigation/wizard/wizard.d.ts +45 -0
- package/dist/navigation/wizard/wizard.js +169 -0
- package/dist/overlays/alert-dialog/alert-dialog.d.ts +103 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +342 -0
- package/dist/overlays/alert-dialog/index.d.ts +1 -0
- package/dist/overlays/alert-dialog/index.js +26 -0
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +17 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +12 -4
- package/dist/overlays/dropdown-menu/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/index.js +8 -2
- package/dist/overlays/index.d.ts +2 -0
- package/dist/overlays/index.js +2 -0
- package/dist/overlays/testing/index.d.ts +5 -0
- package/dist/overlays/testing/index.js +4 -0
- package/dist/overlays/toaster/index.d.ts +2 -1
- package/dist/overlays/toaster/index.js +4 -2
- package/dist/overlays/toaster/toast-store.d.ts +6 -2
- package/dist/overlays/toaster/toast.d.ts +3 -0
- package/dist/overlays/toaster/toast.js +3 -0
- package/dist/overlays/toaster/toaster.d.ts +3 -0
- package/dist/overlays/toaster/toaster.js +36 -3
- package/dist/overlays/tooltip/index.d.ts +1 -0
- package/dist/overlays/tooltip/index.js +4 -0
- package/dist/overlays/tooltip/model.d.ts +10 -0
- package/dist/overlays/tooltip/model.js +13 -0
- package/dist/overlays/tooltip/tooltip.d.ts +41 -0
- package/dist/overlays/tooltip/tooltip.js +116 -0
- package/dist/primitives/use-dismissable-layer.js +1 -1
- package/dist/states/error-state/error-state.d.ts +6 -1
- package/dist/states/error-state/error-state.js +13 -9
- package/dist/states/skeleton/skeleton.d.ts +8 -2
- package/dist/states/skeleton/skeleton.js +44 -2
- package/icons/svg/eye.svg +4 -0
- package/icons/svg/graduation-cap.svg +5 -0
- package/icons/svg/house.svg +4 -0
- package/icons/svg/mail.svg +4 -0
- package/package.json +2 -2
- package/scripts/build-theme.mjs +12 -1
- package/src/atoms/button/button.tsx +25 -3
- package/src/atoms/checkbox/checkbox.tsx +3 -1
- package/src/atoms/chip/chip.tsx +18 -3
- package/src/atoms/chip/index.ts +2 -0
- package/src/atoms/divider/divider.tsx +40 -0
- package/src/atoms/divider/index.ts +1 -0
- package/src/atoms/due-chip/due-chip.tsx +75 -0
- package/src/atoms/due-chip/index.ts +2 -0
- package/src/atoms/due-chip/model.ts +67 -0
- package/src/atoms/icon-button/icon-button.tsx +58 -0
- package/src/atoms/icon-button/index.ts +6 -0
- package/src/atoms/index.ts +6 -0
- package/src/atoms/internal/hit-area.ts +7 -0
- package/src/atoms/kbd/index.ts +1 -0
- package/src/atoms/kbd/kbd.tsx +20 -0
- package/src/atoms/radio-group/radio-group.tsx +8 -2
- package/src/atoms/seal/index.ts +1 -0
- package/src/atoms/seal/seal.tsx +107 -0
- package/src/atoms/spinner/index.ts +1 -0
- package/src/atoms/spinner/spinner.tsx +49 -0
- package/src/atoms/switch/switch.tsx +3 -1
- package/src/auth/auth-illustration/auth-illustration.tsx +100 -0
- package/src/auth/auth-illustration/index.ts +8 -0
- package/src/auth/auth-illustration/look.ts +32 -0
- package/src/auth/auth-illustration/model.ts +330 -0
- package/src/auth/auth-illustration/use-art-pointer.ts +78 -0
- package/src/auth/auth-layout/auth-layout.tsx +282 -0
- package/src/auth/auth-layout/index.ts +1 -0
- package/src/auth/character/character.tsx +346 -0
- package/src/auth/character/index.ts +1 -0
- package/src/auth/index.ts +4 -0
- package/src/auth/internal/auth-context.ts +26 -0
- package/src/auth/internal/auth-styles.tsx +39 -0
- package/src/auth/internal/portal-glyphs.tsx +32 -0
- package/src/auth/login-form/context.ts +78 -0
- package/src/auth/login-form/index.ts +21 -0
- package/src/auth/login-form/login-form.tsx +330 -0
- package/src/auth/login-form/parts.tsx +457 -0
- package/src/auth/looks/auth-illustration-any.tsx +38 -0
- package/src/auth/looks/index.ts +1 -0
- package/src/auth/mosaic/index.ts +1 -0
- package/src/auth/mosaic/mosaic.tsx +255 -0
- package/src/auth/slabs/index.ts +1 -0
- package/src/auth/slabs/slabs.tsx +181 -0
- package/src/auth/stack/index.ts +1 -0
- package/src/auth/stack/stack.tsx +267 -0
- package/src/auth/statement/index.ts +1 -0
- package/src/auth/statement/statement.tsx +122 -0
- package/src/calendar/date-calendar/date-calendar.tsx +230 -0
- package/src/calendar/date-calendar/index.ts +5 -0
- package/src/calendar/index.ts +1 -0
- package/src/calendar/internal/date-utils.ts +115 -0
- package/src/containers/aside/aside.tsx +40 -0
- package/src/containers/aside/index.ts +1 -0
- package/src/containers/banner/banner.tsx +18 -1
- package/src/containers/description-list/description-list.tsx +85 -9
- package/src/containers/feed/feed.tsx +99 -0
- package/src/containers/feed/index.ts +8 -0
- package/src/containers/feed/model.ts +54 -0
- package/src/containers/index.ts +6 -0
- package/src/containers/kpi/kpi.tsx +161 -62
- package/src/containers/list-detail/index.ts +15 -0
- package/src/containers/list-detail/list-detail.tsx +293 -0
- package/src/containers/note/index.ts +1 -0
- package/src/containers/note/note.tsx +38 -0
- package/src/containers/section/index.ts +11 -0
- package/src/containers/section/section.tsx +281 -0
- package/src/containers/shortcuts/index.ts +6 -0
- package/src/containers/shortcuts/shortcuts.tsx +92 -0
- package/src/containers/table/selection.ts +26 -0
- package/src/containers/table/table.tsx +215 -13
- package/src/containers/timeline/index.ts +3 -0
- package/src/containers/timeline/timeline.tsx +204 -93
- package/src/forms/chip-group/chip-group.tsx +184 -0
- package/src/forms/chip-group/index.ts +8 -0
- package/src/forms/combobox/combobox.tsx +359 -0
- package/src/forms/combobox/index.ts +7 -0
- package/src/forms/date-picker/date-picker.tsx +239 -0
- package/src/forms/date-picker/date-time-picker.tsx +178 -0
- package/src/forms/date-picker/index.ts +10 -0
- package/src/forms/date-picker/model.ts +108 -0
- package/src/forms/dropzone/dropzone.tsx +217 -35
- package/src/forms/field/field.tsx +72 -7
- package/src/forms/index.ts +5 -0
- package/src/forms/input/index.ts +8 -1
- package/src/forms/input/input.tsx +99 -12
- package/src/forms/input-icon/input-icon.tsx +1 -1
- package/src/forms/internal/listbox-items.tsx +103 -0
- package/src/forms/internal/listbox.ts +124 -0
- package/src/forms/number-stepper/model.ts +35 -0
- package/src/forms/number-stepper/number-stepper.tsx +132 -42
- package/src/forms/password-input/index.ts +1 -0
- package/src/forms/password-input/password-input.tsx +57 -0
- package/src/forms/select-menu/index.ts +7 -0
- package/src/forms/select-menu/select-menu.tsx +280 -0
- package/src/i18n/strings.ts +153 -0
- package/src/i18n/ui-strings-provider.tsx +15 -4
- package/src/icons/eye.tsx +12 -0
- package/src/icons/graduation-cap.tsx +13 -0
- package/src/icons/house.tsx +12 -0
- package/src/icons/index.ts +4 -0
- package/src/icons/mail.tsx +12 -0
- package/src/navigation/index.ts +1 -0
- package/src/navigation/stepper/index.ts +7 -1
- package/src/navigation/stepper/stepper.tsx +41 -5
- package/src/navigation/tabs/index.ts +7 -0
- package/src/navigation/tabs/tabs-nav.tsx +131 -0
- package/src/navigation/wizard/index.ts +7 -0
- package/src/navigation/wizard/model.ts +61 -0
- package/src/navigation/wizard/wizard.tsx +222 -0
- package/src/overlays/alert-dialog/alert-dialog.tsx +486 -0
- package/src/overlays/alert-dialog/index.ts +19 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +29 -4
- package/src/overlays/dropdown-menu/index.ts +3 -0
- package/src/overlays/index.ts +2 -0
- package/src/overlays/testing/index.ts +5 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toast-store.ts +6 -2
- package/src/overlays/toaster/toast.ts +6 -0
- package/src/overlays/toaster/toaster.tsx +44 -2
- package/src/overlays/tooltip/index.ts +1 -0
- package/src/overlays/tooltip/model.ts +18 -0
- package/src/overlays/tooltip/tooltip.tsx +166 -0
- package/src/primitives/use-dismissable-layer.ts +7 -2
- package/src/states/error-state/error-state.tsx +19 -8
- package/src/states/skeleton/skeleton.tsx +68 -2
- package/styles/tailwind.css +33 -30
- package/styles/theme.css +33 -30
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useId,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState
|
|
9
|
+
} from "react";
|
|
10
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
11
|
+
import { cn } from "../../utils/cn.js";
|
|
12
|
+
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
13
|
+
import { formProgress } from "../auth-illustration/model.js";
|
|
14
|
+
import { useOptionalAuth } from "../internal/auth-context.js";
|
|
15
|
+
import {
|
|
16
|
+
LoginFormContext
|
|
17
|
+
} from "./context.js";
|
|
18
|
+
import {
|
|
19
|
+
LoginFormError,
|
|
20
|
+
LoginFormFooter,
|
|
21
|
+
LoginFormHeader,
|
|
22
|
+
LoginFormIdentifier,
|
|
23
|
+
LoginFormOptions,
|
|
24
|
+
LoginFormPassword,
|
|
25
|
+
LoginFormPortals,
|
|
26
|
+
LoginFormProviders,
|
|
27
|
+
LoginFormSubmit
|
|
28
|
+
} from "./parts.js";
|
|
29
|
+
const MAX_ILLUSTRATED_PORTALS = 3;
|
|
30
|
+
function LoginForm({
|
|
31
|
+
onSubmit,
|
|
32
|
+
portals = [],
|
|
33
|
+
portal: portalProp,
|
|
34
|
+
appearance: appearanceProp,
|
|
35
|
+
defaultPortal,
|
|
36
|
+
onPortalChange,
|
|
37
|
+
loading: loadingProp,
|
|
38
|
+
error: errorProp,
|
|
39
|
+
success: successProp,
|
|
40
|
+
children,
|
|
41
|
+
className,
|
|
42
|
+
classNames,
|
|
43
|
+
onFocus,
|
|
44
|
+
onBlur,
|
|
45
|
+
...props
|
|
46
|
+
}) {
|
|
47
|
+
const strings = useUiStrings();
|
|
48
|
+
const auth = useOptionalAuth();
|
|
49
|
+
const baseId = useId();
|
|
50
|
+
const identifierRef = useRef(null);
|
|
51
|
+
const passwordRef = useRef(null);
|
|
52
|
+
const [identifier, setIdentifier] = useState("");
|
|
53
|
+
const [password, setPassword] = useState("");
|
|
54
|
+
const [remember, setRemember] = useState(false);
|
|
55
|
+
const [internal, setInternal] = useState({ loading: false, error: null, success: false, field: null });
|
|
56
|
+
const [portalValue, setPortalValue] = useControllableState({
|
|
57
|
+
prop: portalProp,
|
|
58
|
+
defaultProp: defaultPortal ?? portals[0]?.value ?? "",
|
|
59
|
+
onChange: onPortalChange
|
|
60
|
+
});
|
|
61
|
+
const appearance = appearanceProp ?? (auth?.panel === "solid" ? "open" : "card");
|
|
62
|
+
const loading = loadingProp ?? internal.loading;
|
|
63
|
+
const error = errorProp !== void 0 ? errorProp : internal.error;
|
|
64
|
+
const success = successProp ?? internal.success;
|
|
65
|
+
const portalIndex = Math.max(
|
|
66
|
+
0,
|
|
67
|
+
portals.findIndex((option) => option.value === portalValue)
|
|
68
|
+
);
|
|
69
|
+
const portal = portals[portalIndex];
|
|
70
|
+
const invalidField = error ? internal.field ?? "password" : null;
|
|
71
|
+
const errorPlacement = error === null || error === void 0 || error === "" ? null : errorProp === void 0 && internal.fieldError ? "field" : "form";
|
|
72
|
+
const focusedField = useRef(null);
|
|
73
|
+
const leftOutcome = useRef(false);
|
|
74
|
+
const setAuthState = auth?.setState;
|
|
75
|
+
const setAuthProgress = auth?.setProgress;
|
|
76
|
+
const setAuthActive = auth?.setActiveIndex;
|
|
77
|
+
const progress = formProgress(identifier.length, password.length > 0);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
setAuthProgress?.(progress);
|
|
80
|
+
}, [progress, setAuthProgress]);
|
|
81
|
+
const hasPortal = portal !== void 0;
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (hasPortal) setAuthActive?.(Math.min(portalIndex, MAX_ILLUSTRATED_PORTALS - 1));
|
|
84
|
+
}, [hasPortal, portalIndex, setAuthActive]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (success) {
|
|
87
|
+
leftOutcome.current = true;
|
|
88
|
+
setAuthState?.("success");
|
|
89
|
+
} else if (error) {
|
|
90
|
+
leftOutcome.current = true;
|
|
91
|
+
setAuthState?.("error");
|
|
92
|
+
} else if (leftOutcome.current) {
|
|
93
|
+
leftOutcome.current = false;
|
|
94
|
+
const field = focusedField.current;
|
|
95
|
+
setAuthState?.(field === "identifier" ? "typing" : field || loading ? "password" : "idle");
|
|
96
|
+
}
|
|
97
|
+
}, [success, error, loading, setAuthState]);
|
|
98
|
+
const context = useMemo(
|
|
99
|
+
() => ({
|
|
100
|
+
ids: {
|
|
101
|
+
identifier: `${baseId}-identifier`,
|
|
102
|
+
password: `${baseId}-password`,
|
|
103
|
+
error: `${baseId}-error`,
|
|
104
|
+
fieldError: `${baseId}-field-error`,
|
|
105
|
+
portals: `${baseId}-portals`
|
|
106
|
+
},
|
|
107
|
+
portals,
|
|
108
|
+
portal,
|
|
109
|
+
setPortal: setPortalValue,
|
|
110
|
+
identifier,
|
|
111
|
+
password,
|
|
112
|
+
appearance,
|
|
113
|
+
remember,
|
|
114
|
+
setRemember,
|
|
115
|
+
loading,
|
|
116
|
+
error,
|
|
117
|
+
invalidField,
|
|
118
|
+
errorPlacement,
|
|
119
|
+
setValue: (field, value) => {
|
|
120
|
+
if (field === "identifier") setIdentifier(value);
|
|
121
|
+
else setPassword(value);
|
|
122
|
+
if (internal.error || internal.field) {
|
|
123
|
+
setInternal((current) => ({ ...current, error: null, field: null }));
|
|
124
|
+
}
|
|
125
|
+
setAuthState?.(field === "identifier" ? "typing" : "password");
|
|
126
|
+
},
|
|
127
|
+
identifierRef,
|
|
128
|
+
passwordRef,
|
|
129
|
+
classNames
|
|
130
|
+
}),
|
|
131
|
+
[
|
|
132
|
+
baseId,
|
|
133
|
+
portals,
|
|
134
|
+
portal,
|
|
135
|
+
setPortalValue,
|
|
136
|
+
identifier,
|
|
137
|
+
password,
|
|
138
|
+
appearance,
|
|
139
|
+
remember,
|
|
140
|
+
loading,
|
|
141
|
+
error,
|
|
142
|
+
invalidField,
|
|
143
|
+
errorPlacement,
|
|
144
|
+
internal.error,
|
|
145
|
+
internal.field,
|
|
146
|
+
classNames,
|
|
147
|
+
setAuthState
|
|
148
|
+
]
|
|
149
|
+
);
|
|
150
|
+
const fieldOf = (target) => target === identifierRef.current ? "identifier" : target === passwordRef.current ? "password" : null;
|
|
151
|
+
const handleFocus = (event) => {
|
|
152
|
+
onFocus?.(event);
|
|
153
|
+
const field = fieldOf(event.target);
|
|
154
|
+
if (field) focusedField.current = field;
|
|
155
|
+
if (field && !loading && !success && !error) {
|
|
156
|
+
setAuthState?.(field === "identifier" ? "typing" : "password");
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const handleBlur = (event) => {
|
|
160
|
+
onBlur?.(event);
|
|
161
|
+
if (!fieldOf(event.target)) return;
|
|
162
|
+
const next = event.relatedTarget;
|
|
163
|
+
const staying = next !== null && fieldOf(next) !== null;
|
|
164
|
+
if (!staying) focusedField.current = null;
|
|
165
|
+
if (!staying && !loading && !success && !error) setAuthState?.("idle");
|
|
166
|
+
};
|
|
167
|
+
const fail = (message, field, fieldError = false) => {
|
|
168
|
+
setInternal({ loading: false, error: message, success: false, field, fieldError });
|
|
169
|
+
(field === "identifier" ? identifierRef : passwordRef).current?.focus();
|
|
170
|
+
};
|
|
171
|
+
const handleSubmit = async (event) => {
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
if (loading) return;
|
|
174
|
+
if (!identifier.trim()) return fail(strings.enterIdentifier, "identifier", true);
|
|
175
|
+
if (!password) return fail(strings.enterPassword, "password", true);
|
|
176
|
+
const values = {
|
|
177
|
+
identifier: identifier.trim(),
|
|
178
|
+
password,
|
|
179
|
+
portal: portal?.value,
|
|
180
|
+
remember
|
|
181
|
+
};
|
|
182
|
+
setInternal({ loading: true, error: null, success: false, field: null });
|
|
183
|
+
try {
|
|
184
|
+
await onSubmit?.(values);
|
|
185
|
+
setInternal({ loading: false, error: null, success: onSubmit !== void 0, field: null });
|
|
186
|
+
} catch (cause) {
|
|
187
|
+
fail(
|
|
188
|
+
cause instanceof Error && cause.message ? cause.message : strings.signInFailed,
|
|
189
|
+
"password"
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
return /* @__PURE__ */ jsx(LoginFormContext, { value: context, children: /* @__PURE__ */ jsx(
|
|
194
|
+
"form",
|
|
195
|
+
{
|
|
196
|
+
method: "post",
|
|
197
|
+
noValidate: true,
|
|
198
|
+
...props,
|
|
199
|
+
"aria-busy": loading || void 0,
|
|
200
|
+
onFocus: handleFocus,
|
|
201
|
+
onBlur: handleBlur,
|
|
202
|
+
onSubmit: handleSubmit,
|
|
203
|
+
"data-appearance": appearance,
|
|
204
|
+
className: cn(
|
|
205
|
+
"grid",
|
|
206
|
+
appearance === "open" ? "mx-auto w-full max-w-110 gap-5" : "gap-3.5 px-7 pt-6.5 pb-5.5 @max-md/auth:px-1 @max-md/auth:pt-4",
|
|
207
|
+
appearance === "open" && auth?.panel === "paper" && "px-7 pt-7.5 pb-6",
|
|
208
|
+
classNames?.root,
|
|
209
|
+
className
|
|
210
|
+
),
|
|
211
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
212
|
+
/* @__PURE__ */ jsx(LoginFormHeader, {}),
|
|
213
|
+
/* @__PURE__ */ jsx(LoginFormPortals, {}),
|
|
214
|
+
/* @__PURE__ */ jsx(LoginFormError, {}),
|
|
215
|
+
/* @__PURE__ */ jsx(LoginFormIdentifier, {}),
|
|
216
|
+
/* @__PURE__ */ jsx(LoginFormPassword, {}),
|
|
217
|
+
/* @__PURE__ */ jsx(LoginFormSubmit, {})
|
|
218
|
+
] })
|
|
219
|
+
}
|
|
220
|
+
) });
|
|
221
|
+
}
|
|
222
|
+
LoginForm.Header = LoginFormHeader;
|
|
223
|
+
LoginForm.Portals = LoginFormPortals;
|
|
224
|
+
LoginForm.Identifier = LoginFormIdentifier;
|
|
225
|
+
LoginForm.Password = LoginFormPassword;
|
|
226
|
+
LoginForm.Options = LoginFormOptions;
|
|
227
|
+
LoginForm.Providers = LoginFormProviders;
|
|
228
|
+
LoginForm.Error = LoginFormError;
|
|
229
|
+
LoginForm.Submit = LoginFormSubmit;
|
|
230
|
+
LoginForm.Footer = LoginFormFooter;
|
|
231
|
+
export {
|
|
232
|
+
LoginForm
|
|
233
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { type ButtonProps } from "../../atoms/button/button.js";
|
|
3
|
+
import { Lock } from "../../icons/index.js";
|
|
4
|
+
export interface LoginFormHeaderProps extends Omit<ComponentPropsWithoutRef<"div">, "title"> {
|
|
5
|
+
/** Defaults to the localized "Sign in". */
|
|
6
|
+
title?: ReactNode;
|
|
7
|
+
/** Defaults to the description of the selected portal. */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
/** Heading element of the title. Defaults to `h1`: the form is the point of the page. */
|
|
10
|
+
titleAs?: "h1" | "h2" | "h3";
|
|
11
|
+
}
|
|
12
|
+
export declare function LoginFormHeader({ title, description, titleAs: Title, className, ...props }: LoginFormHeaderProps): import("react").JSX.Element;
|
|
13
|
+
export interface LoginFormPortalsProps {
|
|
14
|
+
/** Visible heading of the picker. Defaults to the localized "Sign in as". */
|
|
15
|
+
label?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Picker of the portal the person signs in through: a radio group of icon tiles with arrow-key
|
|
20
|
+
* navigation. Renders nothing when the form has fewer than two portals.
|
|
21
|
+
*/
|
|
22
|
+
export declare function LoginFormPortals({ label, className }: LoginFormPortalsProps): import("react").JSX.Element | null;
|
|
23
|
+
export interface LoginFormFieldProps {
|
|
24
|
+
/** Visible label. The default design hides it visually and keeps it for assistive technology. */
|
|
25
|
+
label?: string;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function LoginFormIdentifier({ label, placeholder, className }: LoginFormFieldProps): import("react").JSX.Element;
|
|
30
|
+
export interface LoginFormPasswordProps extends LoginFormFieldProps {
|
|
31
|
+
/** Adds a "Forgot your password?" link to this address. */
|
|
32
|
+
forgotHref?: string;
|
|
33
|
+
/** Replaces the forgot link with any node (a router link, a button). */
|
|
34
|
+
forgot?: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
export declare function LoginFormPassword({ label, placeholder, forgotHref, forgot, className, }: LoginFormPasswordProps): import("react").JSX.Element;
|
|
37
|
+
export interface LoginFormErrorProps extends Omit<ComponentPropsWithoutRef<"p">, "children"> {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Live region for errors about the sign-in itself (wrong credentials, a server message), shown as a
|
|
41
|
+
* callout with an alert icon; place it above the fields. A field left empty is reported under that
|
|
42
|
+
* field instead. It stays in the page while empty so the message is announced.
|
|
43
|
+
*/
|
|
44
|
+
export declare function LoginFormError({ className, ...props }: LoginFormErrorProps): import("react").JSX.Element;
|
|
45
|
+
export interface LoginFormSubmitProps extends Omit<ButtonProps, "type" | "loading"> {
|
|
46
|
+
}
|
|
47
|
+
export declare function LoginFormSubmit({ children, className, ...props }: LoginFormSubmitProps): import("react").JSX.Element;
|
|
48
|
+
export interface LoginFormFooterProps extends ComponentPropsWithoutRef<"div"> {
|
|
49
|
+
}
|
|
50
|
+
/** Terms and privacy links under the form. In the card appearance it is a strip running edge to edge. */
|
|
51
|
+
export declare function LoginFormFooter({ className, ...props }: LoginFormFooterProps): import("react").JSX.Element;
|
|
52
|
+
export { Lock as LoginFormLockIcon };
|
|
53
|
+
export interface LoginFormOptionsProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
54
|
+
/** Label of the checkbox. Defaults to the localized "Remember me". */
|
|
55
|
+
rememberLabel?: string;
|
|
56
|
+
/** Help link or button at the end of the row. */
|
|
57
|
+
help?: ReactNode;
|
|
58
|
+
/** Adds the localized "Need help?" link to this address when `help` is not given. */
|
|
59
|
+
helpHref?: string;
|
|
60
|
+
}
|
|
61
|
+
/** Row under the fields with a remember-me checkbox (reported to `onSubmit` as `remember`) and a help slot. */
|
|
62
|
+
export declare function LoginFormOptions({ rememberLabel, help, helpHref, className, ...props }: LoginFormOptionsProps): import("react").JSX.Element;
|
|
63
|
+
export interface LoginFormProvidersProps extends ComponentPropsWithoutRef<"div"> {
|
|
64
|
+
/** Text on the divider above the providers. Defaults to the localized "Or log in with". */
|
|
65
|
+
label?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Labelled slot for alternative ways to sign in. The library ships no providers: it renders only
|
|
69
|
+
* the children you pass (buttons, links) in a wrapping row, and nothing when there are none.
|
|
70
|
+
*/
|
|
71
|
+
export declare function LoginFormProviders({ label, children, className, ...props }: LoginFormProvidersProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from "../../atoms/button/button.js";
|
|
4
|
+
import { Checkbox } from "../../atoms/checkbox/checkbox.js";
|
|
5
|
+
import { Divider } from "../../atoms/divider/divider.js";
|
|
6
|
+
import { RadioGroupItem, RadioGroupRoot } from "../../atoms/radio-group/radio-group-primitive.js";
|
|
7
|
+
import { Spinner } from "../../atoms/spinner/spinner.js";
|
|
8
|
+
import { Field } from "../../forms/field/field.js";
|
|
9
|
+
import { Input } from "../../forms/input/input.js";
|
|
10
|
+
import { PasswordInput } from "../../forms/password-input/password-input.js";
|
|
11
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
12
|
+
import {
|
|
13
|
+
BookOpen,
|
|
14
|
+
Check,
|
|
15
|
+
CircleAlert,
|
|
16
|
+
GraduationCap,
|
|
17
|
+
House,
|
|
18
|
+
Lock,
|
|
19
|
+
Mail
|
|
20
|
+
} from "../../icons/index.js";
|
|
21
|
+
import { cn } from "../../utils/cn.js";
|
|
22
|
+
import {
|
|
23
|
+
useLoginForm
|
|
24
|
+
} from "./context.js";
|
|
25
|
+
const FALLBACK_ICONS = [
|
|
26
|
+
/* @__PURE__ */ jsx(BookOpen, {}, "book"),
|
|
27
|
+
/* @__PURE__ */ jsx(House, {}, "house"),
|
|
28
|
+
/* @__PURE__ */ jsx(GraduationCap, {}, "cap")
|
|
29
|
+
];
|
|
30
|
+
function LoginFormHeader({
|
|
31
|
+
title,
|
|
32
|
+
description,
|
|
33
|
+
titleAs: Title = "h1",
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}) {
|
|
37
|
+
const strings = useUiStrings();
|
|
38
|
+
const { portal, appearance, classNames } = useLoginForm("Header");
|
|
39
|
+
const open = appearance === "open";
|
|
40
|
+
const text = description ?? portal?.description;
|
|
41
|
+
return /* @__PURE__ */ jsxs("div", { ...props, className: cn("grid gap-1.5", classNames?.header, className), children: [
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
Title,
|
|
44
|
+
{
|
|
45
|
+
className: cn(
|
|
46
|
+
"m-0 font-extrabold tracking-tight",
|
|
47
|
+
open ? "text-4xl" : "text-center text-3xl",
|
|
48
|
+
classNames?.title
|
|
49
|
+
),
|
|
50
|
+
children: title ?? strings.signIn
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
text ? /* @__PURE__ */ jsx(
|
|
54
|
+
"p",
|
|
55
|
+
{
|
|
56
|
+
className: cn(
|
|
57
|
+
"m-0 text-balance text-ink-3 text-control",
|
|
58
|
+
!open && "text-center",
|
|
59
|
+
classNames?.description
|
|
60
|
+
),
|
|
61
|
+
children: text
|
|
62
|
+
}
|
|
63
|
+
) : null
|
|
64
|
+
] });
|
|
65
|
+
}
|
|
66
|
+
const PORTAL_TILE = "relative grid h-13 w-16 place-items-center rounded-input border-[1.5px] border-ink-3 bg-surface text-ink transition-[border-color,background-color,transform,box-shadow] duration-150 group-hover:-translate-y-0.5 group-focus-visible:-translate-y-0.5 group-data-[state=checked]:border-ink group-data-[state=checked]:bg-surface-2 group-data-[state=checked]:shadow-[0_2px_0_var(--ink)] [&>svg]:size-6";
|
|
67
|
+
const PORTAL_CHECK = "absolute top-1 right-1 grid size-4 scale-50 place-items-center rounded-full bg-ink text-surface opacity-0 transition-[opacity,scale] duration-150 group-data-[state=checked]:scale-100 group-data-[state=checked]:opacity-100 [&>svg]:size-3 [&>svg]:stroke-3";
|
|
68
|
+
function LoginFormPortals({ label, className }) {
|
|
69
|
+
const strings = useUiStrings();
|
|
70
|
+
const { portals, portal, setPortal, ids, appearance, classNames } = useLoginForm("Portals");
|
|
71
|
+
if (portals.length < 2) return null;
|
|
72
|
+
return /* @__PURE__ */ jsxs("div", { className: "grid gap-2.5", children: [
|
|
73
|
+
/* @__PURE__ */ jsx(
|
|
74
|
+
"div",
|
|
75
|
+
{
|
|
76
|
+
id: ids.portals,
|
|
77
|
+
className: cn(
|
|
78
|
+
"font-semibold text-ink text-control",
|
|
79
|
+
appearance === "card" && "text-center"
|
|
80
|
+
),
|
|
81
|
+
children: label ?? strings.signInAs
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
/* @__PURE__ */ jsx(
|
|
85
|
+
RadioGroupRoot,
|
|
86
|
+
{
|
|
87
|
+
"aria-labelledby": ids.portals,
|
|
88
|
+
value: portal?.value ?? "",
|
|
89
|
+
onValueChange: setPortal,
|
|
90
|
+
orientation: "horizontal",
|
|
91
|
+
className: cn("grid gap-2.5", classNames?.portals, className),
|
|
92
|
+
style: { gridTemplateColumns: `repeat(${portals.length}, minmax(0, 1fr))` },
|
|
93
|
+
children: portals.map((option, index) => /* @__PURE__ */ jsxs(
|
|
94
|
+
RadioGroupItem,
|
|
95
|
+
{
|
|
96
|
+
value: option.value,
|
|
97
|
+
className: cn(
|
|
98
|
+
"group grid cursor-pointer justify-items-center gap-1.5 rounded-input bg-transparent p-0 font-medium text-control text-ink focus-visible:focus-ring",
|
|
99
|
+
classNames?.portal
|
|
100
|
+
),
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ jsxs("span", { "aria-hidden": "true", className: PORTAL_TILE, children: [
|
|
103
|
+
option.icon ?? FALLBACK_ICONS[index],
|
|
104
|
+
/* @__PURE__ */ jsx("span", { "data-portal-check": "", className: PORTAL_CHECK, children: /* @__PURE__ */ jsx(Check, {}) })
|
|
105
|
+
] }),
|
|
106
|
+
option.label
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
option.value
|
|
110
|
+
))
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ jsx(Divider, { className: "mt-1.5", children: strings.withYourAccount })
|
|
114
|
+
] });
|
|
115
|
+
}
|
|
116
|
+
const fieldClasses = "[&_input]:text-fs-140";
|
|
117
|
+
const INVALID_INPUT = {
|
|
118
|
+
root: "focus-within:outline-danger has-[input[aria-invalid=true]]:border-2",
|
|
119
|
+
start: "text-danger"
|
|
120
|
+
};
|
|
121
|
+
function fieldErrorOf(field, { invalidField, errorPlacement, error, ids }) {
|
|
122
|
+
const invalid = invalidField === field;
|
|
123
|
+
const below = invalid && errorPlacement === "field" ? error : null;
|
|
124
|
+
return {
|
|
125
|
+
invalid,
|
|
126
|
+
below,
|
|
127
|
+
describedBy: invalid ? below ? ids.fieldError : ids.error : void 0
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function FieldError({ id, children }) {
|
|
131
|
+
return /* @__PURE__ */ jsxs(
|
|
132
|
+
"p",
|
|
133
|
+
{
|
|
134
|
+
id,
|
|
135
|
+
role: "alert",
|
|
136
|
+
className: "m-0 flex items-center gap-1.5 font-semibold text-danger text-meta [&>svg]:size-3.5 [&>svg]:shrink-0",
|
|
137
|
+
children: [
|
|
138
|
+
/* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": "true" }),
|
|
139
|
+
children
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
function LoginFormIdentifier({ label, placeholder, className }) {
|
|
145
|
+
const strings = useUiStrings();
|
|
146
|
+
const form = useLoginForm("Identifier");
|
|
147
|
+
const { ids, portal, identifier, setValue, identifierRef, appearance, classNames } = form;
|
|
148
|
+
const { invalid, below, describedBy } = fieldErrorOf("identifier", form);
|
|
149
|
+
const hideLabel = appearance === "card";
|
|
150
|
+
const text = label ?? portal?.identifierLabel ?? strings.identifier;
|
|
151
|
+
return /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", "data-login-field": "identifier", children: [
|
|
152
|
+
/* @__PURE__ */ jsx(
|
|
153
|
+
Field,
|
|
154
|
+
{
|
|
155
|
+
label: text,
|
|
156
|
+
controlId: ids.identifier,
|
|
157
|
+
classNames: { label: hideLabel ? "sr-only" : "" },
|
|
158
|
+
className: cn(fieldClasses, classNames?.identifier, className),
|
|
159
|
+
children: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
160
|
+
Input,
|
|
161
|
+
{
|
|
162
|
+
ref: identifierRef,
|
|
163
|
+
id: ids.identifier,
|
|
164
|
+
name: "identifier",
|
|
165
|
+
size: "lg",
|
|
166
|
+
autoComplete: "username",
|
|
167
|
+
autoCapitalize: "none",
|
|
168
|
+
spellCheck: false,
|
|
169
|
+
placeholder: placeholder ?? (hideLabel ? text : void 0),
|
|
170
|
+
value: identifier,
|
|
171
|
+
onChange: (event) => setValue("identifier", event.currentTarget.value),
|
|
172
|
+
start: /* @__PURE__ */ jsx(Mail, {}),
|
|
173
|
+
classNames: invalid ? INVALID_INPUT : void 0,
|
|
174
|
+
"aria-invalid": invalid || void 0,
|
|
175
|
+
"aria-describedby": describedBy
|
|
176
|
+
}
|
|
177
|
+
) })
|
|
178
|
+
}
|
|
179
|
+
),
|
|
180
|
+
below ? /* @__PURE__ */ jsx(FieldError, { id: ids.fieldError, children: below }) : null
|
|
181
|
+
] });
|
|
182
|
+
}
|
|
183
|
+
function LoginFormPassword({
|
|
184
|
+
label,
|
|
185
|
+
placeholder,
|
|
186
|
+
forgotHref,
|
|
187
|
+
forgot,
|
|
188
|
+
className
|
|
189
|
+
}) {
|
|
190
|
+
const strings = useUiStrings();
|
|
191
|
+
const form = useLoginForm("Password");
|
|
192
|
+
const { ids, password, setValue, passwordRef, appearance, classNames } = form;
|
|
193
|
+
const { invalid, below, describedBy } = fieldErrorOf("password", form);
|
|
194
|
+
const hideLabel = appearance === "card";
|
|
195
|
+
const text = label ?? strings.password;
|
|
196
|
+
const link = forgot ?? (forgotHref ? /* @__PURE__ */ jsx(
|
|
197
|
+
"a",
|
|
198
|
+
{
|
|
199
|
+
href: forgotHref,
|
|
200
|
+
className: "font-medium text-accent-ink text-control underline underline-offset-3 focus-visible:focus-ring",
|
|
201
|
+
children: strings.forgotPassword
|
|
202
|
+
}
|
|
203
|
+
) : null);
|
|
204
|
+
return /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", "data-login-field": "password", children: [
|
|
205
|
+
/* @__PURE__ */ jsx(
|
|
206
|
+
Field,
|
|
207
|
+
{
|
|
208
|
+
label: text,
|
|
209
|
+
controlId: ids.password,
|
|
210
|
+
classNames: { label: hideLabel ? "sr-only" : "" },
|
|
211
|
+
className: cn(fieldClasses, classNames?.password, className),
|
|
212
|
+
children: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
213
|
+
PasswordInput,
|
|
214
|
+
{
|
|
215
|
+
ref: passwordRef,
|
|
216
|
+
id: ids.password,
|
|
217
|
+
name: "password",
|
|
218
|
+
size: "lg",
|
|
219
|
+
start: /* @__PURE__ */ jsx(Lock, {}),
|
|
220
|
+
placeholder: placeholder ?? (hideLabel ? text : void 0),
|
|
221
|
+
value: password,
|
|
222
|
+
onChange: (event) => setValue("password", event.currentTarget.value),
|
|
223
|
+
classNames: invalid ? INVALID_INPUT : void 0,
|
|
224
|
+
"aria-invalid": invalid || void 0,
|
|
225
|
+
"aria-describedby": describedBy
|
|
226
|
+
}
|
|
227
|
+
) })
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
below ? /* @__PURE__ */ jsx(FieldError, { id: ids.fieldError, children: below }) : null,
|
|
231
|
+
link ? /* @__PURE__ */ jsx("div", { className: "justify-self-end", children: link }) : null
|
|
232
|
+
] });
|
|
233
|
+
}
|
|
234
|
+
function LoginFormError({ className, ...props }) {
|
|
235
|
+
const { ids, error, errorPlacement, classNames } = useLoginForm("Error");
|
|
236
|
+
const message = errorPlacement === "form" ? error : null;
|
|
237
|
+
return /* @__PURE__ */ jsx(
|
|
238
|
+
"p",
|
|
239
|
+
{
|
|
240
|
+
...props,
|
|
241
|
+
id: ids.error,
|
|
242
|
+
role: "alert",
|
|
243
|
+
className: cn(
|
|
244
|
+
"m-0 empty:absolute",
|
|
245
|
+
message && "flex items-start gap-2 rounded-input bg-danger-soft px-3 py-2.5 font-semibold text-danger text-meta [&>svg]:mt-px [&>svg]:size-4 [&>svg]:shrink-0",
|
|
246
|
+
classNames?.error,
|
|
247
|
+
className
|
|
248
|
+
),
|
|
249
|
+
children: message ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
250
|
+
/* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": "true" }),
|
|
251
|
+
message
|
|
252
|
+
] }) : null
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
function LoginFormSubmit({ children, className, ...props }) {
|
|
257
|
+
const strings = useUiStrings();
|
|
258
|
+
const { loading, appearance, classNames } = useLoginForm("Submit");
|
|
259
|
+
return /* @__PURE__ */ jsxs(
|
|
260
|
+
Button,
|
|
261
|
+
{
|
|
262
|
+
variant: "primary",
|
|
263
|
+
size: "lg",
|
|
264
|
+
block: true,
|
|
265
|
+
...props,
|
|
266
|
+
type: "submit",
|
|
267
|
+
loading,
|
|
268
|
+
className: cn(appearance === "open" && "rounded-pill", classNames?.submit, className),
|
|
269
|
+
children: [
|
|
270
|
+
loading ? /* @__PURE__ */ jsx(Spinner, { size: "sm", label: false }) : null,
|
|
271
|
+
children ?? strings.signInAction
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
function LoginFormFooter({ className, ...props }) {
|
|
277
|
+
const { appearance, classNames } = useLoginForm("Footer");
|
|
278
|
+
return /* @__PURE__ */ jsx(
|
|
279
|
+
"div",
|
|
280
|
+
{
|
|
281
|
+
...props,
|
|
282
|
+
className: cn(
|
|
283
|
+
"text-ink-3 text-meta [&_a]:text-inherit [&_a]:underline [&_a]:underline-offset-2",
|
|
284
|
+
appearance === "card" ? "-mx-7 -mb-5.5 mt-1 border-t-divider px-5 py-3.5 text-center @max-md/auth:-mx-1 @max-md/auth:px-1" : "text-center",
|
|
285
|
+
classNames?.footer,
|
|
286
|
+
className
|
|
287
|
+
)
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
function LoginFormOptions({
|
|
292
|
+
rememberLabel,
|
|
293
|
+
help,
|
|
294
|
+
helpHref,
|
|
295
|
+
className,
|
|
296
|
+
...props
|
|
297
|
+
}) {
|
|
298
|
+
const strings = useUiStrings();
|
|
299
|
+
const { remember, setRemember, classNames } = useLoginForm("Options");
|
|
300
|
+
const link = help ?? (helpHref ? /* @__PURE__ */ jsx(
|
|
301
|
+
"a",
|
|
302
|
+
{
|
|
303
|
+
href: helpHref,
|
|
304
|
+
className: "font-medium text-accent-ink text-control underline underline-offset-3 focus-visible:focus-ring",
|
|
305
|
+
children: strings.needHelp
|
|
306
|
+
}
|
|
307
|
+
) : null);
|
|
308
|
+
return /* @__PURE__ */ jsxs(
|
|
309
|
+
"div",
|
|
310
|
+
{
|
|
311
|
+
...props,
|
|
312
|
+
className: cn(
|
|
313
|
+
"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",
|
|
314
|
+
classNames?.options,
|
|
315
|
+
className
|
|
316
|
+
),
|
|
317
|
+
children: [
|
|
318
|
+
/* @__PURE__ */ jsx(
|
|
319
|
+
Checkbox,
|
|
320
|
+
{
|
|
321
|
+
name: "remember",
|
|
322
|
+
checked: remember,
|
|
323
|
+
onCheckedChange: (checked) => setRemember(checked === true),
|
|
324
|
+
label: rememberLabel ?? strings.rememberMe,
|
|
325
|
+
classNames: { wrapper: "-ml-2.75" }
|
|
326
|
+
}
|
|
327
|
+
),
|
|
328
|
+
link
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
function LoginFormProviders({
|
|
334
|
+
label,
|
|
335
|
+
children,
|
|
336
|
+
className,
|
|
337
|
+
...props
|
|
338
|
+
}) {
|
|
339
|
+
const strings = useUiStrings();
|
|
340
|
+
const { classNames } = useLoginForm("Providers");
|
|
341
|
+
if (children === void 0 || children === null || children === false) return null;
|
|
342
|
+
const text = label ?? strings.orLogInWith;
|
|
343
|
+
return (
|
|
344
|
+
// biome-ignore lint/a11y/useSemanticElements: a fieldset would add a legend and form-disabling behaviour the slot does not want
|
|
345
|
+
/* @__PURE__ */ jsxs(
|
|
346
|
+
"div",
|
|
347
|
+
{
|
|
348
|
+
...props,
|
|
349
|
+
role: "group",
|
|
350
|
+
"aria-label": text,
|
|
351
|
+
className: cn("grid gap-3", classNames?.providers, className),
|
|
352
|
+
children: [
|
|
353
|
+
/* @__PURE__ */ jsx(Divider, { children: text }),
|
|
354
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center justify-center gap-2.5", children })
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
export {
|
|
361
|
+
LoginFormError,
|
|
362
|
+
LoginFormFooter,
|
|
363
|
+
LoginFormHeader,
|
|
364
|
+
LoginFormIdentifier,
|
|
365
|
+
Lock as LoginFormLockIcon,
|
|
366
|
+
LoginFormOptions,
|
|
367
|
+
LoginFormPassword,
|
|
368
|
+
LoginFormPortals,
|
|
369
|
+
LoginFormProviders,
|
|
370
|
+
LoginFormSubmit
|
|
371
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AuthIllustrationProps } from "../auth-illustration/auth-illustration.js";
|
|
2
|
+
import type { AuthLook } from "../auth-illustration/look.js";
|
|
3
|
+
export type AuthIllustrationVariant = "slabs" | "stack" | "mosaic" | "character" | "statement";
|
|
4
|
+
/** The five looks by name. Importing this module keeps all of them in the bundle. */
|
|
5
|
+
export declare const AUTH_LOOKS: Readonly<Record<AuthIllustrationVariant, AuthLook>>;
|
|
6
|
+
export interface AuthIllustrationAnyProps extends Omit<AuthIllustrationProps, "look"> {
|
|
7
|
+
/** The look by name. Defaults to `slabs`. */
|
|
8
|
+
variant?: AuthIllustrationVariant;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* `AuthIllustration` with the look chosen by a string. It imports all five looks on purpose, so an
|
|
12
|
+
* app that renders it pays for every look in its bundle (about 2 to 3 KB gzip each). Apps that use
|
|
13
|
+
* one look should pass it to `AuthIllustration` from its own entry, for example
|
|
14
|
+
* `@jcsoftdev/ui/auth/stack`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function AuthIllustrationAny({ variant, ...props }: AuthIllustrationAnyProps): import("react").JSX.Element;
|