@king-design/intact 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/components/cascader/styles.ts +1 -1
- package/components/drawer/index.spec.ts +20 -0
- package/components/dropdown/demos/trigger.md +13 -2
- package/components/dropdown/dropdown.ts +29 -13
- package/components/dropdown/index.md +1 -1
- package/components/dropdown/index.spec.ts +34 -0
- package/components/form/demos/basic.md +1 -1
- package/components/form/index.md +7 -4
- package/components/form/methods.ts +2 -1
- package/components/portal.ts +8 -2
- package/components/select/demos/format.md +3 -2
- package/components/select/styles.ts +10 -5
- package/components/table/table.ts +0 -1
- package/components/table/useResizeObserver.ts +22 -0
- package/components/table/useStickyScrollbar.ts +2 -8
- package/components/table/useWidth.ts +4 -18
- package/components/timepicker/index.ts +1 -0
- package/components/tooltip/demos/trigger.md +5 -2
- package/components/tooltip/index.md +1 -1
- package/es/components/cascader/styles.js +1 -1
- package/es/components/drawer/index.spec.js +48 -0
- package/es/components/dropdown/dropdown.d.ts +2 -1
- package/es/components/dropdown/dropdown.js +31 -14
- package/es/components/dropdown/index.spec.js +58 -0
- package/es/components/form/methods.d.ts +2 -1
- package/es/components/portal.js +9 -2
- package/es/components/select/styles.js +2 -2
- package/es/components/table/table.js +1 -1
- package/es/components/table/useResizeObserver.d.ts +2 -0
- package/es/components/table/useResizeObserver.js +20 -0
- package/es/components/table/useStickyScrollbar.d.ts +1 -1
- package/es/components/table/useStickyScrollbar.js +4 -9
- package/es/components/table/useWidth.js +5 -15
- package/es/components/timepicker/index.d.ts +1 -0
- package/es/components/timepicker/index.js +1 -0
- package/es/hooks/useDocumentClick.js +29 -2
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/packages/kpc-react/__tests__/components/drawer.spec.js +34 -18
- package/es/site/data/components/dropdown/demos/trigger/react.js +6 -2
- package/es/site/data/components/select/demos/format/react.js +1 -1
- package/es/site/data/components/tooltip/demos/trigger/react.js +7 -2
- package/hooks/useDocumentClick.ts +29 -1
- package/index.ts +2 -2
- package/package.json +3 -3
- package/dist/fonts/ionicons.eot +0 -0
- package/dist/fonts/ionicons.svg +0 -2230
- package/dist/fonts/ionicons.ttf +0 -0
- package/dist/fonts/ionicons.woff +0 -0
- package/dist/i18n/en-US.js +0 -218
- package/dist/i18n/en-US.min.js +0 -1
- package/dist/kpc.css +0 -3
- package/dist/kpc.js +0 -39860
- package/dist/kpc.min.js +0 -1
- package/dist/kpc.react.js +0 -90483
- package/dist/kpc.react.min.js +0 -1
- package/dist/kpc.vue.js +0 -48096
- package/dist/kpc.vue.min.js +0 -1
- package/dist/ksyun.css +0 -3
|
@@ -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/es/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';
|
|
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";
|
|
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';
|
|
|
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';
|
|
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';
|
|
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';
|
|
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/es/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,4 +57,4 @@ 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";
|
package/es/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,5 +59,5 @@ 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 */
|
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
4
|
-
import React from 'react';
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
5
|
import * as ReactDOM from 'react-dom';
|
|
6
6
|
import { Drawer, Card, Button } from '../../';
|
|
7
7
|
import { Component } from 'intact-react';
|
|
8
8
|
import { wait, dispatchEvent } from '../../../../test/utils';
|
|
9
9
|
describe('Drawer', function () {
|
|
10
|
+
var container;
|
|
11
|
+
beforeEach(function () {
|
|
12
|
+
container = document.createElement('div');
|
|
13
|
+
document.body.appendChild(container);
|
|
14
|
+
});
|
|
15
|
+
afterEach(function () {
|
|
16
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
17
|
+
document.body.removeChild(container);
|
|
18
|
+
});
|
|
10
19
|
it('should render react element correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
11
|
-
var
|
|
20
|
+
var Test, App;
|
|
12
21
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
13
22
|
while (1) {
|
|
14
23
|
switch (_context.prev = _context.next) {
|
|
15
24
|
case 0:
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
App = function _App() {
|
|
26
|
+
var _useState = useState(false),
|
|
27
|
+
show = _useState[0],
|
|
28
|
+
setShow = _useState[1];
|
|
29
|
+
|
|
30
|
+
return /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
onClick: function onClick() {
|
|
32
|
+
return setShow(true);
|
|
33
|
+
}
|
|
34
|
+
}, "show"), /*#__PURE__*/React.createElement(Drawer, {
|
|
35
|
+
value: show,
|
|
36
|
+
mode: "destroy"
|
|
37
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Test, null))));
|
|
38
|
+
};
|
|
18
39
|
|
|
19
40
|
Test = /*#__PURE__*/function (_Component) {
|
|
20
41
|
_inheritsLoose(Test, _Component);
|
|
@@ -33,11 +54,9 @@ describe('Drawer', function () {
|
|
|
33
54
|
}(Component);
|
|
34
55
|
|
|
35
56
|
Test.template = "<div ref=\"a\">test</div>";
|
|
36
|
-
ReactDOM.render( /*#__PURE__*/React.createElement(
|
|
37
|
-
ReactDOM.unmountComponentAtNode(container);
|
|
38
|
-
document.body.removeChild(container);
|
|
57
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(App, null), container);
|
|
39
58
|
|
|
40
|
-
case
|
|
59
|
+
case 4:
|
|
41
60
|
case "end":
|
|
42
61
|
return _context.stop();
|
|
43
62
|
}
|
|
@@ -45,14 +64,12 @@ describe('Drawer', function () {
|
|
|
45
64
|
}, _callee);
|
|
46
65
|
})));
|
|
47
66
|
it('should handle event correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
48
|
-
var
|
|
67
|
+
var click1, click2, _document$querySelect, element1, element2;
|
|
49
68
|
|
|
50
69
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
51
70
|
while (1) {
|
|
52
71
|
switch (_context2.prev = _context2.next) {
|
|
53
72
|
case 0:
|
|
54
|
-
container = document.createElement('div');
|
|
55
|
-
document.body.appendChild(container);
|
|
56
73
|
click1 = sinon.spy(function () {
|
|
57
74
|
return console.log(1);
|
|
58
75
|
});
|
|
@@ -83,20 +100,19 @@ describe('Drawer', function () {
|
|
|
83
100
|
}, "click")))), container);
|
|
84
101
|
_document$querySelect = document.querySelectorAll('.click'), element1 = _document$querySelect[0], element2 = _document$querySelect[1];
|
|
85
102
|
dispatchEvent(element1, 'click');
|
|
86
|
-
_context2.next =
|
|
103
|
+
_context2.next = 7;
|
|
87
104
|
return wait();
|
|
88
105
|
|
|
89
|
-
case
|
|
106
|
+
case 7:
|
|
90
107
|
expect(click1.callCount).to.eql(1);
|
|
91
108
|
dispatchEvent(element2, 'click');
|
|
92
|
-
_context2.next =
|
|
109
|
+
_context2.next = 11;
|
|
93
110
|
return wait();
|
|
94
111
|
|
|
95
|
-
case
|
|
96
|
-
expect(click2.callCount).to.eql(1);
|
|
97
|
-
// document.body.removeChild(container);
|
|
112
|
+
case 11:
|
|
113
|
+
expect(click2.callCount).to.eql(1);
|
|
98
114
|
|
|
99
|
-
case
|
|
115
|
+
case 12:
|
|
100
116
|
case "end":
|
|
101
117
|
return _context2.stop();
|
|
102
118
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { Dropdown, DropdownMenu, DropdownItem, Button, Icon } from '@king-design/react';
|
|
3
|
+
import { Dropdown, DropdownMenu, DropdownItem, Button, Icon, Input } from '@king-design/react';
|
|
4
4
|
import './index.styl';
|
|
5
5
|
|
|
6
6
|
var Demo = /*#__PURE__*/function (_React$Component) {
|
|
@@ -23,7 +23,11 @@ var Demo = /*#__PURE__*/function (_React$Component) {
|
|
|
23
23
|
type: "primary"
|
|
24
24
|
}, "click ", /*#__PURE__*/React.createElement(Icon, {
|
|
25
25
|
className: "ion-ios-arrow-down"
|
|
26
|
-
})), /*#__PURE__*/React.createElement(DropdownMenu, null, /*#__PURE__*/React.createElement(DropdownItem, null, "item 1"), /*#__PURE__*/React.createElement(DropdownItem, null, "item 2"), /*#__PURE__*/React.createElement(DropdownItem, null, "item 3")))
|
|
26
|
+
})), /*#__PURE__*/React.createElement(DropdownMenu, null, /*#__PURE__*/React.createElement(DropdownItem, null, "item 1"), /*#__PURE__*/React.createElement(DropdownItem, null, "item 2"), /*#__PURE__*/React.createElement(DropdownItem, null, "item 3"))), /*#__PURE__*/React.createElement(Dropdown, {
|
|
27
|
+
trigger: "focus"
|
|
28
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
29
|
+
placeholder: "focus"
|
|
30
|
+
}), /*#__PURE__*/React.createElement(DropdownMenu, null, /*#__PURE__*/React.createElement(DropdownItem, null, "item 1"), /*#__PURE__*/React.createElement(DropdownItem, null, "item 2"), /*#__PURE__*/React.createElement(DropdownItem, null, "item 3"))));
|
|
27
31
|
};
|
|
28
32
|
|
|
29
33
|
return Demo;
|
|
@@ -95,7 +95,7 @@ var Demo = /*#__PURE__*/function (_React$Component) {
|
|
|
95
95
|
"verticalAlign": "middle"
|
|
96
96
|
}
|
|
97
97
|
}), /*#__PURE__*/React.createElement("span", {
|
|
98
|
-
className: "
|
|
98
|
+
className: "middle"
|
|
99
99
|
}, value));
|
|
100
100
|
}
|
|
101
101
|
}, _mapInstanceProperty(_context3 = ['ion-chatbubble', 'ion-person-stalker', 'ion-beer', 'ion-camera']).call(_context3, function ($value, $key) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { Tooltip, ButtonGroup, Button } from '@king-design/react';
|
|
3
|
+
import { Tooltip, ButtonGroup, Button, Input } from '@king-design/react';
|
|
4
4
|
|
|
5
5
|
var Demo = /*#__PURE__*/function (_React$Component) {
|
|
6
6
|
_inheritsLoose(Demo, _React$Component);
|
|
@@ -20,7 +20,12 @@ var Demo = /*#__PURE__*/function (_React$Component) {
|
|
|
20
20
|
}, /*#__PURE__*/React.createElement(Button, null, "click")), /*#__PURE__*/React.createElement(Tooltip, {
|
|
21
21
|
hoverable: true,
|
|
22
22
|
content: "the text can be hovered"
|
|
23
|
-
}, /*#__PURE__*/React.createElement(Button, null, "hoverable"))
|
|
23
|
+
}, /*#__PURE__*/React.createElement(Button, null, "hoverable")), /*#__PURE__*/React.createElement(Tooltip, {
|
|
24
|
+
trigger: "focus",
|
|
25
|
+
content: "foucs"
|
|
26
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
27
|
+
placeholder: "focus"
|
|
28
|
+
})));
|
|
24
29
|
};
|
|
25
30
|
|
|
26
31
|
return Demo;
|
|
@@ -5,13 +5,40 @@ export interface IgnoreClickEvent extends MouseEvent {
|
|
|
5
5
|
_ignore?: boolean
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
type FnWithTime = {
|
|
9
|
+
(e: IgnoreClickEvent): void;
|
|
10
|
+
timeStamp?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @reference: Vue3.0
|
|
14
|
+
let getNow = Date.now;
|
|
15
|
+
// Determine what event timestamp the browser is using. Annoyingly, the
|
|
16
|
+
// timestamp can either be hi-res (relative to page load) or low-res
|
|
17
|
+
// (relative to UNIX epoch), so in order to compare time we have to use the
|
|
18
|
+
// same timestamp type when saving the flush timestamp.
|
|
19
|
+
if (getNow() > document.createEvent('Event').timeStamp) {
|
|
20
|
+
// if the low-res timestamp which is bigger than the event timestamp
|
|
21
|
+
// (which is evaluated AFTER) it means the event is using a hi-res timestamp,
|
|
22
|
+
// and we need to use the hi-res version for event listeners as well.
|
|
23
|
+
getNow = () => performance.now();
|
|
24
|
+
}
|
|
25
|
+
// #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
|
|
26
|
+
// and does not fire microtasks in between event propagation, so safe to exclude.
|
|
27
|
+
const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
|
|
28
|
+
const skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
|
|
29
|
+
|
|
8
30
|
export function useDocumentClick(
|
|
9
31
|
ref: RefObject<Element> | (() => Element),
|
|
10
32
|
callback: (e: MouseEvent) => void,
|
|
11
33
|
manual: boolean = false
|
|
12
34
|
) {
|
|
13
|
-
const onDocumentClick = (e: IgnoreClickEvent) => {
|
|
35
|
+
const onDocumentClick: FnWithTime = (e: IgnoreClickEvent) => {
|
|
14
36
|
if (e._ignore) return;
|
|
37
|
+
// https://github.com/ksc-fe/kpc/issues/788
|
|
38
|
+
const timeStamp = e.timeStamp || getNow();
|
|
39
|
+
if (!skipTimestampCheck && onDocumentClick.timeStamp! > timeStamp + 1) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
15
42
|
|
|
16
43
|
const target = e.target as Element;
|
|
17
44
|
const elem = isFunction(ref) ? ref() : ref.value!;
|
|
@@ -21,6 +48,7 @@ export function useDocumentClick(
|
|
|
21
48
|
};
|
|
22
49
|
|
|
23
50
|
const add = () => {
|
|
51
|
+
onDocumentClick.timeStamp = getNow();
|
|
24
52
|
document.addEventListener('click', onDocumentClick);
|
|
25
53
|
document.addEventListener('contextmenu', onDocumentClick);
|
|
26
54
|
};
|
package/index.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
|
|
@@ -62,6 +62,6 @@ export * from './components/treeSelect';
|
|
|
62
62
|
export * from './components/upload';
|
|
63
63
|
export * from './components/wave';
|
|
64
64
|
|
|
65
|
-
export const version = '2.0.
|
|
65
|
+
export const version = '2.0.13-beta.0';
|
|
66
66
|
|
|
67
67
|
/* generate end */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@king-design/intact",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13-beta.0",
|
|
4
4
|
"description": "A component library written in Intact for Intact, Vue, React and Angular",
|
|
5
5
|
"main": "es/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"highlight.js": "^10.4.1",
|
|
117
117
|
"history": "^5.0.0",
|
|
118
118
|
"html-webpack-plugin": "5.3.1",
|
|
119
|
-
"intact-react": "^3.0.
|
|
119
|
+
"intact-react": "^3.0.13",
|
|
120
120
|
"istanbul-instrumenter-loader": "^3.0.0",
|
|
121
121
|
"js-yaml": "^4.1.0",
|
|
122
122
|
"karma": "^6.3.2",
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
"dayjs": "^1.10.7",
|
|
179
179
|
"downloadjs": "^1.4.7",
|
|
180
180
|
"enquire.js": "^2.1.6",
|
|
181
|
-
"intact": "^3.0.
|
|
181
|
+
"intact": "^3.0.13",
|
|
182
182
|
"monaco-editor": "^0.26.1",
|
|
183
183
|
"mxgraphx": "^4.0.7",
|
|
184
184
|
"resize-observer-polyfill": "^1.5.1",
|
package/dist/fonts/ionicons.eot
DELETED
|
Binary file
|