@king-design/react 3.0.0-beta.0 → 3.0.0-beta.2
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 +468 -309
- package/__tests__/components/cascader.spec.tsx +53 -0
- 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.d.ts +1 -1
- package/components/button/styles.js +3 -5
- package/components/carousel/index.vdt.js +2 -2
- package/components/cascader/index.d.ts +22 -11
- package/components/cascader/index.js +9 -12
- package/components/cascader/index.spec.js +81 -0
- package/components/cascader/index.vdt.js +11 -9
- package/components/cascader/styles.js +1 -1
- package/components/cascader/useFields.d.ts +2 -0
- package/components/cascader/useFields.js +18 -0
- package/components/cascader/useFilterable.d.ts +2 -1
- package/components/cascader/useFilterable.js +17 -6
- package/components/cascader/useLabel.d.ts +2 -1
- package/components/cascader/useLabel.js +4 -4
- package/components/cascader/useLoad.d.ts +2 -1
- package/components/cascader/useLoad.js +9 -7
- package/components/collapse/item.vdt.js +1 -1
- package/components/colorpicker/index.d.ts +2 -0
- package/components/colorpicker/index.js +7 -2
- package/components/colorpicker/index.vdt.js +3 -6
- 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/calendar.vdt.js +6 -6
- package/components/datepicker/index.spec.js +171 -153
- package/components/datepicker/index.vdt.js +1 -1
- package/components/datepicker/styles.js +1 -1
- package/components/datepicker/useValue.d.ts +3 -3
- package/components/datepicker/useValue.js +38 -9
- 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/index.spec.js +6 -6
- package/components/dialog/styles.js +1 -1
- package/components/dropdown/dropdown.d.ts +6 -6
- package/components/dropdown/dropdown.js +58 -75
- package/components/dropdown/index.spec.js +96 -17
- package/components/dropdown/item.d.ts +1 -1
- package/components/dropdown/item.js +19 -7
- package/components/dropdown/menu.js +1 -1
- package/components/dropdown/usePosition.js +11 -2
- package/components/editable/index.d.ts +1 -0
- package/components/editable/index.js +20 -6
- package/components/editable/index.vdt.js +2 -1
- package/components/form/index.spec.js +4 -2
- package/components/form/item.vdt.js +2 -1
- package/components/form/styles.js +4 -4
- package/components/grid/useGutter.js +8 -8
- package/components/icon/styles.js +1 -1
- package/components/input/index.d.ts +13 -2
- package/components/input/index.js +16 -13
- package/components/input/index.spec.js +169 -1
- package/components/input/index.vdt.js +44 -12
- package/components/input/search.vdt.js +2 -4
- package/components/input/styles.js +30 -6
- package/components/input/useAutoRows.d.ts +2 -0
- package/components/input/useAutoRows.js +79 -0
- package/components/input/useAutoWidth.js +13 -3
- package/components/input/useFocus.d.ts +4 -0
- package/components/input/useFocus.js +21 -0
- package/components/input/useShowPassword.d.ts +7 -0
- package/components/input/useShowPassword.js +31 -0
- package/components/menu/index.spec.js +26 -15
- package/components/menu/item.d.ts +2 -0
- package/components/menu/item.js +5 -0
- package/components/menu/item.vdt.js +4 -1
- package/components/pagination/index.d.ts +1 -1
- package/components/pagination/index.js +3 -2
- package/components/pagination/index.spec.js +49 -0
- package/components/pagination/index.vdt.js +10 -12
- package/components/pagination/styles.js +1 -1
- 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/portal.d.ts +6 -2
- package/components/portal.js +4 -3
- package/components/position.js +2 -1
- package/components/progress/index.js +1 -1
- package/components/progress/index.vdt.js +46 -8
- package/components/progress/styles.js +19 -13
- package/components/rate/styles.js +1 -1
- package/components/select/base.d.ts +7 -3
- package/components/select/base.js +9 -3
- package/components/select/base.vdt.js +75 -47
- package/components/select/index.spec.js +25 -13
- package/components/select/menu.vdt.js +6 -6
- package/components/select/option.vdt.js +2 -1
- package/components/select/styles.js +11 -5
- package/components/select/useDraggble.d.ts +2 -0
- package/components/select/useDraggble.js +11 -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 +13 -8
- package/components/spinner/styles.js +2 -2
- 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 +1 -0
- package/components/steps/index.js +2 -1
- package/components/steps/index.spec.js +1 -1
- package/components/steps/index.vdt.js +7 -4
- package/components/steps/step.vdt.js +2 -3
- package/components/steps/styles.d.ts +1 -0
- package/components/steps/styles.js +50 -17
- package/components/switch/index.spec.js +82 -65
- package/components/table/cell.js +1 -6
- package/components/table/cell.vdt.js +1 -1
- package/components/table/column.vdt.js +40 -24
- package/components/table/index.spec.js +162 -20
- package/components/table/row.d.ts +1 -1
- package/components/table/row.js +2 -1
- package/components/table/styles.js +16 -9
- package/components/table/table.d.ts +15 -0
- package/components/table/table.js +16 -7
- package/components/table/table.vdt.js +20 -6
- package/components/table/useChecked.d.ts +3 -2
- package/components/table/useChecked.js +23 -12
- package/components/table/useDisableRow.d.ts +2 -1
- package/components/table/useDisableRow.js +4 -4
- package/components/table/useDraggable.d.ts +3 -2
- package/components/table/useDraggable.js +11 -15
- package/components/table/useGroup.d.ts +9 -3
- package/components/table/useGroup.js +48 -37
- package/components/table/useMerge.d.ts +2 -1
- package/components/table/useMerge.js +5 -4
- package/components/table/usePagination.d.ts +8 -0
- package/components/table/usePagination.js +81 -0
- package/components/table/useStickyScrollbar.js +2 -2
- package/components/table/useTree.d.ts +2 -1
- package/components/table/useTree.js +3 -4
- 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 +9 -4
- package/components/tabs/styles.js +32 -34
- 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 +1 -1
- 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 +33 -8
- package/components/tag/tags.d.ts +27 -0
- package/components/tag/tags.js +51 -0
- package/components/tag/tags.vdt.js +91 -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/tooltip/content.d.ts +3 -2
- package/components/tooltip/content.js +18 -1
- package/components/tooltip/content.vdt.js +22 -10
- package/components/tooltip/index.spec.js +147 -92
- package/components/tooltip/styles.d.ts +23 -0
- package/components/tooltip/styles.js +2 -2
- package/components/tooltip/tooltip.d.ts +1 -1
- package/components/tooltip/tooltip.js +11 -11
- package/components/transfer/index.vdt.js +14 -3
- package/components/types.d.ts +1 -0
- package/components/upload/index.spec.js +5 -6
- package/components/upload/index.vdt.js +7 -5
- package/components/utils.d.ts +2 -0
- package/components/utils.js +24 -3
- package/components/virtual.d.ts +8 -0
- package/components/virtual.js +126 -0
- package/hooks/useResizeObserver.d.ts +1 -1
- package/hooks/useResizeObserver.js +19 -6
- package/i18n/en-US.d.ts +4 -1
- package/i18n/en-US.js +6 -2
- package/index.d.ts +5 -3
- package/index.js +5 -3
- package/package.json +2 -2
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +2 -2
- package/styles/fonts/iconfont.svg +35 -35
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/ionicons.js +3 -3
- package/styles/global.js +1 -1
- package/yarn-error.log +41 -43
- package/components/table/useResizeObserver.d.ts +0 -2
- package/components/table/useResizeObserver.js +0 -20
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TableRowKey } from './table';
|
|
2
2
|
import type { useTree } from './useTree';
|
|
3
|
-
|
|
3
|
+
import { State } from '../../hooks/useState';
|
|
4
|
+
export declare function useDisableRow(loopData: ReturnType<typeof useTree>['loopData'], data: State<any[] | undefined>): {
|
|
4
5
|
isDisabled: (data: any, index: number, key: TableRowKey) => boolean;
|
|
5
6
|
getEnableKeys: () => TableRowKey[];
|
|
6
7
|
isDisabledKey: (key: TableRowKey) => boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useInstance } from 'intact-react';
|
|
2
|
-
|
|
2
|
+
import { watchState } from '../../hooks/useState';
|
|
3
|
+
export function useDisableRow(loopData, data) {
|
|
3
4
|
var instance = useInstance();
|
|
4
5
|
var enabledKeys = [];
|
|
5
6
|
var disabledKeys = [];
|
|
@@ -45,9 +46,8 @@ export function useDisableRow(loopData) {
|
|
|
45
46
|
return allKeys;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
instance.on('$receive:children', setDisabledKeys);
|
|
49
|
-
|
|
50
|
-
instance.on('$change:data', setDisabledKeys);
|
|
49
|
+
instance.on('$receive:children', setDisabledKeys);
|
|
50
|
+
watchState(data, setDisabledKeys);
|
|
51
51
|
return {
|
|
52
52
|
isDisabled: isDisabled,
|
|
53
53
|
getEnableKeys: getEnableKeys,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { TableRowKey } from './table';
|
|
2
|
+
import { State } from '../../hooks/useState';
|
|
2
3
|
import type { TableRow } from './row';
|
|
3
|
-
export declare function useDraggable(): {
|
|
4
|
+
export declare function useDraggable(data: State<unknown[] | undefined>): {
|
|
4
5
|
onRowDragStart: (e: MouseEvent, tableRow: TableRow) => void;
|
|
5
6
|
onRowDragOver: (e: MouseEvent, tableRow: TableRow) => void;
|
|
6
7
|
onRowDragEnd: (e: MouseEvent, tableRow: TableRow) => void;
|
|
7
|
-
draggingKey:
|
|
8
|
+
draggingKey: State<TableRowKey | null>;
|
|
8
9
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
2
|
-
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
3
1
|
import { useInstance, nextTick } from 'intact-react';
|
|
4
2
|
import { useState } from '../../hooks/useState';
|
|
5
|
-
|
|
3
|
+
import { swap } from '../utils';
|
|
4
|
+
export function useDraggable(data) {
|
|
6
5
|
var instance = useInstance();
|
|
7
6
|
var draggingKey = useState(null);
|
|
8
7
|
var originIndex;
|
|
@@ -13,7 +12,7 @@ export function useDraggable() {
|
|
|
13
12
|
draggingIndex = originIndex = tableRow.get('index');
|
|
14
13
|
var key = tableRow.get('key');
|
|
15
14
|
draggingKey.set(key);
|
|
16
|
-
originData =
|
|
15
|
+
originData = data.value;
|
|
17
16
|
instance.trigger('dragstart', {
|
|
18
17
|
key: key,
|
|
19
18
|
from: draggingIndex
|
|
@@ -21,27 +20,24 @@ export function useDraggable() {
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
function onRowDragOver(e, tableRow) {
|
|
24
|
-
var _context;
|
|
25
|
-
|
|
26
23
|
e.preventDefault();
|
|
27
24
|
e.stopPropagation();
|
|
25
|
+
if (draggingKey.value === null) return;
|
|
28
26
|
var newIndex = tableRow.get('index');
|
|
29
27
|
if (newIndex === draggingIndex) return; // swap data
|
|
30
28
|
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
var item = _spliceInstanceProperty(data).call(data, draggingIndex, 1)[0];
|
|
34
|
-
|
|
35
|
-
_spliceInstanceProperty(data).call(data, newIndex, 0, item);
|
|
36
|
-
|
|
29
|
+
var newData = swap(data.value, draggingIndex, newIndex);
|
|
37
30
|
draggingIndex = newIndex;
|
|
38
|
-
|
|
31
|
+
data.set(newData);
|
|
39
32
|
}
|
|
40
33
|
|
|
41
34
|
function onRowDragEnd(e, tableRow) {
|
|
42
|
-
e.preventDefault();
|
|
43
|
-
|
|
35
|
+
e.preventDefault(); // revert to origin data, then set to new data to trigger animation
|
|
36
|
+
|
|
37
|
+
var newData = data.value;
|
|
38
|
+
data.set(originData);
|
|
44
39
|
nextTick(function () {
|
|
40
|
+
data.set(newData);
|
|
45
41
|
draggingKey.set(null);
|
|
46
42
|
instance.trigger('dragend', {
|
|
47
43
|
key: tableRow.get('key'),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TableColumnGroupItem } from './column';
|
|
2
|
+
import type { Dropdown } from '../dropdown';
|
|
2
3
|
declare type ContextValue = {
|
|
3
4
|
groupValue: any;
|
|
4
5
|
onChange: (key: string, groupValue: any) => void;
|
|
@@ -8,10 +9,15 @@ export declare const context: {
|
|
|
8
9
|
Consumer: import("intact").ComponentConstructor<import("intact").Component<import("../context").ConsumerProps<ContextValue>, {}, {}, {}>>;
|
|
9
10
|
};
|
|
10
11
|
export declare function useGroup(): {
|
|
11
|
-
onSelect: (value: any,
|
|
12
|
-
isChecked: (value: any
|
|
13
|
-
getGroupText: (groupValue: any) => string | null;
|
|
12
|
+
onSelect: (value: any, onChange: ContextValue['onChange']) => void;
|
|
13
|
+
isChecked: (value: any) => any;
|
|
14
14
|
keywords: import("../../hooks/useState").State<string>;
|
|
15
15
|
filteredGroup: import("../../hooks/useState").State<TableColumnGroupItem[] | undefined>;
|
|
16
|
+
onShow: (groupValue: any) => void;
|
|
17
|
+
reset: () => void;
|
|
18
|
+
confirm: (onChange: ContextValue['onChange']) => void;
|
|
19
|
+
dropdownRef: import("intact").RefObject<Dropdown>;
|
|
20
|
+
localGroupValue: import("../../hooks/useState").State<any>;
|
|
21
|
+
isEmptyValue: (groupValue: any) => boolean | undefined;
|
|
16
22
|
};
|
|
17
23
|
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
|
|
2
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
3
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
4
2
|
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
4
|
+
import { useInstance, createRef } from 'intact-react';
|
|
5
|
+
import { isArray } from 'intact-shared';
|
|
7
6
|
import { toggleArray } from '../utils';
|
|
8
7
|
import { createContext } from '../context';
|
|
9
8
|
import { useState, watchState } from '../../hooks/useState';
|
|
@@ -12,23 +11,37 @@ export function useGroup() {
|
|
|
12
11
|
var instance = useInstance();
|
|
13
12
|
var keywords = useState('');
|
|
14
13
|
var filteredGroup = useState(instance.get('group'));
|
|
14
|
+
var localGroupValue = useState(null);
|
|
15
|
+
var dropdownRef = createRef();
|
|
16
|
+
instance.on('$receive:group', function (group) {
|
|
17
|
+
return filteredGroup.set(group);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function onShow(groupValue) {
|
|
21
|
+
keywords.set('');
|
|
22
|
+
localGroupValue.set(groupValue);
|
|
23
|
+
}
|
|
15
24
|
|
|
16
|
-
function onSelect(value,
|
|
25
|
+
function onSelect(value, onChange) {
|
|
17
26
|
var _instance$get = instance.get(),
|
|
18
27
|
multiple = _instance$get.multiple,
|
|
19
28
|
key = _instance$get.key;
|
|
20
29
|
|
|
21
30
|
if (multiple) {
|
|
22
|
-
|
|
31
|
+
// should click confirm button when it is multiple selection
|
|
32
|
+
localGroupValue.set(toggleArray(localGroupValue.value, value));
|
|
33
|
+
} else {
|
|
34
|
+
// change immediately when it is single selection
|
|
35
|
+
onChange(key, value);
|
|
23
36
|
}
|
|
24
|
-
|
|
25
|
-
onChange(key, value);
|
|
26
37
|
}
|
|
27
38
|
|
|
28
|
-
function isChecked(value
|
|
39
|
+
function isChecked(value) {
|
|
29
40
|
var _instance$get2 = instance.get(),
|
|
30
41
|
multiple = _instance$get2.multiple;
|
|
31
42
|
|
|
43
|
+
var groupValue = localGroupValue.value;
|
|
44
|
+
|
|
32
45
|
if (multiple) {
|
|
33
46
|
return groupValue && _includesInstanceProperty(groupValue).call(groupValue, value);
|
|
34
47
|
}
|
|
@@ -36,38 +49,31 @@ export function useGroup() {
|
|
|
36
49
|
return groupValue === value;
|
|
37
50
|
}
|
|
38
51
|
|
|
39
|
-
function
|
|
52
|
+
function confirm(onChange) {
|
|
40
53
|
var _instance$get3 = instance.get(),
|
|
41
|
-
|
|
42
|
-
group = _instance$get3.group;
|
|
54
|
+
key = _instance$get3.key;
|
|
43
55
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
groupValue = [groupValue];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (group) {
|
|
51
|
-
var _context;
|
|
56
|
+
onChange(key, localGroupValue.value);
|
|
57
|
+
dropdownRef.value.hide(true);
|
|
58
|
+
}
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return item.label;
|
|
57
|
-
}).join(', ');
|
|
60
|
+
function reset() {
|
|
61
|
+
localGroupValue.set([]);
|
|
62
|
+
}
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
64
|
+
function isEmptyValue(groupValue) {
|
|
65
|
+
var _instance$get4 = instance.get(),
|
|
66
|
+
multiple = _instance$get4.multiple;
|
|
63
67
|
|
|
64
|
-
return
|
|
68
|
+
return !groupValue || multiple && (!isArray(groupValue) || groupValue.every(function (value) {
|
|
69
|
+
return !value;
|
|
70
|
+
}));
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
watchState(keywords, function (v) {
|
|
68
|
-
var _instance$
|
|
69
|
-
_instance$
|
|
70
|
-
group = _instance$
|
|
74
|
+
var _instance$get5 = instance.get(),
|
|
75
|
+
_instance$get5$group = _instance$get5.group,
|
|
76
|
+
group = _instance$get5$group === void 0 ? [] : _instance$get5$group;
|
|
71
77
|
|
|
72
78
|
v = _trimInstanceProperty(v).call(v);
|
|
73
79
|
|
|
@@ -75,17 +81,22 @@ export function useGroup() {
|
|
|
75
81
|
filteredGroup.set(group);
|
|
76
82
|
} else {
|
|
77
83
|
filteredGroup.set(_filterInstanceProperty(group).call(group, function (item) {
|
|
78
|
-
var
|
|
84
|
+
var _context, _context2;
|
|
79
85
|
|
|
80
|
-
return _includesInstanceProperty(
|
|
86
|
+
return _includesInstanceProperty(_context = String(item.label)).call(_context, v) || _includesInstanceProperty(_context2 = String(item.value)).call(_context2, v);
|
|
81
87
|
}));
|
|
82
88
|
}
|
|
83
89
|
});
|
|
84
90
|
return {
|
|
85
91
|
onSelect: onSelect,
|
|
86
92
|
isChecked: isChecked,
|
|
87
|
-
getGroupText: getGroupText,
|
|
88
93
|
keywords: keywords,
|
|
89
|
-
filteredGroup: filteredGroup
|
|
94
|
+
filteredGroup: filteredGroup,
|
|
95
|
+
onShow: onShow,
|
|
96
|
+
reset: reset,
|
|
97
|
+
confirm: confirm,
|
|
98
|
+
dropdownRef: dropdownRef,
|
|
99
|
+
localGroupValue: localGroupValue,
|
|
100
|
+
isEmptyValue: isEmptyValue
|
|
90
101
|
};
|
|
91
102
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Props } from 'intact-react';
|
|
2
2
|
import type { TableColumnProps } from './column';
|
|
3
|
+
import { State } from '../../hooks/useState';
|
|
3
4
|
export declare type TableMerge<T = any, CheckType = 'checkbox'> = (row: T, column: CheckType extends 'none' ? Props<TableColumnProps> : Props<TableColumnProps> | null, rowIndex: number, columnIndex: number) => TableMergeConfig | undefined;
|
|
4
5
|
export declare type TableMergeConfig = {
|
|
5
6
|
colspan?: number;
|
|
@@ -10,6 +11,6 @@ export declare type TableGridItem = {
|
|
|
10
11
|
spans: TableMergeConfig | undefined;
|
|
11
12
|
};
|
|
12
13
|
export declare type TableGrid = TableGridItem[][];
|
|
13
|
-
export declare function useMerge(getCols: () => Props<TableColumnProps>[]): {
|
|
14
|
+
export declare function useMerge(getCols: () => Props<TableColumnProps>[], data: State<unknown[] | undefined>): {
|
|
14
15
|
getGrid: () => TableGrid;
|
|
15
16
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useInstance } from 'intact-react';
|
|
2
|
-
|
|
2
|
+
import { watchState } from '../../hooks/useState';
|
|
3
|
+
export function useMerge(getCols, data) {
|
|
3
4
|
var instance = useInstance();
|
|
4
5
|
var grid = [];
|
|
5
6
|
|
|
@@ -8,12 +9,11 @@ export function useMerge(getCols) {
|
|
|
8
9
|
|
|
9
10
|
var _instance$get = instance.get(),
|
|
10
11
|
merge = _instance$get.merge,
|
|
11
|
-
data = _instance$get.data,
|
|
12
12
|
checkType = _instance$get.checkType;
|
|
13
13
|
|
|
14
|
-
if (!data || !data.length || !merge) return;
|
|
14
|
+
if (!data.value || !data.value.length || !merge) return;
|
|
15
15
|
var cols = getCols();
|
|
16
|
-
data.forEach(function (data, rowIndex) {
|
|
16
|
+
data.value.forEach(function (data, rowIndex) {
|
|
17
17
|
var currentRow = [];
|
|
18
18
|
grid.push(currentRow);
|
|
19
19
|
var columnIndexOffset = 0;
|
|
@@ -71,6 +71,7 @@ export function useMerge(getCols) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
instance.on('$receive:children', handleSpans);
|
|
74
|
+
watchState(data, handleSpans);
|
|
74
75
|
return {
|
|
75
76
|
getGrid: getGrid
|
|
76
77
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Pagination, PaginationChangeData } from '../pagination';
|
|
2
|
+
export declare function usePagination(): {
|
|
3
|
+
data: import("../../hooks/useState").State<any[] | undefined>;
|
|
4
|
+
value: import("../../hooks/useState").State<number>;
|
|
5
|
+
limit: import("../../hooks/useState").State<number>;
|
|
6
|
+
onChange: (data: PaginationChangeData) => void;
|
|
7
|
+
paginationRef: import('intact-react').RefObject<Pagination>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
3
|
+
import { useInstance, createRef } from 'intact-react';
|
|
4
|
+
import { useState } from '../../hooks/useState';
|
|
5
|
+
import { Pagination } from '../pagination';
|
|
6
|
+
import { isObject } from 'intact-shared';
|
|
7
|
+
import { useReceive } from '../../hooks/useReceive';
|
|
8
|
+
var defaultPagination = Pagination.defaults();
|
|
9
|
+
export function usePagination() {
|
|
10
|
+
var instance = useInstance();
|
|
11
|
+
var data = useState(instance.get('data'));
|
|
12
|
+
var value = useState(defaultPagination.value);
|
|
13
|
+
var limit = useState(defaultPagination.limit);
|
|
14
|
+
var paginationRef = createRef(); // for unit test
|
|
15
|
+
|
|
16
|
+
useReceive(['data', 'pagination'], function () {
|
|
17
|
+
handleData();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function handleData() {
|
|
21
|
+
var _instance$get = instance.get(),
|
|
22
|
+
_data = _instance$get.data,
|
|
23
|
+
pagination = _instance$get.pagination;
|
|
24
|
+
|
|
25
|
+
if (!_data) {
|
|
26
|
+
data.set(undefined);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!pagination) {
|
|
31
|
+
data.set(_data);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (isObject(pagination)) {
|
|
36
|
+
if (pagination.value) {
|
|
37
|
+
value.set(pagination.value);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (pagination.limit) {
|
|
41
|
+
limit.set(pagination.limit);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
updateDataByPage();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function updateDataByPage() {
|
|
49
|
+
var _instance$get2 = instance.get(),
|
|
50
|
+
_data = _instance$get2.data;
|
|
51
|
+
|
|
52
|
+
var index = (value.value - 1) * limit.value;
|
|
53
|
+
data.set(_sliceInstanceProperty(_data).call(_data, index, index + limit.value));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function onChange(data) {
|
|
57
|
+
var _instance$get3 = instance.get(),
|
|
58
|
+
pagination = _instance$get3.pagination;
|
|
59
|
+
|
|
60
|
+
value.set(data.value);
|
|
61
|
+
limit.set(data.limit);
|
|
62
|
+
updateDataByPage();
|
|
63
|
+
|
|
64
|
+
if (isObject(pagination)) {
|
|
65
|
+
instance.set('pagination', _extends({}, pagination, {
|
|
66
|
+
value: value.value,
|
|
67
|
+
limit: limit.value
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
instance.trigger('changePage', data);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
data: data,
|
|
76
|
+
value: value,
|
|
77
|
+
limit: limit,
|
|
78
|
+
onChange: onChange,
|
|
79
|
+
paginationRef: paginationRef
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -2,7 +2,7 @@ import { createRef, useInstance, onMounted, nextTick } from 'intact-react';
|
|
|
2
2
|
import { useState } from '../../hooks/useState';
|
|
3
3
|
import { isStringOrNumber, isNull } from 'intact-shared';
|
|
4
4
|
import { debounce } from '../utils';
|
|
5
|
-
import { useResizeObserver } from '
|
|
5
|
+
import { useResizeObserver } from '../../hooks/useResizeObserver';
|
|
6
6
|
export function useStickyScrollbar(elementRef, _ref, tableRef, tableScroll) {
|
|
7
7
|
var scrollRef = _ref.scrollRef,
|
|
8
8
|
callbacks = _ref.callbacks;
|
|
@@ -14,7 +14,7 @@ export function useStickyScrollbar(elementRef, _ref, tableRef, tableScroll) {
|
|
|
14
14
|
instance.on('$receive:stickScrollbar', function (v) {
|
|
15
15
|
stick.set(v === true ? 0 : isStringOrNumber(v) ? +v : null);
|
|
16
16
|
});
|
|
17
|
-
useResizeObserver(scrollRef, setTableActualWidth);
|
|
17
|
+
useResizeObserver(scrollRef, setTableActualWidth, true);
|
|
18
18
|
onMounted(function () {
|
|
19
19
|
setTableActualWidth();
|
|
20
20
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TableRowKey } from './table';
|
|
2
|
-
|
|
2
|
+
import { State } from '../../hooks/useState';
|
|
3
|
+
export declare function useTree(data: State<any[] | undefined>): {
|
|
3
4
|
isSpreaded: (key: TableRowKey) => boolean;
|
|
4
5
|
toggleSpreadRow: (key: TableRowKey) => void;
|
|
5
6
|
loopData: <T>(cb: (value: any, index: number, level: number, meta: T | null) => T, shouldBreak?: boolean) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useInstance } from 'intact-react';
|
|
2
2
|
import { inArray } from './useChecked';
|
|
3
3
|
import { toggleArray } from '../utils';
|
|
4
|
-
export function useTree() {
|
|
4
|
+
export function useTree(data) {
|
|
5
5
|
var instance = useInstance();
|
|
6
6
|
|
|
7
7
|
function isSpreaded(key) {
|
|
@@ -18,10 +18,9 @@ export function useTree() {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
var _instance$get = instance.get(),
|
|
21
|
-
childrenKey = _instance$get.childrenKey
|
|
22
|
-
data = _instance$get.data;
|
|
21
|
+
childrenKey = _instance$get.childrenKey;
|
|
23
22
|
|
|
24
|
-
loopDataWithChildrenKey(data, childrenKey, cb, shouldBreak);
|
|
23
|
+
loopDataWithChildrenKey(data.value, childrenKey, cb, shouldBreak);
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
return {
|
|
@@ -3,7 +3,7 @@ import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
|
3
3
|
import { useInstance, onMounted, createRef } from 'intact-react';
|
|
4
4
|
import { useState } from '../../hooks/useState';
|
|
5
5
|
import { scrollbarWidth } from '../position';
|
|
6
|
-
import { useResizeObserver } from '
|
|
6
|
+
import { useResizeObserver } from '../../hooks/useResizeObserver';
|
|
7
7
|
var hasLocalStorage = typeof localStorage !== 'undefined';
|
|
8
8
|
export function useWidth(scrollRef, getColumns) {
|
|
9
9
|
var instance = useInstance();
|
|
@@ -16,7 +16,7 @@ export function useWidth(scrollRef, getColumns) {
|
|
|
16
16
|
});
|
|
17
17
|
useResizeObserver(scrollRef, function () {
|
|
18
18
|
return checkTableWidth(false);
|
|
19
|
-
}); // if exist widthStoreKey, we get the default width from localStorage
|
|
19
|
+
}, true); // if exist widthStoreKey, we get the default width from localStorage
|
|
20
20
|
|
|
21
21
|
function initWidthFromStore() {
|
|
22
22
|
var _instance$get = instance.get(),
|
|
@@ -7,7 +7,7 @@ export interface TabsProps<T = any> {
|
|
|
7
7
|
value?: T;
|
|
8
8
|
vertical?: boolean;
|
|
9
9
|
size?: Sizes;
|
|
10
|
-
type?: 'default' | 'card' | '
|
|
10
|
+
type?: 'default' | 'card' | 'flat-card';
|
|
11
11
|
closable?: boolean;
|
|
12
12
|
beforeChange?: (value: T) => boolean | Promise<boolean>;
|
|
13
13
|
}
|
package/components/tabs/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
2
4
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
5
|
import ClosableDemo from '~/components/tabs/demos/closable';
|
|
4
6
|
import BeforeChangeDemo from '~/components/tabs/demos/beforeChange';
|
|
5
7
|
import { mount, unmount, wait } from '../../test/utils';
|
|
8
|
+
import { Tabs, Tab } from './';
|
|
9
|
+
import { Component } from 'intact-react';
|
|
6
10
|
describe('Tabs', function () {
|
|
7
11
|
afterEach(function () {
|
|
8
12
|
return unmount();
|
|
@@ -93,4 +97,67 @@ describe('Tabs', function () {
|
|
|
93
97
|
}
|
|
94
98
|
}, _callee2);
|
|
95
99
|
})));
|
|
100
|
+
it('vertical scroll', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
101
|
+
var Demo, _mount3, instance, element, prev, next;
|
|
102
|
+
|
|
103
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
104
|
+
while (1) {
|
|
105
|
+
switch (_context4.prev = _context4.next) {
|
|
106
|
+
case 0:
|
|
107
|
+
Demo = /*#__PURE__*/function (_Component) {
|
|
108
|
+
_inheritsLoose(Demo, _Component);
|
|
109
|
+
|
|
110
|
+
function Demo() {
|
|
111
|
+
var _context3;
|
|
112
|
+
|
|
113
|
+
var _this;
|
|
114
|
+
|
|
115
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
116
|
+
args[_key] = arguments[_key];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context3 = [this]).call(_context3, args)) || this;
|
|
120
|
+
_this.Tabs = Tabs;
|
|
121
|
+
_this.Tab = Tab;
|
|
122
|
+
return _this;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
Demo.defaults = function defaults() {
|
|
126
|
+
return {
|
|
127
|
+
tab: 0
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return Demo;
|
|
132
|
+
}(Component);
|
|
133
|
+
|
|
134
|
+
Demo.template = "\n const { Tabs, Tab } = this;\n <Tabs v-model=\"tab\" vertical style=\"height: 200px;\">\n <Tab v-for={new Array(10).fill(0)} value={$key}>\n {$key}\n </Tab>\n </Tabs>\n ";
|
|
135
|
+
_mount3 = mount(Demo), instance = _mount3[0], element = _mount3[1];
|
|
136
|
+
_context4.next = 5;
|
|
137
|
+
return wait(100);
|
|
138
|
+
|
|
139
|
+
case 5:
|
|
140
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
141
|
+
prev = element.querySelector('.k-tabs-prev');
|
|
142
|
+
next = element.querySelector('.k-tabs-next');
|
|
143
|
+
next.click();
|
|
144
|
+
_context4.next = 11;
|
|
145
|
+
return wait();
|
|
146
|
+
|
|
147
|
+
case 11:
|
|
148
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
149
|
+
prev.click();
|
|
150
|
+
_context4.next = 15;
|
|
151
|
+
return wait();
|
|
152
|
+
|
|
153
|
+
case 15:
|
|
154
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
155
|
+
|
|
156
|
+
case 16:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context4.stop();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, _callee3);
|
|
162
|
+
})));
|
|
96
163
|
});
|
|
@@ -3,6 +3,7 @@ import { createVNode as _$cv, className as _$cn, createUnknownComponentVNode as
|
|
|
3
3
|
import { Button } from '../button';
|
|
4
4
|
import { getRestProps } from '../utils';
|
|
5
5
|
import { makeStyles } from './styles';
|
|
6
|
+
import { Icon } from '../icon';
|
|
6
7
|
export default function ($props, $blocks, $__proto__) {
|
|
7
8
|
var _classNameObj;
|
|
8
9
|
|
|
@@ -19,7 +20,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
19
20
|
|
|
20
21
|
var _this$scroll = this.scroll,
|
|
21
22
|
isScroll = _this$scroll.isScroll,
|
|
22
|
-
|
|
23
|
+
offset = _this$scroll.offset,
|
|
23
24
|
enablePrev = _this$scroll.enablePrev,
|
|
24
25
|
enableNext = _this$scroll.enableNext,
|
|
25
26
|
prev = _this$scroll.prev,
|
|
@@ -39,12 +40,14 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
39
40
|
'size': size,
|
|
40
41
|
'disabled': !enablePrev.value,
|
|
41
42
|
'ev-click': prev,
|
|
42
|
-
'children': _$
|
|
43
|
+
'children': _$cc(Icon, {
|
|
44
|
+
'className': _$cn(vertical ? "k-icon-up" : "k-icon-left")
|
|
45
|
+
})
|
|
43
46
|
}, 'prev') : undefined, _$ce(2, 'div', _$ce(2, 'div', [children, _$ce(2, 'div', null, 1, 'k-tabs-active-bar', {
|
|
44
47
|
'style': this.activeBar.value
|
|
45
48
|
})], 0, 'k-tabs-wrapper', {
|
|
46
49
|
'style': {
|
|
47
|
-
transform: "translateX(" +
|
|
50
|
+
transform: vertical ? "translateY(" + offset.value + "px)" : "translateX(" + offset.value + "px)"
|
|
48
51
|
}
|
|
49
52
|
}, null, wrapperRef), 2, 'k-tabs-scroll c-clearfix', null, null, scrollRef), isScroll.value ? _$cc(Button, {
|
|
50
53
|
'className': 'k-tabs-next',
|
|
@@ -54,7 +57,9 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
54
57
|
'size': size,
|
|
55
58
|
'disabled': !enableNext.value,
|
|
56
59
|
'ev-click': next,
|
|
57
|
-
'children': _$
|
|
60
|
+
'children': _$cc(Icon, {
|
|
61
|
+
'className': _$cn(vertical ? "k-icon-down" : "k-icon-right")
|
|
62
|
+
})
|
|
58
63
|
}, 'next') : undefined]);
|
|
59
64
|
}
|
|
60
65
|
;
|