vuetify-swatches 2.1.0 → 2.1.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.
@@ -14,7 +14,7 @@ interface Props {
14
14
  tooltip: boolean;
15
15
  tooltipLocation: Anchor;
16
16
  }
17
- declare const _default: import('vue').DefineComponent<Partial<Props>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
17
+ declare const __VLS_export: import('vue').DefineComponent<Partial<Props>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
18
18
  click: () => any;
19
19
  }, string, import('vue').PublicProps, Readonly<Partial<Props>> & Readonly<{
20
20
  onClick?: (() => any) | undefined;
@@ -32,4 +32,5 @@ declare const _default: import('vue').DefineComponent<Partial<Props>, {}, {}, {}
32
32
  tooltip: boolean;
33
33
  tooltipLocation: Anchor;
34
34
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
35
+ declare const _default: typeof __VLS_export;
35
36
  export default _default;
@@ -1,215 +1,71 @@
1
- import { PropType } from 'vue';
2
1
  import { Variant } from 'vuetify/lib/composables/variant.d.ts';
3
2
  import { Anchor } from 'vuetify/lib/util/index.d.ts';
4
- declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
3
+ /** Swatches prop type */
4
+ type SwatchesProp = (string | undefined)[] | (string | undefined)[][] | Record<string, (string | undefined)[]> | readonly (string | undefined)[] | readonly (readonly (string | undefined)[])[];
5
+ /** Props */
6
+ type __VLS_Props = {
5
7
  /** Model value */
6
- modelValue: {
7
- type: StringConstructor;
8
- default: string;
9
- };
8
+ modelValue?: string;
10
9
  /** Swatch colors */
11
- swatches: {
12
- type: PropType<(string | undefined)[] | (string | undefined)[][] | Record<string, (string | undefined)[]> | readonly (string | undefined)[] | readonly (readonly (string | undefined)[])[]>;
13
- default: () => never[];
14
- };
10
+ swatches?: SwatchesProp;
15
11
  /** Swatch size */
16
- size: {
17
- type: StringConstructor;
18
- default: string;
19
- };
12
+ size?: string;
20
13
  /**
21
14
  * Selected icon
22
- * @see {@link https://vuetifyjs.com/en/components/icons/#usage
15
+ * @see {@link https://vuetifyjs.com/en/components/icons/#usage}
23
16
  */
24
- icon: {
25
- type: StringConstructor;
26
- default: string;
27
- };
28
- /** selected icon size */
29
- iconSize: {
30
- type: StringConstructor;
31
- default: string;
32
- };
17
+ icon?: string;
18
+ /** Selected icon size */
19
+ iconSize?: string;
33
20
  /** Display swatches in a single row */
34
- inline: {
35
- type: BooleanConstructor;
36
- default: boolean;
37
- };
21
+ inline?: boolean;
38
22
  /**
39
- * The variant prop gives you easy access to several different button styles..
40
- *
23
+ * The variant prop gives you easy access to several different button styles.
41
24
  * @see {@link https://vuetifyjs.com/en/components/buttons/#variant}
42
25
  */
43
- variant: {
44
- type: PropType<Variant>;
45
- default: undefined;
46
- };
26
+ variant?: Variant;
47
27
  /**
48
28
  * Removes the ability to click or target the component.
49
- *
50
29
  * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-disabled}
51
30
  */
52
- disabled: {
53
- type: BooleanConstructor;
54
- default: boolean;
55
- };
31
+ disabled?: boolean;
56
32
  /**
57
33
  * Applies a large border radius on the button.
58
- *
59
34
  * @see {@link https://vuetifyjs.com/en/components/buttons/#rounded}
60
35
  */
61
- rounded: {
62
- type: (BooleanConstructor | StringConstructor | NumberConstructor)[];
63
- default: undefined;
64
- };
36
+ rounded?: string | number | boolean;
65
37
  /**
66
38
  * Applies border styles to component.
67
- *
68
39
  * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-border}
69
40
  */
70
- border: {
71
- type: (BooleanConstructor | StringConstructor | NumberConstructor)[];
72
- default: boolean;
73
- };
41
+ border?: string | number | boolean;
74
42
  /**
75
43
  * Designates an elevation applied to the component between 0 and 24.
76
- *
77
44
  * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-elevation}
78
45
  */
79
- elevation: {
80
- type: (StringConstructor | NumberConstructor)[];
81
- default: undefined;
82
- };
46
+ elevation?: string | number;
83
47
  /** Swap cols and rows */
84
- transpose: {
85
- type: BooleanConstructor;
86
- default: boolean;
87
- };
48
+ transpose?: boolean;
88
49
  /**
89
50
  * Tooltip
90
51
  * @see {@link https://vuetifyjs.com/en/components/tooltips/}
91
52
  */
92
- tooltip: {
93
- type: BooleanConstructor;
94
- default: boolean;
95
- };
53
+ tooltip?: boolean;
96
54
  /**
97
55
  * Tooltip location
98
56
  * @see {@link https://vuetifyjs.com/en/components/tooltips/#props-location}
99
57
  */
100
- tooltipLocation: {
101
- type: PropType<Anchor>;
102
- default: undefined;
103
- };
104
- }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
105
- "update:modelValue": (_value: string) => void;
106
- }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
107
- /** Model value */
108
- modelValue: {
109
- type: StringConstructor;
110
- default: string;
111
- };
112
- /** Swatch colors */
113
- swatches: {
114
- type: PropType<(string | undefined)[] | (string | undefined)[][] | Record<string, (string | undefined)[]> | readonly (string | undefined)[] | readonly (readonly (string | undefined)[])[]>;
115
- default: () => never[];
116
- };
117
- /** Swatch size */
118
- size: {
119
- type: StringConstructor;
120
- default: string;
121
- };
122
- /**
123
- * Selected icon
124
- * @see {@link https://vuetifyjs.com/en/components/icons/#usage
125
- */
126
- icon: {
127
- type: StringConstructor;
128
- default: string;
129
- };
130
- /** selected icon size */
131
- iconSize: {
132
- type: StringConstructor;
133
- default: string;
134
- };
135
- /** Display swatches in a single row */
136
- inline: {
137
- type: BooleanConstructor;
138
- default: boolean;
139
- };
140
- /**
141
- * The variant prop gives you easy access to several different button styles..
142
- *
143
- * @see {@link https://vuetifyjs.com/en/components/buttons/#variant}
144
- */
145
- variant: {
146
- type: PropType<Variant>;
147
- default: undefined;
148
- };
149
- /**
150
- * Removes the ability to click or target the component.
151
- *
152
- * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-disabled}
153
- */
154
- disabled: {
155
- type: BooleanConstructor;
156
- default: boolean;
157
- };
158
- /**
159
- * Applies a large border radius on the button.
160
- *
161
- * @see {@link https://vuetifyjs.com/en/components/buttons/#rounded}
162
- */
163
- rounded: {
164
- type: (BooleanConstructor | StringConstructor | NumberConstructor)[];
165
- default: undefined;
166
- };
167
- /**
168
- * Applies border styles to component.
169
- *
170
- * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-border}
171
- */
172
- border: {
173
- type: (BooleanConstructor | StringConstructor | NumberConstructor)[];
174
- default: boolean;
175
- };
176
- /**
177
- * Designates an elevation applied to the component between 0 and 24.
178
- *
179
- * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-elevation}
180
- */
181
- elevation: {
182
- type: (StringConstructor | NumberConstructor)[];
183
- default: undefined;
184
- };
185
- /** Swap cols and rows */
186
- transpose: {
187
- type: BooleanConstructor;
188
- default: boolean;
189
- };
190
- /**
191
- * Tooltip
192
- * @see {@link https://vuetifyjs.com/en/components/tooltips/}
193
- */
194
- tooltip: {
195
- type: BooleanConstructor;
196
- default: boolean;
197
- };
198
- /**
199
- * Tooltip location
200
- * @see {@link https://vuetifyjs.com/en/components/tooltips/#props-location}
201
- */
202
- tooltipLocation: {
203
- type: PropType<Anchor>;
204
- default: undefined;
205
- };
206
- }>> & Readonly<{
207
- "onUpdate:modelValue"?: ((_value: string) => any) | undefined;
58
+ tooltipLocation?: Anchor;
59
+ };
60
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
61
+ "update:modelValue": (value: string) => any;
62
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
63
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
208
64
  }>, {
209
65
  size: string;
210
66
  icon: string;
211
67
  iconSize: string;
212
- variant: "elevated" | "flat" | "tonal" | "outlined" | "text" | "plain";
68
+ variant: Variant;
213
69
  disabled: boolean;
214
70
  rounded: string | number | boolean;
215
71
  border: string | number | boolean;
@@ -217,8 +73,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
217
73
  tooltip: boolean;
218
74
  tooltipLocation: Anchor;
219
75
  modelValue: string;
220
- swatches: (string | undefined)[] | Record<string, (string | undefined)[]> | (string | undefined)[][] | readonly (string | undefined)[] | readonly (readonly (string | undefined)[])[];
76
+ swatches: SwatchesProp;
221
77
  inline: boolean;
222
78
  transpose: boolean;
223
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
79
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
80
+ declare const _default: typeof __VLS_export;
224
81
  export default _default;
package/dist/index.cjs.js CHANGED
@@ -5,8 +5,8 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 2.0.1
8
+ * @version 2.1.1
9
9
  * @see {@link https://github.com/logue/vuetify-swatches}
10
10
  */
11
11
 
12
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),c=require("vuetify/components"),b=require("vuetify/util/colors");function y(l){return l&&typeof l=="object"&&"default"in l?l:{default:l}}var u=y(b);function B(...l){let r=0;for(let a=0;a<l.length;a++)l[a].length>r&&(r=l[a].length);const o=l.length,t=Array(r);for(let a=0;a<r;++a){const n=Array(o);for(let i=0;i<o;++i)n[i]=l[i][a];t[a]=n}return t}var m=e.defineComponent({__name:"SwatchButton",props:{color:{default:void 0},isSelected:{type:Boolean,default:!1},size:{default:"2rem"},icon:{default:"mdi-checkbox-marked-circle"},iconSize:{default:"1rem"},variant:{default:void 0},disabled:{type:Boolean,default:!1},rounded:{type:[String,Number,Boolean],default:void 0},border:{type:[String,Number,Boolean],default:!1},elevation:{default:void 0},tooltip:{type:Boolean,default:!1},tooltipLocation:{default:void 0}},emits:["click"],setup(l,{emit:r}){const o=l,t=r;return(a,n)=>o.color?(e.openBlock(),e.createBlock(e.unref(c.VTooltip),{key:0,disabled:!o.tooltip,location:o.tooltipLocation,text:o.color},{activator:e.withCtx(({props:i})=>[e.createVNode(e.unref(c.VBtn),e.mergeProps(i,{border:o.border,class:[o.color===e.unref(u.default).shades.transparent?"bg-transparent":"","p-0"],color:o.color,disabled:o.disabled,elevation:o.elevation,height:o.size,variant:o.variant,width:o.size,"min-width":"auto",onClick:n[0]||(n[0]=p=>t("click"))}),{default:e.withCtx(()=>[o.isSelected?(e.openBlock(),e.createBlock(e.unref(c.VIcon),{key:0,size:o.iconSize,color:o.color!==e.unref(u.default).shades.transparent?o.color:void 0,icon:o.icon},null,8,["size","color","icon"])):e.createCommentVNode("",!0)]),_:1},16,["border","class","color","disabled","elevation","height","variant","width"])]),_:1},8,["disabled","location","text"])):(e.openBlock(),e.createBlock(e.unref(c.VBtn),{key:1,height:o.size,width:o.size,class:"p-0",disabled:"","min-width":"auto",variant:"text"},null,8,["height","width"]))}}),v=e.defineComponent({__name:"VSwatches",props:{modelValue:{type:String,default:u.default.shades.white},swatches:{type:Array,default:()=>[]},size:{type:String,default:"2rem"},icon:{type:String,default:"mdi-checkbox-marked-circle"},iconSize:{type:String,default:"1rem"},inline:{type:Boolean,default:!1},variant:{type:String,default:void 0},disabled:{type:Boolean,default:!1},rounded:{type:[String,Number,Boolean],default:void 0},border:{type:[String,Number,Boolean],default:!1},elevation:{type:[String,Number],default:void 0},transpose:{type:Boolean,default:!1},tooltip:{type:Boolean,default:!1},tooltipLocation:{type:String,default:void 0}},emits:{"update:modelValue":l=>!0},setup(l,{emit:r}){const o=r,t=l,a=e.computed(()=>{const i=Array.isArray(t.swatches)?t.swatches:Object.values(t.swatches);return t.inline?[i.flat(1/0)]:t.transpose?B(...i):i}),n=e.ref(u.default.shades.white);return e.watch(()=>n.value,i=>o("update:modelValue",i)),e.watch(()=>t.modelValue,i=>{i&&(n.value=i)},{immediate:!0}),(i,p)=>(e.openBlock(),e.createBlock(e.unref(c.VItemGroup),{modelValue:n.value,"onUpdate:modelValue":p[0]||(p[0]=d=>n.value=d),class:e.normalizeClass([{"d-inline":t.inline},"v-swatches"]),mandatory:""},{default:e.withCtx(()=>[t.inline?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(a.value[0],d=>(e.openBlock(),e.createBlock(e.unref(c.VItem),{key:d,value:d},{default:e.withCtx(({isSelected:f,toggle:s})=>[e.createVNode(m,{border:t.border,color:d,disabled:t.disabled,elevation:t.elevation,"icon-size":t.iconSize,icon:t.icon,"is-selected":f,rounded:t.rounded,size:t.size,"tooltip-location":t.tooltipLocation,tooltip:t.tooltip,variant:t.variant,onClick:s},null,8,["border","color","disabled","elevation","icon-size","icon","is-selected","rounded","size","tooltip-location","tooltip","variant","onClick"])]),_:2},1032,["value"]))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(a.value,(d,f)=>(e.openBlock(),e.createElementBlock("div",{key:f},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d,s=>(e.openBlock(),e.createBlock(e.unref(c.VItem),{key:s,value:s},{default:e.withCtx(({isSelected:h,toggle:k})=>[e.createVNode(m,{border:t.border,color:s,disabled:t.disabled,elevation:t.elevation,"icon-size":t.iconSize,icon:t.icon,"is-selected":h,rounded:t.rounded,size:t.size,"tooltip-location":t.tooltipLocation,tooltip:t.tooltip,variant:t.variant,onClick:k},null,8,["border","color","disabled","elevation","icon-size","icon","is-selected","rounded","size","tooltip-location","tooltip","variant","onClick"])]),_:2},1032,["value"]))),128))]))),128))]),_:1},8,["modelValue","class"]))}});const w=l=>l.component("VSwatches",v);exports.default=v;exports.install=w;
12
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("vue"),l=require("vuetify/components"),u=require("vuetify/util/colors");u=s(u,1);function d(...e){let t=0;for(let n=0;n<e.length;n++)e[n].length>t&&(t=e[n].length);let n=e.length,r=Array(t);for(let i=0;i<t;++i){let t=Array(n);for(let r=0;r<n;++r)t[r]=e[r][i];r[i]=t}return r}var f=(0,c.defineComponent)({__name:`SwatchButton`,props:{color:{default:void 0},isSelected:{type:Boolean,default:!1},size:{default:`2rem`},icon:{default:`mdi-checkbox-marked-circle`},iconSize:{default:`1rem`},variant:{default:void 0},disabled:{type:Boolean,default:!1},rounded:{type:[String,Number,Boolean],default:void 0},border:{type:[String,Number,Boolean],default:!1},elevation:{default:void 0},tooltip:{type:Boolean,default:!1},tooltipLocation:{default:void 0}},emits:[`click`],setup(e,{emit:t}){let n=e,r=t;return(e,t)=>n.color?((0,c.openBlock)(),(0,c.createBlock)((0,c.unref)(l.VTooltip),{key:0,disabled:!n.tooltip,location:n.tooltipLocation,text:n.color},{activator:(0,c.withCtx)(({props:e})=>[(0,c.createVNode)((0,c.unref)(l.VBtn),(0,c.mergeProps)(e,{border:n.border,class:[n.color===(0,c.unref)(u.default).shades.transparent?`bg-transparent`:``,`p-0`],color:n.color,disabled:n.disabled,elevation:n.elevation,height:n.size,variant:n.variant,width:n.size,"min-width":`auto`,onClick:t[0]||=e=>r(`click`)}),{default:(0,c.withCtx)(()=>[n.isSelected?((0,c.openBlock)(),(0,c.createBlock)((0,c.unref)(l.VIcon),{key:0,size:n.iconSize,color:n.color===(0,c.unref)(u.default).shades.transparent?void 0:n.color,icon:n.icon},null,8,[`size`,`color`,`icon`])):(0,c.createCommentVNode)(``,!0)]),_:1},16,[`border`,`class`,`color`,`disabled`,`elevation`,`height`,`variant`,`width`])]),_:1},8,[`disabled`,`location`,`text`])):((0,c.openBlock)(),(0,c.createBlock)((0,c.unref)(l.VBtn),{key:1,height:n.size,width:n.size,class:`p-0`,"min-width":`auto`,variant:`text`,disabled:``},null,8,[`height`,`width`]))}}),p=(0,c.defineComponent)({__name:`VSwatches`,props:{modelValue:{default:u.default.shades.white},swatches:{default:()=>[]},size:{default:`2rem`},icon:{default:`mdi-checkbox-marked-circle`},iconSize:{default:`1rem`},inline:{type:Boolean,default:!1},variant:{default:void 0},disabled:{type:Boolean,default:!1},rounded:{type:[String,Number,Boolean],default:void 0},border:{type:[String,Number,Boolean],default:!1},elevation:{default:void 0},transpose:{type:Boolean,default:!1},tooltip:{type:Boolean,default:!1},tooltipLocation:{default:void 0}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=t,r=e,i=(0,c.computed)(()=>{let e=Array.isArray(r.swatches)?r.swatches:Object.values(r.swatches);return r.inline?[e.flat(1/0)]:r.transpose?d(...e):e}),a=(0,c.ref)(u.default.shades.white);return(0,c.watch)(()=>a.value,e=>n(`update:modelValue`,e)),(0,c.watch)(()=>r.modelValue,e=>{e&&(a.value=e)},{immediate:!0}),(e,t)=>((0,c.openBlock)(),(0,c.createBlock)((0,c.unref)(l.VItemGroup),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,class:(0,c.normalizeClass)([{"d-inline":r.inline},`v-swatches`]),mandatory:``},{default:(0,c.withCtx)(()=>[r.inline?((0,c.openBlock)(!0),(0,c.createElementBlock)(c.Fragment,{key:0},(0,c.renderList)(i.value[0],e=>((0,c.openBlock)(),(0,c.createBlock)((0,c.unref)(l.VItem),{key:e,value:e},{default:(0,c.withCtx)(({isSelected:t,toggle:n})=>[(0,c.createVNode)(f,{border:r.border,color:e,disabled:r.disabled,elevation:r.elevation,"icon-size":r.iconSize,icon:r.icon,"is-selected":t,rounded:r.rounded,size:r.size,"tooltip-location":r.tooltipLocation,tooltip:r.tooltip,variant:r.variant,onClick:n},null,8,[`border`,`color`,`disabled`,`elevation`,`icon-size`,`icon`,`is-selected`,`rounded`,`size`,`tooltip-location`,`tooltip`,`variant`,`onClick`])]),_:2},1032,[`value`]))),128)):((0,c.openBlock)(!0),(0,c.createElementBlock)(c.Fragment,{key:1},(0,c.renderList)(i.value,(e,t)=>((0,c.openBlock)(),(0,c.createElementBlock)(`div`,{key:t},[((0,c.openBlock)(!0),(0,c.createElementBlock)(c.Fragment,null,(0,c.renderList)(e,e=>((0,c.openBlock)(),(0,c.createBlock)((0,c.unref)(l.VItem),{key:e,value:e},{default:(0,c.withCtx)(({isSelected:t,toggle:n})=>[(0,c.createVNode)(f,{border:r.border,color:e,disabled:r.disabled,elevation:r.elevation,"icon-size":r.iconSize,icon:r.icon,"is-selected":t,rounded:r.rounded,size:r.size,"tooltip-location":r.tooltipLocation,tooltip:r.tooltip,variant:r.variant,onClick:n},null,8,[`border`,`color`,`disabled`,`elevation`,`icon-size`,`icon`,`is-selected`,`rounded`,`size`,`tooltip-location`,`tooltip`,`variant`,`onClick`])]),_:2},1032,[`value`]))),128))]))),128))]),_:1},8,[`modelValue`,`class`]))}}),m=e=>e.component(`VSwatches`,p);exports.default=p,exports.install=m;