vuetify-swatches 1.3.3 → 1.3.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/README.md +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +61 -78
- package/dist/index.iife.js +79 -100
- package/dist/index.umd.js +79 -100
- package/dist/style.css +5 -5
- package/package.json +42 -41
- package/src/components/VSwatches.vue +134 -144
- package/dist/components/VSwatches.vue.d.ts +0 -126
- package/dist/components/VSwatches.vue.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -117,6 +117,8 @@ const selected: Ref<string> = ref('#ffffff');
|
|
|
117
117
|
|
|
118
118
|
### Options
|
|
119
119
|
|
|
120
|
+
Most props other than size and placement are the same as [v-btn](https://next.vuetifyjs.com/en/api/v-btn/).
|
|
121
|
+
|
|
120
122
|
| Variables | Type | Default | Info |
|
|
121
123
|
| --------- | -------------- | -------------------------- | -------------------------------------------------------------------------- |
|
|
122
124
|
| size | string | 2rem | Swatch Button size |
|
|
@@ -125,6 +127,8 @@ const selected: Ref<string> = ref('#ffffff');
|
|
|
125
127
|
| disabled | boolean | false | Removes the ability to click or target the component. |
|
|
126
128
|
| rounded | number\|string | undefined | Applies a large border radius on the button. |
|
|
127
129
|
| variant | string [^1] | undefined | The variant prop gives you easy access to several different button styles. |
|
|
130
|
+
| elevation | number\|string | undefined |
|
|
131
|
+
| border | number\|string | undefined |
|
|
128
132
|
|
|
129
133
|
[^1] Available variants are: elevated(default), flat, tonal, outlined, text, and plain.
|
|
130
134
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -5,19 +5,15 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.3.
|
|
8
|
+
* @version 1.3.5
|
|
9
9
|
* @see {@link https://github.com/logue/vuetify-swatches}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { defineComponent, ref, resolveComponent, openBlock, createBlock, withCtx, createElementBlock, Fragment, renderList, normalizeClass, createTextVNode, toDisplayString, createCommentVNode } from 'vue';
|
|
12
|
+
import { defineComponent, ref, watch, resolveComponent, openBlock, createBlock, withCtx, createElementBlock, Fragment, renderList, normalizeClass, unref, createTextVNode, toDisplayString, createCommentVNode } from 'vue';
|
|
13
13
|
import colors from 'vuetify/lib/util/colors.mjs';
|
|
14
14
|
|
|
15
|
-
const _sfc_main = defineComponent({
|
|
16
|
-
|
|
17
|
-
model: {
|
|
18
|
-
prop: "modelValue",
|
|
19
|
-
event: "update:modelValue"
|
|
20
|
-
},
|
|
15
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
16
|
+
__name: "VSwatches",
|
|
21
17
|
props: {
|
|
22
18
|
modelValue: { type: String, default: colors.shades.white },
|
|
23
19
|
swatches: {
|
|
@@ -55,84 +51,71 @@ const _sfc_main = defineComponent({
|
|
|
55
51
|
default: void 0
|
|
56
52
|
},
|
|
57
53
|
disabled: { type: Boolean, default: void 0 },
|
|
58
|
-
rounded: { type: String, Number, default: void 0 }
|
|
54
|
+
rounded: { type: [String, Number, Boolean], default: void 0 },
|
|
55
|
+
border: { type: [String, Number, Boolean], default: false },
|
|
56
|
+
elevation: { type: [String, Number], default: void 0 }
|
|
59
57
|
},
|
|
60
58
|
emits: ["update:modelValue"],
|
|
61
|
-
setup(
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const _component_v_sheet = resolveComponent("v-sheet");
|
|
92
|
-
return openBlock(), createBlock(_component_v_sheet, { class: "v-swatches" }, {
|
|
93
|
-
default: withCtx(() => [
|
|
94
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.swatches, (colors, rows) => {
|
|
95
|
-
return openBlock(), createElementBlock("div", { key: rows }, [
|
|
96
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(colors, (color) => {
|
|
97
|
-
return openBlock(), createBlock(_component_v_btn, {
|
|
98
|
-
key: color,
|
|
99
|
-
color,
|
|
100
|
-
disabled: _ctx.disabled,
|
|
101
|
-
height: _ctx.size,
|
|
102
|
-
value: color,
|
|
103
|
-
variant: _ctx.variant,
|
|
104
|
-
width: _ctx.size,
|
|
105
|
-
"data-value": color,
|
|
106
|
-
class: normalizeClass(color === _ctx.shades.transparent ? "bg-trasparent" : ""),
|
|
107
|
-
"min-width": "auto",
|
|
108
|
-
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.onSwatchClick($event))
|
|
109
|
-
}, {
|
|
110
|
-
default: withCtx(() => [
|
|
111
|
-
color === _ctx.modelValue ? (openBlock(), createBlock(_component_v_icon, {
|
|
112
|
-
key: 0,
|
|
113
|
-
size: _ctx.iconSize,
|
|
114
|
-
color: color !== _ctx.shades.transparent ? color : void 0
|
|
59
|
+
setup(__props, { emit: emits }) {
|
|
60
|
+
const props = __props;
|
|
61
|
+
const selected = ref(props.modelValue || colors.shades.white);
|
|
62
|
+
const onSwatchClick = (e) => selected.value = e.target.dataset.value || colors.shades.white;
|
|
63
|
+
watch(
|
|
64
|
+
() => selected.value,
|
|
65
|
+
(s) => emits("update:modelValue", s)
|
|
66
|
+
);
|
|
67
|
+
return (_ctx, _cache) => {
|
|
68
|
+
const _component_v_icon = resolveComponent("v-icon");
|
|
69
|
+
const _component_v_btn = resolveComponent("v-btn");
|
|
70
|
+
const _component_v_sheet = resolveComponent("v-sheet");
|
|
71
|
+
return openBlock(), createBlock(_component_v_sheet, { class: "v-swatches" }, {
|
|
72
|
+
default: withCtx(() => [
|
|
73
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.swatches, (cols, rows) => {
|
|
74
|
+
return openBlock(), createElementBlock("div", { key: rows }, [
|
|
75
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(cols, (color) => {
|
|
76
|
+
return openBlock(), createBlock(_component_v_btn, {
|
|
77
|
+
key: color,
|
|
78
|
+
border: props.border,
|
|
79
|
+
class: normalizeClass(color === unref(colors).shades.transparent ? "bg-trasparent" : ""),
|
|
80
|
+
color,
|
|
81
|
+
disabled: props.disabled,
|
|
82
|
+
elevation: props.elevation,
|
|
83
|
+
height: props.size,
|
|
84
|
+
"data-value": color,
|
|
85
|
+
variant: props.variant,
|
|
86
|
+
width: props.size,
|
|
87
|
+
"min-width": "auto",
|
|
88
|
+
onClick: _cache[0] || (_cache[0] = ($event) => onSwatchClick($event))
|
|
115
89
|
}, {
|
|
116
90
|
default: withCtx(() => [
|
|
117
|
-
|
|
91
|
+
color === __props.modelValue ? (openBlock(), createBlock(_component_v_icon, {
|
|
92
|
+
key: 0,
|
|
93
|
+
size: __props.iconSize,
|
|
94
|
+
color: color !== unref(colors).shades.transparent ? color : void 0
|
|
95
|
+
}, {
|
|
96
|
+
default: withCtx(() => [
|
|
97
|
+
createTextVNode(toDisplayString(props.icon), 1)
|
|
98
|
+
]),
|
|
99
|
+
_: 2
|
|
100
|
+
}, 1032, ["size", "color"])) : createCommentVNode("", true)
|
|
118
101
|
]),
|
|
119
102
|
_: 2
|
|
120
|
-
}, 1032, ["
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}, 1032, ["color", "disabled", "height", "value", "variant", "width", "data-value", "class"]);
|
|
103
|
+
}, 1032, ["border", "class", "color", "disabled", "elevation", "height", "data-value", "variant", "width"]);
|
|
104
|
+
}), 128))
|
|
105
|
+
]);
|
|
124
106
|
}), 128))
|
|
125
|
-
])
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
107
|
+
]),
|
|
108
|
+
_: 1
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const VSwatches_vue_vue_type_style_index_0_lang = '';
|
|
132
115
|
|
|
133
|
-
const installVSwatches = (app) => app.component("VSwatches",
|
|
116
|
+
const installVSwatches = (app) => app.component("VSwatches", _sfc_main);
|
|
134
117
|
if (typeof window !== "undefined" && window.Vue) {
|
|
135
|
-
window.Vue.use(
|
|
118
|
+
window.Vue.use(_sfc_main);
|
|
136
119
|
}
|
|
137
120
|
|
|
138
|
-
export {
|
|
121
|
+
export { _sfc_main as default, installVSwatches as install };
|
package/dist/index.iife.js
CHANGED
|
@@ -5,50 +5,42 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.3.
|
|
8
|
+
* @version 1.3.5
|
|
9
9
|
* @see {@link https://github.com/logue/vuetify-swatches}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
var VSwatches = (function (exports, vue, colors) {
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
18
|
-
|
|
19
|
-
const _sfc_main = vue.defineComponent({
|
|
20
|
-
name: "VSwatches",
|
|
21
|
-
model: {
|
|
22
|
-
prop: "modelValue",
|
|
23
|
-
event: "update:modelValue"
|
|
24
|
-
},
|
|
15
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
16
|
+
__name: "VSwatches",
|
|
25
17
|
props: {
|
|
26
|
-
modelValue: { type: String, default:
|
|
18
|
+
modelValue: { type: String, default: colors.shades.white },
|
|
27
19
|
swatches: {
|
|
28
20
|
type: Array,
|
|
29
21
|
default: () => [
|
|
30
|
-
[
|
|
22
|
+
[colors.shades.black, colors.shades.white, colors.shades.transparent],
|
|
31
23
|
[
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
colors.red.base,
|
|
25
|
+
colors.pink.base,
|
|
26
|
+
colors.purple.base,
|
|
27
|
+
colors.deepPurple.base,
|
|
28
|
+
colors.indigo.base,
|
|
29
|
+
colors.blue.base,
|
|
30
|
+
colors.lightBlue.base,
|
|
31
|
+
colors.cyan.base
|
|
40
32
|
],
|
|
41
33
|
[
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
colors.teal.base,
|
|
35
|
+
colors.green.base,
|
|
36
|
+
colors.lightGreen.base,
|
|
37
|
+
colors.lime.base,
|
|
38
|
+
colors.yellow.base,
|
|
39
|
+
colors.amber.base,
|
|
40
|
+
colors.orange.base,
|
|
41
|
+
colors.deepOrange.base
|
|
50
42
|
],
|
|
51
|
-
[
|
|
43
|
+
[colors.brown.base, colors.blueGrey.base, colors.grey.base]
|
|
52
44
|
]
|
|
53
45
|
},
|
|
54
46
|
size: { type: String, default: "2rem" },
|
|
@@ -59,87 +51,74 @@ var VSwatches = (function (exports, vue, colors) {
|
|
|
59
51
|
default: void 0
|
|
60
52
|
},
|
|
61
53
|
disabled: { type: Boolean, default: void 0 },
|
|
62
|
-
rounded: { type: String, Number, default: void 0 }
|
|
54
|
+
rounded: { type: [String, Number, Boolean], default: void 0 },
|
|
55
|
+
border: { type: [String, Number, Boolean], default: false },
|
|
56
|
+
elevation: { type: [String, Number], default: void 0 }
|
|
63
57
|
},
|
|
64
58
|
emits: ["update:modelValue"],
|
|
65
|
-
setup(
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const _component_v_sheet = vue.resolveComponent("v-sheet");
|
|
96
|
-
return vue.openBlock(), vue.createBlock(_component_v_sheet, { class: "v-swatches" }, {
|
|
97
|
-
default: vue.withCtx(() => [
|
|
98
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.swatches, (colors, rows) => {
|
|
99
|
-
return vue.openBlock(), vue.createElementBlock("div", { key: rows }, [
|
|
100
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(colors, (color) => {
|
|
101
|
-
return vue.openBlock(), vue.createBlock(_component_v_btn, {
|
|
102
|
-
key: color,
|
|
103
|
-
color,
|
|
104
|
-
disabled: _ctx.disabled,
|
|
105
|
-
height: _ctx.size,
|
|
106
|
-
value: color,
|
|
107
|
-
variant: _ctx.variant,
|
|
108
|
-
width: _ctx.size,
|
|
109
|
-
"data-value": color,
|
|
110
|
-
class: vue.normalizeClass(color === _ctx.shades.transparent ? "bg-trasparent" : ""),
|
|
111
|
-
"min-width": "auto",
|
|
112
|
-
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.onSwatchClick($event))
|
|
113
|
-
}, {
|
|
114
|
-
default: vue.withCtx(() => [
|
|
115
|
-
color === _ctx.modelValue ? (vue.openBlock(), vue.createBlock(_component_v_icon, {
|
|
116
|
-
key: 0,
|
|
117
|
-
size: _ctx.iconSize,
|
|
118
|
-
color: color !== _ctx.shades.transparent ? color : void 0
|
|
59
|
+
setup(__props, { emit: emits }) {
|
|
60
|
+
const props = __props;
|
|
61
|
+
const selected = vue.ref(props.modelValue || colors.shades.white);
|
|
62
|
+
const onSwatchClick = (e) => selected.value = e.target.dataset.value || colors.shades.white;
|
|
63
|
+
vue.watch(
|
|
64
|
+
() => selected.value,
|
|
65
|
+
(s) => emits("update:modelValue", s)
|
|
66
|
+
);
|
|
67
|
+
return (_ctx, _cache) => {
|
|
68
|
+
const _component_v_icon = vue.resolveComponent("v-icon");
|
|
69
|
+
const _component_v_btn = vue.resolveComponent("v-btn");
|
|
70
|
+
const _component_v_sheet = vue.resolveComponent("v-sheet");
|
|
71
|
+
return vue.openBlock(), vue.createBlock(_component_v_sheet, { class: "v-swatches" }, {
|
|
72
|
+
default: vue.withCtx(() => [
|
|
73
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.swatches, (cols, rows) => {
|
|
74
|
+
return vue.openBlock(), vue.createElementBlock("div", { key: rows }, [
|
|
75
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(cols, (color) => {
|
|
76
|
+
return vue.openBlock(), vue.createBlock(_component_v_btn, {
|
|
77
|
+
key: color,
|
|
78
|
+
border: props.border,
|
|
79
|
+
class: vue.normalizeClass(color === vue.unref(colors).shades.transparent ? "bg-trasparent" : ""),
|
|
80
|
+
color,
|
|
81
|
+
disabled: props.disabled,
|
|
82
|
+
elevation: props.elevation,
|
|
83
|
+
height: props.size,
|
|
84
|
+
"data-value": color,
|
|
85
|
+
variant: props.variant,
|
|
86
|
+
width: props.size,
|
|
87
|
+
"min-width": "auto",
|
|
88
|
+
onClick: _cache[0] || (_cache[0] = ($event) => onSwatchClick($event))
|
|
119
89
|
}, {
|
|
120
90
|
default: vue.withCtx(() => [
|
|
121
|
-
|
|
91
|
+
color === __props.modelValue ? (vue.openBlock(), vue.createBlock(_component_v_icon, {
|
|
92
|
+
key: 0,
|
|
93
|
+
size: __props.iconSize,
|
|
94
|
+
color: color !== vue.unref(colors).shades.transparent ? color : void 0
|
|
95
|
+
}, {
|
|
96
|
+
default: vue.withCtx(() => [
|
|
97
|
+
vue.createTextVNode(vue.toDisplayString(props.icon), 1)
|
|
98
|
+
]),
|
|
99
|
+
_: 2
|
|
100
|
+
}, 1032, ["size", "color"])) : vue.createCommentVNode("", true)
|
|
122
101
|
]),
|
|
123
102
|
_: 2
|
|
124
|
-
}, 1032, ["
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}, 1032, ["color", "disabled", "height", "value", "variant", "width", "data-value", "class"]);
|
|
103
|
+
}, 1032, ["border", "class", "color", "disabled", "elevation", "height", "data-value", "variant", "width"]);
|
|
104
|
+
}), 128))
|
|
105
|
+
]);
|
|
128
106
|
}), 128))
|
|
129
|
-
])
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
107
|
+
]),
|
|
108
|
+
_: 1
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const VSwatches_vue_vue_type_style_index_0_lang = '';
|
|
136
115
|
|
|
137
|
-
const installVSwatches = (app) => app.component("VSwatches",
|
|
116
|
+
const installVSwatches = (app) => app.component("VSwatches", _sfc_main);
|
|
138
117
|
if (typeof window !== "undefined" && window.Vue) {
|
|
139
|
-
window.Vue.use(
|
|
118
|
+
window.Vue.use(_sfc_main);
|
|
140
119
|
}
|
|
141
120
|
|
|
142
|
-
exports.default =
|
|
121
|
+
exports.default = _sfc_main;
|
|
143
122
|
exports.install = installVSwatches;
|
|
144
123
|
|
|
145
124
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
package/dist/index.umd.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.3.
|
|
8
|
+
* @version 1.3.5
|
|
9
9
|
* @see {@link https://github.com/logue/vuetify-swatches}
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -15,43 +15,35 @@
|
|
|
15
15
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VSwatches = {}, global.Vue, global.colors));
|
|
16
16
|
})(this, (function (exports, vue, colors) { 'use strict';
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
21
|
-
|
|
22
|
-
const _sfc_main = vue.defineComponent({
|
|
23
|
-
name: "VSwatches",
|
|
24
|
-
model: {
|
|
25
|
-
prop: "modelValue",
|
|
26
|
-
event: "update:modelValue"
|
|
27
|
-
},
|
|
18
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
19
|
+
__name: "VSwatches",
|
|
28
20
|
props: {
|
|
29
|
-
modelValue: { type: String, default:
|
|
21
|
+
modelValue: { type: String, default: colors.shades.white },
|
|
30
22
|
swatches: {
|
|
31
23
|
type: Array,
|
|
32
24
|
default: () => [
|
|
33
|
-
[
|
|
25
|
+
[colors.shades.black, colors.shades.white, colors.shades.transparent],
|
|
34
26
|
[
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
colors.red.base,
|
|
28
|
+
colors.pink.base,
|
|
29
|
+
colors.purple.base,
|
|
30
|
+
colors.deepPurple.base,
|
|
31
|
+
colors.indigo.base,
|
|
32
|
+
colors.blue.base,
|
|
33
|
+
colors.lightBlue.base,
|
|
34
|
+
colors.cyan.base
|
|
43
35
|
],
|
|
44
36
|
[
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
37
|
+
colors.teal.base,
|
|
38
|
+
colors.green.base,
|
|
39
|
+
colors.lightGreen.base,
|
|
40
|
+
colors.lime.base,
|
|
41
|
+
colors.yellow.base,
|
|
42
|
+
colors.amber.base,
|
|
43
|
+
colors.orange.base,
|
|
44
|
+
colors.deepOrange.base
|
|
53
45
|
],
|
|
54
|
-
[
|
|
46
|
+
[colors.brown.base, colors.blueGrey.base, colors.grey.base]
|
|
55
47
|
]
|
|
56
48
|
},
|
|
57
49
|
size: { type: String, default: "2rem" },
|
|
@@ -62,87 +54,74 @@
|
|
|
62
54
|
default: void 0
|
|
63
55
|
},
|
|
64
56
|
disabled: { type: Boolean, default: void 0 },
|
|
65
|
-
rounded: { type: String, Number, default: void 0 }
|
|
57
|
+
rounded: { type: [String, Number, Boolean], default: void 0 },
|
|
58
|
+
border: { type: [String, Number, Boolean], default: false },
|
|
59
|
+
elevation: { type: [String, Number], default: void 0 }
|
|
66
60
|
},
|
|
67
61
|
emits: ["update:modelValue"],
|
|
68
|
-
setup(
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const _component_v_sheet = vue.resolveComponent("v-sheet");
|
|
99
|
-
return vue.openBlock(), vue.createBlock(_component_v_sheet, { class: "v-swatches" }, {
|
|
100
|
-
default: vue.withCtx(() => [
|
|
101
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.swatches, (colors, rows) => {
|
|
102
|
-
return vue.openBlock(), vue.createElementBlock("div", { key: rows }, [
|
|
103
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(colors, (color) => {
|
|
104
|
-
return vue.openBlock(), vue.createBlock(_component_v_btn, {
|
|
105
|
-
key: color,
|
|
106
|
-
color,
|
|
107
|
-
disabled: _ctx.disabled,
|
|
108
|
-
height: _ctx.size,
|
|
109
|
-
value: color,
|
|
110
|
-
variant: _ctx.variant,
|
|
111
|
-
width: _ctx.size,
|
|
112
|
-
"data-value": color,
|
|
113
|
-
class: vue.normalizeClass(color === _ctx.shades.transparent ? "bg-trasparent" : ""),
|
|
114
|
-
"min-width": "auto",
|
|
115
|
-
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.onSwatchClick($event))
|
|
116
|
-
}, {
|
|
117
|
-
default: vue.withCtx(() => [
|
|
118
|
-
color === _ctx.modelValue ? (vue.openBlock(), vue.createBlock(_component_v_icon, {
|
|
119
|
-
key: 0,
|
|
120
|
-
size: _ctx.iconSize,
|
|
121
|
-
color: color !== _ctx.shades.transparent ? color : void 0
|
|
62
|
+
setup(__props, { emit: emits }) {
|
|
63
|
+
const props = __props;
|
|
64
|
+
const selected = vue.ref(props.modelValue || colors.shades.white);
|
|
65
|
+
const onSwatchClick = (e) => selected.value = e.target.dataset.value || colors.shades.white;
|
|
66
|
+
vue.watch(
|
|
67
|
+
() => selected.value,
|
|
68
|
+
(s) => emits("update:modelValue", s)
|
|
69
|
+
);
|
|
70
|
+
return (_ctx, _cache) => {
|
|
71
|
+
const _component_v_icon = vue.resolveComponent("v-icon");
|
|
72
|
+
const _component_v_btn = vue.resolveComponent("v-btn");
|
|
73
|
+
const _component_v_sheet = vue.resolveComponent("v-sheet");
|
|
74
|
+
return vue.openBlock(), vue.createBlock(_component_v_sheet, { class: "v-swatches" }, {
|
|
75
|
+
default: vue.withCtx(() => [
|
|
76
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.swatches, (cols, rows) => {
|
|
77
|
+
return vue.openBlock(), vue.createElementBlock("div", { key: rows }, [
|
|
78
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(cols, (color) => {
|
|
79
|
+
return vue.openBlock(), vue.createBlock(_component_v_btn, {
|
|
80
|
+
key: color,
|
|
81
|
+
border: props.border,
|
|
82
|
+
class: vue.normalizeClass(color === vue.unref(colors).shades.transparent ? "bg-trasparent" : ""),
|
|
83
|
+
color,
|
|
84
|
+
disabled: props.disabled,
|
|
85
|
+
elevation: props.elevation,
|
|
86
|
+
height: props.size,
|
|
87
|
+
"data-value": color,
|
|
88
|
+
variant: props.variant,
|
|
89
|
+
width: props.size,
|
|
90
|
+
"min-width": "auto",
|
|
91
|
+
onClick: _cache[0] || (_cache[0] = ($event) => onSwatchClick($event))
|
|
122
92
|
}, {
|
|
123
93
|
default: vue.withCtx(() => [
|
|
124
|
-
|
|
94
|
+
color === __props.modelValue ? (vue.openBlock(), vue.createBlock(_component_v_icon, {
|
|
95
|
+
key: 0,
|
|
96
|
+
size: __props.iconSize,
|
|
97
|
+
color: color !== vue.unref(colors).shades.transparent ? color : void 0
|
|
98
|
+
}, {
|
|
99
|
+
default: vue.withCtx(() => [
|
|
100
|
+
vue.createTextVNode(vue.toDisplayString(props.icon), 1)
|
|
101
|
+
]),
|
|
102
|
+
_: 2
|
|
103
|
+
}, 1032, ["size", "color"])) : vue.createCommentVNode("", true)
|
|
125
104
|
]),
|
|
126
105
|
_: 2
|
|
127
|
-
}, 1032, ["
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}, 1032, ["color", "disabled", "height", "value", "variant", "width", "data-value", "class"]);
|
|
106
|
+
}, 1032, ["border", "class", "color", "disabled", "elevation", "height", "data-value", "variant", "width"]);
|
|
107
|
+
}), 128))
|
|
108
|
+
]);
|
|
131
109
|
}), 128))
|
|
132
|
-
])
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
110
|
+
]),
|
|
111
|
+
_: 1
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const VSwatches_vue_vue_type_style_index_0_lang = '';
|
|
139
118
|
|
|
140
|
-
const installVSwatches = (app) => app.component("VSwatches",
|
|
119
|
+
const installVSwatches = (app) => app.component("VSwatches", _sfc_main);
|
|
141
120
|
if (typeof window !== "undefined" && window.Vue) {
|
|
142
|
-
window.Vue.use(
|
|
121
|
+
window.Vue.use(_sfc_main);
|
|
143
122
|
}
|
|
144
123
|
|
|
145
|
-
exports.default =
|
|
124
|
+
exports.default = _sfc_main;
|
|
146
125
|
exports.install = installVSwatches;
|
|
147
126
|
|
|
148
127
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
package/dist/style.css
CHANGED
|
@@ -5,20 +5,20 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.3.
|
|
8
|
+
* @version 1.3.5
|
|
9
9
|
* @see {@link https://github.com/logue/vuetify-swatches}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
.v-swatches .v-btn {
|
|
12
|
+
.v-swatches div .v-btn {
|
|
13
13
|
padding: 0 !important;
|
|
14
14
|
margin: 0.1rem;
|
|
15
15
|
}
|
|
16
|
-
.v-swatches .v-btn .v-icon {
|
|
16
|
+
.v-swatches div .v-btn .v-icon {
|
|
17
17
|
filter: invert(100%) grayscale(100%) contrast(100);
|
|
18
18
|
}
|
|
19
|
-
.v-swatches .v-btn.bg-trasparent {
|
|
19
|
+
.v-swatches div .v-btn.bg-trasparent {
|
|
20
20
|
background: linear-gradient(to top left, transparent 0, transparent calc(50% - 0.1rem), #F44336 50%, transparent calc(50% + 0.1rem), transparent);
|
|
21
21
|
}
|
|
22
|
-
.v-swatches .v-btn.bg-trasparent .v-icon {
|
|
22
|
+
.v-swatches div .v-btn.bg-trasparent .v-icon {
|
|
23
23
|
filter: none;
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "vuetify-swatches",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.5",
|
|
5
5
|
"description": "Color Swatch component for Vuetify3.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"exports": {
|
|
43
43
|
".": {
|
|
44
44
|
"import": "./dist/index.es.js",
|
|
45
|
-
"require": "./dist/index.umd.js"
|
|
45
|
+
"require": "./dist/index.umd.js",
|
|
46
|
+
"types": "./dist/index.d.ts"
|
|
46
47
|
},
|
|
47
48
|
"./dist/style.css": {
|
|
48
49
|
"import": "./dist/style.css",
|
|
@@ -55,71 +56,72 @@
|
|
|
55
56
|
],
|
|
56
57
|
"engines": {
|
|
57
58
|
"node": ">=18.12.1",
|
|
58
|
-
"yarn": ">=1.22.
|
|
59
|
+
"yarn": ">=1.22.19"
|
|
59
60
|
},
|
|
60
|
-
"packageManager": "yarn@3.
|
|
61
|
+
"packageManager": "yarn@3.3.1",
|
|
61
62
|
"sideEffects": false,
|
|
62
63
|
"scripts": {
|
|
63
64
|
"dev": "vite",
|
|
64
|
-
"clean": "rimraf node_modules/.vite
|
|
65
|
-
"
|
|
66
|
-
"build
|
|
67
|
-
"build:docs": "vite build --config vite.config.docs.ts",
|
|
65
|
+
"clean": "rimraf node_modules/.vite",
|
|
66
|
+
"type-check": "tsc --noEmit --composite false",
|
|
67
|
+
"build": "run-p type-check build-only build-declaration",
|
|
68
68
|
"build:clean": "rimraf dist",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"prepare": "husky install"
|
|
69
|
+
"build:docs": "vite build --config vite.config.docs.ts",
|
|
70
|
+
"build-only": "vite build",
|
|
71
|
+
"build-declaration": "tsc -p tsconfig.app.json --composite false --declaration --declarationMap --declarationDir dist",
|
|
72
|
+
"lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
|
|
73
|
+
"prepare": "husky install",
|
|
74
|
+
"version": "auto-changelog -p && git add CHANGELOG.md"
|
|
74
75
|
},
|
|
75
76
|
"peerDependencies": {
|
|
76
|
-
"vue": "^3.2.
|
|
77
|
-
"vuetify": "^3.0.
|
|
77
|
+
"vue": "^3.2.45",
|
|
78
|
+
"vuetify": "^3.0.6"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
|
-
"@codemirror/lang-html": "^6.
|
|
81
|
-
"@types/node": "^18.11.
|
|
82
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
83
|
-
"@typescript-eslint/parser": "^5.
|
|
84
|
-
"@vitejs/plugin-vue": "^
|
|
81
|
+
"@codemirror/lang-html": "^6.4.0",
|
|
82
|
+
"@types/node": "^18.11.18",
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
|
84
|
+
"@typescript-eslint/parser": "^5.47.1",
|
|
85
|
+
"@vitejs/plugin-vue": "^4.0.0",
|
|
85
86
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
86
87
|
"@vue/tsconfig": "^0.1.3",
|
|
87
88
|
"codemirror": "^6.0.1",
|
|
88
|
-
"eslint": "^8.
|
|
89
|
+
"eslint": "^8.30.0",
|
|
89
90
|
"eslint-config-google": "^0.14.0",
|
|
90
91
|
"eslint-config-prettier": "^8.5.0",
|
|
91
92
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
92
93
|
"eslint-import-resolver-typescript": "^3.5.2",
|
|
93
94
|
"eslint-plugin-import": "^2.26.0",
|
|
94
|
-
"eslint-plugin-jsdoc": "^39.6.
|
|
95
|
+
"eslint-plugin-jsdoc": "^39.6.4",
|
|
95
96
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
96
|
-
"eslint-plugin-vue": "^9.
|
|
97
|
+
"eslint-plugin-vue": "^9.8.0",
|
|
97
98
|
"eslint-plugin-vuejs-accessibility": "^2.0.0",
|
|
98
|
-
"eslint-plugin-vuetify": "^
|
|
99
|
+
"eslint-plugin-vuetify": "^2.0.0-beta.2",
|
|
99
100
|
"eslint-plugin-yaml": "^0.5.0",
|
|
100
|
-
"husky": "^8.0.
|
|
101
|
-
"lint-staged": "^13.0
|
|
101
|
+
"husky": "^8.0.2",
|
|
102
|
+
"lint-staged": "^13.1.0",
|
|
103
|
+
"npm-run-all": "^4.1.5",
|
|
102
104
|
"postcss-html": "^1.5.0",
|
|
103
|
-
"prettier": "^2.
|
|
105
|
+
"prettier": "^2.8.1",
|
|
104
106
|
"rimraf": "^3.0.2",
|
|
105
107
|
"rollup-plugin-visualizer": "^5.8.3",
|
|
106
|
-
"sass": "1.
|
|
107
|
-
"stylelint": "^14.
|
|
108
|
-
"stylelint-config-prettier": "^9.0.
|
|
108
|
+
"sass": "1.57.1",
|
|
109
|
+
"stylelint": "^14.16.1",
|
|
110
|
+
"stylelint-config-prettier": "^9.0.4",
|
|
109
111
|
"stylelint-config-recommended-scss": "^8.0.0",
|
|
110
112
|
"stylelint-config-recommended-vue": "^1.4.0",
|
|
111
113
|
"stylelint-order": "^5.0.0",
|
|
112
114
|
"stylelint-prettier": "^2.0.0",
|
|
113
|
-
"typescript": "^4.
|
|
114
|
-
"vite": "^
|
|
115
|
-
"vite-plugin-banner": "^0.
|
|
116
|
-
"vite-plugin-checker": "^0.5.
|
|
117
|
-
"vite-plugin-vuetify": "^1.0.
|
|
118
|
-
"vue": "^3.2.
|
|
119
|
-
"vue-codemirror6": "1.1.
|
|
115
|
+
"typescript": "^4.9.4",
|
|
116
|
+
"vite": "^4.0.3",
|
|
117
|
+
"vite-plugin-banner": "^0.7.0",
|
|
118
|
+
"vite-plugin-checker": "^0.5.3",
|
|
119
|
+
"vite-plugin-vuetify": "^1.0.1",
|
|
120
|
+
"vue": "^3.2.45",
|
|
121
|
+
"vue-codemirror6": "1.1.2",
|
|
120
122
|
"vue-eslint-parser": "^9.1.0",
|
|
121
|
-
"vue-tsc": "^1.0.
|
|
122
|
-
"vuetify": "^3.0.
|
|
123
|
+
"vue-tsc": "^1.0.18",
|
|
124
|
+
"vuetify": "^3.0.4"
|
|
123
125
|
},
|
|
124
126
|
"husky": {
|
|
125
127
|
"hooks": {
|
|
@@ -127,12 +129,11 @@
|
|
|
127
129
|
}
|
|
128
130
|
},
|
|
129
131
|
"lint-staged": {
|
|
130
|
-
"*.vue": "vue-tsc --noEmit",
|
|
131
132
|
"*.{js,ts,json,yml,yaml,vue,htm,html}": "eslint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint",
|
|
132
133
|
"*.{css,sass,scss,vue,htm,html}": "stylelint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-stylelint",
|
|
133
134
|
"*": "prettier -w -u"
|
|
134
135
|
},
|
|
135
136
|
"resolutions": {
|
|
136
|
-
"prettier": "^2.
|
|
137
|
+
"prettier": "^2.8.1"
|
|
137
138
|
}
|
|
138
139
|
}
|
|
@@ -1,171 +1,161 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/** Vuetify Swatches */
|
|
3
|
+
import { ref, watch, type PropType, type Ref } from 'vue';
|
|
4
|
+
import colors from 'vuetify/lib/util/colors.mjs';
|
|
5
|
+
|
|
6
|
+
/** Emits */
|
|
7
|
+
const emits = defineEmits<{
|
|
8
|
+
(event: 'update:modelValue', value: string): void;
|
|
9
|
+
}>();
|
|
10
|
+
|
|
11
|
+
/** Props */
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
/** Model value */
|
|
14
|
+
modelValue: { type: String, default: colors.shades.white },
|
|
15
|
+
/** Swatch colors */
|
|
16
|
+
swatches: {
|
|
17
|
+
type: Array as PropType<string[] | string[][]>,
|
|
18
|
+
default: () => [
|
|
19
|
+
[colors.shades.black, colors.shades.white, colors.shades.transparent],
|
|
20
|
+
[
|
|
21
|
+
colors.red.base,
|
|
22
|
+
colors.pink.base,
|
|
23
|
+
colors.purple.base,
|
|
24
|
+
colors.deepPurple.base,
|
|
25
|
+
colors.indigo.base,
|
|
26
|
+
colors.blue.base,
|
|
27
|
+
colors.lightBlue.base,
|
|
28
|
+
colors.cyan.base,
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
colors.teal.base,
|
|
32
|
+
colors.green.base,
|
|
33
|
+
colors.lightGreen.base,
|
|
34
|
+
colors.lime.base,
|
|
35
|
+
colors.yellow.base,
|
|
36
|
+
colors.amber.base,
|
|
37
|
+
colors.orange.base,
|
|
38
|
+
colors.deepOrange.base,
|
|
39
|
+
],
|
|
40
|
+
[colors.brown.base, colors.blueGrey.base, colors.grey.base],
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
/** Swatch size */
|
|
44
|
+
size: { type: String, default: '2rem' },
|
|
45
|
+
/** Selected icon */
|
|
46
|
+
icon: { type: String, default: 'mdi-checkbox-marked-circle' },
|
|
47
|
+
/** selected icon size */
|
|
48
|
+
iconSize: { type: String, default: '1rem' },
|
|
49
|
+
/**
|
|
50
|
+
* The variant prop gives you easy access to several different button styles..
|
|
51
|
+
*
|
|
52
|
+
* @see {@link https://next.vuetifyjs.com/en/components/buttons/#variant}
|
|
53
|
+
*/
|
|
54
|
+
variant: {
|
|
55
|
+
type: String as PropType<
|
|
56
|
+
'flat' | 'text' | 'elevated' | 'tonal' | 'outlined' | 'plain'
|
|
57
|
+
>,
|
|
58
|
+
default: undefined,
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Removes the ability to click or target the component.
|
|
62
|
+
*
|
|
63
|
+
* @see {@link https://vuetifyjs.com/en/api/v-btn/#props-disabled}
|
|
64
|
+
*/
|
|
65
|
+
disabled: { type: Boolean, default: undefined },
|
|
66
|
+
/**
|
|
67
|
+
* Applies a large border radius on the button.
|
|
68
|
+
*
|
|
69
|
+
* @see {@link https://next.vuetifyjs.com/en/components/buttons/#rounded}
|
|
70
|
+
*/
|
|
71
|
+
rounded: { type: [String, Number, Boolean], default: undefined },
|
|
72
|
+
/**
|
|
73
|
+
* Applies border styles to component.
|
|
74
|
+
*
|
|
75
|
+
* @see {@link https://next.vuetifyjs.com/en/api/v-btn/#props-border}
|
|
76
|
+
*/
|
|
77
|
+
border: { type: [String, Number, Boolean], default: false },
|
|
78
|
+
/**
|
|
79
|
+
* Designates an elevation applied to the component between 0 and 24.
|
|
80
|
+
*
|
|
81
|
+
* @see {@link https://next.vuetifyjs.com/en/api/v-btn/#props-elevation}
|
|
82
|
+
*/
|
|
83
|
+
elevation: { type: [String, Number], default: undefined },
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
/** Selected Color */
|
|
87
|
+
const selected: Ref<string> = ref(props.modelValue || colors.shades.white);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Swatch button clicked handler
|
|
91
|
+
*
|
|
92
|
+
* @param e - Event
|
|
93
|
+
*/
|
|
94
|
+
const onSwatchClick = (e: Event) =>
|
|
95
|
+
(selected.value =
|
|
96
|
+
(e.target as HTMLButtonElement).dataset.value || colors.shades.white);
|
|
97
|
+
|
|
98
|
+
watch(
|
|
99
|
+
() => selected.value,
|
|
100
|
+
s => emits('update:modelValue', s)
|
|
101
|
+
);
|
|
102
|
+
</script>
|
|
103
|
+
|
|
1
104
|
<template>
|
|
2
105
|
<v-sheet class="v-swatches">
|
|
3
|
-
<div v-for="(
|
|
106
|
+
<div v-for="(cols, rows) in swatches" :key="rows">
|
|
4
107
|
<v-btn
|
|
5
|
-
v-for="color in
|
|
108
|
+
v-for="color in cols"
|
|
6
109
|
:key="color"
|
|
110
|
+
:border="props.border"
|
|
111
|
+
:class="color === colors.shades.transparent ? 'bg-trasparent' : ''"
|
|
7
112
|
:color="color"
|
|
8
|
-
:disabled="disabled"
|
|
9
|
-
:
|
|
10
|
-
:
|
|
11
|
-
:variant="variant"
|
|
12
|
-
:width="size"
|
|
113
|
+
:disabled="props.disabled"
|
|
114
|
+
:elevation="props.elevation"
|
|
115
|
+
:height="props.size"
|
|
13
116
|
:data-value="color"
|
|
14
|
-
:
|
|
117
|
+
:variant="props.variant"
|
|
118
|
+
:width="props.size"
|
|
15
119
|
min-width="auto"
|
|
16
120
|
@click="onSwatchClick($event)"
|
|
17
121
|
>
|
|
18
122
|
<v-icon
|
|
19
123
|
v-if="color === modelValue"
|
|
20
124
|
:size="iconSize"
|
|
21
|
-
:color="color !== shades.transparent ? color : undefined"
|
|
125
|
+
:color="color !== colors.shades.transparent ? color : undefined"
|
|
22
126
|
>
|
|
23
|
-
{{ icon }}
|
|
127
|
+
{{ props.icon }}
|
|
24
128
|
</v-icon>
|
|
25
129
|
</v-btn>
|
|
26
130
|
</div>
|
|
27
131
|
</v-sheet>
|
|
28
132
|
</template>
|
|
29
133
|
|
|
30
|
-
<script lang="ts">
|
|
31
|
-
import {
|
|
32
|
-
defineComponent,
|
|
33
|
-
ref,
|
|
34
|
-
type PropType,
|
|
35
|
-
type Ref,
|
|
36
|
-
type SetupContext,
|
|
37
|
-
} from 'vue';
|
|
38
|
-
|
|
39
|
-
// eslint-disable-next-line import/no-unresolved
|
|
40
|
-
import colors from 'vuetify/lib/util/colors.mjs';
|
|
41
|
-
|
|
42
|
-
/** Vuetify Swatches */
|
|
43
|
-
export default defineComponent({
|
|
44
|
-
/** Component name */
|
|
45
|
-
name: 'VSwatches',
|
|
46
|
-
/** Model Definition */
|
|
47
|
-
model: {
|
|
48
|
-
prop: 'modelValue',
|
|
49
|
-
event: 'update:modelValue',
|
|
50
|
-
},
|
|
51
|
-
props: {
|
|
52
|
-
/** Model value */
|
|
53
|
-
modelValue: { type: String, default: colors.shades.white },
|
|
54
|
-
/** Swatch colors */
|
|
55
|
-
swatches: {
|
|
56
|
-
type: Array as PropType<string[] | string[][]>,
|
|
57
|
-
default: () => [
|
|
58
|
-
[colors.shades.black, colors.shades.white, colors.shades.transparent],
|
|
59
|
-
[
|
|
60
|
-
colors.red.base,
|
|
61
|
-
colors.pink.base,
|
|
62
|
-
colors.purple.base,
|
|
63
|
-
colors.deepPurple.base,
|
|
64
|
-
colors.indigo.base,
|
|
65
|
-
colors.blue.base,
|
|
66
|
-
colors.lightBlue.base,
|
|
67
|
-
colors.cyan.base,
|
|
68
|
-
],
|
|
69
|
-
[
|
|
70
|
-
colors.teal.base,
|
|
71
|
-
colors.green.base,
|
|
72
|
-
colors.lightGreen.base,
|
|
73
|
-
colors.lime.base,
|
|
74
|
-
colors.yellow.base,
|
|
75
|
-
colors.amber.base,
|
|
76
|
-
colors.orange.base,
|
|
77
|
-
colors.deepOrange.base,
|
|
78
|
-
],
|
|
79
|
-
[colors.brown.base, colors.blueGrey.base, colors.grey.base],
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
/** Swatch size */
|
|
83
|
-
size: { type: String, default: '2rem' },
|
|
84
|
-
/** Selected icon */
|
|
85
|
-
icon: { type: String, default: 'mdi-checkbox-marked-circle' },
|
|
86
|
-
/** selected icon size */
|
|
87
|
-
iconSize: { type: String, default: '1rem' },
|
|
88
|
-
/**
|
|
89
|
-
* The variant prop gives you easy access to several different button styles..
|
|
90
|
-
*
|
|
91
|
-
* @see {@link https://next.vuetifyjs.com/en/components/buttons/#variant}
|
|
92
|
-
*/
|
|
93
|
-
variant: {
|
|
94
|
-
type: String as PropType<
|
|
95
|
-
'elevated' | 'flat' | 'tonal' | 'outlined' | 'text' | 'plain'
|
|
96
|
-
>,
|
|
97
|
-
default: undefined,
|
|
98
|
-
},
|
|
99
|
-
/**
|
|
100
|
-
* Removes the ability to click or target the component.
|
|
101
|
-
*
|
|
102
|
-
* @see {@link https://vuetifyjs.com/en/api/v-btn/#props-disabled}
|
|
103
|
-
*/
|
|
104
|
-
disabled: { type: Boolean, default: undefined },
|
|
105
|
-
/**
|
|
106
|
-
* Applies a large border radius on the button.
|
|
107
|
-
*
|
|
108
|
-
* @see {@link https://next.vuetifyjs.com/en/components/buttons/#rounded}
|
|
109
|
-
*/
|
|
110
|
-
rounded: { type: String, Number, default: undefined },
|
|
111
|
-
},
|
|
112
|
-
/** Emits */
|
|
113
|
-
emits: ['update:modelValue'],
|
|
114
|
-
/**
|
|
115
|
-
* Setup
|
|
116
|
-
*
|
|
117
|
-
* @param props - Props
|
|
118
|
-
* @param context - Context
|
|
119
|
-
*/
|
|
120
|
-
setup(props, context: SetupContext) {
|
|
121
|
-
/** Check icon visibility */
|
|
122
|
-
const checkedVisibilty: Ref<boolean> = ref(false);
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Swatch button clicked handler
|
|
126
|
-
*
|
|
127
|
-
* @param e - Event
|
|
128
|
-
*/
|
|
129
|
-
const onSwatchClick = (e: Event) => {
|
|
130
|
-
const value = (e.target as HTMLButtonElement).dataset.value;
|
|
131
|
-
if (!value || props.modelValue === value) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
context.emit('update:modelValue', value);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
checkedVisibilty,
|
|
139
|
-
onSwatchClick,
|
|
140
|
-
shades: colors.shades,
|
|
141
|
-
};
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
</script>
|
|
145
|
-
|
|
146
134
|
<style lang="scss">
|
|
147
|
-
@import '
|
|
135
|
+
@import '~/vuetify/lib/styles/settings';
|
|
148
136
|
|
|
149
137
|
.v-swatches {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
.v-icon {
|
|
155
|
-
filter: invert(100%) grayscale(100%) contrast(100);
|
|
156
|
-
}
|
|
138
|
+
div {
|
|
139
|
+
.v-btn {
|
|
140
|
+
padding: 0 !important;
|
|
141
|
+
margin: 0.1rem;
|
|
157
142
|
|
|
158
|
-
&.bg-trasparent {
|
|
159
|
-
background: linear-gradient(
|
|
160
|
-
to top left,
|
|
161
|
-
transparent 0,
|
|
162
|
-
transparent calc(50% - 0.1rem),
|
|
163
|
-
map-get($red, 'base') 50%,
|
|
164
|
-
transparent calc(50% + 0.1rem),
|
|
165
|
-
transparent
|
|
166
|
-
);
|
|
167
143
|
.v-icon {
|
|
168
|
-
filter:
|
|
144
|
+
filter: invert(100%) grayscale(100%) contrast(100);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&.bg-trasparent {
|
|
148
|
+
background: linear-gradient(
|
|
149
|
+
to top left,
|
|
150
|
+
transparent 0,
|
|
151
|
+
transparent calc(50% - 0.1rem),
|
|
152
|
+
map-get($red, 'base') 50%,
|
|
153
|
+
transparent calc(50% + 0.1rem),
|
|
154
|
+
transparent
|
|
155
|
+
);
|
|
156
|
+
.v-icon {
|
|
157
|
+
filter: none;
|
|
158
|
+
}
|
|
169
159
|
}
|
|
170
160
|
}
|
|
171
161
|
}
|
|
@@ -1,126 +0,0 @@
|
|
|
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
|
-
/** Swatch size */
|
|
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
|
-
* The variant prop gives you easy access to several different button styles..
|
|
31
|
-
*
|
|
32
|
-
* @see {@link https://next.vuetifyjs.com/en/components/buttons/#variant}
|
|
33
|
-
*/
|
|
34
|
-
variant: {
|
|
35
|
-
type: PropType<"text" | "elevated" | "flat" | "tonal" | "outlined" | "plain">;
|
|
36
|
-
default: undefined;
|
|
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: undefined;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Applies a large border radius on the button.
|
|
49
|
-
*
|
|
50
|
-
* @see {@link https://next.vuetifyjs.com/en/components/buttons/#rounded}
|
|
51
|
-
*/
|
|
52
|
-
rounded: {
|
|
53
|
-
type: StringConstructor;
|
|
54
|
-
Number: NumberConstructor;
|
|
55
|
-
default: undefined;
|
|
56
|
-
};
|
|
57
|
-
}, {
|
|
58
|
-
checkedVisibilty: Ref<boolean>;
|
|
59
|
-
onSwatchClick: (e: Event) => void;
|
|
60
|
-
shades: any;
|
|
61
|
-
}, 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<{
|
|
62
|
-
/** Model value */
|
|
63
|
-
modelValue: {
|
|
64
|
-
type: StringConstructor;
|
|
65
|
-
default: any;
|
|
66
|
-
};
|
|
67
|
-
/** Swatch colors */
|
|
68
|
-
swatches: {
|
|
69
|
-
type: PropType<string[] | string[][]>;
|
|
70
|
-
default: () => any[][];
|
|
71
|
-
};
|
|
72
|
-
/** Swatch size */
|
|
73
|
-
size: {
|
|
74
|
-
type: StringConstructor;
|
|
75
|
-
default: string;
|
|
76
|
-
};
|
|
77
|
-
/** Selected icon */
|
|
78
|
-
icon: {
|
|
79
|
-
type: StringConstructor;
|
|
80
|
-
default: string;
|
|
81
|
-
};
|
|
82
|
-
/** selected icon size */
|
|
83
|
-
iconSize: {
|
|
84
|
-
type: StringConstructor;
|
|
85
|
-
default: string;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* The variant prop gives you easy access to several different button styles..
|
|
89
|
-
*
|
|
90
|
-
* @see {@link https://next.vuetifyjs.com/en/components/buttons/#variant}
|
|
91
|
-
*/
|
|
92
|
-
variant: {
|
|
93
|
-
type: PropType<"text" | "elevated" | "flat" | "tonal" | "outlined" | "plain">;
|
|
94
|
-
default: undefined;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Removes the ability to click or target the component.
|
|
98
|
-
*
|
|
99
|
-
* @see {@link https://vuetifyjs.com/en/api/v-btn/#props-disabled}
|
|
100
|
-
*/
|
|
101
|
-
disabled: {
|
|
102
|
-
type: BooleanConstructor;
|
|
103
|
-
default: undefined;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Applies a large border radius on the button.
|
|
107
|
-
*
|
|
108
|
-
* @see {@link https://next.vuetifyjs.com/en/components/buttons/#rounded}
|
|
109
|
-
*/
|
|
110
|
-
rounded: {
|
|
111
|
-
type: StringConstructor;
|
|
112
|
-
Number: NumberConstructor;
|
|
113
|
-
default: undefined;
|
|
114
|
-
};
|
|
115
|
-
}>>, {
|
|
116
|
-
modelValue: string;
|
|
117
|
-
swatches: string[] | string[][];
|
|
118
|
-
size: string;
|
|
119
|
-
icon: string;
|
|
120
|
-
iconSize: string;
|
|
121
|
-
variant: "text" | "elevated" | "flat" | "tonal" | "outlined" | "plain";
|
|
122
|
-
disabled: boolean;
|
|
123
|
-
rounded: string;
|
|
124
|
-
}>;
|
|
125
|
-
export default _default;
|
|
126
|
-
//# sourceMappingURL=VSwatches.vue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VSwatches.vue.d.ts","sourceRoot":"","sources":["../../src/components/VSwatches.vue.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,GAAG,EAET,MAAM,KAAK,CAAC;AAKb,uBAAuB;;IAUnB,kBAAkB;;;;;IAElB,oBAAoB;;;;;IA4BpB,kBAAkB;;;;;IAElB,oBAAoB;;;;;IAEpB,yBAAyB;;;;;IAEzB;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;;;;uBAoBuB,KAAK;;;IA7E/B,kBAAkB;;;;;IAElB,oBAAoB;;;;;IA4BpB,kBAAkB;;;;;IAElB,oBAAoB;;;;;IAEpB,yBAAyB;;;;;IAEzB;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAEH;;;;OAIG;;;;;;;;;;;;;;;;AAlEP,wBAoGG"}
|