@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,226 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
HTMLAttributes,
|
|
6
|
+
TimeHTMLAttributes,
|
|
7
|
+
useCallback,
|
|
8
|
+
useContext,
|
|
9
|
+
useState,
|
|
10
|
+
} from "react"
|
|
11
|
+
import { Slot } from "radix-ui"
|
|
12
|
+
import { Motion } from "../../infrastructure/library/motion"
|
|
13
|
+
import { cn } from "../../infrastructure/utilities/utils"
|
|
14
|
+
import { elasticEnter } from "../../infrastructure/library/motion-utils"
|
|
15
|
+
|
|
16
|
+
// Types
|
|
17
|
+
type TimelineContextValue = {
|
|
18
|
+
activeStep: number
|
|
19
|
+
setActiveStep: (step: number) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Context
|
|
23
|
+
const TimelineContext = createContext<TimelineContextValue | undefined>(
|
|
24
|
+
undefined
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const useTimeline = () => {
|
|
28
|
+
const context = useContext(TimelineContext)
|
|
29
|
+
if (!context) {
|
|
30
|
+
throw new Error("useTimeline must be used within a Timeline")
|
|
31
|
+
}
|
|
32
|
+
return context
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Components
|
|
36
|
+
interface TimelineProps extends HTMLAttributes<HTMLDivElement> {
|
|
37
|
+
defaultValue?: number
|
|
38
|
+
value?: number
|
|
39
|
+
onValueChange?: (value: number) => void
|
|
40
|
+
orientation?: "horizontal" | "vertical"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Timeline({
|
|
44
|
+
defaultValue = 1,
|
|
45
|
+
value,
|
|
46
|
+
onValueChange,
|
|
47
|
+
orientation = "vertical",
|
|
48
|
+
className,
|
|
49
|
+
children,
|
|
50
|
+
...props
|
|
51
|
+
}: TimelineProps) {
|
|
52
|
+
const [activeStep, setInternalStep] = useState(defaultValue)
|
|
53
|
+
|
|
54
|
+
const setActiveStep = useCallback(
|
|
55
|
+
(step: number) => {
|
|
56
|
+
if (value === undefined) {
|
|
57
|
+
setInternalStep(step)
|
|
58
|
+
}
|
|
59
|
+
onValueChange?.(step)
|
|
60
|
+
},
|
|
61
|
+
[value, onValueChange]
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
const currentStep = value ?? activeStep
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<TimelineContext.Provider
|
|
68
|
+
value={{ activeStep: currentStep, setActiveStep }}
|
|
69
|
+
>
|
|
70
|
+
<div
|
|
71
|
+
className={cn(
|
|
72
|
+
"group/timeline flex data-[orientation=horizontal]:w-full data-[orientation=horizontal]:flex-row data-[orientation=vertical]:flex-col",
|
|
73
|
+
className
|
|
74
|
+
)}
|
|
75
|
+
data-orientation={orientation}
|
|
76
|
+
data-slot="timeline"
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
{children}
|
|
80
|
+
</div>
|
|
81
|
+
</TimelineContext.Provider>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// TimelineContent
|
|
86
|
+
function TimelineContent({
|
|
87
|
+
className,
|
|
88
|
+
...props
|
|
89
|
+
}: HTMLAttributes<HTMLDivElement>) {
|
|
90
|
+
return (
|
|
91
|
+
<div
|
|
92
|
+
className={cn("text-muted-foreground text-sm", className)}
|
|
93
|
+
data-slot="timeline-content"
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// TimelineDate
|
|
100
|
+
// TimeHTMLAttributes (not the generic HTMLAttributes) so the <time>-specific `dateTime`
|
|
101
|
+
// attribute is accepted — matches the base wrapper's useRender.ComponentProps<"time">.
|
|
102
|
+
interface TimelineDateProps extends TimeHTMLAttributes<HTMLTimeElement> {
|
|
103
|
+
asChild?: boolean
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function TimelineDate({
|
|
107
|
+
asChild = false,
|
|
108
|
+
className,
|
|
109
|
+
...props
|
|
110
|
+
}: TimelineDateProps) {
|
|
111
|
+
const Comp = asChild ? Slot.Root : "time"
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<Comp
|
|
115
|
+
className={cn(
|
|
116
|
+
"text-muted-foreground mb-1 block text-xs font-medium group-data-[orientation=vertical]/timeline:max-sm:h-4",
|
|
117
|
+
className
|
|
118
|
+
)}
|
|
119
|
+
data-slot="timeline-date"
|
|
120
|
+
{...props}
|
|
121
|
+
/>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// TimelineHeader
|
|
126
|
+
function TimelineHeader({
|
|
127
|
+
className,
|
|
128
|
+
...props
|
|
129
|
+
}: HTMLAttributes<HTMLDivElement>) {
|
|
130
|
+
return (
|
|
131
|
+
<div className={cn(className)} data-slot="timeline-header" {...props} />
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// TimelineIndicator
|
|
136
|
+
interface TimelineIndicatorProps extends HTMLAttributes<HTMLDivElement> {
|
|
137
|
+
asChild?: boolean
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function TimelineIndicator({
|
|
141
|
+
asChild = false,
|
|
142
|
+
className,
|
|
143
|
+
children,
|
|
144
|
+
...props
|
|
145
|
+
}: TimelineIndicatorProps) {
|
|
146
|
+
const Comp = asChild ? Slot.Root : "div"
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<Comp
|
|
150
|
+
aria-hidden="true"
|
|
151
|
+
className={cn(
|
|
152
|
+
"border-primary/20 group-data-completed/timeline-item:border-primary absolute size-4 rounded-full border-2 group-data-[orientation=horizontal]/timeline:-top-6 group-data-[orientation=horizontal]/timeline:left-0 group-data-[orientation=horizontal]/timeline:-translate-y-1/2 group-data-[orientation=vertical]/timeline:top-0 group-data-[orientation=vertical]/timeline:-left-6 group-data-[orientation=vertical]/timeline:-translate-x-1/2",
|
|
153
|
+
className
|
|
154
|
+
)}
|
|
155
|
+
data-slot="timeline-indicator"
|
|
156
|
+
{...props}
|
|
157
|
+
>
|
|
158
|
+
{children}
|
|
159
|
+
</Comp>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// TimelineItem
|
|
164
|
+
interface TimelineItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
165
|
+
step: number
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function TimelineItem({ step, className, ...props }: TimelineItemProps) {
|
|
169
|
+
const { activeStep } = useTimeline()
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<Motion
|
|
173
|
+
animation={elasticEnter()}
|
|
174
|
+
className={cn(
|
|
175
|
+
"group/timeline-item has-[+[data-completed]]:**:data-[slot=timeline-separator]:bg-primary relative flex flex-1 flex-col gap-0.5 group-data-[orientation=horizontal]/timeline:mt-8 group-data-[orientation=horizontal]/timeline:not-last:pe-8 group-data-[orientation=vertical]/timeline:ms-8 group-data-[orientation=vertical]/timeline:not-last:pb-6",
|
|
176
|
+
className
|
|
177
|
+
)}
|
|
178
|
+
data-completed={step <= activeStep || undefined}
|
|
179
|
+
data-slot="timeline-item"
|
|
180
|
+
{...props}
|
|
181
|
+
/>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// TimelineSeparator
|
|
186
|
+
function TimelineSeparator({
|
|
187
|
+
className,
|
|
188
|
+
...props
|
|
189
|
+
}: HTMLAttributes<HTMLDivElement>) {
|
|
190
|
+
return (
|
|
191
|
+
<div
|
|
192
|
+
aria-hidden="true"
|
|
193
|
+
className={cn(
|
|
194
|
+
"bg-primary/10 absolute self-start group-last/timeline-item:hidden group-data-[orientation=horizontal]/timeline:-top-6 group-data-[orientation=horizontal]/timeline:h-0.5 group-data-[orientation=horizontal]/timeline:w-[calc(100%-1rem-0.25rem)] group-data-[orientation=horizontal]/timeline:translate-x-4.5 group-data-[orientation=horizontal]/timeline:-translate-y-1/2 group-data-[orientation=vertical]/timeline:-left-6 group-data-[orientation=vertical]/timeline:h-[calc(100%-1rem-0.25rem)] group-data-[orientation=vertical]/timeline:w-0.5 group-data-[orientation=vertical]/timeline:-translate-x-1/2 group-data-[orientation=vertical]/timeline:translate-y-4.5",
|
|
195
|
+
className
|
|
196
|
+
)}
|
|
197
|
+
data-slot="timeline-separator"
|
|
198
|
+
{...props}
|
|
199
|
+
/>
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// TimelineTitle
|
|
204
|
+
function TimelineTitle({
|
|
205
|
+
className,
|
|
206
|
+
...props
|
|
207
|
+
}: HTMLAttributes<HTMLHeadingElement>) {
|
|
208
|
+
return (
|
|
209
|
+
<h3
|
|
210
|
+
className={cn("text-sm font-medium", className)}
|
|
211
|
+
data-slot="timeline-title"
|
|
212
|
+
{...props}
|
|
213
|
+
/>
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export {
|
|
218
|
+
Timeline,
|
|
219
|
+
TimelineContent,
|
|
220
|
+
TimelineDate,
|
|
221
|
+
TimelineHeader,
|
|
222
|
+
TimelineIndicator,
|
|
223
|
+
TimelineItem,
|
|
224
|
+
TimelineSeparator,
|
|
225
|
+
TimelineTitle,
|
|
226
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {Sheet, SheetContent, SheetTrigger} from "../ui/sheet";
|
|
2
|
+
import {cn} from "../../infrastructure/utilities/utils";
|
|
3
|
+
|
|
4
|
+
export interface LegacySheetProps {
|
|
5
|
+
trigger?: React.ReactNode;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
opened?: boolean;
|
|
8
|
+
onOpenChange?: (status: boolean) => void;
|
|
9
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function LegacySheet({opened, children, onOpenChange, trigger, side, className}: LegacySheetProps) {
|
|
14
|
+
|
|
15
|
+
side = side ?? 'right';
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Sheet open={opened} onOpenChange={onOpenChange}>
|
|
19
|
+
{trigger && (
|
|
20
|
+
<SheetTrigger className={cn('flex items-center w-full')} asChild>
|
|
21
|
+
{trigger}
|
|
22
|
+
</SheetTrigger>
|
|
23
|
+
)}
|
|
24
|
+
<SheetContent
|
|
25
|
+
side={side ?? 'right'}
|
|
26
|
+
className={cn(
|
|
27
|
+
'bg-background/95 backdrop-blur-4xl rounded-xl m-4',
|
|
28
|
+
side === 'left' || side === 'right' ? 'w-[calc(100dvw-32px)]! sm:min-w-[80dvw]! md:min-w-[60dvw]! lg:min-w-[35dvw]! h-full! max-h-[calc(100dvh-32px)]!' : '',
|
|
29
|
+
side === 'top' || side === 'bottom' ? 'min-h-dvh md:min-h-[35dvh]! w-full! max-w-[calc(100dvw-32px)]!' : '',
|
|
30
|
+
className,
|
|
31
|
+
)}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</SheetContent>
|
|
35
|
+
</Sheet>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export enum SizeEnum {
|
|
2
|
+
SM = 'max-w-sm',
|
|
3
|
+
MD = 'max-w-md',
|
|
4
|
+
LG = 'max-w-lg',
|
|
5
|
+
XL = 'max-w-xl',
|
|
6
|
+
XXL = 'max-w-[960px]',
|
|
7
|
+
FULL = 'max-w-[98dvw]',
|
|
8
|
+
AUTO = 'w-auto',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export enum SizeHeightEnum {
|
|
12
|
+
SM = 'h-sm',
|
|
13
|
+
MD = 'h-md',
|
|
14
|
+
LG = 'h-lg',
|
|
15
|
+
XL = 'h-xl',
|
|
16
|
+
XXL = 'h-[800px]',
|
|
17
|
+
FULL = 'h-[98dvh]',
|
|
18
|
+
AUTO = 'h-auto',
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {Fragment} from "react";
|
|
2
|
+
import {ThemeLogoProps} from "./types";
|
|
3
|
+
import {cn} from "../../infrastructure/utilities/utils";
|
|
4
|
+
import {LogoConfig} from "../../domain/config/logo.config";
|
|
5
|
+
import {AppConfig} from "../../domain/config/app.config";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export function ThemeLogo({size, className, color, onDark, variant}: ThemeLogoProps) {
|
|
9
|
+
const _size = size ? `w-${size}` : '';
|
|
10
|
+
const _variant = variant || 'banner';
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Fragment>
|
|
14
|
+
<img src={LogoConfig[_variant][color || 'normal']}
|
|
15
|
+
className={cn("dark:hidden block w-50 h-auto object-contain", _size, className)} alt={AppConfig.APP_NAME}/>
|
|
16
|
+
<img src={LogoConfig[_variant][onDark || 'white']}
|
|
17
|
+
className={cn("dark:block hidden w-50 h-auto object-contain", _size, className)}
|
|
18
|
+
alt={AppConfig.APP_NAME}/>
|
|
19
|
+
</Fragment>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ThemeLogoColorVariant = 'normal' | 'white' | 'black';
|
|
2
|
+
export type ThemeLogoVariant = 'icon' | 'banner' | 'square';
|
|
3
|
+
|
|
4
|
+
export interface ThemeLogoProps {
|
|
5
|
+
size?: number;
|
|
6
|
+
variant?: ThemeLogoVariant;
|
|
7
|
+
color?: ThemeLogoColorVariant;
|
|
8
|
+
onDark?: ThemeLogoColorVariant;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {useEffect} from "react";
|
|
4
|
+
import {PreferColorSchemeEnum} from "./theme.enum";
|
|
5
|
+
import {useThemePreferColorSchemeStore} from "./theme.store";
|
|
6
|
+
|
|
7
|
+
export function ThemePreferColorSchemeProvider() {
|
|
8
|
+
const setColorScheme = useThemePreferColorSchemeStore((state) => state.setColorScheme);
|
|
9
|
+
const initialize = useThemePreferColorSchemeStore((state) => state.initialize);
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
let disposed = false;
|
|
13
|
+
let mediaQuery: MediaQueryList | null = null;
|
|
14
|
+
let changed: ((event: MediaQueryListEvent) => void) | null = null;
|
|
15
|
+
let preferSystem = false;
|
|
16
|
+
|
|
17
|
+
initialize().then((cached) => {
|
|
18
|
+
if (disposed) return;
|
|
19
|
+
|
|
20
|
+
const state = useThemePreferColorSchemeStore.getState();
|
|
21
|
+
const hasRecord = cached.colorScheme !== undefined || cached.preferSystem !== undefined || state.colorScheme !== undefined;
|
|
22
|
+
preferSystem = cached.preferSystem ?? (hasRecord ? state.preferSystem : true);
|
|
23
|
+
const _colorScheme = cached.colorScheme ?? state.colorScheme ?? PreferColorSchemeEnum.Light;
|
|
24
|
+
|
|
25
|
+
mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
26
|
+
|
|
27
|
+
const applySystem = (matches: boolean) =>
|
|
28
|
+
setColorScheme(matches ? PreferColorSchemeEnum.Dark : PreferColorSchemeEnum.Light);
|
|
29
|
+
|
|
30
|
+
if (preferSystem) {
|
|
31
|
+
applySystem(mediaQuery.matches);
|
|
32
|
+
} else {
|
|
33
|
+
setColorScheme(_colorScheme);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
changed = (event: MediaQueryListEvent) => {
|
|
37
|
+
if (preferSystem) applySystem(event.matches);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
mediaQuery.addEventListener("change", changed);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return () => {
|
|
44
|
+
disposed = true;
|
|
45
|
+
if (mediaQuery && changed) mediaQuery.removeEventListener("change", changed);
|
|
46
|
+
};
|
|
47
|
+
}, [initialize, setColorScheme]);
|
|
48
|
+
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import {FaIcon, FaTypeEnum} from "../icons/glyphIcons";
|
|
5
|
+
import {Button} from "../ui/button";
|
|
6
|
+
import {useThemePreferColorSchemeStore} from "./theme.store";
|
|
7
|
+
|
|
8
|
+
export function SwitchColorScheme() {
|
|
9
|
+
const {toggleColorScheme} = useThemePreferColorSchemeStore()
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Button variant={"ghost"} className={"px-3"} onClick={() => toggleColorScheme(true)}>
|
|
13
|
+
<FaIcon type={FaTypeEnum.Solid} name="eclipse"/>
|
|
14
|
+
</Button>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import {Button} from "../ui/button";
|
|
4
|
+
import {MoonIcon, SunIcon} from "lucide-react";
|
|
5
|
+
import {useThemePreferColorSchemeStore} from "./theme.store";
|
|
6
|
+
import {PreferColorSchemeEnum} from "./theme.enum";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function ThemeSwitcherButton() {
|
|
10
|
+
const {colorScheme, toggleColorScheme} = useThemePreferColorSchemeStore()
|
|
11
|
+
return (
|
|
12
|
+
<Button
|
|
13
|
+
variant="ghost"
|
|
14
|
+
onClick={() => toggleColorScheme(true)}
|
|
15
|
+
className="w-8 h-8"
|
|
16
|
+
>
|
|
17
|
+
{colorScheme !== PreferColorSchemeEnum.Light ? <SunIcon/> : <MoonIcon/>}
|
|
18
|
+
</Button>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { create } from "zustand";
|
|
4
|
+
import { PreferColorSchemeEnum } from "./theme.enum";
|
|
5
|
+
|
|
6
|
+
export interface ThemeCacheInterface {
|
|
7
|
+
colorScheme?: PreferColorSchemeEnum;
|
|
8
|
+
preferSystem?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ThemePreferColorSchemeStoreState {
|
|
12
|
+
colorScheme: PreferColorSchemeEnum | undefined;
|
|
13
|
+
preferSystem: boolean;
|
|
14
|
+
toggleColorScheme: (persist?: boolean) => void;
|
|
15
|
+
useSystem: (prefer: boolean) => void;
|
|
16
|
+
setColorScheme: (theme: PreferColorSchemeEnum) => void;
|
|
17
|
+
initialize: () => Promise<ThemeCacheInterface>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const STORAGE_KEY = "@theme-prefers-color-scheme";
|
|
21
|
+
|
|
22
|
+
const readCache = (): ThemeCacheInterface => {
|
|
23
|
+
if (typeof window === "undefined") return {};
|
|
24
|
+
try {
|
|
25
|
+
const raw = window.localStorage.getItem(STORAGE_KEY);
|
|
26
|
+
return raw ? JSON.parse(raw) : {};
|
|
27
|
+
} catch {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const writeCache = (patch: Partial<ThemeCacheInterface>) => {
|
|
33
|
+
if (typeof window === "undefined") return;
|
|
34
|
+
try {
|
|
35
|
+
const current = readCache();
|
|
36
|
+
window.localStorage.setItem(STORAGE_KEY, JSON.stringify({ ...current, ...patch }));
|
|
37
|
+
} catch {
|
|
38
|
+
// ignore storage errors
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const presetPreferColorSchemes = Object.values(PreferColorSchemeEnum);
|
|
43
|
+
|
|
44
|
+
const getTargetElement = () => {
|
|
45
|
+
if (typeof document === "undefined") return undefined;
|
|
46
|
+
return presetPreferColorSchemes
|
|
47
|
+
.filter((scheme) => document.querySelector("body")?.classList.contains(scheme))
|
|
48
|
+
.pop() ? document.querySelector("body") : document.documentElement;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const useThemePreferColorSchemeStore = create<ThemePreferColorSchemeStoreState>((set) => ({
|
|
52
|
+
colorScheme: undefined,
|
|
53
|
+
preferSystem: false,
|
|
54
|
+
useSystem: async (preferSystem: boolean) => {
|
|
55
|
+
writeCache({ preferSystem });
|
|
56
|
+
return set({ preferSystem });
|
|
57
|
+
},
|
|
58
|
+
toggleColorScheme: async (persist: boolean = true) => {
|
|
59
|
+
const body = getTargetElement();
|
|
60
|
+
if (body) {
|
|
61
|
+
const current = body.classList.contains(PreferColorSchemeEnum.Dark)
|
|
62
|
+
? PreferColorSchemeEnum.Dark
|
|
63
|
+
: PreferColorSchemeEnum.Light;
|
|
64
|
+
|
|
65
|
+
const getColorScheme = current == PreferColorSchemeEnum.Light
|
|
66
|
+
? PreferColorSchemeEnum.Dark
|
|
67
|
+
: PreferColorSchemeEnum.Light;
|
|
68
|
+
|
|
69
|
+
body.classList.remove(PreferColorSchemeEnum.Light, PreferColorSchemeEnum.Dark);
|
|
70
|
+
body.classList.add(getColorScheme);
|
|
71
|
+
|
|
72
|
+
if (persist) writeCache({ colorScheme: getColorScheme });
|
|
73
|
+
|
|
74
|
+
return set({ colorScheme: getColorScheme });
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
setColorScheme: async (colorScheme: PreferColorSchemeEnum) => {
|
|
78
|
+
const body = getTargetElement();
|
|
79
|
+
if (body) {
|
|
80
|
+
body.classList.remove(PreferColorSchemeEnum.Light, PreferColorSchemeEnum.Dark);
|
|
81
|
+
body.classList.add(colorScheme);
|
|
82
|
+
}
|
|
83
|
+
writeCache({ colorScheme });
|
|
84
|
+
return set({ colorScheme });
|
|
85
|
+
},
|
|
86
|
+
initialize: async () => readCache(),
|
|
87
|
+
}));
|