@king-design/intact 2.0.14 → 2.0.16
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/colorpicker/index.md +1 -0
- package/components/colorpicker/index.ts +2 -0
- package/components/colorpicker/index.vdt +1 -0
- package/components/dialog/alert.vdt +5 -3
- package/components/dialog/index.md +3 -0
- package/components/dialog/index.spec.ts +35 -0
- package/components/dialog/staticMethods.ts +14 -1
- package/components/dialog/useFixBody.ts +3 -1
- package/components/icon/demos/icons.md +158 -0
- package/components/pagination/demos/disable.md +51 -0
- package/components/pagination/index.md +2 -0
- package/components/pagination/index.spec.ts +14 -0
- package/components/pagination/index.ts +8 -0
- package/components/pagination/index.vdt +13 -3
- package/components/pagination/styles.ts +3 -0
- package/components/portal.ts +38 -28
- package/components/select/demos/basic.md +1 -1
- package/components/table/column.vdt +26 -10
- package/components/table/demos/rowExpandable.md +1 -1
- package/components/table/demos/selectedKeys.md +1 -1
- package/components/table/index.md +3 -3
- package/components/table/index.spec.ts +2 -2
- package/components/table/styles.ts +6 -0
- package/components/table/useGroup.ts +18 -2
- package/components/table/useSortable.ts +4 -1
- package/es/components/colorpicker/index.d.ts +1 -0
- package/es/components/colorpicker/index.js +2 -1
- package/es/components/colorpicker/index.vdt.js +5 -1
- package/es/components/dialog/alert.vdt.js +6 -4
- package/es/components/dialog/index.spec.js +61 -1
- package/es/components/dialog/staticMethods.d.ts +4 -2
- package/es/components/dialog/staticMethods.js +16 -0
- package/es/components/dialog/useFixBody.js +3 -1
- package/es/components/pagination/index.d.ts +2 -0
- package/es/components/pagination/index.js +12 -1
- package/es/components/pagination/index.spec.js +28 -0
- package/es/components/pagination/index.vdt.js +18 -3
- package/es/components/pagination/styles.js +1 -1
- package/es/components/portal.js +23 -11
- package/es/components/table/column.vdt.js +43 -7
- package/es/components/table/index.spec.js +2 -2
- package/es/components/table/styles.js +7 -1
- package/es/components/table/useGroup.d.ts +3 -0
- package/es/components/table/useGroup.js +24 -1
- package/es/components/table/useSortable.d.ts +3 -1
- package/es/components/table/useSortable.js +4 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/packages/kpc-react/__tests__/components/dialog.spec.d.ts +1 -0
- package/es/packages/kpc-react/__tests__/components/dialog.spec.js +45 -0
- package/es/packages/kpc-react/__tests__/components/drawer.spec.js +42 -2
- package/es/site/data/components/icon/demos/icons/index.d.ts +9 -0
- package/es/site/data/components/icon/demos/icons/index.js +24 -0
- package/es/site/data/components/icon/demos/icons/react.d.ts +9 -0
- package/es/site/data/components/icon/demos/icons/react.js +63 -0
- package/es/site/data/components/menu/demos/collapse/react.d.ts +11 -0
- package/es/site/data/components/menu/demos/size/react.d.ts +7 -0
- package/es/site/data/components/pagination/demos/disable/index.d.ts +16 -0
- package/es/site/data/components/pagination/demos/disable/index.js +35 -0
- package/es/site/data/components/pagination/demos/disable/react.d.ts +16 -0
- package/es/site/data/components/pagination/demos/disable/react.js +65 -0
- package/es/site/data/components/select/demos/basic/react.js +1 -2
- package/index.ts +2 -2
- package/package.json +3 -3
- package/styles/fonts/demo.css +370 -0
- package/styles/fonts/demo.html +29 -0
- package/styles/fonts/iconfont.css +477 -0
|
@@ -19,7 +19,7 @@ sidebar: doc
|
|
|
19
19
|
| checkedKeys | 通过`key`数组来指定哪些行被选中 | `TableRowKey[]` | `[]` |
|
|
20
20
|
| rowKey | 设置每行的key | `(value: T, index: number) => TableRowKey` | `(value: T, index: number) => index` |
|
|
21
21
|
| rowCheckable | 当行可选时,是否点击该行任意区域都可选中 | `boolean` | `true` |
|
|
22
|
-
| disableRow | 定义行禁用可选的逻辑,返回`true
|
|
22
|
+
| disableRow | 定义行禁用可选的逻辑,返回`true`,则该行被禁用选择 | `(value: T, index: number, key: TableRowKey) => boolean` | `undefined` |
|
|
23
23
|
| type | 表格类型,默认左右无边框,`"border"`类型会添加边框, `"grid"`类型会展示栅格边框 | `"default"` | `"border"` | `"grid"` | `"default"` |
|
|
24
24
|
| stripe | 相邻行是否展示不同的背景色 | `boolean` | `false` |
|
|
25
25
|
| rowClassName | 通过一个函数定义行的`className`,该函数会传入该行数据,索引和`key`当做参数,返回的字符串将被设为该行的`className` | <code>(value: T, index: number, key: TableRowKey) => string | undefined</code> | `undefined` |
|
|
@@ -28,9 +28,9 @@ sidebar: doc
|
|
|
28
28
|
| loading | 是否展示加载状态 | `boolean` | `false` |
|
|
29
29
|
| merge | 指定表格单元格合并逻辑 | `TableMerge` | `undefined` |
|
|
30
30
|
| expandedKeys | 通过`key`来指定哪些行展开 | `TableRowKey[]` | `undefined` |
|
|
31
|
-
| rowExpandable |
|
|
31
|
+
| rowExpandable | 是否点击该行任意区域即展开 | `boolean` | `true` |
|
|
32
32
|
| selectedKeys | 当`rowSelectable`取值为非`false`时,指定哪些行高亮 | `TableRowKey[]` | `undefined` |
|
|
33
|
-
| rowSelectable |
|
|
33
|
+
| rowSelectable | 是否点击行时高亮该行,取值为`multiple`时,可以同时高亮多行 | `boolean` | `"single"` | `"multiple"` | `false` |
|
|
34
34
|
| childrenKey | 树形表格指定子元素键名 | `string` | `"children"` |
|
|
35
35
|
| indent | 树形表格指定子元素缩进宽度 | `number` | `32` |
|
|
36
36
|
| spreadKeys | 树形表格指定展开的行 | `TableRowKey[]` | `undefined` |
|
|
@@ -194,7 +194,7 @@ describe('Table', () => {
|
|
|
194
194
|
const [table1, table2] = element.querySelectorAll<HTMLElement>('.k-table');
|
|
195
195
|
|
|
196
196
|
const icon = table1.querySelector('.k-table-group') as HTMLElement;
|
|
197
|
-
dispatchEvent(icon, '
|
|
197
|
+
dispatchEvent(icon, 'click');
|
|
198
198
|
await wait();
|
|
199
199
|
const dropdown = getElement('.k-table-group-dropdown')!;
|
|
200
200
|
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
@@ -206,7 +206,7 @@ describe('Table', () => {
|
|
|
206
206
|
expect(table1.innerHTML).to.matchSnapshot();
|
|
207
207
|
|
|
208
208
|
const icon2 = table2.querySelector('.k-table-group') as HTMLElement;
|
|
209
|
-
dispatchEvent(icon2, '
|
|
209
|
+
dispatchEvent(icon2, 'click');
|
|
210
210
|
await wait();
|
|
211
211
|
const dropdown2 = getElement('.k-table-group-dropdown')!;
|
|
212
212
|
expect(dropdown2.innerHTML).to.matchSnapshot();
|
|
@@ -41,6 +41,8 @@ const defaults = {
|
|
|
41
41
|
color: `#a6a6a6`,
|
|
42
42
|
menuMaxHeight: '200px',
|
|
43
43
|
get activeColor() { return theme.color.primary },
|
|
44
|
+
headerPadding: `8px`,
|
|
45
|
+
get headerBorder() { return `1px solid ${theme.color.bg}` },
|
|
44
46
|
},
|
|
45
47
|
|
|
46
48
|
// sort
|
|
@@ -371,5 +373,9 @@ export function makeGroupMenuStyles() {
|
|
|
371
373
|
.k-dropdown-item.k-active {
|
|
372
374
|
color: ${table.group.activeColor};
|
|
373
375
|
}
|
|
376
|
+
.k-table-group-header {
|
|
377
|
+
padding: ${table.group.headerPadding};
|
|
378
|
+
border-bottom: ${table.group.headerBorder};
|
|
379
|
+
}
|
|
374
380
|
`
|
|
375
381
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {useInstance} from 'intact';
|
|
2
|
-
import type {TableColumn} from './column';
|
|
2
|
+
import type {TableColumn, TableColumnGroupItem} from './column';
|
|
3
3
|
import {isNullOrUndefined} from 'intact-shared';
|
|
4
4
|
import {toggleArray} from '../utils';
|
|
5
5
|
import {createContext} from '../context';
|
|
6
|
+
import {useState, watchState} from '../../hooks/useState';
|
|
6
7
|
|
|
7
8
|
type ContextValue = {
|
|
8
9
|
groupValue: any
|
|
@@ -13,6 +14,8 @@ export const context = createContext<ContextValue>();
|
|
|
13
14
|
|
|
14
15
|
export function useGroup() {
|
|
15
16
|
const instance = useInstance() as TableColumn;
|
|
17
|
+
const keywords = useState<string>('');
|
|
18
|
+
const filteredGroup = useState<TableColumnGroupItem[] | undefined>(instance.get('group'));
|
|
16
19
|
|
|
17
20
|
function onSelect(value: any, groupValue: any, onChange: ContextValue['onChange']) {
|
|
18
21
|
const {multiple, key} = instance.get();
|
|
@@ -51,5 +54,18 @@ export function useGroup() {
|
|
|
51
54
|
return null;
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
watchState(keywords, (v) => {
|
|
58
|
+
const {group = []} = instance.get();
|
|
59
|
+
v = v.trim();
|
|
60
|
+
|
|
61
|
+
if (!v) {
|
|
62
|
+
filteredGroup.set(group);
|
|
63
|
+
} else {
|
|
64
|
+
filteredGroup.set(group.filter(item => {
|
|
65
|
+
return String(item.label).includes(v) || String(item.value).includes(v);
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return {onSelect, isChecked, getGroupText, keywords, filteredGroup};
|
|
55
71
|
}
|
|
@@ -10,7 +10,10 @@ export function useSortable() {
|
|
|
10
10
|
// if the same column has been clicked three times consecutively,
|
|
11
11
|
// then let the third click to reset the sort
|
|
12
12
|
let count = 0;
|
|
13
|
-
function onChange(key: string) {
|
|
13
|
+
function onChange(key: string, event: Event & {_ignoreSortable?: boolean}) {
|
|
14
|
+
// ignore when click group dropdown menu
|
|
15
|
+
if (event._ignoreSortable) return;
|
|
16
|
+
|
|
14
17
|
let sort = {...instance.get('sort')} as TableSortValue;
|
|
15
18
|
if (sort.key === key) {
|
|
16
19
|
count++;
|
|
@@ -15,7 +15,9 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
15
15
|
hideIcon = _this$get.hideIcon,
|
|
16
16
|
hideFooter = _this$get.hideFooter,
|
|
17
17
|
hideClose = _this$get.hideClose,
|
|
18
|
-
title = _this$get.title
|
|
18
|
+
title = _this$get.title,
|
|
19
|
+
iconClassName = _this$get.iconClassName,
|
|
20
|
+
icon = _this$get.icon;
|
|
19
21
|
|
|
20
22
|
var classNameObj = (_classNameObj = {
|
|
21
23
|
'k-alert-dialog': true
|
|
@@ -37,14 +39,14 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
37
39
|
|
|
38
40
|
return block ? block.call($this, callBlock, data) : callBlock();
|
|
39
41
|
}), (_$blocks['body'] = function ($super) {
|
|
40
|
-
return [_$ce(2, 'div', !hideIcon ? _$cc(Icon, {
|
|
41
|
-
'className': _$cn({
|
|
42
|
+
return [_$ce(2, 'div', [!hideIcon && !icon ? _$cc(Icon, {
|
|
43
|
+
'className': _$cn(iconClassName || {
|
|
42
44
|
"ion-ios-checkmark": type === 'success',
|
|
43
45
|
"ion-ios-information": type === 'warning',
|
|
44
46
|
"ion-ios-close": type === 'error',
|
|
45
47
|
"ion-ios-help": type === 'confirm'
|
|
46
48
|
})
|
|
47
|
-
}) : undefined, 0, 'k-dialog-tip-icon'), _$ce(2, 'div', [title ? _$ce(2, 'div', title, 0, 'k-alert-dialog-title') : undefined, content], 0, 'k-alert-dialog-wrapper')];
|
|
49
|
+
}) : undefined, icon], 0, 'k-dialog-tip-icon'), _$ce(2, 'div', [title ? _$ce(2, 'div', title, 0, 'k-alert-dialog-title') : undefined, content], 0, 'k-alert-dialog-wrapper')];
|
|
48
50
|
}, __$blocks['body'] = function ($super, data) {
|
|
49
51
|
var block = $blocks['body'];
|
|
50
52
|
|
|
@@ -7,7 +7,7 @@ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
|
7
7
|
|
|
8
8
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
9
|
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { var
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { var _context18; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context18 = Object.prototype.toString.call(o)).call(_context18, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
11
|
|
|
12
12
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
13
13
|
|
|
@@ -15,8 +15,10 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/con
|
|
|
15
15
|
import _keysInstanceProperty from "@babel/runtime-corejs3/core-js/instance/keys";
|
|
16
16
|
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js/instance/starts-with";
|
|
17
17
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
18
|
+
import { __decorate } from "tslib";
|
|
18
19
|
import { Component } from 'intact';
|
|
19
20
|
import { Dialog, BaseDialog } from './';
|
|
21
|
+
import { bind } from '../utils';
|
|
20
22
|
import { getElement, mount, unmount, dispatchEvent, wait } from '../../test/utils';
|
|
21
23
|
import BasicDemo from '~/components/dialog/demos/basic';
|
|
22
24
|
import AsyncCloseDemo from '~/components/dialog/demos/asyncClose';
|
|
@@ -590,6 +592,64 @@ describe('Dialog', function () {
|
|
|
590
592
|
}
|
|
591
593
|
}
|
|
592
594
|
}, _callee12);
|
|
595
|
+
})));
|
|
596
|
+
it('should remove body style when destroy', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
597
|
+
var Demo, _mount13, instance, element;
|
|
598
|
+
|
|
599
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context17) {
|
|
600
|
+
while (1) {
|
|
601
|
+
switch (_context17.prev = _context17.next) {
|
|
602
|
+
case 0:
|
|
603
|
+
Demo = /*#__PURE__*/function (_Component4) {
|
|
604
|
+
_inheritsLoose(Demo, _Component4);
|
|
605
|
+
|
|
606
|
+
function Demo() {
|
|
607
|
+
var _context16;
|
|
608
|
+
|
|
609
|
+
var _this4;
|
|
610
|
+
|
|
611
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
612
|
+
args[_key4] = arguments[_key4];
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
_this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context16 = [this]).call(_context16, args)) || this;
|
|
616
|
+
_this4.Dialog = Dialog;
|
|
617
|
+
return _this4;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
Demo.defaults = function defaults() {
|
|
621
|
+
return {
|
|
622
|
+
show: true
|
|
623
|
+
};
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
var _proto = Demo.prototype;
|
|
627
|
+
|
|
628
|
+
_proto.onClose = function onClose() {
|
|
629
|
+
this.set('show', false);
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
return Demo;
|
|
633
|
+
}(Component);
|
|
634
|
+
|
|
635
|
+
Demo.template = "\n var Dialog = this.Dialog;\n <div>\n <Dialog v-if={this.get('show')}\n value={this.get('show')}\n ev-close={this.onClose}\n ref=\"dialog\"\n >test</Dialog>\n </div>\n ";
|
|
636
|
+
|
|
637
|
+
__decorate([bind], Demo.prototype, "onClose", null);
|
|
638
|
+
|
|
639
|
+
_mount13 = mount(Demo), instance = _mount13[0], element = _mount13[1];
|
|
640
|
+
instance.refs.dialog.close();
|
|
641
|
+
_context17.next = 7;
|
|
642
|
+
return wait();
|
|
643
|
+
|
|
644
|
+
case 7:
|
|
645
|
+
expect(document.body.getAttribute('style')).to.be.null;
|
|
646
|
+
|
|
647
|
+
case 8:
|
|
648
|
+
case "end":
|
|
649
|
+
return _context17.stop();
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}, _callee13);
|
|
593
653
|
}))); // it('should handle v-if and v-model at the same time correctly in Vue', async () => {
|
|
594
654
|
// const Test = {
|
|
595
655
|
// template: `<Dialog v-model="show" v-if="show" ref="dialog">test</Dialog>`,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { VNode } from 'intact';
|
|
2
1
|
import type { Dialog, DialogProps } from './';
|
|
3
2
|
export interface AlertDialogProps extends DialogProps {
|
|
4
|
-
content?: string |
|
|
3
|
+
content?: string | object;
|
|
5
4
|
type?: 'success' | 'warning' | 'error' | 'confirm';
|
|
6
5
|
hideIcon?: boolean;
|
|
7
6
|
hideFooter?: boolean;
|
|
8
7
|
ref?: (i: Dialog) => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
iconClassName?: string;
|
|
10
|
+
icon?: object;
|
|
9
11
|
}
|
|
10
12
|
export declare type StaticMethod = (options?: AlertDialogProps) => Promise<void>;
|
|
11
13
|
export declare function addStaticMethods(Component: typeof Dialog): void;
|
|
@@ -29,6 +29,22 @@ export function addStaticMethods(Component) {
|
|
|
29
29
|
options = {};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
var normalize = Component.normalize;
|
|
33
|
+
|
|
34
|
+
if (normalize) {
|
|
35
|
+
if (options.content) {
|
|
36
|
+
options = _extends({}, options, {
|
|
37
|
+
content: normalize(options.content)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (options.icon) {
|
|
42
|
+
options = _extends({}, options, {
|
|
43
|
+
icon: normalize(options.icon)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
32
48
|
var dialog = new AlertDialog(options);
|
|
33
49
|
dialog.show();
|
|
34
50
|
if (options.ref) options.ref(dialog);
|
|
@@ -11,7 +11,9 @@ export function useFixBody(elementRef) {
|
|
|
11
11
|
instance.on(SHOW, onEnter);
|
|
12
12
|
instance.on('afterClose', onAfterLeave);
|
|
13
13
|
onBeforeUnmount(function () {
|
|
14
|
-
|
|
14
|
+
// should also remove body style when dialog is removed, #805
|
|
15
|
+
// if (fixedBody && instance.get('value')) {
|
|
16
|
+
if (fixedBody) {
|
|
15
17
|
// maybe HIDE event has not triggered
|
|
16
18
|
onClosed(instance);
|
|
17
19
|
}
|
|
@@ -13,6 +13,8 @@ export interface PaginationProps {
|
|
|
13
13
|
showTotal?: boolean;
|
|
14
14
|
showGoto?: boolean;
|
|
15
15
|
showLimits?: boolean;
|
|
16
|
+
disableBtn?: (page: number, limit: number) => boolean;
|
|
17
|
+
disablePage?: (page: number, limit: number) => boolean;
|
|
16
18
|
}
|
|
17
19
|
export interface PaginationEvents {
|
|
18
20
|
change: [PaginationChangeData];
|
|
@@ -16,7 +16,9 @@ var typeDefs = {
|
|
|
16
16
|
simple: Boolean,
|
|
17
17
|
showTotal: Boolean,
|
|
18
18
|
showGoto: Boolean,
|
|
19
|
-
showLimits: Boolean
|
|
19
|
+
showLimits: Boolean,
|
|
20
|
+
disableBtn: Function,
|
|
21
|
+
disablePage: Function
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
var defaults = function defaults() {
|
|
@@ -141,7 +143,16 @@ export var Pagination = /*#__PURE__*/function (_Component) {
|
|
|
141
143
|
};
|
|
142
144
|
|
|
143
145
|
_proto.goto = function goto(e) {
|
|
146
|
+
var _this$get4 = this.get(),
|
|
147
|
+
disablePage = _this$get4.disablePage,
|
|
148
|
+
limit = _this$get4.limit;
|
|
149
|
+
|
|
144
150
|
var value = parseInt(e.target.value) || 1;
|
|
151
|
+
|
|
152
|
+
if (disablePage && disablePage(value, limit)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
145
156
|
this.changePage(value);
|
|
146
157
|
};
|
|
147
158
|
|
|
@@ -3,6 +3,7 @@ import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
|
3
3
|
import BasicDemo from '~/components/pagination/demos/basic';
|
|
4
4
|
import GotoDemo from '~/components/pagination/demos/goto';
|
|
5
5
|
import CurrentDemo from '~/components/pagination/demos/current';
|
|
6
|
+
import DisableDemo from '~/components/pagination/demos/disable';
|
|
6
7
|
import { mount, unmount, dispatchEvent, wait } from '../../test/utils';
|
|
7
8
|
describe('Pagination', function () {
|
|
8
9
|
afterEach(function () {
|
|
@@ -141,4 +142,31 @@ describe('Pagination', function () {
|
|
|
141
142
|
}
|
|
142
143
|
}, _callee3);
|
|
143
144
|
})));
|
|
145
|
+
it('should not goto disabled page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
146
|
+
var _mount4, instance, element, input;
|
|
147
|
+
|
|
148
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
149
|
+
while (1) {
|
|
150
|
+
switch (_context4.prev = _context4.next) {
|
|
151
|
+
case 0:
|
|
152
|
+
_mount4 = mount(DisableDemo), instance = _mount4[0], element = _mount4[1];
|
|
153
|
+
input = element.querySelector('.k-input-inner');
|
|
154
|
+
dispatchEvent(input, 'focus');
|
|
155
|
+
input.value = '11';
|
|
156
|
+
dispatchEvent(input, 'change');
|
|
157
|
+
dispatchEvent(input, 'blur');
|
|
158
|
+
_context4.next = 8;
|
|
159
|
+
return wait();
|
|
160
|
+
|
|
161
|
+
case 8:
|
|
162
|
+
expect(input.value).to.eql('10');
|
|
163
|
+
expect(instance.get('value2')).to.eql(10);
|
|
164
|
+
|
|
165
|
+
case 10:
|
|
166
|
+
case "end":
|
|
167
|
+
return _context4.stop();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}, _callee4);
|
|
171
|
+
})));
|
|
144
172
|
});
|
|
@@ -32,7 +32,9 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
32
32
|
value = _this$get.value,
|
|
33
33
|
limit = _this$get.limit,
|
|
34
34
|
limits = _this$get.limits,
|
|
35
|
-
showLimits = _this$get.showLimits
|
|
35
|
+
showLimits = _this$get.showLimits,
|
|
36
|
+
disableBtn = _this$get.disableBtn,
|
|
37
|
+
disablePage = _this$get.disablePage;
|
|
36
38
|
|
|
37
39
|
if (!total) return _$ccv(' pagination ');
|
|
38
40
|
var classNameObj = (_classNameObj = {
|
|
@@ -47,11 +49,24 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
47
49
|
var totalPages = Math.ceil(total / limit) || 0;
|
|
48
50
|
|
|
49
51
|
var paginationButton = function paginationButton(page) {
|
|
52
|
+
var disabled = false;
|
|
53
|
+
|
|
54
|
+
if (page !== value) {
|
|
55
|
+
if (disablePage) {
|
|
56
|
+
disabled || (disabled = !!disablePage(page, limit));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (disableBtn) {
|
|
60
|
+
disabled || (disabled = !!disableBtn(page, limit));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
50
64
|
return _$cc(Button, {
|
|
51
65
|
'type': type,
|
|
52
66
|
'size': size,
|
|
53
67
|
'icon': true,
|
|
54
68
|
'value': page,
|
|
69
|
+
'disabled': disabled,
|
|
55
70
|
'children': page
|
|
56
71
|
});
|
|
57
72
|
};
|
|
@@ -131,14 +146,14 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
131
146
|
'icon': true,
|
|
132
147
|
'size': size,
|
|
133
148
|
'type': type,
|
|
134
|
-
'disabled': value <= 1,
|
|
149
|
+
'disabled': value <= 1 || !!(disablePage && disablePage(value - 1, limit)),
|
|
135
150
|
'ev-click': this.prev,
|
|
136
151
|
'children': _$cc(Icon, _$tmp0)
|
|
137
152
|
}), paginationItems, _$cc(Button, {
|
|
138
153
|
'icon': true,
|
|
139
154
|
'size': size,
|
|
140
155
|
'type': type,
|
|
141
|
-
'disabled': value >= totalPages,
|
|
156
|
+
'disabled': value >= totalPages || !!(disablePage && disablePage(value + 1, limit)),
|
|
142
157
|
'ev-click': this.next,
|
|
143
158
|
'children': _$cc(Icon, _$tmp1)
|
|
144
159
|
})],
|
|
@@ -55,7 +55,7 @@ setDefault(function () {
|
|
|
55
55
|
}).pagination;
|
|
56
56
|
});
|
|
57
57
|
export function makeStyles() {
|
|
58
|
-
return /*#__PURE__*/css("font-size:", pagination.fontSize, ";.k-pagination-limits,.k-pagination-goto,.k-pagination-total{margin-left:", pagination.gap, ";display:inline-block;vertical-align:middle;}.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, ";&:last-of-type{margin:0!important;}}.k-icon{font-size:18px;}}.k-pagination-goto{.k-input{font-size:inherit;width:", pagination.goto.width, ";margin:", pagination.goto.gap, ";}}.k-select{width:auto;}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
58
|
+
return /*#__PURE__*/css("font-size:", pagination.fontSize, ";.k-pagination-limits,.k-pagination-goto,.k-pagination-total{margin-left:", pagination.gap, ";display:inline-block;vertical-align:middle;}.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, ";&:last-of-type{margin:0!important;}}.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
59
|
var styles = pagination[size];
|
|
60
60
|
var btnStyles = button[size];
|
|
61
61
|
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, ";}}}");
|
package/es/components/portal.js
CHANGED
|
@@ -60,25 +60,37 @@ export var Portal = /*#__PURE__*/function (_Component) {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
_proto.$update = function $update(lastVNode, nextVNode, parentDom, anchor, mountedQueue, force) {
|
|
63
|
+
var _this3 = this;
|
|
64
|
+
|
|
63
65
|
// update container if it has changed
|
|
64
66
|
var lastProps = lastVNode.props;
|
|
65
67
|
var nextProps = nextVNode.props;
|
|
66
|
-
var lastContainer = this.container;
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
var update = function update() {
|
|
70
|
+
var lastContainer = _this3.container;
|
|
71
|
+
|
|
72
|
+
if (lastProps.container !== nextProps.container) {
|
|
73
|
+
_this3.initContainer(nextProps.container, parentDom, anchor);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var nextContainer = _this3.container;
|
|
71
77
|
|
|
72
|
-
|
|
78
|
+
if (lastContainer === nextContainer) {
|
|
79
|
+
patch(lastProps.children, nextProps.children, nextContainer, _this3, _this3.$SVG, anchor, mountedQueue, false);
|
|
80
|
+
} else {
|
|
81
|
+
remove(lastProps.children, lastContainer, false);
|
|
82
|
+
mount(nextProps.children, nextContainer, _this3, _this3.$SVG, anchor, mountedQueue);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
_Component.prototype.$update.call(_this3, lastVNode, nextVNode, parentDom, anchor, mountedQueue, force);
|
|
86
|
+
};
|
|
73
87
|
|
|
74
|
-
if (
|
|
75
|
-
|
|
88
|
+
if (!this.container) {
|
|
89
|
+
// in react, sometimes $update will be called before mountedQueue in $render
|
|
90
|
+
mountedQueue.push(update);
|
|
76
91
|
} else {
|
|
77
|
-
|
|
78
|
-
mount(nextProps.children, nextContainer, this, this.$SVG, anchor, mountedQueue);
|
|
92
|
+
update();
|
|
79
93
|
}
|
|
80
|
-
|
|
81
|
-
_Component.prototype.$update.call(this, lastVNode, nextVNode, parentDom, anchor, mountedQueue, force);
|
|
82
94
|
};
|
|
83
95
|
|
|
84
96
|
_proto.$unmount = function $unmount(vNode, nextVNode) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js/instance/sort";
|
|
2
|
-
import { createUnknownComponentVNode as _$cc, createElementVNode as _$ce, noop as _$no, className as _$cn, map as _$ma } from 'intact';
|
|
2
|
+
import { createUnknownComponentVNode as _$cc, createElementVNode as _$ce, noop as _$no, className as _$cn, extend as _$ex, EMPTY_OBJ as _$em, map as _$ma } from 'intact';
|
|
3
3
|
import { getClassAndStyleForFixed } from './useFixedColumns';
|
|
4
4
|
import { Dropdown, DropdownMenu, DropdownItem } from '../dropdown';
|
|
5
5
|
import { Button } from '../button';
|
|
@@ -14,13 +14,18 @@ import { context as TableContext } from './useColumns';
|
|
|
14
14
|
import { context as ResizableContext } from './useResizable';
|
|
15
15
|
import { context as FixedColumnsContext } from './useFixedColumns';
|
|
16
16
|
import { stopPropagation } from '../utils';
|
|
17
|
+
import { Input } from '../input';
|
|
18
|
+
import { _$ } from '../../i18n';
|
|
17
19
|
var _$tmp0 = {
|
|
18
20
|
'className': 'ion-android-arrow-dropdown'
|
|
19
21
|
};
|
|
20
22
|
var _$tmp1 = {
|
|
21
|
-
'className': 'ion-
|
|
23
|
+
'className': 'ion-ios-search'
|
|
22
24
|
};
|
|
23
25
|
var _$tmp2 = {
|
|
26
|
+
'className': 'ion-android-arrow-dropup k-asc'
|
|
27
|
+
};
|
|
28
|
+
var _$tmp3 = {
|
|
24
29
|
'className': 'ion-android-arrow-dropdown k-desc'
|
|
25
30
|
};
|
|
26
31
|
export default function ($props, $blocks, $__proto__) {
|
|
@@ -45,7 +50,9 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
45
50
|
var _this$group = this.group,
|
|
46
51
|
onSelect = _this$group.onSelect,
|
|
47
52
|
isChecked = _this$group.isChecked,
|
|
48
|
-
getGroupText = _this$group.getGroupText
|
|
53
|
+
getGroupText = _this$group.getGroupText,
|
|
54
|
+
keywords = _this$group.keywords,
|
|
55
|
+
filteredGroup = _this$group.filteredGroup;
|
|
49
56
|
return _$cc(TableContext.Consumer, {
|
|
50
57
|
'children': function children(checkType) {
|
|
51
58
|
return _$cc(GroupContext.Consumer, {
|
|
@@ -98,17 +105,46 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
98
105
|
collision: 'flipfit'
|
|
99
106
|
},
|
|
100
107
|
'key': 'dropdown',
|
|
108
|
+
'trigger': 'click',
|
|
109
|
+
'ev-show': function evShow() {
|
|
110
|
+
return keywords.set('');
|
|
111
|
+
},
|
|
101
112
|
'children': [_$cc(Button, {
|
|
102
113
|
'icon': true,
|
|
103
114
|
'size': 'mini',
|
|
104
115
|
'className': 'k-table-group',
|
|
105
|
-
'ev-click':
|
|
116
|
+
'ev-click': function evClick(e) {
|
|
117
|
+
return e._ignoreSortable = true;
|
|
118
|
+
},
|
|
106
119
|
'children': _$cc(Icon, _$tmp0)
|
|
107
120
|
}), _$cc(DropdownMenu, {
|
|
108
121
|
'className': _$cn((_$cn2 = {
|
|
109
122
|
"k-table-group-dropdown": true
|
|
110
123
|
}, _$cn2[makeGroupMenuStyles()] = true, _$cn2)),
|
|
111
|
-
'children': _$
|
|
124
|
+
'children': [_$ce(2, 'div', _$cc(Input, {
|
|
125
|
+
'size': 'small',
|
|
126
|
+
'fluid': true,
|
|
127
|
+
'placeholder': _$('请输入关键字'),
|
|
128
|
+
'value': keywords.value,
|
|
129
|
+
'ev-$change:value': keywords.set,
|
|
130
|
+
'clearable': true,
|
|
131
|
+
'$blocks': function ($blocks) {
|
|
132
|
+
var _$blocks = {},
|
|
133
|
+
__$blocks = _$ex({}, $blocks);
|
|
134
|
+
|
|
135
|
+
return (_$blocks['suffix'] = function ($super) {
|
|
136
|
+
return _$cc(Icon, _$tmp1);
|
|
137
|
+
}, __$blocks['suffix'] = function ($super, data) {
|
|
138
|
+
var block = $blocks['suffix'];
|
|
139
|
+
|
|
140
|
+
var callBlock = function callBlock() {
|
|
141
|
+
return _$blocks['suffix'].call($this, $super, data);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return block ? block.call($this, callBlock, data) : callBlock();
|
|
145
|
+
}), __$blocks;
|
|
146
|
+
}.call($this, _$em)
|
|
147
|
+
}), 2, 'k-table-group-header'), _$ce(2, 'div', _$ma(filteredGroup.value, function ($value, $key) {
|
|
112
148
|
return _$cc(DropdownItem, {
|
|
113
149
|
'ev-select': function evSelect() {
|
|
114
150
|
return onSelect($value.value, groupValue, onChange);
|
|
@@ -122,9 +158,9 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
122
158
|
'children': $value.label
|
|
123
159
|
}) : _$ce(2, 'span', $value.label, 0)
|
|
124
160
|
});
|
|
125
|
-
}, $this)
|
|
161
|
+
}, $this), 4, 'k-table-group-body')]
|
|
126
162
|
})]
|
|
127
|
-
}, 'dropdown') : undefined, sortable ? _$ce(2, 'div', [_$cc(Icon, _$
|
|
163
|
+
}, 'dropdown') : undefined, sortable ? _$ce(2, 'div', [_$cc(Icon, _$tmp2), _$cc(Icon, _$tmp3)], 4, _$cn((_$cn3 = {
|
|
128
164
|
'k-column-sort': true
|
|
129
165
|
}, _$cn3["k-" + type] = type, _$cn3))) : undefined], 0, 'k-table-title')], 0, _$cn(classNameObj), {
|
|
130
166
|
'style': style,
|
|
@@ -352,7 +352,7 @@ describe('Table', function () {
|
|
|
352
352
|
_instance$refs4 = instance.refs, __test1 = _instance$refs4.__test1, __test2 = _instance$refs4.__test2;
|
|
353
353
|
_element$querySelecto8 = element.querySelectorAll('.k-table'), table1 = _element$querySelecto8[0], table2 = _element$querySelecto8[1];
|
|
354
354
|
icon = table1.querySelector('.k-table-group');
|
|
355
|
-
dispatchEvent(icon, '
|
|
355
|
+
dispatchEvent(icon, 'click');
|
|
356
356
|
_context7.next = 7;
|
|
357
357
|
return wait();
|
|
358
358
|
|
|
@@ -370,7 +370,7 @@ describe('Table', function () {
|
|
|
370
370
|
});
|
|
371
371
|
expect(table1.innerHTML).to.matchSnapshot();
|
|
372
372
|
icon2 = table2.querySelector('.k-table-group');
|
|
373
|
-
dispatchEvent(icon2, '
|
|
373
|
+
dispatchEvent(icon2, 'click');
|
|
374
374
|
_context7.next = 19;
|
|
375
375
|
return wait();
|
|
376
376
|
|
|
@@ -53,6 +53,12 @@ var defaults = {
|
|
|
53
53
|
|
|
54
54
|
get activeColor() {
|
|
55
55
|
return theme.color.primary;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
headerPadding: "8px",
|
|
59
|
+
|
|
60
|
+
get headerBorder() {
|
|
61
|
+
return "1px solid " + theme.color.bg;
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
},
|
|
@@ -89,5 +95,5 @@ export function makeStyles() {
|
|
|
89
95
|
}), ";");
|
|
90
96
|
}
|
|
91
97
|
export function makeGroupMenuStyles() {
|
|
92
|
-
return /*#__PURE__*/css("max-height:", table.group.menuMaxHeight, ";overflow:auto;.k-dropdown-item.k-active{color:", table.group.activeColor, ";}");
|
|
98
|
+
return /*#__PURE__*/css("max-height:", table.group.menuMaxHeight, ";overflow:auto;.k-dropdown-item.k-active{color:", table.group.activeColor, ";}.k-table-group-header{padding:", table.group.headerPadding, ";border-bottom:", table.group.headerBorder, ";}");
|
|
93
99
|
}
|