@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,319 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, {useEffect, useRef, useState} from 'react';
|
|
4
|
+
import {
|
|
5
|
+
Stepper,
|
|
6
|
+
StepperContent,
|
|
7
|
+
StepperIndicator,
|
|
8
|
+
StepperItem,
|
|
9
|
+
StepperNav,
|
|
10
|
+
StepperPanel,
|
|
11
|
+
StepperSeparator,
|
|
12
|
+
StepperTrigger,
|
|
13
|
+
} from '../../reui/stepper';
|
|
14
|
+
import {useModal} from '../hooks/useModal';
|
|
15
|
+
import {Button} from '../../ui/button';
|
|
16
|
+
import {SizeEnum} from '../../size.enum';
|
|
17
|
+
import {ObjectableType} from "../../../domain/entities/objectable.type";
|
|
18
|
+
import {ModalOptions} from "../types/modal.type";
|
|
19
|
+
import {toast} from 'sonner';
|
|
20
|
+
import {useUploadStore} from "../../../infrastructure/stores/upload.store";
|
|
21
|
+
import {UploadProgressDialog} from "../../components/upload-progress-dialog";
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export interface ModalStepperStep<T extends ObjectableType = any> {
|
|
25
|
+
id: string | number;
|
|
26
|
+
title: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
required?: boolean;
|
|
29
|
+
content: React.ReactNode | ((props: {
|
|
30
|
+
next: () => void;
|
|
31
|
+
prev: () => void;
|
|
32
|
+
data: Partial<T>;
|
|
33
|
+
updateData: (newData: any) => void
|
|
34
|
+
}) => React.ReactNode);
|
|
35
|
+
validation?: (data: Partial<T>, updateData: (data: Partial<T>) => void) => Promise<number | string | { step: number | string; lockNavigation?: boolean } | void>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface ModalStepperStageProps<T extends ObjectableType = any> {
|
|
39
|
+
data: Partial<T>;
|
|
40
|
+
index: number;
|
|
41
|
+
id: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ModalStepperAction {
|
|
45
|
+
label?: string;
|
|
46
|
+
hide?: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ModalStepperActions {
|
|
50
|
+
cancel?: ModalStepperAction;
|
|
51
|
+
next?: ModalStepperAction;
|
|
52
|
+
previous?: ModalStepperAction;
|
|
53
|
+
done?: ModalStepperAction;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface ModalStepperProps<T extends ObjectableType = any> {
|
|
57
|
+
steps: ModalStepperStep<T>[];
|
|
58
|
+
title?: string;
|
|
59
|
+
initialData?: Partial<T>;
|
|
60
|
+
setId?: () => string;
|
|
61
|
+
onStep?: (props: ModalStepperStageProps<T>) => void;
|
|
62
|
+
onEnd?: (props: ModalStepperStageProps<T>) => Promise<void> | void;
|
|
63
|
+
onCancel?: () => void;
|
|
64
|
+
actions?: ModalStepperActions;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type ModalStepperResult<T extends ObjectableType = any> = {
|
|
68
|
+
result: T | null;
|
|
69
|
+
id: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function useModalStepper<T extends ObjectableType>(modalProps?: ModalOptions) {
|
|
73
|
+
const {open, close} = useModal();
|
|
74
|
+
|
|
75
|
+
return (props: ModalStepperProps<T>) => {
|
|
76
|
+
return new Promise<ModalStepperResult<T>>((resolve) => {
|
|
77
|
+
const id = open(
|
|
78
|
+
ModalStepperContent,
|
|
79
|
+
{
|
|
80
|
+
...props,
|
|
81
|
+
setId: () => id,
|
|
82
|
+
onStep: (stage: ModalStepperStageProps<T>) => {
|
|
83
|
+
if (props.onStep) props.onStep({...stage, id: id});
|
|
84
|
+
},
|
|
85
|
+
onEnd: async (stage: ModalStepperStageProps<T>) => {
|
|
86
|
+
try {
|
|
87
|
+
await props.onEnd?.({...stage, id: id});
|
|
88
|
+
resolve({id: id, result: stage.data as T});
|
|
89
|
+
close(id);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
onCancel: () => {
|
|
95
|
+
resolve({id: id, result: null});
|
|
96
|
+
if (props.onCancel) props.onCancel();
|
|
97
|
+
close(id)
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
title: props.title,
|
|
102
|
+
size: 'LG',
|
|
103
|
+
...(modalProps || {}),
|
|
104
|
+
scrollable: false,
|
|
105
|
+
useHeight: true
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
function ModalStepperContent<T extends ObjectableType>(
|
|
113
|
+
{
|
|
114
|
+
steps,
|
|
115
|
+
initialData = {} as T,
|
|
116
|
+
setId,
|
|
117
|
+
onStep,
|
|
118
|
+
onEnd,
|
|
119
|
+
onCancel,
|
|
120
|
+
actions,
|
|
121
|
+
}: ModalStepperProps<T>
|
|
122
|
+
) {
|
|
123
|
+
const [activeStep, setActiveStep] = useState(1);
|
|
124
|
+
const [isLocked, setIsLocked] = useState(false);
|
|
125
|
+
const [data, setData] = useState<Partial<T>>(initialData);
|
|
126
|
+
const [showUploadDialog, setShowUploadDialog] = useState(false);
|
|
127
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
128
|
+
const stepperScrollRef = useRef<HTMLDivElement>(null);
|
|
129
|
+
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (stepperScrollRef.current) {
|
|
132
|
+
const activeItem = stepperScrollRef.current.querySelector<HTMLElement>('[data-state="active"]');
|
|
133
|
+
if (activeItem) {
|
|
134
|
+
activeItem.scrollIntoView({behavior: 'smooth', block: 'nearest', inline: 'center'});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}, [activeStep]);
|
|
138
|
+
|
|
139
|
+
const modalId: string = typeof setId == 'function' ? setId() : Math.random().toString(36).substring(2, 9);
|
|
140
|
+
const updateData = (newData: Partial<T>) => {
|
|
141
|
+
setData((prev: Partial<T>) => ({...prev, ...newData}));
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const validateStep = () => {
|
|
145
|
+
const currentStep = steps[activeStep - 1];
|
|
146
|
+
if (!currentStep.required) return true;
|
|
147
|
+
|
|
148
|
+
if (containerRef.current) {
|
|
149
|
+
const inputs = containerRef.current.querySelectorAll('input, select, textarea');
|
|
150
|
+
let isAllValid = true;
|
|
151
|
+
|
|
152
|
+
inputs.forEach((input: any) => {
|
|
153
|
+
if (input.required || input.pattern) {
|
|
154
|
+
if (!input.checkValidity()) {
|
|
155
|
+
input.reportValidity();
|
|
156
|
+
isAllValid = false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return isAllValid;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return true;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const resolveTargetStep = (target: number | string | { step: number | string; lockNavigation?: boolean }): { stepIndex: number; lock?: boolean } => {
|
|
168
|
+
if (typeof target === 'number') return { stepIndex: Math.max(1, Math.min(target, steps.length)) };
|
|
169
|
+
if (typeof target === 'string') {
|
|
170
|
+
const found = steps.findIndex(s => s.id === target);
|
|
171
|
+
return { stepIndex: found !== -1 ? found + 1 : activeStep };
|
|
172
|
+
}
|
|
173
|
+
const { step, lockNavigation } = target;
|
|
174
|
+
if (typeof step === 'number') return { stepIndex: Math.max(1, Math.min(step, steps.length)), lock: lockNavigation };
|
|
175
|
+
const found = steps.findIndex(s => s.id === step);
|
|
176
|
+
return { stepIndex: found !== -1 ? found + 1 : activeStep, lock: lockNavigation };
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const handleNext = async () => {
|
|
180
|
+
if (!validateStep()) return;
|
|
181
|
+
|
|
182
|
+
const currentStep = steps[activeStep - 1];
|
|
183
|
+
if (currentStep.validation) {
|
|
184
|
+
try {
|
|
185
|
+
const result = await currentStep.validation(data, updateData);
|
|
186
|
+
if (result !== undefined) {
|
|
187
|
+
const { stepIndex, lock } = resolveTargetStep(result as any);
|
|
188
|
+
if (lock) setIsLocked(true);
|
|
189
|
+
index = stepIndex;
|
|
190
|
+
onStep?.({data, index, id: modalId});
|
|
191
|
+
setActiveStep(stepIndex);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
} catch (error) {
|
|
195
|
+
toast.error(error instanceof Error ? error.message : 'Validation échouée');
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (activeStep < steps.length) {
|
|
201
|
+
index = activeStep + 1;
|
|
202
|
+
onStep?.({data, index, id: modalId});
|
|
203
|
+
setActiveStep(index);
|
|
204
|
+
} else {
|
|
205
|
+
index = steps.length;
|
|
206
|
+
await finish();
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const finish = async () => {
|
|
211
|
+
const hasActiveUploads = useUploadStore.getState().hasActiveUploads;
|
|
212
|
+
if (hasActiveUploads) {
|
|
213
|
+
setShowUploadDialog(true);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
await onEnd?.({data, index: steps.length, id: modalId});
|
|
218
|
+
} catch (error) {
|
|
219
|
+
toast.error(error instanceof Error ? error.message : 'Une erreur est survenue');
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const handleFinishAfterUploads = () => {
|
|
225
|
+
setShowUploadDialog(false);
|
|
226
|
+
void finish();
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const handlePrev = () => {
|
|
230
|
+
if (isLocked) return;
|
|
231
|
+
if (activeStep > 1) {
|
|
232
|
+
index = activeStep - 1;
|
|
233
|
+
onStep?.({data, index, id: modalId});
|
|
234
|
+
setActiveStep(index);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const handleCancel = () => {
|
|
239
|
+
onCancel?.();
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const isHiddenAction = (action: keyof ModalStepperActions) =>
|
|
243
|
+
typeof actions?.[action]?.hide !== 'boolean' || (typeof actions?.[action]?.hide === 'boolean' && !actions?.[action]?.hide);
|
|
244
|
+
|
|
245
|
+
let index = 0;
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<div className="flex flex-col w-full h-full min-h-[400px]" ref={containerRef}>
|
|
249
|
+
<div className="flex-auto overflow-hidden">
|
|
250
|
+
<Stepper value={activeStep} onValueChange={isLocked ? undefined : setActiveStep} className="space-y-8 w-full h-full ">
|
|
251
|
+
<div ref={stepperScrollRef}
|
|
252
|
+
className="overflow-x-auto scrollbar-none [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden">
|
|
253
|
+
<StepperNav className="w-max p-4">
|
|
254
|
+
{steps.map((step, index) => {
|
|
255
|
+
const stepNumber = index + 1;
|
|
256
|
+
return (
|
|
257
|
+
<StepperItem key={step.id} step={stepNumber}>
|
|
258
|
+
<StepperTrigger className="min-w-[200px]">
|
|
259
|
+
<StepperIndicator>{stepNumber}</StepperIndicator>
|
|
260
|
+
<div className="flex flex-col text-left ml-2">
|
|
261
|
+
<span className="text-sm font-medium">{step.title}</span>
|
|
262
|
+
{step.description && (
|
|
263
|
+
<span
|
|
264
|
+
className="text-xs text-muted-foreground">{step.description}</span>
|
|
265
|
+
)}
|
|
266
|
+
</div>
|
|
267
|
+
</StepperTrigger>
|
|
268
|
+
{index < steps.length - 1 && <StepperSeparator/>}
|
|
269
|
+
</StepperItem>
|
|
270
|
+
);
|
|
271
|
+
})}
|
|
272
|
+
</StepperNav>
|
|
273
|
+
</div>
|
|
274
|
+
|
|
275
|
+
<StepperPanel className="mt-8 w-full h-full overflow-y-auto p-4">
|
|
276
|
+
{steps.map((step, index) => {
|
|
277
|
+
const stepNumber = index + 1;
|
|
278
|
+
return (
|
|
279
|
+
<StepperContent key={step.id} value={stepNumber} className={""}>
|
|
280
|
+
<div className="py-4">
|
|
281
|
+
{typeof step.content === 'function'
|
|
282
|
+
? step.content({next: handleNext, prev: handlePrev, data: data, updateData})
|
|
283
|
+
: step.content}
|
|
284
|
+
</div>
|
|
285
|
+
</StepperContent>
|
|
286
|
+
);
|
|
287
|
+
})}
|
|
288
|
+
</StepperPanel>
|
|
289
|
+
</Stepper>
|
|
290
|
+
</div>
|
|
291
|
+
|
|
292
|
+
<div className=" flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end">
|
|
293
|
+
{isHiddenAction('cancel') && (
|
|
294
|
+
<Button variant="outline" onClick={handleCancel}>
|
|
295
|
+
{actions?.cancel?.label || 'Quitter'}
|
|
296
|
+
</Button>
|
|
297
|
+
)}
|
|
298
|
+
<div className="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
|
|
299
|
+
{isHiddenAction('previous') && (!isLocked && activeStep > 1 && (
|
|
300
|
+
<Button variant="outline" onClick={handlePrev}>
|
|
301
|
+
Précédent
|
|
302
|
+
</Button>
|
|
303
|
+
))}
|
|
304
|
+
{isHiddenAction('previous') && (
|
|
305
|
+
<Button onClick={handleNext}>
|
|
306
|
+
{activeStep === steps.length ? 'Terminer' : 'Suivant'}
|
|
307
|
+
</Button>
|
|
308
|
+
)}
|
|
309
|
+
</div>
|
|
310
|
+
</div>
|
|
311
|
+
|
|
312
|
+
<UploadProgressDialog
|
|
313
|
+
open={showUploadDialog}
|
|
314
|
+
onOpenChange={setShowUploadDialog}
|
|
315
|
+
onAllComplete={handleFinishAfterUploads}
|
|
316
|
+
/>
|
|
317
|
+
</div>
|
|
318
|
+
);
|
|
319
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { DismissableLayer } from 'radix-ui/internal';
|
|
6
|
+
import { useModalStore } from '../stores/useModalStore';
|
|
7
|
+
import { ModalInstance } from '../types/modal.type';
|
|
8
|
+
import ModalBox from './ModalBox';
|
|
9
|
+
import { cn } from "../../../infrastructure/utilities/utils";
|
|
10
|
+
|
|
11
|
+
interface ModalWrapperProps {
|
|
12
|
+
modal: ModalInstance;
|
|
13
|
+
index: number;
|
|
14
|
+
isLast: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ModalWrapper = ({ modal, isLast }: ModalWrapperProps) => {
|
|
18
|
+
const closeModal = useModalStore((state) => state.closeModal);
|
|
19
|
+
|
|
20
|
+
const handleOverlayClick = (e: React.MouseEvent) => {
|
|
21
|
+
const isLocked = modal.options?.locked === true;
|
|
22
|
+
if (e.target === e.currentTarget && !isLocked) closeModal(modal.id);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const stackStyle = useMemo(() => {
|
|
26
|
+
return {
|
|
27
|
+
backgroundColor: modal.options?.backColor,
|
|
28
|
+
};
|
|
29
|
+
}, [modal.options?.backColor]);
|
|
30
|
+
|
|
31
|
+
const isClosing = modal.options?.isClosing;
|
|
32
|
+
const isLocked = modal.options?.locked === true;
|
|
33
|
+
|
|
34
|
+
// Each modal is portaled directly into `document.body` at open time (like any
|
|
35
|
+
// Radix overlay) and lives in the shared Radix dismissable-layer stack. This
|
|
36
|
+
// lets components opened afterwards (Sheet, Popover, Select, AlertDialog, ...)
|
|
37
|
+
// stack above the modal, and ensures Escape / outside interactions only dismiss
|
|
38
|
+
// the topmost layer instead of closing the modal unintentionally.
|
|
39
|
+
return createPortal(
|
|
40
|
+
<DismissableLayer.Root
|
|
41
|
+
className={cn(
|
|
42
|
+
"fixed inset-0 z-50 flex items-center justify-center p-4 transition-all duration-300 pointer-events-auto",
|
|
43
|
+
isLast ? (modal.options?.blurred !== false ? "bg-background/50 backdrop-blur-xl" : "bg-background/80") : "bg-transparent",
|
|
44
|
+
isClosing && "opacity-0"
|
|
45
|
+
)}
|
|
46
|
+
style={stackStyle}
|
|
47
|
+
onClick={handleOverlayClick}
|
|
48
|
+
onEscapeKeyDown={() => {
|
|
49
|
+
if (!isLocked) closeModal(modal.id);
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<div
|
|
53
|
+
className={cn(
|
|
54
|
+
"w-full flex justify-center transition-all duration-300 ease-out",
|
|
55
|
+
isClosing ? "animate-zoom-out" : "animate-in fade-in zoom-in-95"
|
|
56
|
+
)}
|
|
57
|
+
>
|
|
58
|
+
<ModalBox modal={modal} />
|
|
59
|
+
</div>
|
|
60
|
+
</DismissableLayer.Root>,
|
|
61
|
+
document.body
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default ModalWrapper;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ReactNode, useCallback } from 'react';
|
|
2
|
+
import { useModalStore } from '../stores/useModalStore';
|
|
3
|
+
import { ModalOptions } from '../types/modal.type';
|
|
4
|
+
|
|
5
|
+
export const useModal = () => {
|
|
6
|
+
const openModal = useModalStore((state) => state.openModal);
|
|
7
|
+
const closeModal = useModalStore((state) => state.closeModal);
|
|
8
|
+
const closeAllModals = useModalStore((state) => state.closeAllModals);
|
|
9
|
+
const updateModalOptions = useModalStore((state) => state.updateModalOptions);
|
|
10
|
+
|
|
11
|
+
const open = useCallback(
|
|
12
|
+
(component: ReactNode | ((props: any) => ReactNode), props?: any, options?: ModalOptions) => {
|
|
13
|
+
return openModal(component, props, options);
|
|
14
|
+
},
|
|
15
|
+
[openModal]
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const close = useCallback(
|
|
19
|
+
(id: string) => {
|
|
20
|
+
closeModal(id);
|
|
21
|
+
},
|
|
22
|
+
[closeModal]
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const update = useCallback(
|
|
26
|
+
(id: string, options: Partial<ModalOptions>) => {
|
|
27
|
+
updateModalOptions(id, options);
|
|
28
|
+
},
|
|
29
|
+
[updateModalOptions]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
open,
|
|
34
|
+
close,
|
|
35
|
+
closeAll: closeAllModals,
|
|
36
|
+
update,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { ModalInstance, ModalOptions, ModalStore } from '../types/modal.type';
|
|
3
|
+
import {SizeEnum} from "../../size.enum";
|
|
4
|
+
|
|
5
|
+
export const useModalStore = create<ModalStore>((set) => ({
|
|
6
|
+
modals: [],
|
|
7
|
+
|
|
8
|
+
openModal: (component, props = {}, options = {}) => {
|
|
9
|
+
const id = Math.random().toString(36).substring(2, 9);
|
|
10
|
+
const newModal: ModalInstance = {
|
|
11
|
+
id,
|
|
12
|
+
component,
|
|
13
|
+
props,
|
|
14
|
+
options: {
|
|
15
|
+
closable: true,
|
|
16
|
+
size: 'MD',
|
|
17
|
+
...options,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
set((state) => ({
|
|
22
|
+
modals: [...state.modals, newModal],
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
return id;
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
closeModal: (id) => {
|
|
29
|
+
set((state) => {
|
|
30
|
+
const modalToClose = state.modals.find((m) => m.id === id);
|
|
31
|
+
if (!modalToClose) return state;
|
|
32
|
+
|
|
33
|
+
if (modalToClose.options?.isClosing) return state;
|
|
34
|
+
|
|
35
|
+
// Start closing animation
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
set((state) => {
|
|
38
|
+
const modalStillExists = state.modals.find((m) => m.id === id);
|
|
39
|
+
if (modalStillExists?.options?.onClose) {
|
|
40
|
+
modalStillExists.options.onClose();
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
modals: state.modals.filter((m) => m.id !== id),
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}, 300); // match duration-300
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
modals: state.modals.map((m) =>
|
|
50
|
+
m.id === id ? { ...m, options: { ...m.options, isClosing: true } } : m
|
|
51
|
+
),
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
closeAllModals: () => {
|
|
57
|
+
set((state) => {
|
|
58
|
+
state.modals.forEach((m) => {
|
|
59
|
+
if (!m.options?.isClosing) {
|
|
60
|
+
// On peut soit déclencher l'animation pour tous, soit tout fermer d'un coup.
|
|
61
|
+
// Pour respecter la demande d'animation, on devrait aussi le faire ici.
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
set((state) => {
|
|
64
|
+
const modalStillExists = state.modals.find((mod) => mod.id === m.id);
|
|
65
|
+
if (modalStillExists?.options?.onClose) modalStillExists.options.onClose();
|
|
66
|
+
return {
|
|
67
|
+
modals: state.modals.filter((mod) => mod.id !== m.id),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}, 300);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
modals: state.modals.map((m) => ({
|
|
76
|
+
...m,
|
|
77
|
+
options: { ...m.options, isClosing: true },
|
|
78
|
+
})),
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
updateModalOptions: (id, options) => {
|
|
84
|
+
set((state) => ({
|
|
85
|
+
modals: state.modals.map((m) =>
|
|
86
|
+
m.id === id ? { ...m, options: { ...m.options, ...options } } : m
|
|
87
|
+
),
|
|
88
|
+
}));
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import {SizeEnum} from "../../size.enum";
|
|
3
|
+
|
|
4
|
+
export interface ModalOptions {
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
size?: keyof typeof SizeEnum;
|
|
8
|
+
useHeight?: boolean;
|
|
9
|
+
locked?: boolean;
|
|
10
|
+
backColor?: string;
|
|
11
|
+
blurred?: boolean;
|
|
12
|
+
closable?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
isClosing?: boolean;
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
scrollable?: boolean;
|
|
17
|
+
[key: string]: any; // Pour la personnalisation étendue
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ModalInstance {
|
|
21
|
+
id: string;
|
|
22
|
+
component: ReactNode | ((props: any) => ReactNode);
|
|
23
|
+
props?: any;
|
|
24
|
+
options?: ModalOptions;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ModalStore {
|
|
28
|
+
modals: ModalInstance[];
|
|
29
|
+
openModal: (component: ReactNode | ((props: any) => ReactNode), props?: any, options?: ModalOptions) => string;
|
|
30
|
+
closeModal: (id: string) => void;
|
|
31
|
+
closeAllModals: () => void;
|
|
32
|
+
updateModalOptions: (id: string, options: Partial<ModalOptions>) => void;
|
|
33
|
+
}
|