@king-design/react 2.1.1 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/__snapshots__/Dialog.md +1 -1
- package/__tests__/__snapshots__/React Demos.md +410 -374
- package/__tests__/components/drawer.spec.tsx +67 -5
- package/components/button/index.d.ts +1 -1
- package/components/button/index.js +1 -1
- package/components/button/styles.js +3 -3
- package/components/card/styles.js +10 -2
- package/components/checkbox/styles.js +21 -10
- package/components/collapse/styles.js +6 -1
- package/components/copy/index.d.ts +17 -0
- package/components/copy/index.js +43 -0
- package/components/copy/index.spec.d.ts +1 -0
- package/components/copy/index.spec.js +52 -0
- package/components/copy/index.vdt.js +45 -0
- package/components/copy/styles.d.ts +2 -0
- package/components/copy/styles.js +14 -0
- package/components/copy/useCopy.d.ts +4 -0
- package/components/copy/useCopy.js +90 -0
- package/components/datepicker/index.spec.js +1 -1
- package/components/datepicker/index.vdt.js +1 -1
- package/components/datepicker/styles.d.ts +1 -1
- package/components/datepicker/styles.js +5 -2
- package/components/diagram/shapes/callout.d.ts +1 -1
- package/components/diagram/shapes/circle.d.ts +1 -1
- package/components/diagram/shapes/document.d.ts +1 -1
- package/components/diagram/shapes/ellipse.d.ts +1 -1
- package/components/diagram/shapes/hexagon.d.ts +1 -1
- package/components/diagram/shapes/image.d.ts +1 -1
- package/components/diagram/shapes/parallelogram.d.ts +1 -1
- package/components/diagram/shapes/rectangle.d.ts +1 -1
- package/components/diagram/shapes/square.d.ts +1 -1
- package/components/diagram/shapes/text.d.ts +1 -1
- package/components/dialog/alert.vdt.js +6 -5
- package/components/dialog/base.vdt.js +5 -6
- package/components/dialog/index.spec.js +4 -4
- package/components/dialog/styles.js +16 -14
- package/components/drawer/styles.js +20 -5
- package/components/dropdown/styles.js +1 -1
- package/components/form/index.spec.js +4 -2
- package/components/form/item.vdt.js +2 -1
- package/components/form/styles.js +5 -5
- package/components/grid/useGutter.js +8 -8
- package/components/icon/index.d.ts +1 -0
- package/components/icon/index.js +2 -1
- package/components/icon/index.vdt.js +4 -2
- package/components/icon/styles.js +10 -2
- package/components/input/index.d.ts +1 -0
- package/components/input/index.js +4 -11
- package/components/input/index.vdt.js +4 -2
- package/components/input/styles.js +13 -11
- package/components/message/message.js +1 -1
- package/components/message/message.vdt.js +7 -6
- package/components/message/styles.js +8 -8
- package/components/pagination/index.d.ts +1 -1
- package/components/pagination/index.js +1 -1
- package/components/pagination/index.spec.js +4 -2
- package/components/pagination/index.vdt.js +16 -18
- package/components/pagination/styles.js +12 -3
- package/components/popover/content.d.ts +19 -0
- package/components/popover/content.js +31 -0
- package/components/popover/content.vdt.js +68 -0
- package/components/popover/index.d.ts +16 -0
- package/components/popover/index.js +44 -0
- package/components/popover/index.spec.d.ts +1 -0
- package/components/popover/index.spec.js +195 -0
- package/components/popover/styles.d.ts +1 -0
- package/components/popover/styles.js +22 -0
- package/components/progress/index.js +1 -1
- package/components/progress/index.vdt.js +46 -8
- package/components/progress/styles.js +19 -13
- package/components/radio/styles.js +16 -6
- package/components/rate/styles.js +1 -1
- package/components/select/base.d.ts +5 -2
- package/components/select/base.js +7 -3
- package/components/select/base.vdt.js +46 -38
- package/components/select/index.spec.js +2 -2
- package/components/select/menu.vdt.js +1 -1
- package/components/select/styles.js +14 -28
- package/components/select/useDraggble.d.ts +2 -0
- package/components/select/useDraggble.js +11 -0
- package/components/select/useNowrap.d.ts +3 -0
- package/components/select/useNowrap.js +19 -0
- package/components/slider/index.spec.js +48 -9
- package/components/slider/index.vdt.js +23 -12
- package/components/slider/styles.js +23 -14
- package/components/slider/useValue.d.ts +3 -1
- package/components/slider/useValue.js +12 -0
- package/components/spinner/index.d.ts +0 -1
- package/components/spinner/index.js +1 -19
- package/components/spinner/index.vdt.js +15 -8
- package/components/spinner/styles.js +33 -5
- package/components/spinner/useChange.d.ts +1 -1
- package/components/spinner/useChange.js +2 -2
- package/components/spinner/useValue.d.ts +1 -0
- package/components/spinner/useValue.js +16 -1
- package/components/split/index.vdt.js +32 -20
- package/components/split/memo.d.ts +9 -0
- package/components/split/memo.js +26 -0
- package/components/steps/index.d.ts +3 -2
- package/components/steps/index.js +4 -3
- package/components/steps/index.spec.js +1 -1
- package/components/steps/index.vdt.js +8 -4
- package/components/steps/step.vdt.js +17 -9
- package/components/steps/styles.d.ts +2 -1
- package/components/steps/styles.js +106 -72
- package/components/switch/index.spec.js +82 -65
- package/components/switch/styles.js +20 -34
- package/components/table/styles.js +9 -4
- package/components/table/useDraggable.js +3 -10
- package/components/table/useStickyScrollbar.js +2 -2
- package/components/table/useWidth.js +2 -2
- package/components/tabs/index.d.ts +1 -1
- package/components/tabs/index.js +1 -1
- package/components/tabs/index.spec.js +67 -0
- package/components/tabs/index.vdt.js +5 -5
- package/components/tabs/styles.js +73 -29
- package/components/tabs/useScroll.d.ts +1 -1
- package/components/tabs/useScroll.js +75 -48
- package/components/tag/base.d.ts +1 -0
- package/components/tag/base.js +2 -2
- package/components/tag/index.d.ts +1 -0
- package/components/tag/index.js +2 -1
- package/components/tag/index.spec.js +147 -4
- package/components/tag/styles.d.ts +67 -0
- package/components/tag/styles.js +42 -12
- package/components/tag/tags.d.ts +27 -0
- package/components/tag/tags.js +51 -0
- package/components/tag/tags.vdt.js +79 -0
- package/components/tag/useChildren.d.ts +2 -0
- package/components/tag/useChildren.js +39 -0
- package/components/tag/useDraggable.d.ts +3 -0
- package/components/tag/useDraggable.js +89 -0
- package/components/tag/useNowrap.d.ts +7 -0
- package/components/tag/useNowrap.js +115 -0
- package/components/timepicker/index.spec.js +1 -1
- package/components/tip/index.vdt.js +1 -3
- package/components/tip/styles.js +4 -3
- package/components/tooltip/content.d.ts +2 -2
- package/components/tooltip/content.vdt.js +23 -13
- package/components/tooltip/index.spec.js +56 -108
- package/components/tooltip/styles.d.ts +1 -0
- package/components/tooltip/styles.js +13 -8
- package/components/transfer/index.vdt.js +3 -1
- package/components/transfer/styles.js +1 -1
- package/components/transfer/useCheck.d.ts +1 -0
- package/components/transfer/useCheck.js +8 -1
- package/components/upload/index.spec.js +5 -6
- package/components/upload/index.vdt.js +24 -21
- package/components/upload/styles.js +22 -30
- package/components/utils.d.ts +2 -0
- package/components/utils.js +24 -3
- package/hooks/useResizeObserver.d.ts +1 -1
- package/hooks/useResizeObserver.js +19 -6
- package/i18n/en-US.d.ts +6 -2
- package/i18n/en-US.js +8 -3
- package/index.d.ts +4 -2
- package/index.js +4 -2
- package/package.json +1 -1
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +2 -2
- package/styles/fonts/iconfont.svg +189 -369
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/ionicons.js +2 -2
- package/styles/global.js +1 -1
- package/styles/theme.d.ts +10 -2
- package/styles/theme.js +23 -21
- package/components/table/useResizeObserver.d.ts +0 -2
- package/components/table/useResizeObserver.js +0 -20
package/components/tag/styles.js
CHANGED
|
@@ -5,8 +5,8 @@ import { theme, setDefault } from '../../styles/theme';
|
|
|
5
5
|
import '../../styles/global';
|
|
6
6
|
var types = ['primary', 'warning', 'danger', 'success', 'disabled'];
|
|
7
7
|
var defaults = deepDefaults({
|
|
8
|
-
get
|
|
9
|
-
return theme.color.border;
|
|
8
|
+
get border() {
|
|
9
|
+
return "1px solid " + theme.color.border;
|
|
10
10
|
},
|
|
11
11
|
|
|
12
12
|
get borderRadius() {
|
|
@@ -19,9 +19,20 @@ var defaults = deepDefaults({
|
|
|
19
19
|
|
|
20
20
|
padding: "0 8px",
|
|
21
21
|
height: '20px',
|
|
22
|
+
|
|
23
|
+
get bgColor() {
|
|
24
|
+
return theme.color.bg;
|
|
25
|
+
},
|
|
26
|
+
|
|
22
27
|
close: {
|
|
23
28
|
fontSize: '20px',
|
|
24
|
-
gap: '8px'
|
|
29
|
+
gap: '8px',
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* fix the width to calculate the width for nowrap tags,
|
|
33
|
+
* otherwise the width will be decided by font font-icons loaded
|
|
34
|
+
*/
|
|
35
|
+
width: '7px'
|
|
25
36
|
},
|
|
26
37
|
disabled: {
|
|
27
38
|
get color() {
|
|
@@ -38,24 +49,36 @@ var defaults = deepDefaults({
|
|
|
38
49
|
|
|
39
50
|
},
|
|
40
51
|
large: {
|
|
41
|
-
padding: "0px
|
|
42
|
-
height: '
|
|
52
|
+
padding: "0px 8px",
|
|
53
|
+
height: '24px',
|
|
54
|
+
|
|
55
|
+
get fontSize() {
|
|
56
|
+
return theme.large.fontSize;
|
|
57
|
+
},
|
|
58
|
+
|
|
43
59
|
close: {
|
|
44
|
-
fontSize: '
|
|
45
|
-
gap: '
|
|
60
|
+
fontSize: '22px',
|
|
61
|
+
gap: '6px'
|
|
46
62
|
}
|
|
47
63
|
},
|
|
48
64
|
small: {
|
|
49
65
|
padding: "0 4px",
|
|
50
|
-
height: '
|
|
66
|
+
height: '16px',
|
|
67
|
+
|
|
68
|
+
get fontSize() {
|
|
69
|
+
return theme.small.fontSize;
|
|
70
|
+
},
|
|
71
|
+
|
|
51
72
|
close: {
|
|
52
73
|
fontSize: '18px',
|
|
53
74
|
gap: '4px'
|
|
54
75
|
}
|
|
55
76
|
},
|
|
56
77
|
mini: {
|
|
57
|
-
padding: "0
|
|
78
|
+
padding: "0 2px",
|
|
58
79
|
height: '14px',
|
|
80
|
+
// get fontSize() { return theme.mini.fontSize },
|
|
81
|
+
fontSize: '11px',
|
|
59
82
|
close: {
|
|
60
83
|
fontSize: '16px',
|
|
61
84
|
gap: '2px'
|
|
@@ -66,6 +89,9 @@ var defaults = deepDefaults({
|
|
|
66
89
|
return theme.color.bg;
|
|
67
90
|
}
|
|
68
91
|
|
|
92
|
+
},
|
|
93
|
+
tags: {
|
|
94
|
+
gap: '8px'
|
|
69
95
|
}
|
|
70
96
|
}, types.reduce(function (memo, type) {
|
|
71
97
|
if (type === 'disabled') return memo;
|
|
@@ -87,13 +113,17 @@ setDefault(function () {
|
|
|
87
113
|
tag: defaults
|
|
88
114
|
}).tag;
|
|
89
115
|
});
|
|
116
|
+
export { tag };
|
|
90
117
|
export function makeStyles() {
|
|
91
|
-
return /*#__PURE__*/css("display:inline-flex;align-items:center;padding:", tag.padding, ";border:
|
|
118
|
+
return /*#__PURE__*/css("display:inline-flex;align-items:center;padding:", tag.padding, ";border:", tag.border, ";border-radius:", tag.borderRadius, ";font-size:", tag.fontSize, ";height:", tag.height, ";.k-tag-close{font-size:", tag.close.fontSize, ";margin-left:", tag.close.gap, ";width:", tag.close.width, ";}&.k-none{border:none;background:", tag.none.bgColor, ";}", _mapInstanceProperty(types).call(types, function (t) {
|
|
92
119
|
var styles = tag[t];
|
|
93
120
|
return /*#__PURE__*/css("&.k-", t, "{color:", styles.color, ";border-color:", styles.color, ";background:", styles.bgColor, ";}");
|
|
94
121
|
}), " ", _mapInstanceProperty(sizes).call(sizes, function (s) {
|
|
95
122
|
if (s === 'default') return;
|
|
96
123
|
var styles = tag[s];
|
|
97
|
-
return /*#__PURE__*/css("&.k-", s, "{padding:", styles.padding, ";height:", styles.height, ";.k-tag-close{font-size:", styles.close.fontSize, ";margin-left:", styles.close.gap, ";}}");
|
|
98
|
-
}), "&.k-dashed{border-style:dashed;}");
|
|
124
|
+
return /*#__PURE__*/css("&.k-", s, "{padding:", styles.padding, ";height:", styles.height, ";font-size:", styles.fontSize, ";.k-tag-close{font-size:", styles.close.fontSize, ";margin-left:", styles.close.gap, ";}}");
|
|
125
|
+
}), "&.k-dashed{border-style:dashed;}&.k-dragging{opacity:0;}");
|
|
126
|
+
}
|
|
127
|
+
export function makeTagsStyles() {
|
|
128
|
+
return /*#__PURE__*/css("display:flex;flex-wrap:wrap;gap:", defaults.tags.gap, ";position:relative;overflow:hidden;&.k-nowrap{flex-wrap:nowrap;}.k-tag{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:0;}.k-tags-more{cursor:default;font-family:monospace;}.k-tag.k-draggable{cursor:move;}");
|
|
99
129
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Component, TypeDefs, Key } from 'intact-react';
|
|
2
|
+
import { TagProps } from './base';
|
|
3
|
+
import type { Events } from '../types';
|
|
4
|
+
export interface TagsProps extends Pick<TagProps, 'size' | 'border'> {
|
|
5
|
+
nowrap?: boolean;
|
|
6
|
+
draggable?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare type TagsDragStartParam = {
|
|
9
|
+
key: Key;
|
|
10
|
+
from: number;
|
|
11
|
+
};
|
|
12
|
+
export declare type TagsDragEndParam = TagsDragStartParam & {
|
|
13
|
+
to: number;
|
|
14
|
+
};
|
|
15
|
+
export interface TagsEvents {
|
|
16
|
+
dragstart: [TagsDragStartParam];
|
|
17
|
+
dragend: [TagsDragEndParam];
|
|
18
|
+
}
|
|
19
|
+
export declare class Tags extends Component<TagsProps, TagsEvents> {
|
|
20
|
+
static template: string | import("intact").Template<any>;
|
|
21
|
+
static typeDefs: Required<TypeDefs<TagsProps>>;
|
|
22
|
+
static defaults: () => Partial<TagsProps>;
|
|
23
|
+
static events: Events<TagsEvents>;
|
|
24
|
+
private children;
|
|
25
|
+
private draggable;
|
|
26
|
+
private nowrap;
|
|
27
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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-react';
|
|
4
|
+
import template from './tags.vdt';
|
|
5
|
+
import { useNowrap } from './useNowrap';
|
|
6
|
+
import { typeDefs as tagTypeDefs } from './base';
|
|
7
|
+
import { useChildren } from './useChildren';
|
|
8
|
+
import { useDraggable } from './useDraggable';
|
|
9
|
+
var typeDefs = {
|
|
10
|
+
nowrap: Boolean,
|
|
11
|
+
draggable: Boolean,
|
|
12
|
+
size: tagTypeDefs.size,
|
|
13
|
+
border: tagTypeDefs.border
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
var defaults = function defaults() {
|
|
17
|
+
return {
|
|
18
|
+
size: 'default',
|
|
19
|
+
border: 'none'
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var events = {
|
|
24
|
+
dragstart: true,
|
|
25
|
+
dragend: true
|
|
26
|
+
};
|
|
27
|
+
export var Tags = /*#__PURE__*/function (_Component) {
|
|
28
|
+
_inheritsLoose(Tags, _Component);
|
|
29
|
+
|
|
30
|
+
function Tags() {
|
|
31
|
+
var _context;
|
|
32
|
+
|
|
33
|
+
var _this;
|
|
34
|
+
|
|
35
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
36
|
+
args[_key] = arguments[_key];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
40
|
+
_this.children = useChildren();
|
|
41
|
+
_this.draggable = useDraggable(_this.children);
|
|
42
|
+
_this.nowrap = useNowrap(_this.draggable);
|
|
43
|
+
return _this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return Tags;
|
|
47
|
+
}(Component);
|
|
48
|
+
Tags.template = template;
|
|
49
|
+
Tags.typeDefs = typeDefs;
|
|
50
|
+
Tags.defaults = defaults;
|
|
51
|
+
Tags.events = events;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import { createVNode as _$cv, className as _$cn, createUnknownComponentVNode as _$cc, createTextVNode as _$ct, extend as _$ex, EMPTY_OBJ as _$em, createElementVNode as _$ce } from 'intact-react';
|
|
3
|
+
import { TransitionGroup } from 'intact';
|
|
4
|
+
import { getRestProps } from '../utils';
|
|
5
|
+
import { makeTagsStyles } from './styles';
|
|
6
|
+
import { Tag } from './';
|
|
7
|
+
import { Tooltip } from '../tooltip';
|
|
8
|
+
import { Tags } from './tags';
|
|
9
|
+
import { Virtual } from '../virtual';
|
|
10
|
+
export default function ($props, $blocks, $__proto__) {
|
|
11
|
+
var _classNameObj;
|
|
12
|
+
|
|
13
|
+
$blocks || ($blocks = {});
|
|
14
|
+
$props || ($props = {});
|
|
15
|
+
var $this = this;
|
|
16
|
+
|
|
17
|
+
var _this$get = this.get(),
|
|
18
|
+
className = _this$get.className,
|
|
19
|
+
nowrap = _this$get.nowrap,
|
|
20
|
+
size = _this$get.size,
|
|
21
|
+
border = _this$get.border,
|
|
22
|
+
draggable = _this$get.draggable;
|
|
23
|
+
|
|
24
|
+
var classNameObj = (_classNameObj = {
|
|
25
|
+
'k-tags': true,
|
|
26
|
+
'k-nowrap': nowrap,
|
|
27
|
+
'k-draggable': draggable
|
|
28
|
+
}, _classNameObj[makeTagsStyles()] = true, _classNameObj[className] = className, _classNameObj);
|
|
29
|
+
var _this$nowrap = this.nowrap,
|
|
30
|
+
containerRef = _this$nowrap.containerRef,
|
|
31
|
+
children = _this$nowrap.children,
|
|
32
|
+
hiddenChildren = _this$nowrap.hiddenChildren;
|
|
33
|
+
var vNodes = children.value;
|
|
34
|
+
/**
|
|
35
|
+
* We should always render Tooltip in nowrap mode, otherwise it will be removed while we close one tag.
|
|
36
|
+
* Because we will render all tags to calculate the width
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
return _$cv('div', _extends({
|
|
40
|
+
'className': _$cn(classNameObj)
|
|
41
|
+
}, getRestProps(this), {
|
|
42
|
+
'ref': containerRef
|
|
43
|
+
}), [!nowrap ? _$cc(TransitionGroup, {
|
|
44
|
+
'name': 'k-fade',
|
|
45
|
+
'children': vNodes
|
|
46
|
+
}) : vNodes, nowrap ? _$cc(Tooltip, {
|
|
47
|
+
'key': '$tooltip',
|
|
48
|
+
'hoverable': true,
|
|
49
|
+
'theme': 'light',
|
|
50
|
+
'className': 'k-tags-tooltip',
|
|
51
|
+
'children': _$cc(Tag, {
|
|
52
|
+
'key': '$more',
|
|
53
|
+
'className': _$cn({
|
|
54
|
+
"k-tags-more": true,
|
|
55
|
+
'c-hidden': !hiddenChildren.value.length
|
|
56
|
+
}),
|
|
57
|
+
'size': size,
|
|
58
|
+
'border': border,
|
|
59
|
+
'children': [_$ct('\n +'), hiddenChildren.value.length]
|
|
60
|
+
}, '$more'),
|
|
61
|
+
'$blocks': function ($blocks) {
|
|
62
|
+
var _$blocks = {},
|
|
63
|
+
__$blocks = _$ex({}, $blocks);
|
|
64
|
+
|
|
65
|
+
return (_$blocks['content'] = function ($super) {
|
|
66
|
+
return _$ce(2, 'div', hiddenChildren.value, 0, _$cn(classNameObj));
|
|
67
|
+
}, __$blocks['content'] = function ($super, data) {
|
|
68
|
+
var block = $blocks['content'];
|
|
69
|
+
|
|
70
|
+
var callBlock = function callBlock() {
|
|
71
|
+
return _$blocks['content'].call($this, $super, data);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return block ? block.call($this, callBlock, data) : callBlock();
|
|
75
|
+
}), __$blocks;
|
|
76
|
+
}.call($this, _$em)
|
|
77
|
+
}, '$tooltip') : undefined]);
|
|
78
|
+
}
|
|
79
|
+
;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useInstance } from 'intact-react';
|
|
2
|
+
import { eachChildren, findChildren, isComponentVNode } from '../utils';
|
|
3
|
+
import { isStringOrNumber } from 'intact-shared';
|
|
4
|
+
import { useState } from '../../hooks/useState';
|
|
5
|
+
import { Tag } from './';
|
|
6
|
+
import { Dropdown } from '../dropdown';
|
|
7
|
+
import { Tooltip } from '../tooltip';
|
|
8
|
+
export function useChildren() {
|
|
9
|
+
var instance = useInstance();
|
|
10
|
+
var children = useState([]);
|
|
11
|
+
instance.watch('children', function (v) {
|
|
12
|
+
var vNodes = [];
|
|
13
|
+
eachChildren(v, function (vNode) {
|
|
14
|
+
if (isTagOrContainsTag(vNode)) {
|
|
15
|
+
vNodes.push(vNode);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
children.set(vNodes);
|
|
19
|
+
});
|
|
20
|
+
return children;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isTagOrContainsTag(vNode) {
|
|
24
|
+
if (isStringOrNumber(vNode)) return false;
|
|
25
|
+
|
|
26
|
+
if (isComponentVNode(vNode, Tag)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (isComponentVNode(vNode, Dropdown) || isComponentVNode(vNode, Tooltip)) {
|
|
31
|
+
var _vNode$props;
|
|
32
|
+
|
|
33
|
+
return !!findChildren((_vNode$props = vNode.props) == null ? void 0 : _vNode$props.children, function (vNode) {
|
|
34
|
+
return isTagOrContainsTag(vNode);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
2
|
+
import { useInstance, findDomFromVNode, createVNode as h } from 'intact-react';
|
|
3
|
+
import { nextFrame, swap } from '../utils';
|
|
4
|
+
import { useState, watchState } from '../../hooks/useState';
|
|
5
|
+
import { Virtual } from '../virtual';
|
|
6
|
+
import { cx } from '@emotion/css';
|
|
7
|
+
export function useDraggable(originVNodes) {
|
|
8
|
+
var instance = useInstance();
|
|
9
|
+
var children = useState([]);
|
|
10
|
+
var draggingKey = useState(null);
|
|
11
|
+
var draggingIndex = -1;
|
|
12
|
+
var originIndex = -1;
|
|
13
|
+
var lastOverIndex = -1;
|
|
14
|
+
/* let the dragover event only trigger once when tags changed order */
|
|
15
|
+
|
|
16
|
+
watchState(originVNodes, render);
|
|
17
|
+
watchState(draggingKey, render);
|
|
18
|
+
|
|
19
|
+
function render() {
|
|
20
|
+
var _context;
|
|
21
|
+
|
|
22
|
+
var _instance$get = instance.get(),
|
|
23
|
+
draggable = _instance$get.draggable;
|
|
24
|
+
|
|
25
|
+
children.set(!draggable ? originVNodes.value : _mapInstanceProperty(_context = originVNodes.value).call(_context, function (vNode, index) {
|
|
26
|
+
var key = vNode.key;
|
|
27
|
+
return h(Virtual, {
|
|
28
|
+
'ev-dragstart': function evDragstart() {
|
|
29
|
+
return onStart(key, index);
|
|
30
|
+
},
|
|
31
|
+
'ev-dragover': function evDragover(e) {
|
|
32
|
+
return onOver(e, key, index);
|
|
33
|
+
},
|
|
34
|
+
'ev-dragend': function evDragend(e) {
|
|
35
|
+
return onEnd(e);
|
|
36
|
+
},
|
|
37
|
+
key: key,
|
|
38
|
+
draggable: draggable,
|
|
39
|
+
className: cx({
|
|
40
|
+
'k-dragging': key === draggingKey.value,
|
|
41
|
+
'k-draggable': draggable
|
|
42
|
+
})
|
|
43
|
+
}, vNode);
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function onStart(key, index) {
|
|
48
|
+
draggingIndex = originIndex = index;
|
|
49
|
+
nextFrame(function () {
|
|
50
|
+
draggingKey.set(key);
|
|
51
|
+
});
|
|
52
|
+
instance.trigger('dragstart', {
|
|
53
|
+
key: key,
|
|
54
|
+
from: index
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function onOver(e, key, index) {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
e.stopPropagation(); // Dragging the tag of another tags drag to this tags should be ignored
|
|
61
|
+
|
|
62
|
+
if (draggingIndex === -1) return;
|
|
63
|
+
if (lastOverIndex === index) return;
|
|
64
|
+
lastOverIndex = index;
|
|
65
|
+
if (index === draggingIndex) return; // if the tag has move transition, you cannot drag over it before transition ended.
|
|
66
|
+
|
|
67
|
+
var dom = findDomFromVNode(children.value[index], true);
|
|
68
|
+
if (dom.classList.contains('k-fade-move')) return;
|
|
69
|
+
var vNodes = swap(originVNodes.value, draggingIndex, index);
|
|
70
|
+
lastOverIndex = draggingIndex;
|
|
71
|
+
draggingIndex = index;
|
|
72
|
+
originVNodes.set(vNodes);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function onEnd(e) {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
instance.trigger('dragend', {
|
|
78
|
+
key: draggingKey.value,
|
|
79
|
+
from: originIndex,
|
|
80
|
+
to: draggingIndex
|
|
81
|
+
});
|
|
82
|
+
draggingKey.set(null);
|
|
83
|
+
lastOverIndex = -1;
|
|
84
|
+
draggingIndex = -1;
|
|
85
|
+
originIndex = -1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return children;
|
|
89
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { VNode } from 'intact-react';
|
|
2
|
+
import { State } from '../../hooks/useState';
|
|
3
|
+
export declare function useNowrap(originVNodes: State<VNode[]>): {
|
|
4
|
+
containerRef: import("intact").RefObject<HTMLDivElement>;
|
|
5
|
+
children: State<VNode<import("intact").VNodeTag>[]>;
|
|
6
|
+
hiddenChildren: State<VNode<import("intact").VNodeTag>[]>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
2
|
+
import _Map from "@babel/runtime-corejs3/core-js/map";
|
|
3
|
+
import { useInstance, createRef, findDomFromVNode, onBeforeMount, nextTick } from 'intact-react';
|
|
4
|
+
import { useState, watchState } from '../../hooks/useState';
|
|
5
|
+
import { tag as tagStyles } from './styles';
|
|
6
|
+
import { getLeft, getRight } from '../../styles/utils';
|
|
7
|
+
import { useReceive } from '../../hooks/useReceive';
|
|
8
|
+
import { useResizeObserver } from '../../hooks/useResizeObserver';
|
|
9
|
+
export function useNowrap(originVNodes) {
|
|
10
|
+
var instance = useInstance();
|
|
11
|
+
var containerRef = createRef();
|
|
12
|
+
var children = useState([]);
|
|
13
|
+
var hiddenChildren = useState([]);
|
|
14
|
+
var estimateMoreElementWidth = useEstimateMoreElementWidth();
|
|
15
|
+
var offsetMap = useChildrenOffset(originVNodes);
|
|
16
|
+
watchState(originVNodes, function (v) {
|
|
17
|
+
children.set(v);
|
|
18
|
+
nextTick(refresh);
|
|
19
|
+
}); // instance.watch('children', refresh, { presented: true })
|
|
20
|
+
|
|
21
|
+
useResizeObserver(containerRef, refresh);
|
|
22
|
+
|
|
23
|
+
function refresh() {
|
|
24
|
+
if (!instance.get('nowrap')) return;
|
|
25
|
+
var container = containerRef.value;
|
|
26
|
+
var containerWidth = container.offsetWidth;
|
|
27
|
+
var vNodes = [];
|
|
28
|
+
var _originVNodes = originVNodes.value;
|
|
29
|
+
var length = _originVNodes.length;
|
|
30
|
+
|
|
31
|
+
if (_originVNodes.length > 1) {
|
|
32
|
+
_originVNodes.forEach(function (vNode, index) {
|
|
33
|
+
var offset = offsetMap.get(vNode); // estimate the "more" element's with for performance
|
|
34
|
+
|
|
35
|
+
var width = estimateMoreElementWidth(length - index - 1);
|
|
36
|
+
|
|
37
|
+
if (offset + width <= containerWidth) {
|
|
38
|
+
vNodes.push(vNode);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
vNodes.push.apply(vNodes, _originVNodes);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* refresh function will be called in ResizeObserver,
|
|
46
|
+
* state changed will cause container's width to change,
|
|
47
|
+
* and a error will throw (ResizeObserver loop completed with undelivered notifications)
|
|
48
|
+
* so we call setState in requestAnimationFrame
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
requestAnimationFrame(function () {
|
|
53
|
+
hiddenChildren.set(_sliceInstanceProperty(_originVNodes).call(_originVNodes, vNodes.length));
|
|
54
|
+
children.set(vNodes);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
containerRef: containerRef,
|
|
60
|
+
children: children,
|
|
61
|
+
hiddenChildren: hiddenChildren
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function useChildrenOffset(vNodes) {
|
|
66
|
+
var instance = useInstance();
|
|
67
|
+
var map = new _Map(); // instance.watch('children', updateMap, { presented: true })
|
|
68
|
+
|
|
69
|
+
watchState(vNodes, function () {
|
|
70
|
+
return nextTick(updateMap);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
function updateMap() {
|
|
74
|
+
map.clear();
|
|
75
|
+
if (!instance.get('nowrap')) return;
|
|
76
|
+
vNodes.value.forEach(function (vNode) {
|
|
77
|
+
var dom = findDomFromVNode(vNode, true);
|
|
78
|
+
if (!dom || dom.nodeType !== 1) return;
|
|
79
|
+
var offsetLeft = dom.offsetLeft,
|
|
80
|
+
offsetWidth = dom.offsetWidth;
|
|
81
|
+
map.set(vNode, offsetLeft + offsetWidth);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return map;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function useEstimateMoreElementWidth() {
|
|
89
|
+
var instance = useInstance();
|
|
90
|
+
var widthPerChar = 7.2;
|
|
91
|
+
var cacheWidth = 0;
|
|
92
|
+
onBeforeMount(cache);
|
|
93
|
+
useReceive(['size', 'border'], cache, true);
|
|
94
|
+
|
|
95
|
+
function cache() {
|
|
96
|
+
var _instance$get = instance.get(),
|
|
97
|
+
size = _instance$get.size,
|
|
98
|
+
border = _instance$get.border;
|
|
99
|
+
|
|
100
|
+
cacheWidth = parseInt(tagStyles.tags.gap) + widthPerChar
|
|
101
|
+
/* the "+" mark */
|
|
102
|
+
;
|
|
103
|
+
|
|
104
|
+
if (border !== 'none') {
|
|
105
|
+
cacheWidth += 2;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
var padding = size === 'default' ? tagStyles.padding : tagStyles[size].padding;
|
|
109
|
+
cacheWidth += parseInt(getLeft(padding)) + parseInt(getRight(padding));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return function (count) {
|
|
113
|
+
return Math.round(count.toString().length * widthPerChar + cacheWidth);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -100,7 +100,7 @@ describe('Timepicker', function () {
|
|
|
100
100
|
case 45:
|
|
101
101
|
expect(instance.get('timeArray')).to.eql(['01:00:00', '02:00:00']); // remove one value
|
|
102
102
|
|
|
103
|
-
_picker2$querySelecto = picker2.querySelectorAll('.k-
|
|
103
|
+
_picker2$querySelecto = picker2.querySelectorAll('.k-tag-close'), close = _picker2$querySelecto[1];
|
|
104
104
|
close.click();
|
|
105
105
|
_context2.next = 50;
|
|
106
106
|
return wait();
|
|
@@ -55,9 +55,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
55
55
|
'className': 'k-tip-close',
|
|
56
56
|
'children': (_$blocks['close'] = function ($super) {
|
|
57
57
|
return _$cc(Icon, {
|
|
58
|
-
'className': '
|
|
59
|
-
'size': 'large',
|
|
60
|
-
'color': type,
|
|
58
|
+
'className': 'k-icon-close',
|
|
61
59
|
'hoverable': !disabled
|
|
62
60
|
});
|
|
63
61
|
}, __$blocks['close'] = function ($super, data) {
|
package/components/tip/styles.js
CHANGED
|
@@ -5,11 +5,12 @@ import { deepDefaults } from '../../styles/utils';
|
|
|
5
5
|
var defaults = {
|
|
6
6
|
title: {
|
|
7
7
|
fontSize: '14px',
|
|
8
|
-
gap: '8px'
|
|
8
|
+
gap: '8px',
|
|
9
|
+
fontWeight: '500'
|
|
9
10
|
},
|
|
10
11
|
|
|
11
12
|
get color() {
|
|
12
|
-
return theme.color.
|
|
13
|
+
return theme.color.title;
|
|
13
14
|
},
|
|
14
15
|
|
|
15
16
|
get padding() {
|
|
@@ -24,5 +25,5 @@ setDefault(function () {
|
|
|
24
25
|
}).tip;
|
|
25
26
|
});
|
|
26
27
|
export function makeStyles() {
|
|
27
|
-
return /*#__PURE__*/css("&.k-tip{display:flex;height:auto;padding:0;color:", tip.color, "!important;align-items:flex-start;}.k-tip-wrapper{flex:1;padding:", tip.padding, ";}.k-tip-title{font-size:", tip.title.fontSize, ";margin-bottom:", tip.title.gap, ";}&.k-fade-leave-active{position:relative;}");
|
|
28
|
+
return /*#__PURE__*/css("&.k-tip{display:flex;height:auto;padding:0;color:", tip.color, "!important;align-items:flex-start;}.k-tip-wrapper{flex:1;padding:", tip.padding, ";}.k-tip-title{font-size:", tip.title.fontSize, ";margin-bottom:", tip.title.gap, ";font-weight:", tip.title.fontWeight, ";}&.k-fade-leave-active{position:relative;}.k-tip-close:hover{background:none;}");
|
|
28
29
|
}
|
|
@@ -6,9 +6,9 @@ export interface TooltipContentEvents extends DropdownMenuEvents {
|
|
|
6
6
|
export interface TooltipContentBlocks extends DropdownMenuBlocks {
|
|
7
7
|
buttons: null;
|
|
8
8
|
}
|
|
9
|
-
export declare class TooltipContent extends
|
|
9
|
+
export declare class TooltipContent<T extends TooltipContentProps = TooltipContentProps, E extends TooltipContentEvents = TooltipContentEvents, B extends TooltipContentBlocks = TooltipContentBlocks> extends DropdownMenu<T, E, B> {
|
|
10
10
|
static template: string | import('intact-react').Template<any>;
|
|
11
|
-
|
|
11
|
+
protected isEmptyChildren: boolean;
|
|
12
12
|
private arrow;
|
|
13
13
|
init(): void;
|
|
14
14
|
private onEnter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { superCall as _$su, className as _$cn, extend as _$ex, EMPTY_OBJ as _$em,
|
|
1
|
+
import { superCall as _$su, className as _$cn, extend as _$ex, EMPTY_OBJ as _$em, noop as _$no, createElementVNode as _$ce, createUnknownComponentVNode as _$cc } from 'intact-react';
|
|
2
2
|
import { Button } from '../button';
|
|
3
3
|
import makeStyles from './styles';
|
|
4
4
|
export default function ($props, $blocks, $__proto__) {
|
|
@@ -33,7 +33,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
33
33
|
'k-tooltip-content': true,
|
|
34
34
|
'k-hoverable': hoverable || trigger === 'click',
|
|
35
35
|
'k-always': always
|
|
36
|
-
}, _classNameObj["k-" + theme] = true, _classNameObj["k-" + size] = size !== 'default', _classNameObj[className] = className, _classNameObj[makeStyles()] = true, _classNameObj);
|
|
36
|
+
}, _classNameObj["k-" + theme] = true, _classNameObj["k-" + size] = size !== 'default', _classNameObj[className] = className, _classNameObj[makeStyles()] = true, _classNameObj[$props.className] = $props.className, _classNameObj);
|
|
37
37
|
return _$su.call($this, {
|
|
38
38
|
'value': !!value && !this.isEmptyChildren,
|
|
39
39
|
'transition': {
|
|
@@ -50,28 +50,38 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
50
50
|
return (_$blocks['children'] = function ($super) {
|
|
51
51
|
var _$cn2;
|
|
52
52
|
|
|
53
|
-
return [
|
|
54
|
-
|
|
55
|
-
},
|
|
53
|
+
return [(_$blocks['body'] = function ($super) {
|
|
54
|
+
return children;
|
|
55
|
+
}, __$blocks['body'] = function ($super, data) {
|
|
56
|
+
var block = $blocks['body'];
|
|
57
|
+
|
|
58
|
+
var callBlock = function callBlock() {
|
|
59
|
+
return _$blocks['body'].call($this, $super, data);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return block ? block.call($this, callBlock, data) : callBlock();
|
|
63
|
+
}, __$blocks['body'](_$no)), confirm ? _$ce(2, 'div', (_$blocks['footer'] = function ($super) {
|
|
56
64
|
return [_$cc(Button, {
|
|
65
|
+
'ev-click': this.cancel,
|
|
66
|
+
'size': 'small',
|
|
67
|
+
'children': cancelText
|
|
68
|
+
}), _$cc(Button, {
|
|
57
69
|
'type': 'primary',
|
|
58
70
|
'ev-click': this.ok,
|
|
59
71
|
'size': 'small',
|
|
60
72
|
'children': okText
|
|
61
|
-
}), _$cc(Button, {
|
|
62
|
-
'ev-click': this.cancel,
|
|
63
|
-
'size': 'small',
|
|
64
|
-
'children': cancelText
|
|
65
73
|
})];
|
|
66
|
-
}, __$blocks['
|
|
67
|
-
var block = $blocks['
|
|
74
|
+
}, __$blocks['footer'] = function ($super, data) {
|
|
75
|
+
var block = $blocks['footer'];
|
|
68
76
|
|
|
69
77
|
var callBlock = function callBlock() {
|
|
70
|
-
return _$blocks['
|
|
78
|
+
return _$blocks['footer'].call($this, $super, data);
|
|
71
79
|
};
|
|
72
80
|
|
|
73
81
|
return block ? block.call($this, callBlock, data) : callBlock();
|
|
74
|
-
}, __$blocks['
|
|
82
|
+
}, __$blocks['footer'](_$no)), 0, 'k-tooltip-footer', null, 'tooltip-footer') : undefined, showArrow ? _$ce(2, 'i', null, 1, _$cn((_$cn2 = {
|
|
83
|
+
"k-tooltip-arrow": true
|
|
84
|
+
}, _$cn2["k-" + arrowType.value] = arrowType.value, _$cn2)), null, 'tooltip-arrow', arrowRef) : undefined];
|
|
75
85
|
}, __$blocks['children'] = function ($super, data) {
|
|
76
86
|
var block = $blocks['children'];
|
|
77
87
|
|