@king-design/vue 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__/Vue Next Demos.md +441 -313
- package/__tests__/index.ts +4 -4
- 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
|
@@ -9,6 +9,7 @@ var defaults = {
|
|
|
9
9
|
},
|
|
10
10
|
|
|
11
11
|
top: "10px",
|
|
12
|
+
left: "0px",
|
|
12
13
|
transform: "translateY(-10px)",
|
|
13
14
|
|
|
14
15
|
get bgColor() {
|
|
@@ -22,11 +23,10 @@ var defaults = {
|
|
|
22
23
|
gap: "10px",
|
|
23
24
|
boxShadow: 'none',
|
|
24
25
|
padding: "7px 33px 8px 8px",
|
|
25
|
-
closeFontSize: "26px",
|
|
26
26
|
fontSize: '12px',
|
|
27
27
|
|
|
28
28
|
get color() {
|
|
29
|
-
return theme.color.
|
|
29
|
+
return theme.color.text;
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
minWidth: '400px',
|
|
@@ -39,10 +39,10 @@ var defaults = {
|
|
|
39
39
|
},
|
|
40
40
|
|
|
41
41
|
icon: {
|
|
42
|
-
color:
|
|
43
|
-
fontSize: "
|
|
42
|
+
// color: `inherit`,
|
|
43
|
+
fontSize: "18px",
|
|
44
44
|
left: "16px",
|
|
45
|
-
top: "
|
|
45
|
+
top: "7px"
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
var message;
|
|
@@ -52,13 +52,13 @@ setDefault(function () {
|
|
|
52
52
|
}).message;
|
|
53
53
|
});
|
|
54
54
|
export function makeMessagesStyles() {
|
|
55
|
-
return /*#__PURE__*/css("position:fixed;top:", message.top, ";width:100%;pointer-events:none;z-index:", theme.maxZIndex + 1, ";");
|
|
55
|
+
return /*#__PURE__*/css("position:fixed;top:", message.top, ";left:", message.left, ";width:100%;pointer-events:none;z-index:", theme.maxZIndex + 1, ";");
|
|
56
56
|
}
|
|
57
57
|
export function makeMessageStyles() {
|
|
58
58
|
var _context;
|
|
59
59
|
|
|
60
|
-
return /*#__PURE__*/css("text-align:center;width:100%;font-size:", message.fontSize, ";color:", message.color, ";.k-message-container{display:inline-block;box-shadow:", message.boxShadow, ";
|
|
60
|
+
return /*#__PURE__*/css("text-align:center;width:100%;font-size:", message.fontSize, ";color:", message.color, ";.k-message-container{display:inline-block;box-shadow:", message.boxShadow, ";border-radius:", message.borderRadius, ";margin-bottom:", message.gap, ";pointer-events:all;min-width:", message.minWidth, ";max-width:", message.maxWidth, ";position:relative;text-align:", message.textAlign, ";min-height:", message.minHeight, ";}.k-message-wrapper{position:relative;display:inline-block;&.k-with-icon{padding-left:calc(", message.icon.left, " + 14px);}}.k-message-content{display:inline-block;padding:", message.padding, ";vertical-align:middle;word-break:break-word;word-wrap:break-word;}.k-message-close{vertical-align:middle;position:absolute;right:0;top:0;&:hover{background:none;}}.k-message-icon{position:absolute;left:", message.icon.left, ";top:", message.icon.top, ";font-size:", message.icon.fontSize, ";}", _mapInstanceProperty(_context = ['info', 'error', 'success', 'warning']).call(_context, function (type) {
|
|
61
61
|
var color = theme.color[type === 'error' ? 'danger' : type];
|
|
62
|
-
return /*#__PURE__*/css("&.k-", type, "{.k-message-container{
|
|
62
|
+
return /*#__PURE__*/css("&.k-", type, "{.k-message-container{background:", palette(color, -4), ";}.k-message-icon{color:", color, ";}}");
|
|
63
63
|
}), "&.transition-enter-from,&.transition-leave-to{opacity:0;transform:", message.transform, ";}&.transition-enter-active,&.transition-leave-active{transition:transform ", message.transition, ",opacity ", message.transition, ";}&.transition-move{transition:transform ", message.transition, ";}");
|
|
64
64
|
}
|
|
@@ -6,11 +6,13 @@ import BasicDemo from '~/components/pagination/demos/basic';
|
|
|
6
6
|
import GotoDemo from '~/components/pagination/demos/goto';
|
|
7
7
|
import CurrentDemo from '~/components/pagination/demos/current';
|
|
8
8
|
import DisableDemo from '~/components/pagination/demos/disable';
|
|
9
|
-
import { mount, dispatchEvent, wait } from '../../test/utils';
|
|
9
|
+
import { mount, unmount, dispatchEvent, wait } from '../../test/utils';
|
|
10
10
|
import { Component } from 'intact-vue-next';
|
|
11
11
|
import { Pagination } from '.';
|
|
12
12
|
describe('Pagination', function () {
|
|
13
|
-
|
|
13
|
+
afterEach(function () {
|
|
14
|
+
return unmount();
|
|
15
|
+
});
|
|
14
16
|
it('basic test', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
15
17
|
var _mount, instance, element, pagination, btns, prev, next;
|
|
16
18
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _flatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/flat";
|
|
2
3
|
import { createCommentVNode as _$ccv, createUnknownComponentVNode as _$cc, createElementVNode as _$ce, createTextVNode as _$ct, createVNode as _$cv, className as _$cn, map as _$ma } from 'intact-vue-next';
|
|
3
4
|
import { getRestProps, mapChildren } from '../utils';
|
|
4
5
|
import { ButtonGroup, Button } from '../button';
|
|
@@ -8,10 +9,10 @@ import { Icon } from '../icon';
|
|
|
8
9
|
import { _$ } from '../../i18n';
|
|
9
10
|
import { makeStyles } from './styles';
|
|
10
11
|
var _$tmp0 = {
|
|
11
|
-
'className': '
|
|
12
|
+
'className': 'k-icon-arrow-left'
|
|
12
13
|
};
|
|
13
14
|
var _$tmp1 = {
|
|
14
|
-
'className': '
|
|
15
|
+
'className': 'k-icon-arrow-right'
|
|
15
16
|
};
|
|
16
17
|
export default function ($props, $blocks, $__proto__) {
|
|
17
18
|
var _classNameObj;
|
|
@@ -23,7 +24,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
23
24
|
var _this$get = this.get(),
|
|
24
25
|
total = _this$get.total,
|
|
25
26
|
size = _this$get.size,
|
|
26
|
-
|
|
27
|
+
flat = _flatInstanceProperty(_this$get),
|
|
27
28
|
simple = _this$get.simple,
|
|
28
29
|
className = _this$get.className,
|
|
29
30
|
showTotal = _this$get.showTotal,
|
|
@@ -39,13 +40,8 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
39
40
|
if (!total) return _$ccv(' pagination ');
|
|
40
41
|
var classNameObj = (_classNameObj = {
|
|
41
42
|
'k-pagination': true
|
|
42
|
-
}, _classNameObj[className] = className, _classNameObj["k-" + size] = size !== 'default', _classNameObj['k-
|
|
43
|
-
var type = 'default';
|
|
44
|
-
|
|
45
|
-
if (noBorder || simple) {
|
|
46
|
-
type = 'none';
|
|
47
|
-
}
|
|
48
|
-
|
|
43
|
+
}, _classNameObj[className] = className, _classNameObj["k-" + size] = size !== 'default', _classNameObj['k-flat'] = flat, _classNameObj['k-simple'] = simple, _classNameObj[makeStyles()] = true, _classNameObj);
|
|
44
|
+
var type = flat ? 'flat' : simple ? 'none' : 'default';
|
|
49
45
|
var totalPages = Math.ceil(total / limit) || 0;
|
|
50
46
|
|
|
51
47
|
var paginationButton = function paginationButton(page) {
|
|
@@ -140,19 +136,21 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
140
136
|
|
|
141
137
|
return _$cv('div', _extends({
|
|
142
138
|
'className': _$cn(classNameObj)
|
|
143
|
-
}, getRestProps(this)), [_$
|
|
139
|
+
}, getRestProps(this)), [showTotal && !simple ? _$ce(2, 'div', _$('共 {n} 条', {
|
|
140
|
+
n: total
|
|
141
|
+
}), 0, 'k-pagination-total') : undefined, _$cc(ButtonGroup, {
|
|
144
142
|
'checkType': 'radio',
|
|
145
143
|
'children': [_$cc(Button, {
|
|
146
144
|
'icon': true,
|
|
147
145
|
'size': size,
|
|
148
|
-
'type':
|
|
146
|
+
'type': 'none',
|
|
149
147
|
'disabled': value <= 1 || !!(disablePage && disablePage(value - 1, limit)),
|
|
150
148
|
'ev-click': this.prev,
|
|
151
149
|
'children': _$cc(Icon, _$tmp0)
|
|
152
150
|
}), paginationItems, _$cc(Button, {
|
|
153
151
|
'icon': true,
|
|
154
152
|
'size': size,
|
|
155
|
-
'type':
|
|
153
|
+
'type': 'none',
|
|
156
154
|
'disabled': value >= totalPages || !!(disablePage && disablePage(value + 1, limit)),
|
|
157
155
|
'ev-click': this.next,
|
|
158
156
|
'children': _$cc(Icon, _$tmp1)
|
|
@@ -163,6 +161,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
163
161
|
'value': $this.get('value')
|
|
164
162
|
}), !simple ? [showLimits ? _$ce(2, 'div', _$cc(Select, {
|
|
165
163
|
'size': size,
|
|
164
|
+
'flat': flat,
|
|
166
165
|
'children': _$ma(limits, function ($value, $key) {
|
|
167
166
|
return _$cc(Option, {
|
|
168
167
|
'value': $value,
|
|
@@ -175,12 +174,11 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
175
174
|
$this.set('limit', $v);
|
|
176
175
|
},
|
|
177
176
|
'value': $this.get('limit')
|
|
178
|
-
}), 2, 'k-pagination-limits') : undefined, showGoto ? _$ce(2, 'div', [_$ce(2, 'span', _$('
|
|
177
|
+
}), 2, 'k-pagination-limits') : undefined, showGoto ? _$ce(2, 'div', [_$ce(2, 'span', _$('前往'), 0, 'c-middle'), _$cc(Input, {
|
|
179
178
|
'size': size,
|
|
180
179
|
'value': value,
|
|
181
|
-
'ev-change': this.goto
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}), 0, 'k-pagination-total') : undefined] : undefined]);
|
|
180
|
+
'ev-change': this.goto,
|
|
181
|
+
'flat': flat
|
|
182
|
+
}), _$ce(2, 'span', _$('页'), 0, 'c-middle')], 4, 'k-pagination-goto') : undefined] : undefined]);
|
|
185
183
|
}
|
|
186
184
|
;
|
|
@@ -23,7 +23,16 @@ var defaults = deepDefaults({
|
|
|
23
23
|
gap: '16px',
|
|
24
24
|
btn: {
|
|
25
25
|
gap: '6px',
|
|
26
|
-
padding: '0 3px'
|
|
26
|
+
padding: '0 3px',
|
|
27
|
+
|
|
28
|
+
get borderRadius() {
|
|
29
|
+
return theme.borderRadius;
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
get hoverBgColor() {
|
|
33
|
+
return theme.color.hoverBg;
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
},
|
|
28
37
|
// goto
|
|
29
38
|
goto: {
|
|
@@ -55,9 +64,9 @@ setDefault(function () {
|
|
|
55
64
|
}).pagination;
|
|
56
65
|
});
|
|
57
66
|
export function makeStyles() {
|
|
58
|
-
return /*#__PURE__*/css("font-size:", pagination.fontSize, "
|
|
67
|
+
return /*#__PURE__*/css("font-size:", pagination.fontSize, ";>*{display:inline-block;vertical-align:middle;&:not(:first-child){margin-left:", pagination.gap, ";}}.k-pagination-ellipsis{background-color:transparent;border-color:transparent;}.k-btns{.k-btn{width:auto!important;min-width:", button.height, ";padding:", pagination.btn.padding, ";margin-right:", pagination.btn.gap, ";border-radius:", pagination.btn.borderRadius, "!important;&:last-of-type{margin:0!important;}&:hover{background:", pagination.btn.hoverBgColor, ";}}.k-icon{font-size:18px;}}.k-pagination-goto{.k-input{font-size:inherit;width:", pagination.goto.width, ";margin:", pagination.goto.gap, ";}.k-input-inner{text-align:center;}}.k-select{width:auto;}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
59
68
|
var styles = pagination[size];
|
|
60
69
|
var btnStyles = button[size];
|
|
61
70
|
return /*#__PURE__*/css("&.k-", size, "{font-size:", styles.fontSize, ";.k-btn{margin-right:", styles.btnGap, ";min-width:", btnStyles.height, ";.k-icon{font-size:", styles.iconFontSize, ";}}}");
|
|
62
|
-
}), "&.k-
|
|
71
|
+
}), "&.k-flat{.k-select{&,&:hover,&.k-show{border-color:transparent;}}}&.k-simple{.k-btn{margin:0;}.k-input-inner{text-align:center;}.k-pagination-text{vertical-align:middle;}}");
|
|
63
72
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TooltipContent, TooltipContentProps, TooltipContentEvents, TooltipContentBlocks } from "../tooltip/content";
|
|
2
|
+
import { TypeDefs, Children } from 'intact-vue-next';
|
|
3
|
+
export interface PopoverContentProps extends TooltipContentProps {
|
|
4
|
+
type?: 'info' | 'success' | 'warning' | 'error';
|
|
5
|
+
title?: Children;
|
|
6
|
+
content?: Children;
|
|
7
|
+
}
|
|
8
|
+
export interface PopoverContentEvents extends TooltipContentEvents {
|
|
9
|
+
}
|
|
10
|
+
export interface PopoverContentBlocks extends TooltipContentBlocks {
|
|
11
|
+
title: null;
|
|
12
|
+
content: null;
|
|
13
|
+
footer: null;
|
|
14
|
+
}
|
|
15
|
+
export declare class PopoverContent extends TooltipContent<PopoverContentProps, PopoverContentEvents, PopoverContentBlocks> {
|
|
16
|
+
static template: string | import("intact").Template<any>;
|
|
17
|
+
static typeDefs: Required<TypeDefs<PopoverContentProps>>;
|
|
18
|
+
protected isEmptyChildren: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
|
+
import { TooltipContent } from "../tooltip/content";
|
|
4
|
+
import { VNode } from 'intact-vue-next';
|
|
5
|
+
import template from "./content.vdt";
|
|
6
|
+
var typeDefs = {
|
|
7
|
+
type: ['info', 'error', 'success', 'warning'],
|
|
8
|
+
title: [String, Number, VNode, Array],
|
|
9
|
+
content: [String, Number, VNode, Array]
|
|
10
|
+
};
|
|
11
|
+
export var PopoverContent = /*#__PURE__*/function (_TooltipContent) {
|
|
12
|
+
_inheritsLoose(PopoverContent, _TooltipContent);
|
|
13
|
+
|
|
14
|
+
function PopoverContent() {
|
|
15
|
+
var _context;
|
|
16
|
+
|
|
17
|
+
var _this;
|
|
18
|
+
|
|
19
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
+
args[_key] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_this = _TooltipContent.call.apply(_TooltipContent, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
24
|
+
_this.isEmptyChildren = false;
|
|
25
|
+
return _this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return PopoverContent;
|
|
29
|
+
}(TooltipContent);
|
|
30
|
+
PopoverContent.template = template;
|
|
31
|
+
PopoverContent.typeDefs = typeDefs;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { superCall as _$su, className as _$cn, extend as _$ex, EMPTY_OBJ as _$em, createElementVNode as _$ce, createUnknownComponentVNode as _$cc, noop as _$no } from 'intact-vue-next';
|
|
2
|
+
import { Icon } from '../icon';
|
|
3
|
+
import makeStyles from "./styles";
|
|
4
|
+
export default function ($props, $blocks, $__proto__) {
|
|
5
|
+
var _classNameObj;
|
|
6
|
+
|
|
7
|
+
$blocks || ($blocks = {});
|
|
8
|
+
$props || ($props = {});
|
|
9
|
+
var $this = this;
|
|
10
|
+
var _$blocks = {};
|
|
11
|
+
var __$blocks = {};
|
|
12
|
+
|
|
13
|
+
var _this$get = this.get(),
|
|
14
|
+
type = _this$get.type,
|
|
15
|
+
title = _this$get.title,
|
|
16
|
+
content = _this$get.content;
|
|
17
|
+
|
|
18
|
+
var iconMap = {
|
|
19
|
+
info: 'information-fill',
|
|
20
|
+
warning: 'warning-fill',
|
|
21
|
+
success: 'success-fill',
|
|
22
|
+
error: 'error-fill'
|
|
23
|
+
};
|
|
24
|
+
var classNameObj = (_classNameObj = {}, _classNameObj[makeStyles()] = true, _classNameObj['k-popover'] = true, _classNameObj);
|
|
25
|
+
return _$su.call($this, {
|
|
26
|
+
'className': _$cn(classNameObj)
|
|
27
|
+
}, function ($blocks) {
|
|
28
|
+
var _$blocks = {},
|
|
29
|
+
__$blocks = _$ex({}, $blocks);
|
|
30
|
+
|
|
31
|
+
return (_$blocks['body'] = function ($super) {
|
|
32
|
+
return [title || $blocks.title ? _$ce(2, 'div', [type ? _$cc(Icon, {
|
|
33
|
+
'className': _$cn("k-icon-" + iconMap[type] + " k-popover-icon"),
|
|
34
|
+
'color': type === 'error' ? 'danger' : type,
|
|
35
|
+
'size': 'large'
|
|
36
|
+
}) : undefined, (_$blocks['title'] = function ($super) {
|
|
37
|
+
return title;
|
|
38
|
+
}, __$blocks['title'] = function ($super, data) {
|
|
39
|
+
var block = $blocks['title'];
|
|
40
|
+
|
|
41
|
+
var callBlock = function callBlock() {
|
|
42
|
+
return _$blocks['title'].call($this, $super, data);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return block ? block.call($this, callBlock, data) : callBlock();
|
|
46
|
+
}, __$blocks['title'](_$no))], 0, 'k-popover-title') : undefined, content || $blocks.content ? _$ce(2, 'div', (_$blocks['content'] = function ($super) {
|
|
47
|
+
return content;
|
|
48
|
+
}, __$blocks['content'] = function ($super, data) {
|
|
49
|
+
var block = $blocks['content'];
|
|
50
|
+
|
|
51
|
+
var callBlock = function callBlock() {
|
|
52
|
+
return _$blocks['content'].call($this, $super, data);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return block ? block.call($this, callBlock, data) : callBlock();
|
|
56
|
+
}, __$blocks['content'](_$no)), 0, 'k-popover-content') : undefined];
|
|
57
|
+
}, __$blocks['body'] = function ($super, data) {
|
|
58
|
+
var block = $blocks['body'];
|
|
59
|
+
|
|
60
|
+
var callBlock = function callBlock() {
|
|
61
|
+
return _$blocks['body'].call($this, $super, data);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return block ? block.call($this, callBlock, data) : callBlock();
|
|
65
|
+
}), __$blocks;
|
|
66
|
+
}.call($this, $blocks), $__proto__);
|
|
67
|
+
}
|
|
68
|
+
;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Tooltip } from "../tooltip/tooltip";
|
|
2
|
+
import { TooltipProps, TooltipEvents, TooltipBlocks } from "../tooltip/tooltip";
|
|
3
|
+
import { PopoverContentProps, PopoverContentBlocks } from './content';
|
|
4
|
+
export interface PopoverProps extends TooltipProps, PopoverContentProps {
|
|
5
|
+
confirm?: never;
|
|
6
|
+
theme?: never;
|
|
7
|
+
hoverable?: never;
|
|
8
|
+
trigger?: never;
|
|
9
|
+
}
|
|
10
|
+
export interface PopoverEvents extends TooltipEvents {
|
|
11
|
+
}
|
|
12
|
+
export interface PopoverBlocks extends TooltipBlocks, PopoverContentBlocks {
|
|
13
|
+
}
|
|
14
|
+
export declare class _Popover extends Tooltip<PopoverProps, PopoverEvents, PopoverBlocks> {
|
|
15
|
+
}
|
|
16
|
+
export declare const Popover: typeof _Popover;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime-corejs3/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["children", "type", "title", "content", "$blocks"];
|
|
4
|
+
import { createVNode as h, Component } from 'intact-vue-next';
|
|
5
|
+
import { Tooltip } from "../tooltip/tooltip";
|
|
6
|
+
import { PopoverContent } from './content';
|
|
7
|
+
import { noop } from 'intact-shared';
|
|
8
|
+
|
|
9
|
+
function Wrapper(props) {
|
|
10
|
+
var children = props.children,
|
|
11
|
+
type = props.type,
|
|
12
|
+
title = props.title,
|
|
13
|
+
content = props.content,
|
|
14
|
+
$blocks = props.$blocks,
|
|
15
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
16
|
+
|
|
17
|
+
if ($blocks) {
|
|
18
|
+
if ($blocks.title) {
|
|
19
|
+
title = $blocks.title(noop);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if ($blocks.content) {
|
|
23
|
+
content = $blocks.content(noop);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var contentVNode = h(PopoverContent, {
|
|
28
|
+
type: type,
|
|
29
|
+
title: title,
|
|
30
|
+
content: content,
|
|
31
|
+
$blocks: $blocks
|
|
32
|
+
});
|
|
33
|
+
return h(Tooltip, _extends({
|
|
34
|
+
children: [children, contentVNode]
|
|
35
|
+
}, rest, {
|
|
36
|
+
confirm: true,
|
|
37
|
+
theme: 'light',
|
|
38
|
+
hoverable: true,
|
|
39
|
+
trigger: 'click'
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var functionalWrapper = Component.functionalWrapper;
|
|
44
|
+
export var Popover = functionalWrapper ? functionalWrapper(Wrapper) : Wrapper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
|
+
import _Array$from2 from "@babel/runtime-corejs3/core-js/array/from";
|
|
4
|
+
import BasicDemo from '~/components/popover/demos/basic';
|
|
5
|
+
import ContentDemo from '~/components/popover/demos/content';
|
|
6
|
+
import ButtonDemo from '~/components/popover/demos/button';
|
|
7
|
+
import TextDemo from '~/components/popover/demos/text';
|
|
8
|
+
import TypeDemo from '~/components/popover/demos/type';
|
|
9
|
+
import { mount, unmount, dispatchEvent, getElement, wait } from '../../test/utils';
|
|
10
|
+
describe("Popover", function () {
|
|
11
|
+
afterEach(function (done) {
|
|
12
|
+
unmount();
|
|
13
|
+
setTimeout(done, 500);
|
|
14
|
+
});
|
|
15
|
+
it('should handle popover correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
16
|
+
var _mount, instance, element, cancelCb, okCb, content, _Array$from, btn;
|
|
17
|
+
|
|
18
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19
|
+
while (1) {
|
|
20
|
+
switch (_context.prev = _context.next) {
|
|
21
|
+
case 0:
|
|
22
|
+
_mount = mount(BasicDemo), instance = _mount[0], element = _mount[1];
|
|
23
|
+
cancelCb = sinon.spy();
|
|
24
|
+
okCb = sinon.spy();
|
|
25
|
+
instance.refs.popover1.on('cancel', cancelCb);
|
|
26
|
+
instance.refs.popover1.on('ok', okCb);
|
|
27
|
+
dispatchEvent(element.children[0], 'click');
|
|
28
|
+
_context.next = 8;
|
|
29
|
+
return wait();
|
|
30
|
+
|
|
31
|
+
case 8:
|
|
32
|
+
content = getElement('.k-tooltip-content');
|
|
33
|
+
expect(content.innerHTML).to.matchSnapshot();
|
|
34
|
+
content.querySelector('.k-btn').click();
|
|
35
|
+
_context.next = 13;
|
|
36
|
+
return wait(500);
|
|
37
|
+
|
|
38
|
+
case 13:
|
|
39
|
+
expect(content.style.display).eql('none');
|
|
40
|
+
dispatchEvent(element.firstElementChild, 'click');
|
|
41
|
+
_context.next = 17;
|
|
42
|
+
return wait();
|
|
43
|
+
|
|
44
|
+
case 17:
|
|
45
|
+
content = getElement('.k-tooltip-content');
|
|
46
|
+
_Array$from = _Array$from2(content.querySelectorAll('.k-btn')), btn = _Array$from[1];
|
|
47
|
+
btn.click();
|
|
48
|
+
_context.next = 22;
|
|
49
|
+
return wait(500);
|
|
50
|
+
|
|
51
|
+
case 22:
|
|
52
|
+
expect(content.style.display).eql('none');
|
|
53
|
+
expect(cancelCb.callCount).eql(1);
|
|
54
|
+
expect(okCb.callCount).eql(1);
|
|
55
|
+
|
|
56
|
+
case 25:
|
|
57
|
+
case "end":
|
|
58
|
+
return _context.stop();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, _callee);
|
|
62
|
+
})));
|
|
63
|
+
it('should handle type correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
64
|
+
var _mount2, instance, element, _element$querySelecto, info, success, error, warning, test;
|
|
65
|
+
|
|
66
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
67
|
+
while (1) {
|
|
68
|
+
switch (_context3.prev = _context3.next) {
|
|
69
|
+
case 0:
|
|
70
|
+
_mount2 = mount(TypeDemo), instance = _mount2[0], element = _mount2[1];
|
|
71
|
+
_element$querySelecto = element.querySelectorAll('.k-btn'), info = _element$querySelecto[0], success = _element$querySelecto[1], error = _element$querySelecto[2], warning = _element$querySelecto[3];
|
|
72
|
+
|
|
73
|
+
test = /*#__PURE__*/function () {
|
|
74
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(element, className) {
|
|
75
|
+
var content;
|
|
76
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
77
|
+
while (1) {
|
|
78
|
+
switch (_context2.prev = _context2.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
element.click();
|
|
81
|
+
_context2.next = 3;
|
|
82
|
+
return wait();
|
|
83
|
+
|
|
84
|
+
case 3:
|
|
85
|
+
content = getElement('.k-tooltip-content');
|
|
86
|
+
expect(content.querySelector('.k-popover-icon').classList.contains(className)).eql(true);
|
|
87
|
+
|
|
88
|
+
case 5:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context2.stop();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, _callee2);
|
|
94
|
+
}));
|
|
95
|
+
|
|
96
|
+
return function test(_x, _x2) {
|
|
97
|
+
return _ref3.apply(this, arguments);
|
|
98
|
+
};
|
|
99
|
+
}();
|
|
100
|
+
|
|
101
|
+
_context3.next = 5;
|
|
102
|
+
return test(info, 'k-icon-information-fill');
|
|
103
|
+
|
|
104
|
+
case 5:
|
|
105
|
+
_context3.next = 7;
|
|
106
|
+
return test(success, 'k-icon-success-fill');
|
|
107
|
+
|
|
108
|
+
case 7:
|
|
109
|
+
_context3.next = 9;
|
|
110
|
+
return test(error, 'k-icon-error-fill');
|
|
111
|
+
|
|
112
|
+
case 9:
|
|
113
|
+
_context3.next = 11;
|
|
114
|
+
return test(warning, 'k-icon-warning-fill');
|
|
115
|
+
|
|
116
|
+
case 11:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context3.stop();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, _callee3);
|
|
122
|
+
})));
|
|
123
|
+
it('should handle title/content slot correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
124
|
+
var _mount3, instance, element, content;
|
|
125
|
+
|
|
126
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
127
|
+
while (1) {
|
|
128
|
+
switch (_context4.prev = _context4.next) {
|
|
129
|
+
case 0:
|
|
130
|
+
_mount3 = mount(ContentDemo), instance = _mount3[0], element = _mount3[1];
|
|
131
|
+
dispatchEvent(element.children[0], 'click');
|
|
132
|
+
_context4.next = 4;
|
|
133
|
+
return wait();
|
|
134
|
+
|
|
135
|
+
case 4:
|
|
136
|
+
content = getElement('.k-tooltip-content');
|
|
137
|
+
expect(content.querySelector('.k-popover-title')).to.matchSnapshot();
|
|
138
|
+
expect(content.querySelector('.k-popover-content')).to.matchSnapshot();
|
|
139
|
+
|
|
140
|
+
case 7:
|
|
141
|
+
case "end":
|
|
142
|
+
return _context4.stop();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}, _callee4);
|
|
146
|
+
})));
|
|
147
|
+
it('should handle text props correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
148
|
+
var _mount4, instance, element, content, btns;
|
|
149
|
+
|
|
150
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
151
|
+
while (1) {
|
|
152
|
+
switch (_context5.prev = _context5.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
_mount4 = mount(TextDemo), instance = _mount4[0], element = _mount4[1];
|
|
155
|
+
dispatchEvent(element.children[0], 'click');
|
|
156
|
+
_context5.next = 4;
|
|
157
|
+
return wait();
|
|
158
|
+
|
|
159
|
+
case 4:
|
|
160
|
+
content = getElement('.k-tooltip-content');
|
|
161
|
+
btns = content.querySelectorAll('.k-btn');
|
|
162
|
+
expect(btns[0].textContent).eql('cancel');
|
|
163
|
+
expect(btns[1].textContent).eql('confirm');
|
|
164
|
+
|
|
165
|
+
case 8:
|
|
166
|
+
case "end":
|
|
167
|
+
return _context5.stop();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}, _callee5);
|
|
171
|
+
})));
|
|
172
|
+
it('should handle footer slot correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
173
|
+
var _mount5, instance, element, content;
|
|
174
|
+
|
|
175
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
176
|
+
while (1) {
|
|
177
|
+
switch (_context6.prev = _context6.next) {
|
|
178
|
+
case 0:
|
|
179
|
+
_mount5 = mount(ButtonDemo), instance = _mount5[0], element = _mount5[1];
|
|
180
|
+
dispatchEvent(element.children[0], 'click');
|
|
181
|
+
_context6.next = 4;
|
|
182
|
+
return wait();
|
|
183
|
+
|
|
184
|
+
case 4:
|
|
185
|
+
content = getElement('.k-tooltip-content');
|
|
186
|
+
expect(content.querySelector('.k-tooltip-footer').outerHTML).to.matchSnapshot();
|
|
187
|
+
|
|
188
|
+
case 6:
|
|
189
|
+
case "end":
|
|
190
|
+
return _context6.stop();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, _callee6);
|
|
194
|
+
})));
|
|
195
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function makeStyles(): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { css } from '@emotion/css';
|
|
2
|
+
import { theme, setDefault } from '../../styles/theme';
|
|
3
|
+
import { deepDefaults } from '../../styles/utils';
|
|
4
|
+
var defaults = {
|
|
5
|
+
width: '240px',
|
|
6
|
+
padding: '8px 16px',
|
|
7
|
+
gap: '8px',
|
|
8
|
+
title: {
|
|
9
|
+
fontSize: '14px',
|
|
10
|
+
lineHeight: '20px',
|
|
11
|
+
fontWeight: 500
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var popover;
|
|
15
|
+
setDefault(function () {
|
|
16
|
+
popover = deepDefaults(theme, {
|
|
17
|
+
popover: defaults
|
|
18
|
+
}).popover;
|
|
19
|
+
});
|
|
20
|
+
export default function makeStyles() {
|
|
21
|
+
return /*#__PURE__*/css("&.k-tooltip-content.k-popover{width:", popover.width, ";padding:", popover.padding, ";.k-popover-title{display:flex;align-items:center;font-size:", popover.title.fontSize, ";line-height:", popover.title.lineHeight, ";font-weight:", popover.title.fontWeight, ";}.k-popover-icon{margin-right:", popover.gap, ";}.k-popover-content{margin-top:", popover.gap, ";}.k-tooltip-footer{text-align:right;}}");
|
|
22
|
+
}
|