@king-design/react 3.6.0 → 3.6.1
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.
- package/__tests__/__snapshots__/React Demos.md +117 -61
- package/components/copy/index.spec.js +14 -31
- package/components/datepicker/index.spec.js +646 -608
- package/components/datepicker/useValueBase.js +5 -2
- package/components/form/form.d.ts +1 -0
- package/components/form/form.js +7 -0
- package/components/form/index.spec.js +10 -8
- package/components/menu/index.spec.js +28 -0
- package/components/menu/styles.js +2 -2
- package/components/select/index.spec.js +231 -177
- package/components/select/menu.js +1 -1
- package/components/select/useCard.d.ts +4 -3
- package/components/select/useCard.js +15 -4
- package/components/spinner/index.spec.js +82 -44
- package/components/spinner/useValue.js +2 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +2 -2
- package/yarn-error.log +528 -0
|
@@ -189,8 +189,11 @@ export function useValueBase(_ref, _ref2, panel, shouldUpdateValue, updateValueO
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
var valueStr = convertToValueString(_value);
|
|
192
|
-
|
|
193
|
-
instance.
|
|
192
|
+
// only trigger change event once
|
|
193
|
+
if (!isEqualArray(valueStr, instance.get('value'))) {
|
|
194
|
+
instance.set('value', valueStr);
|
|
195
|
+
instance.resetKeywords();
|
|
196
|
+
}
|
|
194
197
|
}
|
|
195
198
|
// TODO
|
|
196
199
|
function setMoment() {
|
|
@@ -32,6 +32,7 @@ export declare class Form extends Component<FormProps, FormEvents> {
|
|
|
32
32
|
init(): void;
|
|
33
33
|
validate(): Promise<boolean>;
|
|
34
34
|
getFirstInvalidFormItem(): FormItem | undefined;
|
|
35
|
+
getAllInvalidFormItems(): FormItem[];
|
|
35
36
|
submit(e: Event): void;
|
|
36
37
|
reset(): void;
|
|
37
38
|
private onSubmit;
|
package/components/form/form.js
CHANGED
|
@@ -3,6 +3,7 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/con
|
|
|
3
3
|
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
4
4
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
5
5
|
import _findInstanceProperty from "@babel/runtime-corejs3/core-js/instance/find";
|
|
6
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
6
7
|
import { __decorate } from "tslib";
|
|
7
8
|
import { Component, provide } from 'intact-react';
|
|
8
9
|
import template from './form.vdt';
|
|
@@ -59,6 +60,12 @@ export var Form = /*#__PURE__*/function (_Component) {
|
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
};
|
|
63
|
+
_proto.getAllInvalidFormItems = function getAllInvalidFormItems() {
|
|
64
|
+
var _context4;
|
|
65
|
+
return _filterInstanceProperty(_context4 = this.items).call(_context4, function (item) {
|
|
66
|
+
return !item.isValid();
|
|
67
|
+
});
|
|
68
|
+
};
|
|
62
69
|
_proto.submit = function submit(e) {
|
|
63
70
|
var _this2 = this;
|
|
64
71
|
this.validate().then(function (valid) {
|
|
@@ -32,7 +32,7 @@ describe('Form', function () {
|
|
|
32
32
|
return unmount();
|
|
33
33
|
});
|
|
34
34
|
it('validate', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
35
|
-
var _mount, instance, element, form, item, input;
|
|
35
|
+
var _mount, instance, element, form, item, items, input;
|
|
36
36
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
37
37
|
while (1) switch (_context.prev = _context.next) {
|
|
38
38
|
case 0:
|
|
@@ -44,24 +44,26 @@ describe('Form', function () {
|
|
|
44
44
|
expect(element.innerHTML).to.matchSnapshot();
|
|
45
45
|
item = form.getFirstInvalidFormItem();
|
|
46
46
|
expect(item.get('label')).to.eql('Input');
|
|
47
|
+
items = form.getAllInvalidFormItems();
|
|
48
|
+
expect(items.length).to.eql(10);
|
|
47
49
|
instance.reset();
|
|
48
|
-
_context.next =
|
|
50
|
+
_context.next = 12;
|
|
49
51
|
return wait();
|
|
50
|
-
case
|
|
52
|
+
case 12:
|
|
51
53
|
expect(instance.get('model')).to.matchSnapshot();
|
|
52
54
|
// validate on focusout
|
|
53
55
|
input = element.querySelector('input');
|
|
54
56
|
dispatchEvent(input, 'focus');
|
|
55
|
-
_context.next =
|
|
57
|
+
_context.next = 17;
|
|
56
58
|
return wait();
|
|
57
|
-
case
|
|
59
|
+
case 17:
|
|
58
60
|
expect(element.innerHTML).to.matchSnapshot();
|
|
59
61
|
dispatchEvent(input, 'focusout');
|
|
60
|
-
_context.next =
|
|
62
|
+
_context.next = 21;
|
|
61
63
|
return wait();
|
|
62
|
-
case
|
|
64
|
+
case 21:
|
|
63
65
|
expect(element.innerHTML).to.matchSnapshot();
|
|
64
|
-
case
|
|
66
|
+
case 22:
|
|
65
67
|
case "end":
|
|
66
68
|
return _context.stop();
|
|
67
69
|
}
|
|
@@ -8,6 +8,7 @@ import BasicDemo from '~/components/menu/demos/basic';
|
|
|
8
8
|
import CollapseDemo from '~/components/menu/demos/collapse';
|
|
9
9
|
import AccordionDemo from '~/components/menu/demos/accordion';
|
|
10
10
|
import CollapseArrowDemo from '~/components/menu/demos/showCollapseArrow';
|
|
11
|
+
import HorizontalDemo from '~/components/menu/demos/horizontal';
|
|
11
12
|
import { mount, unmount, dispatchEvent, getElement, wait } from '../../test/utils';
|
|
12
13
|
import { Menu, MenuItem } from './';
|
|
13
14
|
describe('Menu', function () {
|
|
@@ -271,4 +272,31 @@ describe('Menu', function () {
|
|
|
271
272
|
}
|
|
272
273
|
}, _callee7);
|
|
273
274
|
})));
|
|
275
|
+
it('detecting pop-up position during rapid mouse hover over menus', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
276
|
+
var _mount8, instance, element, _element$querySelecto2, menu3, menu4, dropdownmenu1, top1, dropdownmenu2, top2;
|
|
277
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context9) {
|
|
278
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
279
|
+
case 0:
|
|
280
|
+
_mount8 = mount(HorizontalDemo), instance = _mount8[0], element = _mount8[1];
|
|
281
|
+
_element$querySelecto2 = element.querySelectorAll('.k-menu-item-title'), menu3 = _element$querySelecto2[2], menu4 = _element$querySelecto2[3];
|
|
282
|
+
dispatchEvent(menu3, 'mouseenter');
|
|
283
|
+
_context9.next = 5;
|
|
284
|
+
return wait(500);
|
|
285
|
+
case 5:
|
|
286
|
+
dropdownmenu1 = getElement('.k-dropdown-menu');
|
|
287
|
+
top1 = dropdownmenu1.getBoundingClientRect().top;
|
|
288
|
+
dispatchEvent(menu3, 'mouseleave');
|
|
289
|
+
dispatchEvent(menu4, 'mouseenter');
|
|
290
|
+
_context9.next = 11;
|
|
291
|
+
return wait(1000);
|
|
292
|
+
case 11:
|
|
293
|
+
dropdownmenu2 = getElement('.k-dropdown-menu');
|
|
294
|
+
top2 = dropdownmenu2.getBoundingClientRect().top;
|
|
295
|
+
expect(top1).to.eql(top2);
|
|
296
|
+
case 14:
|
|
297
|
+
case "end":
|
|
298
|
+
return _context9.stop();
|
|
299
|
+
}
|
|
300
|
+
}, _callee8);
|
|
301
|
+
})));
|
|
274
302
|
});
|
|
@@ -21,7 +21,7 @@ var defaults = {
|
|
|
21
21
|
item: {
|
|
22
22
|
height: '40px',
|
|
23
23
|
padding: '0 12px',
|
|
24
|
-
bodyPadding: '
|
|
24
|
+
bodyPadding: '4px',
|
|
25
25
|
color: '#aeaeb9',
|
|
26
26
|
hoverColor: '#fff',
|
|
27
27
|
disabledColor: '#53535a',
|
|
@@ -115,7 +115,7 @@ export var makeMenuStyles = cache(function makeMenuStyles(k) {
|
|
|
115
115
|
return /*#__PURE__*/css("&.", k, "-menu{width:", menu.width, ";transition:width ", menu.transition, ";background:", menu.bgColor, ";font-size:", menu.fontSize, ";position:relative;}.", k, "-icon{width:", menu.icon.width, ";margin-right:", menu.icon.gap, ";text-align:center;flex-shrink:0;}.", k, "-menu-header{height:", menu.header.height, ";padding:0 16px;color:", menu.header.color, ";font-size:", menu.header.fontSize, ";font-weight:bold;}.", k, "-menu-body{padding:", menu.item.bodyPadding, ";max-height:calc(100% - ", menu.header.height, ");overflow-y:auto;overflow-x:hidden;scrollbar-width:none;}.", k, "-menu-title{height:", menu.title.height, ";border-top:", menu.border, ";margin-top:4px;.", k, "-menu-name{transition:all ", menu.transition, ";height:", menu.title.height, ";color:", menu.title.color, ";font-weight:bold;}}.", k, "-menu-arrow-box{width:14px;height:60px;cursor:pointer;background:", menu.bgColor, ";border-radius:0 8px 8px 0;position:absolute;display:flex;align-items:center;justify-content:center;top:50%;left:calc(", menu.width, " - 2px);transition:left ", menu.transition, ";transform:translateY(-50%);border:", menu.border, ";border-left:none;.", k, "-icon{margin-right:0;}&:hover{.", k, "-menu-arrow:before{color:", menu.item.activeBgColor, ";}}}&.", k, "-light{border-right:1px solid ", theme.color.disabledBg, ";background:", menu.light.bgColor, ";.", k, "-menu-header{color:", menu.light.title.color, ";}.", k, "-menu-item{.", k, "-menu-item-title{color:", menu.light.item.color, ";&:hover{background:", menu.light.item.hoverBg, ";}}.", k, "-menu-item-arrow{color:", menu.light.item.color, ";}&.", k, "-highlighted{>.", k, "-menu-item-title{color:", menu.light.item.hoverColor, ";}}&.", k, "-disabled{>.", k, "-menu-item-title{color:", menu.light.item.disabledColor, "!important;}}}.", k, "-menu-title{border-top:", menu.light.border, ";.", k, "-menu-name{color:", menu.light.title.color, ";}}.", k, "-menu-arrow-box{background:", menu.light.bgColor, ";border:", menu.light.border, ";border-left:none;&:hover{.", k, "-menu-arrow:before{color:", menu.light.active.color, ";}}}.", k, "-menu:not(.", k, "-dropdown-menu){background:", menu.light.bgColor, ";}&.", k, "-horizontal{.", k, "-menu-header{border-right:", menu.light.border, ";}.", k, "-menu-body>.", k, "-menu-title{border-right:", menu.light.border, ";}}.", k, "-menu-item.", k, "-active{>.", k, "-menu-item-title{color:", menu.light.active.color, "!important;background:", menu.light.active.bgColor, ";}}.", k, "-sub-menu{.", k, "-menu-item-title,.", k, "-menu-item-arrow{color:", menu.light.item.subTitleColor, "!important;}}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
116
116
|
var styles = menu[size];
|
|
117
117
|
return /*#__PURE__*/css("&.", k, "-", size, "{width:", styles.width, ";font-size:", styles.fontSize, ";.", k, "-menu{font-size:", styles.fontSize, ";}.", k, "-menu-arrow-box{left:calc(", styles.width, " - 2px);}}");
|
|
118
|
-
}), "&.", k, "-collapsed{width:calc(", menu.icon.width, " + (", getLeft(menu.item.padding), " + ", getLeft(menu.item.bodyPadding), ") * 2);.", k, "-icon{margin-right:0;}.", k, "-menu-item-arrow{display:none;}}&.", k, "-collapsed-arrow{width:0px;border-left:none;.", k, "-menu-header{padding:0;}.", k, "-menu-body{overflow:hidden;padding:0;}.", k, "-menu-arrow-box{left:0;.", k, "-menu-arrow:before{transform:rotateY(180deg);}}}&.", k, "-dropdown-menu{width:fit-content;min-width:", menu.dropdown.minWidth, ";.", k, "-menu-item-arrow{transform:rotate(-90deg);}}&.", k, "-horizontal{width:auto;display:flex;.", k, "-menu-body{display:flex;align-items:center;.", k, "-menu-title{border-top:none;border-right:", menu.border, ";}}}");
|
|
118
|
+
}), "&.", k, "-collapsed{width:calc(", menu.icon.width, " + (", getLeft(menu.item.padding), " + ", getLeft(menu.item.bodyPadding), ") * 2);.", k, "-icon{margin-right:0;}.", k, "-menu-item-arrow{display:none;}}&.", k, "-collapsed-arrow{width:0px;border-left:none;.", k, "-menu-header{padding:0;}.", k, "-menu-body{overflow:hidden;padding:0;}.", k, "-menu-arrow-box{left:0;.", k, "-menu-arrow:before{transform:rotateY(180deg);}}}&.", k, "-dropdown-menu{width:fit-content;min-width:", menu.dropdown.minWidth, ";position:absolute;.", k, "-menu-item-arrow{transform:rotate(-90deg);}}&.", k, "-horizontal{width:auto;display:flex;.", k, "-menu-body{display:flex;align-items:center;.", k, "-menu-title{border-top:none;border-right:", menu.border, ";}}}");
|
|
119
119
|
});
|
|
120
120
|
export var makeTitleStyles = cache(function makeTitleStyles(k) {
|
|
121
121
|
var item = menu.item;
|