@king-design/vue 3.6.1 → 3.6.2-beta.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.
@@ -0,0 +1,22 @@
1
+ import { Component } from 'intact-vue-next';
2
+ import type { DropdownItem } from './item';
3
+ export interface ItemEvents {
4
+ onFocusin: () => void;
5
+ onFocusout: () => void;
6
+ onShowMenu: () => void;
7
+ onHideMenu: () => void;
8
+ onSelect: () => void;
9
+ }
10
+ export declare enum Direction {
11
+ Up = 0,
12
+ Down = 1
13
+ }
14
+ export type MenuKeyboardMethods = {
15
+ reset: () => void;
16
+ focus: (item: DropdownItem) => void;
17
+ };
18
+ export type ItemComponent = Component<{
19
+ disabled: boolean;
20
+ }>;
21
+ export declare const ITEM_EVENTS = "ItemEvents";
22
+ export declare const MENU_KEYBOARD = "MenuKeyboard";
@@ -0,0 +1,7 @@
1
+ export var Direction;
2
+ (function (Direction) {
3
+ Direction[Direction["Up"] = 0] = "Up";
4
+ Direction[Direction["Down"] = 1] = "Down";
5
+ })(Direction || (Direction = {}));
6
+ export var ITEM_EVENTS = 'ItemEvents';
7
+ export var MENU_KEYBOARD = 'MenuKeyboard';
@@ -4,6 +4,8 @@ export * from './item';
4
4
  export type { Position as PositionOption, PositionShorthand } from './dropdown';
5
5
  export type { DropdownProps, DropdownEvents, DropdownBlocks, DropdownMenuProps, DropdownMenuEvents, DropdownMenuBlocks, };
6
6
  export declare class Dropdown extends BaseDropdown<DropdownProps, DropdownEvents, DropdownBlocks> {
7
+ static readonly __isDropdown = true;
7
8
  }
8
9
  export declare class DropdownMenu extends BaseDropdownMenu<DropdownMenuProps, DropdownMenuEvents, DropdownMenuBlocks> {
10
+ static readonly __isDropdownMenu = true;
9
11
  }
@@ -23,10 +23,12 @@ export var Dropdown = /*#__PURE__*/function (_BaseDropdown) {
23
23
  }
24
24
  return Dropdown;
25
25
  }(BaseDropdown);
26
+ Dropdown.__isDropdown = true;
26
27
  export var DropdownMenu = /*#__PURE__*/function (_BaseDropdownMenu) {
27
28
  _inheritsLoose(DropdownMenu, _BaseDropdownMenu);
28
29
  function DropdownMenu() {
29
30
  return _BaseDropdownMenu.apply(this, arguments) || this;
30
31
  }
31
32
  return DropdownMenu;
32
- }(BaseDropdownMenu);
33
+ }(BaseDropdownMenu);
34
+ DropdownMenu.__isDropdownMenu = true;
@@ -22,6 +22,6 @@ export declare class DropdownItem extends Component<DropdownItemProps, DropdownI
22
22
  private config;
23
23
  init(): void;
24
24
  select(): void;
25
- hasSubMenu(): undefined;
25
+ hasSubMenu(): Dropdown<import("./dropdown").DropdownProps, import("./dropdown").DropdownEvents, import("./dropdown").DropdownBlocks> | undefined;
26
26
  private onClick;
27
27
  }
@@ -4,10 +4,9 @@ import { __decorate } from "tslib";
4
4
  import { Component, inject } from 'intact-vue-next';
5
5
  import template from './item.vdt';
6
6
  import { bind } from '../utils';
7
- import { useItemKeyboard } from './useKeyboard';
7
+ import { useItemKeyboard } from './useItemKeyboard';
8
8
  import { DROPDOWN } from './dropdown';
9
9
  import { DROPDOWN_MENU } from './menu';
10
- import { Dropdown as ExportDropdown, DropdownMenu as ExportDropdownMenu } from '.';
11
10
  import { useConfigContext } from '../config';
12
11
  var typeDefs = {
13
12
  disabled: Boolean,
@@ -62,12 +61,13 @@ export var DropdownItem = /*#__PURE__*/function (_Component) {
62
61
  var parent = this.$senior;
63
62
  while (parent) {
64
63
  // Tooltip extends Dropdown, it's also a instance of Dropdown
65
- // so use constructor to detect
66
- // if (parent instanceof DropdownMenu) {
67
- if (parent.constructor === ExportDropdownMenu) {
64
+ // we should exclude this case, so use constructor to detect
65
+ // @modify: Check using hasOwnProperty to avoid inheritance issues and circle reference
66
+ var _constructor = parent.constructor;
67
+ if (_constructor.hasOwnProperty('__isDropdownMenu')) {
68
68
  return;
69
69
  }
70
- if (parent.constructor === ExportDropdown) {
70
+ if (_constructor.hasOwnProperty('__isDropdown')) {
71
71
  return parent;
72
72
  }
73
73
  parent = parent.$senior;
@@ -6,7 +6,7 @@ import template from './menu.vdt';
6
6
  import { bind } from '../utils';
7
7
  import { DROPDOWN } from './dropdown';
8
8
  import { useTransition } from './useTransition';
9
- import { useMenuKeyboard } from './useKeyboard';
9
+ import { useMenuKeyboard } from './useMenuKeyboard';
10
10
  import { useMouseOutsidable } from '../../hooks/useMouseOutsidable';
11
11
  import { useConfigContext } from '../config';
12
12
  import { usePositionForDropdownMenu } from './usePosition';
@@ -0,0 +1,6 @@
1
+ import { ItemEvents } from './constants';
2
+ export declare function useItemKeyboard(itemEvents: Omit<ItemEvents, 'onFocusin' | 'onFocusout'>): {
3
+ onMouseEnter(e: MouseEvent): void;
4
+ onMouseLeave(e: MouseEvent): void;
5
+ isFocus: import("../../hooks/useState").State<boolean>;
6
+ };
@@ -0,0 +1,32 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import { useInstance, inject } from 'intact-vue-next';
3
+ import { useRecordItem } from '../../hooks/useRecordComponent';
4
+ import { useState } from '../../hooks/useState';
5
+ import { MENU_KEYBOARD, ITEM_EVENTS } from './constants';
6
+ export function useItemKeyboard(itemEvents) {
7
+ var isFocus = useState(false);
8
+ var keyboard = inject(MENU_KEYBOARD);
9
+ var instance = useInstance();
10
+ useRecordItem(ITEM_EVENTS, instance, _extends({}, itemEvents, {
11
+ onFocusin: function onFocusin() {
12
+ isFocus.set(true);
13
+ },
14
+ onFocusout: function onFocusout() {
15
+ isFocus.set(false);
16
+ }
17
+ }));
18
+ return {
19
+ onMouseEnter: function onMouseEnter(e) {
20
+ instance.trigger('mouseenter', e);
21
+ if (instance.get('disabled')) return;
22
+ keyboard.focus(instance);
23
+ },
24
+ onMouseLeave: function onMouseLeave(e) {
25
+ instance.trigger('mouseleave', e);
26
+ keyboard.reset();
27
+ // If it is a virtual item, it needs to be reset manually because the DOM is reused.
28
+ isFocus.set(false);
29
+ },
30
+ isFocus: isFocus
31
+ };
32
+ }
@@ -0,0 +1,2 @@
1
+ import { Direction } from './constants';
2
+ export declare function useMenuKeyboard(): readonly [readonly [() => void, () => void, (v: boolean) => boolean], (index: number, direction?: Direction) => void, () => void];
@@ -1,20 +1,12 @@
1
- import _extends from "@babel/runtime-corejs3/helpers/extends";
2
- import { onBeforeUpdate, onMounted, onUpdated, useInstance, findDomFromVNode, provide, inject, isComponentClass, isComponentFunction, hasVNodeChildren, hasMultipleChildren } from 'intact-vue-next';
3
- import { useRecordParent, useRecordItem } from '../../hooks/useRecordComponent';
1
+ import { onBeforeUpdate, onMounted, onUpdated, useInstance, findDomFromVNode, provide, isComponentClass, isComponentFunction, hasVNodeChildren, hasMultipleChildren } from 'intact-vue-next';
2
+ import { useRecordParent } from '../../hooks/useRecordComponent';
4
3
  import { useKeyboard } from '../../hooks/useKeyboard';
5
- import { useState } from '../../hooks/useState';
6
4
  import { isComponentVNode } from '../utils';
7
5
  import { DropdownItem } from './item';
8
6
  // can not import DropdownMenu from index.ts, otherwise it will cause circle reference
9
7
  // import {DropdownMenu} from './';
10
8
  import { DropdownMenu } from './menu';
11
- export var Direction;
12
- (function (Direction) {
13
- Direction[Direction["Up"] = 0] = "Up";
14
- Direction[Direction["Down"] = 1] = "Down";
15
- })(Direction || (Direction = {}));
16
- var ITEM_EVENTS = 'ItemEvents';
17
- var MENU_KEYBOARD = 'MenuKeyboard';
9
+ import { ITEM_EVENTS, Direction, MENU_KEYBOARD } from './constants';
18
10
  export function useMenuKeyboard() {
19
11
  var items = [];
20
12
  var itemEvents = useRecordParent(ITEM_EVENTS, true);
@@ -121,33 +113,6 @@ export function useMenuKeyboard() {
121
113
  enter: makeEventCall('onSelect')
122
114
  }), focusByIndex, reset];
123
115
  }
124
- export function useItemKeyboard(itemEvents) {
125
- var isFocus = useState(false);
126
- var keyboard = inject(MENU_KEYBOARD);
127
- var instance = useInstance();
128
- useRecordItem(ITEM_EVENTS, instance, _extends({}, itemEvents, {
129
- onFocusin: function onFocusin() {
130
- isFocus.set(true);
131
- },
132
- onFocusout: function onFocusout() {
133
- isFocus.set(false);
134
- }
135
- }));
136
- return {
137
- onMouseEnter: function onMouseEnter(e) {
138
- instance.trigger('mouseenter', e);
139
- if (instance.get('disabled')) return;
140
- keyboard.focus(instance);
141
- },
142
- onMouseLeave: function onMouseLeave(e) {
143
- instance.trigger('mouseleave', e);
144
- keyboard.reset();
145
- // If it is a virtual item, it needs to be reset manually because the DOM is reused.
146
- isFocus.set(false);
147
- },
148
- isFocus: isFocus
149
- };
150
- }
151
116
  function fixIndex(index, max) {
152
117
  if (index > max) {
153
118
  index = 0;
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.6.1
2
+ * @king-design v3.6.2-beta.1
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -66,7 +66,7 @@ export * from './components/upload';
66
66
  export * from './components/view';
67
67
  export * from './components/virtualList';
68
68
  export * from './components/wave';
69
- export declare const version = "3.6.1";
69
+ export declare const version = "3.6.2-beta.1";
70
70
 
71
71
 
72
72
  export {normalize} from 'intact-vue-next';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.6.1
2
+ * @king-design v3.6.2-beta.1
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -67,7 +67,7 @@ export * from './components/upload';
67
67
  export * from './components/view';
68
68
  export * from './components/virtualList';
69
69
  export * from './components/wave';
70
- export var version = '3.6.1';
70
+ export var version = '3.6.2-beta.1';
71
71
  /* generate end */
72
72
 
73
73
  export {normalize} from 'intact-vue-next';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@king-design/vue",
3
- "version": "3.6.1",
3
+ "version": "3.6.2-beta.1",
4
4
  "description": "King-Design UI components for Vue3.0.",
5
5
  "keywords": [
6
6
  "component",
@@ -1,23 +0,0 @@
1
- import { DropdownItem } from './item';
2
- interface ItemEvents {
3
- onFocusin: () => void;
4
- onFocusout: () => void;
5
- onShowMenu: () => void;
6
- onHideMenu: () => void;
7
- onSelect: () => void;
8
- }
9
- export declare enum Direction {
10
- Up = 0,
11
- Down = 1
12
- }
13
- export type MenuKeyboardMethods = {
14
- reset: () => void;
15
- focus: (item: DropdownItem) => void;
16
- };
17
- export declare function useMenuKeyboard(): readonly [readonly [() => void, () => void, (v: boolean) => boolean], (index: number, direction?: Direction) => void, () => void];
18
- export declare function useItemKeyboard(itemEvents: Omit<ItemEvents, 'onFocusin' | 'onFocusout'>): {
19
- onMouseEnter(e: MouseEvent): void;
20
- onMouseLeave(e: MouseEvent): void;
21
- isFocus: import("../../hooks/useState").State<boolean>;
22
- };
23
- export {};