origam 2.38.0 → 2.38.2
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/CHANGELOG.md +34 -0
- package/dist/src/assets/locales/en.json +1 -1
- package/dist/src/assets/locales/fr.json +2 -2
- package/dist/src/components/Alert/OrigamAlert.vue +739 -165
- package/dist/src/components/App/OrigamApp.vue +95 -19
- package/dist/src/components/App/OrigamAppBar.vue +751 -158
- package/dist/src/components/Audio/OrigamAudio.vue +1288 -346
- package/dist/src/components/Audio/OrigamAudioWaveform.vue +63 -7
- package/dist/src/components/Avatar/OrigamAvatar.vue +678 -126
- package/dist/src/components/Avatar/OrigamAvatarGroup.vue +700 -153
- package/dist/src/components/Badge/OrigamBadge.vue +548 -135
- package/dist/src/components/Blockquote/OrigamBlockquote.vue +698 -140
- package/dist/src/components/BottomNav/OrigamBottomNav.vue +864 -156
- package/dist/src/components/Bracket/OrigamBracket.vue +1013 -380
- package/dist/src/components/Bracket/OrigamBracketCompetitor.vue +674 -154
- package/dist/src/components/Bracket/OrigamBracketMatch.vue +663 -163
- package/dist/src/components/Bracket/OrigamBracketRound.vue +116 -34
- package/dist/src/components/Breadcrumb/OrigamBreadcrumb.vue +654 -119
- package/dist/src/components/Breadcrumb/OrigamBreadcrumbDivider.vue +292 -54
- package/dist/src/components/Breadcrumb/OrigamBreadcrumbItem.vue +657 -126
- package/dist/src/components/Btn/OrigamBtn.vue +928 -249
- package/dist/src/components/Btn/OrigamBtnGroup.vue +658 -141
- package/dist/src/components/Btn/OrigamBtnToggle.vue +578 -91
- package/dist/src/components/Calendar/OrigamCalendar.vue +1142 -484
- package/dist/src/components/Card/OrigamCard.vue +938 -194
- package/dist/src/components/Card/OrigamCardHeader.vue +593 -104
- package/dist/src/components/Card/OrigamCardText.vue +536 -84
- package/dist/src/components/Carousel/OrigamCarousel.vue +778 -202
- package/dist/src/components/Carousel/OrigamCarouselItem.vue +660 -109
- package/dist/src/components/Chart/OrigamChart.vue +942 -452
- package/dist/src/components/Chart/OrigamChartAxis.vue +111 -19
- package/dist/src/components/Chart/OrigamChartBoxPlot.vue +713 -297
- package/dist/src/components/Chart/OrigamChartBullet.vue +701 -286
- package/dist/src/components/Chart/OrigamChartCandlestick.vue +663 -243
- package/dist/src/components/Chart/OrigamChartCartesian.vue +1055 -487
- package/dist/src/components/Chart/OrigamChartGauge.vue +563 -164
- package/dist/src/components/Chart/OrigamChartHeatmap.vue +677 -251
- package/dist/src/components/Chart/OrigamChartHoneycomb.vue +700 -288
- package/dist/src/components/Chart/OrigamChartLegend.vue +108 -16
- package/dist/src/components/Chart/OrigamChartMap.vue +723 -299
- package/dist/src/components/Chart/OrigamChartPareto.vue +721 -276
- package/dist/src/components/Chart/OrigamChartPictorial.vue +777 -355
- package/dist/src/components/Chart/OrigamChartPolar.vue +603 -210
- package/dist/src/components/Chart/OrigamChartPolarBar.vue +674 -271
- package/dist/src/components/Chart/OrigamChartPyramid.vue +685 -250
- package/dist/src/components/Chart/OrigamChartRadar.vue +515 -165
- package/dist/src/components/Chart/OrigamChartRangeSelector.vue +50 -25
- package/dist/src/components/Chart/OrigamChartSankey.vue +913 -467
- package/dist/src/components/Chart/OrigamChartSparkline.vue +711 -268
- package/dist/src/components/Chart/OrigamChartStreamgraph.vue +810 -368
- package/dist/src/components/Chart/OrigamChartSunburst.vue +779 -368
- package/dist/src/components/Chart/OrigamChartTooltip.vue +78 -19
- package/dist/src/components/Chart/OrigamChartTreemap.vue +750 -288
- package/dist/src/components/Chart/OrigamChartVariwide.vue +679 -251
- package/dist/src/components/Chart/OrigamChartWordCloud.vue +674 -265
- package/dist/src/components/Checkbox/OrigamCheckbox.vue +781 -136
- package/dist/src/components/Checkbox/OrigamCheckboxBtn.vue +465 -81
- package/dist/src/components/Checkbox/OrigamCheckboxGroup.vue +824 -137
- package/dist/src/components/Chip/OrigamChip.vue +867 -202
- package/dist/src/components/Chip/OrigamChipGroup.vue +633 -121
- package/dist/src/components/ClientOnly/OrigamClientOnly.vue +30 -4
- package/dist/src/components/Clipboard/OrigamClipboard.vue +624 -105
- package/dist/src/components/Code/OrigamCode.vue +844 -206
- package/dist/src/components/CodeGroup/OrigamCodeGroup.vue +494 -83
- package/dist/src/components/ColorPicker/OrigamColorPicker.vue +777 -159
- package/dist/src/components/ColorPicker/OrigamColorPickerCanvas.vue +295 -181
- package/dist/src/components/ColorPicker/OrigamColorPickerEdit.vue +108 -45
- package/dist/src/components/ColorPicker/OrigamColorPickerPreview.vue +131 -46
- package/dist/src/components/ColorPicker/OrigamColorPickerSwatches.vue +128 -39
- package/dist/src/components/ColorPickerField/OrigamColorPickerField.vue +1123 -258
- package/dist/src/components/CommandPalette/OrigamCommandPalette.vue +415 -162
- package/dist/src/components/ConfirmWrapper/OrigamConfirmWrapper.vue +389 -145
- package/dist/src/components/ContextualMenu/OrigamContextualMenu.vue +852 -147
- package/dist/src/components/Counter/OrigamCounter.vue +588 -96
- package/dist/src/components/DataList/OrigamDataList.vue +619 -113
- package/dist/src/components/DataList/OrigamDataText.vue +295 -65
- package/dist/src/components/DataList/OrigamDataTitle.vue +295 -65
- package/dist/src/components/DataTable/OrigamDataTable.vue +934 -222
- package/dist/src/components/DataTable/OrigamDataTableColumnCell.vue +196 -51
- package/dist/src/components/DataTable/OrigamDataTableFooter.vue +319 -78
- package/dist/src/components/DataTable/OrigamDataTableGroupHeaderRow.vue +124 -44
- package/dist/src/components/DataTable/OrigamDataTableHeaderCell.vue +181 -70
- package/dist/src/components/DataTable/OrigamDataTableHeaders.vue +155 -46
- package/dist/src/components/DataTable/OrigamDataTableHeadersCell.vue +145 -27
- package/dist/src/components/DataTable/OrigamDataTableHeadersCellMobile.vue +126 -43
- package/dist/src/components/DataTable/OrigamDataTableRow.vue +151 -73
- package/dist/src/components/DataTable/OrigamDataTableRows.vue +261 -106
- package/dist/src/components/DatePicker/OrigamDatePicker.vue +1048 -261
- package/dist/src/components/DatePicker/OrigamDatePickerControls.vue +155 -51
- package/dist/src/components/DatePicker/OrigamDatePickerHeader.vue +147 -46
- package/dist/src/components/DatePicker/OrigamDatePickerMonth.vue +312 -134
- package/dist/src/components/DatePicker/OrigamDatePickerMonths.vue +151 -61
- package/dist/src/components/DatePicker/OrigamDatePickerYears.vue +154 -67
- package/dist/src/components/DatePickerField/OrigamDatePickerField.vue +1147 -306
- package/dist/src/components/DefaultsProvider/OrigamDefaultsProvider.vue +74 -14
- package/dist/src/components/Dialog/OrigamDialog.vue +953 -196
- package/dist/src/components/Dialog/OrigamDialogConfirmation.vue +886 -148
- package/dist/src/components/Divider/OrigamDivider.vue +210 -50
- package/dist/src/components/Drawer/OrigamDrawer.vue +909 -207
- package/dist/src/components/EmptyState/OrigamEmptyState.vue +146 -35
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanel.vue +746 -159
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanelContent.vue +591 -95
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanelHeader.vue +663 -143
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanels.vue +675 -134
- package/dist/src/components/Field/OrigamField.vue +1118 -306
- package/dist/src/components/FileField/OrigamFileField.vue +1188 -311
- package/dist/src/components/FileField/OrigamFileFieldDragNDropItem.vue +155 -36
- package/dist/src/components/FileField/OrigamFileFieldListItem.vue +155 -36
- package/dist/src/components/Form/OrigamForm.vue +197 -74
- package/dist/src/components/Grid/OrigamGrid.vue +707 -147
- package/dist/src/components/Grid/OrigamGridItem.vue +110 -37
- package/dist/src/components/Grids/OrigamCol.vue +593 -110
- package/dist/src/components/Grids/OrigamContainer.vue +461 -80
- package/dist/src/components/Grids/OrigamRow.vue +573 -112
- package/dist/src/components/Grids/OrigamSpacer.vue +54 -17
- package/dist/src/components/Icon/OrigamClassIcon.vue +573 -98
- package/dist/src/components/Icon/OrigamComponentIcon.vue +561 -101
- package/dist/src/components/Icon/OrigamIcon.vue +561 -98
- package/dist/src/components/Icon/OrigamLigatureIcon.vue +558 -98
- package/dist/src/components/Icon/OrigamSvgIcon.vue +593 -100
- package/dist/src/components/Img/OrigamImg.vue +869 -228
- package/dist/src/components/InfiniteScroll/OrigamInfiniteScroll.vue +319 -111
- package/dist/src/components/InfiniteScroll/OrigamInfiniteScrollIntersect.vue +80 -17
- package/dist/src/components/InlineEdit/OrigamInlineEdit.vue +476 -140
- package/dist/src/components/Input/OrigamInput.vue +747 -180
- package/dist/src/components/ItemGroup/OrigamItemGroup.vue +112 -36
- package/dist/src/components/ItemGroup/OrigamItemGroupItem.vue +80 -29
- package/dist/src/components/Kbd/OrigamKbd.vue +450 -75
- package/dist/src/components/Label/OrigamLabel.vue +584 -95
- package/dist/src/components/Layout/OrigamLayout.vue +563 -94
- package/dist/src/components/Lazy/OrigamLazy.vue +131 -34
- package/dist/src/components/List/OrigamList.vue +755 -170
- package/dist/src/components/List/OrigamListChildren.vue +59 -19
- package/dist/src/components/List/OrigamListGroup.vue +631 -134
- package/dist/src/components/List/OrigamListGroupActivator.vue +45 -17
- package/dist/src/components/List/OrigamListItem.vue +890 -224
- package/dist/src/components/List/OrigamListItemWrapper.vue +20 -10
- package/dist/src/components/List/OrigamListSubheader.vue +542 -93
- package/dist/src/components/Loader/OrigamLoader.vue +110 -25
- package/dist/src/components/Main/OrigamMain.vue +565 -96
- package/dist/src/components/Masonry/OrigamMasonry.vue +799 -187
- package/dist/src/components/Media/OrigamMediaController.vue +465 -182
- package/dist/src/components/Media/OrigamMediaScrubber.vue +389 -152
- package/dist/src/components/Media/OrigamMediaVolumeControl.vue +174 -44
- package/dist/src/components/Menu/OrigamMenu.vue +1079 -255
- package/dist/src/components/Messages/OrigamMessages.vue +606 -97
- package/dist/src/components/NumberField/OrigamNumberField.vue +1208 -333
- package/dist/src/components/NumberFormat/OrigamNumberFormat.vue +177 -57
- package/dist/src/components/OtpInputField/OrigamOtpInputField.vue +1016 -272
- package/dist/src/components/Overlay/OrigamOverlay.vue +446 -158
- package/dist/src/components/Overlay/OrigamOverlayScrim.vue +122 -30
- package/dist/src/components/Pagination/OrigamPagination.vue +982 -313
- package/dist/src/components/Parallax/OrigamParallax.vue +800 -259
- package/dist/src/components/Parallax/OrigamParallaxElement.vue +694 -178
- package/dist/src/components/Parallax/OrigamParallaxLayer.vue +132 -47
- package/dist/src/components/PasswordField/OrigamPasswordField.vue +1098 -265
- package/dist/src/components/Picker/OrigamPicker.vue +655 -108
- package/dist/src/components/Picker/OrigamPickerTitle.vue +108 -26
- package/dist/src/components/Progress/OrigamProgress.vue +436 -70
- package/dist/src/components/Progress/OrigamProgressCircular.vue +399 -82
- package/dist/src/components/Progress/OrigamProgressLinear.vue +468 -115
- package/dist/src/components/QrCode/OrigamQrCode.vue +642 -126
- package/dist/src/components/Radio/OrigamRadio.vue +772 -132
- package/dist/src/components/Radio/OrigamRadioBtn.vue +446 -71
- package/dist/src/components/Radio/OrigamRadioGroup.vue +808 -135
- package/dist/src/components/RatingField/OrigamRatingField.vue +963 -194
- package/dist/src/components/RatingField/OrigamRatingFieldItem.vue +657 -106
- package/dist/src/components/Responsive/OrigamResponsive.vue +548 -91
- package/dist/src/components/Select/OrigamSelect.vue +1639 -567
- package/dist/src/components/SelectionControl/OrigamSelectionControl.vue +564 -151
- package/dist/src/components/SelectionControl/OrigamSelectionControlGroup.vue +178 -62
- package/dist/src/components/Sheet/OrigamSheet.vue +773 -199
- package/dist/src/components/Skeleton/OrigamSkeleton.vue +249 -46
- package/dist/src/components/Skeleton/OrigamSkeletonGroup.vue +66 -11
- package/dist/src/components/Slide/OrigamSlideGroup.vue +772 -257
- package/dist/src/components/SliderField/OrigamSliderField.vue +1157 -335
- package/dist/src/components/SliderField/OrigamSliderFieldTrack.vue +236 -112
- package/dist/src/components/Snackbar/OrigamSnackbar.vue +871 -214
- package/dist/src/components/Snackbar/OrigamSnackbarGroup.vue +218 -51
- package/dist/src/components/Snackbar/OrigamSnackbarItem.vue +175 -43
- package/dist/src/components/Stepper/OrigamStepper.vue +618 -126
- package/dist/src/components/Stepper/OrigamStepperItem.vue +98 -37
- package/dist/src/components/Switch/OrigamSwitch.vue +879 -156
- package/dist/src/components/Switch/OrigamSwitchTrack.vue +431 -78
- package/dist/src/components/SystemBar/OrigamSystemBar.vue +517 -87
- package/dist/src/components/Table/OrigamTable.vue +585 -124
- package/dist/src/components/Tabs/OrigamTab.vue +239 -73
- package/dist/src/components/Tabs/OrigamTabPanel.vue +125 -39
- package/dist/src/components/Tabs/OrigamTabPanels.vue +148 -57
- package/dist/src/components/Tabs/OrigamTabs.vue +381 -109
- package/dist/src/components/TextField/OrigamTextField.vue +1077 -258
- package/dist/src/components/TextMask/OrigamTextMask.vue +150 -43
- package/dist/src/components/TextareaField/OrigamTextareaField.vue +1162 -310
- package/dist/src/components/TextareaField/OrigamTextareaFieldRichToolbar.vue +77 -79
- package/dist/src/components/ThemeProvider/OrigamThemeProvider.vue +44 -9
- package/dist/src/components/Timeline/OrigamTimeline.vue +113 -43
- package/dist/src/components/Timeline/OrigamTimelineItem.vue +163 -76
- package/dist/src/components/Title/OrigamTitle.vue +505 -82
- package/dist/src/components/Toolbar/OrigamToolbar.vue +679 -142
- package/dist/src/components/Tooltip/OrigamTooltip.vue +288 -72
- package/dist/src/components/Transition/OrigamExpandX.vue +219 -106
- package/dist/src/components/Transition/OrigamExpandY.vue +219 -106
- package/dist/src/components/Transition/OrigamFade.vue +47 -9
- package/dist/src/components/Transition/OrigamReverseTranslatePicker.vue +52 -10
- package/dist/src/components/Transition/OrigamScaleRotate.vue +52 -10
- package/dist/src/components/Transition/OrigamSlideX.vue +52 -10
- package/dist/src/components/Transition/OrigamSlideY.vue +52 -10
- package/dist/src/components/Transition/OrigamSnack.vue +52 -10
- package/dist/src/components/Transition/OrigamTransition.vue +40 -12
- package/dist/src/components/Transition/OrigamTranslateBottom.vue +52 -10
- package/dist/src/components/Transition/OrigamTranslatePicker.vue +52 -10
- package/dist/src/components/Transition/OrigamTranslateScale.vue +209 -97
- package/dist/src/components/Transition/OrigamWindowXReverseTranslate.vue +40 -7
- package/dist/src/components/Transition/OrigamWindowXTranslate.vue +40 -7
- package/dist/src/components/Transition/OrigamWindowYReverseTranslate.vue +40 -7
- package/dist/src/components/Transition/OrigamWindowYTranslate.vue +40 -7
- package/dist/src/components/Treeview/OrigamTreeview.vue +258 -118
- package/dist/src/components/Treeview/OrigamTreeviewNode.vue +126 -88
- package/dist/src/components/Video/OrigamVideo.vue +1178 -331
- package/dist/src/components/VirtualScroll/OrigamVirtualScroll.vue +147 -55
- package/dist/src/components/VirtualScroll/OrigamVirtualScrollItem.vue +94 -19
- package/dist/src/components/Watermark/OrigamWatermark.vue +224 -124
- package/dist/src/components/Window/OrigamWindow.vue +745 -175
- package/dist/src/components/Window/OrigamWindowItem.vue +162 -69
- package/dist/src/composables/Commons/display.composable.cjs +2 -0
- package/dist/src/composables/Commons/display.composable.js +1 -1
- package/dist/src/interfaces/Pagination/pagination.interface.d.ts +1 -1
- package/package.json +8 -8
|
@@ -42,20 +42,78 @@ import { COLOR_NULL } from "../../consts/ColorPicker/color-picker.const";
|
|
|
42
42
|
import { KEYBOARD_VALUES } from "../../enums/Commons/hotkey.enum";
|
|
43
43
|
import { clamp, convertToUnit, getEventCoordinates, int } from "../../utils/Commons/commons.util";
|
|
44
44
|
import { computed, onMounted, ref, shallowRef, StyleValue, watch } from "vue";
|
|
45
|
+
/*********************************************************
|
|
46
|
+
* Global
|
|
47
|
+
*
|
|
48
|
+
* @description
|
|
49
|
+
* Props, emits, canvas rendering and pointer interaction.
|
|
50
|
+
********************************************************/
|
|
45
51
|
const props = defineProps({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
colorHsv: {
|
|
53
|
+
type: [Object, null],
|
|
54
|
+
required: false
|
|
55
|
+
},
|
|
56
|
+
disabled: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
required: false
|
|
59
|
+
},
|
|
60
|
+
dotSize: {
|
|
61
|
+
type: [String, Number],
|
|
62
|
+
required: false
|
|
63
|
+
},
|
|
64
|
+
ariaLabel: {
|
|
65
|
+
type: String,
|
|
66
|
+
required: false
|
|
67
|
+
},
|
|
68
|
+
id: {
|
|
69
|
+
type: String,
|
|
70
|
+
required: false
|
|
71
|
+
},
|
|
72
|
+
class: {
|
|
73
|
+
type: [
|
|
74
|
+
String,
|
|
75
|
+
Array,
|
|
76
|
+
Object
|
|
77
|
+
],
|
|
78
|
+
required: false
|
|
79
|
+
},
|
|
80
|
+
style: {
|
|
81
|
+
type: [
|
|
82
|
+
String,
|
|
83
|
+
Array,
|
|
84
|
+
Object,
|
|
85
|
+
Boolean,
|
|
86
|
+
null
|
|
87
|
+
],
|
|
88
|
+
required: false,
|
|
89
|
+
skipCheck: true
|
|
90
|
+
},
|
|
91
|
+
height: {
|
|
92
|
+
type: [Number, String],
|
|
93
|
+
required: false,
|
|
94
|
+
default: 150
|
|
95
|
+
},
|
|
96
|
+
maxHeight: {
|
|
97
|
+
type: [Number, String],
|
|
98
|
+
required: false
|
|
99
|
+
},
|
|
100
|
+
maxWidth: {
|
|
101
|
+
type: [Number, String],
|
|
102
|
+
required: false
|
|
103
|
+
},
|
|
104
|
+
minHeight: {
|
|
105
|
+
type: [Number, String],
|
|
106
|
+
required: false
|
|
107
|
+
},
|
|
108
|
+
minWidth: {
|
|
109
|
+
type: [Number, String],
|
|
110
|
+
required: false
|
|
111
|
+
},
|
|
112
|
+
width: {
|
|
113
|
+
type: [Number, String],
|
|
114
|
+
required: false,
|
|
115
|
+
default: "100%"
|
|
116
|
+
}
|
|
59
117
|
});
|
|
60
118
|
const emits = defineEmits(["update:colorHsv"]);
|
|
61
119
|
defineSlots();
|
|
@@ -63,218 +121,274 @@ const { filterProps } = useProps(props);
|
|
|
63
121
|
const { t } = useLocale();
|
|
64
122
|
const isInteracting = shallowRef(false);
|
|
65
123
|
const canvasRef = ref();
|
|
124
|
+
/*********************************************************
|
|
125
|
+
* Composables
|
|
126
|
+
********************************************************/
|
|
66
127
|
const { resizeRef } = useResizeObserver((entries) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
128
|
+
if (!resizeRef.value?.offsetParent) return;
|
|
129
|
+
const { width, height } = entries[0].contentRect;
|
|
130
|
+
canvasWidth.value = width;
|
|
131
|
+
canvasHeight.value = height;
|
|
71
132
|
});
|
|
72
133
|
const _canvasHeight = ref(0);
|
|
73
134
|
const canvasHeight = computed({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
135
|
+
get: () => _canvasHeight.value,
|
|
136
|
+
set: (value) => {
|
|
137
|
+
if (value === "100%") {
|
|
138
|
+
_canvasHeight.value = parseFloat(resizeRef.value?.clientHeight || 0);
|
|
139
|
+
} else {
|
|
140
|
+
_canvasHeight.value = parseFloat(value);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
82
143
|
});
|
|
83
144
|
const _canvasWidth = ref(0);
|
|
84
145
|
const canvasWidth = computed({
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
146
|
+
get: () => _canvasWidth.value,
|
|
147
|
+
set: (value) => {
|
|
148
|
+
if (value === "100%") {
|
|
149
|
+
_canvasWidth.value = parseFloat(resizeRef.value?.clientWidth || 0);
|
|
150
|
+
} else {
|
|
151
|
+
_canvasWidth.value = parseFloat(value);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
const _dotPosition = ref({
|
|
156
|
+
x: 0,
|
|
157
|
+
y: 0
|
|
93
158
|
});
|
|
94
|
-
const _dotPosition = ref({ x: 0, y: 0 });
|
|
95
159
|
const dotPosition = computed({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
160
|
+
get: () => _dotPosition.value,
|
|
161
|
+
set(val) {
|
|
162
|
+
if (!canvasRef.value) return;
|
|
163
|
+
const { x, y } = val;
|
|
164
|
+
_dotPosition.value = val;
|
|
165
|
+
emits("update:colorHsv", {
|
|
166
|
+
h: props.colorHsv?.h ?? 0,
|
|
167
|
+
s: clamp(x, 0, canvasWidth.value) / canvasWidth.value,
|
|
168
|
+
v: 1 - clamp(y, 0, canvasHeight.value) / canvasHeight.value,
|
|
169
|
+
a: props.colorHsv?.a ?? 1
|
|
170
|
+
});
|
|
171
|
+
}
|
|
108
172
|
});
|
|
109
173
|
const dotStyles = computed(() => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
174
|
+
const { x, y } = dotPosition.value;
|
|
175
|
+
const radius = int(props.dotSize) / 2;
|
|
176
|
+
return {
|
|
177
|
+
width: convertToUnit(props.dotSize),
|
|
178
|
+
height: convertToUnit(props.dotSize),
|
|
179
|
+
transform: `translate(${convertToUnit(x - radius)}, ${convertToUnit(y - radius)})`
|
|
180
|
+
};
|
|
117
181
|
});
|
|
118
182
|
const updateDotPosition = (x, y, rect) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
183
|
+
const { left, top, width, height } = rect;
|
|
184
|
+
dotPosition.value = {
|
|
185
|
+
x: clamp(x - left, 0, width),
|
|
186
|
+
y: clamp(y - top, 0, height)
|
|
187
|
+
};
|
|
124
188
|
};
|
|
125
189
|
const updateCanvas = () => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
190
|
+
if (!canvasRef.value) return;
|
|
191
|
+
const canvas = canvasRef.value;
|
|
192
|
+
const ctx = canvas.getContext("2d");
|
|
193
|
+
if (!ctx) return;
|
|
194
|
+
const saturationGradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
|
|
195
|
+
saturationGradient.addColorStop(0, "hsla(0, 0%, 100%, 1)");
|
|
196
|
+
saturationGradient.addColorStop(1, `hsla(${props.colorHsv?.h ?? 0}, 100%, 50%, 1)`);
|
|
197
|
+
ctx.fillStyle = saturationGradient;
|
|
198
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
199
|
+
const valueGradient = ctx.createLinearGradient(0, 0, 0, canvas.height);
|
|
200
|
+
valueGradient.addColorStop(0, "hsla(0, 0%, 0%, 0)");
|
|
201
|
+
valueGradient.addColorStop(1, "hsla(0, 0%, 0%, 1)");
|
|
202
|
+
ctx.fillStyle = valueGradient;
|
|
203
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
140
204
|
};
|
|
205
|
+
/*********************************************************
|
|
206
|
+
* ARIA computed values
|
|
207
|
+
********************************************************/
|
|
141
208
|
const canvasAriaLabel = computed(() => {
|
|
142
|
-
|
|
209
|
+
return props.ariaLabel ?? t("origam.color_picker.canvas.aria_label");
|
|
143
210
|
});
|
|
144
211
|
const canvasAriaValueText = computed(() => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
212
|
+
const s = Math.round((props.colorHsv?.s ?? 0) * 100);
|
|
213
|
+
const v = Math.round((props.colorHsv?.v ?? 0) * 100);
|
|
214
|
+
return t("origam.color_picker.canvas.value", s, v);
|
|
148
215
|
});
|
|
216
|
+
/*********************************************************
|
|
217
|
+
* canvasAriaValueNow
|
|
218
|
+
*
|
|
219
|
+
* @description
|
|
220
|
+
* ⛔ issue C6 (a11y audit) — `role="application"` does not carry
|
|
221
|
+
* `aria-valuenow` / `aria-valuemin` / `aria-valuemax` / `aria-valuetext`
|
|
222
|
+
* in its supported-states table (WAI-ARIA 1.2 §5.4, confirmed against
|
|
223
|
+
* the spec: those four properties belong to `slider` / `spinbutton` /
|
|
224
|
+
* `scrollbar` / `progressbar` / `meter`, never to `application`), so a
|
|
225
|
+
* screen reader had no defined way to expose the live value it was
|
|
226
|
+
* already computing.
|
|
227
|
+
* @description
|
|
228
|
+
* `role="slider"` makes `aria-valuenow` a REQUIRED property (MDN),
|
|
229
|
+
* hence this dedicated computed — `s` (saturation) is the reported
|
|
230
|
+
* axis, `aria-valuetext` still carries the full two-axis description
|
|
231
|
+
* for assistive tech that prefers it.
|
|
232
|
+
********************************************************/
|
|
149
233
|
const canvasAriaValueNow = computed(() => {
|
|
150
|
-
|
|
234
|
+
return Math.round((props.colorHsv?.s ?? 0) * 100);
|
|
151
235
|
});
|
|
152
|
-
|
|
153
|
-
|
|
236
|
+
/*********************************************************
|
|
237
|
+
* Event handlers
|
|
238
|
+
********************************************************/
|
|
239
|
+
const STEP_SMALL = .01;
|
|
240
|
+
const STEP_LARGE = .05;
|
|
154
241
|
const handleKeyDown = (e) => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
242
|
+
if (props.disabled) return;
|
|
243
|
+
const step = e.shiftKey ? STEP_LARGE : STEP_SMALL;
|
|
244
|
+
// A picker that has no colour yet (an empty OrigamColorPickerField
|
|
245
|
+
// opens in exactly that state) must still answer the keyboard: a
|
|
246
|
+
// mouse click on this same canvas commits a colour from null, and
|
|
247
|
+
// this element advertises `role="slider"`, `tabindex="0"` and a
|
|
248
|
+
// live `aria-valuetext`. Bailing out on a null colour made it inert
|
|
249
|
+
// for keyboard users precisely when they had nothing to start from.
|
|
250
|
+
const hsv = props.colorHsv ?? COLOR_NULL;
|
|
251
|
+
const { h, a } = hsv;
|
|
252
|
+
let { s, v } = hsv;
|
|
253
|
+
let handled = false;
|
|
254
|
+
switch (e.key) {
|
|
255
|
+
case KEYBOARD_VALUES.LEFT:
|
|
256
|
+
s = clamp(s - step, 0, 1);
|
|
257
|
+
handled = true;
|
|
258
|
+
break;
|
|
259
|
+
case KEYBOARD_VALUES.RIGHT:
|
|
260
|
+
s = clamp(s + step, 0, 1);
|
|
261
|
+
handled = true;
|
|
262
|
+
break;
|
|
263
|
+
case KEYBOARD_VALUES.UP:
|
|
264
|
+
v = clamp(v + step, 0, 1);
|
|
265
|
+
handled = true;
|
|
266
|
+
break;
|
|
267
|
+
case KEYBOARD_VALUES.DOWN:
|
|
268
|
+
v = clamp(v - step, 0, 1);
|
|
269
|
+
handled = true;
|
|
270
|
+
break;
|
|
271
|
+
case KEYBOARD_VALUES.HOME:
|
|
272
|
+
s = 0;
|
|
273
|
+
handled = true;
|
|
274
|
+
break;
|
|
275
|
+
case KEYBOARD_VALUES.END:
|
|
276
|
+
s = 1;
|
|
277
|
+
handled = true;
|
|
278
|
+
break;
|
|
279
|
+
case KEYBOARD_VALUES.PAGEUP:
|
|
280
|
+
v = 1;
|
|
281
|
+
handled = true;
|
|
282
|
+
break;
|
|
283
|
+
case KEYBOARD_VALUES.PAGEDOWN:
|
|
284
|
+
v = 0;
|
|
285
|
+
handled = true;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
if (!handled) return;
|
|
289
|
+
e.preventDefault();
|
|
290
|
+
emits("update:colorHsv", {
|
|
291
|
+
h,
|
|
292
|
+
s,
|
|
293
|
+
v,
|
|
294
|
+
a
|
|
295
|
+
});
|
|
296
|
+
_dotPosition.value = {
|
|
297
|
+
x: s * canvasWidth.value,
|
|
298
|
+
y: (1 - v) * canvasHeight.value
|
|
299
|
+
};
|
|
202
300
|
};
|
|
203
301
|
const handleMouseDown = (e) => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
302
|
+
if (e.type === "mousedown") {
|
|
303
|
+
// Prevent text selection while dragging
|
|
304
|
+
e.preventDefault();
|
|
305
|
+
}
|
|
306
|
+
if (props.disabled) return;
|
|
307
|
+
handleMouseMove(e);
|
|
308
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
309
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
310
|
+
window.addEventListener("touchmove", handleMouseMove);
|
|
311
|
+
window.addEventListener("touchend", handleMouseUp);
|
|
213
312
|
};
|
|
214
313
|
const handleMouseMove = (e) => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
314
|
+
if (props.disabled || !canvasRef.value) return;
|
|
315
|
+
isInteracting.value = true;
|
|
316
|
+
const coords = getEventCoordinates(e);
|
|
317
|
+
updateDotPosition(coords.clientX, coords.clientY, canvasRef.value.getBoundingClientRect());
|
|
219
318
|
};
|
|
220
319
|
const handleMouseUp = () => {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
320
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
321
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
322
|
+
window.removeEventListener("touchmove", handleMouseMove);
|
|
323
|
+
window.removeEventListener("touchend", handleMouseUp);
|
|
225
324
|
};
|
|
226
325
|
watch(() => props.colorHsv?.h, () => {
|
|
227
|
-
|
|
326
|
+
updateCanvas();
|
|
228
327
|
}, { immediate: true });
|
|
229
328
|
watch(() => [canvasWidth.value, canvasHeight.value], (newVal, oldVal) => {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
329
|
+
updateCanvas();
|
|
330
|
+
if (newVal[0] && oldVal[0] && newVal[1] && oldVal[1]) {
|
|
331
|
+
_dotPosition.value = {
|
|
332
|
+
x: dotPosition.value.x * newVal[0] / oldVal[0],
|
|
333
|
+
y: dotPosition.value.y * newVal[1] / oldVal[1]
|
|
334
|
+
};
|
|
335
|
+
}
|
|
237
336
|
}, { flush: "post" });
|
|
238
337
|
watch(() => props.colorHsv, () => {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
338
|
+
if (isInteracting.value) {
|
|
339
|
+
isInteracting.value = false;
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
_dotPosition.value = props.colorHsv ? {
|
|
343
|
+
x: props.colorHsv.s * canvasWidth.value,
|
|
344
|
+
y: (1 - props.colorHsv.v) * canvasHeight.value
|
|
345
|
+
} : {
|
|
346
|
+
x: 0,
|
|
347
|
+
y: 0
|
|
348
|
+
};
|
|
349
|
+
}, {
|
|
350
|
+
deep: true,
|
|
351
|
+
immediate: true
|
|
352
|
+
});
|
|
248
353
|
onMounted(() => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
354
|
+
updateCanvas();
|
|
355
|
+
canvasHeight.value = int(props.height);
|
|
356
|
+
canvasWidth.value = int(props.width);
|
|
357
|
+
_dotPosition.value = props.colorHsv ? {
|
|
358
|
+
x: props.colorHsv.s * canvasWidth.value,
|
|
359
|
+
y: (1 - props.colorHsv.v) * canvasHeight.value
|
|
360
|
+
} : {
|
|
361
|
+
x: 0,
|
|
362
|
+
y: 0
|
|
363
|
+
};
|
|
256
364
|
});
|
|
365
|
+
/*********************************************************
|
|
366
|
+
* Class & Style
|
|
367
|
+
*
|
|
368
|
+
* @description
|
|
369
|
+
* Composes BEM classes and passes through host styles.
|
|
370
|
+
********************************************************/
|
|
257
371
|
const { dimensionStyles } = useDimension(props);
|
|
258
372
|
const colorPickerCanvasStyles = computed(() => {
|
|
259
|
-
|
|
260
|
-
dimensionStyles.value,
|
|
261
|
-
props.style
|
|
262
|
-
];
|
|
373
|
+
return [dimensionStyles.value, props.style];
|
|
263
374
|
});
|
|
264
375
|
const colorPickerCanvasClasses = computed(() => {
|
|
265
|
-
|
|
266
|
-
"origam-color-picker-canvas",
|
|
267
|
-
props.class
|
|
268
|
-
];
|
|
376
|
+
return ["origam-color-picker-canvas", props.class];
|
|
269
377
|
});
|
|
270
378
|
const { id, css, load, isLoaded, unload } = useStyle(colorPickerCanvasStyles, () => props.id);
|
|
379
|
+
/*********************************************************
|
|
380
|
+
* Expose
|
|
381
|
+
*
|
|
382
|
+
* @description
|
|
383
|
+
* Public API surface: filterProps.
|
|
384
|
+
********************************************************/
|
|
271
385
|
defineExpose({
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
386
|
+
filterProps,
|
|
387
|
+
css,
|
|
388
|
+
id,
|
|
389
|
+
load,
|
|
390
|
+
unload,
|
|
391
|
+
isLoaded
|
|
278
392
|
});
|
|
279
393
|
</script>
|
|
280
394
|
|