@king-design/react 2.0.11 → 2.0.13-beta.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.
- package/__tests__/__snapshots__/React Demos.md +58 -58
- package/__tests__/components/drawer.spec.tsx +18 -17
- package/components/cascader/styles.js +1 -1
- package/components/drawer/index.spec.js +48 -0
- package/components/dropdown/dropdown.d.ts +2 -1
- package/components/dropdown/dropdown.js +31 -14
- package/components/dropdown/index.spec.js +58 -0
- package/components/form/methods.d.ts +2 -1
- package/components/portal.js +9 -2
- package/components/select/styles.js +2 -2
- package/components/table/table.js +1 -1
- package/components/table/useResizeObserver.d.ts +2 -0
- package/components/table/useResizeObserver.js +20 -0
- package/components/table/useStickyScrollbar.d.ts +1 -1
- package/components/table/useStickyScrollbar.js +4 -9
- package/components/table/useWidth.js +5 -15
- package/components/timepicker/index.d.ts +1 -0
- package/components/timepicker/index.js +1 -0
- package/hooks/useDocumentClick.js +29 -2
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +2 -2
- package/yarn-error.log +543 -0
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import React, {createRef} from 'react';
|
|
1
|
+
import React, {createRef, useState} from 'react';
|
|
2
2
|
import * as ReactDOM from 'react-dom';
|
|
3
3
|
import {Drawer, Card, Button} from '../../';
|
|
4
4
|
import {Component} from 'intact-react';
|
|
5
5
|
import {getElement, wait, dispatchEvent} from '../../../../test/utils';
|
|
6
6
|
|
|
7
7
|
describe('Drawer', () => {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
let container: HTMLDivElement;
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
container = document.createElement('div');
|
|
10
11
|
document.body.appendChild(container);
|
|
12
|
+
});
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
15
|
+
document.body.removeChild(container);
|
|
16
|
+
});
|
|
11
17
|
|
|
18
|
+
it('should render react element correctly', async () => {
|
|
12
19
|
class Test extends Component {
|
|
13
20
|
static template = `<div ref="a">test</div>`;
|
|
14
21
|
mounted() {
|
|
@@ -16,23 +23,20 @@ describe('Drawer', () => {
|
|
|
16
23
|
}
|
|
17
24
|
}
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
function App() {
|
|
27
|
+
const [show, setShow] = useState(false);
|
|
28
|
+
return <Card>
|
|
29
|
+
<div onClick={() => setShow(true)}>show</div>
|
|
30
|
+
<Drawer value={show} mode="destroy">
|
|
22
31
|
<div><Test /></div>
|
|
23
32
|
</Drawer>
|
|
24
|
-
</Card
|
|
25
|
-
|
|
26
|
-
);
|
|
33
|
+
</Card>;
|
|
34
|
+
}
|
|
27
35
|
|
|
28
|
-
ReactDOM.
|
|
29
|
-
document.body.removeChild(container);
|
|
36
|
+
ReactDOM.render(<App />, container);
|
|
30
37
|
});
|
|
31
38
|
|
|
32
39
|
it('should handle event correctly', async () => {
|
|
33
|
-
const container = document.createElement('div');
|
|
34
|
-
document.body.appendChild(container);
|
|
35
|
-
|
|
36
40
|
const click1 = sinon.spy(() => console.log(1));
|
|
37
41
|
const click2 = sinon.spy(() => console.log(2));
|
|
38
42
|
|
|
@@ -62,8 +66,5 @@ describe('Drawer', () => {
|
|
|
62
66
|
dispatchEvent(element2, 'click');
|
|
63
67
|
await wait();
|
|
64
68
|
expect(click2.callCount).to.eql(1);
|
|
65
|
-
|
|
66
|
-
// ReactDOM.unmountComponentAtNode(container);
|
|
67
|
-
// document.body.removeChild(container);
|
|
68
69
|
});
|
|
69
70
|
});
|
|
@@ -43,7 +43,7 @@ setDefault(function () {
|
|
|
43
43
|
}).cascader;
|
|
44
44
|
});
|
|
45
45
|
export function makeMenuStyles() {
|
|
46
|
-
return /*#__PURE__*/css("min-width:", cascader.width, "!important;height:", cascader.height, ";.k-cascader-arrow{float:right;height:100%;margin-left:", cascader.arrowGap, ";line-height:inherit;}.k-cascader-loading{display:block;text-align:center;margin-top:", cascader.loadingGap, ";}.k-cascader-empty{padding:", cascader.empty.padding, ";color:", cascader.empty.color, ";text-align:center;}.k-cascader-option{&.k-selected{color:", cascader.selectedColor, ";}&.k-active{background:", cascader.activeBgColor, ";}}");
|
|
46
|
+
return /*#__PURE__*/css("min-width:", cascader.width, "!important;min-height:", cascader.height, ";.k-cascader-arrow{float:right;height:100%;margin-left:", cascader.arrowGap, ";line-height:inherit;}.k-cascader-loading{display:block;text-align:center;margin-top:", cascader.loadingGap, ";}.k-cascader-empty{padding:", cascader.empty.padding, ";color:", cascader.empty.color, ";text-align:center;}.k-cascader-option{&.k-selected{color:", cascader.selectedColor, ";}&.k-active{background:", cascader.activeBgColor, ";}}");
|
|
47
47
|
}
|
|
48
48
|
export function makeFilterMenuStyles() {
|
|
49
49
|
return /*#__PURE__*/css("min-width:", _filterInstanceProperty(cascader).minWidth, "!important;height:auto;max-height:", _filterInstanceProperty(cascader).maxHeight, ";em{font-style:normal;color:", _filterInstanceProperty(cascader).highlightColor, ";}");
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
2
4
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
5
|
import BasicDemo from '~/components/drawer/demos/basic';
|
|
4
6
|
import PlacementDemo from '~/components/drawer/demos/placement';
|
|
5
7
|
import overlayDemo from '~/components/drawer/demos/overlay';
|
|
6
8
|
import { mount, unmount, dispatchEvent, getElement, wait } from '../../test/utils';
|
|
9
|
+
import { Component } from 'intact-react';
|
|
10
|
+
import { Drawer } from '.';
|
|
11
|
+
import { Dialog } from '../dialog';
|
|
7
12
|
describe('Drawer', function () {
|
|
8
13
|
afterEach(function (done) {
|
|
9
14
|
unmount();
|
|
@@ -159,4 +164,47 @@ describe('Drawer', function () {
|
|
|
159
164
|
}
|
|
160
165
|
}, _callee4);
|
|
161
166
|
})));
|
|
167
|
+
it('nested dialog', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
168
|
+
var Demo, _mount4, instance, element;
|
|
169
|
+
|
|
170
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context6) {
|
|
171
|
+
while (1) {
|
|
172
|
+
switch (_context6.prev = _context6.next) {
|
|
173
|
+
case 0:
|
|
174
|
+
Demo = /*#__PURE__*/function (_Component) {
|
|
175
|
+
_inheritsLoose(Demo, _Component);
|
|
176
|
+
|
|
177
|
+
function Demo() {
|
|
178
|
+
var _context5;
|
|
179
|
+
|
|
180
|
+
var _this;
|
|
181
|
+
|
|
182
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
183
|
+
args[_key] = arguments[_key];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context5 = [this]).call(_context5, args)) || this;
|
|
187
|
+
_this.Dialog = Dialog;
|
|
188
|
+
_this.Drawer = Drawer;
|
|
189
|
+
return _this;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return Demo;
|
|
193
|
+
}(Component);
|
|
194
|
+
|
|
195
|
+
Demo.template = "\n const {Dialog, Drawer} = this;\n <Drawer value={true}>\n <Dialog value={true} ref=\"dialog\">Dialog</Dialog>\n </Drawer>\n ";
|
|
196
|
+
_mount4 = mount(Demo), instance = _mount4[0], element = _mount4[1];
|
|
197
|
+
_context6.next = 5;
|
|
198
|
+
return wait();
|
|
199
|
+
|
|
200
|
+
case 5:
|
|
201
|
+
expect(instance.refs.dialog.dialogRef.value.parentElement.parentElement).to.eql(document.body);
|
|
202
|
+
|
|
203
|
+
case 6:
|
|
204
|
+
case "end":
|
|
205
|
+
return _context6.stop();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}, _callee5);
|
|
209
|
+
})));
|
|
162
210
|
});
|
|
@@ -8,7 +8,7 @@ export declare type PositionShorthand = 'left' | 'bottom' | 'right' | 'top';
|
|
|
8
8
|
export declare const DROPDOWN = "Dropdown";
|
|
9
9
|
export declare const ROOT_DROPDOWN = "RootDropdown";
|
|
10
10
|
export interface DropdownProps {
|
|
11
|
-
trigger?: 'hover' | 'click' | 'contextmenu';
|
|
11
|
+
trigger?: 'hover' | 'click' | 'contextmenu' | 'focus';
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
value?: boolean;
|
|
14
14
|
position?: Position | 'left' | 'bottom' | 'right' | 'top';
|
|
@@ -52,6 +52,7 @@ export declare class Dropdown<T extends DropdownProps = DropdownProps, E extends
|
|
|
52
52
|
private onEnter;
|
|
53
53
|
private onContextMenu;
|
|
54
54
|
private onLeave;
|
|
55
|
+
private initEventCallbacks;
|
|
55
56
|
private callOriginalCallback;
|
|
56
57
|
private normalizeTriggerProps;
|
|
57
58
|
}
|
|
@@ -14,7 +14,7 @@ import { usePosition } from './usePosition';
|
|
|
14
14
|
export var DROPDOWN = 'Dropdown';
|
|
15
15
|
export var ROOT_DROPDOWN = 'RootDropdown';
|
|
16
16
|
var typeDefs = {
|
|
17
|
-
trigger: ['hover', 'click', 'contextmenu'],
|
|
17
|
+
trigger: ['hover', 'click', 'contextmenu', 'focus'],
|
|
18
18
|
disabled: Boolean,
|
|
19
19
|
value: Boolean,
|
|
20
20
|
position: [Object, 'left', 'bottom', 'right', 'top'],
|
|
@@ -154,6 +154,33 @@ export var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
154
154
|
this.hide();
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
+
_proto.initEventCallbacks = function initEventCallbacks(trigger) {
|
|
158
|
+
var props = {};
|
|
159
|
+
|
|
160
|
+
switch (trigger) {
|
|
161
|
+
case 'focus':
|
|
162
|
+
props['ev-focusin'] = this.onEnter;
|
|
163
|
+
props['ev-focusout'] = this.onLeave;
|
|
164
|
+
break;
|
|
165
|
+
|
|
166
|
+
case 'contextmenu':
|
|
167
|
+
props['ev-contextmenu'] = this.onContextMenu;
|
|
168
|
+
break;
|
|
169
|
+
|
|
170
|
+
default:
|
|
171
|
+
props['ev-click'] = this.onEnter;
|
|
172
|
+
|
|
173
|
+
if (trigger === 'hover') {
|
|
174
|
+
props['ev-mouseenter'] = this.onEnter;
|
|
175
|
+
props['ev-mouseleave'] = this.onLeave;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return props;
|
|
182
|
+
};
|
|
183
|
+
|
|
157
184
|
_proto.callOriginalCallback = function callOriginalCallback(name, e) {
|
|
158
185
|
var callback = this.triggerProps[name];
|
|
159
186
|
var callbackOnDropdown = this.get(name);
|
|
@@ -229,19 +256,7 @@ Dropdown.template = function () {
|
|
|
229
256
|
trigger = _children[0],
|
|
230
257
|
menu = _children[1];
|
|
231
258
|
var triggerType = this.get('trigger');
|
|
232
|
-
var props =
|
|
233
|
-
|
|
234
|
-
if (triggerType !== 'contextmenu') {
|
|
235
|
-
props['ev-click'] = this.onEnter;
|
|
236
|
-
|
|
237
|
-
if (triggerType === 'hover') {
|
|
238
|
-
props['ev-mouseenter'] = this.onEnter;
|
|
239
|
-
props['ev-mouseleave'] = this.onLeave;
|
|
240
|
-
}
|
|
241
|
-
} else {
|
|
242
|
-
props['ev-contextmenu'] = this.onContextMenu;
|
|
243
|
-
}
|
|
244
|
-
|
|
259
|
+
var props = this.initEventCallbacks(triggerType);
|
|
245
260
|
var clonedTrigger = isTextChildren(trigger) ? createVNode('span', null, trigger) : directClone(trigger);
|
|
246
261
|
var triggerProps = this.triggerProps = this.normalizeTriggerProps(trigger.props || EMPTY_OBJ); // add a className for opening status
|
|
247
262
|
|
|
@@ -275,7 +290,9 @@ function useDocumentClickForDropdown(dropdown) {
|
|
|
275
290
|
var _useDocumentClick = useDocumentClick(elementRef, function (e) {
|
|
276
291
|
// case 1: if click an trigger and the trigger type is hover, ignore it
|
|
277
292
|
// case 2: if right click on trigger and the trigger type is contextmenu, ignore it
|
|
293
|
+
// case 3: if click on trigger and the trigger type is focus, do nothing
|
|
278
294
|
var trigger = dropdown.get('trigger');
|
|
295
|
+
if (trigger === 'focus') return;
|
|
279
296
|
var isHover = trigger === 'hover';
|
|
280
297
|
|
|
281
298
|
if (isHover || trigger === 'contextmenu') {
|
|
@@ -483,4 +483,62 @@ describe('Dropdown', function () {
|
|
|
483
483
|
}
|
|
484
484
|
}, _callee9);
|
|
485
485
|
})));
|
|
486
|
+
it('trigger: focus', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
487
|
+
var Demo, _mount9, instance;
|
|
488
|
+
|
|
489
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context14) {
|
|
490
|
+
while (1) {
|
|
491
|
+
switch (_context14.prev = _context14.next) {
|
|
492
|
+
case 0:
|
|
493
|
+
Demo = /*#__PURE__*/function (_Component4) {
|
|
494
|
+
_inheritsLoose(Demo, _Component4);
|
|
495
|
+
|
|
496
|
+
function Demo() {
|
|
497
|
+
var _context13;
|
|
498
|
+
|
|
499
|
+
var _this4;
|
|
500
|
+
|
|
501
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
502
|
+
args[_key4] = arguments[_key4];
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
_this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context13 = [this]).call(_context13, args)) || this;
|
|
506
|
+
_this4.Dropdown = Dropdown;
|
|
507
|
+
_this4.DropdownItem = DropdownItem;
|
|
508
|
+
_this4.DropdownMenu = DropdownMenu;
|
|
509
|
+
return _this4;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return Demo;
|
|
513
|
+
}(Component);
|
|
514
|
+
|
|
515
|
+
Demo.template = "\n const {Dropdown, DropdownMenu, DropdownItem} = this;\n <div>\n <Dropdown trigger=\"focus\">\n <input ref=\"trigger\" />\n <DropdownMenu>\n <DropdownItem>test1</DropdownItem>\n <DropdownItem>test2</DropdownItem>\n </DropdownMenu>\n </Dropdown>\n </div>\n ";
|
|
516
|
+
_mount9 = mount(Demo), instance = _mount9[0];
|
|
517
|
+
dispatchEvent(instance.refs.trigger, 'focusin');
|
|
518
|
+
_context14.next = 6;
|
|
519
|
+
return wait(500);
|
|
520
|
+
|
|
521
|
+
case 6:
|
|
522
|
+
expect(getElement('.k-dropdown-menu')).to.be.exist; // clicking anywhere should not hide menu
|
|
523
|
+
|
|
524
|
+
dispatchEvent(document, 'click');
|
|
525
|
+
_context14.next = 10;
|
|
526
|
+
return wait(500);
|
|
527
|
+
|
|
528
|
+
case 10:
|
|
529
|
+
expect(getElement('.k-dropdown-menu')).to.be.exist;
|
|
530
|
+
dispatchEvent(instance.refs.trigger, 'focusout');
|
|
531
|
+
_context14.next = 14;
|
|
532
|
+
return wait(700);
|
|
533
|
+
|
|
534
|
+
case 14:
|
|
535
|
+
expect(getElement('.k-dropdown-menu')).to.not.be.exist;
|
|
536
|
+
|
|
537
|
+
case 15:
|
|
538
|
+
case "end":
|
|
539
|
+
return _context14.stop();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}, _callee10);
|
|
543
|
+
})));
|
|
486
544
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare type
|
|
1
|
+
export declare type MethodReturn = boolean | string;
|
|
2
|
+
export declare type Method = (value: any, param: any) => MethodReturn | Promise<MethodReturn>;
|
|
2
3
|
export declare type Message = string | ((value: any, param: any) => string);
|
|
3
4
|
export declare type ClassName = string | ((value: any, param: any) => string);
|
|
4
5
|
export declare const methods: Record<string, Method>;
|
package/components/portal.js
CHANGED
|
@@ -3,6 +3,7 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/con
|
|
|
3
3
|
import { Component, createCommentVNode, createTextVNode, mount, patch, remove, inject } from 'intact-react';
|
|
4
4
|
import { isString } from 'intact-shared';
|
|
5
5
|
import { DIALOG } from './dialog/constants';
|
|
6
|
+
import { BaseDialog } from './dialog/base';
|
|
6
7
|
var typeDefs = {
|
|
7
8
|
container: [String, Function]
|
|
8
9
|
};
|
|
@@ -96,8 +97,13 @@ export var Portal = /*#__PURE__*/function (_Component) {
|
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
if (!this.container) {
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
if (this.$senior instanceof BaseDialog) {
|
|
101
|
+
// Dialog and Drawer must be inserted into document.body
|
|
102
|
+
this.container = document.body;
|
|
103
|
+
} else {
|
|
104
|
+
// find the closest dialog if exists
|
|
105
|
+
this.container = parentDom.closest('.k-dialog') || document.body;
|
|
106
|
+
}
|
|
101
107
|
/**
|
|
102
108
|
* @FIXME: We cannot get parent ref from sub component in Vue
|
|
103
109
|
*/
|
|
@@ -108,6 +114,7 @@ export var Portal = /*#__PURE__*/function (_Component) {
|
|
|
108
114
|
// } else {
|
|
109
115
|
// this.container = document.body;
|
|
110
116
|
// }
|
|
117
|
+
|
|
111
118
|
}
|
|
112
119
|
};
|
|
113
120
|
|
|
@@ -94,7 +94,7 @@ var defaults = deepDefaults({
|
|
|
94
94
|
},
|
|
95
95
|
tag: {
|
|
96
96
|
margin: "3px 8px 3px 0",
|
|
97
|
-
padding: "
|
|
97
|
+
padding: "3px 8px",
|
|
98
98
|
|
|
99
99
|
get borderRadius() {
|
|
100
100
|
return theme.borderRadius;
|
|
@@ -188,7 +188,7 @@ setDefault(function () {
|
|
|
188
188
|
}).select;
|
|
189
189
|
});
|
|
190
190
|
export default function makeStyles() {
|
|
191
|
-
return /*#__PURE__*/css("display:inline-flex;align-items:center;vertical-align:middle;position:relative;width:", select.width, ";cursor:pointer;outline:none;border:", select.border, ";background:", select.bgColor, ";transition:border ", select.transition, ",background ", select.transition, ",box-shadow ", select.transition, ";border-radius:", select.borderRadius, ";.k-select-main{flex:1;min-width:0;}.k-select-prefix,.k-select-suffix{color:", select.iconColor, ";position:relative;}.k-select-suffix{margin-left:", select.suffixGap, ";}.k-select-placeholder{color:", select.placeholderColor, ";user-select:none;}&.k-fluid{width:100%;}.k-select-clear{opacity:0;transition:opacity ", select.transition, ",color ", select.transition, "!important;pointer-events:none;position:absolute;z-index:1;top:50%;left:50%;transform:translate(-50%, -50%);}&:hover{border:", select.hoverBorder, ";.k-select-clear.k-show{opacity:1;pointer-events:all;+.k-select-suffix-icon{opacity:0;}}}.k-select-suffix-icon{display:inline-block;transition:opacity ", select.transition, ";}.k-select-arrow{display:inline-block;transition:transform ", select.transition, ";&.k-disabled{color:", select.disabledArrowColor, ";}}&.k-dropdown-open{border:", select.focusBorder, ";.k-select-arrow{transform:rotateX(180deg);}}&:focus{outline:none;border:", select.focusBorder, ";}&.k-disabled{color:", select.disabled.color, ";cursor:not-allowed;background:", select.disabled.bgColor, ";border-color:", select.disabled.borderColor, ";.k-select-tag{background:", select.tag.disabledBgColor, ";}}.k-select-values{display:inline-block;margin-right:-", getRight(select.tag.margin), "
|
|
191
|
+
return /*#__PURE__*/css("display:inline-flex;align-items:center;vertical-align:middle;position:relative;width:", select.width, ";cursor:pointer;outline:none;border:", select.border, ";background:", select.bgColor, ";transition:border ", select.transition, ",background ", select.transition, ",box-shadow ", select.transition, ";border-radius:", select.borderRadius, ";.k-select-main{flex:1;min-width:0;}.k-select-prefix,.k-select-suffix{color:", select.iconColor, ";position:relative;}.k-select-suffix{margin-left:", select.suffixGap, ";}.k-select-placeholder{color:", select.placeholderColor, ";user-select:none;}&.k-fluid{width:100%;}.k-select-clear{opacity:0;transition:opacity ", select.transition, ",color ", select.transition, "!important;pointer-events:none;position:absolute;z-index:1;top:50%;left:50%;transform:translate(-50%, -50%);}&:hover{border:", select.hoverBorder, ";.k-select-clear.k-show{opacity:1;pointer-events:all;+.k-select-suffix-icon{opacity:0;}}}.k-select-suffix-icon{display:inline-block;transition:opacity ", select.transition, ";}.k-select-arrow{display:inline-block;transition:transform ", select.transition, ";&.k-disabled{color:", select.disabledArrowColor, ";}}&.k-dropdown-open{border:", select.focusBorder, ";.k-select-arrow{transform:rotateX(180deg);}}&:focus{outline:none;border:", select.focusBorder, ";}&.k-disabled{color:", select.disabled.color, ";cursor:not-allowed;background:", select.disabled.bgColor, ";border-color:", select.disabled.borderColor, ";.k-select-tag{background:", select.tag.disabledBgColor, ";}}.k-select-values{display:inline-block;margin-right:-", getRight(select.tag.margin), ";width:100%;&.k-with-values{margin:0;}}.k-select-tag{display:inline-flex;align-items:center;padding:", select.tag.padding, ";background:", select.tag.bgColor, ";border-radius:", select.tag.borderRadius, ";margin:", select.tag.margin, ";max-width:calc(100% - ", getRight(select.tag.margin), " - 1px);}.k-select-text{max-width:calc(100% - 18px);word-break:break-word;}.k-select-close{margin-left:", select.tag.delete.gap, ";font-size:", select.tag.delete.fontSize, ";color:", select.tag.delete.color, ";}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
192
192
|
var styles = select[size];
|
|
193
193
|
var className = /*#__PURE__*/css("font-size:", styles.fontSize, ";min-height:", styles.height, ";padding:", styles.padding, ";");
|
|
194
194
|
if (size === 'default') return className;
|
|
@@ -106,7 +106,7 @@ export var Table = /*#__PURE__*/function (_Component) {
|
|
|
106
106
|
_this.selected = useSelected();
|
|
107
107
|
_this.resetRowStatus = useRestRowStatus(_this.disableRow.getAllKeys);
|
|
108
108
|
_this.draggable = useDraggable();
|
|
109
|
-
_this.stickyScrollbar = useStickyScrollbar(_this.stickyHeader.elementRef, _this.scroll, _this.width.tableRef, _this.fixedColumns.setScrollPosition
|
|
109
|
+
_this.stickyScrollbar = useStickyScrollbar(_this.stickyHeader.elementRef, _this.scroll, _this.width.tableRef, _this.fixedColumns.setScrollPosition);
|
|
110
110
|
return _this;
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { onMounted, onBeforeUnmount, useInstance } from 'intact-react';
|
|
2
|
+
import { debounce } from '../utils';
|
|
3
|
+
import ResizeObserver from 'resize-observer-polyfill';
|
|
4
|
+
export function useResizeObserver(elementRef, callback) {
|
|
5
|
+
var instance = useInstance();
|
|
6
|
+
var ro;
|
|
7
|
+
onMounted(function () {
|
|
8
|
+
// use debounce instead of throttle, because if there is
|
|
9
|
+
// transition on parent container, the width is weired
|
|
10
|
+
// #342
|
|
11
|
+
ro = new ResizeObserver(debounce(function () {
|
|
12
|
+
if (instance.$unmounted) return;
|
|
13
|
+
callback();
|
|
14
|
+
}, 100, true));
|
|
15
|
+
ro.observe(elementRef.value);
|
|
16
|
+
});
|
|
17
|
+
onBeforeUnmount(function () {
|
|
18
|
+
ro.disconnect();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -2,7 +2,7 @@ import { RefObject } from 'intact-react';
|
|
|
2
2
|
import { ShouldFixParam } from '../affix';
|
|
3
3
|
import { State } from '../../hooks/useState';
|
|
4
4
|
import type { useScroll } from './useScroll';
|
|
5
|
-
export declare function useStickyScrollbar(elementRef: RefObject<HTMLElement>, { scrollRef, callbacks }: ReturnType<typeof useScroll>, tableRef: RefObject<HTMLElement>, tableScroll: (scrollLeft: number) => void
|
|
5
|
+
export declare function useStickyScrollbar(elementRef: RefObject<HTMLElement>, { scrollRef, callbacks }: ReturnType<typeof useScroll>, tableRef: RefObject<HTMLElement>, tableScroll: (scrollLeft: number) => void): {
|
|
6
6
|
shouldStickScrollbar: ({ offsetBottom, viewportHeight }: ShouldFixParam) => boolean;
|
|
7
7
|
stick: State<number | null>;
|
|
8
8
|
style: State<Record<string, string> | null>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createRef, useInstance, onMounted, nextTick } from 'intact-react';
|
|
2
|
-
import { useState
|
|
2
|
+
import { useState } from '../../hooks/useState';
|
|
3
3
|
import { isStringOrNumber, isNull } from 'intact-shared';
|
|
4
4
|
import { debounce } from '../utils';
|
|
5
|
-
|
|
5
|
+
import { useResizeObserver } from './useResizeObserver';
|
|
6
|
+
export function useStickyScrollbar(elementRef, _ref, tableRef, tableScroll) {
|
|
6
7
|
var scrollRef = _ref.scrollRef,
|
|
7
8
|
callbacks = _ref.callbacks;
|
|
8
9
|
var instance = useInstance();
|
|
@@ -13,13 +14,7 @@ export function useStickyScrollbar(elementRef, _ref, tableRef, tableScroll, tabl
|
|
|
13
14
|
instance.on('$receive:stickScrollbar', function (v) {
|
|
14
15
|
stick.set(v === true ? 0 : isStringOrNumber(v) ? +v : null);
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
if (v) {
|
|
18
|
-
tableActualWidth.set(v + 'px');
|
|
19
|
-
} else {
|
|
20
|
-
setTableActualWidth();
|
|
21
|
-
}
|
|
22
|
-
});
|
|
17
|
+
useResizeObserver(scrollRef, setTableActualWidth);
|
|
23
18
|
onMounted(function () {
|
|
24
19
|
setTableActualWidth();
|
|
25
20
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
2
2
|
import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
3
|
-
import { useInstance, onMounted,
|
|
4
|
-
import ResizeObserver from 'resize-observer-polyfill';
|
|
3
|
+
import { useInstance, onMounted, createRef } from 'intact-react';
|
|
5
4
|
import { useState } from '../../hooks/useState';
|
|
6
|
-
import { debounce } from '../utils';
|
|
7
5
|
import { scrollbarWidth } from '../position';
|
|
6
|
+
import { useResizeObserver } from './useResizeObserver';
|
|
8
7
|
var hasLocalStorage = typeof localStorage !== 'undefined';
|
|
9
8
|
export function useWidth(scrollRef, getColumns) {
|
|
10
9
|
var instance = useInstance();
|
|
@@ -12,20 +11,11 @@ export function useWidth(scrollRef, getColumns) {
|
|
|
12
11
|
var widthMap = useState({});
|
|
13
12
|
var tableWidth = useState(null);
|
|
14
13
|
initWidthFromStore();
|
|
15
|
-
var ro;
|
|
16
14
|
onMounted(function () {
|
|
17
|
-
checkTableWidth(true);
|
|
18
|
-
// transition on parent container, the width is weired
|
|
19
|
-
// #342
|
|
20
|
-
|
|
21
|
-
ro = new ResizeObserver(debounce(function () {
|
|
22
|
-
if (instance.$unmounted) return;
|
|
23
|
-
checkTableWidth(false);
|
|
24
|
-
}, 100, true));
|
|
25
|
-
ro.observe(scrollRef.value);
|
|
15
|
+
return checkTableWidth(true);
|
|
26
16
|
});
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
useResizeObserver(scrollRef, function () {
|
|
18
|
+
return checkTableWidth(false);
|
|
29
19
|
}); // if exist widthStoreKey, we get the default width from localStorage
|
|
30
20
|
|
|
31
21
|
function initWidthFromStore() {
|
|
@@ -3,6 +3,7 @@ import { TimepickerProps, TimepickerEvents, TimepickerBlocks } from './constants
|
|
|
3
3
|
import { SelectPicker } from './selectPicker';
|
|
4
4
|
export type { TimepickerProps, TimepickerEvents, TimepickerBlocks };
|
|
5
5
|
export declare class Timepicker<Multipe extends boolean = false, Range extends boolean = false> extends Component<TimepickerProps<Multipe, Range>, TimepickerEvents, TimepickerBlocks<Range>> {
|
|
6
|
+
static $doubleVNodes: boolean;
|
|
6
7
|
static template(this: Timepicker): import("intact").VNode<typeof SelectPicker>;
|
|
7
8
|
static typeDefs: Required<import("intact").TypeDefs<TimepickerProps<boolean, boolean>>>;
|
|
8
9
|
}
|
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
import { onMounted, onUnmounted } from 'intact-react';
|
|
2
|
-
import { isFunction } from 'intact-shared';
|
|
2
|
+
import { isFunction } from 'intact-shared'; // @reference: Vue3.0
|
|
3
|
+
|
|
4
|
+
var getNow = Date.now; // Determine what event timestamp the browser is using. Annoyingly, the
|
|
5
|
+
// timestamp can either be hi-res (relative to page load) or low-res
|
|
6
|
+
// (relative to UNIX epoch), so in order to compare time we have to use the
|
|
7
|
+
// same timestamp type when saving the flush timestamp.
|
|
8
|
+
|
|
9
|
+
if (getNow() > document.createEvent('Event').timeStamp) {
|
|
10
|
+
// if the low-res timestamp which is bigger than the event timestamp
|
|
11
|
+
// (which is evaluated AFTER) it means the event is using a hi-res timestamp,
|
|
12
|
+
// and we need to use the hi-res version for event listeners as well.
|
|
13
|
+
getNow = function getNow() {
|
|
14
|
+
return performance.now();
|
|
15
|
+
};
|
|
16
|
+
} // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
|
|
17
|
+
// and does not fire microtasks in between event propagation, so safe to exclude.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
|
|
21
|
+
var skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
|
|
3
22
|
export function useDocumentClick(ref, callback, manual) {
|
|
4
23
|
if (manual === void 0) {
|
|
5
24
|
manual = false;
|
|
6
25
|
}
|
|
7
26
|
|
|
8
27
|
var onDocumentClick = function onDocumentClick(e) {
|
|
9
|
-
if (e._ignore) return;
|
|
28
|
+
if (e._ignore) return; // https://github.com/ksc-fe/kpc/issues/788
|
|
29
|
+
|
|
30
|
+
var timeStamp = e.timeStamp || getNow();
|
|
31
|
+
|
|
32
|
+
if (!skipTimestampCheck && onDocumentClick.timeStamp > timeStamp + 1) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
10
36
|
var target = e.target;
|
|
11
37
|
var elem = isFunction(ref) ? ref() : ref.value;
|
|
12
38
|
if (containsOrEqual(elem, target)) return;
|
|
@@ -14,6 +40,7 @@ export function useDocumentClick(ref, callback, manual) {
|
|
|
14
40
|
};
|
|
15
41
|
|
|
16
42
|
var add = function add() {
|
|
43
|
+
onDocumentClick.timeStamp = getNow();
|
|
17
44
|
document.addEventListener('click', onDocumentClick);
|
|
18
45
|
document.addEventListener('contextmenu', onDocumentClick);
|
|
19
46
|
};
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.0.
|
|
2
|
+
* @king-design v2.0.13-beta.0
|
|
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.
|
|
60
|
+
export declare const version = "2.0.13-beta.0";
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
export {normalize} from 'intact-react';
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.0.
|
|
2
|
+
* @king-design v2.0.13-beta.0
|
|
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.
|
|
62
|
+
export var version = '2.0.13-beta.0';
|
|
63
63
|
/* generate end */
|
|
64
64
|
|
|
65
65
|
export {normalize} from 'intact-react';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@king-design/react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13-beta.0",
|
|
4
4
|
"description": "King-Design UI components for React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"component",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dayjs": "^1.10.7",
|
|
38
38
|
"downloadjs": "^1.4.7",
|
|
39
39
|
"enquire.js": "^2.1.6",
|
|
40
|
-
"intact-react": "3.0.
|
|
40
|
+
"intact-react": "3.0.13",
|
|
41
41
|
"monaco-editor": "^0.26.1",
|
|
42
42
|
"mxgraphx": "^4.0.7",
|
|
43
43
|
"resize-observer-polyfill": "^1.5.1",
|