vuetify-swatches 0.3.3 → 1.3.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 +73 -78
- package/dist/components/VSwatches.vue.d.ts +64 -15
- package/dist/components/VSwatches.vue.d.ts.map +1 -1
- package/dist/index.es.js +49 -43
- package/dist/index.iife.js +12 -0
- package/dist/index.umd.js +2 -2
- package/dist/style.css +2 -2
- package/package.json +26 -26
- package/src/components/VSwatches.vue +60 -12
package/README.md
CHANGED
|
@@ -21,24 +21,18 @@ This library is positioned as a complement to Vuetify and provides a minimal UI.
|
|
|
21
21
|
In this example, the selected color is assigned to `selected`.
|
|
22
22
|
|
|
23
23
|
```vue
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
</template>
|
|
27
|
-
|
|
28
|
-
<script>
|
|
29
|
-
import Vue from 'vue';
|
|
24
|
+
<script setup lang="ts">
|
|
25
|
+
import { ref, type Ref } from 'vue';
|
|
30
26
|
|
|
31
27
|
import VSwatches from 'vuetify-swatches';
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
data() {
|
|
35
|
-
return {
|
|
36
|
-
selected: '#ffffff',
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
});
|
|
29
|
+
const selected: Ref<string> = ref('#ffffff');
|
|
40
30
|
</script>
|
|
41
31
|
|
|
32
|
+
<template>
|
|
33
|
+
<v-swatches v-model="selected" />
|
|
34
|
+
</template>
|
|
35
|
+
|
|
42
36
|
<style>
|
|
43
37
|
@import 'vuetify-swatches/dist/style.css';
|
|
44
38
|
</style>
|
|
@@ -49,11 +43,64 @@ The method of specifying `swatches` is the same as [nested-color of Vue Swatches
|
|
|
49
43
|
If you want to make the color palette appear when you click it, combine it with VMenu.
|
|
50
44
|
|
|
51
45
|
```vue
|
|
46
|
+
<script setup lang="ts">
|
|
47
|
+
import { ref, type Ref } from 'vue';
|
|
48
|
+
|
|
49
|
+
import VSwatches from 'vuetify-swatches';
|
|
50
|
+
|
|
51
|
+
const palette: Ref<string[] | string[][]> = ref([
|
|
52
|
+
[
|
|
53
|
+
'#ffb7b7',
|
|
54
|
+
'#ffdbb7',
|
|
55
|
+
'#ffffb7',
|
|
56
|
+
'#b7ffb7',
|
|
57
|
+
'#b7ffff',
|
|
58
|
+
'#b7b7ff',
|
|
59
|
+
'#ffb7ff',
|
|
60
|
+
'#ffffff',
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
'#ff5555',
|
|
64
|
+
'#ffa555',
|
|
65
|
+
'#ffff55',
|
|
66
|
+
'#55ff55',
|
|
67
|
+
'#55ffff',
|
|
68
|
+
'#5555ff',
|
|
69
|
+
'#ff55ff',
|
|
70
|
+
'#aaaaaa',
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
'#ff0000',
|
|
74
|
+
'#ff7f00',
|
|
75
|
+
'#ffff00',
|
|
76
|
+
'#00ff00',
|
|
77
|
+
'#00ffff',
|
|
78
|
+
'#0000ff',
|
|
79
|
+
'#ff00ff',
|
|
80
|
+
'#555555',
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
'#7f0000',
|
|
84
|
+
'#7f4c00',
|
|
85
|
+
'#7f7f00',
|
|
86
|
+
'#007f00',
|
|
87
|
+
'#007f7f',
|
|
88
|
+
'#00007f',
|
|
89
|
+
'#7f007f',
|
|
90
|
+
'#000000',
|
|
91
|
+
],
|
|
92
|
+
]);
|
|
93
|
+
const selected: Ref<string> = ref('#ffffff');
|
|
94
|
+
</script>
|
|
95
|
+
|
|
52
96
|
<template>
|
|
53
97
|
<v-menu offset-y>
|
|
54
|
-
<template #activator="{
|
|
55
|
-
<v-btn v-bind="
|
|
56
|
-
<v-icon
|
|
98
|
+
<template #activator="{ props }">
|
|
99
|
+
<v-btn v-bind="props" class="mb-3" min-width="auto" :color="selected">
|
|
100
|
+
<v-icon
|
|
101
|
+
:color="selected"
|
|
102
|
+
style="filter: invert(100%) grayscale(100%) contrast(100)"
|
|
103
|
+
>
|
|
57
104
|
mdi-menu-down
|
|
58
105
|
</v-icon>
|
|
59
106
|
</v-btn>
|
|
@@ -62,62 +109,6 @@ If you want to make the color palette appear when you click it, combine it with
|
|
|
62
109
|
</v-menu>
|
|
63
110
|
</template>
|
|
64
111
|
|
|
65
|
-
<script>
|
|
66
|
-
import Vue from 'vue';
|
|
67
|
-
|
|
68
|
-
import VSwatches from 'vuetify-swatches';
|
|
69
|
-
|
|
70
|
-
export default Vue.extend({
|
|
71
|
-
data() {
|
|
72
|
-
return {
|
|
73
|
-
selected: '#ffffff',
|
|
74
|
-
palette: [
|
|
75
|
-
[
|
|
76
|
-
'#ffb7b7',
|
|
77
|
-
'#ffdbb7',
|
|
78
|
-
'#ffffb7',
|
|
79
|
-
'#b7ffb7',
|
|
80
|
-
'#b7ffff',
|
|
81
|
-
'#b7b7ff',
|
|
82
|
-
'#ffb7ff',
|
|
83
|
-
'#ffffff',
|
|
84
|
-
],
|
|
85
|
-
[
|
|
86
|
-
'#ff5555',
|
|
87
|
-
'#ffa555',
|
|
88
|
-
'#ffff55',
|
|
89
|
-
'#55ff55',
|
|
90
|
-
'#55ffff',
|
|
91
|
-
'#5555ff',
|
|
92
|
-
'#ff55ff',
|
|
93
|
-
'#aaaaaa',
|
|
94
|
-
],
|
|
95
|
-
[
|
|
96
|
-
'#ff0000',
|
|
97
|
-
'#ff7f00',
|
|
98
|
-
'#ffff00',
|
|
99
|
-
'#00ff00',
|
|
100
|
-
'#00ffff',
|
|
101
|
-
'#0000ff',
|
|
102
|
-
'#ff00ff',
|
|
103
|
-
'#555555',
|
|
104
|
-
],
|
|
105
|
-
[
|
|
106
|
-
'#7f0000',
|
|
107
|
-
'#7f4c00',
|
|
108
|
-
'#7f7f00',
|
|
109
|
-
'#007f00',
|
|
110
|
-
'#007f7f',
|
|
111
|
-
'#00007f',
|
|
112
|
-
'#7f007f',
|
|
113
|
-
'#000000',
|
|
114
|
-
],
|
|
115
|
-
],
|
|
116
|
-
};
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
</script>
|
|
120
|
-
|
|
121
112
|
<style>
|
|
122
113
|
@import 'vuetify-swatches/dist/style.css';
|
|
123
114
|
</style>
|
|
@@ -125,12 +116,16 @@ export default Vue.extend({
|
|
|
125
116
|
|
|
126
117
|
### Options
|
|
127
118
|
|
|
128
|
-
| Variables | Type
|
|
129
|
-
| --------- |
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
| icon
|
|
133
|
-
|
|
|
119
|
+
| Variables | Type | Default | Info |
|
|
120
|
+
| --------- | -------------- | -------------------------- | -------------------------------------------------------------------------- |
|
|
121
|
+
| size | string | 2rem | Swatch Button size |
|
|
122
|
+
| icon | string | mdi-checkbox-marked-circle | checked icon |
|
|
123
|
+
| icon-size | string | 1rem | checked icon size |
|
|
124
|
+
| disabled | boolean | false | Removes the ability to click or target the component. |
|
|
125
|
+
| rounded | number\|string | undefined | Applies a large border radius on the button. |
|
|
126
|
+
| variant | string [^1] | undefined | The variant prop gives you easy access to several different button styles. |
|
|
127
|
+
|
|
128
|
+
[^1] Available variants are: elevated(default), flat, tonal, outlined, text, and plain.
|
|
134
129
|
|
|
135
130
|
## LICENSE
|
|
136
131
|
|
|
@@ -11,17 +11,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
11
11
|
type: PropType<string[] | string[][]>;
|
|
12
12
|
default: () => any[][];
|
|
13
13
|
};
|
|
14
|
-
/**
|
|
15
|
-
elevation: {
|
|
16
|
-
type: NumberConstructor;
|
|
17
|
-
default: number;
|
|
18
|
-
};
|
|
19
|
-
/** Swatch sized */
|
|
14
|
+
/** Swatch size */
|
|
20
15
|
size: {
|
|
21
16
|
type: StringConstructor;
|
|
22
17
|
default: string;
|
|
23
18
|
};
|
|
24
|
-
/**
|
|
19
|
+
/** Selected icon */
|
|
25
20
|
icon: {
|
|
26
21
|
type: StringConstructor;
|
|
27
22
|
default: string;
|
|
@@ -31,9 +26,38 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
31
26
|
type: StringConstructor;
|
|
32
27
|
default: string;
|
|
33
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
|
+
};
|
|
34
57
|
}, {
|
|
35
58
|
checkedVisibilty: Ref<boolean>;
|
|
36
59
|
onSwatchClick: (e: Event) => void;
|
|
60
|
+
shades: any;
|
|
37
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<{
|
|
38
62
|
/** Model value */
|
|
39
63
|
modelValue: {
|
|
@@ -45,17 +69,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
45
69
|
type: PropType<string[] | string[][]>;
|
|
46
70
|
default: () => any[][];
|
|
47
71
|
};
|
|
48
|
-
/**
|
|
49
|
-
elevation: {
|
|
50
|
-
type: NumberConstructor;
|
|
51
|
-
default: number;
|
|
52
|
-
};
|
|
53
|
-
/** Swatch sized */
|
|
72
|
+
/** Swatch size */
|
|
54
73
|
size: {
|
|
55
74
|
type: StringConstructor;
|
|
56
75
|
default: string;
|
|
57
76
|
};
|
|
58
|
-
/**
|
|
77
|
+
/** Selected icon */
|
|
59
78
|
icon: {
|
|
60
79
|
type: StringConstructor;
|
|
61
80
|
default: string;
|
|
@@ -65,13 +84,43 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
65
84
|
type: StringConstructor;
|
|
66
85
|
default: string;
|
|
67
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
|
+
};
|
|
68
115
|
}>>, {
|
|
69
116
|
modelValue: string;
|
|
70
117
|
swatches: string[] | string[][];
|
|
71
|
-
elevation: number;
|
|
72
118
|
size: string;
|
|
73
119
|
icon: string;
|
|
74
120
|
iconSize: string;
|
|
121
|
+
variant: "text" | "elevated" | "flat" | "tonal" | "outlined" | "plain";
|
|
122
|
+
disabled: boolean;
|
|
123
|
+
rounded: string;
|
|
75
124
|
}>;
|
|
76
125
|
export default _default;
|
|
77
126
|
//# 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,
|
|
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,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"}
|
package/dist/index.es.js
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version
|
|
8
|
+
* @version 1.3.0
|
|
9
9
|
* @see {@link https://github.com/logue/vuetify-swatches}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { defineComponent as
|
|
12
|
+
import { defineComponent as k, ref as S, resolveComponent as d, openBlock as n, createBlock as u, withCtx as c, createElementBlock as p, Fragment as b, renderList as h, normalizeClass as _, createTextVNode as C, toDisplayString as z, createCommentVNode as B } from "vue";
|
|
13
13
|
import e from "vuetify/lib/util/colors.mjs";
|
|
14
|
-
const
|
|
14
|
+
const $ = k({
|
|
15
15
|
name: "VSwatches",
|
|
16
16
|
model: {
|
|
17
17
|
prop: "modelValue",
|
|
@@ -22,7 +22,7 @@ const B = V({
|
|
|
22
22
|
swatches: {
|
|
23
23
|
type: Array,
|
|
24
24
|
default: () => [
|
|
25
|
-
[e.shades.black, e.shades.white],
|
|
25
|
+
[e.shades.black, e.shades.white, e.shades.transparent],
|
|
26
26
|
[
|
|
27
27
|
e.red.base,
|
|
28
28
|
e.pink.base,
|
|
@@ -46,68 +46,74 @@ const B = V({
|
|
|
46
46
|
[e.brown.base, e.blueGrey.base, e.grey.base]
|
|
47
47
|
]
|
|
48
48
|
},
|
|
49
|
-
elevation: { type: Number, default: 1 },
|
|
50
49
|
size: { type: String, default: "2rem" },
|
|
51
50
|
icon: { type: String, default: "mdi-checkbox-marked-circle" },
|
|
52
|
-
iconSize: { type: String, default: "1rem" }
|
|
51
|
+
iconSize: { type: String, default: "1rem" },
|
|
52
|
+
variant: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: void 0
|
|
55
|
+
},
|
|
56
|
+
disabled: { type: Boolean, default: void 0 },
|
|
57
|
+
rounded: { type: String, Number, default: void 0 }
|
|
53
58
|
},
|
|
54
59
|
emits: ["update:modelValue"],
|
|
55
|
-
setup(t,
|
|
60
|
+
setup(t, s) {
|
|
56
61
|
return {
|
|
57
|
-
checkedVisibilty:
|
|
58
|
-
onSwatchClick: (
|
|
59
|
-
const
|
|
60
|
-
!
|
|
61
|
-
}
|
|
62
|
+
checkedVisibilty: S(!1),
|
|
63
|
+
onSwatchClick: (o) => {
|
|
64
|
+
const l = o.target.dataset.value;
|
|
65
|
+
!l || t.modelValue === l || s.emit("update:modelValue", l);
|
|
66
|
+
},
|
|
67
|
+
shades: e.shades
|
|
62
68
|
};
|
|
63
69
|
}
|
|
64
70
|
});
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
for (const [r,
|
|
68
|
-
|
|
69
|
-
return
|
|
71
|
+
const N = (t, s) => {
|
|
72
|
+
const i = t.__vccOpts || t;
|
|
73
|
+
for (const [r, o] of s)
|
|
74
|
+
i[r] = o;
|
|
75
|
+
return i;
|
|
70
76
|
};
|
|
71
|
-
function
|
|
72
|
-
const
|
|
73
|
-
return n(),
|
|
74
|
-
default:
|
|
75
|
-
(n(!0), p(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
key: s,
|
|
81
|
-
elevation: t.elevation,
|
|
82
|
-
width: t.size,
|
|
77
|
+
function G(t, s, i, r, o, l) {
|
|
78
|
+
const v = d("v-icon"), f = d("v-btn"), w = d("v-sheet");
|
|
79
|
+
return n(), u(w, { class: "v-swatches" }, {
|
|
80
|
+
default: c(() => [
|
|
81
|
+
(n(!0), p(b, null, h(t.swatches, (y, g) => (n(), p("div", { key: g }, [
|
|
82
|
+
(n(!0), p(b, null, h(y, (a) => (n(), u(f, {
|
|
83
|
+
key: a,
|
|
84
|
+
color: a,
|
|
85
|
+
disabled: t.disabled,
|
|
83
86
|
height: t.size,
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
value: a,
|
|
88
|
+
variant: t.variant,
|
|
89
|
+
width: t.size,
|
|
90
|
+
"data-value": a,
|
|
91
|
+
class: _(a === t.shades.transparent ? "bg-trasparent" : ""),
|
|
86
92
|
"min-width": "auto",
|
|
87
|
-
onClick:
|
|
93
|
+
onClick: s[0] || (s[0] = (V) => t.onSwatchClick(V))
|
|
88
94
|
}, {
|
|
89
|
-
default:
|
|
90
|
-
|
|
95
|
+
default: c(() => [
|
|
96
|
+
a === t.modelValue ? (n(), u(v, {
|
|
91
97
|
key: 0,
|
|
92
98
|
size: t.iconSize,
|
|
93
|
-
color:
|
|
99
|
+
color: a !== t.shades.transparent ? a : void 0
|
|
94
100
|
}, {
|
|
95
|
-
default:
|
|
96
|
-
|
|
101
|
+
default: c(() => [
|
|
102
|
+
C(z(t.icon), 1)
|
|
97
103
|
]),
|
|
98
104
|
_: 2
|
|
99
|
-
}, 1032, ["size", "color"])) :
|
|
105
|
+
}, 1032, ["size", "color"])) : B("", !0)
|
|
100
106
|
]),
|
|
101
107
|
_: 2
|
|
102
|
-
}, 1032, ["
|
|
108
|
+
}, 1032, ["color", "disabled", "height", "value", "variant", "width", "data-value", "class"]))), 128))
|
|
103
109
|
]))), 128))
|
|
104
110
|
]),
|
|
105
111
|
_: 1
|
|
106
112
|
});
|
|
107
113
|
}
|
|
108
|
-
const
|
|
109
|
-
typeof window < "u" && window.Vue && window.Vue.use(
|
|
114
|
+
const m = /* @__PURE__ */ N($, [["render", G]]), D = (t) => t.component("VSwatches", m);
|
|
115
|
+
typeof window < "u" && window.Vue && window.Vue.use(m);
|
|
110
116
|
export {
|
|
111
|
-
|
|
112
|
-
|
|
117
|
+
m as default,
|
|
118
|
+
D as install
|
|
113
119
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vuetify-swatches
|
|
3
|
+
*
|
|
4
|
+
* @description Color Swatch component for Vuetify3.
|
|
5
|
+
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
+
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
|
+
* @license MIT
|
|
8
|
+
* @version 1.3.0
|
|
9
|
+
* @see {@link https://github.com/logue/vuetify-swatches}
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var VSwatches=function(s,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.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"},variant:{type:String,default:void 0},disabled:{type:Boolean,default:void 0},rounded:{type:String,Number,default:void 0}},emits:["update:modelValue"],setup(a,n){return{checkedVisibilty:e.ref(!1),onSwatchClick:o=>{const i=o.target.dataset.value;!i||a.modelValue===i||n.emit("update:modelValue",i)},shades:t.default.shades}}}),V="",p=(a,n)=>{const d=a.__vccOpts||a;for(const[c,o]of n)d[c]=o;return d};function b(a,n,d,c,o,i){const m=e.resolveComponent("v-icon"),w=e.resolveComponent("v-btn"),y=e.resolveComponent("v-sheet");return e.openBlock(),e.createBlock(y,{class:"v-swatches"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.swatches,(g,k)=>(e.openBlock(),e.createElementBlock("div",{key:k},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g,l=>(e.openBlock(),e.createBlock(w,{key:l,color:l,disabled:a.disabled,height:a.size,value:l,variant:a.variant,width:a.size,"data-value":l,class:e.normalizeClass(l===a.shades.transparent?"bg-trasparent":""),"min-width":"auto",onClick:n[0]||(n[0]=_=>a.onSwatchClick(_))},{default:e.withCtx(()=>[l===a.modelValue?(e.openBlock(),e.createBlock(m,{key:0,size:a.iconSize,color:l!==a.shades.transparent?l:void 0},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.icon),1)]),_:2},1032,["size","color"])):e.createCommentVNode("",!0)]),_:2},1032,["color","disabled","height","value","variant","width","data-value","class"]))),128))]))),128))]),_:1})}const r=p(f,[["render",b]]),h=a=>a.component("VSwatches",r);return typeof window<"u"&&window.Vue&&window.Vue.use(r),s.default=r,s.install=h,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),s}({},Vue,colors);
|
package/dist/index.umd.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version
|
|
8
|
+
* @version 1.3.0
|
|
9
9
|
* @see {@link https://github.com/logue/vuetify-swatches}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
(function(
|
|
12
|
+
(function(n,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):(n=typeof globalThis<"u"?globalThis:n||self,e(n.VSwatches={},n.Vue,n.colors))})(this,function(n,e,c){"use strict";const t=(a=>a&&typeof a=="object"&&"default"in a?a:{default:a})(c),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.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"},variant:{type:String,default:void 0},disabled:{type:Boolean,default:void 0},rounded:{type:String,Number,default:void 0}},emits:["update:modelValue"],setup(a,s){return{checkedVisibilty:e.ref(!1),onSwatchClick:d=>{const i=d.target.dataset.value;!i||a.modelValue===i||s.emit("update:modelValue",i)},shades:t.default.shades}}}),V="",p=(a,s)=>{const o=a.__vccOpts||a;for(const[u,d]of s)o[u]=d;return o};function h(a,s,o,u,d,i){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,g)=>(e.openBlock(),e.createElementBlock("div",{key:g},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k,l=>(e.openBlock(),e.createBlock(y,{key:l,color:l,disabled:a.disabled,height:a.size,value:l,variant:a.variant,width:a.size,"data-value":l,class:e.normalizeClass(l===a.shades.transparent?"bg-trasparent":""),"min-width":"auto",onClick:s[0]||(s[0]=_=>a.onSwatchClick(_))},{default:e.withCtx(()=>[l===a.modelValue?(e.openBlock(),e.createBlock(b,{key:0,size:a.iconSize,color:l!==a.shades.transparent?l:void 0},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.icon),1)]),_:2},1032,["size","color"])):e.createCommentVNode("",!0)]),_:2},1032,["color","disabled","height","value","variant","width","data-value","class"]))),128))]))),128))]),_:1})}const r=p(f,[["render",h]]),m=a=>a.component("VSwatches",r);typeof window<"u"&&window.Vue&&window.Vue.use(r),n.default=r,n.install=m,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/style.css
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version
|
|
8
|
+
* @version 1.3.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.bg-trasparent{background:linear-gradient(to top left,transparent 0,transparent calc(50% - .1rem),#F44336 50%,transparent calc(50% + .1rem),transparent)}.v-swatches .v-btn.bg-trasparent .v-icon{filter:none}
|
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": "
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "Color Swatch component for Vuetify3.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"node": ">=16.17.0",
|
|
58
58
|
"yarn": ">=1.22.10"
|
|
59
59
|
},
|
|
60
|
-
"packageManager": "yarn@3.2.
|
|
60
|
+
"packageManager": "yarn@3.2.3",
|
|
61
61
|
"sideEffects": false,
|
|
62
62
|
"scripts": {
|
|
63
63
|
"dev": "vite",
|
|
@@ -73,26 +73,26 @@
|
|
|
73
73
|
"prepare": "husky install"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"vue": "^3.2.
|
|
77
|
-
"vuetify": "^3.0.0-beta.
|
|
76
|
+
"vue": "^3.2.39",
|
|
77
|
+
"vuetify": "^3.0.0-beta.10"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@codemirror/lang-html": "^6.1.
|
|
81
|
-
"@types/node": "^18.7.
|
|
82
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
83
|
-
"@typescript-eslint/parser": "^5.
|
|
84
|
-
"@vitejs/plugin-vue": "^3.0
|
|
80
|
+
"@codemirror/lang-html": "^6.1.1",
|
|
81
|
+
"@types/node": "^18.7.18",
|
|
82
|
+
"@typescript-eslint/eslint-plugin": "^5.37.0",
|
|
83
|
+
"@typescript-eslint/parser": "^5.37.0",
|
|
84
|
+
"@vitejs/plugin-vue": "^3.1.0",
|
|
85
85
|
"@vue/tsconfig": "^0.1.3",
|
|
86
86
|
"codemirror": "^6.0.1",
|
|
87
|
-
"eslint": "^8.
|
|
87
|
+
"eslint": "^8.23.1",
|
|
88
88
|
"eslint-config-google": "^0.14.0",
|
|
89
89
|
"eslint-config-prettier": "^8.5.0",
|
|
90
90
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
91
|
-
"eslint-import-resolver-typescript": "^3.
|
|
91
|
+
"eslint-import-resolver-typescript": "^3.5.1",
|
|
92
92
|
"eslint-plugin-import": "^2.26.0",
|
|
93
93
|
"eslint-plugin-jsdoc": "^39.3.6",
|
|
94
|
-
"eslint-plugin-tsdoc": "^0.2.
|
|
95
|
-
"eslint-plugin-vue": "^9.
|
|
94
|
+
"eslint-plugin-tsdoc": "^0.2.17",
|
|
95
|
+
"eslint-plugin-vue": "^9.4.0",
|
|
96
96
|
"eslint-plugin-vuejs-accessibility": "^1.2.0",
|
|
97
97
|
"eslint-plugin-vuetify": "^1.1.0",
|
|
98
98
|
"eslint-plugin-yaml": "^0.5.0",
|
|
@@ -101,24 +101,24 @@
|
|
|
101
101
|
"postcss-html": "^1.5.0",
|
|
102
102
|
"prettier": "^2.7.1",
|
|
103
103
|
"rimraf": "^3.0.2",
|
|
104
|
-
"rollup-plugin-visualizer": "^5.
|
|
105
|
-
"sass": "1.54.
|
|
106
|
-
"stylelint": "^14.
|
|
104
|
+
"rollup-plugin-visualizer": "^5.8.1",
|
|
105
|
+
"sass": "1.54.9",
|
|
106
|
+
"stylelint": "^14.11.0",
|
|
107
107
|
"stylelint-config-prettier": "^9.0.3",
|
|
108
108
|
"stylelint-config-recommended-scss": "^7.0.0",
|
|
109
109
|
"stylelint-config-recommended-vue": "^1.4.0",
|
|
110
110
|
"stylelint-order": "^5.0.0",
|
|
111
111
|
"stylelint-prettier": "^2.0.0",
|
|
112
|
-
"typescript": "^4.
|
|
113
|
-
"vite": "^3.0
|
|
114
|
-
"vite-plugin-banner": "^0.
|
|
115
|
-
"vite-plugin-checker": "^0.
|
|
116
|
-
"vite-plugin-vuetify": "^1.0.0-alpha.
|
|
117
|
-
"vue": "^3.2.
|
|
118
|
-
"vue-codemirror6": "0.
|
|
119
|
-
"vue-eslint-parser": "^9.0
|
|
120
|
-
"vue-tsc": "^0.40.
|
|
121
|
-
"vuetify": "^3.0.0-beta.
|
|
112
|
+
"typescript": "^4.8.3",
|
|
113
|
+
"vite": "^3.1.0",
|
|
114
|
+
"vite-plugin-banner": "^0.5.0",
|
|
115
|
+
"vite-plugin-checker": "^0.5.1",
|
|
116
|
+
"vite-plugin-vuetify": "^1.0.0-alpha.17",
|
|
117
|
+
"vue": "^3.2.39",
|
|
118
|
+
"vue-codemirror6": "1.0.1",
|
|
119
|
+
"vue-eslint-parser": "^9.1.0",
|
|
120
|
+
"vue-tsc": "^0.40.13",
|
|
121
|
+
"vuetify": "^3.0.0-beta.10"
|
|
122
122
|
},
|
|
123
123
|
"husky": {
|
|
124
124
|
"hooks": {
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<v-sheet class="v-swatches">
|
|
3
|
-
<div v-for="(colors, rows) in swatches" :key="rows"
|
|
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
|
-
:elevation="elevation"
|
|
8
|
-
:width="size"
|
|
9
|
-
:height="size"
|
|
10
7
|
:color="color"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
:height="size"
|
|
10
|
+
:value="color"
|
|
11
|
+
:variant="variant"
|
|
12
|
+
:width="size"
|
|
11
13
|
:data-value="color"
|
|
14
|
+
:class="color === shades.transparent ? 'bg-trasparent' : ''"
|
|
12
15
|
min-width="auto"
|
|
13
16
|
@click="onSwatchClick($event)"
|
|
14
17
|
>
|
|
15
|
-
<v-icon
|
|
18
|
+
<v-icon
|
|
19
|
+
v-if="color === modelValue"
|
|
20
|
+
:size="iconSize"
|
|
21
|
+
:color="color !== shades.transparent ? color : undefined"
|
|
22
|
+
>
|
|
16
23
|
{{ icon }}
|
|
17
24
|
</v-icon>
|
|
18
25
|
</v-btn>
|
|
@@ -48,7 +55,7 @@ export default defineComponent({
|
|
|
48
55
|
swatches: {
|
|
49
56
|
type: Array as PropType<string[] | string[][]>,
|
|
50
57
|
default: () => [
|
|
51
|
-
[colors.shades.black, colors.shades.white],
|
|
58
|
+
[colors.shades.black, colors.shades.white, colors.shades.transparent],
|
|
52
59
|
[
|
|
53
60
|
colors.red.base,
|
|
54
61
|
colors.pink.base,
|
|
@@ -72,29 +79,52 @@ export default defineComponent({
|
|
|
72
79
|
[colors.brown.base, colors.blueGrey.base, colors.grey.base],
|
|
73
80
|
],
|
|
74
81
|
},
|
|
75
|
-
/**
|
|
76
|
-
elevation: { type: Number, default: 1 },
|
|
77
|
-
/** Swatch sized */
|
|
82
|
+
/** Swatch size */
|
|
78
83
|
size: { type: String, default: '2rem' },
|
|
79
|
-
/**
|
|
84
|
+
/** Selected icon */
|
|
80
85
|
icon: { type: String, default: 'mdi-checkbox-marked-circle' },
|
|
81
86
|
/** selected icon size */
|
|
82
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 },
|
|
83
111
|
},
|
|
84
112
|
/** Emits */
|
|
85
113
|
emits: ['update:modelValue'],
|
|
86
114
|
/**
|
|
87
115
|
* Setup
|
|
116
|
+
*
|
|
88
117
|
* @param props - Props
|
|
89
118
|
* @param context - Context
|
|
90
119
|
*/
|
|
91
120
|
setup(props, context: SetupContext) {
|
|
92
121
|
/** Check icon visibility */
|
|
93
122
|
const checkedVisibilty: Ref<boolean> = ref(false);
|
|
123
|
+
|
|
94
124
|
/**
|
|
95
|
-
*
|
|
125
|
+
* Swatch button clicked handler
|
|
96
126
|
*
|
|
97
|
-
* @param e -
|
|
127
|
+
* @param e - Event
|
|
98
128
|
*/
|
|
99
129
|
const onSwatchClick = (e: Event) => {
|
|
100
130
|
const value = (e.target as HTMLButtonElement).dataset.value;
|
|
@@ -103,15 +133,19 @@ export default defineComponent({
|
|
|
103
133
|
}
|
|
104
134
|
context.emit('update:modelValue', value);
|
|
105
135
|
};
|
|
136
|
+
|
|
106
137
|
return {
|
|
107
138
|
checkedVisibilty,
|
|
108
139
|
onSwatchClick,
|
|
140
|
+
shades: colors.shades,
|
|
109
141
|
};
|
|
110
142
|
},
|
|
111
143
|
});
|
|
112
144
|
</script>
|
|
113
145
|
|
|
114
146
|
<style lang="scss">
|
|
147
|
+
@import 'node_modules/vuetify/lib/styles/settings';
|
|
148
|
+
|
|
115
149
|
.v-swatches {
|
|
116
150
|
.v-btn {
|
|
117
151
|
padding: 0 !important;
|
|
@@ -120,6 +154,20 @@ export default defineComponent({
|
|
|
120
154
|
.v-icon {
|
|
121
155
|
filter: invert(100%) grayscale(100%) contrast(100);
|
|
122
156
|
}
|
|
157
|
+
|
|
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
|
+
.v-icon {
|
|
168
|
+
filter: none;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
123
171
|
}
|
|
124
172
|
}
|
|
125
173
|
</style>
|