@king-design/intact 3.6.2-beta.1 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/.DS_Store +0 -0
- package/components/anchor/constants.ts +3 -0
- package/components/anchor/demos/basic.md +34 -0
- package/components/anchor/demos/container.md +76 -0
- package/components/anchor/demos/events.md +100 -0
- package/components/anchor/demos/horizontal.md +33 -0
- package/components/anchor/demos/nested.md +132 -0
- package/components/anchor/index.md +38 -0
- package/components/anchor/index.spec.ts +171 -0
- package/components/anchor/index.ts +159 -0
- package/components/anchor/index.vdt +24 -0
- package/components/anchor/link.ts +44 -0
- package/components/anchor/link.vdt +49 -0
- package/components/anchor/styles.ts +50 -0
- package/components/anchor/useScroll.ts +221 -0
- package/components/config/demos/basic.md +11 -3
- package/components/descriptions/.DS_Store +0 -0
- package/components/dialog/base.vdt +3 -1
- package/components/drawer/demos/resizable.md +67 -0
- package/components/drawer/index.md +1 -0
- package/components/drawer/index.spec.ts +43 -0
- package/components/drawer/index.ts +14 -0
- package/components/drawer/index.vdt +20 -3
- package/components/drawer/styles.ts +44 -0
- package/components/drawer/useDrawerResizable.ts +190 -0
- package/components/icon/demos/color.md +1 -1
- package/components/icon/demos/icons.md +18 -0
- package/components/menu/.DS_Store +0 -0
- package/components/menu/demos/.DS_Store +0 -0
- package/components/menu/demos/collapse.md +2 -2
- package/components/menu/demos/showCollapseArrow.md +3 -3
- package/components/menu/demos/size.md +4 -4
- package/components/menu/styles.ts +7 -3
- package/components/notification/demos/basic.md +27 -0
- package/components/notification/demos/close.md +52 -0
- package/components/notification/demos/duration.md +43 -0
- package/components/notification/demos/events.md +39 -0
- package/components/notification/demos/hideClose.md +30 -0
- package/components/notification/demos/icon.md +47 -0
- package/components/notification/demos/position.md +39 -0
- package/components/notification/demos/types.md +38 -0
- package/components/notification/index.md +62 -0
- package/components/notification/index.spec.ts +211 -0
- package/components/notification/index.ts +2 -0
- package/components/notification/notification.ts +185 -0
- package/components/notification/notification.vdt +62 -0
- package/components/notification/notifications.ts +46 -0
- package/components/notification/notifications.vdt +16 -0
- package/components/notification/styles.ts +179 -0
- package/components/select/styles.ts +2 -0
- package/components/table/.DS_Store +0 -0
- package/components/table/demos/hidden.md +8 -2
- package/components/table/demos/sort.md +4 -4
- package/components/table/styles.ts +6 -2
- package/components/tabs/useActiveBar.ts +3 -3
- package/components/tag/base.ts +4 -0
- package/components/tag/demos/border.md +1 -1
- package/components/tag/demos/color.md +40 -0
- package/components/tag/demos/draggable.md +1 -1
- package/components/tag/demos/tags.md +1 -1
- package/components/tag/index.md +1 -0
- package/components/tag/index.spec.ts +8 -0
- package/components/tag/index.vdt +6 -4
- package/components/tag/styles.ts +23 -0
- package/components/tag/useColor.ts +79 -0
- package/components/timepicker/index.spec.ts +16 -5
- package/components/timepicker/useDefaultValue.ts +16 -7
- package/components/timepicker/useStep.ts +3 -2
- package/components/tour/.DS_Store +0 -0
- package/components/transfer/demos/customFilter.md +1 -1
- package/components/transfer/demos/customList.md +1 -1
- package/components/transfer/demos/getData.md +1 -1
- package/components/transfer/demos/leftChecked.md +1 -1
- package/components/transfer/demos/pagination.md +63 -0
- package/components/transfer/demos/table.md +248 -0
- package/components/transfer/demos/tree.md +1 -1
- package/components/transfer/index.md +2 -0
- package/components/transfer/index.spec.ts +147 -0
- package/components/transfer/index.ts +7 -0
- package/components/transfer/index.vdt +30 -4
- package/components/transfer/styles.ts +11 -1
- package/components/transfer/useCheck.ts +5 -5
- package/components/transfer/usePagination.ts +92 -0
- package/components/virtualList/.DS_Store +0 -0
- package/components/virtualList/demos/.DS_Store +0 -0
- package/dist/fonts/iconfont.eot +0 -0
- package/dist/fonts/iconfont.svg +235 -0
- package/dist/fonts/iconfont.ttf +0 -0
- package/dist/fonts/iconfont.woff +0 -0
- package/dist/fonts/iconfont.woff2 +0 -0
- package/dist/fonts/ionicons.eot +0 -0
- package/dist/fonts/ionicons.svg +2230 -0
- package/dist/fonts/ionicons.ttf +0 -0
- package/dist/fonts/ionicons.woff +0 -0
- package/dist/fonts/ionicons.woff2 +0 -0
- package/dist/i18n/en-US.js +1411 -0
- package/dist/i18n/en-US.js.map +1 -0
- package/dist/i18n/en-US.min.js +1 -0
- package/dist/i18n/index.js +283 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/index.min.js +1 -0
- package/dist/kpc.js +50764 -0
- package/dist/kpc.js.map +1 -0
- package/dist/kpc.min.js +1 -0
- package/dist/kpc.react.js +58380 -0
- package/dist/kpc.react.js.map +1 -0
- package/dist/kpc.react.min.js +1 -0
- package/dist/kpc.tmp.js.map +1 -0
- package/dist/kpc.vue-legacy.js +58272 -0
- package/dist/kpc.vue-legacy.js.map +1 -0
- package/dist/kpc.vue-legacy.min.js +1 -0
- package/dist/kpc.vue.js +58128 -0
- package/dist/kpc.vue.js.map +1 -0
- package/dist/kpc.vue.min.js +1 -0
- package/es/components/anchor/constants.d.ts +2 -0
- package/es/components/anchor/constants.js +2 -0
- package/es/components/anchor/index.d.ts +41 -0
- package/es/components/anchor/index.js +141 -0
- package/es/components/anchor/index.spec.d.ts +1 -0
- package/es/components/anchor/index.spec.js +230 -0
- package/es/components/anchor/index.vdt.js +31 -0
- package/es/components/anchor/link.d.ts +16 -0
- package/es/components/anchor/link.js +52 -0
- package/es/components/anchor/link.vdt.js +49 -0
- package/es/components/anchor/styles.d.ts +5 -0
- package/es/components/anchor/styles.js +30 -0
- package/es/components/anchor/useScroll.d.ts +7 -0
- package/es/components/anchor/useScroll.js +218 -0
- package/es/components/dialog/base.vdt.js +1 -1
- package/es/components/drawer/index.d.ts +3 -0
- package/es/components/drawer/index.js +22 -3
- package/es/components/drawer/index.spec.js +83 -0
- package/es/components/drawer/index.vdt.js +23 -3
- package/es/components/drawer/styles.js +1 -1
- package/es/components/drawer/useDrawerResizable.d.ts +10 -0
- package/es/components/drawer/useDrawerResizable.js +162 -0
- package/es/components/menu/styles.d.ts +1 -0
- package/es/components/menu/styles.js +4 -1
- package/es/components/notification/index.d.ts +1 -0
- package/es/components/notification/index.js +1 -0
- package/es/components/notification/index.spec.d.ts +1 -0
- package/es/components/notification/index.spec.js +317 -0
- package/es/components/notification/notification.d.ts +39 -0
- package/es/components/notification/notification.js +183 -0
- package/es/components/notification/notification.vdt.js +56 -0
- package/es/components/notification/notifications.d.ts +16 -0
- package/es/components/notification/notifications.js +51 -0
- package/es/components/notification/notifications.vdt.js +24 -0
- package/es/components/notification/styles.d.ts +9 -0
- package/es/components/notification/styles.js +110 -0
- package/es/components/select/styles.js +1 -1
- package/es/components/table/styles.js +1 -1
- package/es/components/tabs/useActiveBar.js +7 -3
- package/es/components/tag/base.d.ts +2 -0
- package/es/components/tag/base.js +3 -0
- package/es/components/tag/index.spec.js +17 -0
- package/es/components/tag/index.vdt.js +12 -5
- package/es/components/tag/styles.d.ts +9 -0
- package/es/components/tag/styles.js +14 -1
- package/es/components/tag/useColor.d.ts +7 -0
- package/es/components/tag/useColor.js +71 -0
- package/es/components/timepicker/index.spec.js +70 -42
- package/es/components/timepicker/useDefaultValue.js +12 -7
- package/es/components/timepicker/useStep.js +4 -2
- package/es/components/transfer/index.d.ts +13 -0
- package/es/components/transfer/index.js +6 -2
- package/es/components/transfer/index.spec.js +197 -0
- package/es/components/transfer/index.vdt.js +28 -5
- package/es/components/transfer/styles.js +4 -1
- package/es/components/transfer/useCheck.js +2 -1
- package/es/components/transfer/usePagination.d.ts +12 -0
- package/es/components/transfer/usePagination.js +79 -0
- package/es/index.d.ts +4 -2
- package/es/index.js +4 -2
- package/es/site/data/components/anchor/demos/basic/index.d.ts +11 -0
- package/es/site/data/components/anchor/demos/basic/index.js +18 -0
- package/es/site/data/components/anchor/demos/basic/react.d.ts +11 -0
- package/es/site/data/components/anchor/demos/basic/react.js +46 -0
- package/es/site/data/components/anchor/demos/container/index.d.ts +12 -0
- package/es/site/data/components/anchor/demos/container/index.js +19 -0
- package/es/site/data/components/anchor/demos/container/react.d.ts +12 -0
- package/es/site/data/components/anchor/demos/container/react.js +52 -0
- package/es/site/data/components/anchor/demos/events/index.d.ts +17 -0
- package/es/site/data/components/anchor/demos/events/index.js +36 -0
- package/es/site/data/components/anchor/demos/events/react.d.ts +17 -0
- package/es/site/data/components/anchor/demos/events/react.js +88 -0
- package/es/site/data/components/anchor/demos/horizontal/index.d.ts +11 -0
- package/es/site/data/components/anchor/demos/horizontal/index.js +18 -0
- package/es/site/data/components/anchor/demos/horizontal/react.d.ts +11 -0
- package/es/site/data/components/anchor/demos/horizontal/react.js +46 -0
- package/es/site/data/components/anchor/demos/nested/index.d.ts +12 -0
- package/es/site/data/components/anchor/demos/nested/index.js +19 -0
- package/es/site/data/components/anchor/demos/nested/react.d.ts +12 -0
- package/es/site/data/components/anchor/demos/nested/react.js +100 -0
- package/es/site/data/components/anchor/index.d.ts +57 -0
- package/es/site/data/components/anchor/index.js +32 -0
- package/es/site/data/components/config/demos/basic/index.d.ts +1 -0
- package/es/site/data/components/config/demos/basic/index.js +8 -1
- package/es/site/data/components/config/demos/basic/react.d.ts +1 -0
- package/es/site/data/components/config/demos/basic/react.js +15 -3
- package/es/site/data/components/drawer/demos/resizable/index.d.ts +15 -0
- package/es/site/data/components/drawer/demos/resizable/index.js +26 -0
- package/es/site/data/components/drawer/demos/resizable/react.d.ts +15 -0
- package/es/site/data/components/drawer/demos/resizable/react.js +63 -0
- package/es/site/data/components/icon/demos/icons/index.js +1 -1
- package/es/site/data/components/menu/demos/collapse/index.d.ts +6 -1
- package/es/site/data/components/menu/demos/collapse/react.d.ts +6 -1
- package/es/site/data/components/menu/demos/showCollapseArrow/index.d.ts +8 -1
- package/es/site/data/components/menu/demos/showCollapseArrow/react.d.ts +8 -1
- package/es/site/data/components/menu/demos/size/index.d.ts +7 -2
- package/es/site/data/components/menu/demos/size/react.d.ts +7 -2
- package/es/site/data/components/notification/demos/basic/index.d.ts +6 -0
- package/es/site/data/components/notification/demos/basic/index.js +21 -0
- package/es/site/data/components/notification/demos/basic/react.d.ts +5 -0
- package/es/site/data/components/notification/demos/basic/react.js +24 -0
- package/es/site/data/components/notification/demos/close/index.d.ts +13 -0
- package/es/site/data/components/notification/demos/close/index.js +38 -0
- package/es/site/data/components/notification/demos/close/react.d.ts +13 -0
- package/es/site/data/components/notification/demos/close/react.js +52 -0
- package/es/site/data/components/notification/demos/duration/index.d.ts +7 -0
- package/es/site/data/components/notification/demos/duration/index.js +33 -0
- package/es/site/data/components/notification/demos/duration/react.d.ts +6 -0
- package/es/site/data/components/notification/demos/duration/react.js +38 -0
- package/es/site/data/components/notification/demos/events/index.d.ts +6 -0
- package/es/site/data/components/notification/demos/events/index.js +31 -0
- package/es/site/data/components/notification/demos/events/react.d.ts +5 -0
- package/es/site/data/components/notification/demos/events/react.js +34 -0
- package/es/site/data/components/notification/demos/hideClose/index.d.ts +6 -0
- package/es/site/data/components/notification/demos/hideClose/index.js +25 -0
- package/es/site/data/components/notification/demos/hideClose/react.d.ts +5 -0
- package/es/site/data/components/notification/demos/hideClose/react.js +28 -0
- package/es/site/data/components/notification/demos/icon/index.d.ts +7 -0
- package/es/site/data/components/notification/demos/icon/index.js +33 -0
- package/es/site/data/components/notification/demos/icon/react.d.ts +6 -0
- package/es/site/data/components/notification/demos/icon/react.js +42 -0
- package/es/site/data/components/notification/demos/position/index.d.ts +9 -0
- package/es/site/data/components/notification/demos/position/index.js +27 -0
- package/es/site/data/components/notification/demos/position/react.d.ts +8 -0
- package/es/site/data/components/notification/demos/position/react.js +40 -0
- package/es/site/data/components/notification/demos/types/index.d.ts +9 -0
- package/es/site/data/components/notification/demos/types/index.js +26 -0
- package/es/site/data/components/notification/demos/types/react.d.ts +8 -0
- package/es/site/data/components/notification/demos/types/react.js +39 -0
- package/es/site/data/components/notification/index.d.ts +57 -0
- package/es/site/data/components/notification/index.js +32 -0
- package/es/site/data/components/table/demos/hidden/react.js +21 -3
- package/es/site/data/components/tag/demos/color/index.d.ts +10 -0
- package/es/site/data/components/tag/demos/color/index.js +19 -0
- package/es/site/data/components/tag/demos/color/react.d.ts +10 -0
- package/es/site/data/components/tag/demos/color/react.js +34 -0
- package/es/site/data/components/transfer/demos/pagination/index.d.ts +19 -0
- package/es/site/data/components/transfer/demos/pagination/index.js +42 -0
- package/es/site/data/components/transfer/demos/pagination/react.d.ts +20 -0
- package/es/site/data/components/transfer/demos/pagination/react.js +65 -0
- package/es/site/data/components/transfer/demos/table/index.d.ts +33 -0
- package/es/site/data/components/transfer/demos/table/index.js +132 -0
- package/es/site/data/components/transfer/demos/table/react.d.ts +35 -0
- package/es/site/data/components/transfer/demos/table/react.js +246 -0
- package/es/site/src/router/index.js +4 -33
- package/es/styles/fonts/iconfont.eot +0 -0
- package/es/styles/fonts/iconfont.js +1 -1
- package/es/styles/fonts/iconfont.svg +38 -0
- package/es/styles/fonts/iconfont.ttf +0 -0
- package/es/styles/fonts/iconfont.woff +0 -0
- package/es/styles/fonts/iconfont.woff2 +0 -0
- package/es/styles/theme.d.ts +8 -0
- package/es/styles/theme.js +5 -1
- package/index.ts +4 -2
- package/package.json +2 -2
- package/styles/.DS_Store +0 -0
- package/styles/fonts/demo_index.html +443 -6
- package/styles/fonts/iconfont.css +82 -6
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +1 -1
- package/styles/fonts/iconfont.json +133 -0
- package/styles/fonts/iconfont.svg +38 -0
- package/styles/fonts/iconfont.ts +76 -0
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/iconfont.woff2 +0 -0
- package/styles/theme.ts +4 -0
|
@@ -89,4 +89,47 @@ describe('Drawer', () => {
|
|
|
89
89
|
const [dialog1, dialog2] = getElements('.k-dialog');
|
|
90
90
|
expect(dialog2.querySelector('.k-dialog-body')!.textContent).to.eql('Dialog');
|
|
91
91
|
});
|
|
92
|
+
|
|
93
|
+
it('should show resize bar when resizable is true', async function() {
|
|
94
|
+
class Demo extends Component {
|
|
95
|
+
static template = `
|
|
96
|
+
const {Drawer} = this;
|
|
97
|
+
<Drawer value={true} resizable={true} placement="right">
|
|
98
|
+
<div>Content</div>
|
|
99
|
+
</Drawer>
|
|
100
|
+
`;
|
|
101
|
+
private Drawer = Drawer;
|
|
102
|
+
}
|
|
103
|
+
const [instance, element] = mount(Demo);
|
|
104
|
+
await wait();
|
|
105
|
+
expect(getElement('.k-drawer-resize')).to.not.be.undefined;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should update width when dragging', async function() {
|
|
109
|
+
class Demo extends Component {
|
|
110
|
+
static template = `
|
|
111
|
+
const {Drawer} = this;
|
|
112
|
+
<Drawer value={true} resizable={true} placement="right" ref="drawer">
|
|
113
|
+
<div>Content</div>
|
|
114
|
+
</Drawer>
|
|
115
|
+
`;
|
|
116
|
+
private Drawer = Drawer;
|
|
117
|
+
}
|
|
118
|
+
const [instance, element] = mount(Demo);
|
|
119
|
+
await wait();
|
|
120
|
+
|
|
121
|
+
const drawer = instance.refs.drawer.dialogRef.value;
|
|
122
|
+
const initialWidth = drawer.offsetWidth;
|
|
123
|
+
const resizeBar = getElement('.k-drawer-resize') as HTMLElement;
|
|
124
|
+
|
|
125
|
+
const startX = resizeBar.getBoundingClientRect().left;
|
|
126
|
+
dispatchEvent(resizeBar, 'mousedown', { clientX: startX, which: 1 });
|
|
127
|
+
await wait();
|
|
128
|
+
dispatchEvent(document, 'mousemove', { clientX: startX - 50 });
|
|
129
|
+
await wait();
|
|
130
|
+
dispatchEvent(document, 'mouseup');
|
|
131
|
+
await wait(100);
|
|
132
|
+
|
|
133
|
+
expect(drawer.offsetWidth).to.be.greaterThan(initialWidth);
|
|
134
|
+
});
|
|
92
135
|
});
|
|
@@ -2,24 +2,38 @@ import {TypeDefs} from 'intact';
|
|
|
2
2
|
import template from './index.vdt';
|
|
3
3
|
import {BaseDialog, BaseDialogProps} from '../dialog/base';
|
|
4
4
|
import {Placement, placements} from './styles';
|
|
5
|
+
import {useDrawerResizable} from './useDrawerResizable';
|
|
5
6
|
|
|
6
7
|
export interface DrawerProps extends BaseDialogProps {
|
|
7
8
|
placement?: Placement
|
|
9
|
+
resizable?: boolean
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
const typeDefs: Required<TypeDefs<DrawerProps>> = {
|
|
11
13
|
...BaseDialog.typeDefs,
|
|
12
14
|
placement: placements,
|
|
15
|
+
resizable: Boolean,
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
const defaults = (): Partial<DrawerProps> => ({
|
|
16
19
|
...BaseDialog.defaults(),
|
|
17
20
|
placement: 'right',
|
|
18
21
|
draggable: false,
|
|
22
|
+
resizable: false,
|
|
19
23
|
});
|
|
20
24
|
|
|
21
25
|
export class Drawer extends BaseDialog<DrawerProps> {
|
|
22
26
|
static template = template;
|
|
23
27
|
static typeDefs = typeDefs;
|
|
24
28
|
static defaults = defaults;
|
|
29
|
+
|
|
30
|
+
private _resizable = useDrawerResizable(this.dialogRef);
|
|
31
|
+
|
|
32
|
+
init() {
|
|
33
|
+
super.init();
|
|
34
|
+
|
|
35
|
+
this.watch('width', (v) => {
|
|
36
|
+
this._resizable.drawerWidth.set(v || null);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
25
39
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {makeStyles} from './styles';
|
|
2
2
|
|
|
3
|
-
const {placement, overlay} = this.get();
|
|
3
|
+
const {placement, overlay, resizable, width} = this.get();
|
|
4
|
+
const {
|
|
5
|
+
getResizeBarPosition, getHeightResizeBarPosition,
|
|
6
|
+
drawerWidth, isResizing, drawerHeight, startWidth, startHeight
|
|
7
|
+
} = this._resizable;
|
|
8
|
+
const shouldShowHeightResizeBar = !!(resizable && (placement === 'top' || placement === 'bottom'))
|
|
9
|
+
|
|
4
10
|
const { k } = this.config;
|
|
5
11
|
const classNameObj = {
|
|
6
12
|
[`${k}-drawer`]: true,
|
|
@@ -8,10 +14,21 @@ const classNameObj = {
|
|
|
8
14
|
[makeStyles(overlay, k)]: true
|
|
9
15
|
};
|
|
10
16
|
|
|
11
|
-
<t:super class={classNameObj}>
|
|
17
|
+
<t:super class={classNameObj} width={resizable ? (drawerWidth.value || width) : width}>
|
|
12
18
|
<b:_content>
|
|
13
|
-
<div
|
|
19
|
+
<div
|
|
20
|
+
class={`${k}-drawer-content ${isResizing.value ? `${k}-drawer-resizing` : ''}`}
|
|
21
|
+
style={drawerHeight.value ? { height: `${drawerHeight.value}px` } : null}
|
|
22
|
+
>
|
|
14
23
|
{$super()}
|
|
24
|
+
<div v-if={!!resizable}
|
|
25
|
+
class={`${k}-drawer-resize ${k}-drawer-resize-${getResizeBarPosition()}`}
|
|
26
|
+
ev-mousedown={startWidth}
|
|
27
|
+
/>
|
|
28
|
+
<div v-if={shouldShowHeightResizeBar}
|
|
29
|
+
class={`${k}-drawer-resize-horizontal ${k}-drawer-resize-${getHeightResizeBarPosition()}`}
|
|
30
|
+
ev-mousedown={startHeight}
|
|
31
|
+
/>
|
|
15
32
|
</div>
|
|
16
33
|
</b:_content>
|
|
17
34
|
</t:super>
|
|
@@ -29,6 +29,7 @@ export const makeStyles = cache(function makeStyles(overlay: boolean, k: string)
|
|
|
29
29
|
background: transparent;
|
|
30
30
|
box-shadow: none;
|
|
31
31
|
border-radius: 0;
|
|
32
|
+
max-height: 100vh;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
&.transition-enter-active,
|
|
@@ -43,15 +44,58 @@ export const makeStyles = cache(function makeStyles(overlay: boolean, k: string)
|
|
|
43
44
|
|
|
44
45
|
.${k}-drawer-content {
|
|
45
46
|
height: 100%;
|
|
47
|
+
max-height: 100vh;
|
|
46
48
|
display: flex;
|
|
47
49
|
background: #fff;
|
|
48
50
|
flex-direction: column;
|
|
49
51
|
transform: translateX(0);
|
|
50
52
|
box-shadow: ${drawer.boxShadow};
|
|
53
|
+
position: relative;
|
|
51
54
|
.${k}-dialog-body {
|
|
52
55
|
flex-grow: 1;
|
|
53
56
|
overflow: auto;
|
|
54
57
|
}
|
|
58
|
+
&.${k}-drawer-resizing {
|
|
59
|
+
transition: none !important;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.${k}-drawer-resize {
|
|
64
|
+
position: absolute;
|
|
65
|
+
top: 0;
|
|
66
|
+
bottom: 0;
|
|
67
|
+
width: 5px;
|
|
68
|
+
cursor: col-resize;
|
|
69
|
+
z-index: 10;
|
|
70
|
+
user-select: none;
|
|
71
|
+
&:hover {
|
|
72
|
+
background: rgba(0, 0, 0, 0.1);
|
|
73
|
+
}
|
|
74
|
+
&.${k}-drawer-resize-right {
|
|
75
|
+
right: 0;
|
|
76
|
+
}
|
|
77
|
+
&.${k}-drawer-resize-left {
|
|
78
|
+
left: 0;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.${k}-drawer-resize-horizontal {
|
|
83
|
+
position: absolute;
|
|
84
|
+
left: 0;
|
|
85
|
+
right: 0;
|
|
86
|
+
height: 5px;
|
|
87
|
+
cursor: row-resize;
|
|
88
|
+
z-index: 10;
|
|
89
|
+
user-select: none;
|
|
90
|
+
&:hover {
|
|
91
|
+
background: rgba(0, 0, 0, 0.1);
|
|
92
|
+
}
|
|
93
|
+
&.${k}-drawer-resize-top {
|
|
94
|
+
top: 0;
|
|
95
|
+
}
|
|
96
|
+
&.${k}-drawer-resize-bottom {
|
|
97
|
+
bottom: 0;
|
|
98
|
+
}
|
|
55
99
|
}
|
|
56
100
|
|
|
57
101
|
${makePlacementStyles(k, 'right', `right: 0; height: 100%;`, `translateX(100%)`, `${borderRadius} 0 0 ${borderRadius}`)}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import {useInstance, RefObject, onMounted, onBeforeUnmount} from 'intact';
|
|
2
|
+
import {useState} from '../../hooks/useState';
|
|
3
|
+
import {useDraggable} from '../../hooks/useDraggable';
|
|
4
|
+
import type {Drawer} from './';
|
|
5
|
+
|
|
6
|
+
export function useDrawerResizable(
|
|
7
|
+
drawerRef: RefObject<HTMLElement>,
|
|
8
|
+
) {
|
|
9
|
+
const instance = useInstance() as Drawer;
|
|
10
|
+
const { width } = instance.get();
|
|
11
|
+
const drawerWidth = useState<number | string | null>(width || null);
|
|
12
|
+
const drawerHeight = useState<number | null>(null);
|
|
13
|
+
const isResizing = useState(false);
|
|
14
|
+
|
|
15
|
+
let startX = 0;
|
|
16
|
+
let startWidth = 0;
|
|
17
|
+
let startY = 0;
|
|
18
|
+
let startHeight = 0;
|
|
19
|
+
|
|
20
|
+
let minWidth = 200; // 最小宽度
|
|
21
|
+
let maxWidth = window.innerWidth; // 最大宽度
|
|
22
|
+
let minHeight = 200; // 最小高度
|
|
23
|
+
let maxHeight = window.innerHeight; // 最大高度
|
|
24
|
+
|
|
25
|
+
// 监听窗口大小变化,更新最大宽高
|
|
26
|
+
let handleResize: (() => void) | null = null;
|
|
27
|
+
onMounted(() => {
|
|
28
|
+
handleResize = () => {
|
|
29
|
+
maxWidth = window.innerWidth;
|
|
30
|
+
maxHeight = window.innerHeight;
|
|
31
|
+
};
|
|
32
|
+
window.addEventListener('resize', handleResize);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
onBeforeUnmount(() => {
|
|
36
|
+
if (handleResize) {
|
|
37
|
+
window.removeEventListener('resize', handleResize);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// 宽度拖拽
|
|
42
|
+
function onStartWidth(e: MouseEvent) {
|
|
43
|
+
const drawer = drawerRef.value;
|
|
44
|
+
if (!drawer) return;
|
|
45
|
+
|
|
46
|
+
startX = e.clientX;
|
|
47
|
+
startWidth = drawer.offsetWidth;
|
|
48
|
+
drawerWidth.set(startWidth);
|
|
49
|
+
isResizing.set(true);
|
|
50
|
+
|
|
51
|
+
// 锁定全局样式
|
|
52
|
+
document.body.style.cursor = 'col-resize';
|
|
53
|
+
document.body.style.userSelect = 'none';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function onMoveWidth(e: MouseEvent) {
|
|
57
|
+
const drawer = drawerRef.value;
|
|
58
|
+
if (!drawer) return;
|
|
59
|
+
|
|
60
|
+
const {placement, resizable} = instance.get() as any;
|
|
61
|
+
// 计算鼠标移动距离
|
|
62
|
+
const deltaX = e.clientX - startX;
|
|
63
|
+
let widthDelta = deltaX;
|
|
64
|
+
|
|
65
|
+
// 根据 placement 调整拖拽方向
|
|
66
|
+
if (placement === 'right') {
|
|
67
|
+
widthDelta = -deltaX;
|
|
68
|
+
} else if (placement === 'left') {
|
|
69
|
+
widthDelta = deltaX;
|
|
70
|
+
} else {
|
|
71
|
+
// top / bottom 模式:由于是居中(left: 50%, transform: translateX(-50%))对称增长
|
|
72
|
+
// 宽度变化量应该是位移的两倍才能保持鼠标跟随
|
|
73
|
+
widthDelta = deltaX * 2;
|
|
74
|
+
}
|
|
75
|
+
const newWidth = Math.max(
|
|
76
|
+
minWidth,
|
|
77
|
+
Math.min(maxWidth, startWidth + widthDelta)
|
|
78
|
+
);
|
|
79
|
+
drawerWidth.set(newWidth);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function onEndWidth() {
|
|
83
|
+
isResizing.set(false);
|
|
84
|
+
// 恢复全局样式
|
|
85
|
+
document.body.style.cursor = '';
|
|
86
|
+
document.body.style.userSelect = '';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const widthDrag = useDraggable({
|
|
90
|
+
onStart: onStartWidth,
|
|
91
|
+
onMove: onMoveWidth,
|
|
92
|
+
onEnd: onEndWidth,
|
|
93
|
+
disable() {
|
|
94
|
+
const {resizable} = instance.get();
|
|
95
|
+
return !resizable;
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// 高度拖拽,仅在 placement 为 top / bottom 时启用
|
|
100
|
+
function onStartHeight(e: MouseEvent) {
|
|
101
|
+
const drawer = drawerRef.value;
|
|
102
|
+
if (!drawer) return;
|
|
103
|
+
|
|
104
|
+
const {placement, resizable} = instance.get();
|
|
105
|
+
if (!resizable || (placement !== 'top' && placement !== 'bottom')) return;
|
|
106
|
+
|
|
107
|
+
startY = e.clientY;
|
|
108
|
+
startHeight = drawer.offsetHeight;
|
|
109
|
+
drawerHeight.set(startHeight);
|
|
110
|
+
isResizing.set(true);
|
|
111
|
+
|
|
112
|
+
// 锁定全局样式
|
|
113
|
+
document.body.style.cursor = 'row-resize';
|
|
114
|
+
document.body.style.userSelect = 'none';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function onMoveHeight(e: MouseEvent) {
|
|
118
|
+
const drawer = drawerRef.value;
|
|
119
|
+
if (!drawer) return;
|
|
120
|
+
|
|
121
|
+
const {placement} = instance.get();
|
|
122
|
+
if (placement !== 'top' && placement !== 'bottom') return;
|
|
123
|
+
|
|
124
|
+
const deltaY = e.clientY - startY;
|
|
125
|
+
|
|
126
|
+
const heightDelta = placement === 'top' ? deltaY : -deltaY;
|
|
127
|
+
|
|
128
|
+
const newHeight = Math.max(
|
|
129
|
+
minHeight,
|
|
130
|
+
Math.min(maxHeight, startHeight + heightDelta)
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// 设置状态,由模板进行渲染
|
|
134
|
+
drawerHeight.set(newHeight);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function onEndHeight() {
|
|
138
|
+
isResizing.set(false);
|
|
139
|
+
// 恢复全局样式
|
|
140
|
+
document.body.style.cursor = '';
|
|
141
|
+
document.body.style.userSelect = '';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const heightDrag = useDraggable({
|
|
145
|
+
onStart: onStartHeight,
|
|
146
|
+
onMove: onMoveHeight,
|
|
147
|
+
onEnd: onEndHeight,
|
|
148
|
+
disable() {
|
|
149
|
+
const {placement, resizable} = instance.get();
|
|
150
|
+
return !resizable || (placement !== 'top' && placement !== 'bottom');
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// 重置 resize 状态
|
|
155
|
+
function resetResizeState() {
|
|
156
|
+
const {width} = instance.get();
|
|
157
|
+
drawerWidth.set(width || null);
|
|
158
|
+
drawerHeight.set(null);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 监听 placement 变化,切换时重置 resize 状态
|
|
162
|
+
instance.watch('placement', (newPlacement, oldPlacement) => {
|
|
163
|
+
if (oldPlacement !== undefined && newPlacement !== oldPlacement) {
|
|
164
|
+
resetResizeState();
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// 获取宽度拖拽条位置
|
|
169
|
+
function getResizeBarPosition(): 'left' | 'right' {
|
|
170
|
+
const {placement} = instance.get();
|
|
171
|
+
return placement === 'right' ? 'left' : 'right';
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 获取高度拖拽条位置
|
|
175
|
+
function getHeightResizeBarPosition(): 'top' | 'bottom' {
|
|
176
|
+
const {placement} = instance.get();
|
|
177
|
+
return placement === 'top' ? 'bottom' : 'top';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
drawerWidth,
|
|
182
|
+
drawerHeight,
|
|
183
|
+
isResizing,
|
|
184
|
+
getResizeBarPosition,
|
|
185
|
+
getHeightResizeBarPosition,
|
|
186
|
+
startWidth: widthDrag.start,
|
|
187
|
+
startHeight: heightDrag.start,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
@@ -139,6 +139,24 @@ export default class extends Component<Props> {
|
|
|
139
139
|
['start'],
|
|
140
140
|
['stop'],
|
|
141
141
|
['sortorder'],
|
|
142
|
+
["history"],
|
|
143
|
+
["correlation"],
|
|
144
|
+
["webui"],
|
|
145
|
+
["log"],
|
|
146
|
+
["save"],
|
|
147
|
+
["memory"],
|
|
148
|
+
["Physicalport"],
|
|
149
|
+
["queue"],
|
|
150
|
+
["channel"],
|
|
151
|
+
["cpu"],
|
|
152
|
+
["change"],
|
|
153
|
+
["subnet"],
|
|
154
|
+
["listener"],
|
|
155
|
+
["outboundrules"],
|
|
156
|
+
["inboundrules"],
|
|
157
|
+
["fullscreen"],
|
|
158
|
+
["add-circled"],
|
|
159
|
+
["think"],
|
|
142
160
|
],
|
|
143
161
|
} as Props
|
|
144
162
|
}
|
|
Binary file
|
|
Binary file
|
|
@@ -88,11 +88,11 @@ export default class extends Component<Props> {
|
|
|
88
88
|
return {
|
|
89
89
|
expandedKeys: [],
|
|
90
90
|
selectedKey: '2',
|
|
91
|
-
size: 'small',
|
|
92
|
-
theme: 'light',
|
|
91
|
+
size: 'small' as MenuProps['size'],
|
|
92
|
+
theme: 'light' as MenuProps['theme'],
|
|
93
93
|
showCollapseArrow: true,
|
|
94
94
|
collapse: false,
|
|
95
|
-
}
|
|
95
|
+
};
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
```
|
|
@@ -79,11 +79,11 @@ export default class extends Component {
|
|
|
79
79
|
static defaults() {
|
|
80
80
|
return {
|
|
81
81
|
expandedKeys: ['3'],
|
|
82
|
-
size: 'large',
|
|
83
|
-
theme: 'light',
|
|
84
|
-
type: 'vertical',
|
|
82
|
+
size: 'large' as MenuProps['size'],
|
|
83
|
+
theme: 'light' as MenuProps['theme'],
|
|
84
|
+
type: 'vertical' as MenuProps['type'],
|
|
85
85
|
collapse: false,
|
|
86
|
-
}
|
|
86
|
+
};
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
```
|
|
@@ -50,7 +50,8 @@ const defaults = {
|
|
|
50
50
|
bgColor: '#fff',
|
|
51
51
|
get border() { return `1px solid ${theme.color.disabledBg}` },
|
|
52
52
|
item: {
|
|
53
|
-
get color() { return theme.color.text },
|
|
53
|
+
get color() { return theme.color.text },
|
|
54
|
+
get arrowColor() { return theme.color.lightBlack },
|
|
54
55
|
get hoverColor() { return theme.color.primary },
|
|
55
56
|
get hoverBg() { return theme.color.hoverBg },
|
|
56
57
|
disabledColor: '#b6bec2',
|
|
@@ -183,7 +184,7 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
|
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
.${k}-menu-item-arrow {
|
|
186
|
-
color: ${menu.light.item.
|
|
187
|
+
color: ${menu.light.item.arrowColor};
|
|
187
188
|
}
|
|
188
189
|
&.${k}-highlighted {
|
|
189
190
|
> .${k}-menu-item-title {
|
|
@@ -234,9 +235,12 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
|
|
|
234
235
|
}
|
|
235
236
|
}
|
|
236
237
|
.${k}-sub-menu {
|
|
237
|
-
.${k}-menu-item-title
|
|
238
|
+
.${k}-menu-item-title {
|
|
238
239
|
color: ${menu.light.item.subTitleColor} !important;
|
|
239
240
|
}
|
|
241
|
+
.${k}-menu-item-arrow {
|
|
242
|
+
color: ${menu.light.item.arrowColor} !important;
|
|
243
|
+
}
|
|
240
244
|
}
|
|
241
245
|
}
|
|
242
246
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 基础用法
|
|
3
|
+
order: 0
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
最基础的用法,使用静态方法`notice`显示通知,通过`title`属性设置通知标题,`content`属性设置通知内容。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Button} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<Button ev-click={this.showNotification.bind(this)}>基础用法</Button>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import {Notification} from 'kpc';
|
|
16
|
+
|
|
17
|
+
export default class extends Component {
|
|
18
|
+
static template = template;
|
|
19
|
+
|
|
20
|
+
showNotification() {
|
|
21
|
+
Notification.notice({
|
|
22
|
+
title: 'Hello, Kingcloud Design!',
|
|
23
|
+
content: '这是一条基础用法的通知'
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 控制关闭
|
|
3
|
+
order: 7
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
可以通过`Notification.notice()`、`Notification.info()`等方法返回的唯一ID,调用`Notification.close(id)`来控制通知的关闭。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {ButtonGroup, Button} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<ButtonGroup>
|
|
12
|
+
<Button ev-click={this.showNotification}>显示通知</Button>
|
|
13
|
+
<Button ev-click={this.closeNotification}>关闭通知</Button>
|
|
14
|
+
</ButtonGroup>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {Notification, bind} from 'kpc';
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
notificationId?: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default class extends Component<Props> {
|
|
25
|
+
static template = template;
|
|
26
|
+
|
|
27
|
+
static defaults() {
|
|
28
|
+
return {
|
|
29
|
+
notificationId: undefined
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@bind
|
|
34
|
+
showNotification() {
|
|
35
|
+
const id = Notification.info({
|
|
36
|
+
title: '可关闭的通知',
|
|
37
|
+
content: '点击"关闭通知"按钮可以关闭此通知',
|
|
38
|
+
duration: 0,
|
|
39
|
+
});
|
|
40
|
+
this.set('notificationId', id);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@bind
|
|
44
|
+
closeNotification() {
|
|
45
|
+
const notificationId = this.get('notificationId');
|
|
46
|
+
if (notificationId !== undefined) {
|
|
47
|
+
Notification.close(notificationId as number);
|
|
48
|
+
this.set('notificationId', undefined);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 修改关闭延时
|
|
3
|
+
order: 5
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
通知默认4.5秒后关闭,可以设置`duration`属性自定义关闭延时;`duration`设置为`0`,通知不会自动关闭,只能手动关闭。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {ButtonGroup, Button} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<ButtonGroup>
|
|
12
|
+
<Button ev-click={this.showCloseDelay}>10s后关闭</Button>
|
|
13
|
+
<Button ev-click={this.showStick}>不会自动关闭</Button>
|
|
14
|
+
</ButtonGroup>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {Notification} from 'kpc';
|
|
19
|
+
import {bind} from 'kpc';
|
|
20
|
+
|
|
21
|
+
export default class extends Component {
|
|
22
|
+
static template = template;
|
|
23
|
+
|
|
24
|
+
@bind
|
|
25
|
+
showCloseDelay() {
|
|
26
|
+
Notification.warning({
|
|
27
|
+
title: '10s后关闭',
|
|
28
|
+
content: '这条通知10s后才会自动关闭',
|
|
29
|
+
duration: 10000,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@bind
|
|
34
|
+
showStick() {
|
|
35
|
+
Notification.warning({
|
|
36
|
+
title: '不会自动关闭',
|
|
37
|
+
content: '这条通知不会自动关闭,需要手动关闭',
|
|
38
|
+
duration: 0,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 点击与关闭事件
|
|
3
|
+
order: 6
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
通知支持点击和关闭事件回调,可以通过`onClick`和`onClose`属性设置回调函数。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {ButtonGroup, Button} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<ButtonGroup>
|
|
12
|
+
<Button ev-click={this.showNotification}>显示通知</Button>
|
|
13
|
+
</ButtonGroup>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import {Notification, Message} from 'kpc';
|
|
18
|
+
import {bind} from 'kpc';
|
|
19
|
+
|
|
20
|
+
export default class extends Component {
|
|
21
|
+
static template = template;
|
|
22
|
+
|
|
23
|
+
@bind
|
|
24
|
+
showNotification() {
|
|
25
|
+
Notification.info({
|
|
26
|
+
title: '事件通知',
|
|
27
|
+
content: '点击通知或等待自动关闭,查看页面信息提示',
|
|
28
|
+
onClick: (e) => {
|
|
29
|
+
Message.info('你点击了通知');
|
|
30
|
+
},
|
|
31
|
+
onClose: () => {
|
|
32
|
+
Message.warning('通知已关闭');
|
|
33
|
+
},
|
|
34
|
+
className: 'event-test'
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|