vuetify-swatches 2.1.1 → 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,42 +1,56 @@
1
1
  {
2
2
  "name": "vuetify-swatches",
3
- "version": "2.1.1",
3
+ "version": "2.3.0",
4
4
  "description": "Color Swatch component for Vuetify3.",
5
5
  "keywords": [
6
- "vue",
7
- "vue3",
8
- "vue-components",
9
- "color-picker",
10
6
  "color-palette",
7
+ "color-picker",
11
8
  "swatches",
9
+ "vue",
10
+ "vue-components",
12
11
  "vue-plugin",
12
+ "vue3",
13
13
  "vuetify",
14
14
  "vuetify3"
15
15
  ],
16
+ "homepage": "https://github.com/logue/vuetify-swatches",
17
+ "bugs": {
18
+ "url": "https://github.com/logue/vuetify-swatches/issues"
19
+ },
16
20
  "license": "MIT",
17
- "type": "module",
18
21
  "author": {
19
22
  "name": "Logue",
20
23
  "email": "logue@hotmail.co.jp",
21
24
  "url": "https://logue.dev/"
22
25
  },
23
- "homepage": "https://github.com/logue/vuetify-swatches",
24
26
  "repository": {
25
27
  "type": "git",
26
28
  "url": "git@github.com:logue/vuetify-swatches.git"
27
29
  },
28
- "bugs": {
29
- "url": "https://github.com/logue/vuetify-swatches/issues"
30
- },
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",
31
46
  "main": "dist/index.umd.js",
32
47
  "module": "dist/index.es.js",
33
- "jsdelivr": "dist/index.iife.js",
34
- "unpkg": "dist/index.iife.js",
35
- "types": "dist/index.d.ts",
36
- "style": "dist/vuetify-swatches.css",
37
48
  "browser": {
38
49
  "./sfc": "./src/components/VSwatches.vue"
39
50
  },
51
+ "types": "dist/index.d.ts",
52
+ "unpkg": "dist/index.iife.js",
53
+ "jsdelivr": "dist/index.iife.js",
40
54
  "exports": {
41
55
  ".": {
42
56
  "types": "./dist/index.d.ts",
@@ -57,116 +71,82 @@
57
71
  },
58
72
  "./umd": "./dist/index.umd.js",
59
73
  "./iife": "./dist/index.iife.js",
60
- "./dist/style.css": "./dist/vuetify-swatches.css",
74
+ "./dist/style.css": "./dist/style.css",
61
75
  "./package.json": "./package.json"
62
76
  },
63
- "files": [
64
- "dist",
65
- "src/components/VSwatches.vue"
66
- ],
67
- "engines": {
68
- "node": "^20.19.0 || >=22.12.0"
69
- },
70
- "packageManager": "pnpm@11.9.0",
71
77
  "scripts": {
72
- "dev": "vite",
73
- "clean": "rimraf ./node_modules/.vite",
78
+ "dev": "vp dev --open",
79
+ "lint": "run-s lint:*",
80
+ "lint:check": "vize lint --type-aware",
81
+ "lint:oxlint": "vp lint --fix",
82
+ "lint:oxfmt": "vp fmt",
74
83
  "build": "run-s build:lib build:presets",
75
84
  "build:lib": "run-p type-check build-only",
76
- "build:docs": "vite build --mode=docs",
77
- "build:presets": "vite build --config vite.config.presets.ts",
78
- "build:analyze": "vite build --mode analyze",
79
- "build:clean": "rimraf dist",
80
- "lint": "run-s lint:*",
81
- "lint:oxlint": "oxlint . --fix",
82
- "lint:eslint": "eslint . --fix --cache --cache-location ./node_modules/.vite/eslint-cache",
83
- "lint:prettier": "prettier \"./**/*.{js,ts,json,css,sass,scss,htm,html,vue,md}\" -w -u",
84
- "lint:style": "stylelint \"./**/*.{css,sass,scss,htm,html,vue}\" --fix --cache-location ./node_modules/.vite/stylelint-cache && prettier \"./**/*.{css,sass,scss,htm,html,vue}\" -w -u",
85
- "preview": "vite preview",
86
- "test:unit": "vitest",
87
- "test:coverage": "vitest run --coverage",
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",
88
92
  "test:e2e": "playwright test",
89
- "build-only": "vite build",
90
- "type-check": "vue-tsc --build",
91
- "prepare": "husky"
92
- },
93
- "peerDependencies": {
94
- "vue": ">=3.5",
95
- "vuetify": ">=4"
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"
96
100
  },
97
101
  "dependencies": {
98
- "es-toolkit": "^1.49.0"
102
+ "es-toolkit": "^1.53.2"
99
103
  },
100
104
  "devDependencies": {
101
105
  "@codemirror/lang-vue": "^0.1.3",
102
- "@eslint-community/eslint-plugin-eslint-comments": "^4.7.2",
103
- "@eslint/markdown": "^8.0.3",
106
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
107
+ "@eslint/markdown": "^9.0.0",
104
108
  "@mdi/font": "^7.4.47",
105
- "@playwright/test": "^1.61.1",
106
- "@tsconfig/node-lts": "^24.0.0",
107
- "@types/jsdom": "^28.0.3",
108
- "@types/node": "^26.1.0",
109
- "@vitejs/plugin-vue": "^6.0.7",
110
- "@vitest/coverage-v8": "^4.1.9",
111
- "@vitest/eslint-plugin": "1.6.20",
112
- "@vue/eslint-config-prettier": "^10.2.0",
113
- "@vue/eslint-config-typescript": "^14.9.0",
114
- "@vue/test-utils": "^2.4.11",
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",
115
118
  "@vue/tsconfig": "^0.9.1",
116
- "esbuild": "^0.28.1",
117
- "eslint": "^10.6.0",
118
- "eslint-import-resolver-custom-alias": "^1.3.2",
119
- "eslint-import-resolver-typescript": "^4.4.5",
120
- "eslint-plugin-import-x": "^4.17.1",
121
- "eslint-plugin-node": "^11.1.0",
122
- "eslint-plugin-oxlint": "^1.72.0",
123
- "eslint-plugin-playwright": "^2.10.4",
124
- "eslint-plugin-security": "^4.0.1",
125
- "eslint-plugin-vue": "^10.9.2",
126
- "eslint-plugin-vuejs-accessibility": "^2.5.0",
127
- "eslint-plugin-vuetify": "^2.7.2",
128
- "husky": "^9.1.7",
129
- "jiti": "^2.7.0",
130
- "jsdom": "29.1.1",
131
- "lint-staged": "^17.0.8",
132
- "npm-run-all2": "^9.0.2",
133
- "oxlint": "^1.72.0",
134
- "postcss-html": "^1.8.1",
135
- "prettier": "^3.9.4",
136
- "resize-observer-polyfill": "^1.5.1",
137
- "rimraf": "^6.1.3",
138
- "rollup-plugin-visualizer": "^7.0.1",
139
- "sass-embedded": "^1.100.0",
140
- "stylelint": "^17.14.0",
141
- "stylelint-config-html": "^1.1.0",
142
- "stylelint-config-recommended-scss": "^17.0.1",
143
- "stylelint-config-recommended-vue": "^1.6.1",
144
- "stylelint-order": "^8.1.1",
145
- "stylelint-scss": "^7.2.0",
146
- "typescript": "^6.0.3",
147
- "typescript-eslint": "^8.62.1",
148
- "vite": "^8.1.3",
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:",
149
131
  "vite-plugin-banner": "^0.8.1",
150
- "vite-plugin-checker": "0.14.4",
151
- "vite-plugin-dts": "^5.0.3",
152
- "vite-plugin-vue-devtools": "^8.1.5",
132
+ "vite-plugin-checker": "^1.1.0",
133
+ "vite-plugin-dts": "^5.1.2",
134
+ "vite-plugin-vue-devtools": "^8.2.1",
153
135
  "vite-plugin-vuetify": "^2.1.3",
154
- "vitest": "^4.1.9",
155
- "vue-codemirror6": "^1.5.2",
156
- "vue-tsc": "^3.3.6"
157
- },
158
- "husky": {
159
- "hooks": {
160
- "pre-commit": "lint-staged"
161
- }
136
+ "vite-plus": "catalog:",
137
+ "vitest": "catalog:",
138
+ "vize": "^0.839.0",
139
+ "vue-codemirror6": "^1.8.2"
162
140
  },
163
- "lint-staged": {
164
- "*": "run-s lint:*"
141
+ "peerDependencies": {
142
+ "vue": ">=3.5",
143
+ "vuetify": ">=4"
165
144
  },
166
- "resolutions": {
167
- "js-yaml": ">=4.1.1"
145
+ "engines": {
146
+ "node": "^20.19.0 || >=22.12.0"
168
147
  },
148
+ "packageManager": "pnpm@12.26.0",
169
149
  "stackblitz": {
170
150
  "startCommand": "pnpm run test:unit"
171
151
  }
172
- }
152
+ }
@@ -1,6 +1,6 @@
1
- <script setup lang="ts">
1
+ <script lang="ts" setup vapor>
2
2
  /** Vuetify Swatches */
3
- import { computed, ref, watch, type ComputedRef, type Ref } from 'vue';
3
+ import { computed } from 'vue';
4
4
 
5
5
  import { zip } from 'es-toolkit';
6
6
  import { VItem, VItemGroup } from 'vuetify/components';
@@ -8,144 +8,67 @@ import colors from 'vuetify/util/colors';
8
8
 
9
9
  import SwatchButton from './SwatchButton.vue';
10
10
 
11
- import type { Variant } from 'vuetify/lib/composables/variant.d.ts';
12
- import type { Anchor } from 'vuetify/lib/util/index.d.ts';
13
-
14
- /** Swatches prop type */
15
- type SwatchesProp =
16
- | (string | undefined)[]
17
- | (string | undefined)[][]
18
- | Record<string, (string | undefined)[]>
19
- | readonly (string | undefined)[]
20
- | readonly (readonly (string | undefined)[])[];
21
-
22
- /** Emits */
23
- const emit = defineEmits<{
24
- 'update:modelValue': [value: string];
25
- }>();
11
+ import type { VSwatchesProps } from '@/types/VSwatchesProps.d.ts';
26
12
 
27
13
  /** Props */
28
- const props = withDefaults(
29
- defineProps<{
30
- /** Model value */
31
- modelValue?: string;
32
- /** Swatch colors */
33
- swatches?: SwatchesProp;
34
- /** Swatch size */
35
- size?: string;
36
- /**
37
- * Selected icon
38
- * @see {@link https://vuetifyjs.com/en/components/icons/#usage}
39
- */
40
- icon?: string;
41
- /** Selected icon size */
42
- iconSize?: string;
43
- /** Display swatches in a single row */
44
- inline?: boolean;
45
- /**
46
- * The variant prop gives you easy access to several different button styles.
47
- * @see {@link https://vuetifyjs.com/en/components/buttons/#variant}
48
- */
49
- variant?: Variant;
50
- /**
51
- * Removes the ability to click or target the component.
52
- * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-disabled}
53
- */
54
- disabled?: boolean;
55
- /**
56
- * Applies a large border radius on the button.
57
- * @see {@link https://vuetifyjs.com/en/components/buttons/#rounded}
58
- */
59
- rounded?: string | number | boolean;
60
- /**
61
- * Applies border styles to component.
62
- * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-border}
63
- */
64
- border?: string | number | boolean;
65
- /**
66
- * Designates an elevation applied to the component between 0 and 24.
67
- * @see {@link https://vuetifyjs.com/en/api/v-btn/#props-elevation}
68
- */
69
- elevation?: string | number;
70
- /** Swap cols and rows */
71
- transpose?: boolean;
72
- /**
73
- * Tooltip
74
- * @see {@link https://vuetifyjs.com/en/components/tooltips/}
75
- */
76
- tooltip?: boolean;
77
- /**
78
- * Tooltip location
79
- * @see {@link https://vuetifyjs.com/en/components/tooltips/#props-location}
80
- */
81
- tooltipLocation?: Anchor;
82
- }>(),
83
- {
84
- modelValue: colors.shades.white,
85
- swatches: () => [],
86
- size: '2rem',
87
- icon: 'mdi-checkbox-marked-circle',
88
- iconSize: '1rem',
89
- inline: false,
90
- variant: undefined,
91
- disabled: false,
92
- rounded: undefined,
93
- border: false,
94
- elevation: undefined,
95
- transpose: false,
96
- tooltip: false,
97
- tooltipLocation: undefined,
98
- }
99
- );
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
33
+ });
100
34
 
101
35
  /** Normalized swatches structure for rendering */
102
- const normalizedSwatches: ComputedRef<string[][]> = computed(() => {
103
- // Convert to array structure first
104
- const baseSwatches: string[][] = Array.isArray(props.swatches)
105
- ? props.swatches
106
- : Object.values(props.swatches);
107
-
108
- // Apply inline mode: flatten all colors into a single row
109
- if (props.inline) {
110
- 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()];
111
53
  }
112
54
 
113
- // Apply transpose mode: swap rows and columns
114
- if (props.transpose) {
115
- return zip(...baseSwatches) as string[][];
55
+ if (transpose) {
56
+ return zip(...rows);
116
57
  }
117
58
 
118
- // Default: preserve the original structure
119
- return baseSwatches;
120
- });
59
+ return rows;
60
+ }
121
61
 
122
- /** Selected Color */
123
- const selected: Ref<string> = ref(colors.shades.white);
124
-
125
- watch(
126
- () => selected.value,
127
- s => emit('update:modelValue', s)
128
- );
129
-
130
- watch(
131
- () => props.modelValue,
132
- newValue => {
133
- if (newValue) {
134
- selected.value = newValue;
135
- }
136
- },
137
- { immediate: true }
138
- );
62
+ function isSwatchRows(swatches: VSwatchesProps['swatches']): swatches is SwatchRows {
63
+ return Array.isArray(swatches) && swatches.every(Array.isArray);
64
+ }
65
+
66
+ type SwatchRows = readonly (readonly (string | undefined)[])[];
139
67
  </script>
140
68
 
141
69
  <template>
142
- <v-item-group
143
- v-model="selected"
144
- :class="{ 'd-inline': props.inline }"
145
- class="v-swatches"
146
- mandatory
147
- >
148
- <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">
149
72
  <v-item
150
73
  v-for="color in normalizedSwatches[0]"
151
74
  :key="color"
@@ -153,73 +76,71 @@ watch(
153
76
  :value="color"
154
77
  >
155
78
  <swatch-button
156
- :border="props.border"
79
+ :border="border"
157
80
  :color="color"
158
- :disabled="props.disabled"
159
- :elevation="props.elevation"
160
- :icon-size="props.iconSize"
161
- :icon="props.icon"
81
+ :disabled="disabled"
82
+ :elevation="elevation"
83
+ :icon-size="iconSize"
84
+ :icon="icon"
162
85
  :is-selected="isSelected"
163
- :rounded="props.rounded"
164
- :size="props.size"
165
- :tooltip-location="props.tooltipLocation"
166
- :tooltip="props.tooltip"
167
- :variant="props.variant"
86
+ :rounded="rounded"
87
+ :size="size"
88
+ :tooltip-location="tooltipLocation"
89
+ :tooltip="tooltip"
90
+ :variant="variant"
168
91
  @click="toggle"
169
92
  />
170
93
  </v-item>
171
94
  </template>
172
- <div v-for="(cols, rows) in normalizedSwatches" v-else :key="rows">
173
- <v-item
174
- v-for="color in cols"
175
- :key="color"
176
- v-slot="{ isSelected, toggle }"
177
- :value="color"
178
- >
179
- <swatch-button
180
- :border="props.border"
181
- :color="color"
182
- :disabled="props.disabled"
183
- :elevation="props.elevation"
184
- :icon-size="props.iconSize"
185
- :icon="props.icon"
186
- :is-selected="isSelected"
187
- :rounded="props.rounded"
188
- :size="props.size"
189
- :tooltip-location="props.tooltipLocation"
190
- :tooltip="props.tooltip"
191
- :variant="props.variant"
192
- @click="toggle"
193
- />
194
- </v-item>
195
- </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>
196
116
  </v-item-group>
197
117
  </template>
198
118
 
199
- <style lang="scss">
119
+ <style lang="scss" scoped>
200
120
  .v-swatches {
201
- .v-btn {
121
+ :deep(.v-btn) {
202
122
  margin: 0.1rem;
123
+ }
124
+
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
+ }
203
141
 
204
- /** Reverse checkd mark color */
205
- .v-icon {
206
- filter: invert(100%) grayscale(100%) contrast(100);
207
- }
208
-
209
- /** Add Slash */
210
- &.bg-transparent {
211
- background: linear-gradient(
212
- to top left,
213
- transparent 0,
214
- transparent calc(50% - 0.1rem),
215
- rgb(var(--v-theme-error)) 50%,
216
- transparent calc(50% + 0.1rem),
217
- transparent
218
- );
219
- .v-icon {
220
- filter: none;
221
- }
222
- }
142
+ :deep(.bg-transparent .v-icon) {
143
+ filter: none;
223
144
  }
224
145
  }
225
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,3 +0,0 @@
1
- import { default as MetaInterface } from './interfaces/MetaInterface';
2
- declare const meta: MetaInterface;
3
- export default meta;
@@ -1,36 +0,0 @@
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 __VLS_export: 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
- declare const _default: typeof __VLS_export;
36
- export default _default;