vuetify-swatches 2.0.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.
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,43 +11,37 @@
9
11
 
10
12
  ![demo](https://user-images.githubusercontent.com/480173/156681882-d3d5e868-ba9a-4a34-9e75-08272d39da64.gif)
11
13
 
12
- ⚠ **Version 2.x Breaking Changes**: This version includes significant architectural changes.
13
-
14
- ⚠ This is for Vuetify3. If you are using Vuetify2, please use 1.0.x.
14
+ A color swatch component for Vuetify 3.
15
15
 
16
- This project is a remake of [saintplay's vue-swatches](https://saintplay.github.io/vue-swatches/) with [Vuetify](https://vuetifyjs.com/).
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.
17
18
 
18
- Unlike the original version, it provides a UI based on Vuetify, such as ripple effects and dark mode.
19
+ ## Compatibility
19
20
 
20
- 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.
21
+ - `2.x`: Vuetify 3 (current)
22
+ - `1.x`: Vuetify 2
21
23
 
22
- ## Usage
24
+ `2.x` contains breaking changes and requires the `swatches` prop.
23
25
 
24
- **Note**: In v2.x, the component requires a `swatches` prop to display colors. You can either provide your own color array or use the preset palettes.
26
+ ## Installation
25
27
 
26
- ### Using Preset Palettes
28
+ ```bash
29
+ pnpm add vuetify-swatches
30
+ ```
27
31
 
28
- You can import pre-defined color palettes separately. This keeps your bundle size small by only importing what you need:
32
+ ## Quick Start
29
33
 
30
34
  ```vue
31
35
  <script setup lang="ts">
32
36
  import { ref, type Ref } from 'vue';
33
-
34
37
  import VSwatches from 'vuetify-swatches';
35
- // Import only the palette you need
36
38
  import { basicPalette } from 'vuetify-swatches/presets/basic';
37
- // or
38
- import { advancedPalette } from 'vuetify-swatches/presets/advanced';
39
39
 
40
40
  const selected: Ref<string> = ref('#ffffff');
41
41
  </script>
42
42
 
43
43
  <template>
44
- <!-- Use the basic palette (22 colors) -->
45
44
  <v-swatches v-model="selected" :swatches="basicPalette" />
46
-
47
- <!-- Or use the advanced palette (~200 color variations) -->
48
- <v-swatches v-model="selected" :swatches="advancedPalette" />
49
45
  </template>
50
46
 
51
47
  <style>
@@ -53,69 +49,23 @@ const selected: Ref<string> = ref('#ffffff');
53
49
  </style>
54
50
  ```
55
51
 
56
- ## Props
57
-
58
- Most props other than size and placement are the same as [v-btn](https://vuetifyjs.com/en/api/v-btn/).
59
-
60
- | Variables | Type | Default | Info |
61
- | ---------------- | -------------- | -------------------------- | -------------------------------------------------------------------------- |
62
- | size | string | 2rem | Swatch Button size |
63
- | icon | string | mdi-checkbox-marked-circle | checked icon |
64
- | icon-size | string | 1rem | checked icon size |
65
- | disabled | boolean | false | Removes the ability to click or target the component. |
66
- | rounded | number\|string | undefined | Applies a large border radius on the button. |
67
- | variant | Variant [^1] | undefined | The variant prop gives you easy access to several different button styles. |
68
- | elevation | number\|string | undefined | |
69
- | border | number\|string | undefined | |
70
- | transpose | boolean | false | Swaps the rows and columns of swatches. |
71
- | tooltip | boolean | false | Display color value in tooltip. |
72
- | tooltip-location | Anchor [^2] | undefined | Tooltip location. |
73
-
74
- [^1]: <https://vuetifyjs.com/api/v-btn/#props-variant>
75
-
76
- [^2]: <https://vuetifyjs.com/en/components/tooltips/#props-location>
77
-
78
- ## Example
79
-
80
- For more details, see the [demo page](https://logue.dev/vuetify-swatches).
81
-
82
- ### Show color code in tooltip
52
+ ## Preset Palettes
83
53
 
84
- Display the color code in a tooltip when you hover over the swatch.
54
+ - `basicPalette`: lightweight palette for common use cases
55
+ - `advancedPalette`: larger palette with many color variations
85
56
 
86
- ```vue
87
- <script setup lang="ts">
88
- import { ref, type Ref } from 'vue';
89
-
90
- import VSwatches from 'vuetify-swatches';
91
- import { basicPalette } from 'vuetify-swatches/presets';
92
-
93
- const selected: Ref<string> = ref('#ffffff');
94
- </script>
95
-
96
- <template>
97
- <v-swatches
98
- v-model="selected"
99
- :swatches="basicPalette"
100
- tooltip
101
- tooltip-location="top"
102
- class="mb-3"
103
- />
104
- </template>
105
-
106
- <style>
107
- @import 'vuetify-swatches/dist/style.css';
108
- </style>
57
+ ```ts
58
+ import { basicPalette } from 'vuetify-swatches/presets/basic';
59
+ import { advancedPalette } from 'vuetify-swatches/presets/advanced';
109
60
  ```
110
61
 
111
- ### Using Custom Colors
62
+ ## Custom Palette
112
63
 
113
- You can also provide your own custom color palette. The method of specifying `swatches` is the same as [nested-color of Vue Swatches](https://saintplay.github.io/vue-swatches/examples/#nested-colors).
64
+ You can pass your own nested color array to `swatches`.
114
65
 
115
66
  ```vue
116
67
  <script setup lang="ts">
117
68
  import { ref, type Ref } from 'vue';
118
-
119
69
  import VSwatches from 'vuetify-swatches';
120
70
 
121
71
  const customPalette: Ref<string[][]> = ref([
@@ -160,76 +110,49 @@ const customPalette: Ref<string[][]> = ref([
160
110
  '#000000',
161
111
  ],
162
112
  ]);
113
+
163
114
  const selected: Ref<string> = ref('#ffffff');
164
115
  </script>
165
116
 
166
117
  <template>
167
118
  <v-swatches v-model="selected" :swatches="customPalette" />
168
119
  </template>
169
-
170
- <style>
171
- @import 'vuetify-swatches/dist/style.css';
172
- </style>
173
120
  ```
174
121
 
175
- ### Using with VMenu
122
+ ## Props
176
123
 
177
- If you want to make the color palette appear when you click it, combine it with VMenu:
124
+ Most props (except swatch-specific options) follow [v-btn](https://vuetifyjs.com/en/api/v-btn/).
178
125
 
179
- ```vue
180
- <script setup lang="ts">
181
- import { ref, type Ref } from 'vue';
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 |
182
139
 
183
- import VSwatches from 'vuetify-swatches';
184
- import { advancedPalette } from 'vuetify-swatches/presets';
140
+ Reference:
185
141
 
186
- const selected: Ref<string> = ref('#ffffff');
187
- </script>
142
+ - Variant: <https://vuetifyjs.com/api/v-btn/#props-variant>
143
+ - Tooltip location: <https://vuetifyjs.com/en/components/tooltips/#props-location>
188
144
 
189
- <template>
190
- <v-menu class="mb-3">
191
- <template #activator="{ props }">
192
- <v-btn v-bind="props" class="mb-3" min-width="auto" :color="color4">
193
- <v-icon
194
- :color="color4"
195
- style="filter: invert(100%) grayscale(100%) contrast(100)"
196
- >
197
- mdi-menu-down
198
- </v-icon>
199
- </v-btn>
200
- </template>
201
- <v-card title="Select a color">
202
- <v-swatches v-model="color4" :swatches="advancedPalette" />
203
- </v-card>
204
- </v-menu>
205
- </template>
145
+ ## Demo
206
146
 
207
- <style>
208
- @import 'vuetify-swatches/dist/style.css';
209
- </style>
210
- ```
147
+ - Demo page: <https://logue.dev/vuetify-swatches>
211
148
 
212
- ### CDN Usage
213
-
214
- ```html
215
- <!-- Vue core -->
216
- <script src="https://cdn.jsdelivr.net/npm/vue@3.5.25/dist/vue.global.js"></script>
217
- <script src="https://cdn.jsdelivr.net/npm/vuetify@3.11.0/dist/vuetify.min.js"></script>
218
- <link
219
- rel="stylesheet"
220
- href="https://cdn.jsdelivr.net/npm/vuetify@3.11.0/dist/vuetify.min.js"
221
- />
222
- <!-- Markdown wasm -->
223
- <script src="https://cdn.jsdelivr.net/npm/vuetify-swatches@2.0.3/dist/index.iife.min.js"></script>
224
- <script>
225
- const { createApp } = Vue;
226
- const { createVuetify } = Vuetify;
227
-
228
- const app = createApp();
229
- app.use(vuetify).component(VSwatches).mount('#app');
230
- </script>
231
- ```
149
+ ## License
150
+
151
+ Copyright (c) 2022-2026 Logue.
152
+ Licensed under the [MIT License](LICENSE).
153
+
154
+ ## Sponsor
232
155
 
233
- ## LICENSE
156
+ If this project helps your work, consider sponsoring:
234
157
 
235
- ©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)
@@ -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;