@dataloop-ai/components 0.13.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/.eslintrc.js +154 -0
- package/.prettierrc.json +7 -0
- package/Dockerfile +12 -0
- package/LICENSE +201 -0
- package/README.md +43 -0
- package/favicon.ico +0 -0
- package/index.html +13 -0
- package/index.ts +1 -0
- package/jest.config.js +16 -0
- package/jest.setup.js +59 -0
- package/models.ts +1 -0
- package/package.json +109 -0
- package/src/App.vue +201 -0
- package/src/assets/globals.scss +253 -0
- package/src/assets/globalsKeys.ts +28 -0
- package/src/components/DlAccordion/AccordionHeader.vue +148 -0
- package/src/components/DlAccordion/DlAccordion.vue +108 -0
- package/src/components/DlAccordion/index.ts +2 -0
- package/src/components/DlAlert.vue +227 -0
- package/src/components/DlAvatar.vue +99 -0
- package/src/components/DlBadge.vue +127 -0
- package/src/components/DlButton/DlButton.vue +370 -0
- package/src/components/DlButton/index.ts +4 -0
- package/src/components/DlButton/utils.ts +169 -0
- package/src/components/DlButtonGroup.vue +122 -0
- package/src/components/DlCheckbox.vue +298 -0
- package/src/components/DlChip/DlChip.vue +244 -0
- package/src/components/DlChip/index.ts +4 -0
- package/src/components/DlChip/utils.ts +100 -0
- package/src/components/DlColorPicker/DlAlpha.vue +142 -0
- package/src/components/DlColorPicker/DlBox.vue +75 -0
- package/src/components/DlColorPicker/DlColorPicker.vue +306 -0
- package/src/components/DlColorPicker/DlColors.vue +139 -0
- package/src/components/DlColorPicker/DlHue.vue +135 -0
- package/src/components/DlColorPicker/DlPreview.vue +61 -0
- package/src/components/DlColorPicker/DlSaturation.vue +152 -0
- package/src/components/DlColorPicker/constants.ts +16 -0
- package/src/components/DlColorPicker/index.ts +20 -0
- package/src/components/DlColorPicker/types.ts +11 -0
- package/src/components/DlColorPicker/utils.ts +128 -0
- package/src/components/DlCounters.vue +173 -0
- package/src/components/DlDatePicker/DlCalendar.vue +332 -0
- package/src/components/DlDatePicker/DlDatePicker.vue +315 -0
- package/src/components/DlDatePicker/DlMonthCalendar.vue +282 -0
- package/src/components/DlDatePicker/classes/Calendar.ts +110 -0
- package/src/components/DlDatePicker/classes/CalendarDate.ts +12 -0
- package/src/components/DlDatePicker/classes/CustomDate.ts +218 -0
- package/src/components/DlDatePicker/index.ts +3 -0
- package/src/components/DlDatePicker/isInRange.ts +44 -0
- package/src/components/DlDatePicker/types.ts +4 -0
- package/src/components/DlDatePicker/utils.ts +39 -0
- package/src/components/DlDateTimeRange/DlCardSidebar.vue +109 -0
- package/src/components/DlDateTimeRange/DlDateInput.vue +105 -0
- package/src/components/DlDateTimeRange/DlDateTimeRange.vue +468 -0
- package/src/components/DlDateTimeRange/index.ts +3 -0
- package/src/components/DlDateTimeRange/types.ts +42 -0
- package/src/components/DlDialogBox/DlDialogBox.vue +196 -0
- package/src/components/DlDialogBox/DlDialogBoxFooter.vue +22 -0
- package/src/components/DlDialogBox/DlDialogBoxHeader.vue +75 -0
- package/src/components/DlDialogBox/index.ts +5 -0
- package/src/components/DlDropdownButton.vue +463 -0
- package/src/components/DlIcon.vue +147 -0
- package/src/components/DlInfoErrorMessage.vue +91 -0
- package/src/components/DlItem/DlItem.vue +35 -0
- package/src/components/DlItem/index.ts +2 -0
- package/src/components/DlItemSection.vue +88 -0
- package/src/components/DlLink/DlLink.vue +76 -0
- package/src/components/DlLink/index.ts +4 -0
- package/src/components/DlLink/utils.ts +4 -0
- package/src/components/DlList.vue +61 -0
- package/src/components/DlListItem/DlListItem.vue +205 -0
- package/src/components/DlListItem/index.ts +3 -0
- package/src/components/DlListItem/utils.ts +14 -0
- package/src/components/DlMenu/DlMenu.vue +438 -0
- package/src/components/DlMenu/index.ts +3 -0
- package/src/components/DlMenu/utils.ts +138 -0
- package/src/components/DlOptionGroup/DlOptionGroup.vue +201 -0
- package/src/components/DlOptionGroup/MenuItemWrapper.vue +48 -0
- package/src/components/DlOptionGroup/OptionGroup.types.ts +36 -0
- package/src/components/DlOptionGroup/SimpleWrapper.vue +28 -0
- package/src/components/DlOptionGroup/index.ts +4 -0
- package/src/components/DlOptionGroup/utils.ts +40 -0
- package/src/components/DlPagination/DlPagination.vue +184 -0
- package/src/components/DlPagination/PageNavigation.vue +350 -0
- package/src/components/DlPagination/PaginationLegend.vue +41 -0
- package/src/components/DlPagination/QuickNavigation.vue +146 -0
- package/src/components/DlPagination/RowsSelector.vue +74 -0
- package/src/components/DlPagination/index.ts +3 -0
- package/src/components/DlPanelContainer/DlPanel.vue +213 -0
- package/src/components/DlPanelContainer/DlPanelContainer.vue +527 -0
- package/src/components/DlPanelContainer/index.ts +4 -0
- package/src/components/DlPopup/DlPopup.vue +478 -0
- package/src/components/DlPopup/DraggableUpper.vue +64 -0
- package/src/components/DlPopup/PopupHeader.vue +129 -0
- package/src/components/DlPopup/index.ts +1 -0
- package/src/components/DlProgressBar.vue +159 -0
- package/src/components/DlProgressChart.vue +299 -0
- package/src/components/DlRadio.vue +218 -0
- package/src/components/DlRange/DlRange.vue +439 -0
- package/src/components/DlRange/utils.ts +209 -0
- package/src/components/DlSearch.vue +155 -0
- package/src/components/DlSelect/DlSelect.vue +992 -0
- package/src/components/DlSelect/SelectOption.vue +261 -0
- package/src/components/DlSelect/index.ts +4 -0
- package/src/components/DlSelect/utils.ts +43 -0
- package/src/components/DlSkeleton.vue +72 -0
- package/src/components/DlSlider/DlSlider.vue +243 -0
- package/src/components/DlSlider/components/DlSliderBase.vue +380 -0
- package/src/components/DlSlider/components/DlSliderInput.vue +123 -0
- package/src/components/DlSlider/components/index.ts +4 -0
- package/src/components/DlSlider/index.ts +3 -0
- package/src/components/DlSlider/sliderStyles.scss +109 -0
- package/src/components/DlSlider/useSlider.ts +277 -0
- package/src/components/DlSlider/utils.ts +7 -0
- package/src/components/DlSmartSearch/DlJsonEditor.vue +309 -0
- package/src/components/DlSmartSearch/DlSmartSearch.vue +333 -0
- package/src/components/DlSmartSearch/DlSmartSearchInput.vue +741 -0
- package/src/components/DlSmartSearch/DlSuggestionsDropdown.vue +73 -0
- package/src/components/DlSmartSearch/highlightSyntax.ts +169 -0
- package/src/components/DlSmartSearch/index.ts +4 -0
- package/src/components/DlSmartSearch/types.ts +36 -0
- package/src/components/DlSmartSearch/utils.ts +45 -0
- package/src/components/DlStepper/DlStepper.vue +196 -0
- package/src/components/DlStepper/DlStepperContainer.vue +55 -0
- package/src/components/DlStepper/DlStepperContent.vue +101 -0
- package/src/components/DlStepper/DlStepperFooter.vue +133 -0
- package/src/components/DlStepper/DlStepperHeader.vue +49 -0
- package/src/components/DlStepper/DlStepperSidebar.vue +167 -0
- package/src/components/DlStepper/Step.ts +101 -0
- package/src/components/DlStepper/Stepper.ts +107 -0
- package/src/components/DlStepper/index.ts +7 -0
- package/src/components/DlStepper/interfaces.ts +11 -0
- package/src/components/DlSwitch.vue +280 -0
- package/src/components/DlTabPanels/DlTabPanel.vue +22 -0
- package/src/components/DlTabPanels/DlTabPanels.vue +41 -0
- package/src/components/DlTabPanels/index.ts +4 -0
- package/src/components/DlTabPanels/utils.ts +19 -0
- package/src/components/DlTable/DlTable.vue +1264 -0
- package/src/components/DlTable/DlTd.vue +109 -0
- package/src/components/DlTable/DlTh.vue +126 -0
- package/src/components/DlTable/DlTr.vue +44 -0
- package/src/components/DlTable/ResizableManager.ts +233 -0
- package/src/components/DlTable/dl-table-styles.scss +466 -0
- package/src/components/DlTable/hooks/tableActions.ts +64 -0
- package/src/components/DlTable/hooks/tableColumnSelection.ts +112 -0
- package/src/components/DlTable/hooks/tableFilter.ts +42 -0
- package/src/components/DlTable/hooks/tablePagination.ts +197 -0
- package/src/components/DlTable/hooks/tableRowExpand.ts +55 -0
- package/src/components/DlTable/hooks/tableRowSelection.ts +106 -0
- package/src/components/DlTable/hooks/tableSort.ts +125 -0
- package/src/components/DlTable/index.ts +6 -0
- package/src/components/DlTable/types.ts +96 -0
- package/src/components/DlTabs/DlTab.vue +146 -0
- package/src/components/DlTabs/DlTabs.vue +192 -0
- package/src/components/DlTabs/TabsWrapper.vue +104 -0
- package/src/components/DlTabs/index.ts +4 -0
- package/src/components/DlTabs/types.ts +8 -0
- package/src/components/DlTextArea.vue +151 -0
- package/src/components/DlTextHolder.vue +65 -0
- package/src/components/DlTextInput.vue +753 -0
- package/src/components/DlThemeProvider.vue +41 -0
- package/src/components/DlTimePicker/DlTimeCounter.vue +81 -0
- package/src/components/DlTimePicker/DlTimePicker.vue +151 -0
- package/src/components/DlTimePicker/DlTimePickerInput.vue +311 -0
- package/src/components/DlTimePicker/index.ts +3 -0
- package/src/components/DlTimePicker/types.ts +4 -0
- package/src/components/DlTooltip.vue +456 -0
- package/src/components/DlTrend.vue +97 -0
- package/src/components/DlTypography.vue +87 -0
- package/src/components/DlVirtualScroll/DlVirtualScroll.vue +290 -0
- package/src/components/DlVirtualScroll/index.ts +3 -0
- package/src/components/DlVirtualScroll/useVirtualScroll.ts +833 -0
- package/src/components/DlWidget/DlWidget.vue +50 -0
- package/src/components/DlWidget/DlWidgetGrid.vue +360 -0
- package/src/components/DlWidget/index.ts +4 -0
- package/src/components/DlWidget/types.ts +6 -0
- package/src/components/DlWidget/utils.ts +30 -0
- package/src/components/index.ts +118 -0
- package/src/demo/DlAccordionDemo.vue +60 -0
- package/src/demo/DlAlertDemo.vue +54 -0
- package/src/demo/DlAvatarDemo.vue +43 -0
- package/src/demo/DlBadgeDemo.vue +65 -0
- package/src/demo/DlButtonDemo.vue +266 -0
- package/src/demo/DlCheckboxDemo.vue +50 -0
- package/src/demo/DlChipDemo.vue +181 -0
- package/src/demo/DlColorPickerDemo.vue +43 -0
- package/src/demo/DlCounterDemo.vue +53 -0
- package/src/demo/DlDateTimeRangeDemo.vue +217 -0
- package/src/demo/DlDialogBoxDemo.vue +175 -0
- package/src/demo/DlDropdownButtonDemo.vue +260 -0
- package/src/demo/DlIconDemo.vue +47 -0
- package/src/demo/DlLinkDemo.vue +23 -0
- package/src/demo/DlListDemo.vue +177 -0
- package/src/demo/DlMenuDemo.vue +524 -0
- package/src/demo/DlOptionGroupDemo.vue +79 -0
- package/src/demo/DlPaginationDemo.vue +44 -0
- package/src/demo/DlPanelContainerDemo.vue +221 -0
- package/src/demo/DlPopupDemo.vue +58 -0
- package/src/demo/DlProgressBarDemo.vue +22 -0
- package/src/demo/DlProgressChartDemo.vue +71 -0
- package/src/demo/DlRadioDemo.vue +35 -0
- package/src/demo/DlRangeDemo.vue +44 -0
- package/src/demo/DlSearchDemo.vue +27 -0
- package/src/demo/DlSelectDemo.vue +355 -0
- package/src/demo/DlSkeletonDemo.vue +20 -0
- package/src/demo/DlSliderDemo.vue +47 -0
- package/src/demo/DlStepperDemo/CenteredStepperInDialogBox.vue +260 -0
- package/src/demo/DlStepperDemo/SimpleStepper.vue +202 -0
- package/src/demo/DlStepperDemo/StepperInDialogBox.vue +261 -0
- package/src/demo/DlStepperDemo/index.ts +5 -0
- package/src/demo/DlStepperDemo/steps/AssignmentsStep.vue +97 -0
- package/src/demo/DlStepperDemo/steps/DataStep.vue +158 -0
- package/src/demo/DlStepperDemo/steps/GeneralStep.vue +106 -0
- package/src/demo/DlStepperDemo/steps/InstructionStep.vue +176 -0
- package/src/demo/DlStepperDemo/steps/QualityStep.vue +65 -0
- package/src/demo/DlSwitchDemo.vue +49 -0
- package/src/demo/DlTableDemo.vue +475 -0
- package/src/demo/DlTabsDemo.vue +67 -0
- package/src/demo/DlTdDemo.vue +19 -0
- package/src/demo/DlTextAreaDemo.vue +37 -0
- package/src/demo/DlTextHolderDemo.vue +42 -0
- package/src/demo/DlTextInputDemo.vue +89 -0
- package/src/demo/DlThDemo.vue +32 -0
- package/src/demo/DlTooltipDemo.vue +60 -0
- package/src/demo/DlTrDemo.vue +18 -0
- package/src/demo/DlTrendDemo.vue +25 -0
- package/src/demo/DlTypographyDemo.vue +93 -0
- package/src/demo/DlWidgetDemo.vue +157 -0
- package/src/demo/SmartSearchDemo/DlSmartSearchDemo.vue +202 -0
- package/src/demo/SmartSearchDemo/schema.ts +44 -0
- package/src/demo/index.ts +141 -0
- package/src/directives/TouchPan.ts +525 -0
- package/src/env.d.ts +8 -0
- package/src/hooks/use-anchor.ts +223 -0
- package/src/hooks/use-model-toggle.ts +181 -0
- package/src/hooks/use-portal.ts +104 -0
- package/src/hooks/use-scroll-target.ts +53 -0
- package/src/hooks/use-size-observer.ts +24 -0
- package/src/hooks/use-suggestions.ts +355 -0
- package/src/hooks/use-tick.ts +32 -0
- package/src/hooks/use-timeout.ts +20 -0
- package/src/hooks/use-transition.ts +32 -0
- package/src/hooks/use-window-size.ts +25 -0
- package/src/hooks/useForm.ts +12 -0
- package/src/index.ts +7 -0
- package/src/main.ts +4 -0
- package/src/models.ts +4 -0
- package/src/types.ts +6 -0
- package/src/utils/calcs.ts +18 -0
- package/src/utils/click-outside.ts +108 -0
- package/src/utils/component-name-parser.ts +1 -0
- package/src/utils/css-color-names.ts +150 -0
- package/src/utils/dom.ts +55 -0
- package/src/utils/draggable-table.ts +416 -0
- package/src/utils/escape-key.ts +54 -0
- package/src/utils/events.ts +67 -0
- package/src/utils/focus-manager.ts +33 -0
- package/src/utils/focusout.ts +29 -0
- package/src/utils/format.ts +3 -0
- package/src/utils/getColor.ts +17 -0
- package/src/utils/getLighterGradient.ts +36 -0
- package/src/utils/getRootStyles.ts +52 -0
- package/src/utils/global-config.ts +6 -0
- package/src/utils/global-nodes.ts +42 -0
- package/src/utils/includes.ts +3 -0
- package/src/utils/index.ts +29 -0
- package/src/utils/inject-object-prop.ts +21 -0
- package/src/utils/input-sizes.ts +7 -0
- package/src/utils/is-ellipsis-active.ts +3 -0
- package/src/utils/is-in-viewport.ts +13 -0
- package/src/utils/is.ts +15 -0
- package/src/utils/key-composition.ts +17 -0
- package/src/utils/keyCodes.ts +12 -0
- package/src/utils/logger/ConsoleLogger.ts +65 -0
- package/src/utils/logger/ILogger.ts +8 -0
- package/src/utils/logger/index.ts +8 -0
- package/src/utils/nav-keys-constants.ts +1 -0
- package/src/utils/portal.ts +55 -0
- package/src/utils/position-engine.ts +381 -0
- package/src/utils/render.ts +36 -0
- package/src/utils/ripple.ts +7 -0
- package/src/utils/scroll.ts +73 -0
- package/src/utils/selection.ts +15 -0
- package/src/utils/sort.ts +7 -0
- package/src/utils/splitByQuotes.ts +32 -0
- package/src/utils/string.ts +6 -0
- package/src/utils/teleport.ts +14 -0
- package/src/utils/theme.ts +2 -0
- package/src/utils/vm.ts +16 -0
- package/storybook.js +8 -0
- package/tsconfig.json +44 -0
- package/tsconfig.node.json +8 -0
- package/types.ts +1 -0
- package/vite.config.ts +13 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="hue"
|
|
4
|
+
@mousedown.prevent.stop="selectHue"
|
|
5
|
+
>
|
|
6
|
+
<canvas ref="canvasHue" />
|
|
7
|
+
<div
|
|
8
|
+
:style="slideHueStyle"
|
|
9
|
+
class="slide"
|
|
10
|
+
/>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
import { defineComponent } from 'vue-demi'
|
|
16
|
+
|
|
17
|
+
export default defineComponent({
|
|
18
|
+
name: 'DlHue',
|
|
19
|
+
props: {
|
|
20
|
+
hsv: {
|
|
21
|
+
type: Object,
|
|
22
|
+
default: () => ({
|
|
23
|
+
h: 0,
|
|
24
|
+
s: 0,
|
|
25
|
+
v: 0
|
|
26
|
+
})
|
|
27
|
+
},
|
|
28
|
+
width: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 14
|
|
31
|
+
},
|
|
32
|
+
height: {
|
|
33
|
+
type: Number,
|
|
34
|
+
default: 152
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
emits: ['selectHue', 'updateHue'],
|
|
38
|
+
data() {
|
|
39
|
+
return {
|
|
40
|
+
slideHueStyle: {}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
mounted() {
|
|
44
|
+
this.renderColor()
|
|
45
|
+
this.renderSlide()
|
|
46
|
+
},
|
|
47
|
+
methods: {
|
|
48
|
+
renderColor() {
|
|
49
|
+
const canvas = this.$refs.canvasHue as HTMLCanvasElement
|
|
50
|
+
const width = this.width
|
|
51
|
+
const height = this.height
|
|
52
|
+
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D
|
|
53
|
+
canvas.width = width
|
|
54
|
+
canvas.height = height
|
|
55
|
+
|
|
56
|
+
const gradient = ctx.createLinearGradient(0, 0, 0, height)
|
|
57
|
+
gradient.addColorStop(0, '#FF0000')
|
|
58
|
+
gradient.addColorStop(0.17 * 1, '#FF00FF')
|
|
59
|
+
gradient.addColorStop(0.17 * 2, '#0000FF')
|
|
60
|
+
gradient.addColorStop(0.17 * 3, '#00FFFF')
|
|
61
|
+
gradient.addColorStop(0.17 * 4, '#00FF00')
|
|
62
|
+
gradient.addColorStop(0.17 * 5, '#FFFF00')
|
|
63
|
+
gradient.addColorStop(1, '#FF0000')
|
|
64
|
+
ctx.fillStyle = gradient
|
|
65
|
+
ctx.fillRect(0, 0, width, height)
|
|
66
|
+
},
|
|
67
|
+
renderSlide() {
|
|
68
|
+
this.slideHueStyle = {
|
|
69
|
+
top: (1 - this.hsv.h / 360) * this.height - 2 + 'px'
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
selectHue(e: MouseEvent) {
|
|
73
|
+
const { top: hueTop } = this.$el.getBoundingClientRect()
|
|
74
|
+
const ctx = (e.target as HTMLCanvasElement).getContext(
|
|
75
|
+
'2d'
|
|
76
|
+
) as CanvasRenderingContext2D
|
|
77
|
+
let color: { r: number; g: number; b: number } = null
|
|
78
|
+
|
|
79
|
+
const mousemove = (e: MouseEvent) => {
|
|
80
|
+
let y = e.clientY - hueTop
|
|
81
|
+
|
|
82
|
+
if (y < 0) {
|
|
83
|
+
y = 0
|
|
84
|
+
}
|
|
85
|
+
if (y > this.height) {
|
|
86
|
+
y = this.height
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.slideHueStyle = {
|
|
90
|
+
top: y - 2 + 'px'
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const imgData = ctx.getImageData(
|
|
94
|
+
0,
|
|
95
|
+
Math.min(y, this.height - 1),
|
|
96
|
+
1,
|
|
97
|
+
1
|
|
98
|
+
)
|
|
99
|
+
const [r, g, b] = imgData.data
|
|
100
|
+
color = { r, g, b }
|
|
101
|
+
this.$emit('selectHue', color)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
mousemove(e)
|
|
105
|
+
|
|
106
|
+
const mouseup = () => {
|
|
107
|
+
document.removeEventListener('mousemove', mousemove)
|
|
108
|
+
document.removeEventListener('mouseup', mouseup)
|
|
109
|
+
this.$emit('updateHue', color)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
document.addEventListener('mousemove', mousemove)
|
|
113
|
+
document.addEventListener('mouseup', mouseup)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<style scoped lang="scss">
|
|
120
|
+
.hue {
|
|
121
|
+
position: relative;
|
|
122
|
+
margin-left: 10px;
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
.slide {
|
|
125
|
+
position: absolute;
|
|
126
|
+
left: 0;
|
|
127
|
+
top: 100px;
|
|
128
|
+
width: 100%;
|
|
129
|
+
height: 4px;
|
|
130
|
+
background: #fff;
|
|
131
|
+
box-shadow: 0 0 1px 0 rgba(0, 0, 0, 0.3);
|
|
132
|
+
pointer-events: none;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
</style>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<canvas style="border-radius: 2px" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { defineComponent } from 'vue-demi'
|
|
7
|
+
import { createAlphaSquare } from './utils'
|
|
8
|
+
|
|
9
|
+
export default defineComponent({
|
|
10
|
+
name: 'DlPreview',
|
|
11
|
+
props: {
|
|
12
|
+
color: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: '#000000'
|
|
15
|
+
},
|
|
16
|
+
width: {
|
|
17
|
+
type: Number,
|
|
18
|
+
default: 100
|
|
19
|
+
},
|
|
20
|
+
height: {
|
|
21
|
+
type: Number,
|
|
22
|
+
default: 28
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
data() {
|
|
26
|
+
return {
|
|
27
|
+
alphaSize: 5
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
watch: {
|
|
31
|
+
color() {
|
|
32
|
+
this.renderColor()
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
mounted() {
|
|
36
|
+
this.renderColor()
|
|
37
|
+
},
|
|
38
|
+
methods: {
|
|
39
|
+
renderColor() {
|
|
40
|
+
const canvas = this.$el as HTMLCanvasElement
|
|
41
|
+
const width = this.width
|
|
42
|
+
const height = this.height
|
|
43
|
+
const size = this.alphaSize
|
|
44
|
+
const canvasSquare = createAlphaSquare(size)
|
|
45
|
+
|
|
46
|
+
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D
|
|
47
|
+
canvas.width = width
|
|
48
|
+
canvas.height = height
|
|
49
|
+
|
|
50
|
+
ctx.fillStyle = ctx.createPattern(
|
|
51
|
+
canvasSquare,
|
|
52
|
+
'repeat'
|
|
53
|
+
) as CanvasPattern
|
|
54
|
+
ctx.fillRect(0, 0, width, height)
|
|
55
|
+
|
|
56
|
+
ctx.fillStyle = this.color
|
|
57
|
+
ctx.fillRect(0, 0, width, height)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
</script>
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="saturation"
|
|
4
|
+
@mousedown.prevent.stop="selectSaturation"
|
|
5
|
+
>
|
|
6
|
+
<canvas ref="canvasSaturation" />
|
|
7
|
+
<div
|
|
8
|
+
:style="slideSaturationStyle"
|
|
9
|
+
class="slide"
|
|
10
|
+
/>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
import { defineComponent } from 'vue-demi'
|
|
16
|
+
import { createLinearGradient } from './utils'
|
|
17
|
+
|
|
18
|
+
export default defineComponent({
|
|
19
|
+
name: 'DlSaturation',
|
|
20
|
+
props: {
|
|
21
|
+
color: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: '#000000'
|
|
24
|
+
},
|
|
25
|
+
hsv: {
|
|
26
|
+
type: Object,
|
|
27
|
+
default: () => ({
|
|
28
|
+
h: 0,
|
|
29
|
+
s: 0,
|
|
30
|
+
v: 0
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
size: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default: 152
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
emits: ['selectSaturation', 'updateSaturation'],
|
|
39
|
+
data() {
|
|
40
|
+
return {
|
|
41
|
+
slideSaturationStyle: {}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
mounted() {
|
|
45
|
+
this.renderColor()
|
|
46
|
+
this.renderSlide()
|
|
47
|
+
},
|
|
48
|
+
methods: {
|
|
49
|
+
renderColor() {
|
|
50
|
+
const canvas = this.$refs.canvasSaturation as HTMLCanvasElement
|
|
51
|
+
const size = this.size
|
|
52
|
+
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D
|
|
53
|
+
canvas.width = size
|
|
54
|
+
canvas.height = size
|
|
55
|
+
|
|
56
|
+
ctx.fillStyle = this.color
|
|
57
|
+
ctx.fillRect(0, 0, size, size)
|
|
58
|
+
|
|
59
|
+
createLinearGradient(
|
|
60
|
+
'l',
|
|
61
|
+
ctx,
|
|
62
|
+
size,
|
|
63
|
+
size,
|
|
64
|
+
'#FFFFFF',
|
|
65
|
+
'rgba(255,255,255,0)'
|
|
66
|
+
)
|
|
67
|
+
createLinearGradient(
|
|
68
|
+
'p',
|
|
69
|
+
ctx,
|
|
70
|
+
size,
|
|
71
|
+
size,
|
|
72
|
+
'rgba(0,0,0,0)',
|
|
73
|
+
'#000000'
|
|
74
|
+
)
|
|
75
|
+
},
|
|
76
|
+
renderSlide() {
|
|
77
|
+
this.slideSaturationStyle = {
|
|
78
|
+
left: this.hsv.s * this.size - 5 + 'px',
|
|
79
|
+
top: (1 - this.hsv.v) * this.size - 5 + 'px'
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
selectSaturation(e: any) {
|
|
83
|
+
const { top: saturationTop, left: saturationLeft } =
|
|
84
|
+
this.$el.getBoundingClientRect()
|
|
85
|
+
const ctx = e.target.getContext('2d')
|
|
86
|
+
let color: { r: number; g: number; b: number } = null
|
|
87
|
+
|
|
88
|
+
const mousemove = (e: MouseEvent) => {
|
|
89
|
+
let x = e.clientX - saturationLeft
|
|
90
|
+
let y = e.clientY - saturationTop
|
|
91
|
+
|
|
92
|
+
if (x < 0) {
|
|
93
|
+
x = 0
|
|
94
|
+
}
|
|
95
|
+
if (y < 0) {
|
|
96
|
+
y = 0
|
|
97
|
+
}
|
|
98
|
+
if (x > this.size) {
|
|
99
|
+
x = this.size
|
|
100
|
+
}
|
|
101
|
+
if (y > this.size) {
|
|
102
|
+
y = this.size
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.slideSaturationStyle = {
|
|
106
|
+
left: x - 5 + 'px',
|
|
107
|
+
top: y - 5 + 'px'
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const imgData = ctx.getImageData(
|
|
111
|
+
Math.min(x, this.size - 1),
|
|
112
|
+
Math.min(y, this.size - 1),
|
|
113
|
+
1,
|
|
114
|
+
1
|
|
115
|
+
)
|
|
116
|
+
const [r, g, b] = imgData.data
|
|
117
|
+
color = { r, g, b }
|
|
118
|
+
this.$emit('selectSaturation', color)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
mousemove(e)
|
|
122
|
+
|
|
123
|
+
const mouseup = () => {
|
|
124
|
+
document.removeEventListener('mousemove', mousemove)
|
|
125
|
+
document.removeEventListener('mouseup', mouseup)
|
|
126
|
+
this.$emit('updateSaturation', color)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
document.addEventListener('mousemove', mousemove)
|
|
130
|
+
document.addEventListener('mouseup', mouseup)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<style scoped lang="scss">
|
|
137
|
+
.saturation {
|
|
138
|
+
position: relative;
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
.slide {
|
|
141
|
+
position: absolute;
|
|
142
|
+
left: 100px;
|
|
143
|
+
top: 0;
|
|
144
|
+
width: 10px;
|
|
145
|
+
height: 10px;
|
|
146
|
+
border-radius: 50%;
|
|
147
|
+
border: 1px solid #fff;
|
|
148
|
+
box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.3);
|
|
149
|
+
pointer-events: none;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import DlColorPicker from './DlColorPicker.vue'
|
|
2
|
+
import DlColors from './DlColors.vue'
|
|
3
|
+
import DlHue from './DlHue.vue'
|
|
4
|
+
import DlPreview from './DlPreview.vue'
|
|
5
|
+
import DlSaturation from './DlSaturation.vue'
|
|
6
|
+
import DlBox from './DlBox.vue'
|
|
7
|
+
import DlAlpha from './DlAlpha.vue'
|
|
8
|
+
|
|
9
|
+
export * from './types'
|
|
10
|
+
export * from './utils'
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
DlColorPicker,
|
|
14
|
+
DlColors,
|
|
15
|
+
DlHue,
|
|
16
|
+
DlPreview,
|
|
17
|
+
DlSaturation,
|
|
18
|
+
DlBox,
|
|
19
|
+
DlAlpha
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type RGBColor = { r: number; g: number; b: number }
|
|
2
|
+
export type RGBAColor = { r: number; g: number; b: number; a: number }
|
|
3
|
+
export type HSVColor = { h: number; s: number; v: number }
|
|
4
|
+
|
|
5
|
+
export type ColorValue = RGBAColor & HSVColor
|
|
6
|
+
|
|
7
|
+
export type NewColor = {
|
|
8
|
+
rgba: RGBAColor
|
|
9
|
+
hsv: HSVColor
|
|
10
|
+
hex: string
|
|
11
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ColorValue, HSVColor, RGBAColor, RGBColor } from './types'
|
|
2
|
+
|
|
3
|
+
export function setColorValue(color: any): ColorValue {
|
|
4
|
+
let rgba: RGBAColor = { r: 0, g: 0, b: 0, a: 1 }
|
|
5
|
+
if (/#/.test(color)) {
|
|
6
|
+
rgba = hex2rgb(color)
|
|
7
|
+
} else if (/rgb/.test(color)) {
|
|
8
|
+
rgba = rgb2rgba(color)
|
|
9
|
+
} else if (typeof color === 'string') {
|
|
10
|
+
rgba = rgb2rgba(`rgba(${color})`)
|
|
11
|
+
} else if (Object.prototype.toString.call(color) === '[object Object]') {
|
|
12
|
+
rgba = color
|
|
13
|
+
}
|
|
14
|
+
const { r, g, b, a = 1 } = rgba
|
|
15
|
+
const { h, s, v } = rgb2hsv(rgba)
|
|
16
|
+
return { r, g, b, a, h, s, v }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function createAlphaSquare(size: number): HTMLCanvasElement {
|
|
20
|
+
const canvas = document.createElement('canvas')
|
|
21
|
+
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D
|
|
22
|
+
|
|
23
|
+
const doubleSize = size * 2
|
|
24
|
+
canvas.width = doubleSize
|
|
25
|
+
canvas.height = doubleSize
|
|
26
|
+
|
|
27
|
+
ctx.fillStyle = '#ffffff'
|
|
28
|
+
ctx.fillRect(0, 0, doubleSize, doubleSize)
|
|
29
|
+
ctx.fillStyle = '#ccd5db'
|
|
30
|
+
ctx.fillRect(0, 0, size, size)
|
|
31
|
+
ctx.fillRect(size, size, size, size)
|
|
32
|
+
|
|
33
|
+
return canvas
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function createLinearGradient(
|
|
37
|
+
direction: string,
|
|
38
|
+
ctx: CanvasRenderingContext2D,
|
|
39
|
+
width: number,
|
|
40
|
+
height: number,
|
|
41
|
+
color1: string,
|
|
42
|
+
color2: string
|
|
43
|
+
): void {
|
|
44
|
+
const isL = direction === 'l'
|
|
45
|
+
const gradient = ctx.createLinearGradient(
|
|
46
|
+
0,
|
|
47
|
+
0,
|
|
48
|
+
isL ? width : 0,
|
|
49
|
+
isL ? 0 : height
|
|
50
|
+
)
|
|
51
|
+
gradient.addColorStop(0.01, color1)
|
|
52
|
+
gradient.addColorStop(0.99, color2)
|
|
53
|
+
ctx.fillStyle = gradient
|
|
54
|
+
ctx.fillRect(0, 0, width, height)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function rgb2hex({ r, g, b }: RGBColor, toUpper: boolean): string {
|
|
58
|
+
const change = (val: number) => ('0' + Number(val).toString(16)).slice(-2)
|
|
59
|
+
const color = `#${change(r)}${change(g)}${change(b)}`
|
|
60
|
+
return toUpper ? color.toUpperCase() : color
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function hex2rgb(hex: string): RGBAColor {
|
|
64
|
+
hex = hex.slice(1)
|
|
65
|
+
|
|
66
|
+
const change = (val: string) => parseInt(val, 16) || 0
|
|
67
|
+
|
|
68
|
+
if (hex.length === 3) {
|
|
69
|
+
if (hex[0] === hex[1] && hex[0] === hex[2]) {
|
|
70
|
+
return {
|
|
71
|
+
r: change(hex.slice(0, 2)),
|
|
72
|
+
g: change(hex.slice(0, 2)),
|
|
73
|
+
b: change(hex.slice(0, 2)),
|
|
74
|
+
a: 1
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
r: change(hex.slice(0, 2)),
|
|
81
|
+
g: change(hex.slice(2, 4)),
|
|
82
|
+
b: change(hex.slice(4, 6)),
|
|
83
|
+
a: 1
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function rgb2rgba(value: string | any): RGBAColor {
|
|
88
|
+
value = (/rgba?\((.*?)\)/.exec(value) || ['', '0,0,0,1'])[1].split(',')
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
r: Number(value[0]) || 0,
|
|
92
|
+
g: Number(value[1]) || 0,
|
|
93
|
+
b: Number(value[2]) || 0,
|
|
94
|
+
a: Number(value[3] ? value[3] : 1)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function rgb2hsv(rgbColor: RGBColor): HSVColor {
|
|
99
|
+
const r = rgbColor.r / 255
|
|
100
|
+
const g = rgbColor.g / 255
|
|
101
|
+
const b = rgbColor.b / 255
|
|
102
|
+
|
|
103
|
+
const max = Math.max(r, g, b)
|
|
104
|
+
const min = Math.min(r, g, b)
|
|
105
|
+
const delta = max - min
|
|
106
|
+
|
|
107
|
+
let h = 0
|
|
108
|
+
if (max === min) {
|
|
109
|
+
h = 0
|
|
110
|
+
} else if (max === r) {
|
|
111
|
+
if (g >= b) {
|
|
112
|
+
h = (60 * (g - b)) / delta
|
|
113
|
+
} else {
|
|
114
|
+
h = (60 * (g - b)) / delta + 360
|
|
115
|
+
}
|
|
116
|
+
} else if (max === g) {
|
|
117
|
+
h = (60 * (b - r)) / delta + 120
|
|
118
|
+
} else if (max === b) {
|
|
119
|
+
h = (60 * (r - g)) / delta + 240
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
h = Math.floor(h)
|
|
123
|
+
|
|
124
|
+
const s = parseFloat((max === 0 ? 0 : 1 - min / max).toFixed(2))
|
|
125
|
+
const v = parseFloat(max.toFixed(2))
|
|
126
|
+
|
|
127
|
+
return { h, s, v }
|
|
128
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="uuid"
|
|
4
|
+
class="container"
|
|
5
|
+
>
|
|
6
|
+
<ul>
|
|
7
|
+
<li
|
|
8
|
+
v-for="(item, index) in items"
|
|
9
|
+
:key="index"
|
|
10
|
+
class="item"
|
|
11
|
+
>
|
|
12
|
+
<div :class="computeClass('item-content')">
|
|
13
|
+
<p :class="computeClass('item-value')">
|
|
14
|
+
{{ item.value }}
|
|
15
|
+
</p>
|
|
16
|
+
<p
|
|
17
|
+
v-show="item.text"
|
|
18
|
+
class="item-text"
|
|
19
|
+
>
|
|
20
|
+
{{ capitalize(item.text) }}
|
|
21
|
+
</p>
|
|
22
|
+
<p
|
|
23
|
+
v-show="item.subtext"
|
|
24
|
+
class="item-subtext"
|
|
25
|
+
>
|
|
26
|
+
{{ item.subtext && capitalize(item.subtext) }}
|
|
27
|
+
</p>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="divider" />
|
|
30
|
+
</li>
|
|
31
|
+
</ul>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script lang="ts">
|
|
36
|
+
import { v4 } from 'uuid'
|
|
37
|
+
import { defineComponent, PropType } from 'vue-demi'
|
|
38
|
+
|
|
39
|
+
interface CounterItem {
|
|
40
|
+
value?: number
|
|
41
|
+
text: string
|
|
42
|
+
subtext?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default defineComponent({
|
|
46
|
+
name: 'DlCounters',
|
|
47
|
+
props: {
|
|
48
|
+
small: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false
|
|
51
|
+
},
|
|
52
|
+
items: {
|
|
53
|
+
type: Array as PropType<CounterItem[]>,
|
|
54
|
+
default: (): CounterItem[] => [],
|
|
55
|
+
validator(value: CounterItem[]): boolean {
|
|
56
|
+
return value.length <= 8
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
data() {
|
|
61
|
+
return {
|
|
62
|
+
uuid: `dl-counters-${v4()}`
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
methods: {
|
|
66
|
+
capitalize(value: string): string {
|
|
67
|
+
return value[0].toUpperCase() + value.slice(1)
|
|
68
|
+
},
|
|
69
|
+
computeClass(value: string): (string | boolean)[] {
|
|
70
|
+
return [value, this.small && `${value}--small`]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<style scoped lang="scss">
|
|
77
|
+
.container {
|
|
78
|
+
padding: 10px;
|
|
79
|
+
width: fit-content;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ul {
|
|
83
|
+
list-style-type: none;
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
margin: 0;
|
|
86
|
+
padding: 0;
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: stretch;
|
|
89
|
+
|
|
90
|
+
.item {
|
|
91
|
+
display: flex;
|
|
92
|
+
justify-content: center;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.item-content {
|
|
96
|
+
display: flex;
|
|
97
|
+
flex-direction: column;
|
|
98
|
+
align-items: center;
|
|
99
|
+
padding-left: 30px;
|
|
100
|
+
padding-right: 30px;
|
|
101
|
+
|
|
102
|
+
&--small {
|
|
103
|
+
padding-left: 20px;
|
|
104
|
+
padding-right: 20px;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.item-value {
|
|
109
|
+
font-size: var(--dl-font-size-h1);
|
|
110
|
+
color: var(--dl-color-secondary);
|
|
111
|
+
padding: 2px;
|
|
112
|
+
margin: 0;
|
|
113
|
+
line-height: 35px;
|
|
114
|
+
|
|
115
|
+
&--small {
|
|
116
|
+
line-height: 23px;
|
|
117
|
+
font-size: var(--dl-font-size-h2);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.item-text {
|
|
122
|
+
font-size: var(--dl-font-size-h4);
|
|
123
|
+
color: var(--dl-color-darker);
|
|
124
|
+
margin: 0;
|
|
125
|
+
text-align: center;
|
|
126
|
+
max-width: 130px;
|
|
127
|
+
line-height: 18px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.item-subtext {
|
|
131
|
+
font-size: var(--dl-font-size-body);
|
|
132
|
+
color: var(--dl-color-medium);
|
|
133
|
+
margin: 0;
|
|
134
|
+
text-align: center;
|
|
135
|
+
max-width: 130px;
|
|
136
|
+
padding-top: 2px;
|
|
137
|
+
overflow: hidden;
|
|
138
|
+
text-overflow: ellipsis;
|
|
139
|
+
line-height: 16px;
|
|
140
|
+
max-height: 35.1px;
|
|
141
|
+
white-space: pre-wrap;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.divider {
|
|
145
|
+
display: block;
|
|
146
|
+
background-color: var(--dl-color-separator);
|
|
147
|
+
width: 1px;
|
|
148
|
+
align-self: stretch;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
li {
|
|
152
|
+
float: left;
|
|
153
|
+
text-decoration: none;
|
|
154
|
+
position: relative;
|
|
155
|
+
|
|
156
|
+
&:first-child {
|
|
157
|
+
.item-content {
|
|
158
|
+
padding-left: 0;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&:last-child {
|
|
163
|
+
.divider {
|
|
164
|
+
display: none;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.item-content {
|
|
168
|
+
padding-right: 0;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
</style>
|