@king-design/intact 3.3.2 → 3.4.0-beta.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 (81) hide show
  1. package/components/button/demos/basic.md +5 -2
  2. package/components/button/demos/ghost.md +1 -0
  3. package/components/button/demos/group.md +7 -0
  4. package/components/button/group.ts +2 -0
  5. package/components/button/index.md +1 -0
  6. package/components/button/index.ts +2 -0
  7. package/components/button/index.vdt +12 -7
  8. package/components/button/styles.ts +31 -1
  9. package/components/dialog/alert.vdt +2 -3
  10. package/components/dialog/demos/static.md +18 -0
  11. package/components/switch/demos/beforeChange.md +52 -0
  12. package/components/switch/index.md +2 -0
  13. package/components/switch/index.spec.ts +11 -0
  14. package/components/switch/index.ts +28 -6
  15. package/components/switch/index.vdt +8 -2
  16. package/components/switch/styles.ts +15 -1
  17. package/components/table/cell.vdt +6 -1
  18. package/components/table/column.ts +2 -0
  19. package/components/table/column.vdt +2 -1
  20. package/components/table/demos/hidden.md +44 -0
  21. package/components/table/index.md +1 -0
  22. package/components/table/index.spec.ts +63 -0
  23. package/components/table/styles.ts +6 -3
  24. package/components/table/table.vdt +4 -2
  25. package/components/table/useChecked.ts +2 -1
  26. package/components/table/useColumns.ts +1 -1
  27. package/components/table/useDisableRow.ts +3 -1
  28. package/components/table/useMerge.ts +6 -1
  29. package/components/utils.ts +19 -0
  30. package/es/components/button/group.d.ts +1 -0
  31. package/es/components/button/group.js +2 -1
  32. package/es/components/button/index.d.ts +1 -0
  33. package/es/components/button/index.js +1 -0
  34. package/es/components/button/index.vdt.js +13 -6
  35. package/es/components/button/styles.d.ts +1 -1
  36. package/es/components/button/styles.js +3 -3
  37. package/es/components/dialog/alert.vdt.js +2 -2
  38. package/es/components/switch/index.d.ts +3 -1
  39. package/es/components/switch/index.js +65 -13
  40. package/es/components/switch/index.spec.js +21 -0
  41. package/es/components/switch/index.vdt.js +14 -4
  42. package/es/components/switch/styles.js +12 -7
  43. package/es/components/table/cell.vdt.js +3 -1
  44. package/es/components/table/column.d.ts +1 -0
  45. package/es/components/table/column.js +1 -0
  46. package/es/components/table/column.vdt.js +3 -2
  47. package/es/components/table/index.spec.js +313 -221
  48. package/es/components/table/styles.js +1 -1
  49. package/es/components/table/table.vdt.js +1 -1
  50. package/es/components/table/useChecked.js +3 -1
  51. package/es/components/table/useColumns.js +1 -1
  52. package/es/components/table/useDisableRow.js +3 -1
  53. package/es/components/table/useMerge.js +6 -1
  54. package/es/components/utils.js +17 -0
  55. package/es/i18n/en-US.js +6 -2
  56. package/es/index.d.ts +2 -2
  57. package/es/index.js +2 -2
  58. package/es/site/data/components/button/demos/basic/react.js +7 -1
  59. package/es/site/data/components/button/demos/ghost/react.js +3 -0
  60. package/es/site/data/components/button/demos/group/react.js +17 -0
  61. package/es/site/data/components/dialog/demos/static/index.d.ts +1 -0
  62. package/es/site/data/components/dialog/demos/static/index.js +15 -0
  63. package/es/site/data/components/dialog/demos/static/react.d.ts +1 -0
  64. package/es/site/data/components/dialog/demos/static/react.js +18 -1
  65. package/es/site/data/components/popover/demos/tooltip/index.d.ts +7 -0
  66. package/es/site/data/components/popover/demos/tooltip/index.js +21 -0
  67. package/es/site/data/components/popover/demos/tooltip/react.d.ts +6 -0
  68. package/es/site/data/components/popover/demos/tooltip/react.js +30 -0
  69. package/es/site/data/components/switch/demos/beforeChange/index.d.ts +12 -0
  70. package/es/site/data/components/switch/demos/beforeChange/index.js +39 -0
  71. package/es/site/data/components/switch/demos/beforeChange/react.d.ts +11 -0
  72. package/es/site/data/components/switch/demos/beforeChange/react.js +62 -0
  73. package/es/site/data/components/table/demos/hidden/index.d.ts +14 -0
  74. package/es/site/data/components/table/demos/hidden/index.js +28 -0
  75. package/es/site/data/components/table/demos/hidden/react.d.ts +13 -0
  76. package/es/site/data/components/table/demos/hidden/react.js +63 -0
  77. package/i18n/en-US.ts +5 -2
  78. package/index.ts +2 -2
  79. package/package.json +2 -2
  80. package/components/menu/.DS_Store +0 -0
  81. package/components/menu/demos/.DS_Store +0 -0
@@ -3,7 +3,7 @@ title: 按钮类型
3
3
  order: 0
4
4
  ---
5
5
 
6
- 有如下几种类型:默认按钮,主按钮,次按钮,警告按钮,危险按钮,成功按钮,文字按钮,超链接按钮,扁平按钮
6
+ 有如下几种类型:默认按钮,主按钮,次按钮,警告按钮,危险按钮,成功按钮,文字按钮,超链接按钮,扁平按钮, 自定义color按钮
7
7
 
8
8
  ```vdt
9
9
  import {Button} from 'kpc';
@@ -18,10 +18,13 @@ import {Button} from 'kpc';
18
18
  <Button type="none">none</Button>
19
19
  <Button type="link">link</Button>
20
20
  <Button type="flat">flat</Button>
21
+ <Button color="red">custom</Button>
22
+ <Button color="#0000ea">custom</Button>
23
+ <Button color="rgb(183, 18, 193)">custom</Button>
21
24
  </div>
22
25
  ```
23
26
 
24
27
  ```styl
25
28
  .k-btn
26
- margin-right 20px
29
+ margin 0 20px 20px 0
27
30
  ```
@@ -14,6 +14,7 @@ import {Button, Icon} from 'kpc';
14
14
  <Button type="warning" ghost>warning</Button>
15
15
  <Button type="danger" ghost>danger</Button>
16
16
  <Button type="success" ghost>success</Button>
17
+ <Button color="rgb(183, 18, 193)" ghost>custom</Button>
17
18
  <Button type="none" ghost>none</Button>
18
19
  <Button type="primary" ghost disabled>primay</Button>
19
20
  </div>
@@ -74,6 +74,13 @@ import {Button, ButtonGroup, Icon} from 'kpc';
74
74
  <Button value="guangzhou">广州</Button>
75
75
  <Button value="shenzhen">深圳</Button>
76
76
  </ButtonGroup>
77
+ <p>支持自定义ButtonGroup下的Button宽度</p>
78
+ <ButtonGroup checkType="radio" v-model="city" btnWidth="100px">
79
+ <Button value="beijing">北京</Button>
80
+ <Button value="shanghai">上海</Button>
81
+ <Button value="guangzhou">广州</Button>
82
+ <Button value="shenzhen">深圳</Button>
83
+ </ButtonGroup>
77
84
  </div>
78
85
  ```
79
86
 
@@ -10,6 +10,7 @@ export interface ButtonGroupProps {
10
10
  checkType?: 'none' | 'radio' | 'checkbox'
11
11
  fluid?: boolean
12
12
  seperate?: boolean
13
+ btnWidth?: number | string
13
14
  }
14
15
 
15
16
  const typeDefs: Required<TypeDefs<ButtonGroupProps>> = {
@@ -18,6 +19,7 @@ const typeDefs: Required<TypeDefs<ButtonGroupProps>> = {
18
19
  fluid: Boolean,
19
20
  checkType: ['none', 'radio', 'checkbox'],
20
21
  seperate: Boolean,
22
+ btnWidth: [Number, String],
21
23
  };
22
24
 
23
25
  const defaults = (): Partial<ButtonGroupProps> => ({
@@ -23,6 +23,7 @@ sidebar: doc
23
23
  | value | 对于`radio/checkbox`类型的按钮组,我们可以给每个按钮指定一个选中时的值 | `*` | `undefined` |
24
24
  | name | 对于`radio/checkbox`类型的按钮组,我们给`input`指定`name`属性 | `string` | `undefined` |
25
25
  | ghost | 展示透明背景的按钮 | `boolean` | `false` |
26
+ | color | 自定义字体、边框、波纹动效颜色 | `string` | `undefined` |
26
27
 
27
28
  ## ButtonGroup
28
29
 
@@ -26,6 +26,7 @@ export interface ButtonProps extends ButtonHTMLAttributes {
26
26
  size?: Sizes,
27
27
  icon?: boolean
28
28
  circle?: boolean
29
+ color?: string
29
30
  loading?: boolean
30
31
  disabled?: boolean
31
32
  fluid?: boolean
@@ -47,6 +48,7 @@ const typeDefs: Required<TypeDefs<Omit<ButtonProps, keyof ButtonHTMLAttributes>>
47
48
  size: ['large', 'default', 'small', 'mini'],
48
49
  icon: Boolean,
49
50
  circle: Boolean,
51
+ color: String,
50
52
  loading: Boolean,
51
53
  disabled: Boolean,
52
54
  fluid: Boolean,
@@ -1,4 +1,4 @@
1
- import {getRestProps} from '../utils';
1
+ import {addStyle, getRestProps} from '../utils';
2
2
  import {Icon} from '../icon';
3
3
  import {makeButtonStyles} from './styles';
4
4
  import {DynamicButton} from './dynamicButton';
@@ -8,7 +8,7 @@ import {button as theme} from './styles';
8
8
  let {
9
9
  type, className, size, icon, circle, ref, key, tabindex,
10
10
  tagName, htmlType, fluid, children, loading, disabled,
11
- name, ghost,
11
+ name, ghost, color, style
12
12
  } = this.get();
13
13
 
14
14
  const { cls, k } = this.config;
@@ -42,7 +42,7 @@ if (!icon && Array.isArray(children)) {
42
42
  const classNameObj = {
43
43
  [cls('btn')]: true,
44
44
  [cls(size)]: size !== 'default',
45
- [cls(type)]: true,
45
+ [cls(type)]: !color,
46
46
  [cls(`btn-icon`)]: icon,
47
47
  [className]: className,
48
48
  [cls('circle')]: circle,
@@ -51,7 +51,8 @@ const classNameObj = {
51
51
  [cls('active')]: checked,
52
52
  [cls('disabled')]: disabled || loading,
53
53
  [cls('ghost')]: ghost,
54
- [makeButtonStyles(k, iconSide)]: true,
54
+ [cls('custom')]: color,
55
+ [makeButtonStyles(k, iconSide, color)]: true,
55
56
  };
56
57
 
57
58
  const loadingIcon = (
@@ -63,11 +64,14 @@ const loadingIcon = (
63
64
  );
64
65
 
65
66
  const buttonGroup = this.buttonGroup;
66
- const checkType = buttonGroup ? buttonGroup.get('checkType') : 'none';
67
+ const checkType = buttonGroup?.get('checkType') ?? 'none';
68
+ const btnWidth = buttonGroup?.get('btnWidth');
69
+ const _style = {
70
+ width: typeof btnWidth === 'number' ? `${btnWidth}px` : btnWidth,
71
+ }
67
72
  const isCheckType = checkType !== 'none';
68
73
  const typeStyles = theme[type];
69
- const waveColor = typeStyles && typeStyles.borderColor || theme.primary.borderColor;
70
-
74
+ const waveColor = typeStyles && typeStyles.borderColor || color || theme.primary.borderColor;
71
75
  <Wave disabled={loading || disabled || type === 'none' || type === 'link'}
72
76
  inset={type === 'flat' ? '-1px' : '-2px'}
73
77
  color={waveColor}
@@ -76,6 +80,7 @@ const waveColor = typeStyles && typeStyles.borderColor || theme.primary.borderCo
76
80
  class={classNameObj}
77
81
  tagName={tagName}
78
82
  {...getRestProps(this)}
83
+ style={btnWidth ? addStyle(style, _style) : style}
79
84
  ref={this.elementRef}
80
85
  tabindex={disabled || loading ? '-1' : tabindex}
81
86
  ev-click={this.onClick}
@@ -157,7 +157,7 @@ setDefault(() => {
157
157
 
158
158
  export {button};
159
159
 
160
- export const makeButtonStyles = cache(function makeButtonStyles(k: string, iconSide?: string) {
160
+ export const makeButtonStyles = cache(function makeButtonStyles(k: string, iconSide?: string, color?: string) {
161
161
  const {secondary, link} = button;
162
162
 
163
163
  return cx(
@@ -247,6 +247,22 @@ export const makeButtonStyles = cache(function makeButtonStyles(k: string, iconS
247
247
  }
248
248
  }
249
249
 
250
+
251
+
252
+ ${color && css`
253
+ &.${k}-custom {
254
+ color: ${color};
255
+ border-color: ${color};
256
+ &:hover,
257
+ &:focus {
258
+ background: ${palette(color, -4)};
259
+ }
260
+ &:active {
261
+ background: ${palette(color, -3)};
262
+ }
263
+ }
264
+ `}
265
+
250
266
  &.${k}-link {
251
267
  color: ${link.color};
252
268
  &:hover {
@@ -395,6 +411,20 @@ export const makeButtonStyles = cache(function makeButtonStyles(k: string, iconS
395
411
  }
396
412
  `
397
413
  })}
414
+ ${color && css`
415
+ &.${k}-custom {
416
+ color: ${color};
417
+ border-color: ${color};
418
+ &:hover {
419
+ color: ${palette(color, -1)};
420
+ border-color: ${palette(color, -1)};
421
+ }
422
+ &:active {
423
+ color: ${palette(color, 1)};
424
+ border-color: ${palette(color, 1)};
425
+ }
426
+ }
427
+ `}
398
428
  // disabled
399
429
  &.${k}-disabled {
400
430
  &, &:hover {
@@ -24,11 +24,10 @@ const classNameObj = {
24
24
  v-if={!hideIcon && !icon}
25
25
  class={iconClassName || {
26
26
  [`${k}-icon-success-fill`]: type === 'success',
27
- [`${k}-icon-warning-fill`]: type === 'warning',
27
+ [`${k}-icon-warning-fill`]: type === 'warning' || type === 'confirm',
28
28
  [`${k}-icon-error-fill`]: type === 'error',
29
- [`${k}-icon-question-fill`]: type === 'confirm',
30
29
  }}
31
- color={type === 'error' ? 'danger' : type === 'confirm' ? 'primary' : type}
30
+ color={type === 'error' ? 'danger' : type === 'confirm' ? 'warning' : type}
32
31
  />
33
32
  {icon}
34
33
  </div>
@@ -29,6 +29,10 @@ import {Button, ButtonGroup} from 'kpc';
29
29
  ev-click={this.showDialogWithTitle.bind(this, $value)}
30
30
  >Show {$value[0].toUpperCase() + $value.substring(1)} Dialog with Title</Button>
31
31
  </ButtonGroup>
32
+
33
+ <br />
34
+ <br />
35
+ <Button ev-click={this.showAsyncCloseConfirm}>异步关闭confirm弹层</Button>
32
36
  </div>
33
37
  ```
34
38
 
@@ -69,5 +73,19 @@ export default class extends Component<Props> {
69
73
  Message.info('clicked cancel button');
70
74
  });
71
75
  }
76
+
77
+ showAsyncCloseConfirm() {
78
+ let dialog: Dialog;
79
+ Dialog.confirm({
80
+ content: '点击确认,异步关闭',
81
+ ref: (_dialog) => dialog = _dialog,
82
+ ok: () => {
83
+ dialog.showLoading();
84
+ setTimeout(() => {
85
+ dialog.close();
86
+ }, 3000);
87
+ },
88
+ });
89
+ }
72
90
  }
73
91
  ```
@@ -0,0 +1,52 @@
1
+ ---
2
+ title: 定义switch切换前的拦截函数
3
+ order: 8
4
+ ---
5
+
6
+ 给`Switch`添加`beforeChange`函数,来定义开关切换之前的逻辑,如果该函数返回`true`则成功切换,否则忽略本次切换
7
+
8
+ > 支持异步函数
9
+
10
+ ```vdt
11
+ import {Switch} from 'kpc';
12
+
13
+ <div>
14
+ <Switch v-model="value1" beforeChange={this.beforeChange} />
15
+ <Switch v-model="value2" beforeChange={this.beforeChangeFalse} />
16
+ </div>
17
+ ```
18
+
19
+ ```styl
20
+ .k-switch
21
+ margin-right 20px
22
+ ```
23
+
24
+ ```ts
25
+ import { Message } from 'kpc';
26
+ export default class extends Component {
27
+ static template = template;
28
+ static defaults() {
29
+ return {
30
+ value1: false,
31
+ value2: false,
32
+ }
33
+ }
34
+
35
+ beforeChange(value: any) {
36
+ return new Promise<boolean>(resolve => {
37
+ Message.warning(`current value is ${value}`);
38
+ setTimeout(() => {
39
+ resolve(true);
40
+ }, 1000);
41
+ });
42
+ }
43
+ beforeChangeFalse(value: any) {
44
+ Message.warning(`current value is ${value}`);
45
+ return new Promise<boolean>(resolve => {
46
+ setTimeout(() => {
47
+ resolve(false);
48
+ }, 1000);
49
+ });
50
+ }
51
+ }
52
+ ```
@@ -22,6 +22,8 @@ sidebar: doc
22
22
  | height | 开关的高度 | `number` &#124; `string` | `undefined` |
23
23
  | size | 尺寸 | `"large"` &#124; `"default"` &#124; `"small"` &#124; `"mini"` | `"default"` |
24
24
  | disabled | 控制禁用 | `boolean` | `false` |
25
+ | loading | 开关loading属性 | `boolean` | `false` |
26
+ | beforeChange | 切换`Switch`之前的拦截函数,如果该函数返回`false`则阻止本次切换,支持异步函数, 参数为当前value | <code>(value: any) => boolean &#124; Promise&lt;boolean&gt;</code> | `undefined` |
25
27
 
26
28
  # 扩展点
27
29
 
@@ -2,6 +2,7 @@ import BasicDemo from '~/components/switch/demos/basic';
2
2
  import DisabledDemo from '~/components/switch/demos/disabled';
3
3
  import ValueDemo from '~/components/switch/demos/value';
4
4
  import WidthHeightDemo from '~/components/switch/demos/widthHeight';
5
+ import BeforeChangeDemo from '~/components/switch/demos/beforeChange';
5
6
  import {mount, unmount, dispatchEvent, wait} from '../../test/utils';
6
7
 
7
8
  describe('Switch', () => {
@@ -118,4 +119,14 @@ describe('Switch', () => {
118
119
  await wait();
119
120
  expect(element.outerHTML).to.matchSnapshot();
120
121
  });
122
+
123
+ it('beforeChange', async function() {
124
+ const [instance, element] = mount(BeforeChangeDemo);
125
+ const [el1, el2] = element.querySelectorAll<HTMLElement>('.k-switch');
126
+ el1.click();
127
+ el2.click();
128
+ await wait(1000);
129
+ expect(instance.get('value1')).to.be.true;
130
+ expect(instance.get('value2')).to.be.false;
131
+ });
121
132
  });
@@ -17,6 +17,8 @@ export interface SwitchProps<True = any, False = any> {
17
17
  height?: number | string
18
18
  size?: Sizes
19
19
  disabled?: boolean
20
+ loading?: boolean
21
+ beforeChange?: (value: True | False | undefined) => boolean | Promise<boolean>;
20
22
  }
21
23
 
22
24
  export interface SwitchEvents {
@@ -40,6 +42,8 @@ const typeDefs: Required<TypeDefs<SwitchProps>> = {
40
42
  height: [Number, String],
41
43
  size: sizes,
42
44
  disabled: Boolean,
45
+ loading: Boolean,
46
+ beforeChange: Function,
43
47
  };
44
48
 
45
49
  const defaults = (): Partial<SwitchProps> => ({
@@ -47,6 +51,7 @@ const defaults = (): Partial<SwitchProps> => ({
47
51
  trueValue: true,
48
52
  falseValue: false,
49
53
  size: 'default',
54
+ loading: false,
50
55
  });
51
56
 
52
57
  const events: Events<SwitchEvents> = {
@@ -90,13 +95,30 @@ export class Switch<True = true, False = false> extends Component<SwitchProps<Tr
90
95
  }
91
96
  }
92
97
 
93
- public toggle(isKeypress: boolean) {
94
- if (this.get('disabled')) return;
98
+ public async toggle(isKeypress: boolean) {
99
+ const {disabled, beforeChange, value} = this.get();
100
+ if (disabled) return;
95
101
 
96
- // if is not keypress, we blur it to remove focus style
97
- if (!isKeypress) {
98
- this.elementRef.value!.blur();
99
- }
102
+ // if is not keypress, we blur it to remove focus style
103
+ if (!isKeypress) {
104
+ this.elementRef.value!.blur();
105
+ }
106
+
107
+ if (beforeChange) {
108
+ this.set({
109
+ disabled: true,
110
+ loading: true
111
+ });
112
+ try {
113
+ const ret = await beforeChange(value);
114
+ if (!ret) return;
115
+ } finally {
116
+ this.set({
117
+ disabled: false,
118
+ loading: false
119
+ });
120
+ }
121
+ }
100
122
 
101
123
  if (this.isChecked()) {
102
124
  this.uncheck();
@@ -1,10 +1,11 @@
1
1
  import {makeStyles} from './styles';
2
2
  import {addStyle, getRestProps} from '../utils';
3
+ import {Icon} from '../icon';
3
4
 
4
5
  let {
5
6
  className, style, name, on,
6
7
  off, value, trueValue, falseValue,
7
- width, height, size, disabled,
8
+ width, height, size, disabled, loading
8
9
  } = this.get();
9
10
 
10
11
  const {start, dragging, barRef, barWidth} = this.draggable;
@@ -24,6 +25,7 @@ const classNameObj = {
24
25
  let onStyle;
25
26
  let offStyle;
26
27
  let barStyle;
28
+ let iconStyle;
27
29
  if (width || height) {
28
30
  const _style = {};
29
31
  onStyle = {};
@@ -51,6 +53,9 @@ if (width || height) {
51
53
  barStyle = {
52
54
  width: value === trueValue ? '100%' : `${height}px`,
53
55
  }
56
+ iconStyle = {
57
+ fontSize: `${height * 0.7}px`,
58
+ }
54
59
  }
55
60
  style = addStyle(style, _style);
56
61
  }
@@ -74,7 +79,7 @@ if (barWidth.value) {
74
79
  v-model-true={trueValue}
75
80
  v-model-false={falseValue}
76
81
  tabindex="-1"
77
- />
82
+ />
78
83
  <div class={`${k}-switch-off`} v-if={off || $blocks.off} style={offStyle}>
79
84
  <b:off>{off}</b:off>
80
85
  </div>
@@ -83,6 +88,7 @@ if (barWidth.value) {
83
88
  <b:on>{on}</b:on>
84
89
  </div>
85
90
  <div class={`${k}-switch-wrapper`}>
91
+ <Icon v-if={loading} class={`${k}-switch-icon ion-load-c`} rotate style={iconStyle}/>
86
92
  <div class={`${k}-switch-handle`}
87
93
  ev-click={this.onClickOnHandle}
88
94
  ev-mousedown={start}
@@ -27,6 +27,7 @@ const defaults = {
27
27
  width: `45px`,
28
28
  height: `24px`,
29
29
  padding: `3px`,
30
+ iconSize: `16px`,
30
31
  },
31
32
 
32
33
  // large
@@ -34,6 +35,7 @@ const defaults = {
34
35
  width: `58px`,
35
36
  height: `30px`,
36
37
  padding: `3px`,
38
+ iconSize: `20px`,
37
39
  },
38
40
 
39
41
  // small
@@ -41,6 +43,7 @@ const defaults = {
41
43
  width: `30px`,
42
44
  height: `16px`,
43
45
  padding: `2px`,
46
+ iconSize: `10px`,
44
47
  },
45
48
 
46
49
  // mini
@@ -48,6 +51,7 @@ const defaults = {
48
51
  width: `18px`,
49
52
  height: `10px`,
50
53
  padding: `1px`,
54
+ iconSize: `6px`,
51
55
  },
52
56
 
53
57
  // disabled
@@ -116,6 +120,13 @@ export const makeStyles = cache(function makeStyles(k: string) {
116
120
  }
117
121
  }
118
122
 
123
+ .${k}-switch-icon {
124
+ position: absolute;
125
+ left: 50%;
126
+ top: 50%;
127
+ transform: translate(-50%, -50%);
128
+ }
129
+
119
130
  // text
120
131
  .${k}-switch-on,
121
132
  .${k}-switch-off {
@@ -139,7 +150,7 @@ export const makeStyles = cache(function makeStyles(k: string) {
139
150
 
140
151
  // size
141
152
  ${sizes.map(size => {
142
- const {width, height, padding} = kswitch[size];
153
+ const {width, height, padding, iconSize} = kswitch[size];
143
154
  return css`
144
155
  &.${k}-${size},
145
156
  &.${k}-${size} .${k}-switch-on,
@@ -167,6 +178,9 @@ export const makeStyles = cache(function makeStyles(k: string) {
167
178
  .${k}-switch-off {
168
179
  padding: 0 calc(${height} / 3) 0 ${height};
169
180
  }
181
+ .${k}-switch-icon {
182
+ font-size: ${iconSize};
183
+ }
170
184
  }
171
185
  `
172
186
  })}
@@ -26,7 +26,12 @@ if (columnIndex === 0 && indent) {
26
26
  style.paddingLeft = `${indent}px`;
27
27
  }
28
28
 
29
- <td className={className}
29
+ const classNameObj = {
30
+ [`${k}-hidden`]: props.hidden,
31
+ [className]: className
32
+ }
33
+
34
+ <td class={classNameObj}
30
35
  style={style}
31
36
  title={getTextByChildren(children)}
32
37
  rowspan={rowspan}
@@ -16,6 +16,7 @@ export interface TableColumnProps {
16
16
  exportTitle?: string
17
17
  exportCell?: (data: any, index: number) => string
18
18
  minWidth?: number
19
+ hidden?: boolean
19
20
 
20
21
  // passed by Table
21
22
  // offset: number
@@ -54,6 +55,7 @@ const typeDefs: Required<TypeDefs<TableColumnProps>> = {
54
55
  exportTitle: String,
55
56
  exportCell: Function,
56
57
  minWidth: Number,
58
+ hidden: Boolean,
57
59
 
58
60
  // offset: null,
59
61
  cols: null,
@@ -16,7 +16,7 @@ import {Input} from '../input';
16
16
  import {_$} from '../../i18n';
17
17
  import {ignoreSortable} from './useSortable';
18
18
 
19
- const {title, fixed, group, multiple, key, sortable, cols, rows} = this.get();
19
+ const {title, fixed, group, multiple, key, sortable, cols, rows, hidden} = this.get();
20
20
  const {
21
21
  onSelect, isChecked, keywords, filteredGroup,
22
22
  onShow, reset, confirm, dropdownRef,
@@ -37,6 +37,7 @@ const { k } = this.config;
37
37
  const {className, style} = getClassAndStyleForFixed(this.get(), offsetMap[key], k, checkType);
38
38
  const classNameObj = {
39
39
  [`${k}-column-sortable`]: sortable,
40
+ [`${k}-hidden`]: hidden,
40
41
  [className]: className,
41
42
  }
42
43
 
@@ -0,0 +1,44 @@
1
+ ---
2
+ title: 隐藏列
3
+ order: 31
4
+ ---
5
+
6
+ 通过`TableColumn`的`hidden`属性配置隐藏列
7
+
8
+ ```vdt
9
+ import {Table, TableColumn} from 'kpc';
10
+
11
+ <div>
12
+ <Table data={this.get('data')} resizable>
13
+ <TableColumn key="a" title="Title 1" minWidth={200}/>
14
+ <TableColumn key="b" title="Title 2" minWidth={300} hidden/>
15
+ <TableColumn key="c" title="Title 3"/>
16
+ </Table>
17
+ <p>无数据展示</p>
18
+ <Table data={this.get('data2')} resizable>
19
+ <TableColumn key="a" title="Title 1" />
20
+ <TableColumn key="b" title="Title 2" hidden/>
21
+ <TableColumn key="c" title="Title 3"/>
22
+ </Table>
23
+ </div>
24
+ ```
25
+
26
+ ```styl
27
+ .k-table
28
+ margin-bottom 20px
29
+ ```
30
+
31
+ ```ts
32
+ export default class extends Component {
33
+ static template = template;
34
+ static defaults() {
35
+ return {
36
+ data: [
37
+ {a: 'Cell 1-1', b: 'Cell 1-2', c: 'cell 1-3'},
38
+ {a: 'Cell 2-1', b: 'Cell 2-2', c: 'cell 2-3'}
39
+ ],
40
+ data2: []
41
+ };
42
+ }
43
+ }
44
+ ```
@@ -111,6 +111,7 @@ export interface PaginationProps {
111
111
  | exportCell | 自定义导出的单元格内容 | `(data: any, index: number) => string` | `undefined` |
112
112
  | minWidth | 指定当前列拖动时的最小宽度,优先级高于`Table`的`minColWidth` | `number` | `undefined` |
113
113
  | className | 给当前列添加className | `string` &#124; `Record<string, any>` | `undefined` |
114
+ | hidden | 是否隐藏当前列,仅为不可见,不影响`exportTable`导出表格 | `boolean` | `false` |
114
115
 
115
116
  ```ts
116
117
  import {VNode} from 'intact';