@thinkpixellab-public/px-vue 4.1.4 → 4.1.5
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/components/PxBalancedText.vue +14 -12
- package/components/PxColorPalette.vue +2 -11
- package/components/PxColorPanel.vue +1 -1
- package/components/PxColorPicker.vue +2 -2
- package/components/PxContain.vue +1 -10
- package/components/PxDatePicker.vue +0 -1
- package/components/PxExpander.vue +1 -7
- package/components/PxFlip.vue +1 -7
- package/components/PxGsapScrubber.vue +0 -1
- package/components/PxLabeledInput.vue +9 -12
- package/components/PxQrCode.vue +1 -7
- package/components/PxSvgRender.vue +1 -2
- package/components/PxSyncHeight.vue +1 -14
- package/components/PxTransition.vue +0 -2
- package/dev/demos/Demo-PxCardGrid.vue +0 -1
- package/dev/demos/Demo-PxContain.vue +1 -7
- package/dev/demos/Demo-PxSideDrawer.vue +1 -8
- package/dev/demos/Demo-PxStylesPreview.vue +0 -2
- package/dev/demos/Demo-PxSwiper.vue +1 -9
- package/package.json +76 -79
- package/components/PxBaseColor.vue +0 -187
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
<component
|
|
6
6
|
:is="calcTag"
|
|
7
7
|
class="px-balanced-text"
|
|
8
|
-
:style="{ opacity: elementOpacity, color: debugColor, textAlign }"
|
|
8
|
+
:style="{ opacity: elementOpacity, color: debugColor, textAlign, width: '100%' }"
|
|
9
9
|
>
|
|
10
10
|
<!-- html -->
|
|
11
11
|
<component
|
|
12
12
|
v-if="hasHtml"
|
|
13
13
|
:class="[bem('inner', { html: true }), innerClass]"
|
|
14
|
-
:style="
|
|
14
|
+
:style="calcInnerStyle"
|
|
15
15
|
:is="calcInnerTag"
|
|
16
16
|
ref="text"
|
|
17
17
|
v-html="html"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<component
|
|
22
22
|
v-else
|
|
23
23
|
:class="[bem('inner'), innerClass]"
|
|
24
|
-
:style="
|
|
24
|
+
:style="calcInnerStyle"
|
|
25
25
|
:is="calcInnerTag"
|
|
26
26
|
ref="text"
|
|
27
27
|
>
|
|
@@ -109,6 +109,17 @@ export default {
|
|
|
109
109
|
const defaultTag = this.hasHtml ? 'div' : 'span';
|
|
110
110
|
return this.innerTag || defaultTag;
|
|
111
111
|
},
|
|
112
|
+
|
|
113
|
+
calcInnerStyle() {
|
|
114
|
+
const style = this.innerStyle || {};
|
|
115
|
+
if (typeof style === 'string') {
|
|
116
|
+
return style + ' display: inline-block;';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
style.display = 'inline-block';
|
|
120
|
+
return style;
|
|
121
|
+
},
|
|
122
|
+
|
|
112
123
|
hasHtml() {
|
|
113
124
|
return !!this.htmlValue && !this.text;
|
|
114
125
|
},
|
|
@@ -204,12 +215,3 @@ export default {
|
|
|
204
215
|
},
|
|
205
216
|
};
|
|
206
217
|
</script>
|
|
207
|
-
|
|
208
|
-
<style lang="scss">
|
|
209
|
-
.px-balanced-text {
|
|
210
|
-
width: 100%;
|
|
211
|
-
&__inner {
|
|
212
|
-
display: inline-block;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
</style>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Describe this component...
|
|
3
3
|
-->
|
|
4
4
|
<template>
|
|
5
|
-
<div
|
|
5
|
+
<div style="display: flex; gap: 0.5em">
|
|
6
6
|
<PxColorPaletteButton
|
|
7
7
|
v-for="(color, index) in calcPalette"
|
|
8
8
|
:key="index"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
25
|
<script>
|
|
26
|
-
import PxBaseColor from '
|
|
26
|
+
import PxBaseColor from '../bases/PxBaseColor.vue';
|
|
27
27
|
import tinycolor from 'tinycolor2';
|
|
28
28
|
import PxColorPaletteButton from './PxColorPaletteButton.vue';
|
|
29
29
|
import PxColorPicker from './PxColorPicker.vue';
|
|
@@ -114,12 +114,3 @@ export default {
|
|
|
114
114
|
},
|
|
115
115
|
};
|
|
116
116
|
</script>
|
|
117
|
-
|
|
118
|
-
<style lang="scss">
|
|
119
|
-
@use '../styles/px.scss' as *;
|
|
120
|
-
|
|
121
|
-
.px-color-palette {
|
|
122
|
-
display: flex;
|
|
123
|
-
gap: 0.5em;
|
|
124
|
-
}
|
|
125
|
-
</style>
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
import Drag from '../utils/drag.js';
|
|
52
52
|
import PxBaseColor from '../bases/PxBaseColor.vue';
|
|
53
53
|
import PxIconButton from './PxIconButton.vue';
|
|
54
|
-
import EyeDropperSvg from '../assets/icons/eyedropper.svg';
|
|
54
|
+
import EyeDropperSvg from '../assets/icons/eyedropper.svg?url';
|
|
55
55
|
|
|
56
56
|
export default {
|
|
57
57
|
name: 'px-color-panel',
|
|
@@ -28,8 +28,8 @@ import PxColorPaletteButton from './PxColorPaletteButton.vue';
|
|
|
28
28
|
import PxBaseColor from '../bases/PxBaseColor.vue';
|
|
29
29
|
import propsFilter from '../utils/propsFilter.js';
|
|
30
30
|
import { PxIcon, PxIconSrcOrAttrs } from './PxIcon.vue';
|
|
31
|
-
import EyeDropperSvg from '../assets/icons/eyedropper.svg';
|
|
32
|
-
import EllipsisSvg from '../assets/icons/ellipsis.svg';
|
|
31
|
+
import EyeDropperSvg from '../assets/icons/eyedropper.svg?url';
|
|
32
|
+
import EllipsisSvg from '../assets/icons/ellipsis.svg?url';
|
|
33
33
|
|
|
34
34
|
const PxColorPicker = {
|
|
35
35
|
name: 'px-color-picker',
|
package/components/PxContain.vue
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
-->
|
|
11
11
|
|
|
12
12
|
<template>
|
|
13
|
-
<div
|
|
13
|
+
<div style="width: 100%; height: 100%; position: relative">
|
|
14
14
|
<slot
|
|
15
15
|
name="default"
|
|
16
16
|
:top="contain.top"
|
|
@@ -336,12 +336,3 @@ export default {
|
|
|
336
336
|
},
|
|
337
337
|
};
|
|
338
338
|
</script>
|
|
339
|
-
|
|
340
|
-
<style lang="scss">
|
|
341
|
-
@use '../styles/px.scss' as *;
|
|
342
|
-
.px-contain {
|
|
343
|
-
width: 100%;
|
|
344
|
-
height: 100%;
|
|
345
|
-
position: relative;
|
|
346
|
-
}
|
|
347
|
-
</style>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<template>
|
|
6
6
|
<px-transition-expand :duration="duration">
|
|
7
|
-
<div
|
|
7
|
+
<div v-show="expanded" style="position: relative">
|
|
8
8
|
<slot />
|
|
9
9
|
</div>
|
|
10
10
|
</px-transition-expand>
|
|
@@ -54,9 +54,3 @@ export default {
|
|
|
54
54
|
},
|
|
55
55
|
};
|
|
56
56
|
</script>
|
|
57
|
-
|
|
58
|
-
<style lang="scss">
|
|
59
|
-
.px-expander {
|
|
60
|
-
position: relative;
|
|
61
|
-
}
|
|
62
|
-
</style>
|
package/components/PxFlip.vue
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
-->
|
|
13
13
|
|
|
14
14
|
<template>
|
|
15
|
-
<div
|
|
15
|
+
<div>
|
|
16
16
|
<!-- in the component -->
|
|
17
17
|
<slot name="default" :state="currentValue">
|
|
18
18
|
<!-- fallback -->
|
|
@@ -91,9 +91,3 @@ export default {
|
|
|
91
91
|
},
|
|
92
92
|
};
|
|
93
93
|
</script>
|
|
94
|
-
|
|
95
|
-
<style lang="scss">
|
|
96
|
-
.px-flip {
|
|
97
|
-
// add styles here
|
|
98
|
-
}
|
|
99
|
-
</style>
|
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
Describe this component...
|
|
3
3
|
-->
|
|
4
4
|
<template>
|
|
5
|
-
<div
|
|
5
|
+
<div
|
|
6
|
+
:class="bem({ ...variantsMap })"
|
|
7
|
+
:style="{
|
|
8
|
+
display: 'flex',
|
|
9
|
+
'align-items': 'flex-start',
|
|
10
|
+
'flex-direction': 'column',
|
|
11
|
+
gap: '0.5em',
|
|
12
|
+
}"
|
|
13
|
+
>
|
|
6
14
|
<label :for="calcInputId" :class="[bem('label'), labelClass]">
|
|
7
15
|
<slot name="label">
|
|
8
16
|
{{ label }}
|
|
@@ -41,14 +49,3 @@ export default {
|
|
|
41
49
|
// methods: {},
|
|
42
50
|
};
|
|
43
51
|
</script>
|
|
44
|
-
|
|
45
|
-
<style lang="scss">
|
|
46
|
-
@use '../styles/px.scss' as *;
|
|
47
|
-
|
|
48
|
-
.px-labeled-input {
|
|
49
|
-
display: flex;
|
|
50
|
-
align-items: flex-start;
|
|
51
|
-
flex-direction: column;
|
|
52
|
-
gap: 0.5em;
|
|
53
|
-
}
|
|
54
|
-
</style>
|
package/components/PxQrCode.vue
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
-->
|
|
8
8
|
<template>
|
|
9
|
-
<div
|
|
9
|
+
<div style="aspect-ratio: 1">
|
|
10
10
|
<qrcode-vue
|
|
11
11
|
v-if="content"
|
|
12
12
|
:value="content"
|
|
@@ -49,9 +49,3 @@ export default {
|
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
</script>
|
|
52
|
-
|
|
53
|
-
<style lang="scss">
|
|
54
|
-
.px-qr-code {
|
|
55
|
-
aspect-ratio: 1;
|
|
56
|
-
}
|
|
57
|
-
</style>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#VUE3 Todo
|
|
3
3
|
-->
|
|
4
4
|
<template>
|
|
5
|
-
<component v-bind:is="tag" :
|
|
5
|
+
<component v-bind:is="tag" :style="{ minHeight: groupHeight + 'px' }">
|
|
6
6
|
<component v-bind:is="innerTag" ref="inner" :class="[bem('inner'), innerClass]">
|
|
7
7
|
<slot />
|
|
8
8
|
</component>
|
|
@@ -125,16 +125,3 @@ export default {
|
|
|
125
125
|
},
|
|
126
126
|
};
|
|
127
127
|
</script>
|
|
128
|
-
|
|
129
|
-
<!-- <style lang="scss">
|
|
130
|
-
.px-sync-height {
|
|
131
|
-
position: relative;
|
|
132
|
-
&__inner {
|
|
133
|
-
position: absolute;
|
|
134
|
-
top: 0;
|
|
135
|
-
left: 0;
|
|
136
|
-
right: 0;
|
|
137
|
-
display: inline;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
</style> -->
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Describe this component...
|
|
3
3
|
-->
|
|
4
4
|
<template>
|
|
5
|
-
<div
|
|
5
|
+
<div>
|
|
6
6
|
<px-tester>
|
|
7
7
|
<px-test name="Aspect" testId="pxcontain-aspect" :size="{ h: 600 }">
|
|
8
8
|
<px-contain aspect="16:9" :px="true">
|
|
@@ -104,9 +104,3 @@ export default {
|
|
|
104
104
|
// methods: {},
|
|
105
105
|
};
|
|
106
106
|
</script>
|
|
107
|
-
|
|
108
|
-
<style lang="scss">
|
|
109
|
-
.demo-px-contain {
|
|
110
|
-
// add styles here
|
|
111
|
-
}
|
|
112
|
-
</style>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Describe this component...
|
|
3
3
|
-->
|
|
4
4
|
<template>
|
|
5
|
-
<div
|
|
5
|
+
<div>
|
|
6
6
|
<px-side-drawer>
|
|
7
7
|
<section>
|
|
8
8
|
<a href="#">Link One</a>
|
|
@@ -60,10 +60,3 @@ export default {
|
|
|
60
60
|
// methods: {},
|
|
61
61
|
};
|
|
62
62
|
</script>
|
|
63
|
-
|
|
64
|
-
<style lang="scss">
|
|
65
|
-
@use '../../styles/px.scss' as *;
|
|
66
|
-
.demo-px-slide-drawer {
|
|
67
|
-
// add styles here
|
|
68
|
-
}
|
|
69
|
-
</style>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Describe this component...
|
|
3
3
|
-->
|
|
4
4
|
<template>
|
|
5
|
-
<div
|
|
5
|
+
<div>
|
|
6
6
|
<px-swiper :loop="true">
|
|
7
7
|
<px-swiper-slide>
|
|
8
8
|
<div class="swiper-max-width">
|
|
@@ -34,11 +34,3 @@ export default {
|
|
|
34
34
|
// methods: {},
|
|
35
35
|
};
|
|
36
36
|
</script>
|
|
37
|
-
|
|
38
|
-
<style lang="scss">
|
|
39
|
-
@use '../../styles/px.scss' as *;
|
|
40
|
-
|
|
41
|
-
.demo-px-swiper {
|
|
42
|
-
// add styles here
|
|
43
|
-
}
|
|
44
|
-
</style>
|
package/package.json
CHANGED
|
@@ -1,81 +1,78 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"url": "https://github.com/thinkpixellab/px-vue/issues"
|
|
79
|
-
},
|
|
80
|
-
"homepage": "https://github.com/thinkpixellab/px-vue#readme"
|
|
2
|
+
"name": "@thinkpixellab-public/px-vue",
|
|
3
|
+
"version": "4.1.5",
|
|
4
|
+
"description": "General purpose Vue components and helpers that can be used across projects.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Pixel Lab"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/thinkpixellab/px-vue.git"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"storybook-px": "PX_LOCAL=1 storybook dev -p 6006",
|
|
16
|
+
"storybook": "storybook dev -p 6006",
|
|
17
|
+
"build-storybook": "storybook build",
|
|
18
|
+
"test": "vitest",
|
|
19
|
+
"serve": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve dev/serve.js",
|
|
20
|
+
"chromatic": "npx chromatic --project-token=chpt_30d6cbeac803e5a"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@floating-ui/dom": "^1.6.13",
|
|
24
|
+
"@popperjs/core": "^2.11.8",
|
|
25
|
+
"@thinkpixellab-public/px-styles": "^4.1.3",
|
|
26
|
+
"@thinkpixellab-public/px-vue-tester": "^2.0.0",
|
|
27
|
+
"@thinkpixellab-public/vue-resize-directive": "^1.2.2",
|
|
28
|
+
"body-scroll-lock": "^3.1.5",
|
|
29
|
+
"chrono-node": "^2.7.8",
|
|
30
|
+
"dateformat": "^5.0.3",
|
|
31
|
+
"gsap": "^3.12.7",
|
|
32
|
+
"highlight.js": "^11.11.1",
|
|
33
|
+
"mitt": "^3.0.1",
|
|
34
|
+
"qrcode.vue": "^3.6.0",
|
|
35
|
+
"sortablejs": "^1.15.6",
|
|
36
|
+
"throttle-debounce": "^5.0.2",
|
|
37
|
+
"tiny-date-picker": "^3.2.8",
|
|
38
|
+
"tinycolor2": "^1.6.0",
|
|
39
|
+
"vue-inline-svg": "^3.1.4"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@babel/core": "^7.26.7",
|
|
43
|
+
"@chromatic-com/storybook": "^3.2.4",
|
|
44
|
+
"@rushstack/eslint-patch": "^1.10.5",
|
|
45
|
+
"@storybook/addon-essentials": "^8.5.3",
|
|
46
|
+
"@storybook/addon-interactions": "^8.5.3",
|
|
47
|
+
"@storybook/addon-links": "^8.5.3",
|
|
48
|
+
"@storybook/addon-mdx-gfm": "^8.5.3",
|
|
49
|
+
"@storybook/blocks": "^8.5.3",
|
|
50
|
+
"@storybook/manager-api": "^8.5.3",
|
|
51
|
+
"@storybook/test": "^8.5.3",
|
|
52
|
+
"@storybook/theming": "^8.5.3",
|
|
53
|
+
"@storybook/vue3": "^8.5.3",
|
|
54
|
+
"@storybook/vue3-vite": "^8.5.3",
|
|
55
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
56
|
+
"@vue/eslint-config-prettier": "^10.2.0",
|
|
57
|
+
"@vue/test-utils": "^2.4.6",
|
|
58
|
+
"babel-eslint": "^10.1.0",
|
|
59
|
+
"babel-loader": "^9.2.1",
|
|
60
|
+
"chromatic": "^11.25.2",
|
|
61
|
+
"eslint": "^9.19.0",
|
|
62
|
+
"eslint-plugin-storybook": "^0.11.2",
|
|
63
|
+
"eslint-plugin-vue": "^9.32.0",
|
|
64
|
+
"jsdom": "^26.0.0",
|
|
65
|
+
"prettier": "^3.4.2",
|
|
66
|
+
"sass": "^1.83.4",
|
|
67
|
+
"storybook": "^8.5.3",
|
|
68
|
+
"storybook-addon-pseudo-states": "^4.0.2",
|
|
69
|
+
"storybook-dark-mode": "^4.0.2",
|
|
70
|
+
"vite": "^6.0.11",
|
|
71
|
+
"vitest": "^3.0.5",
|
|
72
|
+
"vue-loader": "^17.4.2"
|
|
73
|
+
},
|
|
74
|
+
"bugs": {
|
|
75
|
+
"url": "https://github.com/thinkpixellab/px-vue/issues"
|
|
76
|
+
},
|
|
77
|
+
"homepage": "https://github.com/thinkpixellab/px-vue#readme"
|
|
81
78
|
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import tinycolor from 'tinycolor2';
|
|
3
|
-
import {
|
|
4
|
-
hsvaEnsureObject,
|
|
5
|
-
hsvaIsEqual,
|
|
6
|
-
hsvaToHsla,
|
|
7
|
-
hslaToStr,
|
|
8
|
-
hsvaContrastColor,
|
|
9
|
-
} from '../utils/color.js';
|
|
10
|
-
|
|
11
|
-
const TINY_FORMATS = ['rgb', 'prgb', 'hex6', 'hex3', 'hex8', 'name', 'hsl', 'hsv'];
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
name: 'px-color-picker',
|
|
15
|
-
|
|
16
|
-
props: {
|
|
17
|
-
/**
|
|
18
|
-
* The color value.
|
|
19
|
-
*/
|
|
20
|
-
color: { default: '#FF0000' },
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The format of the color value (used for emitting events, v-model, and the default format
|
|
24
|
-
* for getColor). Allowed values are the same as those available from the tinycolor library
|
|
25
|
-
* (rgb, prgb, hex6, hex3, hex8, name, hsl, hsv) as well as 'auto' (which will attempt to
|
|
26
|
-
* use the same format as the last value set with the color prop) and 'tiny' (which will
|
|
27
|
-
* return a tinycolor object) and 'hsva' which will return hsva values as an object. The
|
|
28
|
-
* format has the advantage of not requiring a tinycolor object to be created when the color
|
|
29
|
-
* changes.
|
|
30
|
-
*
|
|
31
|
-
* @values rgb, prgb, hex6, hex3, hex8, name, hsl, hsv, auto, tiny
|
|
32
|
-
*/
|
|
33
|
-
format: { type: String, default: 'hsva' },
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Whether alpha colors are enabled.
|
|
37
|
-
*/
|
|
38
|
-
alphaEnabled: { type: Boolean, default: false },
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
data() {
|
|
42
|
-
return { autoFormat: this.format, h: 0, s: 0, v: 0, a: 1 };
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
computed: {
|
|
46
|
-
hsva() {
|
|
47
|
-
return { h: this.h, s: this.s, v: this.v, a: this.alphaEnabled ? this.a : 1 };
|
|
48
|
-
},
|
|
49
|
-
hsla() {
|
|
50
|
-
return hsvaToHsla(this.hsva);
|
|
51
|
-
},
|
|
52
|
-
hslStr() {
|
|
53
|
-
return hslaToStr(this.hsla, false);
|
|
54
|
-
},
|
|
55
|
-
hslaStr() {
|
|
56
|
-
return hslaToStr(this.hsla, true);
|
|
57
|
-
},
|
|
58
|
-
hslaTransparentStr() {
|
|
59
|
-
return hslaToStr({ ...this.hsla, a: 0 }, true);
|
|
60
|
-
},
|
|
61
|
-
hueStr() {
|
|
62
|
-
return `hsl(${this.h}, 100%, 50%)`;
|
|
63
|
-
},
|
|
64
|
-
contrastStr() {
|
|
65
|
-
return hsvaContrastColor(this.hsva);
|
|
66
|
-
},
|
|
67
|
-
eyedropperSupported() {
|
|
68
|
-
return window?.EyeDropper;
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
watch: {
|
|
73
|
-
color(nv) {
|
|
74
|
-
// update colorValue when color changes
|
|
75
|
-
this.setColor(nv);
|
|
76
|
-
},
|
|
77
|
-
hsla() {
|
|
78
|
-
// emit change when this changes as a proxy for changes to hsva as individual props
|
|
79
|
-
this.emitChange();
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
mounted() {
|
|
84
|
-
if (this.color) {
|
|
85
|
-
this.setColor(this.color);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// TODO: default is hsva, but that isn't in the TINY_FORMATS list
|
|
89
|
-
// if (this.format) {
|
|
90
|
-
// if (!TINY_FORMATS.includes(this.format)) {
|
|
91
|
-
// console.warn(
|
|
92
|
-
// `[PxBaseColor] Invalid format: "${this.format}". See comments in PxBaseColor.vue`,
|
|
93
|
-
// );
|
|
94
|
-
// }
|
|
95
|
-
// }
|
|
96
|
-
},
|
|
97
|
-
methods: {
|
|
98
|
-
setColor(strOrHsva) {
|
|
99
|
-
if (typeof strOrHsva === 'string') {
|
|
100
|
-
this.setColorStr(strOrHsva);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (typeof strOrHsva === 'object') {
|
|
104
|
-
this.setColorHsva(strOrHsva);
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
setColorStr(str) {
|
|
109
|
-
// this is for efficiency but also to prevent color creep as we convert between formats
|
|
110
|
-
if (this.lastEmit == str) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const tiny = tinycolor(str);
|
|
115
|
-
this.autoFormat = tiny.getFormat();
|
|
116
|
-
|
|
117
|
-
const hsva = tiny.toHsv();
|
|
118
|
-
this.setColorHsva(hsva);
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
setColorHsva(hsva) {
|
|
122
|
-
if (this.isCurrentHsva(hsva)) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
this.h = hsva.h;
|
|
127
|
-
this.s = hsva.s;
|
|
128
|
-
this.v = hsva.v;
|
|
129
|
-
this.a = hsva.a;
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
emitChange() {
|
|
133
|
-
const clr = this.getColor(this.format);
|
|
134
|
-
|
|
135
|
-
this.lastEmit = clr;
|
|
136
|
-
|
|
137
|
-
this.$emit('update:color', clr);
|
|
138
|
-
this.$emit('change', clr);
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
getColor(format = null) {
|
|
142
|
-
format = format || this.format;
|
|
143
|
-
|
|
144
|
-
if (format == 'auto') {
|
|
145
|
-
format = this.autoFormat;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
let clr = { h: this.h, s: this.s, v: this.v, a: this.a };
|
|
149
|
-
|
|
150
|
-
if (format == 'hsva') {
|
|
151
|
-
return clr;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (format && [...TINY_FORMATS, 'tiny'].includes(format)) {
|
|
155
|
-
const tiny = tinycolor(clr);
|
|
156
|
-
|
|
157
|
-
if (format == 'tiny') {
|
|
158
|
-
clr = tiny;
|
|
159
|
-
} else {
|
|
160
|
-
clr = tiny.toString(format);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return clr;
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
colorStrToHsva(str) {
|
|
168
|
-
const tiny = tinycolor(str);
|
|
169
|
-
return tiny.toHsv();
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
isCurrentHsva(hOrObj, s, v, a) {
|
|
173
|
-
const hsvaCompare = hsvaEnsureObject(hOrObj, s, v, a);
|
|
174
|
-
return hsvaIsEqual(this.hsva, hsvaCompare);
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
setColorFromEyedropper() {
|
|
178
|
-
if (this.eyedropperSupported) {
|
|
179
|
-
const eyeDropper = new EyeDropper();
|
|
180
|
-
eyeDropper.open().then(result => {
|
|
181
|
-
this.setColorStr(result.sRGBHex);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
</script>
|