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/dist/index.umd.js CHANGED
@@ -1,12 +1,221 @@
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
- (function(l,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vuetify/lib/util/colors.mjs")):typeof define=="function"&&define.amd?define(["exports","vue","vuetify/lib/util/colors.mjs"],e):(l=typeof globalThis<"u"?globalThis:l||self,e(l.VSwatches={},l.Vue,l.colors))})(this,function(l,e,u){"use strict";const t=(a=>a&&typeof a=="object"&&"default"in a?a:{default:a})(u),f=e.defineComponent({name:"VSwatches",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:t.default.shades.white},swatches:{type:Array,default:()=>[[t.default.shades.black,t.default.shades.white],[t.default.red.base,t.default.pink.base,t.default.purple.base,t.default.deepPurple.base,t.default.indigo.base,t.default.blue.base,t.default.lightBlue.base,t.default.cyan.base],[t.default.teal.base,t.default.green.base,t.default.lightGreen.base,t.default.lime.base,t.default.yellow.base,t.default.amber.base,t.default.orange.base,t.default.deepOrange.base],[t.default.brown.base,t.default.blueGrey.base,t.default.grey.base]]},elevation:{type:Number,default:1},size:{type:String,default:"2rem"},icon:{type:String,default:"mdi-checkbox-marked-circle"},iconSize:{type:String,default:"1rem"}},emits:["update:modelValue"],setup(a,n){return{checkedVisibilty:e.ref(!1),onSwatchClick:i=>{const d=i.target.dataset.value;!d||a.modelValue===d||n.emit("update:modelValue",d)}}}}),S="",p=(a,n)=>{const s=a.__vccOpts||a;for(const[c,i]of n)s[c]=i;return s};function m(a,n,s,c,i,d){const b=e.resolveComponent("v-icon"),y=e.resolveComponent("v-btn"),w=e.resolveComponent("v-sheet");return e.openBlock(),e.createBlock(w,{class:"v-swatches"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.swatches,(k,_)=>(e.openBlock(),e.createElementBlock("div",{key:_,class:"d-flex"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k,o=>(e.openBlock(),e.createBlock(y,{key:o,elevation:a.elevation,width:a.size,height:a.size,color:o,"data-value":o,"min-width":"auto",onClick:n[0]||(n[0]=g=>a.onSwatchClick(g))},{default:e.withCtx(()=>[o===a.modelValue?(e.openBlock(),e.createBlock(b,{key:0,size:a.iconSize,color:o},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.icon),1)]),_:2},1032,["size","color"])):e.createCommentVNode("",!0)]),_:2},1032,["elevation","width","height","color","data-value"]))),128))]))),128))]),_:1})}const r=p(f,[["render",m]]),h=a=>a.component("VSwatches",r);typeof window<"u"&&window.Vue&&window.Vue.use(r),l.default=r,l.install=h,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
12
+ (function (global, factory) {
13
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue-demi'), require('vuetify/lib/components'), require('vuetify/lib/util/colors')) :
14
+ typeof define === 'function' && define.amd ? define(['exports', 'vue-demi', 'vuetify/lib/components', 'vuetify/lib/util/colors'], factory) :
15
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VSwatches = {}, global.VueDemi, global.Vuetify, global.colors));
16
+ })(this, (function (exports, vueDemi, components, colors) { 'use strict';
17
+
18
+ const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
19
+
20
+ const colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
21
+
22
+ const _sfc_main = vueDemi.defineComponent({
23
+ name: "VSwatches",
24
+ components: {
25
+ VSheet: components.VSheet,
26
+ VBtn: components.VBtn,
27
+ VIcon: components.VIcon
28
+ },
29
+ model: {
30
+ prop: "modelValue",
31
+ event: "update:modelValue"
32
+ },
33
+ props: {
34
+ modelValue: { type: String, default: "#ffffff" },
35
+ swatches: {
36
+ type: Array,
37
+ default: () => [
38
+ [colors__default.default.shades.black, colors__default.default.shades.white, colors__default.default.shades.transparent],
39
+ [
40
+ colors__default.default.red.base,
41
+ colors__default.default.pink.base,
42
+ colors__default.default.purple.base,
43
+ colors__default.default.deepPurple.base,
44
+ colors__default.default.indigo.base,
45
+ colors__default.default.blue.base,
46
+ colors__default.default.lightBlue.base,
47
+ colors__default.default.cyan.base
48
+ ],
49
+ [
50
+ colors__default.default.teal.base,
51
+ colors__default.default.green.base,
52
+ colors__default.default.lightGreen.base,
53
+ colors__default.default.lime.base,
54
+ colors__default.default.yellow.base,
55
+ colors__default.default.amber.base,
56
+ colors__default.default.orange.base,
57
+ colors__default.default.deepOrange.base
58
+ ],
59
+ [colors__default.default.brown.base, colors__default.default.blueGrey.base, colors__default.default.grey.base]
60
+ ]
61
+ },
62
+ size: { type: String, default: "2rem" },
63
+ icon: { type: String, default: "mdi-checkbox-marked-circle" },
64
+ iconSize: { type: String, default: "1rem" },
65
+ depressed: { type: Boolean, default: false },
66
+ disabled: { type: Boolean, default: false },
67
+ elevation: { type: [Number, String], default: void 0 },
68
+ outlined: { type: Boolean, default: false },
69
+ plain: { type: Boolean, default: false },
70
+ raised: { type: Boolean, default: true },
71
+ rounded: { type: Boolean, default: false },
72
+ tile: { type: Boolean, default: false }
73
+ },
74
+ emits: ["update:modelValue"],
75
+ setup(props, context) {
76
+ const checkedVisibilty = vueDemi.ref(false);
77
+ const onSwatchClick = (e) => {
78
+ const value = e.target.value;
79
+ if (!value || props.modelValue === value) {
80
+ return;
81
+ }
82
+ context.emit("update:modelValue", value);
83
+ };
84
+ return {
85
+ checkedVisibilty,
86
+ onSwatchClick
87
+ };
88
+ }
89
+ });
90
+
91
+ const VSwatches_vue_vue_type_style_index_0_lang = '';
92
+
93
+ function normalizeComponent (
94
+ scriptExports,
95
+ render,
96
+ staticRenderFns,
97
+ functionalTemplate,
98
+ injectStyles,
99
+ scopeId,
100
+ moduleIdentifier, /* server only */
101
+ shadowMode /* vue-cli only */
102
+ ) {
103
+ // Vue.extend constructor export interop
104
+ var options = typeof scriptExports === 'function'
105
+ ? scriptExports.options
106
+ : scriptExports;
107
+
108
+ // render functions
109
+ if (render) {
110
+ options.render = render;
111
+ options.staticRenderFns = staticRenderFns;
112
+ options._compiled = true;
113
+ }
114
+
115
+ // functional template
116
+ if (functionalTemplate) {
117
+ options.functional = true;
118
+ }
119
+
120
+ // scopedId
121
+ if (scopeId) {
122
+ options._scopeId = 'data-v-' + scopeId;
123
+ }
124
+
125
+ var hook;
126
+ if (moduleIdentifier) { // server build
127
+ hook = function (context) {
128
+ // 2.3 injection
129
+ context =
130
+ context || // cached call
131
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
132
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
133
+ // 2.2 with runInNewContext: true
134
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
135
+ context = __VUE_SSR_CONTEXT__;
136
+ }
137
+ // inject component styles
138
+ if (injectStyles) {
139
+ injectStyles.call(this, context);
140
+ }
141
+ // register component module identifier for async chunk inference
142
+ if (context && context._registeredComponents) {
143
+ context._registeredComponents.add(moduleIdentifier);
144
+ }
145
+ };
146
+ // used by ssr in case component is cached and beforeCreate
147
+ // never gets called
148
+ options._ssrRegister = hook;
149
+ } else if (injectStyles) {
150
+ hook = shadowMode
151
+ ? function () {
152
+ injectStyles.call(
153
+ this,
154
+ (options.functional ? this.parent : this).$root.$options.shadowRoot
155
+ );
156
+ }
157
+ : injectStyles;
158
+ }
159
+
160
+ if (hook) {
161
+ if (options.functional) {
162
+ // for template-only hot-reload because in that case the render fn doesn't
163
+ // go through the normalizer
164
+ options._injectStyles = hook;
165
+ // register for functional component in vue file
166
+ var originalRender = options.render;
167
+ options.render = function renderWithStyleInjection (h, context) {
168
+ hook.call(context);
169
+ return originalRender(h, context)
170
+ };
171
+ } else {
172
+ // inject component registration as beforeCreate hook
173
+ var existing = options.beforeCreate;
174
+ options.beforeCreate = existing
175
+ ? [].concat(existing, hook)
176
+ : [hook];
177
+ }
178
+ }
179
+
180
+ return {
181
+ exports: scriptExports,
182
+ options: options
183
+ }
184
+ }
185
+
186
+ var _sfc_render = function render() {
187
+ var _vm = this, _c = _vm._self._c; _vm._self._setupProxy;
188
+ return _c("v-sheet", { staticClass: "v-swatches" }, _vm._l(_vm.swatches, function(colors, rows) {
189
+ return _c("div", { key: rows }, _vm._l(colors, function(color) {
190
+ 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) {
191
+ return _vm.onSwatchClick($event);
192
+ } } }, [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);
193
+ }), 1);
194
+ }), 0);
195
+ };
196
+ var _sfc_staticRenderFns = [];
197
+ _sfc_render._withStripped = true;
198
+ var __component__ = /* @__PURE__ */ normalizeComponent(
199
+ _sfc_main,
200
+ _sfc_render,
201
+ _sfc_staticRenderFns,
202
+ false,
203
+ null,
204
+ null,
205
+ null,
206
+ null
207
+ );
208
+ __component__.options.__file = "D:/Documents/Projects/vuetify-swatch/src/components/VSwatches.vue";
209
+ const VSwatches = __component__.exports;
210
+
211
+ const installVSwatches = (app) => app.component("VSwatches", VSwatches);
212
+ if (typeof window !== "undefined" && window.Vue) {
213
+ window.Vue.use(VSwatches);
214
+ }
215
+
216
+ exports.default = VSwatches;
217
+ exports.install = installVSwatches;
218
+
219
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
220
+
221
+ }));