kui-vue 3.3.11 → 3.3.12

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 (51) hide show
  1. package/components/_tool/clone.js +1 -2
  2. package/components/_tool/utils.js +3 -3
  3. package/components/alert/styles/index.less +2 -2
  4. package/components/avatar/AvatarGroup.jsx +2 -2
  5. package/components/backtop/styles/index.less +44 -47
  6. package/components/base/drop.jsx +3 -2
  7. package/components/base/pop.jsx +34 -20
  8. package/components/button/button.jsx +5 -11
  9. package/components/button/index.js +1 -8
  10. package/components/collapse/styles/index.less +3 -16
  11. package/components/colorPicker/colorpicker.jsx +1 -1
  12. package/components/colorPicker/styles/index.less +6 -18
  13. package/components/datePicker/datecalendar.jsx +1 -1
  14. package/components/datePicker/styles/datepicker.less +4 -14
  15. package/components/drawer/drawer.jsx +1 -1
  16. package/components/dropdown/demo/base.md +1 -1
  17. package/components/dropdown/demo/rightmenu.md +5 -5
  18. package/components/dropdown/dropdown.jsx +11 -3
  19. package/components/dropdown/styles/index.less +31 -13
  20. package/components/form/form.jsx +1 -1
  21. package/components/form/styles/index.less +3 -14
  22. package/components/fragment/component.js +98 -0
  23. package/components/fragment/frag.js +362 -0
  24. package/components/fragment/fragment.js +19 -0
  25. package/components/fragment/index.js +104 -0
  26. package/components/fragment/ssr.js +4 -0
  27. package/components/icon/demo/search.vue +1 -1
  28. package/components/image/styles/index.less +41 -17
  29. package/components/index.js +2 -2
  30. package/components/menu/menuitem.jsx +12 -7
  31. package/components/menu/styles/index.less +189 -202
  32. package/components/menu/submenu.jsx +106 -37
  33. package/components/message/styles/index.less +11 -14
  34. package/components/modal/index.js +1 -1
  35. package/components/modal/modal.jsx +2 -2
  36. package/components/modal/styles/index.less +227 -221
  37. package/components/notice/styles/index.less +19 -5
  38. package/components/popconfirm/styles/index.less +33 -14
  39. package/components/poptip/styles/index.less +3 -14
  40. package/components/radio/button.jsx +1 -1
  41. package/components/select/styles/index.less +8 -31
  42. package/components/table/table.jsx +1 -1
  43. package/components/tabs/styles/index.less +3 -2
  44. package/components/tag/styles/index.less +3 -15
  45. package/components/tooltip/styles/index.less +45 -16
  46. package/components/tooltip/tooltip.jsx +3 -3
  47. package/components/tree/node.jsx +1 -1
  48. package/dist/k-ui.css +2 -2
  49. package/dist/k-ui.js +2 -2
  50. package/package.json +3 -3
  51. package/components/menu/styles/dropmenu.less +0 -119
@@ -1,20 +1,27 @@
1
1
  @import '../../styles/var.less';
2
+
2
3
  .k-dropdown {
3
4
  font-size: 12px;
4
5
  line-height: 1.5;
5
6
  position: absolute;
6
7
  z-index: 1001;
8
+
7
9
  .k-dropdown-content {
8
10
  background: var(--kui-color-control-10);
9
11
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
10
12
  border-radius: var(--kui-border-radius);
11
13
  }
14
+
12
15
  .k-dropdown-menu {
13
16
  min-width: 150px;
14
17
  }
15
18
  }
16
19
 
17
20
  .k-dropdown-has-arrow {
21
+ .k-dropdown-content {
22
+ box-shadow: none;
23
+ }
24
+
18
25
  .k-dropdown-arrow {
19
26
  position: absolute;
20
27
  box-sizing: border-box;
@@ -23,6 +30,7 @@
23
30
  height: 7px;
24
31
  color: var(--kui-color-control-10);
25
32
  }
33
+
26
34
  // &[k-placement^=top] {
27
35
  // margin-top: -3px;
28
36
  // }
@@ -34,97 +42,116 @@
34
42
  bottom: 6px;
35
43
  height: 7px;
36
44
  }
45
+
37
46
  .k-dropdown-body {
38
47
  margin-bottom: 12px;
39
48
  }
40
49
  }
50
+
41
51
  &[k-placement=top] {
42
52
  .k-dropdown-arrow {
43
53
  left: 50%;
44
54
  transform: translateX(-50%);
45
55
  }
46
56
  }
57
+
47
58
  &[k-placement=top-right] {
48
59
  .k-dropdown-arrow {
49
60
  right: 12px;
50
61
  }
51
62
  }
63
+
52
64
  &[k-placement=top-left] {
53
65
  .k-dropdown-arrow {
54
66
  left: 12px;
55
67
  }
56
68
  }
69
+
57
70
  &[k-placement^=bottom] {
58
71
  .k-dropdown-arrow {
59
72
  top: 6px;
60
73
  height: 7px;
61
74
  transform: rotate(180deg);
62
75
  }
76
+
63
77
  .k-dropdown-body {
64
78
  margin-top: 12px;
65
79
  }
66
80
  }
81
+
67
82
  &[k-placement=bottom] {
68
83
  .k-dropdown-arrow {
69
84
  left: 50%;
70
85
  transform: translateX(-50%) rotate(180deg);
71
86
  }
72
87
  }
88
+
73
89
  &[k-placement=bottom-left] {
74
90
  .k-dropdown-arrow {
75
91
  left: 10px;
76
92
  }
77
93
  }
94
+
78
95
  &[k-placement=bottom-right] {
79
96
  .k-dropdown-arrow {
80
97
  right: 10px;
81
98
  }
82
99
  }
100
+
83
101
  &[k-placement^=left] {
84
102
  .k-dropdown-arrow {
85
103
  right: 8px;
86
104
  box-shadow: 3px -3px 7px rgba(0, 0, 0, 0.07);
87
105
  }
106
+
88
107
  .k-dropdown-body {
89
108
  margin-right: 12px;
90
109
  }
91
110
  }
111
+
92
112
  &[k-placement=left] {
93
113
  .k-dropdown-arrow {
94
114
  top: 50%;
95
115
  transform: translateY(-50%);
96
116
  }
97
117
  }
118
+
98
119
  &[k-placement=left-bottom] {
99
120
  .k-dropdown-arrow {
100
121
  bottom: 10px;
101
122
  }
102
123
  }
124
+
103
125
  &[k-placement=left-top] {
104
126
  .k-dropdown-arrow {
105
127
  top: 10px;
106
128
  }
107
129
  }
130
+
108
131
  &[k-placement^=right] {
109
132
  .k-dropdown-arrow {
110
133
  left: 8px;
111
134
  box-shadow: -3px 3px 7px rgba(0, 0, 0, 0.07);
112
135
  }
136
+
113
137
  .k-dropdown-body {
114
138
  margin-left: 12px;
115
139
  }
116
140
  }
141
+
117
142
  &[k-placement=right] {
118
143
  .k-dropdown-arrow {
119
144
  top: 50%;
120
145
  transform: translateY(-50%);
121
146
  }
122
147
  }
148
+
123
149
  &[k-placement=right-top] {
124
150
  .k-dropdown-arrow {
125
151
  top: 10px;
126
152
  }
127
153
  }
154
+
128
155
  &[k-placement=right-bottom] {
129
156
  .k-dropdown-arrow {
130
157
  bottom: 10px;
@@ -132,32 +159,23 @@
132
159
  }
133
160
  }
134
161
 
135
- @keyframes dropdown-zoom-in {
162
+ @keyframes dropdown-zoom {
136
163
  0% {
137
164
  transform: scaleY(0);
138
165
  opacity: 0;
139
166
  }
167
+
140
168
  100% {
141
169
  transform: scaleY(1);
142
170
  opacity: 1;
143
171
  }
144
172
  }
145
173
 
146
- @keyframes dropdown-zoom-out {
147
- 0% {
148
- transform: scaleY(1);
149
- opacity: 1;
150
- }
151
- 100% {
152
- transform: scaleY(0);
153
- opacity: 0;
154
- }
155
- }
156
174
 
157
175
  .k-dropdown-fade-enter-active {
158
- animation: dropdown-zoom-in .3s;
176
+ animation: dropdown-zoom .3s;
159
177
  }
160
178
 
161
179
  .k-dropdown-fade-leave-active {
162
- animation: dropdown-zoom-out .3s;
180
+ animation: dropdown-zoom .3s reverse;
163
181
  }
@@ -130,7 +130,7 @@ export default {
130
130
  submit(e) {
131
131
  e && e.preventDefault()
132
132
  this.validate((valid) => {
133
- let model = JSON.parse(JSON.stringify(this.model))
133
+ let model = JSON.parse(JSON.stringify(this.model || '{}'))
134
134
  this.$emit('submit', { valid, model })
135
135
  })
136
136
  },
@@ -187,7 +187,7 @@
187
187
  }
188
188
  }
189
189
 
190
- @keyframes k-form-item-fade-in {
190
+ @keyframes k-form-item-fade {
191
191
  0% {
192
192
  transform: scaleY(0);
193
193
  opacity: 0;
@@ -199,22 +199,11 @@
199
199
  }
200
200
  }
201
201
 
202
- @keyframes k-form-item-fade-out {
203
- 0% {
204
- transform: scaleY(1);
205
- opacity: 1;
206
- }
207
-
208
- 100% {
209
- transform: scaleY(0);
210
- opacity: 0;
211
- }
212
- }
213
202
 
214
203
  .k-form-item-fade-enter-active {
215
- animation: k-form-item-fade-in .3s;
204
+ animation: k-form-item-fade .3s;
216
205
  }
217
206
 
218
207
  .k-form-item-fade-leave-active {
219
- animation: k-form-item-fade-out .3s;
208
+ animation: k-form-item-fade .3s reverse;
220
209
  }
@@ -0,0 +1,98 @@
1
+ export const freeze = (object, property, value) => {
2
+ Object.defineProperty(object, property, {
3
+ configurable: true,
4
+ get() { return value; },
5
+ set(v) { console.warn(`tried to set frozen property ${property} with ${v}`) }
6
+ });
7
+ };
8
+
9
+ export const unfreeze = (object, property, value = null) => {
10
+ Object.defineProperty(object, property, {
11
+ configurable: true,
12
+ writable: true,
13
+ value: value
14
+ });
15
+ };
16
+
17
+ export default {
18
+ abstract: true,
19
+ name: 'Fragment',
20
+
21
+ props: {
22
+ name: {
23
+ type: String,
24
+ default: () => Math.floor(Date.now() * Math.random()).toString(16)
25
+ },
26
+ html: {
27
+ type: String,
28
+ default: null
29
+ }
30
+ },
31
+
32
+ mounted() {
33
+ const container = this.$el
34
+ const parent = container.parentNode
35
+
36
+ container.__isFragment = true
37
+ container.__isMounted = false
38
+
39
+ const head = document.createComment(`fragment#${this.name}#head`)
40
+ const tail = document.createComment(`fragment#${this.name}#tail`)
41
+
42
+ container.__head = head
43
+ container.__tail = tail
44
+
45
+ // use document fragment to improve efficiency
46
+ let tpl = document.createDocumentFragment()
47
+ tpl.appendChild(head)
48
+
49
+ Array.from(container.childNodes)
50
+ .forEach(node => {
51
+ // container.appendChild(node, true)
52
+ let notFrChild = !node.hasOwnProperty('__isFragmentChild__')
53
+ tpl.appendChild(node)
54
+ if (notFrChild) {
55
+ freeze(node, 'parentNode', container)
56
+ freeze(node, '__isFragmentChild__', true)
57
+ }
58
+ })
59
+
60
+ tpl.appendChild(tail)
61
+
62
+ // embed html
63
+ if (this.html) {
64
+ let template = document.createElement('template')
65
+ template.innerHTML = this.html
66
+ // copy elements over
67
+ Array.from(template.content.childNodes).forEach(node => {
68
+ tpl.appendChild(node)
69
+ })
70
+ }
71
+
72
+ let next = container.nextSibling
73
+ parent.insertBefore(tpl, container, true)
74
+ parent.removeChild(container)
75
+ freeze(container, 'parentNode', parent)
76
+ freeze(container, 'nextSibling', next)
77
+ if (next)
78
+ freeze(next, 'previousSibling', container)
79
+
80
+ container.__isMounted = true
81
+ },
82
+
83
+ render(h) {
84
+ const children = this.$slots.default
85
+
86
+ // add fragment attribute on the children
87
+ if (children && children.length)
88
+ children.forEach(child =>
89
+ child.data = { ...child.data, attrs: { fragment: this.name, ...(child.data || {}).attrs } }
90
+ )
91
+
92
+ return h(
93
+ "div",
94
+ { attrs: { fragment: this.name } },
95
+ children
96
+ )
97
+ }
98
+ };
@@ -0,0 +1,362 @@
1
+ const $placeholder = Symbol();
2
+ const $fakeParent = Symbol();
3
+ const $nextSiblingPatched = Symbol();
4
+ const $childNodesPatched = Symbol();
5
+
6
+ const isFrag = node => 'frag' in node;
7
+
8
+ const parentNodeDescriptor = {
9
+ get() {
10
+ return this[$fakeParent] || this.parentElement;
11
+ },
12
+ configurable: true,
13
+ };
14
+
15
+ const patchParentNode = (
16
+ node,
17
+ fakeParent,
18
+ ) => {
19
+ if ($fakeParent in node) {
20
+ return;
21
+ }
22
+
23
+ node[$fakeParent] = fakeParent;
24
+
25
+ Object.defineProperty(node, 'parentNode', parentNodeDescriptor);
26
+ };
27
+
28
+ const nextSiblingDescriptor = {
29
+ get() {
30
+ const { childNodes } = this.parentNode;
31
+ const index = childNodes.indexOf(this);
32
+ if (index > -1) {
33
+ return childNodes[index + 1] || null;
34
+ }
35
+
36
+ return null;
37
+ },
38
+ };
39
+
40
+ const patchNextSibling = (node) => {
41
+ if ($nextSiblingPatched in node) {
42
+ return;
43
+ }
44
+
45
+ node[$nextSiblingPatched] = true;
46
+
47
+ Object.defineProperty(
48
+ node,
49
+ 'nextSibling',
50
+ nextSiblingDescriptor,
51
+ );
52
+ };
53
+
54
+ const getTopFragment = (node, fromParent) => {
55
+ while (node.parentNode !== fromParent) {
56
+ const { parentNode } = node;
57
+ if (parentNode) {
58
+ node = parentNode;
59
+ }
60
+ }
61
+
62
+ return node;
63
+ };
64
+
65
+ let getChildNodes;
66
+
67
+ // For a parent to get fake children
68
+ const getChildNodesWithFragments = (node) => {
69
+ // In case SSR
70
+ if (!getChildNodes) {
71
+ const childNodesDescriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'childNodes');
72
+ getChildNodes = childNodesDescriptor.get;
73
+ }
74
+
75
+ const realChildNodes = getChildNodes.apply(node);
76
+ const childNodes = Array.from(realChildNodes).map(
77
+ childNode => getTopFragment(childNode, node),
78
+ );
79
+
80
+ // De-dupe child nodes that point to the same fragment
81
+ return childNodes.filter(
82
+ (childNode, index) => childNode !== childNodes[index - 1],
83
+ );
84
+ };
85
+
86
+ const childNodesDescriptor = {
87
+ get() {
88
+ return this.frag || getChildNodesWithFragments(this);
89
+ },
90
+ };
91
+
92
+ const firstChildDescriptor = {
93
+ get() {
94
+ return this.childNodes[0] || null;
95
+ },
96
+ };
97
+
98
+ function hasChildNodes() {
99
+ return this.childNodes.length > 0;
100
+ }
101
+
102
+ const patchChildNodes = (node) => {
103
+ if ($childNodesPatched in node) {
104
+ return;
105
+ }
106
+
107
+ node[$childNodesPatched] = true;
108
+
109
+ Object.defineProperties(node, {
110
+ childNodes: childNodesDescriptor,
111
+ firstChild: firstChildDescriptor,
112
+ });
113
+
114
+ node.hasChildNodes = hasChildNodes;
115
+ };
116
+
117
+ /**
118
+ * Methods overwritten for vue-frag to use internally
119
+ */
120
+
121
+ // This works recursively. If child is also a frag, it automatically goes another level down
122
+ function before(...nodes) {
123
+ this.frag[0].before(...nodes);
124
+ }
125
+
126
+ function remove() {
127
+ // If the fragment is being removed, all children, including placeholder should be removed
128
+ const { frag } = this;
129
+ const removed = frag.splice(0, frag.length);
130
+ removed.forEach((node) => {
131
+ node.remove();
132
+ });
133
+ }
134
+
135
+ // FlatMap polyfill
136
+ const getFragmentLeafNodes = children => Array.prototype.concat(
137
+ ...children.map(childNode => (
138
+ isFrag(childNode)
139
+ ? getFragmentLeafNodes(childNode.frag)
140
+ : childNode
141
+ )),
142
+ );
143
+
144
+ const addPlaceholder = (
145
+ node,
146
+ insertBeforeNode,
147
+ ) => {
148
+ const placeholder = node[$placeholder];
149
+
150
+ insertBeforeNode.before(placeholder);
151
+ patchParentNode(placeholder, node);
152
+ node.frag.unshift(placeholder);
153
+ };
154
+
155
+ function removeChild(node) {
156
+ if (isFrag(this)) {
157
+ // If this is a fragment element
158
+ const hasChildInFragment = this.frag.indexOf(node);
159
+ if (hasChildInFragment > -1) {
160
+ const [removedNode] = this.frag.splice(hasChildInFragment, 1);
161
+
162
+ // If last node, insert placeholder
163
+ if (this.frag.length === 0) {
164
+ addPlaceholder(this, removedNode);
165
+ }
166
+
167
+ node.remove();
168
+ }
169
+ } else {
170
+ // For frag parent
171
+ const children = getChildNodesWithFragments(this);
172
+ const hasChild = children.indexOf(node);
173
+
174
+ if (hasChild > -1) {
175
+ node.remove();
176
+ }
177
+ }
178
+
179
+ return node;
180
+ }
181
+
182
+ function insertBefore(
183
+ insertNode,
184
+ insertBeforeNode,
185
+ ) {
186
+ // Should this be leaf nodes?
187
+ const insertNodes = insertNode.frag || [insertNode];
188
+
189
+ // If this element is a fragment, insert nodes in virtual fragment
190
+ if (isFrag(this)) {
191
+ /**
192
+ * In this case, it's impossible for insertNode.frag to be defined
193
+ * aka insertNode is always a single node
194
+ */
195
+ if (
196
+ // Parent already patched
197
+ insertNode[$fakeParent] === this
198
+
199
+ // Previously inserted (reinserted via keep-alive)
200
+ && insertNode.parentElement
201
+ ) {
202
+ return insertNode;
203
+ }
204
+
205
+ const { frag } = this;
206
+
207
+ if (insertBeforeNode) {
208
+ const index = frag.indexOf(insertBeforeNode);
209
+ if (index > -1) {
210
+ frag.splice(index, 0, ...insertNodes);
211
+ insertBeforeNode.before(...insertNodes);
212
+ }
213
+ } else {
214
+ const lastNode = frag[frag.length - 1];
215
+ frag.push(...insertNodes);
216
+ lastNode.after(...insertNodes);
217
+ }
218
+
219
+ removePlaceholder(this);
220
+ } else if (insertBeforeNode) {
221
+ if (this.childNodes.includes(insertBeforeNode)) {
222
+ insertBeforeNode.before(...insertNodes);
223
+ }
224
+ } else {
225
+ this.append(...insertNodes);
226
+ }
227
+
228
+ insertNodes.forEach((node) => {
229
+ patchParentNode(node, this);
230
+ });
231
+
232
+ const lastNode = insertNodes[insertNodes.length - 1];
233
+ patchNextSibling(lastNode);
234
+
235
+ return insertNode;
236
+ }
237
+
238
+ function appendChild(node) {
239
+ if (
240
+ // Parent already patched
241
+ node[$fakeParent] === this
242
+
243
+ // Previously inserted (reinserted via keep-alive)
244
+ && node.parentElement
245
+ ) {
246
+ return node;
247
+ }
248
+
249
+ const { frag } = this;
250
+ const lastChild = frag[frag.length - 1];
251
+
252
+ lastChild.after(node);
253
+ patchParentNode(node, this);
254
+
255
+ removePlaceholder(this);
256
+
257
+ frag.push(node);
258
+
259
+ return node;
260
+ }
261
+
262
+ const removePlaceholder = (node) => {
263
+ const placeholder = node[$placeholder];
264
+ if (node.frag[0] === placeholder) {
265
+ node.frag.shift();
266
+ placeholder.remove();
267
+ }
268
+ };
269
+
270
+ const innerHTMLDescriptor = {
271
+ set(htmlString) {
272
+ // If it has childrem (non-placeholder), remove them
273
+ if (this.frag[0] !== this[$placeholder]) {
274
+ this.frag.slice().forEach(
275
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
276
+ child => this.removeChild(child),
277
+ );
278
+ }
279
+
280
+ if (htmlString) {
281
+ const domify = document.createElement('div');
282
+ domify.innerHTML = htmlString;
283
+
284
+ // Array.from makes a copy of the NodeList, which is live updating as we appendChild
285
+ Array.from(domify.childNodes).forEach((node) => {
286
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
287
+ this.appendChild(node);
288
+ });
289
+ }
290
+ },
291
+ get() {
292
+ return '';
293
+ },
294
+ };
295
+
296
+ const frag = {
297
+ inserted(element) {
298
+ const {
299
+ parentNode,
300
+ nextSibling,
301
+ previousSibling,
302
+ } = element;
303
+
304
+ const childNodes = Array.from(element.childNodes);
305
+
306
+ // If there are no children, insert a comment placeholder to mark the location
307
+ const placeholder = document.createComment('');
308
+
309
+ if (childNodes.length === 0) {
310
+ childNodes.push(placeholder);
311
+ }
312
+
313
+ element.frag = childNodes;
314
+ element[$placeholder] = placeholder;
315
+
316
+ // Swap element with children (or placeholder)
317
+ const fragment = document.createDocumentFragment();
318
+ fragment.append(...getFragmentLeafNodes(childNodes));
319
+ element.replaceWith(fragment);
320
+
321
+ childNodes.forEach((node) => {
322
+ patchParentNode(node, element);
323
+ patchNextSibling(node);
324
+ });
325
+
326
+ patchChildNodes(element);
327
+
328
+ Object.assign(element, {
329
+ remove,
330
+ appendChild,
331
+ insertBefore,
332
+ removeChild,
333
+ before,
334
+ });
335
+
336
+ Object.defineProperty(element, 'innerHTML', innerHTMLDescriptor);
337
+
338
+ if (parentNode) {
339
+ Object.assign(parentNode, {
340
+ removeChild,
341
+ insertBefore,
342
+ });
343
+ patchParentNode(element, parentNode);
344
+ patchChildNodes(parentNode);
345
+ }
346
+
347
+ if (nextSibling) {
348
+ patchNextSibling(element);
349
+ }
350
+
351
+ if (previousSibling) {
352
+ patchNextSibling(previousSibling);
353
+ }
354
+ },
355
+
356
+ unbind(element) {
357
+ element.remove();
358
+ // Not necessary to clean up .frag, etc because Node is scrapped
359
+ },
360
+ };
361
+
362
+ export default frag;
@@ -0,0 +1,19 @@
1
+ import frag from './frag.js';
2
+
3
+ export default {
4
+ name: 'Fragment',
5
+ directives: {
6
+ frag,
7
+ },
8
+ render(h) {
9
+ return h(
10
+ 'div',
11
+ {
12
+ directives: [
13
+ { name: 'frag' },
14
+ ],
15
+ },
16
+ this.$slots.default,
17
+ );
18
+ },
19
+ };