ropav 0.1.6 → 0.1.8
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 +7 -1
- package/dist/accordion.css +17 -17
- package/dist/accordion.js +123 -155
- package/dist/alert.css +18 -18
- package/dist/alert.js +10 -11
- package/dist/ancestry.js +136 -0
- package/dist/aria.js +14 -0
- package/dist/aspect-ratio.js +1 -1
- package/dist/attributes.js +9 -0
- package/dist/attributes2.js +29 -0
- package/dist/avatar.css +19 -19
- package/dist/avatar.js +9 -17
- package/dist/badge.css +16 -16
- package/dist/badge.js +5 -5
- package/dist/button-group.js +1 -1
- package/dist/button-link.js +4 -3
- package/dist/button.js +4 -3
- package/dist/button.scss_vue_type_style_index_0_src_true_lang.js +1 -1
- package/dist/calendar.css +173 -0
- package/dist/calendar.js +714 -0
- package/dist/calendar2.js +37 -0
- package/dist/card.js +1 -1
- package/dist/checkbox.css +32 -32
- package/dist/checkbox.js +22 -28
- package/dist/chevron-left.js +12 -0
- package/dist/collapse.css +6 -6
- package/dist/collapse.js +7 -6
- package/dist/collectionNavigation.js +2 -99
- package/dist/color-input.css +19 -19
- package/dist/color-input.js +14 -13
- package/dist/color-picker.css +40 -40
- package/dist/color-picker.js +247 -276
- package/dist/color-picker2.js +1 -9
- package/dist/color-swatch.css +4 -4
- package/dist/color-swatch.js +6 -8
- package/dist/color.js +5 -10
- package/dist/combobox.css +251 -0
- package/dist/combobox.js +410 -0
- package/dist/componentColors.js +125 -84
- package/dist/componentRef.js +26 -0
- package/dist/components/accordion/accordionContext.d.ts +3 -0
- package/dist/components/accordion/accordionModel.d.ts +14 -0
- package/dist/components/accordion/index.d.ts +2 -1
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/accordion/types.d.ts +1 -2
- package/dist/components/accordion/useAccordion.d.ts +2 -2
- package/dist/components/accordion/useAccordionItem.d.ts +2 -0
- package/dist/components/calendar/calendar.d.ts +30 -0
- package/dist/components/calendar/calendarBehavior.d.ts +49 -0
- package/dist/components/calendar/index.d.ts +3 -0
- package/dist/components/calendar/index.js +3 -0
- package/dist/components/calendar/types.d.ts +53 -0
- package/dist/components/calendar/useCalendar.d.ts +24 -0
- package/dist/components/checkbox/useCheckbox.d.ts +1 -2
- package/dist/components/color-picker/index.js +2 -2
- package/dist/components/color-picker/types.d.ts +2 -2
- package/dist/components/color-picker/useColorPickerDrag.d.ts +1 -1
- package/dist/components/color-picker/useColorPickerSaturation.d.ts +22 -0
- package/dist/components/color-picker/useColorPickerSlider.d.ts +20 -0
- package/dist/components/color-picker/useColorPickerValue.d.ts +1 -1
- package/dist/components/combobox/combobox.d.ts +29 -0
- package/dist/components/combobox/comboboxModel.d.ts +4 -0
- package/dist/components/combobox/index.d.ts +3 -0
- package/dist/components/combobox/index.js +2 -0
- package/dist/components/combobox/types.d.ts +43 -0
- package/dist/components/combobox/useCombobox.d.ts +45 -0
- package/dist/components/date-picker/date-picker.d.ts +33 -0
- package/dist/components/date-picker/datePickerModel.d.ts +10 -0
- package/dist/components/date-picker/index.d.ts +4 -0
- package/dist/components/date-picker/index.js +2 -0
- package/dist/components/date-picker/types.d.ts +57 -0
- package/dist/components/date-picker/useDatePicker.d.ts +29 -0
- package/dist/components/date-picker/useDatePickerValueState.d.ts +21 -0
- package/dist/components/dialog/{dialog-core.d.ts → dialogContext.d.ts} +1 -5
- package/dist/components/dialog/useDialogContentInteractions.d.ts +18 -0
- package/dist/components/dialog/useDialogRootState.d.ts +19 -0
- package/dist/components/dropdown-menu/dropdown-menu-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-item-row.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-items.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-model.d.ts +8 -0
- package/dist/components/dropdown-menu/dropdown-menu-root.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-trigger.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-sub.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +2 -2
- package/dist/components/dropdown-menu/{dropdown-menu-primitive-core.d.ts → dropdownMenuContext.d.ts} +17 -30
- package/dist/components/dropdown-menu/dropdownMenuDataModel.d.ts +20 -0
- package/dist/components/dropdown-menu/dropdownMenuInteraction.d.ts +3 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionNavigation.d.ts +24 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionRegistry.d.ts +42 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionTypes.d.ts +114 -0
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts +11 -11
- package/dist/components/dropdown-menu/useDropdownMenuContextTrigger.d.ts +9 -0
- package/dist/components/dropdown-menu/useDropdownMenuDataController.d.ts +35 -0
- package/dist/components/dropdown-menu/useDropdownMenuDataRegistration.d.ts +24 -0
- package/dist/components/dropdown-menu/useDropdownMenuHoverIntent.d.ts +6 -5
- package/dist/components/dropdown-menu/useDropdownMenuInteractionDismissal.d.ts +17 -0
- package/dist/components/dropdown-menu/useDropdownMenuInteractionKeyboard.d.ts +19 -0
- package/dist/components/dropdown-menu/useDropdownMenuPortalPosition.d.ts +0 -1
- package/dist/components/dropdown-menu/useDropdownMenuPresentation.d.ts +28 -0
- package/dist/components/dropdown-menu/useDropdownMenuPrimitiveContent.d.ts +2 -2
- package/dist/components/dropdown-menu/useDropdownMenuRenderItems.d.ts +1 -1
- package/dist/components/dropdown-menu/useDropdownMenuTargetBindings.d.ts +19 -0
- package/dist/components/dropzone/dropzone.d.ts +31 -0
- package/dist/components/dropzone/dropzoneModel.d.ts +16 -0
- package/dist/components/dropzone/index.d.ts +3 -0
- package/dist/components/dropzone/index.js +2 -0
- package/dist/components/dropzone/types.d.ts +56 -0
- package/dist/components/dropzone/useDropzone.d.ts +25 -0
- package/dist/components/file-input/file-input.d.ts +29 -0
- package/dist/components/file-input/index.d.ts +3 -0
- package/dist/components/file-input/index.js +2 -0
- package/dist/components/file-input/types.d.ts +37 -0
- package/dist/components/file-input/useFileInput.d.ts +15 -0
- package/dist/components/floating/index.js +2 -2
- package/dist/components/floating/useFloatingPosition.d.ts +1 -14
- package/dist/components/floating/useFloatingTargetLifecycle.d.ts +32 -0
- package/dist/components/floating/useHoverDisclosure.d.ts +10 -0
- package/dist/components/hover-card/hover-card.d.ts +25 -0
- package/dist/components/hover-card/index.d.ts +3 -0
- package/dist/components/hover-card/index.js +2 -0
- package/dist/components/hover-card/types.d.ts +45 -0
- package/dist/components/hover-card/useHoverCard.d.ts +22 -0
- package/dist/components/hover-card/useHoverCardDisclosure.d.ts +19 -0
- package/dist/components/multi-select/index.d.ts +3 -0
- package/dist/components/multi-select/index.js +2 -0
- package/dist/components/multi-select/multi-select.d.ts +30 -0
- package/dist/components/multi-select/multiSelectModel.d.ts +3 -0
- package/dist/components/multi-select/types.d.ts +49 -0
- package/dist/components/multi-select/useMultiSelect.d.ts +46 -0
- package/dist/components/number-input/numberInputModel.d.ts +15 -0
- package/dist/components/number-input/useNumberInput.d.ts +3 -19
- package/dist/components/pagination/index.d.ts +1 -1
- package/dist/components/pagination/index.js +1 -1
- package/dist/components/pagination/paginationModel.d.ts +4 -0
- package/dist/components/pagination/types.d.ts +15 -0
- package/dist/components/pagination/usePagination.d.ts +3 -19
- package/dist/components/popover/usePopoverBindings.d.ts +13 -0
- package/dist/components/progress/progressModel.d.ts +8 -0
- package/dist/components/progress/useProgress.d.ts +0 -6
- package/dist/components/radio/useRadio.d.ts +1 -2
- package/dist/components/scroll-area/scroll-area.d.ts +1 -1
- package/dist/components/scroll-area/scrollAreaModel.d.ts +64 -0
- package/dist/components/scroll-area/useScrollArea.d.ts +70 -53
- package/dist/components/scroll-area/{useScrollAreaPresentation.d.ts → useScrollAreaAttributes.d.ts} +37 -17
- package/dist/components/scroll-area/useScrollAreaDerivedState.d.ts +8 -0
- package/dist/components/scroll-area/useScrollAreaMeasurement.d.ts +35 -0
- package/dist/components/scroll-area/useScrollAreaPointer.d.ts +11 -9
- package/dist/components/scroll-area/useScrollAreaVisibility.d.ts +15 -20
- package/dist/components/segmented-control/index.d.ts +3 -0
- package/dist/components/segmented-control/index.js +2 -0
- package/dist/components/segmented-control/segmented-control.d.ts +26 -0
- package/dist/components/segmented-control/types.d.ts +47 -0
- package/dist/components/segmented-control/useSegmentedControl.d.ts +15 -0
- package/dist/components/select/useSelect.d.ts +31 -19
- package/dist/components/slider/rangeSliderModel.d.ts +41 -0
- package/dist/components/slider/{sliderCore.d.ts → sliderModel.d.ts} +0 -1
- package/dist/components/slider/useRangeSlider.d.ts +9 -17
- package/dist/components/slider/useRangeSliderPointer.d.ts +1 -1
- package/dist/components/slider/useRangeSliderValueState.d.ts +40 -0
- package/dist/components/slider/useSlider.d.ts +7 -13
- package/dist/components/slider/useSliderPointerPreview.d.ts +22 -0
- package/dist/components/slider/useSliderTooltipState.d.ts +40 -0
- package/dist/components/slider/useSliderValueState.d.ts +33 -0
- package/dist/components/tags-input/index.d.ts +3 -0
- package/dist/components/tags-input/index.js +2 -0
- package/dist/components/tags-input/tags-input.d.ts +27 -0
- package/dist/components/tags-input/tagsInputModel.d.ts +12 -0
- package/dist/components/tags-input/types.d.ts +37 -0
- package/dist/components/tags-input/useTagsInput.d.ts +23 -0
- package/dist/components/teleport-provider/index.js +1 -1
- package/dist/components/teleport-provider/useTeleportTarget.d.ts +1 -2
- package/dist/components/toast/useToastLifecycle.d.ts +19 -0
- package/dist/components/tooltip/useTooltip.d.ts +1 -2
- package/dist/components/tooltip/useTooltipTargetBindings.d.ts +12 -0
- package/dist/css.js +12 -0
- package/dist/date-picker.css +49 -0
- package/dist/date-picker.js +809 -0
- package/dist/dialog.js +215 -218
- package/dist/direction.js +6 -0
- package/dist/dropdown-menu.css +21 -3
- package/dist/dropdown-menu.js +1626 -1185
- package/dist/dropzone.css +135 -0
- package/dist/dropzone.js +431 -0
- package/dist/events.js +59 -0
- package/dist/field.css +8 -8
- package/dist/field.js +13 -25
- package/dist/file-input.css +135 -0
- package/dist/file-input.js +198 -0
- package/dist/floatingOffset.js +11 -0
- package/dist/focus-trap.js +7 -5
- package/dist/focusNavigation.js +37 -0
- package/dist/hover-card.css +80 -0
- package/dist/hover-card.js +402 -0
- package/dist/icon-button.css +8 -8
- package/dist/icon-button.js +7 -6
- package/dist/index.d.ts +9 -0
- package/dist/index.js +20 -9
- package/dist/input.css +24 -24
- package/dist/input.js +19 -31
- package/dist/interactive.js +18 -0
- package/dist/internal/composables/useOverlayLayer.d.ts +12 -0
- package/dist/modal.js +2 -2
- package/dist/multi-select.css +316 -0
- package/dist/multi-select.js +481 -0
- package/dist/nativeChoice.js +169 -0
- package/dist/number-input.css +18 -18
- package/dist/number-input.js +44 -44
- package/dist/number.js +22 -0
- package/dist/overlay.js +3 -2
- package/dist/pagination.css +28 -28
- package/dist/pagination.js +66 -73
- package/dist/pointerSession.js +130 -0
- package/dist/popover.css +55 -37
- package/dist/popover.js +75 -101
- package/dist/progress.js +10 -13
- package/dist/query.js +40 -0
- package/dist/radio.css +18 -18
- package/dist/radio.js +30 -36
- package/dist/rafScheduler.js +34 -0
- package/dist/scroll-area.css +28 -28
- package/dist/scroll-area.js +540 -554
- package/dist/segmented-control.css +176 -0
- package/dist/segmented-control.js +382 -0
- package/dist/select.css +50 -48
- package/dist/select.js +131 -289
- package/dist/slider.css +191 -191
- package/dist/slider.js +720 -706
- package/dist/styles-api.d.ts +0 -1
- package/dist/styles-api.js +1 -4
- package/dist/switch.css +17 -17
- package/dist/switch.js +14 -15
- package/dist/tabs.css +43 -43
- package/dist/tabs.js +29 -56
- package/dist/tags-input.css +197 -0
- package/dist/tags-input.js +380 -0
- package/dist/text.js +17 -0
- package/dist/textarea.css +26 -26
- package/dist/textarea.js +21 -32
- package/dist/toast.css +26 -26
- package/dist/toast.js +141 -118
- package/dist/tooltip.css +12 -12
- package/dist/tooltip.js +64 -63
- package/dist/useCollapse.js +8 -11
- package/dist/useControlState.js +3 -6
- package/dist/useEditableOptionList.js +216 -0
- package/dist/useFlatOptionCollection.js +134 -0
- package/dist/useFloatingPosition.js +14 -40
- package/dist/useFloatingTargetLifecycle.js +127 -0
- package/dist/useFormControl.js +1 -0
- package/dist/useHoverDisclosure.js +561 -0
- package/dist/useNativeChoiceTransaction.js +46 -0
- package/dist/useNativeFileSelection.js +86 -0
- package/dist/useOverlayZIndex.js +246 -19
- package/dist/useTeleportTarget.js +3 -14
- package/dist/useTypeahead.js +94 -0
- package/dist/utils/aria.d.ts +3 -0
- package/dist/utils/attributes.d.ts +2 -0
- package/dist/utils/bem.d.ts +3 -0
- package/dist/utils/collectionNavigation.d.ts +2 -0
- package/dist/utils/color.d.ts +7 -0
- package/dist/{components/color-picker/color-picker-utils.d.ts → utils/colorPicker.d.ts} +5 -4
- package/dist/utils/componentColors.d.ts +7 -0
- package/dist/utils/css.d.ts +3 -0
- package/dist/utils/date.d.ts +13 -0
- package/dist/utils/dateAvailability.d.ts +7 -0
- package/dist/utils/dom/ancestry.d.ts +8 -0
- package/dist/utils/dom/attributes.d.ts +16 -0
- package/dist/utils/dom/componentRef.d.ts +4 -0
- package/dist/utils/dom/direction.d.ts +2 -0
- package/dist/utils/dom/events.d.ts +5 -0
- package/dist/utils/dom/files.d.ts +3 -0
- package/dist/utils/dom/focusNavigation.d.ts +7 -0
- package/dist/utils/dom/interactive.d.ts +2 -0
- package/dist/utils/dom/nativeChoice.d.ts +17 -0
- package/dist/utils/dom/pointerSession.d.ts +20 -0
- package/dist/utils/dom/query.d.ts +4 -0
- package/dist/utils/dom/scroll.d.ts +24 -0
- package/dist/utils/floatingOffset.d.ts +10 -0
- package/dist/utils/geometry.d.ts +14 -0
- package/dist/utils/indexPath.d.ts +6 -0
- package/dist/utils/number.d.ts +4 -0
- package/dist/utils/optionFilter.d.ts +5 -0
- package/dist/utils/rafScheduler.d.ts +4 -0
- package/dist/utils/text.d.ts +2 -0
- package/docs/code-architecture.md +118 -0
- package/docs/public-floating-api.md +13 -9
- package/docs/public-styles-api.md +25 -12
- package/package.json +51 -14
- package/src/styles/_mixins.scss +26 -0
- package/src/styles/styles-manifest.json +1 -2
- package/dist/components/dropdown-menu/dropdown-menu-outside.d.ts +0 -3
- package/dist/components/dropdown-menu/dropdown-menu-utils.d.ts +0 -21
- package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +0 -36
- package/dist/components/dropdown-menu/useDropdownMenuDom.d.ts +0 -29
- package/dist/components/dropdown-menu/useDropdownMenuInteractions.d.ts +0 -52
- package/dist/components/dropdown-menu/useDropdownMenuNavigation.d.ts +0 -17
- package/dist/components/dropdown-menu/useDropdownSubmenus.d.ts +0 -18
- package/dist/components/scroll-area/scrollAreaCore.d.ts +0 -30
- package/dist/components/scroll-area/useScrollAreaControls.d.ts +0 -25
- package/dist/components/scroll-area/useScrollAreaMetrics.d.ts +0 -38
- package/dist/components/select/useSelectNativeControl.d.ts +0 -9
- package/dist/components/select/useSelectNativeValue.d.ts +0 -9
- package/dist/floating.js +0 -415
- /package/dist/components/alert/{useAlertColor.d.ts → alertColor.d.ts} +0 -0
- /package/dist/components/avatar/{useAvatarColor.d.ts → avatarColor.d.ts} +0 -0
- /package/dist/components/badge/{useBadgeColor.d.ts → badgeColor.d.ts} +0 -0
- /package/dist/components/button/{useButtonColor.d.ts → buttonColor.d.ts} +0 -0
- /package/dist/components/color-swatch/{useColorSwatchColor.d.ts → colorSwatchColor.d.ts} +0 -0
- /package/dist/components/toast/{useToastColor.d.ts → toastColor.d.ts} +0 -0
package/dist/color-picker.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import './color-picker.css';
|
|
2
|
-
import {
|
|
2
|
+
import { t as useStylesApi } from "./styles-api.js";
|
|
3
|
+
import { n as toPresenceAttribute } from "./attributes.js";
|
|
3
4
|
import { t as bem } from "./bem.js";
|
|
4
5
|
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
|
|
6
|
+
import { i as roundTo, t as clamp } from "./number.js";
|
|
5
7
|
import { t as parseCssColor } from "./color.js";
|
|
6
8
|
import { t as check_default } from "./check.js";
|
|
7
9
|
import { t as color_swatch_default } from "./color-swatch.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
10
|
+
import { n as toHTMLElement } from "./componentRef.js";
|
|
11
|
+
import { t as createPointerSession } from "./pointerSession.js";
|
|
12
|
+
import { i as isNodeWithinElement } from "./events.js";
|
|
13
|
+
import { child, computed, createComponent, createFor, createIf, createSlot, createTemplateRefSetter, defineVaporComponent, extend, next, nthChild, on, onBeforeUnmount, ref, renderEffect, setAttr, setClass, setDynamicProps, setInsertionState, setProp, setStyle, setTemplateRefBinding, setValue, template, unref } from "vue";
|
|
14
|
+
//#region src/utils/colorPicker.ts
|
|
15
|
+
var colorPickerFormats = [
|
|
16
|
+
"hex",
|
|
17
|
+
"hexa",
|
|
18
|
+
"rgb",
|
|
19
|
+
"rgba",
|
|
20
|
+
"hsl",
|
|
21
|
+
"hsla"
|
|
22
|
+
];
|
|
12
23
|
function clampPercent(value) {
|
|
13
24
|
return clamp(Number.isFinite(value) ? value : 0, 0, 100);
|
|
14
25
|
}
|
|
@@ -27,7 +38,18 @@ function clampOpacity(value) {
|
|
|
27
38
|
return clamp(Number.isFinite(value) ? value : 100, 0, 100);
|
|
28
39
|
}
|
|
29
40
|
function roundPercent(value) {
|
|
30
|
-
return
|
|
41
|
+
return roundTo(value);
|
|
42
|
+
}
|
|
43
|
+
function getColorPickerKeyboardValue(key, currentValue, maxValue, step = 1) {
|
|
44
|
+
switch (key) {
|
|
45
|
+
case "ArrowRight":
|
|
46
|
+
case "ArrowUp": return currentValue + step;
|
|
47
|
+
case "ArrowLeft":
|
|
48
|
+
case "ArrowDown": return currentValue - step;
|
|
49
|
+
case "Home": return 0;
|
|
50
|
+
case "End": return maxValue;
|
|
51
|
+
default: return;
|
|
52
|
+
}
|
|
31
53
|
}
|
|
32
54
|
function isColorPickerAlphaFormat(format) {
|
|
33
55
|
return format === "hexa" || format === "rgba" || format === "hsla";
|
|
@@ -142,127 +164,129 @@ function formatAlpha(opacity) {
|
|
|
142
164
|
return formatNumber(clampOpacity(opacity) / 100);
|
|
143
165
|
}
|
|
144
166
|
function formatNumber(value) {
|
|
145
|
-
return String(
|
|
167
|
+
return String(roundTo(value));
|
|
146
168
|
}
|
|
147
169
|
//#endregion
|
|
148
170
|
//#region src/components/color-picker/useColorPickerDrag.ts
|
|
149
|
-
function getPointerId(event) {
|
|
150
|
-
return Number.isFinite(event.pointerId) ? event.pointerId : void 0;
|
|
151
|
-
}
|
|
152
171
|
function useColorPickerDrag({ target, focusTarget, readonly, isGeometryValid, updateFromPointer }) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const currentSession = session;
|
|
160
|
-
if (!currentSession) return false;
|
|
161
|
-
const pointerId = getPointerId(event);
|
|
162
|
-
return currentSession.pointerId === void 0 || pointerId === currentSession.pointerId;
|
|
163
|
-
}
|
|
164
|
-
function cancelScheduledFrame() {
|
|
165
|
-
if (frameId !== void 0) frameWindow?.cancelAnimationFrame(frameId);
|
|
166
|
-
frameWindow = null;
|
|
167
|
-
frameId = void 0;
|
|
168
|
-
}
|
|
169
|
-
function applyScheduledUpdate(currentSession) {
|
|
170
|
-
if (session !== currentSession) return;
|
|
171
|
-
if (geometryDirty) {
|
|
172
|
-
const rect = currentSession.element.getBoundingClientRect();
|
|
173
|
-
if (!isGeometryValid(rect)) return;
|
|
174
|
-
currentSession.rect = rect;
|
|
175
|
-
geometryDirty = false;
|
|
176
|
-
}
|
|
177
|
-
const pointer = pendingPointer;
|
|
178
|
-
pendingPointer = void 0;
|
|
179
|
-
if (pointer) updateFromPointer(pointer, currentSession.rect);
|
|
180
|
-
}
|
|
181
|
-
function flushScheduledUpdate() {
|
|
182
|
-
const currentSession = session;
|
|
183
|
-
cancelScheduledFrame();
|
|
184
|
-
if (currentSession) applyScheduledUpdate(currentSession);
|
|
185
|
-
}
|
|
186
|
-
function scheduleUpdate() {
|
|
187
|
-
const currentSession = session;
|
|
188
|
-
if (!currentSession) return;
|
|
189
|
-
const view = currentSession.view;
|
|
190
|
-
if (!view?.requestAnimationFrame) {
|
|
191
|
-
applyScheduledUpdate(currentSession);
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
if (frameId !== void 0) return;
|
|
195
|
-
frameWindow = view;
|
|
196
|
-
frameId = view.requestAnimationFrame(() => {
|
|
197
|
-
frameWindow = null;
|
|
198
|
-
frameId = void 0;
|
|
199
|
-
applyScheduledUpdate(currentSession);
|
|
200
|
-
});
|
|
172
|
+
function refreshGeometry(currentSession) {
|
|
173
|
+
const rect = currentSession.element.getBoundingClientRect();
|
|
174
|
+
if (!isGeometryValid(rect)) return false;
|
|
175
|
+
currentSession.geometryValid = true;
|
|
176
|
+
currentSession.rect = rect;
|
|
177
|
+
return true;
|
|
201
178
|
}
|
|
202
|
-
function
|
|
203
|
-
|
|
204
|
-
geometryDirty = true;
|
|
205
|
-
scheduleUpdate();
|
|
206
|
-
}
|
|
207
|
-
function stopDragging() {
|
|
208
|
-
const stoppedSession = session;
|
|
209
|
-
if (!stoppedSession) return;
|
|
210
|
-
stoppedSession.view?.removeEventListener("pointermove", onPointerMove);
|
|
211
|
-
stoppedSession.view?.removeEventListener("pointerup", onPointerEnd);
|
|
212
|
-
stoppedSession.view?.removeEventListener("pointercancel", onPointerEnd);
|
|
213
|
-
stoppedSession.view?.removeEventListener("resize", onGeometryChange);
|
|
214
|
-
stoppedSession.view?.removeEventListener("scroll", onGeometryChange, true);
|
|
215
|
-
cancelScheduledFrame();
|
|
216
|
-
geometryDirty = false;
|
|
217
|
-
pendingPointer = void 0;
|
|
218
|
-
session = void 0;
|
|
219
|
-
}
|
|
220
|
-
function onPointerMove(event) {
|
|
221
|
-
if (!isCurrentPointer(event)) return;
|
|
222
|
-
pendingPointer = {
|
|
179
|
+
function applyPointer(event, currentSession) {
|
|
180
|
+
updateFromPointer({
|
|
223
181
|
clientX: event.clientX,
|
|
224
182
|
clientY: event.clientY
|
|
183
|
+
}, currentSession.rect);
|
|
184
|
+
}
|
|
185
|
+
const pointerSession = createPointerSession({
|
|
186
|
+
onStart(event, currentSession) {
|
|
187
|
+
if (currentSession.geometryValid) applyPointer(event, currentSession);
|
|
188
|
+
},
|
|
189
|
+
onUpdate: applyPointer,
|
|
190
|
+
refreshGeometry
|
|
191
|
+
});
|
|
192
|
+
function onPointerDown(event) {
|
|
193
|
+
return pointerSession.start(event, () => {
|
|
194
|
+
if (readonly()) return;
|
|
195
|
+
const element = target.value;
|
|
196
|
+
if (!element) return;
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
(focusTarget?.value ?? element).focus();
|
|
199
|
+
const rect = element.getBoundingClientRect();
|
|
200
|
+
const geometryValid = isGeometryValid(rect);
|
|
201
|
+
return {
|
|
202
|
+
geometryDirty: !geometryValid,
|
|
203
|
+
state: {
|
|
204
|
+
element,
|
|
205
|
+
geometryValid,
|
|
206
|
+
rect
|
|
207
|
+
},
|
|
208
|
+
target: element
|
|
209
|
+
};
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
onBeforeUnmount(pointerSession.stop);
|
|
213
|
+
return { onPointerDown };
|
|
214
|
+
}
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/components/color-picker/useColorPickerSaturation.ts
|
|
217
|
+
function useColorPickerSaturation({ modelValue, hue, readonly, onChange }) {
|
|
218
|
+
const saturationRef = ref(null);
|
|
219
|
+
const saturationInputRef = ref(null);
|
|
220
|
+
const selection = computed(() => {
|
|
221
|
+
const currentSelection = modelValue();
|
|
222
|
+
return {
|
|
223
|
+
saturation: clampPercent(currentSelection.saturation),
|
|
224
|
+
value: clampPercent(currentSelection.value)
|
|
225
225
|
};
|
|
226
|
-
|
|
226
|
+
});
|
|
227
|
+
const normalizedHue = computed(() => normalizeHue(hue()));
|
|
228
|
+
function setSaturationElement(value) {
|
|
229
|
+
saturationRef.value = toHTMLElement(value);
|
|
227
230
|
}
|
|
228
|
-
function
|
|
229
|
-
|
|
230
|
-
if (event.type === "pointerup") flushScheduledUpdate();
|
|
231
|
-
stopDragging();
|
|
231
|
+
function setSaturationInput(value) {
|
|
232
|
+
saturationInputRef.value = toHTMLElement(value);
|
|
232
233
|
}
|
|
233
|
-
function
|
|
234
|
-
if (readonly()
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
(focusTarget?.value ?? el).focus();
|
|
239
|
-
stopDragging();
|
|
240
|
-
const nextSession = {
|
|
241
|
-
element: el,
|
|
242
|
-
pointerId: getPointerId(event),
|
|
243
|
-
rect: el.getBoundingClientRect(),
|
|
244
|
-
view: el.ownerDocument.defaultView
|
|
234
|
+
function commitSelection(nextSaturation, nextValue) {
|
|
235
|
+
if (readonly()) return;
|
|
236
|
+
const nextSelection = {
|
|
237
|
+
saturation: roundPercent(clampPercent(nextSaturation)),
|
|
238
|
+
value: roundPercent(clampPercent(nextValue))
|
|
245
239
|
};
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
240
|
+
if (nextSelection.saturation === selection.value.saturation && nextSelection.value === selection.value.value) return;
|
|
241
|
+
onChange(nextSelection);
|
|
242
|
+
}
|
|
243
|
+
function updateAxis(axis, nextValue) {
|
|
244
|
+
if (axis === "saturation") {
|
|
245
|
+
commitSelection(nextValue, selection.value.value);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
commitSelection(selection.value.saturation, nextValue);
|
|
249
|
+
}
|
|
250
|
+
function onAxisKeydown(event, axis) {
|
|
251
|
+
const currentValue = axis === "saturation" ? selection.value.saturation : selection.value.value;
|
|
252
|
+
const nextValue = getColorPickerKeyboardValue(event.key, currentValue, 100, event.shiftKey ? 10 : void 0);
|
|
253
|
+
if (nextValue === void 0) return;
|
|
254
|
+
event.preventDefault();
|
|
255
|
+
if (!readonly()) updateAxis(axis, nextValue);
|
|
256
|
+
}
|
|
257
|
+
function onAxisInput(event, axis) {
|
|
258
|
+
const input = event.currentTarget;
|
|
259
|
+
if (!(input instanceof HTMLInputElement)) return;
|
|
260
|
+
if (readonly()) {
|
|
261
|
+
input.value = String(axis === "saturation" ? selection.value.saturation : selection.value.value);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
updateAxis(axis, Number(input.value));
|
|
265
|
+
}
|
|
266
|
+
function updateFromTwoDimensionalPointer(pointer, rect) {
|
|
267
|
+
if (rect.width <= 0 || rect.height <= 0) return;
|
|
268
|
+
commitSelection((pointer.clientX - rect.left) / rect.width * 100, 100 - (pointer.clientY - rect.top) / rect.height * 100);
|
|
269
|
+
}
|
|
270
|
+
const { onPointerDown } = useColorPickerDrag({
|
|
271
|
+
target: saturationRef,
|
|
272
|
+
focusTarget: saturationInputRef,
|
|
273
|
+
readonly,
|
|
274
|
+
isGeometryValid: (rect) => rect.width > 0 && rect.height > 0,
|
|
275
|
+
updateFromPointer: updateFromTwoDimensionalPointer
|
|
276
|
+
});
|
|
277
|
+
return {
|
|
278
|
+
setSaturationElement,
|
|
279
|
+
setSaturationInput,
|
|
280
|
+
selection,
|
|
281
|
+
normalizedHue,
|
|
282
|
+
onPointerDown,
|
|
283
|
+
onAxisKeydown,
|
|
284
|
+
onAxisInput
|
|
285
|
+
};
|
|
261
286
|
}
|
|
262
287
|
//#endregion
|
|
263
288
|
//#region src/components/color-picker/color-picker-saturation.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
264
|
-
var t0$2 = template("<div data-v-
|
|
265
|
-
delegateEvents("input", "keydown", "pointerdown");
|
|
289
|
+
var t0$2 = template("<div data-v-9c7fa05b role=group data-control=saturation><input data-v-9c7fa05b class=\"rp-color-picker__axis-input rp-color-picker__axis-input--saturation\"type=range min=0 max=100 step=1 aria-label=Saturation aria-orientation=horizontal><input data-v-9c7fa05b class=\"rp-color-picker__axis-input rp-color-picker__axis-input--value\"type=range min=0 max=100 step=1 aria-label=Value aria-orientation=vertical><span data-v-9c7fa05b class=rp-color-picker__surface aria-hidden=true></span><span data-v-9c7fa05b data-control=saturation aria-hidden=true>", 1);
|
|
266
290
|
//#endregion
|
|
267
291
|
//#region src/components/color-picker/color-picker-saturation.vue
|
|
268
292
|
var color_picker_saturation_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -312,124 +336,115 @@ var color_picker_saturation_default = /*#__PURE__*/ _plugin_vue_export_helper_de
|
|
|
312
336
|
setup(__props, { emit: __emit }) {
|
|
313
337
|
const props = __props;
|
|
314
338
|
const emit = __emit;
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
339
|
+
const { setSaturationElement, setSaturationInput, selection, normalizedHue, onPointerDown, onAxisKeydown, onAxisInput } = useColorPickerSaturation({
|
|
340
|
+
modelValue: () => props.modelValue,
|
|
341
|
+
hue: () => props.hue,
|
|
342
|
+
readonly: () => props.readonly,
|
|
343
|
+
onChange: (nextSelection) => emit("update:modelValue", nextSelection)
|
|
344
|
+
});
|
|
320
345
|
const saturationStyle = computed(() => ({
|
|
321
|
-
"--_rp-color-picker-hue": String(normalizeHueForColor(
|
|
322
|
-
"--_rp-color-picker-saturation-x": `${
|
|
323
|
-
"--_rp-color-picker-saturation-y": `${100 - value.value}%`,
|
|
324
|
-
"--_rp-color-picker-current": getHsvCssColor(
|
|
346
|
+
"--_rp-color-picker-hue": String(normalizeHueForColor(normalizedHue.value)),
|
|
347
|
+
"--_rp-color-picker-saturation-x": `${selection.value.saturation}%`,
|
|
348
|
+
"--_rp-color-picker-saturation-y": `${100 - selection.value.value}%`,
|
|
349
|
+
"--_rp-color-picker-current": getHsvCssColor(normalizedHue.value, selection.value.saturation, selection.value.value)
|
|
325
350
|
}));
|
|
326
|
-
const ariaValueText = computed(() => `${Math.round(
|
|
351
|
+
const ariaValueText = computed(() => `${Math.round(selection.value.saturation)}% saturation, ${Math.round(selection.value.value)}% value`);
|
|
327
352
|
const groupAriaLabel = computed(() => props.labelledby ? void 0 : props.ariaLabel || "Color area");
|
|
328
|
-
function updateValue(nextSaturation, nextValue) {
|
|
329
|
-
if (props.readonly) return;
|
|
330
|
-
const normalizedSaturation = roundPercent(clampPercent(nextSaturation));
|
|
331
|
-
const normalizedValue = roundPercent(clampPercent(nextValue));
|
|
332
|
-
if (normalizedSaturation === saturation.value && normalizedValue === value.value) return;
|
|
333
|
-
emit("update:modelValue", {
|
|
334
|
-
saturation: normalizedSaturation,
|
|
335
|
-
value: normalizedValue
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
function updateFromPointer(e, rect) {
|
|
339
|
-
if (rect.width <= 0 || rect.height <= 0) return;
|
|
340
|
-
updateValue((e.clientX - rect.left) / rect.width * 100, 100 - (e.clientY - rect.top) / rect.height * 100);
|
|
341
|
-
}
|
|
342
|
-
const { onPointerDown } = useColorPickerDrag({
|
|
343
|
-
target: saturationRef,
|
|
344
|
-
focusTarget: saturationInputRef,
|
|
345
|
-
readonly: () => props.readonly,
|
|
346
|
-
isGeometryValid: (rect) => rect.width > 0 && rect.height > 0,
|
|
347
|
-
updateFromPointer
|
|
348
|
-
});
|
|
349
|
-
function onAxisKeydown(event, axis) {
|
|
350
|
-
const currentValue = axis === "saturation" ? saturation.value : value.value;
|
|
351
|
-
const step = event.shiftKey ? 10 : 1;
|
|
352
|
-
let nextValue;
|
|
353
|
-
switch (event.key) {
|
|
354
|
-
case "ArrowRight":
|
|
355
|
-
case "ArrowUp":
|
|
356
|
-
nextValue = currentValue + step;
|
|
357
|
-
break;
|
|
358
|
-
case "ArrowLeft":
|
|
359
|
-
case "ArrowDown":
|
|
360
|
-
nextValue = currentValue - step;
|
|
361
|
-
break;
|
|
362
|
-
case "Home":
|
|
363
|
-
nextValue = 0;
|
|
364
|
-
break;
|
|
365
|
-
case "End":
|
|
366
|
-
nextValue = 100;
|
|
367
|
-
break;
|
|
368
|
-
}
|
|
369
|
-
if (nextValue === void 0) return;
|
|
370
|
-
event.preventDefault();
|
|
371
|
-
if (!props.readonly) updateAxis(axis, nextValue);
|
|
372
|
-
}
|
|
373
|
-
function onAxisInput(event, axis) {
|
|
374
|
-
const input = event.currentTarget;
|
|
375
|
-
if (!(input instanceof HTMLInputElement)) return;
|
|
376
|
-
if (props.readonly) {
|
|
377
|
-
input.value = String(axis === "saturation" ? saturation.value : value.value);
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
updateAxis(axis, Number(input.value));
|
|
381
|
-
}
|
|
382
|
-
function updateAxis(axis, nextValue) {
|
|
383
|
-
if (axis === "saturation") updateValue(nextValue, value.value);
|
|
384
|
-
else updateValue(saturation.value, nextValue);
|
|
385
|
-
}
|
|
386
353
|
const _setTemplateRef = createTemplateRefSetter();
|
|
387
354
|
const n3 = t0$2();
|
|
388
355
|
const n0 = child(n3);
|
|
389
356
|
const n1 = next(n0, 1);
|
|
390
357
|
const n2 = nthChild(n3, 3);
|
|
391
|
-
n0
|
|
392
|
-
n0
|
|
393
|
-
|
|
394
|
-
n1
|
|
395
|
-
|
|
396
|
-
n3.$evtpointerdown = createInvoker((e) => unref(onPointerDown)(e));
|
|
397
|
-
_setTemplateRef(n3, saturationRef, null, "saturationRef");
|
|
358
|
+
on(n0, "input", ($event) => unref(onAxisInput)($event, "saturation"));
|
|
359
|
+
on(n0, "keydown", ($event) => unref(onAxisKeydown)($event, "saturation"));
|
|
360
|
+
on(n1, "input", ($event) => unref(onAxisInput)($event, "value"));
|
|
361
|
+
on(n1, "keydown", ($event) => unref(onAxisKeydown)($event, "value"));
|
|
362
|
+
on(n3, "pointerdown", (e) => unref(onPointerDown)(e));
|
|
398
363
|
renderEffect(() => {
|
|
399
364
|
const _describedby = __props.describedby;
|
|
400
365
|
const _readonly = __props.readonly;
|
|
401
366
|
const _id = __props.id;
|
|
402
|
-
const
|
|
367
|
+
const _selection = unref(selection);
|
|
403
368
|
const _ariaValueText = ariaValueText.value;
|
|
404
|
-
const _value = value.value;
|
|
405
369
|
setClass(n3, ["rp-color-picker__saturation", __props.controlClass]);
|
|
406
370
|
setStyle(n3, [saturationStyle.value, __props.controlStyle]);
|
|
407
371
|
setAttr(n3, "aria-label", groupAriaLabel.value);
|
|
408
372
|
setAttr(n3, "aria-labelledby", __props.labelledby);
|
|
409
373
|
setAttr(n3, "aria-describedby", _describedby);
|
|
410
|
-
setAttr(n3, "data-readonly", unref(
|
|
374
|
+
setAttr(n3, "data-readonly", unref(toPresenceAttribute)(_readonly));
|
|
411
375
|
setProp(n0, "id", _id);
|
|
412
|
-
setValue(n0,
|
|
413
|
-
setAttr(n0, "aria-valuenow", Math.round(
|
|
376
|
+
setValue(n0, _selection.saturation);
|
|
377
|
+
setAttr(n0, "aria-valuenow", Math.round(_selection.saturation));
|
|
414
378
|
setAttr(n0, "aria-valuetext", _ariaValueText);
|
|
415
379
|
setAttr(n0, "aria-describedby", _describedby);
|
|
416
380
|
setAttr(n0, "aria-readonly", _readonly || void 0);
|
|
381
|
+
_setTemplateRef(n0, setSaturationInput, null, "setSaturationInput");
|
|
417
382
|
setProp(n1, "id", _id ? `${_id}-value` : void 0);
|
|
418
|
-
setValue(n1,
|
|
419
|
-
setAttr(n1, "aria-valuenow", Math.round(
|
|
383
|
+
setValue(n1, _selection.value);
|
|
384
|
+
setAttr(n1, "aria-valuenow", Math.round(_selection.value));
|
|
420
385
|
setAttr(n1, "aria-valuetext", _ariaValueText);
|
|
421
386
|
setAttr(n1, "aria-describedby", _describedby);
|
|
422
387
|
setAttr(n1, "aria-readonly", _readonly || void 0);
|
|
423
388
|
setClass(n2, ["rp-color-picker__handle", __props.handleClass]);
|
|
424
389
|
setStyle(n2, __props.handleStyle);
|
|
390
|
+
_setTemplateRef(n3, setSaturationElement, null, "setSaturationElement");
|
|
425
391
|
});
|
|
426
392
|
return n3;
|
|
427
393
|
}
|
|
428
|
-
}), [["__scopeId", "data-v-
|
|
394
|
+
}), [["__scopeId", "data-v-9c7fa05b"]]);
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/components/color-picker/useColorPickerSlider.ts
|
|
397
|
+
function useColorPickerSlider({ variant, value, readonly, onChange }) {
|
|
398
|
+
const sliderRef = ref(null);
|
|
399
|
+
const sliderState = computed(() => {
|
|
400
|
+
const isHue = variant() === "hue";
|
|
401
|
+
const normalizedValue = isHue ? normalizeHue(value()) : clampOpacity(value());
|
|
402
|
+
return {
|
|
403
|
+
isHue,
|
|
404
|
+
max: isHue ? 359 : 100,
|
|
405
|
+
value: normalizedValue,
|
|
406
|
+
outputValue: normalizeOutputValue(normalizedValue, isHue)
|
|
407
|
+
};
|
|
408
|
+
});
|
|
409
|
+
function setSliderElement(element) {
|
|
410
|
+
sliderRef.value = toHTMLElement(element);
|
|
411
|
+
}
|
|
412
|
+
function commitValue(nextValue) {
|
|
413
|
+
if (readonly()) return;
|
|
414
|
+
const normalizedNextValue = normalizeOutputValue(nextValue, sliderState.value.isHue);
|
|
415
|
+
if (normalizedNextValue === sliderState.value.outputValue) return;
|
|
416
|
+
onChange(normalizedNextValue);
|
|
417
|
+
}
|
|
418
|
+
function updateFromHorizontalPointer(pointer, rect) {
|
|
419
|
+
if (rect.width <= 0) return;
|
|
420
|
+
commitValue((pointer.clientX - rect.left) / rect.width * sliderState.value.max);
|
|
421
|
+
}
|
|
422
|
+
const { onPointerDown } = useColorPickerDrag({
|
|
423
|
+
target: sliderRef,
|
|
424
|
+
readonly,
|
|
425
|
+
isGeometryValid: (rect) => rect.width > 0,
|
|
426
|
+
updateFromPointer: updateFromHorizontalPointer
|
|
427
|
+
});
|
|
428
|
+
function onKeydown(event) {
|
|
429
|
+
if (readonly()) return;
|
|
430
|
+
const nextValue = getColorPickerKeyboardValue(event.key, sliderState.value.value, sliderState.value.max, event.shiftKey ? 10 : void 0);
|
|
431
|
+
if (nextValue === void 0) return;
|
|
432
|
+
event.preventDefault();
|
|
433
|
+
commitValue(nextValue);
|
|
434
|
+
}
|
|
435
|
+
return {
|
|
436
|
+
setSliderElement,
|
|
437
|
+
sliderState,
|
|
438
|
+
onPointerDown,
|
|
439
|
+
onKeydown
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
function normalizeOutputValue(nextValue, isHue) {
|
|
443
|
+
return isHue ? Math.round(clampHue(nextValue)) : roundPercent(clampOpacity(nextValue));
|
|
444
|
+
}
|
|
429
445
|
//#endregion
|
|
430
446
|
//#region src/components/color-picker/color-picker-slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
431
|
-
var t0$1 = template("<div data-v-
|
|
432
|
-
delegateEvents("pointerdown", "keydown");
|
|
447
|
+
var t0$1 = template("<div data-v-3a0ac9e0 role=slider tabindex=0 aria-orientation=horizontal aria-valuemin=0><span data-v-3a0ac9e0 aria-hidden=true></span><span data-v-3a0ac9e0 aria-hidden=true>", 1);
|
|
433
448
|
//#endregion
|
|
434
449
|
//#region src/components/color-picker/color-picker-slider.vue
|
|
435
450
|
var color_picker_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -476,92 +491,51 @@ var color_picker_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_defaul
|
|
|
476
491
|
setup(__props, { emit: __emit }) {
|
|
477
492
|
const props = __props;
|
|
478
493
|
const emit = __emit;
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
494
|
+
const { setSliderElement, sliderState, onPointerDown, onKeydown } = useColorPickerSlider({
|
|
495
|
+
variant: () => props.variant,
|
|
496
|
+
value: () => props.value,
|
|
497
|
+
readonly: () => props.readonly,
|
|
498
|
+
onChange: (value) => emit("update:value", value)
|
|
499
|
+
});
|
|
482
500
|
const rootClass = computed(() => `rp-color-picker__${props.variant}`);
|
|
483
501
|
const surfaceClass = computed(() => ["rp-color-picker__slider-surface", `rp-color-picker__${props.variant}-surface`]);
|
|
484
502
|
const internalHandleClass = computed(() => ["rp-color-picker__slider-handle", `rp-color-picker__${props.variant}-handle`]);
|
|
485
|
-
const normalizedValue = computed(() => isHue.value ? normalizeHue(props.value) : clampOpacity(props.value));
|
|
486
|
-
const currentOutputValue = computed(() => normalizeOutputValue(normalizedValue.value));
|
|
487
503
|
const sliderStyle = computed(() => {
|
|
488
|
-
const style = { "--_rp-color-picker-slider-x": `${
|
|
489
|
-
if (
|
|
504
|
+
const style = { "--_rp-color-picker-slider-x": `${sliderState.value.outputValue / sliderState.value.max * 100}%` };
|
|
505
|
+
if (sliderState.value.isHue) style["--_rp-color-picker-hue"] = String(normalizeHueForColor(sliderState.value.outputValue));
|
|
490
506
|
else style["--_rp-color-picker-opacity-color"] = props.color;
|
|
491
507
|
return style;
|
|
492
508
|
});
|
|
493
|
-
const ariaLabel = computed(() =>
|
|
494
|
-
const ariaValueText = computed(() =>
|
|
495
|
-
function updateValue(nextValue) {
|
|
496
|
-
if (props.readonly) return;
|
|
497
|
-
const normalizedNextValue = normalizeOutputValue(nextValue);
|
|
498
|
-
if (normalizedNextValue === currentOutputValue.value) return;
|
|
499
|
-
emit("update:value", normalizedNextValue);
|
|
500
|
-
}
|
|
501
|
-
function updateFromPointer(e, rect) {
|
|
502
|
-
if (rect.width <= 0) return;
|
|
503
|
-
updateValue((e.clientX - rect.left) / rect.width * max.value);
|
|
504
|
-
}
|
|
505
|
-
const { onPointerDown } = useColorPickerDrag({
|
|
506
|
-
target: sliderRef,
|
|
507
|
-
readonly: () => props.readonly,
|
|
508
|
-
isGeometryValid: (rect) => rect.width > 0,
|
|
509
|
-
updateFromPointer
|
|
510
|
-
});
|
|
511
|
-
function onKeydown(e) {
|
|
512
|
-
if (props.readonly) return;
|
|
513
|
-
const step = e.shiftKey ? 10 : 1;
|
|
514
|
-
switch (e.key) {
|
|
515
|
-
case "ArrowRight":
|
|
516
|
-
case "ArrowUp":
|
|
517
|
-
e.preventDefault();
|
|
518
|
-
updateValue(normalizedValue.value + step);
|
|
519
|
-
break;
|
|
520
|
-
case "ArrowLeft":
|
|
521
|
-
case "ArrowDown":
|
|
522
|
-
e.preventDefault();
|
|
523
|
-
updateValue(normalizedValue.value - step);
|
|
524
|
-
break;
|
|
525
|
-
case "Home":
|
|
526
|
-
e.preventDefault();
|
|
527
|
-
updateValue(0);
|
|
528
|
-
break;
|
|
529
|
-
case "End":
|
|
530
|
-
e.preventDefault();
|
|
531
|
-
updateValue(max.value);
|
|
532
|
-
break;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
function normalizeOutputValue(value) {
|
|
536
|
-
return isHue.value ? Math.round(clampHue(value)) : roundPercent(clampOpacity(value));
|
|
537
|
-
}
|
|
509
|
+
const ariaLabel = computed(() => sliderState.value.isHue ? "Hue" : "Opacity");
|
|
510
|
+
const ariaValueText = computed(() => sliderState.value.isHue ? `${Math.round(sliderState.value.value)} degrees hue` : `${Math.round(sliderState.value.value)}% opacity`);
|
|
538
511
|
const _setTemplateRef = createTemplateRefSetter();
|
|
539
512
|
const n2 = t0$1();
|
|
540
513
|
const n0 = child(n2);
|
|
541
514
|
const n1 = next(n0, 1);
|
|
542
|
-
n2
|
|
543
|
-
n2
|
|
544
|
-
_setTemplateRef(n2, sliderRef, null, "sliderRef");
|
|
515
|
+
on(n2, "pointerdown", (e) => unref(onPointerDown)(e));
|
|
516
|
+
on(n2, "keydown", (e) => unref(onKeydown)(e));
|
|
545
517
|
renderEffect(() => {
|
|
518
|
+
const _sliderState = unref(sliderState);
|
|
546
519
|
const _readonly = __props.readonly;
|
|
547
520
|
const _variant = __props.variant;
|
|
548
521
|
setClass(n2, [rootClass.value, __props.controlClass]);
|
|
549
522
|
setStyle(n2, [sliderStyle.value, __props.controlStyle]);
|
|
550
523
|
setAttr(n2, "aria-label", ariaLabel.value);
|
|
551
|
-
setAttr(n2, "aria-valuemax", max
|
|
552
|
-
setAttr(n2, "aria-valuenow", Math.round(
|
|
524
|
+
setAttr(n2, "aria-valuemax", _sliderState.max);
|
|
525
|
+
setAttr(n2, "aria-valuenow", Math.round(_sliderState.value));
|
|
553
526
|
setAttr(n2, "aria-valuetext", ariaValueText.value);
|
|
554
527
|
setAttr(n2, "aria-readonly", _readonly || void 0);
|
|
555
|
-
setAttr(n2, "data-readonly", unref(
|
|
528
|
+
setAttr(n2, "data-readonly", unref(toPresenceAttribute)(_readonly));
|
|
556
529
|
setAttr(n2, "data-control", _variant);
|
|
557
530
|
setClass(n0, surfaceClass.value);
|
|
558
531
|
setClass(n1, [internalHandleClass.value, __props.handleClass]);
|
|
559
532
|
setStyle(n1, __props.handleStyle);
|
|
560
533
|
setAttr(n1, "data-control", _variant);
|
|
534
|
+
_setTemplateRef(n2, setSliderElement, null, "setSliderElement");
|
|
561
535
|
});
|
|
562
536
|
return n2;
|
|
563
537
|
}
|
|
564
|
-
}), [["__scopeId", "data-v-
|
|
538
|
+
}), [["__scopeId", "data-v-3a0ac9e0"]]);
|
|
565
539
|
//#endregion
|
|
566
540
|
//#region src/components/color-picker/useColorPickerSwatches.ts
|
|
567
541
|
var MAX_SWATCHES_PER_ROW = 15;
|
|
@@ -595,9 +569,7 @@ function useColorPickerSwatches(props, options) {
|
|
|
595
569
|
focusedSwatchIndex.value = index;
|
|
596
570
|
}
|
|
597
571
|
function onSwatchesFocusout(event) {
|
|
598
|
-
|
|
599
|
-
const nextTarget = event.relatedTarget;
|
|
600
|
-
if (group instanceof HTMLElement && nextTarget instanceof Node && group.contains(nextTarget)) return;
|
|
572
|
+
if (isNodeWithinElement(event.relatedTarget, event.currentTarget)) return;
|
|
601
573
|
focusedSwatchIndex.value = null;
|
|
602
574
|
}
|
|
603
575
|
function onSwatchKeydown(event, index) {
|
|
@@ -720,11 +692,10 @@ function getComparableColor(color) {
|
|
|
720
692
|
}
|
|
721
693
|
//#endregion
|
|
722
694
|
//#region src/components/color-picker/color-picker.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
723
|
-
var t0 = template("<div data-v-
|
|
724
|
-
var t1 = template("<button data-v-
|
|
725
|
-
var t2 = template("<div data-v-
|
|
726
|
-
var t3 = template("<div data-v-
|
|
727
|
-
delegateEvents("click", "keydown", "focusout");
|
|
695
|
+
var t0 = template("<div data-v-7fe38e4e class=rp-color-picker__header><span data-v-7fe38e4e>");
|
|
696
|
+
var t1 = template("<button data-v-7fe38e4e>");
|
|
697
|
+
var t2 = template("<div data-v-7fe38e4e>");
|
|
698
|
+
var t3 = template("<div data-v-7fe38e4e>", 1);
|
|
728
699
|
//#endregion
|
|
729
700
|
//#region src/components/color-picker/color-picker.vue
|
|
730
701
|
var color_picker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -763,14 +734,14 @@ var color_picker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
763
734
|
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
764
735
|
const rootAttrs = computed(() => getRootAttrs({
|
|
765
736
|
class: rootClass.value,
|
|
766
|
-
"data-readonly":
|
|
737
|
+
"data-readonly": toPresenceAttribute(props.readonly)
|
|
767
738
|
}));
|
|
768
739
|
const { selectedColor, saturationValue, opacityColor, showAlphaControls, updateSelection, updateHue, updateOpacity, selectColor, isColorSelected } = useColorPickerValue(props, (value) => emit("update:modelValue", value));
|
|
769
740
|
const { swatchesRef, normalizedSwatchesPerRow, validSwatches, swatchesStyle, swatchSize, isSwatchSelected, getSwatchTabindex, selectSwatch, onSwatchFocus, onSwatchesFocusout, onSwatchKeydown } = useColorPickerSwatches(props, {
|
|
770
741
|
isSelected: isColorSelected,
|
|
771
742
|
select: selectColor
|
|
772
743
|
});
|
|
773
|
-
const
|
|
744
|
+
const templateRefs = { swatches: swatchesRef };
|
|
774
745
|
const n22 = t3();
|
|
775
746
|
renderEffect(() => setDynamicProps(n22, [rootAttrs.value]));
|
|
776
747
|
setInsertionState(n22, null, 0);
|
|
@@ -850,7 +821,7 @@ var color_picker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
850
821
|
const _index = _for_key0.value;
|
|
851
822
|
const _isSwatchSelected = unref(isSwatchSelected);
|
|
852
823
|
const _swatch = _for_item0.value;
|
|
853
|
-
const
|
|
824
|
+
const _toPresenceAttribute = unref(toPresenceAttribute);
|
|
854
825
|
setDynamicProps(n20, [unref(getPartAttrs)("swatch", { class: "rp-color-picker__swatch" }), {
|
|
855
826
|
type: "button",
|
|
856
827
|
role: "radio",
|
|
@@ -859,8 +830,8 @@ var color_picker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
859
830
|
"aria-checked": _isSwatchSelected(_index),
|
|
860
831
|
"aria-label": `Select color ${_swatch}`,
|
|
861
832
|
title: _swatch,
|
|
862
|
-
"data-selected":
|
|
863
|
-
"data-readonly":
|
|
833
|
+
"data-selected": _toPresenceAttribute(_isSwatchSelected(_index)),
|
|
834
|
+
"data-readonly": _toPresenceAttribute(_readonly)
|
|
864
835
|
}]);
|
|
865
836
|
});
|
|
866
837
|
setInsertionState(n20, null, 0);
|
|
@@ -873,17 +844,17 @@ var color_picker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
873
844
|
return createComponent(unref(check_default), { class: "rp-color-picker__swatch-check" });
|
|
874
845
|
}, null, 129);
|
|
875
846
|
}, { _: 8 }));
|
|
876
|
-
n20
|
|
847
|
+
on(n20, "click", () => unref(selectSwatch)(_for_item0.value));
|
|
877
848
|
on(n20, "focus", () => unref(onSwatchFocus)(_for_key0.value));
|
|
878
|
-
n20
|
|
849
|
+
on(n20, "keydown", ($event) => unref(onSwatchKeydown)($event, _for_key0.value));
|
|
879
850
|
return n20;
|
|
880
851
|
}, (swatch, index) => `${swatch}-${index}`, 9);
|
|
881
|
-
n21
|
|
882
|
-
|
|
852
|
+
on(n21, "focusout", (e) => unref(onSwatchesFocusout)(e));
|
|
853
|
+
setTemplateRefBinding(n21, () => templateRefs.swatches);
|
|
883
854
|
return n21;
|
|
884
855
|
});
|
|
885
856
|
return n22;
|
|
886
857
|
}
|
|
887
|
-
}), [["__scopeId", "data-v-
|
|
858
|
+
}), [["__scopeId", "data-v-7fe38e4e"]]);
|
|
888
859
|
//#endregion
|
|
889
|
-
export {
|
|
860
|
+
export { parseColorPickerValue as i, colorPickerFormats as n, formatColorPickerValue as r, color_picker_default as t };
|