@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,203 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Slot } from "radix-ui"
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../infrastructure/utilities/utils"
|
|
5
|
+
|
|
6
|
+
export type KpiCardVariant =
|
|
7
|
+
| "default"
|
|
8
|
+
| "primary"
|
|
9
|
+
| "secondary"
|
|
10
|
+
| "outline"
|
|
11
|
+
| "error"
|
|
12
|
+
| "warning"
|
|
13
|
+
| "success"
|
|
14
|
+
| "info";
|
|
15
|
+
|
|
16
|
+
interface KpiVariantToken {
|
|
17
|
+
color: string
|
|
18
|
+
bg: string
|
|
19
|
+
fg: string
|
|
20
|
+
chip: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const variantTokens: Record<KpiCardVariant, KpiVariantToken> = {
|
|
24
|
+
default: {color: "var(--muted-foreground)", bg: "var(--card)", fg: "var(--foreground)", chip: "text-muted-foreground bg-muted"},
|
|
25
|
+
primary: {color: "var(--primary)", bg: "var(--primary)", fg: "var(--primary-foreground)", chip: "text-primary bg-primary/10"},
|
|
26
|
+
secondary: {color: "var(--secondary)", bg: "var(--secondary)", fg: "var(--secondary-foreground)", chip: "text-secondary-foreground bg-secondary/20"},
|
|
27
|
+
outline: {color: "var(--border)", bg: "var(--card)", fg: "var(--foreground)", chip: "text-muted-foreground bg-muted"},
|
|
28
|
+
error: {color: "var(--destructive)", bg: "var(--destructive)", fg: "var(--destructive-foreground)", chip: "text-destructive bg-destructive/10"},
|
|
29
|
+
warning: {color: "var(--warning)", bg: "var(--warning)", fg: "var(--warning-foreground)", chip: "text-warning bg-warning/10"},
|
|
30
|
+
success: {color: "var(--success)", bg: "var(--success)", fg: "var(--success-foreground)", chip: "text-success bg-success/10"},
|
|
31
|
+
info: {color: "var(--info)", bg: "var(--info)", fg: "var(--info-foreground)", chip: "text-info bg-info/10"},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface KpiCardContextValue {
|
|
35
|
+
variant: KpiCardVariant
|
|
36
|
+
prominent: boolean
|
|
37
|
+
token: KpiVariantToken
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const KpiCardContext = React.createContext<KpiCardContextValue | null>(null)
|
|
41
|
+
|
|
42
|
+
function useKpiCard(): KpiCardContextValue {
|
|
43
|
+
const ctx = React.useContext(KpiCardContext)
|
|
44
|
+
if (!ctx) throw new Error("KpiCard.* components must be used within <KpiCard>.")
|
|
45
|
+
return ctx
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* -------------------------------------------------------------------------- */
|
|
49
|
+
/* KpiCard */
|
|
50
|
+
/* -------------------------------------------------------------------------- */
|
|
51
|
+
|
|
52
|
+
interface KpiCardProps extends React.ComponentProps<"div"> {
|
|
53
|
+
variant?: KpiCardVariant
|
|
54
|
+
prominent?: boolean
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function KpiCardComponent({variant = "default", prominent = false, className, ...props}: KpiCardProps) {
|
|
58
|
+
const token = variantTokens[variant]
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<KpiCardContext.Provider value={{variant, prominent, token}}>
|
|
62
|
+
<div
|
|
63
|
+
data-slot="kpi-card"
|
|
64
|
+
data-variant={variant}
|
|
65
|
+
data-prominent={prominent || undefined}
|
|
66
|
+
className={cn(
|
|
67
|
+
"relative flex flex-col gap-2.5 overflow-hidden rounded-2xl border border-border bg-card p-4 pl-5 transition-colors",
|
|
68
|
+
prominent && "border-transparent shadow-md",
|
|
69
|
+
className
|
|
70
|
+
)}
|
|
71
|
+
style={prominent ? {background: token.bg, color: token.fg} : undefined}
|
|
72
|
+
{...props}
|
|
73
|
+
>
|
|
74
|
+
{/*<span*/}
|
|
75
|
+
{/* aria-hidden*/}
|
|
76
|
+
{/* className="absolute inset-y-0 left-0 w-1"*/}
|
|
77
|
+
{/* style={{background: prominent ? `color-mix(in oklab, ${token.fg} 30%, transparent)` : token.color}}*/}
|
|
78
|
+
{/*/>*/}
|
|
79
|
+
{props.children}
|
|
80
|
+
</div>
|
|
81
|
+
</KpiCardContext.Provider>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* -------------------------------------------------------------------------- */
|
|
86
|
+
/* KpiCard.Header */
|
|
87
|
+
/* -------------------------------------------------------------------------- */
|
|
88
|
+
|
|
89
|
+
function KpiCardHeader({className, ...props}: React.ComponentProps<"div">) {
|
|
90
|
+
const {prominent} = useKpiCard()
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
data-slot="kpi-card-header"
|
|
95
|
+
className={cn("flex items-center gap-2", !prominent && "text-muted-foreground", className)}
|
|
96
|
+
{...props}
|
|
97
|
+
/>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* -------------------------------------------------------------------------- */
|
|
102
|
+
/* KpiCard.Icon */
|
|
103
|
+
/* -------------------------------------------------------------------------- */
|
|
104
|
+
|
|
105
|
+
function KpiCardIcon({asChild = false, className, ...props}: React.ComponentProps<"span"> & {asChild?: boolean}) {
|
|
106
|
+
const {prominent, token} = useKpiCard()
|
|
107
|
+
const Comp = asChild ? Slot.Root : "span"
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<Comp
|
|
111
|
+
data-slot="kpi-card-icon"
|
|
112
|
+
className={cn(
|
|
113
|
+
"flex size-7 shrink-0 items-center justify-center rounded-lg",
|
|
114
|
+
!prominent && token.chip,
|
|
115
|
+
className
|
|
116
|
+
)}
|
|
117
|
+
style={prominent ? {background: `color-mix(in oklab, ${token.fg} 20%, transparent)`, color: token.fg} : undefined}
|
|
118
|
+
{...props}
|
|
119
|
+
/>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* -------------------------------------------------------------------------- */
|
|
124
|
+
/* KpiCard.Title */
|
|
125
|
+
/* -------------------------------------------------------------------------- */
|
|
126
|
+
|
|
127
|
+
function KpiCardTitle({className, ...props}: React.ComponentProps<"span">) {
|
|
128
|
+
return (
|
|
129
|
+
<span
|
|
130
|
+
data-slot="kpi-card-title"
|
|
131
|
+
className={cn("min-w-0 flex-1 truncate text-sm font-medium", className)}
|
|
132
|
+
{...props}
|
|
133
|
+
/>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* -------------------------------------------------------------------------- */
|
|
138
|
+
/* KpiCard.Value */
|
|
139
|
+
/* -------------------------------------------------------------------------- */
|
|
140
|
+
|
|
141
|
+
function KpiCardValue({className, ...props}: React.ComponentProps<"div">) {
|
|
142
|
+
return (
|
|
143
|
+
<div
|
|
144
|
+
data-slot="kpi-card-value"
|
|
145
|
+
className={cn("text-3xl font-bold leading-tight tabular-nums", className)}
|
|
146
|
+
{...props}
|
|
147
|
+
/>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* -------------------------------------------------------------------------- */
|
|
152
|
+
/* KpiCard.Badge */
|
|
153
|
+
/* -------------------------------------------------------------------------- */
|
|
154
|
+
|
|
155
|
+
function KpiCardBadge({className, ...props}: React.ComponentProps<"span">) {
|
|
156
|
+
const {prominent, token} = useKpiCard()
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<span
|
|
160
|
+
data-slot="kpi-card-badge"
|
|
161
|
+
className={cn("inline-flex w-fit items-center gap-1 rounded-md px-1.5 py-0.5 text-xs font-medium", className)}
|
|
162
|
+
style={prominent
|
|
163
|
+
? {background: `color-mix(in oklab, ${token.fg} 15%, transparent)`}
|
|
164
|
+
: {background: `color-mix(in oklab, ${token.color} 10%, transparent)`, color: token.color}}
|
|
165
|
+
{...props}
|
|
166
|
+
/>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* -------------------------------------------------------------------------- */
|
|
171
|
+
/* KpiCard.Content */
|
|
172
|
+
/* -------------------------------------------------------------------------- */
|
|
173
|
+
|
|
174
|
+
function KpiCardContent({className, ...props}: React.ComponentProps<"div">) {
|
|
175
|
+
return (
|
|
176
|
+
<div
|
|
177
|
+
data-slot="kpi-card-content"
|
|
178
|
+
className={cn("flex flex-col gap-1.5", className)}
|
|
179
|
+
{...props}
|
|
180
|
+
/>
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const KpiCard = Object.assign(KpiCardComponent, {
|
|
185
|
+
Header: KpiCardHeader,
|
|
186
|
+
Icon: KpiCardIcon,
|
|
187
|
+
Title: KpiCardTitle,
|
|
188
|
+
Value: KpiCardValue,
|
|
189
|
+
Badge: KpiCardBadge,
|
|
190
|
+
Content: KpiCardContent,
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
export {
|
|
194
|
+
KpiCard,
|
|
195
|
+
KpiCardHeader,
|
|
196
|
+
KpiCardIcon,
|
|
197
|
+
KpiCardTitle,
|
|
198
|
+
KpiCardValue,
|
|
199
|
+
KpiCardBadge,
|
|
200
|
+
KpiCardContent,
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export type {KpiCardProps}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
|
|
5
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../infrastructure/utilities/utils"
|
|
8
|
+
|
|
9
|
+
function LabelSelectorRoot({ className, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
|
|
10
|
+
return (
|
|
11
|
+
<RadioGroupPrimitive.Root
|
|
12
|
+
data-slot="label-selector-root"
|
|
13
|
+
className={cn(
|
|
14
|
+
"flex items-center justify-between gap-4 py-3 bg-muted dark:bg-muted/60 p-3 pl-5 rounded-full",
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface LabelSelectorLabelProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
23
|
+
value: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function LabelSelectorLabel({ className, value, ...props }: LabelSelectorLabelProps) {
|
|
27
|
+
return (
|
|
28
|
+
<div data-slot="label-selector-label" className={cn("text-base font-normal leading-none", className)} {...props}>
|
|
29
|
+
{value}
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function LabelSelectorContent({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
|
35
|
+
return <div data-slot="label-selector-content" className={cn("flex items-center gap-2", className)} {...props} />
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const labelSelectorItemVariants = cva(
|
|
39
|
+
"group relative shrink-0 cursor-pointer outline-none transition-all flex items-center justify-center disabled:cursor-not-allowed disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
40
|
+
{
|
|
41
|
+
variants: {
|
|
42
|
+
variant: {
|
|
43
|
+
default:
|
|
44
|
+
"border-2 border-muted-foreground/20 bg-background hover:border-muted-foreground/40 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
45
|
+
outline:
|
|
46
|
+
"border-2 border-input bg-background hover:bg-accent hover:text-accent-foreground data-[state=checked]:border-primary data-[state=checked]:bg-accent data-[state=checked]:text-foreground",
|
|
47
|
+
ghost:
|
|
48
|
+
"hover:bg-accent hover:text-accent-foreground data-[state=checked]:bg-accent data-[state=checked]:text-foreground",
|
|
49
|
+
solid:
|
|
50
|
+
"bg-muted text-muted-foreground hover:bg-muted/80 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
51
|
+
},
|
|
52
|
+
size: {
|
|
53
|
+
sm: "min-w-[2rem] h-8 px-3 text-xs",
|
|
54
|
+
default: "min-w-[2.5rem] h-10 px-4 text-sm",
|
|
55
|
+
lg: "min-w-[3rem] h-12 px-5 text-base",
|
|
56
|
+
},
|
|
57
|
+
rounded: {
|
|
58
|
+
none: "rounded-none",
|
|
59
|
+
sm: "rounded-sm",
|
|
60
|
+
md: "rounded-md",
|
|
61
|
+
lg: "rounded-lg",
|
|
62
|
+
full: "rounded-full",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
defaultVariants: {
|
|
66
|
+
variant: "default",
|
|
67
|
+
size: "default",
|
|
68
|
+
rounded: "lg",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
interface LabelSelectorItemProps
|
|
74
|
+
extends React.ComponentProps<typeof RadioGroupPrimitive.Item>,
|
|
75
|
+
VariantProps<typeof labelSelectorItemVariants> {
|
|
76
|
+
value: string
|
|
77
|
+
label?: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function LabelSelectorItem({ className, value, label, variant, size, rounded, ...props }: LabelSelectorItemProps) {
|
|
81
|
+
return (
|
|
82
|
+
<RadioGroupPrimitive.Item
|
|
83
|
+
data-slot="label-selector-item"
|
|
84
|
+
value={value}
|
|
85
|
+
className={cn(labelSelectorItemVariants({ variant, size, rounded, className }))}
|
|
86
|
+
{...props}
|
|
87
|
+
>
|
|
88
|
+
<span className="font-medium">{label || value}</span>
|
|
89
|
+
</RadioGroupPrimitive.Item>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const LabelSelector = {
|
|
94
|
+
Root: LabelSelectorRoot,
|
|
95
|
+
Label: LabelSelectorLabel,
|
|
96
|
+
Content: LabelSelectorContent,
|
|
97
|
+
Item: LabelSelectorItem,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { labelSelectorItemVariants }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Label as LabelPrimitive } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../infrastructure/utilities/utils"
|
|
7
|
+
|
|
8
|
+
function Label({
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
|
12
|
+
return (
|
|
13
|
+
<LabelPrimitive.Root
|
|
14
|
+
data-slot="label"
|
|
15
|
+
className={cn(
|
|
16
|
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { Label }
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import {useMemo} from "react";
|
|
5
|
+
import {LegacyInput, type LegacyInputProps} from "./legacy-input";
|
|
6
|
+
import {CalendarIcon} from "lucide-react";
|
|
7
|
+
|
|
8
|
+
export interface LegacyBirthDateInputProps extends Omit<LegacyInputProps, 'input'> {
|
|
9
|
+
minAge?: number;
|
|
10
|
+
input?: Omit<React.ComponentProps<"input">, 'type' | 'max'>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const LegacyBirthDateInput = React.forwardRef<HTMLInputElement, LegacyBirthDateInputProps>(
|
|
14
|
+
({minAge = 18, input, ...props}, ref) => {
|
|
15
|
+
const maxDate = useMemo(() => {
|
|
16
|
+
const date = new Date();
|
|
17
|
+
date.setFullYear(date.getFullYear() - minAge);
|
|
18
|
+
return date.toISOString().split('T')[0];
|
|
19
|
+
}, [minAge]);
|
|
20
|
+
|
|
21
|
+
props = props || {};
|
|
22
|
+
props.id = props.id || 'birthDate';
|
|
23
|
+
props.label = props.label || 'Date de naissance';
|
|
24
|
+
props.description = props.description || `Utilisée pour vérifier l'éligibilité et la sécurité du compte. L'âge minimum requit de ${minAge} an${minAge > 1 ? 's' : ''}`;
|
|
25
|
+
props.icon = props.icon || (<CalendarIcon className="size-4 text-muted-foreground/60"/>);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<LegacyInput
|
|
29
|
+
ref={ref}
|
|
30
|
+
input={{
|
|
31
|
+
...input,
|
|
32
|
+
type: "date",
|
|
33
|
+
max: maxDate,
|
|
34
|
+
}}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
LegacyBirthDateInput.displayName = "LegacyBirthDateInput";
|
|
42
|
+
|
|
43
|
+
export {LegacyBirthDateInput};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export {
|
|
2
|
+
LegacyColorPicker,
|
|
3
|
+
type LegacyColorPickerProps,
|
|
4
|
+
} from "./legacy-color-picker"
|
|
5
|
+
export {
|
|
6
|
+
colorPickerTriggerVariants,
|
|
7
|
+
LegacyColorPickerTrigger,
|
|
8
|
+
LegacyColorPickerOpenButton,
|
|
9
|
+
type LegacyColorPickerTriggerProps,
|
|
10
|
+
type LegacyColorPickerOpenButtonProps,
|
|
11
|
+
} from "./legacy-color-picker.trigger"
|
|
12
|
+
export { LegacyColorPickerContent } from "./legacy-color-picker.content"
|
|
13
|
+
export {
|
|
14
|
+
LegacyColorPickerSwatch,
|
|
15
|
+
LegacyColorPickerSwatchGroup,
|
|
16
|
+
type LegacyColorPickerSwatchProps,
|
|
17
|
+
} from "./legacy-color-picker.swatches"
|
|
18
|
+
export {
|
|
19
|
+
LegacyColorPickerHexInput,
|
|
20
|
+
type LegacyColorPickerHexInputProps,
|
|
21
|
+
} from "./legacy-color-picker.hex-input"
|
|
22
|
+
export {
|
|
23
|
+
LegacyColorPickerProvider,
|
|
24
|
+
useLegacyColorPickerContext,
|
|
25
|
+
type LegacyColorPickerContextValue,
|
|
26
|
+
} from "./legacy-color-picker.context"
|
|
27
|
+
export { LegacyColorPickerPicker } from "./legacy-color-picker.picker"
|
|
28
|
+
export { LegacyColorPickerRecent } from "./legacy-color-picker.recent"
|
|
29
|
+
export { LegacyColorPickerQuickList } from "./legacy-color-picker.quick-list"
|
|
30
|
+
export { DEFAULT_COLOR_PICKER_PRESETS } from "./legacy-color-picker.presets"
|
|
31
|
+
export {
|
|
32
|
+
DEFAULT_COLOR,
|
|
33
|
+
normalizeHex,
|
|
34
|
+
hexToRgba,
|
|
35
|
+
rgbaToHex,
|
|
36
|
+
rgbaToCss,
|
|
37
|
+
rgbToHsv,
|
|
38
|
+
hsvToRgb,
|
|
39
|
+
type RgbaColor,
|
|
40
|
+
type HsvColor,
|
|
41
|
+
} from "./legacy-color-picker.utils"
|
|
42
|
+
export type { LegacyColorPickerSize } from "./legacy-color-picker.types"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../../infrastructure/utilities/utils"
|
|
6
|
+
import { PopoverContent } from "../popover"
|
|
7
|
+
import { LegacyColorPickerHexInput } from "./legacy-color-picker.hex-input"
|
|
8
|
+
import { LegacyColorPickerPicker } from "./legacy-color-picker.picker"
|
|
9
|
+
import { LegacyColorPickerRecent } from "./legacy-color-picker.recent"
|
|
10
|
+
import { LegacyColorPickerSwatchGroup } from "./legacy-color-picker.swatches"
|
|
11
|
+
|
|
12
|
+
export function LegacyColorPickerContent({
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
...props
|
|
16
|
+
}: React.ComponentProps<typeof PopoverContent>) {
|
|
17
|
+
return (
|
|
18
|
+
<PopoverContent
|
|
19
|
+
data-slot="color-picker-content"
|
|
20
|
+
align="center"
|
|
21
|
+
sideOffset={6}
|
|
22
|
+
className={cn("w-fit min-w-56 gap-3 p-3", className)}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
{children ?? (
|
|
26
|
+
<>
|
|
27
|
+
<LegacyColorPickerPicker />
|
|
28
|
+
<div className="h-px bg-border" />
|
|
29
|
+
<LegacyColorPickerSwatchGroup />
|
|
30
|
+
<LegacyColorPickerRecent />
|
|
31
|
+
<div className="h-px bg-border" />
|
|
32
|
+
<LegacyColorPickerHexInput />
|
|
33
|
+
</>
|
|
34
|
+
)}
|
|
35
|
+
</PopoverContent>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
|
|
5
|
+
import type { LegacyColorPickerSize } from "./legacy-color-picker.types"
|
|
6
|
+
|
|
7
|
+
export interface LegacyColorPickerContextValue {
|
|
8
|
+
value: string
|
|
9
|
+
onValueChange: (value: string) => void
|
|
10
|
+
onCommit: (value: string) => void
|
|
11
|
+
size: LegacyColorPickerSize
|
|
12
|
+
disabled: boolean
|
|
13
|
+
presets: string[]
|
|
14
|
+
recentColors: string[]
|
|
15
|
+
quickListCount: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const LegacyColorPickerContext = React.createContext<LegacyColorPickerContextValue | null>(null)
|
|
19
|
+
|
|
20
|
+
export function useLegacyColorPickerContext(): LegacyColorPickerContextValue {
|
|
21
|
+
const context = React.useContext(LegacyColorPickerContext)
|
|
22
|
+
if (!context) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
"Les composants LegacyColorPicker doivent être utilisés dans un <LegacyColorPicker>."
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
return context
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function LegacyColorPickerProvider({
|
|
31
|
+
value,
|
|
32
|
+
children,
|
|
33
|
+
}: {
|
|
34
|
+
value: LegacyColorPickerContextValue
|
|
35
|
+
children: React.ReactNode
|
|
36
|
+
}) {
|
|
37
|
+
return (
|
|
38
|
+
<LegacyColorPickerContext.Provider value={value}>
|
|
39
|
+
{children}
|
|
40
|
+
</LegacyColorPickerContext.Provider>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../../infrastructure/utilities/utils"
|
|
6
|
+
import { InputGroup, InputGroupAddon, InputGroupInput } from "../input-group"
|
|
7
|
+
import { useLegacyColorPickerContext } from "./legacy-color-picker.context"
|
|
8
|
+
import { normalizeHex } from "./legacy-color-picker.utils"
|
|
9
|
+
|
|
10
|
+
export interface LegacyColorPickerHexInputProps extends React.ComponentProps<"div"> {
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
showPreview?: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function LegacyColorPickerHexInput({
|
|
16
|
+
className,
|
|
17
|
+
disabled = false,
|
|
18
|
+
showPreview = true,
|
|
19
|
+
...props
|
|
20
|
+
}: LegacyColorPickerHexInputProps) {
|
|
21
|
+
const { value, onValueChange, onCommit, disabled: contextDisabled } = useLegacyColorPickerContext()
|
|
22
|
+
const currentHex = value.replace(/^#/, "")
|
|
23
|
+
const [raw, setRaw] = React.useState(currentHex)
|
|
24
|
+
const [focused, setFocused] = React.useState(false)
|
|
25
|
+
const resolvedDisabled = disabled || contextDisabled
|
|
26
|
+
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
if (!focused) {
|
|
29
|
+
setRaw(value.replace(/^#/, ""))
|
|
30
|
+
}
|
|
31
|
+
}, [value, focused])
|
|
32
|
+
|
|
33
|
+
const normalized = normalizeHex(raw)
|
|
34
|
+
const previewColor = normalized ?? value
|
|
35
|
+
const isInvalid = raw.trim().length > 0 && normalized === null
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
data-slot="color-picker-hex-input"
|
|
40
|
+
className={cn("flex items-center gap-2.5", className)}
|
|
41
|
+
{...props}
|
|
42
|
+
>
|
|
43
|
+
<InputGroup className="flex-1">
|
|
44
|
+
<InputGroupAddon align="inline-start">#</InputGroupAddon>
|
|
45
|
+
<InputGroupInput
|
|
46
|
+
data-slot="color-picker-hex-input-field"
|
|
47
|
+
value={raw}
|
|
48
|
+
onChange={(event) => {
|
|
49
|
+
const next = event.target.value.toUpperCase().replace(/[^0-9A-Fa-f]/g, "").slice(0, 8)
|
|
50
|
+
setRaw(next)
|
|
51
|
+
const normalizedNext = normalizeHex(next)
|
|
52
|
+
if (normalizedNext) {
|
|
53
|
+
onValueChange(normalizedNext)
|
|
54
|
+
}
|
|
55
|
+
}}
|
|
56
|
+
onFocus={(event) => {
|
|
57
|
+
setFocused(true)
|
|
58
|
+
event.currentTarget.select()
|
|
59
|
+
}}
|
|
60
|
+
onBlur={() => {
|
|
61
|
+
setFocused(false)
|
|
62
|
+
const normalized = normalizeHex(raw)
|
|
63
|
+
if (normalized) {
|
|
64
|
+
onCommit(normalized)
|
|
65
|
+
} else {
|
|
66
|
+
setRaw(value.replace(/^#/, ""))
|
|
67
|
+
}
|
|
68
|
+
}}
|
|
69
|
+
onKeyDown={(event) => {
|
|
70
|
+
if (event.key === "Enter") {
|
|
71
|
+
event.currentTarget.blur()
|
|
72
|
+
}
|
|
73
|
+
}}
|
|
74
|
+
placeholder="RRGGBBAA"
|
|
75
|
+
maxLength={8}
|
|
76
|
+
spellCheck={false}
|
|
77
|
+
autoCapitalize="characters"
|
|
78
|
+
aria-label="Code hexadécimal de la couleur"
|
|
79
|
+
aria-invalid={isInvalid || undefined}
|
|
80
|
+
disabled={resolvedDisabled}
|
|
81
|
+
className="font-mono text-sm tracking-wide"
|
|
82
|
+
/>
|
|
83
|
+
</InputGroup>
|
|
84
|
+
{showPreview && (
|
|
85
|
+
<span
|
|
86
|
+
data-slot="color-picker-hex-input-preview"
|
|
87
|
+
aria-hidden
|
|
88
|
+
className={cn(
|
|
89
|
+
"size-6 shrink-0 rounded-md ring-1 ring-inset ring-foreground/10 transition-opacity",
|
|
90
|
+
isInvalid && "opacity-40"
|
|
91
|
+
)}
|
|
92
|
+
style={{ backgroundColor: previewColor }}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
</div>
|
|
96
|
+
)
|
|
97
|
+
}
|