@king-design/intact 2.0.16 → 2.0.17-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 +2 -1
- package/components/dropdown/dropdown.ts +18 -9
- package/components/dropdown/menu.ts +1 -1
- package/components/tooltip/tooltip.ts +0 -2
- package/es/components/cascader/styles.js +1 -1
- package/es/components/dropdown/dropdown.d.ts +0 -1
- package/es/components/dropdown/dropdown.js +19 -7
- package/es/components/dropdown/menu.js +1 -1
- package/es/components/tooltip/tooltip.d.ts +0 -1
- package/es/components/tooltip/tooltip.js +1 -12
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/index.ts +2 -2
- package/package.json +1 -1
|
@@ -126,10 +126,7 @@ export class Dropdown<
|
|
|
126
126
|
|
|
127
127
|
return [
|
|
128
128
|
clonedTrigger,
|
|
129
|
-
|
|
130
|
-
this.alwaysPortal || !this.rootDropdown ?
|
|
131
|
-
h(Portal, {children: menu, container: this.get('container')}) :
|
|
132
|
-
menu
|
|
129
|
+
h(Portal, {children: menu, container: this.get('container')})
|
|
133
130
|
];
|
|
134
131
|
};
|
|
135
132
|
|
|
@@ -139,8 +136,6 @@ export class Dropdown<
|
|
|
139
136
|
public showedDropdown: Dropdown | null = null;
|
|
140
137
|
public positionHook = usePosition();
|
|
141
138
|
|
|
142
|
-
protected alwaysPortal = false;
|
|
143
|
-
|
|
144
139
|
private timer: number | undefined = undefined;
|
|
145
140
|
private triggerProps: any = null;
|
|
146
141
|
|
|
@@ -294,9 +289,10 @@ export class Dropdown<
|
|
|
294
289
|
function useDocumentClickForDropdown(dropdown: Dropdown) {
|
|
295
290
|
const elementRef = () => findDomFromVNode(dropdown.menuVNode!, true) as Element;
|
|
296
291
|
const [addDocumentClick, removeDocumentClick] = useDocumentClick(elementRef, (e) => {
|
|
297
|
-
// case 1: if click
|
|
298
|
-
// case 2: if right click on trigger and
|
|
299
|
-
// case 3: if click on trigger and
|
|
292
|
+
// case 1: if click a trigger and its trigger type is hover, ignore it
|
|
293
|
+
// case 2: if right click on a trigger and its trigger type is contextmenu, ignore it
|
|
294
|
+
// case 3: if click on a trigger and its trigger type is focus, do nothing
|
|
295
|
+
// case 3: if click on sub-dropdown, we should also show the parent dropdown, so ignore it
|
|
300
296
|
const trigger = dropdown.get('trigger');
|
|
301
297
|
if (trigger === 'focus') return;
|
|
302
298
|
|
|
@@ -310,6 +306,8 @@ function useDocumentClickForDropdown(dropdown: Dropdown) {
|
|
|
310
306
|
}
|
|
311
307
|
}
|
|
312
308
|
|
|
309
|
+
if (isSubDropdownElement(e.target as Element, dropdown)) return;
|
|
310
|
+
|
|
313
311
|
dropdown.hide(true);
|
|
314
312
|
}, true);
|
|
315
313
|
|
|
@@ -317,6 +315,17 @@ function useDocumentClickForDropdown(dropdown: Dropdown) {
|
|
|
317
315
|
dropdown.on('hide', removeDocumentClick);
|
|
318
316
|
}
|
|
319
317
|
|
|
318
|
+
function isSubDropdownElement(elem: Element, dropdown: Dropdown): boolean {
|
|
319
|
+
const showedDropdown = dropdown.showedDropdown;
|
|
320
|
+
if (!showedDropdown) return false;
|
|
321
|
+
|
|
322
|
+
const subMenuElement = findDomFromVNode(showedDropdown.menuVNode!, true) as Element;
|
|
323
|
+
if (containsOrEqual(subMenuElement, elem)) {
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
return isSubDropdownElement(elem, showedDropdown);
|
|
327
|
+
}
|
|
328
|
+
|
|
320
329
|
function useHideLastMenuOnShow(dropdown: Dropdown) {
|
|
321
330
|
const parentDropdown = dropdown.dropdown;
|
|
322
331
|
dropdown.on('show', () => {
|
|
@@ -63,7 +63,7 @@ function useKeyboardForDropdownMenu(dropdown: Dropdown) {
|
|
|
63
63
|
const focus = () => focusByIndex(0);
|
|
64
64
|
|
|
65
65
|
// In Cascader the menu may have been replaced by another menu, in this case,
|
|
66
|
-
// if the dropdown has showed
|
|
66
|
+
// if the dropdown has showed while we mounted the menu, add keydown listener
|
|
67
67
|
if (dropdown.get('value')) {
|
|
68
68
|
onShow();
|
|
69
69
|
}
|
|
@@ -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;
|
|
46
|
+
return /*#__PURE__*/css("min-width:", cascader.width, "!important;height:", cascader.height, ";overflow:auto;.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, ";}");
|
|
@@ -57,7 +57,6 @@ export var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
57
57
|
_this.rootDropdown = null;
|
|
58
58
|
_this.showedDropdown = null;
|
|
59
59
|
_this.positionHook = usePosition();
|
|
60
|
-
_this.alwaysPortal = false;
|
|
61
60
|
_this.timer = undefined;
|
|
62
61
|
_this.triggerProps = null;
|
|
63
62
|
return _this;
|
|
@@ -267,11 +266,10 @@ Dropdown.template = function () {
|
|
|
267
266
|
});
|
|
268
267
|
clonedTrigger.className = className;
|
|
269
268
|
this.menuVNode = menu;
|
|
270
|
-
return [clonedTrigger,
|
|
271
|
-
this.alwaysPortal || !this.rootDropdown ? h(Portal, {
|
|
269
|
+
return [clonedTrigger, h(Portal, {
|
|
272
270
|
children: menu,
|
|
273
271
|
container: this.get('container')
|
|
274
|
-
})
|
|
272
|
+
})];
|
|
275
273
|
};
|
|
276
274
|
|
|
277
275
|
__decorate([bind], Dropdown.prototype, "position", null);
|
|
@@ -288,9 +286,10 @@ function useDocumentClickForDropdown(dropdown) {
|
|
|
288
286
|
};
|
|
289
287
|
|
|
290
288
|
var _useDocumentClick = useDocumentClick(elementRef, function (e) {
|
|
291
|
-
// case 1: if click
|
|
292
|
-
// case 2: if right click on trigger and
|
|
293
|
-
// case 3: if click on trigger and
|
|
289
|
+
// case 1: if click a trigger and its trigger type is hover, ignore it
|
|
290
|
+
// case 2: if right click on a trigger and its trigger type is contextmenu, ignore it
|
|
291
|
+
// case 3: if click on a trigger and its trigger type is focus, do nothing
|
|
292
|
+
// case 3: if click on sub-dropdown, we should also show the parent dropdown, so ignore it
|
|
294
293
|
var trigger = dropdown.get('trigger');
|
|
295
294
|
if (trigger === 'focus') return;
|
|
296
295
|
var isHover = trigger === 'hover';
|
|
@@ -305,6 +304,7 @@ function useDocumentClickForDropdown(dropdown) {
|
|
|
305
304
|
}
|
|
306
305
|
}
|
|
307
306
|
|
|
307
|
+
if (isSubDropdownElement(e.target, dropdown)) return;
|
|
308
308
|
dropdown.hide(true);
|
|
309
309
|
}, true),
|
|
310
310
|
addDocumentClick = _useDocumentClick[0],
|
|
@@ -314,6 +314,18 @@ function useDocumentClickForDropdown(dropdown) {
|
|
|
314
314
|
dropdown.on('hide', removeDocumentClick);
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
function isSubDropdownElement(elem, dropdown) {
|
|
318
|
+
var showedDropdown = dropdown.showedDropdown;
|
|
319
|
+
if (!showedDropdown) return false;
|
|
320
|
+
var subMenuElement = findDomFromVNode(showedDropdown.menuVNode, true);
|
|
321
|
+
|
|
322
|
+
if (containsOrEqual(subMenuElement, elem)) {
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return isSubDropdownElement(elem, showedDropdown);
|
|
327
|
+
}
|
|
328
|
+
|
|
317
329
|
function useHideLastMenuOnShow(dropdown) {
|
|
318
330
|
var parentDropdown = dropdown.dropdown;
|
|
319
331
|
dropdown.on('show', function () {
|
|
@@ -85,7 +85,7 @@ function useKeyboardForDropdownMenu(dropdown) {
|
|
|
85
85
|
var focus = function focus() {
|
|
86
86
|
return focusByIndex(0);
|
|
87
87
|
}; // In Cascader the menu may have been replaced by another menu, in this case,
|
|
88
|
-
// if the dropdown has showed
|
|
88
|
+
// if the dropdown has showed while we mounted the menu, add keydown listener
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
if (dropdown.get('value')) {
|
|
@@ -23,6 +23,5 @@ export declare class Tooltip<T extends TooltipProps = TooltipProps, E extends To
|
|
|
23
23
|
static typeDefs: Required<TypeDefs<TooltipProps>>;
|
|
24
24
|
static defaults: () => Partial<TooltipProps>;
|
|
25
25
|
static events: Events<TooltipEvents>;
|
|
26
|
-
protected alwaysPortal: boolean;
|
|
27
26
|
hide(immediately: boolean): void;
|
|
28
27
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
3
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
4
3
|
import { Dropdown } from '../dropdown/dropdown';
|
|
5
4
|
import { _$ } from '../../i18n';
|
|
6
5
|
import { themes } from './styles';
|
|
@@ -44,17 +43,7 @@ export var Tooltip = /*#__PURE__*/function (_Dropdown) {
|
|
|
44
43
|
_inheritsLoose(Tooltip, _Dropdown);
|
|
45
44
|
|
|
46
45
|
function Tooltip() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var _this;
|
|
50
|
-
|
|
51
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
52
|
-
args[_key] = arguments[_key];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
_this = _Dropdown.call.apply(_Dropdown, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
56
|
-
_this.alwaysPortal = true;
|
|
57
|
-
return _this;
|
|
46
|
+
return _Dropdown.apply(this, arguments) || this;
|
|
58
47
|
}
|
|
59
48
|
|
|
60
49
|
var _proto = Tooltip.prototype;
|
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.0.
|
|
2
|
+
* @king-design v2.0.17-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.17-beta.0";
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.0.
|
|
2
|
+
* @king-design v2.0.17-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.17-beta.0';
|
|
63
63
|
/* generate end */
|
package/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.0.
|
|
2
|
+
* @king-design v2.0.17-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.17-beta.0';
|
|
66
66
|
|
|
67
67
|
/* generate end */
|