@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,266 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../../infrastructure/utilities/utils"
|
|
6
|
+
import { useLegacyColorPickerContext } from "./legacy-color-picker.context"
|
|
7
|
+
import {
|
|
8
|
+
hexToRgba,
|
|
9
|
+
hsvToRgb,
|
|
10
|
+
rgbToHsv,
|
|
11
|
+
rgbaToCss,
|
|
12
|
+
rgbaToHex,
|
|
13
|
+
type HsvColor,
|
|
14
|
+
type RgbaColor,
|
|
15
|
+
} from "./legacy-color-picker.utils"
|
|
16
|
+
|
|
17
|
+
function clamp01(value: number): number {
|
|
18
|
+
return Math.min(1, Math.max(0, value))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getRelativePosition(event: React.PointerEvent<HTMLElement>): { x: number; y: number } {
|
|
22
|
+
const rect = event.currentTarget.getBoundingClientRect()
|
|
23
|
+
return {
|
|
24
|
+
x: clamp01((event.clientX - rect.left) / rect.width),
|
|
25
|
+
y: clamp01((event.clientY - rect.top) / rect.height),
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function useDragState() {
|
|
30
|
+
const dragging = React.useRef(false)
|
|
31
|
+
|
|
32
|
+
const onPointerDown = React.useCallback((event: React.PointerEvent<HTMLElement>) => {
|
|
33
|
+
if (event.button !== 0 && event.pointerType === "mouse") return
|
|
34
|
+
dragging.current = true
|
|
35
|
+
event.currentTarget.setPointerCapture?.(event.pointerId)
|
|
36
|
+
}, [])
|
|
37
|
+
|
|
38
|
+
const onPointerUp = React.useCallback((event: React.PointerEvent<HTMLElement>) => {
|
|
39
|
+
dragging.current = false
|
|
40
|
+
try {
|
|
41
|
+
event.currentTarget.releasePointerCapture?.(event.pointerId)
|
|
42
|
+
} catch {
|
|
43
|
+
// Capture déjà libérée
|
|
44
|
+
}
|
|
45
|
+
}, [])
|
|
46
|
+
|
|
47
|
+
return { dragging, onPointerDown, onPointerUp }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface ColorRangeInputProps {
|
|
51
|
+
value: number
|
|
52
|
+
gradient: React.CSSProperties["backgroundImage"]
|
|
53
|
+
label: string
|
|
54
|
+
valueText?: string
|
|
55
|
+
disabled?: boolean
|
|
56
|
+
onChange: (value: number) => void
|
|
57
|
+
onCommit?: (value: number) => void
|
|
58
|
+
className?: string
|
|
59
|
+
style?: React.CSSProperties
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function ColorRangeInput({
|
|
63
|
+
value,
|
|
64
|
+
gradient,
|
|
65
|
+
label,
|
|
66
|
+
valueText,
|
|
67
|
+
disabled = false,
|
|
68
|
+
onChange,
|
|
69
|
+
onCommit,
|
|
70
|
+
className,
|
|
71
|
+
style,
|
|
72
|
+
}: ColorRangeInputProps) {
|
|
73
|
+
const { dragging, onPointerDown, onPointerUp } = useDragState()
|
|
74
|
+
|
|
75
|
+
const commit = React.useCallback(() => {
|
|
76
|
+
onCommit?.(value)
|
|
77
|
+
}, [onCommit, value])
|
|
78
|
+
|
|
79
|
+
const updateFromEvent = (event: React.PointerEvent<HTMLElement>) => {
|
|
80
|
+
onChange(getRelativePosition(event).x)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {
|
|
84
|
+
const step = event.shiftKey ? 0.05 : 0.01
|
|
85
|
+
if (event.key === "ArrowRight" || event.key === "ArrowUp") {
|
|
86
|
+
event.preventDefault()
|
|
87
|
+
onChange(clamp01(value + step))
|
|
88
|
+
} else if (event.key === "ArrowLeft" || event.key === "ArrowDown") {
|
|
89
|
+
event.preventDefault()
|
|
90
|
+
onChange(clamp01(value - step))
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
role="slider"
|
|
97
|
+
aria-label={label}
|
|
98
|
+
aria-valuemin={0}
|
|
99
|
+
aria-valuemax={100}
|
|
100
|
+
aria-valuenow={Math.round(value * 100)}
|
|
101
|
+
aria-valuetext={valueText}
|
|
102
|
+
aria-disabled={disabled || undefined}
|
|
103
|
+
tabIndex={disabled ? -1 : 0}
|
|
104
|
+
data-slot="color-picker-range"
|
|
105
|
+
className={cn(
|
|
106
|
+
"relative h-4 w-full cursor-pointer rounded-full outline-none select-none touch-none",
|
|
107
|
+
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
108
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
109
|
+
className
|
|
110
|
+
)}
|
|
111
|
+
style={{ backgroundImage: gradient, ...style }}
|
|
112
|
+
onPointerDown={disabled ? undefined : onPointerDown}
|
|
113
|
+
onPointerMove={disabled ? undefined : (event) => dragging.current && updateFromEvent(event)}
|
|
114
|
+
onPointerUp={disabled ? undefined : (event) => {
|
|
115
|
+
onPointerUp(event)
|
|
116
|
+
commit()
|
|
117
|
+
}}
|
|
118
|
+
onPointerCancel={disabled ? undefined : onPointerUp}
|
|
119
|
+
onBlur={disabled || !onCommit ? undefined : commit}
|
|
120
|
+
onKeyDown={disabled ? undefined : handleKeyDown}
|
|
121
|
+
>
|
|
122
|
+
<span
|
|
123
|
+
aria-hidden
|
|
124
|
+
className="pointer-events-none absolute top-1/2 size-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-background bg-white shadow-md"
|
|
125
|
+
style={{ left: `${clamp01(value) * 100}%` }}
|
|
126
|
+
/>
|
|
127
|
+
</div>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface SaturationValuePickerProps {
|
|
132
|
+
hsv: HsvColor
|
|
133
|
+
disabled?: boolean
|
|
134
|
+
onChange: (saturation: number, value01: number) => void
|
|
135
|
+
onCommit?: (saturation: number, value01: number) => void
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function SaturationValuePicker({
|
|
139
|
+
hsv,
|
|
140
|
+
disabled = false,
|
|
141
|
+
onChange,
|
|
142
|
+
onCommit,
|
|
143
|
+
}: SaturationValuePickerProps) {
|
|
144
|
+
const { dragging, onPointerDown, onPointerUp } = useDragState()
|
|
145
|
+
const hueEnd = hsvToRgb(hsv.h, 1, 1)
|
|
146
|
+
|
|
147
|
+
const commit = React.useCallback(() => {
|
|
148
|
+
onCommit?.(hsv.s, hsv.v)
|
|
149
|
+
}, [onCommit, hsv.s, hsv.v])
|
|
150
|
+
|
|
151
|
+
const updateFromEvent = (event: React.PointerEvent<HTMLElement>) => {
|
|
152
|
+
const { x, y } = getRelativePosition(event)
|
|
153
|
+
onChange(x, 1 - y)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<div
|
|
158
|
+
role="slider"
|
|
159
|
+
aria-label="Teinte et saturation"
|
|
160
|
+
aria-valuetext={`Saturation ${Math.round(hsv.s * 100)} %, Luminosité ${Math.round(hsv.v * 100)} %`}
|
|
161
|
+
aria-disabled={disabled || undefined}
|
|
162
|
+
tabIndex={disabled ? -1 : 0}
|
|
163
|
+
data-slot="color-picker-saturation-value"
|
|
164
|
+
className={cn(
|
|
165
|
+
"relative aspect-[4/3] w-full cursor-crosshair rounded-lg outline-none select-none touch-none",
|
|
166
|
+
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
167
|
+
"disabled:pointer-events-none disabled:opacity-50"
|
|
168
|
+
)}
|
|
169
|
+
style={{
|
|
170
|
+
backgroundImage: `linear-gradient(to top, rgb(0, 0, 0), rgba(0, 0, 0, 0)), linear-gradient(to right, rgb(255, 255, 255), rgb(${Math.round(hueEnd.r)}, ${Math.round(hueEnd.g)}, ${Math.round(hueEnd.b)}))`,
|
|
171
|
+
}}
|
|
172
|
+
onPointerDown={disabled ? undefined : onPointerDown}
|
|
173
|
+
onPointerMove={disabled ? undefined : (event) => dragging.current && updateFromEvent(event)}
|
|
174
|
+
onPointerUp={disabled ? undefined : (event) => {
|
|
175
|
+
onPointerUp(event)
|
|
176
|
+
commit()
|
|
177
|
+
}}
|
|
178
|
+
onPointerCancel={disabled ? undefined : onPointerUp}
|
|
179
|
+
onBlur={disabled || !onCommit ? undefined : commit}
|
|
180
|
+
>
|
|
181
|
+
<span
|
|
182
|
+
aria-hidden
|
|
183
|
+
className="pointer-events-none absolute size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-background shadow-md"
|
|
184
|
+
style={{
|
|
185
|
+
left: `${hsv.s * 100}%`,
|
|
186
|
+
top: `${(1 - hsv.v) * 100}%`,
|
|
187
|
+
backgroundColor: rgbaToCss({ ...hsvToRgb(hsv.h, hsv.s, hsv.v), a: 1 }),
|
|
188
|
+
}}
|
|
189
|
+
/>
|
|
190
|
+
</div>
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function LegacyColorPickerPicker({
|
|
195
|
+
className,
|
|
196
|
+
...props
|
|
197
|
+
}: React.ComponentProps<"div">) {
|
|
198
|
+
const { value, disabled, onValueChange, onCommit } = useLegacyColorPickerContext()
|
|
199
|
+
const rgba = hexToRgba(value) ?? { r: 59, g: 130, b: 246, a: 1 }
|
|
200
|
+
const hsv = rgbToHsv(rgba.r, rgba.g, rgba.b)
|
|
201
|
+
|
|
202
|
+
const liveUpdate = React.useCallback(
|
|
203
|
+
(next: RgbaColor) => {
|
|
204
|
+
onValueChange(rgbaToHex(next))
|
|
205
|
+
},
|
|
206
|
+
[onValueChange]
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
const finalize = React.useCallback(
|
|
210
|
+
(next: RgbaColor) => {
|
|
211
|
+
onCommit(rgbaToHex(next))
|
|
212
|
+
},
|
|
213
|
+
[onCommit]
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<div
|
|
218
|
+
data-slot="color-picker-picker"
|
|
219
|
+
className={cn("flex flex-col gap-2", className)}
|
|
220
|
+
{...props}
|
|
221
|
+
>
|
|
222
|
+
<SaturationValuePicker
|
|
223
|
+
disabled={disabled}
|
|
224
|
+
hsv={hsv}
|
|
225
|
+
onChange={(s, v) => {
|
|
226
|
+
const rgb = hsvToRgb(hsv.h, s, v)
|
|
227
|
+
liveUpdate({ r: rgb.r, g: rgb.g, b: rgb.b, a: rgba.a })
|
|
228
|
+
}}
|
|
229
|
+
onCommit={(s, v) => {
|
|
230
|
+
const rgb = hsvToRgb(hsv.h, s, v)
|
|
231
|
+
finalize({ r: rgb.r, g: rgb.g, b: rgb.b, a: rgba.a })
|
|
232
|
+
}}
|
|
233
|
+
/>
|
|
234
|
+
<div className="flex items-center gap-2">
|
|
235
|
+
<div className="min-w-0 flex-1">
|
|
236
|
+
<ColorRangeInput
|
|
237
|
+
value={hsv.h / 360}
|
|
238
|
+
label="Teinte"
|
|
239
|
+
valueText={`${Math.round(hsv.h)} degrés`}
|
|
240
|
+
disabled={disabled}
|
|
241
|
+
onChange={(x) => {
|
|
242
|
+
const rgb = hsvToRgb(x * 360, hsv.s, hsv.v)
|
|
243
|
+
liveUpdate({ r: rgb.r, g: rgb.g, b: rgb.b, a: rgba.a })
|
|
244
|
+
}}
|
|
245
|
+
onCommit={(x) => {
|
|
246
|
+
const rgb = hsvToRgb(x * 360, hsv.s, hsv.v)
|
|
247
|
+
finalize({ r: rgb.r, g: rgb.g, b: rgb.b, a: rgba.a })
|
|
248
|
+
}}
|
|
249
|
+
gradient="linear-gradient(to right, hsl(0 100% 50%), hsl(60 100% 50%), hsl(120 100% 50%), hsl(180 100% 50%), hsl(240 100% 50%), hsl(300 100% 50%), hsl(360 100% 50%))"
|
|
250
|
+
/>
|
|
251
|
+
</div>
|
|
252
|
+
<div className="min-w-0 flex-1">
|
|
253
|
+
<ColorRangeInput
|
|
254
|
+
value={rgba.a}
|
|
255
|
+
label="Opacité"
|
|
256
|
+
valueText={`${Math.round(rgba.a * 100)} %`}
|
|
257
|
+
disabled={disabled}
|
|
258
|
+
onChange={(a) => liveUpdate({ ...rgba, a })}
|
|
259
|
+
onCommit={(a) => finalize({ ...rgba, a })}
|
|
260
|
+
gradient={`linear-gradient(to right, rgba(${Math.round(rgba.r)}, ${Math.round(rgba.g)}, ${Math.round(rgba.b)}, 0), rgb(${Math.round(rgba.r)}, ${Math.round(rgba.g)}, ${Math.round(rgba.b)}))`}
|
|
261
|
+
/>
|
|
262
|
+
</div>
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
)
|
|
266
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const DEFAULT_COLOR_PICKER_PRESETS = [
|
|
2
|
+
"#EF4444", // red-500
|
|
3
|
+
"#F97316", // orange-500
|
|
4
|
+
"#F59E0B", // amber-500
|
|
5
|
+
"#EAB308", // yellow-500
|
|
6
|
+
"#84CC16", // lime-500
|
|
7
|
+
"#22C55E", // green-500
|
|
8
|
+
"#10B981", // emerald-500
|
|
9
|
+
"#14B8A6", // teal-500
|
|
10
|
+
"#06B6D4", // cyan-500
|
|
11
|
+
"#0EA5E9", // sky-500
|
|
12
|
+
"#3B82F6", // blue-500
|
|
13
|
+
"#6366F1", // indigo-500
|
|
14
|
+
"#8B5CF6", // violet-500
|
|
15
|
+
"#A855F7", // purple-500
|
|
16
|
+
"#D946EF", // fuchsia-500
|
|
17
|
+
"#EC4899", // pink-500
|
|
18
|
+
"#F43F5E", // rose-500
|
|
19
|
+
"#334155", // slate-700
|
|
20
|
+
"#6B7280", // gray-500
|
|
21
|
+
"#E5E7EB", // gray-200
|
|
22
|
+
]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../../infrastructure/utilities/utils"
|
|
6
|
+
import { useLegacyColorPickerContext } from "./legacy-color-picker.context"
|
|
7
|
+
import { LegacyColorPickerSwatch } from "./legacy-color-picker.swatches"
|
|
8
|
+
|
|
9
|
+
export function LegacyColorPickerQuickList({
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<"div">) {
|
|
13
|
+
const { recentColors, presets, quickListCount } = useLegacyColorPickerContext()
|
|
14
|
+
|
|
15
|
+
const colors = React.useMemo(() => {
|
|
16
|
+
const seen = new Set<string>()
|
|
17
|
+
const result: string[] = []
|
|
18
|
+
for (const color of [...recentColors, ...presets]) {
|
|
19
|
+
const key = color.toLowerCase()
|
|
20
|
+
if (seen.has(key)) continue
|
|
21
|
+
seen.add(key)
|
|
22
|
+
result.push(color)
|
|
23
|
+
if (result.length >= quickListCount) break
|
|
24
|
+
}
|
|
25
|
+
return result
|
|
26
|
+
}, [recentColors, presets, quickListCount])
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
data-slot="color-picker-quick-list"
|
|
31
|
+
aria-label="Couleurs rapides"
|
|
32
|
+
className={cn(
|
|
33
|
+
"no-scrollbar flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto p-4",
|
|
34
|
+
className
|
|
35
|
+
)}
|
|
36
|
+
{...props}
|
|
37
|
+
>
|
|
38
|
+
<div
|
|
39
|
+
role="group"
|
|
40
|
+
aria-label="Couleurs prédéfinies et récentes"
|
|
41
|
+
className="flex shrink-0 items-center gap-1.5"
|
|
42
|
+
>
|
|
43
|
+
{colors.map((color) => (
|
|
44
|
+
<LegacyColorPickerSwatch key={color} value={color} size="sm" />
|
|
45
|
+
))}
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../../infrastructure/utilities/utils"
|
|
6
|
+
import { useLegacyColorPickerContext } from "./legacy-color-picker.context"
|
|
7
|
+
import { LegacyColorPickerSwatch } from "./legacy-color-picker.swatches"
|
|
8
|
+
|
|
9
|
+
export function LegacyColorPickerRecent({
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<"div">) {
|
|
13
|
+
const { recentColors } = useLegacyColorPickerContext()
|
|
14
|
+
|
|
15
|
+
if (recentColors.length === 0) {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
data-slot="color-picker-recent"
|
|
22
|
+
className={cn("flex flex-col gap-1.5", className)}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
<span className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
|
|
26
|
+
Récentes
|
|
27
|
+
</span>
|
|
28
|
+
<div
|
|
29
|
+
role="group"
|
|
30
|
+
aria-label="Dernières couleurs sélectionnées"
|
|
31
|
+
className="grid grid-cols-5 gap-1.5"
|
|
32
|
+
>
|
|
33
|
+
{recentColors.map((color) => (
|
|
34
|
+
<LegacyColorPickerSwatch
|
|
35
|
+
key={color}
|
|
36
|
+
value={color}
|
|
37
|
+
title={`Récemment utilisée : ${color}`}
|
|
38
|
+
/>
|
|
39
|
+
))}
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../../infrastructure/utilities/utils"
|
|
6
|
+
import {
|
|
7
|
+
chainHandlers,
|
|
8
|
+
useElasticInteraction,
|
|
9
|
+
} from "../../../infrastructure/hooks/use-elastic-interaction"
|
|
10
|
+
import { useLegacyColorPickerContext } from "./legacy-color-picker.context"
|
|
11
|
+
|
|
12
|
+
export function LegacyColorPickerSwatchGroup({
|
|
13
|
+
className,
|
|
14
|
+
...props
|
|
15
|
+
}: React.ComponentProps<"div">) {
|
|
16
|
+
const { presets } = useLegacyColorPickerContext()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
data-slot="color-picker-swatch-group"
|
|
21
|
+
role="group"
|
|
22
|
+
aria-label="Couleurs prédéfinies"
|
|
23
|
+
className={cn("grid grid-cols-5 gap-1.5", className)}
|
|
24
|
+
{...props}
|
|
25
|
+
>
|
|
26
|
+
{presets.map((color) => (
|
|
27
|
+
<LegacyColorPickerSwatch key={color} value={color} />
|
|
28
|
+
))}
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface LegacyColorPickerSwatchProps extends React.ComponentProps<"button"> {
|
|
34
|
+
value: string
|
|
35
|
+
size?: "sm" | "md"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const swatchSizeClasses: Record<NonNullable<LegacyColorPickerSwatchProps["size"]>, string> = {
|
|
39
|
+
sm: "size-5",
|
|
40
|
+
md: "size-6",
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function LegacyColorPickerSwatch({
|
|
44
|
+
value,
|
|
45
|
+
size = "md",
|
|
46
|
+
className,
|
|
47
|
+
disabled = false,
|
|
48
|
+
title,
|
|
49
|
+
onClick,
|
|
50
|
+
onPointerDown,
|
|
51
|
+
onPointerUp,
|
|
52
|
+
onPointerCancel,
|
|
53
|
+
onPointerLeave,
|
|
54
|
+
onMouseEnter,
|
|
55
|
+
onMouseLeave,
|
|
56
|
+
onFocus,
|
|
57
|
+
onBlur,
|
|
58
|
+
...props
|
|
59
|
+
}: LegacyColorPickerSwatchProps) {
|
|
60
|
+
const {
|
|
61
|
+
value: selectedValue,
|
|
62
|
+
onValueChange,
|
|
63
|
+
onCommit,
|
|
64
|
+
disabled: contextDisabled,
|
|
65
|
+
} = useLegacyColorPickerContext()
|
|
66
|
+
const isSelected = selectedValue.toLowerCase() === value.toLowerCase()
|
|
67
|
+
const resolvedDisabled = disabled || contextDisabled
|
|
68
|
+
const elastic = useElasticInteraction({ pressScale: 0.92, focusScale: 1.05, hoverScale: 1.12 })
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<button
|
|
72
|
+
type="button"
|
|
73
|
+
data-slot="color-picker-swatch"
|
|
74
|
+
data-state={isSelected ? "selected" : "idle"}
|
|
75
|
+
aria-pressed={isSelected}
|
|
76
|
+
aria-label={title ?? `Couleur ${value}`}
|
|
77
|
+
title={title ?? value}
|
|
78
|
+
disabled={resolvedDisabled}
|
|
79
|
+
className={cn(
|
|
80
|
+
"relative flex items-center justify-center rounded-full outline-none transition-transform",
|
|
81
|
+
swatchSizeClasses[size],
|
|
82
|
+
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
83
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
84
|
+
className
|
|
85
|
+
)}
|
|
86
|
+
style={{
|
|
87
|
+
backgroundColor: value,
|
|
88
|
+
// border: isSelected ? `5px solid ${value}` : "0 solid transparent",
|
|
89
|
+
boxShadow: isSelected
|
|
90
|
+
? `0 0 0 2px var(--background), 0 0 0 3.5px ${value}`
|
|
91
|
+
: "inset 0 0 0 1px rgba(0, 0, 0, 0.06)",
|
|
92
|
+
}}
|
|
93
|
+
onClick={(event) => {
|
|
94
|
+
onValueChange(value)
|
|
95
|
+
onCommit(value)
|
|
96
|
+
onClick?.(event)
|
|
97
|
+
}}
|
|
98
|
+
onPointerDown={chainHandlers(elastic.onPointerDown, onPointerDown)}
|
|
99
|
+
onPointerUp={chainHandlers(elastic.onPointerUp, onPointerUp)}
|
|
100
|
+
onPointerCancel={chainHandlers(elastic.onPointerCancel, onPointerCancel)}
|
|
101
|
+
onPointerLeave={chainHandlers(elastic.onPointerLeave, onPointerLeave)}
|
|
102
|
+
onMouseEnter={chainHandlers(elastic.onMouseEnter, onMouseEnter)}
|
|
103
|
+
onMouseLeave={chainHandlers(elastic.onMouseLeave, onMouseLeave)}
|
|
104
|
+
onFocus={chainHandlers(elastic.onFocus, onFocus)}
|
|
105
|
+
onBlur={chainHandlers(elastic.onBlur, onBlur)}
|
|
106
|
+
{...props}
|
|
107
|
+
>
|
|
108
|
+
{isSelected && <span className="size-2 rounded-full bg-background" />}
|
|
109
|
+
</button>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
import { PaletteIcon } from "lucide-react"
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../../infrastructure/utilities/utils"
|
|
8
|
+
import {
|
|
9
|
+
chainHandlers,
|
|
10
|
+
useElasticInteraction,
|
|
11
|
+
} from "../../../infrastructure/hooks/use-elastic-interaction"
|
|
12
|
+
import { PopoverTrigger } from "../popover"
|
|
13
|
+
import { useLegacyColorPickerContext } from "./legacy-color-picker.context"
|
|
14
|
+
|
|
15
|
+
export const colorPickerTriggerVariants = cva(
|
|
16
|
+
"relative inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full outline-none transition-transform select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
17
|
+
{
|
|
18
|
+
variants: {
|
|
19
|
+
size: {
|
|
20
|
+
xs: "size-4",
|
|
21
|
+
sm: "size-5",
|
|
22
|
+
md: "size-6",
|
|
23
|
+
lg: "size-7",
|
|
24
|
+
xl: "size-8",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
size: "md",
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
export interface LegacyColorPickerTriggerProps
|
|
34
|
+
extends VariantProps<typeof colorPickerTriggerVariants>,
|
|
35
|
+
React.ComponentProps<typeof PopoverTrigger> {
|
|
36
|
+
asChild?: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function LegacyColorPickerTrigger({
|
|
40
|
+
className,
|
|
41
|
+
size,
|
|
42
|
+
asChild = false,
|
|
43
|
+
title,
|
|
44
|
+
onPointerDown,
|
|
45
|
+
onPointerUp,
|
|
46
|
+
onPointerCancel,
|
|
47
|
+
onPointerLeave,
|
|
48
|
+
onMouseEnter,
|
|
49
|
+
onMouseLeave,
|
|
50
|
+
onFocus,
|
|
51
|
+
onBlur,
|
|
52
|
+
...props
|
|
53
|
+
}: LegacyColorPickerTriggerProps) {
|
|
54
|
+
const { value, size: contextSize, disabled } = useLegacyColorPickerContext()
|
|
55
|
+
const resolvedSize = size ?? contextSize
|
|
56
|
+
const elastic = useElasticInteraction({ pressScale: 0.96, focusScale: 1.04, hoverScale: 1.05 })
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<PopoverTrigger
|
|
60
|
+
asChild={asChild}
|
|
61
|
+
data-slot="color-picker-trigger"
|
|
62
|
+
aria-label={title ?? `Couleur ${value}`}
|
|
63
|
+
title={title ?? value}
|
|
64
|
+
disabled={disabled}
|
|
65
|
+
className={cn(colorPickerTriggerVariants({ size: resolvedSize }), className)}
|
|
66
|
+
style={{ backgroundColor: value, boxShadow: "inset 0 0 0 1px rgba(0, 0, 0, 0.06)" }}
|
|
67
|
+
onPointerDown={chainHandlers(elastic.onPointerDown, onPointerDown)}
|
|
68
|
+
onPointerUp={chainHandlers(elastic.onPointerUp, onPointerUp)}
|
|
69
|
+
onPointerCancel={chainHandlers(elastic.onPointerCancel, onPointerCancel)}
|
|
70
|
+
onPointerLeave={chainHandlers(elastic.onPointerLeave, onPointerLeave)}
|
|
71
|
+
onMouseEnter={chainHandlers(elastic.onMouseEnter, onMouseEnter)}
|
|
72
|
+
onMouseLeave={chainHandlers(elastic.onMouseLeave, onMouseLeave)}
|
|
73
|
+
onFocus={chainHandlers(elastic.onFocus, onFocus)}
|
|
74
|
+
onBlur={chainHandlers(elastic.onBlur, onBlur)}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface LegacyColorPickerOpenButtonProps
|
|
81
|
+
extends React.ComponentProps<typeof PopoverTrigger> {}
|
|
82
|
+
|
|
83
|
+
export function LegacyColorPickerOpenButton({
|
|
84
|
+
className,
|
|
85
|
+
asChild = false,
|
|
86
|
+
title,
|
|
87
|
+
onPointerDown,
|
|
88
|
+
onPointerUp,
|
|
89
|
+
onPointerCancel,
|
|
90
|
+
onPointerLeave,
|
|
91
|
+
onMouseEnter,
|
|
92
|
+
onMouseLeave,
|
|
93
|
+
onFocus,
|
|
94
|
+
onBlur,
|
|
95
|
+
...props
|
|
96
|
+
}: LegacyColorPickerOpenButtonProps) {
|
|
97
|
+
const { disabled } = useLegacyColorPickerContext()
|
|
98
|
+
const elastic = useElasticInteraction({ pressScale: 0.92, focusScale: 1.08, hoverScale: 1.1 })
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<PopoverTrigger
|
|
102
|
+
asChild={asChild}
|
|
103
|
+
data-slot="color-picker-open-button"
|
|
104
|
+
aria-label={title ?? "Ouvrir le sélecteur de couleurs"}
|
|
105
|
+
title={title ?? "Ouvrir le sélecteur de couleurs"}
|
|
106
|
+
disabled={disabled}
|
|
107
|
+
className={cn(
|
|
108
|
+
"inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full",
|
|
109
|
+
"bg-foreground text-background outline-none transition-transform select-none",
|
|
110
|
+
"hover:bg-primary hover:text-primary-foreground",
|
|
111
|
+
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
112
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
113
|
+
className
|
|
114
|
+
)}
|
|
115
|
+
onPointerDown={chainHandlers(elastic.onPointerDown, onPointerDown)}
|
|
116
|
+
onPointerUp={chainHandlers(elastic.onPointerUp, onPointerUp)}
|
|
117
|
+
onPointerCancel={chainHandlers(elastic.onPointerCancel, onPointerCancel)}
|
|
118
|
+
onPointerLeave={chainHandlers(elastic.onPointerLeave, onPointerLeave)}
|
|
119
|
+
onMouseEnter={chainHandlers(elastic.onMouseEnter, onMouseEnter)}
|
|
120
|
+
onMouseLeave={chainHandlers(elastic.onMouseLeave, onMouseLeave)}
|
|
121
|
+
onFocus={chainHandlers(elastic.onFocus, onFocus)}
|
|
122
|
+
onBlur={chainHandlers(elastic.onBlur, onBlur)}
|
|
123
|
+
{...props}
|
|
124
|
+
>
|
|
125
|
+
<PaletteIcon aria-hidden className="size-3.5" />
|
|
126
|
+
</PopoverTrigger>
|
|
127
|
+
)
|
|
128
|
+
}
|