@sakoa/ui 0.1.0
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 +171 -0
- package/dist/App.d.ts +2 -0
- package/dist/cli/index.js +9243 -0
- package/dist/components/DemoSection.d.ts +30 -0
- package/dist/components/SApiKeyboard.d.ts +22 -0
- package/dist/components/SApiSection.d.ts +21 -0
- package/dist/components/SApiTable.d.ts +46 -0
- package/dist/components/STableOfContents.d.ts +2 -0
- package/dist/components/ui/SAlert.d.ts +76 -0
- package/dist/components/ui/SBadge.d.ts +56 -0
- package/dist/components/ui/SButton.d.ts +67 -0
- package/dist/components/ui/SCheckbox.d.ts +64 -0
- package/dist/components/ui/SChip.d.ts +43 -0
- package/dist/components/ui/SDatePicker.d.ts +77 -0
- package/dist/components/ui/SGlassButton.d.ts +70 -0
- package/dist/components/ui/SIcon.d.ts +29 -0
- package/dist/components/ui/SInput.d.ts +129 -0
- package/dist/components/ui/SKbd.d.ts +24 -0
- package/dist/components/ui/SKbdShortcut.d.ts +14 -0
- package/dist/components/ui/SSelect.d.ts +148 -0
- package/dist/components/ui/SSkeleton.d.ts +37 -0
- package/dist/components/ui/SSwitch.d.ts +61 -0
- package/dist/components/ui/STooltip.d.ts +82 -0
- package/dist/components/ui/accordion/SAccordionContent.d.ts +23 -0
- package/dist/components/ui/accordion/SAccordionItem.d.ts +70 -0
- package/dist/components/ui/accordion/SAccordionTrigger.d.ts +37 -0
- package/dist/components/ui/accordion/index.d.ts +4 -0
- package/dist/components/ui/avatar/SAvatar.d.ts +36 -0
- package/dist/components/ui/avatar/SAvatarFallback.d.ts +26 -0
- package/dist/components/ui/avatar/SAvatarGroup.d.ts +30 -0
- package/dist/components/ui/avatar/SAvatarImage.d.ts +23 -0
- package/dist/components/ui/avatar/index.d.ts +4 -0
- package/dist/components/ui/breadcrumb/SBreadcrumb.d.ts +22 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbEllipsis.d.ts +17 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbItem.d.ts +17 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbLink.d.ts +26 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbList.d.ts +17 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbPage.d.ts +17 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbSeparator.d.ts +17 -0
- package/dist/components/ui/breadcrumb/index.d.ts +7 -0
- package/dist/components/ui/card/SCard.d.ts +103 -0
- package/dist/components/ui/card/SCardActions.d.ts +44 -0
- package/dist/components/ui/card/SCardContent.d.ts +35 -0
- package/dist/components/ui/card/SCardFooter.d.ts +38 -0
- package/dist/components/ui/card/SCardHeader.d.ts +53 -0
- package/dist/components/ui/card/SCardMedia.d.ts +83 -0
- package/dist/components/ui/card/SGlassCard.d.ts +103 -0
- package/dist/components/ui/card/SMorphingCardContent.d.ts +18 -0
- package/dist/components/ui/card/index.d.ts +24 -0
- package/dist/components/ui/carousel/SCarousel.d.ts +166 -0
- package/dist/components/ui/carousel/index.d.ts +2 -0
- package/dist/components/ui/color-picker/SColorPickerAlphaSlider.d.ts +4 -0
- package/dist/components/ui/color-picker/SColorPickerCopy.d.ts +19 -0
- package/dist/components/ui/color-picker/SColorPickerEyeDropper.d.ts +17 -0
- package/dist/components/ui/color-picker/SColorPickerHueSlider.d.ts +4 -0
- package/dist/components/ui/color-picker/SColorPickerInputs.d.ts +2 -0
- package/dist/components/ui/color-picker/SColorPickerPresets.d.ts +9 -0
- package/dist/components/ui/color-picker/SColorPickerPreview.d.ts +2 -0
- package/dist/components/ui/color-picker/SColorPickerRecent.d.ts +7 -0
- package/dist/components/ui/color-picker/SColorPickerSpectrum.d.ts +4 -0
- package/dist/components/ui/color-picker/index.d.ts +11 -0
- package/dist/components/ui/drawer/index.d.ts +11 -0
- package/dist/components/ui/dropdown/SDropdownDivider.d.ts +8 -0
- package/dist/components/ui/dropdown/SDropdownGroup.d.ts +25 -0
- package/dist/components/ui/dropdown/SDropdownItem.d.ts +56 -0
- package/dist/components/ui/dropdown/index.d.ts +4 -0
- package/dist/components/ui/form/SForm.d.ts +38 -0
- package/dist/components/ui/form/SFormField.d.ts +31 -0
- package/dist/components/ui/form/index.d.ts +5 -0
- package/dist/components/ui/modal/index.d.ts +19 -0
- package/dist/components/ui/option/SOption.d.ts +32 -0
- package/dist/components/ui/option/SOptionGroup.d.ts +28 -0
- package/dist/components/ui/option/index.d.ts +2 -0
- package/dist/components/ui/otp/SOTP.d.ts +122 -0
- package/dist/components/ui/otp/SOTPGroup.d.ts +23 -0
- package/dist/components/ui/otp/SOTPSeparator.d.ts +17 -0
- package/dist/components/ui/otp/SOTPSlot.d.ts +49 -0
- package/dist/components/ui/otp/index.d.ts +7 -0
- package/dist/components/ui/otp/types.d.ts +26 -0
- package/dist/components/ui/otp/useOTPContext.d.ts +42 -0
- package/dist/components/ui/pagination/SPagination.d.ts +151 -0
- package/dist/components/ui/pagination/index.d.ts +2 -0
- package/dist/components/ui/progress/SProgress.d.ts +62 -0
- package/dist/components/ui/progress/SProgressRange.d.ts +91 -0
- package/dist/components/ui/progress/index.d.ts +4 -0
- package/dist/components/ui/radio/SRadio.d.ts +58 -0
- package/dist/components/ui/radio/SRadioGroup.d.ts +52 -0
- package/dist/components/ui/radio/index.d.ts +2 -0
- package/dist/components/ui/stepper/SStepper.d.ts +83 -0
- package/dist/components/ui/stepper/SStepperContent.d.ts +24 -0
- package/dist/components/ui/stepper/SStepperDescription.d.ts +20 -0
- package/dist/components/ui/stepper/SStepperIndicator.d.ts +37 -0
- package/dist/components/ui/stepper/SStepperItem.d.ts +37 -0
- package/dist/components/ui/stepper/SStepperSeparator.d.ts +5 -0
- package/dist/components/ui/stepper/SStepperTitle.d.ts +20 -0
- package/dist/components/ui/stepper/SStepperTrigger.d.ts +22 -0
- package/dist/components/ui/stepper/index.d.ts +11 -0
- package/dist/components/ui/table/STableBody.d.ts +27 -0
- package/dist/components/ui/table/STableCell.d.ts +55 -0
- package/dist/components/ui/table/STableColumn.d.ts +87 -0
- package/dist/components/ui/table/STableEmpty.d.ts +54 -0
- package/dist/components/ui/table/STableHeader.d.ts +25 -0
- package/dist/components/ui/table/STableRow.d.ts +38 -0
- package/dist/components/ui/table/STableSkeleton.d.ts +29 -0
- package/dist/components/ui/table/index.d.ts +98 -0
- package/dist/components/ui/table/useDataTable.d.ts +80 -0
- package/dist/components/ui/tabs/STabPane.d.ts +31 -0
- package/dist/components/ui/tabs/STabsContent.d.ts +21 -0
- package/dist/components/ui/tabs/STabsIndicator.d.ts +9 -0
- package/dist/components/ui/tabs/STabsTrigger.d.ts +28 -0
- package/dist/components/ui/tabs/index.d.ts +6 -0
- package/dist/components/ui/toast/SToast.d.ts +49 -0
- package/dist/components/ui/toast/SToastContainer.d.ts +21 -0
- package/dist/components/ui/toast/index.d.ts +2 -0
- package/dist/composables/useAsync.d.ts +134 -0
- package/dist/composables/useClickOutside.d.ts +69 -0
- package/dist/composables/useClipboard.d.ts +46 -0
- package/dist/composables/useDebounce.d.ts +150 -0
- package/dist/composables/useDialog.d.ts +118 -0
- package/dist/composables/useForm.d.ts +204 -0
- package/dist/composables/useHotkey.d.ts +128 -0
- package/dist/composables/useIntersectionObserver.d.ts +156 -0
- package/dist/composables/useLocalStorage.d.ts +120 -0
- package/dist/composables/useMediaQuery.d.ts +115 -0
- package/dist/composables/useTheme.d.ts +8 -0
- package/dist/composables/useToast.d.ts +1619 -0
- package/dist/index.d.ts +71 -0
- package/dist/layouts/UILayout.d.ts +2 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/main.d.ts +0 -0
- package/dist/router.d.ts +2 -0
- package/dist/saka-ui.css +1 -0
- package/dist/saka-ui.js +18513 -0
- package/dist/saka-ui.umd.cjs +38 -0
- package/dist/views/docs/CustomizationView.d.ts +2 -0
- package/dist/views/docs/FormValidationView.d.ts +2 -0
- package/dist/views/docs/StylingGuideView.d.ts +2 -0
- package/dist/views/docs/UseAsyncView.d.ts +2 -0
- package/dist/views/docs/UseClickOutsideView.d.ts +124 -0
- package/dist/views/docs/UseClipboardView.d.ts +4 -0
- package/dist/views/docs/UseDebounceView.d.ts +2 -0
- package/dist/views/docs/UseHotkeyView.d.ts +205 -0
- package/dist/views/docs/UseIntersectionObserverView.d.ts +5 -0
- package/dist/views/docs/UseLocalStorageView.d.ts +2 -0
- package/dist/views/docs/UseMediaQueryView.d.ts +2 -0
- package/dist/views/docs/UseThemeView.d.ts +2 -0
- package/dist/views/examples/AuthFormView.d.ts +2 -0
- package/dist/views/examples/CreditCardFormView.d.ts +6 -0
- package/dist/views/examples/FormFieldExampleView.d.ts +2 -0
- package/dist/views/examples/ProjectFormView.d.ts +2 -0
- package/dist/views/ui/AccordionView.d.ts +2 -0
- package/dist/views/ui/AlertView.d.ts +2 -0
- package/dist/views/ui/AvatarView.d.ts +2 -0
- package/dist/views/ui/BadgeView.d.ts +2 -0
- package/dist/views/ui/BreadcrumbView.d.ts +2 -0
- package/dist/views/ui/ButtonView.d.ts +2 -0
- package/dist/views/ui/CardView.d.ts +2 -0
- package/dist/views/ui/CarouselView.d.ts +274 -0
- package/dist/views/ui/CheckboxView.d.ts +2 -0
- package/dist/views/ui/ChipView.d.ts +2 -0
- package/dist/views/ui/ColorPickerView.d.ts +2 -0
- package/dist/views/ui/DatePickerView.d.ts +2 -0
- package/dist/views/ui/DialogView.d.ts +2 -0
- package/dist/views/ui/DrawerView.d.ts +2 -0
- package/dist/views/ui/DropdownView.d.ts +2 -0
- package/dist/views/ui/GlassButtonView.d.ts +2 -0
- package/dist/views/ui/GlassCardView.d.ts +2 -0
- package/dist/views/ui/HomeView.d.ts +2 -0
- package/dist/views/ui/IconsView.d.ts +2 -0
- package/dist/views/ui/InputView.d.ts +2 -0
- package/dist/views/ui/KbdView.d.ts +2 -0
- package/dist/views/ui/ModalView.d.ts +2 -0
- package/dist/views/ui/MorphingCardView.d.ts +2 -0
- package/dist/views/ui/MorphingModalView.d.ts +2 -0
- package/dist/views/ui/OTPView.d.ts +206 -0
- package/dist/views/ui/PaginationView.d.ts +2 -0
- package/dist/views/ui/ProgressView.d.ts +2 -0
- package/dist/views/ui/RadioView.d.ts +2 -0
- package/dist/views/ui/SelectView.d.ts +2 -0
- package/dist/views/ui/SkeletonView.d.ts +2 -0
- package/dist/views/ui/StepperView.d.ts +2 -0
- package/dist/views/ui/SwitchView.d.ts +2 -0
- package/dist/views/ui/TableView.d.ts +2 -0
- package/dist/views/ui/TabsView.d.ts +2 -0
- package/dist/views/ui/ToastView.d.ts +2 -0
- package/dist/views/ui/TooltipView.d.ts +2 -0
- package/dist/vite.svg +1 -0
- package/package.json +64 -0
- package/registry/components/accordion.json +19 -0
- package/registry/components/alert.json +17 -0
- package/registry/components/avatar.json +18 -0
- package/registry/components/badge.json +14 -0
- package/registry/components/breadcrumb.json +24 -0
- package/registry/components/button.json +17 -0
- package/registry/components/card.json +23 -0
- package/registry/components/carousel.json +19 -0
- package/registry/components/checkbox.json +17 -0
- package/registry/components/chip.json +17 -0
- package/registry/components/color-picker.json +24 -0
- package/registry/components/date-picker.json +17 -0
- package/registry/components/drawer.json +26 -0
- package/registry/components/dropdown.json +21 -0
- package/registry/components/form.json +16 -0
- package/registry/components/glass-button.json +17 -0
- package/registry/components/icon.json +17 -0
- package/registry/components/input.json +17 -0
- package/registry/components/kbd.json +16 -0
- package/registry/components/modal.json +32 -0
- package/registry/components/option.json +16 -0
- package/registry/components/otp.json +23 -0
- package/registry/components/pagination.json +18 -0
- package/registry/components/progress.json +16 -0
- package/registry/components/radio.json +19 -0
- package/registry/components/select.json +17 -0
- package/registry/components/skeleton.json +14 -0
- package/registry/components/switch.json +17 -0
- package/registry/components/table.json +26 -0
- package/registry/components/tabs.json +19 -0
- package/registry/components/toast.json +19 -0
- package/registry/components/tooltip.json +14 -0
- package/registry/index.json +4 -0
- package/registry/source/components/ui/SAlert.vue +388 -0
- package/registry/source/components/ui/SBadge.vue +243 -0
- package/registry/source/components/ui/SButton.vue +387 -0
- package/registry/source/components/ui/SCheckbox.vue +310 -0
- package/registry/source/components/ui/SChip.vue +130 -0
- package/registry/source/components/ui/SDatePicker.vue +1290 -0
- package/registry/source/components/ui/SGlassButton.vue +547 -0
- package/registry/source/components/ui/SIcon.vue +78 -0
- package/registry/source/components/ui/SInput.vue +1054 -0
- package/registry/source/components/ui/SKbd.vue +96 -0
- package/registry/source/components/ui/SKbdShortcut.vue +36 -0
- package/registry/source/components/ui/SSelect.vue +1290 -0
- package/registry/source/components/ui/SSkeleton.vue +185 -0
- package/registry/source/components/ui/SSwitch.vue +275 -0
- package/registry/source/components/ui/STooltip.vue +491 -0
- package/registry/source/components/ui/accordion/SAccordion.vue +248 -0
- package/registry/source/components/ui/accordion/SAccordionItem.vue +353 -0
- package/registry/source/components/ui/accordion/index.ts +5 -0
- package/registry/source/components/ui/avatar/SAvatar.vue +169 -0
- package/registry/source/components/ui/avatar/SAvatarFallback.vue +66 -0
- package/registry/source/components/ui/avatar/SAvatarGroup.vue +69 -0
- package/registry/source/components/ui/avatar/SAvatarImage.vue +92 -0
- package/registry/source/components/ui/avatar/index.ts +5 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumb.vue +23 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbEllipsis.vue +17 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbItem.vue +14 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbLink.vue +46 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbList.vue +17 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbPage.vue +15 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbSeparator.vue +18 -0
- package/registry/source/components/ui/breadcrumb/index.ts +7 -0
- package/registry/source/components/ui/card/SCard.vue +517 -0
- package/registry/source/components/ui/card/SCardActions.vue +129 -0
- package/registry/source/components/ui/card/SCardContent.vue +117 -0
- package/registry/source/components/ui/card/SCardFooter.vue +103 -0
- package/registry/source/components/ui/card/SCardHeader.vue +163 -0
- package/registry/source/components/ui/card/SCardMedia.vue +312 -0
- package/registry/source/components/ui/card/index.ts +34 -0
- package/registry/source/components/ui/carousel/SCarousel.vue +1069 -0
- package/registry/source/components/ui/carousel/SCarouselSlide.vue +107 -0
- package/registry/source/components/ui/carousel/index.ts +3 -0
- package/registry/source/components/ui/color-picker/SColorPicker.vue +772 -0
- package/registry/source/components/ui/color-picker/SColorPickerAlphaSlider.vue +158 -0
- package/registry/source/components/ui/color-picker/SColorPickerCopy.vue +76 -0
- package/registry/source/components/ui/color-picker/SColorPickerEyeDropper.vue +68 -0
- package/registry/source/components/ui/color-picker/SColorPickerHueSlider.vue +138 -0
- package/registry/source/components/ui/color-picker/SColorPickerInputs.vue +227 -0
- package/registry/source/components/ui/color-picker/SColorPickerPresets.vue +87 -0
- package/registry/source/components/ui/color-picker/SColorPickerPreview.vue +46 -0
- package/registry/source/components/ui/color-picker/SColorPickerRecent.vue +74 -0
- package/registry/source/components/ui/color-picker/SColorPickerSpectrum.vue +149 -0
- package/registry/source/components/ui/color-picker/index.ts +11 -0
- package/registry/source/components/ui/drawer/SDrawer.vue +797 -0
- package/registry/source/components/ui/drawer/SDrawerClose.vue +64 -0
- package/registry/source/components/ui/drawer/SDrawerContent.vue +81 -0
- package/registry/source/components/ui/drawer/SDrawerDescription.vue +40 -0
- package/registry/source/components/ui/drawer/SDrawerFooter.vue +97 -0
- package/registry/source/components/ui/drawer/SDrawerHandle.vue +79 -0
- package/registry/source/components/ui/drawer/SDrawerHeader.vue +117 -0
- package/registry/source/components/ui/drawer/SDrawerTitle.vue +40 -0
- package/registry/source/components/ui/drawer/SDrawerTrigger.vue +51 -0
- package/registry/source/components/ui/drawer/index.ts +20 -0
- package/registry/source/components/ui/dropdown/SDropdown.vue +843 -0
- package/registry/source/components/ui/dropdown/SDropdownDivider.vue +23 -0
- package/registry/source/components/ui/dropdown/SDropdownGroup.vue +53 -0
- package/registry/source/components/ui/dropdown/SDropdownItem.vue +179 -0
- package/registry/source/components/ui/dropdown/index.ts +5 -0
- package/registry/source/components/ui/form/SForm.vue +84 -0
- package/registry/source/components/ui/form/SFormField.vue +78 -0
- package/registry/source/components/ui/form/index.ts +8 -0
- package/registry/source/components/ui/modal/SModal.vue +648 -0
- package/registry/source/components/ui/modal/SModalClose.vue +49 -0
- package/registry/source/components/ui/modal/SModalContent.vue +74 -0
- package/registry/source/components/ui/modal/SModalDescription.vue +39 -0
- package/registry/source/components/ui/modal/SModalFooter.vue +84 -0
- package/registry/source/components/ui/modal/SModalHeader.vue +107 -0
- package/registry/source/components/ui/modal/SModalTitle.vue +39 -0
- package/registry/source/components/ui/modal/SModalTrigger.vue +61 -0
- package/registry/source/components/ui/modal/SMorphingModal.vue +429 -0
- package/registry/source/components/ui/modal/SMorphingModalClose.vue +42 -0
- package/registry/source/components/ui/modal/SMorphingModalDescription.vue +49 -0
- package/registry/source/components/ui/modal/SMorphingModalImage.vue +44 -0
- package/registry/source/components/ui/modal/SMorphingModalSubtitle.vue +29 -0
- package/registry/source/components/ui/modal/SMorphingModalTitle.vue +34 -0
- package/registry/source/components/ui/modal/SMorphingModalTrigger.vue +95 -0
- package/registry/source/components/ui/modal/index.ts +32 -0
- package/registry/source/components/ui/option/SOption.vue +180 -0
- package/registry/source/components/ui/option/SOptionGroup.vue +77 -0
- package/registry/source/components/ui/option/index.ts +3 -0
- package/registry/source/components/ui/otp/SOTP.vue +843 -0
- package/registry/source/components/ui/otp/SOTPGroup.vue +29 -0
- package/registry/source/components/ui/otp/SOTPSeparator.vue +15 -0
- package/registry/source/components/ui/otp/SOTPSlot.vue +462 -0
- package/registry/source/components/ui/otp/index.ts +7 -0
- package/registry/source/components/ui/otp/types.ts +27 -0
- package/registry/source/components/ui/otp/useOTPContext.ts +62 -0
- package/registry/source/components/ui/pagination/SPagination.vue +923 -0
- package/registry/source/components/ui/pagination/index.ts +8 -0
- package/registry/source/components/ui/progress/SProgress.vue +635 -0
- package/registry/source/components/ui/progress/SProgressRange.vue +715 -0
- package/registry/source/components/ui/progress/index.ts +4 -0
- package/registry/source/components/ui/radio/SRadio.vue +407 -0
- package/registry/source/components/ui/radio/SRadioGroup.vue +200 -0
- package/registry/source/components/ui/radio/index.ts +3 -0
- package/registry/source/components/ui/table/SDataTable.vue +828 -0
- package/registry/source/components/ui/table/STableBody.vue +70 -0
- package/registry/source/components/ui/table/STableCell.vue +147 -0
- package/registry/source/components/ui/table/STableColumn.vue +120 -0
- package/registry/source/components/ui/table/STableEmpty.vue +159 -0
- package/registry/source/components/ui/table/STableHeader.vue +132 -0
- package/registry/source/components/ui/table/STableRow.vue +106 -0
- package/registry/source/components/ui/table/STableSkeleton.vue +208 -0
- package/registry/source/components/ui/table/index.ts +126 -0
- package/registry/source/components/ui/table/useDataTable.ts +519 -0
- package/registry/source/components/ui/tabs/STabPane.vue +130 -0
- package/registry/source/components/ui/tabs/STabs.vue +467 -0
- package/registry/source/components/ui/tabs/index.ts +7 -0
- package/registry/source/components/ui/toast/SToast.vue +261 -0
- package/registry/source/components/ui/toast/SToastContainer.vue +209 -0
- package/registry/source/components/ui/toast/index.ts +2 -0
- package/registry/source/composables/useForm.ts +960 -0
- package/registry/source/composables/useTheme.ts +86 -0
- package/registry/source/composables/useToast.ts +440 -0
- package/registry/source/lib/utils.ts +6 -0
|
@@ -0,0 +1,772 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type InjectionKey, type Ref, type ComputedRef } from 'vue'
|
|
3
|
+
|
|
4
|
+
export interface SColorPickerContext {
|
|
5
|
+
hsva: Ref<{ h: number; s: number; v: number; a: number }>
|
|
6
|
+
currentRgb: ComputedRef<{ r: number; g: number; b: number; a: number }>
|
|
7
|
+
currentHex: ComputedRef<string>
|
|
8
|
+
currentHsl: ComputedRef<{ h: number; s: number; l: number; a: number }>
|
|
9
|
+
displayValue: ComputedRef<string>
|
|
10
|
+
activeFormat: Ref<'hex' | 'rgb' | 'hsl'>
|
|
11
|
+
recentColors: Ref<string[]>
|
|
12
|
+
showAlpha: ComputedRef<boolean>
|
|
13
|
+
disabled: ComputedRef<boolean>
|
|
14
|
+
readonly: ComputedRef<boolean>
|
|
15
|
+
size: ComputedRef<'small' | 'medium' | 'large'>
|
|
16
|
+
sizeConfig: ComputedRef<{
|
|
17
|
+
panelWidth: string
|
|
18
|
+
spectrumHeight: string
|
|
19
|
+
slider: string
|
|
20
|
+
swatch: string
|
|
21
|
+
input: string
|
|
22
|
+
label: string
|
|
23
|
+
}>
|
|
24
|
+
parseColor: (color: string) => void
|
|
25
|
+
emitChange: () => void
|
|
26
|
+
emitInput: () => void
|
|
27
|
+
cycleFormat: () => void
|
|
28
|
+
selectPreset: (color: string) => void
|
|
29
|
+
addToRecent: (color: string) => void
|
|
30
|
+
hsvToRgb: (h: number, s: number, v: number) => { r: number; g: number; b: number }
|
|
31
|
+
rgbToHsv: (r: number, g: number, b: number) => { h: number; s: number; v: number }
|
|
32
|
+
rgbToHsl: (r: number, g: number, b: number) => { h: number; s: number; l: number }
|
|
33
|
+
hexToRgb: (hex: string) => { r: number; g: number; b: number; a: number }
|
|
34
|
+
rgbToHex: (r: number, g: number, b: number, a?: number) => string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const SColorPickerContextKey: InjectionKey<SColorPickerContext> = Symbol('SColorPickerContext')
|
|
38
|
+
|
|
39
|
+
import SColorPickerSpectrum from './SColorPickerSpectrum.vue'
|
|
40
|
+
import SColorPickerHueSlider from './SColorPickerHueSlider.vue'
|
|
41
|
+
import SColorPickerAlphaSlider from './SColorPickerAlphaSlider.vue'
|
|
42
|
+
import SColorPickerPreview from './SColorPickerPreview.vue'
|
|
43
|
+
import SColorPickerEyeDropper from './SColorPickerEyeDropper.vue'
|
|
44
|
+
import SColorPickerCopy from './SColorPickerCopy.vue'
|
|
45
|
+
import SColorPickerInputs from './SColorPickerInputs.vue'
|
|
46
|
+
import SColorPickerPresets from './SColorPickerPresets.vue'
|
|
47
|
+
import SColorPickerRecent from './SColorPickerRecent.vue'
|
|
48
|
+
|
|
49
|
+
export default {
|
|
50
|
+
components: {
|
|
51
|
+
SColorPickerSpectrum,
|
|
52
|
+
SColorPickerHueSlider,
|
|
53
|
+
SColorPickerAlphaSlider,
|
|
54
|
+
SColorPickerPreview,
|
|
55
|
+
SColorPickerEyeDropper,
|
|
56
|
+
SColorPickerCopy,
|
|
57
|
+
SColorPickerInputs,
|
|
58
|
+
SColorPickerPresets,
|
|
59
|
+
SColorPickerRecent
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<script setup lang="ts">
|
|
65
|
+
defineOptions({ inheritAttrs: false })
|
|
66
|
+
|
|
67
|
+
import { ref, computed, watch, onMounted, onBeforeUnmount, provide, useSlots } from 'vue'
|
|
68
|
+
import { cn } from '../../../lib/utils'
|
|
69
|
+
|
|
70
|
+
// ──── Props ────
|
|
71
|
+
export interface Props {
|
|
72
|
+
modelValue?: string
|
|
73
|
+
mode?: 'inline' | 'dropdown'
|
|
74
|
+
format?: 'hex' | 'rgb' | 'hsl'
|
|
75
|
+
showAlpha?: boolean
|
|
76
|
+
showSpectrum?: boolean
|
|
77
|
+
showSliders?: boolean
|
|
78
|
+
showPreview?: boolean
|
|
79
|
+
showInputs?: boolean
|
|
80
|
+
showPresets?: boolean
|
|
81
|
+
presets?: string[]
|
|
82
|
+
showEyeDropper?: boolean
|
|
83
|
+
showRecent?: boolean
|
|
84
|
+
maxRecent?: number
|
|
85
|
+
size?: 'small' | 'medium' | 'large'
|
|
86
|
+
triggerStyle?: 'button' | 'swatch'
|
|
87
|
+
disabled?: boolean
|
|
88
|
+
readonly?: boolean
|
|
89
|
+
label?: string
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
93
|
+
modelValue: '#3b82f6',
|
|
94
|
+
mode: 'inline',
|
|
95
|
+
format: 'hex',
|
|
96
|
+
showAlpha: false,
|
|
97
|
+
showSpectrum: true,
|
|
98
|
+
showSliders: true,
|
|
99
|
+
showPreview: true,
|
|
100
|
+
showInputs: true,
|
|
101
|
+
showPresets: true,
|
|
102
|
+
presets: () => [
|
|
103
|
+
'#ef4444', '#f97316', '#f59e0b', '#eab308', '#84cc16', '#22c55e',
|
|
104
|
+
'#10b981', '#14b8a6', '#06b6d4', '#0ea5e9', '#3b82f6', '#6366f1',
|
|
105
|
+
'#8b5cf6', '#a855f7', '#d946ef', '#ec4899', '#f43f5e', '#000000',
|
|
106
|
+
'#ffffff', '#6b7280'
|
|
107
|
+
],
|
|
108
|
+
showEyeDropper: true,
|
|
109
|
+
showRecent: true,
|
|
110
|
+
maxRecent: 8,
|
|
111
|
+
size: 'medium',
|
|
112
|
+
triggerStyle: 'button',
|
|
113
|
+
disabled: false,
|
|
114
|
+
readonly: false,
|
|
115
|
+
label: undefined
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const emit = defineEmits<{
|
|
119
|
+
'update:modelValue': [value: string]
|
|
120
|
+
'change': [value: string]
|
|
121
|
+
'input': [value: string]
|
|
122
|
+
}>()
|
|
123
|
+
|
|
124
|
+
const slots = useSlots()
|
|
125
|
+
|
|
126
|
+
// ──── State ────
|
|
127
|
+
const isOpen = ref(false)
|
|
128
|
+
const activeFormat = ref<'hex' | 'rgb' | 'hsl'>('hex')
|
|
129
|
+
const recentColors = ref<string[]>([])
|
|
130
|
+
|
|
131
|
+
// Refs
|
|
132
|
+
const containerRef = ref<HTMLElement | null>(null)
|
|
133
|
+
|
|
134
|
+
// Internal color state (HSV + Alpha)
|
|
135
|
+
const hsva = ref({ h: 210, s: 76, v: 96, a: 1 })
|
|
136
|
+
|
|
137
|
+
// ──── Size configs ────
|
|
138
|
+
const sizeConfig = computed(() => ({
|
|
139
|
+
small: {
|
|
140
|
+
panelWidth: 'w-52 min-w-52 max-w-full',
|
|
141
|
+
spectrumHeight: 'h-32',
|
|
142
|
+
slider: 'h-3',
|
|
143
|
+
swatch: 'w-5 h-5',
|
|
144
|
+
input: 'text-xs px-2 py-1',
|
|
145
|
+
label: 'text-xs'
|
|
146
|
+
},
|
|
147
|
+
medium: {
|
|
148
|
+
panelWidth: 'w-72 min-w-64 max-w-full',
|
|
149
|
+
spectrumHeight: 'h-44',
|
|
150
|
+
slider: 'h-4',
|
|
151
|
+
swatch: 'w-6 h-6',
|
|
152
|
+
input: 'text-sm px-2.5 py-1.5',
|
|
153
|
+
label: 'text-sm'
|
|
154
|
+
},
|
|
155
|
+
large: {
|
|
156
|
+
panelWidth: 'w-80 min-w-72 max-w-full',
|
|
157
|
+
spectrumHeight: 'h-52',
|
|
158
|
+
slider: 'h-5',
|
|
159
|
+
swatch: 'w-7 h-7',
|
|
160
|
+
input: 'text-base px-3 py-2',
|
|
161
|
+
label: 'text-base'
|
|
162
|
+
}
|
|
163
|
+
}[props.size]))
|
|
164
|
+
|
|
165
|
+
// ──── Color conversions ────
|
|
166
|
+
function hexToRgb(hex: string): { r: number; g: number; b: number; a: number } {
|
|
167
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(hex)
|
|
168
|
+
if (result) {
|
|
169
|
+
return {
|
|
170
|
+
r: parseInt(result[1], 16),
|
|
171
|
+
g: parseInt(result[2], 16),
|
|
172
|
+
b: parseInt(result[3], 16),
|
|
173
|
+
a: result[4] ? parseInt(result[4], 16) / 255 : 1
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return { r: 0, g: 0, b: 0, a: 1 }
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function rgbToHex(r: number, g: number, b: number, a?: number): string {
|
|
180
|
+
const toHex = (n: number) => Math.round(n).toString(16).padStart(2, '0')
|
|
181
|
+
const hex = `#${toHex(r)}${toHex(g)}${toHex(b)}`
|
|
182
|
+
if (a !== undefined && a < 1) {
|
|
183
|
+
return hex + toHex(a * 255)
|
|
184
|
+
}
|
|
185
|
+
return hex
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function rgbToHsv(r: number, g: number, b: number): { h: number; s: number; v: number } {
|
|
189
|
+
r /= 255; g /= 255; b /= 255
|
|
190
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b)
|
|
191
|
+
const d = max - min
|
|
192
|
+
let h = 0
|
|
193
|
+
const s = max === 0 ? 0 : d / max * 100
|
|
194
|
+
const v = max * 100
|
|
195
|
+
|
|
196
|
+
if (max !== min) {
|
|
197
|
+
switch (max) {
|
|
198
|
+
case r: h = (g - b) / d + (g < b ? 6 : 0); break
|
|
199
|
+
case g: h = (b - r) / d + 2; break
|
|
200
|
+
case b: h = (r - g) / d + 4; break
|
|
201
|
+
}
|
|
202
|
+
h *= 60
|
|
203
|
+
}
|
|
204
|
+
return { h, s, v }
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function hsvToRgb(h: number, s: number, v: number): { r: number; g: number; b: number } {
|
|
208
|
+
s /= 100; v /= 100
|
|
209
|
+
const c = v * s
|
|
210
|
+
const x = c * (1 - Math.abs((h / 60) % 2 - 1))
|
|
211
|
+
const m = v - c
|
|
212
|
+
let r = 0, g = 0, b = 0
|
|
213
|
+
|
|
214
|
+
if (h >= 0 && h < 60) { r = c; g = x; b = 0 }
|
|
215
|
+
else if (h >= 60 && h < 120) { r = x; g = c; b = 0 }
|
|
216
|
+
else if (h >= 120 && h < 180) { r = 0; g = c; b = x }
|
|
217
|
+
else if (h >= 180 && h < 240) { r = 0; g = x; b = c }
|
|
218
|
+
else if (h >= 240 && h < 300) { r = x; g = 0; b = c }
|
|
219
|
+
else { r = c; g = 0; b = x }
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
r: Math.round((r + m) * 255),
|
|
223
|
+
g: Math.round((g + m) * 255),
|
|
224
|
+
b: Math.round((b + m) * 255)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function rgbToHsl(r: number, g: number, b: number): { h: number; s: number; l: number } {
|
|
229
|
+
r /= 255; g /= 255; b /= 255
|
|
230
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b)
|
|
231
|
+
let h = 0, s = 0
|
|
232
|
+
const l = (max + min) / 2
|
|
233
|
+
|
|
234
|
+
if (max !== min) {
|
|
235
|
+
const d = max - min
|
|
236
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min)
|
|
237
|
+
switch (max) {
|
|
238
|
+
case r: h = ((g - b) / d + (g < b ? 6 : 0)) / 6; break
|
|
239
|
+
case g: h = ((b - r) / d + 2) / 6; break
|
|
240
|
+
case b: h = ((r - g) / d + 4) / 6; break
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return { h: Math.round(h * 360), s: Math.round(s * 100), l: Math.round(l * 100) }
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// ──── Computed values ────
|
|
248
|
+
const currentRgb = computed(() => {
|
|
249
|
+
const rgb = hsvToRgb(hsva.value.h, hsva.value.s, hsva.value.v)
|
|
250
|
+
return { ...rgb, a: hsva.value.a }
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
const currentHex = computed(() => {
|
|
254
|
+
const { r, g, b } = currentRgb.value
|
|
255
|
+
return rgbToHex(r, g, b, props.showAlpha ? hsva.value.a : undefined)
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
const currentHsl = computed(() => {
|
|
259
|
+
const { r, g, b } = currentRgb.value
|
|
260
|
+
return { ...rgbToHsl(r, g, b), a: hsva.value.a }
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
const displayValue = computed(() => {
|
|
264
|
+
const { r, g, b, a } = currentRgb.value
|
|
265
|
+
const { h, s, l } = currentHsl.value
|
|
266
|
+
|
|
267
|
+
switch (activeFormat.value) {
|
|
268
|
+
case 'rgb':
|
|
269
|
+
return props.showAlpha
|
|
270
|
+
? `rgba(${r}, ${g}, ${b}, ${a.toFixed(2)})`
|
|
271
|
+
: `rgb(${r}, ${g}, ${b})`
|
|
272
|
+
case 'hsl':
|
|
273
|
+
return props.showAlpha
|
|
274
|
+
? `hsla(${h}, ${s}%, ${l}%, ${a.toFixed(2)})`
|
|
275
|
+
: `hsl(${h}, ${s}%, ${l}%)`
|
|
276
|
+
default:
|
|
277
|
+
return currentHex.value.toUpperCase()
|
|
278
|
+
}
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
const outputValue = computed(() => {
|
|
282
|
+
const { r, g, b, a } = currentRgb.value
|
|
283
|
+
const { h, s, l } = currentHsl.value
|
|
284
|
+
|
|
285
|
+
switch (props.format) {
|
|
286
|
+
case 'rgb':
|
|
287
|
+
return props.showAlpha
|
|
288
|
+
? `rgba(${r}, ${g}, ${b}, ${a.toFixed(2)})`
|
|
289
|
+
: `rgb(${r}, ${g}, ${b})`
|
|
290
|
+
case 'hsl':
|
|
291
|
+
return props.showAlpha
|
|
292
|
+
? `hsla(${h}, ${s}%, ${l}%, ${a.toFixed(2)})`
|
|
293
|
+
: `hsl(${h}, ${s}%, ${l}%)`
|
|
294
|
+
default:
|
|
295
|
+
return currentHex.value.toUpperCase()
|
|
296
|
+
}
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
// ──── Parse color ────
|
|
300
|
+
function parseColor(color: string) {
|
|
301
|
+
if (!color) return
|
|
302
|
+
|
|
303
|
+
if (color.startsWith('#')) {
|
|
304
|
+
const rgb = hexToRgb(color)
|
|
305
|
+
const hsv = rgbToHsv(rgb.r, rgb.g, rgb.b)
|
|
306
|
+
hsva.value = { ...hsv, a: rgb.a }
|
|
307
|
+
return
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const rgbMatch = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/)
|
|
311
|
+
if (rgbMatch) {
|
|
312
|
+
const r = parseInt(rgbMatch[1])
|
|
313
|
+
const g = parseInt(rgbMatch[2])
|
|
314
|
+
const b = parseInt(rgbMatch[3])
|
|
315
|
+
const a = rgbMatch[4] ? parseFloat(rgbMatch[4]) : 1
|
|
316
|
+
const hsv = rgbToHsv(r, g, b)
|
|
317
|
+
hsva.value = { ...hsv, a }
|
|
318
|
+
return
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const hslMatch = color.match(/hsla?\((\d+),\s*(\d+)%?,\s*(\d+)%?(?:,\s*([\d.]+))?\)/)
|
|
322
|
+
if (hslMatch) {
|
|
323
|
+
const h = parseInt(hslMatch[1])
|
|
324
|
+
const s = parseInt(hslMatch[2])
|
|
325
|
+
const l = parseInt(hslMatch[3])
|
|
326
|
+
const a = hslMatch[4] ? parseFloat(hslMatch[4]) : 1
|
|
327
|
+
const sNorm = s / 100
|
|
328
|
+
const lNorm = l / 100
|
|
329
|
+
const v = lNorm + sNorm * Math.min(lNorm, 1 - lNorm)
|
|
330
|
+
const sv = v === 0 ? 0 : 2 * (1 - lNorm / v)
|
|
331
|
+
hsva.value = { h, s: sv * 100, v: v * 100, a }
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Watch for external value changes
|
|
336
|
+
watch(() => props.modelValue, (newValue) => {
|
|
337
|
+
if (newValue) parseColor(newValue)
|
|
338
|
+
}, { immediate: true })
|
|
339
|
+
|
|
340
|
+
// ──── Emit helpers ────
|
|
341
|
+
function emitChange() {
|
|
342
|
+
emit('update:modelValue', outputValue.value)
|
|
343
|
+
emit('change', outputValue.value)
|
|
344
|
+
addToRecent(currentHex.value)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function emitInput() {
|
|
348
|
+
emit('input', outputValue.value)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// ──── Preset / Recent ────
|
|
352
|
+
function selectPreset(color: string) {
|
|
353
|
+
if (props.disabled || props.readonly) return
|
|
354
|
+
parseColor(color)
|
|
355
|
+
emitChange()
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function addToRecent(color: string) {
|
|
359
|
+
const normalized = color.toUpperCase()
|
|
360
|
+
recentColors.value = [
|
|
361
|
+
normalized,
|
|
362
|
+
...recentColors.value.filter(c => c !== normalized)
|
|
363
|
+
].slice(0, props.maxRecent)
|
|
364
|
+
|
|
365
|
+
try {
|
|
366
|
+
localStorage.setItem('s-color-picker-recent', JSON.stringify(recentColors.value))
|
|
367
|
+
} catch { /* ignore */ }
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function loadRecentColors() {
|
|
371
|
+
try {
|
|
372
|
+
const stored = localStorage.getItem('s-color-picker-recent')
|
|
373
|
+
if (stored) recentColors.value = JSON.parse(stored)
|
|
374
|
+
} catch { /* ignore */ }
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// ──── Format cycling ────
|
|
378
|
+
function cycleFormat() {
|
|
379
|
+
const formats: Array<'hex' | 'rgb' | 'hsl'> = ['hex', 'rgb', 'hsl']
|
|
380
|
+
const currentIndex = formats.indexOf(activeFormat.value)
|
|
381
|
+
activeFormat.value = formats[(currentIndex + 1) % formats.length]
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// ──── Dropdown handling ────
|
|
385
|
+
function toggle() {
|
|
386
|
+
if (props.disabled) return
|
|
387
|
+
isOpen.value = !isOpen.value
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function handleClickOutside(event: MouseEvent) {
|
|
391
|
+
if (props.mode !== 'dropdown' || !isOpen.value) return
|
|
392
|
+
const target = event.target as Node
|
|
393
|
+
if (containerRef.value && !containerRef.value.contains(target)) {
|
|
394
|
+
isOpen.value = false
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// ──── Compound API detection ────
|
|
399
|
+
const isCompound = computed(() => !!slots.default)
|
|
400
|
+
|
|
401
|
+
// ──── Provide context ────
|
|
402
|
+
const context: SColorPickerContext = {
|
|
403
|
+
hsva,
|
|
404
|
+
currentRgb,
|
|
405
|
+
currentHex,
|
|
406
|
+
currentHsl,
|
|
407
|
+
displayValue,
|
|
408
|
+
activeFormat,
|
|
409
|
+
recentColors,
|
|
410
|
+
showAlpha: computed(() => props.showAlpha),
|
|
411
|
+
disabled: computed(() => props.disabled),
|
|
412
|
+
readonly: computed(() => props.readonly),
|
|
413
|
+
size: computed(() => props.size),
|
|
414
|
+
sizeConfig,
|
|
415
|
+
parseColor,
|
|
416
|
+
emitChange,
|
|
417
|
+
emitInput,
|
|
418
|
+
cycleFormat,
|
|
419
|
+
selectPreset,
|
|
420
|
+
addToRecent,
|
|
421
|
+
hsvToRgb,
|
|
422
|
+
rgbToHsv,
|
|
423
|
+
rgbToHsl,
|
|
424
|
+
hexToRgb,
|
|
425
|
+
rgbToHex
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
provide(SColorPickerContextKey, context)
|
|
429
|
+
|
|
430
|
+
// ──── Lifecycle ────
|
|
431
|
+
onMounted(() => {
|
|
432
|
+
loadRecentColors()
|
|
433
|
+
document.addEventListener('click', handleClickOutside)
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
onBeforeUnmount(() => {
|
|
437
|
+
document.removeEventListener('click', handleClickOutside)
|
|
438
|
+
})
|
|
439
|
+
</script>
|
|
440
|
+
|
|
441
|
+
<template>
|
|
442
|
+
<div
|
|
443
|
+
ref="containerRef"
|
|
444
|
+
v-bind="$attrs"
|
|
445
|
+
:class="cn('s-color-picker', `s-color-picker--${size}`, {
|
|
446
|
+
's-color-picker--disabled': disabled,
|
|
447
|
+
's-color-picker--readonly': readonly
|
|
448
|
+
})"
|
|
449
|
+
>
|
|
450
|
+
<!-- Label -->
|
|
451
|
+
<label v-if="label" class="s-color-picker__label" :class="sizeConfig.label">
|
|
452
|
+
{{ label }}
|
|
453
|
+
</label>
|
|
454
|
+
|
|
455
|
+
<!-- Custom Trigger Slot (simple API) -->
|
|
456
|
+
<div
|
|
457
|
+
v-if="mode === 'dropdown' && $slots.trigger"
|
|
458
|
+
class="s-color-picker__trigger-custom"
|
|
459
|
+
@click.stop="toggle"
|
|
460
|
+
>
|
|
461
|
+
<slot
|
|
462
|
+
name="trigger"
|
|
463
|
+
:color="currentHex"
|
|
464
|
+
:display-value="displayValue"
|
|
465
|
+
:rgb="currentRgb"
|
|
466
|
+
:hsl="currentHsl"
|
|
467
|
+
:is-open="isOpen"
|
|
468
|
+
:toggle="toggle"
|
|
469
|
+
:disabled="disabled"
|
|
470
|
+
/>
|
|
471
|
+
</div>
|
|
472
|
+
|
|
473
|
+
<!-- Dropdown Trigger: Button Style (simple API) -->
|
|
474
|
+
<button
|
|
475
|
+
v-if="mode === 'dropdown' && !$slots.trigger && triggerStyle === 'button' && !isCompound"
|
|
476
|
+
type="button"
|
|
477
|
+
class="s-color-picker__trigger"
|
|
478
|
+
:class="sizeConfig.input"
|
|
479
|
+
:disabled="disabled"
|
|
480
|
+
@click.stop="toggle"
|
|
481
|
+
>
|
|
482
|
+
<span
|
|
483
|
+
class="s-color-picker__trigger-swatch"
|
|
484
|
+
:style="{ backgroundColor: currentHex }"
|
|
485
|
+
></span>
|
|
486
|
+
<span class="s-color-picker__trigger-value">{{ displayValue }}</span>
|
|
487
|
+
<svg
|
|
488
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
489
|
+
width="16"
|
|
490
|
+
height="16"
|
|
491
|
+
viewBox="0 0 24 24"
|
|
492
|
+
fill="none"
|
|
493
|
+
stroke="currentColor"
|
|
494
|
+
stroke-width="2"
|
|
495
|
+
stroke-linecap="round"
|
|
496
|
+
stroke-linejoin="round"
|
|
497
|
+
class="s-color-picker__trigger-icon"
|
|
498
|
+
:class="{ 'rotate-180': isOpen }"
|
|
499
|
+
>
|
|
500
|
+
<path d="m6 9 6 6 6-6" />
|
|
501
|
+
</svg>
|
|
502
|
+
</button>
|
|
503
|
+
|
|
504
|
+
<!-- Dropdown Trigger: Swatch Style (simple API) -->
|
|
505
|
+
<button
|
|
506
|
+
v-if="mode === 'dropdown' && !$slots.trigger && triggerStyle === 'swatch' && !isCompound"
|
|
507
|
+
type="button"
|
|
508
|
+
class="s-color-picker__trigger-swatch-bar"
|
|
509
|
+
:disabled="disabled"
|
|
510
|
+
@click.stop="toggle"
|
|
511
|
+
>
|
|
512
|
+
<span
|
|
513
|
+
class="s-color-picker__trigger-swatch-bar-color"
|
|
514
|
+
:style="{ backgroundColor: showAlpha ? `rgba(${currentRgb.r}, ${currentRgb.g}, ${currentRgb.b}, ${hsva.a})` : currentHex }"
|
|
515
|
+
></span>
|
|
516
|
+
</button>
|
|
517
|
+
|
|
518
|
+
<!-- Compound API: render default slot directly -->
|
|
519
|
+
<template v-if="isCompound">
|
|
520
|
+
<div
|
|
521
|
+
v-show="mode === 'inline' || isOpen"
|
|
522
|
+
class="s-color-picker__panel"
|
|
523
|
+
:class="[sizeConfig.panelWidth, { 's-color-picker__panel--dropdown': mode === 'dropdown' }]"
|
|
524
|
+
>
|
|
525
|
+
<slot
|
|
526
|
+
:color="currentHex"
|
|
527
|
+
:rgb="currentRgb"
|
|
528
|
+
:hsl="currentHsl"
|
|
529
|
+
:display-value="displayValue"
|
|
530
|
+
:hsva="hsva"
|
|
531
|
+
/>
|
|
532
|
+
</div>
|
|
533
|
+
</template>
|
|
534
|
+
|
|
535
|
+
<!-- Simple API: render all sections based on show* props -->
|
|
536
|
+
<template v-else>
|
|
537
|
+
<div
|
|
538
|
+
v-show="mode === 'inline' || isOpen"
|
|
539
|
+
class="s-color-picker__panel"
|
|
540
|
+
:class="[sizeConfig.panelWidth, { 's-color-picker__panel--dropdown': mode === 'dropdown' }]"
|
|
541
|
+
>
|
|
542
|
+
<slot name="panel-before" />
|
|
543
|
+
|
|
544
|
+
<!-- Spectrum -->
|
|
545
|
+
<SColorPickerSpectrum v-if="showSpectrum" />
|
|
546
|
+
|
|
547
|
+
<!-- Sliders -->
|
|
548
|
+
<div v-if="showSliders" class="s-color-picker__sliders">
|
|
549
|
+
<SColorPickerHueSlider />
|
|
550
|
+
<SColorPickerAlphaSlider v-if="showAlpha" />
|
|
551
|
+
</div>
|
|
552
|
+
|
|
553
|
+
<!-- Preview & Tools -->
|
|
554
|
+
<div v-if="showPreview" class="s-color-picker__preview-row">
|
|
555
|
+
<SColorPickerPreview />
|
|
556
|
+
<div class="s-color-picker__tools">
|
|
557
|
+
<SColorPickerEyeDropper v-if="showEyeDropper" />
|
|
558
|
+
<SColorPickerCopy />
|
|
559
|
+
</div>
|
|
560
|
+
</div>
|
|
561
|
+
|
|
562
|
+
<!-- Inputs -->
|
|
563
|
+
<SColorPickerInputs v-if="showInputs" />
|
|
564
|
+
|
|
565
|
+
<!-- Presets -->
|
|
566
|
+
<SColorPickerPresets v-if="showPresets && presets.length" :presets="presets" />
|
|
567
|
+
|
|
568
|
+
<!-- Recent -->
|
|
569
|
+
<SColorPickerRecent v-if="showRecent" />
|
|
570
|
+
|
|
571
|
+
<slot name="panel-after" />
|
|
572
|
+
</div>
|
|
573
|
+
</template>
|
|
574
|
+
</div>
|
|
575
|
+
</template>
|
|
576
|
+
|
|
577
|
+
<style scoped>
|
|
578
|
+
.s-color-picker {
|
|
579
|
+
position: relative;
|
|
580
|
+
display: inline-flex;
|
|
581
|
+
flex-direction: column;
|
|
582
|
+
gap: 0.5rem;
|
|
583
|
+
font-family: inherit;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.s-color-picker--disabled {
|
|
587
|
+
opacity: 0.5;
|
|
588
|
+
pointer-events: none;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
.s-color-picker--readonly {
|
|
592
|
+
pointer-events: none;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
.s-color-picker__label {
|
|
596
|
+
color: var(--s-muted-foreground);
|
|
597
|
+
font-weight: 500;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/* Dropdown Trigger */
|
|
601
|
+
.s-color-picker__trigger {
|
|
602
|
+
display: inline-flex;
|
|
603
|
+
align-items: center;
|
|
604
|
+
gap: 0.5rem;
|
|
605
|
+
padding: 0.5rem 0.75rem;
|
|
606
|
+
border-radius: 0.5rem;
|
|
607
|
+
border: 1px solid var(--s-border);
|
|
608
|
+
background: var(--s-background);
|
|
609
|
+
color: var(--s-foreground);
|
|
610
|
+
cursor: pointer;
|
|
611
|
+
transition: all 0.2s ease;
|
|
612
|
+
min-width: 180px;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.s-color-picker__trigger:hover:not(:disabled) {
|
|
616
|
+
border-color: var(--s-primary);
|
|
617
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--s-primary) 15%, transparent);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
.s-color-picker__trigger:focus {
|
|
621
|
+
outline: none;
|
|
622
|
+
border-color: var(--s-primary);
|
|
623
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--s-primary) 15%, transparent);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.s-color-picker__trigger-swatch {
|
|
627
|
+
width: 1.25rem;
|
|
628
|
+
height: 1.25rem;
|
|
629
|
+
border-radius: 0.25rem;
|
|
630
|
+
border: 1px solid var(--s-border);
|
|
631
|
+
flex-shrink: 0;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
.s-color-picker__trigger-value {
|
|
635
|
+
flex: 1;
|
|
636
|
+
text-align: left;
|
|
637
|
+
font-family: ui-monospace, monospace;
|
|
638
|
+
font-size: 0.875rem;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/* Swatch Bar Trigger */
|
|
642
|
+
.s-color-picker__trigger-swatch-bar {
|
|
643
|
+
display: block;
|
|
644
|
+
width: 100%;
|
|
645
|
+
min-width: 180px;
|
|
646
|
+
height: 2.5rem;
|
|
647
|
+
padding: 0.25rem;
|
|
648
|
+
border-radius: 0.5rem;
|
|
649
|
+
border: 1px solid var(--s-border);
|
|
650
|
+
background: var(--s-background);
|
|
651
|
+
cursor: pointer;
|
|
652
|
+
transition: all 0.2s ease;
|
|
653
|
+
background-image:
|
|
654
|
+
linear-gradient(45deg, var(--s-border) 25%, transparent 25%),
|
|
655
|
+
linear-gradient(-45deg, var(--s-border) 25%, transparent 25%),
|
|
656
|
+
linear-gradient(45deg, transparent 75%, var(--s-border) 75%),
|
|
657
|
+
linear-gradient(-45deg, transparent 75%, var(--s-border) 75%);
|
|
658
|
+
background-size: 10px 10px;
|
|
659
|
+
background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
.s-color-picker__trigger-swatch-bar:hover:not(:disabled) {
|
|
663
|
+
border-color: var(--s-primary);
|
|
664
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--s-primary) 15%, transparent);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
.s-color-picker__trigger-swatch-bar:focus {
|
|
668
|
+
outline: none;
|
|
669
|
+
border-color: var(--s-primary);
|
|
670
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--s-primary) 15%, transparent);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
.s-color-picker__trigger-swatch-bar-color {
|
|
674
|
+
display: block;
|
|
675
|
+
width: 100%;
|
|
676
|
+
height: 100%;
|
|
677
|
+
border-radius: 0.25rem;
|
|
678
|
+
transition: background-color 0.15s ease;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.s-color-picker__trigger-icon {
|
|
682
|
+
color: var(--s-muted-foreground);
|
|
683
|
+
transition: transform 0.2s ease;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
.s-color-picker__trigger-custom {
|
|
687
|
+
display: inline-block;
|
|
688
|
+
cursor: pointer;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/* Panel */
|
|
692
|
+
.s-color-picker__panel {
|
|
693
|
+
display: flex;
|
|
694
|
+
flex-direction: column;
|
|
695
|
+
gap: 0.75rem;
|
|
696
|
+
padding: 1rem;
|
|
697
|
+
border-radius: 1rem;
|
|
698
|
+
background: var(--s-background);
|
|
699
|
+
border: 1px solid var(--s-border);
|
|
700
|
+
box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.2),
|
|
701
|
+
0 0 0 1px rgba(255, 255, 255, 0.05) inset;
|
|
702
|
+
backdrop-filter: blur(20px);
|
|
703
|
+
box-sizing: border-box;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
@media (max-width: 400px) {
|
|
707
|
+
.s-color-picker__panel {
|
|
708
|
+
min-width: 100% !important;
|
|
709
|
+
width: 100% !important;
|
|
710
|
+
padding: 0.75rem;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
.s-color-picker__panel--dropdown {
|
|
715
|
+
position: absolute;
|
|
716
|
+
top: 100%;
|
|
717
|
+
left: 0;
|
|
718
|
+
z-index: 999;
|
|
719
|
+
margin-top: 0.5rem;
|
|
720
|
+
animation: s-color-picker-fade-in 0.2s ease;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
@keyframes s-color-picker-fade-in {
|
|
724
|
+
from {
|
|
725
|
+
opacity: 0;
|
|
726
|
+
transform: translateY(-8px);
|
|
727
|
+
}
|
|
728
|
+
to {
|
|
729
|
+
opacity: 1;
|
|
730
|
+
transform: translateY(0);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/* Sliders container */
|
|
735
|
+
.s-color-picker__sliders {
|
|
736
|
+
display: flex;
|
|
737
|
+
flex-direction: column;
|
|
738
|
+
gap: 0.5rem;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/* Preview Row */
|
|
742
|
+
.s-color-picker__preview-row {
|
|
743
|
+
display: flex;
|
|
744
|
+
align-items: center;
|
|
745
|
+
gap: 0.75rem;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
.s-color-picker__tools {
|
|
749
|
+
display: flex;
|
|
750
|
+
gap: 0.25rem;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/* Size adjustments */
|
|
754
|
+
.s-color-picker--small .s-color-picker__panel {
|
|
755
|
+
padding: 0.75rem;
|
|
756
|
+
gap: 0.5rem;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
.s-color-picker--large .s-color-picker__panel {
|
|
760
|
+
padding: 1.25rem;
|
|
761
|
+
gap: 1rem;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
@media (max-width: 400px) {
|
|
765
|
+
.s-color-picker__trigger {
|
|
766
|
+
min-width: 140px;
|
|
767
|
+
}
|
|
768
|
+
.s-color-picker__trigger-swatch-bar {
|
|
769
|
+
min-width: 140px;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
</style>
|