@liorian/sdk 0.28.0-alpha.56010ca
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/README.md +483 -0
- package/package.json +94 -0
- package/schemas/module.schema.json +818 -0
- package/src/application/index.ts +3 -0
- package/src/application/module-instance.ts +36 -0
- package/src/application/service/auth-api-service.ts +291 -0
- package/src/application/service/auth-user.service.ts +108 -0
- package/src/application/service/index.ts +12 -0
- package/src/application/service/module-activation-api.service.ts +105 -0
- package/src/application/service/notifications-api-service.ts +38 -0
- package/src/application/service/notifications-push.service.ts +299 -0
- package/src/application/service/notifications-socket-service.ts +76 -0
- package/src/application/service/organizations-api-service.ts +104 -0
- package/src/application/service/otp-api-service.ts +11 -0
- package/src/application/service/storage-api-service.ts +77 -0
- package/src/application/service/storefront-api.service.ts +72 -0
- package/src/application/service/user-preferences-api.service.ts +57 -0
- package/src/domain/config/app.config.ts +35 -0
- package/src/domain/config/auth.config.ts +30 -0
- package/src/domain/config/index.ts +4 -0
- package/src/domain/config/logo.config.ts +17 -0
- package/src/domain/entities/activities.interface.ts +18 -0
- package/src/domain/entities/catalog.interface.ts +96 -0
- package/src/domain/entities/index.ts +13 -0
- package/src/domain/entities/media.ts +22 -0
- package/src/domain/entities/module-activation.interface.ts +173 -0
- package/src/domain/entities/module.interface.ts +101 -0
- package/src/domain/entities/notification.interface.ts +23 -0
- package/src/domain/entities/objectable.type.ts +3 -0
- package/src/domain/entities/organization.interface.ts +81 -0
- package/src/domain/entities/user-auth.interface.ts +17 -0
- package/src/domain/entities/user-phone.interface.ts +11 -0
- package/src/domain/entities/user-profile.interface.ts +23 -0
- package/src/domain/entities/user.interface.ts +79 -0
- package/src/domain/enums/coloring.enum.ts +6 -0
- package/src/domain/enums/domains.enum.ts +282 -0
- package/src/domain/enums/index.ts +8 -0
- package/src/domain/enums/module-category.enum.ts +57 -0
- package/src/domain/enums/module.enum.ts +97 -0
- package/src/domain/enums/routine.enum.ts +12 -0
- package/src/domain/enums/user-profile.enum.ts +25 -0
- package/src/domain/enums/user-status.enum.ts +7 -0
- package/src/domain/index.ts +6 -0
- package/src/domain/typing/auth-caches.ts +12 -0
- package/src/domain/typing/auth-oauth.types.ts +172 -0
- package/src/domain/typing/devise.ts +2 -0
- package/src/domain/typing/index.ts +10 -0
- package/src/domain/typing/response.ts +30 -0
- package/src/domain/typing/routine.types.ts +113 -0
- package/src/domain/typing/session.interface.ts +28 -0
- package/src/domain/typing/statisticals.ts +11 -0
- package/src/domain/typing/user-media-upload.ts +9 -0
- package/src/domain/typing/values.ts +6 -0
- package/src/index.tsx +168 -0
- package/src/infrastructure/capabilities/cache-storage/capability.ts +129 -0
- package/src/infrastructure/capabilities/cache-storage/enum.ts +5 -0
- package/src/infrastructure/capabilities/cache-storage/index.ts +4 -0
- package/src/infrastructure/capabilities/cache-storage/types.ts +13 -0
- package/src/infrastructure/capabilities/index.ts +3 -0
- package/src/infrastructure/capabilities/stackable/capability.ts +55 -0
- package/src/infrastructure/capabilities/stackable/index.ts +3 -0
- package/src/infrastructure/capabilities/stackable/types.ts +24 -0
- package/src/infrastructure/common-classname.constant.ts +4 -0
- package/src/infrastructure/data/countries.ts +208 -0
- package/src/infrastructure/data/gender.ts +5 -0
- package/src/infrastructure/data/index.ts +3 -0
- package/src/infrastructure/dataset/index.ts +3 -0
- package/src/infrastructure/dataset/sign-in.dataset.ts +21 -0
- package/src/infrastructure/dataset/sign-up.dataset.ts +64 -0
- package/src/infrastructure/hooks/index.ts +10 -0
- package/src/infrastructure/hooks/use-activity-lock-draft.ts +69 -0
- package/src/infrastructure/hooks/use-auth.ts +24 -0
- package/src/infrastructure/hooks/use-elastic-interaction.ts +180 -0
- package/src/infrastructure/hooks/use-is-desktop.ts +25 -0
- package/src/infrastructure/hooks/use-is-tauri.ts +17 -0
- package/src/infrastructure/hooks/use-mobile.ts +19 -0
- package/src/infrastructure/hooks/use-notifications.ts +128 -0
- package/src/infrastructure/hooks/use-recent-colors.ts +113 -0
- package/src/infrastructure/hooks/use-recent-modules.ts +76 -0
- package/src/infrastructure/index.tsx +11 -0
- package/src/infrastructure/library/design-system.ts +95 -0
- package/src/infrastructure/library/index.tsx +5 -0
- package/src/infrastructure/library/motion-utils.ts +77 -0
- package/src/infrastructure/library/motion.tsx +31 -0
- package/src/infrastructure/library/scroll-progress.tsx +93 -0
- package/src/infrastructure/providers/auth-guard.provider.tsx +47 -0
- package/src/infrastructure/providers/auth.provider.tsx +168 -0
- package/src/infrastructure/providers/index.tsx +8 -0
- package/src/infrastructure/providers/module-usage.provider.tsx +95 -0
- package/src/infrastructure/providers/modules-guard.provider.tsx +64 -0
- package/src/infrastructure/providers/modules-routines.provider.tsx +33 -0
- package/src/infrastructure/providers/modules-switcher.provider.tsx +25 -0
- package/src/infrastructure/providers/query.provider.tsx +27 -0
- package/src/infrastructure/routines/__tests__/routine.test.ts +368 -0
- package/src/infrastructure/routines/index.tsx +3 -0
- package/src/infrastructure/routines/routine.hook.ts +121 -0
- package/src/infrastructure/routines/routine.ts +283 -0
- package/src/infrastructure/routines/routine.tsx +283 -0
- package/src/infrastructure/stores/activity-lock.store.ts +22 -0
- package/src/infrastructure/stores/auth-user-connected.store.ts +24 -0
- package/src/infrastructure/stores/dataset.store.ts +106 -0
- package/src/infrastructure/stores/index.ts +6 -0
- package/src/infrastructure/stores/module.store.ts +266 -0
- package/src/infrastructure/stores/upload.store.ts +198 -0
- package/src/infrastructure/utilities/access-label.util.ts +158 -0
- package/src/infrastructure/utilities/activities.util.tsx +54 -0
- package/src/infrastructure/utilities/activity-lock.service.ts +263 -0
- package/src/infrastructure/utilities/activity-tracker.service.ts +205 -0
- package/src/infrastructure/utilities/api-service.ts +237 -0
- package/src/infrastructure/utilities/auth-logout.util.ts +23 -0
- package/src/infrastructure/utilities/classname.util.ts +7 -0
- package/src/infrastructure/utilities/encryption.service.ts +125 -0
- package/src/infrastructure/utilities/form-snapshot.service.ts +304 -0
- package/src/infrastructure/utilities/format.util.ts +40 -0
- package/src/infrastructure/utilities/index.tsx +23 -0
- package/src/infrastructure/utilities/media-label.service.ts +47 -0
- package/src/infrastructure/utilities/modules.ts +11 -0
- package/src/infrastructure/utilities/permission.util.ts +22 -0
- package/src/infrastructure/utilities/push-permission.util.ts +43 -0
- package/src/infrastructure/utilities/route-access.ts +38 -0
- package/src/infrastructure/utilities/socket-service.ts +123 -0
- package/src/infrastructure/utilities/sso-auth.util.ts +188 -0
- package/src/infrastructure/utilities/stringable.util.ts +16 -0
- package/src/infrastructure/utilities/strings.util.ts +18 -0
- package/src/infrastructure/utilities/tauri.util.ts +15 -0
- package/src/infrastructure/utilities/utils.ts +6 -0
- package/src/infrastructure/utilities/values.ts +5 -0
- package/src/presentation/8starlabs-ui/button.tsx +94 -0
- package/src/presentation/8starlabs-ui/flip-clock.tsx +368 -0
- package/src/presentation/8starlabs-ui/heatmap.tsx +430 -0
- package/src/presentation/8starlabs-ui/hooks/index.tsx +2 -0
- package/src/presentation/8starlabs-ui/hooks/use-mobile.ts +21 -0
- package/src/presentation/8starlabs-ui/index.tsx +20 -0
- package/src/presentation/8starlabs-ui/json-viewer.tsx +972 -0
- package/src/presentation/8starlabs-ui/marquee.tsx +134 -0
- package/src/presentation/8starlabs-ui/partition-bar.tsx +198 -0
- package/src/presentation/8starlabs-ui/scroll-fade.tsx +158 -0
- package/src/presentation/8starlabs-ui/status-indicator.tsx +86 -0
- package/src/presentation/8starlabs-ui/system-banner.tsx +50 -0
- package/src/presentation/8starlabs-ui/timeline.tsx +576 -0
- package/src/presentation/8starlabs-ui/transport-badge.tsx +249 -0
- package/src/presentation/8starlabs-ui/ui/copy-button.tsx +60 -0
- package/src/presentation/8starlabs-ui/ui/index.tsx +2 -0
- package/src/presentation/analytics-section.tsx +85 -0
- package/src/presentation/app-sidebar.tsx +234 -0
- package/src/presentation/charts/area-widget.chart-skeleton.tsx +61 -0
- package/src/presentation/charts/area-widget.chart.tsx +128 -0
- package/src/presentation/charts/chart-widgets.types.ts +81 -0
- package/src/presentation/charts/index.tsx +16 -0
- package/src/presentation/charts/line-widget.chart-skeleton.tsx +64 -0
- package/src/presentation/charts/line-widget.chart.tsx +105 -0
- package/src/presentation/charts/pie-widget.chart-skeleton.tsx +56 -0
- package/src/presentation/charts/pie-widget.chart.tsx +168 -0
- package/src/presentation/charts/radar-widget.chart-skeleton.tsx +67 -0
- package/src/presentation/charts/radar-widget.chart.tsx +80 -0
- package/src/presentation/charts/radial-stacked-widget.chart-skeleton.tsx +66 -0
- package/src/presentation/charts/radial-stacked-widget.chart.tsx +120 -0
- package/src/presentation/charts/radial-widget.chart-skeleton.tsx +61 -0
- package/src/presentation/charts/radial-widget.chart.tsx +87 -0
- package/src/presentation/charts/tooltip-widget.chart-skeleton.tsx +64 -0
- package/src/presentation/charts/tooltip-widget.chart.tsx +89 -0
- package/src/presentation/components/activity-actions.tsx +20 -0
- package/src/presentation/components/activity-container.tsx +55 -0
- package/src/presentation/components/activity-content.tsx +20 -0
- package/src/presentation/components/activity-descriptor-parser.tsx +37 -0
- package/src/presentation/components/activity-header.tsx +20 -0
- package/src/presentation/components/activity-loader.tsx +19 -0
- package/src/presentation/components/activity-title.tsx +32 -0
- package/src/presentation/components/activity.tsx +22 -0
- package/src/presentation/components/auth/index.tsx +4 -0
- package/src/presentation/components/auth/sso-callback.view.tsx +44 -0
- package/src/presentation/components/auth/sso-disconnect.view.tsx +41 -0
- package/src/presentation/components/auth/sso-sign-in.view.tsx +29 -0
- package/src/presentation/components/auth-lock-screen.tsx +309 -0
- package/src/presentation/components/auth-session.view.tsx +17 -0
- package/src/presentation/components/data-table.tsx +814 -0
- package/src/presentation/components/dynamic-icon.tsx +16 -0
- package/src/presentation/components/floating-upload.tsx +291 -0
- package/src/presentation/components/index.tsx +40 -0
- package/src/presentation/components/local-time.tsx +170 -0
- package/src/presentation/components/markdown-parser.tsx +201 -0
- package/src/presentation/components/message-scroller.tsx +131 -0
- package/src/presentation/components/module-first-access-config.view.tsx +181 -0
- package/src/presentation/components/module-first-access-pending.view.tsx +38 -0
- package/src/presentation/components/module-guard.tsx +34 -0
- package/src/presentation/components/modules-first-access.guard.tsx +88 -0
- package/src/presentation/components/modules-guard-forbidden.tsx +46 -0
- package/src/presentation/components/notification-details.modal.tsx +145 -0
- package/src/presentation/components/notification-item.tsx +127 -0
- package/src/presentation/components/notifications-popover.tsx +128 -0
- package/src/presentation/components/push-notifications.provider.tsx +65 -0
- package/src/presentation/components/upload-progress-dialog.tsx +140 -0
- package/src/presentation/components/waiting-bar.tsx +22 -0
- package/src/presentation/components/waiting-section.tsx +15 -0
- package/src/presentation/components/waiting.tsx +14 -0
- package/src/presentation/data-grid/data-grid-empty.tsx +24 -0
- package/src/presentation/data-grid/data-grid-search-engine.tsx +32 -0
- package/src/presentation/data-grid/data-grid.tsx +892 -0
- package/src/presentation/data-grid/index.tsx +4 -0
- package/src/presentation/form-screen.tsx +95 -0
- package/src/presentation/icons/custom.tsx +20 -0
- package/src/presentation/icons/glyphIcons.tsx +53 -0
- package/src/presentation/icons/icons.enum.ts +4 -0
- package/src/presentation/icons/icons.util.ts +6 -0
- package/src/presentation/icons/index.tsx +8 -0
- package/src/presentation/icons/lucide.tsx +17 -0
- package/src/presentation/icons/remix.tsx +33 -0
- package/src/presentation/icons/types.ts +27 -0
- package/src/presentation/index.tsx +45 -0
- package/src/presentation/modals/components/ModalBox.tsx +74 -0
- package/src/presentation/modals/components/ModalPortal.tsx +31 -0
- package/src/presentation/modals/components/ModalStepper.tsx +319 -0
- package/src/presentation/modals/components/ModalWrapper.tsx +65 -0
- package/src/presentation/modals/components/index.tsx +5 -0
- package/src/presentation/modals/hooks/index.ts +2 -0
- package/src/presentation/modals/hooks/useModal.ts +38 -0
- package/src/presentation/modals/index.tsx +5 -0
- package/src/presentation/modals/stores/index.ts +2 -0
- package/src/presentation/modals/stores/useModalStore.ts +90 -0
- package/src/presentation/modals/types/index.ts +2 -0
- package/src/presentation/modals/types/modal.type.ts +33 -0
- package/src/presentation/module-menubar.tsx +300 -0
- package/src/presentation/module-widget.tsx +233 -0
- package/src/presentation/nav-documents.tsx +89 -0
- package/src/presentation/nav-main.tsx +62 -0
- package/src/presentation/nav-secondary.tsx +41 -0
- package/src/presentation/nav-user.tsx +109 -0
- package/src/presentation/permission-action-badge.tsx +35 -0
- package/src/presentation/reui/index.tsx +3 -0
- package/src/presentation/reui/stepper.tsx +508 -0
- package/src/presentation/reui/timeline.tsx +226 -0
- package/src/presentation/sheets/index.tsx +2 -0
- package/src/presentation/sheets/legacy-sheet-header.tsx +0 -0
- package/src/presentation/sheets/legacy-sheet.tsx +37 -0
- package/src/presentation/size.enum.ts +19 -0
- package/src/presentation/system/index.tsx +3 -0
- package/src/presentation/system/logo.theme.tsx +21 -0
- package/src/presentation/system/types.ts +10 -0
- package/src/presentation/theme/index.tsx +6 -0
- package/src/presentation/theme/prefer-color-scheme.tsx +50 -0
- package/src/presentation/theme/switch-color-scheme.tsx +16 -0
- package/src/presentation/theme/theme-switcher-button.tsx +20 -0
- package/src/presentation/theme/theme.enum.ts +4 -0
- package/src/presentation/theme/theme.store.ts +87 -0
- package/src/presentation/themes/index.tsx +2 -0
- package/src/presentation/themes/katon/dashboard-layout.tsx +1080 -0
- package/src/presentation/themes/katon/edge-section.tsx +19 -0
- package/src/presentation/themes/katon/header-menubar.tsx +270 -0
- package/src/presentation/themes/katon/header-modules-available.tsx +44 -0
- package/src/presentation/themes/katon/header-modules-recents.tsx +52 -0
- package/src/presentation/themes/katon/header-modules-store.tsx +25 -0
- package/src/presentation/themes/katon/header-options.tsx +13 -0
- package/src/presentation/themes/katon/header-organization-select.tsx +146 -0
- package/src/presentation/themes/katon/header-routines.tsx +74 -0
- package/src/presentation/themes/katon/header-tasks-connected-user.tsx +150 -0
- package/src/presentation/themes/katon/index.tsx +16 -0
- package/src/presentation/themes/katon/main-wrapper.tsx +34 -0
- package/src/presentation/themes/katon/module-item-link.tsx +32 -0
- package/src/presentation/themes/katon/view-frame.tsx +25 -0
- package/src/presentation/themes/katon/view-helmet.tsx +53 -0
- package/src/presentation/themes/katon/view-status.tsx +32 -0
- package/src/presentation/themes/katon/view-wrapper.tsx +15 -0
- package/src/presentation/themes/katon/view.tsx +42 -0
- package/src/presentation/ui/accordion-multiselect.tsx +206 -0
- package/src/presentation/ui/accordion.tsx +81 -0
- package/src/presentation/ui/alert-dialog.tsx +199 -0
- package/src/presentation/ui/alert.tsx +76 -0
- package/src/presentation/ui/aspect-ratio.tsx +11 -0
- package/src/presentation/ui/attachment.tsx +204 -0
- package/src/presentation/ui/avatar.tsx +112 -0
- package/src/presentation/ui/badge.tsx +49 -0
- package/src/presentation/ui/breadcrumb.tsx +122 -0
- package/src/presentation/ui/bubble.tsx +125 -0
- package/src/presentation/ui/button-group.tsx +83 -0
- package/src/presentation/ui/button.tsx +87 -0
- package/src/presentation/ui/calendar.tsx +222 -0
- package/src/presentation/ui/card.tsx +106 -0
- package/src/presentation/ui/carousel.tsx +242 -0
- package/src/presentation/ui/chart.tsx +373 -0
- package/src/presentation/ui/checkbox.tsx +33 -0
- package/src/presentation/ui/clickable.tsx +58 -0
- package/src/presentation/ui/collapsible.tsx +33 -0
- package/src/presentation/ui/color-swatch-selector.tsx +81 -0
- package/src/presentation/ui/combobox.tsx +299 -0
- package/src/presentation/ui/command.tsx +195 -0
- package/src/presentation/ui/context-menu.tsx +263 -0
- package/src/presentation/ui/dialog.tsx +168 -0
- package/src/presentation/ui/direction.tsx +22 -0
- package/src/presentation/ui/drawer.tsx +134 -0
- package/src/presentation/ui/dropdown-menu.tsx +269 -0
- package/src/presentation/ui/empty.tsx +104 -0
- package/src/presentation/ui/field.tsx +238 -0
- package/src/presentation/ui/granularity-selector.tsx +58 -0
- package/src/presentation/ui/hover-card.tsx +44 -0
- package/src/presentation/ui/index.tsx +74 -0
- package/src/presentation/ui/input-group.tsx +156 -0
- package/src/presentation/ui/input-otp.tsx +87 -0
- package/src/presentation/ui/input.tsx +19 -0
- package/src/presentation/ui/item.tsx +196 -0
- package/src/presentation/ui/kpi-card.tsx +203 -0
- package/src/presentation/ui/label-selector.tsx +100 -0
- package/src/presentation/ui/label.tsx +24 -0
- package/src/presentation/ui/legacy-birth-date-input.tsx +43 -0
- package/src/presentation/ui/legacy-color-picker/index.tsx +42 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.content.tsx +37 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.context.tsx +42 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.hex-input.tsx +97 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.picker.tsx +266 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.presets.ts +22 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.quick-list.tsx +49 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.recent.tsx +43 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.swatches.tsx +111 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.trigger.tsx +128 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.tsx +110 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.types.ts +1 -0
- package/src/presentation/ui/legacy-color-picker/legacy-color-picker.utils.ts +114 -0
- package/src/presentation/ui/legacy-country-input.tsx +171 -0
- package/src/presentation/ui/legacy-gender-input.tsx +22 -0
- package/src/presentation/ui/legacy-input.tsx +106 -0
- package/src/presentation/ui/legacy-phone-input.tsx +213 -0
- package/src/presentation/ui/legacy-select-input.tsx +114 -0
- package/src/presentation/ui/legacy-text-area.tsx +111 -0
- package/src/presentation/ui/list-items.tsx +59 -0
- package/src/presentation/ui/marker.tsx +69 -0
- package/src/presentation/ui/media-player/index.tsx +12 -0
- package/src/presentation/ui/media-player/media-player.context.tsx +36 -0
- package/src/presentation/ui/media-player/media-player.tsx +167 -0
- package/src/presentation/ui/media-player/player-controls.tsx +207 -0
- package/src/presentation/ui/media-player/players/audio-player.tsx +78 -0
- package/src/presentation/ui/media-player/players/index.tsx +4 -0
- package/src/presentation/ui/media-player/players/video-player.tsx +193 -0
- package/src/presentation/ui/media-player/players/voice-note-player.tsx +108 -0
- package/src/presentation/ui/media-player/use-media-player.hook.ts +263 -0
- package/src/presentation/ui/menubar.tsx +281 -0
- package/src/presentation/ui/message.tsx +92 -0
- package/src/presentation/ui/navigation-menu.tsx +172 -0
- package/src/presentation/ui/pagination.tsx +129 -0
- package/src/presentation/ui/popover.tsx +89 -0
- package/src/presentation/ui/progress.tsx +31 -0
- package/src/presentation/ui/resizable.tsx +50 -0
- package/src/presentation/ui/select.tsx +192 -0
- package/src/presentation/ui/separator.tsx +28 -0
- package/src/presentation/ui/sheet.tsx +147 -0
- package/src/presentation/ui/sidebar.tsx +702 -0
- package/src/presentation/ui/skeleton.tsx +13 -0
- package/src/presentation/ui/slide-to-confirm.tsx +129 -0
- package/src/presentation/ui/slider.tsx +59 -0
- package/src/presentation/ui/sonner.tsx +58 -0
- package/src/presentation/ui/switch.tsx +33 -0
- package/src/presentation/ui/table.tsx +116 -0
- package/src/presentation/ui/tabs.tsx +90 -0
- package/src/presentation/ui/text-gradient.tsx +84 -0
- package/src/presentation/ui/textarea.tsx +18 -0
- package/src/presentation/ui/timeline-steps.tsx +235 -0
- package/src/presentation/ui/toggle-group.tsx +89 -0
- package/src/presentation/ui/toggle.tsx +47 -0
- package/src/presentation/ui/tooltip.tsx +57 -0
- package/src/presentation/uploading/index.tsx +3 -0
- package/src/presentation/uploading/media-upload-field.tsx +152 -0
- package/src/presentation/uploading/storage-media.tsx +210 -0
- package/src/styles.css +403 -0
- package/src/themes.css +1038 -0
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Children,
|
|
5
|
+
cloneElement,
|
|
6
|
+
createContext,
|
|
7
|
+
CSSProperties,
|
|
8
|
+
HTMLAttributes,
|
|
9
|
+
ReactElement,
|
|
10
|
+
useContext,
|
|
11
|
+
useEffect,
|
|
12
|
+
useLayoutEffect,
|
|
13
|
+
useRef,
|
|
14
|
+
useState
|
|
15
|
+
} from "react";
|
|
16
|
+
import { cn } from "../../infrastructure/utilities/utils";
|
|
17
|
+
import { cva, VariantProps } from "class-variance-authority";
|
|
18
|
+
|
|
19
|
+
// CSS VARIANTS
|
|
20
|
+
|
|
21
|
+
// Dot in the center of the timeline item
|
|
22
|
+
const timelineDotVariants = cva(
|
|
23
|
+
"relative h-4 w-4 rounded-full z-10 flex items-center justify-center",
|
|
24
|
+
{
|
|
25
|
+
variants: {
|
|
26
|
+
variant: {
|
|
27
|
+
default: "border-primary",
|
|
28
|
+
secondary: "border-secondary",
|
|
29
|
+
destructive: "border-destructive",
|
|
30
|
+
outline: ""
|
|
31
|
+
},
|
|
32
|
+
hollow: {
|
|
33
|
+
true: "border-2 bg-card",
|
|
34
|
+
false: "border-2"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
compoundVariants: [
|
|
38
|
+
{
|
|
39
|
+
hollow: false,
|
|
40
|
+
variant: "default",
|
|
41
|
+
class: "bg-primary"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
hollow: false,
|
|
45
|
+
variant: "secondary",
|
|
46
|
+
class: "bg-secondary"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
hollow: false,
|
|
50
|
+
variant: "destructive",
|
|
51
|
+
class: "bg-destructive"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
hollow: false,
|
|
55
|
+
variant: "outline",
|
|
56
|
+
class: "bg-background"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
defaultVariants: {
|
|
60
|
+
variant: "default",
|
|
61
|
+
hollow: false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// Card container
|
|
67
|
+
const timelineItemVariants = cva(
|
|
68
|
+
"flex flex-col rounded-md transition-all p-4 shrink-0",
|
|
69
|
+
{
|
|
70
|
+
variants: {
|
|
71
|
+
variant: {
|
|
72
|
+
default: "bg-card border text-card-foreground shadow-sm",
|
|
73
|
+
secondary: "bg-secondary text-secondary-foreground shadow-sm",
|
|
74
|
+
destructive:
|
|
75
|
+
"bg-destructive/10 border border-destructive/20 text-destructive-foreground shadow-sm",
|
|
76
|
+
outline: "bg-transparent border shadow-sm"
|
|
77
|
+
},
|
|
78
|
+
noCards: {
|
|
79
|
+
true: "border-none shadow-none bg-transparent",
|
|
80
|
+
false: ""
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
defaultVariants: {
|
|
84
|
+
variant: "default",
|
|
85
|
+
noCards: false
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// Branch connecting dot to card
|
|
91
|
+
const timelineBranchVariants = cva("absolute z-0", {
|
|
92
|
+
variants: {
|
|
93
|
+
variant: {
|
|
94
|
+
default: "bg-primary",
|
|
95
|
+
secondary: "bg-secondary",
|
|
96
|
+
destructive: "bg-destructive",
|
|
97
|
+
outline: "bg-border"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
defaultVariants: {
|
|
101
|
+
variant: "default"
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Timeline layout container
|
|
106
|
+
const timelineLayoutVariants = cva("grid relative", {
|
|
107
|
+
variants: {
|
|
108
|
+
orientation: {
|
|
109
|
+
horizontal: "grid-flow-col grid-rows-[min-content_2rem_min-content]",
|
|
110
|
+
vertical: "grid-cols-[1fr_2rem_1fr] auto-rows-min"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
defaultVariants: {
|
|
114
|
+
orientation: "horizontal"
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Timeline item container (card + dot + line + branch)
|
|
119
|
+
const timelineItemContainerVariants = cva("flex relative snap-center", {
|
|
120
|
+
variants: {
|
|
121
|
+
orientation: {
|
|
122
|
+
horizontal: "w-full justify-center",
|
|
123
|
+
vertical: "h-full items-center"
|
|
124
|
+
},
|
|
125
|
+
side: {
|
|
126
|
+
before: "",
|
|
127
|
+
after: ""
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
compoundVariants: [
|
|
131
|
+
{ orientation: "horizontal", side: "before", class: "items-end" },
|
|
132
|
+
{ orientation: "horizontal", side: "after", class: "items-start" },
|
|
133
|
+
{ orientation: "vertical", side: "before", class: "justify-end" },
|
|
134
|
+
{ orientation: "vertical", side: "after", class: "justify-start" }
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// EXPORTED INTERFACES AND COMPONENTS
|
|
139
|
+
export interface TimelineItemProps
|
|
140
|
+
extends HTMLAttributes<HTMLLIElement>,
|
|
141
|
+
VariantProps<typeof timelineItemVariants> {
|
|
142
|
+
hollow?: boolean;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
type _timelineItemProps = TimelineItemProps & {
|
|
146
|
+
index?: number | null;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export interface TimelineProps
|
|
150
|
+
extends HTMLAttributes<HTMLDivElement>,
|
|
151
|
+
VariantProps<typeof timelineLayoutVariants> {
|
|
152
|
+
children?: React.ReactNode;
|
|
153
|
+
|
|
154
|
+
alternating?: boolean;
|
|
155
|
+
alignment?: "top/left" | "bottom/right";
|
|
156
|
+
|
|
157
|
+
horizItemSpacing?: number;
|
|
158
|
+
horizItemWidth?: number;
|
|
159
|
+
|
|
160
|
+
vertItemSpacing?: number;
|
|
161
|
+
vertItemMaxWidth?: number;
|
|
162
|
+
|
|
163
|
+
orientation?: "horizontal" | "vertical";
|
|
164
|
+
|
|
165
|
+
noCards?: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface TimelineItemDateProps
|
|
169
|
+
extends Omit<HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
170
|
+
children: Date | string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface TimelineItemTitleProps
|
|
174
|
+
extends HTMLAttributes<HTMLHeadingElement> {
|
|
175
|
+
children: React.ReactNode;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface TimelineItemDescriptionProps
|
|
179
|
+
extends HTMLAttributes<HTMLParagraphElement> {
|
|
180
|
+
children: React.ReactNode;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
type TimelineContextType = {
|
|
184
|
+
orientation: "horizontal" | "vertical";
|
|
185
|
+
total: number;
|
|
186
|
+
cardWidth: number;
|
|
187
|
+
maxCardWidth: number;
|
|
188
|
+
alternating: boolean;
|
|
189
|
+
alignment: "top/left" | "bottom/right";
|
|
190
|
+
noCards: boolean;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const TlCtxt = createContext<TimelineContextType | null>(null);
|
|
194
|
+
|
|
195
|
+
function useTimelineContext() {
|
|
196
|
+
const context = useContext(TlCtxt);
|
|
197
|
+
if (context === null) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
"Timeline components must be used within a Timeline component."
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
return context;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export default function Timeline({
|
|
206
|
+
children,
|
|
207
|
+
className,
|
|
208
|
+
horizItemWidth = 220,
|
|
209
|
+
horizItemSpacing = 130,
|
|
210
|
+
vertItemSpacing = 130,
|
|
211
|
+
vertItemMaxWidth = 350,
|
|
212
|
+
alternating = true,
|
|
213
|
+
alignment = "top/left",
|
|
214
|
+
orientation = "horizontal",
|
|
215
|
+
noCards = false,
|
|
216
|
+
...props
|
|
217
|
+
}: TimelineProps) {
|
|
218
|
+
const isVertical = orientation === "vertical";
|
|
219
|
+
|
|
220
|
+
const safePadding = Math.max(0, (horizItemWidth - horizItemSpacing) / 2);
|
|
221
|
+
|
|
222
|
+
const [verticalPadding, setVerticalPadding] = useState({ top: 0, bottom: 0 });
|
|
223
|
+
const listRef = useRef<HTMLUListElement>(null);
|
|
224
|
+
|
|
225
|
+
useLayoutEffect(() => {
|
|
226
|
+
if (!isVertical || !listRef.current) {
|
|
227
|
+
setVerticalPadding({ top: 0, bottom: 0 });
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const computePadding = () => {
|
|
232
|
+
const list = listRef.current;
|
|
233
|
+
if (!list) return;
|
|
234
|
+
|
|
235
|
+
// Find all cards
|
|
236
|
+
const cards = list.querySelectorAll('[data-timeline-card="true"]');
|
|
237
|
+
if (cards.length === 0) return;
|
|
238
|
+
|
|
239
|
+
const firstCard = cards[0];
|
|
240
|
+
const lastCard = cards[cards.length - 1];
|
|
241
|
+
|
|
242
|
+
// Calculate heights
|
|
243
|
+
const firstHeight = firstCard.getBoundingClientRect().height;
|
|
244
|
+
const lastHeight = lastCard.getBoundingClientRect().height;
|
|
245
|
+
|
|
246
|
+
// Formula: (CardHeight - Spacing) / 2
|
|
247
|
+
// We use Math.max(0, ...) because if the card is smaller than spacing,
|
|
248
|
+
// we don't want negative padding.
|
|
249
|
+
const top = Math.max(0, (firstHeight - vertItemSpacing) / 2);
|
|
250
|
+
const bottom = Math.max(0, (lastHeight - vertItemSpacing) / 2);
|
|
251
|
+
|
|
252
|
+
setVerticalPadding({ top, bottom });
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
// Run initially
|
|
256
|
+
computePadding();
|
|
257
|
+
|
|
258
|
+
// Re-run if window resizes (content wrapping changes height)
|
|
259
|
+
const observer = new ResizeObserver(() => computePadding());
|
|
260
|
+
observer.observe(listRef.current);
|
|
261
|
+
|
|
262
|
+
return () => observer.disconnect();
|
|
263
|
+
}, [isVertical, vertItemSpacing, children]);
|
|
264
|
+
|
|
265
|
+
const contextVal: TimelineContextType = {
|
|
266
|
+
orientation,
|
|
267
|
+
total: Children.count(children),
|
|
268
|
+
cardWidth: horizItemWidth,
|
|
269
|
+
maxCardWidth: vertItemMaxWidth,
|
|
270
|
+
alternating,
|
|
271
|
+
alignment,
|
|
272
|
+
noCards
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
return (
|
|
276
|
+
<div
|
|
277
|
+
id="timeline-container"
|
|
278
|
+
className={cn(
|
|
279
|
+
"flex h-full w-full p-4",
|
|
280
|
+
isVertical ? "flex-col" : "flex-row",
|
|
281
|
+
className
|
|
282
|
+
)}
|
|
283
|
+
role="list"
|
|
284
|
+
aria-orientation={orientation}
|
|
285
|
+
aria-label="Timeline"
|
|
286
|
+
{...props}
|
|
287
|
+
>
|
|
288
|
+
<ul
|
|
289
|
+
id="timeline-grid"
|
|
290
|
+
className={timelineLayoutVariants({ orientation })}
|
|
291
|
+
style={
|
|
292
|
+
isVertical
|
|
293
|
+
? {
|
|
294
|
+
gridAutoRows: `${vertItemSpacing}px`,
|
|
295
|
+
// DYNAMIC GRID COLUMNS
|
|
296
|
+
gridTemplateColumns: alternating
|
|
297
|
+
? "1fr 2rem 1fr" // Standard centered
|
|
298
|
+
: alignment === "top/left" // "Content Left"
|
|
299
|
+
? "1fr 2rem" // remove right column
|
|
300
|
+
: "2rem 1fr", // remove left column (Line First)
|
|
301
|
+
paddingTop: `${verticalPadding.top}px`,
|
|
302
|
+
paddingBottom: `${verticalPadding.bottom}px`
|
|
303
|
+
}
|
|
304
|
+
: {
|
|
305
|
+
gridAutoColumns: `${horizItemSpacing}px`,
|
|
306
|
+
// DYNAMIC GRID ROWS
|
|
307
|
+
gridTemplateRows: alternating
|
|
308
|
+
? "min-content 2rem min-content"
|
|
309
|
+
: alignment === "top/left" // "Content Top"
|
|
310
|
+
? "min-content 2rem"
|
|
311
|
+
: "2rem min-content",
|
|
312
|
+
paddingLeft: `${safePadding}px`,
|
|
313
|
+
paddingRight: `${safePadding}px`
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
ref={listRef}
|
|
317
|
+
>
|
|
318
|
+
<TlCtxt.Provider value={contextVal}>
|
|
319
|
+
{Children.map(children, (child, index) =>
|
|
320
|
+
cloneElement(child as ReactElement<any>, { index })
|
|
321
|
+
)}
|
|
322
|
+
</TlCtxt.Provider>
|
|
323
|
+
</ul>
|
|
324
|
+
</div>
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function getGridAndLineStyles(
|
|
329
|
+
side: "before" | "after",
|
|
330
|
+
index: number,
|
|
331
|
+
isVertical: boolean,
|
|
332
|
+
alternating: boolean
|
|
333
|
+
): { gridStyle: CSSProperties; lineStyle: CSSProperties } {
|
|
334
|
+
let gridStyle: CSSProperties = {};
|
|
335
|
+
let lineStyle: CSSProperties = {};
|
|
336
|
+
|
|
337
|
+
if (isVertical) {
|
|
338
|
+
// VERTICAL LOGIC
|
|
339
|
+
if (alternating) {
|
|
340
|
+
// 3 Columns: [Content] [Line] [Content]
|
|
341
|
+
gridStyle = { gridColumn: side === "before" ? 1 : 3, gridRow: index + 1 };
|
|
342
|
+
lineStyle = { gridColumn: 2, gridRow: index + 1, height: "100%" };
|
|
343
|
+
} else {
|
|
344
|
+
// 2 Columns
|
|
345
|
+
if (side === "before") {
|
|
346
|
+
// [Content] [Line]
|
|
347
|
+
gridStyle = { gridColumn: 1, gridRow: index + 1 };
|
|
348
|
+
lineStyle = { gridColumn: 2, gridRow: index + 1, height: "100%" };
|
|
349
|
+
} else {
|
|
350
|
+
// [Line] [Content]
|
|
351
|
+
gridStyle = { gridColumn: 2, gridRow: index + 1 };
|
|
352
|
+
lineStyle = { gridColumn: 1, gridRow: index + 1, height: "100%" };
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
// HORIZONTAL LOGIC
|
|
357
|
+
if (alternating) {
|
|
358
|
+
// 3 Rows: [Content] [Line] [Content]
|
|
359
|
+
gridStyle = { gridColumn: index + 1, gridRow: side === "before" ? 1 : 3 };
|
|
360
|
+
lineStyle = { gridColumn: index + 1, gridRow: 2, width: "100%" };
|
|
361
|
+
} else {
|
|
362
|
+
// 2 Rows
|
|
363
|
+
if (side === "before") {
|
|
364
|
+
// [Content]
|
|
365
|
+
// [Line]
|
|
366
|
+
gridStyle = { gridColumn: index + 1, gridRow: 1 };
|
|
367
|
+
lineStyle = { gridColumn: index + 1, gridRow: 2, width: "100%" };
|
|
368
|
+
} else {
|
|
369
|
+
// [Line]
|
|
370
|
+
// [Content]
|
|
371
|
+
gridStyle = { gridColumn: index + 1, gridRow: 2 };
|
|
372
|
+
lineStyle = { gridColumn: index + 1, gridRow: 1, width: "100%" };
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return { gridStyle, lineStyle };
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function getCardStyle(
|
|
381
|
+
isVertical: boolean,
|
|
382
|
+
cardWidth: number,
|
|
383
|
+
maxCardWidth: number
|
|
384
|
+
): CSSProperties {
|
|
385
|
+
return isVertical
|
|
386
|
+
? {
|
|
387
|
+
maxWidth: `${maxCardWidth}px`
|
|
388
|
+
}
|
|
389
|
+
: {
|
|
390
|
+
width: `${cardWidth}px`,
|
|
391
|
+
minWidth: `${cardWidth}px`,
|
|
392
|
+
maxWidth: `${cardWidth}px`
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function getBranchStyle(
|
|
397
|
+
isVertical: boolean,
|
|
398
|
+
isEven: boolean,
|
|
399
|
+
alternating: boolean,
|
|
400
|
+
alignment: "top/left" | "bottom/right"
|
|
401
|
+
): string {
|
|
402
|
+
return isVertical
|
|
403
|
+
? alternating
|
|
404
|
+
? isEven
|
|
405
|
+
? "h-px w-4 left-0"
|
|
406
|
+
: "h-px w-4 right-0"
|
|
407
|
+
: alignment === "top/left"
|
|
408
|
+
? "h-px w-4 left-0"
|
|
409
|
+
: "h-px w-4 right-0"
|
|
410
|
+
: alternating
|
|
411
|
+
? isEven
|
|
412
|
+
? "w-px h-4 top-0"
|
|
413
|
+
: "w-px h-4 bottom-0"
|
|
414
|
+
: alignment === "top/left"
|
|
415
|
+
? "w-px h-4 top-0"
|
|
416
|
+
: "w-px h-4 bottom-0";
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export function TimelineItem({
|
|
420
|
+
children,
|
|
421
|
+
className,
|
|
422
|
+
variant,
|
|
423
|
+
hollow = false,
|
|
424
|
+
index = null,
|
|
425
|
+
...props
|
|
426
|
+
}: _timelineItemProps) {
|
|
427
|
+
if (index == null) {
|
|
428
|
+
throw new Error("TimelineItem must be used as a direct child of Timeline.");
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const {
|
|
432
|
+
orientation,
|
|
433
|
+
total,
|
|
434
|
+
cardWidth,
|
|
435
|
+
maxCardWidth,
|
|
436
|
+
alternating,
|
|
437
|
+
alignment,
|
|
438
|
+
noCards
|
|
439
|
+
} = useTimelineContext();
|
|
440
|
+
|
|
441
|
+
const isEven = index % 2 === 0;
|
|
442
|
+
const isVertical = orientation === "vertical";
|
|
443
|
+
|
|
444
|
+
// Determine "side" based on index
|
|
445
|
+
const side = alternating
|
|
446
|
+
? isEven
|
|
447
|
+
? "before"
|
|
448
|
+
: "after"
|
|
449
|
+
: alignment === "top/left"
|
|
450
|
+
? "before"
|
|
451
|
+
: "after";
|
|
452
|
+
|
|
453
|
+
const { gridStyle, lineStyle } = getGridAndLineStyles(
|
|
454
|
+
side,
|
|
455
|
+
index,
|
|
456
|
+
isVertical,
|
|
457
|
+
alternating
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
return (
|
|
461
|
+
<>
|
|
462
|
+
<li
|
|
463
|
+
id={`timeline-item-${index}-container`}
|
|
464
|
+
className={cn(timelineItemContainerVariants({ orientation, side }))}
|
|
465
|
+
style={gridStyle}
|
|
466
|
+
role="listitem"
|
|
467
|
+
aria-posinset={index + 1}
|
|
468
|
+
aria-setsize={total}
|
|
469
|
+
{...props}
|
|
470
|
+
>
|
|
471
|
+
<div
|
|
472
|
+
id={`timeline-item-${index}`}
|
|
473
|
+
style={getCardStyle(isVertical, cardWidth, maxCardWidth)}
|
|
474
|
+
className={cn(timelineItemVariants({ variant, noCards }), className)}
|
|
475
|
+
data-timeline-card={true}
|
|
476
|
+
>
|
|
477
|
+
{children}
|
|
478
|
+
</div>
|
|
479
|
+
</li>
|
|
480
|
+
|
|
481
|
+
<li
|
|
482
|
+
id={`timeline-item-${index}-middle`}
|
|
483
|
+
className="relative flex items-center justify-center"
|
|
484
|
+
style={lineStyle}
|
|
485
|
+
>
|
|
486
|
+
<div
|
|
487
|
+
className={cn(
|
|
488
|
+
"absolute bg-muted",
|
|
489
|
+
index === 0
|
|
490
|
+
? isVertical
|
|
491
|
+
? "rounded-t-full"
|
|
492
|
+
: "rounded-l-full"
|
|
493
|
+
: "",
|
|
494
|
+
index === total - 1
|
|
495
|
+
? isVertical
|
|
496
|
+
? "rounded-b-full"
|
|
497
|
+
: "rounded-r-full"
|
|
498
|
+
: "",
|
|
499
|
+
isVertical ? "h-full w-1" : "w-full h-1"
|
|
500
|
+
)}
|
|
501
|
+
id={`timeline-item-${index}-line`}
|
|
502
|
+
aria-hidden="true"
|
|
503
|
+
/>
|
|
504
|
+
|
|
505
|
+
<div
|
|
506
|
+
className={cn(
|
|
507
|
+
timelineBranchVariants({ variant }),
|
|
508
|
+
getBranchStyle(isVertical, isEven, alternating, alignment)
|
|
509
|
+
)}
|
|
510
|
+
id={`timeline-item-${index}-branch`}
|
|
511
|
+
aria-hidden="true"
|
|
512
|
+
/>
|
|
513
|
+
|
|
514
|
+
<div
|
|
515
|
+
className={cn(timelineDotVariants({ variant, hollow }))}
|
|
516
|
+
id={`timeline-item-${index}-dot`}
|
|
517
|
+
aria-hidden="true"
|
|
518
|
+
/>
|
|
519
|
+
</li>
|
|
520
|
+
</>
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export function TimelineItemDate({
|
|
525
|
+
children,
|
|
526
|
+
className,
|
|
527
|
+
...props
|
|
528
|
+
}: TimelineItemDateProps) {
|
|
529
|
+
return (
|
|
530
|
+
<span
|
|
531
|
+
className={cn("text-xs text-muted-foreground mb-1", className)}
|
|
532
|
+
{...props}
|
|
533
|
+
>
|
|
534
|
+
{children instanceof Date ? (
|
|
535
|
+
<time dateTime={children.toISOString()}>
|
|
536
|
+
{dateFormatter.format(children)}
|
|
537
|
+
</time>
|
|
538
|
+
) : (
|
|
539
|
+
children
|
|
540
|
+
)}
|
|
541
|
+
</span>
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
export function TimelineItemTitle({
|
|
546
|
+
children,
|
|
547
|
+
className,
|
|
548
|
+
...props
|
|
549
|
+
}: TimelineItemTitleProps) {
|
|
550
|
+
return (
|
|
551
|
+
<h3 className={cn("font-semibold", className)} {...props}>
|
|
552
|
+
{children}
|
|
553
|
+
</h3>
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
export function TimelineItemDescription({
|
|
558
|
+
children,
|
|
559
|
+
className,
|
|
560
|
+
...props
|
|
561
|
+
}: TimelineItemDescriptionProps) {
|
|
562
|
+
return (
|
|
563
|
+
<p
|
|
564
|
+
className={cn("text-sm text-muted-foreground mt-2", className)}
|
|
565
|
+
{...props}
|
|
566
|
+
>
|
|
567
|
+
{children}
|
|
568
|
+
</p>
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const dateFormatter = new Intl.DateTimeFormat("en-US", {
|
|
573
|
+
day: "numeric",
|
|
574
|
+
month: "short",
|
|
575
|
+
year: "numeric"
|
|
576
|
+
});
|