@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,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules every look shares (the `.ui-auth-art` wrapper, the portal glyphs, the spark burst, the error shake).
|
|
3
|
+
* Each look carries the rest of its own rules, so an app only ships the looks it renders. Every colour is derived from the theme tokens with `color-mix`,
|
|
4
|
+
* so dark mode and every `data-accent` apply without extra code. React 19 hoists and dedupes
|
|
5
|
+
* `<style href precedence>`, so rendering this from several components injects the rules once.
|
|
6
|
+
*
|
|
7
|
+
* Only the look's root `<svg>` (a direct child of `.ui-auth-art`) is sized and shaken here: icons
|
|
8
|
+
* nested inside a look, like the statement's arrow, keep their own size and motion.
|
|
9
|
+
*/
|
|
10
|
+
const CSS = `
|
|
11
|
+
@keyframes ui-auth-spark{0%{opacity:0;transform:scale(.3) rotate(0)}12%{opacity:1}100%{opacity:0;transform:translate(var(--dx),var(--dy)) scale(1.1) rotate(120deg)}}
|
|
12
|
+
@keyframes ui-auth-shake{20%,60%{transform:translateX(-9px)}40%,80%{transform:translateX(9px)}}
|
|
13
|
+
@keyframes ui-auth-rise{from{opacity:0;transform:translateY(18px)}}
|
|
14
|
+
.ui-auth-rise{animation:ui-auth-rise .7s .25s var(--motion-ease,cubic-bezier(.2,.7,.2,1)) backwards}
|
|
15
|
+
.ui-auth-art{--ua-edge:color-mix(in srgb,var(--ink) 88%,var(--surface));--ua-shadow:color-mix(in srgb,black 14%,transparent);--ua-spark-0:var(--accent);--ua-spark-1:var(--accent-2);--ua-spark-2:var(--accent-soft);--ua-spark-3:var(--ink);--ua-bounce:cubic-bezier(.34,1.5,.5,1);--ua-land:cubic-bezier(.2,.9,.25,1.15);--ua-glide:cubic-bezier(.2,.7,.2,1)}
|
|
16
|
+
.ui-auth-art[data-panel=solid]{--ua-edge:var(--auth-art-ink);--ua-tint:color-mix(in srgb,var(--auth-art-bg) 22%,white);--ua-mid:color-mix(in srgb,var(--auth-art-ink) 30%,var(--auth-art-bg));--ua-shadow:color-mix(in srgb,var(--auth-art-ink) 22%,transparent);--ua-spark-0:var(--auth-art-ink);--ua-spark-1:var(--ua-tint);--ua-spark-2:color-mix(in srgb,var(--auth-art-ink) 55%,var(--auth-art-bg));--ua-spark-3:var(--auth-art-ink)}
|
|
17
|
+
.ui-auth-art>svg{display:block;width:100%;height:auto;max-height:var(--auth-art-max-h,none);overflow:visible}
|
|
18
|
+
.ui-auth-art[data-state=error]>svg{animation:ui-auth-shake .5s var(--ua-glide)}
|
|
19
|
+
.ui-auth-g{stroke-width:3;stroke-linejoin:round;stroke:var(--glyph-b)}
|
|
20
|
+
.ui-auth-ga{fill:var(--glyph-a)}
|
|
21
|
+
.ui-auth-gc{fill:var(--glyph-c)}
|
|
22
|
+
.ui-auth-gline{fill:none}
|
|
23
|
+
.ui-auth-spark{fill:var(--ua-spark-0);opacity:0;transform-box:fill-box;transform-origin:center;animation:ui-auth-spark 1s .75s cubic-bezier(.1,.7,.3,1) both}
|
|
24
|
+
.ui-auth-spark[data-tone="1"]{fill:var(--ua-spark-1)}
|
|
25
|
+
.ui-auth-spark[data-tone="2"]{fill:var(--ua-spark-2)}
|
|
26
|
+
.ui-auth-spark[data-tone="3"]{fill:var(--ua-spark-3)}
|
|
27
|
+
@media (prefers-reduced-motion:reduce){
|
|
28
|
+
.ui-auth-rise,.ui-auth-art[data-state=error]>svg{animation:none}
|
|
29
|
+
.ui-auth-spark{animation:none;opacity:1;transform:translate(calc(var(--dx) * .62),calc(var(--dy) * .62))}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
export function AuthStyles() {
|
|
34
|
+
return (
|
|
35
|
+
<style href="jcsoftdev-ui-auth-styles" precedence="default">
|
|
36
|
+
{CSS}
|
|
37
|
+
</style>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The three portal glyphs (a book, a house and a graduation cap) on a 100px square. They paint with
|
|
5
|
+
* `--glyph-a` (fill), `--glyph-b` (outline), `--glyph-c` (detail) and `--glyph-line` (accent line).
|
|
6
|
+
*/
|
|
7
|
+
export const PORTAL_GLYPHS: readonly ReactNode[] = [
|
|
8
|
+
<g key="book">
|
|
9
|
+
<path
|
|
10
|
+
className="ui-auth-g ui-auth-ga"
|
|
11
|
+
d="M18 30 Q34 23 50 32 Q66 23 82 30 V74 Q66 67 50 76 Q34 67 18 74Z"
|
|
12
|
+
/>
|
|
13
|
+
<path
|
|
14
|
+
className="ui-auth-g ui-auth-gline"
|
|
15
|
+
d="M50 32V76"
|
|
16
|
+
style={{ stroke: "var(--glyph-line)" }}
|
|
17
|
+
/>
|
|
18
|
+
</g>,
|
|
19
|
+
<g key="house">
|
|
20
|
+
<path className="ui-auth-g ui-auth-ga" d="M50 20 L84 48 H75 V78 H25 V48 H16Z" />
|
|
21
|
+
<rect className="ui-auth-g ui-auth-gc" x="42" y="56" width="16" height="22" />
|
|
22
|
+
</g>,
|
|
23
|
+
<g key="cap">
|
|
24
|
+
<path className="ui-auth-g ui-auth-ga" d="M50 24 L90 44 L50 64 L10 44Z" />
|
|
25
|
+
<path
|
|
26
|
+
className="ui-auth-g ui-auth-gline"
|
|
27
|
+
d="M28 55 V70 Q50 84 72 70 V55"
|
|
28
|
+
style={{ stroke: "var(--glyph-line)", strokeWidth: 5 }}
|
|
29
|
+
/>
|
|
30
|
+
<path className="ui-auth-g ui-auth-gline" d="M88 46 V72" />
|
|
31
|
+
</g>,
|
|
32
|
+
];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, type ReactNode, type RefObject, useContext } from "react";
|
|
4
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
5
|
+
|
|
6
|
+
export interface LoginPortal {
|
|
7
|
+
/** Value reported to `onSubmit` and the form's `portal` field. */
|
|
8
|
+
value: string;
|
|
9
|
+
label: string;
|
|
10
|
+
/** Line under the title while this portal is selected. */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** Label and placeholder of the identifier field while this portal is selected. */
|
|
13
|
+
identifierLabel?: string;
|
|
14
|
+
/** Icon of the tile; the first three portals fall back to a book, a house and a cap. */
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type LoginFormPart =
|
|
19
|
+
| "root"
|
|
20
|
+
| "header"
|
|
21
|
+
| "title"
|
|
22
|
+
| "description"
|
|
23
|
+
| "portals"
|
|
24
|
+
| "portal"
|
|
25
|
+
| "identifier"
|
|
26
|
+
| "password"
|
|
27
|
+
| "error"
|
|
28
|
+
| "submit"
|
|
29
|
+
| "options"
|
|
30
|
+
| "providers"
|
|
31
|
+
| "footer";
|
|
32
|
+
|
|
33
|
+
export type LoginFormAppearance = "card" | "open";
|
|
34
|
+
|
|
35
|
+
export type LoginField = "identifier" | "password";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Where the current error is shown: `field` under the field it is about (a field left empty),
|
|
39
|
+
* `form` in `LoginForm.Error` (the sign-in itself failed).
|
|
40
|
+
*/
|
|
41
|
+
export type LoginErrorPlacement = "field" | "form";
|
|
42
|
+
|
|
43
|
+
export interface LoginFormContextValue {
|
|
44
|
+
ids: {
|
|
45
|
+
identifier: string;
|
|
46
|
+
password: string;
|
|
47
|
+
/** `LoginForm.Error`, the live region of errors about the whole sign-in. */
|
|
48
|
+
error: string;
|
|
49
|
+
/** Message under the identifier or the password, for errors about that field. */
|
|
50
|
+
fieldError: string;
|
|
51
|
+
portals: string;
|
|
52
|
+
};
|
|
53
|
+
portals: readonly LoginPortal[];
|
|
54
|
+
portal: LoginPortal | undefined;
|
|
55
|
+
setPortal: (value: string) => void;
|
|
56
|
+
identifier: string;
|
|
57
|
+
password: string;
|
|
58
|
+
appearance: LoginFormAppearance;
|
|
59
|
+
remember: boolean;
|
|
60
|
+
setRemember: (remember: boolean) => void;
|
|
61
|
+
loading: boolean;
|
|
62
|
+
error: string | null;
|
|
63
|
+
/** The field the current error belongs to, so it can be marked invalid. */
|
|
64
|
+
invalidField: LoginField | null;
|
|
65
|
+
errorPlacement: LoginErrorPlacement | null;
|
|
66
|
+
setValue: (field: LoginField, value: string) => void;
|
|
67
|
+
identifierRef: RefObject<HTMLInputElement | null>;
|
|
68
|
+
passwordRef: RefObject<HTMLInputElement | null>;
|
|
69
|
+
classNames: ClassNames<LoginFormPart> | undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const LoginFormContext = createContext<LoginFormContextValue | null>(null);
|
|
73
|
+
|
|
74
|
+
export function useLoginForm(part: string): LoginFormContextValue {
|
|
75
|
+
const context = useContext(LoginFormContext);
|
|
76
|
+
if (!context) throw new Error(`LoginForm.${part} must be rendered inside a LoginForm`);
|
|
77
|
+
return context;
|
|
78
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from "./login-form.js";
|
|
2
|
+
export {
|
|
3
|
+
LoginFormError,
|
|
4
|
+
type LoginFormErrorProps,
|
|
5
|
+
type LoginFormFieldProps,
|
|
6
|
+
LoginFormFooter,
|
|
7
|
+
type LoginFormFooterProps,
|
|
8
|
+
LoginFormHeader,
|
|
9
|
+
type LoginFormHeaderProps,
|
|
10
|
+
LoginFormIdentifier,
|
|
11
|
+
LoginFormOptions,
|
|
12
|
+
type LoginFormOptionsProps,
|
|
13
|
+
LoginFormPassword,
|
|
14
|
+
type LoginFormPasswordProps,
|
|
15
|
+
LoginFormPortals,
|
|
16
|
+
type LoginFormPortalsProps,
|
|
17
|
+
LoginFormProviders,
|
|
18
|
+
type LoginFormProvidersProps,
|
|
19
|
+
LoginFormSubmit,
|
|
20
|
+
type LoginFormSubmitProps,
|
|
21
|
+
} from "./parts.js";
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type ComponentPropsWithoutRef,
|
|
5
|
+
type FocusEvent,
|
|
6
|
+
type FormEvent,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
useEffect,
|
|
9
|
+
useId,
|
|
10
|
+
useMemo,
|
|
11
|
+
useRef,
|
|
12
|
+
useState,
|
|
13
|
+
} from "react";
|
|
14
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
15
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
16
|
+
import { cn } from "../../utils/cn.js";
|
|
17
|
+
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
18
|
+
import { formProgress } from "../auth-illustration/model.js";
|
|
19
|
+
import { useOptionalAuth } from "../internal/auth-context.js";
|
|
20
|
+
import {
|
|
21
|
+
type LoginField,
|
|
22
|
+
type LoginFormAppearance,
|
|
23
|
+
LoginFormContext,
|
|
24
|
+
type LoginFormContextValue,
|
|
25
|
+
type LoginFormPart,
|
|
26
|
+
type LoginPortal,
|
|
27
|
+
} from "./context.js";
|
|
28
|
+
import {
|
|
29
|
+
LoginFormError,
|
|
30
|
+
LoginFormFooter,
|
|
31
|
+
LoginFormHeader,
|
|
32
|
+
LoginFormIdentifier,
|
|
33
|
+
LoginFormOptions,
|
|
34
|
+
LoginFormPassword,
|
|
35
|
+
LoginFormPortals,
|
|
36
|
+
LoginFormProviders,
|
|
37
|
+
LoginFormSubmit,
|
|
38
|
+
} from "./parts.js";
|
|
39
|
+
|
|
40
|
+
export type { LoginFormAppearance, LoginFormPart, LoginPortal } from "./context.js";
|
|
41
|
+
|
|
42
|
+
export interface LoginValues {
|
|
43
|
+
identifier: string;
|
|
44
|
+
password: string;
|
|
45
|
+
/** Value of the selected portal; `undefined` when the form has none. */
|
|
46
|
+
portal: string | undefined;
|
|
47
|
+
/** State of `LoginForm.Options`' remember-me checkbox. */
|
|
48
|
+
remember: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const MAX_ILLUSTRATED_PORTALS = 3;
|
|
52
|
+
|
|
53
|
+
export interface LoginFormProps
|
|
54
|
+
extends Omit<ComponentPropsWithoutRef<"form">, "onSubmit" | "children"> {
|
|
55
|
+
/**
|
|
56
|
+
* Called with the values when the form is submitted with both fields filled. A returned promise
|
|
57
|
+
* keeps the form loading; if it resolves the form reads as signed in, if it rejects the message of
|
|
58
|
+
* the error (or the localized default) is shown. Leave it out and drive `loading`, `error` and
|
|
59
|
+
* `success` yourself.
|
|
60
|
+
*/
|
|
61
|
+
onSubmit?: (values: LoginValues) => void | Promise<void>;
|
|
62
|
+
/** Portals the person can sign in through. With two or more, `LoginForm.Portals` renders a picker. */
|
|
63
|
+
portals?: readonly LoginPortal[];
|
|
64
|
+
/** Selected portal value. Controlled; omit it for an uncontrolled picker. */
|
|
65
|
+
portal?: string;
|
|
66
|
+
defaultPortal?: string;
|
|
67
|
+
onPortalChange?: (value: string) => void;
|
|
68
|
+
/**
|
|
69
|
+
* `card` is the form inside the panel card, labels hidden visually. `open` has no card chrome and
|
|
70
|
+
* shows the labels above the fields with a pill button. Defaults to `open` inside an
|
|
71
|
+
* `AuthLayout panel="solid"` and `card` otherwise.
|
|
72
|
+
*/
|
|
73
|
+
appearance?: LoginFormAppearance;
|
|
74
|
+
/** The form is waiting for the server. Overrides the state `onSubmit` keeps. */
|
|
75
|
+
loading?: boolean;
|
|
76
|
+
/** Sign-in error to show. `null` clears it. Overrides the state `onSubmit` keeps. */
|
|
77
|
+
error?: string | null;
|
|
78
|
+
/** The sign-in worked. Overrides the state `onSubmit` keeps. */
|
|
79
|
+
success?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Parts to place yourself: `LoginForm.Header`, `.Portals`, `.Error`, `.Identifier`, `.Password`,
|
|
82
|
+
* `.Options`, `.Submit`, `.Providers` and `.Footer`. Without children the form renders them in that
|
|
83
|
+
* order (no `.Options`, `.Providers` or `.Footer`). A field left empty is reported under that field;
|
|
84
|
+
* `.Error` shows only errors about the sign-in itself, so place it above the fields.
|
|
85
|
+
*/
|
|
86
|
+
children?: ReactNode;
|
|
87
|
+
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
88
|
+
classNames?: ClassNames<LoginFormPart>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Sign-in form that works alone and, inside an `AuthLayout`, drives its illustration: focusing the
|
|
93
|
+
* identifier or the password, typing, failing and signing in all update the layout's state and
|
|
94
|
+
* progress, and the selected portal becomes the illustration's active slab.
|
|
95
|
+
*/
|
|
96
|
+
export function LoginForm({
|
|
97
|
+
onSubmit,
|
|
98
|
+
portals = [],
|
|
99
|
+
portal: portalProp,
|
|
100
|
+
appearance: appearanceProp,
|
|
101
|
+
defaultPortal,
|
|
102
|
+
onPortalChange,
|
|
103
|
+
loading: loadingProp,
|
|
104
|
+
error: errorProp,
|
|
105
|
+
success: successProp,
|
|
106
|
+
children,
|
|
107
|
+
className,
|
|
108
|
+
classNames,
|
|
109
|
+
onFocus,
|
|
110
|
+
onBlur,
|
|
111
|
+
...props
|
|
112
|
+
}: LoginFormProps) {
|
|
113
|
+
const strings = useUiStrings();
|
|
114
|
+
const auth = useOptionalAuth();
|
|
115
|
+
const baseId = useId();
|
|
116
|
+
const identifierRef = useRef<HTMLInputElement | null>(null);
|
|
117
|
+
const passwordRef = useRef<HTMLInputElement | null>(null);
|
|
118
|
+
const [identifier, setIdentifier] = useState("");
|
|
119
|
+
const [password, setPassword] = useState("");
|
|
120
|
+
const [remember, setRemember] = useState(false);
|
|
121
|
+
const [internal, setInternal] = useState<{
|
|
122
|
+
loading: boolean;
|
|
123
|
+
error: string | null;
|
|
124
|
+
success: boolean;
|
|
125
|
+
field: LoginField | null;
|
|
126
|
+
/** The error is about a field left empty, not about the sign-in. */
|
|
127
|
+
fieldError?: boolean;
|
|
128
|
+
}>({ loading: false, error: null, success: false, field: null });
|
|
129
|
+
const [portalValue, setPortalValue] = useControllableState<string>({
|
|
130
|
+
prop: portalProp,
|
|
131
|
+
defaultProp: defaultPortal ?? portals[0]?.value ?? "",
|
|
132
|
+
onChange: onPortalChange,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const appearance = appearanceProp ?? (auth?.panel === "solid" ? "open" : "card");
|
|
136
|
+
const loading = loadingProp ?? internal.loading;
|
|
137
|
+
const error = errorProp !== undefined ? errorProp : internal.error;
|
|
138
|
+
const success = successProp ?? internal.success;
|
|
139
|
+
const portalIndex = Math.max(
|
|
140
|
+
0,
|
|
141
|
+
portals.findIndex((option) => option.value === portalValue),
|
|
142
|
+
);
|
|
143
|
+
const portal = portals[portalIndex];
|
|
144
|
+
const invalidField = error ? (internal.field ?? "password") : null;
|
|
145
|
+
const errorPlacement =
|
|
146
|
+
error === null || error === undefined || error === ""
|
|
147
|
+
? null
|
|
148
|
+
: errorProp === undefined && internal.fieldError
|
|
149
|
+
? "field"
|
|
150
|
+
: "form";
|
|
151
|
+
|
|
152
|
+
const focusedField = useRef<LoginField | null>(null);
|
|
153
|
+
const leftOutcome = useRef(false);
|
|
154
|
+
const setAuthState = auth?.setState;
|
|
155
|
+
const setAuthProgress = auth?.setProgress;
|
|
156
|
+
const setAuthActive = auth?.setActiveIndex;
|
|
157
|
+
const progress = formProgress(identifier.length, password.length > 0);
|
|
158
|
+
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
setAuthProgress?.(progress);
|
|
161
|
+
}, [progress, setAuthProgress]);
|
|
162
|
+
const hasPortal = portal !== undefined;
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
if (hasPortal) setAuthActive?.(Math.min(portalIndex, MAX_ILLUSTRATED_PORTALS - 1));
|
|
165
|
+
}, [hasPortal, portalIndex, setAuthActive]);
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (success) {
|
|
168
|
+
leftOutcome.current = true;
|
|
169
|
+
setAuthState?.("success");
|
|
170
|
+
} else if (error) {
|
|
171
|
+
leftOutcome.current = true;
|
|
172
|
+
setAuthState?.("error");
|
|
173
|
+
} else if (leftOutcome.current) {
|
|
174
|
+
// The outcome went away (a controlled flag reset, or a new submit started): read focus again.
|
|
175
|
+
leftOutcome.current = false;
|
|
176
|
+
const field = focusedField.current;
|
|
177
|
+
setAuthState?.(field === "identifier" ? "typing" : field || loading ? "password" : "idle");
|
|
178
|
+
}
|
|
179
|
+
}, [success, error, loading, setAuthState]);
|
|
180
|
+
|
|
181
|
+
const context = useMemo<LoginFormContextValue>(
|
|
182
|
+
() => ({
|
|
183
|
+
ids: {
|
|
184
|
+
identifier: `${baseId}-identifier`,
|
|
185
|
+
password: `${baseId}-password`,
|
|
186
|
+
error: `${baseId}-error`,
|
|
187
|
+
fieldError: `${baseId}-field-error`,
|
|
188
|
+
portals: `${baseId}-portals`,
|
|
189
|
+
},
|
|
190
|
+
portals,
|
|
191
|
+
portal,
|
|
192
|
+
setPortal: setPortalValue,
|
|
193
|
+
identifier,
|
|
194
|
+
password,
|
|
195
|
+
appearance,
|
|
196
|
+
remember,
|
|
197
|
+
setRemember,
|
|
198
|
+
loading,
|
|
199
|
+
error,
|
|
200
|
+
invalidField,
|
|
201
|
+
errorPlacement,
|
|
202
|
+
setValue: (field, value) => {
|
|
203
|
+
if (field === "identifier") setIdentifier(value);
|
|
204
|
+
else setPassword(value);
|
|
205
|
+
if (internal.error || internal.field) {
|
|
206
|
+
setInternal((current) => ({ ...current, error: null, field: null }));
|
|
207
|
+
}
|
|
208
|
+
setAuthState?.(field === "identifier" ? "typing" : "password");
|
|
209
|
+
},
|
|
210
|
+
identifierRef,
|
|
211
|
+
passwordRef,
|
|
212
|
+
classNames,
|
|
213
|
+
}),
|
|
214
|
+
[
|
|
215
|
+
baseId,
|
|
216
|
+
portals,
|
|
217
|
+
portal,
|
|
218
|
+
setPortalValue,
|
|
219
|
+
identifier,
|
|
220
|
+
password,
|
|
221
|
+
appearance,
|
|
222
|
+
remember,
|
|
223
|
+
loading,
|
|
224
|
+
error,
|
|
225
|
+
invalidField,
|
|
226
|
+
errorPlacement,
|
|
227
|
+
internal.error,
|
|
228
|
+
internal.field,
|
|
229
|
+
classNames,
|
|
230
|
+
setAuthState,
|
|
231
|
+
],
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
const fieldOf = (target: EventTarget): LoginField | null =>
|
|
235
|
+
target === identifierRef.current
|
|
236
|
+
? "identifier"
|
|
237
|
+
: target === passwordRef.current
|
|
238
|
+
? "password"
|
|
239
|
+
: null;
|
|
240
|
+
|
|
241
|
+
const handleFocus = (event: FocusEvent<HTMLFormElement>) => {
|
|
242
|
+
onFocus?.(event);
|
|
243
|
+
const field = fieldOf(event.target);
|
|
244
|
+
if (field) focusedField.current = field;
|
|
245
|
+
if (field && !loading && !success && !error) {
|
|
246
|
+
setAuthState?.(field === "identifier" ? "typing" : "password");
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const handleBlur = (event: FocusEvent<HTMLFormElement>) => {
|
|
250
|
+
onBlur?.(event);
|
|
251
|
+
if (!fieldOf(event.target)) return;
|
|
252
|
+
const next = event.relatedTarget;
|
|
253
|
+
const staying = next !== null && fieldOf(next) !== null;
|
|
254
|
+
if (!staying) focusedField.current = null;
|
|
255
|
+
if (!staying && !loading && !success && !error) setAuthState?.("idle");
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const fail = (message: string, field: LoginField, fieldError = false) => {
|
|
259
|
+
setInternal({ loading: false, error: message, success: false, field, fieldError });
|
|
260
|
+
(field === "identifier" ? identifierRef : passwordRef).current?.focus();
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
if (loading) return;
|
|
266
|
+
if (!identifier.trim()) return fail(strings.enterIdentifier, "identifier", true);
|
|
267
|
+
if (!password) return fail(strings.enterPassword, "password", true);
|
|
268
|
+
const values: LoginValues = {
|
|
269
|
+
identifier: identifier.trim(),
|
|
270
|
+
password,
|
|
271
|
+
portal: portal?.value,
|
|
272
|
+
remember,
|
|
273
|
+
};
|
|
274
|
+
setInternal({ loading: true, error: null, success: false, field: null });
|
|
275
|
+
try {
|
|
276
|
+
await onSubmit?.(values);
|
|
277
|
+
setInternal({ loading: false, error: null, success: onSubmit !== undefined, field: null });
|
|
278
|
+
} catch (cause) {
|
|
279
|
+
fail(
|
|
280
|
+
cause instanceof Error && cause.message ? cause.message : strings.signInFailed,
|
|
281
|
+
"password",
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
return (
|
|
287
|
+
<LoginFormContext value={context}>
|
|
288
|
+
<form
|
|
289
|
+
method="post"
|
|
290
|
+
noValidate
|
|
291
|
+
{...props}
|
|
292
|
+
aria-busy={loading || undefined}
|
|
293
|
+
onFocus={handleFocus}
|
|
294
|
+
onBlur={handleBlur}
|
|
295
|
+
onSubmit={handleSubmit}
|
|
296
|
+
data-appearance={appearance}
|
|
297
|
+
className={cn(
|
|
298
|
+
"grid",
|
|
299
|
+
appearance === "open"
|
|
300
|
+
? "mx-auto w-full max-w-110 gap-5"
|
|
301
|
+
: "gap-3.5 px-7 pt-6.5 pb-5.5 @max-md/auth:px-1 @max-md/auth:pt-4",
|
|
302
|
+
appearance === "open" && auth?.panel === "paper" && "px-7 pt-7.5 pb-6",
|
|
303
|
+
classNames?.root,
|
|
304
|
+
className,
|
|
305
|
+
)}
|
|
306
|
+
>
|
|
307
|
+
{children ?? (
|
|
308
|
+
<>
|
|
309
|
+
<LoginFormHeader />
|
|
310
|
+
<LoginFormPortals />
|
|
311
|
+
<LoginFormError />
|
|
312
|
+
<LoginFormIdentifier />
|
|
313
|
+
<LoginFormPassword />
|
|
314
|
+
<LoginFormSubmit />
|
|
315
|
+
</>
|
|
316
|
+
)}
|
|
317
|
+
</form>
|
|
318
|
+
</LoginFormContext>
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
LoginForm.Header = LoginFormHeader;
|
|
323
|
+
LoginForm.Portals = LoginFormPortals;
|
|
324
|
+
LoginForm.Identifier = LoginFormIdentifier;
|
|
325
|
+
LoginForm.Password = LoginFormPassword;
|
|
326
|
+
LoginForm.Options = LoginFormOptions;
|
|
327
|
+
LoginForm.Providers = LoginFormProviders;
|
|
328
|
+
LoginForm.Error = LoginFormError;
|
|
329
|
+
LoginForm.Submit = LoginFormSubmit;
|
|
330
|
+
LoginForm.Footer = LoginFormFooter;
|