@thinkpixellab-public/px-vue 4.1.4 → 4.1.6

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.
@@ -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="innerStyle"
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="innerStyle"
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 :class="bem()">
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 './PxBaseColor.vue';
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>
@@ -36,6 +36,7 @@ export default {
36
36
  </script>
37
37
 
38
38
  <style lang="scss">
39
+ @use 'sass:string';
39
40
  @use '../styles/px.scss' as *;
40
41
 
41
42
  @function color-wheel-gradient($count, $blend: true, $sat: 100%, $light: 50%) {
@@ -53,7 +54,7 @@ export default {
53
54
  }
54
55
  }
55
56
 
56
- @return unquote($grad);
57
+ @return string.unquote($grad);
57
58
  }
58
59
 
59
60
  .px-color-palette-button {
@@ -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',
@@ -10,7 +10,7 @@
10
10
  -->
11
11
 
12
12
  <template>
13
- <div :class="bem()">
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>
@@ -253,4 +253,3 @@ export default {
253
253
  padding: sp(1);
254
254
  }
255
255
  </style>
256
- ./PxPopupButton.vue
@@ -4,7 +4,7 @@
4
4
 
5
5
  <template>
6
6
  <px-transition-expand :duration="duration">
7
- <div :class="bem()" v-show="expanded">
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>
@@ -252,7 +252,9 @@ export default {
252
252
  grid-area: 1 / 1;
253
253
  }
254
254
 
255
- @include transition(opacity, $dur: 100ms);
255
+ & {
256
+ @include transition(opacity, $dur: 100ms);
257
+ }
256
258
  }
257
259
 
258
260
  &--fitting & {
@@ -12,7 +12,7 @@
12
12
  -->
13
13
 
14
14
  <template>
15
- <div :class="bem()">
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>
@@ -141,6 +141,5 @@ export default {
141
141
  font-weight: bold;
142
142
  font-size: 12px;
143
143
  }
144
- // add styles here
145
144
  }
146
145
  </style>
@@ -2,7 +2,15 @@
2
2
  Describe this component...
3
3
  -->
4
4
  <template>
5
- <div :class="bem({ ...variantsMap })">
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>
@@ -6,7 +6,7 @@
6
6
 
7
7
  -->
8
8
  <template>
9
- <div :class="bem()">
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>
@@ -141,6 +141,7 @@ export default {
141
141
 
142
142
  <style lang="scss">
143
143
  @use '../styles/px.scss' as *;
144
+ @use 'sass:color';
144
145
 
145
146
  .px-resizer {
146
147
  position: relative;
@@ -173,7 +174,7 @@ export default {
173
174
  &__resize-y {
174
175
  color: accent();
175
176
  &:hover {
176
- color: darken(accent(), 10%);
177
+ color: color.adjust(accent(), $lightness: -10%);
177
178
  }
178
179
  &:active {
179
180
  opacity: 0.5;
@@ -1,6 +1,5 @@
1
1
  <script>
2
- import { h, createVNode } from 'vue';
3
- import { parse } from '@vue/compiler-dom';
2
+ import { h } from 'vue';
4
3
 
5
4
  export default {
6
5
  name: 'px-svg-render',
@@ -2,7 +2,7 @@
2
2
  #VUE3 Todo
3
3
  -->
4
4
  <template>
5
- <component v-bind:is="tag" :class="bem()" :style="{ minHeight: groupHeight + 'px' }">
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> -->
@@ -206,7 +206,9 @@ export default {
206
206
  @include button();
207
207
  }
208
208
 
209
- gap: var(--px-toggle-button-gap);
209
+ & {
210
+ gap: var(--px-toggle-button-gap);
211
+ }
210
212
 
211
213
  &__icon,
212
214
  &__label {
@@ -256,17 +258,17 @@ export default {
256
258
 
257
259
  // default checked state
258
260
  &--checked.px-button--default:not(:disabled) {
259
- background-color: color(select);
261
+ background-color: clr(select);
260
262
  box-shadow: none;
261
263
  &:hover {
262
- background-color: color(select);
264
+ background-color: clr(select);
263
265
  box-shadow: none;
264
266
  }
265
267
  }
266
268
 
267
269
  // outline checked state
268
270
  &--checked.px-button--outline:not(:disabled) {
269
- background-color: color(accent, 0.15);
271
+ background-color: clr(accent, 0.15);
270
272
  }
271
273
 
272
274
  &--icon & {
@@ -193,5 +193,3 @@ export default {
193
193
  },
194
194
  };
195
195
  </script>
196
-
197
- <style lang="scss"></style>
@@ -45,7 +45,6 @@ export default {
45
45
 
46
46
  <style lang="scss">
47
47
  .demo-px-card-grid {
48
- // add styles here
49
48
  padding: 5vh 0 10vh;
50
49
  }
51
50
  </style>
@@ -2,7 +2,7 @@
2
2
  Describe this component...
3
3
  -->
4
4
  <template>
5
- <div :class="bem()">
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 :class="bem()">
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>
@@ -37,7 +37,5 @@ export default {
37
37
  // initialize
38
38
  @include init();
39
39
  @include boilerplate($scoped: true);
40
-
41
- // add styles here
42
40
  }
43
41
  </style>
@@ -2,7 +2,7 @@
2
2
  Describe this component...
3
3
  -->
4
4
  <template>
5
- <div :class="bem()">
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,79 @@
1
1
  {
2
- "name": "@thinkpixellab-public/px-vue",
3
- "version": "4.1.4",
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.11",
24
- "@popperjs/core": "^2.11.8",
25
- "@storybook/test": "^8.3.4",
26
- "@thinkpixellab-public/px-styles": "^4.1.2",
27
- "@thinkpixellab-public/px-vue-tester": "^2.0.0",
28
- "@thinkpixellab-public/vue-resize-directive": "^1.2.2",
29
- "body-scroll-lock": "^3.1.5",
30
- "chrono-node": "^2.7.7",
31
- "dateformat": "^5.0.3",
32
- "gsap": "^3.12.5",
33
- "highlight.js": "^11.10.0",
34
- "mitt": "^3.0.1",
35
- "qrcode": "^1.5.4",
36
- "qrcode.vue": "^3.5.0",
37
- "sortablejs": "^1.15.3",
38
- "storybook-dark-mode": "^4.0.2",
39
- "throttle-debounce": "^5.0.2",
40
- "tiny-date-picker": "^3.2.8",
41
- "tinycolor2": "^1.6.0",
42
- "vue": "^3.5.10",
43
- "vue-inline-svg": "^3.1.4"
44
- },
45
- "devDependencies": {
46
- "@babel/core": "^7.25.2",
47
- "@chromatic-com/storybook": "^2.0.2",
48
- "@nuxt/kit": "^3.15.1",
49
- "@rushstack/eslint-patch": "^1.10.4",
50
- "@storybook/addon-essentials": "^8.3.4",
51
- "@storybook/addon-interactions": "^8.3.4",
52
- "@storybook/addon-links": "^8.3.4",
53
- "@storybook/addon-mdx-gfm": "^8.3.4",
54
- "@storybook/blocks": "^8.3.4",
55
- "@storybook/manager-api": "^8.3.4",
56
- "@storybook/theming": "^8.3.4",
57
- "@storybook/vue3": "^8.3.4",
58
- "@storybook/vue3-vite": "^8.3.4",
59
- "@vitejs/plugin-vue": "^5.1.4",
60
- "@vue/eslint-config-prettier": "^9.0.0",
61
- "@vue/test-utils": "^2.4.6",
62
- "babel-eslint": "^10.1.0",
63
- "babel-loader": "^9.2.1",
64
- "chromatic": "^11.11.0",
65
- "eslint": "^9.11.1",
66
- "eslint-plugin-storybook": "^0.9.0",
67
- "eslint-plugin-vue": "^9.28.0",
68
- "jsdom": "^25.0.1",
69
- "prettier": "^3.3.3",
70
- "sass": "^1.77.6",
71
- "storybook": "^8.3.4",
72
- "storybook-addon-pseudo-states": "^4.0.2",
73
- "vite": "^5.4.8",
74
- "vitest": "^2.1.1",
75
- "vue-loader": "^17.4.2"
76
- },
77
- "bugs": {
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.6",
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
+ "@nuxt/kit": "^3.15.4",
45
+ "@rushstack/eslint-patch": "^1.10.5",
46
+ "@storybook/addon-essentials": "^8.5.3",
47
+ "@storybook/addon-interactions": "^8.5.3",
48
+ "@storybook/addon-links": "^8.5.3",
49
+ "@storybook/addon-mdx-gfm": "^8.5.3",
50
+ "@storybook/blocks": "^8.5.3",
51
+ "@storybook/manager-api": "^8.5.3",
52
+ "@storybook/test": "^8.5.3",
53
+ "@storybook/theming": "^8.5.3",
54
+ "@storybook/vue3": "^8.5.3",
55
+ "@storybook/vue3-vite": "^8.5.3",
56
+ "@vitejs/plugin-vue": "^5.2.1",
57
+ "@vue/eslint-config-prettier": "^10.2.0",
58
+ "@vue/test-utils": "^2.4.6",
59
+ "babel-eslint": "^10.1.0",
60
+ "babel-loader": "^9.2.1",
61
+ "chromatic": "^11.25.2",
62
+ "eslint": "^9.19.0",
63
+ "eslint-plugin-storybook": "^0.11.2",
64
+ "eslint-plugin-vue": "^9.32.0",
65
+ "jsdom": "^26.0.0",
66
+ "prettier": "^3.4.2",
67
+ "sass": "^1.83.4",
68
+ "storybook": "^8.5.3",
69
+ "storybook-addon-pseudo-states": "^4.0.2",
70
+ "storybook-dark-mode": "^4.0.2",
71
+ "vite": "^6.0.11",
72
+ "vitest": "^3.0.5",
73
+ "vue-loader": "^17.4.2"
74
+ },
75
+ "bugs": {
76
+ "url": "https://github.com/thinkpixellab/px-vue/issues"
77
+ },
78
+ "homepage": "https://github.com/thinkpixellab/px-vue#readme"
81
79
  }
@@ -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>