@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,158 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, computed, inject, onBeforeUnmount } from 'vue'
|
|
3
|
+
import { SColorPickerContextKey, type SColorPickerContext } from './SColorPicker.vue'
|
|
4
|
+
|
|
5
|
+
const ctx = inject<SColorPickerContext>(SColorPickerContextKey)
|
|
6
|
+
if (!ctx) console.warn('[SColorPickerAlphaSlider] Must be used inside SColorPicker')
|
|
7
|
+
|
|
8
|
+
const sliderRef = ref<HTMLElement | null>(null)
|
|
9
|
+
const isDragging = ref(false)
|
|
10
|
+
|
|
11
|
+
const cursorPosition = computed(() => ({
|
|
12
|
+
left: `${(ctx?.hsva.value.a ?? 1) * 100}%`
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
const alphaGradient = computed(() => {
|
|
16
|
+
if (!ctx) return ''
|
|
17
|
+
const { r, g, b } = ctx.currentRgb.value
|
|
18
|
+
return `linear-gradient(to right, transparent, rgb(${r}, ${g}, ${b}))`
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
function updateFromEvent(event: MouseEvent) {
|
|
22
|
+
if (!sliderRef.value || !ctx) return
|
|
23
|
+
const rect = sliderRef.value.getBoundingClientRect()
|
|
24
|
+
const x = Math.max(0, Math.min(event.clientX - rect.left, rect.width))
|
|
25
|
+
ctx.hsva.value.a = x / rect.width
|
|
26
|
+
ctx.emitInput()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function updateFromTouch(event: TouchEvent) {
|
|
30
|
+
if (!sliderRef.value || !ctx || !event.touches[0]) return
|
|
31
|
+
const rect = sliderRef.value.getBoundingClientRect()
|
|
32
|
+
const x = Math.max(0, Math.min(event.touches[0].clientX - rect.left, rect.width))
|
|
33
|
+
ctx.hsva.value.a = x / rect.width
|
|
34
|
+
ctx.emitInput()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function onMouseDown(event: MouseEvent) {
|
|
38
|
+
if (ctx?.disabled.value || ctx?.readonly.value) return
|
|
39
|
+
isDragging.value = true
|
|
40
|
+
updateFromEvent(event)
|
|
41
|
+
document.addEventListener('mousemove', onMouseMove)
|
|
42
|
+
document.addEventListener('mouseup', onMouseUp)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function onTouchStart(event: TouchEvent) {
|
|
46
|
+
if (ctx?.disabled.value || ctx?.readonly.value) return
|
|
47
|
+
event.preventDefault()
|
|
48
|
+
isDragging.value = true
|
|
49
|
+
updateFromTouch(event)
|
|
50
|
+
document.addEventListener('touchmove', onTouchMove, { passive: false })
|
|
51
|
+
document.addEventListener('touchend', onTouchEnd)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function onMouseMove(event: MouseEvent) {
|
|
55
|
+
if (!isDragging.value) return
|
|
56
|
+
updateFromEvent(event)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function onTouchMove(event: TouchEvent) {
|
|
60
|
+
if (!isDragging.value) return
|
|
61
|
+
event.preventDefault()
|
|
62
|
+
updateFromTouch(event)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function onMouseUp() {
|
|
66
|
+
isDragging.value = false
|
|
67
|
+
document.removeEventListener('mousemove', onMouseMove)
|
|
68
|
+
document.removeEventListener('mouseup', onMouseUp)
|
|
69
|
+
ctx?.emitChange()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function onTouchEnd() {
|
|
73
|
+
isDragging.value = false
|
|
74
|
+
document.removeEventListener('touchmove', onTouchMove)
|
|
75
|
+
document.removeEventListener('touchend', onTouchEnd)
|
|
76
|
+
ctx?.emitChange()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
onBeforeUnmount(() => {
|
|
80
|
+
document.removeEventListener('mousemove', onMouseMove)
|
|
81
|
+
document.removeEventListener('mouseup', onMouseUp)
|
|
82
|
+
document.removeEventListener('touchmove', onTouchMove)
|
|
83
|
+
document.removeEventListener('touchend', onTouchEnd)
|
|
84
|
+
})
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<template>
|
|
88
|
+
<div
|
|
89
|
+
ref="sliderRef"
|
|
90
|
+
class="s-color-picker__slider s-color-picker__slider--alpha"
|
|
91
|
+
:class="ctx?.sizeConfig.value?.slider"
|
|
92
|
+
@mousedown="onMouseDown"
|
|
93
|
+
@touchstart="onTouchStart"
|
|
94
|
+
>
|
|
95
|
+
<div class="s-color-picker__slider-alpha-bg"></div>
|
|
96
|
+
<div
|
|
97
|
+
class="s-color-picker__slider-alpha-gradient"
|
|
98
|
+
:style="{ background: alphaGradient }"
|
|
99
|
+
></div>
|
|
100
|
+
<div
|
|
101
|
+
class="s-color-picker__slider-cursor"
|
|
102
|
+
:class="{ 's-color-picker__slider-cursor--dragging': isDragging }"
|
|
103
|
+
:style="cursorPosition"
|
|
104
|
+
></div>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
|
|
108
|
+
<style scoped>
|
|
109
|
+
.s-color-picker__slider {
|
|
110
|
+
position: relative;
|
|
111
|
+
border-radius: 999px;
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
touch-action: none;
|
|
115
|
+
user-select: none;
|
|
116
|
+
-webkit-user-select: none;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.s-color-picker__slider--alpha {
|
|
120
|
+
position: relative;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.s-color-picker__slider-alpha-bg {
|
|
124
|
+
position: absolute;
|
|
125
|
+
inset: 0;
|
|
126
|
+
border-radius: 999px;
|
|
127
|
+
background-image: linear-gradient(45deg, #ccc 25%, transparent 25%),
|
|
128
|
+
linear-gradient(-45deg, #ccc 25%, transparent 25%),
|
|
129
|
+
linear-gradient(45deg, transparent 75%, #ccc 75%),
|
|
130
|
+
linear-gradient(-45deg, transparent 75%, #ccc 75%);
|
|
131
|
+
background-size: 8px 8px;
|
|
132
|
+
background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.s-color-picker__slider-alpha-gradient {
|
|
136
|
+
position: absolute;
|
|
137
|
+
inset: 0;
|
|
138
|
+
border-radius: 999px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.s-color-picker__slider-cursor {
|
|
142
|
+
position: absolute;
|
|
143
|
+
top: 50%;
|
|
144
|
+
width: 1rem;
|
|
145
|
+
height: 1rem;
|
|
146
|
+
transform: translate(-50%, -50%);
|
|
147
|
+
background: white;
|
|
148
|
+
border-radius: 50%;
|
|
149
|
+
border: 2px solid white;
|
|
150
|
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
|
|
151
|
+
pointer-events: none;
|
|
152
|
+
transition: transform 0.1s ease;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.s-color-picker__slider-cursor--dragging {
|
|
156
|
+
transform: translate(-50%, -50%) scale(1.2);
|
|
157
|
+
}
|
|
158
|
+
</style>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, inject } from 'vue'
|
|
3
|
+
import { SColorPickerContextKey, type SColorPickerContext } from './SColorPicker.vue'
|
|
4
|
+
|
|
5
|
+
const ctx = inject<SColorPickerContext>(SColorPickerContextKey)
|
|
6
|
+
if (!ctx) console.warn('[SColorPickerCopy] Must be used inside SColorPicker')
|
|
7
|
+
|
|
8
|
+
const copied = ref(false)
|
|
9
|
+
|
|
10
|
+
async function copyToClipboard() {
|
|
11
|
+
if (!ctx) return
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
await navigator.clipboard.writeText(ctx.displayValue.value)
|
|
15
|
+
copied.value = true
|
|
16
|
+
setTimeout(() => copied.value = false, 1500)
|
|
17
|
+
} catch {
|
|
18
|
+
const textarea = document.createElement('textarea')
|
|
19
|
+
textarea.value = ctx.displayValue.value
|
|
20
|
+
document.body.appendChild(textarea)
|
|
21
|
+
textarea.select()
|
|
22
|
+
document.execCommand('copy')
|
|
23
|
+
document.body.removeChild(textarea)
|
|
24
|
+
copied.value = true
|
|
25
|
+
setTimeout(() => copied.value = false, 1500)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<button
|
|
32
|
+
type="button"
|
|
33
|
+
class="s-color-picker__tool-btn"
|
|
34
|
+
:class="{ 's-color-picker__tool-btn--copied': copied }"
|
|
35
|
+
title="Copy color"
|
|
36
|
+
@click="copyToClipboard"
|
|
37
|
+
>
|
|
38
|
+
<slot :copied="copied">
|
|
39
|
+
<svg v-if="!copied" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
40
|
+
<rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
|
|
41
|
+
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />
|
|
42
|
+
</svg>
|
|
43
|
+
<svg v-else xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
44
|
+
<path d="M20 6 9 17l-5-5" />
|
|
45
|
+
</svg>
|
|
46
|
+
</slot>
|
|
47
|
+
</button>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<style scoped>
|
|
51
|
+
.s-color-picker__tool-btn {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
width: 2.25rem;
|
|
56
|
+
height: 2.25rem;
|
|
57
|
+
border-radius: 0.5rem;
|
|
58
|
+
border: 1px solid var(--s-border);
|
|
59
|
+
background: var(--s-muted);
|
|
60
|
+
color: var(--s-muted-foreground);
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
transition: all 0.2s ease;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.s-color-picker__tool-btn:hover:not(:disabled) {
|
|
66
|
+
background: var(--s-accent);
|
|
67
|
+
color: var(--s-foreground);
|
|
68
|
+
border-color: var(--s-primary);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.s-color-picker__tool-btn--copied {
|
|
72
|
+
background: var(--s-primary);
|
|
73
|
+
color: white;
|
|
74
|
+
border-color: var(--s-primary);
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, inject, onMounted } from 'vue'
|
|
3
|
+
import { SColorPickerContextKey, type SColorPickerContext } from './SColorPicker.vue'
|
|
4
|
+
|
|
5
|
+
const ctx = inject<SColorPickerContext>(SColorPickerContextKey)
|
|
6
|
+
if (!ctx) console.warn('[SColorPickerEyeDropper] Must be used inside SColorPicker')
|
|
7
|
+
|
|
8
|
+
const supportsEyeDropper = ref(false)
|
|
9
|
+
|
|
10
|
+
onMounted(() => {
|
|
11
|
+
supportsEyeDropper.value = typeof window !== 'undefined' && 'EyeDropper' in window
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
async function openEyeDropper() {
|
|
15
|
+
if (ctx?.disabled.value || ctx?.readonly.value || !supportsEyeDropper.value) return
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
// @ts-expect-error EyeDropper API may not be in types
|
|
19
|
+
const eyeDropper = new EyeDropper()
|
|
20
|
+
const result = await eyeDropper.open()
|
|
21
|
+
ctx?.parseColor(result.sRGBHex)
|
|
22
|
+
ctx?.emitChange()
|
|
23
|
+
} catch {
|
|
24
|
+
// User cancelled or error
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<button
|
|
31
|
+
v-if="supportsEyeDropper"
|
|
32
|
+
type="button"
|
|
33
|
+
class="s-color-picker__tool-btn"
|
|
34
|
+
title="Pick color from screen"
|
|
35
|
+
:disabled="ctx?.disabled.value || ctx?.readonly.value"
|
|
36
|
+
@click="openEyeDropper"
|
|
37
|
+
>
|
|
38
|
+
<slot>
|
|
39
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
40
|
+
<path d="m2 22 1-1h3l9-9" />
|
|
41
|
+
<path d="M3 21v-3l9-9" />
|
|
42
|
+
<path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z" />
|
|
43
|
+
</svg>
|
|
44
|
+
</slot>
|
|
45
|
+
</button>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<style scoped>
|
|
49
|
+
.s-color-picker__tool-btn {
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
width: 2.25rem;
|
|
54
|
+
height: 2.25rem;
|
|
55
|
+
border-radius: 0.5rem;
|
|
56
|
+
border: 1px solid var(--s-border);
|
|
57
|
+
background: var(--s-muted);
|
|
58
|
+
color: var(--s-muted-foreground);
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
transition: all 0.2s ease;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.s-color-picker__tool-btn:hover:not(:disabled) {
|
|
64
|
+
background: var(--s-accent);
|
|
65
|
+
color: var(--s-foreground);
|
|
66
|
+
border-color: var(--s-primary);
|
|
67
|
+
}
|
|
68
|
+
</style>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, computed, inject, onBeforeUnmount } from 'vue'
|
|
3
|
+
import { SColorPickerContextKey, type SColorPickerContext } from './SColorPicker.vue'
|
|
4
|
+
|
|
5
|
+
const ctx = inject<SColorPickerContext>(SColorPickerContextKey)
|
|
6
|
+
if (!ctx) console.warn('[SColorPickerHueSlider] Must be used inside SColorPicker')
|
|
7
|
+
|
|
8
|
+
const sliderRef = ref<HTMLElement | null>(null)
|
|
9
|
+
const isDragging = ref(false)
|
|
10
|
+
|
|
11
|
+
const cursorPosition = computed(() => ({
|
|
12
|
+
left: `${((ctx?.hsva.value.h ?? 0) / 360) * 100}%`
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
function updateFromEvent(event: MouseEvent) {
|
|
16
|
+
if (!sliderRef.value || !ctx) return
|
|
17
|
+
const rect = sliderRef.value.getBoundingClientRect()
|
|
18
|
+
const x = Math.max(0, Math.min(event.clientX - rect.left, rect.width))
|
|
19
|
+
ctx.hsva.value.h = (x / rect.width) * 360
|
|
20
|
+
ctx.emitInput()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function updateFromTouch(event: TouchEvent) {
|
|
24
|
+
if (!sliderRef.value || !ctx || !event.touches[0]) return
|
|
25
|
+
const rect = sliderRef.value.getBoundingClientRect()
|
|
26
|
+
const x = Math.max(0, Math.min(event.touches[0].clientX - rect.left, rect.width))
|
|
27
|
+
ctx.hsva.value.h = (x / rect.width) * 360
|
|
28
|
+
ctx.emitInput()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function onMouseDown(event: MouseEvent) {
|
|
32
|
+
if (ctx?.disabled.value || ctx?.readonly.value) return
|
|
33
|
+
isDragging.value = true
|
|
34
|
+
updateFromEvent(event)
|
|
35
|
+
document.addEventListener('mousemove', onMouseMove)
|
|
36
|
+
document.addEventListener('mouseup', onMouseUp)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function onTouchStart(event: TouchEvent) {
|
|
40
|
+
if (ctx?.disabled.value || ctx?.readonly.value) return
|
|
41
|
+
event.preventDefault()
|
|
42
|
+
isDragging.value = true
|
|
43
|
+
updateFromTouch(event)
|
|
44
|
+
document.addEventListener('touchmove', onTouchMove, { passive: false })
|
|
45
|
+
document.addEventListener('touchend', onTouchEnd)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function onMouseMove(event: MouseEvent) {
|
|
49
|
+
if (!isDragging.value) return
|
|
50
|
+
updateFromEvent(event)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function onTouchMove(event: TouchEvent) {
|
|
54
|
+
if (!isDragging.value) return
|
|
55
|
+
event.preventDefault()
|
|
56
|
+
updateFromTouch(event)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function onMouseUp() {
|
|
60
|
+
isDragging.value = false
|
|
61
|
+
document.removeEventListener('mousemove', onMouseMove)
|
|
62
|
+
document.removeEventListener('mouseup', onMouseUp)
|
|
63
|
+
ctx?.emitChange()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function onTouchEnd() {
|
|
67
|
+
isDragging.value = false
|
|
68
|
+
document.removeEventListener('touchmove', onTouchMove)
|
|
69
|
+
document.removeEventListener('touchend', onTouchEnd)
|
|
70
|
+
ctx?.emitChange()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
onBeforeUnmount(() => {
|
|
74
|
+
document.removeEventListener('mousemove', onMouseMove)
|
|
75
|
+
document.removeEventListener('mouseup', onMouseUp)
|
|
76
|
+
document.removeEventListener('touchmove', onTouchMove)
|
|
77
|
+
document.removeEventListener('touchend', onTouchEnd)
|
|
78
|
+
})
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<template>
|
|
82
|
+
<div
|
|
83
|
+
ref="sliderRef"
|
|
84
|
+
class="s-color-picker__slider s-color-picker__slider--hue"
|
|
85
|
+
:class="ctx?.sizeConfig.value?.slider"
|
|
86
|
+
@mousedown="onMouseDown"
|
|
87
|
+
@touchstart="onTouchStart"
|
|
88
|
+
>
|
|
89
|
+
<div
|
|
90
|
+
class="s-color-picker__slider-cursor"
|
|
91
|
+
:class="{ 's-color-picker__slider-cursor--dragging': isDragging }"
|
|
92
|
+
:style="cursorPosition"
|
|
93
|
+
></div>
|
|
94
|
+
</div>
|
|
95
|
+
</template>
|
|
96
|
+
|
|
97
|
+
<style scoped>
|
|
98
|
+
.s-color-picker__slider {
|
|
99
|
+
position: relative;
|
|
100
|
+
border-radius: 999px;
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
touch-action: none;
|
|
104
|
+
user-select: none;
|
|
105
|
+
-webkit-user-select: none;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.s-color-picker__slider--hue {
|
|
109
|
+
background: linear-gradient(
|
|
110
|
+
to right,
|
|
111
|
+
hsl(0, 100%, 50%),
|
|
112
|
+
hsl(60, 100%, 50%),
|
|
113
|
+
hsl(120, 100%, 50%),
|
|
114
|
+
hsl(180, 100%, 50%),
|
|
115
|
+
hsl(240, 100%, 50%),
|
|
116
|
+
hsl(300, 100%, 50%),
|
|
117
|
+
hsl(360, 100%, 50%)
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.s-color-picker__slider-cursor {
|
|
122
|
+
position: absolute;
|
|
123
|
+
top: 50%;
|
|
124
|
+
width: 1rem;
|
|
125
|
+
height: 1rem;
|
|
126
|
+
transform: translate(-50%, -50%);
|
|
127
|
+
background: white;
|
|
128
|
+
border-radius: 50%;
|
|
129
|
+
border: 2px solid white;
|
|
130
|
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
|
|
131
|
+
pointer-events: none;
|
|
132
|
+
transition: transform 0.1s ease;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.s-color-picker__slider-cursor--dragging {
|
|
136
|
+
transform: translate(-50%, -50%) scale(1.2);
|
|
137
|
+
}
|
|
138
|
+
</style>
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, watch, inject } from 'vue'
|
|
3
|
+
import { SColorPickerContextKey, type SColorPickerContext } from './SColorPicker.vue'
|
|
4
|
+
|
|
5
|
+
const ctx = inject<SColorPickerContext>(SColorPickerContextKey)
|
|
6
|
+
if (!ctx) console.warn('[SColorPickerInputs] Must be used inside SColorPicker')
|
|
7
|
+
|
|
8
|
+
const hexInput = ref('')
|
|
9
|
+
const rgbInputs = ref({ r: 0, g: 0, b: 0, a: 100 })
|
|
10
|
+
const hslInputs = ref({ h: 0, s: 0, l: 0, a: 100 })
|
|
11
|
+
|
|
12
|
+
// Sync inputs with current color
|
|
13
|
+
watch([() => ctx?.currentHex.value, () => ctx?.currentRgb.value, () => ctx?.currentHsl.value], () => {
|
|
14
|
+
if (!ctx) return
|
|
15
|
+
hexInput.value = ctx.currentHex.value.toUpperCase()
|
|
16
|
+
rgbInputs.value = {
|
|
17
|
+
r: ctx.currentRgb.value.r,
|
|
18
|
+
g: ctx.currentRgb.value.g,
|
|
19
|
+
b: ctx.currentRgb.value.b,
|
|
20
|
+
a: Math.round(ctx.hsva.value.a * 100)
|
|
21
|
+
}
|
|
22
|
+
hslInputs.value = {
|
|
23
|
+
h: ctx.currentHsl.value.h,
|
|
24
|
+
s: ctx.currentHsl.value.s,
|
|
25
|
+
l: ctx.currentHsl.value.l,
|
|
26
|
+
a: Math.round(ctx.hsva.value.a * 100)
|
|
27
|
+
}
|
|
28
|
+
}, { immediate: true })
|
|
29
|
+
|
|
30
|
+
function handleHexInput() {
|
|
31
|
+
if (!ctx) return
|
|
32
|
+
const hex = hexInput.value.startsWith('#') ? hexInput.value : '#' + hexInput.value
|
|
33
|
+
if (/^#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(hex)) {
|
|
34
|
+
ctx.parseColor(hex)
|
|
35
|
+
ctx.emitChange()
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function handleRgbInput() {
|
|
40
|
+
if (!ctx) return
|
|
41
|
+
const { r, g, b, a } = rgbInputs.value
|
|
42
|
+
if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) {
|
|
43
|
+
const hsv = ctx.rgbToHsv(r, g, b)
|
|
44
|
+
ctx.hsva.value = { ...hsv, a: a / 100 }
|
|
45
|
+
ctx.emitChange()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function handleHslInput() {
|
|
50
|
+
if (!ctx) return
|
|
51
|
+
const { h, s, l, a } = hslInputs.value
|
|
52
|
+
if (h >= 0 && h <= 360 && s >= 0 && s <= 100 && l >= 0 && l <= 100) {
|
|
53
|
+
const sNorm = s / 100
|
|
54
|
+
const lNorm = l / 100
|
|
55
|
+
const v = lNorm + sNorm * Math.min(lNorm, 1 - lNorm)
|
|
56
|
+
const sv = v === 0 ? 0 : 2 * (1 - lNorm / v)
|
|
57
|
+
ctx.hsva.value = { h, s: sv * 100, v: v * 100, a: a / 100 }
|
|
58
|
+
ctx.emitChange()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<template>
|
|
64
|
+
<div v-if="ctx" class="s-color-picker__inputs">
|
|
65
|
+
<div class="s-color-picker__format-toggle">
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
class="s-color-picker__format-btn"
|
|
69
|
+
:class="ctx.sizeConfig.value?.input"
|
|
70
|
+
@click="ctx.cycleFormat()"
|
|
71
|
+
>
|
|
72
|
+
{{ ctx.activeFormat.value.toUpperCase() }}
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<!-- HEX Input -->
|
|
77
|
+
<div v-if="ctx.activeFormat.value === 'hex'" class="s-color-picker__input-group s-color-picker__input-group--hex">
|
|
78
|
+
<input
|
|
79
|
+
v-model="hexInput"
|
|
80
|
+
type="text"
|
|
81
|
+
class="s-color-picker__input"
|
|
82
|
+
:class="ctx.sizeConfig.value?.input"
|
|
83
|
+
:disabled="ctx.disabled.value || ctx.readonly.value"
|
|
84
|
+
maxlength="9"
|
|
85
|
+
@blur="handleHexInput"
|
|
86
|
+
@keydown.enter="handleHexInput"
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<!-- RGB Inputs -->
|
|
91
|
+
<div v-if="ctx.activeFormat.value === 'rgb'" class="s-color-picker__input-group s-color-picker__input-group--rgb">
|
|
92
|
+
<div class="s-color-picker__input-field">
|
|
93
|
+
<input v-model.number="rgbInputs.r" type="number" class="s-color-picker__input" :class="ctx.sizeConfig.value?.input" :disabled="ctx.disabled.value || ctx.readonly.value" min="0" max="255" @blur="handleRgbInput" @keydown.enter="handleRgbInput" />
|
|
94
|
+
<span class="s-color-picker__input-label">R</span>
|
|
95
|
+
</div>
|
|
96
|
+
<div class="s-color-picker__input-field">
|
|
97
|
+
<input v-model.number="rgbInputs.g" type="number" class="s-color-picker__input" :class="ctx.sizeConfig.value?.input" :disabled="ctx.disabled.value || ctx.readonly.value" min="0" max="255" @blur="handleRgbInput" @keydown.enter="handleRgbInput" />
|
|
98
|
+
<span class="s-color-picker__input-label">G</span>
|
|
99
|
+
</div>
|
|
100
|
+
<div class="s-color-picker__input-field">
|
|
101
|
+
<input v-model.number="rgbInputs.b" type="number" class="s-color-picker__input" :class="ctx.sizeConfig.value?.input" :disabled="ctx.disabled.value || ctx.readonly.value" min="0" max="255" @blur="handleRgbInput" @keydown.enter="handleRgbInput" />
|
|
102
|
+
<span class="s-color-picker__input-label">B</span>
|
|
103
|
+
</div>
|
|
104
|
+
<div v-if="ctx.showAlpha.value" class="s-color-picker__input-field">
|
|
105
|
+
<input v-model.number="rgbInputs.a" type="number" class="s-color-picker__input" :class="ctx.sizeConfig.value?.input" :disabled="ctx.disabled.value || ctx.readonly.value" min="0" max="100" @blur="handleRgbInput" @keydown.enter="handleRgbInput" />
|
|
106
|
+
<span class="s-color-picker__input-label">A</span>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<!-- HSL Inputs -->
|
|
111
|
+
<div v-if="ctx.activeFormat.value === 'hsl'" class="s-color-picker__input-group s-color-picker__input-group--hsl">
|
|
112
|
+
<div class="s-color-picker__input-field">
|
|
113
|
+
<input v-model.number="hslInputs.h" type="number" class="s-color-picker__input" :class="ctx.sizeConfig.value?.input" :disabled="ctx.disabled.value || ctx.readonly.value" min="0" max="360" @blur="handleHslInput" @keydown.enter="handleHslInput" />
|
|
114
|
+
<span class="s-color-picker__input-label">H</span>
|
|
115
|
+
</div>
|
|
116
|
+
<div class="s-color-picker__input-field">
|
|
117
|
+
<input v-model.number="hslInputs.s" type="number" class="s-color-picker__input" :class="ctx.sizeConfig.value?.input" :disabled="ctx.disabled.value || ctx.readonly.value" min="0" max="100" @blur="handleHslInput" @keydown.enter="handleHslInput" />
|
|
118
|
+
<span class="s-color-picker__input-label">S</span>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="s-color-picker__input-field">
|
|
121
|
+
<input v-model.number="hslInputs.l" type="number" class="s-color-picker__input" :class="ctx.sizeConfig.value?.input" :disabled="ctx.disabled.value || ctx.readonly.value" min="0" max="100" @blur="handleHslInput" @keydown.enter="handleHslInput" />
|
|
122
|
+
<span class="s-color-picker__input-label">L</span>
|
|
123
|
+
</div>
|
|
124
|
+
<div v-if="ctx.showAlpha.value" class="s-color-picker__input-field">
|
|
125
|
+
<input v-model.number="hslInputs.a" type="number" class="s-color-picker__input" :class="ctx.sizeConfig.value?.input" :disabled="ctx.disabled.value || ctx.readonly.value" min="0" max="100" @blur="handleHslInput" @keydown.enter="handleHslInput" />
|
|
126
|
+
<span class="s-color-picker__input-label">A</span>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
</template>
|
|
131
|
+
|
|
132
|
+
<style scoped>
|
|
133
|
+
.s-color-picker__inputs {
|
|
134
|
+
display: flex;
|
|
135
|
+
gap: 0.5rem;
|
|
136
|
+
align-items: flex-start;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.s-color-picker__format-toggle {
|
|
140
|
+
flex-shrink: 0;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.s-color-picker__format-btn {
|
|
144
|
+
padding: 0.375rem 0.5rem;
|
|
145
|
+
border-radius: 0.375rem;
|
|
146
|
+
border: 1px solid var(--s-border);
|
|
147
|
+
background: var(--s-muted);
|
|
148
|
+
color: var(--s-muted-foreground);
|
|
149
|
+
font-weight: 600;
|
|
150
|
+
font-size: 0.625rem;
|
|
151
|
+
cursor: pointer;
|
|
152
|
+
transition: all 0.2s ease;
|
|
153
|
+
min-width: 2.5rem;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.s-color-picker__format-btn:hover {
|
|
157
|
+
background: var(--s-accent);
|
|
158
|
+
color: var(--s-foreground);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.s-color-picker__input-group {
|
|
162
|
+
display: flex;
|
|
163
|
+
gap: 0.375rem;
|
|
164
|
+
flex: 1;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.s-color-picker__input-group--hex .s-color-picker__input {
|
|
168
|
+
flex: 1;
|
|
169
|
+
font-family: ui-monospace, monospace;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.s-color-picker__input-field {
|
|
173
|
+
display: flex;
|
|
174
|
+
flex-direction: column;
|
|
175
|
+
gap: 0.125rem;
|
|
176
|
+
flex: 1;
|
|
177
|
+
min-width: 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.s-color-picker__input {
|
|
181
|
+
width: 100%;
|
|
182
|
+
padding: 0.375rem 0.5rem;
|
|
183
|
+
border-radius: 0.375rem;
|
|
184
|
+
border: 1px solid var(--s-border);
|
|
185
|
+
background: var(--s-muted);
|
|
186
|
+
color: var(--s-foreground);
|
|
187
|
+
text-align: center;
|
|
188
|
+
transition: all 0.2s ease;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.s-color-picker__input:focus {
|
|
192
|
+
outline: none;
|
|
193
|
+
border-color: var(--s-primary);
|
|
194
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--s-primary) 15%, transparent);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.s-color-picker__input::-webkit-inner-spin-button,
|
|
198
|
+
.s-color-picker__input::-webkit-outer-spin-button {
|
|
199
|
+
-webkit-appearance: none;
|
|
200
|
+
margin: 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.s-color-picker__input[type='number'] {
|
|
204
|
+
appearance: textfield;
|
|
205
|
+
-moz-appearance: textfield;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.s-color-picker__input-label {
|
|
209
|
+
font-size: 0.625rem;
|
|
210
|
+
font-weight: 600;
|
|
211
|
+
color: var(--s-muted-foreground);
|
|
212
|
+
text-align: center;
|
|
213
|
+
text-transform: uppercase;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@media (max-width: 400px) {
|
|
217
|
+
.s-color-picker__input-group--rgb,
|
|
218
|
+
.s-color-picker__input-group--hsl {
|
|
219
|
+
flex-wrap: wrap;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.s-color-picker__input-field {
|
|
223
|
+
min-width: calc(50% - 0.25rem);
|
|
224
|
+
flex: 1 1 calc(50% - 0.25rem);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
</style>
|