vuetify-swatches 0.0.2 → 0.0.3

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
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "vuetify-swatches",
4
4
  "private": false,
5
- "version": "0.0.2",
5
+ "version": "0.0.3",
6
6
  "description": "Color Swatch component for Vuetify.",
7
7
  "keywords": [
8
8
  "vuejs",
@@ -53,6 +53,7 @@
53
53
  "sideEffects": false,
54
54
  "scripts": {
55
55
  "dev": "vite",
56
+ "clean": "rimraf node_modules/.vite",
56
57
  "build": "vite build & vue-tsc",
57
58
  "build:clean": "rimraf dist && rimraf types",
58
59
  "lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
@@ -60,55 +61,67 @@
60
61
  "lint:markup": "vue-tsc --noEmit",
61
62
  "prepare": "husky install"
62
63
  },
64
+ "dependencies": {
65
+ "vue-demi": "latest"
66
+ },
67
+ "peerDependencies": {
68
+ "@vue/composition-api": "^1.4.9",
69
+ "vue": "^2.6.14 || ^3.2.31",
70
+ "vuetify": "^2.6.4"
71
+ },
72
+ "peerDependenciesMeta": {
73
+ "@vue/composition-api": {
74
+ "optional": true
75
+ }
76
+ },
63
77
  "devDependencies": {
64
- "@types/node": "^17.0.23",
65
- "@typescript-eslint/eslint-plugin": "^5.17.0",
66
- "@typescript-eslint/parser": "^5.17.0",
67
- "@vue/compiler-sfc": "^3.2.31",
78
+ "@codemirror/basic-setup": "^0.19.3",
79
+ "@codemirror/lang-html": "^0.19.4",
80
+ "@modyqyw/vite-plugin-eslint": "^1.2.0",
81
+ "@types/node": "^17.0.25",
82
+ "@typescript-eslint/eslint-plugin": "^5.20.0",
83
+ "@typescript-eslint/parser": "^5.20.0",
84
+ "@vue/composition-api": "^1.4.9",
68
85
  "@vue/eslint-config-typescript": "^10.0.0",
69
- "eslint": "^8.12.0",
86
+ "eslint": "^8.13.0",
70
87
  "eslint-config-google": "^0.14.0",
71
88
  "eslint-config-prettier": "^8.5.0",
72
89
  "eslint-config-vuetify": "^0.6.1",
73
90
  "eslint-import-resolver-alias": "^1.1.2",
74
- "eslint-import-resolver-typescript": "^2.7.0",
75
- "eslint-plugin-import": "^2.25.4",
91
+ "eslint-import-resolver-typescript": "^2.7.1",
92
+ "eslint-plugin-import": "^2.26.0",
76
93
  "eslint-plugin-prettier": "^4.0.0",
77
94
  "eslint-plugin-prettier-vue": "^3.1.0",
78
- "eslint-plugin-tsdoc": "^0.2.14",
79
- "eslint-plugin-vue": "^8.5.0",
95
+ "eslint-plugin-tsdoc": "^0.2.16",
96
+ "eslint-plugin-vue": "^8.6.0",
80
97
  "eslint-plugin-vuejs-accessibility": "^1.1.1",
81
98
  "eslint-plugin-vuetify": "^1.1.0",
82
99
  "eslint-plugin-yaml": "^0.5.0",
83
100
  "husky": "^7.0.4",
84
- "lint-staged": "^12.3.7",
85
- "postcss-html": "^1.3.0",
86
- "prettier": "^2.6.1",
87
- "prettier-plugin-jsdoc": "^0.3.34",
101
+ "lint-staged": "^12.3.8",
102
+ "postcss-html": "^1.4.1",
103
+ "prettier": "^2.6.2",
104
+ "prettier-plugin-jsdoc": "^0.3.38",
88
105
  "prettier-plugin-md-nocjsp": "^1.2.0",
89
106
  "prettier-plugin-sort-imports": "^1.6.0",
90
107
  "rimraf": "^3.0.2",
91
108
  "sass": "1.32.12",
92
- "stylelint": "^14.6.1",
109
+ "stylelint": "^14.7.1",
93
110
  "stylelint-config-prettier": "^9.0.3",
94
111
  "stylelint-config-recommended-scss": "^6.0.0",
95
112
  "stylelint-config-recommended-vue": "^1.4.0",
96
113
  "stylelint-order": "^5.0.0",
97
114
  "stylelint-prettier": "^2.0.0",
98
115
  "typescript": "^4.6.3",
99
- "unplugin-vue-components": "^0.18.5",
100
- "vite": "^2.9.0",
101
- "vite-plugin-eslint": "^1.3.0",
116
+ "unplugin-vue-components": "^0.19.3",
117
+ "vite": "^2.9.5",
102
118
  "vite-plugin-stylelint": "^2.1.0",
103
119
  "vite-plugin-vue2": "^1.9.3",
104
120
  "vue": "^2.6.14",
105
- "vue-class-component": "^7.2.6",
106
- "vue-codemirror6": "0.1.0",
121
+ "vue-codemirror6": "0.1.3",
107
122
  "vue-eslint-parser": "^8.3.0",
108
- "vue-property-decorator": "^9.1.2",
109
123
  "vue-template-compiler": "^2.6.14",
110
- "vue-tsc": "^0.33.9",
111
- "vuetify": "^2.6.4"
124
+ "vue-tsc": "^0.34.7"
112
125
  },
113
126
  "husky": {
114
127
  "hooks": {
@@ -24,93 +24,114 @@
24
24
  </template>
25
25
 
26
26
  <script lang="ts">
27
- import { Component, Prop, PropSync, Vue } from 'vue-property-decorator';
27
+ import { ref, defineComponent, type SetupContext, type Ref } from 'vue-demi';
28
28
 
29
29
  import { VSheet, VIcon, VBtn } from 'vuetify/lib';
30
30
  import colors from 'vuetify/lib/util/colors';
31
31
 
32
- @Component({
32
+ /** Vuetify Swatches */
33
+ export default defineComponent({
34
+ /** Component name */
33
35
  name: 'VSwatches',
36
+ /** Components */
34
37
  components: {
35
38
  VSheet,
36
39
  VBtn,
37
40
  VIcon,
38
41
  },
39
- })
40
- /** Swatch */
41
- export default class VSwatches extends Vue {
42
- /** チェックアイコンの表示制御 */
43
- checkedVisibilty = false;
44
-
45
- /** カラー一覧 */
46
- @PropSync('swatches', {
47
- type: Array,
48
- default: () => [
49
- [colors.shades.black, colors.shades.white],
50
- [
51
- colors.red.base,
52
- colors.pink.base,
53
- colors.purple.base,
54
- colors.deepPurple.base,
55
- colors.indigo.base,
56
- colors.blue.base,
57
- colors.lightBlue.base,
58
- colors.cyan.base,
59
- ],
60
- [
61
- colors.teal.base,
62
- colors.green.base,
63
- colors.lightGreen.base,
64
- colors.lime.base,
65
- colors.yellow.base,
66
- colors.amber.base,
67
- colors.orange.base,
68
- colors.deepOrange.base,
42
+ /** Model Definition */
43
+ model: {
44
+ prop: 'modelValue',
45
+ event: 'update:modelValue',
46
+ },
47
+ props: {
48
+ /** Model value */
49
+ modelValue: { type: String, required: true },
50
+ /** Swatch colors */
51
+ swatches: {
52
+ type: Array as () => string[] | string[][],
53
+ default: () => [
54
+ [colors.shades.black, colors.shades.white],
55
+ [
56
+ colors.red.base,
57
+ colors.pink.base,
58
+ colors.purple.base,
59
+ colors.deepPurple.base,
60
+ colors.indigo.base,
61
+ colors.blue.base,
62
+ colors.lightBlue.base,
63
+ colors.cyan.base,
64
+ ],
65
+ [
66
+ colors.teal.base,
67
+ colors.green.base,
68
+ colors.lightGreen.base,
69
+ colors.lime.base,
70
+ colors.yellow.base,
71
+ colors.amber.base,
72
+ colors.orange.base,
73
+ colors.deepOrange.base,
74
+ ],
75
+ [colors.brown.base, colors.blueGrey.base, colors.grey.base],
69
76
  ],
70
- [colors.brown.base, colors.blueGrey.base, colors.grey.base],
71
- ],
72
- })
73
- palette!: string[] | string[][];
74
-
75
- /** 親コンポーネントからのバインディング */
76
- @PropSync('value', { required: true, type: String })
77
- selected!: string;
77
+ },
78
+ /** Swatch sized */
79
+ size: { type: String, default: '2rem' },
80
+ /** selected icon */
81
+ icon: { type: String, default: 'mdi-checkbox-marked-circle' },
82
+ /** selected icon size */
83
+ iconSize: { type: String, default: '1rem' },
84
+ },
85
+ /** Emits */
86
+ emits: ['update:modelValue'],
87
+ /**
88
+ * Setup
89
+ * @param props - Props
90
+ * @param context - Context
91
+ */
92
+ setup(props, context: SetupContext) {
93
+ /** チェックアイコンの表示制御 */
94
+ const checkedVisibilty: Ref<boolean> = ref(false);
78
95
 
79
- /** ボタンの大きさ */
80
- @Prop({ default: '2rem', type: String })
81
- readonly size!: string;
96
+ /** Palette */
97
+ const palette: Ref<string[] | string[][]> = ref(props.swatches);
82
98
 
83
- /** 使用するアイコン */
84
- @Prop({ default: 'mdi-checkbox-marked-circle', type: String })
85
- readonly icon!: string;
99
+ /** Selected color */
100
+ const selected: Ref<string> = ref(props.modelValue);
86
101
 
87
- /** アイコンサイズ */
88
- @Prop({ default: '1rem', type: String })
89
- readonly iconSize!: string;
102
+ /**
103
+ * ボタンがクリックされた
104
+ *
105
+ * @param e - イベント
106
+ */
107
+ const onSwatchClick = (e: Event) => {
108
+ const value = (e.target as HTMLButtonElement).value;
109
+ if (!value || selected.value === value) {
110
+ return;
111
+ }
112
+ selected.value = value;
113
+ context.emit('update:modelValue', value);
114
+ };
90
115
 
91
- /**
92
- * ボタンがクリックされた
93
- *
94
- * @param e - イベント
95
- */
96
- onSwatchClick(e: Event) {
97
- const value = (e.target as HTMLButtonElement).value;
98
- if (!value || this.selected === value) {
99
- return;
100
- }
101
- this.selected = value;
102
- this.$emit('input', value);
103
- }
104
- }
116
+ return {
117
+ checkedVisibilty,
118
+ palette,
119
+ selected,
120
+ onSwatchClick,
121
+ };
122
+ },
123
+ });
105
124
  </script>
106
125
 
107
- <style lang="scss" scoped>
108
- .v-btn {
109
- padding: 0 !important;
110
- margin: 0.1rem;
126
+ <style lang="scss">
127
+ .v-swatches {
128
+ .v-btn {
129
+ padding: 0 !important;
130
+ margin: 0.1rem;
111
131
 
112
- .v-icon {
113
- filter: invert(100%);
132
+ .v-icon {
133
+ filter: invert(100%);
134
+ }
114
135
  }
115
136
  }
116
137
  </style>