vue-editify 0.1.2 → 0.1.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.
@@ -1,196 +1,196 @@
1
- <template>
2
- <label class="editify-checkbox" :class="{ disabled: disabled }">
3
- <span v-if="placement == 'left' && label" class="editify-checkbox-label" :data-editify-placement="placement" v-text="label"></span>
4
- <input @change="change" :value="value" :disabled="disabled" :checked="check" type="checkbox" />
5
- <span class="editify-checkbox-item" :class="{ reverse: !color, round: round, checked: check && !disabled }" :style="itemStyle">
6
- <Icon value="check" :style="{ opacity: check ? '' : 0 }" />
7
- </span>
8
- <span v-if="placement == 'right' && label" class="editify-checkbox-label" :data-editify-placement="placement" v-text="label"></span>
9
- </label>
10
- </template>
11
-
12
- <script>
13
- import { common as DapCommon } from 'dap-util'
14
- import Icon from './Icon'
15
- export default {
16
- name: 'Checkbox',
17
- emits: ['update:modelValue', 'change'],
18
- props: {
19
- //是否禁用
20
- disabled: {
21
- type: Boolean,
22
- default: false
23
- },
24
- //是否选中
25
- modelValue: {
26
- type: [Boolean, Array],
27
- default: false
28
- },
29
- //label文字
30
- label: {
31
- type: String,
32
- default: null
33
- },
34
- //值
35
- value: {
36
- type: [Object, Number, String, Array],
37
- default: ''
38
- },
39
- //是否圆形
40
- round: {
41
- type: Boolean,
42
- default: false
43
- },
44
- //文字位置
45
- placement: {
46
- type: String,
47
- default: 'right',
48
- validator(value) {
49
- return ['left', 'right'].includes(value)
50
- }
51
- },
52
- //主题颜色
53
- color: {
54
- type: String,
55
- default: '',
56
- validator(value) {
57
- return DapCommon.matchingText(value, 'hex')
58
- }
59
- }
60
- },
61
- computed: {
62
- check() {
63
- if (typeof this.modelValue == 'boolean') {
64
- return this.modelValue
65
- }
66
- if (Array.isArray(this.modelValue)) {
67
- //数组中是否已包含此复选框的值
68
- return this.modelValue.some(item => {
69
- return DapCommon.equal(item, this.value)
70
- })
71
- }
72
- return false
73
- },
74
- itemStyle() {
75
- let style = {}
76
- if (this.color && this.check && !this.disabled) {
77
- style.backgroundColor = this.color
78
- style.borderColor = this.color
79
- }
80
- return style
81
- }
82
- },
83
- components: {
84
- Icon
85
- },
86
- methods: {
87
- change(event) {
88
- if (Array.isArray(this.modelValue)) {
89
- let arr = [...this.modelValue]
90
- //勾选且不包含
91
- if (event.target.checked && !this.check) {
92
- arr.push(this.value)
93
- }
94
- //取消且包含
95
- else if (this.check) {
96
- arr = arr.filter(item => {
97
- return !DapCommon.equal(item, this.value)
98
- })
99
- }
100
- this.$emit('update:modelValue', arr)
101
- this.$emit('change', arr)
102
- } else if (typeof this.modelValue == 'boolean') {
103
- this.$emit('update:modelValue', event.target.checked)
104
- this.$emit('change', event.target.checked)
105
- }
106
- }
107
- }
108
- }
109
- </script>
110
-
111
- <style scoped lang="less">
112
- .editify-checkbox {
113
- display: inline-flex;
114
- margin: 0;
115
- padding: 0;
116
- position: relative;
117
- vertical-align: middle;
118
- justify-content: flex-start;
119
- align-items: center;
120
- cursor: pointer;
121
- user-select: none;
122
- font-size: @font-size;
123
-
124
- input[type='checkbox'] {
125
- width: 0;
126
- height: 0;
127
- opacity: 0;
128
- border: none;
129
- display: none;
130
- }
131
-
132
- .editify-checkbox-item {
133
- display: inline-flex;
134
- display: -webkit-inline-flex;
135
- justify-content: center;
136
- align-items: center;
137
- position: relative;
138
- margin: 0;
139
- padding: 1px;
140
- border: 1px solid @border-color;
141
- background-color: @background;
142
- border-radius: 2px;
143
- color: @background;
144
- transition: border-color 0.1s cubic-bezier(0.71, -0.46, 0.29, 1.46), background-color 0.1s cubic-bezier(0.71, -0.46, 0.29, 1.46), color 0.1s cubic-bezier(0.71, -0.46, 0.29, 1.46);
145
-
146
- &.round {
147
- border-radius: 50%;
148
- }
149
-
150
- &.checked {
151
- background-color: @font-color;
152
- border-color: @font-color;
153
-
154
- &.reverse {
155
- background-color: @background;
156
- color: @font-color-light;
157
- border-color: @border-color;
158
- }
159
- }
160
-
161
- :deep(.editify-icon) {
162
- font-size: 18px;
163
- zoom: 50%;
164
- }
165
- }
166
-
167
- .editify-checkbox-label {
168
- vertical-align: middle;
169
- color: @font-color;
170
- user-select: none;
171
- line-height: 1;
172
-
173
- &[data-editify-placement='left'] {
174
- margin-right: 6px;
175
- }
176
-
177
- &[data-editify-placement='right'] {
178
- margin-left: 6px;
179
- }
180
- }
181
-
182
- &.disabled {
183
- cursor: not-allowed;
184
- .editify-checkbox-item,
185
- .editify-checkbox-item.check {
186
- background-color: @background-darker;
187
- border-color: @border-color;
188
- color: @font-color-disabled;
189
- }
190
-
191
- .editify-checkbox-label {
192
- color: @font-color-disabled;
193
- }
194
- }
195
- }
196
- </style>
1
+ <template>
2
+ <label class="editify-checkbox" :class="{ disabled: disabled }">
3
+ <span v-if="placement == 'left' && label" class="editify-checkbox-label" :data-editify-placement="placement" v-text="label"></span>
4
+ <input @change="change" :value="value" :disabled="disabled" :checked="check" type="checkbox" />
5
+ <span class="editify-checkbox-item" :class="{ reverse: !color, round: round, checked: check && !disabled }" :style="itemStyle">
6
+ <Icon value="check" :style="{ opacity: check ? '' : 0 }" />
7
+ </span>
8
+ <span v-if="placement == 'right' && label" class="editify-checkbox-label" :data-editify-placement="placement" v-text="label"></span>
9
+ </label>
10
+ </template>
11
+
12
+ <script>
13
+ import { common as DapCommon } from 'dap-util'
14
+ import Icon from './Icon'
15
+ export default {
16
+ name: 'Checkbox',
17
+ emits: ['update:modelValue', 'change'],
18
+ props: {
19
+ //是否禁用
20
+ disabled: {
21
+ type: Boolean,
22
+ default: false
23
+ },
24
+ //是否选中
25
+ modelValue: {
26
+ type: [Boolean, Array],
27
+ default: false
28
+ },
29
+ //label文字
30
+ label: {
31
+ type: String,
32
+ default: null
33
+ },
34
+ //值
35
+ value: {
36
+ type: [Object, Number, String, Array],
37
+ default: ''
38
+ },
39
+ //是否圆形
40
+ round: {
41
+ type: Boolean,
42
+ default: false
43
+ },
44
+ //文字位置
45
+ placement: {
46
+ type: String,
47
+ default: 'right',
48
+ validator(value) {
49
+ return ['left', 'right'].includes(value)
50
+ }
51
+ },
52
+ //主题颜色
53
+ color: {
54
+ type: String,
55
+ default: '',
56
+ validator(value) {
57
+ return DapCommon.matchingText(value, 'hex')
58
+ }
59
+ }
60
+ },
61
+ computed: {
62
+ check() {
63
+ if (typeof this.modelValue == 'boolean') {
64
+ return this.modelValue
65
+ }
66
+ if (Array.isArray(this.modelValue)) {
67
+ //数组中是否已包含此复选框的值
68
+ return this.modelValue.some(item => {
69
+ return DapCommon.equal(item, this.value)
70
+ })
71
+ }
72
+ return false
73
+ },
74
+ itemStyle() {
75
+ let style = {}
76
+ if (this.color && this.check && !this.disabled) {
77
+ style.backgroundColor = this.color
78
+ style.borderColor = this.color
79
+ }
80
+ return style
81
+ }
82
+ },
83
+ components: {
84
+ Icon
85
+ },
86
+ methods: {
87
+ change(event) {
88
+ if (Array.isArray(this.modelValue)) {
89
+ let arr = [...this.modelValue]
90
+ //勾选且不包含
91
+ if (event.target.checked && !this.check) {
92
+ arr.push(this.value)
93
+ }
94
+ //取消且包含
95
+ else if (this.check) {
96
+ arr = arr.filter(item => {
97
+ return !DapCommon.equal(item, this.value)
98
+ })
99
+ }
100
+ this.$emit('update:modelValue', arr)
101
+ this.$emit('change', arr)
102
+ } else if (typeof this.modelValue == 'boolean') {
103
+ this.$emit('update:modelValue', event.target.checked)
104
+ this.$emit('change', event.target.checked)
105
+ }
106
+ }
107
+ }
108
+ }
109
+ </script>
110
+
111
+ <style scoped lang="less">
112
+ .editify-checkbox {
113
+ display: inline-flex;
114
+ margin: 0;
115
+ padding: 0;
116
+ position: relative;
117
+ vertical-align: middle;
118
+ justify-content: flex-start;
119
+ align-items: center;
120
+ cursor: pointer;
121
+ user-select: none;
122
+ font-size: @font-size;
123
+
124
+ input[type='checkbox'] {
125
+ width: 0;
126
+ height: 0;
127
+ opacity: 0;
128
+ border: none;
129
+ display: none;
130
+ }
131
+
132
+ .editify-checkbox-item {
133
+ display: inline-flex;
134
+ display: -webkit-inline-flex;
135
+ justify-content: center;
136
+ align-items: center;
137
+ position: relative;
138
+ margin: 0;
139
+ padding: 1px;
140
+ border: 1px solid @border-color;
141
+ background-color: @background;
142
+ border-radius: 2px;
143
+ color: @background;
144
+ transition: border-color 0.1s cubic-bezier(0.71, -0.46, 0.29, 1.46), background-color 0.1s cubic-bezier(0.71, -0.46, 0.29, 1.46), color 0.1s cubic-bezier(0.71, -0.46, 0.29, 1.46);
145
+
146
+ &.round {
147
+ border-radius: 50%;
148
+ }
149
+
150
+ &.checked {
151
+ background-color: @font-color;
152
+ border-color: @font-color;
153
+
154
+ &.reverse {
155
+ background-color: @background;
156
+ color: @font-color-light;
157
+ border-color: @border-color;
158
+ }
159
+ }
160
+
161
+ :deep(.editify-icon) {
162
+ font-size: 18px;
163
+ zoom: 50%;
164
+ }
165
+ }
166
+
167
+ .editify-checkbox-label {
168
+ vertical-align: middle;
169
+ color: @font-color;
170
+ user-select: none;
171
+ line-height: 1;
172
+
173
+ &[data-editify-placement='left'] {
174
+ margin-right: 6px;
175
+ }
176
+
177
+ &[data-editify-placement='right'] {
178
+ margin-left: 6px;
179
+ }
180
+ }
181
+
182
+ &.disabled {
183
+ cursor: not-allowed;
184
+ .editify-checkbox-item,
185
+ .editify-checkbox-item.check {
186
+ background-color: @background-darker;
187
+ border-color: @border-color;
188
+ color: @font-color-disabled;
189
+ }
190
+
191
+ .editify-checkbox-label {
192
+ color: @font-color-disabled;
193
+ }
194
+ }
195
+ }
196
+ </style>
@@ -1,31 +1,31 @@
1
- <template>
2
- <i class="editify-icon" :class="'editify-icon-' + value"></i>
3
- </template>
4
- <script>
5
- export default {
6
- name: 'Icon',
7
- props: {
8
- //图标值
9
- value: {
10
- type: String,
11
- default: ''
12
- }
13
- }
14
- }
15
- </script>
16
- <style lang="less" scoped>
17
- @font-face {
18
- font-family: 'editify-icon';
19
- src: url('../../icon/iconfont.woff?t=1699274556400') format('woff'), url('../../icon/iconfont.ttf?t=1699274556400') format('truetype');
20
- }
21
-
22
- .editify-icon {
23
- font-family: 'editify-icon' !important;
24
- font-size: inherit;
25
- font-style: normal;
26
- -webkit-font-smoothing: antialiased;
27
- -moz-osx-font-smoothing: grayscale;
28
- line-height: 1;
29
- vertical-align: middle;
30
- }
31
- </style>
1
+ <template>
2
+ <i class="editify-icon" :class="'editify-icon-' + value"></i>
3
+ </template>
4
+ <script>
5
+ export default {
6
+ name: 'Icon',
7
+ props: {
8
+ //图标值
9
+ value: {
10
+ type: String,
11
+ default: ''
12
+ }
13
+ }
14
+ }
15
+ </script>
16
+ <style lang="less" scoped>
17
+ @font-face {
18
+ font-family: 'editify-icon';
19
+ src: url('../../icon/iconfont.woff?t=1699274556400') format('woff'), url('../../icon/iconfont.ttf?t=1699274556400') format('truetype');
20
+ }
21
+
22
+ .editify-icon {
23
+ font-family: 'editify-icon' !important;
24
+ font-size: inherit;
25
+ font-style: normal;
26
+ -webkit-font-smoothing: antialiased;
27
+ -moz-osx-font-smoothing: grayscale;
28
+ line-height: 1;
29
+ vertical-align: middle;
30
+ }
31
+ </style>