@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.
@@ -33,7 +33,8 @@ setDefault(() => {
33
33
  export function makeMenuStyles() {
34
34
  return css`
35
35
  min-width: ${cascader.width} !important;
36
- min-height: ${cascader.height};
36
+ height: ${cascader.height};
37
+ overflow: auto;
37
38
  .k-cascader-arrow {
38
39
  float: right;
39
40
  height: 100%;
@@ -126,10 +126,7 @@ export class Dropdown<
126
126
 
127
127
  return [
128
128
  clonedTrigger,
129
- // wrap the root dropdown menu to Portal to render into body
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 an trigger and the trigger type is hover, ignore it
298
- // case 2: if right click on trigger and the trigger type is contextmenu, ignore it
299
- // case 3: if click on trigger and the trigger type is focus, do nothing
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 on mount the menu, add keydown listener
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
  }
@@ -72,8 +72,6 @@ export class Tooltip<
72
72
  static defaults = defaults;
73
73
  static events = events;
74
74
 
75
- protected alwaysPortal = true;
76
-
77
75
  hide(immediately: boolean) {
78
76
  if (this.get('always')) return;
79
77
 
@@ -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;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, ";}}");
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, ";}");
@@ -41,7 +41,6 @@ export declare class Dropdown<T extends DropdownProps = DropdownProps, E extends
41
41
  value: boolean;
42
42
  };
43
43
  };
44
- protected alwaysPortal: boolean;
45
44
  private timer;
46
45
  private triggerProps;
47
46
  init(): void;
@@ -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, // wrap the root dropdown menu to Portal to render into body
271
- this.alwaysPortal || !this.rootDropdown ? h(Portal, {
269
+ return [clonedTrigger, h(Portal, {
272
270
  children: menu,
273
271
  container: this.get('container')
274
- }) : menu];
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 an trigger and the trigger type is hover, ignore it
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
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 on mount the menu, add keydown listener
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
- var _context;
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.16
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.16";
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.16
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.16';
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.16
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.16';
65
+ export const version = '2.0.17-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.16",
3
+ "version": "2.0.17-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": {