vuetify-swatches 2.1.0 → 2.3.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/package.json CHANGED
@@ -1,43 +1,56 @@
1
1
  {
2
- "$schema": "https://schemastore.org/package.json",
3
2
  "name": "vuetify-swatches",
4
- "version": "2.1.0",
3
+ "version": "2.3.0",
5
4
  "description": "Color Swatch component for Vuetify3.",
6
5
  "keywords": [
7
- "vue",
8
- "vue3",
9
- "vue-components",
10
- "color-picker",
11
6
  "color-palette",
7
+ "color-picker",
12
8
  "swatches",
9
+ "vue",
10
+ "vue-components",
13
11
  "vue-plugin",
12
+ "vue3",
14
13
  "vuetify",
15
14
  "vuetify3"
16
15
  ],
16
+ "homepage": "https://github.com/logue/vuetify-swatches",
17
+ "bugs": {
18
+ "url": "https://github.com/logue/vuetify-swatches/issues"
19
+ },
17
20
  "license": "MIT",
18
- "type": "module",
19
21
  "author": {
20
22
  "name": "Logue",
21
23
  "email": "logue@hotmail.co.jp",
22
24
  "url": "https://logue.dev/"
23
25
  },
24
- "homepage": "https://github.com/logue/vuetify-swatches",
25
26
  "repository": {
26
27
  "type": "git",
27
28
  "url": "git@github.com:logue/vuetify-swatches.git"
28
29
  },
29
- "bugs": {
30
- "url": "https://github.com/logue/vuetify-swatches/issues"
31
- },
30
+ "funding": [
31
+ {
32
+ "type": "github",
33
+ "url": "https://github.com/sponsors/logue"
34
+ },
35
+ {
36
+ "type": "ko-fi",
37
+ "url": "https://ko-fi.com/logue"
38
+ }
39
+ ],
40
+ "style": "dist/style.css",
41
+ "files": [
42
+ "dist",
43
+ "src/components/VSwatches.vue"
44
+ ],
45
+ "type": "module",
32
46
  "main": "dist/index.umd.js",
33
47
  "module": "dist/index.es.js",
34
- "jsdelivr": "dist/index.iife.js",
35
- "unpkg": "dist/index.iife.js",
36
- "types": "dist/index.d.ts",
37
- "style": "dist/vuetify-swatches.css",
38
48
  "browser": {
39
49
  "./sfc": "./src/components/VSwatches.vue"
40
50
  },
51
+ "types": "dist/index.d.ts",
52
+ "unpkg": "dist/index.iife.js",
53
+ "jsdelivr": "dist/index.iife.js",
41
54
  "exports": {
42
55
  ".": {
43
56
  "types": "./dist/index.d.ts",
@@ -58,102 +71,82 @@
58
71
  },
59
72
  "./umd": "./dist/index.umd.js",
60
73
  "./iife": "./dist/index.iife.js",
61
- "./dist/style.css": "./dist/vuetify-swatches.css",
74
+ "./dist/style.css": "./dist/style.css",
62
75
  "./package.json": "./package.json"
63
76
  },
64
- "files": [
65
- "dist",
66
- "src/components/VSwatches.vue"
67
- ],
68
- "engines": {
69
- "node": ">=24.11.1"
70
- },
71
- "packageManager": "pnpm@10.30.3",
72
- "sideEffects": false,
73
77
  "scripts": {
74
- "dev": "vite",
75
- "clean": "rimraf node_modules/.vite",
76
- "type-check": "vue-tsc --build --force",
77
- "build": "run-s type-check build-only build:presets",
78
- "build:analyze": "vite build --mode=analyze",
79
- "build:clean": "rimraf dist docs",
80
- "build:docs": "vite build --mode=docs",
81
- "build-only": "vite build",
82
- "build:presets": "vite build --config vite.config.presets.ts",
78
+ "dev": "vp dev --open",
83
79
  "lint": "run-s lint:*",
84
- "lint:oxlint": "oxlint . --fix",
85
- "lint:eslint": "eslint . --fix --cache --cache-location ./node_modules/.vite/eslint-cache",
86
- "lint:prettier": "prettier \"./**/*.{js,ts,json,css,sass,scss,htm,html,vue,md}\" -w -u",
87
- "preview": "vite preview --mode=docs",
88
- "test": "vitest",
89
- "test:run": "vitest run",
90
- "test:coverage": "vitest run --coverage",
91
- "test:ui": "vitest --ui",
92
- "prepare": "husky",
93
- "version": "auto-changelog -p && git add CHANGELOG.md"
94
- },
95
- "peerDependencies": {
96
- "vue": ">=3.5.29",
97
- "vuetify": ">=4.0.1"
80
+ "lint:check": "vize lint --type-aware",
81
+ "lint:oxlint": "vp lint --fix",
82
+ "lint:oxfmt": "vp fmt",
83
+ "build": "run-s build:lib build:presets",
84
+ "build:lib": "run-p type-check build-only",
85
+ "build:docs": "vp build --mode=docs",
86
+ "build:presets": "vp build --config vite.config.presets.ts",
87
+ "build:analyze": "vp build --mode analyze",
88
+ "preview": "vp preview",
89
+ "test": "vp test",
90
+ "test:run": "vp test run",
91
+ "test:coverage": "vp test run --coverage",
92
+ "test:e2e": "playwright test",
93
+ "clean": "rimraf dist",
94
+ "clean:hard": "rimraf dist node_modules/.tmp node_modules/.vite node_modules/.vite-tmp",
95
+ "build-only": "vp build",
96
+ "type-check": "vize check --tsconfig tsconfig.app.json",
97
+ "skills:install": "npx --no-install skills --version >/dev/null 2>&1 && npx skills experimental_install --yes || echo '\\033[1;33m⚠️ [Warning] skills command not found. Skipped auto-installation of agent skills.\\033[0m'",
98
+ "skills:update": "npx skills update",
99
+ "prepare": "vp config && pnpm run skills:install"
98
100
  },
99
101
  "dependencies": {
100
- "es-toolkit": "^1.45.1"
102
+ "es-toolkit": "^1.53.2"
101
103
  },
102
104
  "devDependencies": {
103
- "@codemirror/lang-vue": "0.1.3",
104
- "@tsconfig/node-lts": "^24.0.0",
105
- "@types/jsdom": "^28.0.0",
106
- "@types/node": "^25.3.5",
107
- "@vitejs/plugin-vue": "^6.0.4",
108
- "@vitest/coverage-v8": "^4.0.18",
109
- "@vitest/eslint-plugin": "^1.6.9",
110
- "@vue/eslint-config-prettier": "^10.2.0",
111
- "@vue/eslint-config-typescript": "^14.7.0",
112
- "@vue/test-utils": "^2.4.6",
113
- "@vue/tsconfig": "^0.9.0",
114
- "eslint": "^10.0.2",
115
- "eslint-import-resolver-custom-alias": "^1.3.2",
116
- "eslint-import-resolver-typescript": "^4.4.4",
117
- "eslint-plugin-import-x": "^4.16.1",
118
- "eslint-plugin-oxlint": "^1.51.0",
119
- "eslint-plugin-security": "^4.0.0",
120
- "eslint-plugin-vue": "^10.8.0",
121
- "eslint-plugin-vuejs-accessibility": "^2.5.0",
122
- "eslint-plugin-vuetify": "^2.7.0",
123
- "husky": "^9.1.7",
124
- "jiti": "^2.6.1",
125
- "jsdom": "^28.1.0",
126
- "lint-staged": "^16.3.2",
127
- "npm-run-all2": "^8.0.4",
128
- "oxlint": "^1.51.0",
129
- "prettier": "^3.8.1",
130
- "rimraf": "^6.1.3",
131
- "rollup-plugin-visualizer": "^7.0.1",
132
- "sass-embedded": "^1.97.3",
133
- "typescript": "^5.9.3",
134
- "typescript-eslint": "^8.56.1",
135
- "vite": "^7.3.1",
105
+ "@codemirror/lang-vue": "^0.1.3",
106
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
107
+ "@eslint/markdown": "^9.0.0",
108
+ "@mdi/font": "^7.4.47",
109
+ "@playwright/test": "^1.65.2",
110
+ "@tsconfig/node-lts": "^26.0.1",
111
+ "@types/jsdom": "^30.0.0",
112
+ "@types/node": "^26.6.11",
113
+ "@typescript/native": "npm:typescript@^7.0.2",
114
+ "@vitejs/plugin-vue": "^6.1.1",
115
+ "@vitest/coverage-v8": "catalog:",
116
+ "@vue/language-core": "^3.3.14",
117
+ "@vue/test-utils": "^2.6.0",
118
+ "@vue/tsconfig": "^0.9.1",
119
+ "eslint-config-vuetify": "^4.7.2",
120
+ "eslint-plugin-playwright": "^2.12.2",
121
+ "eslint-plugin-security": "^4.2.1",
122
+ "eslint-plugin-vuetify": "^2.7.3",
123
+ "jsdom": "^31.0.1",
124
+ "npm-run-all2": "^9.1.0",
125
+ "rimraf": "^6.1.4",
126
+ "rollup-plugin-visualizer": "^7.3.0",
127
+ "sass-embedded": "^1.108.2",
128
+ "taze": "^21.3.0",
129
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
130
+ "vite": "catalog:",
136
131
  "vite-plugin-banner": "^0.8.1",
137
- "vite-plugin-checker": "^0.12.0",
138
- "vite-plugin-dts": "^4.5.4",
132
+ "vite-plugin-checker": "^1.1.0",
133
+ "vite-plugin-dts": "^5.1.2",
134
+ "vite-plugin-vue-devtools": "^8.2.1",
139
135
  "vite-plugin-vuetify": "^2.1.3",
140
- "vitest": "^4.0.18",
141
- "vue": "^3.5.29",
142
- "vue-codemirror6": "^1.4.3",
143
- "vue-eslint-parser": "^10.4.0",
144
- "vue-tsc": "^3.2.5"
136
+ "vite-plus": "catalog:",
137
+ "vitest": "catalog:",
138
+ "vize": "^0.839.0",
139
+ "vue-codemirror6": "^1.8.2"
145
140
  },
146
- "husky": {
147
- "hooks": {
148
- "pre-commit": "lint-staged"
149
- }
141
+ "peerDependencies": {
142
+ "vue": ">=3.5",
143
+ "vuetify": ">=4"
150
144
  },
151
- "lint-staged": {
152
- "*": "run-s lint:*"
145
+ "engines": {
146
+ "node": "^20.19.0 || >=22.12.0"
153
147
  },
154
- "resolutions": {
155
- "json5": ">=2.2.3",
156
- "minimatch": ">=10.2.3",
157
- "yaml": ">=2.3.2"
148
+ "packageManager": "pnpm@12.26.0",
149
+ "stackblitz": {
150
+ "startCommand": "pnpm run test:unit"
158
151
  }
159
152
  }
@@ -1,13 +1,6 @@
1
- <script setup lang="ts">
1
+ <script lang="ts" setup vapor>
2
2
  /** Vuetify Swatches */
3
- import {
4
- computed,
5
- ref,
6
- watch,
7
- type ComputedRef,
8
- type PropType,
9
- type Ref,
10
- } from 'vue';
3
+ import { computed } from 'vue';
11
4
 
12
5
  import { zip } from 'es-toolkit';
13
6
  import { VItem, VItemGroup } from 'vuetify/components';
@@ -15,168 +8,67 @@ import colors from 'vuetify/util/colors';
15
8
 
16
9
  import SwatchButton from './SwatchButton.vue';
17
10
 
18
- import type { Variant } from 'vuetify/lib/composables/variant.d.ts';
19
- import type { Anchor } from 'vuetify/lib/util/index.d.ts';
20
-
21
- /** Emits */
22
- const emits = defineEmits({
23
- 'update:modelValue': (_value: string) => true,
24
- });
11
+ import type { VSwatchesProps } from '@/types/VSwatchesProps.d.ts';
25
12
 
26
13
  /** Props */
27
- const props = defineProps({
28
- /** Model value */
29
- modelValue: { type: String, default: colors.shades.white },
30
- /** Swatch colors */
31
- swatches: {
32
- type: Array as PropType<
33
- | (string | undefined)[]
34
- | (string | undefined)[][]
35
- | Record<string, (string | undefined)[]>
36
- | readonly (string | undefined)[]
37
- | readonly (readonly (string | undefined)[])[]
38
- >,
39
- default: () => [],
40
- },
41
- /** Swatch size */
42
- size: {
43
- type: String,
44
- default: '2rem',
45
- },
46
- /**
47
- * Selected icon
48
- * @see {@link https://vuetifyjs.com/en/components/icons/#usage
49
- */
50
- icon: {
51
- type: String,
52
- default: 'mdi-checkbox-marked-circle',
53
- },
54
- /** selected icon size */
55
- iconSize: {
56
- type: String,
57
- default: '1rem',
58
- },
59
- /** Display swatches in a single row */
60
- inline: {
61
- type: Boolean,
62
- default: false,
63
- },
64
- /**
65
- * The variant prop gives you easy access to several different button styles..
66
- *
67
- * @see {@link https://vuetifyjs.com/en/components/buttons/#variant}
68
- */
69
- variant: {
70
- type: String as PropType<Variant>,
71
- default: undefined,
72
- },
73
- /**
74
- * Removes the ability to click or target the component.
75
- *
76
- * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-disabled}
77
- */
78
- disabled: {
79
- type: Boolean,
80
- default: false,
81
- },
82
- /**
83
- * Applies a large border radius on the button.
84
- *
85
- * @see {@link https://vuetifyjs.com/en/components/buttons/#rounded}
86
- */
87
- rounded: {
88
- type: [String, Number, Boolean],
89
- default: undefined,
90
- },
91
- /**
92
- * Applies border styles to component.
93
- *
94
- * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-border}
95
- */
96
- border: {
97
- type: [String, Number, Boolean],
98
- default: false,
99
- },
100
- /**
101
- * Designates an elevation applied to the component between 0 and 24.
102
- *
103
- * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-elevation}
104
- */
105
- elevation: {
106
- type: [String, Number],
107
- default: undefined,
108
- },
109
- /** Swap cols and rows */
110
- transpose: {
111
- type: Boolean,
112
- default: false,
113
- },
114
- /**
115
- * Tooltip
116
- * @see {@link https://vuetifyjs.com/en/components/tooltips/}
117
- */
118
- tooltip: {
119
- type: Boolean,
120
- default: false,
121
- },
122
- /**
123
- * Tooltip location
124
- * @see {@link https://vuetifyjs.com/en/components/tooltips/#props-location}
125
- */
126
- tooltipLocation: {
127
- type: String as PropType<Anchor>,
128
- default: undefined,
129
- },
14
+ const {
15
+ swatches = [],
16
+ size = '2rem',
17
+ icon = 'mdi-checkbox-marked-circle',
18
+ iconSize = '1rem',
19
+ inline = false,
20
+ variant,
21
+ disabled = false,
22
+ rounded,
23
+ border = false,
24
+ elevation,
25
+ transpose = false,
26
+ tooltip = false,
27
+ tooltipLocation
28
+ } = defineProps<Partial<Omit<VSwatchesProps, 'modelValue'>>>();
29
+
30
+ /** Selected Color */
31
+ const selected = defineModel<string>({
32
+ default: colors.shades.white
130
33
  });
131
34
 
132
35
  /** Normalized swatches structure for rendering */
133
- const normalizedSwatches: ComputedRef<string[][]> = computed(() => {
134
- // Convert to array structure first
135
- const baseSwatches: string[][] = Array.isArray(props.swatches)
136
- ? props.swatches
137
- : Object.values(props.swatches);
138
-
139
- // Apply inline mode: flatten all colors into a single row
140
- if (props.inline) {
141
- return [baseSwatches.flat(Infinity) as string[]];
36
+ const normalizedSwatches = computed(() => normalizeSwatches(swatches, inline, transpose));
37
+
38
+ function normalizeSwatches(
39
+ swatches: VSwatchesProps['swatches'],
40
+ inline: boolean,
41
+ transpose: boolean
42
+ ): SwatchRows {
43
+ const rows = Array.isArray(swatches)
44
+ ? isSwatchRows(swatches)
45
+ ? swatches
46
+ : swatches.length > 0
47
+ ? [swatches]
48
+ : []
49
+ : Object.values(swatches);
50
+
51
+ if (inline) {
52
+ return [rows.flat()];
142
53
  }
143
54
 
144
- // Apply transpose mode: swap rows and columns
145
- if (props.transpose) {
146
- return zip(...baseSwatches) as string[][];
55
+ if (transpose) {
56
+ return zip(...rows);
147
57
  }
148
58
 
149
- // Default: preserve the original structure
150
- return baseSwatches;
151
- });
152
-
153
- /** Selected Color */
154
- const selected: Ref<string> = ref(colors.shades.white);
59
+ return rows;
60
+ }
155
61
 
156
- watch(
157
- () => selected.value,
158
- s => emits('update:modelValue', s)
159
- );
62
+ function isSwatchRows(swatches: VSwatchesProps['swatches']): swatches is SwatchRows {
63
+ return Array.isArray(swatches) && swatches.every(Array.isArray);
64
+ }
160
65
 
161
- watch(
162
- () => props.modelValue,
163
- newValue => {
164
- if (newValue) {
165
- selected.value = newValue;
166
- }
167
- },
168
- { immediate: true }
169
- );
66
+ type SwatchRows = readonly (readonly (string | undefined)[])[];
170
67
  </script>
171
68
 
172
69
  <template>
173
- <v-item-group
174
- v-model="selected"
175
- :class="{ 'd-inline': props.inline }"
176
- class="v-swatches"
177
- mandatory
178
- >
179
- <template v-if="props.inline">
70
+ <v-item-group v-model="selected" class="v-swatches" :class="{ 'd-inline': inline }" mandatory>
71
+ <template v-if="inline">
180
72
  <v-item
181
73
  v-for="color in normalizedSwatches[0]"
182
74
  :key="color"
@@ -184,73 +76,71 @@ watch(
184
76
  :value="color"
185
77
  >
186
78
  <swatch-button
187
- :border="props.border"
79
+ :border="border"
188
80
  :color="color"
189
- :disabled="props.disabled"
190
- :elevation="props.elevation"
191
- :icon-size="props.iconSize"
192
- :icon="props.icon"
81
+ :disabled="disabled"
82
+ :elevation="elevation"
83
+ :icon-size="iconSize"
84
+ :icon="icon"
193
85
  :is-selected="isSelected"
194
- :rounded="props.rounded"
195
- :size="props.size"
196
- :tooltip-location="props.tooltipLocation"
197
- :tooltip="props.tooltip"
198
- :variant="props.variant"
86
+ :rounded="rounded"
87
+ :size="size"
88
+ :tooltip-location="tooltipLocation"
89
+ :tooltip="tooltip"
90
+ :variant="variant"
199
91
  @click="toggle"
200
92
  />
201
93
  </v-item>
202
94
  </template>
203
- <div v-for="(cols, rows) in normalizedSwatches" v-else :key="rows">
204
- <v-item
205
- v-for="color in cols"
206
- :key="color"
207
- v-slot="{ isSelected, toggle }"
208
- :value="color"
209
- >
210
- <swatch-button
211
- :border="props.border"
212
- :color="color"
213
- :disabled="props.disabled"
214
- :elevation="props.elevation"
215
- :icon-size="props.iconSize"
216
- :icon="props.icon"
217
- :is-selected="isSelected"
218
- :rounded="props.rounded"
219
- :size="props.size"
220
- :tooltip-location="props.tooltipLocation"
221
- :tooltip="props.tooltip"
222
- :variant="props.variant"
223
- @click="toggle"
224
- />
225
- </v-item>
226
- </div>
95
+ <template v-else>
96
+ <div v-for="(cols, rows) in normalizedSwatches" :key="rows">
97
+ <v-item v-for="color in cols" :key="color" v-slot="{ isSelected, toggle }" :value="color">
98
+ <swatch-button
99
+ :border="border"
100
+ :color="color"
101
+ :disabled="disabled"
102
+ :elevation="elevation"
103
+ :icon-size="iconSize"
104
+ :icon="icon"
105
+ :is-selected="isSelected"
106
+ :rounded="rounded"
107
+ :size="size"
108
+ :tooltip-location="tooltipLocation"
109
+ :tooltip="tooltip"
110
+ :variant="variant"
111
+ @click="toggle"
112
+ />
113
+ </v-item>
114
+ </div>
115
+ </template>
227
116
  </v-item-group>
228
117
  </template>
229
118
 
230
- <style lang="scss">
119
+ <style lang="scss" scoped>
231
120
  .v-swatches {
232
- .v-btn {
121
+ :deep(.v-btn) {
233
122
  margin: 0.1rem;
123
+ }
234
124
 
235
- /** Reverse checkd mark color */
236
- .v-icon {
237
- filter: invert(100%) grayscale(100%) contrast(100);
238
- }
125
+ /** Reverse checkd mark color */
126
+ :deep(.v-icon) {
127
+ filter: invert(100%) grayscale(100%) contrast(100);
128
+ }
129
+
130
+ /** Add Slash */
131
+ :deep(.bg-transparent) {
132
+ background: linear-gradient(
133
+ to top left,
134
+ transparent 0,
135
+ transparent calc(50% - 0.1rem),
136
+ rgb(var(--v-theme-error)) 50%,
137
+ transparent calc(50% + 0.1rem),
138
+ transparent
139
+ );
140
+ }
239
141
 
240
- /** Add Slash */
241
- &.bg-transparent {
242
- background: linear-gradient(
243
- to top left,
244
- transparent 0,
245
- transparent calc(50% - 0.1rem),
246
- rgb(var(--v-theme-error)) 50%,
247
- transparent calc(50% + 0.1rem),
248
- transparent
249
- );
250
- .v-icon {
251
- filter: none;
252
- }
253
- }
142
+ :deep(.bg-transparent .v-icon) {
143
+ filter: none;
254
144
  }
255
145
  }
256
146
  </style>
package/dist/Meta.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { default as MetaInterface } from './interfaces/MetaInterface';
2
- declare const meta: MetaInterface;
3
- export default meta;
@@ -1,12 +0,0 @@
1
- /**
2
- * vuetify-swatches
3
- *
4
- * @description Color Swatch component for Vuetify3.
5
- * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
7
- * @license MIT
8
- * @version 2.0.1
9
- * @see {@link https://github.com/logue/vuetify-swatches}
10
- */
11
-
12
- .v-swatches .v-btn{margin:.1rem}.v-swatches .v-btn .v-icon{filter:invert(100%) grayscale(100%) contrast(100)}.v-swatches .v-btn.bg-transparent{background:linear-gradient(to top left,transparent 0,transparent calc(50% - .1rem),rgb(var(--v-theme-error)) 50%,transparent calc(50% + .1rem),transparent)}.v-swatches .v-btn.bg-transparent .v-icon{filter:none}