vuetify-swatches 0.3.3 → 1.0.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/README.md CHANGED
@@ -8,8 +8,6 @@
8
8
 
9
9
  ![demo](https://user-images.githubusercontent.com/480173/156681882-d3d5e868-ba9a-4a34-9e75-08272d39da64.gif)
10
10
 
11
- This branch is for vuetify3. Not usable for production, experimental use only. Bidirectional binding (select swatch button by value) does not work due to a problem on the Vuetify3 side.
12
-
13
11
  This project is a remake of [saintplay's vue-swatches](https://saintplay.github.io/vue-swatches/) with [Vuetify](https://vuetifyjs.com/).
14
12
 
15
13
  Unlike the original version, it provides a UI based on Vuetify, such as ripple effects and dark mode.
@@ -40,7 +38,7 @@ export default Vue.extend({
40
38
  </script>
41
39
 
42
40
  <style>
43
- @import 'vuetify-swatches/dist/style.css';
41
+ @import 'vuetify-swatches/style.css';
44
42
  </style>
45
43
  ```
46
44
 
@@ -119,18 +117,25 @@ export default Vue.extend({
119
117
  </script>
120
118
 
121
119
  <style>
122
- @import 'vuetify-swatches/dist/style.css';
120
+ @import 'vuetify-swatches/style.css';
123
121
  </style>
124
122
  ```
125
123
 
126
124
  ### Options
127
125
 
128
- | Variables | Type | Default | Info |
129
- | --------- | ------ | -------------------------- | ------------------ |
130
- | elevation | number | 1 | shadow size |
131
- | size | string | 2rem | Swatch Button size |
132
- | icon | string | mdi-checkbox-marked-circle | checked icon |
133
- | icon-size | string | 1rem | checked icon size |
126
+ | Variables | Type | Default | Info |
127
+ | --------- | -------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
128
+ | size | string | 2rem | Swatch Button size |
129
+ | icon | string | mdi-checkbox-marked-circle | checked icon |
130
+ | icon-size | string | 1rem | checked icon size |
131
+ | depressed | boolean | false | Removes the button box shadow. |
132
+ | disabled | boolean | false | Removes the ability to click or target the component. |
133
+ | elevation | number\|string | undefined | Designates an elevation applied to the component between 0 and 24. |
134
+ | outlined | false | Makes the background transparent and applies a thin border. |
135
+ | plain | false | Removes the default background change applied when hovering over the button. |
136
+ | raised | true | Raised buttons have a box shadow that increases when clicked. This is the default style. |
137
+ | rounded | false | Applies a large border radius on the button. |
138
+ | tile | false | Removes the component’s border-radius. |
134
139
 
135
140
  ## LICENSE
136
141
 
@@ -1,77 +1,218 @@
1
- import { type PropType, type Ref } from 'vue';
2
- /** Vuetify Swatches */
3
- declare const _default: import("vue").DefineComponent<{
4
- /** Model value */
5
- modelValue: {
6
- type: StringConstructor;
7
- default: any;
8
- };
9
- /** Swatch colors */
10
- swatches: {
11
- type: PropType<string[] | string[][]>;
12
- default: () => any[][];
13
- };
14
- /** The size of the shadow of the button */
15
- elevation: {
16
- type: NumberConstructor;
17
- default: number;
18
- };
19
- /** Swatch sized */
20
- size: {
21
- type: StringConstructor;
22
- default: string;
23
- };
24
- /** selected icon */
25
- icon: {
26
- type: StringConstructor;
27
- default: string;
28
- };
29
- /** selected icon size */
30
- iconSize: {
31
- type: StringConstructor;
32
- default: string;
33
- };
34
- }, {
35
- checkedVisibilty: Ref<boolean>;
36
- onSwatchClick: (e: Event) => void;
37
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
38
- /** Model value */
39
- modelValue: {
40
- type: StringConstructor;
41
- default: any;
42
- };
43
- /** Swatch colors */
44
- swatches: {
45
- type: PropType<string[] | string[][]>;
46
- default: () => any[][];
47
- };
48
- /** The size of the shadow of the button */
49
- elevation: {
50
- type: NumberConstructor;
51
- default: number;
52
- };
53
- /** Swatch sized */
54
- size: {
55
- type: StringConstructor;
56
- default: string;
57
- };
58
- /** selected icon */
59
- icon: {
60
- type: StringConstructor;
61
- default: string;
62
- };
63
- /** selected icon size */
64
- iconSize: {
65
- type: StringConstructor;
66
- default: string;
67
- };
68
- }>>, {
69
- modelValue: string;
70
- swatches: string[] | string[][];
71
- elevation: number;
72
- size: string;
73
- icon: string;
74
- iconSize: string;
75
- }>;
76
- export default _default;
1
+ import { type PropType, type Ref } from 'vue-demi';
2
+ /** Vuetify Swatches */
3
+ declare const _default: import("vue-demi").DefineComponent<{
4
+ /** Model value */
5
+ modelValue: {
6
+ type: StringConstructor;
7
+ default: string;
8
+ };
9
+ /** Swatch colors */
10
+ swatches: {
11
+ type: PropType<string[] | string[][]>;
12
+ default: () => string[][];
13
+ };
14
+ /** Swatch sized */
15
+ size: {
16
+ type: StringConstructor;
17
+ default: string;
18
+ };
19
+ /** Selected icon */
20
+ icon: {
21
+ type: StringConstructor;
22
+ default: string;
23
+ };
24
+ /** selected icon size */
25
+ iconSize: {
26
+ type: StringConstructor;
27
+ default: string;
28
+ };
29
+ /**
30
+ * Removes the button box shadow.
31
+ *
32
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#depressed}
33
+ */
34
+ depressed: {
35
+ type: BooleanConstructor;
36
+ default: boolean;
37
+ };
38
+ /**
39
+ * Removes the ability to click or target the component.
40
+ *
41
+ * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-disabled}
42
+ */
43
+ disabled: {
44
+ type: BooleanConstructor;
45
+ default: boolean;
46
+ };
47
+ /**
48
+ * Designates an elevation applied to the component between 0 and 24.
49
+ *
50
+ * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-elevation}
51
+ */
52
+ elevation: {
53
+ type: (StringConstructor | NumberConstructor)[];
54
+ default: undefined;
55
+ };
56
+ /**
57
+ * Makes the background transparent and applies a thin border.
58
+ *
59
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#outlined}
60
+ */
61
+ outlined: {
62
+ type: BooleanConstructor;
63
+ default: boolean;
64
+ };
65
+ /**
66
+ * Removes the default background change applied when hovering over the button.
67
+ *
68
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#plain}
69
+ */
70
+ plain: {
71
+ type: BooleanConstructor;
72
+ default: boolean;
73
+ };
74
+ /**
75
+ * Raised buttons have a box shadow that increases when clicked. This is the default style.
76
+ *
77
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#raised}
78
+ */
79
+ raised: {
80
+ type: BooleanConstructor;
81
+ default: boolean;
82
+ };
83
+ /**
84
+ * Applies a large border radius on the button.
85
+ *
86
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#rounded}
87
+ */
88
+ rounded: {
89
+ type: BooleanConstructor;
90
+ default: boolean;
91
+ };
92
+ /**
93
+ * Removes the component’s border-radius.
94
+ *
95
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#tile}
96
+ */
97
+ tile: {
98
+ type: BooleanConstructor;
99
+ default: boolean;
100
+ };
101
+ }, {
102
+ checkedVisibilty: Ref<boolean>;
103
+ onSwatchClick: (e: Event) => void;
104
+ }, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue-demi").ExtractPropTypes<{
105
+ /** Model value */
106
+ modelValue: {
107
+ type: StringConstructor;
108
+ default: string;
109
+ };
110
+ /** Swatch colors */
111
+ swatches: {
112
+ type: PropType<string[] | string[][]>;
113
+ default: () => string[][];
114
+ };
115
+ /** Swatch sized */
116
+ size: {
117
+ type: StringConstructor;
118
+ default: string;
119
+ };
120
+ /** Selected icon */
121
+ icon: {
122
+ type: StringConstructor;
123
+ default: string;
124
+ };
125
+ /** selected icon size */
126
+ iconSize: {
127
+ type: StringConstructor;
128
+ default: string;
129
+ };
130
+ /**
131
+ * Removes the button box shadow.
132
+ *
133
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#depressed}
134
+ */
135
+ depressed: {
136
+ type: BooleanConstructor;
137
+ default: boolean;
138
+ };
139
+ /**
140
+ * Removes the ability to click or target the component.
141
+ *
142
+ * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-disabled}
143
+ */
144
+ disabled: {
145
+ type: BooleanConstructor;
146
+ default: boolean;
147
+ };
148
+ /**
149
+ * Designates an elevation applied to the component between 0 and 24.
150
+ *
151
+ * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-elevation}
152
+ */
153
+ elevation: {
154
+ type: (StringConstructor | NumberConstructor)[];
155
+ default: undefined;
156
+ };
157
+ /**
158
+ * Makes the background transparent and applies a thin border.
159
+ *
160
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#outlined}
161
+ */
162
+ outlined: {
163
+ type: BooleanConstructor;
164
+ default: boolean;
165
+ };
166
+ /**
167
+ * Removes the default background change applied when hovering over the button.
168
+ *
169
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#plain}
170
+ */
171
+ plain: {
172
+ type: BooleanConstructor;
173
+ default: boolean;
174
+ };
175
+ /**
176
+ * Raised buttons have a box shadow that increases when clicked. This is the default style.
177
+ *
178
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#raised}
179
+ */
180
+ raised: {
181
+ type: BooleanConstructor;
182
+ default: boolean;
183
+ };
184
+ /**
185
+ * Applies a large border radius on the button.
186
+ *
187
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#rounded}
188
+ */
189
+ rounded: {
190
+ type: BooleanConstructor;
191
+ default: boolean;
192
+ };
193
+ /**
194
+ * Removes the component’s border-radius.
195
+ *
196
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#tile}
197
+ */
198
+ tile: {
199
+ type: BooleanConstructor;
200
+ default: boolean;
201
+ };
202
+ }>>, {
203
+ modelValue: string;
204
+ swatches: string[] | string[][];
205
+ size: string;
206
+ icon: string;
207
+ iconSize: string;
208
+ depressed: boolean;
209
+ disabled: boolean;
210
+ elevation: string | number;
211
+ outlined: boolean;
212
+ plain: boolean;
213
+ raised: boolean;
214
+ rounded: boolean;
215
+ tile: boolean;
216
+ }>;
217
+ export default _default;
77
218
  //# sourceMappingURL=VSwatches.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VSwatches.vue.d.ts","sourceRoot":"","sources":["../../src/components/VSwatches.vue.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,GAAG,EAET,MAAM,KAAK,CAAC;AAKb,uBAAuB;;IAUnB,kBAAkB;;;;;IAElB,oBAAoB;;;;;IA4BpB,2CAA2C;;;;;IAE3C,mBAAmB;;;;;IAEnB,oBAAoB;;;;;IAEpB,yBAAyB;;;;;;;uBAkBC,KAAK;;IAtD/B,kBAAkB;;;;;IAElB,oBAAoB;;;;;IA4BpB,2CAA2C;;;;;IAE3C,mBAAmB;;;;;IAEnB,oBAAoB;;;;;IAEpB,yBAAyB;;;;;;;;;;;;;AA7C7B,wBA2EG"}
1
+ {"version":3,"file":"VSwatches.vue.d.ts","sourceRoot":"","sources":["../../src/components/VSwatches.vue.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,GAAG,EAET,MAAM,UAAU,CAAC;AAKlB,uBAAuB;;IAgBnB,kBAAkB;;;;;IAElB,oBAAoB;;;;;IA4BpB,mBAAmB;;;;;IAEnB,oBAAoB;;;;;IAEpB,yBAAyB;;;;;IAEzB;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;;;uBAoBuB,KAAK;;IAtG/B,kBAAkB;;;;;IAElB,oBAAoB;;;;;IA4BpB,mBAAmB;;;;;IAEnB,oBAAoB;;;;;IAEpB,yBAAyB;;;;;IAEzB;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;;;;;;;;;;;;;;;;AAjGP,wBAkIG"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import VSwatches from './components/VSwatches.vue';
2
- declare const installVSwatches: (app: any) => any;
3
- export { VSwatches as default, installVSwatches as install };
1
+ import VSwatches from './components/VSwatches.vue';
2
+ declare const installVSwatches: (app: any) => any;
3
+ export { VSwatches as default, installVSwatches as install };
4
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.es.js CHANGED
@@ -1,113 +1,129 @@
1
1
  /**
2
2
  * vuetify-swatches
3
3
  *
4
- * @description Color Swatch component for Vuetify3.
4
+ * @description Color Swatch component for Vuetify.
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 0.3.3
8
+ * @version 1.0.0
9
9
  * @see {@link https://github.com/logue/vuetify-swatches}
10
10
  */
11
11
 
12
- import { defineComponent as V, ref as k, resolveComponent as d, openBlock as n, createBlock as c, withCtx as u, createElementBlock as p, Fragment as m, renderList as b, createTextVNode as S, toDisplayString as C, createCommentVNode as z } from "vue";
13
- import e from "vuetify/lib/util/colors.mjs";
14
- const B = V({
12
+ import { defineComponent as b, ref as v } from "vue-demi";
13
+ import { VSheet as y, VBtn as w, VIcon as V } from "vuetify/lib/components";
14
+ import t from "vuetify/lib/util/colors";
15
+ const S = b({
15
16
  name: "VSwatches",
17
+ components: {
18
+ VSheet: y,
19
+ VBtn: w,
20
+ VIcon: V
21
+ },
16
22
  model: {
17
23
  prop: "modelValue",
18
24
  event: "update:modelValue"
19
25
  },
20
26
  props: {
21
- modelValue: { type: String, default: e.shades.white },
27
+ modelValue: { type: String, default: "#ffffff" },
22
28
  swatches: {
23
29
  type: Array,
24
30
  default: () => [
25
- [e.shades.black, e.shades.white],
31
+ [t.shades.black, t.shades.white, t.shades.transparent],
26
32
  [
27
- e.red.base,
28
- e.pink.base,
29
- e.purple.base,
30
- e.deepPurple.base,
31
- e.indigo.base,
32
- e.blue.base,
33
- e.lightBlue.base,
34
- e.cyan.base
33
+ t.red.base,
34
+ t.pink.base,
35
+ t.purple.base,
36
+ t.deepPurple.base,
37
+ t.indigo.base,
38
+ t.blue.base,
39
+ t.lightBlue.base,
40
+ t.cyan.base
35
41
  ],
36
42
  [
37
- e.teal.base,
38
- e.green.base,
39
- e.lightGreen.base,
40
- e.lime.base,
41
- e.yellow.base,
42
- e.amber.base,
43
- e.orange.base,
44
- e.deepOrange.base
43
+ t.teal.base,
44
+ t.green.base,
45
+ t.lightGreen.base,
46
+ t.lime.base,
47
+ t.yellow.base,
48
+ t.amber.base,
49
+ t.orange.base,
50
+ t.deepOrange.base
45
51
  ],
46
- [e.brown.base, e.blueGrey.base, e.grey.base]
52
+ [t.brown.base, t.blueGrey.base, t.grey.base]
47
53
  ]
48
54
  },
49
- elevation: { type: Number, default: 1 },
50
55
  size: { type: String, default: "2rem" },
51
56
  icon: { type: String, default: "mdi-checkbox-marked-circle" },
52
- iconSize: { type: String, default: "1rem" }
57
+ iconSize: { type: String, default: "1rem" },
58
+ depressed: { type: Boolean, default: !1 },
59
+ disabled: { type: Boolean, default: !1 },
60
+ elevation: { type: [Number, String], default: void 0 },
61
+ outlined: { type: Boolean, default: !1 },
62
+ plain: { type: Boolean, default: !1 },
63
+ raised: { type: Boolean, default: !0 },
64
+ rounded: { type: Boolean, default: !1 },
65
+ tile: { type: Boolean, default: !1 }
53
66
  },
54
67
  emits: ["update:modelValue"],
55
- setup(t, a) {
68
+ setup(s, e) {
56
69
  return {
57
- checkedVisibilty: k(!1),
58
- onSwatchClick: (l) => {
59
- const i = l.target.dataset.value;
60
- !i || t.modelValue === i || a.emit("update:modelValue", i);
70
+ checkedVisibilty: v(!1),
71
+ onSwatchClick: (i) => {
72
+ const n = i.target.value;
73
+ !n || s.modelValue === n || e.emit("update:modelValue", n);
61
74
  }
62
75
  };
63
76
  }
64
77
  });
65
- const $ = (t, a) => {
66
- const o = t.__vccOpts || t;
67
- for (const [r, l] of a)
68
- o[r] = l;
69
- return o;
70
- };
71
- function N(t, a, o, r, l, i) {
72
- const f = d("v-icon"), w = d("v-btn"), v = d("v-sheet");
73
- return n(), c(v, { class: "v-swatches" }, {
74
- default: u(() => [
75
- (n(!0), p(m, null, b(t.swatches, (y, _) => (n(), p("div", {
76
- key: _,
77
- class: "d-flex"
78
- }, [
79
- (n(!0), p(m, null, b(y, (s) => (n(), c(w, {
80
- key: s,
81
- elevation: t.elevation,
82
- width: t.size,
83
- height: t.size,
84
- color: s,
85
- "data-value": s,
86
- "min-width": "auto",
87
- onClick: a[0] || (a[0] = (g) => t.onSwatchClick(g))
88
- }, {
89
- default: u(() => [
90
- s === t.modelValue ? (n(), c(f, {
91
- key: 0,
92
- size: t.iconSize,
93
- color: s
94
- }, {
95
- default: u(() => [
96
- S(C(t.icon), 1)
97
- ]),
98
- _: 2
99
- }, 1032, ["size", "color"])) : z("", !0)
100
- ]),
101
- _: 2
102
- }, 1032, ["elevation", "width", "height", "color", "data-value"]))), 128))
103
- ]))), 128))
104
- ]),
105
- _: 1
106
- });
78
+ function g(s, e, r, d, i, n, u, _) {
79
+ var a = typeof s == "function" ? s.options : s;
80
+ e && (a.render = e, a.staticRenderFns = r, a._compiled = !0), d && (a.functional = !0), n && (a._scopeId = "data-v-" + n);
81
+ var l;
82
+ if (u ? (l = function(o) {
83
+ o = o || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !o && typeof __VUE_SSR_CONTEXT__ < "u" && (o = __VUE_SSR_CONTEXT__), i && i.call(this, o), o && o._registeredComponents && o._registeredComponents.add(u);
84
+ }, a._ssrRegister = l) : i && (l = _ ? function() {
85
+ i.call(
86
+ this,
87
+ (a.functional ? this.parent : this).$root.$options.shadowRoot
88
+ );
89
+ } : i), l)
90
+ if (a.functional) {
91
+ a._injectStyles = l;
92
+ var h = a.render;
93
+ a.render = function(m, p) {
94
+ return l.call(p), h(m, p);
95
+ };
96
+ } else {
97
+ var f = a.beforeCreate;
98
+ a.beforeCreate = f ? [].concat(f, l) : [l];
99
+ }
100
+ return {
101
+ exports: s,
102
+ options: a
103
+ };
107
104
  }
108
- const h = /* @__PURE__ */ $(B, [["render", N]]), A = (t) => t.component("VSwatches", h);
109
- typeof window < "u" && window.Vue && window.Vue.use(h);
105
+ var C = function() {
106
+ var e = this, r = e._self._c;
107
+ return e._self._setupProxy, r("v-sheet", { staticClass: "v-swatches" }, e._l(e.swatches, function(d, i) {
108
+ return r("div", { key: i }, e._l(d, function(n) {
109
+ return r("v-btn", { key: n, attrs: { color: n, depressed: e.depressed, disabled: e.disabled, elevation: e.elevation, height: e.size, outlined: e.outlined, plain: e.plain, raised: e.raised, tile: e.tile, value: n, width: e.size, "min-width": "auto" }, on: { click: function(u) {
110
+ return e.onSwatchClick(u);
111
+ } } }, [n === e.modelValue ? r("v-icon", { attrs: { size: e.iconSize, color: n !== "transparent" ? n : void 0 } }, [e._v(" " + e._s(e.icon) + " ")]) : e._e()], 1);
112
+ }), 1);
113
+ }), 0);
114
+ }, k = [], B = /* @__PURE__ */ g(
115
+ S,
116
+ C,
117
+ k,
118
+ !1,
119
+ null,
120
+ null,
121
+ null,
122
+ null
123
+ );
124
+ const c = B.exports, T = (s) => s.component("VSwatches", c);
125
+ typeof window < "u" && window.Vue && window.Vue.use(c);
110
126
  export {
111
- h as default,
112
- A as install
127
+ c as default,
128
+ T as install
113
129
  };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * vuetify-swatches
3
+ *
4
+ * @description Color Swatch component for Vuetify.
5
+ * @author Logue <logue@hotmail.co.jp>
6
+ * @copyright 2022 By Masashi Yoshikawa All rights reserved.
7
+ * @license MIT
8
+ * @version 1.0.0
9
+ * @see {@link https://github.com/logue/vuetify-swatches}
10
+ */
11
+
12
+ var VSwatches=function(u,p,c,v){"use strict";const t=(a=>a&&typeof a=="object"&&"default"in a?a:{default:a})(v),y=p.defineComponent({name:"VSwatches",components:{VSheet:c.VSheet,VBtn:c.VBtn,VIcon:c.VIcon},model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:"#ffffff"},swatches:{type:Array,default:()=>[[t.default.shades.black,t.default.shades.white,t.default.shades.transparent],[t.default.red.base,t.default.pink.base,t.default.purple.base,t.default.deepPurple.base,t.default.indigo.base,t.default.blue.base,t.default.lightBlue.base,t.default.cyan.base],[t.default.teal.base,t.default.green.base,t.default.lightGreen.base,t.default.lime.base,t.default.yellow.base,t.default.amber.base,t.default.orange.base,t.default.deepOrange.base],[t.default.brown.base,t.default.blueGrey.base,t.default.grey.base]]},size:{type:String,default:"2rem"},icon:{type:String,default:"mdi-checkbox-marked-circle"},iconSize:{type:String,default:"1rem"},depressed:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},elevation:{type:[Number,String],default:void 0},outlined:{type:Boolean,default:!1},plain:{type:Boolean,default:!1},raised:{type:Boolean,default:!0},rounded:{type:Boolean,default:!1},tile:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(a,e){return{checkedVisibilty:p.ref(!1),onSwatchClick:s=>{const n=s.target.value;!n||a.modelValue===n||e.emit("update:modelValue",n)}}}}),R="";function m(a,e,o,r,s,n,f,C){var l=typeof a=="function"?a.options:a;e&&(l.render=e,l.staticRenderFns=o,l._compiled=!0),r&&(l.functional=!0),n&&(l._scopeId="data-v-"+n);var d;if(f?(d=function(i){i=i||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!i&&typeof __VUE_SSR_CONTEXT__<"u"&&(i=__VUE_SSR_CONTEXT__),s&&s.call(this,i),i&&i._registeredComponents&&i._registeredComponents.add(f)},l._ssrRegister=d):s&&(d=C?function(){s.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:s),d)if(l.functional){l._injectStyles=d;var k=l.render;l.render=function(B,b){return d.call(b),k(B,b)}}else{var h=l.beforeCreate;l.beforeCreate=h?[].concat(h,d):[d]}return{exports:a,options:l}}var V=function(){var e=this,o=e._self._c;return e._self._setupProxy,o("v-sheet",{staticClass:"v-swatches"},e._l(e.swatches,function(r,s){return o("div",{key:s},e._l(r,function(n){return o("v-btn",{key:n,attrs:{color:n,depressed:e.depressed,disabled:e.disabled,elevation:e.elevation,height:e.size,outlined:e.outlined,plain:e.plain,raised:e.raised,tile:e.tile,value:n,width:e.size,"min-width":"auto"},on:{click:function(f){return e.onSwatchClick(f)}}},[n===e.modelValue?o("v-icon",{attrs:{size:e.iconSize,color:n!=="transparent"?n:void 0}},[e._v(" "+e._s(e.icon)+" ")]):e._e()],1)}),1)}),0)},w=[],S=m(y,V,w,!1,null,null,null,null);const _=S.exports,g=a=>a.component("VSwatches",_);return typeof window<"u"&&window.Vue&&window.Vue.use(_),u.default=_,u.install=g,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),u}({},VueDemi,Vuetify,colors);
package/dist/index.umd.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * vuetify-swatches
3
3
  *
4
- * @description Color Swatch component for Vuetify3.
4
+ * @description Color Swatch component for Vuetify.
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 0.3.3
8
+ * @version 1.0.0
9
9
  * @see {@link https://github.com/logue/vuetify-swatches}
10
10
  */
11
11
 
12
- (function(l,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vuetify/lib/util/colors.mjs")):typeof define=="function"&&define.amd?define(["exports","vue","vuetify/lib/util/colors.mjs"],e):(l=typeof globalThis<"u"?globalThis:l||self,e(l.VSwatches={},l.Vue,l.colors))})(this,function(l,e,u){"use strict";const t=(a=>a&&typeof a=="object"&&"default"in a?a:{default:a})(u),f=e.defineComponent({name:"VSwatches",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:t.default.shades.white},swatches:{type:Array,default:()=>[[t.default.shades.black,t.default.shades.white],[t.default.red.base,t.default.pink.base,t.default.purple.base,t.default.deepPurple.base,t.default.indigo.base,t.default.blue.base,t.default.lightBlue.base,t.default.cyan.base],[t.default.teal.base,t.default.green.base,t.default.lightGreen.base,t.default.lime.base,t.default.yellow.base,t.default.amber.base,t.default.orange.base,t.default.deepOrange.base],[t.default.brown.base,t.default.blueGrey.base,t.default.grey.base]]},elevation:{type:Number,default:1},size:{type:String,default:"2rem"},icon:{type:String,default:"mdi-checkbox-marked-circle"},iconSize:{type:String,default:"1rem"}},emits:["update:modelValue"],setup(a,n){return{checkedVisibilty:e.ref(!1),onSwatchClick:i=>{const d=i.target.dataset.value;!d||a.modelValue===d||n.emit("update:modelValue",d)}}}}),S="",p=(a,n)=>{const s=a.__vccOpts||a;for(const[c,i]of n)s[c]=i;return s};function m(a,n,s,c,i,d){const b=e.resolveComponent("v-icon"),y=e.resolveComponent("v-btn"),w=e.resolveComponent("v-sheet");return e.openBlock(),e.createBlock(w,{class:"v-swatches"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.swatches,(k,_)=>(e.openBlock(),e.createElementBlock("div",{key:_,class:"d-flex"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k,o=>(e.openBlock(),e.createBlock(y,{key:o,elevation:a.elevation,width:a.size,height:a.size,color:o,"data-value":o,"min-width":"auto",onClick:n[0]||(n[0]=g=>a.onSwatchClick(g))},{default:e.withCtx(()=>[o===a.modelValue?(e.openBlock(),e.createBlock(b,{key:0,size:a.iconSize,color:o},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.icon),1)]),_:2},1032,["size","color"])):e.createCommentVNode("",!0)]),_:2},1032,["elevation","width","height","color","data-value"]))),128))]))),128))]),_:1})}const r=p(f,[["render",m]]),h=a=>a.component("VSwatches",r);typeof window<"u"&&window.Vue&&window.Vue.use(r),l.default=r,l.install=h,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
12
+ (function(i,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue-demi"),require("vuetify/lib/components"),require("vuetify/lib/util/colors")):typeof define=="function"&&define.amd?define(["exports","vue-demi","vuetify/lib/components","vuetify/lib/util/colors"],f):(i=typeof globalThis<"u"?globalThis:i||self,f(i.VSwatches={},i.VueDemi,i.Vuetify,i.colors))})(this,function(i,f,p,v){"use strict";const t=(a=>a&&typeof a=="object"&&"default"in a?a:{default:a})(v),y=f.defineComponent({name:"VSwatches",components:{VSheet:p.VSheet,VBtn:p.VBtn,VIcon:p.VIcon},model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:"#ffffff"},swatches:{type:Array,default:()=>[[t.default.shades.black,t.default.shades.white,t.default.shades.transparent],[t.default.red.base,t.default.pink.base,t.default.purple.base,t.default.deepPurple.base,t.default.indigo.base,t.default.blue.base,t.default.lightBlue.base,t.default.cyan.base],[t.default.teal.base,t.default.green.base,t.default.lightGreen.base,t.default.lime.base,t.default.yellow.base,t.default.amber.base,t.default.orange.base,t.default.deepOrange.base],[t.default.brown.base,t.default.blueGrey.base,t.default.grey.base]]},size:{type:String,default:"2rem"},icon:{type:String,default:"mdi-checkbox-marked-circle"},iconSize:{type:String,default:"1rem"},depressed:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},elevation:{type:[Number,String],default:void 0},outlined:{type:Boolean,default:!1},plain:{type:Boolean,default:!1},raised:{type:Boolean,default:!0},rounded:{type:Boolean,default:!1},tile:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(a,e){return{checkedVisibilty:f.ref(!1),onSwatchClick:s=>{const l=s.target.value;!l||a.modelValue===l||e.emit("update:modelValue",l)}}}}),T="";function m(a,e,u,r,s,l,c,C){var n=typeof a=="function"?a.options:a;e&&(n.render=e,n.staticRenderFns=u,n._compiled=!0),r&&(n.functional=!0),l&&(n._scopeId="data-v-"+l);var o;if(c?(o=function(d){d=d||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!d&&typeof __VUE_SSR_CONTEXT__<"u"&&(d=__VUE_SSR_CONTEXT__),s&&s.call(this,d),d&&d._registeredComponents&&d._registeredComponents.add(c)},n._ssrRegister=o):s&&(o=C?function(){s.call(this,(n.functional?this.parent:this).$root.$options.shadowRoot)}:s),o)if(n.functional){n._injectStyles=o;var k=n.render;n.render=function(B,b){return o.call(b),k(B,b)}}else{var h=n.beforeCreate;n.beforeCreate=h?[].concat(h,o):[o]}return{exports:a,options:n}}var V=function(){var e=this,u=e._self._c;return e._self._setupProxy,u("v-sheet",{staticClass:"v-swatches"},e._l(e.swatches,function(r,s){return u("div",{key:s},e._l(r,function(l){return u("v-btn",{key:l,attrs:{color:l,depressed:e.depressed,disabled:e.disabled,elevation:e.elevation,height:e.size,outlined:e.outlined,plain:e.plain,raised:e.raised,tile:e.tile,value:l,width:e.size,"min-width":"auto"},on:{click:function(c){return e.onSwatchClick(c)}}},[l===e.modelValue?u("v-icon",{attrs:{size:e.iconSize,color:l!=="transparent"?l:void 0}},[e._v(" "+e._s(e.icon)+" ")]):e._e()],1)}),1)}),0)},w=[],S=m(y,V,w,!1,null,null,null,null);const _=S.exports,g=a=>a.component("VSwatches",_);typeof window<"u"&&window.Vue&&window.Vue.use(_),i.default=_,i.install=g,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/style.css CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * vuetify-swatches
3
3
  *
4
- * @description Color Swatch component for Vuetify3.
4
+ * @description Color Swatch component for Vuetify.
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 0.3.3
8
+ * @version 1.0.0
9
9
  * @see {@link https://github.com/logue/vuetify-swatches}
10
10
  */
11
11
 
12
- .v-swatches .v-btn{padding:0!important;margin:.1rem}.v-swatches .v-btn .v-icon{filter:invert(100%) grayscale(100%) contrast(100)}
12
+ .v-swatches .v-btn{padding:0!important;margin:.1rem}.v-swatches .v-btn .v-icon{filter:invert(100%) grayscale(100%) contrast(100)}.v-swatches .v-btn.transparent{background:linear-gradient(to top left,transparent 0,transparent calc(50% - .1rem),#F44336 50%,transparent calc(50% + .1rem),transparent)}.v-swatches .v-btn.transparent .v-icon{filter:none}
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "vuetify-swatches",
4
- "version": "0.3.3",
5
- "description": "Color Swatch component for Vuetify3.",
4
+ "version": "1.0.0",
5
+ "license": "MIT",
6
+ "description": "Color Swatch component for Vuetify.",
6
7
  "keywords": [
7
8
  "vuejs",
8
9
  "vue",
@@ -10,14 +11,12 @@
10
11
  "color-picker",
11
12
  "color-palette",
12
13
  "swatches",
13
- "vue3",
14
+ "vue2",
14
15
  "vue-plugin",
15
16
  "vue-resource",
16
17
  "vuetify",
17
- "vuetify3",
18
18
  "vuetify-components"
19
19
  ],
20
- "license": "MIT",
21
20
  "type": "module",
22
21
  "author": {
23
22
  "name": "Logue",
@@ -37,7 +36,7 @@
37
36
  "types": "dist/index.d.ts",
38
37
  "style": "dist/style.css",
39
38
  "browser": {
40
- "./sfc": "./src/components/VSwatches.vue"
39
+ "sfc": "src/components/VSwatches.vue"
41
40
  },
42
41
  "exports": {
43
42
  ".": {
@@ -53,17 +52,17 @@
53
52
  "dist",
54
53
  "src/components/VSwatches.vue"
55
54
  ],
55
+ "sideEffects": false,
56
56
  "engines": {
57
57
  "node": ">=16.17.0",
58
58
  "yarn": ">=1.22.10"
59
59
  },
60
60
  "packageManager": "yarn@3.2.2",
61
- "sideEffects": false,
62
61
  "scripts": {
63
62
  "dev": "vite",
64
63
  "clean": "rimraf node_modules/.vite ",
65
64
  "build": "vite build & vue-tsc --declaration --emitDeclarationOnly",
66
- "build:analyze": "vue-tsc --noEmit & vite build --mode analyze",
65
+ "build:analyze": "vue-tsc --noEmit && vite build --mode analyze",
67
66
  "build:docs": "vite build --config vite.config.docs.ts",
68
67
  "build:clean": "rimraf dist",
69
68
  "lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . -w -u",
@@ -72,27 +71,39 @@
72
71
  "preview": "vite preview --config vite.config.docs.ts",
73
72
  "prepare": "husky install"
74
73
  },
74
+ "dependencies": {
75
+ "vue-demi": "latest"
76
+ },
75
77
  "peerDependencies": {
76
- "vue": "^3.2.37",
77
- "vuetify": "^3.0.0-beta.8"
78
+ "@vue/composition-api": "^1.7.0",
79
+ "vue": "^2.6.14 || <3",
80
+ "vuetify": "^2.6.10"
81
+ },
82
+ "peerDependenciesMeta": {
83
+ "@vue/composition-api": {
84
+ "optional": true
85
+ }
78
86
  },
79
87
  "devDependencies": {
80
- "@codemirror/lang-html": "^6.1.0",
81
- "@types/node": "^18.7.6",
82
- "@typescript-eslint/eslint-plugin": "^5.33.1",
83
- "@typescript-eslint/parser": "^5.33.1",
84
- "@vitejs/plugin-vue": "^3.0.3",
88
+ "@codemirror/lang-html": "^6.1.1",
89
+ "@types/lodash": "^4.14.185",
90
+ "@types/node": "^18.7.18",
91
+ "@typescript-eslint/eslint-plugin": "^5.37.0",
92
+ "@typescript-eslint/parser": "^5.37.0",
93
+ "@vitejs/plugin-vue2": "^2.0.0",
94
+ "@vue/eslint-config-prettier": "^7.0.0",
85
95
  "@vue/tsconfig": "^0.1.3",
86
96
  "codemirror": "^6.0.1",
87
- "eslint": "^8.22.0",
97
+ "eslint": "^8.23.1",
88
98
  "eslint-config-google": "^0.14.0",
89
99
  "eslint-config-prettier": "^8.5.0",
90
100
  "eslint-import-resolver-alias": "^1.1.2",
91
- "eslint-import-resolver-typescript": "^3.4.2",
101
+ "eslint-import-resolver-typescript": "^3.5.1",
102
+ "eslint-plugin-html": "^7.1.0",
92
103
  "eslint-plugin-import": "^2.26.0",
93
104
  "eslint-plugin-jsdoc": "^39.3.6",
94
- "eslint-plugin-tsdoc": "^0.2.16",
95
- "eslint-plugin-vue": "^9.3.0",
105
+ "eslint-plugin-tsdoc": "^0.2.17",
106
+ "eslint-plugin-vue": "^9.4.0",
96
107
  "eslint-plugin-vuejs-accessibility": "^1.2.0",
97
108
  "eslint-plugin-vuetify": "^1.1.0",
98
109
  "eslint-plugin-yaml": "^0.5.0",
@@ -101,24 +112,25 @@
101
112
  "postcss-html": "^1.5.0",
102
113
  "prettier": "^2.7.1",
103
114
  "rimraf": "^3.0.2",
104
- "rollup-plugin-visualizer": "^5.7.1",
105
- "sass": "1.54.4",
106
- "stylelint": "^14.10.0",
115
+ "rollup-plugin-visualizer": "^5.8.1",
116
+ "sass": "1.32.12",
117
+ "stylelint": "^14.11.0",
107
118
  "stylelint-config-prettier": "^9.0.3",
108
119
  "stylelint-config-recommended-scss": "^7.0.0",
109
120
  "stylelint-config-recommended-vue": "^1.4.0",
110
121
  "stylelint-order": "^5.0.0",
111
122
  "stylelint-prettier": "^2.0.0",
112
- "typescript": "^4.7.4",
113
- "vite": "^3.0.8",
114
- "vite-plugin-banner": "^0.3.0",
115
- "vite-plugin-checker": "^0.4.9",
116
- "vite-plugin-vuetify": "^1.0.0-alpha.14",
117
- "vue": "^3.2.37",
118
- "vue-codemirror6": "0.6.8",
119
- "vue-eslint-parser": "^9.0.3",
120
- "vue-tsc": "^0.40.1",
121
- "vuetify": "^3.0.0-beta.8"
123
+ "typescript": "^4.8.3",
124
+ "unplugin-vue-components": "^0.22.7",
125
+ "vite": "^3.1.0",
126
+ "vite-plugin-banner": "^0.5.0",
127
+ "vite-plugin-checker": "^0.5.1",
128
+ "vue": "^2.7.10",
129
+ "vue-codemirror6": "1.0.1",
130
+ "vue-eslint-parser": "^9.1.0",
131
+ "vue-template-compiler": "^2.7.10",
132
+ "vue-tsc": "^0.40.13",
133
+ "vuetify": "^2.6.10"
122
134
  },
123
135
  "husky": {
124
136
  "hooks": {
@@ -1,18 +1,28 @@
1
1
  <template>
2
2
  <v-sheet class="v-swatches">
3
- <div v-for="(colors, rows) in swatches" :key="rows" class="d-flex">
3
+ <div v-for="(colors, rows) in swatches" :key="rows">
4
4
  <v-btn
5
5
  v-for="color in colors"
6
6
  :key="color"
7
+ :color="color"
8
+ :depressed="depressed"
9
+ :disabled="disabled"
7
10
  :elevation="elevation"
8
- :width="size"
9
11
  :height="size"
10
- :color="color"
11
- :data-value="color"
12
+ :outlined="outlined"
13
+ :plain="plain"
14
+ :raised="raised"
15
+ :tile="tile"
16
+ :value="color"
17
+ :width="size"
12
18
  min-width="auto"
13
19
  @click="onSwatchClick($event)"
14
20
  >
15
- <v-icon v-if="color === modelValue" :size="iconSize" :color="color">
21
+ <v-icon
22
+ v-if="color === modelValue"
23
+ :size="iconSize"
24
+ :color="color !== 'transparent' ? color : undefined"
25
+ >
16
26
  {{ icon }}
17
27
  </v-icon>
18
28
  </v-btn>
@@ -27,15 +37,21 @@ import {
27
37
  type PropType,
28
38
  type Ref,
29
39
  type SetupContext,
30
- } from 'vue';
40
+ } from 'vue-demi';
31
41
 
32
- // eslint-disable-next-line import/no-unresolved
33
- import colors from 'vuetify/lib/util/colors.mjs';
42
+ import { VSheet, VIcon, VBtn } from 'vuetify/lib/components';
43
+ import colors from 'vuetify/lib/util/colors';
34
44
 
35
45
  /** Vuetify Swatches */
36
46
  export default defineComponent({
37
47
  /** Component name */
38
48
  name: 'VSwatches',
49
+ /** Components */
50
+ components: {
51
+ VSheet,
52
+ VBtn,
53
+ VIcon,
54
+ },
39
55
  /** Model Definition */
40
56
  model: {
41
57
  prop: 'modelValue',
@@ -43,12 +59,12 @@ export default defineComponent({
43
59
  },
44
60
  props: {
45
61
  /** Model value */
46
- modelValue: { type: String, default: colors.shades.white },
62
+ modelValue: { type: String, default: '#ffffff' },
47
63
  /** Swatch colors */
48
64
  swatches: {
49
65
  type: Array as PropType<string[] | string[][]>,
50
66
  default: () => [
51
- [colors.shades.black, colors.shades.white],
67
+ [colors.shades.black, colors.shades.white, colors.shades.transparent],
52
68
  [
53
69
  colors.red.base,
54
70
  colors.pink.base,
@@ -72,37 +88,86 @@ export default defineComponent({
72
88
  [colors.brown.base, colors.blueGrey.base, colors.grey.base],
73
89
  ],
74
90
  },
75
- /** The size of the shadow of the button */
76
- elevation: { type: Number, default: 1 },
77
91
  /** Swatch sized */
78
92
  size: { type: String, default: '2rem' },
79
- /** selected icon */
93
+ /** Selected icon */
80
94
  icon: { type: String, default: 'mdi-checkbox-marked-circle' },
81
95
  /** selected icon size */
82
96
  iconSize: { type: String, default: '1rem' },
97
+ /**
98
+ * Removes the button box shadow.
99
+ *
100
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#depressed}
101
+ */
102
+ depressed: { type: Boolean, default: false },
103
+ /**
104
+ * Removes the ability to click or target the component.
105
+ *
106
+ * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-disabled}
107
+ */
108
+ disabled: { type: Boolean, default: false },
109
+ /**
110
+ * Designates an elevation applied to the component between 0 and 24.
111
+ *
112
+ * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-elevation}
113
+ */
114
+ elevation: { type: [Number, String], default: undefined },
115
+ /**
116
+ * Makes the background transparent and applies a thin border.
117
+ *
118
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#outlined}
119
+ */
120
+ outlined: { type: Boolean, default: false },
121
+ /**
122
+ * Removes the default background change applied when hovering over the button.
123
+ *
124
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#plain}
125
+ */
126
+ plain: { type: Boolean, default: false },
127
+ /**
128
+ * Raised buttons have a box shadow that increases when clicked. This is the default style.
129
+ *
130
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#raised}
131
+ */
132
+ raised: { type: Boolean, default: true },
133
+ /**
134
+ * Applies a large border radius on the button.
135
+ *
136
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#rounded}
137
+ */
138
+ rounded: { type: Boolean, default: false },
139
+ /**
140
+ * Removes the component’s border-radius.
141
+ *
142
+ * @see {@link https://vuetifyjs.com/en/components/buttons/#tile}
143
+ */
144
+ tile: { type: Boolean, default: false },
83
145
  },
84
146
  /** Emits */
85
147
  emits: ['update:modelValue'],
86
148
  /**
87
149
  * Setup
150
+ *
88
151
  * @param props - Props
89
152
  * @param context - Context
90
153
  */
91
154
  setup(props, context: SetupContext) {
92
155
  /** Check icon visibility */
93
156
  const checkedVisibilty: Ref<boolean> = ref(false);
157
+
94
158
  /**
95
- * ボタンがクリックされた
159
+ * Swatch button clicked handler
96
160
  *
97
- * @param e - イベント
161
+ * @param e - Event
98
162
  */
99
163
  const onSwatchClick = (e: Event) => {
100
- const value = (e.target as HTMLButtonElement).dataset.value;
164
+ const value = (e.target as HTMLButtonElement).value;
101
165
  if (!value || props.modelValue === value) {
102
166
  return;
103
167
  }
104
168
  context.emit('update:modelValue', value);
105
169
  };
170
+
106
171
  return {
107
172
  checkedVisibilty,
108
173
  onSwatchClick,
@@ -112,6 +177,8 @@ export default defineComponent({
112
177
  </script>
113
178
 
114
179
  <style lang="scss">
180
+ @import 'node_modules/vuetify/src/styles/styles';
181
+
115
182
  .v-swatches {
116
183
  .v-btn {
117
184
  padding: 0 !important;
@@ -120,6 +187,20 @@ export default defineComponent({
120
187
  .v-icon {
121
188
  filter: invert(100%) grayscale(100%) contrast(100);
122
189
  }
190
+
191
+ &.transparent {
192
+ background: linear-gradient(
193
+ to top left,
194
+ transparent 0,
195
+ transparent calc(50% - 0.1rem),
196
+ map-get($red, 'base') 50%,
197
+ transparent calc(50% + 0.1rem),
198
+ transparent
199
+ );
200
+ .v-icon {
201
+ filter: none;
202
+ }
203
+ }
123
204
  }
124
205
  }
125
206
  </style>