@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.
Files changed (281) hide show
  1. package/components/.DS_Store +0 -0
  2. package/components/anchor/constants.ts +3 -0
  3. package/components/anchor/demos/basic.md +34 -0
  4. package/components/anchor/demos/container.md +76 -0
  5. package/components/anchor/demos/events.md +100 -0
  6. package/components/anchor/demos/horizontal.md +33 -0
  7. package/components/anchor/demos/nested.md +132 -0
  8. package/components/anchor/index.md +38 -0
  9. package/components/anchor/index.spec.ts +171 -0
  10. package/components/anchor/index.ts +159 -0
  11. package/components/anchor/index.vdt +24 -0
  12. package/components/anchor/link.ts +44 -0
  13. package/components/anchor/link.vdt +49 -0
  14. package/components/anchor/styles.ts +50 -0
  15. package/components/anchor/useScroll.ts +221 -0
  16. package/components/config/demos/basic.md +11 -3
  17. package/components/descriptions/.DS_Store +0 -0
  18. package/components/dialog/base.vdt +3 -1
  19. package/components/drawer/demos/resizable.md +67 -0
  20. package/components/drawer/index.md +1 -0
  21. package/components/drawer/index.spec.ts +43 -0
  22. package/components/drawer/index.ts +14 -0
  23. package/components/drawer/index.vdt +20 -3
  24. package/components/drawer/styles.ts +44 -0
  25. package/components/drawer/useDrawerResizable.ts +190 -0
  26. package/components/icon/demos/color.md +1 -1
  27. package/components/icon/demos/icons.md +18 -0
  28. package/components/menu/.DS_Store +0 -0
  29. package/components/menu/demos/.DS_Store +0 -0
  30. package/components/menu/demos/collapse.md +2 -2
  31. package/components/menu/demos/showCollapseArrow.md +3 -3
  32. package/components/menu/demos/size.md +4 -4
  33. package/components/menu/styles.ts +7 -3
  34. package/components/notification/demos/basic.md +27 -0
  35. package/components/notification/demos/close.md +52 -0
  36. package/components/notification/demos/duration.md +43 -0
  37. package/components/notification/demos/events.md +39 -0
  38. package/components/notification/demos/hideClose.md +30 -0
  39. package/components/notification/demos/icon.md +47 -0
  40. package/components/notification/demos/position.md +39 -0
  41. package/components/notification/demos/types.md +38 -0
  42. package/components/notification/index.md +62 -0
  43. package/components/notification/index.spec.ts +211 -0
  44. package/components/notification/index.ts +2 -0
  45. package/components/notification/notification.ts +185 -0
  46. package/components/notification/notification.vdt +62 -0
  47. package/components/notification/notifications.ts +46 -0
  48. package/components/notification/notifications.vdt +16 -0
  49. package/components/notification/styles.ts +179 -0
  50. package/components/select/styles.ts +2 -0
  51. package/components/table/.DS_Store +0 -0
  52. package/components/table/demos/hidden.md +8 -2
  53. package/components/table/demos/sort.md +4 -4
  54. package/components/table/styles.ts +6 -2
  55. package/components/tabs/useActiveBar.ts +3 -3
  56. package/components/tag/base.ts +4 -0
  57. package/components/tag/demos/border.md +1 -1
  58. package/components/tag/demos/color.md +40 -0
  59. package/components/tag/demos/draggable.md +1 -1
  60. package/components/tag/demos/tags.md +1 -1
  61. package/components/tag/index.md +1 -0
  62. package/components/tag/index.spec.ts +8 -0
  63. package/components/tag/index.vdt +6 -4
  64. package/components/tag/styles.ts +23 -0
  65. package/components/tag/useColor.ts +79 -0
  66. package/components/timepicker/index.spec.ts +16 -5
  67. package/components/timepicker/useDefaultValue.ts +16 -7
  68. package/components/timepicker/useStep.ts +3 -2
  69. package/components/tour/.DS_Store +0 -0
  70. package/components/transfer/demos/customFilter.md +1 -1
  71. package/components/transfer/demos/customList.md +1 -1
  72. package/components/transfer/demos/getData.md +1 -1
  73. package/components/transfer/demos/leftChecked.md +1 -1
  74. package/components/transfer/demos/pagination.md +63 -0
  75. package/components/transfer/demos/table.md +248 -0
  76. package/components/transfer/demos/tree.md +1 -1
  77. package/components/transfer/index.md +2 -0
  78. package/components/transfer/index.spec.ts +147 -0
  79. package/components/transfer/index.ts +7 -0
  80. package/components/transfer/index.vdt +30 -4
  81. package/components/transfer/styles.ts +11 -1
  82. package/components/transfer/useCheck.ts +5 -5
  83. package/components/transfer/usePagination.ts +92 -0
  84. package/components/virtualList/.DS_Store +0 -0
  85. package/components/virtualList/demos/.DS_Store +0 -0
  86. package/dist/fonts/iconfont.eot +0 -0
  87. package/dist/fonts/iconfont.svg +235 -0
  88. package/dist/fonts/iconfont.ttf +0 -0
  89. package/dist/fonts/iconfont.woff +0 -0
  90. package/dist/fonts/iconfont.woff2 +0 -0
  91. package/dist/fonts/ionicons.eot +0 -0
  92. package/dist/fonts/ionicons.svg +2230 -0
  93. package/dist/fonts/ionicons.ttf +0 -0
  94. package/dist/fonts/ionicons.woff +0 -0
  95. package/dist/fonts/ionicons.woff2 +0 -0
  96. package/dist/i18n/en-US.js +1411 -0
  97. package/dist/i18n/en-US.js.map +1 -0
  98. package/dist/i18n/en-US.min.js +1 -0
  99. package/dist/i18n/index.js +283 -0
  100. package/dist/i18n/index.js.map +1 -0
  101. package/dist/i18n/index.min.js +1 -0
  102. package/dist/kpc.js +50764 -0
  103. package/dist/kpc.js.map +1 -0
  104. package/dist/kpc.min.js +1 -0
  105. package/dist/kpc.react.js +58380 -0
  106. package/dist/kpc.react.js.map +1 -0
  107. package/dist/kpc.react.min.js +1 -0
  108. package/dist/kpc.tmp.js.map +1 -0
  109. package/dist/kpc.vue-legacy.js +58272 -0
  110. package/dist/kpc.vue-legacy.js.map +1 -0
  111. package/dist/kpc.vue-legacy.min.js +1 -0
  112. package/dist/kpc.vue.js +58128 -0
  113. package/dist/kpc.vue.js.map +1 -0
  114. package/dist/kpc.vue.min.js +1 -0
  115. package/es/components/anchor/constants.d.ts +2 -0
  116. package/es/components/anchor/constants.js +2 -0
  117. package/es/components/anchor/index.d.ts +41 -0
  118. package/es/components/anchor/index.js +141 -0
  119. package/es/components/anchor/index.spec.d.ts +1 -0
  120. package/es/components/anchor/index.spec.js +230 -0
  121. package/es/components/anchor/index.vdt.js +31 -0
  122. package/es/components/anchor/link.d.ts +16 -0
  123. package/es/components/anchor/link.js +52 -0
  124. package/es/components/anchor/link.vdt.js +49 -0
  125. package/es/components/anchor/styles.d.ts +5 -0
  126. package/es/components/anchor/styles.js +30 -0
  127. package/es/components/anchor/useScroll.d.ts +7 -0
  128. package/es/components/anchor/useScroll.js +218 -0
  129. package/es/components/dialog/base.vdt.js +1 -1
  130. package/es/components/drawer/index.d.ts +3 -0
  131. package/es/components/drawer/index.js +22 -3
  132. package/es/components/drawer/index.spec.js +83 -0
  133. package/es/components/drawer/index.vdt.js +23 -3
  134. package/es/components/drawer/styles.js +1 -1
  135. package/es/components/drawer/useDrawerResizable.d.ts +10 -0
  136. package/es/components/drawer/useDrawerResizable.js +162 -0
  137. package/es/components/menu/styles.d.ts +1 -0
  138. package/es/components/menu/styles.js +4 -1
  139. package/es/components/notification/index.d.ts +1 -0
  140. package/es/components/notification/index.js +1 -0
  141. package/es/components/notification/index.spec.d.ts +1 -0
  142. package/es/components/notification/index.spec.js +317 -0
  143. package/es/components/notification/notification.d.ts +39 -0
  144. package/es/components/notification/notification.js +183 -0
  145. package/es/components/notification/notification.vdt.js +56 -0
  146. package/es/components/notification/notifications.d.ts +16 -0
  147. package/es/components/notification/notifications.js +51 -0
  148. package/es/components/notification/notifications.vdt.js +24 -0
  149. package/es/components/notification/styles.d.ts +9 -0
  150. package/es/components/notification/styles.js +110 -0
  151. package/es/components/select/styles.js +1 -1
  152. package/es/components/table/styles.js +1 -1
  153. package/es/components/tabs/useActiveBar.js +7 -3
  154. package/es/components/tag/base.d.ts +2 -0
  155. package/es/components/tag/base.js +3 -0
  156. package/es/components/tag/index.spec.js +17 -0
  157. package/es/components/tag/index.vdt.js +12 -5
  158. package/es/components/tag/styles.d.ts +9 -0
  159. package/es/components/tag/styles.js +14 -1
  160. package/es/components/tag/useColor.d.ts +7 -0
  161. package/es/components/tag/useColor.js +71 -0
  162. package/es/components/timepicker/index.spec.js +70 -42
  163. package/es/components/timepicker/useDefaultValue.js +12 -7
  164. package/es/components/timepicker/useStep.js +4 -2
  165. package/es/components/transfer/index.d.ts +13 -0
  166. package/es/components/transfer/index.js +6 -2
  167. package/es/components/transfer/index.spec.js +197 -0
  168. package/es/components/transfer/index.vdt.js +28 -5
  169. package/es/components/transfer/styles.js +4 -1
  170. package/es/components/transfer/useCheck.js +2 -1
  171. package/es/components/transfer/usePagination.d.ts +12 -0
  172. package/es/components/transfer/usePagination.js +79 -0
  173. package/es/index.d.ts +4 -2
  174. package/es/index.js +4 -2
  175. package/es/site/data/components/anchor/demos/basic/index.d.ts +11 -0
  176. package/es/site/data/components/anchor/demos/basic/index.js +18 -0
  177. package/es/site/data/components/anchor/demos/basic/react.d.ts +11 -0
  178. package/es/site/data/components/anchor/demos/basic/react.js +46 -0
  179. package/es/site/data/components/anchor/demos/container/index.d.ts +12 -0
  180. package/es/site/data/components/anchor/demos/container/index.js +19 -0
  181. package/es/site/data/components/anchor/demos/container/react.d.ts +12 -0
  182. package/es/site/data/components/anchor/demos/container/react.js +52 -0
  183. package/es/site/data/components/anchor/demos/events/index.d.ts +17 -0
  184. package/es/site/data/components/anchor/demos/events/index.js +36 -0
  185. package/es/site/data/components/anchor/demos/events/react.d.ts +17 -0
  186. package/es/site/data/components/anchor/demos/events/react.js +88 -0
  187. package/es/site/data/components/anchor/demos/horizontal/index.d.ts +11 -0
  188. package/es/site/data/components/anchor/demos/horizontal/index.js +18 -0
  189. package/es/site/data/components/anchor/demos/horizontal/react.d.ts +11 -0
  190. package/es/site/data/components/anchor/demos/horizontal/react.js +46 -0
  191. package/es/site/data/components/anchor/demos/nested/index.d.ts +12 -0
  192. package/es/site/data/components/anchor/demos/nested/index.js +19 -0
  193. package/es/site/data/components/anchor/demos/nested/react.d.ts +12 -0
  194. package/es/site/data/components/anchor/demos/nested/react.js +100 -0
  195. package/es/site/data/components/anchor/index.d.ts +57 -0
  196. package/es/site/data/components/anchor/index.js +32 -0
  197. package/es/site/data/components/config/demos/basic/index.d.ts +1 -0
  198. package/es/site/data/components/config/demos/basic/index.js +8 -1
  199. package/es/site/data/components/config/demos/basic/react.d.ts +1 -0
  200. package/es/site/data/components/config/demos/basic/react.js +15 -3
  201. package/es/site/data/components/drawer/demos/resizable/index.d.ts +15 -0
  202. package/es/site/data/components/drawer/demos/resizable/index.js +26 -0
  203. package/es/site/data/components/drawer/demos/resizable/react.d.ts +15 -0
  204. package/es/site/data/components/drawer/demos/resizable/react.js +63 -0
  205. package/es/site/data/components/icon/demos/icons/index.js +1 -1
  206. package/es/site/data/components/menu/demos/collapse/index.d.ts +6 -1
  207. package/es/site/data/components/menu/demos/collapse/react.d.ts +6 -1
  208. package/es/site/data/components/menu/demos/showCollapseArrow/index.d.ts +8 -1
  209. package/es/site/data/components/menu/demos/showCollapseArrow/react.d.ts +8 -1
  210. package/es/site/data/components/menu/demos/size/index.d.ts +7 -2
  211. package/es/site/data/components/menu/demos/size/react.d.ts +7 -2
  212. package/es/site/data/components/notification/demos/basic/index.d.ts +6 -0
  213. package/es/site/data/components/notification/demos/basic/index.js +21 -0
  214. package/es/site/data/components/notification/demos/basic/react.d.ts +5 -0
  215. package/es/site/data/components/notification/demos/basic/react.js +24 -0
  216. package/es/site/data/components/notification/demos/close/index.d.ts +13 -0
  217. package/es/site/data/components/notification/demos/close/index.js +38 -0
  218. package/es/site/data/components/notification/demos/close/react.d.ts +13 -0
  219. package/es/site/data/components/notification/demos/close/react.js +52 -0
  220. package/es/site/data/components/notification/demos/duration/index.d.ts +7 -0
  221. package/es/site/data/components/notification/demos/duration/index.js +33 -0
  222. package/es/site/data/components/notification/demos/duration/react.d.ts +6 -0
  223. package/es/site/data/components/notification/demos/duration/react.js +38 -0
  224. package/es/site/data/components/notification/demos/events/index.d.ts +6 -0
  225. package/es/site/data/components/notification/demos/events/index.js +31 -0
  226. package/es/site/data/components/notification/demos/events/react.d.ts +5 -0
  227. package/es/site/data/components/notification/demos/events/react.js +34 -0
  228. package/es/site/data/components/notification/demos/hideClose/index.d.ts +6 -0
  229. package/es/site/data/components/notification/demos/hideClose/index.js +25 -0
  230. package/es/site/data/components/notification/demos/hideClose/react.d.ts +5 -0
  231. package/es/site/data/components/notification/demos/hideClose/react.js +28 -0
  232. package/es/site/data/components/notification/demos/icon/index.d.ts +7 -0
  233. package/es/site/data/components/notification/demos/icon/index.js +33 -0
  234. package/es/site/data/components/notification/demos/icon/react.d.ts +6 -0
  235. package/es/site/data/components/notification/demos/icon/react.js +42 -0
  236. package/es/site/data/components/notification/demos/position/index.d.ts +9 -0
  237. package/es/site/data/components/notification/demos/position/index.js +27 -0
  238. package/es/site/data/components/notification/demos/position/react.d.ts +8 -0
  239. package/es/site/data/components/notification/demos/position/react.js +40 -0
  240. package/es/site/data/components/notification/demos/types/index.d.ts +9 -0
  241. package/es/site/data/components/notification/demos/types/index.js +26 -0
  242. package/es/site/data/components/notification/demos/types/react.d.ts +8 -0
  243. package/es/site/data/components/notification/demos/types/react.js +39 -0
  244. package/es/site/data/components/notification/index.d.ts +57 -0
  245. package/es/site/data/components/notification/index.js +32 -0
  246. package/es/site/data/components/table/demos/hidden/react.js +21 -3
  247. package/es/site/data/components/tag/demos/color/index.d.ts +10 -0
  248. package/es/site/data/components/tag/demos/color/index.js +19 -0
  249. package/es/site/data/components/tag/demos/color/react.d.ts +10 -0
  250. package/es/site/data/components/tag/demos/color/react.js +34 -0
  251. package/es/site/data/components/transfer/demos/pagination/index.d.ts +19 -0
  252. package/es/site/data/components/transfer/demos/pagination/index.js +42 -0
  253. package/es/site/data/components/transfer/demos/pagination/react.d.ts +20 -0
  254. package/es/site/data/components/transfer/demos/pagination/react.js +65 -0
  255. package/es/site/data/components/transfer/demos/table/index.d.ts +33 -0
  256. package/es/site/data/components/transfer/demos/table/index.js +132 -0
  257. package/es/site/data/components/transfer/demos/table/react.d.ts +35 -0
  258. package/es/site/data/components/transfer/demos/table/react.js +246 -0
  259. package/es/site/src/router/index.js +4 -33
  260. package/es/styles/fonts/iconfont.eot +0 -0
  261. package/es/styles/fonts/iconfont.js +1 -1
  262. package/es/styles/fonts/iconfont.svg +38 -0
  263. package/es/styles/fonts/iconfont.ttf +0 -0
  264. package/es/styles/fonts/iconfont.woff +0 -0
  265. package/es/styles/fonts/iconfont.woff2 +0 -0
  266. package/es/styles/theme.d.ts +8 -0
  267. package/es/styles/theme.js +5 -1
  268. package/index.ts +4 -2
  269. package/package.json +2 -2
  270. package/styles/.DS_Store +0 -0
  271. package/styles/fonts/demo_index.html +443 -6
  272. package/styles/fonts/iconfont.css +82 -6
  273. package/styles/fonts/iconfont.eot +0 -0
  274. package/styles/fonts/iconfont.js +1 -1
  275. package/styles/fonts/iconfont.json +133 -0
  276. package/styles/fonts/iconfont.svg +38 -0
  277. package/styles/fonts/iconfont.ts +76 -0
  278. package/styles/fonts/iconfont.ttf +0 -0
  279. package/styles/fonts/iconfont.woff +0 -0
  280. package/styles/fonts/iconfont.woff2 +0 -0
  281. 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" hidden/>
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(c, sort) {
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.type === 'desc' ?
79
- (a[sort.key] > b[sort.key] ? -1 : 1) :
80
- (a[sort.key] > b[sort.key] ? 1 : -1);
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
- &:first-of-type:before {
145
- display: none;
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, width: '0'}
26
+ {top: oldStyles.top, height: '0'}
26
27
  );
27
28
  } else {
28
- styles.set(null);
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;
@@ -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 {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: 边框
3
- order: 3
3
+ order: 4
4
4
  ---
5
5
 
6
6
  通过`border`可以定义边框样式: `solid` `dashed` `none`(默认)
@@ -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
+ ```
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: 标签可拖动
3
- order: 5
3
+ order: 6
4
4
  ---
5
5
 
6
6
  ```vdt
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: 标签组
3
- order: 4
3
+ order: 5
4
4
  ---
5
5
 
6
6
  使用`Tags`包裹`Tag`可以展示标签组,给`Tags`指定`nowrap`可以让标签自适应仅展示成一行,超出的部分会隐藏,
@@ -12,6 +12,7 @@ sidebar: doc
12
12
  | 属性 | 说明 | 类型 | 默认值 |
13
13
  | --- | --- | --- | --- |
14
14
  | type | 组件类型 | `"default"` &#124; `"primary"` &#124; `"success"` &#124; `"warning"` &#124; `"danger"` | `"default"` |
15
+ | color | 颜色 | `"default"` &#124; `"primary"` &#124; `"success"` &#124; `"warning"` &#124; `"danger"` &#124; `"purple"` &#124; `"teal"` &#124; `"blue"` &#124; `"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
  });
@@ -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}-${type}`]: type !== 'default',
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={type}
34
+ color={iconColor.value}
33
35
  hoverable={!disabled}
34
36
  v-if={closable}
35
37
  ev-click={this.onClose}
@@ -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
+ }