@jcsoftdev/ui 0.4.0 → 0.6.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 +434 -0
- package/README.md +26 -4
- package/bin/ui-theme.mjs +40 -6
- package/dist/ai/code-block/code-block.js +1 -1
- package/dist/atoms/big-date/big-date.js +2 -2
- package/dist/atoms/button/button.d.ts +14 -2
- package/dist/atoms/button/button.js +12 -5
- package/dist/atoms/chip/chip.d.ts +5 -0
- package/dist/atoms/chip/chip.js +3 -3
- 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/icon-button/icon-button.d.ts +1 -1
- package/dist/atoms/icon-button/icon-button.js +1 -1
- package/dist/atoms/index.d.ts +1 -0
- package/dist/atoms/index.js +1 -0
- package/dist/atoms/internal/hit-area.d.ts +5 -4
- package/dist/atoms/internal/hit-area.js +1 -1
- package/dist/atoms/progress/index.d.ts +1 -1
- package/dist/atoms/progress/index.js +4 -1
- package/dist/atoms/progress/progress.d.ts +6 -1
- package/dist/atoms/progress/progress.js +19 -1
- package/dist/atoms/radio-group/radio-group.js +1 -1
- package/dist/atoms/status-pill/status-pill.d.ts +16 -5
- package/dist/atoms/status-pill/status-pill.js +43 -18
- 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/brand/logo-forge.js +1 -1
- package/dist/charts/candlestick-chart/candlestick-chart.js +2 -2
- package/dist/charts/chart-grid/chart-grid.js +2 -2
- package/dist/charts/chord-chart/chord-chart.js +1 -1
- package/dist/charts/core/axes.js +2 -2
- package/dist/charts/core/cartesian/annotations.js +2 -2
- package/dist/charts/core/cartesian/marks.js +1 -1
- package/dist/charts/core/distribution/marks.js +1 -1
- package/dist/charts/core/distribution/xy-points.js +1 -1
- package/dist/charts/core/export-menu.js +1 -1
- package/dist/charts/funnel-chart/funnel-chart.js +1 -1
- package/dist/charts/gantt-chart/gantt-chart.js +4 -4
- package/dist/charts/gantt-chart/gantt-marks.js +3 -3
- package/dist/charts/index.d.ts +2 -0
- package/dist/charts/index.js +2 -0
- package/dist/charts/maps/geo/map-data-table.js +1 -1
- package/dist/charts/polar-area-chart/polar-area-chart.js +1 -1
- package/dist/charts/radar-chart/radar-chart.js +1 -1
- package/dist/charts/stock-chart/stock-chart.js +1 -1
- package/dist/charts/stock-chart/stock-drawing-layer.js +3 -3
- package/dist/charts/stock-chart/stock-plot.js +2 -2
- package/dist/containers/chat-thread/chat-thread.d.ts +98 -0
- package/dist/containers/chat-thread/chat-thread.js +219 -0
- package/dist/containers/chat-thread/format.d.ts +20 -0
- package/dist/containers/chat-thread/format.js +50 -0
- package/dist/containers/chat-thread/index.d.ts +1 -0
- package/dist/containers/chat-thread/index.js +8 -0
- package/dist/containers/cols/cols.d.ts +1 -1
- package/dist/containers/cols/cols.js +7 -0
- package/dist/containers/comment/comment.js +1 -1
- package/dist/containers/context-rail/context-rail.d.ts +62 -0
- package/dist/containers/context-rail/context-rail.js +175 -0
- package/dist/containers/context-rail/index.d.ts +1 -0
- package/dist/containers/context-rail/index.js +6 -0
- package/dist/containers/dashboard/dashboard.d.ts +40 -0
- package/dist/containers/dashboard/dashboard.js +84 -0
- package/dist/containers/dashboard/index.d.ts +1 -0
- package/dist/containers/dashboard/index.js +14 -0
- package/dist/containers/data-grid/data-grid.demos.js +4 -4
- package/dist/containers/data-grid/data-grid.js +6 -6
- package/dist/containers/data-grid/filter-builder-editor.js +2 -2
- package/dist/containers/data-grid/grid-toolbar.js +1 -1
- package/dist/containers/data-grid/spreadsheet.demos.d.ts +1 -1
- package/dist/containers/data-grid/spreadsheet.demos.js +1 -1
- package/dist/containers/detail-header/detail-header.d.ts +24 -0
- package/dist/containers/detail-header/detail-header.js +32 -0
- package/dist/containers/detail-header/index.d.ts +1 -0
- package/dist/containers/detail-header/index.js +6 -0
- package/dist/containers/facts/facts.js +1 -1
- package/dist/containers/filter-bar/filter-bar.d.ts +58 -0
- package/dist/containers/filter-bar/filter-bar.js +123 -0
- package/dist/containers/filter-bar/index.d.ts +1 -0
- package/dist/containers/filter-bar/index.js +6 -0
- package/dist/containers/hbars/hbars.js +2 -2
- package/dist/containers/index.d.ts +9 -0
- package/dist/containers/index.js +9 -0
- package/dist/containers/kanban/kanban.d.ts +23 -2
- package/dist/containers/kanban/kanban.js +101 -21
- package/dist/containers/kanban/model.d.ts +12 -0
- package/dist/containers/kanban/model.js +8 -0
- package/dist/containers/kpi/kpi.js +1 -1
- package/dist/containers/kpi-group/kpi-group.d.ts +6 -1
- package/dist/containers/kpi-group/kpi-group.js +6 -2
- package/dist/containers/list-detail/index.d.ts +1 -1
- package/dist/containers/list-detail/index.js +4 -0
- package/dist/containers/list-detail/list-detail.d.ts +51 -3
- package/dist/containers/list-detail/list-detail.js +109 -15
- package/dist/containers/page/page.d.ts +17 -4
- package/dist/containers/page/page.js +33 -4
- package/dist/containers/page-header/back.d.ts +10 -0
- package/dist/containers/page-header/back.js +28 -0
- package/dist/containers/page-header/index.d.ts +1 -0
- package/dist/containers/page-header/index.js +1 -0
- package/dist/containers/page-header/page-header.d.ts +19 -2
- package/dist/containers/page-header/page-header.js +26 -2
- package/dist/containers/pagination/cursor-pagination.d.ts +28 -0
- package/dist/containers/pagination/cursor-pagination.js +48 -0
- package/dist/containers/pagination/index.d.ts +3 -0
- package/dist/containers/pagination/index.js +10 -0
- package/dist/containers/pagination/pagination.d.ts +52 -0
- package/dist/containers/pagination/pagination.js +216 -0
- package/dist/containers/pagination/range.d.ts +29 -0
- package/dist/containers/pagination/range.js +42 -0
- package/dist/containers/pagination/use-pagination.d.ts +18 -0
- package/dist/containers/pagination/use-pagination.js +22 -0
- package/dist/containers/responsive-list/responsive-list.d.ts +28 -2
- package/dist/containers/responsive-list/responsive-list.js +134 -25
- package/dist/containers/row-actions/index.d.ts +1 -0
- package/dist/containers/row-actions/index.js +4 -0
- package/dist/containers/row-actions/row-actions.d.ts +26 -0
- package/dist/containers/row-actions/row-actions.js +78 -0
- package/dist/containers/selectable-card/index.d.ts +1 -0
- package/dist/containers/selectable-card/index.js +6 -0
- package/dist/containers/selectable-card/selectable-card.d.ts +26 -0
- package/dist/containers/selectable-card/selectable-card.js +57 -0
- package/dist/containers/settings-layout/settings-layout.d.ts +24 -7
- package/dist/containers/settings-layout/settings-layout.js +63 -8
- package/dist/containers/shortcuts/shortcuts.js +1 -1
- package/dist/containers/table/cell-padding.d.ts +2 -0
- package/dist/containers/table/cell-padding.js +4 -0
- package/dist/containers/table/index.d.ts +1 -0
- package/dist/containers/table/index.js +8 -0
- package/dist/containers/table/sort.d.ts +14 -0
- package/dist/containers/table/sort.js +11 -0
- package/dist/containers/table/table-parts.d.ts +24 -0
- package/dist/containers/table/table-parts.js +52 -0
- package/dist/containers/table/table.d.ts +37 -3
- package/dist/containers/table/table.js +120 -19
- package/dist/containers/table-columns-menu/index.d.ts +1 -0
- package/dist/containers/table-columns-menu/index.js +6 -0
- package/dist/containers/table-columns-menu/table-columns-menu.d.ts +14 -0
- package/dist/containers/table-columns-menu/table-columns-menu.js +46 -0
- package/dist/dashboards/layout.d.ts +1 -27
- package/dist/dashboards/layout.js +8 -40
- package/dist/forms/chip-group/chip-group.d.ts +5 -0
- package/dist/forms/chip-group/chip-group.js +3 -1
- package/dist/forms/combobox/combobox.js +1 -1
- package/dist/forms/copy-field/copy-field.js +1 -1
- package/dist/forms/date-picker/date-picker.d.ts +3 -1
- package/dist/forms/date-picker/date-picker.js +4 -2
- package/dist/forms/date-picker/date-time-picker.d.ts +8 -2
- package/dist/forms/date-picker/date-time-picker.js +13 -2
- package/dist/forms/field/field.d.ts +9 -2
- package/dist/forms/field/field.js +18 -4
- package/dist/forms/fieldset/fieldset.d.ts +11 -0
- package/dist/forms/fieldset/fieldset.js +12 -0
- package/dist/forms/fieldset/index.d.ts +1 -0
- package/dist/forms/fieldset/index.js +4 -0
- package/dist/forms/form-footer/form-footer.d.ts +26 -0
- package/dist/forms/form-footer/form-footer.js +44 -0
- package/dist/forms/form-footer/index.d.ts +1 -0
- package/dist/forms/form-footer/index.js +4 -0
- package/dist/forms/form-grid/form-grid.d.ts +21 -4
- package/dist/forms/form-grid/form-grid.js +20 -3
- package/dist/forms/form-grid/index.d.ts +1 -1
- package/dist/forms/form-grid/index.js +6 -2
- package/dist/forms/form-section/form-section.d.ts +12 -0
- package/dist/forms/form-section/form-section.js +30 -0
- package/dist/forms/form-section/index.d.ts +1 -0
- package/dist/forms/form-section/index.js +4 -0
- package/dist/forms/index.d.ts +4 -0
- package/dist/forms/index.js +4 -0
- package/dist/forms/input/input.d.ts +6 -2
- package/dist/forms/input/input.js +6 -2
- package/dist/forms/internal/listbox-items.d.ts +1 -1
- package/dist/forms/internal/listbox-items.js +3 -2
- package/dist/forms/native-select/native-select.js +1 -1
- 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/index.d.ts +1 -1
- package/dist/forms/select/select.d.ts +5 -2
- package/dist/forms/select/select.js +7 -2
- package/dist/forms/select-menu/select-menu.js +1 -1
- package/dist/forms/time-input/time-input.d.ts +4 -2
- package/dist/forms/time-input/time-input.js +3 -1
- package/dist/i18n/strings.d.ts +150 -0
- package/dist/i18n/strings.js +80 -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/motion/count-up.d.ts +20 -0
- package/dist/motion/count-up.js +59 -0
- package/dist/motion/cross-fade.d.ts +21 -0
- package/dist/motion/cross-fade.js +86 -0
- package/dist/motion/index.d.ts +5 -0
- package/dist/motion/index.js +14 -0
- package/dist/motion/model.d.ts +15 -0
- package/dist/motion/model.js +68 -0
- package/dist/motion/motion-styles.d.ts +1 -0
- package/dist/motion/motion-styles.js +35 -0
- package/dist/motion/reveal.d.ts +37 -0
- package/dist/motion/reveal.js +69 -0
- package/dist/motion/use-enter-phase.d.ts +11 -0
- package/dist/motion/use-enter-phase.js +40 -0
- package/dist/motion/use-highlight-row.d.ts +22 -0
- package/dist/motion/use-highlight-row.js +38 -0
- package/dist/navigation/tabs/tabs.js +1 -1
- package/dist/navigation/wizard/wizard.d.ts +4 -1
- package/dist/navigation/wizard/wizard.js +3 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +8 -1
- package/dist/overlays/context-menu/context-menu.js +3 -1
- package/dist/overlays/dialog/dialog.js +10 -2
- package/dist/overlays/drawer/drawer.d.ts +18 -4
- package/dist/overlays/drawer/drawer.js +53 -4
- package/dist/overlays/drawer/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +1 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +5 -4
- package/dist/overlays/hover-card/hover-card.js +2 -0
- package/dist/overlays/popover/popover.js +2 -0
- package/dist/overlays/toaster/index.d.ts +1 -1
- package/dist/overlays/toaster/toaster.d.ts +28 -2
- package/dist/overlays/toaster/toaster.js +73 -29
- package/dist/overlays/tooltip/tooltip.js +2 -0
- package/dist/primitives/use-presence.js +9 -0
- package/dist/shell/app-shell/app-shell.d.ts +8 -1
- package/dist/shell/app-shell/app-shell.js +50 -3
- package/dist/shell/index.d.ts +1 -0
- package/dist/shell/index.js +1 -0
- package/dist/shell/sidebar/sidebar.d.ts +17 -1
- package/dist/shell/sidebar/sidebar.js +126 -76
- package/dist/shell/topbar/topbar.d.ts +4 -2
- package/dist/shell/topbar/topbar.js +2 -0
- package/dist/showcase/operations-bento.js +2 -2
- package/dist/states/empty-state/empty-state.d.ts +10 -3
- package/dist/states/empty-state/empty-state.js +46 -5
- package/dist/states/error-state/error-state.js +1 -1
- package/dist/states/skeleton/skeleton.js +1 -1
- package/dist/utils/class-tokens.generated.js +4 -6
- package/dist/utils/list-navigation.d.ts +14 -0
- package/dist/utils/list-navigation.js +44 -0
- package/dist/utils/overlay-motion.d.ts +12 -0
- package/dist/utils/overlay-motion.js +14 -0
- package/dist/utils/use-container-width.d.ts +6 -0
- package/dist/utils/use-container-width.js +19 -0
- 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 +46 -5
- package/src/ai/code-block/code-block.tsx +1 -1
- package/src/atoms/big-date/big-date.tsx +2 -2
- package/src/atoms/button/button.tsx +33 -6
- package/src/atoms/chip/chip.tsx +8 -3
- package/src/atoms/divider/divider.tsx +40 -0
- package/src/atoms/divider/index.ts +1 -0
- package/src/atoms/icon-button/icon-button.tsx +2 -2
- package/src/atoms/index.ts +1 -0
- package/src/atoms/internal/hit-area.ts +5 -4
- package/src/atoms/progress/index.ts +8 -1
- package/src/atoms/progress/progress.tsx +30 -1
- package/src/atoms/radio-group/radio-group.tsx +1 -1
- package/src/atoms/status-pill/status-pill.tsx +59 -18
- 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/brand/logo-forge.tsx +1 -1
- package/src/charts/candlestick-chart/candlestick-chart.tsx +2 -2
- package/src/charts/chart-grid/chart-grid.tsx +2 -2
- package/src/charts/chord-chart/chord-chart.tsx +1 -1
- package/src/charts/core/axes.tsx +2 -2
- package/src/charts/core/cartesian/annotations.tsx +2 -2
- package/src/charts/core/cartesian/marks.tsx +1 -1
- package/src/charts/core/distribution/marks.tsx +1 -1
- package/src/charts/core/distribution/xy-points.tsx +1 -1
- package/src/charts/core/export-menu.tsx +1 -1
- package/src/charts/funnel-chart/funnel-chart.tsx +1 -1
- package/src/charts/gantt-chart/gantt-chart.tsx +4 -4
- package/src/charts/gantt-chart/gantt-marks.tsx +3 -3
- package/src/charts/index.ts +2 -0
- package/src/charts/maps/geo/map-data-table.tsx +1 -1
- package/src/charts/polar-area-chart/polar-area-chart.tsx +1 -1
- package/src/charts/radar-chart/radar-chart.tsx +1 -1
- package/src/charts/stock-chart/stock-chart.tsx +1 -1
- package/src/charts/stock-chart/stock-drawing-layer.tsx +3 -3
- package/src/charts/stock-chart/stock-plot.tsx +2 -2
- package/src/containers/chat-thread/chat-thread.tsx +331 -0
- package/src/containers/chat-thread/format.ts +67 -0
- package/src/containers/chat-thread/index.ts +12 -0
- package/src/containers/cols/cols.tsx +13 -1
- package/src/containers/comment/comment.tsx +1 -1
- package/src/containers/context-rail/context-rail.tsx +229 -0
- package/src/containers/context-rail/index.ts +7 -0
- package/src/containers/dashboard/dashboard.tsx +142 -0
- package/src/containers/dashboard/index.ts +12 -0
- package/src/containers/data-grid/data-grid.demos.tsx +4 -4
- package/src/containers/data-grid/data-grid.tsx +6 -6
- package/src/containers/data-grid/filter-builder-editor.tsx +2 -2
- package/src/containers/data-grid/grid-toolbar.tsx +1 -1
- package/src/containers/data-grid/spreadsheet.demos.tsx +1 -1
- package/src/containers/detail-header/detail-header.tsx +64 -0
- package/src/containers/detail-header/index.ts +5 -0
- package/src/containers/facts/facts.tsx +1 -1
- package/src/containers/filter-bar/filter-bar.tsx +201 -0
- package/src/containers/filter-bar/index.ts +7 -0
- package/src/containers/hbars/hbars.tsx +2 -2
- package/src/containers/index.ts +9 -0
- package/src/containers/kanban/kanban.tsx +146 -39
- package/src/containers/kanban/model.ts +20 -0
- package/src/containers/kpi/kpi.tsx +1 -1
- package/src/containers/kpi-group/kpi-group.tsx +17 -2
- package/src/containers/list-detail/index.ts +5 -0
- package/src/containers/list-detail/list-detail.tsx +157 -9
- package/src/containers/page/page.tsx +61 -7
- package/src/containers/page-header/back.tsx +42 -0
- package/src/containers/page-header/index.ts +1 -0
- package/src/containers/page-header/page-header.tsx +49 -3
- package/src/containers/pagination/cursor-pagination.tsx +79 -0
- package/src/containers/pagination/index.ts +7 -0
- package/src/containers/pagination/pagination.tsx +266 -0
- package/src/containers/pagination/range.ts +68 -0
- package/src/containers/pagination/use-pagination.ts +44 -0
- package/src/containers/responsive-list/responsive-list.tsx +183 -46
- package/src/containers/row-actions/index.ts +1 -0
- package/src/containers/row-actions/row-actions.tsx +114 -0
- package/src/containers/selectable-card/index.ts +5 -0
- package/src/containers/selectable-card/selectable-card.tsx +84 -0
- package/src/containers/settings-layout/settings-layout.tsx +104 -13
- package/src/containers/shortcuts/shortcuts.tsx +1 -1
- package/src/containers/table/cell-padding.ts +2 -0
- package/src/containers/table/index.ts +6 -0
- package/src/containers/table/sort.ts +23 -0
- package/src/containers/table/table-parts.tsx +81 -0
- package/src/containers/table/table.tsx +212 -45
- package/src/containers/table-columns-menu/index.ts +5 -0
- package/src/containers/table-columns-menu/table-columns-menu.tsx +68 -0
- package/src/dashboards/layout.tsx +8 -75
- package/src/forms/chip-group/chip-group.tsx +8 -1
- package/src/forms/combobox/combobox.tsx +1 -1
- package/src/forms/copy-field/copy-field.tsx +1 -1
- package/src/forms/date-picker/date-picker.tsx +7 -2
- package/src/forms/date-picker/date-time-picker.tsx +28 -2
- package/src/forms/field/field.tsx +30 -3
- package/src/forms/fieldset/fieldset.tsx +22 -0
- package/src/forms/fieldset/index.ts +1 -0
- package/src/forms/form-footer/form-footer.tsx +74 -0
- package/src/forms/form-footer/index.ts +1 -0
- package/src/forms/form-grid/form-grid.tsx +42 -5
- package/src/forms/form-grid/index.ts +8 -1
- package/src/forms/form-section/form-section.tsx +41 -0
- package/src/forms/form-section/index.ts +1 -0
- package/src/forms/index.ts +4 -0
- package/src/forms/input/input.tsx +12 -3
- package/src/forms/internal/listbox-items.tsx +3 -4
- package/src/forms/native-select/native-select.tsx +1 -1
- package/src/forms/password-input/index.ts +1 -0
- package/src/forms/password-input/password-input.tsx +57 -0
- package/src/forms/select/index.ts +1 -1
- package/src/forms/select/select.tsx +14 -3
- package/src/forms/select-menu/select-menu.tsx +1 -1
- package/src/forms/time-input/time-input.tsx +6 -2
- package/src/i18n/strings.ts +150 -0
- 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/motion/count-up.tsx +83 -0
- package/src/motion/cross-fade.tsx +139 -0
- package/src/motion/index.ts +5 -0
- package/src/motion/model.ts +86 -0
- package/src/motion/motion-styles.tsx +47 -0
- package/src/motion/reveal.tsx +115 -0
- package/src/motion/use-enter-phase.ts +50 -0
- package/src/motion/use-highlight-row.ts +63 -0
- package/src/navigation/tabs/tabs.tsx +1 -1
- package/src/navigation/wizard/wizard.tsx +6 -1
- package/src/overlays/alert-dialog/alert-dialog.tsx +5 -1
- package/src/overlays/context-menu/context-menu.tsx +3 -2
- package/src/overlays/dialog/dialog.tsx +7 -2
- package/src/overlays/drawer/drawer.tsx +68 -6
- package/src/overlays/drawer/index.ts +1 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +5 -4
- package/src/overlays/hover-card/hover-card.tsx +2 -0
- package/src/overlays/popover/popover.tsx +2 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toaster.tsx +113 -17
- package/src/overlays/tooltip/tooltip.tsx +2 -0
- package/src/primitives/use-presence.ts +13 -0
- package/src/shell/app-shell/app-shell.tsx +54 -2
- package/src/shell/index.ts +1 -0
- package/src/shell/sidebar/sidebar.tsx +154 -75
- package/src/shell/topbar/topbar.tsx +8 -0
- package/src/showcase/operations-bento.tsx +2 -2
- package/src/states/empty-state/empty-state.tsx +52 -9
- package/src/states/error-state/error-state.tsx +1 -1
- package/src/states/skeleton/skeleton.tsx +1 -1
- package/src/utils/class-tokens.generated.ts +4 -6
- package/src/utils/list-navigation.ts +63 -0
- package/src/utils/overlay-motion.ts +33 -0
- package/src/utils/use-container-width.ts +24 -0
- package/styles/Theme.kt +15 -18
- package/styles/tailwind.css +29 -28
- package/styles/theme.css +29 -28
- package/styles/tokens.css +46 -0
- package/tokens/default.json +51 -29
|
@@ -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;
|