vuetify-swatches 1.8.0 → 2.1.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022-2025 Masashi Yoshikawa
3
+ Copyright (c) 2022-2026 Masashi Yoshikawa
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.ja.md ADDED
@@ -0,0 +1,159 @@
1
+ # Vuetify Swatches
2
+
3
+ [English](README.md) | [日本語](README.ja.md)
4
+
5
+ [![jsdelivr CDN](https://data.jsdelivr.com/v1/package/npm/vuetify-swatches/badge)](https://www.jsdelivr.com/package/npm/vuetify-swatches)
6
+ [![NPM Downloads](https://img.shields.io/npm/dm/vuetify-swatches.svg?style=flat)](https://www.npmjs.com/package/vuetify-swatches)
7
+ [![Open in unpkg](https://img.shields.io/badge/Open%20in-unpkg-blue)](https://uiwjs.github.io/npm-unpkg/#/pkg/vuetify-swatches/file/README.md)
8
+ [![npm version](https://img.shields.io/npm/v/vuetify-swatches.svg)](https://www.npmjs.com/package/vuetify-swatches)
9
+ [![Open in Gitpod](https://shields.io/badge/Open%20in-Gitpod-green?logo=Gitpod)](https://gitpod.io/#https://github.com/logue/vuetify-swatches)
10
+ [![Twitter Follow](https://img.shields.io/twitter/follow/logue256?style=plastic)](https://twitter.com/logue256)
11
+
12
+ ![demo](https://user-images.githubusercontent.com/480173/156681882-d3d5e868-ba9a-4a34-9e75-08272d39da64.gif)
13
+
14
+ Vuetify 3 向けのカラースウォッチコンポーネントです。
15
+
16
+ このプロジェクトは [saintplay の vue-swatches](https://saintplay.github.io/vue-swatches/) を
17
+ [Vuetify](https://vuetifyjs.com/) ベースで再構築したものです。
18
+ シンプルな API のまま、Vuetify の UI に自然に組み込める設計を目指しています。
19
+
20
+ ## 対応バージョン
21
+
22
+ - `2.x`: Vuetify 3(現行)
23
+ - `1.x`: Vuetify 2
24
+
25
+ `2.x` は破壊的変更を含み、`swatches` プロパティが必須です。
26
+
27
+ ## インストール
28
+
29
+ ```bash
30
+ pnpm add vuetify-swatches
31
+ ```
32
+
33
+ ## クイックスタート
34
+
35
+ ```vue
36
+ <script setup lang="ts">
37
+ import { ref, type Ref } from 'vue';
38
+ import VSwatches from 'vuetify-swatches';
39
+ import { basicPalette } from 'vuetify-swatches/presets/basic';
40
+
41
+ const selected: Ref<string> = ref('#ffffff');
42
+ </script>
43
+
44
+ <template>
45
+ <v-swatches v-model="selected" :swatches="basicPalette" />
46
+ </template>
47
+
48
+ <style>
49
+ @import 'vuetify-swatches/dist/style.css';
50
+ </style>
51
+ ```
52
+
53
+ ## プリセットパレット
54
+
55
+ - `basicPalette`: 軽量で一般的な用途向け
56
+ - `advancedPalette`: 色バリエーションが豊富な拡張パレット
57
+
58
+ ```ts
59
+ import { basicPalette } from 'vuetify-swatches/presets/basic';
60
+ import { advancedPalette } from 'vuetify-swatches/presets/advanced';
61
+ ```
62
+
63
+ ## カスタムパレット
64
+
65
+ `swatches` にはネストした配列で任意の色パレットを渡せます。
66
+
67
+ ```vue
68
+ <script setup lang="ts">
69
+ import { ref, type Ref } from 'vue';
70
+ import VSwatches from 'vuetify-swatches';
71
+
72
+ const customPalette: Ref<string[][]> = ref([
73
+ [
74
+ '#ffb7b7',
75
+ '#ffdbb7',
76
+ '#ffffb7',
77
+ '#b7ffb7',
78
+ '#b7ffff',
79
+ '#b7b7ff',
80
+ '#ffb7ff',
81
+ '#ffffff',
82
+ ],
83
+ [
84
+ '#ff5555',
85
+ '#ffa555',
86
+ '#ffff55',
87
+ '#55ff55',
88
+ '#55ffff',
89
+ '#5555ff',
90
+ '#ff55ff',
91
+ '#aaaaaa',
92
+ ],
93
+ [
94
+ '#ff0000',
95
+ '#ff7f00',
96
+ '#ffff00',
97
+ '#00ff00',
98
+ '#00ffff',
99
+ '#0000ff',
100
+ '#ff00ff',
101
+ '#555555',
102
+ ],
103
+ [
104
+ '#7f0000',
105
+ '#7f4c00',
106
+ '#7f7f00',
107
+ '#007f00',
108
+ '#007f7f',
109
+ '#00007f',
110
+ '#7f007f',
111
+ '#000000',
112
+ ],
113
+ ]);
114
+
115
+ const selected: Ref<string> = ref('#ffffff');
116
+ </script>
117
+
118
+ <template>
119
+ <v-swatches v-model="selected" :swatches="customPalette" />
120
+ </template>
121
+ ```
122
+
123
+ ## Props
124
+
125
+ スウォッチ固有の項目以外は、基本的に [v-btn](https://vuetifyjs.com/en/api/v-btn/) の仕様に準拠します。
126
+
127
+ | Prop | Type | Default | 説明 |
128
+ | ------------------ | -------------- | ---------------------------- | ---------------------------- |
129
+ | `size` | string | `2rem` | スウォッチボタンのサイズ |
130
+ | `icon` | string | `mdi-checkbox-marked-circle` | 選択時に表示するアイコン |
131
+ | `icon-size` | string | `1rem` | アイコンサイズ |
132
+ | `disabled` | boolean | `false` | 操作を無効化 |
133
+ | `rounded` | number\|string | `undefined` | 角丸 |
134
+ | `variant` | Variant | `undefined` | Vuetify のボタンバリアント |
135
+ | `elevation` | number\|string | `undefined` | Vuetify の elevation |
136
+ | `border` | number\|string | `undefined` | Vuetify の border |
137
+ | `transpose` | boolean | `false` | 行と列を入れ替える |
138
+ | `tooltip` | boolean | `false` | ツールチップで色コードを表示 |
139
+ | `tooltip-location` | Anchor | `undefined` | ツールチップの表示位置 |
140
+
141
+ 参照:
142
+
143
+ - Variant: <https://vuetifyjs.com/api/v-btn/#props-variant>
144
+ - Tooltip location: <https://vuetifyjs.com/en/components/tooltips/#props-location>
145
+
146
+ ## デモ
147
+
148
+ - デモページ: <https://logue.dev/vuetify-swatches>
149
+
150
+ ## ライセンス
151
+
152
+ Copyright (c) 2022-2026 Logue.
153
+ [MIT License](LICENSE) のもとで公開しています。
154
+
155
+ ## スポンサー
156
+
157
+ このプロジェクトが役に立ったら、スポンサーとしての支援をご検討ください。
158
+
159
+ [![GitHub Sponsors](https://img.shields.io/github/sponsors/logue?label=Sponsor&logo=github&color=ea4aaa)](https://github.com/sponsors/logue)
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Vuetify Swatches
2
2
 
3
+ [English](README.md) | [日本語](README.ja.md)
4
+
3
5
  [![jsdelivr CDN](https://data.jsdelivr.com/v1/package/npm/vuetify-swatches/badge)](https://www.jsdelivr.com/package/npm/vuetify-swatches)
4
6
  [![NPM Downloads](https://img.shields.io/npm/dm/vuetify-swatches.svg?style=flat)](https://www.npmjs.com/package/vuetify-swatches)
5
7
  [![Open in unpkg](https://img.shields.io/badge/Open%20in-unpkg-blue)](https://uiwjs.github.io/npm-unpkg/#/pkg/vuetify-swatches/file/README.md)
@@ -9,29 +11,37 @@
9
11
 
10
12
  ![demo](https://user-images.githubusercontent.com/480173/156681882-d3d5e868-ba9a-4a34-9e75-08272d39da64.gif)
11
13
 
12
- ⚠ This is for Vuetify3. If you are using Vuetify2, please use 1.0.x.
14
+ A color swatch component for Vuetify 3.
15
+
16
+ This project is a Vuetify-based remake of [saintplay's vue-swatches](https://saintplay.github.io/vue-swatches/).
17
+ It keeps the API simple while fitting naturally into Vuetify UI patterns.
13
18
 
14
- This project is a remake of [saintplay's vue-swatches](https://saintplay.github.io/vue-swatches/) with [Vuetify](https://vuetifyjs.com/).
19
+ ## Compatibility
15
20
 
16
- Unlike the original version, it provides a UI based on Vuetify, such as ripple effects and dark mode.
21
+ - `2.x`: Vuetify 3 (current)
22
+ - `1.x`: Vuetify 2
17
23
 
18
- 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.
24
+ `2.x` contains breaking changes and requires the `swatches` prop.
19
25
 
20
- ## Usage
26
+ ## Installation
27
+
28
+ ```bash
29
+ pnpm add vuetify-swatches
30
+ ```
21
31
 
22
- In this example, the selected color is assigned to `selected`.
32
+ ## Quick Start
23
33
 
24
34
  ```vue
25
35
  <script setup lang="ts">
26
36
  import { ref, type Ref } from 'vue';
27
-
28
37
  import VSwatches from 'vuetify-swatches';
38
+ import { basicPalette } from 'vuetify-swatches/presets/basic';
29
39
 
30
40
  const selected: Ref<string> = ref('#ffffff');
31
41
  </script>
32
42
 
33
43
  <template>
34
- <v-swatches v-model="selected" />
44
+ <v-swatches v-model="selected" :swatches="basicPalette" />
35
45
  </template>
36
46
 
37
47
  <style>
@@ -39,17 +49,26 @@ const selected: Ref<string> = ref('#ffffff');
39
49
  </style>
40
50
  ```
41
51
 
42
- The method of specifying `swatches` is the same as [nested-color of Vue Swatches](https://saintplay.github.io/vue-swatches/examples/#nested-colors).
52
+ ## Preset Palettes
53
+
54
+ - `basicPalette`: lightweight palette for common use cases
55
+ - `advancedPalette`: larger palette with many color variations
43
56
 
44
- If you want to make the color palette appear when you click it, combine it with VMenu.
57
+ ```ts
58
+ import { basicPalette } from 'vuetify-swatches/presets/basic';
59
+ import { advancedPalette } from 'vuetify-swatches/presets/advanced';
60
+ ```
61
+
62
+ ## Custom Palette
63
+
64
+ You can pass your own nested color array to `swatches`.
45
65
 
46
66
  ```vue
47
67
  <script setup lang="ts">
48
68
  import { ref, type Ref } from 'vue';
49
-
50
69
  import VSwatches from 'vuetify-swatches';
51
70
 
52
- const palette: Ref<string[] | string[][]> = ref([
71
+ const customPalette: Ref<string[][]> = ref([
53
72
  [
54
73
  '#ffb7b7',
55
74
  '#ffdbb7',
@@ -91,68 +110,49 @@ const palette: Ref<string[] | string[][]> = ref([
91
110
  '#000000',
92
111
  ],
93
112
  ]);
113
+
94
114
  const selected: Ref<string> = ref('#ffffff');
95
115
  </script>
96
116
 
97
117
  <template>
98
- <v-menu offset-y>
99
- <template #activator="{ props }">
100
- <v-btn v-bind="props" class="mb-3" min-width="auto" :color="selected">
101
- <v-icon
102
- :color="selected"
103
- style="filter: invert(100%) grayscale(100%) contrast(100)"
104
- >
105
- mdi-menu-down
106
- </v-icon>
107
- </v-btn>
108
- </template>
109
- <v-swatches v-model="selected" :swatches="palette" />
110
- </v-menu>
118
+ <v-swatches v-model="selected" :swatches="customPalette" />
111
119
  </template>
112
-
113
- <style>
114
- @import 'vuetify-swatches/dist/style.css';
115
- </style>
116
120
  ```
117
121
 
118
- ### Options
119
-
120
- Most props other than size and placement are the same as [v-btn](https://vuetifyjs.com/en/api/v-btn/).
121
-
122
- | Variables | Type | Default | Info |
123
- | --------- | -------------- | -------------------------- | -------------------------------------------------------------------------- |
124
- | size | string | 2rem | Swatch Button size |
125
- | icon | string | mdi-checkbox-marked-circle | checked icon |
126
- | icon-size | string | 1rem | checked icon size |
127
- | disabled | boolean | false | Removes the ability to click or target the component. |
128
- | rounded | number\|string | undefined | Applies a large border radius on the button. |
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 |
132
-
133
- [^1] Available variants are: elevated(default), flat, tonal, outlined, text, and plain.
134
-
135
- ### CDN Usage
136
-
137
- ```html
138
- <!-- Vue core -->
139
- <script src="https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.js"></script>
140
- <script src="https://cdn.jsdelivr.net/npm/vuetify@3.3.14/dist/vuetify.min.js"></script>
141
- <link
142
- rel="stylesheet"
143
- href="https://cdn.jsdelivr.net/npm/vuetify@3.3.14/dist/vuetify.min.js"
144
- />
145
- <!-- Markdown wasm -->
146
- <script src="https://cdn.jsdelivr.net/npm/vuetify-swatches@1.4.3/dist/index.iife.min.js"></script>
147
- <script>
148
- const { createApp } = Vue;
149
- const { createVuetify } = Vuetify;
150
-
151
- const app = createApp();
152
- app.use(vuetify).component(VSwatches).mount('#app');
153
- </script>
154
- ```
122
+ ## Props
123
+
124
+ Most props (except swatch-specific options) follow [v-btn](https://vuetifyjs.com/en/api/v-btn/).
125
+
126
+ | Prop | Type | Default | Description |
127
+ | ------------------ | -------------- | ---------------------------- | ----------------------------- |
128
+ | `size` | string | `2rem` | Swatch button size |
129
+ | `icon` | string | `mdi-checkbox-marked-circle` | Icon shown for selected color |
130
+ | `icon-size` | string | `1rem` | Icon size |
131
+ | `disabled` | boolean | `false` | Disables interaction |
132
+ | `rounded` | number\|string | `undefined` | Border radius |
133
+ | `variant` | Variant | `undefined` | Vuetify button variant |
134
+ | `elevation` | number\|string | `undefined` | Vuetify elevation |
135
+ | `border` | number\|string | `undefined` | Vuetify border |
136
+ | `transpose` | boolean | `false` | Swap rows and columns |
137
+ | `tooltip` | boolean | `false` | Show color value in tooltip |
138
+ | `tooltip-location` | Anchor | `undefined` | Tooltip location |
139
+
140
+ Reference:
141
+
142
+ - Variant: <https://vuetifyjs.com/api/v-btn/#props-variant>
143
+ - Tooltip location: <https://vuetifyjs.com/en/components/tooltips/#props-location>
144
+
145
+ ## Demo
146
+
147
+ - Demo page: <https://logue.dev/vuetify-swatches>
148
+
149
+ ## License
150
+
151
+ Copyright (c) 2022-2026 Logue.
152
+ Licensed under the [MIT License](LICENSE).
153
+
154
+ ## Sponsor
155
155
 
156
- ## LICENSE
156
+ If this project helps your work, consider sponsoring:
157
157
 
158
- ©2022-2025 by Logue. Licensed under the [MIT License](LICENSE).
158
+ [![GitHub Sponsors](https://img.shields.io/github/sponsors/logue?label=Sponsor&logo=github&color=ea4aaa)](https://github.com/sponsors/logue)
@@ -0,0 +1,35 @@
1
+ import { Variant } from 'vuetify/lib/composables/variant.d.ts';
2
+ import { Anchor } from 'vuetify/lib/util/index.d.ts';
3
+ interface Props {
4
+ color: string;
5
+ isSelected: boolean;
6
+ size: string;
7
+ icon: string;
8
+ iconSize: string;
9
+ variant: Variant;
10
+ disabled: boolean;
11
+ rounded: string | number | boolean;
12
+ border: string | number | boolean;
13
+ elevation: string | number;
14
+ tooltip: boolean;
15
+ tooltipLocation: Anchor;
16
+ }
17
+ declare const _default: import('vue').DefineComponent<Partial<Props>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
18
+ click: () => any;
19
+ }, string, import('vue').PublicProps, Readonly<Partial<Props>> & Readonly<{
20
+ onClick?: (() => any) | undefined;
21
+ }>, {
22
+ color: string;
23
+ isSelected: boolean;
24
+ size: string;
25
+ icon: string;
26
+ iconSize: string;
27
+ variant: Variant;
28
+ disabled: boolean;
29
+ rounded: string | number | boolean;
30
+ border: string | number | boolean;
31
+ elevation: string | number;
32
+ tooltip: boolean;
33
+ tooltipLocation: Anchor;
34
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
35
+ export default _default;
@@ -1,4 +1,6 @@
1
1
  import { PropType } from 'vue';
2
+ import { Variant } from 'vuetify/lib/composables/variant.d.ts';
3
+ import { Anchor } from 'vuetify/lib/util/index.d.ts';
2
4
  declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
3
5
  /** Model value */
4
6
  modelValue: {
@@ -7,15 +9,18 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
7
9
  };
8
10
  /** Swatch colors */
9
11
  swatches: {
10
- type: PropType<string[] | string[][] | Record<string, string[]>>;
11
- default: () => string[][];
12
+ type: PropType<(string | undefined)[] | (string | undefined)[][] | Record<string, (string | undefined)[]> | readonly (string | undefined)[] | readonly (readonly (string | undefined)[])[]>;
13
+ default: () => never[];
12
14
  };
13
15
  /** Swatch size */
14
16
  size: {
15
17
  type: StringConstructor;
16
18
  default: string;
17
19
  };
18
- /** Selected icon */
20
+ /**
21
+ * Selected icon
22
+ * @see {@link https://vuetifyjs.com/en/components/icons/#usage
23
+ */
19
24
  icon: {
20
25
  type: StringConstructor;
21
26
  default: string;
@@ -25,13 +30,18 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
25
30
  type: StringConstructor;
26
31
  default: string;
27
32
  };
33
+ /** Display swatches in a single row */
34
+ inline: {
35
+ type: BooleanConstructor;
36
+ default: boolean;
37
+ };
28
38
  /**
29
39
  * The variant prop gives you easy access to several different button styles..
30
40
  *
31
41
  * @see {@link https://vuetifyjs.com/en/components/buttons/#variant}
32
42
  */
33
43
  variant: {
34
- type: PropType<NonNullable<"flat" | "text" | "elevated" | "tonal" | "outlined" | "plain">>;
44
+ type: PropType<Variant>;
35
45
  default: undefined;
36
46
  };
37
47
  /**
@@ -49,7 +59,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
49
59
  * @see {@link https://vuetifyjs.com/en/components/buttons/#rounded}
50
60
  */
51
61
  rounded: {
52
- type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
62
+ type: (BooleanConstructor | StringConstructor | NumberConstructor)[];
53
63
  default: undefined;
54
64
  };
55
65
  /**
@@ -58,7 +68,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
58
68
  * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-border}
59
69
  */
60
70
  border: {
61
- type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
71
+ type: (BooleanConstructor | StringConstructor | NumberConstructor)[];
62
72
  default: boolean;
63
73
  };
64
74
  /**
@@ -70,6 +80,27 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
70
80
  type: (StringConstructor | NumberConstructor)[];
71
81
  default: undefined;
72
82
  };
83
+ /** Swap cols and rows */
84
+ transpose: {
85
+ type: BooleanConstructor;
86
+ default: boolean;
87
+ };
88
+ /**
89
+ * Tooltip
90
+ * @see {@link https://vuetifyjs.com/en/components/tooltips/}
91
+ */
92
+ tooltip: {
93
+ type: BooleanConstructor;
94
+ default: boolean;
95
+ };
96
+ /**
97
+ * Tooltip location
98
+ * @see {@link https://vuetifyjs.com/en/components/tooltips/#props-location}
99
+ */
100
+ tooltipLocation: {
101
+ type: PropType<Anchor>;
102
+ default: undefined;
103
+ };
73
104
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
74
105
  "update:modelValue": (_value: string) => void;
75
106
  }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
@@ -80,15 +111,18 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
80
111
  };
81
112
  /** Swatch colors */
82
113
  swatches: {
83
- type: PropType<string[] | string[][] | Record<string, string[]>>;
84
- default: () => string[][];
114
+ type: PropType<(string | undefined)[] | (string | undefined)[][] | Record<string, (string | undefined)[]> | readonly (string | undefined)[] | readonly (readonly (string | undefined)[])[]>;
115
+ default: () => never[];
85
116
  };
86
117
  /** Swatch size */
87
118
  size: {
88
119
  type: StringConstructor;
89
120
  default: string;
90
121
  };
91
- /** Selected icon */
122
+ /**
123
+ * Selected icon
124
+ * @see {@link https://vuetifyjs.com/en/components/icons/#usage
125
+ */
92
126
  icon: {
93
127
  type: StringConstructor;
94
128
  default: string;
@@ -98,13 +132,18 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
98
132
  type: StringConstructor;
99
133
  default: string;
100
134
  };
135
+ /** Display swatches in a single row */
136
+ inline: {
137
+ type: BooleanConstructor;
138
+ default: boolean;
139
+ };
101
140
  /**
102
141
  * The variant prop gives you easy access to several different button styles..
103
142
  *
104
143
  * @see {@link https://vuetifyjs.com/en/components/buttons/#variant}
105
144
  */
106
145
  variant: {
107
- type: PropType<NonNullable<"flat" | "text" | "elevated" | "tonal" | "outlined" | "plain">>;
146
+ type: PropType<Variant>;
108
147
  default: undefined;
109
148
  };
110
149
  /**
@@ -122,7 +161,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
122
161
  * @see {@link https://vuetifyjs.com/en/components/buttons/#rounded}
123
162
  */
124
163
  rounded: {
125
- type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
164
+ type: (BooleanConstructor | StringConstructor | NumberConstructor)[];
126
165
  default: undefined;
127
166
  };
128
167
  /**
@@ -131,7 +170,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
131
170
  * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-border}
132
171
  */
133
172
  border: {
134
- type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
173
+ type: (BooleanConstructor | StringConstructor | NumberConstructor)[];
135
174
  default: boolean;
136
175
  };
137
176
  /**
@@ -143,18 +182,43 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
143
182
  type: (StringConstructor | NumberConstructor)[];
144
183
  default: undefined;
145
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
+ };
146
206
  }>> & Readonly<{
147
207
  "onUpdate:modelValue"?: ((_value: string) => any) | undefined;
148
208
  }>, {
149
- modelValue: string;
150
- swatches: string[] | Record<string, string[]> | string[][];
151
209
  size: string;
152
210
  icon: string;
153
211
  iconSize: string;
154
- variant: NonNullable<"flat" | "text" | "elevated" | "tonal" | "outlined" | "plain">;
212
+ variant: "elevated" | "flat" | "tonal" | "outlined" | "text" | "plain";
155
213
  disabled: boolean;
156
214
  rounded: string | number | boolean;
157
215
  border: string | number | boolean;
158
216
  elevation: string | number;
217
+ tooltip: boolean;
218
+ tooltipLocation: Anchor;
219
+ modelValue: string;
220
+ swatches: (string | undefined)[] | Record<string, (string | undefined)[]> | (string | undefined)[][] | readonly (string | undefined)[] | readonly (readonly (string | undefined)[])[];
221
+ inline: boolean;
222
+ transpose: boolean;
159
223
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
160
224
  export default _default;
package/dist/index.cjs.js CHANGED
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * @description Color Swatch component for Vuetify3.
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2022-2025 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.8.0
8
+ * @version 2.0.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"),n=require("vuetify/components"),h=require("vuetify/util/colors");function p(a){return a&&typeof a=="object"&&"default"in a?a:{default:a}}var t=p(h),s=e.defineComponent({__name:"VSwatches",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:!1},rounded:{type:[String,Number,Boolean],default:void 0},border:{type:[String,Number,Boolean],default:!1},elevation:{type:[String,Number],default:void 0}},emits:{"update:modelValue":a=>!0},setup(a,{emit:i}){const o=i,l=a,u=e.ref(t.default.shades.white),c=d=>u.value=d.target.value||t.default.shades.white;return e.watch(()=>u.value,d=>o("update:modelValue",d)),e.onMounted(()=>{l.modelValue&&(u.value=l.modelValue)}),(d,v)=>(e.openBlock(),e.createBlock(e.unref(n.VSheet),{class:"v-swatches"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.swatches,(f,b)=>(e.openBlock(),e.createElementBlock("div",{key:b},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f,r=>(e.openBlock(),e.createBlock(e.unref(n.VBtn),{key:r,border:l.border,class:e.normalizeClass(r===e.unref(t.default).shades.transparent?"bg-transparent":""),color:r,disabled:l.disabled,elevation:l.elevation,height:l.size,value:r,variant:l.variant,width:l.size,"min-width":"auto",onClick:c},{default:e.withCtx(()=>[r===a.modelValue?(e.openBlock(),e.createBlock(e.unref(n.VIcon),{key:0,size:a.iconSize,color:r!==e.unref(t.default).shades.transparent?r:void 0},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.icon),1)]),_:1},8,["size","color"])):e.createCommentVNode("",!0)]),_:2},1032,["border","class","color","disabled","elevation","height","value","variant","width"]))),128))]))),128))]),_:1}))}});const m=a=>a.component("VSwatches",s);exports.default=s;exports.install=m;
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;