@king-design/vue 2.0.7 → 2.0.9

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.
@@ -234,7 +234,7 @@ describe('Datepicker', function () {
234
234
  }, _callee6);
235
235
  })));
236
236
  it('range date', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
237
- var _mount6, instance, element, select, content, _content$querySelecto, panel1, panel2, _panel1$querySelector, nextMonth, nextYear, _content$querySelecto2, monthValues1, monthValues2, _panel2$querySelector, prevYear;
237
+ var _mount6, instance, element, select, content, _content$querySelecto, panel1, panel2, _panel1$querySelector, nextMonth, nextYear, _content$querySelecto2, monthValues1, monthValues2, monthStart, yearStart, monthEnd, yearEnd, _panel2$querySelector, prevYear, firstDecadeStart, secondDecadeStart;
238
238
 
239
239
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
240
240
  while (1) {
@@ -252,45 +252,51 @@ describe('Datepicker', function () {
252
252
  _panel1$querySelector = panel1.querySelectorAll('.k-next'), nextMonth = _panel1$querySelector[0], nextYear = _panel1$querySelector[1];
253
253
  _content$querySelecto2 = content.querySelectorAll('.k-month-values'), monthValues1 = _content$querySelecto2[0], monthValues2 = _content$querySelecto2[1];
254
254
  nextMonth.click();
255
- _context7.next = 12;
255
+ monthStart = (month + 1) % 12 + 1;
256
+ yearStart = year + Math.floor((month + 1) / 12);
257
+ monthEnd = (month + 2) % 12 + 1;
258
+ yearEnd = year + Math.floor((month + 2) / 12);
259
+ _context7.next = 16;
256
260
  return wait();
257
261
 
258
- case 12:
259
- expect(monthValues1.textContent).to.eql(year + "\u5E74" + (month + 1 + 1) + "\u6708");
260
- expect(monthValues2.textContent).to.eql(year + "\u5E74" + (month + 1 + 2) + "\u6708");
262
+ case 16:
263
+ expect(monthValues1.textContent).to.eql(yearStart + "\u5E74" + monthStart + "\u6708");
264
+ expect(monthValues2.textContent).to.eql(yearEnd + "\u5E74" + monthEnd + "\u6708");
261
265
  nextYear.click();
262
- _context7.next = 17;
266
+ _context7.next = 21;
263
267
  return wait();
264
268
 
265
- case 17:
266
- expect(monthValues1.textContent).to.eql(year + 1 + "\u5E74" + (month + 1 + 1) + "\u6708");
267
- expect(monthValues2.textContent).to.eql(year + 1 + "\u5E74" + (month + 1 + 2) + "\u6708");
269
+ case 21:
270
+ expect(monthValues1.textContent).to.eql(yearStart + 1 + "\u5E74" + monthStart + "\u6708");
271
+ expect(monthValues2.textContent).to.eql(yearEnd + 1 + "\u5E74" + monthEnd + "\u6708");
268
272
  _panel2$querySelector = panel2.querySelectorAll('.k-prev'), prevYear = _panel2$querySelector[0];
269
273
  prevYear.click();
270
- _context7.next = 23;
274
+ _context7.next = 27;
271
275
  return wait();
272
276
 
273
- case 23:
274
- expect(monthValues1.textContent).to.eql(year + "\u5E74" + (month + 1 + 1) + "\u6708");
275
- expect(monthValues2.textContent).to.eql(year + "\u5E74" + (month + 1 + 2) + "\u6708"); // year panel
277
+ case 27:
278
+ expect(monthValues1.textContent).to.eql(yearStart + "\u5E74" + monthStart + "\u6708");
279
+ expect(monthValues2.textContent).to.eql(yearEnd + "\u5E74" + monthEnd + "\u6708"); // year panel
276
280
 
277
281
  dispatchEvent(monthValues1.firstElementChild, 'click');
278
282
  dispatchEvent(monthValues2.firstElementChild, 'click');
279
- _context7.next = 29;
283
+ _context7.next = 33;
280
284
  return wait();
281
285
 
282
- case 29:
283
- expect(monthValues1.textContent).to.eql(startYear + "\u5E74 - " + (startYear + 9) + "\u5E74");
284
- expect(monthValues1.textContent).to.eql(monthValues2.textContent);
286
+ case 33:
287
+ firstDecadeStart = Math.floor(yearStart / 10) * 10;
288
+ secondDecadeStart = Math.floor(yearEnd / 10) * 10;
289
+ expect(monthValues1.textContent).to.eql(firstDecadeStart + "\u5E74 - " + (firstDecadeStart + 9) + "\u5E74");
290
+ expect(monthValues1.textContent).to.eql(secondDecadeStart + "\u5E74 - " + (secondDecadeStart + 9) + "\u5E74");
285
291
  nextYear.click();
286
- _context7.next = 34;
292
+ _context7.next = 40;
287
293
  return wait();
288
294
 
289
- case 34:
290
- expect(monthValues1.textContent).to.eql(startYear + 10 + "\u5E74 - " + (startYear + 19) + "\u5E74");
291
- expect(monthValues1.textContent).to.eql(monthValues2.textContent);
295
+ case 40:
296
+ expect(monthValues1.textContent).to.eql(firstDecadeStart + 10 + "\u5E74 - " + (secondDecadeStart + 19) + "\u5E74");
297
+ expect(monthValues1.textContent).to.eql(secondDecadeStart + 10 + "\u5E74 - " + (secondDecadeStart + 19) + "\u5E74");
292
298
 
293
- case 36:
299
+ case 42:
294
300
  case "end":
295
301
  return _context7.stop();
296
302
  }
@@ -1,3 +1,4 @@
1
+ import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
1
2
  import { useInstance, onUnmounted } from 'intact-vue-next';
2
3
  import { SHOW, HIDE } from './constants'; // only close the top dialog when press ESC
3
4
 
@@ -22,14 +23,19 @@ export function useEscClosable() {
22
23
  });
23
24
 
24
25
  function onHide() {
25
- var dialog = dialogs.pop(); // const dialog = dialogs.shift();
26
+ // the order is uncertain in different frameworks
27
+ var index = dialogs.indexOf(instance); // const dialog = dialogs.pop();
28
+ // const dialog = dialogs.shift();
26
29
 
27
30
  if (process.env.NODE_ENV !== 'production') {
28
- if (dialog !== instance) {
29
- throw new Error('The dialog has handled hide callback. It is a bug of KPC');
31
+ // if (dialog !== instance) {
32
+ if (index === -1) {
33
+ throw new Error('The dialog has handled hide callback. Maybe it is a bug of KPC');
30
34
  }
31
35
  }
32
36
 
37
+ _spliceInstanceProperty(dialogs).call(dialogs, 0, index);
38
+
33
39
  if (!dialogs.length) {
34
40
  document.removeEventListener('keydown', escClose);
35
41
  }
@@ -123,8 +123,8 @@ export function useMenuKeyboard() {
123
123
  reset: reset,
124
124
  focus: function focus(item) {
125
125
  // reset();
126
- var index = items.indexOf(item);
127
- if (index === -1) debugger;
126
+ var index = items.indexOf(item); // if (index === -1) debugger
127
+
128
128
  focusIndex = index;
129
129
  focusItem(item);
130
130
  }
@@ -10,6 +10,7 @@ export declare class Portal<T extends PortalProps = PortalProps> extends Compone
10
10
  private dialog;
11
11
  mountedQueue?: Function[];
12
12
  mountedDone?: boolean;
13
+ $isPortal: boolean;
13
14
  $render(lastVNode: VNodeComponentClass<this> | null, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[]): void;
14
15
  $update(lastVNode: VNodeComponentClass<this>, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[], force: boolean): void;
15
16
  $unmount(vNode: VNodeComponentClass<this>, nextVNode: VNodeComponentClass<this> | null): void;
@@ -1,6 +1,6 @@
1
1
  import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
2
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
3
- import { Component, createCommentVNode, createTextVNode, mount, patch, remove, inject, callAll } from 'intact-vue-next';
3
+ import { Component, createCommentVNode, createTextVNode, mount, patch, remove, inject } from 'intact-vue-next';
4
4
  import { isString } from 'intact-shared';
5
5
  import { DIALOG } from './dialog/constants';
6
6
  var typeDefs = {
@@ -23,6 +23,7 @@ export var Portal = /*#__PURE__*/function (_Component) {
23
23
  _this.dialog = inject(DIALOG, null);
24
24
  _this.mountedQueue = void 0;
25
25
  _this.mountedDone = void 0;
26
+ _this.$isPortal = true;
26
27
  return _this;
27
28
  }
28
29
 
@@ -39,21 +40,20 @@ export var Portal = /*#__PURE__*/function (_Component) {
39
40
  _proto.$render = function $render(lastVNode, nextVNode, parentDom, anchor, mountedQueue) {
40
41
  var _this2 = this;
41
42
 
43
+ /**
44
+ * In React, we cannot render real elements in mountedQueue.
45
+ * Because the rendering time of react element is uncontrollable
46
+ */
47
+ var nextProps = nextVNode.props;
48
+ var fakeContainer = document.createDocumentFragment();
42
49
  mountedQueue.push(function () {
43
- var nextProps = nextVNode.props;
44
50
  var parentDom = _this2.$lastInput.dom.parentElement;
45
- /**
46
- * initialize a new mountedQueue to place the callbacks of sub-components to it,
47
- * so that we can call them before the sibling components of the Portal
48
- */
49
-
50
- var mountedQueue = [];
51
51
 
52
52
  _this2.initContainer(nextProps.container, parentDom, anchor);
53
53
 
54
- mount(nextProps.children, _this2.container, _this2, _this2.$SVG, null, mountedQueue);
55
- callAll(mountedQueue);
54
+ _this2.container.appendChild(fakeContainer);
56
55
  });
56
+ mount(nextProps.children, fakeContainer, this, this.$SVG, null, mountedQueue);
57
57
 
58
58
  _Component.prototype.$render.call(this, lastVNode, nextVNode, parentDom, anchor, mountedQueue);
59
59
  };
@@ -99,7 +99,7 @@ export var Portal = /*#__PURE__*/function (_Component) {
99
99
  // find the closest dialog if exists
100
100
  var tmp;
101
101
 
102
- if ((tmp = this.dialog) && (tmp = tmp.dialogRef.value)) {
102
+ if ((tmp = this.dialog) && tmp !== this.$senior && (tmp = tmp.dialogRef.value)) {
103
103
  this.container = tmp;
104
104
  } else {
105
105
  this.container = document.body;
@@ -1,4 +1,5 @@
1
1
  import _sortInstanceProperty from "@babel/runtime-corejs3/core-js/instance/sort";
2
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
2
3
  import { css } from '@emotion/css';
3
4
  import { theme, setDefault } from '../../styles/theme';
4
5
  import { deepDefaults, palette } from '../../styles/utils';
@@ -75,6 +76,7 @@ var defaults = {
75
76
  resizeWidth: "5px",
76
77
  draggingOpacity: ".4"
77
78
  };
79
+ var aligns = ['left', 'right', 'center'];
78
80
  var table;
79
81
  setDefault(function () {
80
82
  table = deepDefaults(theme, {
@@ -82,7 +84,9 @@ setDefault(function () {
82
84
  }).table;
83
85
  });
84
86
  export function makeStyles() {
85
- return /*#__PURE__*/css("font-size:", table.fontSize, ";color:", table.color, ";border-top:", table.border, ";position:relative;z-index:0;.k-table-wrapper{border-bottom:", table.border, ";overflow:auto;}table{width:100%;border-spacing:0;table-layout:fixed;td,th{transition:all ", table.transition, ";}}thead{text-align:", table.thead.textAlign, ";font-size:", table.thead.fontSize, ";font-weight:", table.thead.fontWeight, ";position:sticky;top:0;z-index:2;tr{height:", table.thead.height, ";}}th{padding:", table.thead.padding, ";position:relative;background:", table.thead.bgColor, ";border-bottom:", table.border, ";&:before{content:'';height:", table.thead.delimiterHeight, ";position:absolute;background-color:", table.thead.delimiterColor, ";width:1px;left:1px;top:50%;transform:translateY(-50%);}&:first-of-type:before{display:none;}}.k-table-title{display:inline-flex;align-items:center;max-width:100%;}.k-table-title-text{flex:1;}tbody{tr{&:hover td{background:", table.tbody.hoverBgcolor, ";}&:last-of-type td{border-bottom-color:transparent;}}}td{padding:", table.tbody.padding, ";border-bottom:", table.border, ";background:", table.bgColor, ";word-wrap:break-word;}.k-fixed-left,.k-fixed-right{position:sticky;z-index:1;&:after{content:'';display:block;transition:box-shadow ", table.transition, ";position:absolute;top:0;bottom:0px;width:10px;pointer-events:none;}}.k-fixed-left:after{right:-11px;}.k-fixed-right:after{left:-11px;}&.k-scroll-left .k-fixed-right:after{box-shadow:", table.fixRightShadow, ";}&.k-scroll-right .k-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}&.k-scroll-middle{.k-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}.k-fixed-right:after{box-shadow:", table.fixRightShadow, ";}}.k-fixed-right+.k-fixed-right:after{display:none;}.k-table-affix-header{position:sticky;top:0;left:0;.k-affix-wrapper{overflow:hidden;}&.k-fixed{position:relative;}}&.k-border,&.k-grid{.k-table-wrapper{border-left:", table.border, ";border-right:", table.border, ";}}&.k-grid{td:not(:last-of-type),th:not(:last-of-type){border-right:", table.border, ";}th:before{display:none;}}&.k-stripe{tr:nth-child(even):not(:hover) td{background:", table.stripeBgColor, ";}}.k-table-group{width:", table.group.width, "!important;height:", table.group.width, "!important;margin-left:", table.group.gap, ";position:relative;color:", table.group.color, ";&:hover{color:", theme.color.primary, ";}.k-icon{transition:transform ", table.transition, ";}&.k-dropdown-open .k-icon{transform:rotate(180deg);}}.k-table-check{.k-checkbox,.k-radio{position:relative;top:-1px;}}.k-column-sortable{cursor:pointer;}.k-column-sort{.k-icon{display:block;height:", _sortInstanceProperty(table).iconHeight, ";line-height:", _sortInstanceProperty(table).iconHeight, ";margin-left:", _sortInstanceProperty(table).gap, ";color:", _sortInstanceProperty(table).color, ";}&.k-asc .k-icon.k-desc,&.k-desc .k-icon.k-asc{color:", _sortInstanceProperty(table).disabledColor, ";}}.k-table-spin.k-overlay{z-index:2;}.k-table-empty{text-align:center;}tr.k-expand{td{padding:0;background:#fdfcff;}}&.k-with-expand{tr:not(.k-expand){td{border-bottom:none;}}}.k-table-expand{border-top:", table.border, ";box-sizing:content-box;}tbody tr.k-selected td{background:", table.selectedBgColor, ";}.k-table-arrow{margin-right:", table.arrow.gap, ";transition:transform ", table.transition, ";position:relative;top:-1px;}tr.k-spreaded{.k-table-arrow{transform:rotate(90deg);}}.k-table-resize{height:100%;width:", table.resizeWidth, ";position:absolute;top:0;left:-1px;cursor:ew-resize;}tr.k-dragging{opacity:", table.draggingOpacity, ";}.k-table-scrollbar{overflow-x:auto;overflow-y:hidden;}.k-table-scrollbar-inner{height:1px;}");
87
+ return /*#__PURE__*/css("font-size:", table.fontSize, ";color:", table.color, ";border-top:", table.border, ";position:relative;z-index:0;.k-table-wrapper{border-bottom:", table.border, ";overflow:auto;}table{width:100%;border-spacing:0;table-layout:fixed;td,th{transition:all ", table.transition, ";}}thead{text-align:", table.thead.textAlign, ";font-size:", table.thead.fontSize, ";font-weight:", table.thead.fontWeight, ";position:sticky;top:0;z-index:2;tr{height:", table.thead.height, ";}}th{padding:", table.thead.padding, ";position:relative;background:", table.thead.bgColor, ";border-bottom:", table.border, ";&:before{content:'';height:", table.thead.delimiterHeight, ";position:absolute;background-color:", table.thead.delimiterColor, ";width:1px;left:1px;top:50%;transform:translateY(-50%);}&:first-of-type:before{display:none;}}.k-table-title{display:inline-flex;align-items:center;max-width:100%;}.k-table-title-text{flex:1;}tbody{tr{&:hover td{background:", table.tbody.hoverBgcolor, ";}&:last-of-type td{border-bottom-color:transparent;}}}td{padding:", table.tbody.padding, ";border-bottom:", table.border, ";background:", table.bgColor, ";word-wrap:break-word;}.k-fixed-left,.k-fixed-right{position:sticky;z-index:1;&:after{content:'';display:block;transition:box-shadow ", table.transition, ";position:absolute;top:0;bottom:0px;width:10px;pointer-events:none;}}.k-fixed-left:after{right:-11px;}.k-fixed-right:after{left:-11px;}&.k-scroll-left .k-fixed-right:after{box-shadow:", table.fixRightShadow, ";}&.k-scroll-right .k-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}&.k-scroll-middle{.k-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}.k-fixed-right:after{box-shadow:", table.fixRightShadow, ";}}.k-fixed-right+.k-fixed-right:after{display:none;}.k-table-affix-header{position:sticky;top:0;left:0;.k-affix-wrapper{overflow:hidden;}&.k-fixed{position:relative;}}&.k-border,&.k-grid{.k-table-wrapper{border-left:", table.border, ";border-right:", table.border, ";}}&.k-grid{td:not(:last-of-type),th:not(:last-of-type){border-right:", table.border, ";}th:before{display:none;}}&.k-stripe{tr:nth-child(even):not(:hover) td{background:", table.stripeBgColor, ";}}.k-table-group{width:", table.group.width, "!important;height:", table.group.width, "!important;margin-left:", table.group.gap, ";position:relative;color:", table.group.color, ";&:hover{color:", theme.color.primary, ";}.k-icon{transition:transform ", table.transition, ";}&.k-dropdown-open .k-icon{transform:rotate(180deg);}}.k-table-check{.k-checkbox,.k-radio{position:relative;top:-1px;}}.k-column-sortable{cursor:pointer;}.k-column-sort{.k-icon{display:block;height:", _sortInstanceProperty(table).iconHeight, ";line-height:", _sortInstanceProperty(table).iconHeight, ";margin-left:", _sortInstanceProperty(table).gap, ";color:", _sortInstanceProperty(table).color, ";}&.k-asc .k-icon.k-desc,&.k-desc .k-icon.k-asc{color:", _sortInstanceProperty(table).disabledColor, ";}}.k-table-spin.k-overlay{z-index:2;}.k-table-empty{text-align:center;}tr.k-expand{td{padding:0;background:#fdfcff;}}&.k-with-expand{tr:not(.k-expand){td{border-bottom:none;}}}.k-table-expand{border-top:", table.border, ";box-sizing:content-box;}tbody tr.k-selected td{background:", table.selectedBgColor, ";}.k-table-arrow{margin-right:", table.arrow.gap, ";transition:transform ", table.transition, ";position:relative;top:-1px;}tr.k-spreaded{.k-table-arrow{transform:rotate(90deg);}}.k-table-resize{height:100%;width:", table.resizeWidth, ";position:absolute;top:0;left:-1px;cursor:ew-resize;}tr.k-dragging{opacity:", table.draggingOpacity, ";}.k-table-scrollbar{overflow-x:auto;overflow-y:hidden;}.k-table-scrollbar-inner{height:1px;}", _mapInstanceProperty(aligns).call(aligns, function (type) {
88
+ return /*#__PURE__*/css(".k-align-", type, "{text-align:", type, ";}");
89
+ }), ";");
86
90
  }
87
91
  export function makeGroupMenuStyles() {
88
92
  return /*#__PURE__*/css("max-height:", table.group.menuMaxHeight, ";overflow:auto;.k-dropdown-item.k-active{color:", table.group.activeColor, ";}");
@@ -15,7 +15,7 @@ export declare function useFixedColumns(getColumns: () => VNodeComponentClass<Ta
15
15
  getHasFixedLeft: () => boolean;
16
16
  getOffsetMap: () => Record<Key, number>;
17
17
  };
18
- export declare function getClassAndStyleForFixed({ className, fixed }: Props<TableColumnProps>, offset: number, checkType?: TableProps['checkType']): {
18
+ export declare function getClassAndStyleForFixed({ className, fixed, align }: Props<TableColumnProps>, offset: number, checkType?: TableProps['checkType']): {
19
19
  className: string;
20
20
  style: {
21
21
  [x: string]: string;
@@ -125,10 +125,11 @@ export function getClassAndStyleForFixed(_ref2, offset, checkType) {
125
125
  var _cx, _ref3;
126
126
 
127
127
  var className = _ref2.className,
128
- fixed = _ref2.fixed;
128
+ fixed = _ref2.fixed,
129
+ align = _ref2.align;
129
130
  var extraOffset = checkType && checkType !== 'none' && fixed === 'left' ? 40 : 0;
130
131
  return {
131
- className: cx((_cx = {}, _cx[className] = !!className, _cx["k-fixed-" + fixed] = !!fixed, _cx)),
132
+ className: cx((_cx = {}, _cx[className] = !!className, _cx["k-fixed-" + fixed] = !!fixed, _cx["k-align-" + align] = !!align, _cx)),
132
133
  style: fixed ? (_ref3 = {}, _ref3[fixed] = offset + extraOffset + "px", _ref3) : null
133
134
  };
134
135
  }
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v2.0.7
2
+ * @king-design v2.0.9
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -57,7 +57,7 @@ export * from './components/tree';
57
57
  export * from './components/treeSelect';
58
58
  export * from './components/upload';
59
59
  export * from './components/wave';
60
- export declare const version = "2.0.7";
60
+ export declare const version = "2.0.9";
61
61
 
62
62
 
63
63
  export {normalize} from 'intact-vue-next';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v2.0.7
2
+ * @king-design v2.0.9
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -59,7 +59,7 @@ export * from './components/tree';
59
59
  export * from './components/treeSelect';
60
60
  export * from './components/upload';
61
61
  export * from './components/wave';
62
- export var version = '2.0.7';
62
+ export var version = '2.0.9';
63
63
  /* generate end */
64
64
 
65
65
  export {normalize} from 'intact-vue-next';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@king-design/vue",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "King-Design UI components for Vue3.0.",
5
5
  "keywords": [
6
6
  "component",
@@ -38,7 +38,7 @@
38
38
  "dayjs": "^1.10.7",
39
39
  "downloadjs": "^1.4.7",
40
40
  "enquire.js": "^2.1.6",
41
- "intact-vue-next": "^3.0.8",
41
+ "intact-vue-next": "^3.0.10",
42
42
  "monaco-editor": "^0.26.1",
43
43
  "mxgraphx": "^4.0.7",
44
44
  "resize-observer-polyfill": "^1.5.1",