@king-design/intact 2.0.1 → 2.0.4
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/index.spec.ts +59 -0
- package/components/cascader/index.vdt +4 -4
- package/components/cascader/useLabel.ts +9 -9
- package/components/dropdown/dropdown.ts +5 -6
- package/components/form/index.spec.ts +1 -1
- package/components/menu/demos/collapse.md +3 -1
- package/components/menu/index.spec.ts +10 -4
- package/components/menu/item.ts +5 -4
- package/components/menu/item.vdt +3 -3
- package/components/menu/menu.ts +4 -0
- package/components/menu/useExpanded.ts +1 -1
- package/components/menu/useHighlight.ts +45 -40
- package/components/portal.ts +1 -1
- package/components/skeleton/demos/animate.md +30 -0
- package/components/skeleton/demos/avator.md +30 -0
- package/components/skeleton/demos/basic.md +30 -0
- package/components/skeleton/demos/custom.md +39 -0
- package/components/skeleton/demos/rows.md +32 -0
- package/components/skeleton/index.md +24 -0
- package/components/skeleton/index.ts +2 -0
- package/components/skeleton/item.ts +30 -0
- package/components/skeleton/item.vdt +28 -0
- package/components/skeleton/skeleton.ts +33 -0
- package/components/skeleton/skeleton.vdt +32 -0
- package/components/skeleton/style.ts +105 -0
- package/components/tree/useFilter.ts +1 -2
- package/es/components/cascader/index.spec.js +88 -0
- package/es/components/cascader/index.vdt.js +4 -4
- package/es/components/cascader/useLabel.js +8 -12
- package/es/components/dropdown/dropdown.js +7 -7
- package/es/components/form/index.spec.js +2 -4
- package/es/components/menu/index.spec.js +13 -6
- package/es/components/menu/item.d.ts +0 -1
- package/es/components/menu/item.js +6 -4
- package/es/components/menu/item.vdt.js +4 -4
- package/es/components/menu/menu.d.ts +3 -0
- package/es/components/menu/menu.js +4 -0
- package/es/components/menu/useExpanded.d.ts +1 -4
- package/es/components/menu/useHighlight.d.ts +5 -8
- package/es/components/menu/useHighlight.js +44 -33
- package/es/components/portal.js +1 -1
- package/es/components/skeleton/index.d.ts +2 -0
- package/es/components/skeleton/index.js +2 -0
- package/es/components/skeleton/item.d.ts +16 -0
- package/es/components/skeleton/item.js +26 -0
- package/es/components/skeleton/item.vdt.js +35 -0
- package/es/components/skeleton/skeleton.d.ts +17 -0
- package/es/components/skeleton/skeleton.js +30 -0
- package/es/components/skeleton/skeleton.vdt.js +37 -0
- package/es/components/skeleton/style.d.ts +6 -0
- package/es/components/skeleton/style.js +35 -0
- package/es/components/tree/useFilter.js +1 -2
- package/es/index.d.ts +3 -2
- package/es/index.js +3 -2
- package/es/packages/kpc-react/__tests__/components/form.spec.d.ts +1 -0
- package/es/packages/kpc-react/__tests__/components/form.spec.js +46 -0
- package/es/site/data/components/menu/demos/collapse/index.js +1 -0
- package/es/site/data/components/menu/demos/collapse/react.js +7 -0
- package/es/site/data/components/skeleton/demos/animate/index.d.ts +11 -0
- package/es/site/data/components/skeleton/demos/animate/index.js +23 -0
- package/es/site/data/components/skeleton/demos/animate/react.d.ts +11 -0
- package/es/site/data/components/skeleton/demos/animate/react.js +38 -0
- package/es/site/data/components/skeleton/demos/avator/index.d.ts +11 -0
- package/es/site/data/components/skeleton/demos/avator/index.js +23 -0
- package/es/site/data/components/skeleton/demos/avator/react.d.ts +11 -0
- package/es/site/data/components/skeleton/demos/avator/react.js +37 -0
- package/es/site/data/components/skeleton/demos/basic/index.d.ts +11 -0
- package/es/site/data/components/skeleton/demos/basic/index.js +23 -0
- package/es/site/data/components/skeleton/demos/basic/react.d.ts +11 -0
- package/es/site/data/components/skeleton/demos/basic/react.js +36 -0
- package/es/site/data/components/skeleton/demos/custom/index.d.ts +11 -0
- package/es/site/data/components/skeleton/demos/custom/index.js +23 -0
- package/es/site/data/components/skeleton/demos/custom/react.d.ts +11 -0
- package/es/site/data/components/skeleton/demos/custom/react.js +60 -0
- package/es/site/data/components/skeleton/demos/rows/index.d.ts +13 -0
- package/es/site/data/components/skeleton/demos/rows/index.js +24 -0
- package/es/site/data/components/skeleton/demos/rows/react.d.ts +13 -0
- package/es/site/data/components/skeleton/demos/rows/react.js +38 -0
- package/es/site/data/components/skeleton/index.d.ts +57 -0
- package/es/site/data/components/skeleton/index.js +42 -0
- package/es/site/src/client.js +4 -4
- package/es/site/src/components/footer/styles.js +1 -1
- package/es/site/src/pages/colorProcess/index.d.ts +21 -0
- package/es/site/src/pages/colorProcess/index.js +79 -0
- package/es/site/src/pages/colorProcess/style.d.ts +3 -0
- package/es/site/src/pages/colorProcess/style.js +53 -0
- package/es/site/src/pages/font/index.d.ts +12 -0
- package/es/site/src/pages/font/index.js +22 -0
- package/es/site/src/pages/font/styles.d.ts +1 -0
- package/es/site/src/pages/font/styles.js +9 -0
- package/es/site/src/pages/iframe/colorProcess/styles.js +2 -2
- package/es/site/src/pages/index/BestPractice/styles.js +1 -1
- package/es/site/src/pages/index/ColorProcess/styles.js +2 -2
- package/es/site/src/pages/index/KingVersion/styles.js +1 -1
- package/es/site/src/pages/index/NewFunction/index.d.ts +2 -0
- package/es/site/src/pages/index/NewFunction/index.js +8 -2
- package/es/site/src/pages/index/NewFunction/styles.js +1 -1
- package/es/site/src/pages/index/styles.js +2 -1
- package/es/site/src/pages/resource/index.d.ts +1 -0
- package/es/site/src/pages/resource/index.js +4 -1
- package/es/site/src/pages/styles.js +1 -1
- package/es/site/src/router/index.js +75 -5
- package/index.ts +3 -2
- package/package.json +5 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {makeItemStyles} from './style';
|
|
2
|
+
import {getRestProps} from '../utils';
|
|
3
|
+
|
|
4
|
+
const {type} = this.get();
|
|
5
|
+
|
|
6
|
+
const classNameObj = {
|
|
7
|
+
'k-skeleton-item': true,
|
|
8
|
+
[makeItemStyles()]: true
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const ItemklsObj = {
|
|
12
|
+
'k-skeleton-item-box': true,
|
|
13
|
+
[`skeleton-item-${type}`]: true
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const skeletonItem = <div class={ItemklsObj} {...getRestProps(this)}>
|
|
17
|
+
<svg
|
|
18
|
+
v-if={type === 'image'}
|
|
19
|
+
viewBox="0 0 1024 1024"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
>
|
|
22
|
+
<path
|
|
23
|
+
d="M64 896V128h896v768H64z m64-128l192-192 116.352 116.352L640 448l256 307.2V192H128v576z m224-480a96 96 0 1 1-0.064 192.064A96 96 0 0 1 352 288z"
|
|
24
|
+
/>
|
|
25
|
+
</svg>
|
|
26
|
+
</div>;
|
|
27
|
+
|
|
28
|
+
<div class={classNameObj}>{skeletonItem}</div>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {Component, TypeDefs} from 'intact';
|
|
2
|
+
import template from './skeleton.vdt';
|
|
3
|
+
|
|
4
|
+
export interface SkeletonProps {
|
|
5
|
+
loading: boolean
|
|
6
|
+
animated?: boolean
|
|
7
|
+
rows?: number
|
|
8
|
+
avator?: boolean
|
|
9
|
+
size?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SkeletonEvents {}
|
|
13
|
+
|
|
14
|
+
export interface SkeletonBlocks {}
|
|
15
|
+
|
|
16
|
+
const typeDefs: Required<TypeDefs<SkeletonProps>> = {
|
|
17
|
+
loading: Boolean,
|
|
18
|
+
animated: Boolean,
|
|
19
|
+
rows: Number,
|
|
20
|
+
avator: Boolean,
|
|
21
|
+
size: String
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const defaults = (): Partial<SkeletonProps> => ({
|
|
25
|
+
rows: 2,
|
|
26
|
+
size: 'large'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export class Skeleton extends Component<SkeletonProps, SkeletonEvents, SkeletonBlocks> {
|
|
30
|
+
static template = template;
|
|
31
|
+
static typeDefs = typeDefs;
|
|
32
|
+
static defaults = defaults;
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {SkeletonItem} from './item';
|
|
2
|
+
import {makeStyles, kls} from './style';
|
|
3
|
+
|
|
4
|
+
const {rows, avator, animated, children, loading, size} = this.get();
|
|
5
|
+
|
|
6
|
+
const targetRows = typeof rows !== 'number'
|
|
7
|
+
? 3
|
|
8
|
+
: rows < 1
|
|
9
|
+
? 1
|
|
10
|
+
: parseInt(rows);
|
|
11
|
+
|
|
12
|
+
const skeletonList = Array(targetRows + 2).fill();
|
|
13
|
+
const skeletonItems = <SkeletonItem v-for={skeletonList}></SkeletonItem>;
|
|
14
|
+
|
|
15
|
+
const classNameObj = {
|
|
16
|
+
'k-skeleton': true,
|
|
17
|
+
'k-animated': animated,
|
|
18
|
+
[makeStyles(size)]: true
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
<div class={classNameObj} v-if={loading}>
|
|
22
|
+
<template v-if={children}>
|
|
23
|
+
<div>{children}</div>
|
|
24
|
+
</template>
|
|
25
|
+
<template v-else>
|
|
26
|
+
<div v-if={avator} class={kls('avator-box')}>
|
|
27
|
+
<SkeletonItem type="avator"></SkeletonItem>
|
|
28
|
+
<div class="k-skeleton-items">{skeletonItems}</div>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="k-skeleton-items" v-else>{skeletonItems}</div>
|
|
31
|
+
</template>
|
|
32
|
+
</div>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {deepDefaults} from '../../styles/utils';
|
|
2
|
+
import { theme, setDefault } from '../../styles/theme';
|
|
3
|
+
import {css, keyframes} from '@emotion/css';
|
|
4
|
+
import '../../styles/global';
|
|
5
|
+
|
|
6
|
+
export const kls = (className: string) => `k-skeleton-${className}`;
|
|
7
|
+
|
|
8
|
+
type ItemSize = 'default' | 'large' | 'small' | 'mini';
|
|
9
|
+
|
|
10
|
+
const defaults = {
|
|
11
|
+
item: {
|
|
12
|
+
bgColor: '#dcdde0'
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
let skeleton: typeof defaults;
|
|
17
|
+
setDefault(() => {
|
|
18
|
+
skeleton = deepDefaults(theme, {skeleton: defaults}).skeleton;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export function makeStyles(size: ItemSize) {
|
|
22
|
+
return css`
|
|
23
|
+
&.k-animated {
|
|
24
|
+
.${kls('item')} {
|
|
25
|
+
& > .k-skeleton-item-box {
|
|
26
|
+
background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
|
|
27
|
+
background-size: 400% 100%;
|
|
28
|
+
animation: ${skeletonLoading} 1.4s ease infinite;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
.k-skeleton-items {
|
|
33
|
+
.${kls('item')}:first-child {
|
|
34
|
+
.skeleton-item-text {
|
|
35
|
+
width: 33%;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
.${kls('item')}:last-child {
|
|
39
|
+
.skeleton-item-text {
|
|
40
|
+
width: 61%;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
.${kls('avator-box')} {
|
|
45
|
+
display: flex;
|
|
46
|
+
& > div:last-child {
|
|
47
|
+
flex-grow: 1;
|
|
48
|
+
padding-left: 20px;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
.skeleton-item-button,
|
|
52
|
+
.skeleton-item-input {
|
|
53
|
+
height: ${theme[size].height}
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const skeletonLoading = keyframes`
|
|
59
|
+
0% {
|
|
60
|
+
background-position: 100% 50%;
|
|
61
|
+
}
|
|
62
|
+
to {
|
|
63
|
+
background-position: 0 50%;
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
export function makeItemStyles() {
|
|
68
|
+
const skeletonItem = skeleton.item;
|
|
69
|
+
return css`
|
|
70
|
+
& > div {
|
|
71
|
+
background: ${skeletonItem.bgColor}
|
|
72
|
+
}
|
|
73
|
+
.skeleton-item-text {
|
|
74
|
+
width: 100%;
|
|
75
|
+
height: 16px;
|
|
76
|
+
border-radius: 4px;
|
|
77
|
+
margin-top: 16px;
|
|
78
|
+
}
|
|
79
|
+
.skeleton-item-avator {
|
|
80
|
+
width: 40px;
|
|
81
|
+
height: 40px;
|
|
82
|
+
border-radius: 50%;
|
|
83
|
+
}
|
|
84
|
+
.skeleton-item-image {
|
|
85
|
+
display: flex;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
align-items: center;
|
|
88
|
+
width: 200px;
|
|
89
|
+
height: 200px;
|
|
90
|
+
& > svg {
|
|
91
|
+
width: 48px;
|
|
92
|
+
height: 48px;
|
|
93
|
+
fill: ${skeletonItem.bgColor};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
.skeleton-item-button {
|
|
97
|
+
width: 64px;
|
|
98
|
+
background: ${skeletonItem.bgColor};
|
|
99
|
+
}
|
|
100
|
+
.skeleton-item-input {
|
|
101
|
+
width: 160px;
|
|
102
|
+
background: ${skeletonItem.bgColor};
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
@@ -47,11 +47,10 @@ export function useFilter(getNodes: () => Node<Key>[], getExpandedKeys: () => Se
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function updateFilterUpward(node: Node<Key> | null) {
|
|
50
|
-
if (!node) return;
|
|
50
|
+
if (!node || node.filter) return;
|
|
51
51
|
|
|
52
52
|
// should expand the node
|
|
53
53
|
getExpandedKeys().add(node.key);
|
|
54
|
-
if (node.filter) return;
|
|
55
54
|
|
|
56
55
|
node.filter = true;
|
|
57
56
|
updateFilterUpward(node.parent);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
2
4
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
5
|
import BasicDemo from '~/components/cascader/demos/basic';
|
|
4
6
|
import CustomDemo from '~/components/cascader/demos/custom';
|
|
@@ -6,6 +8,8 @@ import ChangeOnSelectDemo from '~/components/cascader/demos/changeOnSelect';
|
|
|
6
8
|
import LoadDataDemo from '~/components/cascader/demos/loadData';
|
|
7
9
|
import FilterDemo from '~/components/cascader/demos/filterable';
|
|
8
10
|
import { mount, unmount, dispatchEvent, getElement, getElements, wait } from '../../test/utils';
|
|
11
|
+
import { Cascader } from './';
|
|
12
|
+
import { Component } from 'intact';
|
|
9
13
|
describe('Cascader', function () {
|
|
10
14
|
afterEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
11
15
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -278,4 +282,88 @@ describe('Cascader', function () {
|
|
|
278
282
|
}
|
|
279
283
|
}, _callee7);
|
|
280
284
|
})));
|
|
285
|
+
it('duplicated sub data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
286
|
+
var Demo, _mount7, instance, element, _getElements2, dropdown1, dropdown2, _dropdown1$querySelec4, item1, item2, _dropdown2$querySelec3, item21, dropdown3, _dropdown3$querySelec2, item31;
|
|
287
|
+
|
|
288
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context9) {
|
|
289
|
+
while (1) {
|
|
290
|
+
switch (_context9.prev = _context9.next) {
|
|
291
|
+
case 0:
|
|
292
|
+
Demo = /*#__PURE__*/function (_Component) {
|
|
293
|
+
_inheritsLoose(Demo, _Component);
|
|
294
|
+
|
|
295
|
+
function Demo() {
|
|
296
|
+
var _context8;
|
|
297
|
+
|
|
298
|
+
var _this;
|
|
299
|
+
|
|
300
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
301
|
+
args[_key] = arguments[_key];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context8 = [this]).call(_context8, args)) || this;
|
|
305
|
+
_this.Cascader = Cascader;
|
|
306
|
+
return _this;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
Demo.defaults = function defaults() {
|
|
310
|
+
return {
|
|
311
|
+
value: ['beijing', 'haidian'],
|
|
312
|
+
data: [{
|
|
313
|
+
value: 'beijing',
|
|
314
|
+
label: '北京',
|
|
315
|
+
children: [{
|
|
316
|
+
value: 'haidian',
|
|
317
|
+
label: '海淀区'
|
|
318
|
+
}]
|
|
319
|
+
}, {
|
|
320
|
+
value: 'hunan',
|
|
321
|
+
label: '湖南',
|
|
322
|
+
children: [{
|
|
323
|
+
value: 'haidian',
|
|
324
|
+
label: '海淀区'
|
|
325
|
+
}]
|
|
326
|
+
}]
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
return Demo;
|
|
331
|
+
}(Component);
|
|
332
|
+
|
|
333
|
+
Demo.template = "const {Cascader} = this; <Cascader data={this.get('data')} v-model=\"value\" />";
|
|
334
|
+
_mount7 = mount(Demo), instance = _mount7[0], element = _mount7[1];
|
|
335
|
+
dispatchEvent(element, 'click');
|
|
336
|
+
_context9.next = 6;
|
|
337
|
+
return wait();
|
|
338
|
+
|
|
339
|
+
case 6:
|
|
340
|
+
_getElements2 = getElements('.k-cascader-menu'), dropdown1 = _getElements2[0], dropdown2 = _getElements2[1];
|
|
341
|
+
_dropdown1$querySelec4 = dropdown1.querySelectorAll(':scope > .k-dropdown-item'), item1 = _dropdown1$querySelec4[0], item2 = _dropdown1$querySelec4[1];
|
|
342
|
+
expect(item1.classList.contains('k-selected')).to.be.true;
|
|
343
|
+
expect(item2.classList.contains('k-selected')).to.be.false;
|
|
344
|
+
_dropdown2$querySelec3 = dropdown2.querySelectorAll(':scope > .k-dropdown-item'), item21 = _dropdown2$querySelec3[0];
|
|
345
|
+
expect(item21.classList.contains('k-selected')).to.be.true;
|
|
346
|
+
dispatchEvent(item2, 'click');
|
|
347
|
+
_context9.next = 15;
|
|
348
|
+
return wait();
|
|
349
|
+
|
|
350
|
+
case 15:
|
|
351
|
+
dropdown3 = getElement('.k-cascader-menu');
|
|
352
|
+
_dropdown3$querySelec2 = dropdown3.querySelectorAll(':scope > .k-dropdown-item'), item31 = _dropdown3$querySelec2[0];
|
|
353
|
+
expect(item31.classList.contains('k-selected')).to.be.false;
|
|
354
|
+
dispatchEvent(item31, 'click');
|
|
355
|
+
_context9.next = 21;
|
|
356
|
+
return wait();
|
|
357
|
+
|
|
358
|
+
case 21:
|
|
359
|
+
expect(instance.get('value')).to.eql(['hunan', 'haidian']);
|
|
360
|
+
expect(element.textContent).to.eql('湖南 / 海淀区');
|
|
361
|
+
|
|
362
|
+
case 23:
|
|
363
|
+
case "end":
|
|
364
|
+
return _context9.stop();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}, _callee8);
|
|
368
|
+
})));
|
|
281
369
|
});
|
|
@@ -41,7 +41,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
41
41
|
onSelect = _this$value.onSelect,
|
|
42
42
|
toggleShowedValue = _this$value.toggleShowedValue;
|
|
43
43
|
|
|
44
|
-
var Options = function Options(data, level, loaded) {
|
|
44
|
+
var Options = function Options(data, level, loaded, parentSelected) {
|
|
45
45
|
if (!data.length) {
|
|
46
46
|
if (!loaded) {
|
|
47
47
|
return _$cc(Icon, _$tmp0);
|
|
@@ -53,7 +53,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
53
53
|
return _mapInstanceProperty(data).call(data, function (item, index) {
|
|
54
54
|
var value = item.value;
|
|
55
55
|
var showed = isShowed(value, level);
|
|
56
|
-
var selected = isSelected(value, level);
|
|
56
|
+
var selected = parentSelected && isSelected(value, level);
|
|
57
57
|
var children = item.children;
|
|
58
58
|
|
|
59
59
|
var Item = function Item() {
|
|
@@ -79,7 +79,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
79
79
|
'ev-show': _this.load.bind(null, item),
|
|
80
80
|
'children': [Item(), _$cc(DropdownMenu, {
|
|
81
81
|
'className': _$cn(classNameObj),
|
|
82
|
-
'children': showed ? Options(children, level + 1, item.loaded) : null
|
|
82
|
+
'children': showed ? Options(children, level + 1, item.loaded, selected) : null
|
|
83
83
|
})]
|
|
84
84
|
}) : Item();
|
|
85
85
|
});
|
|
@@ -100,7 +100,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
100
100
|
return !filterable || !keywords ? _$cc(DropdownMenu, {
|
|
101
101
|
'className': _$cn(classNameObj),
|
|
102
102
|
'key': 'common',
|
|
103
|
-
'children': Options(data, 0, true)
|
|
103
|
+
'children': Options(data, 0, true, true)
|
|
104
104
|
}, 'common') : _$cc(DropdownMenu, {
|
|
105
105
|
'key': 'filter',
|
|
106
106
|
'className': _$cn((_$cn2 = {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
|
|
2
1
|
import { useInstance } from 'intact';
|
|
3
2
|
import { useBaseLabel } from '../select/useBaseLabel';
|
|
4
3
|
export function useLabel() {
|
|
@@ -11,27 +10,24 @@ export function useLabel() {
|
|
|
11
10
|
var labels = [];
|
|
12
11
|
var length = value.length;
|
|
13
12
|
|
|
14
|
-
var loop = function loop(data) {
|
|
13
|
+
var loop = function loop(data, level) {
|
|
14
|
+
if (level === length) return;
|
|
15
|
+
|
|
15
16
|
for (var i = 0; i < data.length; i++) {
|
|
16
17
|
var item = data[i];
|
|
17
18
|
|
|
18
|
-
if (
|
|
19
|
+
if (item.value === value[level]) {
|
|
19
20
|
labels.push(item.label);
|
|
21
|
+
var children = item.children;
|
|
20
22
|
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
+
if (children) {
|
|
24
|
+
loop(children, level + 1);
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
var children = item.children;
|
|
27
|
-
|
|
28
|
-
if (children) {
|
|
29
|
-
loop(children);
|
|
30
|
-
}
|
|
31
27
|
}
|
|
32
28
|
};
|
|
33
29
|
|
|
34
|
-
loop(data);
|
|
30
|
+
loop(data, 0);
|
|
35
31
|
return labels.length ? format(labels) : null;
|
|
36
32
|
}
|
|
37
33
|
|
|
@@ -163,9 +163,11 @@ export var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
163
163
|
|
|
164
164
|
_proto.normalizeTriggerProps = function normalizeTriggerProps(props) {
|
|
165
165
|
// if use kpc in react or vue, normalize props by Wrapper.props.vnode;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
var vnode = props.vnode;
|
|
167
|
+
if (!vnode) return props; // maybe we render the intact component in react slot property, in this case
|
|
168
|
+
// the $isReact is false. so use the vnode $$typeof field as gauge
|
|
169
|
+
|
|
170
|
+
if (vnode.$$typeof || this.$isVueNext) {
|
|
169
171
|
var _props = vnode.props;
|
|
170
172
|
if (!_props) return props;
|
|
171
173
|
return {
|
|
@@ -179,12 +181,10 @@ export var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
179
181
|
|
|
180
182
|
};
|
|
181
183
|
} else if (this.$isVue) {
|
|
182
|
-
var
|
|
183
|
-
if (!_vnode) return props;
|
|
184
|
-
var data = _vnode.data;
|
|
184
|
+
var data = vnode.data;
|
|
185
185
|
var on = data && data.on || EMPTY_OBJ;
|
|
186
186
|
var ret = {
|
|
187
|
-
vnode:
|
|
187
|
+
vnode: vnode
|
|
188
188
|
};
|
|
189
189
|
['click', 'mouseenter', 'mouseleave', 'contextmenu'].forEach(function (event) {
|
|
190
190
|
var method = on[event];
|
|
@@ -8,7 +8,7 @@ import BasicDemo, { data as basicDemoData } from '~/components/form/demos/basic'
|
|
|
8
8
|
import CustomDemo from '~/components/form/demos/custom';
|
|
9
9
|
import VariableDemo from '~/components/form/demos/variable';
|
|
10
10
|
import RemoteDemo from '~/components/form/demos/remote';
|
|
11
|
-
import { mount,
|
|
11
|
+
import { mount, dispatchEvent, wait } from '../../test/utils';
|
|
12
12
|
import { Component } from 'intact';
|
|
13
13
|
import { Form, FormItem } from './';
|
|
14
14
|
import { Input } from '../input';
|
|
@@ -29,9 +29,7 @@ RemoteDemo.prototype.validateUserName = function (value) {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
describe('Form', function () {
|
|
32
|
-
afterEach(
|
|
33
|
-
return unmount();
|
|
34
|
-
});
|
|
32
|
+
// afterEach(() => unmount());
|
|
35
33
|
it('validate', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
36
34
|
var _mount, instance, element, form, item, input;
|
|
37
35
|
|
|
@@ -39,14 +39,14 @@ describe('Menu', function () {
|
|
|
39
39
|
}, _callee);
|
|
40
40
|
})));
|
|
41
41
|
it('select', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
42
|
-
var _mount2, instance, element,
|
|
42
|
+
var _mount2, instance, element, _element$querySelecto, title, disabledTitle, subTitle;
|
|
43
43
|
|
|
44
44
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
45
45
|
while (1) {
|
|
46
46
|
switch (_context2.prev = _context2.next) {
|
|
47
47
|
case 0:
|
|
48
48
|
_mount2 = mount(CollapseDemo), instance = _mount2[0], element = _mount2[1];
|
|
49
|
-
|
|
49
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
50
50
|
_element$querySelecto = element.querySelectorAll('.k-menu-title'), title = _element$querySelecto[0], disabledTitle = _element$querySelecto[1];
|
|
51
51
|
title.click();
|
|
52
52
|
_context2.next = 6;
|
|
@@ -54,14 +54,14 @@ describe('Menu', function () {
|
|
|
54
54
|
|
|
55
55
|
case 6:
|
|
56
56
|
expect(element.outerHTML).to.matchSnapshot();
|
|
57
|
-
expect(
|
|
57
|
+
expect(instance.get('selectedKey')).to.eql('1');
|
|
58
58
|
disabledTitle.click();
|
|
59
59
|
_context2.next = 11;
|
|
60
60
|
return wait();
|
|
61
61
|
|
|
62
62
|
case 11:
|
|
63
63
|
expect(element.outerHTML).to.matchSnapshot();
|
|
64
|
-
expect(
|
|
64
|
+
expect(instance.get('selectedKey')).to.eql('1');
|
|
65
65
|
subTitle = element.querySelector('.k-expanded .k-menu .k-menu-title');
|
|
66
66
|
subTitle.click();
|
|
67
67
|
_context2.next = 17;
|
|
@@ -69,9 +69,16 @@ describe('Menu', function () {
|
|
|
69
69
|
|
|
70
70
|
case 17:
|
|
71
71
|
expect(element.outerHTML).to.matchSnapshot();
|
|
72
|
-
expect(
|
|
72
|
+
expect(instance.get('selectedKey')).to.eql('3-1'); // clear
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
instance.set('selectedKey', '');
|
|
75
|
+
_context2.next = 22;
|
|
76
|
+
return wait();
|
|
77
|
+
|
|
78
|
+
case 22:
|
|
79
|
+
expect(element.querySelector('.k-highlighted')).to.be.null;
|
|
80
|
+
|
|
81
|
+
case 23:
|
|
75
82
|
case "end":
|
|
76
83
|
return _context2.stop();
|
|
77
84
|
}
|
|
@@ -5,10 +5,11 @@ import { Component, inject, provide } from 'intact';
|
|
|
5
5
|
import { ROOT_MENU, MENU } from './menu';
|
|
6
6
|
import template from './item.vdt';
|
|
7
7
|
import { bind } from '../utils';
|
|
8
|
-
import { useHighlight } from './useHighlight';
|
|
9
8
|
import { useExpanded } from './useExpanded';
|
|
10
9
|
import { useDropdown } from './useDropdown';
|
|
11
10
|
import { useRouter, navigate } from '../../hooks/useRouter';
|
|
11
|
+
import { useRecordItem } from '../../hooks/useRecordComponent';
|
|
12
|
+
import { MENU_RECORD_KEY } from './useHighlight';
|
|
12
13
|
var typeDefs = {
|
|
13
14
|
key: {
|
|
14
15
|
type: [String, Number],
|
|
@@ -36,7 +37,6 @@ export var MenuItem = /*#__PURE__*/function (_Component) {
|
|
|
36
37
|
_this.parentMenu = inject(MENU);
|
|
37
38
|
_this.parentMenuItem = inject(MENU_ITEM, null);
|
|
38
39
|
_this.expanded = useExpanded(_this.rootMenu, _this.parentMenu);
|
|
39
|
-
_this.highlight = useHighlight(_this.rootMenu, _this.parentMenuItem);
|
|
40
40
|
_this.dropdown = useDropdown(_this.rootMenu, _this.parentMenu);
|
|
41
41
|
_this.router = useRouter();
|
|
42
42
|
return _this;
|
|
@@ -46,19 +46,21 @@ export var MenuItem = /*#__PURE__*/function (_Component) {
|
|
|
46
46
|
|
|
47
47
|
_proto.init = function init() {
|
|
48
48
|
provide(MENU_ITEM, this);
|
|
49
|
+
useRecordItem(MENU_RECORD_KEY);
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
_proto.onClick = function onClick(hasSubMenu, e) {
|
|
52
53
|
var _this$get = this.get(),
|
|
53
54
|
disabled = _this$get.disabled,
|
|
54
|
-
to = _this$get.to
|
|
55
|
+
to = _this$get.to,
|
|
56
|
+
key = _this$get.key;
|
|
55
57
|
|
|
56
58
|
if (disabled) return;
|
|
57
59
|
|
|
58
60
|
if (hasSubMenu) {
|
|
59
61
|
this.expanded.toggle();
|
|
60
62
|
} else {
|
|
61
|
-
this.highlight.select();
|
|
63
|
+
this.rootMenu.highlight.select(key);
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
this.trigger('click', e);
|
|
@@ -32,9 +32,9 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
32
32
|
disabled = _this$get.disabled,
|
|
33
33
|
dot = _this$get.dot;
|
|
34
34
|
|
|
35
|
-
var
|
|
36
|
-
isHighlighted =
|
|
37
|
-
isSelected =
|
|
35
|
+
var _rootMenu$highlight = rootMenu.highlight,
|
|
36
|
+
isHighlighted = _rootMenu$highlight.isHighlighted,
|
|
37
|
+
isSelected = _rootMenu$highlight.isSelected;
|
|
38
38
|
var isExpandedKey = this.expanded.isExpanded;
|
|
39
39
|
var isExpanded = isExpandedKey(key);
|
|
40
40
|
|
|
@@ -50,7 +50,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
50
50
|
|
|
51
51
|
var classNameObj = (_classNameObj = {
|
|
52
52
|
'k-menu-item': true
|
|
53
|
-
}, _classNameObj[className] = className, _classNameObj['k-expanded'] = isExpanded, _classNameObj['k-disabled'] = disabled, _classNameObj['k-active'] = isSelected(), _classNameObj['k-highlighted'] = isHighlighted(), _classNameObj[makeItemStyles()] = true, _classNameObj);
|
|
53
|
+
}, _classNameObj[className] = className, _classNameObj['k-expanded'] = isExpanded, _classNameObj['k-disabled'] = disabled, _classNameObj['k-active'] = isSelected(key), _classNameObj['k-highlighted'] = isHighlighted(key), _classNameObj[makeItemStyles()] = true, _classNameObj);
|
|
54
54
|
var showDot = isTopItem && !iconVNode && isNullOrUndefined(dot) ? rootDot : dot;
|
|
55
55
|
|
|
56
56
|
var title = function title(children) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Component, TypeDefs, Key } from 'intact';
|
|
2
|
+
import { useHighlight } from './useHighlight';
|
|
2
3
|
export interface MenuProps<K extends Key = Key> {
|
|
3
4
|
expandedKeys?: K[];
|
|
4
5
|
selectedKey?: K;
|
|
@@ -22,5 +23,7 @@ export declare class Menu<K extends Key = Key> extends Component<MenuProps<K>, M
|
|
|
22
23
|
static defaults: () => Partial<MenuProps<Key>>;
|
|
23
24
|
rootMenu: Menu<Key> | null;
|
|
24
25
|
parentMenu: Menu<Key> | null;
|
|
26
|
+
subExpandedKeys?: Set<K>;
|
|
27
|
+
highlight?: ReturnType<typeof useHighlight>;
|
|
25
28
|
init(): void;
|
|
26
29
|
}
|
|
@@ -2,6 +2,7 @@ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
3
|
import { Component, provide, inject } from 'intact';
|
|
4
4
|
import template from './menu.vdt';
|
|
5
|
+
import { useHighlight } from './useHighlight';
|
|
5
6
|
var typeDefs = {
|
|
6
7
|
expandedKeys: Array,
|
|
7
8
|
selectedKey: [String, Number],
|
|
@@ -39,6 +40,8 @@ export var Menu = /*#__PURE__*/function (_Component) {
|
|
|
39
40
|
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
40
41
|
_this.rootMenu = inject(ROOT_MENU, null);
|
|
41
42
|
_this.parentMenu = inject(MENU, null);
|
|
43
|
+
_this.subExpandedKeys = void 0;
|
|
44
|
+
_this.highlight = void 0;
|
|
42
45
|
return _this;
|
|
43
46
|
}
|
|
44
47
|
|
|
@@ -49,6 +52,7 @@ export var Menu = /*#__PURE__*/function (_Component) {
|
|
|
49
52
|
|
|
50
53
|
if (!this.rootMenu) {
|
|
51
54
|
provide(ROOT_MENU, this);
|
|
55
|
+
this.highlight = useHighlight();
|
|
52
56
|
}
|
|
53
57
|
};
|
|
54
58
|
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { Key } from 'intact';
|
|
2
1
|
import type { Menu } from './';
|
|
3
|
-
export declare function useExpanded(rootMenu: Menu, parentMenu: Menu
|
|
4
|
-
subExpandedKeys?: Set<Key>;
|
|
5
|
-
}): {
|
|
2
|
+
export declare function useExpanded(rootMenu: Menu, parentMenu: Menu): {
|
|
6
3
|
isExpanded: () => boolean;
|
|
7
4
|
expand: () => void;
|
|
8
5
|
shrink: () => void;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { Key } from 'intact';
|
|
2
|
-
|
|
3
|
-
export declare function useHighlight(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
updateStatus: (v: Key | undefined) => void;
|
|
8
|
-
select: () => void;
|
|
9
|
-
isSelected: () => boolean;
|
|
2
|
+
export declare const MENU_RECORD_KEY = "MenuKeys";
|
|
3
|
+
export declare function useHighlight(): {
|
|
4
|
+
isHighlighted: (key: Key) => boolean;
|
|
5
|
+
select: (key: Key) => void;
|
|
6
|
+
isSelected: (key: Key) => boolean;
|
|
10
7
|
};
|