kui-vue 3.3.11 → 3.4.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 (66) hide show
  1. package/components/_tool/clone.js +1 -2
  2. package/components/_tool/transfer.js +5 -5
  3. package/components/_tool/utils.js +2 -137
  4. package/components/alert/styles/index.less +2 -2
  5. package/components/avatar/AvatarGroup.jsx +2 -2
  6. package/components/backtop/styles/index.less +44 -47
  7. package/components/base/drop.jsx +231 -17
  8. package/components/base/pop.jsx +35 -21
  9. package/components/button/button.jsx +5 -11
  10. package/components/button/index.js +1 -8
  11. package/components/collapse/styles/index.less +3 -16
  12. package/components/colorPicker/colorpicker.jsx +4 -3
  13. package/components/colorPicker/styles/index.less +22 -43
  14. package/components/datePicker/datecalendar.jsx +1 -1
  15. package/components/datePicker/datepicker.jsx +5 -2
  16. package/components/datePicker/styles/datepicker.less +4 -14
  17. package/components/drawer/drawer.jsx +1 -1
  18. package/components/dropdown/demo/base.md +1 -1
  19. package/components/dropdown/demo/rightmenu.md +5 -5
  20. package/components/dropdown/dropdown.jsx +11 -3
  21. package/components/dropdown/styles/index.less +35 -13
  22. package/components/form/demo/align.md +1 -1
  23. package/components/form/demo/base.md +1 -1
  24. package/components/form/demo/dynamicvalid.md +1 -1
  25. package/components/form/demo/length.md +2 -2
  26. package/components/form/demo/valid.md +2 -2
  27. package/components/form/form.jsx +1 -1
  28. package/components/form/styles/index.less +3 -14
  29. package/components/fragment/component.js +98 -0
  30. package/components/fragment/frag.js +362 -0
  31. package/components/fragment/fragment.js +19 -0
  32. package/components/fragment/index.js +104 -0
  33. package/components/fragment/ssr.js +4 -0
  34. package/components/icon/demo/search.vue +1 -1
  35. package/components/image/styles/index.less +41 -17
  36. package/components/index.js +2 -2
  37. package/components/input/styles/index.less +2 -2
  38. package/components/menu/menuitem.jsx +12 -7
  39. package/components/menu/styles/index.less +190 -203
  40. package/components/menu/submenu.jsx +106 -37
  41. package/components/message/styles/index.less +11 -14
  42. package/components/modal/index.js +1 -1
  43. package/components/modal/modal.jsx +2 -2
  44. package/components/modal/styles/index.less +227 -221
  45. package/components/notice/styles/index.less +19 -5
  46. package/components/popconfirm/styles/index.less +33 -14
  47. package/components/poptip/demo/closeinside.md +1 -1
  48. package/components/poptip/styles/index.less +3 -14
  49. package/components/radio/button.jsx +1 -1
  50. package/components/rate/styles/index.less +9 -1
  51. package/components/select/demo/base.md +1 -1
  52. package/components/select/demo/multiple.md +1 -1
  53. package/components/select/demo/theme.md +11 -13
  54. package/components/select/select.jsx +64 -34
  55. package/components/select/styles/index.less +143 -149
  56. package/components/table/table.jsx +1 -1
  57. package/components/tabs/styles/index.less +3 -2
  58. package/components/tag/styles/index.less +3 -15
  59. package/components/tooltip/styles/index.less +48 -17
  60. package/components/tooltip/tooltip.jsx +3 -3
  61. package/components/tree/node.jsx +1 -1
  62. package/dist/k-ui.css +2 -2
  63. package/dist/k-ui.js +2 -2
  64. package/package.json +4 -4
  65. package/components/menu/styles/dropmenu.less +0 -119
  66. /package/{README.md → readme.md} +0 -0
@@ -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
+ };
@@ -0,0 +1,104 @@
1
+ import component, { freeze, unfreeze } from './component'
2
+ import ssr from './ssr'
3
+
4
+ export const Fragment = component
5
+
6
+ export const SSR = ssr
7
+
8
+ export const Plugin = {
9
+ install: function (Vue) {
10
+ const orgRemoveChild = window.Node.prototype.removeChild
11
+ window.Node.prototype.removeChild = function (node) {
12
+ if (this.__isFragment) {
13
+ if (this.parentNode) {
14
+ let ret = this.parentNode.removeChild(node)
15
+ unfreeze(node, 'parentNode')
16
+ return ret
17
+ }
18
+ } else if (node.__isFragment && node.__isMounted) {
19
+ while (node.__head.nextSibling !== node.__tail) orgRemoveChild.call(this, node.__head.nextSibling)
20
+
21
+ orgRemoveChild.call(this, node.__head)
22
+ orgRemoveChild.call(this, node.__tail)
23
+ let prev = node.__head.previousSibling,
24
+ next = node.__tail.nextSibling
25
+ if (prev) freeze(prev, 'nextSibling', next)
26
+ if (next) freeze(next, 'previousSibling', prev)
27
+
28
+ unfreeze(node, 'parentNode')
29
+ return node
30
+ } else {
31
+ let prev = node.previousSibling,
32
+ next = node.nextSibling
33
+ let ret = orgRemoveChild.call(this, node)
34
+ if (prev) freeze(prev, 'nextSibling', next)
35
+ if (next) freeze(next, 'previousSibling', prev)
36
+ return ret
37
+ }
38
+ }
39
+
40
+ const orgInsertBefore = window.Node.prototype.insertBefore
41
+ window.Node.prototype.insertBefore = function (node, ref, inFragment = false) {
42
+ let realRef = !!ref && !!ref.__isFragment && !!ref.__isMounted ? ref.__head : ref
43
+ if (this.__isFragment) {
44
+ let notFrChild = !node.hasOwnProperty('__isFragmentChild__'),
45
+ freezeParent = !inFragment || notFrChild
46
+
47
+ notFrChild && freeze(node, '__isFragmentChild__', true)
48
+ let ret = this.parentNode ? this.parentNode.insertBefore(node, ref) : orgInsertBefore.call(this, node, realRef)
49
+ freezeParent && freeze(node, 'parentNode', this)
50
+
51
+ return ret
52
+ } else if (node.__isFragment && node.__isMounted) {
53
+ if (node === ref) {
54
+ console.error('something must be wrong')
55
+ return
56
+ }
57
+ freeze(node, 'parentNode', this)
58
+ if (node.previousSibling) freeze(node.previousSibling, 'nextSibling', node.nextSibling)
59
+ if (node.nextSibling) freeze(node.nextSibling, 'previousSibling', node.previousSibling)
60
+ freeze(node, 'nextSibling', ref)
61
+ freeze(node, 'previousSibling', ref.previousSibling)
62
+ if (ref.previousSibling) freeze(ref.previousSibling, 'nextSibling', node)
63
+ freeze(ref, 'previousSibling', node)
64
+
65
+ let tpl = document.createDocumentFragment(),
66
+ ele = node.__head
67
+ while (ele !== node.__tail) {
68
+ tpl.appendChild(ele)
69
+ ele = ele.nextSibling
70
+ }
71
+ tpl.appendChild(node.__tail)
72
+ orgInsertBefore.call(this, tpl, realRef)
73
+ return node
74
+ } else {
75
+ return orgInsertBefore.call(this, node, realRef)
76
+ }
77
+ }
78
+
79
+ const orgAppendChild = window.Node.prototype.appendChild
80
+ window.Node.prototype.appendChild = function (node, inFragment = false) {
81
+ if (this.__isFragment) {
82
+ if (this.parentNode) {
83
+ let notFrChild = !node.hasOwnProperty('__isFragmentChild__'),
84
+ freezeParent = !inFragment || notFrChild
85
+
86
+ notFrChild && freeze(node, '__isFragmentChild__', true)
87
+ let ret = this.parentNode.insertBefore(node, this.__tail, inFragment)
88
+ freezeParent && freeze(node, 'parentNode', this)
89
+
90
+ return ret
91
+ }
92
+ } else {
93
+ return orgAppendChild.call(this, node)
94
+ }
95
+ }
96
+ Vue.component('Fragment', component)
97
+ },
98
+ }
99
+
100
+ export default {
101
+ Fragment,
102
+ Plugin,
103
+ SSR,
104
+ }
@@ -0,0 +1,4 @@
1
+ export default function(vnode, meta) {
2
+ if (process.env.NODE_ENV !== 'production')
3
+ console.warn('v-fragment SSR is not implemented yet.')
4
+ }
@@ -97,7 +97,7 @@
97
97
  <script>
98
98
  // import { LogoKui } from 'kui-icons'
99
99
  import * as icons from 'kui-icons'
100
- console.log(icons)
100
+ // console.log(icons)
101
101
  // import sprite from 'kui-icons/lib/sprite.svg'
102
102
  // import icons from '../lib/kui-icons'
103
103
  // import sprite from '../lib/sprite.svg'