@king-design/intact 3.2.1 → 3.3.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/divider/demos/basic.md +35 -0
- package/components/divider/demos/horizontal.md +31 -0
- package/components/divider/demos/margin.md +32 -0
- package/components/divider/demos/text.md +27 -0
- package/components/divider/index.md +16 -0
- package/components/divider/index.spec.ts +0 -0
- package/components/divider/index.ts +36 -0
- package/components/divider/index.vdt +35 -0
- package/components/divider/styles.ts +109 -0
- package/components/dropdown/dropdown.ts +1 -1
- package/components/ellipsis/demos/basic.md +44 -0
- package/components/ellipsis/demos/custom.md +36 -0
- package/components/ellipsis/demos/position.md +24 -0
- package/components/ellipsis/index.md +14 -0
- package/components/ellipsis/index.spec.ts +58 -0
- package/components/ellipsis/index.ts +36 -0
- package/components/ellipsis/index.vdt +39 -0
- package/components/ellipsis/styles.ts +22 -0
- package/components/ellipsis/useEllipsis.ts +31 -0
- package/components/menu/demos/showCollapseArrow.md +11 -6
- package/components/menu/item.vdt +6 -3
- package/components/menu/styles.ts +9 -8
- package/components/menu/title.vdt +2 -1
- package/components/table/table.vdt +1 -1
- package/components/tag/index.spec.ts +1 -1
- package/components/tag/tags.vdt +1 -1
- package/components/view/index.ts +24 -0
- package/es/components/divider/index.d.ts +14 -0
- package/es/components/divider/index.js +38 -0
- package/es/components/divider/index.spec.d.ts +1 -0
- package/es/components/divider/index.spec.js +1 -0
- package/es/components/divider/index.vdt.js +31 -0
- package/es/components/divider/styles.d.ts +5 -0
- package/es/components/divider/styles.js +35 -0
- package/es/components/dropdown/dropdown.js +2 -2
- package/es/components/ellipsis/index.d.ts +16 -0
- package/es/components/ellipsis/index.js +36 -0
- package/es/components/ellipsis/index.spec.d.ts +1 -0
- package/es/components/ellipsis/index.spec.js +94 -0
- package/es/components/ellipsis/index.vdt.js +50 -0
- package/es/components/ellipsis/styles.d.ts +5 -0
- package/es/components/ellipsis/styles.js +10 -0
- package/es/components/ellipsis/useEllipsis.d.ts +4 -0
- package/es/components/ellipsis/useEllipsis.js +21 -0
- package/es/components/menu/item.vdt.js +8 -3
- package/es/components/menu/styles.d.ts +1 -1
- package/es/components/menu/styles.js +6 -5
- package/es/components/menu/title.vdt.js +6 -2
- package/es/components/table/table.vdt.js +1 -1
- package/es/components/tag/index.spec.js +4 -2
- package/es/components/tag/tags.vdt.js +2 -1
- package/es/components/view/index.d.ts +15 -0
- package/es/components/view/index.js +30 -0
- package/es/i18n/en-US.d.ts +1 -1
- package/es/i18n/en-US.js +1 -1
- package/es/index.d.ts +5 -2
- package/es/index.js +5 -2
- package/es/site/data/components/divider/demos/basic/index.d.ts +9 -0
- package/es/site/data/components/divider/demos/basic/index.js +18 -0
- package/es/site/data/components/divider/demos/basic/react.d.ts +9 -0
- package/es/site/data/components/divider/demos/basic/react.js +27 -0
- package/es/site/data/components/divider/demos/horizontal/index.d.ts +6 -0
- package/es/site/data/components/divider/demos/horizontal/index.js +14 -0
- package/es/site/data/components/divider/demos/horizontal/react.d.ts +5 -0
- package/es/site/data/components/divider/demos/horizontal/react.js +26 -0
- package/es/site/data/components/divider/demos/margin/index.d.ts +8 -0
- package/es/site/data/components/divider/demos/margin/index.js +18 -0
- package/es/site/data/components/divider/demos/margin/react.d.ts +7 -0
- package/es/site/data/components/divider/demos/margin/react.js +37 -0
- package/es/site/data/components/divider/demos/text/index.d.ts +5 -0
- package/es/site/data/components/divider/demos/text/index.js +13 -0
- package/es/site/data/components/divider/demos/text/react.d.ts +4 -0
- package/es/site/data/components/divider/demos/text/react.js +19 -0
- package/es/site/data/components/divider/index.d.ts +57 -0
- package/es/site/data/components/divider/index.js +32 -0
- package/es/site/data/components/ellipsis/demos/basic/index.d.ts +12 -0
- package/es/site/data/components/ellipsis/demos/basic/index.js +19 -0
- package/es/site/data/components/ellipsis/demos/basic/react.d.ts +12 -0
- package/es/site/data/components/ellipsis/demos/basic/react.js +40 -0
- package/es/site/data/components/ellipsis/demos/custom/index.d.ts +6 -0
- package/es/site/data/components/ellipsis/demos/custom/index.js +14 -0
- package/es/site/data/components/ellipsis/demos/custom/react.d.ts +5 -0
- package/es/site/data/components/ellipsis/demos/custom/react.js +42 -0
- package/es/site/data/components/ellipsis/demos/position/index.d.ts +6 -0
- package/es/site/data/components/ellipsis/demos/position/index.js +14 -0
- package/es/site/data/components/ellipsis/demos/position/react.d.ts +5 -0
- package/es/site/data/components/ellipsis/demos/position/react.js +26 -0
- package/es/site/data/components/ellipsis/index.d.ts +57 -0
- package/es/site/data/components/ellipsis/index.js +32 -0
- package/es/site/data/components/menu/demos/showCollapseArrow/index.js +3 -2
- package/es/site/data/components/menu/demos/showCollapseArrow/react.js +16 -6
- package/es/styles/theme.d.ts +8 -0
- package/es/styles/theme.js +8 -4
- package/i18n/en-US.ts +1 -1
- package/index.ts +5 -2
- package/package.json +3 -4
- package/styles/theme.ts +4 -0
|
@@ -6,7 +6,7 @@ order: 6
|
|
|
6
6
|
`showCollapseArrow`定义是否展示折叠按钮,`MenuTitle`定义菜单标题项。
|
|
7
7
|
|
|
8
8
|
```vdt
|
|
9
|
-
import {Menu, MenuItem, Icon, MenuTitle, Switch, ButtonGroup, Button} from 'kpc';
|
|
9
|
+
import {Menu, MenuItem, Icon, MenuTitle, Switch, ButtonGroup, Button, Divider} from 'kpc';
|
|
10
10
|
<div>
|
|
11
11
|
<ButtonGroup checkType="radio"
|
|
12
12
|
v-model="theme"
|
|
@@ -32,6 +32,7 @@ import {Menu, MenuItem, Icon, MenuTitle, Switch, ButtonGroup, Button} from 'kpc'
|
|
|
32
32
|
<Menu
|
|
33
33
|
v-model:expandedKeys="expandedKeys"
|
|
34
34
|
v-model:selectedKey="selectedKey"
|
|
35
|
+
v-model:collapse="collapse"
|
|
35
36
|
theme={this.get('theme')}
|
|
36
37
|
size={this.get('size')}
|
|
37
38
|
showCollapseArrow={this.get('showCollapseArrow')}
|
|
@@ -43,7 +44,7 @@ import {Menu, MenuItem, Icon, MenuTitle, Switch, ButtonGroup, Button} from 'kpc'
|
|
|
43
44
|
<MenuTitle>title 1</MenuTitle>
|
|
44
45
|
<MenuItem key="1">menu 1</MenuItem>
|
|
45
46
|
<MenuItem key="2">menu 2</MenuItem>
|
|
46
|
-
<MenuItem key="3">menu 3</MenuItem>
|
|
47
|
+
<MenuItem key="3">menu 3menu 3menu 3menu 3menu 3menu 3</MenuItem>
|
|
47
48
|
<MenuTitle>title 2</MenuTitle>
|
|
48
49
|
<MenuItem key="4">menu 1</MenuItem>
|
|
49
50
|
<MenuItem key="5" disabled>menu 2</MenuItem>
|
|
@@ -56,12 +57,13 @@ import {Menu, MenuItem, Icon, MenuTitle, Switch, ButtonGroup, Button} from 'kpc'
|
|
|
56
57
|
<MenuItem key="6-4">
|
|
57
58
|
sub menu 7
|
|
58
59
|
<Menu>
|
|
59
|
-
<MenuItem key="6-7-1">
|
|
60
|
-
<MenuItem key="6-7-2">
|
|
60
|
+
<MenuItem key="6-7-1">option 1</MenuItem>
|
|
61
|
+
<MenuItem key="6-7-2">option 2</MenuItem>
|
|
61
62
|
</Menu>
|
|
62
63
|
</MenuItem>
|
|
63
64
|
</Menu>
|
|
64
65
|
</MenuItem>
|
|
66
|
+
<Divider theme={ this.get('theme') === 'white' ? 'light' : this.get('theme')} class="divider-style"/>
|
|
65
67
|
<MenuItem key="8" to="/">menu 8</MenuItem>
|
|
66
68
|
</Menu>
|
|
67
69
|
</div>
|
|
@@ -70,6 +72,8 @@ import {Menu, MenuItem, Icon, MenuTitle, Switch, ButtonGroup, Button} from 'kpc'
|
|
|
70
72
|
```styl
|
|
71
73
|
.k-switch
|
|
72
74
|
margin 0 16px
|
|
75
|
+
.divider-style
|
|
76
|
+
margin 4px 0 0 0
|
|
73
77
|
```
|
|
74
78
|
|
|
75
79
|
```ts
|
|
@@ -84,9 +88,10 @@ export default class extends Component<Props> {
|
|
|
84
88
|
return {
|
|
85
89
|
expandedKeys: [],
|
|
86
90
|
selectedKey: '2',
|
|
87
|
-
size: '
|
|
91
|
+
size: 'small',
|
|
88
92
|
theme: 'light',
|
|
89
|
-
showCollapseArrow:
|
|
93
|
+
showCollapseArrow: true,
|
|
94
|
+
collapse: false,
|
|
90
95
|
} as MenuProps;
|
|
91
96
|
}
|
|
92
97
|
}
|
package/components/menu/item.vdt
CHANGED
|
@@ -3,12 +3,13 @@ import {Dropdown, DropdownItem} from '../dropdown';
|
|
|
3
3
|
import {Tooltip} from '../tooltip';
|
|
4
4
|
import {Icon} from '../icon';
|
|
5
5
|
import {Menu} from './menu';
|
|
6
|
+
import {Ellipsis} from '../ellipsis';
|
|
6
7
|
import {getRestProps, expandAnimationCallbacks} from '../utils';
|
|
7
8
|
import {isNullOrUndefined} from 'intact-shared';
|
|
8
9
|
import {makeItemStyles, makeTitleStyles, makeNestedMenuStyles} from './styles';
|
|
9
10
|
|
|
10
11
|
const rootMenu = this.rootMenu;
|
|
11
|
-
const {theme, type, dot: rootDot} = rootMenu.get();
|
|
12
|
+
const {theme, type, dot: rootDot, size} = rootMenu.get();
|
|
12
13
|
const {children, key, className, disabled, dot} = this.get();
|
|
13
14
|
const {isHighlighted, isSelected} = rootMenu.highlight;
|
|
14
15
|
const {isExpanded: isExpandedKey} = this.expanded;
|
|
@@ -36,7 +37,9 @@ const title = (children) => (
|
|
|
36
37
|
ev-click={this.onClick.bind(this, subMenuVNode)}
|
|
37
38
|
>
|
|
38
39
|
<Icon class={`${k}-menu-dot ion-record`} v-if={showDot} />
|
|
39
|
-
<div class={`${k}-menu-name`}>
|
|
40
|
+
<div class={`${k}-menu-name`}>
|
|
41
|
+
<Ellipsis position="bottom">{children}</Ellipsis>
|
|
42
|
+
</div>
|
|
40
43
|
<Icon class={`${k}-menu-item-arrow ion-arrow-down-b`} v-if={subMenuVNode} />
|
|
41
44
|
</div>
|
|
42
45
|
);
|
|
@@ -52,7 +55,7 @@ const title = (children) => (
|
|
|
52
55
|
{(() => {
|
|
53
56
|
if (subMenuVNode) {
|
|
54
57
|
const paddingLeft = this.parentMenu.get('_paddingLeft');
|
|
55
|
-
const [_classname, _paddingLeft] = makeNestedMenuStyles(k, showDot || !!iconVNode, paddingLeft);
|
|
58
|
+
const [_classname, _paddingLeft] = makeNestedMenuStyles(k, showDot || !!iconVNode, paddingLeft, size);
|
|
56
59
|
const className = _$cn({
|
|
57
60
|
[_classname]: true,
|
|
58
61
|
[subMenuVNode.className]: subMenuVNode.className,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {css} from '@emotion/css';
|
|
2
2
|
import {theme, setDefault} from '../../styles/theme';
|
|
3
3
|
import {deepDefaults, getLeft, palette} from '../../styles/utils';
|
|
4
|
+
import type {MenuProps} from './menu';
|
|
4
5
|
import '../../styles/global';
|
|
5
6
|
import { cache } from '../utils';
|
|
6
7
|
|
|
@@ -121,8 +122,9 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
|
|
|
121
122
|
|
|
122
123
|
.${k}-menu-body {
|
|
123
124
|
padding: ${menu.item.bodyPadding};
|
|
124
|
-
max-height: calc(
|
|
125
|
+
max-height: calc(100% - ${menu.header.height});
|
|
125
126
|
overflow-y: auto;
|
|
127
|
+
overflow-x: hidden;
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
// menu title
|
|
@@ -168,6 +170,7 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
|
|
|
168
170
|
// theme light
|
|
169
171
|
&.${k}-light {
|
|
170
172
|
border: 1px solid ${theme.color.disabledBg};
|
|
173
|
+
border-top: 0;
|
|
171
174
|
background: ${menu.light.bgColor};
|
|
172
175
|
.${k}-menu-header {
|
|
173
176
|
color: ${menu.light.title.color};
|
|
@@ -341,13 +344,9 @@ export const makeItemStyles = cache(function makeItemStyles(k: string) {
|
|
|
341
344
|
display: flex;
|
|
342
345
|
align-items: center;
|
|
343
346
|
min-width: 0;
|
|
344
|
-
span {
|
|
345
|
-
overflow: hidden;
|
|
346
|
-
text-overflow: ellipsis;
|
|
347
|
-
min-width: 0;
|
|
348
|
-
}
|
|
349
347
|
.${k}-icon {
|
|
350
348
|
color: inherit;
|
|
349
|
+
display: inline-block;
|
|
351
350
|
}
|
|
352
351
|
}
|
|
353
352
|
.${k}-menu-item-arrow {
|
|
@@ -398,8 +397,9 @@ export const makeItemStyles = cache(function makeItemStyles(k: string) {
|
|
|
398
397
|
`
|
|
399
398
|
});
|
|
400
399
|
|
|
401
|
-
export const makeNestedMenuStyles = cache(function makeNestedMenuStyles(k: string, hasIcon: boolean, parentPaddingLeft: string = getLeft(menu.item.padding)) {
|
|
402
|
-
const
|
|
400
|
+
export const makeNestedMenuStyles = cache(function makeNestedMenuStyles(k: string, hasIcon: boolean, parentPaddingLeft: string = getLeft(menu.item.padding), size: MenuProps['size']) {
|
|
401
|
+
const fontSize = `${size === 'small' ? menu.small.fontSize : menu.fontSize}`;
|
|
402
|
+
const paddingLeft = `${parentPaddingLeft}${hasIcon ? ' + ' + menu.icon.width + ' + ' + menu.icon.gap : ' + ' + fontSize}`;
|
|
403
403
|
return [
|
|
404
404
|
css`
|
|
405
405
|
&.${k}-menu {
|
|
@@ -409,6 +409,7 @@ export const makeNestedMenuStyles = cache(function makeNestedMenuStyles(k: strin
|
|
|
409
409
|
border: none;
|
|
410
410
|
.${k}-menu-body {
|
|
411
411
|
padding: 0;
|
|
412
|
+
max-height: 100%;
|
|
412
413
|
.${k}-menu-item-title {
|
|
413
414
|
padding-left: calc(${paddingLeft});
|
|
414
415
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {Icon} from '../icon';
|
|
2
|
+
import {Ellipsis} from '../ellipsis';
|
|
2
3
|
import {getRestProps, findChildren, isComponentVNode} from '../utils';
|
|
3
4
|
import {makeTitleStyles} from './styles';
|
|
4
5
|
|
|
@@ -17,7 +18,7 @@ const classNameObj = {
|
|
|
17
18
|
[`${k}-menu-name`]: true,
|
|
18
19
|
[makeTitleStyles(k)]: true
|
|
19
20
|
}}>
|
|
20
|
-
<
|
|
21
|
+
<Ellipsis position="bottom" v-if={!collapse}>{children}</Ellipsis>
|
|
21
22
|
<template v-else>
|
|
22
23
|
{findChildren(children, vNode => isComponentVNode(vNode, Icon))}
|
|
23
24
|
</template>
|
|
@@ -4,7 +4,7 @@ import TagsDemo from '~/components/tag/demos/tags';
|
|
|
4
4
|
import DraggableDemo from '~/components/tag/demos/draggable';
|
|
5
5
|
|
|
6
6
|
describe('Tag', () => {
|
|
7
|
-
|
|
7
|
+
afterEach(() => unmount());
|
|
8
8
|
|
|
9
9
|
it('should not close tag if we has prevented default', async () => {
|
|
10
10
|
const [instance, element] = mount(ClosableDemo);
|
package/components/tag/tags.vdt
CHANGED
|
@@ -44,7 +44,7 @@ const vNodes = children.value;
|
|
|
44
44
|
+{hiddenChildren.value.length}
|
|
45
45
|
</Tag>
|
|
46
46
|
<b:content>
|
|
47
|
-
<div class={classNameObj}>{hiddenChildren.value}</div>
|
|
47
|
+
<div class={{ ...classNameObj, [`${k}-nowrap`]: false /* should not nowrap */ }}>{hiddenChildren.value}</div>
|
|
48
48
|
</b:content>
|
|
49
49
|
</Tooltip>
|
|
50
50
|
<b:append />
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Component, createVNode as h, TypeDefs } from 'intact';
|
|
2
|
+
|
|
3
|
+
export interface ViewProps {
|
|
4
|
+
tag?: string,
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const typeDefs: Required<TypeDefs<ViewProps>> = {
|
|
8
|
+
tag: String,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A component only used in React or Vue to bind event, so that
|
|
13
|
+
* it can use Intact Event system to stop propagation (stopPropagation).
|
|
14
|
+
*/
|
|
15
|
+
export class View extends Component<ViewProps> {
|
|
16
|
+
static template(this: View) {
|
|
17
|
+
const { tag, ...rest } = this.get();
|
|
18
|
+
return h(tag!, rest as any);
|
|
19
|
+
}
|
|
20
|
+
static typeDefs = typeDefs;
|
|
21
|
+
static defaults() {
|
|
22
|
+
return { tag: 'div' };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Component, TypeDefs } from 'intact';
|
|
2
|
+
export interface DividerProps {
|
|
3
|
+
borderType?: 'solid' | 'dashed' | 'dotted' | 'double';
|
|
4
|
+
position?: 'left' | 'right' | 'center';
|
|
5
|
+
type?: 'vertical' | 'horizontal';
|
|
6
|
+
theme?: 'light' | 'dark';
|
|
7
|
+
margin?: 'large' | 'default' | 'small' | 'none' | number;
|
|
8
|
+
}
|
|
9
|
+
export declare class Divider extends Component<DividerProps> {
|
|
10
|
+
static template: string | import("intact").Template<any>;
|
|
11
|
+
static typeDefs: Required<TypeDefs<DividerProps>>;
|
|
12
|
+
static defaults: () => Partial<DividerProps>;
|
|
13
|
+
private config;
|
|
14
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
|
+
import { Component } from 'intact';
|
|
4
|
+
import template from './index.vdt';
|
|
5
|
+
import { useConfigContext } from '../config';
|
|
6
|
+
var typeDefs = {
|
|
7
|
+
borderType: ['solid', 'dashed', 'dotted', 'double'],
|
|
8
|
+
position: ['left', 'right', 'center'],
|
|
9
|
+
type: ['vertical', 'horizontal'],
|
|
10
|
+
theme: ['light', 'dark'],
|
|
11
|
+
margin: ['large', 'default', 'small', 'none', Number]
|
|
12
|
+
};
|
|
13
|
+
var defaults = function defaults() {
|
|
14
|
+
return {
|
|
15
|
+
borderType: 'solid',
|
|
16
|
+
position: 'center',
|
|
17
|
+
type: 'horizontal',
|
|
18
|
+
theme: 'light',
|
|
19
|
+
margin: 'default'
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export var Divider = /*#__PURE__*/function (_Component) {
|
|
23
|
+
_inheritsLoose(Divider, _Component);
|
|
24
|
+
function Divider() {
|
|
25
|
+
var _context;
|
|
26
|
+
var _this;
|
|
27
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
28
|
+
args[_key] = arguments[_key];
|
|
29
|
+
}
|
|
30
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
31
|
+
_this.config = useConfigContext();
|
|
32
|
+
return _this;
|
|
33
|
+
}
|
|
34
|
+
return Divider;
|
|
35
|
+
}(Component);
|
|
36
|
+
Divider.template = template;
|
|
37
|
+
Divider.typeDefs = typeDefs;
|
|
38
|
+
Divider.defaults = defaults;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import { createVNode as _$cv, className as _$cn, createElementVNode as _$ce } from 'intact';
|
|
3
|
+
import { makeStyles } from './styles';
|
|
4
|
+
import { getRestProps, addStyle } from '../utils';
|
|
5
|
+
export default function ($props, $blocks, $__proto__) {
|
|
6
|
+
var _classNameObj;
|
|
7
|
+
$blocks || ($blocks = {});
|
|
8
|
+
$props || ($props = {});
|
|
9
|
+
var $this = this;
|
|
10
|
+
var _this$get = this.get(),
|
|
11
|
+
children = _this$get.children,
|
|
12
|
+
className = _this$get.className,
|
|
13
|
+
borderType = _this$get.borderType,
|
|
14
|
+
position = _this$get.position,
|
|
15
|
+
type = _this$get.type,
|
|
16
|
+
theme = _this$get.theme,
|
|
17
|
+
margin = _this$get.margin,
|
|
18
|
+
style = _this$get.style;
|
|
19
|
+
var k = this.config.k;
|
|
20
|
+
var _style = {};
|
|
21
|
+
if (typeof margin === 'number') {
|
|
22
|
+
var _margin = type === 'vertical' ? "0 " + margin + "px" : margin + "px 0";
|
|
23
|
+
_style.margin = _margin;
|
|
24
|
+
}
|
|
25
|
+
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-divider"] = true, _classNameObj[k + "-" + (theme === 'dark' ? 'dark' : 'light')] = theme, _classNameObj[k + "-" + type] = type, _classNameObj[k + "-" + margin] = margin && typeof margin !== 'number', _classNameObj[k + "-with-text"] = children && type === 'horizontal', _classNameObj[k + "-" + position] = position !== 'center', _classNameObj[makeStyles(k, borderType)] = true, _classNameObj[className] = className, _classNameObj);
|
|
26
|
+
return _$cv('div', _extends({}, getRestProps(this), {
|
|
27
|
+
'className': _$cn(classNameObj),
|
|
28
|
+
'style': addStyle(style, _style)
|
|
29
|
+
}), children && type === 'horizontal' ? _$ce(2, 'div', children, 0, _$cn(k + "-divider-text")) : undefined);
|
|
30
|
+
}
|
|
31
|
+
;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
2
|
+
import { css } from '@emotion/css';
|
|
3
|
+
import { theme, setDefault } from '../../styles/theme';
|
|
4
|
+
import { deepDefaults } from '../../styles/utils';
|
|
5
|
+
import '../../styles/global';
|
|
6
|
+
import { cache } from '../utils';
|
|
7
|
+
var sizes = ['large', 'default', 'small'];
|
|
8
|
+
var defaults = {
|
|
9
|
+
positionOffset: '5%',
|
|
10
|
+
get borderColor() {
|
|
11
|
+
return theme.color.darkBorder;
|
|
12
|
+
},
|
|
13
|
+
light: {
|
|
14
|
+
get borderColor() {
|
|
15
|
+
return theme.color.disabledBg;
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
large: {
|
|
19
|
+
get margin() {
|
|
20
|
+
return theme.large.padding;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var divider;
|
|
25
|
+
setDefault(function () {
|
|
26
|
+
divider = deepDefaults(theme, {
|
|
27
|
+
divider: defaults
|
|
28
|
+
}).divider;
|
|
29
|
+
makeStyles == null || makeStyles.clearCache();
|
|
30
|
+
});
|
|
31
|
+
export var makeStyles = cache(function makeStyles(k, borderType) {
|
|
32
|
+
return /*#__PURE__*/css("&.", k, "-divider{padding:0;border-top:1px ", borderType, " ", divider.borderColor, ";}&.", k, "-light{border-top-color:", divider.light.borderColor, ";&.", k, "-with-text{&::before,&::after{border-top-color:", divider.light.borderColor, ";}}&.", k, "-vertical{border-right-color:", divider.light.borderColor, ";}}&.", k, "-vertical{border-top:0;display:inline-block;height:100%;border-right:1px solid ", divider.borderColor, ";vertical-align:middle;}&.", k, "-horizontal{width:100%;min-width:100%;}&.", k, "-with-text{border-top:0;display:flex;align-items:center;white-space:nowrap;text-align:center;&::before,&::after{width:50%;content:'';transform:translateY(50%);border-top:1px solid ", divider.borderColor, ";}}.", k, "-divider-text{padding:0 16px;}&.", k, "-left{&::before{width:", divider.positionOffset, ";}&::after{width:calc(100% - ", divider.positionOffset, ");}}&.", k, "-right{&::before{width:calc(100% - ", divider.positionOffset, ");}&::after{width:", divider.positionOffset, ";}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
33
|
+
return /*#__PURE__*/css("&.", k, "-", size, "{margin:", theme[size].margin, " 0;&.", k, "-vertical{margin:0 ", theme[size].margin, ";}}");
|
|
34
|
+
}), ";");
|
|
35
|
+
});
|
|
@@ -177,8 +177,8 @@ Dropdown.template = function () {
|
|
|
177
177
|
if (this.$isVue || this.$isVueNext) {
|
|
178
178
|
if (Array.isArray(children)) {
|
|
179
179
|
children = _filterInstanceProperty(children).call(children, function (child) {
|
|
180
|
-
return child !== ' ';
|
|
181
|
-
});
|
|
180
|
+
return child !== ' ' && child;
|
|
181
|
+
} /* comment is null in vue3 */);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Component, TypeDefs } from 'intact';
|
|
2
|
+
import { Options } from '../position';
|
|
3
|
+
export type Position = Options;
|
|
4
|
+
export interface EllipsisProps {
|
|
5
|
+
maxLines?: number;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
position?: Position | 'left' | 'bottom' | 'right' | 'top';
|
|
8
|
+
theme?: 'light' | 'dark';
|
|
9
|
+
}
|
|
10
|
+
export declare class Ellipsis extends Component<EllipsisProps> {
|
|
11
|
+
static template: string | import("intact").Template<any>;
|
|
12
|
+
static typeDefs: Required<TypeDefs<EllipsisProps>>;
|
|
13
|
+
static defaults: () => Partial<EllipsisProps>;
|
|
14
|
+
private ellipsis;
|
|
15
|
+
private config;
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
|
+
import { Component } from 'intact';
|
|
4
|
+
import template from './index.vdt';
|
|
5
|
+
import { useEllipsis } from './useEllipsis';
|
|
6
|
+
import { useConfigContext } from '../config';
|
|
7
|
+
var typeDefs = {
|
|
8
|
+
maxLines: Number,
|
|
9
|
+
disabled: Boolean,
|
|
10
|
+
position: [Object, 'left', 'bottom', 'right', 'top'],
|
|
11
|
+
theme: ['light', 'dark']
|
|
12
|
+
};
|
|
13
|
+
var defaults = function defaults() {
|
|
14
|
+
return {
|
|
15
|
+
disabled: false,
|
|
16
|
+
theme: 'light'
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export var Ellipsis = /*#__PURE__*/function (_Component) {
|
|
20
|
+
_inheritsLoose(Ellipsis, _Component);
|
|
21
|
+
function Ellipsis() {
|
|
22
|
+
var _context;
|
|
23
|
+
var _this;
|
|
24
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
25
|
+
args[_key] = arguments[_key];
|
|
26
|
+
}
|
|
27
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
28
|
+
_this.ellipsis = useEllipsis();
|
|
29
|
+
_this.config = useConfigContext();
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
return Ellipsis;
|
|
33
|
+
}(Component);
|
|
34
|
+
Ellipsis.template = template;
|
|
35
|
+
Ellipsis.typeDefs = typeDefs;
|
|
36
|
+
Ellipsis.defaults = defaults;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
|
+
import BasicDemo from '~/components/ellipsis/demos/basic';
|
|
4
|
+
import { mount, unmount, dispatchEvent, getElement, wait } from '../../test/utils';
|
|
5
|
+
describe('Ellipsis', function () {
|
|
6
|
+
afterEach(function () {
|
|
7
|
+
return unmount();
|
|
8
|
+
});
|
|
9
|
+
it('should support drag Ellipsis', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
10
|
+
var _mount, instance, element, _element$querySelecto, ellipsis1, ellipsis2, dragLine, children1, content1, children2, content2;
|
|
11
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
12
|
+
while (1) switch (_context.prev = _context.next) {
|
|
13
|
+
case 0:
|
|
14
|
+
_mount = mount(BasicDemo), instance = _mount[0], element = _mount[1];
|
|
15
|
+
_element$querySelecto = element.querySelectorAll('.k-ellipsis'), ellipsis1 = _element$querySelecto[0], ellipsis2 = _element$querySelecto[1];
|
|
16
|
+
dragLine = element.querySelector('.k-split-line-wrapper'); // There is no tooltip content by default
|
|
17
|
+
expect(getElement('.k-tooltip-content')).to.be.undefined;
|
|
18
|
+
// mouse move
|
|
19
|
+
dispatchEvent(dragLine, 'mousedown', {
|
|
20
|
+
which: 1,
|
|
21
|
+
clientX: 200,
|
|
22
|
+
clientY: 0
|
|
23
|
+
});
|
|
24
|
+
dispatchEvent(document, 'mousemove', {
|
|
25
|
+
clientX: 100,
|
|
26
|
+
clientY: 0
|
|
27
|
+
});
|
|
28
|
+
dispatchEvent(dragLine, 'mouseup');
|
|
29
|
+
_context.next = 9;
|
|
30
|
+
return wait(200);
|
|
31
|
+
case 9:
|
|
32
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
33
|
+
// mouseenter ellipsis dom
|
|
34
|
+
children1 = ellipsis1.firstElementChild;
|
|
35
|
+
dispatchEvent(children1, 'mouseenter');
|
|
36
|
+
_context.next = 14;
|
|
37
|
+
return wait(0);
|
|
38
|
+
case 14:
|
|
39
|
+
expect(children1.classList.contains('k-dropdown-open')).to.be.true;
|
|
40
|
+
content1 = getElement('.k-tooltip-content');
|
|
41
|
+
expect(content1.textContent).eql('测试测试测试测试测试测试');
|
|
42
|
+
children2 = ellipsis2.firstElementChild;
|
|
43
|
+
dispatchEvent(children2, 'mouseenter');
|
|
44
|
+
_context.next = 21;
|
|
45
|
+
return wait(0);
|
|
46
|
+
case 21:
|
|
47
|
+
content2 = getElement('.k-tooltip-content');
|
|
48
|
+
expect(content2.textContent).eql('最大几行忽略最大几行忽略最大几行忽略');
|
|
49
|
+
case 23:
|
|
50
|
+
case "end":
|
|
51
|
+
return _context.stop();
|
|
52
|
+
}
|
|
53
|
+
}, _callee);
|
|
54
|
+
})));
|
|
55
|
+
it('should disabled tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
56
|
+
var _mount2, instance, element, ellipsis3, dragLine, children3;
|
|
57
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
58
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
_mount2 = mount(BasicDemo), instance = _mount2[0], element = _mount2[1];
|
|
61
|
+
ellipsis3 = element.querySelectorAll('.k-ellipsis')[2];
|
|
62
|
+
dragLine = element.querySelector('.k-split-line-wrapper');
|
|
63
|
+
dispatchEvent(dragLine, 'mousedown', {
|
|
64
|
+
which: 1,
|
|
65
|
+
clientX: 200,
|
|
66
|
+
clientY: 0
|
|
67
|
+
});
|
|
68
|
+
dispatchEvent(document, 'mousemove', {
|
|
69
|
+
clientX: 300,
|
|
70
|
+
clientY: 0
|
|
71
|
+
});
|
|
72
|
+
dispatchEvent(dragLine, 'mouseup');
|
|
73
|
+
_context2.next = 8;
|
|
74
|
+
return wait(200);
|
|
75
|
+
case 8:
|
|
76
|
+
// disabled close tooltip
|
|
77
|
+
expect(ellipsis3.firstElementChild.classList.contains('k-dropdown-open')).to.be.false;
|
|
78
|
+
instance.set('disabled', false);
|
|
79
|
+
_context2.next = 12;
|
|
80
|
+
return wait();
|
|
81
|
+
case 12:
|
|
82
|
+
children3 = ellipsis3.firstElementChild;
|
|
83
|
+
dispatchEvent(children3, 'mouseenter');
|
|
84
|
+
_context2.next = 16;
|
|
85
|
+
return wait();
|
|
86
|
+
case 16:
|
|
87
|
+
expect(children3.classList.contains('k-dropdown-open')).to.be.true;
|
|
88
|
+
case 17:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context2.stop();
|
|
91
|
+
}
|
|
92
|
+
}, _callee2);
|
|
93
|
+
})));
|
|
94
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import { createElementVNode as _$ce, className as _$cn, createVNode as _$cv, createUnknownComponentVNode as _$cc, extend as _$ex, EMPTY_OBJ as _$em } from 'intact';
|
|
3
|
+
import { makeStyles } from './styles';
|
|
4
|
+
import { Tooltip } from '../tooltip';
|
|
5
|
+
import { getRestProps, addStyle } from '../utils';
|
|
6
|
+
export default function ($props, $blocks, $__proto__) {
|
|
7
|
+
var _$cn2, _$cn3;
|
|
8
|
+
$blocks || ($blocks = {});
|
|
9
|
+
$props || ($props = {});
|
|
10
|
+
var $this = this;
|
|
11
|
+
var _this$get = this.get(),
|
|
12
|
+
children = _this$get.children,
|
|
13
|
+
className = _this$get.className,
|
|
14
|
+
maxLines = _this$get.maxLines,
|
|
15
|
+
disabled = _this$get.disabled,
|
|
16
|
+
position = _this$get.position,
|
|
17
|
+
theme = _this$get.theme,
|
|
18
|
+
style = _this$get.style;
|
|
19
|
+
var k = this.config.k;
|
|
20
|
+
var _this$ellipsis = this.ellipsis,
|
|
21
|
+
showTooltip = _this$ellipsis.showTooltip,
|
|
22
|
+
ellipsisRef = _this$ellipsis.ellipsisRef;
|
|
23
|
+
var tooltip = showTooltip.value && !disabled;
|
|
24
|
+
var wrapper = _$ce(2, 'div', children, 0, _$cn((_$cn2 = {
|
|
25
|
+
'c-ellipsis': true
|
|
26
|
+
}, _$cn2[k + "-ellipsis-wrapper"] = true, _$cn2[className] = className && !tooltip, _$cn2)));
|
|
27
|
+
return _$cv('div', _extends({}, getRestProps(this), {
|
|
28
|
+
'className': _$cn((_$cn3 = {}, _$cn3[k + "-ellipsis"] = true, _$cn3[k + "-multiline"] = maxLines, _$cn3[makeStyles(k, maxLines)] = true, _$cn3)),
|
|
29
|
+
'ref': ellipsisRef
|
|
30
|
+
}), tooltip ? _$cc(Tooltip, {
|
|
31
|
+
'position': position,
|
|
32
|
+
'theme': theme,
|
|
33
|
+
'className': _$cn(className),
|
|
34
|
+
'children': wrapper,
|
|
35
|
+
'$blocks': function ($blocks) {
|
|
36
|
+
var _$blocks = {},
|
|
37
|
+
__$blocks = _$ex({}, $blocks);
|
|
38
|
+
return (_$blocks['content'] = function ($super) {
|
|
39
|
+
return children;
|
|
40
|
+
}, __$blocks['content'] = function ($super, data) {
|
|
41
|
+
var block = $blocks['content'];
|
|
42
|
+
var callBlock = function callBlock() {
|
|
43
|
+
return _$blocks['content'].call($this, $super, data);
|
|
44
|
+
};
|
|
45
|
+
return block ? block.call($this, callBlock, data) : callBlock();
|
|
46
|
+
}), __$blocks;
|
|
47
|
+
}.call($this, _$em)
|
|
48
|
+
}) : wrapper);
|
|
49
|
+
}
|
|
50
|
+
;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { css } from '@emotion/css';
|
|
2
|
+
import { setDefault } from '../../styles/theme';
|
|
3
|
+
import '../../styles/global';
|
|
4
|
+
import { cache } from '../utils';
|
|
5
|
+
setDefault(function () {
|
|
6
|
+
makeStyles == null || makeStyles.clearCache();
|
|
7
|
+
});
|
|
8
|
+
export var makeStyles = cache(function makeStyles(k, maxLines) {
|
|
9
|
+
return /*#__PURE__*/css("width:100%;&.", k, "-multiline{.k-ellipsis-wrapper{white-space:normal;display:-webkit-box;-webkit-line-clamp:", maxLines, ";-webkit-box-orient:vertical;}}");
|
|
10
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useInstance, createRef } from 'intact';
|
|
2
|
+
import { useResizeObserver } from '../../hooks/useResizeObserver';
|
|
3
|
+
import { useState } from '../../hooks/useState';
|
|
4
|
+
export function useEllipsis() {
|
|
5
|
+
var instance = useInstance();
|
|
6
|
+
var ellipsisRef = createRef();
|
|
7
|
+
var showTooltip = useState(false);
|
|
8
|
+
useResizeObserver(ellipsisRef, isShowTooltip);
|
|
9
|
+
function isShowTooltip() {
|
|
10
|
+
var isMulti = instance.get('maxLines');
|
|
11
|
+
var element = ellipsisRef.value.children[0];
|
|
12
|
+
var _showTooltip = isMulti ? element.scrollHeight > element.clientHeight : element.offsetWidth < element.scrollWidth;
|
|
13
|
+
requestAnimationFrame(function () {
|
|
14
|
+
showTooltip.set(_showTooltip);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
ellipsisRef: ellipsisRef,
|
|
19
|
+
showTooltip: showTooltip
|
|
20
|
+
};
|
|
21
|
+
}
|