@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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {Component, VNodeComponentClass, TypeDefs} from 'intact';
|
|
2
|
+
import template from './notifications.vdt';
|
|
3
|
+
import type {Notification} from './notification';
|
|
4
|
+
import { useConfigContext } from '../config';
|
|
5
|
+
|
|
6
|
+
export interface NotificationsProps {
|
|
7
|
+
classNamePrefix?: string
|
|
8
|
+
position?: 'topRight' | 'topLeft' | 'bottomRight' | 'bottomLeft' | 'top' | 'bottom'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const typeDefs: Required<TypeDefs<NotificationsProps>> = {
|
|
12
|
+
classNamePrefix: String,
|
|
13
|
+
position: ['topRight', 'topLeft', 'bottomRight', 'bottomLeft', 'top', 'bottom'],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export class Notifications extends Component {
|
|
17
|
+
static template = template;
|
|
18
|
+
static typeDefs = typeDefs;
|
|
19
|
+
|
|
20
|
+
private notifications: VNodeComponentClass<Notification>[] = [];
|
|
21
|
+
private config = useConfigContext();
|
|
22
|
+
__cleanup?: () => void;
|
|
23
|
+
|
|
24
|
+
notice(notification: VNodeComponentClass<Notification>) {
|
|
25
|
+
this.notifications.push(notification);
|
|
26
|
+
this.forceUpdate();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
delete(key: number | string) {
|
|
30
|
+
const notifications = this.notifications;
|
|
31
|
+
const index = notifications.findIndex(notification => notification.key === key);
|
|
32
|
+
if (process.env.NODE_ENV !== 'production' && !~index) {
|
|
33
|
+
throw new Error('You are removing a notification that does not exist.');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
notifications.splice(index, 1);
|
|
37
|
+
this.forceUpdate();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
onAfterLeave() {
|
|
41
|
+
// 当离开动画完成后,如果该位置 通知列表为空,则清理容器
|
|
42
|
+
if (this.notifications.length === 0 && this.__cleanup) {
|
|
43
|
+
this.__cleanup();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {TransitionGroup} from 'intact';
|
|
2
|
+
import {makeNotificationsStyles} from './styles';
|
|
3
|
+
import { ConfigProvider } from '../config';
|
|
4
|
+
|
|
5
|
+
const k = this.get('classNamePrefix') || this.config.k;
|
|
6
|
+
const position = this.get('position') || 'topRight';
|
|
7
|
+
|
|
8
|
+
<ConfigProvider value={{classNamePrefix: k}}>
|
|
9
|
+
<div class={{[`${k}-notifications`]: true, [makeNotificationsStyles(k, position)]: true}}>
|
|
10
|
+
<TransitionGroup onAfterLeave={this.onAfterLeave.bind(this)}>
|
|
11
|
+
<template v-for={this.notifications} key={$value.key}>
|
|
12
|
+
{$value}
|
|
13
|
+
</template>
|
|
14
|
+
</TransitionGroup>
|
|
15
|
+
</div>
|
|
16
|
+
</ConfigProvider>
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {css} from '@emotion/css';
|
|
2
|
+
import {theme, setDefault} from '../../styles/theme';
|
|
3
|
+
import {deepDefaults} from '../../styles/utils';
|
|
4
|
+
import '../../styles/global';
|
|
5
|
+
import { cache } from '../utils';
|
|
6
|
+
|
|
7
|
+
const defaults = {
|
|
8
|
+
get transition() { return theme.transition.large },
|
|
9
|
+
top: `24px`,
|
|
10
|
+
right: `24px`,
|
|
11
|
+
left: `24px`,
|
|
12
|
+
bottom: `24px`,
|
|
13
|
+
leftTransform: `translateX(-100%)`,
|
|
14
|
+
rightTransform: `translateX(100%)`,
|
|
15
|
+
topTransform: `translateY(-100%)`,
|
|
16
|
+
bottomTransform: `translateY(100%)`,
|
|
17
|
+
bgColor: '#fff',
|
|
18
|
+
get borderRadius() { return theme.borderRadius },
|
|
19
|
+
gap: `8px`,
|
|
20
|
+
boxShadow: '0px 4px 32px 4px #00000014',
|
|
21
|
+
padding: `12px`,
|
|
22
|
+
get fontSize() { return theme.default.fontSize },
|
|
23
|
+
get contentColor() { return theme.color.text },
|
|
24
|
+
get titleColor() { return theme.color.title },
|
|
25
|
+
minWidth: '320px',
|
|
26
|
+
width: '360px',
|
|
27
|
+
maxWidth: '400px',
|
|
28
|
+
titleFontSize: '14px',
|
|
29
|
+
titleFontWeight: '500',
|
|
30
|
+
titleMarginBottom: '8px',
|
|
31
|
+
bodyLineHeight: '1.5',
|
|
32
|
+
|
|
33
|
+
icon: {
|
|
34
|
+
fontSize: `20px`,
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
close: {
|
|
38
|
+
right: `12px`,
|
|
39
|
+
top: `12px`,
|
|
40
|
+
width: `20px`,
|
|
41
|
+
height: `20px`,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
let notification: typeof defaults;
|
|
46
|
+
setDefault(() => {
|
|
47
|
+
notification = deepDefaults(theme, {notification: defaults}).notification;
|
|
48
|
+
makeNotificationsStyles?.clearCache();
|
|
49
|
+
makeNotificationStyles?.clearCache();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
export const makeNotificationsStyles = cache(function makeNotificationsStyles(
|
|
54
|
+
k: string,
|
|
55
|
+
position: string
|
|
56
|
+
) {
|
|
57
|
+
// 位置配置
|
|
58
|
+
const positions = {
|
|
59
|
+
topRight: { top: notification.top, right: notification.right, left: '', bottom: '', transform: '' },
|
|
60
|
+
topLeft: { top: notification.top, left: notification.left, right: '', bottom: '', transform: '' },
|
|
61
|
+
bottomRight: { bottom: notification.top, right: notification.right, left: '', top: '', transform: '' },
|
|
62
|
+
bottomLeft: { bottom: notification.top, left: notification.left, right: '', top: '', transform: '' },
|
|
63
|
+
top: { top: notification.top, left: '50%', right: '', bottom: '', transform: 'translateX(-50%)' },
|
|
64
|
+
bottom: { bottom: notification.top, left: '50%', right: '', top: '', transform: 'translateX(-50%)' },
|
|
65
|
+
};
|
|
66
|
+
const pos = positions[position as keyof typeof positions] || positions.topRight;
|
|
67
|
+
|
|
68
|
+
return css`
|
|
69
|
+
position: fixed;
|
|
70
|
+
${pos.top ? `top: ${pos.top};` : ''}
|
|
71
|
+
${pos.bottom ? `bottom: ${pos.bottom};` : ''}
|
|
72
|
+
${pos.left ? `left: ${pos.left};` : ''}
|
|
73
|
+
${pos.right ? `right: ${pos.right};` : ''}
|
|
74
|
+
${pos.transform ? `transform: ${pos.transform};` : ''}
|
|
75
|
+
width: auto;
|
|
76
|
+
pointer-events: none;
|
|
77
|
+
z-index: ${theme.maxZIndex + 1};
|
|
78
|
+
`;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const makeNotificationStyles = cache(function makeNotificationStyles(k: string) {
|
|
82
|
+
return css`
|
|
83
|
+
.${k}-notification-container {
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
position: relative;
|
|
87
|
+
box-shadow: ${notification.boxShadow};
|
|
88
|
+
border-radius: ${notification.borderRadius};
|
|
89
|
+
margin-bottom: ${notification.gap};
|
|
90
|
+
pointer-events: all;
|
|
91
|
+
min-width: ${notification.minWidth};
|
|
92
|
+
max-width: ${notification.maxWidth};
|
|
93
|
+
width: ${notification.width};
|
|
94
|
+
background: ${notification.bgColor};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.${k}-notification-wrapper {
|
|
98
|
+
position: relative;
|
|
99
|
+
display: flex;
|
|
100
|
+
gap: ${notification.gap};
|
|
101
|
+
padding: ${notification.padding};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.${k}-notification-icon {
|
|
105
|
+
.${k}-icon {
|
|
106
|
+
font-size: ${notification.icon.fontSize};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.${k}-notification-content {
|
|
111
|
+
flex: 1;
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.${k}-notification-title {
|
|
117
|
+
font-size: ${notification.titleFontSize};
|
|
118
|
+
font-weight: ${notification.titleFontWeight};
|
|
119
|
+
color: ${notification.titleColor};
|
|
120
|
+
margin-bottom: ${notification.titleMarginBottom};
|
|
121
|
+
line-height: ${notification.bodyLineHeight};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.${k}-notification-body {
|
|
125
|
+
font-size: ${notification.fontSize};
|
|
126
|
+
color: ${notification.contentColor};
|
|
127
|
+
line-height: ${notification.bodyLineHeight};
|
|
128
|
+
word-break: break-word;
|
|
129
|
+
word-wrap: break-word;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.${k}-notification-close {
|
|
133
|
+
position: absolute;
|
|
134
|
+
right: ${notification.close.right};
|
|
135
|
+
top: ${notification.close.top};
|
|
136
|
+
width: ${notification.close.width};
|
|
137
|
+
height: ${notification.close.height};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 过渡动画 - 右侧位置(topRight, bottomRight)
|
|
141
|
+
&.${k}-position-topRight.transition-enter-from,
|
|
142
|
+
&.${k}-position-bottomRight.transition-enter-from,
|
|
143
|
+
&.${k}-position-topRight.transition-leave-to,
|
|
144
|
+
&.${k}-position-bottomRight.transition-leave-to {
|
|
145
|
+
opacity: 0;
|
|
146
|
+
transform: ${notification.rightTransform};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 过渡动画 - 左侧位置(topLeft, bottomLeft)
|
|
150
|
+
&.${k}-position-topLeft.transition-enter-from,
|
|
151
|
+
&.${k}-position-bottomLeft.transition-enter-from,
|
|
152
|
+
&.${k}-position-topLeft.transition-leave-to,
|
|
153
|
+
&.${k}-position-bottomLeft.transition-leave-to {
|
|
154
|
+
opacity: 0;
|
|
155
|
+
transform: ${notification.leftTransform};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// 过渡动画 - 中间位置(top, bottom)
|
|
159
|
+
&.${k}-position-top.transition-enter-from,
|
|
160
|
+
&.${k}-position-top.transition-leave-to {
|
|
161
|
+
opacity: 0;
|
|
162
|
+
transform: ${notification.topTransform};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&.${k}-position-bottom.transition-enter-from,
|
|
166
|
+
&.${k}-position-bottom.transition-leave-to {
|
|
167
|
+
opacity: 0;
|
|
168
|
+
transform: ${notification.bottomTransform};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
&.transition-enter-active,
|
|
172
|
+
&.transition-leave-active {
|
|
173
|
+
transition: transform ${notification.transition}, opacity ${notification.transition};
|
|
174
|
+
}
|
|
175
|
+
&.transition-move {
|
|
176
|
+
transition: transform ${notification.transition};
|
|
177
|
+
}
|
|
178
|
+
`;
|
|
179
|
+
});
|
|
@@ -313,6 +313,8 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
|
|
|
313
313
|
height: ${select.card.height};
|
|
314
314
|
.${k}-tabs {
|
|
315
315
|
border: none;
|
|
316
|
+
border-top-right-radius: 0;
|
|
317
|
+
border-bottom-right-radius: 0;
|
|
316
318
|
overflow: auto;
|
|
317
319
|
}
|
|
318
320
|
.${k}-select-group {
|
|
Binary file
|
|
@@ -16,10 +16,16 @@ import {Table, TableColumn} from 'kpc';
|
|
|
16
16
|
</Table>
|
|
17
17
|
<p>无数据展示</p>
|
|
18
18
|
<Table data={this.get('data2')} resizable>
|
|
19
|
-
<TableColumn key="a" title="Title 1" />
|
|
20
|
-
<TableColumn key="b" title="Title 2"
|
|
19
|
+
<TableColumn key="a" title="Title 1" hidden />
|
|
20
|
+
<TableColumn key="b" title="Title 2" />
|
|
21
21
|
<TableColumn key="c" title="Title 3"/>
|
|
22
22
|
</Table>
|
|
23
|
+
<Table data={this.get('data2')} resizable checkType="none">
|
|
24
|
+
<TableColumn key="a" title="Title 1" hidden />
|
|
25
|
+
<TableColumn key="b" title="Title 2" />
|
|
26
|
+
<TableColumn key="c" title="Title 3" hidden />
|
|
27
|
+
<TableColumn key="d" title="Title 4"/>
|
|
28
|
+
</Table>
|
|
23
29
|
</div>
|
|
24
30
|
```
|
|
25
31
|
|
|
@@ -71,13 +71,13 @@ export default class extends Component<Props> {
|
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
```vue-methods
|
|
74
|
-
_onSort(
|
|
74
|
+
_onSort(sort?: TableSortValue<'name' | 'age'>) {
|
|
75
75
|
console.log(sort);
|
|
76
76
|
const data = this.data.slice(0);
|
|
77
77
|
data.sort((a, b) => {
|
|
78
|
-
return sort
|
|
79
|
-
(a[sort
|
|
80
|
-
(a[sort
|
|
78
|
+
return sort!.type === 'desc' ?
|
|
79
|
+
(a[sort!.key!] > b[sort!.key!] ? -1 : 1) :
|
|
80
|
+
(a[sort!.key!] > b[sort!.key!] ? 1 : -1);
|
|
81
81
|
});
|
|
82
82
|
this.data = data;
|
|
83
83
|
this.sort = sort;
|
|
@@ -128,7 +128,9 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
128
128
|
position: relative;
|
|
129
129
|
background: ${table.thead.bgColor};
|
|
130
130
|
line-height: normal;
|
|
131
|
+
// hide all :before firstly, then show all :before except first th
|
|
131
132
|
&:before {
|
|
133
|
+
display: none;
|
|
132
134
|
content: '';
|
|
133
135
|
height: ${table.thead.delimiterHeight};
|
|
134
136
|
position: absolute;
|
|
@@ -141,8 +143,10 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
141
143
|
&.${k}-fixed-right:before {
|
|
142
144
|
left: -2px;
|
|
143
145
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
}
|
|
147
|
+
&:not(.${k}-grid) {
|
|
148
|
+
th:not(.${k}-hidden) ~ th:not(.${k}-hidden):before {
|
|
149
|
+
display: block;
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
152
|
.${k}-table-title {
|
|
@@ -16,21 +16,21 @@ export function useActiveBar() {
|
|
|
16
16
|
const element = findDomFromVNode(instance.$lastInput!, true) as HTMLElement;
|
|
17
17
|
const { k } = instance.config;
|
|
18
18
|
const activeTab = element.querySelector(`.${k}-tab.${k}-active`) as HTMLElement | null;
|
|
19
|
+
const vertical = instance.get('vertical');
|
|
19
20
|
|
|
20
21
|
if (!activeTab) {
|
|
21
22
|
const oldStyles = styles.value;
|
|
22
23
|
if (oldStyles) {
|
|
23
24
|
styles.set(oldStyles.left ?
|
|
24
25
|
{left: oldStyles.left, width: '0'} :
|
|
25
|
-
{top: oldStyles.top,
|
|
26
|
+
{top: oldStyles.top, height: '0'}
|
|
26
27
|
);
|
|
27
28
|
} else {
|
|
28
|
-
styles.set(
|
|
29
|
+
styles.set(vertical ? {height: '0'} : {width: '0'});
|
|
29
30
|
}
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
const vertical = instance.get('vertical');
|
|
34
34
|
if (!vertical) {
|
|
35
35
|
const width = activeTab.offsetWidth;
|
|
36
36
|
const left = activeTab.offsetLeft;
|
package/components/tag/base.ts
CHANGED
|
@@ -4,9 +4,11 @@ import template from './index.vdt';
|
|
|
4
4
|
import {sizes, Sizes} from '../../styles/utils';
|
|
5
5
|
import type {Events, Colors} from '../types';
|
|
6
6
|
import { useConfigContext } from '../config';
|
|
7
|
+
import { useColor } from './useColor';
|
|
7
8
|
|
|
8
9
|
export interface TagProps {
|
|
9
10
|
type?: Colors
|
|
11
|
+
color?: Colors | 'purple' | 'teal' | 'blue' | 'yellow' | string
|
|
10
12
|
closable?: boolean
|
|
11
13
|
closed?: boolean
|
|
12
14
|
disabled?: boolean
|
|
@@ -22,6 +24,7 @@ export interface TagBlocks { }
|
|
|
22
24
|
|
|
23
25
|
export const typeDefs: Required<TypeDefs<TagProps>> = {
|
|
24
26
|
type: ['default', 'primary', 'danger', 'success', 'warning'],
|
|
27
|
+
color: String,
|
|
25
28
|
closable: Boolean,
|
|
26
29
|
closed: Boolean,
|
|
27
30
|
disabled: Boolean,
|
|
@@ -50,6 +53,7 @@ export class Tag<
|
|
|
50
53
|
static events = events;
|
|
51
54
|
|
|
52
55
|
private config = useConfigContext();
|
|
56
|
+
private tagColor = useColor();
|
|
53
57
|
|
|
54
58
|
@bind
|
|
55
59
|
private onClose(e: MouseEvent): void {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 颜色
|
|
3
|
+
order: 3
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`color` 属性支持 `type` 的所有类型、内置颜色(`purple`, `teal`, `blue`, `yellow`)或自定义颜色值。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Tag} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div class="container">
|
|
12
|
+
<Tag v-for={this.get('colors')} color={$value}>
|
|
13
|
+
{$value}
|
|
14
|
+
</Tag>
|
|
15
|
+
</div>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```styl
|
|
19
|
+
.container
|
|
20
|
+
display flex
|
|
21
|
+
gap 8px
|
|
22
|
+
flex-wrap wrap
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import {TagProps} from 'kpc';
|
|
27
|
+
|
|
28
|
+
interface Props {
|
|
29
|
+
colors: string[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default class extends Component {
|
|
33
|
+
static template = template;
|
|
34
|
+
static defaults() {
|
|
35
|
+
return {
|
|
36
|
+
colors: ['default', 'primary', 'danger', 'success', 'warning', 'purple', 'teal', 'blue', 'yellow', '#f50', '#87d068', 'rgb(255, 0, 179)'],
|
|
37
|
+
} as Props;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
package/components/tag/index.md
CHANGED
|
@@ -12,6 +12,7 @@ sidebar: doc
|
|
|
12
12
|
| 属性 | 说明 | 类型 | 默认值 |
|
|
13
13
|
| --- | --- | --- | --- |
|
|
14
14
|
| type | 组件类型 | `"default"` | `"primary"` | `"success"` | `"warning"` | `"danger"` | `"default"` |
|
|
15
|
+
| color | 颜色 | `"default"` | `"primary"` | `"success"` | `"warning"` | `"danger"` | `"purple"` | `"teal"` | `"blue"` | `"yellow"` | `undefined` |
|
|
15
16
|
| closable | 是否可关闭 | `boolean` | `false` |
|
|
16
17
|
| closed | 是否已关闭 | `boolean` | `false` |
|
|
17
18
|
| disabled | 是否展示禁用状态 | `boolean` | `false` |
|
|
@@ -2,6 +2,7 @@ import ClosableDemo from '~/components/tag/demos/closable';
|
|
|
2
2
|
import {mount, unmount, wait, dispatchEvent, getElement} from '../../test/utils';
|
|
3
3
|
import TagsDemo from '~/components/tag/demos/tags';
|
|
4
4
|
import DraggableDemo from '~/components/tag/demos/draggable';
|
|
5
|
+
import ColorDemo from '~/components/tag/demos/color';
|
|
5
6
|
|
|
6
7
|
describe('Tag', () => {
|
|
7
8
|
afterEach(() => unmount());
|
|
@@ -86,4 +87,11 @@ describe('Tag', () => {
|
|
|
86
87
|
// should not drag to other tags
|
|
87
88
|
await test(tag11, tag2);
|
|
88
89
|
});
|
|
90
|
+
|
|
91
|
+
it('should support color property', async () => {
|
|
92
|
+
const [instance, element] = mount(ColorDemo);
|
|
93
|
+
await wait();
|
|
94
|
+
|
|
95
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
96
|
+
});
|
|
89
97
|
});
|
package/components/tag/index.vdt
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import {Icon} from '../icon';
|
|
2
|
-
import {getRestProps} from '../utils';
|
|
2
|
+
import {addStyle, getRestProps} from '../utils';
|
|
3
3
|
import {makeStyles} from './styles';
|
|
4
4
|
import {Transition} from 'intact';
|
|
5
5
|
|
|
6
6
|
const {
|
|
7
7
|
className, children, type, border,
|
|
8
|
-
disabled, closable, closed, size
|
|
8
|
+
disabled, closable, closed, size, style
|
|
9
9
|
} = this.get();
|
|
10
10
|
const { k } = this.config;
|
|
11
|
+
const { colorClassName, customStyle, iconColor } = this.tagColor;
|
|
11
12
|
|
|
12
13
|
const classNameObj = {
|
|
13
14
|
[`${k}-tag`]: !$props.className,
|
|
14
15
|
[className]: className,
|
|
15
|
-
[`${k}-${
|
|
16
|
+
[`${k}-${colorClassName.value}`]: colorClassName.value,
|
|
16
17
|
[`${k}-${size}`]: size !== 'default',
|
|
17
18
|
[`${k}-${border}`]: border,
|
|
18
19
|
[`${k}-disabled`]: disabled,
|
|
@@ -25,11 +26,12 @@ const classNameObj = {
|
|
|
25
26
|
<div v-if={!closed}
|
|
26
27
|
class={classNameObj}
|
|
27
28
|
{...getRestProps(this)}
|
|
29
|
+
style={addStyle(style, customStyle.value)}
|
|
28
30
|
>
|
|
29
31
|
<b:body>{children}</b:body>
|
|
30
32
|
<b:_close>
|
|
31
33
|
<Icon class={`${k}-tag-close ion-ios-close-empty`}
|
|
32
|
-
color={
|
|
34
|
+
color={iconColor.value}
|
|
33
35
|
hoverable={!disabled}
|
|
34
36
|
v-if={closable}
|
|
35
37
|
ev-click={this.onClose}
|
package/components/tag/styles.ts
CHANGED
|
@@ -10,8 +10,14 @@ type TypeStyles = {
|
|
|
10
10
|
color: string
|
|
11
11
|
bgColor: string
|
|
12
12
|
}
|
|
13
|
+
type Colors = ValueOf<typeof colors>
|
|
14
|
+
type ColorStyles = {
|
|
15
|
+
color: string
|
|
16
|
+
bgColor: string
|
|
17
|
+
}
|
|
13
18
|
|
|
14
19
|
const types = ['primary', 'warning', 'danger', 'success', 'disabled'] as const;
|
|
20
|
+
const colors = ['purple', 'teal', 'blue', 'yellow'] as const;
|
|
15
21
|
|
|
16
22
|
const defaults = deepDefaults(
|
|
17
23
|
{
|
|
@@ -79,6 +85,13 @@ const defaults = deepDefaults(
|
|
|
79
85
|
};
|
|
80
86
|
return memo;
|
|
81
87
|
}, {} as {[key in Exclude<Types, 'disabled'>]: TypeStyles}),
|
|
88
|
+
colors.reduce((memo, color) => {
|
|
89
|
+
memo[color] = {
|
|
90
|
+
get color() { return theme.color[color] },
|
|
91
|
+
get bgColor() { return palette(theme.color[color], -4)}
|
|
92
|
+
};
|
|
93
|
+
return memo;
|
|
94
|
+
}, {} as {[key in Colors]: ColorStyles}),
|
|
82
95
|
);
|
|
83
96
|
|
|
84
97
|
let tag: typeof defaults;
|
|
@@ -110,6 +123,16 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
110
123
|
background: ${tag.none.bgColor};
|
|
111
124
|
}
|
|
112
125
|
|
|
126
|
+
${colors.map(c => {
|
|
127
|
+
return css`
|
|
128
|
+
&.${k}-${c} {
|
|
129
|
+
color: ${tag[c].color};
|
|
130
|
+
border-color: ${tag[c].color};
|
|
131
|
+
background: ${tag[c].bgColor};
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
})}
|
|
135
|
+
|
|
113
136
|
${types.map(t => {
|
|
114
137
|
const styles = tag[t];
|
|
115
138
|
return css`
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useInstance } from 'intact';
|
|
2
|
+
import type { Tag } from './base';
|
|
3
|
+
import { palette } from '../../styles/utils';
|
|
4
|
+
import { useState } from '../../hooks/useState';
|
|
5
|
+
import { useReceive } from '../../hooks/useReceive';
|
|
6
|
+
import { theme } from '../../styles/theme';
|
|
7
|
+
|
|
8
|
+
// type 支持的颜色
|
|
9
|
+
const TYPE_COLORS = ['default', 'primary', 'danger', 'success', 'warning'] as const;
|
|
10
|
+
// color 支持的扩展内置颜色
|
|
11
|
+
const EXTENDED_COLORS = ['purple', 'teal', 'blue', 'yellow'] as const;
|
|
12
|
+
// 所有内置颜色
|
|
13
|
+
const BUILT_IN_COLORS = [...TYPE_COLORS, ...EXTENDED_COLORS] as const;
|
|
14
|
+
|
|
15
|
+
export function getIconColorValue(color: string | undefined, disabled: boolean | undefined): string | undefined {
|
|
16
|
+
if (disabled) return theme.color.disabled;
|
|
17
|
+
if (!color || color === 'default') return 'default';
|
|
18
|
+
if (BUILT_IN_COLORS.includes(color as any)) {
|
|
19
|
+
const themeColor = theme.color[color as keyof typeof theme.color];
|
|
20
|
+
return themeColor;
|
|
21
|
+
}
|
|
22
|
+
return color;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function useColor() {
|
|
26
|
+
const instance = useInstance() as Tag;
|
|
27
|
+
|
|
28
|
+
const effectiveColor = useState<string | undefined>(undefined);
|
|
29
|
+
const colorClassName = useState<string | undefined>(undefined);
|
|
30
|
+
const customStyle = useState<Record<string, string>>({});
|
|
31
|
+
const iconColor = useState<string | undefined>(undefined);
|
|
32
|
+
|
|
33
|
+
function updateColor() {
|
|
34
|
+
const { color, type, disabled } = instance.get();
|
|
35
|
+
const _effectiveColor = color || (TYPE_COLORS.includes(type as any) ? type : undefined); // color优先
|
|
36
|
+
|
|
37
|
+
effectiveColor.set(_effectiveColor);
|
|
38
|
+
|
|
39
|
+
const isBuiltIn = _effectiveColor ? BUILT_IN_COLORS.includes(_effectiveColor as any) : false;
|
|
40
|
+
|
|
41
|
+
// 内置颜色 - 更新 colorClassName
|
|
42
|
+
if (_effectiveColor && isBuiltIn && _effectiveColor !== 'default') {
|
|
43
|
+
colorClassName.set(_effectiveColor);
|
|
44
|
+
} else {
|
|
45
|
+
colorClassName.set(undefined);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 自定义颜色 - 更新 customStyle
|
|
49
|
+
if (_effectiveColor && !isBuiltIn && !disabled) {
|
|
50
|
+
const bgColor = palette(_effectiveColor, -4);
|
|
51
|
+
customStyle.set({
|
|
52
|
+
color: _effectiveColor,
|
|
53
|
+
borderColor: _effectiveColor,
|
|
54
|
+
backgroundColor: bgColor
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
customStyle.set({});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 更新 iconColor
|
|
61
|
+
if (!_effectiveColor && !disabled) {
|
|
62
|
+
iconColor.set('default');
|
|
63
|
+
} else {
|
|
64
|
+
const _iconColor = getIconColorValue(_effectiveColor, disabled);
|
|
65
|
+
iconColor.set(_iconColor);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
useReceive<Tag>(['color', 'type', 'disabled'], updateColor);
|
|
70
|
+
|
|
71
|
+
updateColor();
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
effectiveColor,
|
|
75
|
+
colorClassName,
|
|
76
|
+
customStyle,
|
|
77
|
+
iconColor,
|
|
78
|
+
};
|
|
79
|
+
}
|