@king-design/vue 3.1.5 → 3.2.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__/Vue Next Demos.md +21 -15
- package/components/cascader/index.d.ts +45 -0
- package/components/config/index.spec.js +22 -14
- package/components/datepicker/index.d.ts +63 -0
- package/components/datepicker/index.spec.js +10 -5
- package/components/datepicker/useValue.js +9 -1
- package/components/diagram/index.d.ts +1 -1
- package/components/layout/aside.vdt.js +1 -1
- package/components/layout/styles.js +2 -17
- package/components/menu/index.d.ts +1 -0
- package/components/menu/index.js +2 -1
- package/components/menu/index.spec.js +59 -28
- package/components/menu/item.vdt.js +3 -3
- package/components/menu/menu.d.ts +2 -0
- package/components/menu/menu.js +12 -1
- package/components/menu/menu.vdt.js +9 -4
- package/components/menu/styles.d.ts +15 -12
- package/components/menu/styles.js +38 -38
- package/components/menu/title.d.ts +7 -0
- package/components/menu/title.js +22 -0
- package/components/menu/title.vdt.js +25 -0
- package/components/radio/styles.js +1 -1
- package/components/select/index.spec.js +1 -1
- package/components/select/option.vdt.js +1 -0
- package/components/select/select.d.ts +33 -0
- package/components/select/select.js +4 -1
- package/components/steps/context.d.ts +3 -3
- package/components/table/column.vdt.js +6 -6
- package/components/table/useSortable.d.ts +7 -3
- package/components/table/useSortable.js +5 -1
- package/components/timepicker/panelPicker.d.ts +54 -0
- package/components/treeSelect/index.d.ts +28 -0
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +2 -2
- package/styles/theme.js +1 -2
- package/yarn-error.log +0 -1013
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { TypeDefs } from 'intact-vue-next';
|
|
2
|
+
import dayjs from './dayjs';
|
|
3
|
+
import { State } from '../../hooks/useState';
|
|
4
|
+
import { Shortcut } from './shortcuts';
|
|
5
|
+
import { BasePicker, BasePickerProps, BasePickerEvents, BasePickerBlocks, Value } from './basepicker';
|
|
6
|
+
export * as shortcuts from './shortcuts';
|
|
7
|
+
export interface DatepickerProps<V extends Value = Value, M extends boolean = boolean, R extends boolean = boolean> extends BasePickerProps<V extends string ? V : V | string, M, R> {
|
|
8
|
+
type?: 'date' | 'datetime' | 'year' | 'month';
|
|
9
|
+
shortcuts?: Shortcut[];
|
|
10
|
+
}
|
|
11
|
+
export interface DatepickerEvents extends BasePickerEvents {
|
|
12
|
+
}
|
|
13
|
+
export interface DatepickerBlocks<V extends Value = Value, R extends boolean = boolean> extends BasePickerBlocks<V, R> {
|
|
14
|
+
}
|
|
15
|
+
export declare class Datepicker<V extends Value = Value, M extends boolean = false, R extends boolean = false> extends BasePicker<DatepickerProps<V, M, R>, DatepickerEvents, DatepickerBlocks<V, R>> {
|
|
16
|
+
static template: string | import('intact-vue-next').Template<any>;
|
|
17
|
+
static typeDefs: Required<TypeDefs<DatepickerProps<Value, boolean, boolean>>>;
|
|
18
|
+
static defaults: () => Partial<DatepickerProps<Value, boolean, boolean>>;
|
|
19
|
+
formats: {
|
|
20
|
+
getValueFormat: () => string;
|
|
21
|
+
getShowFormat: () => string;
|
|
22
|
+
createDateByValueFormat: (value: Value) => dayjs.Dayjs;
|
|
23
|
+
createDateByShowFormat: (value: string) => dayjs.Dayjs;
|
|
24
|
+
getShowString: (value: dayjs.Dayjs) => string;
|
|
25
|
+
getValueString: (value: dayjs.Dayjs) => string;
|
|
26
|
+
};
|
|
27
|
+
disabled: {
|
|
28
|
+
isDisabled: (value: dayjs.Dayjs, type?: dayjs.OpUnitType) => boolean;
|
|
29
|
+
isDisabledTime: (value: dayjs.Dayjs, flag: import("./usePanel").PanelFlags) => boolean;
|
|
30
|
+
isDisabledConfirm: () => boolean;
|
|
31
|
+
maxDate: State<dayjs.Dayjs | null>;
|
|
32
|
+
minDate: State<dayjs.Dayjs | null>;
|
|
33
|
+
};
|
|
34
|
+
panel: {
|
|
35
|
+
startPanel: State<import("./usePanel").PanelTypes>;
|
|
36
|
+
endPanel: State<import("./usePanel").PanelTypes>;
|
|
37
|
+
changePanel: (type: import("./usePanel").PanelTypes, flag?: import("./usePanel").PanelFlags) => void;
|
|
38
|
+
getPanel: (flag: import("./usePanel").PanelFlags) => State<import("./usePanel").PanelTypes>;
|
|
39
|
+
reset: () => void;
|
|
40
|
+
startRef: import('intact-vue-next').RefObject<import("./calendar").DatepickerCalendar>;
|
|
41
|
+
endRef: import('intact-vue-next').RefObject<import("./calendar").DatepickerCalendar>;
|
|
42
|
+
};
|
|
43
|
+
focusDate: {
|
|
44
|
+
focusDate: State<dayjs.Dayjs | null>;
|
|
45
|
+
reset: () => void;
|
|
46
|
+
};
|
|
47
|
+
value: {
|
|
48
|
+
format: () => string | string[];
|
|
49
|
+
onConfirm: () => void;
|
|
50
|
+
onChangeTime: (date: dayjs.Dayjs, flag: import("./usePanel").PanelFlags) => void;
|
|
51
|
+
getTimeValue: (flag: import("./usePanel").PanelFlags) => dayjs.Dayjs | null | undefined;
|
|
52
|
+
convertToDayjs: (v: Value | [Value, Value] | Value[] | [Value, Value][] | null | undefined) => import("./basepicker").DayjsValue;
|
|
53
|
+
getDayjsValue: () => import("./basepicker").DayjsValue;
|
|
54
|
+
value: State<import("./basepicker").StateValue>;
|
|
55
|
+
setValue: (v: import("./basepicker").StateValueItem, fromInput: boolean) => void;
|
|
56
|
+
onChangeDate: (v: dayjs.Dayjs, flag: import("./usePanel").PanelFlags) => void;
|
|
57
|
+
};
|
|
58
|
+
init(): void;
|
|
59
|
+
protected getPlaceholder(): string | number | boolean | import("misstime/dist/utils/types").VNode<any> | import('intact-vue-next').Children[];
|
|
60
|
+
protected getLabel(): string | string[];
|
|
61
|
+
protected clear(e: MouseEvent): void;
|
|
62
|
+
private setByShortcut;
|
|
63
|
+
}
|
|
@@ -801,22 +801,27 @@ describe('Datepicker', function () {
|
|
|
801
801
|
first = calendar1.querySelectorAll('.k-calendar-item')[17];
|
|
802
802
|
second = calendar2.querySelectorAll('.k-calendar-item')[17];
|
|
803
803
|
first.click();
|
|
804
|
+
// should stay at date panel
|
|
805
|
+
_context21.next = 12;
|
|
806
|
+
return wait();
|
|
807
|
+
case 12:
|
|
808
|
+
expect(calendar1.querySelector('.k-days')).be.exist;
|
|
804
809
|
second.click();
|
|
805
|
-
_context21.next =
|
|
810
|
+
_context21.next = 16;
|
|
806
811
|
return wait();
|
|
807
|
-
case
|
|
812
|
+
case 16:
|
|
808
813
|
dispatchEvent(calendar1.querySelector('.k-scroll-select-wrapper .k-active').nextElementSibling, 'click');
|
|
809
814
|
dispatchEvent(calendar2.querySelector('.k-scroll-select-wrapper .k-active').previousElementSibling, 'click');
|
|
810
815
|
content.querySelector('.k-datepicker-footer .k-btn').click();
|
|
811
|
-
_context21.next =
|
|
816
|
+
_context21.next = 21;
|
|
812
817
|
return wait();
|
|
813
|
-
case
|
|
818
|
+
case 21:
|
|
814
819
|
value2 = instance.get('time');
|
|
815
820
|
expect(value2).have.lengthOf(2);
|
|
816
821
|
expect(_mapInstanceProperty(value2).call(value2, function (item) {
|
|
817
822
|
return item.split(' ')[1];
|
|
818
823
|
})).eql(['01:00:00', '22:59:59']);
|
|
819
|
-
case
|
|
824
|
+
case 24:
|
|
820
825
|
case "end":
|
|
821
826
|
return _context21.stop();
|
|
822
827
|
}
|
|
@@ -61,7 +61,15 @@ export function useValue(formats, disabled, panel) {
|
|
|
61
61
|
}
|
|
62
62
|
setValue(_value, false);
|
|
63
63
|
if (type === 'datetime') {
|
|
64
|
-
|
|
64
|
+
if (range) {
|
|
65
|
+
// only change to time panel after selected start and end date
|
|
66
|
+
if (_value.length === 2) {
|
|
67
|
+
panel.changePanel(PanelTypes.Time, PanelFlags.Start);
|
|
68
|
+
panel.changePanel(PanelTypes.Time, PanelFlags.End);
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
panel.changePanel(PanelTypes.Time, flag);
|
|
72
|
+
}
|
|
65
73
|
} else if (!multiple && (!range || _value.length === 2)) {
|
|
66
74
|
instance.hide();
|
|
67
75
|
}
|
|
@@ -10,7 +10,7 @@ export * from './shapes/rectangle';
|
|
|
10
10
|
export * from './shapes/square';
|
|
11
11
|
export * from './shapes/text';
|
|
12
12
|
export * from './shapes/line';
|
|
13
|
-
declare const DDiamond: import("
|
|
13
|
+
declare const DDiamond: import("misstime").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>, DTriangle: import("misstime").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>, DCylinder: import("misstime").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>, DCloud: import("misstime").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>;
|
|
14
14
|
export { DDiamond, DTriangle, DCylinder, DCloud };
|
|
15
15
|
export * from './layouts/layout';
|
|
16
16
|
export * from './layouts/circle';
|
|
@@ -26,7 +26,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
26
26
|
}
|
|
27
27
|
return vNode;
|
|
28
28
|
});
|
|
29
|
-
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-layout-aside"] = true, _classNameObj[k + "-collapsed"] = collapse, _classNameObj[k + "-fixed"] = fixed, _classNameObj[k + "-" + theme] = true, _classNameObj[className] = className, _classNameObj[makeAsideStyles(k)] = true, _classNameObj);
|
|
29
|
+
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-layout-aside"] = true, _classNameObj[k + "-collapsed"] = collapse, _classNameObj[k + "-fixed"] = fixed, _classNameObj[k + "-" + (theme === 'dark' ? 'dark' : 'light')] = true, _classNameObj[className] = className, _classNameObj[makeAsideStyles(k)] = true, _classNameObj);
|
|
30
30
|
return _$cv('div', _extends({}, getRestProps(this), {
|
|
31
31
|
'className': _$cn(classNameObj),
|
|
32
32
|
'style': this.getStyles(k)
|
|
@@ -30,17 +30,6 @@ var defaults = {
|
|
|
30
30
|
return menu.light.border;
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
white: {
|
|
34
|
-
get color() {
|
|
35
|
-
return menu.white.item.color;
|
|
36
|
-
},
|
|
37
|
-
get bgColor() {
|
|
38
|
-
return menu.white.bgColor;
|
|
39
|
-
},
|
|
40
|
-
get border() {
|
|
41
|
-
return menu.white.border;
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
33
|
get collapsedWidth() {
|
|
45
34
|
return "calc(" + getLeft(menu.item.padding) + " * 2 + " + menu.icon.width + ")";
|
|
46
35
|
},
|
|
@@ -64,16 +53,12 @@ export var makeLayoutStyles = cache(function makeLayoutStyles(k) {
|
|
|
64
53
|
return /*#__PURE__*/css("display:flex;flex-direction:column;flex:1;transition:padding-left ", layout.transition, ";&.", k, "-has-aside{flex-direction:row;}.", k, "-layout-footer{padding:", layout.footerPadding, ";}.", k, "-layout-body{flex:1;}");
|
|
65
54
|
});
|
|
66
55
|
export var makeHeaderStyles = cache(function makeHeaderStyles(k) {
|
|
67
|
-
return /*#__PURE__*/css("display:flex;align-items:center;color:", layout.color, ";background:", layout.bgColor, ";left:0;transition:left ", layout.transition, ";&.", k, "-fixed{position:fixed;left:0;right:0;top:0;z-index:", theme.midZIndex + 1, ";}>.", k, "-menu{background:transparent!important;}&.", k, "-blur{backdrop-filter:blur(20px);background:", setAlpha(layout.bgColor, 0.1), ";}&.", k, "-box-shadow{border-bottom:none!important;box-shadow:", theme.boxShadow, ";}",
|
|
68
|
-
if (theme === 'dark') return;
|
|
69
|
-
var styles = layout[theme];
|
|
70
|
-
return /*#__PURE__*/css("&.", k, "-", theme, "{background:", styles.bgColor, ";color:", styles.color, ";border-bottom:", styles.border, ";&.", k, "-blur{background:", setAlpha(styles.bgColor, 0.1), ";}}");
|
|
71
|
-
}), ";");
|
|
56
|
+
return /*#__PURE__*/css("display:flex;align-items:center;color:", layout.color, ";background:", layout.bgColor, ";left:0;transition:left ", layout.transition, ";&.", k, "-fixed{position:fixed;left:0;right:0;top:0;z-index:", theme.midZIndex + 1, ";}>.", k, "-menu{background:transparent!important;}&.", k, "-blur{backdrop-filter:blur(20px);background:", setAlpha(layout.bgColor, 0.1), ";}&.", k, "-box-shadow{border-bottom:none!important;box-shadow:", theme.boxShadow, ";}&.", k, "-light{background:", layout.light.bgColor, ";color:", layout.light.color, ";border-bottom:", layout.light.border, ";&.", k, "-blur{background:", setAlpha(layout.light.bgColor, 0.1), ";}}");
|
|
72
57
|
});
|
|
73
58
|
export var makeAsideStyles = cache(function makeAsideStyles(k) {
|
|
74
59
|
return /*#__PURE__*/css("transition:width ", layout.transition, ";display:flex;flex-direction:column;background:", layout.bgColor, ";color:", layout.color, ";", _mapInstanceProperty(themes).call(themes, function (theme) {
|
|
75
60
|
if (theme === 'dark') return;
|
|
76
|
-
var styles = layout
|
|
61
|
+
var styles = layout.light;
|
|
77
62
|
return /*#__PURE__*/css("&.", k, "-", theme, "{background:", styles.bgColor, ";color:", styles.color, ";border-right:", styles.border, ";}");
|
|
78
63
|
}), " &.", k, "-fixed{position:fixed;overflow:auto;left:0;top:0;bottom:0;z-index:", theme.midZIndex, ";}.", k, "-menu{width:auto!important;}");
|
|
79
64
|
});
|
package/components/menu/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { Component } from 'intact-vue-next';
|
|
|
7
7
|
import BasicDemo from '~/components/menu/demos/basic';
|
|
8
8
|
import CollapseDemo from '~/components/menu/demos/collapse';
|
|
9
9
|
import AccordionDemo from '~/components/menu/demos/accordion';
|
|
10
|
+
import CollapseArrowDemo from '~/components/menu/demos/showCollapseArrow';
|
|
10
11
|
import { mount, unmount, dispatchEvent, getElement, wait } from '../../test/utils';
|
|
11
12
|
import { Menu, MenuItem } from './';
|
|
12
13
|
describe('Menu', function () {
|
|
@@ -23,7 +24,7 @@ describe('Menu', function () {
|
|
|
23
24
|
return wait();
|
|
24
25
|
case 3:
|
|
25
26
|
// shrink
|
|
26
|
-
title = element.querySelector('.k-expanded .k-menu-title');
|
|
27
|
+
title = element.querySelector('.k-expanded .k-menu-item-title');
|
|
27
28
|
title.click();
|
|
28
29
|
_context.next = 7;
|
|
29
30
|
return wait(500);
|
|
@@ -53,7 +54,7 @@ describe('Menu', function () {
|
|
|
53
54
|
return wait();
|
|
54
55
|
case 4:
|
|
55
56
|
expect(element.innerHTML).to.matchSnapshot();
|
|
56
|
-
_element$querySelecto = element.querySelectorAll('.k-menu-title'), title = _element$querySelecto[0], disabledTitle = _element$querySelecto[1];
|
|
57
|
+
_element$querySelecto = element.querySelectorAll('.k-menu-body .k-menu-item-title'), title = _element$querySelecto[0], disabledTitle = _element$querySelecto[1];
|
|
57
58
|
title.click();
|
|
58
59
|
_context2.next = 9;
|
|
59
60
|
return wait();
|
|
@@ -66,7 +67,7 @@ describe('Menu', function () {
|
|
|
66
67
|
case 14:
|
|
67
68
|
expect(element.outerHTML).to.matchSnapshot();
|
|
68
69
|
expect(instance.get('selectedKey')).to.eql('1');
|
|
69
|
-
subTitle = element.querySelector('.k-expanded .k-menu .k-menu-title');
|
|
70
|
+
subTitle = element.querySelector('.k-expanded .k-menu .k-menu-body .k-menu-item-title');
|
|
70
71
|
subTitle.click();
|
|
71
72
|
_context2.next = 20;
|
|
72
73
|
return wait();
|
|
@@ -97,14 +98,14 @@ describe('Menu', function () {
|
|
|
97
98
|
case 4:
|
|
98
99
|
expect(element.outerHTML).to.matchSnapshot();
|
|
99
100
|
// show sub menu
|
|
100
|
-
title = element.querySelector('.k-menu-item:nth-child(3) .k-menu-title');
|
|
101
|
+
title = element.querySelector('.k-menu-body .k-menu-item:nth-child(3) .k-menu-item-title');
|
|
101
102
|
dispatchEvent(title, 'mouseenter');
|
|
102
103
|
_context3.next = 9;
|
|
103
104
|
return wait();
|
|
104
105
|
case 9:
|
|
105
106
|
dropdown = getElement('.k-dropdown-menu.k-menu');
|
|
106
107
|
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
107
|
-
dispatchEvent(dropdown.querySelector('.k-menu-item:nth-child(4) .k-menu-title'), 'mouseenter');
|
|
108
|
+
dispatchEvent(dropdown.querySelector('.k-menu-body .k-menu-item:nth-child(4) .k-menu-item-title'), 'mouseenter');
|
|
108
109
|
_context3.next = 14;
|
|
109
110
|
return wait();
|
|
110
111
|
case 14:
|
|
@@ -128,19 +129,19 @@ describe('Menu', function () {
|
|
|
128
129
|
case 0:
|
|
129
130
|
_mount4 = mount(CollapseDemo), instance = _mount4[0], element = _mount4[1];
|
|
130
131
|
instance.set('collapse', true);
|
|
131
|
-
title = element.querySelector('.k-menu-title');
|
|
132
|
+
title = element.querySelector('.k-menu-body .k-menu-item-title');
|
|
132
133
|
title.click();
|
|
133
134
|
_context4.next = 6;
|
|
134
135
|
return wait();
|
|
135
136
|
case 6:
|
|
136
137
|
expect(element.outerHTML).to.matchSnapshot();
|
|
137
|
-
title = element.querySelector('.k-menu-item:nth-child(3) .k-menu-title');
|
|
138
|
+
title = element.querySelector('.k-menu-body .k-menu-item:nth-child(3) .k-menu-item-title');
|
|
138
139
|
dispatchEvent(title, 'mouseenter');
|
|
139
140
|
_context4.next = 11;
|
|
140
141
|
return wait();
|
|
141
142
|
case 11:
|
|
142
143
|
dropdown = getElement('.k-dropdown-menu.k-menu');
|
|
143
|
-
dropdown.querySelector('.k-menu-title').click();
|
|
144
|
+
dropdown.querySelector('.k-menu-body .k-menu-item-title').click();
|
|
144
145
|
_context4.next = 15;
|
|
145
146
|
return wait();
|
|
146
147
|
case 15:
|
|
@@ -157,40 +158,41 @@ describe('Menu', function () {
|
|
|
157
158
|
}, _callee4);
|
|
158
159
|
})));
|
|
159
160
|
it('accordion', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
160
|
-
var _mount5, instance, element, menu3, subMenu1, subMenu4, menu1;
|
|
161
|
+
var _mount5, instance, element, rootElement, menu3, subMenu1, subMenu4, menu1;
|
|
161
162
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
162
163
|
while (1) switch (_context5.prev = _context5.next) {
|
|
163
164
|
case 0:
|
|
164
|
-
_mount5 = mount(AccordionDemo), instance = _mount5[0], element = _mount5[1];
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
_mount5 = mount(AccordionDemo), instance = _mount5[0], element = _mount5[1]; // const menu3 = element.children[2] as HTMLElement;
|
|
166
|
+
rootElement = element.firstElementChild;
|
|
167
|
+
menu3 = rootElement.children[2];
|
|
168
|
+
subMenu1 = menu3.querySelector('.k-menu .k-menu-body').firstElementChild.querySelector('.k-menu-item-title');
|
|
167
169
|
subMenu1.click();
|
|
168
|
-
_context5.next =
|
|
170
|
+
_context5.next = 7;
|
|
169
171
|
return wait();
|
|
170
|
-
case
|
|
171
|
-
expect(
|
|
172
|
+
case 7:
|
|
173
|
+
expect(rootElement.innerHTML).to.matchSnapshot();
|
|
172
174
|
expect(instance.get('expandedKeys')).to.eql(['3', '3-1']);
|
|
173
|
-
subMenu4 = menu3.querySelector('.k-menu').lastElementChild.querySelector('.k-menu-title');
|
|
175
|
+
subMenu4 = menu3.querySelector('.k-menu .k-menu-body').lastElementChild.querySelector('.k-menu-item-title');
|
|
174
176
|
subMenu4.click();
|
|
175
|
-
_context5.next =
|
|
177
|
+
_context5.next = 13;
|
|
176
178
|
return wait();
|
|
177
|
-
case
|
|
178
|
-
expect(
|
|
179
|
+
case 13:
|
|
180
|
+
expect(rootElement.innerHTML).to.matchSnapshot();
|
|
179
181
|
expect(instance.get('expandedKeys')).to.eql(['3', '3-4']);
|
|
180
|
-
menu1 =
|
|
182
|
+
menu1 = rootElement.firstElementChild.querySelector('.k-menu-item-title');
|
|
181
183
|
menu1.click();
|
|
182
|
-
_context5.next =
|
|
184
|
+
_context5.next = 19;
|
|
183
185
|
return wait();
|
|
184
|
-
case
|
|
185
|
-
expect(
|
|
186
|
+
case 19:
|
|
187
|
+
expect(rootElement.innerHTML).to.matchSnapshot();
|
|
186
188
|
expect(instance.get('expandedKeys')).to.eql(['3-4', '1']);
|
|
187
|
-
menu3.querySelector('.k-menu-title').click();
|
|
188
|
-
_context5.next =
|
|
189
|
+
menu3.querySelector('.k-menu-item-title').click();
|
|
190
|
+
_context5.next = 24;
|
|
189
191
|
return wait();
|
|
190
|
-
case
|
|
191
|
-
expect(
|
|
192
|
+
case 24:
|
|
193
|
+
expect(rootElement.innerHTML).to.matchSnapshot();
|
|
192
194
|
expect(instance.get('expandedKeys')).to.eql(['3-4', '3']);
|
|
193
|
-
case
|
|
195
|
+
case 26:
|
|
194
196
|
case "end":
|
|
195
197
|
return _context5.stop();
|
|
196
198
|
}
|
|
@@ -240,4 +242,33 @@ describe('Menu', function () {
|
|
|
240
242
|
}
|
|
241
243
|
}, _callee6);
|
|
242
244
|
})));
|
|
245
|
+
it('collapsed arrow', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
246
|
+
var _mount7, instance, element, arrow;
|
|
247
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context8) {
|
|
248
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
249
|
+
case 0:
|
|
250
|
+
_mount7 = mount(CollapseArrowDemo), instance = _mount7[0], element = _mount7[1];
|
|
251
|
+
instance.set('showCollapseArrow', true);
|
|
252
|
+
_context8.next = 4;
|
|
253
|
+
return wait();
|
|
254
|
+
case 4:
|
|
255
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
256
|
+
arrow = element.querySelector('.k-menu .k-menu-arrow-box');
|
|
257
|
+
arrow.click();
|
|
258
|
+
_context8.next = 9;
|
|
259
|
+
return wait(500);
|
|
260
|
+
case 9:
|
|
261
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
262
|
+
instance.set('showCollapseArrow', false);
|
|
263
|
+
_context8.next = 13;
|
|
264
|
+
return wait();
|
|
265
|
+
case 13:
|
|
266
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
267
|
+
expect(getElement('.k-menu-arrow-box')).to.be.undefined;
|
|
268
|
+
case 15:
|
|
269
|
+
case "end":
|
|
270
|
+
return _context8.stop();
|
|
271
|
+
}
|
|
272
|
+
}, _callee7);
|
|
273
|
+
})));
|
|
243
274
|
});
|
|
@@ -47,8 +47,8 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
47
47
|
return _$ce(2, 'div', [showDot ? _$cc(Icon, {
|
|
48
48
|
'className': _$cn(k + "-menu-dot ion-record")
|
|
49
49
|
}) : undefined, _$ce(2, 'div', children, 0, _$cn(k + "-menu-name")), subMenuVNode ? _$cc(Icon, {
|
|
50
|
-
'className': _$cn(k + "-menu-arrow
|
|
51
|
-
}) : undefined], 0, _$cn((_$cn2 = {}, _$cn2[k + "-menu-title"] = true, _$cn2[makeTitleStyles(k)] = true, _$cn2)), {
|
|
50
|
+
'className': _$cn(k + "-menu-item-arrow ion-arrow-down-b")
|
|
51
|
+
}) : undefined], 0, _$cn((_$cn2 = {}, _$cn2[k + "-menu-item-title"] = true, _$cn2[makeTitleStyles(k)] = true, _$cn2)), {
|
|
52
52
|
'ev-click': _this.onClick.bind(_this, subMenuVNode)
|
|
53
53
|
});
|
|
54
54
|
};
|
|
@@ -65,7 +65,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
65
65
|
var _makeNestedMenuStyles = makeNestedMenuStyles(k, showDot || !!iconVNode, paddingLeft),
|
|
66
66
|
_classname = _makeNestedMenuStyles[0],
|
|
67
67
|
_paddingLeft = _makeNestedMenuStyles[1];
|
|
68
|
-
var _className = _$cn((_$cn3 = {}, _$cn3[_classname] = true, _$cn3[subMenuVNode.className] = subMenuVNode.className, _$cn3));
|
|
68
|
+
var _className = _$cn((_$cn3 = {}, _$cn3[_classname] = true, _$cn3[subMenuVNode.className] = subMenuVNode.className, _$cn3[k + "-sub-menu"] = true, _$cn3));
|
|
69
69
|
var clonedVNode = directClone(subMenuVNode);
|
|
70
70
|
clonedVNode.props = _extends({}, clonedVNode.props, {
|
|
71
71
|
className: _className,
|
|
@@ -5,6 +5,7 @@ export interface MenuProps<K extends Key = Key> {
|
|
|
5
5
|
selectedKey?: K;
|
|
6
6
|
theme?: 'light' | 'dark' | 'white';
|
|
7
7
|
collapse?: boolean;
|
|
8
|
+
showCollapseArrow?: boolean;
|
|
8
9
|
type?: 'vertical' | 'horizontal';
|
|
9
10
|
size?: 'large' | 'default' | 'small';
|
|
10
11
|
accordion?: boolean;
|
|
@@ -28,4 +29,5 @@ export declare class Menu<K extends Key = Key> extends Component<MenuProps<K>, M
|
|
|
28
29
|
highlight?: ReturnType<typeof useHighlight>;
|
|
29
30
|
private config;
|
|
30
31
|
init(): void;
|
|
32
|
+
onClick(e: MouseEvent): void;
|
|
31
33
|
}
|
package/components/menu/menu.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
|
+
import { __decorate } from "tslib";
|
|
3
4
|
import { Component, provide, inject } from 'intact-vue-next';
|
|
4
5
|
import template from './menu.vdt';
|
|
5
6
|
import { useHighlight } from './useHighlight';
|
|
6
7
|
import { useConfigContext } from '../config';
|
|
8
|
+
import { bind } from '../utils';
|
|
7
9
|
var typeDefs = {
|
|
8
10
|
expandedKeys: Array,
|
|
9
11
|
selectedKey: [String, Number],
|
|
10
12
|
theme: ['light', 'dark', 'white'],
|
|
11
13
|
collapse: Boolean,
|
|
14
|
+
showCollapseArrow: Boolean,
|
|
12
15
|
type: ['vertical', 'horizontal'],
|
|
13
16
|
size: ['large', 'default', 'small'],
|
|
14
17
|
accordion: Boolean,
|
|
@@ -50,8 +53,16 @@ export var Menu = /*#__PURE__*/function (_Component) {
|
|
|
50
53
|
this.highlight = useHighlight();
|
|
51
54
|
}
|
|
52
55
|
};
|
|
56
|
+
_proto.onClick = function onClick(e) {
|
|
57
|
+
var _this$get = this.get(),
|
|
58
|
+
collapse = _this$get.collapse;
|
|
59
|
+
this.set({
|
|
60
|
+
collapse: !collapse
|
|
61
|
+
});
|
|
62
|
+
};
|
|
53
63
|
return Menu;
|
|
54
64
|
}(Component);
|
|
55
65
|
Menu.template = template;
|
|
56
66
|
Menu.typeDefs = typeDefs;
|
|
57
|
-
Menu.defaults = defaults;
|
|
67
|
+
Menu.defaults = defaults;
|
|
68
|
+
__decorate([bind], Menu.prototype, "onClick", null);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
-
import { noop as _$no, createElementVNode as _$ce, className as _$cn,
|
|
2
|
+
import { noop as _$no, createElementVNode as _$ce, className as _$cn, createUnknownComponentVNode as _$cc, createVNode as _$cv } from 'intact-vue-next';
|
|
3
3
|
import { DropdownMenu } from '../dropdown';
|
|
4
4
|
import { getRestProps, findChildren, isComponentVNode } from '../utils';
|
|
5
5
|
import { isDropdown } from './useDropdown';
|
|
@@ -19,11 +19,12 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
19
19
|
collapse = _get.collapse,
|
|
20
20
|
theme = _get.theme,
|
|
21
21
|
type = _get.type,
|
|
22
|
-
size = _get.size
|
|
22
|
+
size = _get.size,
|
|
23
|
+
showCollapseArrow = _get.showCollapseArrow;
|
|
23
24
|
var isRootMenu = !this.rootMenu;
|
|
24
25
|
var isDropdownMenu = !isRootMenu && isDropdown(this.rootMenu);
|
|
25
26
|
var k = this.config.k;
|
|
26
|
-
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-menu"] = true, _classNameObj[className] = className, _classNameObj[k + "-" + theme] = (isRootMenu || isDropdownMenu) && theme, _classNameObj[k + "-" + size] = isRootMenu && size !== 'default', _classNameObj[k + "-collapsed"] = isRootMenu && collapse, _classNameObj[k + "-" + type] = isRootMenu && type, _classNameObj[makeMenuStyles(k)] = true, _classNameObj);
|
|
27
|
+
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-menu"] = true, _classNameObj[className] = className, _classNameObj[k + "-" + (theme === 'dark' ? 'dark' : 'light')] = (isRootMenu || isDropdownMenu) && theme, _classNameObj[k + "-" + size] = isRootMenu && size !== 'default', _classNameObj[k + "-collapsed"] = isRootMenu && collapse, _classNameObj[k + "-collapsed-arrow"] = isRootMenu && showCollapseArrow && collapse, _classNameObj[k + "-" + type] = isRootMenu && type, _classNameObj[makeMenuStyles(k)] = true, _classNameObj);
|
|
27
28
|
var header = (_$blocks['header'] = function ($super) {
|
|
28
29
|
return null;
|
|
29
30
|
}, __$blocks['header'] = function ($super, data) {
|
|
@@ -35,7 +36,11 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
35
36
|
}, __$blocks['header'](_$no));
|
|
36
37
|
var content = [$blocks.header ? _$ce(2, 'div', !collapse ? header : findChildren(header, function (vNode) {
|
|
37
38
|
return isComponentVNode(vNode, Icon);
|
|
38
|
-
}), 0, _$cn((_$cn2 = {}, _$cn2[k + "-menu-header"] = true, _$cn2[makeTitleStyles(k)] = true, _$cn2))) : undefined,
|
|
39
|
+
}), 0, _$cn((_$cn2 = {}, _$cn2[k + "-menu-header"] = true, _$cn2[makeTitleStyles(k)] = true, _$cn2))) : undefined, isRootMenu && showCollapseArrow && type !== 'horizontal' ? _$ce(2, 'div', _$cc(Icon, {
|
|
40
|
+
'className': _$cn(k + "-menu-arrow ion-arrow-left-b")
|
|
41
|
+
}), 2, _$cn(k + "-menu-arrow-box"), {
|
|
42
|
+
'ev-click': this.onClick.bind(this)
|
|
43
|
+
}) : undefined, _$ce(2, 'div', children, 0, _$cn(k + "-menu-body"))];
|
|
39
44
|
return !isDropdownMenu ? _$cv('div', _extends({}, getRestProps(this), {
|
|
40
45
|
'className': _$cn(classNameObj)
|
|
41
46
|
}), content) : _$cc(DropdownMenu, _extends({}, getRestProps(this), {
|
|
@@ -5,14 +5,23 @@ declare const defaults: {
|
|
|
5
5
|
bgColor: string;
|
|
6
6
|
fontSize: string;
|
|
7
7
|
readonly borderRadius: string;
|
|
8
|
+
readonly border: string;
|
|
8
9
|
item: {
|
|
9
10
|
height: string;
|
|
10
11
|
padding: string;
|
|
12
|
+
bodyPadding: string;
|
|
11
13
|
color: string;
|
|
12
14
|
hoverColor: string;
|
|
13
|
-
|
|
15
|
+
disabledColor: string;
|
|
14
16
|
readonly activeBgColor: string;
|
|
17
|
+
readonly hoverBgColor: string;
|
|
15
18
|
dotFontSize: string;
|
|
19
|
+
subTitleColor: string;
|
|
20
|
+
};
|
|
21
|
+
title: {
|
|
22
|
+
height: string;
|
|
23
|
+
padding: string;
|
|
24
|
+
color: string;
|
|
16
25
|
};
|
|
17
26
|
icon: {
|
|
18
27
|
width: string;
|
|
@@ -21,27 +30,21 @@ declare const defaults: {
|
|
|
21
30
|
header: {
|
|
22
31
|
height: string;
|
|
23
32
|
fontSize: string;
|
|
33
|
+
color: string;
|
|
24
34
|
borderBottom: string;
|
|
25
35
|
};
|
|
26
|
-
subBgColor: string;
|
|
27
36
|
light: {
|
|
28
37
|
bgColor: string;
|
|
29
|
-
|
|
30
|
-
border: string;
|
|
38
|
+
readonly border: string;
|
|
31
39
|
item: {
|
|
32
40
|
readonly color: string;
|
|
33
41
|
readonly hoverColor: string;
|
|
42
|
+
readonly hoverBg: string;
|
|
34
43
|
disabledColor: string;
|
|
44
|
+
subTitleColor: string;
|
|
35
45
|
};
|
|
36
|
-
|
|
37
|
-
white: {
|
|
38
|
-
bgColor: string;
|
|
39
|
-
subBgColor: string;
|
|
40
|
-
border: string;
|
|
41
|
-
item: {
|
|
46
|
+
title: {
|
|
42
47
|
readonly color: string;
|
|
43
|
-
readonly hoverColor: string;
|
|
44
|
-
readonly disabledColor: string;
|
|
45
48
|
};
|
|
46
49
|
active: {
|
|
47
50
|
readonly color: string;
|