vuetify-swatches 0.3.3 → 1.0.1

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
@@ -5,16 +5,17 @@
5
5
  [![Open in unpkg](https://img.shields.io/badge/Open%20in-unpkg-blue)](https://uiwjs.github.io/npm-unpkg/#/pkg/vuetify-swatches/file/README.md)
6
6
  [![npm version](https://img.shields.io/npm/v/vuetify-swatches.svg)](https://www.npmjs.com/package/vuetify-swatches)
7
7
  [![Open in Gitpod](https://shields.io/badge/Open%20in-Gitpod-green?logo=Gitpod)](https://gitpod.io/#https://github.com/logue/vuetify-swatches)
8
+ [![Twitter Follow](https://img.shields.io/twitter/follow/logue256?style=plastic)](https://twitter.com/logue256)
8
9
 
9
10
  ![demo](https://user-images.githubusercontent.com/480173/156681882-d3d5e868-ba9a-4a34-9e75-08272d39da64.gif)
10
11
 
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
12
  This project is a remake of [saintplay's vue-swatches](https://saintplay.github.io/vue-swatches/) with [Vuetify](https://vuetifyjs.com/).
14
13
 
15
14
  Unlike the original version, it provides a UI based on Vuetify, such as ripple effects and dark mode.
16
15
 
17
- This library is positioned as a complement to Vuetify and provides a minimal UI. Use the[Menu Component](https://vuetifyjs.com/components/menus/) if you want to display a pop-up menu, and the [Card component](https://vuetifyjs.com/components/cards/) if you want to display a palette.
16
+ This library is positioned as a complement to Vuetify and provides a minimal UI. Use the [Menu Component](https://vuetifyjs.com/components/menus/) if you want to display a pop-up menu, and the [Card component](https://vuetifyjs.com/components/cards/) if you want to display a palette.
17
+
18
+ For Vuetify3, please use the [next branch](https://github.com/logue/vuetify-swatches/tree/next).
18
19
 
19
20
  ## Usage
20
21
 
@@ -40,7 +41,7 @@ export default Vue.extend({
40
41
  </script>
41
42
 
42
43
  <style>
43
- @import 'vuetify-swatches/dist/style.css';
44
+ @import 'vuetify-swatches/style.css';
44
45
  </style>
45
46
  ```
46
47
 
@@ -119,18 +120,25 @@ export default Vue.extend({
119
120
  </script>
120
121
 
121
122
  <style>
122
- @import 'vuetify-swatches/dist/style.css';
123
+ @import 'vuetify-swatches/style.css';
123
124
  </style>
124
125
  ```
125
126
 
126
127
  ### Options
127
128
 
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 |
129
+ | Variables | Type | Default | Info |
130
+ | --------- | -------------- | -------------------------- | ---------------------------------------------------------------------------------------- |
131
+ | size | string | 2rem | Swatch Button size |
132
+ | icon | string | mdi-checkbox-marked-circle | checked icon |
133
+ | icon-size | string | 1rem | checked icon size |
134
+ | depressed | boolean | false | Removes the button box shadow. |
135
+ | disabled | boolean | false | Removes the ability to click or target the component. |
136
+ | elevation | number\|string | undefined | Designates an elevation applied to the component between 0 and 24. |
137
+ | outlined | boolean | false | Makes the background transparent and applies a thin border. |
138
+ | plain | boolean | false | Removes the default background change applied when hovering over the button. |
139
+ | raised | boolean | true | Raised buttons have a box shadow that increases when clicked. This is the default style. |
140
+ | rounded | boolean | false | Applies a large border radius on the button. |
141
+ | tile | boolean | false | Removes the component’s border-radius. |
134
142
 
135
143
  ## LICENSE
136
144
 
package/dist/index.es.js CHANGED
@@ -1,113 +1,210 @@
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.1
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, ref } from 'vue-demi';
13
+ import { VSheet, VBtn, VIcon } from 'vuetify/lib/components';
14
+ import colors from 'vuetify/lib/util/colors';
15
+
16
+ const _sfc_main = defineComponent({
15
17
  name: "VSwatches",
18
+ components: {
19
+ VSheet,
20
+ VBtn,
21
+ VIcon
22
+ },
16
23
  model: {
17
24
  prop: "modelValue",
18
25
  event: "update:modelValue"
19
26
  },
20
27
  props: {
21
- modelValue: { type: String, default: e.shades.white },
28
+ modelValue: { type: String, default: "#ffffff" },
22
29
  swatches: {
23
30
  type: Array,
24
31
  default: () => [
25
- [e.shades.black, e.shades.white],
32
+ [colors.shades.black, colors.shades.white, colors.shades.transparent],
26
33
  [
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
34
+ colors.red.base,
35
+ colors.pink.base,
36
+ colors.purple.base,
37
+ colors.deepPurple.base,
38
+ colors.indigo.base,
39
+ colors.blue.base,
40
+ colors.lightBlue.base,
41
+ colors.cyan.base
35
42
  ],
36
43
  [
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
44
+ colors.teal.base,
45
+ colors.green.base,
46
+ colors.lightGreen.base,
47
+ colors.lime.base,
48
+ colors.yellow.base,
49
+ colors.amber.base,
50
+ colors.orange.base,
51
+ colors.deepOrange.base
45
52
  ],
46
- [e.brown.base, e.blueGrey.base, e.grey.base]
53
+ [colors.brown.base, colors.blueGrey.base, colors.grey.base]
47
54
  ]
48
55
  },
49
- elevation: { type: Number, default: 1 },
50
56
  size: { type: String, default: "2rem" },
51
57
  icon: { type: String, default: "mdi-checkbox-marked-circle" },
52
- iconSize: { type: String, default: "1rem" }
58
+ iconSize: { type: String, default: "1rem" },
59
+ depressed: { type: Boolean, default: false },
60
+ disabled: { type: Boolean, default: false },
61
+ elevation: { type: [Number, String], default: void 0 },
62
+ outlined: { type: Boolean, default: false },
63
+ plain: { type: Boolean, default: false },
64
+ raised: { type: Boolean, default: true },
65
+ rounded: { type: Boolean, default: false },
66
+ tile: { type: Boolean, default: false }
53
67
  },
54
68
  emits: ["update:modelValue"],
55
- setup(t, a) {
56
- 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);
69
+ setup(props, context) {
70
+ const checkedVisibilty = ref(false);
71
+ const onSwatchClick = (e) => {
72
+ const value = e.target.value;
73
+ if (!value || props.modelValue === value) {
74
+ return;
61
75
  }
76
+ context.emit("update:modelValue", value);
77
+ };
78
+ return {
79
+ checkedVisibilty,
80
+ onSwatchClick
62
81
  };
63
82
  }
64
83
  });
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
- });
84
+
85
+ const VSwatches_vue_vue_type_style_index_0_lang = '';
86
+
87
+ function normalizeComponent (
88
+ scriptExports,
89
+ render,
90
+ staticRenderFns,
91
+ functionalTemplate,
92
+ injectStyles,
93
+ scopeId,
94
+ moduleIdentifier, /* server only */
95
+ shadowMode /* vue-cli only */
96
+ ) {
97
+ // Vue.extend constructor export interop
98
+ var options = typeof scriptExports === 'function'
99
+ ? scriptExports.options
100
+ : scriptExports;
101
+
102
+ // render functions
103
+ if (render) {
104
+ options.render = render;
105
+ options.staticRenderFns = staticRenderFns;
106
+ options._compiled = true;
107
+ }
108
+
109
+ // functional template
110
+ if (functionalTemplate) {
111
+ options.functional = true;
112
+ }
113
+
114
+ // scopedId
115
+ if (scopeId) {
116
+ options._scopeId = 'data-v-' + scopeId;
117
+ }
118
+
119
+ var hook;
120
+ if (moduleIdentifier) { // server build
121
+ hook = function (context) {
122
+ // 2.3 injection
123
+ context =
124
+ context || // cached call
125
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
126
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
127
+ // 2.2 with runInNewContext: true
128
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
129
+ context = __VUE_SSR_CONTEXT__;
130
+ }
131
+ // inject component styles
132
+ if (injectStyles) {
133
+ injectStyles.call(this, context);
134
+ }
135
+ // register component module identifier for async chunk inference
136
+ if (context && context._registeredComponents) {
137
+ context._registeredComponents.add(moduleIdentifier);
138
+ }
139
+ };
140
+ // used by ssr in case component is cached and beforeCreate
141
+ // never gets called
142
+ options._ssrRegister = hook;
143
+ } else if (injectStyles) {
144
+ hook = shadowMode
145
+ ? function () {
146
+ injectStyles.call(
147
+ this,
148
+ (options.functional ? this.parent : this).$root.$options.shadowRoot
149
+ );
150
+ }
151
+ : injectStyles;
152
+ }
153
+
154
+ if (hook) {
155
+ if (options.functional) {
156
+ // for template-only hot-reload because in that case the render fn doesn't
157
+ // go through the normalizer
158
+ options._injectStyles = hook;
159
+ // register for functional component in vue file
160
+ var originalRender = options.render;
161
+ options.render = function renderWithStyleInjection (h, context) {
162
+ hook.call(context);
163
+ return originalRender(h, context)
164
+ };
165
+ } else {
166
+ // inject component registration as beforeCreate hook
167
+ var existing = options.beforeCreate;
168
+ options.beforeCreate = existing
169
+ ? [].concat(existing, hook)
170
+ : [hook];
171
+ }
172
+ }
173
+
174
+ return {
175
+ exports: scriptExports,
176
+ options: options
177
+ }
107
178
  }
108
- const h = /* @__PURE__ */ $(B, [["render", N]]), A = (t) => t.component("VSwatches", h);
109
- typeof window < "u" && window.Vue && window.Vue.use(h);
110
- export {
111
- h as default,
112
- A as install
179
+
180
+ var _sfc_render = function render() {
181
+ var _vm = this, _c = _vm._self._c; _vm._self._setupProxy;
182
+ return _c("v-sheet", { staticClass: "v-swatches" }, _vm._l(_vm.swatches, function(colors, rows) {
183
+ return _c("div", { key: rows }, _vm._l(colors, function(color) {
184
+ return _c("v-btn", { key: color, attrs: { "color": color, "depressed": _vm.depressed, "disabled": _vm.disabled, "elevation": _vm.elevation, "height": _vm.size, "outlined": _vm.outlined, "plain": _vm.plain, "raised": _vm.raised, "tile": _vm.tile, "value": color, "width": _vm.size, "min-width": "auto" }, on: { "click": function($event) {
185
+ return _vm.onSwatchClick($event);
186
+ } } }, [color === _vm.modelValue ? _c("v-icon", { attrs: { "size": _vm.iconSize, "color": color !== "transparent" ? color : void 0 } }, [_vm._v(" " + _vm._s(_vm.icon) + " ")]) : _vm._e()], 1);
187
+ }), 1);
188
+ }), 0);
113
189
  };
190
+ var _sfc_staticRenderFns = [];
191
+ _sfc_render._withStripped = true;
192
+ var __component__ = /* @__PURE__ */ normalizeComponent(
193
+ _sfc_main,
194
+ _sfc_render,
195
+ _sfc_staticRenderFns,
196
+ false,
197
+ null,
198
+ null,
199
+ null,
200
+ null
201
+ );
202
+ __component__.options.__file = "D:/Documents/Projects/vuetify-swatch/src/components/VSwatches.vue";
203
+ const VSwatches = __component__.exports;
204
+
205
+ const installVSwatches = (app) => app.component("VSwatches", VSwatches);
206
+ if (typeof window !== "undefined" && window.Vue) {
207
+ window.Vue.use(VSwatches);
208
+ }
209
+
210
+ export { VSwatches as default, installVSwatches as install };
@@ -0,0 +1,220 @@
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.1
9
+ * @see {@link https://github.com/logue/vuetify-swatches}
10
+ */
11
+
12
+ var VSwatches = (function (exports, vueDemi, components, colors) {
13
+ 'use strict';
14
+
15
+ const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
16
+
17
+ const colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
18
+
19
+ const _sfc_main = vueDemi.defineComponent({
20
+ name: "VSwatches",
21
+ components: {
22
+ VSheet: components.VSheet,
23
+ VBtn: components.VBtn,
24
+ VIcon: components.VIcon
25
+ },
26
+ model: {
27
+ prop: "modelValue",
28
+ event: "update:modelValue"
29
+ },
30
+ props: {
31
+ modelValue: { type: String, default: "#ffffff" },
32
+ swatches: {
33
+ type: Array,
34
+ default: () => [
35
+ [colors__default.default.shades.black, colors__default.default.shades.white, colors__default.default.shades.transparent],
36
+ [
37
+ colors__default.default.red.base,
38
+ colors__default.default.pink.base,
39
+ colors__default.default.purple.base,
40
+ colors__default.default.deepPurple.base,
41
+ colors__default.default.indigo.base,
42
+ colors__default.default.blue.base,
43
+ colors__default.default.lightBlue.base,
44
+ colors__default.default.cyan.base
45
+ ],
46
+ [
47
+ colors__default.default.teal.base,
48
+ colors__default.default.green.base,
49
+ colors__default.default.lightGreen.base,
50
+ colors__default.default.lime.base,
51
+ colors__default.default.yellow.base,
52
+ colors__default.default.amber.base,
53
+ colors__default.default.orange.base,
54
+ colors__default.default.deepOrange.base
55
+ ],
56
+ [colors__default.default.brown.base, colors__default.default.blueGrey.base, colors__default.default.grey.base]
57
+ ]
58
+ },
59
+ size: { type: String, default: "2rem" },
60
+ icon: { type: String, default: "mdi-checkbox-marked-circle" },
61
+ iconSize: { type: String, default: "1rem" },
62
+ depressed: { type: Boolean, default: false },
63
+ disabled: { type: Boolean, default: false },
64
+ elevation: { type: [Number, String], default: void 0 },
65
+ outlined: { type: Boolean, default: false },
66
+ plain: { type: Boolean, default: false },
67
+ raised: { type: Boolean, default: true },
68
+ rounded: { type: Boolean, default: false },
69
+ tile: { type: Boolean, default: false }
70
+ },
71
+ emits: ["update:modelValue"],
72
+ setup(props, context) {
73
+ const checkedVisibilty = vueDemi.ref(false);
74
+ const onSwatchClick = (e) => {
75
+ const value = e.target.value;
76
+ if (!value || props.modelValue === value) {
77
+ return;
78
+ }
79
+ context.emit("update:modelValue", value);
80
+ };
81
+ return {
82
+ checkedVisibilty,
83
+ onSwatchClick
84
+ };
85
+ }
86
+ });
87
+
88
+ const VSwatches_vue_vue_type_style_index_0_lang = '';
89
+
90
+ function normalizeComponent (
91
+ scriptExports,
92
+ render,
93
+ staticRenderFns,
94
+ functionalTemplate,
95
+ injectStyles,
96
+ scopeId,
97
+ moduleIdentifier, /* server only */
98
+ shadowMode /* vue-cli only */
99
+ ) {
100
+ // Vue.extend constructor export interop
101
+ var options = typeof scriptExports === 'function'
102
+ ? scriptExports.options
103
+ : scriptExports;
104
+
105
+ // render functions
106
+ if (render) {
107
+ options.render = render;
108
+ options.staticRenderFns = staticRenderFns;
109
+ options._compiled = true;
110
+ }
111
+
112
+ // functional template
113
+ if (functionalTemplate) {
114
+ options.functional = true;
115
+ }
116
+
117
+ // scopedId
118
+ if (scopeId) {
119
+ options._scopeId = 'data-v-' + scopeId;
120
+ }
121
+
122
+ var hook;
123
+ if (moduleIdentifier) { // server build
124
+ hook = function (context) {
125
+ // 2.3 injection
126
+ context =
127
+ context || // cached call
128
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
129
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
130
+ // 2.2 with runInNewContext: true
131
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
132
+ context = __VUE_SSR_CONTEXT__;
133
+ }
134
+ // inject component styles
135
+ if (injectStyles) {
136
+ injectStyles.call(this, context);
137
+ }
138
+ // register component module identifier for async chunk inference
139
+ if (context && context._registeredComponents) {
140
+ context._registeredComponents.add(moduleIdentifier);
141
+ }
142
+ };
143
+ // used by ssr in case component is cached and beforeCreate
144
+ // never gets called
145
+ options._ssrRegister = hook;
146
+ } else if (injectStyles) {
147
+ hook = shadowMode
148
+ ? function () {
149
+ injectStyles.call(
150
+ this,
151
+ (options.functional ? this.parent : this).$root.$options.shadowRoot
152
+ );
153
+ }
154
+ : injectStyles;
155
+ }
156
+
157
+ if (hook) {
158
+ if (options.functional) {
159
+ // for template-only hot-reload because in that case the render fn doesn't
160
+ // go through the normalizer
161
+ options._injectStyles = hook;
162
+ // register for functional component in vue file
163
+ var originalRender = options.render;
164
+ options.render = function renderWithStyleInjection (h, context) {
165
+ hook.call(context);
166
+ return originalRender(h, context)
167
+ };
168
+ } else {
169
+ // inject component registration as beforeCreate hook
170
+ var existing = options.beforeCreate;
171
+ options.beforeCreate = existing
172
+ ? [].concat(existing, hook)
173
+ : [hook];
174
+ }
175
+ }
176
+
177
+ return {
178
+ exports: scriptExports,
179
+ options: options
180
+ }
181
+ }
182
+
183
+ var _sfc_render = function render() {
184
+ var _vm = this, _c = _vm._self._c; _vm._self._setupProxy;
185
+ return _c("v-sheet", { staticClass: "v-swatches" }, _vm._l(_vm.swatches, function(colors, rows) {
186
+ return _c("div", { key: rows }, _vm._l(colors, function(color) {
187
+ return _c("v-btn", { key: color, attrs: { "color": color, "depressed": _vm.depressed, "disabled": _vm.disabled, "elevation": _vm.elevation, "height": _vm.size, "outlined": _vm.outlined, "plain": _vm.plain, "raised": _vm.raised, "tile": _vm.tile, "value": color, "width": _vm.size, "min-width": "auto" }, on: { "click": function($event) {
188
+ return _vm.onSwatchClick($event);
189
+ } } }, [color === _vm.modelValue ? _c("v-icon", { attrs: { "size": _vm.iconSize, "color": color !== "transparent" ? color : void 0 } }, [_vm._v(" " + _vm._s(_vm.icon) + " ")]) : _vm._e()], 1);
190
+ }), 1);
191
+ }), 0);
192
+ };
193
+ var _sfc_staticRenderFns = [];
194
+ _sfc_render._withStripped = true;
195
+ var __component__ = /* @__PURE__ */ normalizeComponent(
196
+ _sfc_main,
197
+ _sfc_render,
198
+ _sfc_staticRenderFns,
199
+ false,
200
+ null,
201
+ null,
202
+ null,
203
+ null
204
+ );
205
+ __component__.options.__file = "D:/Documents/Projects/vuetify-swatch/src/components/VSwatches.vue";
206
+ const VSwatches = __component__.exports;
207
+
208
+ const installVSwatches = (app) => app.component("VSwatches", VSwatches);
209
+ if (typeof window !== "undefined" && window.Vue) {
210
+ window.Vue.use(VSwatches);
211
+ }
212
+
213
+ exports.default = VSwatches;
214
+ exports.install = installVSwatches;
215
+
216
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
217
+
218
+ return exports;
219
+
220
+ })({}, VueDemi, Vuetify, colors);