umy-ui-table 1.2.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.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/lib/button.js +1 -0
  4. package/lib/icon.js +1 -0
  5. package/lib/index.js +1 -0
  6. package/lib/locale/format.js +56 -0
  7. package/lib/locale/index.js +72 -0
  8. package/lib/locale/lang/en.js +123 -0
  9. package/lib/locale/lang/zh-CN.js +119 -0
  10. package/lib/mixins/locale.js +17 -0
  11. package/lib/theme-chalk/base.css +0 -0
  12. package/lib/theme-chalk/button.css +1 -0
  13. package/lib/theme-chalk/fonts/element-icons.ttf +0 -0
  14. package/lib/theme-chalk/fonts/element-icons.woff +0 -0
  15. package/lib/theme-chalk/fonts/iconfont.1785562768224.ttf +0 -0
  16. package/lib/theme-chalk/fonts/iconfont.1785562768224.woff +0 -0
  17. package/lib/theme-chalk/fonts/iconfont.1785562768224.woff2 +0 -0
  18. package/lib/theme-chalk/icon.css +1 -0
  19. package/lib/theme-chalk/index.css +1 -0
  20. package/lib/theme-chalk/u-table-column.css +0 -0
  21. package/lib/theme-chalk/u-table.css +1 -0
  22. package/lib/theme-chalk/ux-grid.css +1 -0
  23. package/lib/theme-chalk/ux-table-column.css +0 -0
  24. package/lib/u-table-column.js +1 -0
  25. package/lib/u-table.js +1 -0
  26. package/lib/umd/locale/en.js +139 -0
  27. package/lib/umd/locale/zh-CN.js +135 -0
  28. package/lib/umy-ui.common.js +1 -0
  29. package/lib/utils/svg.js +33 -0
  30. package/lib/utils/types.js +35 -0
  31. package/lib/utils/util.js +268 -0
  32. package/lib/ux-grid.js +1 -0
  33. package/lib/ux-table-column.js +1 -0
  34. package/package.json +117 -0
  35. package/packages/button/index.js +7 -0
  36. package/packages/button/src/button-group.vue +10 -0
  37. package/packages/button/src/button.vue +166 -0
  38. package/packages/checkbox/index.js +8 -0
  39. package/packages/checkbox/src/checkbox-button.vue +199 -0
  40. package/packages/checkbox/src/checkbox-group.vue +48 -0
  41. package/packages/checkbox/src/checkbox.vue +222 -0
  42. package/packages/checkbox-button/index.js +8 -0
  43. package/packages/checkbox-group/index.js +8 -0
  44. package/packages/icon/index.js +7 -0
  45. package/packages/icon/src/icon.vue +40 -0
  46. package/packages/input/index.js +2 -0
  47. package/packages/input/src/calcTextareaHeight.js +104 -0
  48. package/packages/input/src/input.vue +424 -0
  49. package/packages/option/index.js +2 -0
  50. package/packages/pagination/index.js +2 -0
  51. package/packages/pagination/src/pager.vue +163 -0
  52. package/packages/pagination/src/pagination.js +386 -0
  53. package/packages/scrollbar/index.js +8 -0
  54. package/packages/scrollbar/src/bar.js +92 -0
  55. package/packages/scrollbar/src/main.js +130 -0
  56. package/packages/scrollbar/src/util.js +34 -0
  57. package/packages/select/index.js +2 -0
  58. package/packages/select/src/navigation-mixin.js +54 -0
  59. package/packages/select/src/option-group.vue +60 -0
  60. package/packages/select/src/option.vue +163 -0
  61. package/packages/select/src/select-dropdown.vue +74 -0
  62. package/packages/select/src/select.vue +889 -0
  63. package/packages/table/index.js +8 -0
  64. package/packages/table/src/config.js +123 -0
  65. package/packages/table/src/dropdown.js +28 -0
  66. package/packages/table/src/filter-panel.vue +194 -0
  67. package/packages/table/src/layout-observer.js +68 -0
  68. package/packages/table/src/store/current.js +71 -0
  69. package/packages/table/src/store/expand.js +65 -0
  70. package/packages/table/src/store/helper.js +37 -0
  71. package/packages/table/src/store/index.js +145 -0
  72. package/packages/table/src/store/tree.js +208 -0
  73. package/packages/table/src/store/watcher.js +448 -0
  74. package/packages/table/src/table-body.js +493 -0
  75. package/packages/table/src/table-column.js +381 -0
  76. package/packages/table/src/table-footer.js +174 -0
  77. package/packages/table/src/table-header.js +537 -0
  78. package/packages/table/src/table-layout.js +231 -0
  79. package/packages/table/src/table.vue +741 -0
  80. package/packages/table/src/util.js +256 -0
  81. package/packages/tag/index.js +8 -0
  82. package/packages/tag/src/tag.vue +58 -0
  83. package/packages/tools/directives/mousewheel.js +18 -0
  84. package/packages/tools/directives/repeat-click.js +24 -0
  85. package/packages/tools/locale/format.js +46 -0
  86. package/packages/tools/locale/index.js +48 -0
  87. package/packages/tools/locale/lang/en.js +120 -0
  88. package/packages/tools/locale/lang/zh-CN.js +116 -0
  89. package/packages/tools/mixins/emitter.js +33 -0
  90. package/packages/tools/mixins/focus.js +9 -0
  91. package/packages/tools/mixins/locale.js +9 -0
  92. package/packages/tools/mixins/migrating.js +54 -0
  93. package/packages/tools/transitions/collapse-transition.js +77 -0
  94. package/packages/tools/utils/after-leave.js +27 -0
  95. package/packages/tools/utils/aria-dialog.js +90 -0
  96. package/packages/tools/utils/aria-utils.js +122 -0
  97. package/packages/tools/utils/clickoutside.js +76 -0
  98. package/packages/tools/utils/date-util.js +292 -0
  99. package/packages/tools/utils/date.js +368 -0
  100. package/packages/tools/utils/dom.js +227 -0
  101. package/packages/tools/utils/menu/aria-menubar.js +14 -0
  102. package/packages/tools/utils/menu/aria-menuitem.js +49 -0
  103. package/packages/tools/utils/menu/aria-submenu.js +59 -0
  104. package/packages/tools/utils/merge.js +15 -0
  105. package/packages/tools/utils/popper.js +1276 -0
  106. package/packages/tools/utils/popup/index.js +218 -0
  107. package/packages/tools/utils/popup/popup-manager.js +194 -0
  108. package/packages/tools/utils/resize-event.js +35 -0
  109. package/packages/tools/utils/scroll-into-view.js +27 -0
  110. package/packages/tools/utils/scrollbar-width.js +29 -0
  111. package/packages/tools/utils/shared.js +7 -0
  112. package/packages/tools/utils/svg.js +1 -0
  113. package/packages/tools/utils/types.js +28 -0
  114. package/packages/tools/utils/util.js +241 -0
  115. package/packages/tools/utils/vdom.js +5 -0
  116. package/packages/tools/utils/vue-popper.js +198 -0
  117. package/packages/tooltip/index.js +8 -0
  118. package/packages/tooltip/src/main.js +241 -0
  119. package/packages/u-table/index.js +4 -0
  120. package/packages/u-table/revise-el-table-mixins/index.js +10 -0
  121. package/packages/u-table/revise-el-table-mixins/table-extend.js +60 -0
  122. package/packages/u-table/revise-el-table-mixins/table.mixins.js +261 -0
  123. package/packages/u-table/revise-el-table-mixins/virtual-table-body-render.js +132 -0
  124. package/packages/u-table/src/u-table.vue +248 -0
  125. package/packages/u-table/u-table-mixins/index.js +483 -0
  126. package/packages/u-table/u-table-tree-mixins/methods.js +120 -0
  127. package/packages/u-table/u-table-tree-mixins/u-table-tree-mixins.js +161 -0
  128. package/packages/u-table-column/index.js +8 -0
  129. package/packages/utils/common.js +27 -0
  130. package/packages/ux-grid/index.js +6 -0
  131. package/packages/ux-grid/mixins/index.js +707 -0
  132. package/packages/ux-grid/src/interceptor.js +6 -0
  133. package/packages/ux-grid/src/ux-grid.vue +301 -0
  134. package/packages/ux-table-column/index.js +10 -0
  135. package/tools/locale/format.js +46 -0
  136. package/tools/locale/index.js +54 -0
  137. package/tools/locale/lang/en.js +120 -0
  138. package/tools/locale/lang/zh-CN.js +116 -0
  139. package/tools/mixins/locale.js +9 -0
  140. package/tools/utils/svg.js +1 -0
  141. package/tools/utils/types.js +28 -0
  142. package/tools/utils/util.js +241 -0
@@ -0,0 +1,166 @@
1
+ <template>
2
+ <button
3
+ class="u-button"
4
+ :class="[
5
+ [`icon-${position}`],
6
+ typeStyle,
7
+ sizeStyle,
8
+ plainStyle,
9
+ dangerStyle,
10
+ dashedStyle,
11
+ loadingStyle,
12
+ circleStyle,
13
+ ]"
14
+ :disabled="disabled || loading"
15
+ ref="button"
16
+ :style="roundStyle"
17
+ @click="onClick"
18
+ @focus="focusOn"
19
+ @blur="blurIt"
20
+ >
21
+ <u-icon
22
+ :name="loading ? 'loading' : icon"
23
+ :color="color"
24
+ :style="disabledStyle"
25
+ v-if="icon || loading"
26
+ :class="{ loading: loading }"
27
+ >
28
+ </u-icon>
29
+ <span class="u-button-content" :style="disabledStyle">
30
+ <slot> </slot>
31
+ </span>
32
+ </button>
33
+ </template>
34
+
35
+ <script>
36
+ import Icon from "../../icon/src/icon.vue";
37
+
38
+ export default {
39
+ name: "u-button",
40
+ components: {
41
+ "u-icon": Icon,
42
+ },
43
+ methods: {
44
+ onClick() {
45
+ this.$emit("click");
46
+ this.dangerAnimation();
47
+ },
48
+ dangerAnimation() {
49
+ let arr = this.$refs.button.classList;
50
+ arr.remove("loop");
51
+ arr.add("loop");
52
+ setTimeout(() => {
53
+ arr.remove("loop");
54
+ }, 300);
55
+ },
56
+ focusOn() {},
57
+ blurIt() {},
58
+ },
59
+ computed: {
60
+ disabledStyle() {
61
+ if (this.disabled) return "pointer-events: none;";
62
+ },
63
+ typeStyle() {
64
+ if (!this.type) return;
65
+ return `type-${this.type}`;
66
+ },
67
+ sizeStyle() {
68
+ if (!this.size) return;
69
+ return `size-${this.size}`;
70
+ },
71
+ roundStyle() {
72
+ if (this.round) {
73
+ return "border-radius:21px;";
74
+ }
75
+ },
76
+ circleStyle() {
77
+ if (this.circle) {
78
+ return "circle";
79
+ }
80
+ },
81
+ plainStyle() {
82
+ if (this.plain) {
83
+ return "plain";
84
+ }
85
+ },
86
+ dangerStyle() {
87
+ if (this.danger) {
88
+ return "danger";
89
+ }
90
+ },
91
+ dashedStyle() {
92
+ if (this.dashed) {
93
+ return "dashed";
94
+ }
95
+ },
96
+ loadingStyle() {
97
+ if (this.loading) {
98
+ return "loadingCloak";
99
+ }
100
+ },
101
+ },
102
+ props: {
103
+ icon: {
104
+ type: String,
105
+ },
106
+ disabled: {
107
+ type: Boolean,
108
+ default: false,
109
+ },
110
+ type: {
111
+ type: String,
112
+ validator: (val) =>
113
+ ["primary", "success", "warn", "error", "info"].indexOf(val) > -1,
114
+ },
115
+ plain: {
116
+ type: Boolean,
117
+ default: false,
118
+ },
119
+ dashed: {
120
+ type: Boolean,
121
+ default: false,
122
+ },
123
+ size: {
124
+ type: String,
125
+ default: "medium",
126
+ validator(val) {
127
+ return ["big", "medium", "small", "mini"].indexOf(val) > -1;
128
+ },
129
+ },
130
+ round: {
131
+ type: Boolean,
132
+ default: false,
133
+ },
134
+ color: {
135
+ type: String,
136
+ default() {
137
+ if (this.type) {
138
+ return "white";
139
+ } else {
140
+ return "black";
141
+ }
142
+ },
143
+ },
144
+
145
+ loading: {
146
+ type: Boolean,
147
+ default: false,
148
+ },
149
+ danger: {
150
+ type: Boolean,
151
+ default: false,
152
+ },
153
+ position: {
154
+ type: String,
155
+ default: "left",
156
+ validator(value) {
157
+ return !(value !== "left" && value !== "right");
158
+ },
159
+ },
160
+ circle: {
161
+ type: Boolean,
162
+ default: false,
163
+ },
164
+ },
165
+ };
166
+ </script>
@@ -0,0 +1,8 @@
1
+ import ElCheckbox from './src/checkbox';
2
+
3
+ /* istanbul ignore next */
4
+ ElCheckbox.install = function(Vue) {
5
+ Vue.component(ElCheckbox.name, ElCheckbox);
6
+ };
7
+
8
+ export default ElCheckbox;
@@ -0,0 +1,199 @@
1
+ <template>
2
+ <label
3
+ class="el-checkbox-button"
4
+ :class="[
5
+ size ? 'el-checkbox-button--' + size : '',
6
+ { 'is-disabled': isDisabled },
7
+ { 'is-checked': isChecked },
8
+ { 'is-focus': focus },
9
+ ]"
10
+ role="checkbox"
11
+ :aria-checked="isChecked"
12
+ :aria-disabled="isDisabled"
13
+ >
14
+ <input
15
+ v-if="trueLabel || falseLabel"
16
+ class="el-checkbox-button__original"
17
+ type="checkbox"
18
+ :name="name"
19
+ :disabled="isDisabled"
20
+ :true-value="trueLabel"
21
+ :false-value="falseLabel"
22
+ v-model="model"
23
+ @change="handleChange"
24
+ @focus="focus = true"
25
+ @blur="focus = false">
26
+ <input
27
+ v-else
28
+ class="el-checkbox-button__original"
29
+ type="checkbox"
30
+ :name="name"
31
+ :disabled="isDisabled"
32
+ :value="label"
33
+ v-model="model"
34
+ @change="handleChange"
35
+ @focus="focus = true"
36
+ @blur="focus = false">
37
+
38
+ <span class="el-checkbox-button__inner"
39
+ v-if="$slots.default || label"
40
+ :style="isChecked ? activeStyle : null">
41
+ <slot>{{label}}</slot>
42
+ </span>
43
+
44
+ </label>
45
+ </template>
46
+ <script>
47
+ import Emitter from '../../tools/mixins/emitter';
48
+
49
+ export default {
50
+ name: 'ElCheckboxButton',
51
+
52
+ mixins: [Emitter],
53
+
54
+ inject: {
55
+ elForm: {
56
+ default: ''
57
+ },
58
+ elFormItem: {
59
+ default: ''
60
+ }
61
+ },
62
+
63
+ data() {
64
+ return {
65
+ selfModel: false,
66
+ focus: false,
67
+ isLimitExceeded: false
68
+ };
69
+ },
70
+
71
+ props: {
72
+ value: {},
73
+ label: {},
74
+ disabled: Boolean,
75
+ checked: Boolean,
76
+ name: String,
77
+ trueLabel: [String, Number],
78
+ falseLabel: [String, Number]
79
+ },
80
+ computed: {
81
+ model: {
82
+ get() {
83
+ return this._checkboxGroup
84
+ ? this.store : this.value !== undefined
85
+ ? this.value : this.selfModel;
86
+ },
87
+
88
+ set(val) {
89
+ if (this._checkboxGroup) {
90
+ this.isLimitExceeded = false;
91
+ (this._checkboxGroup.min !== undefined &&
92
+ val.length < this._checkboxGroup.min &&
93
+ (this.isLimitExceeded = true));
94
+
95
+ (this._checkboxGroup.max !== undefined &&
96
+ val.length > this._checkboxGroup.max &&
97
+ (this.isLimitExceeded = true));
98
+
99
+ this.isLimitExceeded === false &&
100
+ this.dispatch('ElCheckboxGroup', 'input', [val]);
101
+ } else if (this.value !== undefined) {
102
+ this.$emit('input', val);
103
+ } else {
104
+ this.selfModel = val;
105
+ }
106
+ }
107
+ },
108
+
109
+ isChecked() {
110
+ if ({}.toString.call(this.model) === '[object Boolean]') {
111
+ return this.model;
112
+ } else if (Array.isArray(this.model)) {
113
+ return this.model.indexOf(this.label) > -1;
114
+ } else if (this.model !== null && this.model !== undefined) {
115
+ return this.model === this.trueLabel;
116
+ }
117
+ },
118
+
119
+ _checkboxGroup() {
120
+ let parent = this.$parent;
121
+ while (parent) {
122
+ if (parent.$options.componentName !== 'ElCheckboxGroup') {
123
+ parent = parent.$parent;
124
+ } else {
125
+ return parent;
126
+ }
127
+ }
128
+ return false;
129
+ },
130
+
131
+ store() {
132
+ return this._checkboxGroup ? this._checkboxGroup.value : this.value;
133
+ },
134
+
135
+ activeStyle() {
136
+ return {
137
+ backgroundColor: this._checkboxGroup.fill || '',
138
+ borderColor: this._checkboxGroup.fill || '',
139
+ color: this._checkboxGroup.textColor || '',
140
+ 'box-shadow': '-1px 0 0 0 ' + this._checkboxGroup.fill
141
+
142
+ };
143
+ },
144
+
145
+ _elFormItemSize() {
146
+ return (this.elFormItem || {}).elFormItemSize;
147
+ },
148
+
149
+ size() {
150
+ return this._checkboxGroup.checkboxGroupSize || this._elFormItemSize || (this.$ELEMENT || {}).size;
151
+ },
152
+
153
+ /* used to make the isDisabled judgment under max/min props */
154
+ isLimitDisabled() {
155
+ const { max, min } = this._checkboxGroup;
156
+ return !!(max || min) &&
157
+ (this.model.length >= max && !this.isChecked) ||
158
+ (this.model.length <= min && this.isChecked);
159
+ },
160
+
161
+ isDisabled() {
162
+ return this._checkboxGroup
163
+ ? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled
164
+ : this.disabled || (this.elForm || {}).disabled;
165
+ }
166
+ },
167
+ methods: {
168
+ addToStore() {
169
+ if (
170
+ Array.isArray(this.model) &&
171
+ this.model.indexOf(this.label) === -1
172
+ ) {
173
+ this.model.push(this.label);
174
+ } else {
175
+ this.model = this.trueLabel || true;
176
+ }
177
+ },
178
+ handleChange(ev) {
179
+ if (this.isLimitExceeded) return;
180
+ let value;
181
+ if (ev.target.checked) {
182
+ value = this.trueLabel === undefined ? true : this.trueLabel;
183
+ } else {
184
+ value = this.falseLabel === undefined ? false : this.falseLabel;
185
+ }
186
+ this.$emit('change', value, ev);
187
+ this.$nextTick(() => {
188
+ if (this._checkboxGroup) {
189
+ this.dispatch('ElCheckboxGroup', 'change', [this._checkboxGroup.value]);
190
+ }
191
+ });
192
+ }
193
+ },
194
+
195
+ created() {
196
+ this.checked && this.addToStore();
197
+ }
198
+ };
199
+ </script>
@@ -0,0 +1,48 @@
1
+ <script>
2
+ import Emitter from '../../tools/mixins/emitter';
3
+
4
+ export default {
5
+ name: 'ElCheckboxGroup',
6
+
7
+ componentName: 'ElCheckboxGroup',
8
+
9
+ mixins: [Emitter],
10
+
11
+ inject: {
12
+ elFormItem: {
13
+ default: ''
14
+ }
15
+ },
16
+
17
+ props: {
18
+ value: {},
19
+ disabled: Boolean,
20
+ min: Number,
21
+ max: Number,
22
+ size: String,
23
+ fill: String,
24
+ textColor: String
25
+ },
26
+
27
+ computed: {
28
+ _elFormItemSize() {
29
+ return (this.elFormItem || {}).elFormItemSize;
30
+ },
31
+ checkboxGroupSize() {
32
+ return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
33
+ }
34
+ },
35
+
36
+ watch: {
37
+ value(value) {
38
+ this.dispatch('ElFormItem', 'el.form.change', [value]);
39
+ }
40
+ }
41
+ };
42
+ </script>
43
+
44
+ <template>
45
+ <div class="el-checkbox-group" role="group" aria-label="checkbox-group">
46
+ <slot></slot>
47
+ </div>
48
+ </template>
@@ -0,0 +1,222 @@
1
+ <template>
2
+ <label
3
+ class="el-checkbox"
4
+ :class="[
5
+ border && checkboxSize ? 'el-checkbox--' + checkboxSize : '',
6
+ { 'is-disabled': isDisabled },
7
+ { 'is-bordered': border },
8
+ { 'is-checked': isChecked }
9
+ ]"
10
+ :id="id"
11
+ >
12
+ <span class="el-checkbox__input"
13
+ :class="{
14
+ 'is-disabled': isDisabled,
15
+ 'is-checked': isChecked,
16
+ 'is-indeterminate': indeterminate,
17
+ 'is-focus': focus
18
+ }"
19
+ :tabindex="indeterminate ? 0 : false"
20
+ :role="indeterminate ? 'checkbox' : false"
21
+ :aria-checked="indeterminate ? 'mixed' : false"
22
+ >
23
+ <span class="el-checkbox__inner"></span>
24
+ <input
25
+ v-if="trueLabel || falseLabel"
26
+ class="el-checkbox__original"
27
+ type="checkbox"
28
+ :aria-hidden="indeterminate ? 'true' : 'false'"
29
+ :name="name"
30
+ :disabled="isDisabled"
31
+ :true-value="trueLabel"
32
+ :false-value="falseLabel"
33
+ v-model="model"
34
+ @change="handleChange"
35
+ @focus="focus = true"
36
+ @blur="focus = false">
37
+ <input
38
+ v-else
39
+ class="el-checkbox__original"
40
+ type="checkbox"
41
+ :aria-hidden="indeterminate ? 'true' : 'false'"
42
+ :disabled="isDisabled"
43
+ :value="label"
44
+ :name="name"
45
+ v-model="model"
46
+ @change="handleChange"
47
+ @focus="focus = true"
48
+ @blur="focus = false">
49
+ </span>
50
+ <span class="el-checkbox__label" v-if="$slots.default || label">
51
+ <slot></slot>
52
+ <template v-if="!$slots.default">{{label}}</template>
53
+ </span>
54
+ </label>
55
+ </template>
56
+ <script>
57
+ import Emitter from '../../tools/mixins/emitter';
58
+
59
+ export default {
60
+ name: 'ElCheckbox',
61
+
62
+ mixins: [Emitter],
63
+
64
+ inject: {
65
+ elForm: {
66
+ default: ''
67
+ },
68
+ elFormItem: {
69
+ default: ''
70
+ }
71
+ },
72
+
73
+ componentName: 'ElCheckbox',
74
+
75
+ data() {
76
+ return {
77
+ selfModel: false,
78
+ focus: false,
79
+ isLimitExceeded: false
80
+ };
81
+ },
82
+
83
+ computed: {
84
+ model: {
85
+ get() {
86
+ return this.isGroup
87
+ ? this.store : this.value !== undefined
88
+ ? this.value : this.selfModel;
89
+ },
90
+
91
+ set(val) {
92
+ if (this.isGroup) {
93
+ this.isLimitExceeded = false;
94
+ (this._checkboxGroup.min !== undefined &&
95
+ val.length < this._checkboxGroup.min &&
96
+ (this.isLimitExceeded = true));
97
+
98
+ (this._checkboxGroup.max !== undefined &&
99
+ val.length > this._checkboxGroup.max &&
100
+ (this.isLimitExceeded = true));
101
+
102
+ this.isLimitExceeded === false &&
103
+ this.dispatch('ElCheckboxGroup', 'input', [val]);
104
+ } else {
105
+ this.$emit('input', val);
106
+ this.selfModel = val;
107
+ }
108
+ }
109
+ },
110
+
111
+ isChecked() {
112
+ if ({}.toString.call(this.model) === '[object Boolean]') {
113
+ return this.model;
114
+ } else if (Array.isArray(this.model)) {
115
+ return this.model.indexOf(this.label) > -1;
116
+ } else if (this.model !== null && this.model !== undefined) {
117
+ return this.model === this.trueLabel;
118
+ }
119
+ },
120
+
121
+ isGroup() {
122
+ let parent = this.$parent;
123
+ while (parent) {
124
+ if (parent.$options.componentName !== 'ElCheckboxGroup') {
125
+ parent = parent.$parent;
126
+ } else {
127
+ this._checkboxGroup = parent;
128
+ return true;
129
+ }
130
+ }
131
+ return false;
132
+ },
133
+
134
+ store() {
135
+ return this._checkboxGroup ? this._checkboxGroup.value : this.value;
136
+ },
137
+
138
+ /* used to make the isDisabled judgment under max/min props */
139
+ isLimitDisabled() {
140
+ const { max, min } = this._checkboxGroup;
141
+ return !!(max || min) &&
142
+ (this.model.length >= max && !this.isChecked) ||
143
+ (this.model.length <= min && this.isChecked);
144
+ },
145
+
146
+ isDisabled() {
147
+ return this.isGroup
148
+ ? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled
149
+ : this.disabled || (this.elForm || {}).disabled;
150
+ },
151
+
152
+ _elFormItemSize() {
153
+ return (this.elFormItem || {}).elFormItemSize;
154
+ },
155
+
156
+ checkboxSize() {
157
+ const temCheckboxSize = this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
158
+ return this.isGroup
159
+ ? this._checkboxGroup.checkboxGroupSize || temCheckboxSize
160
+ : temCheckboxSize;
161
+ }
162
+ },
163
+
164
+ props: {
165
+ value: {},
166
+ label: {},
167
+ indeterminate: Boolean,
168
+ disabled: Boolean,
169
+ checked: Boolean,
170
+ name: String,
171
+ trueLabel: [String, Number],
172
+ falseLabel: [String, Number],
173
+ id: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/
174
+ controls: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/
175
+ border: Boolean,
176
+ size: String
177
+ },
178
+
179
+ methods: {
180
+ addToStore() {
181
+ if (
182
+ Array.isArray(this.model) &&
183
+ this.model.indexOf(this.label) === -1
184
+ ) {
185
+ this.model.push(this.label);
186
+ } else {
187
+ this.model = this.trueLabel || true;
188
+ }
189
+ },
190
+ handleChange(ev) {
191
+ if (this.isLimitExceeded) return;
192
+ let value;
193
+ if (ev.target.checked) {
194
+ value = this.trueLabel === undefined ? true : this.trueLabel;
195
+ } else {
196
+ value = this.falseLabel === undefined ? false : this.falseLabel;
197
+ }
198
+ this.$emit('change', value, ev);
199
+ this.$nextTick(() => {
200
+ if (this.isGroup) {
201
+ this.dispatch('ElCheckboxGroup', 'change', [this._checkboxGroup.value]);
202
+ }
203
+ });
204
+ }
205
+ },
206
+
207
+ created() {
208
+ this.checked && this.addToStore();
209
+ },
210
+ mounted() { // 为indeterminate元素 添加aria-controls 属性
211
+ if (this.indeterminate) {
212
+ this.$el.setAttribute('aria-controls', this.controls);
213
+ }
214
+ },
215
+
216
+ watch: {
217
+ value(value) {
218
+ this.dispatch('ElFormItem', 'el.form.change', value);
219
+ }
220
+ }
221
+ };
222
+ </script>
@@ -0,0 +1,8 @@
1
+ import ElCheckboxButton from '../checkbox/src/checkbox-button.vue';
2
+
3
+ /* istanbul ignore next */
4
+ ElCheckboxButton.install = function(Vue) {
5
+ Vue.component(ElCheckboxButton.name, ElCheckboxButton);
6
+ };
7
+
8
+ export default ElCheckboxButton;
@@ -0,0 +1,8 @@
1
+ import ElCheckboxGroup from '../checkbox/src/checkbox-group.vue';
2
+
3
+ /* istanbul ignore next */
4
+ ElCheckboxGroup.install = function(Vue) {
5
+ Vue.component(ElCheckboxGroup.name, ElCheckboxGroup);
6
+ };
7
+
8
+ export default ElCheckboxGroup;
@@ -0,0 +1,7 @@
1
+ import UIcon from './src/icon.vue';
2
+
3
+ UIcon.install = function(Vue) {
4
+ Vue.component(UIcon.name, UIcon);
5
+ };
6
+
7
+ export default UIcon
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <svg
3
+ class="u-icon"
4
+ @click="$emit('click', $event)"
5
+ :style="{ fill: `${color}`, fontSize: fontWidth }"
6
+ :class="{ loading: loading }"
7
+ >
8
+ <use :xlink:href="`#icon-${name}`"></use>
9
+ </svg>
10
+ </template>
11
+
12
+ <script>
13
+ import "../../tools/utils/svg.js";
14
+ import { isString, isNumber } from "../../tools/utils/types";
15
+
16
+ export default {
17
+ name: "u-icon",
18
+ props: {
19
+ name,
20
+ fontSize: {
21
+ type: Number | String,
22
+ default: "1em ",
23
+ },
24
+ color: {
25
+ type: String,
26
+ },
27
+ loading: {
28
+ type: Boolean,
29
+ default: false,
30
+ },
31
+ },
32
+ computed: {
33
+ fontWidth() {
34
+ if (isString(this.fontSize)) return this.fontSize;
35
+ if (isNumber(this.fontWidth)) return this.fontSize + "px";
36
+ return new Error("fontSize must be Number or String");
37
+ },
38
+ },
39
+ };
40
+ </script>